instruction
stringclasses 1
value | input
stringlengths 31
235k
| output
class label 2
classes |
---|---|---|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_SEQUENCE_OF_NonStandardParameter ( 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_NonStandardParameter , SEQUENCE_OF_NonStandardParameter_sequence_of ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void DOT ( void ) {
XPR ( NTR "." ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_initialize_rd_consts ( VP9_COMP * cpi ) {
VP9_COMMON * const cm = & cpi -> common ;
MACROBLOCK * const x = & cpi -> mb ;
RD_OPT * const rd = & cpi -> rd ;
int i ;
vp9_clear_system_state ( ) ;
rd -> RDDIV = RDDIV_BITS ;
rd -> RDMULT = vp9_compute_rd_mult ( cpi , cm -> base_qindex + cm -> y_dc_delta_q ) ;
x -> errorperbit = rd -> RDMULT / RD_MULT_EPB_RATIO ;
x -> errorperbit += ( x -> errorperbit == 0 ) ;
x -> select_tx_size = ( cpi -> sf . tx_size_search_method == USE_LARGESTALL && cm -> frame_type != KEY_FRAME ) ? 0 : 1 ;
set_block_thresholds ( cm , rd ) ;
if ( ! cpi -> sf . use_nonrd_pick_mode || cm -> frame_type == KEY_FRAME ) {
fill_token_costs ( x -> token_costs , cm -> fc . coef_probs ) ;
for ( i = 0 ;
i < PARTITION_CONTEXTS ;
++ i ) vp9_cost_tokens ( cpi -> partition_cost [ i ] , get_partition_probs ( cm , i ) , vp9_partition_tree ) ;
}
if ( ! cpi -> sf . use_nonrd_pick_mode || ( cm -> current_video_frame & 0x07 ) == 1 || cm -> frame_type == KEY_FRAME ) {
fill_mode_costs ( cpi ) ;
if ( ! frame_is_intra_only ( cm ) ) {
vp9_build_nmv_cost_table ( x -> nmvjointcost , cm -> allow_high_precision_mv ? x -> nmvcost_hp : x -> nmvcost , & cm -> fc . nmvc , cm -> allow_high_precision_mv ) ;
for ( i = 0 ;
i < INTER_MODE_CONTEXTS ;
++ i ) vp9_cost_tokens ( ( int * ) cpi -> inter_mode_cost [ i ] , cm -> fc . inter_mode_probs [ i ] , vp9_inter_mode_tree ) ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int svq3_decode_mb ( SVQ3Context * s , unsigned int mb_type ) {
H264Context * h = & s -> h ;
int i , j , k , m , dir , mode ;
int cbp = 0 ;
uint32_t vlc ;
int8_t * top , * left ;
const int mb_xy = h -> mb_xy ;
const int b_xy = 4 * h -> mb_x + 4 * h -> mb_y * h -> b_stride ;
h -> top_samples_available = ( h -> mb_y == 0 ) ? 0x33FF : 0xFFFF ;
h -> left_samples_available = ( h -> mb_x == 0 ) ? 0x5F5F : 0xFFFF ;
h -> topright_samples_available = 0xFFFF ;
if ( mb_type == 0 ) {
if ( h -> pict_type == AV_PICTURE_TYPE_P || s -> next_pic -> f . mb_type [ mb_xy ] == - 1 ) {
svq3_mc_dir_part ( s , 16 * h -> mb_x , 16 * h -> mb_y , 16 , 16 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
if ( h -> pict_type == AV_PICTURE_TYPE_B ) svq3_mc_dir_part ( s , 16 * h -> mb_x , 16 * h -> mb_y , 16 , 16 , 0 , 0 , 0 , 0 , 1 , 1 ) ;
mb_type = MB_TYPE_SKIP ;
}
else {
mb_type = FFMIN ( s -> next_pic -> f . mb_type [ mb_xy ] , 6 ) ;
if ( svq3_mc_dir ( s , mb_type , PREDICT_MODE , 0 , 0 ) < 0 ) return - 1 ;
if ( svq3_mc_dir ( s , mb_type , PREDICT_MODE , 1 , 1 ) < 0 ) return - 1 ;
mb_type = MB_TYPE_16x16 ;
}
}
else if ( mb_type < 8 ) {
if ( s -> thirdpel_flag && s -> halfpel_flag == ! get_bits1 ( & h -> gb ) ) mode = THIRDPEL_MODE ;
else if ( s -> halfpel_flag && s -> thirdpel_flag == ! get_bits1 ( & h -> gb ) ) mode = HALFPEL_MODE ;
else mode = FULLPEL_MODE ;
for ( m = 0 ;
m < 2 ;
m ++ ) {
if ( h -> mb_x > 0 && h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - 1 ] + 6 ] != - 1 ) {
for ( i = 0 ;
i < 4 ;
i ++ ) AV_COPY32 ( h -> mv_cache [ m ] [ scan8 [ 0 ] - 1 + i * 8 ] , h -> cur_pic . f . motion_val [ m ] [ b_xy - 1 + i * h -> b_stride ] ) ;
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) AV_ZERO32 ( h -> mv_cache [ m ] [ scan8 [ 0 ] - 1 + i * 8 ] ) ;
}
if ( h -> mb_y > 0 ) {
memcpy ( h -> mv_cache [ m ] [ scan8 [ 0 ] - 1 * 8 ] , h -> cur_pic . f . motion_val [ m ] [ b_xy - h -> b_stride ] , 4 * 2 * sizeof ( int16_t ) ) ;
memset ( & h -> ref_cache [ m ] [ scan8 [ 0 ] - 1 * 8 ] , ( h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] ] == - 1 ) ? PART_NOT_AVAILABLE : 1 , 4 ) ;
if ( h -> mb_x < h -> mb_width - 1 ) {
AV_COPY32 ( h -> mv_cache [ m ] [ scan8 [ 0 ] + 4 - 1 * 8 ] , h -> cur_pic . f . motion_val [ m ] [ b_xy - h -> b_stride + 4 ] ) ;
h -> ref_cache [ m ] [ scan8 [ 0 ] + 4 - 1 * 8 ] = ( h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride + 1 ] + 6 ] == - 1 || h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] ] == - 1 ) ? PART_NOT_AVAILABLE : 1 ;
}
else h -> ref_cache [ m ] [ scan8 [ 0 ] + 4 - 1 * 8 ] = PART_NOT_AVAILABLE ;
if ( h -> mb_x > 0 ) {
AV_COPY32 ( h -> mv_cache [ m ] [ scan8 [ 0 ] - 1 - 1 * 8 ] , h -> cur_pic . f . motion_val [ m ] [ b_xy - h -> b_stride - 1 ] ) ;
h -> ref_cache [ m ] [ scan8 [ 0 ] - 1 - 1 * 8 ] = ( h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride - 1 ] + 3 ] == - 1 ) ? PART_NOT_AVAILABLE : 1 ;
}
else h -> ref_cache [ m ] [ scan8 [ 0 ] - 1 - 1 * 8 ] = PART_NOT_AVAILABLE ;
}
else memset ( & h -> ref_cache [ m ] [ scan8 [ 0 ] - 1 * 8 - 1 ] , PART_NOT_AVAILABLE , 8 ) ;
if ( h -> pict_type != AV_PICTURE_TYPE_B ) break ;
}
if ( h -> pict_type == AV_PICTURE_TYPE_P ) {
if ( svq3_mc_dir ( s , mb_type - 1 , mode , 0 , 0 ) < 0 ) return - 1 ;
}
else {
if ( mb_type != 2 ) {
if ( svq3_mc_dir ( s , 0 , mode , 0 , 0 ) < 0 ) return - 1 ;
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( h -> cur_pic . f . motion_val [ 0 ] [ b_xy + i * h -> b_stride ] , 0 , 4 * 2 * sizeof ( int16_t ) ) ;
}
if ( mb_type != 1 ) {
if ( svq3_mc_dir ( s , 0 , mode , 1 , mb_type == 3 ) < 0 ) return - 1 ;
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( h -> cur_pic . f . motion_val [ 1 ] [ b_xy + i * h -> b_stride ] , 0 , 4 * 2 * sizeof ( int16_t ) ) ;
}
}
mb_type = MB_TYPE_16x16 ;
}
else if ( mb_type == 8 || mb_type == 33 ) {
memset ( h -> intra4x4_pred_mode_cache , - 1 , 8 * 5 * sizeof ( int8_t ) ) ;
if ( mb_type == 8 ) {
if ( h -> mb_x > 0 ) {
for ( i = 0 ;
i < 4 ;
i ++ ) h -> intra4x4_pred_mode_cache [ scan8 [ 0 ] - 1 + i * 8 ] = h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - 1 ] + 6 - i ] ;
if ( h -> intra4x4_pred_mode_cache [ scan8 [ 0 ] - 1 ] == - 1 ) h -> left_samples_available = 0x5F5F ;
}
if ( h -> mb_y > 0 ) {
h -> intra4x4_pred_mode_cache [ 4 + 8 * 0 ] = h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] + 0 ] ;
h -> intra4x4_pred_mode_cache [ 5 + 8 * 0 ] = h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] + 1 ] ;
h -> intra4x4_pred_mode_cache [ 6 + 8 * 0 ] = h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] + 2 ] ;
h -> intra4x4_pred_mode_cache [ 7 + 8 * 0 ] = h -> intra4x4_pred_mode [ h -> mb2br_xy [ mb_xy - h -> mb_stride ] + 3 ] ;
if ( h -> intra4x4_pred_mode_cache [ 4 + 8 * 0 ] == - 1 ) h -> top_samples_available = 0x33FF ;
}
for ( i = 0 ;
i < 16 ;
i += 2 ) {
vlc = svq3_get_ue_golomb ( & h -> gb ) ;
if ( vlc >= 25 ) {
av_log ( h -> avctx , AV_LOG_ERROR , "luma prediction:%d\n" , vlc ) ;
return - 1 ;
}
left = & h -> intra4x4_pred_mode_cache [ scan8 [ i ] - 1 ] ;
top = & h -> intra4x4_pred_mode_cache [ scan8 [ i ] - 8 ] ;
left [ 1 ] = svq3_pred_1 [ top [ 0 ] + 1 ] [ left [ 0 ] + 1 ] [ svq3_pred_0 [ vlc ] [ 0 ] ] ;
left [ 2 ] = svq3_pred_1 [ top [ 1 ] + 1 ] [ left [ 1 ] + 1 ] [ svq3_pred_0 [ vlc ] [ 1 ] ] ;
if ( left [ 1 ] == - 1 || left [ 2 ] == - 1 ) {
av_log ( h -> avctx , AV_LOG_ERROR , "weird prediction\n" ) ;
return - 1 ;
}
}
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( & h -> intra4x4_pred_mode_cache [ scan8 [ 0 ] + 8 * i ] , DC_PRED , 4 ) ;
}
write_back_intra_pred_mode ( h ) ;
if ( mb_type == 8 ) {
ff_h264_check_intra4x4_pred_mode ( h ) ;
h -> top_samples_available = ( h -> mb_y == 0 ) ? 0x33FF : 0xFFFF ;
h -> left_samples_available = ( h -> mb_x == 0 ) ? 0x5F5F : 0xFFFF ;
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( & h -> intra4x4_pred_mode_cache [ scan8 [ 0 ] + 8 * i ] , DC_128_PRED , 4 ) ;
h -> top_samples_available = 0x33FF ;
h -> left_samples_available = 0x5F5F ;
}
mb_type = MB_TYPE_INTRA4x4 ;
}
else {
dir = i_mb_type_info [ mb_type - 8 ] . pred_mode ;
dir = ( dir >> 1 ) ^ 3 * ( dir & 1 ) ^ 1 ;
if ( ( h -> intra16x16_pred_mode = ff_h264_check_intra_pred_mode ( h , dir , 0 ) ) == - 1 ) {
av_log ( h -> avctx , AV_LOG_ERROR , "check_intra_pred_mode = -1\n" ) ;
return - 1 ;
}
cbp = i_mb_type_info [ mb_type - 8 ] . cbp ;
mb_type = MB_TYPE_INTRA16x16 ;
}
if ( ! IS_INTER ( mb_type ) && h -> pict_type != AV_PICTURE_TYPE_I ) {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( h -> cur_pic . f . motion_val [ 0 ] [ b_xy + i * h -> b_stride ] , 0 , 4 * 2 * sizeof ( int16_t ) ) ;
if ( h -> pict_type == AV_PICTURE_TYPE_B ) {
for ( i = 0 ;
i < 4 ;
i ++ ) memset ( h -> cur_pic . f . motion_val [ 1 ] [ b_xy + i * h -> b_stride ] , 0 , 4 * 2 * sizeof ( int16_t ) ) ;
}
}
if ( ! IS_INTRA4x4 ( mb_type ) ) {
memset ( h -> intra4x4_pred_mode + h -> mb2br_xy [ mb_xy ] , DC_PRED , 8 ) ;
}
if ( ! IS_SKIP ( mb_type ) || h -> pict_type == AV_PICTURE_TYPE_B ) {
memset ( h -> non_zero_count_cache + 8 , 0 , 14 * 8 * sizeof ( uint8_t ) ) ;
h -> dsp . clear_blocks ( h -> mb + 0 ) ;
h -> dsp . clear_blocks ( h -> mb + 384 ) ;
}
if ( ! IS_INTRA16x16 ( mb_type ) && ( ! IS_SKIP ( mb_type ) || h -> pict_type == AV_PICTURE_TYPE_B ) ) {
if ( ( vlc = svq3_get_ue_golomb ( & h -> gb ) ) >= 48 ) {
av_log ( h -> avctx , AV_LOG_ERROR , "cbp_vlc=%d\n" , vlc ) ;
return - 1 ;
}
cbp = IS_INTRA ( mb_type ) ? golomb_to_intra4x4_cbp [ vlc ] : golomb_to_inter_cbp [ vlc ] ;
}
if ( IS_INTRA16x16 ( mb_type ) || ( h -> pict_type != AV_PICTURE_TYPE_I && s -> adaptive_quant && cbp ) ) {
h -> qscale += svq3_get_se_golomb ( & h -> gb ) ;
if ( h -> qscale > 31u ) {
av_log ( h -> avctx , AV_LOG_ERROR , "qscale:%d\n" , h -> qscale ) ;
return - 1 ;
}
}
if ( IS_INTRA16x16 ( mb_type ) ) {
AV_ZERO128 ( h -> mb_luma_dc [ 0 ] + 0 ) ;
AV_ZERO128 ( h -> mb_luma_dc [ 0 ] + 8 ) ;
if ( svq3_decode_block ( & h -> gb , h -> mb_luma_dc [ 0 ] , 0 , 1 ) ) {
av_log ( h -> avctx , AV_LOG_ERROR , "error while decoding intra luma dc\n" ) ;
return - 1 ;
}
}
if ( cbp ) {
const int index = IS_INTRA16x16 ( mb_type ) ? 1 : 0 ;
const int type = ( ( h -> qscale < 24 && IS_INTRA4x4 ( mb_type ) ) ? 2 : 1 ) ;
for ( i = 0 ;
i < 4 ;
i ++ ) if ( ( cbp & ( 1 << i ) ) ) {
for ( j = 0 ;
j < 4 ;
j ++ ) {
k = index ? ( 1 * ( j & 1 ) + 2 * ( i & 1 ) + 2 * ( j & 2 ) + 4 * ( i & 2 ) ) : ( 4 * i + j ) ;
h -> non_zero_count_cache [ scan8 [ k ] ] = 1 ;
if ( svq3_decode_block ( & h -> gb , & h -> mb [ 16 * k ] , index , type ) ) {
av_log ( h -> avctx , AV_LOG_ERROR , "error while decoding block\n" ) ;
return - 1 ;
}
}
}
if ( ( cbp & 0x30 ) ) {
for ( i = 1 ;
i < 3 ;
++ i ) if ( svq3_decode_block ( & h -> gb , & h -> mb [ 16 * 16 * i ] , 0 , 3 ) ) {
av_log ( h -> avctx , AV_LOG_ERROR , "error while decoding chroma dc block\n" ) ;
return - 1 ;
}
if ( ( cbp & 0x20 ) ) {
for ( i = 1 ;
i < 3 ;
i ++ ) {
for ( j = 0 ;
j < 4 ;
j ++ ) {
k = 16 * i + j ;
h -> non_zero_count_cache [ scan8 [ k ] ] = 1 ;
if ( svq3_decode_block ( & h -> gb , & h -> mb [ 16 * k ] , 1 , 1 ) ) {
av_log ( h -> avctx , AV_LOG_ERROR , "error while decoding chroma ac block\n" ) ;
return - 1 ;
}
}
}
}
}
}
h -> cbp = cbp ;
h -> cur_pic . f . mb_type [ mb_xy ] = mb_type ;
if ( IS_INTRA ( mb_type ) ) h -> chroma_pred_mode = ff_h264_check_intra_pred_mode ( h , DC_PRED8x8 , 1 ) ;
return 0 ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int get_metadata_size ( const uint8_t * buf , int buf_size ) {
int metadata_last , metadata_size ;
const uint8_t * buf_end = buf + buf_size ;
buf += 4 ;
do {
if ( buf_end - buf < 4 ) return 0 ;
avpriv_flac_parse_block_header ( buf , & metadata_last , NULL , & metadata_size ) ;
buf += 4 ;
if ( buf_end - buf < metadata_size ) {
return 0 ;
}
buf += metadata_size ;
}
while ( ! metadata_last ) ;
return buf_size - ( buf_end - buf ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline void IRQ_resetbit ( IRQQueue * q , int n_IRQ ) {
clear_bit ( n_IRQ , q -> queue ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void output ( code_int code , GifCtx * ctx ) {
if ( ctx -> cur_bits == CUR_BITS_FINISHED ) return ;
ctx -> cur_accum &= masks [ ctx -> cur_bits ] ;
if ( ctx -> cur_bits > 0 ) {
ctx -> cur_accum |= ( ( long ) code << ctx -> cur_bits ) ;
}
else {
ctx -> cur_accum = code ;
}
ctx -> cur_bits += ctx -> n_bits ;
while ( ctx -> cur_bits >= 8 ) {
char_out ( ( unsigned int ) ( ctx -> cur_accum & 0xff ) , ctx ) ;
ctx -> cur_accum >>= 8 ;
ctx -> cur_bits -= 8 ;
}
if ( ctx -> free_ent > ctx -> maxcode || ctx -> clear_flg ) {
if ( ctx -> clear_flg ) {
ctx -> maxcode = MAXCODE ( ctx -> n_bits = ctx -> g_init_bits ) ;
ctx -> clear_flg = 0 ;
}
else {
++ ( ctx -> n_bits ) ;
if ( ctx -> n_bits == maxbits ) {
ctx -> maxcode = maxmaxcode ;
}
else {
ctx -> maxcode = MAXCODE ( ctx -> n_bits ) ;
}
}
}
if ( code == ctx -> EOFCode ) {
while ( ctx -> cur_bits > 0 ) {
char_out ( ( unsigned int ) ( ctx -> cur_accum & 0xff ) , ctx ) ;
ctx -> cur_accum >>= 8 ;
ctx -> cur_bits -= 8 ;
}
ctx -> cur_bits = CUR_BITS_FINISHED ;
flush_char ( ctx ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void pdf_run_TL ( fz_context * ctx , pdf_processor * proc , float leading ) {
pdf_run_processor * pr = ( pdf_run_processor * ) proc ;
pdf_gstate * gstate = pr -> gstate + pr -> gtop ;
gstate -> text . leading = leading ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void init_dir_data ( iax_call_dirdata * dirdata ) {
dirdata -> current_frag_bytes = 0 ;
dirdata -> current_frag_minlen = 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_CloseLogicalChannelAck ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_CloseLogicalChannelAck , CloseLogicalChannelAck_sequence ) ;
# line 554 "../../asn1/h245/h245.cnf" if ( h245_pi != NULL ) h245_pi -> msg_type = H245_CloseLogChnAck ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int output_data ( MLPDecodeContext * m , unsigned int substr , AVFrame * frame , int * got_frame_ptr ) {
AVCodecContext * avctx = m -> avctx ;
SubStream * s = & m -> substream [ substr ] ;
unsigned int i , out_ch = 0 ;
int32_t * data_32 ;
int16_t * data_16 ;
int ret ;
int is32 = ( m -> avctx -> sample_fmt == AV_SAMPLE_FMT_S32 ) ;
if ( m -> avctx -> channels != s -> max_matrix_channel + 1 ) {
av_log ( m -> avctx , AV_LOG_ERROR , "channel count mismatch\n" ) ;
return AVERROR_INVALIDDATA ;
}
if ( ! s -> blockpos ) {
av_log ( avctx , AV_LOG_ERROR , "No samples to output.\n" ) ;
return AVERROR_INVALIDDATA ;
}
frame -> nb_samples = s -> blockpos ;
if ( ( ret = ff_get_buffer ( avctx , frame ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
data_32 = ( int32_t * ) frame -> data [ 0 ] ;
data_16 = ( int16_t * ) frame -> data [ 0 ] ;
for ( i = 0 ;
i < s -> blockpos ;
i ++ ) {
for ( out_ch = 0 ;
out_ch <= s -> max_matrix_channel ;
out_ch ++ ) {
int mat_ch = s -> ch_assign [ out_ch ] ;
int32_t sample = m -> sample_buffer [ i ] [ mat_ch ] << s -> output_shift [ mat_ch ] ;
s -> lossless_check_data ^= ( sample & 0xffffff ) << mat_ch ;
if ( is32 ) * data_32 ++ = sample << 8 ;
else * data_16 ++ = sample >> 8 ;
}
}
* got_frame_ptr = 1 ;
return 0 ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_Rfc2733Format ( 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_Rfc2733Format , Rfc2733Format_choice , NULL ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void proto_tree_set_uint ( field_info * fi , guint32 value ) {
header_field_info * hfinfo ;
guint32 integer ;
hfinfo = fi -> hfinfo ;
integer = value ;
if ( hfinfo -> bitmask ) {
integer &= ( guint32 ) ( hfinfo -> bitmask ) ;
integer >>= hfinfo_bitshift ( hfinfo ) ;
}
fvalue_set_uinteger ( & fi -> value , integer ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void set_block_thresholds ( const VP9_COMMON * cm , RD_OPT * rd ) {
int i , bsize , segment_id ;
for ( segment_id = 0 ;
segment_id < MAX_SEGMENTS ;
++ segment_id ) {
const int qindex = clamp ( vp9_get_qindex ( & cm -> seg , segment_id , cm -> base_qindex ) + cm -> y_dc_delta_q , 0 , MAXQ ) ;
const int q = compute_rd_thresh_factor ( qindex ) ;
for ( bsize = 0 ;
bsize < BLOCK_SIZES ;
++ bsize ) {
const int t = q * rd_thresh_block_size_factor [ bsize ] ;
const int thresh_max = INT_MAX / t ;
if ( bsize >= BLOCK_8X8 ) {
for ( i = 0 ;
i < MAX_MODES ;
++ i ) rd -> threshes [ segment_id ] [ bsize ] [ i ] = rd -> thresh_mult [ i ] < thresh_max ? rd -> thresh_mult [ i ] * t / 4 : INT_MAX ;
}
else {
for ( i = 0 ;
i < MAX_REFS ;
++ i ) rd -> threshes [ segment_id ] [ bsize ] [ i ] = rd -> thresh_mult_sub8x8 [ i ] < thresh_max ? rd -> thresh_mult_sub8x8 [ i ] * t / 4 : INT_MAX ;
}
}
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
TSReturnCode compare_field_values ( RegressionTest * test , TSMBuffer bufp1 , TSMLoc hdr_loc1 , TSMLoc field_loc1 , TSMBuffer bufp2 , TSMLoc hdr_loc2 , TSMLoc field_loc2 ) {
int no_of_values1 ;
int no_of_values2 ;
int i ;
const char * str1 = nullptr ;
const char * str2 = nullptr ;
int length1 = 0 ;
int length2 = 0 ;
no_of_values1 = TSMimeHdrFieldValuesCount ( bufp1 , hdr_loc1 , field_loc1 ) ;
no_of_values2 = TSMimeHdrFieldValuesCount ( bufp2 , hdr_loc2 , field_loc2 ) ;
if ( no_of_values1 != no_of_values2 ) {
SDK_RPRINT ( test , "compare_field_values" , "TestCase" , TC_FAIL , "Field Values not equal" ) ;
return TS_ERROR ;
}
for ( i = 0 ;
i < no_of_values1 ;
i ++ ) {
str1 = TSMimeHdrFieldValueStringGet ( bufp1 , hdr_loc1 , field_loc1 , i , & length1 ) ;
str2 = TSMimeHdrFieldValueStringGet ( bufp2 , hdr_loc2 , field_loc2 , i , & length2 ) ;
if ( ! ( ( length1 == length2 ) && ( strncmp ( str1 , str2 , length1 ) == 0 ) ) ) {
SDK_RPRINT ( test , "compare_field_values" , "TestCase" , TC_FAIL , "Field Value %d differ from each other" , i ) ;
return TS_ERROR ;
}
}
return TS_SUCCESS ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void test_subselect ( ) {
MYSQL_STMT * stmt ;
int rc , id ;
MYSQL_BIND my_bind [ 1 ] ;
DBUG_ENTER ( "test_subselect" ) ;
myheader ( "test_subselect" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_sub1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_sub2" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_sub1(id int)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_sub2(id int, id1 int)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_sub1 values(2)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_sub2 VALUES(1, 7), (2, 7)" ) ;
myquery ( rc ) ;
rc = mysql_commit ( mysql ) ;
myquery ( rc ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_LONG ;
my_bind [ 0 ] . buffer = ( void * ) & id ;
my_bind [ 0 ] . length = 0 ;
my_bind [ 0 ] . is_null = 0 ;
stmt = mysql_simple_prepare ( mysql , "INSERT INTO test_sub2(id) SELECT * FROM test_sub1 WHERE id= ?" ) ;
check_stmt ( stmt ) ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
id = 2 ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
verify_st_affected_rows ( stmt , 1 ) ;
id = 9 ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
verify_st_affected_rows ( stmt , 0 ) ;
mysql_stmt_close ( stmt ) ;
rc = my_stmt_result ( "SELECT * FROM test_sub2" ) ;
DIE_UNLESS ( rc == 3 ) ;
rc = my_stmt_result ( "SELECT ROW(1, 7) IN (select id, id1 " "from test_sub2 WHERE id1= 8)" ) ;
DIE_UNLESS ( rc == 1 ) ;
rc = my_stmt_result ( "SELECT ROW(1, 7) IN (select id, id1 " "from test_sub2 WHERE id1= 7)" ) ;
DIE_UNLESS ( rc == 1 ) ;
stmt = mysql_simple_prepare ( mysql , ( "SELECT ROW(1, 7) IN (select id, id1 " "from test_sub2 WHERE id1= ?)" ) ) ;
check_stmt ( stmt ) ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_bind_result ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
id = 7 ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n row 1: %d" , id ) ;
DIE_UNLESS ( id == 1 ) ;
rc = mysql_stmt_fetch ( stmt ) ;
DIE_UNLESS ( rc == MYSQL_NO_DATA ) ;
id = 8 ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n row 1: %d" , id ) ;
DIE_UNLESS ( id == 0 ) ;
rc = mysql_stmt_fetch ( stmt ) ;
DIE_UNLESS ( rc == MYSQL_NO_DATA ) ;
mysql_stmt_close ( stmt ) ;
DBUG_VOID_RETURN ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_T_broadcastMyLogicalChannelResponse ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_T_broadcastMyLogicalChannelResponse , T_broadcastMyLogicalChannelResponse_choice , NULL ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int mpeg_decode_mb ( MpegEncContext * s , int16_t block [ 12 ] [ 64 ] ) {
int i , j , k , cbp , val , mb_type , motion_type ;
const int mb_block_count = 4 + ( 1 << s -> chroma_format ) ;
av_dlog ( s -> avctx , "decode_mb: x=%d y=%d\n" , s -> mb_x , s -> mb_y ) ;
assert ( s -> mb_skipped == 0 ) ;
if ( s -> mb_skip_run -- != 0 ) {
if ( s -> pict_type == AV_PICTURE_TYPE_P ) {
s -> mb_skipped = 1 ;
s -> current_picture . mb_type [ s -> mb_x + s -> mb_y * s -> mb_stride ] = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16 ;
}
else {
int mb_type ;
if ( s -> mb_x ) mb_type = s -> current_picture . mb_type [ s -> mb_x + s -> mb_y * s -> mb_stride - 1 ] ;
else mb_type = s -> current_picture . mb_type [ s -> mb_width + ( s -> mb_y - 1 ) * s -> mb_stride - 1 ] ;
if ( IS_INTRA ( mb_type ) ) return - 1 ;
s -> current_picture . mb_type [ s -> mb_x + s -> mb_y * s -> mb_stride ] = mb_type | MB_TYPE_SKIP ;
if ( ( s -> mv [ 0 ] [ 0 ] [ 0 ] | s -> mv [ 0 ] [ 0 ] [ 1 ] | s -> mv [ 1 ] [ 0 ] [ 0 ] | s -> mv [ 1 ] [ 0 ] [ 1 ] ) == 0 ) s -> mb_skipped = 1 ;
}
return 0 ;
}
switch ( s -> pict_type ) {
default : case AV_PICTURE_TYPE_I : if ( get_bits1 ( & s -> gb ) == 0 ) {
if ( get_bits1 ( & s -> gb ) == 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "invalid mb type in I Frame at %d %d\n" , s -> mb_x , s -> mb_y ) ;
return - 1 ;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA ;
}
else {
mb_type = MB_TYPE_INTRA ;
}
break ;
case AV_PICTURE_TYPE_P : mb_type = get_vlc2 ( & s -> gb , mb_ptype_vlc . table , MB_PTYPE_VLC_BITS , 1 ) ;
if ( mb_type < 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "invalid mb type in P Frame at %d %d\n" , s -> mb_x , s -> mb_y ) ;
return - 1 ;
}
mb_type = ptype2mb_type [ mb_type ] ;
break ;
case AV_PICTURE_TYPE_B : mb_type = get_vlc2 ( & s -> gb , mb_btype_vlc . table , MB_BTYPE_VLC_BITS , 1 ) ;
if ( mb_type < 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "invalid mb type in B Frame at %d %d\n" , s -> mb_x , s -> mb_y ) ;
return - 1 ;
}
mb_type = btype2mb_type [ mb_type ] ;
break ;
}
av_dlog ( s -> avctx , "mb_type=%x\n" , mb_type ) ;
if ( IS_INTRA ( mb_type ) ) {
s -> dsp . clear_blocks ( s -> block [ 0 ] ) ;
if ( ! s -> chroma_y_shift ) {
s -> dsp . clear_blocks ( s -> block [ 6 ] ) ;
}
if ( s -> picture_structure == PICT_FRAME && ! s -> frame_pred_frame_dct ) {
s -> interlaced_dct = get_bits1 ( & s -> gb ) ;
}
if ( IS_QUANT ( mb_type ) ) s -> qscale = get_qscale ( s ) ;
if ( s -> concealment_motion_vectors ) {
if ( s -> picture_structure != PICT_FRAME ) skip_bits1 ( & s -> gb ) ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> last_mv [ 0 ] [ 0 ] [ 0 ] = s -> last_mv [ 0 ] [ 1 ] [ 0 ] = mpeg_decode_motion ( s , s -> mpeg_f_code [ 0 ] [ 0 ] , s -> last_mv [ 0 ] [ 0 ] [ 0 ] ) ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> last_mv [ 0 ] [ 0 ] [ 1 ] = s -> last_mv [ 0 ] [ 1 ] [ 1 ] = mpeg_decode_motion ( s , s -> mpeg_f_code [ 0 ] [ 1 ] , s -> last_mv [ 0 ] [ 0 ] [ 1 ] ) ;
skip_bits1 ( & s -> gb ) ;
}
else memset ( s -> last_mv , 0 , sizeof ( s -> last_mv ) ) ;
s -> mb_intra = 1 ;
if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration > 1 ) {
ff_xvmc_pack_pblocks ( s , - 1 ) ;
if ( s -> swap_uv ) {
exchange_uv ( s ) ;
}
}
if ( s -> codec_id == AV_CODEC_ID_MPEG2VIDEO ) {
if ( s -> flags2 & CODEC_FLAG2_FAST ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
mpeg2_fast_decode_block_intra ( s , * s -> pblocks [ i ] , i ) ;
}
}
else {
for ( i = 0 ;
i < mb_block_count ;
i ++ ) {
if ( mpeg2_decode_block_intra ( s , * s -> pblocks [ i ] , i ) < 0 ) return - 1 ;
}
}
}
else {
for ( i = 0 ;
i < 6 ;
i ++ ) {
if ( mpeg1_decode_block_intra ( s , * s -> pblocks [ i ] , i ) < 0 ) return - 1 ;
}
}
}
else {
if ( mb_type & MB_TYPE_ZERO_MV ) {
assert ( mb_type & MB_TYPE_CBP ) ;
s -> mv_dir = MV_DIR_FORWARD ;
if ( s -> picture_structure == PICT_FRAME ) {
if ( ! s -> frame_pred_frame_dct ) s -> interlaced_dct = get_bits1 ( & s -> gb ) ;
s -> mv_type = MV_TYPE_16X16 ;
}
else {
s -> mv_type = MV_TYPE_FIELD ;
mb_type |= MB_TYPE_INTERLACED ;
s -> field_select [ 0 ] [ 0 ] = s -> picture_structure - 1 ;
}
if ( IS_QUANT ( mb_type ) ) s -> qscale = get_qscale ( s ) ;
s -> last_mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
s -> last_mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
s -> last_mv [ 0 ] [ 1 ] [ 0 ] = 0 ;
s -> last_mv [ 0 ] [ 1 ] [ 1 ] = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
}
else {
assert ( mb_type & MB_TYPE_L0L1 ) ;
if ( s -> frame_pred_frame_dct ) motion_type = MT_FRAME ;
else {
motion_type = get_bits ( & s -> gb , 2 ) ;
if ( s -> picture_structure == PICT_FRAME && HAS_CBP ( mb_type ) ) s -> interlaced_dct = get_bits1 ( & s -> gb ) ;
}
if ( IS_QUANT ( mb_type ) ) s -> qscale = get_qscale ( s ) ;
s -> mv_dir = ( mb_type >> 13 ) & 3 ;
av_dlog ( s -> avctx , "motion_type=%d\n" , motion_type ) ;
switch ( motion_type ) {
case MT_FRAME : if ( s -> picture_structure == PICT_FRAME ) {
mb_type |= MB_TYPE_16x16 ;
s -> mv_type = MV_TYPE_16X16 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( USES_LIST ( mb_type , i ) ) {
s -> mv [ i ] [ 0 ] [ 0 ] = s -> last_mv [ i ] [ 0 ] [ 0 ] = s -> last_mv [ i ] [ 1 ] [ 0 ] = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 0 ] , s -> last_mv [ i ] [ 0 ] [ 0 ] ) ;
s -> mv [ i ] [ 0 ] [ 1 ] = s -> last_mv [ i ] [ 0 ] [ 1 ] = s -> last_mv [ i ] [ 1 ] [ 1 ] = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 1 ] , s -> last_mv [ i ] [ 0 ] [ 1 ] ) ;
if ( s -> full_pel [ i ] ) {
s -> mv [ i ] [ 0 ] [ 0 ] <<= 1 ;
s -> mv [ i ] [ 0 ] [ 1 ] <<= 1 ;
}
}
}
}
else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED ;
s -> mv_type = MV_TYPE_16X8 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( USES_LIST ( mb_type , i ) ) {
for ( j = 0 ;
j < 2 ;
j ++ ) {
s -> field_select [ i ] [ j ] = get_bits1 ( & s -> gb ) ;
for ( k = 0 ;
k < 2 ;
k ++ ) {
val = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ k ] , s -> last_mv [ i ] [ j ] [ k ] ) ;
s -> last_mv [ i ] [ j ] [ k ] = val ;
s -> mv [ i ] [ j ] [ k ] = val ;
}
}
}
}
}
break ;
case MT_FIELD : s -> mv_type = MV_TYPE_FIELD ;
if ( s -> picture_structure == PICT_FRAME ) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( USES_LIST ( mb_type , i ) ) {
for ( j = 0 ;
j < 2 ;
j ++ ) {
s -> field_select [ i ] [ j ] = get_bits1 ( & s -> gb ) ;
val = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 0 ] , s -> last_mv [ i ] [ j ] [ 0 ] ) ;
s -> last_mv [ i ] [ j ] [ 0 ] = val ;
s -> mv [ i ] [ j ] [ 0 ] = val ;
av_dlog ( s -> avctx , "fmx=%d\n" , val ) ;
val = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 1 ] , s -> last_mv [ i ] [ j ] [ 1 ] >> 1 ) ;
s -> last_mv [ i ] [ j ] [ 1 ] = val << 1 ;
s -> mv [ i ] [ j ] [ 1 ] = val ;
av_dlog ( s -> avctx , "fmy=%d\n" , val ) ;
}
}
}
}
else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( USES_LIST ( mb_type , i ) ) {
s -> field_select [ i ] [ 0 ] = get_bits1 ( & s -> gb ) ;
for ( k = 0 ;
k < 2 ;
k ++ ) {
val = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ k ] , s -> last_mv [ i ] [ 0 ] [ k ] ) ;
s -> last_mv [ i ] [ 0 ] [ k ] = val ;
s -> last_mv [ i ] [ 1 ] [ k ] = val ;
s -> mv [ i ] [ 0 ] [ k ] = val ;
}
}
}
}
break ;
case MT_DMV : s -> mv_type = MV_TYPE_DMV ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( USES_LIST ( mb_type , i ) ) {
int dmx , dmy , mx , my , m ;
const int my_shift = s -> picture_structure == PICT_FRAME ;
mx = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 0 ] , s -> last_mv [ i ] [ 0 ] [ 0 ] ) ;
s -> last_mv [ i ] [ 0 ] [ 0 ] = mx ;
s -> last_mv [ i ] [ 1 ] [ 0 ] = mx ;
dmx = get_dmv ( s ) ;
my = mpeg_decode_motion ( s , s -> mpeg_f_code [ i ] [ 1 ] , s -> last_mv [ i ] [ 0 ] [ 1 ] >> my_shift ) ;
dmy = get_dmv ( s ) ;
s -> last_mv [ i ] [ 0 ] [ 1 ] = my << my_shift ;
s -> last_mv [ i ] [ 1 ] [ 1 ] = my << my_shift ;
s -> mv [ i ] [ 0 ] [ 0 ] = mx ;
s -> mv [ i ] [ 0 ] [ 1 ] = my ;
s -> mv [ i ] [ 1 ] [ 0 ] = mx ;
s -> mv [ i ] [ 1 ] [ 1 ] = my ;
if ( s -> picture_structure == PICT_FRAME ) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED ;
m = s -> top_field_first ? 1 : 3 ;
s -> mv [ i ] [ 2 ] [ 0 ] = ( ( mx * m + ( mx > 0 ) ) >> 1 ) + dmx ;
s -> mv [ i ] [ 2 ] [ 1 ] = ( ( my * m + ( my > 0 ) ) >> 1 ) + dmy - 1 ;
m = 4 - m ;
s -> mv [ i ] [ 3 ] [ 0 ] = ( ( mx * m + ( mx > 0 ) ) >> 1 ) + dmx ;
s -> mv [ i ] [ 3 ] [ 1 ] = ( ( my * m + ( my > 0 ) ) >> 1 ) + dmy + 1 ;
}
else {
mb_type |= MB_TYPE_16x16 ;
s -> mv [ i ] [ 2 ] [ 0 ] = ( ( mx + ( mx > 0 ) ) >> 1 ) + dmx ;
s -> mv [ i ] [ 2 ] [ 1 ] = ( ( my + ( my > 0 ) ) >> 1 ) + dmy ;
if ( s -> picture_structure == PICT_TOP_FIELD ) s -> mv [ i ] [ 2 ] [ 1 ] -- ;
else s -> mv [ i ] [ 2 ] [ 1 ] ++ ;
}
}
}
break ;
default : av_log ( s -> avctx , AV_LOG_ERROR , "00 motion_type at %d %d\n" , s -> mb_x , s -> mb_y ) ;
return - 1 ;
}
}
s -> mb_intra = 0 ;
if ( HAS_CBP ( mb_type ) ) {
s -> dsp . clear_blocks ( s -> block [ 0 ] ) ;
cbp = get_vlc2 ( & s -> gb , mb_pat_vlc . table , MB_PAT_VLC_BITS , 1 ) ;
if ( mb_block_count > 6 ) {
cbp <<= mb_block_count - 6 ;
cbp |= get_bits ( & s -> gb , mb_block_count - 6 ) ;
s -> dsp . clear_blocks ( s -> block [ 6 ] ) ;
}
if ( cbp <= 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "invalid cbp at %d %d\n" , s -> mb_x , s -> mb_y ) ;
return - 1 ;
}
if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration > 1 ) {
ff_xvmc_pack_pblocks ( s , cbp ) ;
if ( s -> swap_uv ) {
exchange_uv ( s ) ;
}
}
if ( s -> codec_id == AV_CODEC_ID_MPEG2VIDEO ) {
if ( s -> flags2 & CODEC_FLAG2_FAST ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
if ( cbp & 32 ) {
mpeg2_fast_decode_block_non_intra ( s , * s -> pblocks [ i ] , i ) ;
}
else {
s -> block_last_index [ i ] = - 1 ;
}
cbp += cbp ;
}
}
else {
cbp <<= 12 - mb_block_count ;
for ( i = 0 ;
i < mb_block_count ;
i ++ ) {
if ( cbp & ( 1 << 11 ) ) {
if ( mpeg2_decode_block_non_intra ( s , * s -> pblocks [ i ] , i ) < 0 ) return - 1 ;
}
else {
s -> block_last_index [ i ] = - 1 ;
}
cbp += cbp ;
}
}
}
else {
if ( s -> flags2 & CODEC_FLAG2_FAST ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
if ( cbp & 32 ) {
mpeg1_fast_decode_block_inter ( s , * s -> pblocks [ i ] , i ) ;
}
else {
s -> block_last_index [ i ] = - 1 ;
}
cbp += cbp ;
}
}
else {
for ( i = 0 ;
i < 6 ;
i ++ ) {
if ( cbp & 32 ) {
if ( mpeg1_decode_block_inter ( s , * s -> pblocks [ i ] , i ) < 0 ) return - 1 ;
}
else {
s -> block_last_index [ i ] = - 1 ;
}
cbp += cbp ;
}
}
}
}
else {
for ( i = 0 ;
i < 12 ;
i ++ ) s -> block_last_index [ i ] = - 1 ;
}
}
s -> current_picture . mb_type [ s -> mb_x + s -> mb_y * s -> mb_stride ] = mb_type ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void pk_transaction_set_hints ( PkTransaction * transaction , GVariant * params , GDBusMethodInvocation * context ) {
gboolean ret ;
guint i ;
g_autofree gchar * * hints = NULL ;
g_autoptr ( GError ) error = NULL ;
g_autofree gchar * dbg = NULL ;
g_return_if_fail ( PK_IS_TRANSACTION ( transaction ) ) ;
g_return_if_fail ( transaction -> priv -> tid != NULL ) ;
g_variant_get ( params , "(^a&s)" , & hints ) ;
dbg = g_strjoinv ( ", " , ( gchar * * ) hints ) ;
g_debug ( "SetHints method called: %s" , dbg ) ;
for ( i = 0 ;
hints [ i ] != NULL ;
i ++ ) {
g_auto ( GStrv ) sections = NULL ;
sections = g_strsplit ( hints [ i ] , "=" , 2 ) ;
if ( g_strv_length ( sections ) == 2 ) {
ret = pk_transaction_set_hint ( transaction , sections [ 0 ] , sections [ 1 ] , & error ) ;
if ( ! ret ) goto out ;
}
else {
g_set_error ( & error , PK_TRANSACTION_ERROR , PK_TRANSACTION_ERROR_NOT_SUPPORTED , "Could not parse hint '%s'" , hints [ i ] ) ;
goto out ;
}
}
out : pk_transaction_dbus_return ( context , error ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int qdev_print_devinfo ( DeviceInfo * info , char * dest , int len ) {
int pos = 0 ;
int ret ;
ret = snprintf ( dest + pos , len - pos , "name \"%s\", bus %s" , info -> name , info -> bus_info -> name ) ;
pos += MIN ( len - pos , ret ) ;
if ( info -> alias ) {
ret = snprintf ( dest + pos , len - pos , ", alias \"%s\"" , info -> alias ) ;
pos += MIN ( len - pos , ret ) ;
}
if ( info -> desc ) {
ret = snprintf ( dest + pos , len - pos , ", desc \"%s\"" , info -> desc ) ;
pos += MIN ( len - pos , ret ) ;
}
if ( info -> no_user ) {
ret = snprintf ( dest + pos , len - pos , ", no-user" ) ;
pos += MIN ( len - pos , ret ) ;
}
return pos ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
err_status_t srtp_stream_alloc ( srtp_stream_ctx_t * * str_ptr , const srtp_policy_t * p ) {
srtp_stream_ctx_t * str ;
err_status_t stat ;
str = ( srtp_stream_ctx_t * ) crypto_alloc ( sizeof ( srtp_stream_ctx_t ) ) ;
if ( str == NULL ) return err_status_alloc_fail ;
* str_ptr = str ;
stat = crypto_kernel_alloc_cipher ( p -> rtp . cipher_type , & str -> rtp_cipher , p -> rtp . cipher_key_len , p -> rtp . auth_tag_len ) ;
if ( stat ) {
crypto_free ( str ) ;
return stat ;
}
stat = crypto_kernel_alloc_auth ( p -> rtp . auth_type , & str -> rtp_auth , p -> rtp . auth_key_len , p -> rtp . auth_tag_len ) ;
if ( stat ) {
cipher_dealloc ( str -> rtp_cipher ) ;
crypto_free ( str ) ;
return stat ;
}
str -> limit = ( key_limit_ctx_t * ) crypto_alloc ( sizeof ( key_limit_ctx_t ) ) ;
if ( str -> limit == NULL ) {
auth_dealloc ( str -> rtp_auth ) ;
cipher_dealloc ( str -> rtp_cipher ) ;
crypto_free ( str ) ;
return err_status_alloc_fail ;
}
stat = crypto_kernel_alloc_cipher ( p -> rtcp . cipher_type , & str -> rtcp_cipher , p -> rtcp . cipher_key_len , p -> rtcp . auth_tag_len ) ;
if ( stat ) {
auth_dealloc ( str -> rtp_auth ) ;
cipher_dealloc ( str -> rtp_cipher ) ;
crypto_free ( str -> limit ) ;
crypto_free ( str ) ;
return stat ;
}
stat = crypto_kernel_alloc_auth ( p -> rtcp . auth_type , & str -> rtcp_auth , p -> rtcp . auth_key_len , p -> rtcp . auth_tag_len ) ;
if ( stat ) {
cipher_dealloc ( str -> rtcp_cipher ) ;
auth_dealloc ( str -> rtp_auth ) ;
cipher_dealloc ( str -> rtp_cipher ) ;
crypto_free ( str -> limit ) ;
crypto_free ( str ) ;
return stat ;
}
stat = ekt_alloc ( & str -> ekt , p -> ekt ) ;
if ( stat ) {
auth_dealloc ( str -> rtcp_auth ) ;
cipher_dealloc ( str -> rtcp_cipher ) ;
auth_dealloc ( str -> rtp_auth ) ;
cipher_dealloc ( str -> rtp_cipher ) ;
crypto_free ( str -> limit ) ;
crypto_free ( str ) ;
return stat ;
}
return err_status_ok ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static cmsBool Type_ParametricCurve_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {
cmsToneCurve * Curve = ( cmsToneCurve * ) Ptr ;
int i , nParams , typen ;
static const int ParamsByType [ ] = {
0 , 1 , 3 , 4 , 5 , 7 }
;
typen = Curve -> Segments [ 0 ] . Type ;
if ( Curve -> nSegments > 1 || typen < 1 ) {
cmsSignalError ( self -> ContextID , cmsERROR_UNKNOWN_EXTENSION , "Multisegment or Inverted parametric curves cannot be written" ) ;
return FALSE ;
}
if ( typen > 5 ) {
cmsSignalError ( self -> ContextID , cmsERROR_UNKNOWN_EXTENSION , "Unsupported parametric curve" ) ;
return FALSE ;
}
nParams = ParamsByType [ typen ] ;
if ( ! _cmsWriteUInt16Number ( io , ( cmsUInt16Number ) ( Curve -> Segments [ 0 ] . Type - 1 ) ) ) return FALSE ;
if ( ! _cmsWriteUInt16Number ( io , 0 ) ) return FALSE ;
for ( i = 0 ;
i < nParams ;
i ++ ) {
if ( ! _cmsWrite15Fixed16Number ( io , Curve -> Segments [ 0 ] . Params [ i ] ) ) return FALSE ;
}
return TRUE ;
cmsUNUSED_PARAMETER ( nItems ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void udpv6_destroy_sock ( struct sock * sk ) {
lock_sock ( sk ) ;
udp_v6_flush_pending_frames ( sk ) ;
release_sock ( sk ) ;
inet6_destroy_sock ( sk ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
SPL_METHOD ( SplDoublyLinkedList , offsetExists ) {
zval * zindex ;
spl_dllist_object * intern ;
long index ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , "z" , & zindex ) == FAILURE ) {
return ;
}
intern = ( spl_dllist_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
index = spl_offset_convert_to_long ( zindex TSRMLS_CC ) ;
RETURN_BOOL ( index >= 0 && index < intern -> llist -> count ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static __always_inline __u64 __le64_to_cpup ( const __le64 * p ) {
return ( __u64 ) * p ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static __inline __uint16_t __uint16_identity ( __uint16_t __x ) {
return __x ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int64_t rd_pick_intra_sbuv_mode ( VP9_COMP * cpi , MACROBLOCK * x , PICK_MODE_CONTEXT * ctx , int * rate , int * rate_tokenonly , int64_t * distortion , int * skippable , BLOCK_SIZE bsize , TX_SIZE max_tx_size ) {
MACROBLOCKD * xd = & x -> e_mbd ;
PREDICTION_MODE mode ;
PREDICTION_MODE mode_selected = DC_PRED ;
int64_t best_rd = INT64_MAX , this_rd ;
int this_rate_tokenonly , this_rate , s ;
int64_t this_distortion , this_sse ;
for ( mode = DC_PRED ;
mode <= TM_PRED ;
++ mode ) {
if ( ! ( cpi -> sf . intra_uv_mode_mask [ max_tx_size ] & ( 1 << mode ) ) ) continue ;
xd -> mi [ 0 ] . src_mi -> mbmi . uv_mode = mode ;
super_block_uvrd ( cpi , x , & this_rate_tokenonly , & this_distortion , & s , & this_sse , bsize , best_rd ) ;
if ( this_rate_tokenonly == INT_MAX ) continue ;
this_rate = this_rate_tokenonly + cpi -> intra_uv_mode_cost [ cpi -> common . frame_type ] [ mode ] ;
this_rd = RDCOST ( x -> rdmult , x -> rddiv , this_rate , this_distortion ) ;
if ( this_rd < best_rd ) {
mode_selected = mode ;
best_rd = this_rd ;
* rate = this_rate ;
* rate_tokenonly = this_rate_tokenonly ;
* distortion = this_distortion ;
* skippable = s ;
if ( ! x -> select_tx_size ) swap_block_ptr ( x , ctx , 2 , 0 , 1 , MAX_MB_PLANE ) ;
}
}
xd -> mi [ 0 ] . src_mi -> mbmi . uv_mode = mode_selected ;
return best_rd ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void steamdiscover_dissect_body_proofrequest ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , gint offset , gint bytes_left ) {
gint len ;
gint64 value ;
protobuf_desc_t pb = {
tvb , offset , bytes_left }
;
protobuf_tag_t tag = {
0 , 0 , 0 }
;
while ( protobuf_iter_next ( & pb , & tag ) ) {
switch ( tag . field_number ) {
case STEAMDISCOVER_FN_PROOFREQUEST_CHALLENGE : STEAMDISCOVER_ENSURE_WIRETYPE ( PROTOBUF_WIRETYPE_LENGTHDELIMITED ) ;
value = get_varint64 ( pb . tvb , pb . offset , pb . bytes_left , & len ) ;
proto_tree_add_item ( tree , hf_steam_ihs_discovery_body_proofrequest_challenge , pb . tvb , pb . offset + len , ( gint ) value , ENC_NA ) ;
len += ( gint ) value ;
break ;
default : len = protobuf_dissect_unknown_field ( & pb , & tag , pinfo , tree , NULL ) ;
break ;
}
protobuf_seek_forward ( & pb , len ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _new_null ( void ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_new_null ( ) ;
}
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _new_reserve ( sk_ ## t1 ## _compfunc compare , int n ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_new_reserve ( ( OPENSSL_sk_compfunc ) compare , n ) ;
}
static ossl_inline int sk_ ## t1 ## _reserve ( STACK_OF ( t1 ) * sk , int n ) {
return OPENSSL_sk_reserve ( ( OPENSSL_STACK * ) sk , n ) ;
}
static ossl_inline void sk_ ## t1 ## _free ( STACK_OF ( t1 ) * sk ) {
OPENSSL_sk_free ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline void sk_ ## t1 ## _zero ( STACK_OF ( t1 ) * sk ) {
OPENSSL_sk_zero ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline t2 * sk_ ## t1 ## _delete ( STACK_OF ( t1 ) * sk , int i ) {
return ( t2 * ) OPENSSL_sk_delete ( ( OPENSSL_STACK * ) sk , i ) ;
}
static ossl_inline t2 * sk_ ## t1 ## _delete_ptr ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return ( t2 * ) OPENSSL_sk_delete_ptr ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _push ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_push ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _unshift ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_unshift ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline t2 * sk_ ## t1 ## _pop ( STACK_OF ( t1 ) * sk ) {
return ( t2 * ) OPENSSL_sk_pop ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) {
return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) {
OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ;
}
static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) {
return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ;
}
static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) {
return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {
OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {
return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;
}
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;
}
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;
}
static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {
return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;
}
# define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;
typedef const char * OPENSSL_CSTRING ;
DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char ) DEFINE_SPECIAL_STACK_OF_CONST ( OPENSSL_CSTRING , char ) typedef void * OPENSSL_BLOCK ;
DEFINE_SPECIAL_STACK_OF ( OPENSSL_BLOCK , void )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int loco_decode_plane ( LOCOContext * l , uint8_t * data , int width , int height , int stride , const uint8_t * buf , int buf_size , int step ) {
RICEContext rc ;
int val ;
int i , j ;
init_get_bits ( & rc . gb , buf , buf_size * 8 ) ;
rc . save = 0 ;
rc . run = 0 ;
rc . run2 = 0 ;
rc . lossy = l -> lossy ;
rc . sum = 8 ;
rc . count = 1 ;
val = loco_get_rice ( & rc ) ;
data [ 0 ] = 128 + val ;
for ( i = 1 ;
i < width ;
i ++ ) {
val = loco_get_rice ( & rc ) ;
data [ i * step ] = data [ i * step - step ] + val ;
}
data += stride ;
for ( j = 1 ;
j < height ;
j ++ ) {
val = loco_get_rice ( & rc ) ;
data [ 0 ] = data [ - stride ] + val ;
for ( i = 1 ;
i < width ;
i ++ ) {
val = loco_get_rice ( & rc ) ;
data [ i * step ] = loco_predict ( & data [ i * step ] , stride , step ) + val ;
}
data += stride ;
}
return ( get_bits_count ( & rc . gb ) + 7 ) >> 3 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int vp9_full_search_sad_c ( const MACROBLOCK * x , const MV * ref_mv , int sad_per_bit , int distance , const vp9_variance_fn_ptr_t * fn_ptr , const MV * center_mv , MV * best_mv ) {
int r , c ;
const MACROBLOCKD * const xd = & x -> e_mbd ;
const struct buf_2d * const what = & x -> plane [ 0 ] . src ;
const struct buf_2d * const in_what = & xd -> plane [ 0 ] . pre [ 0 ] ;
const int row_min = MAX ( ref_mv -> row - distance , x -> mv_row_min ) ;
const int row_max = MIN ( ref_mv -> row + distance , x -> mv_row_max ) ;
const int col_min = MAX ( ref_mv -> col - distance , x -> mv_col_min ) ;
const int col_max = MIN ( ref_mv -> col + distance , x -> mv_col_max ) ;
const MV fcenter_mv = {
center_mv -> row >> 3 , center_mv -> col >> 3 }
;
int best_sad = fn_ptr -> 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 ) ;
* best_mv = * ref_mv ;
for ( r = row_min ;
r < row_max ;
++ r ) {
for ( c = col_min ;
c < col_max ;
++ c ) {
const MV mv = {
r , c }
;
const int sad = fn_ptr -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & mv ) , in_what -> stride ) + mvsad_err_cost ( x , & mv , & fcenter_mv , sad_per_bit ) ;
if ( sad < best_sad ) {
best_sad = sad ;
* best_mv = mv ;
}
}
}
return best_sad ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void gif_read_error ( Gif_Context * gfc , int is_error , const char * text ) {
Gif_ReadErrorHandler handler = gfc -> handler ? gfc -> handler : default_error_handler ;
if ( is_error >= 0 ) gfc -> errors [ is_error > 0 ] += 1 ;
if ( handler ) handler ( gfc -> stream , gfc -> gfi , is_error , text ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST_F ( ProtocolHandlerRegistryTest , TestReplaceNonDefaultHandler ) {
ProtocolHandler ph1 = CreateProtocolHandler ( "mailto" , GURL ( "http://test.com/%s" ) , "test1" ) ;
ProtocolHandler ph2 = CreateProtocolHandler ( "mailto" , GURL ( "http://test.com/updated-url/%s" ) , "test2" ) ;
ProtocolHandler ph3 = CreateProtocolHandler ( "mailto" , GURL ( "http://else.com/%s" ) , "test3" ) ;
registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ;
registry ( ) -> OnAcceptRegisterProtocolHandler ( ph3 ) ;
ASSERT_TRUE ( registry ( ) -> AttemptReplace ( ph2 ) ) ;
const ProtocolHandler & handler ( registry ( ) -> GetHandlerFor ( "mailto" ) ) ;
ASSERT_EQ ( handler . url ( ) , ph3 . url ( ) ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
int PEM_write_bio_ ## name ( BIO * bp , const type * x ) ;
# define DECLARE_PEM_write_cb_bio ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , type * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
# define DECLARE_PEM_write ( name , type ) DECLARE_PEM_write_bio ( name , type ) DECLARE_PEM_write_fp ( name , type ) # define DECLARE_PEM_write_const ( name , type ) DECLARE_PEM_write_bio_const ( name , type ) DECLARE_PEM_write_fp_const ( name , type ) # define DECLARE_PEM_write_cb ( name , type ) DECLARE_PEM_write_cb_bio ( name , type ) DECLARE_PEM_write_cb_fp ( name , type ) # define DECLARE_PEM_read ( name , type ) DECLARE_PEM_read_bio ( name , type ) DECLARE_PEM_read_fp ( name , type ) # define DECLARE_PEM_rw ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write ( name , type ) # define DECLARE_PEM_rw_const ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_const ( name , type ) # define DECLARE_PEM_rw_cb ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_cb ( name , type ) typedef int pem_password_cb ( char * buf , int size , int rwflag , void * userdata ) ;
int PEM_get_EVP_CIPHER_INFO ( char * header , EVP_CIPHER_INFO * cipher ) ;
int PEM_do_header ( EVP_CIPHER_INFO * cipher , unsigned char * data , long * len , pem_password_cb * callback , void * u ) ;
int PEM_read_bio ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len ) ;
# define PEM_FLAG_SECURE 0x1 # define PEM_FLAG_EAY_COMPATIBLE 0x2 # define PEM_FLAG_ONLY_B64 0x4 int PEM_read_bio_ex ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len , unsigned int flags ) ;
int PEM_bytes_read_bio_secmem ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
int PEM_write_bio ( BIO * bp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
int PEM_bytes_read_bio ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
void * PEM_ASN1_read_bio ( d2i_of_void * d2i , const char * name , BIO * bp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write_bio ( i2d_of_void * i2d , const char * name , BIO * bp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read_bio ( BIO * bp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
int PEM_X509_INFO_write_bio ( BIO * bp , X509_INFO * xi , EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cd , void * u ) ;
# ifndef OPENSSL_NO_STDIO int PEM_read ( FILE * fp , char * * name , char * * header , unsigned char * * data , long * len ) ;
int PEM_write ( FILE * fp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
void * PEM_ASN1_read ( d2i_of_void * d2i , const char * name , FILE * fp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write ( i2d_of_void * i2d , const char * name , FILE * fp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * callback , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read ( FILE * fp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
# endif int PEM_SignInit ( EVP_MD_CTX * ctx , EVP_MD * type ) ;
int PEM_SignUpdate ( EVP_MD_CTX * ctx , unsigned char * d , unsigned int cnt ) ;
int PEM_SignFinal ( EVP_MD_CTX * ctx , unsigned char * sigret , unsigned int * siglen , EVP_PKEY * pkey ) ;
int PEM_def_callback ( char * buf , int num , int rwflag , void * userdata ) ;
void PEM_proc_type ( char * buf , int type ) ;
void PEM_dek_info ( char * buf , const char * type , int len , char * str ) ;
# include < openssl / symhacks . h > DECLARE_PEM_rw ( X509 , X509 ) DECLARE_PEM_rw ( X509_AUX , X509 ) DECLARE_PEM_rw ( X509_REQ , X509_REQ ) DECLARE_PEM_write ( X509_REQ_NEW , X509_REQ ) DECLARE_PEM_rw ( X509_CRL , X509_CRL ) DECLARE_PEM_rw ( PKCS7 , PKCS7 ) DECLARE_PEM_rw ( NETSCAPE_CERT_SEQUENCE , NETSCAPE_CERT_SEQUENCE ) DECLARE_PEM_rw ( PKCS8 , X509_SIG ) DECLARE_PEM_rw ( PKCS8_PRIV_KEY_INFO , PKCS8_PRIV_KEY_INFO ) # ifndef OPENSSL_NO_RSA DECLARE_PEM_rw_cb ( RSAPrivateKey , RSA ) DECLARE_PEM_rw_const ( RSAPublicKey , RSA ) DECLARE_PEM_rw ( RSA_PUBKEY , RSA ) # endif # ifndef OPENSSL_NO_DSA DECLARE_PEM_rw_cb ( DSAPrivateKey , DSA ) DECLARE_PEM_rw ( DSA_PUBKEY , DSA ) DECLARE_PEM_rw_const ( DSAparams , DSA ) # endif # ifndef OPENSSL_NO_EC DECLARE_PEM_rw_const ( ECPKParameters , EC_GROUP ) DECLARE_PEM_rw_cb ( ECPrivateKey , EC_KEY ) DECLARE_PEM_rw ( EC_PUBKEY , EC_KEY ) # endif # ifndef OPENSSL_NO_DH DECLARE_PEM_rw_const ( DHparams , DH )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int rtp_packetize_xiph_config ( sout_stream_id_sys_t * id , const char * fmtp , int64_t i_pts ) {
if ( fmtp == NULL ) return VLC_EGENERIC ;
char * start = strstr ( fmtp , "configuration=" ) ;
assert ( start != NULL ) ;
start += sizeof ( "configuration=" ) - 1 ;
char * end = strchr ( start , ';
' ) ;
assert ( end != NULL ) ;
size_t len = end - start ;
char * b64 = malloc ( len + 1 ) ;
if ( ! b64 ) return VLC_EGENERIC ;
memcpy ( b64 , start , len ) ;
b64 [ len ] = '\0' ;
int i_max = rtp_mtu ( id ) - 6 ;
uint8_t * p_orig , * p_data ;
int i_data ;
i_data = vlc_b64_decode_binary ( & p_orig , b64 ) ;
free ( b64 ) ;
if ( i_data <= 9 ) {
free ( p_orig ) ;
return VLC_EGENERIC ;
}
p_data = p_orig + 9 ;
i_data -= 9 ;
int i_count = ( i_data + i_max - 1 ) / i_max ;
for ( int i = 0 ;
i < i_count ;
i ++ ) {
int i_payload = __MIN ( i_max , i_data ) ;
block_t * out = block_Alloc ( 18 + i_payload ) ;
unsigned fragtype , numpkts ;
if ( i_count == 1 ) {
fragtype = 0 ;
numpkts = 1 ;
}
else {
numpkts = 0 ;
if ( i == 0 ) fragtype = 1 ;
else if ( i == i_count - 1 ) fragtype = 3 ;
else fragtype = 2 ;
}
uint32_t header = ( ( XIPH_IDENT & 0xffffff ) << 8 ) | ( fragtype << 6 ) | ( 1 << 4 ) | numpkts ;
rtp_packetize_common ( id , out , 0 , i_pts ) ;
SetDWBE ( out -> p_buffer + 12 , header ) ;
SetWBE ( out -> p_buffer + 16 , i_payload ) ;
memcpy ( & out -> p_buffer [ 18 ] , p_data , i_payload ) ;
out -> i_dts = i_pts ;
rtp_packetize_send ( id , out ) ;
p_data += i_payload ;
i_data -= i_payload ;
}
free ( p_orig ) ;
return VLC_SUCCESS ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static bool spec_ctrl_needed ( void * opaque ) {
X86CPU * cpu = opaque ;
CPUX86State * env = & cpu -> env ;
return env -> spec_ctrl != 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void format_errmsg ( char * nfmt , size_t lennfmt , const char * fmt , int errval ) {
char errmsg [ 256 ] ;
char c ;
char * n ;
const char * f ;
size_t len ;
n = nfmt ;
f = fmt ;
while ( ( c = * f ++ ) != '\0' && n < ( nfmt + lennfmt - 1 ) ) {
if ( c != '%' ) {
* n ++ = c ;
continue ;
}
if ( ( c = * f ++ ) != 'm' ) {
* n ++ = '%' ;
if ( '\0' == c ) break ;
* n ++ = c ;
continue ;
}
errno_to_str ( errval , errmsg , sizeof ( errmsg ) ) ;
len = strlen ( errmsg ) ;
if ( ( n + len ) < ( nfmt + lennfmt - 1 ) ) {
memcpy ( n , errmsg , len ) ;
n += len ;
}
}
* n = '\0' ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int msg_msg_alloc_security ( struct msg_msg * msg ) {
struct msg_security_struct * msec ;
msec = kzalloc ( sizeof ( struct msg_security_struct ) , GFP_KERNEL ) ;
if ( ! msec ) return - ENOMEM ;
msec -> sid = SECINITSID_UNLABELED ;
msg -> security = msec ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int qemuAgentSend ( qemuAgentPtr mon , qemuAgentMessagePtr msg , int seconds ) {
int ret = - 1 ;
unsigned long long then = 0 ;
if ( mon -> lastError . code != VIR_ERR_OK ) {
VIR_DEBUG ( "Attempt to send command while error is set %s" , NULLSTR ( mon -> lastError . message ) ) ;
virSetError ( & mon -> lastError ) ;
return - 1 ;
}
if ( seconds > VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK ) {
unsigned long long now ;
if ( virTimeMillisNow ( & now ) < 0 ) return - 1 ;
if ( seconds == VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT ) seconds = QEMU_AGENT_WAIT_TIME ;
then = now + seconds * 1000ull ;
}
mon -> msg = msg ;
qemuAgentUpdateWatch ( mon ) ;
while ( ! mon -> msg -> finished ) {
if ( ( then && virCondWaitUntil ( & mon -> notify , & mon -> parent . lock , then ) < 0 ) || ( ! then && virCondWait ( & mon -> notify , & mon -> parent . lock ) < 0 ) ) {
if ( errno == ETIMEDOUT ) {
virReportError ( VIR_ERR_AGENT_UNRESPONSIVE , "%s" , _ ( "Guest agent not available for now" ) ) ;
ret = - 2 ;
}
else {
virReportSystemError ( errno , "%s" , _ ( "Unable to wait on agent monitor " "condition" ) ) ;
}
goto cleanup ;
}
}
if ( mon -> lastError . code != VIR_ERR_OK ) {
VIR_DEBUG ( "Send command resulted in error %s" , NULLSTR ( mon -> lastError . message ) ) ;
virSetError ( & mon -> lastError ) ;
goto cleanup ;
}
ret = 0 ;
cleanup : mon -> msg = NULL ;
qemuAgentUpdateWatch ( mon ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static const char * _UTF16BEGetName ( const UConverter * cnv ) {
if ( UCNV_GET_VERSION ( cnv ) == 0 ) {
return "UTF-16BE" ;
}
else {
return "UTF-16BE,version=1" ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int kvm_put_debugregs ( X86CPU * cpu ) {
CPUX86State * env = & cpu -> env ;
struct kvm_debugregs dbgregs ;
int i ;
if ( ! kvm_has_debugregs ( ) ) {
return 0 ;
}
for ( i = 0 ;
i < 4 ;
i ++ ) {
dbgregs . db [ i ] = env -> dr [ i ] ;
}
dbgregs . dr6 = env -> dr [ 6 ] ;
dbgregs . dr7 = env -> dr [ 7 ] ;
dbgregs . flags = 0 ;
return kvm_vcpu_ioctl ( CPU ( cpu ) , KVM_SET_DEBUGREGS , & dbgregs ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int arm_cpu_env_mask ( void ) {
char * env ;
env = getenv ( "VPX_SIMD_CAPS_MASK" ) ;
return env && * env ? ( int ) strtol ( env , NULL , 0 ) : ~ 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int isoent_alloc_path_table ( struct archive_write * a , struct vdd * vdd , int max_depth ) {
int i ;
vdd -> max_depth = max_depth ;
vdd -> pathtbl = malloc ( sizeof ( * vdd -> pathtbl ) * vdd -> max_depth ) ;
if ( vdd -> pathtbl == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Can't allocate memory" ) ;
return ( ARCHIVE_FATAL ) ;
}
for ( i = 0 ;
i < vdd -> max_depth ;
i ++ ) {
vdd -> pathtbl [ i ] . first = NULL ;
vdd -> pathtbl [ i ] . last = & ( vdd -> pathtbl [ i ] . first ) ;
vdd -> pathtbl [ i ] . sorted = NULL ;
vdd -> pathtbl [ i ] . cnt = 0 ;
}
return ( ARCHIVE_OK ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
sf_count_t psf_ftell ( SF_PRIVATE * psf ) {
sf_count_t pos ;
if ( psf -> virtual_io ) return psf -> vio . tell ( psf -> vio_user_data ) ;
if ( psf -> is_pipe ) return psf -> pipeoffset ;
pos = lseek ( psf -> file . filedes , 0 , SEEK_CUR ) ;
if ( pos == ( ( sf_count_t ) - 1 ) ) {
psf_log_syserr ( psf , errno ) ;
return - 1 ;
}
;
return pos - psf -> fileoffset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void do_get_replace_column ( struct st_command * command ) {
char * from = command -> first_argument ;
char * buff , * start ;
DBUG_ENTER ( "get_replace_columns" ) ;
free_replace_column ( ) ;
if ( ! * from ) die ( "Missing argument in %s" , command -> query ) ;
start = buff = ( char * ) my_malloc ( strlen ( from ) + 1 , MYF ( MY_WME | MY_FAE ) ) ;
while ( * from ) {
char * to ;
uint column_number ;
to = get_string ( & buff , & from , command ) ;
if ( ! ( column_number = atoi ( to ) ) || column_number > MAX_COLUMNS ) die ( "Wrong column number to replace_column in '%s'" , command -> query ) ;
if ( ! * from ) die ( "Wrong number of arguments to replace_column in '%s'" , command -> query ) ;
to = get_string ( & buff , & from , command ) ;
my_free ( replace_column [ column_number - 1 ] ) ;
replace_column [ column_number - 1 ] = my_strdup ( to , MYF ( MY_WME | MY_FAE ) ) ;
set_if_bigger ( max_replace_column , column_number ) ;
}
my_free ( start ) ;
command -> last_argument = command -> end ;
DBUG_VOID_RETURN ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void _slurm_rpc_step_layout ( slurm_msg_t * msg ) {
int error_code = SLURM_SUCCESS ;
slurm_msg_t response_msg ;
DEF_TIMERS ;
job_step_id_msg_t * req = ( job_step_id_msg_t * ) msg -> data ;
slurm_step_layout_t * step_layout = NULL ;
slurmctld_lock_t job_read_lock = {
READ_LOCK , READ_LOCK , READ_LOCK , NO_LOCK , NO_LOCK }
;
uid_t uid = g_slurm_auth_get_uid ( msg -> auth_cred , slurmctld_config . auth_info ) ;
struct job_record * job_ptr = NULL ;
struct step_record * step_ptr = NULL ;
START_TIMER ;
debug2 ( "Processing RPC: REQUEST_STEP_LAYOUT, from uid=%d" , uid ) ;
lock_slurmctld ( job_read_lock ) ;
error_code = job_alloc_info ( uid , req -> job_id , & job_ptr ) ;
END_TIMER2 ( "_slurm_rpc_step_layout" ) ;
if ( error_code || ( job_ptr == NULL ) ) {
unlock_slurmctld ( job_read_lock ) ;
if ( error_code == ESLURM_ACCESS_DENIED ) {
error ( "Security vioation, REQUEST_STEP_LAYOUT for " "JobId=%u from uid=%u" , req -> job_id , uid ) ;
}
else {
if ( slurmctld_conf . debug_flags & DEBUG_FLAG_STEPS ) info ( "%s: JobId=%u, uid=%u: %s" , __func__ , req -> job_id , uid , slurm_strerror ( error_code ) ) ;
}
slurm_send_rc_msg ( msg , error_code ) ;
return ;
}
step_ptr = find_step_record ( job_ptr , req -> step_id ) ;
if ( ! step_ptr ) {
unlock_slurmctld ( job_read_lock ) ;
if ( slurmctld_conf . debug_flags & DEBUG_FLAG_STEPS ) info ( "%s: JobId=%u.%u Not Found" , __func__ , req -> job_id , req -> step_id ) ;
slurm_send_rc_msg ( msg , ESLURM_INVALID_JOB_ID ) ;
return ;
}
step_layout = slurm_step_layout_copy ( step_ptr -> step_layout ) ;
# ifdef HAVE_FRONT_END if ( job_ptr -> batch_host ) step_layout -> front_end = xstrdup ( job_ptr -> batch_host ) ;
# endif unlock_slurmctld ( job_read_lock ) ;
slurm_msg_t_init ( & response_msg ) ;
response_msg . flags = msg -> flags ;
response_msg . protocol_version = msg -> protocol_version ;
response_msg . msg_type = RESPONSE_STEP_LAYOUT ;
response_msg . data = step_layout ;
slurm_send_node_msg ( msg -> conn_fd , & response_msg ) ;
slurm_step_layout_destroy ( step_layout ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int main ( ) {
pthread_key_create ( & threadKey , nullptr ) ;
Utils : : init ( & Debug , & Error ) ;
{
cout << endl << "===================== Test 1" << endl ;
Utils : : HeaderValueList whitelistCookies ;
whitelistCookies . push_back ( "c1" ) ;
whitelistCookies . push_back ( "c2" ) ;
whitelistCookies . push_back ( "c3" ) ;
whitelistCookies . push_back ( "c4" ) ;
whitelistCookies . push_back ( "c5" ) ;
Variables esi_vars ( "vars_test" , & Debug , & Error , whitelistCookies ) ;
const char * strings [ ] = {
"Cookie" , ";
c1=v1;
c2=v2;
;
c3;
c4=;
c5=v5 " , "Host" , "example.com" , "Referer" , "google.com" , "Blah" , "Blah" , "Accept-Language" , "en-gb , en-us , ," , "Accept-Language" , "ka-in" , nullptr }
;
HttpHeaderList headers ;
addToHeaderList ( strings , headers ) ;
esi_vars . populate ( headers ) ;
esi_vars . populate ( "a=b&c=d&e=f" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1}
" ) == "v1" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c2}
" ) == "v2" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c3}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c4}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c5}
" ) == "v5" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c2}
" ) != "v1" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
C1}
" ) != "v1" ) ;
assert ( esi_vars . getValue ( "HTTP_USER_AGENT" ) . size ( ) == 0 ) ;
assert ( esi_vars . getValue ( "BLAH" ) . size ( ) == 0 ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "example.com" ) ;
assert ( esi_vars . getValue ( "HTTP_host" ) == "example.com" ) ;
assert ( esi_vars . getValue ( "HTTP_REFERER" ) == "google.com" ) ;
assert ( esi_vars . getValue ( "HTTP_BLAH" ) . size ( ) == 0 ) ;
assert ( esi_vars . getValue ( "HTTP_ACCEPT_LANGUAGE{
en-gb}
" ) == "true" ) ;
assert ( esi_vars . getValue ( "HTTP_ACCEPT_LANGUAGE{
en-us}
" ) == "true" ) ;
assert ( esi_vars . getValue ( "HTTP_ACCEPT_LANGUAGE{
es-us}
" ) == "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "a=b&c=d&e=f" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "b" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
e}
" ) == "f" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
z}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIEc1" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIEc1}
" ) == "" ) ;
assert ( esi_vars . getValue ( "{
c1}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1{
c2}
}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1{
c2}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1c}
2}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1c2}
" ) == "" ) ;
assert ( esi_vars . getValue ( "{
c1c2}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1}
c" ) == "" ) ;
esi_vars . populate ( HttpHeader ( "hosT" , - 1 , "localhost" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "localhost" ) ;
esi_vars . populate ( HttpHeader ( "User-agent" , - 1 , "Mozilla/5.0 (Windows;
U;
Windows NT 5.1;
en-US;
rv:1.9.1.6) " "Gecko/20091201 Firefox/3.5.6 (.NETgecko CLR 3.5.30729)" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_ACCEPT_LANGUAGE{
ka-in}
" ) == "true" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1}
" ) == "" ) ;
esi_vars . populate ( headers ) ;
esi_vars . populate ( "a=b&c=d&e=f" ) ;
Expression esi_expr ( "vars_test" , & Debug , & Error , esi_vars ) ;
assert ( esi_expr . expand ( nullptr ) == "" ) ;
assert ( esi_expr . expand ( "" ) == "" ) ;
assert ( esi_expr . expand ( "blah" ) == "blah" ) ;
assert ( esi_expr . expand ( "blah$(HTTP_HOST" ) == "" ) ;
assert ( esi_expr . expand ( "blah$A(HTTP_HOST)" ) == "blah$A(HTTP_HOST)" ) ;
assert ( esi_expr . expand ( "blah$()" ) == "blah" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_HOST)" ) == "blah-example.com" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_REFERER)" ) == "blah-google.com" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_COOKIE{
c1}
)" ) == "blah-v1" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_COOKIE{
c1a}
)" ) == "blah-" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_COOKIE{
c1}
$(HTTP_HOST))" ) == "" ) ;
assert ( esi_expr . expand ( "blah-$(HTTP_COOKIE{
c1}
)-$(HTTP_HOST)" ) == "blah-v1-example.com" ) ;
assert ( esi_expr . expand ( "$()" ) == "" ) ;
assert ( esi_expr . expand ( "$(HTTP_COOKIE{
c1}
)$(HTTP_COOKIE{
c2}
)$(HTTP_HOST)" ) == "v1v2example.com" ) ;
assert ( esi_expr . expand ( "'blah" ) == "" ) ;
assert ( esi_expr . expand ( "\"blah" ) == "" ) ;
assert ( esi_expr . expand ( "'blah'" ) == "blah" ) ;
assert ( esi_expr . expand ( "\"blah\"" ) == "blah" ) ;
assert ( esi_expr . expand ( "'$(HTTP_COOKIE{
c1}
)'" ) == "v1" ) ;
assert ( esi_expr . expand ( "\"$(HTTP_HOST)\"" ) == "example.com" ) ;
assert ( esi_expr . expand ( " blah " ) == "blah" ) ;
assert ( esi_expr . expand ( " $(HTTP_REFERER) $(HTTP_HOST) " ) == "google.com example.com" ) ;
assert ( esi_expr . expand ( " ' foo ' " ) == " foo " ) ;
assert ( esi_expr . expand ( " ' foo '" ) == " foo " ) ;
assert ( esi_expr . expand ( "bar " ) == "bar" ) ;
assert ( esi_expr . evaluate ( "foo" ) == true ) ;
assert ( esi_expr . evaluate ( "" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_HOST)" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_XHOST)" ) == false ) ;
assert ( esi_expr . evaluate ( "foo == foo" ) == true ) ;
assert ( esi_expr . evaluate ( "'foo' == \"foo\"" ) == true ) ;
assert ( esi_expr . evaluate ( "foo == foo1" ) == false ) ;
assert ( esi_expr . evaluate ( "'foo' == \"foo1\"" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_REFERER) == google.com" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_HOST)=='example.com'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_REFERER) != google.com" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_HOST)!='example.com'" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_HOST) == 'facebook.com'" ) == false ) ;
assert ( esi_expr . evaluate ( "!" ) == true ) ;
assert ( esi_expr . evaluate ( "!abc" ) == false ) ;
assert ( esi_expr . evaluate ( "!$(FOO_BAR)" ) == true ) ;
assert ( esi_expr . evaluate ( "!$(HTTP_HOST)" ) == false ) ;
assert ( esi_expr . evaluate ( "abc!abc" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) == 'v1'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1b}
) == 'v1'" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) <= 'v2'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) < 'v2'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) >= 'v0'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) > 'v2'" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) & 'v2'" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
foo}
) & $(HTTP_COOKIE{
bar}
)" ) == false ) ;
assert ( esi_expr . evaluate ( "'' | $(HTTP_COOKIE{
c1}
)" ) == true ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
foo}
) | $(HTTP_COOKIE{
bar}
)" ) == false ) ;
assert ( esi_expr . expand ( "foo|bar" ) == "foo|bar" ) ;
assert ( esi_expr . expand ( "$(HTTP_HOST|" ) == "" ) ;
assert ( esi_expr . expand ( "$(HTTP_HOST|foo" ) == "" ) ;
assert ( esi_expr . expand ( "$(HTTP_HOST|foo)" ) == "example.com" ) ;
assert ( esi_expr . expand ( "$(HTTP_XHOST|foo)" ) == "foo" ) ;
assert ( esi_expr . expand ( "$(|foo)" ) == "foo" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-uk}
)" ) == "" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-uk}
|'yes')" ) == "yes" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-uk}
|'yes with space')" ) == "yes with space" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-gb}
|'yes')" ) == "true" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-gb}
|'yes)" ) == "" ) ;
assert ( esi_expr . expand ( "$(HTTP_ACCEPT_LANGUAGE{
en-uk}
|'yes)" ) == "" ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
non-existent}
) < 7" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) > $(HTTP_COOKIE{
non-existent}
)" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
non-existent}
) <= 7" ) == false ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) >= $(HTTP_COOKIE{
non-existent}
)" ) == false ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "a" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "a" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) . size ( ) == 0 ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) . size ( ) == 0 ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "a=b" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "a=b" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "b" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "a=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "a=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "b" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "&a=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "&a=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "b" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "name1=value1&name2=value2&name3=val%32ue" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "name1=value1&name2=value2&name3=val%32ue" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
name1}
" ) == "value1" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
name2}
" ) == "value2" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
name3}
" ) == "val%32ue" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
name4}
" ) == "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
}
" ) == "" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
foo}
" ) == "" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "=" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "=" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "a=&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "a=&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "=b&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
a}
" ) == "" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "foo=bar&blah=&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "foo=bar&blah=&" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
foo}
" ) == "bar" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
blah}
" ) == "" ) ;
esi_vars . clear ( ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) . size ( ) == 0 ) ;
esi_vars . populate ( "=blah&foo=bar" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING" ) == "=blah&foo=bar" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
foo}
" ) == "bar" ) ;
assert ( esi_vars . getValue ( "QUERY_STRING{
blah}
" ) == "" ) ;
}
{
cout << endl << "===================== Test 2" << endl ;
gFakeDebugLog . assign ( "" ) ;
Utils : : HeaderValueList whitelistCookies ;
Variables esi_vars ( "vars_test" , & fakeDebug , & Error , whitelistCookies ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "example.com" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Referer" , - 1 , "google.com" , - 1 ) ) ;
const char * PARSING_DEBUG_MESSAGE = "Parsing headers" ;
assert ( gFakeDebugLog . find ( PARSING_DEBUG_MESSAGE ) >= gFakeDebugLog . size ( ) ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "example.com" ) ;
size_t str_pos = gFakeDebugLog . find ( PARSING_DEBUG_MESSAGE ) ;
assert ( str_pos < gFakeDebugLog . size ( ) ) ;
assert ( esi_vars . getValue ( "HTTP_REFERER" ) == "google.com" ) ;
assert ( gFakeDebugLog . rfind ( PARSING_DEBUG_MESSAGE ) == str_pos ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "localhost" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "localhost" ) ;
assert ( gFakeDebugLog . rfind ( PARSING_DEBUG_MESSAGE ) == str_pos ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "localhost" ) ;
assert ( esi_vars . getValue ( "HTTP_REFERER" ) == "google.com" ) ;
esi_vars . clear ( ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "home" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "home" ) ;
assert ( gFakeDebugLog . rfind ( PARSING_DEBUG_MESSAGE ) != str_pos ) ;
assert ( esi_vars . getValue ( "HTTP_REFERER" ) == "" ) ;
}
{
cout << endl << "===================== Test 3" << endl ;
Utils : : HeaderValueList whitelistCookies ;
whitelistCookies . push_back ( "age" ) ;
whitelistCookies . push_back ( "grade" ) ;
whitelistCookies . push_back ( "avg" ) ;
whitelistCookies . push_back ( "t1" ) ;
whitelistCookies . push_back ( "t2" ) ;
whitelistCookies . push_back ( "t3" ) ;
whitelistCookies . push_back ( "t4" ) ;
whitelistCookies . push_back ( "t5" ) ;
whitelistCookies . push_back ( "c1" ) ;
Variables esi_vars ( "vars_test" , & Debug , & Error , whitelistCookies ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "example.com" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Referer" , - 1 , "google.com" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "age=21;
grade=-5;
avg=4.3;
t1=\" \";
t2=0.0" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "t3=-0;
t4=0;
t5=6" , - 1 ) ) ;
Expression esi_expr ( "vars_test" , & Debug , & Error , esi_vars ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
age}
) >= -9" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
age}
) > 9" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
age}
) < 22" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
age}
) <= 22.1" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
age}
) > 100a" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
t1}
)" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
grade}
)" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
grade}
) == -5" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
grade}
) != -5.1" ) ) ;
assert ( esi_expr . evaluate ( "!$(HTTP_COOKIE{
t2}
)" ) ) ;
assert ( esi_expr . evaluate ( "!$(HTTP_COOKIE{
t3}
)" ) ) ;
assert ( esi_expr . evaluate ( "!$(HTTP_COOKIE{
t4}
)" ) ) ;
assert ( esi_expr . evaluate ( "+4.3 == $(HTTP_COOKIE{
avg}
)" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
grade}
) < -0x2" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
t2}
) | 1" ) ) ;
assert ( ! esi_expr . evaluate ( "$(HTTP_COOKIE{
t3}
) & 1" ) ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
t5}
) == 6" ) ) ;
string strange_cookie ( "c1=123" ) ;
strange_cookie [ 4 ] = '\0' ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , strange_cookie . data ( ) , strange_cookie . size ( ) ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1}
" ) . size ( ) == 3 ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c1}
" ) [ 1 ] == '\0' ) ;
assert ( esi_expr . evaluate ( "$(HTTP_COOKIE{
c1}
) != 1" ) ) ;
}
{
cout << endl << "===================== Test 4" << endl ;
Utils : : HeaderValueList whitelistCookies ;
whitelistCookies . push_back ( "FPS" ) ;
whitelistCookies . push_back ( "mb" ) ;
whitelistCookies . push_back ( "Y" ) ;
whitelistCookies . push_back ( "C" ) ;
whitelistCookies . push_back ( "F" ) ;
whitelistCookies . push_back ( "a" ) ;
whitelistCookies . push_back ( "c" ) ;
Variables esi_vars ( "vars_test" , & Debug , & Error , whitelistCookies ) ;
string cookie_str ( "FPS=dl;
mb=d=OPsv7rvU4FFaAOoIRi75BBuqdMdbMLFuDwQmk6nKrCgno7L4xuN44zm7QBQJRmQSh8ken6GSVk8-&v=1;
C=mg=1;
" "Y=v=1&n=fmaptagvuff50&l=fc0d94i7/o&p=m2f0000313000400&r=8j&lg=en-US&intl=us;
" "F=a=4KvLV9IMvTJnIAqCk25y9Use6hnPALtUf3n78PihlcIqvmzoW.Ax8UyW8_oxtgFNrrdmooqZmPa7WsX4gE." "6sI69wuNwRKrRPFT29h9lhwuxxLz0RuQedVXhJhc323Q-&b=8gQZ" ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , cookie_str . data ( ) , cookie_str . size ( ) ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
FPS}
" ) == "dl" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
mb}
" ) == "d=OPsv7rvU4FFaAOoIRi75BBuqdMdbMLFuDwQmk6nKrCgno7L4xuN44zm7QBQJRmQSh8ken6GSVk8-&v=1" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
n}
" ) == "fmaptagvuff50" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
l}
" ) == "fc0d94i7/o" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
intl}
" ) == "us" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
C}
" ) == "mg=1" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
non-existent}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y}
" ) == "v=1&n=fmaptagvuff50&l=fc0d94i7/o&p=m2f0000313000400&r=8j&lg=en-US&intl=us" ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "www.example.com" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
F}
" ) == "a=4KvLV9IMvTJnIAqCk25y9Use6hnPALtUf3n78PihlcIqvmzoW." "Ax8UyW8_oxtgFNrrdmooqZmPa7WsX4gE.6sI69wuNwRKrRPFT29h9lhwuxxLz0RuQedVXhJhc323Q-&b=8gQZ" ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "www.example.com" ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "a=b;
c=d" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
intl}
" ) == "us" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
F}
" ) == "a=4KvLV9IMvTJnIAqCk25y9Use6hnPALtUf3n78PihlcIqvmzoW." "Ax8UyW8_oxtgFNrrdmooqZmPa7WsX4gE.6sI69wuNwRKrRPFT29h9lhwuxxLz0RuQedVXhJhc323Q-&b=8gQZ" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
a}
" ) == "b" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
c}
" ) == "d" ) ;
assert ( esi_vars . getValue ( "HTTP_HOST" ) == "www.example.com" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
blah}
" ) == "" ) ;
esi_vars . clear ( ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "Y=junk" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y}
" ) == "junk" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
Y;
intl}
" ) == "" ) ;
}
{
cout << endl << "===================== Test 5" << endl ;
Utils : : HeaderValueList whitelistCookies ;
Variables esi_vars ( "vars_test" , & Debug , & Error , whitelistCookies ) ;
esi_vars . populate ( HttpHeader ( "hdr1" , - 1 , "hval1" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Hdr2" , - 1 , "hval2" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "@Intenal-hdr1" , - 1 , "internal-hval1" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_HEADER{
hdr1}
" ) == "hval1" ) ;
assert ( esi_vars . getValue ( "HTTP_HEADER{
hdr2}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_HEADER{
Hdr2}
" ) == "hval2" ) ;
assert ( esi_vars . getValue ( "HTTP_HEADER{
non-existent}
" ) == "" ) ;
assert ( esi_vars . getValue ( "HTTP_HEADER{
@Intenal-hdr1}
" ) == "internal-hval1" ) ;
}
{
cout << endl << "===================== Test 6" << endl ;
Utils : : HeaderValueList whitelistCookies ;
whitelistCookies . push_back ( "*" ) ;
Variables esi_vars ( "vars_test" , & Debug , & Error , whitelistCookies ) ;
esi_vars . populate ( HttpHeader ( "Host" , - 1 , "example.com" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "age=21;
grade=-5;
avg=4.3;
t1=\" \";
t2=0.0" , - 1 ) ) ;
esi_vars . populate ( HttpHeader ( "Cookie" , - 1 , "t3=-0;
t4=0;
t5=6" , - 1 ) ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
age}
" ) == "21" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
grade}
" ) == "-5" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
avg}
" ) == "4.3" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
t1}
" ) == " " ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
t2}
" ) == "0.0" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
t3}
" ) == "-0" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
t4}
" ) == "0" ) ;
assert ( esi_vars . getValue ( "HTTP_COOKIE{
t5}
" ) == "6" ) ;
}
cout << endl << "All tests passed!" << endl ;
return 0 ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
gcry_err_code_t _gcry_pubkey_get_sexp ( gcry_sexp_t * r_sexp , int mode , gcry_ctx_t ctx ) {
mpi_ec_t ec ;
if ( ! r_sexp ) return GPG_ERR_INV_VALUE ;
* r_sexp = NULL ;
switch ( mode ) {
case 0 : case GCRY_PK_GET_PUBKEY : case GCRY_PK_GET_SECKEY : break ;
default : return GPG_ERR_INV_VALUE ;
}
if ( ! ctx ) return GPG_ERR_NO_CRYPT_CTX ;
ec = _gcry_ctx_find_pointer ( ctx , CONTEXT_TYPE_EC ) ;
if ( ec ) return _gcry_pk_ecc_get_sexp ( r_sexp , mode , ec ) ;
return GPG_ERR_WRONG_CRYPT_CTX ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint8_t * dst , ptrdiff_t stride , const uint8_t * above , const uint8_t * left ) {
type ## _predictor ( dst , stride , size , above , left ) ;
}
# define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) static INLINE void d207_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) above ;
for ( r = 0 ;
r < bs - 1 ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( r = 0 ;
r < bs - 2 ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;
dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;
for ( r = bs - 2 ;
r >= 0 ;
-- r ) for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;
}
intra_pred_allsizes ( d207 ) static INLINE void d63_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) left ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] * 2 + above [ r / 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] , 1 ) ;
dst += stride ;
}
}
intra_pred_allsizes ( d63 ) static INLINE void d45_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) left ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d45 ) static INLINE void d117_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 3 ;
r < bs ;
++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d117 ) static INLINE void d135_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d135 ) static INLINE void d153_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;
for ( r = 1 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;
dst ++ ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d153 ) static INLINE void v_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) left ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memcpy ( dst , above , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( v ) static INLINE void h_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) above ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , left [ r ] , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( h ) static INLINE void tm_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
int ytop_left = above [ - 1 ] ;
for ( r = 0 ;
r < bs ;
r ++ ) {
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = clip_pixel ( left [ r ] + above [ c ] - ytop_left ) ;
dst += stride ;
}
}
intra_pred_allsizes ( tm ) static INLINE void dc_128_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) above ;
( void ) left ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , 128 , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc_128 ) static INLINE void dc_left_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int i , r , expected_dc , sum = 0 ;
( void ) above ;
for ( i = 0 ;
i < bs ;
i ++ ) sum += left [ i ] ;
expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc_left ) static INLINE void dc_top_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int i , r , expected_dc , sum = 0 ;
( void ) left ;
for ( i = 0 ;
i < bs ;
i ++ ) sum += above [ i ] ;
expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc_top ) static INLINE void dc_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int i , r , expected_dc , sum = 0 ;
const int count = 2 * bs ;
for ( i = 0 ;
i < bs ;
i ++ ) {
sum += above [ i ] ;
sum += left [ i ] ;
}
expected_dc = ( sum + ( count >> 1 ) ) / count ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc )
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void predict_and_reconstruct_intra_block ( int plane , int block , BLOCK_SIZE plane_bsize , TX_SIZE tx_size , void * arg ) {
struct intra_args * const args = ( struct intra_args * ) arg ;
VP9_COMMON * const cm = args -> cm ;
MACROBLOCKD * const xd = args -> xd ;
struct macroblockd_plane * const pd = & xd -> plane [ plane ] ;
MODE_INFO * const mi = xd -> mi [ 0 ] ;
const PREDICTION_MODE mode = ( plane == 0 ) ? get_y_mode ( mi , block ) : mi -> mbmi . uv_mode ;
int x , y ;
uint8_t * dst ;
txfrm_block_to_raster_xy ( plane_bsize , tx_size , block , & x , & y ) ;
dst = & pd -> dst . buf [ 4 * y * pd -> dst . stride + 4 * x ] ;
vp9_predict_intra_block ( xd , block >> ( tx_size << 1 ) , b_width_log2 ( plane_bsize ) , tx_size , mode , dst , pd -> dst . stride , dst , pd -> dst . stride , x , y , plane ) ;
if ( ! mi -> mbmi . skip ) {
const int eob = vp9_decode_block_tokens ( cm , xd , plane , block , plane_bsize , x , y , tx_size , args -> r ) ;
inverse_transform_block ( xd , plane , block , tx_size , dst , pd -> dst . stride , eob ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void vvalue_strbuf_append_blob ( wmem_strbuf_t * strbuf , void * ptr ) {
struct data_blob * blob = ( struct data_blob * ) ptr ;
wmem_strbuf_append_printf ( strbuf , "size: %d" , ( int ) blob -> size ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static FT_Error cid_parse_dict ( CID_Face face , CID_Loader * loader , FT_Byte * base , FT_Long size ) {
CID_Parser * parser = & loader -> parser ;
parser -> root . cursor = base ;
parser -> root . limit = base + size ;
parser -> root . error = FT_Err_Ok ;
{
FT_Byte * cur = base ;
FT_Byte * limit = cur + size ;
for ( ;
;
) {
FT_Byte * newlimit ;
parser -> root . cursor = cur ;
cid_parser_skip_spaces ( parser ) ;
if ( parser -> root . cursor >= limit ) newlimit = limit - 1 - 17 ;
else newlimit = parser -> root . cursor - 17 ;
for ( ;
cur < newlimit ;
cur ++ ) {
if ( * cur == '%' && ft_strncmp ( ( char * ) cur , "%ADOBeginFontDict" , 17 ) == 0 ) {
if ( face -> cid . num_dicts > 0 ) parser -> num_dict ++ ;
}
}
cur = parser -> root . cursor ;
if ( cur >= limit ) break ;
cid_parser_skip_PS_token ( parser ) ;
if ( parser -> root . cursor >= limit || parser -> root . error ) break ;
if ( * cur == '/' && cur + 2 < limit ) {
FT_PtrDist len ;
cur ++ ;
len = parser -> root . cursor - cur ;
if ( len > 0 && len < 22 ) {
T1_Field keyword = ( T1_Field ) cid_field_records ;
for ( ;
;
) {
FT_Byte * name ;
name = ( FT_Byte * ) keyword -> ident ;
if ( ! name ) break ;
if ( cur [ 0 ] == name [ 0 ] && len == ( FT_PtrDist ) ft_strlen ( ( const char * ) name ) ) {
FT_PtrDist n ;
for ( n = 1 ;
n < len ;
n ++ ) if ( cur [ n ] != name [ n ] ) break ;
if ( n >= len ) {
parser -> root . error = cid_load_keyword ( face , loader , keyword ) ;
if ( parser -> root . error ) return parser -> root . error ;
break ;
}
}
keyword ++ ;
}
}
}
cur = parser -> root . cursor ;
}
}
return parser -> root . error ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_T_adaptationLayerType ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_T_adaptationLayerType , T_adaptationLayerType_choice , NULL ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void dtap_tp_gprs_test_mode_cmd ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_len = len ;
curr_offset = offset ;
ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_TP_PDU_DESCRIPTION , NULL ) ;
ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_TP_MODE_FLAG , NULL ) ;
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_dtap_extraneous_data ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_F ( LocalNTPOneGoogleBarSmokeTest , NTPLoadsWithOneGoogleBar ) {
OneGoogleBarData data ;
data . bar_html = "<div id='thebar'></div>" ;
data . in_head_script = "window.inHeadRan = true;
" ;
data . after_bar_script = "window.afterBarRan = true;
" ;
data . end_of_body_script = "console.log('ogb-done');
" ;
one_google_bar_fetcher ( ) -> set_one_google_bar_data ( data ) ;
content : : WebContents * active_tab = local_ntp_test_utils : : OpenNewTab ( browser ( ) , GURL ( "about:blank" ) ) ;
ASSERT_FALSE ( search : : IsInstantNTP ( active_tab ) ) ;
content : : ConsoleObserverDelegate console_observer ( active_tab , "ogb-done" ) ;
active_tab -> SetDelegate ( & console_observer ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , GURL ( chrome : : kChromeUINewTabURL ) ) ;
ASSERT_TRUE ( search : : IsInstantNTP ( active_tab ) ) ;
ASSERT_EQ ( GURL ( chrome : : kChromeSearchLocalNtpUrl ) , active_tab -> GetController ( ) . GetVisibleEntry ( ) -> GetURL ( ) ) ;
console_observer . Wait ( ) ;
EXPECT_EQ ( "ogb-done" , console_observer . message ( ) ) ;
bool in_head_ran = false ;
ASSERT_TRUE ( instant_test_utils : : GetBoolFromJS ( active_tab , "!!window.inHeadRan" , & in_head_ran ) ) ;
EXPECT_TRUE ( in_head_ran ) ;
bool after_bar_ran = false ;
ASSERT_TRUE ( instant_test_utils : : GetBoolFromJS ( active_tab , "!!window.afterBarRan" , & after_bar_ran ) ) ;
EXPECT_TRUE ( after_bar_ran ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void evhttp_clear_headers ( struct evkeyvalq * headers ) {
struct evkeyval * header ;
for ( header = TAILQ_FIRST ( headers ) ;
header != NULL ;
header = TAILQ_FIRST ( headers ) ) {
TAILQ_REMOVE ( headers , header , next ) ;
free ( header -> key ) ;
free ( header -> value ) ;
free ( header ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void debugCB_fromU ( const void * context , UConverterFromUnicodeArgs * fromUArgs , const UChar * codeUnits , int32_t length , UChar32 codePoint , UConverterCallbackReason reason , UErrorCode * err ) {
debugCBContext * ctx = ( debugCBContext * ) context ;
# if DEBUG_TMI printf ( "debugCB_fromU: Context %p:%d called, reason %d on cnv %p [err=%s]\n" , ctx , ctx -> serial , reason , fromUArgs -> converter , u_errorName ( * err ) ) ;
# endif if ( ctx -> magic != 0xC0FFEE ) {
fprintf ( stderr , "debugCB_fromU: Context %p:%d magic is 0x%x should be 0xC0FFEE.\n" , ctx , ctx -> serial , ctx -> magic ) ;
return ;
}
if ( reason == UCNV_CLONE ) {
UConverterFromUCallback saveCallback ;
const void * saveContext ;
debugCBContext * cloned ;
UErrorCode subErr = U_ZERO_ERROR ;
# if DEBUG_TMI printf ( "debugCB_fromU: cloning..\n" ) ;
# endif cloned = debugCB_clone ( ctx ) ;
if ( cloned == NULL ) {
fprintf ( stderr , "debugCB_fromU: internal clone failed on %p\n" , ctx ) ;
* err = U_MEMORY_ALLOCATION_ERROR ;
return ;
}
ucnv_setFromUCallBack ( fromUArgs -> converter , cloned -> subCallback , cloned -> subContext , & saveCallback , & saveContext , & subErr ) ;
if ( cloned -> subCallback != NULL ) {
# if DEBUG_TMI printf ( "debugCB_fromU:%p calling subCB %p\n" , ctx , cloned -> subCallback ) ;
# endif cloned -> subCallback ( cloned -> subContext , fromUArgs , codeUnits , length , codePoint , reason , err ) ;
}
else {
printf ( "debugCB_fromU:%p, NOT calling subCB, it's NULL\n" , ctx ) ;
}
ucnv_setFromUCallBack ( fromUArgs -> converter , saveCallback , cloned , & cloned -> subCallback , & cloned -> subContext , & subErr ) ;
if ( U_FAILURE ( subErr ) ) {
* err = subErr ;
}
}
if ( ctx -> subCallback != NULL && reason != UCNV_CLONE ) {
ctx -> subCallback ( ctx -> subContext , fromUArgs , codeUnits , length , codePoint , reason , err ) ;
}
if ( reason == UCNV_CLOSE ) {
# if DEBUG_TMI printf ( "debugCB_fromU: Context %p:%d closing\n" , ctx , ctx -> serial ) ;
# endif free ( ctx ) ;
}
# if DEBUG_TMI printf ( "debugCB_fromU: leaving cnv %p, ctx %p: err %s\n" , fromUArgs -> converter , ctx , u_errorName ( * err ) ) ;
# endif }
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_T_port ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 0U , 65535U , & ip_port , FALSE ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int jbig2_error ( Jbig2Ctx * ctx , Jbig2Severity severity , int32_t segment_number , const char * fmt , ... ) {
char buf [ 1024 ] ;
va_list ap ;
int n ;
int code ;
va_start ( ap , fmt ) ;
n = vsnprintf ( buf , sizeof ( buf ) , fmt , ap ) ;
va_end ( ap ) ;
if ( n < 0 || n == sizeof ( buf ) ) strncpy ( buf , "jbig2_error: error in generating error string" , sizeof ( buf ) ) ;
code = ctx -> error_callback ( ctx -> error_callback_data , buf , severity , segment_number ) ;
if ( severity == JBIG2_SEVERITY_FATAL ) code = - 1 ;
return code ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int zmbv_decode_intra ( ZmbvContext * c ) {
uint8_t * src = c -> decomp_buf ;
if ( c -> fmt == ZMBV_FMT_8BPP ) {
memcpy ( c -> pal , src , 768 ) ;
src += 768 ;
}
memcpy ( c -> cur , src , c -> width * c -> height * ( c -> bpp / 8 ) ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int gs_main_run_string_end ( gs_main_instance * minst , int user_errors , int * pexit_code , ref * perror_object ) {
ref rstr ;
make_empty_const_string ( & rstr , avm_foreign | a_readonly ) ;
return gs_main_interpret ( minst , & rstr , user_errors , pexit_code , perror_object ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline void decode_dc_coeffs ( GetBitContext * gb , int16_t * out , int nblocks ) {
int16_t prev_dc ;
int i , sign ;
int16_t delta ;
unsigned int code ;
code = decode_vlc_codeword ( gb , FIRST_DC_CB ) ;
out [ 0 ] = prev_dc = TOSIGNED ( code ) ;
out += 64 ;
delta = 3 ;
for ( i = 1 ;
i < nblocks ;
i ++ , out += 64 ) {
code = decode_vlc_codeword ( gb , ff_prores_dc_codebook [ FFMIN ( FFABS ( delta ) , 3 ) ] ) ;
sign = - ( ( ( delta >> 15 ) & 1 ) ^ ( code & 1 ) ) ;
delta = ( ( ( code + 1 ) >> 1 ) ^ sign ) - sign ;
prev_dc += delta ;
out [ 0 ] = prev_dc ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void dissect_rsvp_restart_cap ( proto_tree * ti , proto_tree * rsvp_object_tree , tvbuff_t * tvb , int offset , int obj_length , int rsvp_class _U_ , int type ) {
int offset2 = offset + 4 ;
guint restart , recovery ;
proto_item_set_text ( ti , "RESTART CAPABILITY: " ) ;
switch ( type ) {
case 1 : proto_tree_add_uint ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type ) ;
restart = tvb_get_ntohl ( tvb , offset2 ) ;
proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_restart_cap_restart_time , tvb , offset2 , 4 , restart , "%d ms" , restart ) ;
recovery = tvb_get_ntohl ( tvb , offset2 + 4 ) ;
proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_restart_cap_recovery_time , tvb , offset2 + 4 , 4 , recovery , "%d ms" , recovery ) ;
proto_item_append_text ( ti , "Restart Time: %d ms. Recovery Time: %d ms." , restart , recovery ) ;
break ;
default : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , "Unknown (%u)" , type ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_restart_cap_data , tvb , offset2 , obj_length - 4 , ENC_NA ) ;
break ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int find_best_16x16_intra ( VP9_COMP * cpi , PREDICTION_MODE * pbest_mode ) {
MACROBLOCK * const x = & cpi -> mb ;
MACROBLOCKD * const xd = & x -> e_mbd ;
PREDICTION_MODE best_mode = - 1 , mode ;
unsigned int best_err = INT_MAX ;
for ( mode = DC_PRED ;
mode <= TM_PRED ;
mode ++ ) {
unsigned int err ;
xd -> mi [ 0 ] -> mbmi . mode = mode ;
vp9_predict_intra_block ( xd , 0 , 2 , TX_16X16 , mode , x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , xd -> plane [ 0 ] . dst . buf , xd -> plane [ 0 ] . dst . stride , 0 , 0 , 0 ) ;
err = vp9_sad16x16 ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , xd -> plane [ 0 ] . dst . buf , xd -> plane [ 0 ] . dst . stride ) ;
if ( err < best_err ) {
best_err = err ;
best_mode = mode ;
}
}
if ( pbest_mode ) * pbest_mode = best_mode ;
return best_err ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static char * memdup ( const char * src , size_t buffer_length ) {
size_t length ;
bool add = FALSE ;
char * buffer ;
if ( buffer_length ) length = buffer_length ;
else if ( src ) {
length = strlen ( src ) ;
add = TRUE ;
}
else return strdup ( "" ) ;
buffer = malloc ( length + add ) ;
if ( ! buffer ) return NULL ;
memcpy ( buffer , src , length ) ;
if ( add ) buffer [ length ] = '\0' ;
return buffer ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int CreateOK ( struct ubik_trans * ut , afs_int32 cid , afs_int32 oid , afs_int32 flag , int admin ) {
if ( restricted && ! admin ) return 0 ;
if ( flag & PRFOREIGN ) {
return 0 ;
}
else if ( flag & PRGRP ) {
if ( cid == ANONYMOUSID ) {
if ( ( oid == 0 ) || ! pr_noAuth ) return 0 ;
}
}
else {
if ( ! admin && ! pr_noAuth ) return 0 ;
}
return 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static PyObject * string_rsplit ( PyStringObject * self , PyObject * args ) {
Py_ssize_t len = PyString_GET_SIZE ( self ) , n ;
Py_ssize_t maxsplit = - 1 ;
const char * s = PyString_AS_STRING ( self ) , * sub ;
PyObject * subobj = Py_None ;
if ( ! PyArg_ParseTuple ( args , "|On:rsplit" , & subobj , & maxsplit ) ) return NULL ;
if ( maxsplit < 0 ) maxsplit = PY_SSIZE_T_MAX ;
if ( subobj == Py_None ) return stringlib_rsplit_whitespace ( ( PyObject * ) self , s , len , maxsplit ) ;
if ( PyString_Check ( subobj ) ) {
sub = PyString_AS_STRING ( subobj ) ;
n = PyString_GET_SIZE ( subobj ) ;
}
# ifdef Py_USING_UNICODE else if ( PyUnicode_Check ( subobj ) ) return PyUnicode_RSplit ( ( PyObject * ) self , subobj , maxsplit ) ;
# endif else if ( PyObject_AsCharBuffer ( subobj , & sub , & n ) ) return NULL ;
return stringlib_rsplit ( ( PyObject * ) self , s , len , sub , n , maxsplit ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
ptvcursor_t * ptvcursor_new ( proto_tree * tree , tvbuff_t * tvb , gint offset ) {
ptvcursor_t * ptvc ;
ptvc = ( ptvcursor_t * ) wmem_alloc ( wmem_packet_scope ( ) , sizeof ( ptvcursor_t ) ) ;
ptvc -> tree = tree ;
ptvc -> tvb = tvb ;
ptvc -> offset = offset ;
ptvc -> pushed_tree = NULL ;
ptvc -> pushed_tree_max = 0 ;
ptvc -> pushed_tree_index = 0 ;
return ptvc ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
SPL_METHOD ( DirectoryIterator , isDot ) {
spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
if ( zend_parse_parameters_none ( ) == FAILURE ) {
return ;
}
RETURN_BOOL ( spl_filesystem_is_dot ( intern -> u . dir . entry . d_name ) ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int sendpkt ( void * xdata , size_t xdatalen ) {
if ( debug >= 3 ) printf ( "Sending %zu octets\n" , xdatalen ) ;
if ( send ( sockfd , xdata , ( size_t ) xdatalen , 0 ) == - 1 ) {
warning ( "write to %s failed" , currenthost ) ;
return - 1 ;
}
if ( debug >= 4 ) {
printf ( "Request packet:\n" ) ;
dump_hex_printable ( xdata , xdatalen ) ;
}
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
proto_item * proto_tree_add_int ( proto_tree * tree , int hfindex , tvbuff_t * tvb , gint start , gint length , gint32 value ) {
proto_item * pi = NULL ;
header_field_info * hfinfo ;
CHECK_FOR_NULL_TREE ( tree ) ;
TRY_TO_FAKE_THIS_ITEM ( tree , hfindex , hfinfo ) ;
switch ( hfinfo -> type ) {
case FT_INT8 : case FT_INT16 : case FT_INT24 : case FT_INT32 : pi = proto_tree_add_pi ( tree , hfinfo , tvb , start , & length ) ;
proto_tree_set_int ( PNODE_FINFO ( pi ) , value ) ;
break ;
default : DISSECTOR_ASSERT_NOT_REACHED ( ) ;
}
return pi ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void kvm_msr_entry_add ( X86CPU * cpu , uint32_t index , uint64_t value ) {
struct kvm_msrs * msrs = cpu -> kvm_msr_buf ;
void * limit = ( ( void * ) msrs ) + MSR_BUF_SIZE ;
struct kvm_msr_entry * entry = & msrs -> entries [ msrs -> nmsrs ] ;
assert ( ( void * ) ( entry + 1 ) <= limit ) ;
entry -> index = index ;
entry -> reserved = 0 ;
entry -> data = value ;
msrs -> nmsrs ++ ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void data_destroy_arabic ( void * data ) {
arabic_shape_plan_t * arabic_plan = ( arabic_shape_plan_t * ) data ;
arabic_fallback_plan_destroy ( arabic_plan -> fallback_plan ) ;
free ( data ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static char * Tag2String ( uint32 tag ) {
static char buffer [ 8 ] ;
buffer [ 0 ] = tag >> 24 ;
buffer [ 1 ] = tag >> 16 ;
buffer [ 2 ] = tag >> 8 ;
buffer [ 3 ] = tag ;
buffer [ 4 ] = 0 ;
return ( buffer ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void check_reset_of_active_ep ( struct usb_device * udev , unsigned int epnum , char * ioctl_name ) {
struct usb_host_endpoint * * eps ;
struct usb_host_endpoint * ep ;
eps = ( epnum & USB_DIR_IN ) ? udev -> ep_in : udev -> ep_out ;
ep = eps [ epnum & 0x0f ] ;
if ( ep && ! list_empty ( & ep -> urb_list ) ) dev_warn ( & udev -> dev , "Process %d (%s) called USBDEVFS_%s for active endpoint 0x%02x\n" , task_pid_nr ( current ) , current -> comm , ioctl_name , epnum ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static char * fstrndup ( const char * ptr , unsigned long len ) {
char * result ;
if ( len <= 0 ) return NULL ;
result = ALLOC_N ( char , len ) ;
memcpy ( result , ptr , len ) ;
return result ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void bitmap_writer_build_type_index ( struct pack_idx_entry * * index , uint32_t index_nr ) {
uint32_t i ;
writer . commits = ewah_new ( ) ;
writer . trees = ewah_new ( ) ;
writer . blobs = ewah_new ( ) ;
writer . tags = ewah_new ( ) ;
for ( i = 0 ;
i < index_nr ;
++ i ) {
struct object_entry * entry = ( struct object_entry * ) index [ i ] ;
enum object_type real_type ;
entry -> in_pack_pos = i ;
switch ( entry -> type ) {
case OBJ_COMMIT : case OBJ_TREE : case OBJ_BLOB : case OBJ_TAG : real_type = entry -> type ;
break ;
default : real_type = sha1_object_info ( entry -> idx . sha1 , NULL ) ;
break ;
}
switch ( real_type ) {
case OBJ_COMMIT : ewah_set ( writer . commits , i ) ;
break ;
case OBJ_TREE : ewah_set ( writer . trees , i ) ;
break ;
case OBJ_BLOB : ewah_set ( writer . blobs , i ) ;
break ;
case OBJ_TAG : ewah_set ( writer . tags , i ) ;
break ;
default : die ( "Missing type information for %s (%d/%d)" , sha1_to_hex ( entry -> idx . sha1 ) , real_type , entry -> type ) ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static CURLcode glob_range ( URLGlob * glob , char * * patternp , size_t * posp , unsigned long * amount , int globindex ) {
URLPattern * pat ;
int rc ;
char * pattern = * patternp ;
char * c ;
pat = & glob -> pattern [ glob -> size ] ;
pat -> globindex = globindex ;
if ( ISALPHA ( * pattern ) ) {
char min_c ;
char max_c ;
int step = 1 ;
pat -> type = UPTCharRange ;
rc = sscanf ( pattern , "%c-%c" , & min_c , & max_c ) ;
if ( ( rc == 2 ) && ( pattern [ 3 ] == ':' ) ) {
char * endp ;
unsigned long lstep ;
errno = 0 ;
lstep = strtoul ( & pattern [ 4 ] , & endp , 10 ) ;
if ( errno || ( * endp != ']' ) ) step = - 1 ;
else {
pattern = endp + 1 ;
step = ( int ) lstep ;
if ( step > ( max_c - min_c ) ) step = - 1 ;
}
}
else pattern += 4 ;
* posp += ( pattern - * patternp ) ;
if ( ( rc != 2 ) || ( min_c >= max_c ) || ( ( max_c - min_c ) > ( 'z' - 'a' ) ) || ( step <= 0 ) ) return GLOBERROR ( "bad range" , * posp , CURLE_URL_MALFORMAT ) ;
pat -> content . CharRange . step = step ;
pat -> content . CharRange . ptr_c = pat -> content . CharRange . min_c = min_c ;
pat -> content . CharRange . max_c = max_c ;
if ( multiply ( amount , ( pat -> content . CharRange . max_c - pat -> content . CharRange . min_c ) / pat -> content . CharRange . step + 1 ) ) return GLOBERROR ( "range overflow" , * posp , CURLE_URL_MALFORMAT ) ;
}
else if ( ISDIGIT ( * pattern ) ) {
unsigned long min_n ;
unsigned long max_n = 0 ;
unsigned long step_n = 0 ;
char * endp ;
pat -> type = UPTNumRange ;
pat -> content . NumRange . padlength = 0 ;
if ( * pattern == '0' ) {
c = pattern ;
while ( ISDIGIT ( * c ) ) {
c ++ ;
++ pat -> content . NumRange . padlength ;
}
}
errno = 0 ;
min_n = strtoul ( pattern , & endp , 10 ) ;
if ( errno || ( endp == pattern ) ) endp = NULL ;
else {
if ( * endp != '-' ) endp = NULL ;
else {
pattern = endp + 1 ;
errno = 0 ;
max_n = strtoul ( pattern , & endp , 10 ) ;
if ( errno || ( * endp == ':' ) ) {
pattern = endp + 1 ;
errno = 0 ;
step_n = strtoul ( pattern , & endp , 10 ) ;
if ( errno ) endp = NULL ;
}
else step_n = 1 ;
if ( endp && ( * endp == ']' ) ) {
pattern = endp + 1 ;
}
else endp = NULL ;
}
}
* posp += ( pattern - * patternp ) ;
if ( ! endp || ( min_n > max_n ) || ( step_n > ( max_n - min_n ) ) || ! step_n ) return GLOBERROR ( "bad range" , * posp , CURLE_URL_MALFORMAT ) ;
pat -> content . NumRange . ptr_n = pat -> content . NumRange . min_n = min_n ;
pat -> content . NumRange . max_n = max_n ;
pat -> content . NumRange . step = step_n ;
if ( multiply ( amount , ( pat -> content . NumRange . max_n - pat -> content . NumRange . min_n ) / pat -> content . NumRange . step + 1 ) ) return GLOBERROR ( "range overflow" , * posp , CURLE_URL_MALFORMAT ) ;
}
else return GLOBERROR ( "bad range specification" , * posp , CURLE_URL_MALFORMAT ) ;
* patternp = pattern ;
return CURLE_OK ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void dissect_zcl_appl_ctrl_exec_cmd ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {
proto_tree_add_item ( tree , hf_zbee_zcl_appl_ctrl_exec_cmd_id , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TSReturnCode TSMimeHdrFieldValueInt64Set ( TSMBuffer bufp , TSMLoc hdr , TSMLoc field , int idx , int64_t value ) {
sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
sdk_assert ( ( sdk_sanity_check_mime_hdr_handle ( hdr ) == TS_SUCCESS ) || ( sdk_sanity_check_http_hdr_handle ( hdr ) == TS_SUCCESS ) ) ;
sdk_assert ( sdk_sanity_check_field_handle ( field , hdr ) == TS_SUCCESS ) ;
if ( ! isWriteable ( bufp ) ) {
return TS_ERROR ;
}
char tmp [ 20 ] ;
int len = mime_format_int64 ( tmp , value , sizeof ( tmp ) ) ;
TSMimeFieldValueSet ( bufp , field , idx , tmp , len ) ;
return TS_SUCCESS ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int SpoolssWritePrinter_r ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep ) {
guint32 size ;
offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_writeprinter_numwritten , & size ) ;
col_append_fstr ( pinfo -> cinfo , COL_INFO , ", %d bytes written" , size ) ;
offset = dissect_doserror ( tvb , offset , pinfo , tree , di , drep , hf_rc , NULL ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_fdct16x16_c ( const int16_t * input , int16_t * output , int stride ) {
int pass ;
int16_t intermediate [ 256 ] ;
const int16_t * in = input ;
int16_t * out = intermediate ;
for ( pass = 0 ;
pass < 2 ;
++ pass ) {
int step1 [ 8 ] ;
int step2 [ 8 ] ;
int step3 [ 8 ] ;
int input [ 8 ] ;
int temp1 , temp2 ;
int i ;
for ( i = 0 ;
i < 16 ;
i ++ ) {
if ( 0 == pass ) {
input [ 0 ] = ( in [ 0 * stride ] + in [ 15 * stride ] ) * 4 ;
input [ 1 ] = ( in [ 1 * stride ] + in [ 14 * stride ] ) * 4 ;
input [ 2 ] = ( in [ 2 * stride ] + in [ 13 * stride ] ) * 4 ;
input [ 3 ] = ( in [ 3 * stride ] + in [ 12 * stride ] ) * 4 ;
input [ 4 ] = ( in [ 4 * stride ] + in [ 11 * stride ] ) * 4 ;
input [ 5 ] = ( in [ 5 * stride ] + in [ 10 * stride ] ) * 4 ;
input [ 6 ] = ( in [ 6 * stride ] + in [ 9 * stride ] ) * 4 ;
input [ 7 ] = ( in [ 7 * stride ] + in [ 8 * stride ] ) * 4 ;
step1 [ 0 ] = ( in [ 7 * stride ] - in [ 8 * stride ] ) * 4 ;
step1 [ 1 ] = ( in [ 6 * stride ] - in [ 9 * stride ] ) * 4 ;
step1 [ 2 ] = ( in [ 5 * stride ] - in [ 10 * stride ] ) * 4 ;
step1 [ 3 ] = ( in [ 4 * stride ] - in [ 11 * stride ] ) * 4 ;
step1 [ 4 ] = ( in [ 3 * stride ] - in [ 12 * stride ] ) * 4 ;
step1 [ 5 ] = ( in [ 2 * stride ] - in [ 13 * stride ] ) * 4 ;
step1 [ 6 ] = ( in [ 1 * stride ] - in [ 14 * stride ] ) * 4 ;
step1 [ 7 ] = ( in [ 0 * stride ] - in [ 15 * stride ] ) * 4 ;
}
else {
input [ 0 ] = ( ( in [ 0 * 16 ] + 1 ) >> 2 ) + ( ( in [ 15 * 16 ] + 1 ) >> 2 ) ;
input [ 1 ] = ( ( in [ 1 * 16 ] + 1 ) >> 2 ) + ( ( in [ 14 * 16 ] + 1 ) >> 2 ) ;
input [ 2 ] = ( ( in [ 2 * 16 ] + 1 ) >> 2 ) + ( ( in [ 13 * 16 ] + 1 ) >> 2 ) ;
input [ 3 ] = ( ( in [ 3 * 16 ] + 1 ) >> 2 ) + ( ( in [ 12 * 16 ] + 1 ) >> 2 ) ;
input [ 4 ] = ( ( in [ 4 * 16 ] + 1 ) >> 2 ) + ( ( in [ 11 * 16 ] + 1 ) >> 2 ) ;
input [ 5 ] = ( ( in [ 5 * 16 ] + 1 ) >> 2 ) + ( ( in [ 10 * 16 ] + 1 ) >> 2 ) ;
input [ 6 ] = ( ( in [ 6 * 16 ] + 1 ) >> 2 ) + ( ( in [ 9 * 16 ] + 1 ) >> 2 ) ;
input [ 7 ] = ( ( in [ 7 * 16 ] + 1 ) >> 2 ) + ( ( in [ 8 * 16 ] + 1 ) >> 2 ) ;
step1 [ 0 ] = ( ( in [ 7 * 16 ] + 1 ) >> 2 ) - ( ( in [ 8 * 16 ] + 1 ) >> 2 ) ;
step1 [ 1 ] = ( ( in [ 6 * 16 ] + 1 ) >> 2 ) - ( ( in [ 9 * 16 ] + 1 ) >> 2 ) ;
step1 [ 2 ] = ( ( in [ 5 * 16 ] + 1 ) >> 2 ) - ( ( in [ 10 * 16 ] + 1 ) >> 2 ) ;
step1 [ 3 ] = ( ( in [ 4 * 16 ] + 1 ) >> 2 ) - ( ( in [ 11 * 16 ] + 1 ) >> 2 ) ;
step1 [ 4 ] = ( ( in [ 3 * 16 ] + 1 ) >> 2 ) - ( ( in [ 12 * 16 ] + 1 ) >> 2 ) ;
step1 [ 5 ] = ( ( in [ 2 * 16 ] + 1 ) >> 2 ) - ( ( in [ 13 * 16 ] + 1 ) >> 2 ) ;
step1 [ 6 ] = ( ( in [ 1 * 16 ] + 1 ) >> 2 ) - ( ( in [ 14 * 16 ] + 1 ) >> 2 ) ;
step1 [ 7 ] = ( ( in [ 0 * 16 ] + 1 ) >> 2 ) - ( ( in [ 15 * 16 ] + 1 ) >> 2 ) ;
}
{
int s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ;
int t0 , t1 , t2 , t3 ;
int x0 , x1 , x2 , x3 ;
s0 = input [ 0 ] + input [ 7 ] ;
s1 = input [ 1 ] + input [ 6 ] ;
s2 = input [ 2 ] + input [ 5 ] ;
s3 = input [ 3 ] + input [ 4 ] ;
s4 = input [ 3 ] - input [ 4 ] ;
s5 = input [ 2 ] - input [ 5 ] ;
s6 = input [ 1 ] - input [ 6 ] ;
s7 = input [ 0 ] - input [ 7 ] ;
x0 = s0 + s3 ;
x1 = s1 + s2 ;
x2 = s1 - s2 ;
x3 = s0 - s3 ;
t0 = ( x0 + x1 ) * cospi_16_64 ;
t1 = ( x0 - x1 ) * cospi_16_64 ;
t2 = x3 * cospi_8_64 + x2 * cospi_24_64 ;
t3 = x3 * cospi_24_64 - x2 * cospi_8_64 ;
out [ 0 ] = fdct_round_shift ( t0 ) ;
out [ 4 ] = fdct_round_shift ( t2 ) ;
out [ 8 ] = fdct_round_shift ( t1 ) ;
out [ 12 ] = fdct_round_shift ( t3 ) ;
t0 = ( s6 - s5 ) * cospi_16_64 ;
t1 = ( s6 + s5 ) * cospi_16_64 ;
t2 = fdct_round_shift ( t0 ) ;
t3 = fdct_round_shift ( t1 ) ;
x0 = s4 + t2 ;
x1 = s4 - t2 ;
x2 = s7 - t3 ;
x3 = s7 + t3 ;
t0 = x0 * cospi_28_64 + x3 * cospi_4_64 ;
t1 = x1 * cospi_12_64 + x2 * cospi_20_64 ;
t2 = x2 * cospi_12_64 + x1 * - cospi_20_64 ;
t3 = x3 * cospi_28_64 + x0 * - cospi_4_64 ;
out [ 2 ] = fdct_round_shift ( t0 ) ;
out [ 6 ] = fdct_round_shift ( t2 ) ;
out [ 10 ] = fdct_round_shift ( t1 ) ;
out [ 14 ] = fdct_round_shift ( t3 ) ;
}
{
temp1 = ( step1 [ 5 ] - step1 [ 2 ] ) * cospi_16_64 ;
temp2 = ( step1 [ 4 ] - step1 [ 3 ] ) * cospi_16_64 ;
step2 [ 2 ] = fdct_round_shift ( temp1 ) ;
step2 [ 3 ] = fdct_round_shift ( temp2 ) ;
temp1 = ( step1 [ 4 ] + step1 [ 3 ] ) * cospi_16_64 ;
temp2 = ( step1 [ 5 ] + step1 [ 2 ] ) * cospi_16_64 ;
step2 [ 4 ] = fdct_round_shift ( temp1 ) ;
step2 [ 5 ] = fdct_round_shift ( temp2 ) ;
step3 [ 0 ] = step1 [ 0 ] + step2 [ 3 ] ;
step3 [ 1 ] = step1 [ 1 ] + step2 [ 2 ] ;
step3 [ 2 ] = step1 [ 1 ] - step2 [ 2 ] ;
step3 [ 3 ] = step1 [ 0 ] - step2 [ 3 ] ;
step3 [ 4 ] = step1 [ 7 ] - step2 [ 4 ] ;
step3 [ 5 ] = step1 [ 6 ] - step2 [ 5 ] ;
step3 [ 6 ] = step1 [ 6 ] + step2 [ 5 ] ;
step3 [ 7 ] = step1 [ 7 ] + step2 [ 4 ] ;
temp1 = step3 [ 1 ] * - cospi_8_64 + step3 [ 6 ] * cospi_24_64 ;
temp2 = step3 [ 2 ] * cospi_24_64 + step3 [ 5 ] * cospi_8_64 ;
step2 [ 1 ] = fdct_round_shift ( temp1 ) ;
step2 [ 2 ] = fdct_round_shift ( temp2 ) ;
temp1 = step3 [ 2 ] * cospi_8_64 - step3 [ 5 ] * cospi_24_64 ;
temp2 = step3 [ 1 ] * cospi_24_64 + step3 [ 6 ] * cospi_8_64 ;
step2 [ 5 ] = fdct_round_shift ( temp1 ) ;
step2 [ 6 ] = fdct_round_shift ( temp2 ) ;
step1 [ 0 ] = step3 [ 0 ] + step2 [ 1 ] ;
step1 [ 1 ] = step3 [ 0 ] - step2 [ 1 ] ;
step1 [ 2 ] = step3 [ 3 ] + step2 [ 2 ] ;
step1 [ 3 ] = step3 [ 3 ] - step2 [ 2 ] ;
step1 [ 4 ] = step3 [ 4 ] - step2 [ 5 ] ;
step1 [ 5 ] = step3 [ 4 ] + step2 [ 5 ] ;
step1 [ 6 ] = step3 [ 7 ] - step2 [ 6 ] ;
step1 [ 7 ] = step3 [ 7 ] + step2 [ 6 ] ;
temp1 = step1 [ 0 ] * cospi_30_64 + step1 [ 7 ] * cospi_2_64 ;
temp2 = step1 [ 1 ] * cospi_14_64 + step1 [ 6 ] * cospi_18_64 ;
out [ 1 ] = fdct_round_shift ( temp1 ) ;
out [ 9 ] = fdct_round_shift ( temp2 ) ;
temp1 = step1 [ 2 ] * cospi_22_64 + step1 [ 5 ] * cospi_10_64 ;
temp2 = step1 [ 3 ] * cospi_6_64 + step1 [ 4 ] * cospi_26_64 ;
out [ 5 ] = fdct_round_shift ( temp1 ) ;
out [ 13 ] = fdct_round_shift ( temp2 ) ;
temp1 = step1 [ 3 ] * - cospi_26_64 + step1 [ 4 ] * cospi_6_64 ;
temp2 = step1 [ 2 ] * - cospi_10_64 + step1 [ 5 ] * cospi_22_64 ;
out [ 3 ] = fdct_round_shift ( temp1 ) ;
out [ 11 ] = fdct_round_shift ( temp2 ) ;
temp1 = step1 [ 1 ] * - cospi_18_64 + step1 [ 6 ] * cospi_14_64 ;
temp2 = step1 [ 0 ] * - cospi_2_64 + step1 [ 7 ] * cospi_30_64 ;
out [ 7 ] = fdct_round_shift ( temp1 ) ;
out [ 15 ] = fdct_round_shift ( temp2 ) ;
}
in ++ ;
out += 16 ;
}
in = intermediate ;
out = output ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline void set_bits ( uint8_t * tab , int start , int len ) {
int end , mask , end1 ;
end = start + len ;
tab += start >> 3 ;
mask = 0xff << ( start & 7 ) ;
if ( ( start & ~ 7 ) == ( end & ~ 7 ) ) {
if ( start < end ) {
mask &= ~ ( 0xff << ( end & 7 ) ) ;
* tab |= mask ;
}
}
else {
* tab ++ |= mask ;
start = ( start + 8 ) & ~ 7 ;
end1 = end & ~ 7 ;
while ( start < end1 ) {
* tab ++ = 0xff ;
start += 8 ;
}
if ( start < end ) {
mask = ~ ( 0xff << ( end & 7 ) ) ;
* tab |= mask ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_nlm4_freeall ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ ) {
return dissect_nlm_freeall ( tvb , 0 , pinfo , tree , 4 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void do_cat_file ( struct st_command * command ) {
int error ;
static DYNAMIC_STRING ds_filename ;
const struct command_arg cat_file_args [ ] = {
{
"filename" , ARG_STRING , TRUE , & ds_filename , "File to read from" }
}
;
DBUG_ENTER ( "do_cat_file" ) ;
check_command_args ( command , command -> first_argument , cat_file_args , sizeof ( cat_file_args ) / sizeof ( struct command_arg ) , ' ' ) ;
DBUG_PRINT ( "info" , ( "Reading from, file: %s" , ds_filename . str ) ) ;
error = cat_file ( & ds_res , ds_filename . str ) ;
handle_command_error ( command , error , my_errno ) ;
dynstr_free ( & ds_filename ) ;
DBUG_VOID_RETURN ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void evhttp_get_body ( struct evhttp_connection * evcon , struct evhttp_request * req ) {
const char * xfer_enc ;
if ( req -> kind == EVHTTP_REQUEST && req -> type != EVHTTP_REQ_POST ) {
evhttp_connection_done ( evcon ) ;
return ;
}
evcon -> state = EVCON_READING_BODY ;
xfer_enc = evhttp_find_header ( req -> input_headers , "Transfer-Encoding" ) ;
if ( xfer_enc != NULL && strcasecmp ( xfer_enc , "chunked" ) == 0 ) {
req -> chunked = 1 ;
req -> ntoread = - 1 ;
}
else {
if ( evhttp_get_body_length ( req ) == - 1 ) {
evhttp_connection_fail ( evcon , EVCON_HTTP_INVALID_HEADER ) ;
return ;
}
}
evhttp_read_body ( evcon , req ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void proto_registrar_dump_protocols ( void ) {
protocol_t * protocol ;
int i ;
void * cookie = NULL ;
i = proto_get_first_protocol ( & cookie ) ;
while ( i != - 1 ) {
protocol = find_protocol_by_id ( i ) ;
ws_debug_printf ( "%s\t%s\t%s\n" , protocol -> name , protocol -> short_name , protocol -> filter_name ) ;
i = proto_get_next_protocol ( & cookie ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int arm_cpu_caps ( void ) {
int flags ;
int mask ;
if ( ! arm_cpu_env_flags ( & flags ) ) {
return flags ;
}
mask = arm_cpu_env_mask ( ) ;
# if HAVE_EDSP flags |= HAS_EDSP ;
# endif # if HAVE_MEDIA flags |= HAS_MEDIA ;
# endif # if HAVE_NEON || HAVE_NEON_ASM flags |= HAS_NEON ;
# endif return flags & mask ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline int h263_mv4_search ( MpegEncContext * s , int mx , int my , int shift ) {
MotionEstContext * const c = & s -> me ;
const int size = 1 ;
const int h = 8 ;
int block ;
int P [ 10 ] [ 2 ] ;
int dmin_sum = 0 , mx4_sum = 0 , my4_sum = 0 ;
int same = 1 ;
const int stride = c -> stride ;
uint8_t * mv_penalty = c -> current_mv_penalty ;
init_mv4_ref ( c ) ;
for ( block = 0 ;
block < 4 ;
block ++ ) {
int mx4 , my4 ;
int pred_x4 , pred_y4 ;
int dmin4 ;
static const int off [ 4 ] = {
2 , 1 , 1 , - 1 }
;
const int mot_stride = s -> b8_stride ;
const int mot_xy = s -> block_index [ block ] ;
P_LEFT [ 0 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - 1 ] [ 0 ] ;
P_LEFT [ 1 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - 1 ] [ 1 ] ;
if ( P_LEFT [ 0 ] > ( c -> xmax << shift ) ) P_LEFT [ 0 ] = ( c -> xmax << shift ) ;
if ( s -> first_slice_line && block < 2 ) {
c -> pred_x = pred_x4 = P_LEFT [ 0 ] ;
c -> pred_y = pred_y4 = P_LEFT [ 1 ] ;
}
else {
P_TOP [ 0 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - mot_stride ] [ 0 ] ;
P_TOP [ 1 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - mot_stride ] [ 1 ] ;
P_TOPRIGHT [ 0 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - mot_stride + off [ block ] ] [ 0 ] ;
P_TOPRIGHT [ 1 ] = s -> current_picture . f . motion_val [ 0 ] [ mot_xy - mot_stride + off [ block ] ] [ 1 ] ;
if ( P_TOP [ 1 ] > ( c -> ymax << shift ) ) P_TOP [ 1 ] = ( c -> ymax << shift ) ;
if ( P_TOPRIGHT [ 0 ] < ( c -> xmin << shift ) ) P_TOPRIGHT [ 0 ] = ( c -> xmin << shift ) ;
if ( P_TOPRIGHT [ 0 ] > ( c -> xmax << shift ) ) P_TOPRIGHT [ 0 ] = ( c -> xmax << shift ) ;
if ( P_TOPRIGHT [ 1 ] > ( c -> ymax << shift ) ) P_TOPRIGHT [ 1 ] = ( c -> ymax << shift ) ;
P_MEDIAN [ 0 ] = mid_pred ( P_LEFT [ 0 ] , P_TOP [ 0 ] , P_TOPRIGHT [ 0 ] ) ;
P_MEDIAN [ 1 ] = mid_pred ( P_LEFT [ 1 ] , P_TOP [ 1 ] , P_TOPRIGHT [ 1 ] ) ;
c -> pred_x = pred_x4 = P_MEDIAN [ 0 ] ;
c -> pred_y = pred_y4 = P_MEDIAN [ 1 ] ;
}
P_MV1 [ 0 ] = mx ;
P_MV1 [ 1 ] = my ;
dmin4 = epzs_motion_search4 ( s , & mx4 , & my4 , P , block , block , s -> p_mv_table , ( 1 << 16 ) >> shift ) ;
dmin4 = c -> sub_motion_search ( s , & mx4 , & my4 , dmin4 , block , block , size , h ) ;
if ( s -> dsp . me_sub_cmp [ 0 ] != s -> dsp . mb_cmp [ 0 ] ) {
int dxy ;
const int offset = ( ( block & 1 ) + ( block >> 1 ) * stride ) * 8 ;
uint8_t * dest_y = c -> scratchpad + offset ;
if ( s -> quarter_sample ) {
uint8_t * ref = c -> ref [ block ] [ 0 ] + ( mx4 >> 2 ) + ( my4 >> 2 ) * stride ;
dxy = ( ( my4 & 3 ) << 2 ) | ( mx4 & 3 ) ;
if ( s -> no_rounding ) s -> dsp . put_no_rnd_qpel_pixels_tab [ 1 ] [ dxy ] ( dest_y , ref , stride ) ;
else s -> dsp . put_qpel_pixels_tab [ 1 ] [ dxy ] ( dest_y , ref , stride ) ;
}
else {
uint8_t * ref = c -> ref [ block ] [ 0 ] + ( mx4 >> 1 ) + ( my4 >> 1 ) * stride ;
dxy = ( ( my4 & 1 ) << 1 ) | ( mx4 & 1 ) ;
if ( s -> no_rounding ) s -> dsp . put_no_rnd_pixels_tab [ 1 ] [ dxy ] ( dest_y , ref , stride , h ) ;
else s -> dsp . put_pixels_tab [ 1 ] [ dxy ] ( dest_y , ref , stride , h ) ;
}
dmin_sum += ( mv_penalty [ mx4 - pred_x4 ] + mv_penalty [ my4 - pred_y4 ] ) * c -> mb_penalty_factor ;
}
else dmin_sum += dmin4 ;
if ( s -> quarter_sample ) {
mx4_sum += mx4 / 2 ;
my4_sum += my4 / 2 ;
}
else {
mx4_sum += mx4 ;
my4_sum += my4 ;
}
s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ block ] ] [ 0 ] = mx4 ;
s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ block ] ] [ 1 ] = my4 ;
if ( mx4 != mx || my4 != my ) same = 0 ;
}
if ( same ) return INT_MAX ;
if ( s -> dsp . me_sub_cmp [ 0 ] != s -> dsp . mb_cmp [ 0 ] ) {
dmin_sum += s -> dsp . mb_cmp [ 0 ] ( s , s -> new_picture . f . data [ 0 ] + s -> mb_x * 16 + s -> mb_y * 16 * stride , c -> scratchpad , stride , 16 ) ;
}
if ( c -> avctx -> mb_cmp & FF_CMP_CHROMA ) {
int dxy ;
int mx , my ;
int offset ;
mx = ff_h263_round_chroma ( mx4_sum ) ;
my = ff_h263_round_chroma ( my4_sum ) ;
dxy = ( ( my & 1 ) << 1 ) | ( mx & 1 ) ;
offset = ( s -> mb_x * 8 + ( mx >> 1 ) ) + ( s -> mb_y * 8 + ( my >> 1 ) ) * s -> uvlinesize ;
if ( s -> no_rounding ) {
s -> dsp . put_no_rnd_pixels_tab [ 1 ] [ dxy ] ( c -> scratchpad , s -> last_picture . f . data [ 1 ] + offset , s -> uvlinesize , 8 ) ;
s -> dsp . put_no_rnd_pixels_tab [ 1 ] [ dxy ] ( c -> scratchpad + 8 , s -> last_picture . f . data [ 2 ] + offset , s -> uvlinesize , 8 ) ;
}
else {
s -> dsp . put_pixels_tab [ 1 ] [ dxy ] ( c -> scratchpad , s -> last_picture . f . data [ 1 ] + offset , s -> uvlinesize , 8 ) ;
s -> dsp . put_pixels_tab [ 1 ] [ dxy ] ( c -> scratchpad + 8 , s -> last_picture . f . data [ 2 ] + offset , s -> uvlinesize , 8 ) ;
}
dmin_sum += s -> dsp . mb_cmp [ 1 ] ( s , s -> new_picture . f . data [ 1 ] + s -> mb_x * 8 + s -> mb_y * 8 * s -> uvlinesize , c -> scratchpad , s -> uvlinesize , 8 ) ;
dmin_sum += s -> dsp . mb_cmp [ 1 ] ( s , s -> new_picture . f . data [ 2 ] + s -> mb_x * 8 + s -> mb_y * 8 * s -> uvlinesize , c -> scratchpad + 8 , s -> uvlinesize , 8 ) ;
}
c -> pred_x = mx ;
c -> pred_y = my ;
switch ( c -> avctx -> mb_cmp & 0xFF ) {
case FF_CMP_RD : return dmin_sum ;
default : return dmin_sum + 11 * c -> mb_penalty_factor ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void gather_data_for_subcel ( SubcelEvaluation * subcel , int x , int y , RoqContext * enc , RoqTempdata * tempData ) {
uint8_t mb4 [ 4 * 4 * 3 ] ;
uint8_t mb2 [ 2 * 2 * 3 ] ;
int cluster_index ;
int i , best_dist ;
static const int bitsUsed [ 4 ] = {
2 , 10 , 10 , 34 }
;
if ( enc -> framesSinceKeyframe >= 1 ) {
subcel -> motion = enc -> this_motion4 [ y * enc -> width / 16 + x / 4 ] ;
subcel -> eval_dist [ RoQ_ID_FCC ] = eval_motion_dist ( enc , x , y , enc -> this_motion4 [ y * enc -> width / 16 + x / 4 ] , 4 ) ;
}
else subcel -> eval_dist [ RoQ_ID_FCC ] = INT_MAX ;
if ( enc -> framesSinceKeyframe >= 2 ) subcel -> eval_dist [ RoQ_ID_MOT ] = block_sse ( enc -> frame_to_enc -> data , enc -> current_frame -> data , x , y , x , y , enc -> frame_to_enc -> linesize , enc -> current_frame -> linesize , 4 ) ;
else subcel -> eval_dist [ RoQ_ID_MOT ] = INT_MAX ;
cluster_index = y * enc -> width / 16 + x / 4 ;
get_frame_mb ( enc -> frame_to_enc , x , y , mb4 , 4 ) ;
subcel -> eval_dist [ RoQ_ID_SLD ] = index_mb ( mb4 , tempData -> codebooks . unpacked_cb4 , tempData -> codebooks . numCB4 , & subcel -> cbEntry , 4 ) ;
subcel -> eval_dist [ RoQ_ID_CCC ] = 0 ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
subcel -> subCels [ i ] = tempData -> closest_cb2 [ cluster_index * 4 + i ] ;
get_frame_mb ( enc -> frame_to_enc , x + 2 * ( i & 1 ) , y + ( i & 2 ) , mb2 , 2 ) ;
subcel -> eval_dist [ RoQ_ID_CCC ] += squared_diff_macroblock ( tempData -> codebooks . unpacked_cb2 + subcel -> subCels [ i ] * 2 * 2 * 3 , mb2 , 2 ) ;
}
best_dist = INT_MAX ;
for ( i = 0 ;
i < 4 ;
i ++ ) if ( ROQ_LAMBDA_SCALE * subcel -> eval_dist [ i ] + enc -> lambda * bitsUsed [ i ] < best_dist ) {
subcel -> best_coding = i ;
subcel -> best_bit_use = bitsUsed [ i ] ;
best_dist = ROQ_LAMBDA_SCALE * subcel -> eval_dist [ i ] + enc -> lambda * bitsUsed [ i ] ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void nautilus_directory_monitor_add_internal ( NautilusDirectory * directory , NautilusFile * file , gconstpointer client , gboolean monitor_hidden_files , NautilusFileAttributes file_attributes , NautilusDirectoryCallback callback , gpointer callback_data ) {
Monitor * monitor ;
GList * file_list ;
char * file_uri = NULL ;
char * dir_uri = NULL ;
g_assert ( NAUTILUS_IS_DIRECTORY ( directory ) ) ;
if ( file != NULL ) {
file_uri = nautilus_file_get_uri ( file ) ;
}
if ( directory != NULL ) {
dir_uri = nautilus_directory_get_uri ( directory ) ;
}
nautilus_profile_start ( "uri %s file-uri %s client %p" , dir_uri , file_uri , client ) ;
g_free ( dir_uri ) ;
g_free ( file_uri ) ;
remove_monitor ( directory , file , client ) ;
monitor = g_new ( Monitor , 1 ) ;
monitor -> file = file ;
monitor -> monitor_hidden_files = monitor_hidden_files ;
monitor -> client = client ;
monitor -> request = nautilus_directory_set_up_request ( file_attributes ) ;
if ( file == NULL ) {
REQUEST_SET_TYPE ( monitor -> request , REQUEST_FILE_LIST ) ;
}
directory -> details -> monitor_list = g_list_prepend ( directory -> details -> monitor_list , monitor ) ;
request_counter_add_request ( directory -> details -> monitor_counters , monitor -> request ) ;
if ( callback != NULL ) {
file_list = nautilus_directory_get_file_list ( directory ) ;
( * callback ) ( directory , file_list , callback_data ) ;
nautilus_file_list_free ( file_list ) ;
}
if ( directory -> details -> monitor == NULL ) {
directory -> details -> monitor = nautilus_monitor_directory ( directory -> details -> location ) ;
}
if ( REQUEST_WANTS_TYPE ( monitor -> request , REQUEST_FILE_INFO ) && directory -> details -> mime_db_monitor == 0 ) {
directory -> details -> mime_db_monitor = g_signal_connect_object ( nautilus_signaller_get_current ( ) , "mime-data-changed" , G_CALLBACK ( mime_db_changed_callback ) , directory , 0 ) ;
}
if ( file != NULL ) {
nautilus_directory_add_file_to_work_queue ( directory , file ) ;
}
else {
add_all_files_to_work_queue ( directory ) ;
}
nautilus_directory_async_state_changed ( directory ) ;
nautilus_profile_end ( NULL ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int mpeg_decode_frame ( AVCodecContext * avctx , void * data , int * got_output , AVPacket * avpkt ) {
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
Mpeg1Context * s = avctx -> priv_data ;
AVFrame * picture = data ;
MpegEncContext * s2 = & s -> mpeg_enc_ctx ;
av_dlog ( avctx , "fill_buffer\n" ) ;
if ( buf_size == 0 || ( buf_size == 4 && AV_RB32 ( buf ) == SEQ_END_CODE ) ) {
if ( s2 -> low_delay == 0 && s2 -> next_picture_ptr ) {
int ret = av_frame_ref ( picture , & s2 -> next_picture_ptr -> f ) ;
if ( ret < 0 ) return ret ;
s2 -> next_picture_ptr = NULL ;
* got_output = 1 ;
}
return buf_size ;
}
if ( s2 -> flags & CODEC_FLAG_TRUNCATED ) {
int next = ff_mpeg1_find_frame_end ( & s2 -> parse_context , buf , buf_size , NULL ) ;
if ( ff_combine_frame ( & s2 -> parse_context , next , ( const uint8_t * * ) & buf , & buf_size ) < 0 ) return buf_size ;
}
if ( s -> mpeg_enc_ctx_allocated == 0 && avctx -> codec_tag == AV_RL32 ( "VCR2" ) ) vcr2_init_sequence ( avctx ) ;
s -> slice_count = 0 ;
if ( avctx -> extradata && ! s -> extradata_decoded ) {
int ret = decode_chunks ( avctx , picture , got_output , avctx -> extradata , avctx -> extradata_size ) ;
s -> extradata_decoded = 1 ;
if ( ret < 0 && ( avctx -> err_recognition & AV_EF_EXPLODE ) ) return ret ;
}
return decode_chunks ( avctx , picture , got_output , buf , buf_size ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int parse_RowsBufferCol ( tvbuff_t * tvb , int offset , guint32 row , guint32 col , struct CPMSetBindingsIn * bindingsin , struct rows_data * rowsin , gboolean b_is_64bit , proto_tree * parent_tree , const char * fmt , ... ) {
proto_tree * tree ;
proto_item * item ;
guint32 buf_start = offset ;
guint32 buf_offset = buf_start + ( row * bindingsin -> brow ) ;
struct CTableColumn * pcol = & bindingsin -> acolumns [ col ] ;
static const value_string STATUS [ ] = {
{
0 , "StoreStatusOk" }
, {
1 , "StoreStatusDeferred" }
, {
2 , "StoreStatusNull" }
, {
0 , NULL }
}
;
const char * txt ;
va_list ap ;
va_start ( ap , fmt ) ;
txt = wmem_strdup_vprintf ( wmem_packet_scope ( ) , fmt , ap ) ;
va_end ( ap ) ;
tree = proto_tree_add_subtree ( parent_tree , tvb , offset , 0 , ett_GetRowsColumn , & item , txt ) ;
proto_item_append_text ( item , " (%s)" , pcol -> name ) ;
if ( pcol -> statusused ) {
int tmp_offset = buf_offset + pcol -> statusoffset ;
proto_tree_add_string ( tree , hf_mswsp_ctablecolumn_status , tvb , tmp_offset , 1 , val_to_str ( tvb_get_guint8 ( tvb , tmp_offset ) , STATUS , "(Invalid: 0x%x)" ) ) ;
}
if ( pcol -> lengthused ) {
int tmp_offset = buf_offset + pcol -> lengthoffset ;
proto_tree_add_item ( tree , hf_mswsp_ctablecolumn_length , tvb , tmp_offset , 1 , ENC_LITTLE_ENDIAN ) ;
}
if ( pcol -> valueused ) {
int tmp_offset = buf_offset + pcol -> valueoffset ;
struct CRowVariant variant ;
guint32 len = pcol -> valuesize ;
guint64 base_address = rowsin -> ulclientbase ;
ZERO_STRUCT ( variant ) ;
if ( pcol -> lengthused ) {
len = tvb_get_letohs ( tvb , buf_offset + pcol -> lengthoffset ) - pcol -> valuesize ;
}
if ( pcol -> vtype == VT_VARIANT ) {
parse_VariantCol ( tvb , tmp_offset , tree , base_address , len , b_is_64bit , & variant , "CRowVariant" ) ;
}
}
return offset ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
void proto_register_h245 ( void ) {
static hf_register_info hf [ ] = {
{
& hf_h245_pdu_type , {
"PDU Type" , "h245.pdu_type" , FT_UINT32 , BASE_DEC , VALS ( h245_MultimediaSystemControlMessage_vals ) , 0 , "Type of H.245 PDU" , HFILL }
}
, {
& hf_h245Manufacturer , {
"H.245 Manufacturer" , "h245.Manufacturer" , FT_UINT32 , BASE_HEX , VALS ( H221ManufacturerCode_vals ) , 0 , "h245.H.221 Manufacturer" , HFILL }
}
, {
& hf_h245_subMessageIdentifier_standard , {
"subMessageIdentifier" , "h245.subMessageIdentifier.standard" , FT_UINT32 , BASE_DEC , VALS ( h245_h239subMessageIdentifier_vals ) , 0 , NULL , HFILL }
}
, # include "packet-h245-hfarr.c" }
;
static gint * ett [ ] = {
& ett_h245 , & ett_h245_returnedFunction , # include "packet-h245-ettarr.c" }
;
module_t * h245_module ;
proto_h245 = proto_register_protocol ( PNAME , PSNAME , PFNAME ) ;
register_init_routine ( h245_init ) ;
proto_register_field_array ( proto_h245 , hf , array_length ( hf ) ) ;
proto_register_subtree_array ( ett , array_length ( ett ) ) ;
h245_module = prefs_register_protocol ( proto_h245 , NULL ) ;
prefs_register_bool_preference ( h245_module , "reassembly" , "Reassemble H.245 messages spanning multiple TCP segments" , "Whether the H.245 dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings." , & h245_reassembly ) ;
prefs_register_bool_preference ( h245_module , "shorttypes" , "Show short message types" , "Whether the dissector should show short names or the long names from the standard" , & h245_shorttypes ) ;
register_dissector ( "h245dg" , dissect_h245_h245 , proto_h245 ) ;
register_dissector ( "h245" , dissect_h245 , proto_h245 ) ;
nsp_object_dissector_table = register_dissector_table ( "h245.nsp.object" , "H.245 NonStandardParameter (object)" , FT_STRING , BASE_NONE ) ;
nsp_h221_dissector_table = register_dissector_table ( "h245.nsp.h221" , "H.245 NonStandardParameter (h221)" , FT_UINT32 , BASE_HEX ) ;
gef_name_dissector_table = register_dissector_table ( "h245.gef.name" , "H.245 Generic Extensible Framework (names)" , FT_STRING , BASE_NONE ) ;
gef_content_dissector_table = register_dissector_table ( "h245.gef.content" , "H.245 Generic Extensible Framework" , FT_STRING , BASE_NONE ) ;
h245_tap = register_tap ( "h245" ) ;
h245dg_tap = register_tap ( "h245dg" ) ;
oid_add_from_string ( "h239ControlCapability" , "0.0.8.239.1.1" ) ;
oid_add_from_string ( "h239ExtendedVideoCapability" , "0.0.8.239.1.2" ) ;
oid_add_from_string ( "generic-message" , "0.0.8.239.2" ) ;
oid_add_from_string ( "h245 version 3" , "0.0.8.245.0.3" ) ;
oid_add_from_string ( "h245 version 4" , "0.0.8.245.0.4" ) ;
oid_add_from_string ( "h245 version 5" , "0.0.8.245.0.5" ) ;
oid_add_from_string ( "h245 version 6" , "0.0.8.245.0.6" ) ;
oid_add_from_string ( "h245 version 7" , "0.0.8.245.0.7" ) ;
oid_add_from_string ( "h245 version 8" , "0.0.8.245.0.8" ) ;
oid_add_from_string ( "h245 version 9" , "0.0.8.245.0.9" ) ;
oid_add_from_string ( "h245 version 10" , "0.0.8.245.0.10" ) ;
oid_add_from_string ( "h245 version 11" , "0.0.8.245.0.11" ) ;
oid_add_from_string ( "h245 version 12" , "0.0.8.245.0.12" ) ;
oid_add_from_string ( "h245 version 13" , "0.0.8.245.0.13" ) ;
oid_add_from_string ( "ISO/IEC 14496-2 MPEG-4 video" , "0.0.8.245.1.0.0" ) ;
oid_add_from_string ( "ISO/IEC 14496-3 MPEG-4 audio" , "0.0.8.245.1.1.0" ) ;
oid_add_from_string ( "AMR" , "0.0.8.245.1.1.1" ) ;
oid_add_from_string ( "acelp" , "0.0.8.245.1.1.2" ) ;
oid_add_from_string ( "us1" , "0.0.8.245.1.1.3" ) ;
oid_add_from_string ( "is127evrc" , "0.0.8.245.1.1.4" ) ;
oid_add_from_string ( "ISO/IEC 13818-7" , "0.0.8.245.1.1.5" ) ;
oid_add_from_string ( "rfc3389" , "0.0.8.245.1.1.6" ) ;
oid_add_from_string ( "L-16" , "0.0.8.245.1.1.7" ) ;
oid_add_from_string ( "bounded-audio-stream" , "0.0.8.245.1.1.8" ) ;
oid_add_from_string ( "AMR-NB" , "0.0.8.245.1.1.9" ) ;
oid_add_from_string ( "AMR-WB" , "0.0.8.245.1.1.10" ) ;
oid_add_from_string ( "ilbc" , "0.0.8.245.1.1.11" ) ;
oid_add_from_string ( "ISO/IEC 14496-1" , "0.0.8.245.1.2.0" ) ;
oid_add_from_string ( "Nx64" , "0.0.8.245.1.2.1" ) ;
oid_add_from_string ( "logical-channel-bit-ratemanagement" , "0.0.8.245.1.3.0" ) ;
oid_add_from_string ( "h264 generic-capabilities" , "0.0.8.241.0.0.1" ) ;
oid_add_from_string ( "iPpacketization_h241AnnexA(single NAL unit mode)" , "0.0.8.241.0.0.0.0" ) ;
oid_add_from_string ( "iPpacketization_RFC3984NonInterleaved" , "0.0.8.241.0.0.0.1" ) ;
oid_add_from_string ( "iPpacketization_RFC3984Interleaved" , "0.0.8.241.0.0.0.2" ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int aasc_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
AascContext * s = avctx -> priv_data ;
int compr , i , stride , ret ;
if ( ( ret = ff_reget_buffer ( avctx , s -> frame ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "reget_buffer() failed\n" ) ;
return ret ;
}
compr = AV_RL32 ( buf ) ;
buf += 4 ;
buf_size -= 4 ;
switch ( compr ) {
case 0 : stride = ( avctx -> width * 3 + 3 ) & ~ 3 ;
for ( i = avctx -> height - 1 ;
i >= 0 ;
i -- ) {
memcpy ( s -> frame -> data [ 0 ] + i * s -> frame -> linesize [ 0 ] , buf , avctx -> width * 3 ) ;
buf += stride ;
}
break ;
case 1 : bytestream2_init ( & s -> gb , buf , buf_size ) ;
ff_msrle_decode ( avctx , ( AVPicture * ) s -> frame , 8 , & s -> gb ) ;
break ;
default : av_log ( avctx , AV_LOG_ERROR , "Unknown compression type %d\n" , compr ) ;
return AVERROR_INVALIDDATA ;
}
* got_frame = 1 ;
if ( ( ret = av_frame_ref ( data , s -> frame ) ) < 0 ) return ret ;
return buf_size ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int proc_release_port ( struct usb_dev_state * ps , void __user * arg ) {
unsigned portnum ;
if ( get_user ( portnum , ( unsigned __user * ) arg ) ) return - EFAULT ;
return usb_hub_release_port ( ps -> dev , portnum , ps ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int ssl23_get_client_hello ( SSL * s ) {
char buf_space [ 11 ] ;
char * buf = & ( buf_space [ 0 ] ) ;
unsigned char * p , * d , * d_len , * dd ;
unsigned int i ;
unsigned int csl , sil , cl ;
int n = 0 , j ;
int type = 0 ;
int v [ 2 ] ;
if ( s -> state == SSL23_ST_SR_CLNT_HELLO_A ) {
v [ 0 ] = v [ 1 ] = 0 ;
if ( ! ssl3_setup_buffers ( s ) ) goto err ;
n = ssl23_read_bytes ( s , sizeof buf_space ) ;
if ( n != sizeof buf_space ) return ( n ) ;
p = s -> packet ;
memcpy ( buf , p , n ) ;
if ( ( p [ 0 ] & 0x80 ) && ( p [ 2 ] == SSL2_MT_CLIENT_HELLO ) ) {
if ( ( p [ 3 ] == 0x00 ) && ( p [ 4 ] == 0x02 ) ) {
v [ 0 ] = p [ 3 ] ;
v [ 1 ] = p [ 4 ] ;
if ( ! ( s -> options & SSL_OP_NO_SSLv2 ) ) type = 1 ;
}
else if ( p [ 3 ] == SSL3_VERSION_MAJOR ) {
v [ 0 ] = p [ 3 ] ;
v [ 1 ] = p [ 4 ] ;
if ( p [ 4 ] >= TLS1_VERSION_MINOR ) {
if ( p [ 4 ] >= TLS1_2_VERSION_MINOR && ! ( s -> options & SSL_OP_NO_TLSv1_2 ) ) {
s -> version = TLS1_2_VERSION ;
s -> state = SSL23_ST_SR_CLNT_HELLO_B ;
}
else if ( p [ 4 ] >= TLS1_1_VERSION_MINOR && ! ( s -> options & SSL_OP_NO_TLSv1_1 ) ) {
s -> version = TLS1_1_VERSION ;
s -> state = SSL23_ST_SR_CLNT_HELLO_B ;
}
else if ( ! ( s -> options & SSL_OP_NO_TLSv1 ) ) {
s -> version = TLS1_VERSION ;
s -> state = SSL23_ST_SR_CLNT_HELLO_B ;
}
else if ( ! ( s -> options & SSL_OP_NO_SSLv3 ) ) {
s -> version = SSL3_VERSION ;
s -> state = SSL23_ST_SR_CLNT_HELLO_B ;
}
else if ( ! ( s -> options & SSL_OP_NO_SSLv2 ) ) {
type = 1 ;
}
}
else if ( ! ( s -> options & SSL_OP_NO_SSLv3 ) ) {
s -> version = SSL3_VERSION ;
s -> state = SSL23_ST_SR_CLNT_HELLO_B ;
}
else if ( ! ( s -> options & SSL_OP_NO_SSLv2 ) ) type = 1 ;
}
}
else if ( ( p [ 0 ] == SSL3_RT_HANDSHAKE ) && ( p [ 1 ] == SSL3_VERSION_MAJOR ) && ( p [ 5 ] == SSL3_MT_CLIENT_HELLO ) && ( ( p [ 3 ] == 0 && p [ 4 ] < 5 ) || ( p [ 9 ] >= p [ 1 ] ) ) ) {
v [ 0 ] = p [ 1 ] ;
if ( p [ 3 ] == 0 && p [ 4 ] < 6 ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_RECORD_TOO_SMALL ) ;
goto err ;
}
if ( p [ 9 ] > SSL3_VERSION_MAJOR ) v [ 1 ] = 0xff ;
else v [ 1 ] = p [ 10 ] ;
if ( v [ 1 ] >= TLS1_VERSION_MINOR ) {
if ( v [ 1 ] >= TLS1_2_VERSION_MINOR && ! ( s -> options & SSL_OP_NO_TLSv1_2 ) ) {
s -> version = TLS1_2_VERSION ;
type = 3 ;
}
else if ( v [ 1 ] >= TLS1_1_VERSION_MINOR && ! ( s -> options & SSL_OP_NO_TLSv1_1 ) ) {
s -> version = TLS1_1_VERSION ;
type = 3 ;
}
else if ( ! ( s -> options & SSL_OP_NO_TLSv1 ) ) {
s -> version = TLS1_VERSION ;
type = 3 ;
}
else if ( ! ( s -> options & SSL_OP_NO_SSLv3 ) ) {
s -> version = SSL3_VERSION ;
type = 3 ;
}
}
else {
if ( ! ( s -> options & SSL_OP_NO_SSLv3 ) ) {
s -> version = SSL3_VERSION ;
type = 3 ;
}
else if ( ! ( s -> options & SSL_OP_NO_TLSv1 ) ) {
s -> version = TLS1_VERSION ;
type = 3 ;
}
}
}
else if ( ( strncmp ( "GET " , ( char * ) p , 4 ) == 0 ) || ( strncmp ( "POST " , ( char * ) p , 5 ) == 0 ) || ( strncmp ( "HEAD " , ( char * ) p , 5 ) == 0 ) || ( strncmp ( "PUT " , ( char * ) p , 4 ) == 0 ) ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_HTTP_REQUEST ) ;
goto err ;
}
else if ( strncmp ( "CONNECT" , ( char * ) p , 7 ) == 0 ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_HTTPS_PROXY_REQUEST ) ;
goto err ;
}
}
OPENSSL_assert ( s -> version <= TLS_MAX_VERSION ) ;
# ifdef OPENSSL_FIPS if ( FIPS_mode ( ) && ( s -> version < TLS1_VERSION ) ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE ) ;
goto err ;
}
# endif if ( s -> state == SSL23_ST_SR_CLNT_HELLO_B ) {
type = 2 ;
p = s -> packet ;
v [ 0 ] = p [ 3 ] ;
v [ 1 ] = p [ 4 ] ;
n = ( ( p [ 0 ] & 0x7f ) << 8 ) | p [ 1 ] ;
if ( n > ( 1024 * 4 ) ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_RECORD_TOO_LARGE ) ;
goto err ;
}
if ( n < 9 ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_RECORD_LENGTH_MISMATCH ) ;
goto err ;
}
j = ssl23_read_bytes ( s , n + 2 ) ;
if ( j <= 0 ) return ( j ) ;
ssl3_finish_mac ( s , s -> packet + 2 , s -> packet_length - 2 ) ;
if ( s -> msg_callback ) s -> msg_callback ( 0 , SSL2_VERSION , 0 , s -> packet + 2 , s -> packet_length - 2 , s , s -> msg_callback_arg ) ;
p = s -> packet ;
p += 5 ;
n2s ( p , csl ) ;
n2s ( p , sil ) ;
n2s ( p , cl ) ;
d = ( unsigned char * ) s -> init_buf -> data ;
if ( ( csl + sil + cl + 11 ) != s -> packet_length ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_RECORD_LENGTH_MISMATCH ) ;
goto err ;
}
* ( d ++ ) = SSL3_MT_CLIENT_HELLO ;
d_len = d ;
d += 3 ;
* ( d ++ ) = SSL3_VERSION_MAJOR ;
* ( d ++ ) = v [ 1 ] ;
i = ( cl > SSL3_RANDOM_SIZE ) ? SSL3_RANDOM_SIZE : cl ;
memset ( d , 0 , SSL3_RANDOM_SIZE ) ;
memcpy ( & ( d [ SSL3_RANDOM_SIZE - i ] ) , & ( p [ csl + sil ] ) , i ) ;
d += SSL3_RANDOM_SIZE ;
* ( d ++ ) = 0 ;
j = 0 ;
dd = d ;
d += 2 ;
for ( i = 0 ;
i < csl ;
i += 3 ) {
if ( p [ i ] != 0 ) continue ;
* ( d ++ ) = p [ i + 1 ] ;
* ( d ++ ) = p [ i + 2 ] ;
j += 2 ;
}
s2n ( j , dd ) ;
* ( d ++ ) = 1 ;
* ( d ++ ) = 0 ;
# if 0 p = p + csl + sil + cl ;
while ( p < s -> packet + s -> packet_length ) {
* ( d ++ ) = * ( p ++ ) ;
}
# endif i = ( d - ( unsigned char * ) s -> init_buf -> data ) - 4 ;
l2n3 ( ( long ) i , d_len ) ;
s -> s3 -> tmp . reuse_message = 1 ;
s -> s3 -> tmp . message_type = SSL3_MT_CLIENT_HELLO ;
s -> s3 -> tmp . message_size = i ;
}
if ( type == 1 ) {
# ifdef OPENSSL_NO_SSL2 SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_UNSUPPORTED_PROTOCOL ) ;
goto err ;
# else if ( s -> s2 == NULL ) {
if ( ! ssl2_new ( s ) ) goto err ;
}
else ssl2_clear ( s ) ;
if ( s -> s3 != NULL ) ssl3_free ( s ) ;
if ( ! BUF_MEM_grow_clean ( s -> init_buf , SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER ) ) {
goto err ;
}
s -> state = SSL2_ST_GET_CLIENT_HELLO_A ;
if ( s -> options & SSL_OP_NO_TLSv1 && s -> options & SSL_OP_NO_SSLv3 ) s -> s2 -> ssl2_rollback = 0 ;
else s -> s2 -> ssl2_rollback = 1 ;
s -> rstate = SSL_ST_READ_HEADER ;
s -> packet_length = n ;
s -> packet = & ( s -> s2 -> rbuf [ 0 ] ) ;
memcpy ( s -> packet , buf , n ) ;
s -> s2 -> rbuf_left = n ;
s -> s2 -> rbuf_offs = 0 ;
s -> method = SSLv2_server_method ( ) ;
s -> handshake_func = s -> method -> ssl_accept ;
# endif }
if ( ( type == 2 ) || ( type == 3 ) ) {
const SSL_METHOD * new_method ;
new_method = ssl23_get_server_method ( s -> version ) ;
if ( new_method == NULL ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_UNSUPPORTED_PROTOCOL ) ;
goto err ;
}
s -> method = new_method ;
if ( ! ssl_init_wbio_buffer ( s , 1 ) ) goto err ;
s -> state = SSL3_ST_SR_CLNT_HELLO_A ;
if ( type == 3 ) {
s -> rstate = SSL_ST_READ_HEADER ;
s -> packet_length = n ;
if ( s -> s3 -> rbuf . buf == NULL ) if ( ! ssl3_setup_read_buffer ( s ) ) goto err ;
s -> packet = & ( s -> s3 -> rbuf . buf [ 0 ] ) ;
memcpy ( s -> packet , buf , n ) ;
s -> s3 -> rbuf . left = n ;
s -> s3 -> rbuf . offset = 0 ;
}
else {
s -> packet_length = 0 ;
s -> s3 -> rbuf . left = 0 ;
s -> s3 -> rbuf . offset = 0 ;
}
# if 0 s -> client_version = ( v [ 0 ] << 8 ) | v [ 1 ] ;
# endif s -> handshake_func = s -> method -> ssl_accept ;
}
if ( ( type < 1 ) || ( type > 3 ) ) {
SSLerr ( SSL_F_SSL23_GET_CLIENT_HELLO , SSL_R_UNKNOWN_PROTOCOL ) ;
goto err ;
}
s -> init_num = 0 ;
if ( buf != buf_space ) OPENSSL_free ( buf ) ;
return ( SSL_accept ( s ) ) ;
err : if ( buf != buf_space ) OPENSSL_free ( buf ) ;
return ( - 1 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int config_filter_parsers_get ( struct config_filter_context * ctx , pool_t pool , const char * const * modules , const struct config_filter * filter , struct config_module_parser * * parsers_r , struct master_service_settings_output * output_r , const char * * error_r ) {
struct config_filter_parser * const * src ;
struct config_module_parser * dest ;
const char * error = NULL , * * error_p ;
unsigned int i , count ;
src = config_filter_find_all ( ctx , pool , modules , filter , output_r ) ;
for ( count = 0 ;
src [ 0 ] -> parsers [ count ] . root != NULL ;
count ++ ) ;
dest = p_new ( pool , struct config_module_parser , count + 1 ) ;
for ( i = 0 ;
i < count ;
i ++ ) {
dest [ i ] = src [ 0 ] -> parsers [ i ] ;
dest [ i ] . parser = settings_parser_dup ( src [ 0 ] -> parsers [ i ] . parser , pool ) ;
}
for ( i = 1 ;
src [ i ] != NULL ;
i ++ ) {
if ( config_filter_is_superset ( & src [ i ] -> filter , & src [ i - 1 ] -> filter ) ) error_p = NULL ;
else error_p = & error ;
if ( config_module_parser_apply_changes ( dest , src [ i ] , pool , error_p ) < 0 ) {
i_assert ( error != NULL ) ;
config_filter_parsers_free ( dest ) ;
* error_r = error ;
return - 1 ;
}
}
* parsers_r = dest ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int parse_CAggregSortKey ( tvbuff_t * tvb , int offset , proto_tree * parent_tree , proto_tree * pad_tree , const char * fmt , ... ) {
guint32 order ;
proto_item * item ;
proto_tree * tree ;
const char * txt ;
va_list ap ;
va_start ( ap , fmt ) ;
txt = wmem_strdup_vprintf ( wmem_packet_scope ( ) , fmt , ap ) ;
va_end ( ap ) ;
tree = proto_tree_add_subtree ( parent_tree , tvb , offset , 0 , ett_CAggregSortKey , & item , txt ) ;
order = tvb_get_letohl ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_caggregsortkey_order , tvb , offset , 4 , order ) ;
offset += 4 ;
offset = parse_CAggregSpec ( tvb , offset , tree , pad_tree , "ColumnSpec" ) ;
proto_item_set_end ( item , tvb , offset ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void proto_register_rtmpt ( void ) {
static hf_register_info hf [ ] = {
{
& hf_rtmpt_handshake_c0 , {
"Protocol version" , "rtmpt.handshake.c0" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake C0" , HFILL }
}
, {
& hf_rtmpt_handshake_s0 , {
"Protocol version" , "rtmpt.handshake.s0" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake S0" , HFILL }
}
, {
& hf_rtmpt_handshake_c1 , {
"Handshake data" , "rtmpt.handshake.c1" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake C1" , HFILL }
}
, {
& hf_rtmpt_handshake_s1 , {
"Handshake data" , "rtmpt.handshake.s1" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake S1" , HFILL }
}
, {
& hf_rtmpt_handshake_c2 , {
"Handshake data" , "rtmpt.handshake.c2" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake C2" , HFILL }
}
, {
& hf_rtmpt_handshake_s2 , {
"Handshake data" , "rtmpt.handshake.s2" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Handshake S2" , HFILL }
}
, {
& hf_rtmpt_header_format , {
"Format" , "rtmpt.header.format" , FT_UINT8 , BASE_DEC , NULL , 0xC0 , "RTMPT Basic Header format" , HFILL }
}
, {
& hf_rtmpt_header_csid , {
"Chunk Stream ID" , "rtmpt.header.csid" , FT_UINT8 , BASE_DEC , NULL , 0x3F , "RTMPT Basic Header chunk stream ID" , HFILL }
}
, {
& hf_rtmpt_header_timestamp , {
"Timestamp" , "rtmpt.header.timestamp" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Message Header timestamp" , HFILL }
}
, {
& hf_rtmpt_header_timestamp_delta , {
"Timestamp delta" , "rtmpt.header.timestampdelta" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Message Header timestamp delta" , HFILL }
}
, {
& hf_rtmpt_header_body_size , {
"Body size" , "rtmpt.header.bodysize" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Message Header body size" , HFILL }
}
, {
& hf_rtmpt_header_typeid , {
"Type ID" , "rtmpt.header.typeid" , FT_UINT8 , BASE_HEX , VALS ( rtmpt_opcode_vals ) , 0x0 , "RTMPT Message Header type ID" , HFILL }
}
, {
& hf_rtmpt_header_streamid , {
"Stream ID" , "rtmpt.header.streamid" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT Header stream ID" , HFILL }
}
, {
& hf_rtmpt_header_ets , {
"Extended timestamp" , "rtmpt.header.ets" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Message Header extended timestamp" , HFILL }
}
, {
& hf_rtmpt_scm_chunksize , {
"Chunk size" , "rtmpt.scm.chunksize" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT SCM chunk size" , HFILL }
}
, {
& hf_rtmpt_scm_csid , {
"Chunk stream ID" , "rtmpt.scm.csid" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT SCM chunk stream ID" , HFILL }
}
, {
& hf_rtmpt_scm_seq , {
"Sequence number" , "rtmpt.scm.seq" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT SCM acknowledgement sequence number" , HFILL }
}
, {
& hf_rtmpt_scm_was , {
"Window acknowledgement size" , "rtmpt.scm.was" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT SCM window acknowledgement size" , HFILL }
}
, {
& hf_rtmpt_scm_limittype , {
"Limit type" , "rtmpt.scm.limittype" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_limit_vals ) , 0x0 , "RTMPT SCM window acknowledgement size" , HFILL }
}
, {
& hf_rtmpt_ucm_eventtype , {
"Event type" , "rtmpt.ucm.eventtype" , FT_UINT16 , BASE_DEC , VALS ( rtmpt_ucm_vals ) , 0x0 , "RTMPT UCM event type" , HFILL }
}
, {
& hf_rtmpt_function_call , {
"Response to this call in frame" , "rtmpt.function.call" , FT_FRAMENUM , BASE_NONE , NULL , 0x0 , "RTMPT function call" , HFILL }
}
, {
& hf_rtmpt_function_response , {
"Call for this response in frame" , "rtmpt.function.response" , FT_FRAMENUM , BASE_NONE , NULL , 0x0 , "RTMPT function response" , HFILL }
}
, {
& hf_rtmpt_audio_control , {
"Audio control" , "rtmpt.audio.control" , FT_UINT8 , BASE_HEX , NULL , 0x0 , "RTMPT Audio control" , HFILL }
}
, {
& hf_rtmpt_audio_format , {
"Format" , "rtmpt.audio.format" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_audio_codecs ) , 0xf0 , "RTMPT Audio format" , HFILL }
}
, {
& hf_rtmpt_audio_rate , {
"Sample rate" , "rtmpt.audio.rate" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_audio_rates ) , 0x0c , "RTMPT Audio sample rate" , HFILL }
}
, {
& hf_rtmpt_audio_size , {
"Sample size" , "rtmpt.audio.size" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_audio_sizes ) , 0x02 , "RTMPT Audio sample size" , HFILL }
}
, {
& hf_rtmpt_audio_type , {
"Channels" , "rtmpt.audio.type" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_audio_types ) , 0x01 , "RTMPT Audio channel count" , HFILL }
}
, {
& hf_rtmpt_audio_data , {
"Audio data" , "rtmpt.audio.data" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Audio data" , HFILL }
}
, {
& hf_rtmpt_video_control , {
"Video control" , "rtmpt.video.control" , FT_UINT8 , BASE_HEX , NULL , 0x0 , "RTMPT Video control" , HFILL }
}
, {
& hf_rtmpt_video_type , {
"Type" , "rtmpt.video.type" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_video_types ) , 0xf0 , "RTMPT Video type" , HFILL }
}
, {
& hf_rtmpt_video_format , {
"Format" , "rtmpt.video.format" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_video_codecs ) , 0x0f , "RTMPT Video format" , HFILL }
}
, {
& hf_rtmpt_video_data , {
"Video data" , "rtmpt.video.data" , FT_BYTES , BASE_NONE , NULL , 0x0 , "RTMPT Video data" , HFILL }
}
, {
& hf_rtmpt_tag_type , {
"Type" , "rtmpt.tag.type" , FT_UINT8 , BASE_DEC , VALS ( rtmpt_tag_vals ) , 0x0 , "RTMPT Aggregate tag type" , HFILL }
}
, {
& hf_rtmpt_tag_datasize , {
"Data size" , "rtmpt.tag.datasize" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Aggregate tag data size" , HFILL }
}
, {
& hf_rtmpt_tag_timestamp , {
"Timestamp" , "rtmpt.tag.timestamp" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Aggregate tag timestamp" , HFILL }
}
, {
& hf_rtmpt_tag_ets , {
"Timestamp Extended" , "rtmpt.tag.ets" , FT_UINT8 , BASE_DEC , NULL , 0x0 , "RTMPT Aggregate tag timestamp extended" , HFILL }
}
, {
& hf_rtmpt_tag_streamid , {
"Stream ID" , "rtmpt.tag.streamid" , FT_UINT24 , BASE_DEC , NULL , 0x0 , "RTMPT Aggregate tag stream ID" , HFILL }
}
, {
& hf_rtmpt_tag_tagsize , {
"Previous tag size" , "rtmpt.tag.tagsize" , FT_UINT32 , BASE_DEC , NULL , 0x0 , "RTMPT Aggregate previous tag size" , HFILL }
}
}
;
static gint * ett [ ] = {
& ett_rtmpt , & ett_rtmpt_handshake , & ett_rtmpt_header , & ett_rtmpt_body , & ett_rtmpt_ucm , & ett_rtmpt_audio_control , & ett_rtmpt_video_control , & ett_rtmpt_tag , & ett_rtmpt_tag_data }
;
module_t * rtmpt_module ;
proto_rtmpt = proto_register_protocol ( "Real Time Messaging Protocol" , "RTMPT" , "rtmpt" ) ;
proto_register_field_array ( proto_rtmpt , hf , array_length ( hf ) ) ;
proto_register_subtree_array ( ett , array_length ( ett ) ) ;
rtmpt_module = prefs_register_protocol ( proto_rtmpt , NULL ) ;
prefs_register_bool_preference ( rtmpt_module , "desegment" , "Reassemble RTMPT messages spanning multiple TCP segments" , "Whether the RTMPT dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\"" " in the TCP protocol settings." , & rtmpt_desegment ) ;
prefs_register_uint_preference ( rtmpt_module , "max_packet_size" , "Maximum packet size" , "The largest acceptable packet size for reassembly" , 10 , & rtmpt_max_packet_size ) ;
}
| 0False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.