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 | int ff_h264_decode_mb_cabac ( H264Context * h ) {
int mb_xy ;
int mb_type , partition_count , cbp = 0 ;
int dct8x8_allowed = h -> pps . transform_8x8_mode ;
int decode_chroma = h -> sps . chroma_format_idc == 1 || h -> sps . chroma_format_idc == 2 ;
const int pixel_shift = h -> pixel_shift ;
mb_xy = h -> mb_xy = h -> mb_x + h -> mb_y * h -> mb_stride ;
tprintf ( h -> avctx , "pic:%d mb:%d/%d\n" , h -> frame_num , h -> mb_x , h -> mb_y ) ;
if ( h -> slice_type_nos != AV_PICTURE_TYPE_I ) {
int skip ;
if ( FRAME_MBAFF && ( h -> mb_y & 1 ) == 1 && h -> prev_mb_skipped ) skip = h -> next_mb_skipped ;
else skip = decode_cabac_mb_skip ( h , h -> mb_x , h -> mb_y ) ;
if ( skip ) {
if ( FRAME_MBAFF && ( h -> mb_y & 1 ) == 0 ) {
h -> cur_pic . f . mb_type [ mb_xy ] = MB_TYPE_SKIP ;
h -> next_mb_skipped = decode_cabac_mb_skip ( h , h -> mb_x , h -> mb_y + 1 ) ;
if ( ! h -> next_mb_skipped ) h -> mb_mbaff = h -> mb_field_decoding_flag = decode_cabac_field_decoding_flag ( h ) ;
}
decode_mb_skip ( h ) ;
h -> cbp_table [ mb_xy ] = 0 ;
h -> chroma_pred_mode_table [ mb_xy ] = 0 ;
h -> last_qscale_diff = 0 ;
return 0 ;
}
}
if ( FRAME_MBAFF ) {
if ( ( h -> mb_y & 1 ) == 0 ) h -> mb_mbaff = h -> mb_field_decoding_flag = decode_cabac_field_decoding_flag ( h ) ;
}
h -> prev_mb_skipped = 0 ;
fill_decode_neighbors ( h , - ( MB_FIELD ) ) ;
if ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) {
int ctx = 0 ;
assert ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) ;
if ( ! IS_DIRECT ( h -> left_type [ LTOP ] - 1 ) ) ctx ++ ;
if ( ! IS_DIRECT ( h -> top_type - 1 ) ) ctx ++ ;
if ( ! get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + ctx ] ) ) {
mb_type = 0 ;
}
else if ( ! get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 3 ] ) ) {
mb_type = 1 + get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;
}
else {
int bits ;
bits = get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 4 ] ) << 3 ;
bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) << 2 ;
bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) << 1 ;
bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;
if ( bits < 8 ) {
mb_type = bits + 3 ;
}
else if ( bits == 13 ) {
mb_type = decode_cabac_intra_mb_type ( h , 32 , 0 ) ;
goto decode_intra_mb ;
}
else if ( bits == 14 ) {
mb_type = 11 ;
}
else if ( bits == 15 ) {
mb_type = 22 ;
}
else {
bits = ( bits << 1 ) + get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;
mb_type = bits - 4 ;
}
}
partition_count = b_mb_type_info [ mb_type ] . partition_count ;
mb_type = b_mb_type_info [ mb_type ] . type ;
}
else if ( h -> slice_type_nos == AV_PICTURE_TYPE_P ) {
if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 14 ] ) == 0 ) {
if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 15 ] ) == 0 ) {
mb_type = 3 * get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 16 ] ) ;
}
else {
mb_type = 2 - get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 17 ] ) ;
}
partition_count = p_mb_type_info [ mb_type ] . partition_count ;
mb_type = p_mb_type_info [ mb_type ] . type ;
}
else {
mb_type = decode_cabac_intra_mb_type ( h , 17 , 0 ) ;
goto decode_intra_mb ;
}
}
else {
mb_type = decode_cabac_intra_mb_type ( h , 3 , 1 ) ;
if ( h -> slice_type == AV_PICTURE_TYPE_SI && mb_type ) mb_type -- ;
assert ( h -> slice_type_nos == AV_PICTURE_TYPE_I ) ;
decode_intra_mb : partition_count = 0 ;
cbp = i_mb_type_info [ mb_type ] . cbp ;
h -> intra16x16_pred_mode = i_mb_type_info [ mb_type ] . pred_mode ;
mb_type = i_mb_type_info [ mb_type ] . type ;
}
if ( MB_FIELD ) mb_type |= MB_TYPE_INTERLACED ;
h -> slice_table [ mb_xy ] = h -> slice_num ;
if ( IS_INTRA_PCM ( mb_type ) ) {
const int mb_size = ff_h264_mb_sizes [ h -> sps . chroma_format_idc ] * h -> sps . bit_depth_luma >> 3 ;
const uint8_t * ptr ;
ptr = h -> cabac . bytestream ;
if ( h -> cabac . low & 0x1 ) ptr -- ;
if ( CABAC_BITS == 16 ) {
if ( h -> cabac . low & 0x1FF ) ptr -- ;
}
if ( ( int ) ( h -> cabac . bytestream_end - ptr ) < mb_size ) return - 1 ;
h -> intra_pcm_ptr = ptr ;
ptr += mb_size ;
ff_init_cabac_decoder ( & h -> cabac , ptr , h -> cabac . bytestream_end - ptr ) ;
h -> cbp_table [ mb_xy ] = 0xf7ef ;
h -> chroma_pred_mode_table [ mb_xy ] = 0 ;
h -> cur_pic . f . qscale_table [ mb_xy ] = 0 ;
memset ( h -> non_zero_count [ mb_xy ] , 16 , 48 ) ;
h -> cur_pic . f . mb_type [ mb_xy ] = mb_type ;
h -> last_qscale_diff = 0 ;
return 0 ;
}
fill_decode_caches ( h , mb_type ) ;
if ( IS_INTRA ( mb_type ) ) {
int i , pred_mode ;
if ( IS_INTRA4x4 ( mb_type ) ) {
if ( dct8x8_allowed && get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 399 + h -> neighbor_transform_size ] ) ) {
mb_type |= MB_TYPE_8x8DCT ;
for ( i = 0 ;
i < 16 ;
i += 4 ) {
int pred = pred_intra_mode ( h , i ) ;
int mode = decode_cabac_mb_intra4x4_pred_mode ( h , pred ) ;
fill_rectangle ( & h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] , 2 , 2 , 8 , mode , 1 ) ;
}
}
else {
for ( i = 0 ;
i < 16 ;
i ++ ) {
int pred = pred_intra_mode ( h , i ) ;
h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] = decode_cabac_mb_intra4x4_pred_mode ( h , pred ) ;
av_dlog ( h -> avctx , "i4x4 pred=%d mode=%d\n" , pred , h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] ) ;
}
}
write_back_intra_pred_mode ( h ) ;
if ( ff_h264_check_intra4x4_pred_mode ( h ) < 0 ) return - 1 ;
}
else {
h -> intra16x16_pred_mode = ff_h264_check_intra_pred_mode ( h , h -> intra16x16_pred_mode , 0 ) ;
if ( h -> intra16x16_pred_mode < 0 ) return - 1 ;
}
if ( decode_chroma ) {
h -> chroma_pred_mode_table [ mb_xy ] = pred_mode = decode_cabac_mb_chroma_pre_mode ( h ) ;
pred_mode = ff_h264_check_intra_pred_mode ( h , pred_mode , 1 ) ;
if ( pred_mode < 0 ) return - 1 ;
h -> chroma_pred_mode = pred_mode ;
}
else {
h -> chroma_pred_mode = DC_128_PRED8x8 ;
}
}
else if ( partition_count == 4 ) {
int i , j , sub_partition_count [ 4 ] , list , ref [ 2 ] [ 4 ] ;
if ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
h -> sub_mb_type [ i ] = decode_cabac_b_mb_sub_type ( h ) ;
sub_partition_count [ i ] = b_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . partition_count ;
h -> sub_mb_type [ i ] = b_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . type ;
}
if ( IS_DIRECT ( h -> sub_mb_type [ 0 ] | h -> sub_mb_type [ 1 ] | h -> sub_mb_type [ 2 ] | h -> sub_mb_type [ 3 ] ) ) {
ff_h264_pred_direct_motion ( h , & mb_type ) ;
h -> ref_cache [ 0 ] [ scan8 [ 4 ] ] = h -> ref_cache [ 1 ] [ scan8 [ 4 ] ] = h -> ref_cache [ 0 ] [ scan8 [ 12 ] ] = h -> ref_cache [ 1 ] [ scan8 [ 12 ] ] = PART_NOT_AVAILABLE ;
for ( i = 0 ;
i < 4 ;
i ++ ) fill_rectangle ( & h -> direct_cache [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , ( h -> sub_mb_type [ i ] >> 1 ) & 0xFF , 1 ) ;
}
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) {
h -> sub_mb_type [ i ] = decode_cabac_p_mb_sub_type ( h ) ;
sub_partition_count [ i ] = p_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . partition_count ;
h -> sub_mb_type [ i ] = p_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . type ;
}
}
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
if ( IS_DIRECT ( h -> sub_mb_type [ i ] ) ) continue ;
if ( IS_DIR ( h -> sub_mb_type [ i ] , 0 , list ) ) {
int rc = h -> ref_count [ list ] << MB_MBAFF ;
if ( rc > 1 ) {
ref [ list ] [ i ] = decode_cabac_mb_ref ( h , list , 4 * i ) ;
if ( ref [ list ] [ i ] >= ( unsigned ) rc ) {
av_log ( h -> avctx , AV_LOG_ERROR , "Reference %d >= %d\n" , ref [ list ] [ i ] , rc ) ;
return - 1 ;
}
}
else ref [ list ] [ i ] = 0 ;
}
else {
ref [ list ] [ i ] = - 1 ;
}
h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 1 ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 8 ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 9 ] = ref [ list ] [ i ] ;
}
}
if ( dct8x8_allowed ) dct8x8_allowed = get_dct8x8_allowed ( h ) ;
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
h -> ref_cache [ list ] [ scan8 [ 4 * i ] ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 1 ] ;
if ( IS_DIRECT ( h -> sub_mb_type [ i ] ) ) {
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 2 ) ;
continue ;
}
if ( IS_DIR ( h -> sub_mb_type [ i ] , 0 , list ) && ! IS_DIRECT ( h -> sub_mb_type [ i ] ) ) {
const int sub_mb_type = h -> sub_mb_type [ i ] ;
const int block_width = ( sub_mb_type & ( MB_TYPE_16x16 | MB_TYPE_16x8 ) ) ? 2 : 1 ;
for ( j = 0 ;
j < sub_partition_count [ i ] ;
j ++ ) {
int mpx , mpy ;
int mx , my ;
const int index = 4 * i + block_width * j ;
int16_t ( * mv_cache ) [ 2 ] = & h -> mv_cache [ list ] [ scan8 [ index ] ] ;
uint8_t ( * mvd_cache ) [ 2 ] = & h -> mvd_cache [ list ] [ scan8 [ index ] ] ;
pred_motion ( h , index , block_width , list , h -> ref_cache [ list ] [ scan8 [ index ] ] , & mx , & my ) ;
DECODE_CABAC_MB_MVD ( h , list , index ) tprintf ( h -> avctx , "final mv:%d %d\n" , mx , my ) ;
if ( IS_SUB_8X8 ( sub_mb_type ) ) {
mv_cache [ 1 ] [ 0 ] = mv_cache [ 8 ] [ 0 ] = mv_cache [ 9 ] [ 0 ] = mx ;
mv_cache [ 1 ] [ 1 ] = mv_cache [ 8 ] [ 1 ] = mv_cache [ 9 ] [ 1 ] = my ;
mvd_cache [ 1 ] [ 0 ] = mvd_cache [ 8 ] [ 0 ] = mvd_cache [ 9 ] [ 0 ] = mpx ;
mvd_cache [ 1 ] [ 1 ] = mvd_cache [ 8 ] [ 1 ] = mvd_cache [ 9 ] [ 1 ] = mpy ;
}
else if ( IS_SUB_8X4 ( sub_mb_type ) ) {
mv_cache [ 1 ] [ 0 ] = mx ;
mv_cache [ 1 ] [ 1 ] = my ;
mvd_cache [ 1 ] [ 0 ] = mpx ;
mvd_cache [ 1 ] [ 1 ] = mpy ;
}
else if ( IS_SUB_4X8 ( sub_mb_type ) ) {
mv_cache [ 8 ] [ 0 ] = mx ;
mv_cache [ 8 ] [ 1 ] = my ;
mvd_cache [ 8 ] [ 0 ] = mpx ;
mvd_cache [ 8 ] [ 1 ] = mpy ;
}
mv_cache [ 0 ] [ 0 ] = mx ;
mv_cache [ 0 ] [ 1 ] = my ;
mvd_cache [ 0 ] [ 0 ] = mpx ;
mvd_cache [ 0 ] [ 1 ] = mpy ;
}
}
else {
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 4 ) ;
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 2 ) ;
}
}
}
}
else if ( IS_DIRECT ( mb_type ) ) {
ff_h264_pred_direct_motion ( h , & mb_type ) ;
fill_rectangle ( h -> mvd_cache [ 0 ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 2 ) ;
fill_rectangle ( h -> mvd_cache [ 1 ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 2 ) ;
dct8x8_allowed &= h -> sps . direct_8x8_inference_flag ;
}
else {
int list , i ;
if ( IS_16X16 ( mb_type ) ) {
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
if ( IS_DIR ( mb_type , 0 , list ) ) {
int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;
if ( rc > 1 ) {
ref = decode_cabac_mb_ref ( h , list , 0 ) ;
if ( ref >= ( unsigned ) rc ) {
av_log ( h -> avctx , AV_LOG_ERROR , "Reference %d >= %d\n" , ref , rc ) ;
return - 1 ;
}
}
else ref = 0 ;
fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , ref , 1 ) ;
}
}
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
if ( IS_DIR ( mb_type , 0 , list ) ) {
int mx , my , mpx , mpy ;
pred_motion ( h , 0 , 4 , list , h -> ref_cache [ list ] [ scan8 [ 0 ] ] , & mx , & my ) ;
DECODE_CABAC_MB_MVD ( h , list , 0 ) tprintf ( h -> avctx , "final mv:%d %d\n" , mx , my ) ;
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , pack16to32 ( mx , my ) , 4 ) ;
}
}
}
else if ( IS_16X8 ( mb_type ) ) {
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( IS_DIR ( mb_type , i , list ) ) {
int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;
if ( rc > 1 ) {
ref = decode_cabac_mb_ref ( h , list , 8 * i ) ;
if ( ref >= ( unsigned ) rc ) {
av_log ( h -> avctx , AV_LOG_ERROR , "Reference %d >= %d\n" , ref , rc ) ;
return - 1 ;
}
}
else ref = 0 ;
fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , ref , 1 ) ;
}
else fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , ( LIST_NOT_USED & 0xFF ) , 1 ) ;
}
}
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( IS_DIR ( mb_type , i , list ) ) {
int mx , my , mpx , mpy ;
pred_16x8_motion ( h , 8 * i , list , h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , & mx , & my ) ;
DECODE_CABAC_MB_MVD ( h , list , 8 * i ) tprintf ( h -> avctx , "final mv:%d %d\n" , mx , my ) ;
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , pack16to32 ( mx , my ) , 4 ) ;
}
else {
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , 0 , 2 ) ;
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , 0 , 4 ) ;
}
}
}
}
else {
assert ( IS_8X16 ( mb_type ) ) ;
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( IS_DIR ( mb_type , i , list ) ) {
int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;
if ( rc > 1 ) {
ref = decode_cabac_mb_ref ( h , list , 4 * i ) ;
if ( ref >= ( unsigned ) rc ) {
av_log ( h -> avctx , AV_LOG_ERROR , "Reference %d >= %d\n" , ref , rc ) ;
return - 1 ;
}
}
else ref = 0 ;
fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , ref , 1 ) ;
}
else fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , ( LIST_NOT_USED & 0xFF ) , 1 ) ;
}
}
for ( list = 0 ;
list < h -> list_count ;
list ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( IS_DIR ( mb_type , i , list ) ) {
int mx , my , mpx , mpy ;
pred_8x16_motion ( h , i * 4 , list , h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , & mx , & my ) ;
DECODE_CABAC_MB_MVD ( h , list , 4 * i ) tprintf ( h -> avctx , "final mv:%d %d\n" , mx , my ) ;
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , pack16to32 ( mx , my ) , 4 ) ;
}
else {
fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , 0 , 2 ) ;
fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , 0 , 4 ) ;
}
}
}
}
}
if ( IS_INTER ( mb_type ) ) {
h -> chroma_pred_mode_table [ mb_xy ] = 0 ;
write_back_motion ( h , mb_type ) ;
}
if ( ! IS_INTRA16x16 ( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma ( h ) ;
if ( decode_chroma ) cbp |= decode_cabac_mb_cbp_chroma ( h ) << 4 ;
}
h -> cbp_table [ mb_xy ] = h -> cbp = cbp ;
if ( dct8x8_allowed && ( cbp & 15 ) && ! IS_INTRA ( mb_type ) ) {
mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 399 + h -> neighbor_transform_size ] ) ;
}
if ( CHROMA444 && IS_8x8DCT ( mb_type ) ) {
int i ;
uint8_t * nnz_cache = h -> non_zero_count_cache ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( h -> left_type [ LEFT ( i ) ] && ! IS_8x8DCT ( h -> left_type [ LEFT ( i ) ] ) ) {
nnz_cache [ 3 + 8 * 1 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 2 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 6 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 7 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 11 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 12 + 2 * 8 * i ] = IS_INTRA ( mb_type ) ? 64 : 0 ;
}
}
if ( h -> top_type && ! IS_8x8DCT ( h -> top_type ) ) {
uint32_t top_empty = CABAC && ! IS_INTRA ( mb_type ) ? 0 : 0x40404040 ;
AV_WN32A ( & nnz_cache [ 4 + 8 * 0 ] , top_empty ) ;
AV_WN32A ( & nnz_cache [ 4 + 8 * 5 ] , top_empty ) ;
AV_WN32A ( & nnz_cache [ 4 + 8 * 10 ] , top_empty ) ;
}
}
h -> cur_pic . f . mb_type [ mb_xy ] = mb_type ;
if ( cbp || IS_INTRA16x16 ( mb_type ) ) {
const uint8_t * scan , * scan8x8 ;
const uint32_t * qmul ;
if ( IS_INTERLACED ( mb_type ) ) {
scan8x8 = h -> qscale ? h -> field_scan8x8 : h -> field_scan8x8_q0 ;
scan = h -> qscale ? h -> field_scan : h -> field_scan_q0 ;
}
else {
scan8x8 = h -> qscale ? h -> zigzag_scan8x8 : h -> zigzag_scan8x8_q0 ;
scan = h -> qscale ? h -> zigzag_scan : h -> zigzag_scan_q0 ;
}
if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 60 + ( h -> last_qscale_diff != 0 ) ] ) ) {
int val = 1 ;
int ctx = 2 ;
const int max_qp = 51 + 6 * ( h -> sps . bit_depth_luma - 8 ) ;
while ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 60 + ctx ] ) ) {
ctx = 3 ;
val ++ ;
if ( val > 2 * max_qp ) {
av_log ( h -> avctx , AV_LOG_ERROR , "cabac decode of qscale diff failed at %d %d\n" , h -> mb_x , h -> mb_y ) ;
return - 1 ;
}
}
if ( val & 0x01 ) val = ( val + 1 ) >> 1 ;
else val = - ( ( val + 1 ) >> 1 ) ;
h -> last_qscale_diff = val ;
h -> qscale += val ;
if ( ( ( unsigned ) h -> qscale ) > max_qp ) {
if ( h -> qscale < 0 ) h -> qscale += max_qp + 1 ;
else h -> qscale -= max_qp + 1 ;
}
h -> chroma_qp [ 0 ] = get_chroma_qp ( h , 0 , h -> qscale ) ;
h -> chroma_qp [ 1 ] = get_chroma_qp ( h , 1 , h -> qscale ) ;
}
else h -> last_qscale_diff = 0 ;
decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 0 ) ;
if ( CHROMA444 ) {
decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 1 ) ;
decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 2 ) ;
}
else if ( CHROMA422 ) {
if ( cbp & 0x30 ) {
int c ;
for ( c = 0 ;
c < 2 ;
c ++ ) decode_cabac_residual_dc_422 ( h , h -> mb + ( ( 256 + 16 * 16 * c ) << pixel_shift ) , 3 , CHROMA_DC_BLOCK_INDEX + c , chroma422_dc_scan , 8 ) ;
}
if ( cbp & 0x20 ) {
int c , i , i8x8 ;
for ( c = 0 ;
c < 2 ;
c ++ ) {
int16_t * mb = h -> mb + ( 16 * ( 16 + 16 * c ) << pixel_shift ) ;
qmul = h -> dequant4_coeff [ c + 1 + ( IS_INTRA ( mb_type ) ? 0 : 3 ) ] [ h -> chroma_qp [ c ] ] ;
for ( i8x8 = 0 ;
i8x8 < 2 ;
i8x8 ++ ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
const int index = 16 + 16 * c + 8 * i8x8 + i ;
decode_cabac_residual_nondc ( h , mb , 4 , index , scan + 1 , qmul , 15 ) ;
mb += 16 << pixel_shift ;
}
}
}
}
else {
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
}
}
else {
if ( cbp & 0x30 ) {
int c ;
for ( c = 0 ;
c < 2 ;
c ++ ) decode_cabac_residual_dc ( h , h -> mb + ( ( 256 + 16 * 16 * c ) << pixel_shift ) , 3 , CHROMA_DC_BLOCK_INDEX + c , chroma_dc_scan , 4 ) ;
}
if ( cbp & 0x20 ) {
int c , i ;
for ( c = 0 ;
c < 2 ;
c ++ ) {
qmul = h -> dequant4_coeff [ c + 1 + ( IS_INTRA ( mb_type ) ? 0 : 3 ) ] [ h -> chroma_qp [ c ] ] ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
const int index = 16 + 16 * c + i ;
decode_cabac_residual_nondc ( h , h -> mb + ( 16 * index << pixel_shift ) , 4 , index , scan + 1 , qmul , 15 ) ;
}
}
}
else {
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
}
}
}
else {
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;
h -> last_qscale_diff = 0 ;
}
h -> cur_pic . f . qscale_table [ mb_xy ] = h -> qscale ;
write_back_non_zero_count ( h ) ;
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void usage ( const char * name ) {
( printf ) ( "Usage: %s [OPTIONS] FILE\n" "QEMU Disk Network Block Device Server\n" "\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n" "Connection properties:\n" " -p, --port=PORT port to listen on (default `%d')\n" " -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n" " -k, --socket=PATH path to the unix socket\n" " (default '" SOCKET_PATH "')\n" " -e, --shared=NUM device can be shared by NUM clients (default '1')\n" " -t, --persistent don't exit on the last connection\n" " -v, --verbose display extra debugging information\n" " -x, --export-name=NAME expose export by name\n" " -D, --description=TEXT with -x, also export a human-readable description\n" "\n" "Exposing part of the image:\n" " -o, --offset=OFFSET offset into the image\n" " -P, --partition=NUM only expose partition NUM\n" "\n" "General purpose options:\n" " --object type,id=ID,... define an object such as 'secret' for providing\n" " passwords and/or encryption keys\n" " -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n" " specify tracing options\n" " --fork fork off the server process and exit the parent\n" " once the server is running\n" # ifdef __linux__ "Kernel NBD client support:\n" " -c, --connect=DEV connect FILE to the local NBD device DEV\n" " -d, --disconnect disconnect the specified device\n" "\n" # endif "\n" "Block device options:\n" " -f, --format=FORMAT set image format (raw, qcow2, ...)\n" " -r, --read-only export read-only\n" " -s, --snapshot use FILE as an external snapshot, create a temporary\n" " file with backing_file=FILE, redirect the write to\n" " the temporary one\n" " -l, --load-snapshot=SNAPSHOT_PARAM\n" " load an internal snapshot inside FILE and export it\n" " as an read-only device, SNAPSHOT_PARAM format is\n" " 'snapshot.id=[ID],snapshot.name=[NAME]', or\n" " '[ID_OR_NAME]'\n" " -n, --nocache disable host cache\n" " --cache=MODE set cache mode (none, writeback, ...)\n" " --aio=MODE set AIO mode (native or threads)\n" " --discard=MODE set discard mode (ignore, unmap)\n" " --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n" " --image-opts treat FILE as a full set of image options\n" "\n" "Report bugs to <[email protected]>\n" , name , NBD_DEFAULT_PORT , "DEVICE" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ImportRGBOQuantum ( const Image * image , QuantumInfo * quantum_info , const MagickSizeType number_pixels , const unsigned char * magick_restrict p , Quantum * magick_restrict q , ExceptionInfo * exception ) {
QuantumAny range ;
register ssize_t x ;
unsigned int pixel ;
assert ( image != ( Image * ) NULL ) ;
assert ( image -> signature == MagickCoreSignature ) ;
switch ( quantum_info -> depth ) {
case 8 : {
unsigned char pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushCharPixel ( p , & pixel ) ;
SetPixelRed ( image , ScaleCharToQuantum ( pixel ) , q ) ;
p = PushCharPixel ( p , & pixel ) ;
SetPixelGreen ( image , ScaleCharToQuantum ( pixel ) , q ) ;
p = PushCharPixel ( p , & pixel ) ;
SetPixelBlue ( image , ScaleCharToQuantum ( pixel ) , q ) ;
p = PushCharPixel ( p , & pixel ) ;
SetPixelOpacity ( image , ScaleCharToQuantum ( pixel ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 10 : {
pixel = 0 ;
if ( quantum_info -> pack == MagickFalse ) {
register ssize_t i ;
size_t quantum ;
ssize_t n ;
n = 0 ;
quantum = 0 ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
switch ( n % 3 ) {
case 0 : {
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
quantum = ( size_t ) ( ScaleShortToQuantum ( ( unsigned short ) ( ( ( pixel >> 22 ) & 0x3ff ) << 6 ) ) ) ;
break ;
}
case 1 : {
quantum = ( size_t ) ( ScaleShortToQuantum ( ( unsigned short ) ( ( ( pixel >> 12 ) & 0x3ff ) << 6 ) ) ) ;
break ;
}
case 2 : {
quantum = ( size_t ) ( ScaleShortToQuantum ( ( unsigned short ) ( ( ( pixel >> 2 ) & 0x3ff ) << 6 ) ) ) ;
break ;
}
}
switch ( i ) {
case 0 : SetPixelRed ( image , ( Quantum ) quantum , q ) ;
break ;
case 1 : SetPixelGreen ( image , ( Quantum ) quantum , q ) ;
break ;
case 2 : SetPixelBlue ( image , ( Quantum ) quantum , q ) ;
break ;
case 3 : SetPixelOpacity ( image , ( Quantum ) quantum , q ) ;
break ;
}
n ++ ;
}
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) ( pixel << 6 ) ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) ( pixel << 6 ) ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) ( pixel << 6 ) ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelOpacity ( image , ScaleShortToQuantum ( ( unsigned short ) ( pixel << 6 ) ) , q ) ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 16 : {
unsigned short pixel ;
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelRed ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelGreen ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelBlue ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelOpacity ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelRed ( image , ScaleShortToQuantum ( pixel ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelGreen ( image , ScaleShortToQuantum ( pixel ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelBlue ( image , ScaleShortToQuantum ( pixel ) , q ) ;
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelOpacity ( image , ScaleShortToQuantum ( pixel ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 32 : {
unsigned int pixel ;
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
float pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushFloatPixel ( quantum_info , p , & pixel ) ;
SetPixelRed ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushFloatPixel ( quantum_info , p , & pixel ) ;
SetPixelGreen ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushFloatPixel ( quantum_info , p , & pixel ) ;
SetPixelBlue ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushFloatPixel ( quantum_info , p , & pixel ) ;
SetPixelOpacity ( image , ClampToQuantum ( pixel ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelRed ( image , ScaleLongToQuantum ( pixel ) , q ) ;
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelGreen ( image , ScaleLongToQuantum ( pixel ) , q ) ;
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelBlue ( image , ScaleLongToQuantum ( pixel ) , q ) ;
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelOpacity ( image , ScaleLongToQuantum ( pixel ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 64 : {
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
double pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushDoublePixel ( quantum_info , p , & pixel ) ;
SetPixelRed ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushDoublePixel ( quantum_info , p , & pixel ) ;
SetPixelGreen ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushDoublePixel ( quantum_info , p , & pixel ) ;
SetPixelBlue ( image , ClampToQuantum ( pixel ) , q ) ;
p = PushDoublePixel ( quantum_info , p , & pixel ) ;
SetPixelOpacity ( image , ClampToQuantum ( pixel ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
}
default : {
range = GetQuantumRange ( quantum_info -> depth ) ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelRed ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelGreen ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelBlue ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ;
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelOpacity ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ;
q += GetPixelChannels ( image ) ;
}
break ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static uint32_t PREP_io_800_readb ( void * opaque , uint32_t addr ) {
sysctrl_t * sysctrl = opaque ;
uint32_t retval = 0xFF ;
switch ( addr ) {
case 0x0092 : retval = sysctrl -> endian << 1 ;
break ;
case 0x0800 : retval = 0xEF ;
break ;
case 0x0802 : retval = 0xAD ;
break ;
case 0x0803 : retval = 0xE0 ;
break ;
case 0x080C : retval = 0x3C ;
break ;
case 0x0810 : retval = 0x39 ;
break ;
case 0x0814 : break ;
case 0x0818 : retval = 0x00 ;
break ;
case 0x081C : retval = sysctrl -> syscontrol ;
break ;
case 0x0823 : retval = 0x03 ;
break ;
case 0x0850 : retval = sysctrl -> contiguous_map ;
break ;
default : printf ( "ERROR: unaffected IO port: %04" PRIx32 " read\n" , addr ) ;
break ;
}
PPC_IO_DPRINTF ( "0x%08" PRIx32 " <= 0x%02" PRIx32 "\n" , addr - PPC_IO_BASE , retval ) ;
return retval ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int combined_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int mi_row , int mi_col , int_mv * tmp_mv , int * rate_mv , int64_t best_rd_sofar ) {
MACROBLOCKD * xd = & x -> e_mbd ;
MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ;
struct buf_2d backup_yv12 [ MAX_MB_PLANE ] = {
{
0 , 0 }
}
;
const int step_param = cpi -> sf . mv . fullpel_search_step_param ;
const int sadpb = x -> sadperbit16 ;
MV mvp_full ;
const int ref = mbmi -> ref_frame [ 0 ] ;
const MV ref_mv = mbmi -> ref_mvs [ ref ] [ 0 ] . as_mv ;
int dis ;
int rate_mode ;
const int tmp_col_min = x -> mv_col_min ;
const int tmp_col_max = x -> mv_col_max ;
const int tmp_row_min = x -> mv_row_min ;
const int tmp_row_max = x -> mv_row_max ;
int rv = 0 ;
int sad_list [ 5 ] ;
const YV12_BUFFER_CONFIG * scaled_ref_frame = vp9_get_scaled_ref_frame ( cpi , ref ) ;
if ( cpi -> common . show_frame && ( x -> pred_mv_sad [ ref ] >> 3 ) > x -> pred_mv_sad [ LAST_FRAME ] ) return rv ;
if ( scaled_ref_frame ) {
int i ;
for ( i = 0 ;
i < MAX_MB_PLANE ;
i ++ ) backup_yv12 [ i ] = xd -> plane [ i ] . pre [ 0 ] ;
vp9_setup_pre_planes ( xd , 0 , scaled_ref_frame , mi_row , mi_col , NULL ) ;
}
vp9_set_mv_search_range ( x , & ref_mv ) ;
assert ( x -> mv_best_ref_index [ ref ] <= 2 ) ;
if ( x -> mv_best_ref_index [ ref ] < 2 ) mvp_full = mbmi -> ref_mvs [ ref ] [ x -> mv_best_ref_index [ ref ] ] . as_mv ;
else mvp_full = x -> pred_mv [ ref ] ;
mvp_full . col >>= 3 ;
mvp_full . row >>= 3 ;
vp9_full_pixel_search ( cpi , x , bsize , & mvp_full , step_param , sadpb , cond_sad_list ( cpi , sad_list ) , & ref_mv , & tmp_mv -> as_mv , INT_MAX , 0 ) ;
x -> mv_col_min = tmp_col_min ;
x -> mv_col_max = tmp_col_max ;
x -> mv_row_min = tmp_row_min ;
x -> mv_row_max = tmp_row_max ;
mvp_full . row = tmp_mv -> as_mv . row * 8 ;
mvp_full . col = tmp_mv -> as_mv . col * 8 ;
* rate_mv = vp9_mv_bit_cost ( & mvp_full , & ref_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ;
rate_mode = cpi -> inter_mode_cost [ mbmi -> mode_context [ ref ] ] [ INTER_OFFSET ( NEWMV ) ] ;
rv = ! ( RDCOST ( x -> rdmult , x -> rddiv , ( * rate_mv + rate_mode ) , 0 ) > best_rd_sofar ) ;
if ( rv ) {
cpi -> find_fractional_mv_step ( x , & tmp_mv -> as_mv , & ref_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , cpi -> sf . mv . subpel_force_stop , cpi -> sf . mv . subpel_iters_per_step , cond_sad_list ( cpi , sad_list ) , x -> nmvjointcost , x -> mvcost , & dis , & x -> pred_sse [ ref ] , NULL , 0 , 0 ) ;
x -> pred_mv [ ref ] = tmp_mv -> as_mv ;
}
if ( scaled_ref_frame ) {
int i ;
for ( i = 0 ;
i < MAX_MB_PLANE ;
i ++ ) xd -> plane [ i ] . pre [ 0 ] = backup_yv12 [ i ] ;
}
return rv ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | TEST ( URLFixerTest , FixupURL ) {
for ( size_t i = 0 ;
i < arraysize ( fixup_cases ) ;
++ i ) {
FixupCase value = fixup_cases [ i ] ;
EXPECT_EQ ( value . output , url_formatter : : FixupURL ( value . input , "" ) . possibly_invalid_spec ( ) ) << "input: " << value . input ;
}
FixupCase tld_cases [ ] = {
{
"somedomainthatwillnotbeagtld" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"somedomainthatwillnotbeagtld." , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"somedomainthatwillnotbeagtld.." , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
".somedomainthatwillnotbeagtld" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"www.somedomainthatwillnotbeagtld" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"somedomainthatwillnotbeagtld.com" , "http://somedomainthatwillnotbeagtld.com/" }
, {
"http://somedomainthatwillnotbeagtld" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"..somedomainthatwillnotbeagtld.." , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"http://www.somedomainthatwillnotbeagtld" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"9999999999999999" , "http://www.9999999999999999.com/" }
, {
"somedomainthatwillnotbeagtld/foo" , "http://www.somedomainthatwillnotbeagtld.com/foo" }
, {
"somedomainthatwillnotbeagtld.com/foo" , "http://somedomainthatwillnotbeagtld.com/foo" }
, {
"somedomainthatwillnotbeagtld/?foo=.com" , "http://www.somedomainthatwillnotbeagtld.com/?foo=.com" }
, {
"www.somedomainthatwillnotbeagtld/?foo=www." , "http://www.somedomainthatwillnotbeagtld.com/?foo=www." }
, {
"somedomainthatwillnotbeagtld.com/?foo=.com" , "http://somedomainthatwillnotbeagtld.com/?foo=.com" }
, {
"http://www.somedomainthatwillnotbeagtld.com" , "http://www.somedomainthatwillnotbeagtld.com/" }
, {
"somedomainthatwillnotbeagtld:123" , "http://www.somedomainthatwillnotbeagtld.com:123/" }
, {
"http://somedomainthatwillnotbeagtld:123" , "http://www.somedomainthatwillnotbeagtld.com:123/" }
, }
;
for ( size_t i = 0 ;
i < arraysize ( tld_cases ) ;
++ i ) {
FixupCase value = tld_cases [ i ] ;
EXPECT_EQ ( value . output , url_formatter : : FixupURL ( value . input , "com" ) . possibly_invalid_spec ( ) ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static ossl_inline void lh_ ## type ## _stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline unsigned long lh_ ## type ## _get_down_load ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_get_down_load ( ( OPENSSL_LHASH * ) lh ) ;
}
static ossl_inline void lh_ ## type ## _set_down_load ( LHASH_OF ( type ) * lh , unsigned long dl ) {
OPENSSL_LH_set_down_load ( ( OPENSSL_LHASH * ) lh , dl ) ;
}
static ossl_inline void lh_ ## type ## _doall ( LHASH_OF ( type ) * lh , void ( * doall ) ( type * ) ) {
OPENSSL_LH_doall ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNC ) doall ) ;
}
LHASH_OF ( type ) # define IMPLEMENT_LHASH_DOALL_ARG_CONST ( type , argtype ) int_implement_lhash_doall ( type , argtype , const type ) # define IMPLEMENT_LHASH_DOALL_ARG ( type , argtype ) int_implement_lhash_doall ( type , argtype , type ) # define int_implement_lhash_doall ( type , argtype , cbargtype ) static ossl_inline void lh_ ## type ## _doall_ ## argtype ( LHASH_OF ( type ) * lh , void ( * fn ) ( cbargtype * , argtype * ) , argtype * arg ) {
OPENSSL_LH_doall_arg ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNCARG ) fn , ( void * ) arg ) ;
}
LHASH_OF ( type ) DEFINE_LHASH_OF ( OPENSSL_STRING ) ;
# ifdef _MSC_VER # pragma warning ( push ) # pragma warning ( disable : 4090 ) # endif DEFINE_LHASH_OF ( OPENSSL_CSTRING ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | struct mszipd_stream * mszipd_init ( struct mspack_system * system , struct mspack_file * input , struct mspack_file * output , int input_buffer_size , int repair_mode ) {
struct mszipd_stream * zip ;
if ( ! system ) return NULL ;
input_buffer_size = ( input_buffer_size + 1 ) & - 2 ;
if ( input_buffer_size < 2 ) return NULL ;
if ( ! ( zip = ( struct mszipd_stream * ) system -> alloc ( system , sizeof ( struct mszipd_stream ) ) ) ) {
return NULL ;
}
zip -> inbuf = ( unsigned char * ) system -> alloc ( system , ( size_t ) input_buffer_size ) ;
if ( ! zip -> inbuf ) {
system -> free ( zip ) ;
return NULL ;
}
zip -> sys = system ;
zip -> input = input ;
zip -> output = output ;
zip -> inbuf_size = input_buffer_size ;
zip -> input_end = 0 ;
zip -> error = MSPACK_ERR_OK ;
zip -> repair_mode = repair_mode ;
zip -> flush_window = & mszipd_flush_window ;
zip -> i_ptr = zip -> i_end = & zip -> inbuf [ 0 ] ;
zip -> o_ptr = zip -> o_end = NULL ;
zip -> bit_buffer = 0 ;
zip -> bits_left = 0 ;
return zip ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int tls_process_cke_srp ( SSL * s , PACKET * pkt , int * al ) {
# ifndef OPENSSL_NO_SRP unsigned int i ;
const unsigned char * data ;
if ( ! PACKET_get_net_2 ( pkt , & i ) || ! PACKET_get_bytes ( pkt , & data , i ) ) {
* al = SSL_AD_DECODE_ERROR ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , SSL_R_BAD_SRP_A_LENGTH ) ;
return 0 ;
}
if ( ( s -> srp_ctx . A = BN_bin2bn ( data , i , NULL ) ) == NULL ) {
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , ERR_R_BN_LIB ) ;
return 0 ;
}
if ( BN_ucmp ( s -> srp_ctx . A , s -> srp_ctx . N ) >= 0 || BN_is_zero ( s -> srp_ctx . A ) ) {
* al = SSL_AD_ILLEGAL_PARAMETER ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , SSL_R_BAD_SRP_PARAMETERS ) ;
return 0 ;
}
OPENSSL_free ( s -> session -> srp_username ) ;
s -> session -> srp_username = OPENSSL_strdup ( s -> srp_ctx . login ) ;
if ( s -> session -> srp_username == NULL ) {
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , ERR_R_MALLOC_FAILURE ) ;
return 0 ;
}
if ( ! srp_generate_server_master_secret ( s ) ) {
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , ERR_R_INTERNAL_ERROR ) ;
return 0 ;
}
return 1 ;
# else * al = SSL_AD_INTERNAL_ERROR ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_SRP , ERR_R_INTERNAL_ERROR ) ;
return 0 ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void update_state_rt ( VP9_COMP * cpi , PICK_MODE_CONTEXT * ctx , int mi_row , int mi_col , int bsize ) {
VP9_COMMON * const cm = & cpi -> common ;
MACROBLOCK * const x = & cpi -> mb ;
MACROBLOCKD * const xd = & x -> e_mbd ;
MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ;
const struct segmentation * const seg = & cm -> seg ;
* ( xd -> mi [ 0 ] . src_mi ) = ctx -> mic ;
xd -> mi [ 0 ] . src_mi = & xd -> mi [ 0 ] ;
if ( ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ ) && seg -> enabled ) {
vp9_cyclic_refresh_update_segment ( cpi , & xd -> mi [ 0 ] . src_mi -> mbmi , mi_row , mi_col , bsize , 1 ) ;
vp9_init_plane_quantizers ( cpi , x ) ;
}
if ( is_inter_block ( mbmi ) ) {
vp9_update_mv_count ( cm , xd ) ;
if ( cm -> interp_filter == SWITCHABLE ) {
const int pred_ctx = vp9_get_pred_context_switchable_interp ( xd ) ;
++ cm -> counts . switchable_interp [ pred_ctx ] [ mbmi -> interp_filter ] ;
}
}
x -> skip = ctx -> skip ;
x -> skip_txfm [ 0 ] = mbmi -> segment_id ? 0 : ctx -> skip_txfm [ 0 ] ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | afs_int32 SPR_ListOwned ( struct rx_call * call , afs_int32 aid , prlist * alist , afs_int32 * lastP ) {
afs_int32 code ;
afs_int32 cid = ANONYMOUSID ;
code = listOwned ( call , aid , alist , lastP , & cid ) ;
osi_auditU ( call , PTS_LstOwnEvent , code , AUD_ID , aid , AUD_END ) ;
ViceLog ( 125 , ( "PTS_ListOwned: code %d cid %d aid %d\n" , code , cid , aid ) ) ;
return code ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline uint32_t e1000e_rx_wb_interrupt_cause ( E1000ECore * core , int queue_idx , bool min_threshold_hit ) {
if ( ! msix_enabled ( core -> owner ) ) {
return E1000_ICS_RXT0 | ( min_threshold_hit ? E1000_ICS_RXDMT0 : 0 ) ;
}
return ( queue_idx == 0 ) ? E1000_ICR_RXQ0 : E1000_ICR_RXQ1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void fdct8 ( const tran_low_t * input , tran_low_t * output ) {
tran_high_t s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ;
tran_high_t t0 , t1 , t2 , t3 ;
tran_high_t 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 = x2 * cospi_24_64 + x3 * cospi_8_64 ;
t3 = - x2 * cospi_8_64 + x3 * cospi_24_64 ;
output [ 0 ] = fdct_round_shift ( t0 ) ;
output [ 2 ] = fdct_round_shift ( t2 ) ;
output [ 4 ] = fdct_round_shift ( t1 ) ;
output [ 6 ] = 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 ;
output [ 1 ] = fdct_round_shift ( t0 ) ;
output [ 3 ] = fdct_round_shift ( t2 ) ;
output [ 5 ] = fdct_round_shift ( t1 ) ;
output [ 7 ] = fdct_round_shift ( t3 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void decode_isf_indices_36b ( uint16_t * ind , float * isf_q ) {
int i ;
for ( i = 0 ;
i < 9 ;
i ++ ) isf_q [ i ] = dico1_isf [ ind [ 0 ] ] [ i ] * ( 1.0f / ( 1 << 15 ) ) ;
for ( i = 0 ;
i < 7 ;
i ++ ) isf_q [ i + 9 ] = dico2_isf [ ind [ 1 ] ] [ i ] * ( 1.0f / ( 1 << 15 ) ) ;
for ( i = 0 ;
i < 5 ;
i ++ ) isf_q [ i ] += dico21_isf_36b [ ind [ 2 ] ] [ i ] * ( 1.0f / ( 1 << 15 ) ) ;
for ( i = 0 ;
i < 4 ;
i ++ ) isf_q [ i + 5 ] += dico22_isf_36b [ ind [ 3 ] ] [ i ] * ( 1.0f / ( 1 << 15 ) ) ;
for ( i = 0 ;
i < 7 ;
i ++ ) isf_q [ i + 9 ] += dico23_isf_36b [ ind [ 4 ] ] [ i ] * ( 1.0f / ( 1 << 15 ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | unsigned int vp9_sub_pixel_variance ## W ## x ## H ## _c ( const uint8_t * src , int src_stride , int xoffset , int yoffset , const uint8_t * dst , int dst_stride , unsigned int * sse ) {
uint16_t fdata3 [ ( H + 1 ) * W ] ;
uint8_t temp2 [ H * W ] ;
var_filter_block2d_bil_first_pass ( src , fdata3 , src_stride , 1 , H + 1 , W , BILINEAR_FILTERS_2TAP ( xoffset ) ) ;
var_filter_block2d_bil_second_pass ( fdata3 , temp2 , W , W , H , W , BILINEAR_FILTERS_2TAP ( yoffset ) ) ;
return vp9_variance ## W ## x ## H ## _c ( temp2 , W , dst , dst_stride , sse ) ;
\ }
# define SUBPIX_AVG_VAR ( W , H ) unsigned int vp9_sub_pixel_avg_variance ## W ## x ## H ## _c ( const uint8_t * src , int src_stride , int xoffset , int yoffset , const uint8_t * dst , int dst_stride , unsigned int * sse , const uint8_t * second_pred ) {
uint16_t fdata3 [ ( H + 1 ) * W ] ;
uint8_t temp2 [ H * W ] ;
DECLARE_ALIGNED_ARRAY ( 16 , uint8_t , temp3 , H * W ) ;
var_filter_block2d_bil_first_pass ( src , fdata3 , src_stride , 1 , H + 1 , W , BILINEAR_FILTERS_2TAP ( xoffset ) ) ;
var_filter_block2d_bil_second_pass ( fdata3 , temp2 , W , W , H , W , BILINEAR_FILTERS_2TAP ( yoffset ) ) ;
vp9_comp_avg_pred ( temp3 , second_pred , W , H , temp2 , W ) ;
return vp9_variance ## W ## x ## H ## _c ( temp3 , W , dst , dst_stride , sse ) ;
\ }
void vp9_get16x16var_c ( const uint8_t * src_ptr , int source_stride , const uint8_t * ref_ptr , int ref_stride , unsigned int * sse , int * sum ) {
variance ( src_ptr , source_stride , ref_ptr , ref_stride , 16 , 16 , sse , sum ) ;
}
void vp9_get8x8var_c ( const uint8_t * src_ptr , int source_stride , const uint8_t * ref_ptr , int ref_stride , unsigned int * sse , int * sum ) {
variance ( src_ptr , source_stride , ref_ptr , ref_stride , 8 , 8 , sse , sum ) ;
}
unsigned int vp9_mse16x16_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sse ) {
int sum ;
variance ( src , src_stride , ref , ref_stride , 16 , 16 , sse , & sum ) ;
return * sse ;
}
unsigned int vp9_mse16x8_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sse ) {
int sum ;
variance ( src , src_stride , ref , ref_stride , 16 , 8 , sse , & sum ) ;
return * sse ;
}
unsigned int vp9_mse8x16_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sse ) {
int sum ;
variance ( src , src_stride , ref , ref_stride , 8 , 16 , sse , & sum ) ;
return * sse ;
}
unsigned int vp9_mse8x8_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sse ) {
int sum ;
variance ( src , src_stride , ref , ref_stride , 8 , 8 , sse , & sum ) ;
return * sse ;
}
VAR ( 4 , 4 ) SUBPIX_VAR ( 4 , 4 ) SUBPIX_AVG_VAR ( 4 , 4 ) VAR ( 4 , 8 ) SUBPIX_VAR ( 4 , 8 ) SUBPIX_AVG_VAR ( 4 , 8 ) VAR ( 8 , 4 ) SUBPIX_VAR ( 8 , 4 ) SUBPIX_AVG_VAR ( 8 , 4 ) VAR ( 8 , 8 ) SUBPIX_VAR ( 8 , 8 ) SUBPIX_AVG_VAR ( 8 , 8 ) VAR ( 8 , 16 ) SUBPIX_VAR ( 8 , 16 ) SUBPIX_AVG_VAR ( 8 , 16 ) VAR ( 16 , 8 ) SUBPIX_VAR ( 16 , 8 ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int may_context_mount_sb_relabel ( u32 sid , struct superblock_security_struct * sbsec , const struct cred * cred ) {
const struct task_security_struct * tsec = cred -> security ;
int rc ;
rc = avc_has_perm ( tsec -> sid , sbsec -> sid , SECCLASS_FILESYSTEM , FILESYSTEM__RELABELFROM , NULL ) ;
if ( rc ) return rc ;
rc = avc_has_perm ( tsec -> sid , sid , SECCLASS_FILESYSTEM , FILESYSTEM__RELABELTO , NULL ) ;
return rc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_CPMGetNotify ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree _U_ , gboolean in _U_ , void * data _U_ ) {
col_append_str ( pinfo -> cinfo , COL_INFO , "GetNotify" ) ;
return tvb_reported_length ( tvb ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | unsigned int vp9_mse8x8_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sse ) {
int sum ;
variance ( src , src_stride , ref , ref_stride , 8 , 8 , sse , & sum ) ;
return * sse ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_NewATMVCIndication ( 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_NewATMVCIndication , NewATMVCIndication_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int cont_data_handler ( TSCont contp , TSEvent , void * ) {
MyData * my_data = ( MyData * ) TSContDataGet ( contp ) ;
if ( my_data -> data1 == 1 && my_data -> data2 == 2 ) {
SDK_RPRINT ( SDK_ContData_test , "TSContDataSet" , "TestCase1" , TC_PASS , "ok" ) ;
SDK_RPRINT ( SDK_ContData_test , "TSContDataGet" , "TestCase1" , TC_PASS , "ok" ) ;
* SDK_ContData_pstatus = REGRESSION_TEST_PASSED ;
}
else {
SDK_RPRINT ( SDK_ContData_test , "TSContDataSet" , "TestCase1" , TC_FAIL , "bad data" ) ;
SDK_RPRINT ( SDK_ContData_test , "TSContDataGet" , "TestCase1" , TC_FAIL , "bad data" ) ;
* SDK_ContData_pstatus = REGRESSION_TEST_FAILED ;
}
TSfree ( my_data ) ;
TSContDestroy ( contp ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dump_marks_helper ( FILE * f , uintmax_t base , struct mark_set * m ) {
uintmax_t k ;
if ( m -> shift ) {
for ( k = 0 ;
k < 1024 ;
k ++ ) {
if ( m -> data . sets [ k ] ) dump_marks_helper ( f , base + ( k << m -> shift ) , m -> data . sets [ k ] ) ;
}
}
else {
for ( k = 0 ;
k < 1024 ;
k ++ ) {
if ( m -> data . marked [ k ] ) fprintf ( f , ":%" PRIuMAX " %s\n" , base + k , sha1_to_hex ( m -> data . marked [ k ] -> idx . sha1 ) ) ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int s_aos_seek ( register stream * s , gs_offset_t pos ) {
uint end = s -> srlimit - s -> cbuf + 1 ;
long offset = pos - s -> position ;
if ( offset >= 0 && offset <= end ) {
s -> srptr = s -> cbuf + offset - 1 ;
return 0 ;
}
if ( pos < 0 || pos > s -> file_limit ) return ERRC ;
s -> srptr = s -> srlimit = s -> cbuf - 1 ;
s -> end_status = 0 ;
s -> position = pos ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_H263Resolution ( 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_H263Resolution , H263Resolution_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int nsv_parse_NSVs_header ( AVFormatContext * s ) {
NSVContext * nsv = s -> priv_data ;
AVIOContext * pb = s -> pb ;
uint32_t vtag , atag ;
uint16_t vwidth , vheight ;
AVRational framerate ;
int i ;
AVStream * st ;
NSVStream * nst ;
vtag = avio_rl32 ( pb ) ;
atag = avio_rl32 ( pb ) ;
vwidth = avio_rl16 ( pb ) ;
vheight = avio_rl16 ( pb ) ;
i = avio_r8 ( pb ) ;
av_log ( s , AV_LOG_TRACE , "NSV NSVs framerate code %2x\n" , i ) ;
if ( i & 0x80 ) {
int t = ( i & 0x7F ) >> 2 ;
if ( t < 16 ) framerate = ( AVRational ) {
1 , t + 1 }
;
else framerate = ( AVRational ) {
t - 15 , 1 }
;
if ( i & 1 ) {
framerate . num *= 1000 ;
framerate . den *= 1001 ;
}
if ( ( i & 3 ) == 3 ) framerate . num *= 24 ;
else if ( ( i & 3 ) == 2 ) framerate . num *= 25 ;
else framerate . num *= 30 ;
}
else framerate = ( AVRational ) {
i , 1 }
;
nsv -> avsync = avio_rl16 ( pb ) ;
nsv -> framerate = framerate ;
av_log ( s , AV_LOG_TRACE , "NSV NSVs vsize %dx%d\n" , vwidth , vheight ) ;
if ( s -> nb_streams == 0 ) {
nsv -> vtag = vtag ;
nsv -> atag = atag ;
nsv -> vwidth = vwidth ;
nsv -> vheight = vwidth ;
if ( vtag != T_NONE ) {
int i ;
st = avformat_new_stream ( s , NULL ) ;
if ( ! st ) goto fail ;
st -> id = NSV_ST_VIDEO ;
nst = av_mallocz ( sizeof ( NSVStream ) ) ;
if ( ! nst ) goto fail ;
st -> priv_data = nst ;
st -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ;
st -> codecpar -> codec_tag = vtag ;
st -> codecpar -> codec_id = ff_codec_get_id ( nsv_codec_video_tags , vtag ) ;
st -> codecpar -> width = vwidth ;
st -> codecpar -> height = vheight ;
st -> codecpar -> bits_per_coded_sample = 24 ;
avpriv_set_pts_info ( st , 64 , framerate . den , framerate . num ) ;
st -> start_time = 0 ;
st -> duration = av_rescale ( nsv -> duration , framerate . num , 1000 * framerate . den ) ;
for ( i = 0 ;
i < nsv -> index_entries ;
i ++ ) {
if ( nsv -> nsvs_timestamps ) {
av_add_index_entry ( st , nsv -> nsvs_file_offset [ i ] , nsv -> nsvs_timestamps [ i ] , 0 , 0 , AVINDEX_KEYFRAME ) ;
}
else {
int64_t ts = av_rescale ( i * nsv -> durationsv -> index_entries , framerate . num , 1000 * framerate . den ) ;
av_add_index_entry ( st , nsv -> nsvs_file_offset [ i ] , ts , 0 , 0 , AVINDEX_KEYFRAME ) ;
}
}
}
if ( atag != T_NONE ) {
st = avformat_new_stream ( s , NULL ) ;
if ( ! st ) goto fail ;
st -> id = NSV_ST_AUDIO ;
nst = av_mallocz ( sizeof ( NSVStream ) ) ;
if ( ! nst ) goto fail ;
st -> priv_data = nst ;
st -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ;
st -> codecpar -> codec_tag = atag ;
st -> codecpar -> codec_id = ff_codec_get_id ( nsv_codec_audio_tags , atag ) ;
st -> need_parsing = AVSTREAM_PARSE_FULL ;
avpriv_set_pts_info ( st , 64 , 1 , framerate . num * 1000 ) ;
st -> start_time = 0 ;
st -> duration = ( int64_t ) nsv -> duration * framerate . num ;
}
}
else {
if ( nsv -> vtag != vtag || nsv -> atag != atag || nsv -> vwidth != vwidth || nsv -> vheight != vwidth ) {
av_log ( s , AV_LOG_TRACE , "NSV NSVs header values differ from the first one!!!\n" ) ;
}
}
nsv -> state = NSV_HAS_READ_NSVS ;
return 0 ;
fail : nsv -> state = NSV_UNSYNC ;
return - 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( BrowsingDataRemoverImplTest , RemoveCookieLastHour ) {
BlockUntilBrowsingDataRemoved ( AnHourAgo ( ) , base : : Time : : Max ( ) , BrowsingDataRemover : : REMOVE_COOKIES , false ) ;
EXPECT_EQ ( BrowsingDataRemover : : REMOVE_COOKIES , GetRemovalMask ( ) ) ;
EXPECT_EQ ( BrowsingDataHelper : : UNPROTECTED_WEB , GetOriginTypeMask ( ) ) ;
StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData ( ) ;
EXPECT_EQ ( removal_data . remove_mask , StoragePartition : : REMOVE_DATA_MASK_COOKIES ) ;
EXPECT_EQ ( removal_data . quota_storage_remove_mask , ~ StoragePartition : : QUOTA_MANAGED_STORAGE_MASK_PERSISTENT ) ;
EXPECT_EQ ( removal_data . remove_begin , GetBeginTime ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static SERVER_SETUP_REC * create_server_setup ( GHashTable * optlist ) {
CHAT_PROTOCOL_REC * rec ;
SERVER_SETUP_REC * server ;
char * chatnet ;
rec = chat_protocol_find_net ( optlist ) ;
if ( rec == NULL ) rec = chat_protocol_get_default ( ) ;
else {
chatnet = g_hash_table_lookup ( optlist , rec -> chatnet ) ;
if ( chatnet_find ( chatnet ) == NULL ) {
printformat ( NULL , NULL , MSGLEVEL_CLIENTNOTICE , TXT_UNKNOWN_CHATNET , chatnet ) ;
return NULL ;
}
}
server = rec -> create_server_setup ( ) ;
server -> chat_type = rec -> id ;
return server ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gcry_err_code_t oaep_encode ( gcry_mpi_t * r_result , unsigned int nbits , int algo , const unsigned char * value , size_t valuelen , const unsigned char * label , size_t labellen , const void * random_override , size_t random_override_len ) {
gcry_err_code_t rc = 0 ;
gcry_error_t err ;
unsigned char * frame = NULL ;
size_t nframe = ( nbits + 7 ) / 8 ;
unsigned char * p ;
size_t hlen ;
size_t n ;
* r_result = NULL ;
if ( ! label || ! labellen ) {
label = ( const unsigned char * ) "" ;
labellen = 0 ;
}
hlen = gcry_md_get_algo_dlen ( algo ) ;
if ( valuelen > nframe - 2 * hlen - 2 || ! nframe ) {
return GPG_ERR_TOO_SHORT ;
}
frame = gcry_calloc_secure ( 1 , nframe ) ;
if ( ! frame ) return gpg_err_code_from_syserror ( ) ;
gcry_md_hash_buffer ( algo , frame + 1 + hlen , label , labellen ) ;
n = nframe - valuelen - 1 ;
frame [ n ] = 0x01 ;
memcpy ( frame + n + 1 , value , valuelen ) ;
if ( random_override ) {
if ( random_override_len != hlen ) {
gcry_free ( frame ) ;
return GPG_ERR_INV_ARG ;
}
memcpy ( frame + 1 , random_override , hlen ) ;
}
else gcry_randomize ( frame + 1 , hlen , GCRY_STRONG_RANDOM ) ;
{
unsigned char * dmask ;
dmask = gcry_malloc_secure ( nframe - hlen - 1 ) ;
if ( ! dmask ) {
rc = gpg_err_code_from_syserror ( ) ;
gcry_free ( frame ) ;
return rc ;
}
rc = mgf1 ( dmask , nframe - hlen - 1 , frame + 1 , hlen , algo ) ;
if ( rc ) {
gcry_free ( dmask ) ;
gcry_free ( frame ) ;
return rc ;
}
for ( n = 1 + hlen , p = dmask ;
n < nframe ;
n ++ ) frame [ n ] ^= * p ++ ;
gcry_free ( dmask ) ;
}
{
unsigned char * smask ;
smask = gcry_malloc_secure ( hlen ) ;
if ( ! smask ) {
rc = gpg_err_code_from_syserror ( ) ;
gcry_free ( frame ) ;
return rc ;
}
rc = mgf1 ( smask , hlen , frame + 1 + hlen , nframe - hlen - 1 , algo ) ;
if ( rc ) {
gcry_free ( smask ) ;
gcry_free ( frame ) ;
return rc ;
}
for ( n = 1 , p = smask ;
n < 1 + hlen ;
n ++ ) frame [ n ] ^= * p ++ ;
gcry_free ( smask ) ;
}
err = gcry_mpi_scan ( r_result , GCRYMPI_FMT_USG , frame , nframe , NULL ) ;
if ( err ) rc = gcry_err_code ( err ) ;
else if ( DBG_CIPHER ) log_mpidump ( "OAEP encoded data" , * r_result ) ;
gcry_free ( frame ) ;
return rc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void config_fudge ( config_tree * ptree ) {
addr_opts_node * curr_fudge ;
attr_val * curr_opt ;
sockaddr_u addr_sock ;
address_node * addr_node ;
struct refclockstat clock_stat ;
int err_flag ;
curr_fudge = HEAD_PFIFO ( ptree -> fudge ) ;
for ( ;
curr_fudge != NULL ;
curr_fudge = curr_fudge -> link ) {
err_flag = 0 ;
addr_node = curr_fudge -> addr ;
ZERO_SOCK ( & addr_sock ) ;
if ( getnetnum ( addr_node -> address , & addr_sock , 1 , t_REF ) != 1 ) {
err_flag = 1 ;
msyslog ( LOG_ERR , "unrecognized fudge reference clock address %s, line ignored" , stoa ( & addr_sock ) ) ;
}
if ( ! ISREFCLOCKADR ( & addr_sock ) ) {
err_flag = 1 ;
msyslog ( LOG_ERR , "inappropriate address %s for the fudge command, line ignored" , stoa ( & addr_sock ) ) ;
}
memset ( & clock_stat , 0 , sizeof ( clock_stat ) ) ;
curr_opt = HEAD_PFIFO ( curr_fudge -> options ) ;
for ( ;
curr_opt != NULL ;
curr_opt = curr_opt -> link ) {
switch ( curr_opt -> attr ) {
case T_Time1 : clock_stat . haveflags |= CLK_HAVETIME1 ;
clock_stat . fudgetime1 = curr_opt -> value . d ;
break ;
case T_Time2 : clock_stat . haveflags |= CLK_HAVETIME2 ;
clock_stat . fudgetime2 = curr_opt -> value . d ;
break ;
case T_Stratum : clock_stat . haveflags |= CLK_HAVEVAL1 ;
clock_stat . fudgeval1 = curr_opt -> value . i ;
break ;
case T_Refid : clock_stat . haveflags |= CLK_HAVEVAL2 ;
clock_stat . fudgeval2 = 0 ;
memcpy ( & clock_stat . fudgeval2 , curr_opt -> value . s , min ( strlen ( curr_opt -> value . s ) , 4 ) ) ;
break ;
case T_Flag1 : clock_stat . haveflags |= CLK_HAVEFLAG1 ;
if ( curr_opt -> value . i ) clock_stat . flags |= CLK_FLAG1 ;
else clock_stat . flags &= ~ CLK_FLAG1 ;
break ;
case T_Flag2 : clock_stat . haveflags |= CLK_HAVEFLAG2 ;
if ( curr_opt -> value . i ) clock_stat . flags |= CLK_FLAG2 ;
else clock_stat . flags &= ~ CLK_FLAG2 ;
break ;
case T_Flag3 : clock_stat . haveflags |= CLK_HAVEFLAG3 ;
if ( curr_opt -> value . i ) clock_stat . flags |= CLK_FLAG3 ;
else clock_stat . flags &= ~ CLK_FLAG3 ;
break ;
case T_Flag4 : clock_stat . haveflags |= CLK_HAVEFLAG4 ;
if ( curr_opt -> value . i ) clock_stat . flags |= CLK_FLAG4 ;
else clock_stat . flags &= ~ CLK_FLAG4 ;
break ;
default : msyslog ( LOG_ERR , "Unexpected fudge flag %s (%d) for %s\n" , token_name ( curr_opt -> attr ) , curr_opt -> attr , stoa ( & addr_sock ) ) ;
exit ( curr_opt -> attr ? curr_opt -> attr : 1 ) ;
}
}
# ifdef REFCLOCK if ( ! err_flag ) refclock_control ( & addr_sock , & clock_stat , NULL ) ;
# endif }
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int gx_parse_output_file_name ( gs_parsed_file_name_t * pfn , const char * * pfmt , const char * fname , uint fnlen , gs_memory_t * memory ) {
int code ;
* pfmt = 0 ;
pfn -> memory = 0 ;
pfn -> iodev = NULL ;
pfn -> fname = NULL ;
pfn -> len = 0 ;
if ( fnlen == 0 ) return 0 ;
code = gs_parse_file_name ( pfn , fname , fnlen , memory ) ;
if ( code < 0 ) {
if ( fname [ 0 ] == '%' ) {
pfn -> len = fnlen ;
pfn -> fname = fname ;
code = gx_parse_output_format ( pfn , pfmt ) ;
}
if ( code < 0 ) return code ;
}
if ( ! pfn -> iodev ) {
if ( ( pfn -> len == 1 ) && ( pfn -> fname [ 0 ] == '-' ) ) {
pfn -> iodev = gs_findiodevice ( memory , ( const byte * ) "%stdout" , 7 ) ;
pfn -> fname = NULL ;
}
else if ( pfn -> fname [ 0 ] == '|' ) {
pfn -> iodev = gs_findiodevice ( memory , ( const byte * ) "%pipe" , 5 ) ;
pfn -> fname ++ , pfn -> len -- ;
}
else pfn -> iodev = iodev_default ( memory ) ;
if ( ! pfn -> iodev ) return_error ( gs_error_undefinedfilename ) ;
}
if ( ! pfn -> fname ) return 0 ;
code = gx_parse_output_format ( pfn , pfmt ) ;
if ( code < 0 ) return code ;
if ( strlen ( pfn -> iodev -> dname ) + pfn -> len + code >= gp_file_name_sizeof ) return_error ( gs_error_undefinedfilename ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ff_init_short_region ( MPADecodeContext * s , GranuleDef * g ) {
if ( g -> block_type == 2 ) {
if ( s -> sample_rate_index != 8 ) g -> region_size [ 0 ] = ( 36 / 2 ) ;
else g -> region_size [ 0 ] = ( 72 / 2 ) ;
}
else {
if ( s -> sample_rate_index <= 2 ) g -> region_size [ 0 ] = ( 36 / 2 ) ;
else if ( s -> sample_rate_index != 8 ) g -> region_size [ 0 ] = ( 54 / 2 ) ;
else g -> region_size [ 0 ] = ( 108 / 2 ) ;
}
g -> region_size [ 1 ] = ( 576 / 2 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void srtp_calc_aead_iv_srtcp ( srtp_stream_ctx_t * stream , v128_t * iv , uint32_t seq_num , srtcp_hdr_t * hdr ) {
v128_t in ;
v128_t salt ;
memset ( & in , 0 , sizeof ( v128_t ) ) ;
memset ( & salt , 0 , sizeof ( v128_t ) ) ;
in . v16 [ 0 ] = 0 ;
memcpy ( & in . v16 [ 1 ] , & hdr -> ssrc , 4 ) ;
in . v16 [ 3 ] = 0 ;
in . v32 [ 2 ] = 0x7FFFFFFF & htonl ( seq_num ) ;
debug_print ( mod_srtp , "Pre-salted RTCP IV = %s\n" , v128_hex_string ( & in ) ) ;
memcpy ( salt . v8 , stream -> c_salt , 12 ) ;
debug_print ( mod_srtp , "RTCP SALT = %s\n" , v128_hex_string ( & salt ) ) ;
v128_xor ( iv , & in , & salt ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | GType hb_gobject_ ## name ## _get_type ( void ) \ {
static gsize type_id = 0 ;
if ( g_once_init_enter ( & type_id ) ) {
GType id = g_boxed_type_register_static ( g_intern_static_string ( "hb_" # name "_t" ) , ( GBoxedCopyFunc ) copy_func , ( GBoxedFreeFunc ) free_func ) ;
g_once_init_leave ( & type_id , id ) ;
}
return type_id ;
\ }
# define HB_DEFINE_OBJECT_TYPE ( name ) HB_DEFINE_BOXED_TYPE ( name , hb_ ## name ## _reference , hb_ ## name ## _destroy ) ;
# define HB_DEFINE_VALUE_TYPE ( name ) static hb_ ## name ## _t * _hb_ ## name ## _reference ( const hb_ ## name ## _t * l ) {
hb_ ## name ## _t * c = ( hb_ ## name ## _t * ) calloc ( 1 , sizeof ( hb_ ## name ## _t ) ) ;
if ( unlikely ( ! c ) ) return NULL ;
* c = * l ;
return c ;
}
static void _hb_ ## name ## _destroy ( hb_ ## name ## _t * l ) {
free ( l ) ;
}
HB_DEFINE_BOXED_TYPE ( name , _hb_ ## name ## _reference , _hb_ ## name ## _destroy ) ;
HB_DEFINE_OBJECT_TYPE ( buffer ) HB_DEFINE_OBJECT_TYPE ( blob ) HB_DEFINE_OBJECT_TYPE ( face ) HB_DEFINE_OBJECT_TYPE ( font ) HB_DEFINE_OBJECT_TYPE ( font_funcs ) HB_DEFINE_OBJECT_TYPE ( set ) HB_DEFINE_OBJECT_TYPE ( shape_plan ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void encode_parse_info ( VC2EncContext * s , enum DiracParseCodes pcode ) {
uint32_t cur_pos , dist ;
avpriv_align_put_bits ( & s -> pb ) ;
cur_pos = put_bits_count ( & s -> pb ) >> 3 ;
avpriv_put_string ( & s -> pb , "BBCD" , 0 ) ;
put_bits ( & s -> pb , 8 , pcode ) ;
dist = cur_pos - s -> next_parse_offset ;
AV_WB32 ( s -> pb . buf + s -> next_parse_offset + 5 , dist ) ;
s -> next_parse_offset = cur_pos ;
put_bits32 ( & s -> pb , pcode == DIRAC_PCODE_END_SEQ ? 13 : 0 ) ;
put_bits32 ( & s -> pb , s -> last_parse_code == DIRAC_PCODE_END_SEQ ? 13 : dist ) ;
s -> last_parse_code = pcode ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int get_max_filter_level ( const VP9_COMP * cpi ) {
if ( cpi -> oxcf . pass == 2 ) {
return cpi -> twopass . section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4 : MAX_LOOP_FILTER ;
}
else {
return MAX_LOOP_FILTER ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void init_motion_estimation ( VP9_COMP * cpi ) {
int y_stride = cpi -> scaled_source . y_stride ;
if ( cpi -> sf . mv . search_method == NSTEP ) {
vp9_init3smotion_compensation ( & cpi -> ss_cfg , y_stride ) ;
}
else if ( cpi -> sf . mv . search_method == DIAMOND ) {
vp9_init_dsmotion_compensation ( & cpi -> ss_cfg , y_stride ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int encode_thread ( AVCodecContext * c , void * arg ) {
MpegEncContext * s = * ( void * * ) arg ;
int mb_x , mb_y , pdif = 0 ;
int chr_h = 16 >> s -> chroma_y_shift ;
int i , j ;
MpegEncContext best_s , backup_s ;
uint8_t bit_buf [ 2 ] [ MAX_MB_BYTES ] ;
uint8_t bit_buf2 [ 2 ] [ MAX_MB_BYTES ] ;
uint8_t bit_buf_tex [ 2 ] [ MAX_MB_BYTES ] ;
PutBitContext pb [ 2 ] , pb2 [ 2 ] , tex_pb [ 2 ] ;
ff_check_alignment ( ) ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
init_put_bits ( & pb [ i ] , bit_buf [ i ] , MAX_MB_BYTES ) ;
init_put_bits ( & pb2 [ i ] , bit_buf2 [ i ] , MAX_MB_BYTES ) ;
init_put_bits ( & tex_pb [ i ] , bit_buf_tex [ i ] , MAX_MB_BYTES ) ;
}
s -> last_bits = put_bits_count ( & s -> pb ) ;
s -> mv_bits = 0 ;
s -> misc_bits = 0 ;
s -> i_tex_bits = 0 ;
s -> p_tex_bits = 0 ;
s -> i_count = 0 ;
s -> f_count = 0 ;
s -> b_count = 0 ;
s -> skip_count = 0 ;
for ( i = 0 ;
i < 3 ;
i ++ ) {
s -> last_dc [ i ] = 128 << s -> intra_dc_precision ;
s -> current_picture . f . error [ i ] = 0 ;
}
s -> mb_skip_run = 0 ;
memset ( s -> last_mv , 0 , sizeof ( s -> last_mv ) ) ;
s -> last_mv_dir = 0 ;
switch ( s -> codec_id ) {
case AV_CODEC_ID_H263 : case AV_CODEC_ID_H263P : case AV_CODEC_ID_FLV1 : if ( CONFIG_H263_ENCODER ) s -> gob_index = ff_h263_get_gob_height ( s ) ;
break ;
case AV_CODEC_ID_MPEG4 : if ( CONFIG_MPEG4_ENCODER && s -> partitioned_frame ) ff_mpeg4_init_partitions ( s ) ;
break ;
}
s -> resync_mb_x = 0 ;
s -> resync_mb_y = 0 ;
s -> first_slice_line = 1 ;
s -> ptr_lastgob = s -> pb . buf ;
for ( mb_y = s -> start_mb_y ;
mb_y < s -> end_mb_y ;
mb_y ++ ) {
s -> mb_x = 0 ;
s -> mb_y = mb_y ;
ff_set_qscale ( s , s -> qscale ) ;
ff_init_block_index ( s ) ;
for ( mb_x = 0 ;
mb_x < s -> mb_width ;
mb_x ++ ) {
int xy = mb_y * s -> mb_stride + mb_x ;
int mb_type = s -> mb_type [ xy ] ;
int dmin = INT_MAX ;
int dir ;
if ( s -> pb . buf_end - s -> pb . buf - ( put_bits_count ( & s -> pb ) >> 3 ) < MAX_MB_BYTES ) {
av_log ( s -> avctx , AV_LOG_ERROR , "encoded frame too large\n" ) ;
return - 1 ;
}
if ( s -> data_partitioning ) {
if ( s -> pb2 . buf_end - s -> pb2 . buf - ( put_bits_count ( & s -> pb2 ) >> 3 ) < MAX_MB_BYTES || s -> tex_pb . buf_end - s -> tex_pb . buf - ( put_bits_count ( & s -> tex_pb ) >> 3 ) < MAX_MB_BYTES ) {
av_log ( s -> avctx , AV_LOG_ERROR , "encoded frame too large\n" ) ;
return - 1 ;
}
}
s -> mb_x = mb_x ;
s -> mb_y = mb_y ;
ff_update_block_index ( s ) ;
if ( CONFIG_H261_ENCODER && s -> codec_id == AV_CODEC_ID_H261 ) {
ff_h261_reorder_mb_index ( s ) ;
xy = s -> mb_y * s -> mb_stride + s -> mb_x ;
mb_type = s -> mb_type [ xy ] ;
}
if ( s -> rtp_mode ) {
int current_packet_size , is_gob_start ;
current_packet_size = ( ( put_bits_count ( & s -> pb ) + 7 ) >> 3 ) - ( s -> ptr_lastgob - s -> pb . buf ) ;
is_gob_start = s -> avctx -> rtp_payload_size && current_packet_size >= s -> avctx -> rtp_payload_size && mb_y + mb_x > 0 ;
if ( s -> start_mb_y == mb_y && mb_y > 0 && mb_x == 0 ) is_gob_start = 1 ;
switch ( s -> codec_id ) {
case AV_CODEC_ID_H263 : case AV_CODEC_ID_H263P : if ( ! s -> h263_slice_structured ) if ( s -> mb_x || s -> mb_y % s -> gob_index ) is_gob_start = 0 ;
break ;
case AV_CODEC_ID_MPEG2VIDEO : if ( s -> mb_x == 0 && s -> mb_y != 0 ) is_gob_start = 1 ;
case AV_CODEC_ID_MPEG1VIDEO : if ( s -> mb_skip_run ) is_gob_start = 0 ;
break ;
}
if ( is_gob_start ) {
if ( s -> start_mb_y != mb_y || mb_x != 0 ) {
write_slice_end ( s ) ;
if ( CONFIG_MPEG4_ENCODER && s -> codec_id == AV_CODEC_ID_MPEG4 && s -> partitioned_frame ) {
ff_mpeg4_init_partitions ( s ) ;
}
}
assert ( ( put_bits_count ( & s -> pb ) & 7 ) == 0 ) ;
current_packet_size = put_bits_ptr ( & s -> pb ) - s -> ptr_lastgob ;
if ( s -> avctx -> error_rate && s -> resync_mb_x + s -> resync_mb_y > 0 ) {
int r = put_bits_count ( & s -> pb ) / 8 + s -> picture_number + 16 + s -> mb_x + s -> mb_y ;
int d = 100 / s -> avctx -> error_rate ;
if ( r % d == 0 ) {
current_packet_size = 0 ;
s -> pb . buf_ptr = s -> ptr_lastgob ;
assert ( put_bits_ptr ( & s -> pb ) == s -> ptr_lastgob ) ;
}
}
if ( s -> avctx -> rtp_callback ) {
int number_mb = ( mb_y - s -> resync_mb_y ) * s -> mb_width + mb_x - s -> resync_mb_x ;
s -> avctx -> rtp_callback ( s -> avctx , s -> ptr_lastgob , current_packet_size , number_mb ) ;
}
update_mb_info ( s , 1 ) ;
switch ( s -> codec_id ) {
case AV_CODEC_ID_MPEG4 : if ( CONFIG_MPEG4_ENCODER ) {
ff_mpeg4_encode_video_packet_header ( s ) ;
ff_mpeg4_clean_buffers ( s ) ;
}
break ;
case AV_CODEC_ID_MPEG1VIDEO : case AV_CODEC_ID_MPEG2VIDEO : if ( CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER ) {
ff_mpeg1_encode_slice_header ( s ) ;
ff_mpeg1_clean_buffers ( s ) ;
}
break ;
case AV_CODEC_ID_H263 : case AV_CODEC_ID_H263P : if ( CONFIG_H263_ENCODER ) ff_h263_encode_gob_header ( s , mb_y ) ;
break ;
}
if ( s -> flags & CODEC_FLAG_PASS1 ) {
int bits = put_bits_count ( & s -> pb ) ;
s -> misc_bits += bits - s -> last_bits ;
s -> last_bits = bits ;
}
s -> ptr_lastgob += current_packet_size ;
s -> first_slice_line = 1 ;
s -> resync_mb_x = mb_x ;
s -> resync_mb_y = mb_y ;
}
}
if ( ( s -> resync_mb_x == s -> mb_x ) && s -> resync_mb_y + 1 == s -> mb_y ) {
s -> first_slice_line = 0 ;
}
s -> mb_skipped = 0 ;
s -> dquant = 0 ;
update_mb_info ( s , 0 ) ;
if ( mb_type & ( mb_type - 1 ) || ( s -> mpv_flags & FF_MPV_FLAG_QP_RD ) ) {
int next_block = 0 ;
int pb_bits_count , pb2_bits_count , tex_pb_bits_count ;
copy_context_before_encode ( & backup_s , s , - 1 ) ;
backup_s . pb = s -> pb ;
best_s . data_partitioning = s -> data_partitioning ;
best_s . partitioned_frame = s -> partitioned_frame ;
if ( s -> data_partitioning ) {
backup_s . pb2 = s -> pb2 ;
backup_s . tex_pb = s -> tex_pb ;
}
if ( mb_type & CANDIDATE_MB_TYPE_INTER ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> p_mv_table [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> p_mv_table [ xy ] [ 1 ] ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTER , pb , pb2 , tex_pb , & dmin , & next_block , s -> mv [ 0 ] [ 0 ] [ 0 ] , s -> mv [ 0 ] [ 0 ] [ 1 ] ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_INTER_I ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 0 ] [ i ] = s -> p_field_select_table [ i ] [ xy ] ;
s -> mv [ 0 ] [ i ] [ 0 ] = s -> p_field_mv_table [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> p_field_mv_table [ i ] [ j ] [ xy ] [ 1 ] ;
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTER_I , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_SKIPPED ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_SKIPPED , pb , pb2 , tex_pb , & dmin , & next_block , s -> mv [ 0 ] [ 0 ] [ 0 ] , s -> mv [ 0 ] [ 0 ] [ 1 ] ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_INTER4V ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_8X8 ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
s -> mv [ 0 ] [ i ] [ 0 ] = s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 1 ] ;
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTER4V , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_FORWARD ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> b_forw_mv_table [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> b_forw_mv_table [ xy ] [ 1 ] ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_FORWARD , pb , pb2 , tex_pb , & dmin , & next_block , s -> mv [ 0 ] [ 0 ] [ 0 ] , s -> mv [ 0 ] [ 0 ] [ 1 ] ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_BACKWARD ) {
s -> mv_dir = MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 0 ;
s -> mv [ 1 ] [ 0 ] [ 0 ] = s -> b_back_mv_table [ xy ] [ 0 ] ;
s -> mv [ 1 ] [ 0 ] [ 1 ] = s -> b_back_mv_table [ xy ] [ 1 ] ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_BACKWARD , pb , pb2 , tex_pb , & dmin , & next_block , s -> mv [ 1 ] [ 0 ] [ 0 ] , s -> mv [ 1 ] [ 0 ] [ 1 ] ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_BIDIR ) {
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> b_bidir_forw_mv_table [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> b_bidir_forw_mv_table [ xy ] [ 1 ] ;
s -> mv [ 1 ] [ 0 ] [ 0 ] = s -> b_bidir_back_mv_table [ xy ] [ 0 ] ;
s -> mv [ 1 ] [ 0 ] [ 1 ] = s -> b_bidir_back_mv_table [ xy ] [ 1 ] ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_BIDIR , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_FORWARD_I ) {
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 0 ] [ i ] = s -> b_field_select_table [ 0 ] [ i ] [ xy ] ;
s -> mv [ 0 ] [ i ] [ 0 ] = s -> b_field_mv_table [ 0 ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> b_field_mv_table [ 0 ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_FORWARD_I , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_BACKWARD_I ) {
s -> mv_dir = MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 1 ] [ i ] = s -> b_field_select_table [ 1 ] [ i ] [ xy ] ;
s -> mv [ 1 ] [ i ] [ 0 ] = s -> b_field_mv_table [ 1 ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 1 ] [ i ] [ 1 ] = s -> b_field_mv_table [ 1 ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_BACKWARD_I , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_BIDIR_I ) {
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( dir = 0 ;
dir < 2 ;
dir ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ dir ] [ i ] = s -> b_field_select_table [ dir ] [ i ] [ xy ] ;
s -> mv [ dir ] [ i ] [ 0 ] = s -> b_field_mv_table [ dir ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ dir ] [ i ] [ 1 ] = s -> b_field_mv_table [ dir ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_BIDIR_I , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( mb_type & CANDIDATE_MB_TYPE_INTRA ) {
s -> mv_dir = 0 ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = 1 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTRA , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
if ( s -> h263_pred || s -> h263_aic ) {
if ( best_s . mb_intra ) s -> mbintra_table [ mb_x + mb_y * s -> mb_stride ] = 1 ;
else ff_clean_intra_table_entries ( s ) ;
}
}
if ( ( s -> mpv_flags & FF_MPV_FLAG_QP_RD ) && dmin < INT_MAX ) {
if ( best_s . mv_type == MV_TYPE_16X16 ) {
const int last_qp = backup_s . qscale ;
int qpi , qp , dc [ 6 ] ;
int16_t ac [ 6 ] [ 16 ] ;
const int mvdir = ( best_s . mv_dir & MV_DIR_BACKWARD ) ? 1 : 0 ;
static const int dquant_tab [ 4 ] = {
- 1 , 1 , - 2 , 2 }
;
assert ( backup_s . dquant == 0 ) ;
s -> mv_dir = best_s . mv_dir ;
s -> mv_type = MV_TYPE_16X16 ;
s -> mb_intra = best_s . mb_intra ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = best_s . mv [ 0 ] [ 0 ] [ 0 ] ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = best_s . mv [ 0 ] [ 0 ] [ 1 ] ;
s -> mv [ 1 ] [ 0 ] [ 0 ] = best_s . mv [ 1 ] [ 0 ] [ 0 ] ;
s -> mv [ 1 ] [ 0 ] [ 1 ] = best_s . mv [ 1 ] [ 0 ] [ 1 ] ;
qpi = s -> pict_type == AV_PICTURE_TYPE_B ? 2 : 0 ;
for ( ;
qpi < 4 ;
qpi ++ ) {
int dquant = dquant_tab [ qpi ] ;
qp = last_qp + dquant ;
if ( qp < s -> avctx -> qmin || qp > s -> avctx -> qmax ) continue ;
backup_s . dquant = dquant ;
if ( s -> mb_intra && s -> dc_val [ 0 ] ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
dc [ i ] = s -> dc_val [ 0 ] [ s -> block_index [ i ] ] ;
memcpy ( ac [ i ] , s -> ac_val [ 0 ] [ s -> block_index [ i ] ] , sizeof ( int16_t ) * 16 ) ;
}
}
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTER , pb , pb2 , tex_pb , & dmin , & next_block , s -> mv [ mvdir ] [ 0 ] [ 0 ] , s -> mv [ mvdir ] [ 0 ] [ 1 ] ) ;
if ( best_s . qscale != qp ) {
if ( s -> mb_intra && s -> dc_val [ 0 ] ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = dc [ i ] ;
memcpy ( s -> ac_val [ 0 ] [ s -> block_index [ i ] ] , ac [ i ] , sizeof ( int16_t ) * 16 ) ;
}
}
}
}
}
}
if ( CONFIG_MPEG4_ENCODER && mb_type & CANDIDATE_MB_TYPE_DIRECT ) {
int mx = s -> b_direct_mv_table [ xy ] [ 0 ] ;
int my = s -> b_direct_mv_table [ xy ] [ 1 ] ;
backup_s . dquant = 0 ;
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT ;
s -> mb_intra = 0 ;
ff_mpeg4_set_direct_mv ( s , mx , my ) ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_DIRECT , pb , pb2 , tex_pb , & dmin , & next_block , mx , my ) ;
}
if ( CONFIG_MPEG4_ENCODER && mb_type & CANDIDATE_MB_TYPE_DIRECT0 ) {
backup_s . dquant = 0 ;
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT ;
s -> mb_intra = 0 ;
ff_mpeg4_set_direct_mv ( s , 0 , 0 ) ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_DIRECT , pb , pb2 , tex_pb , & dmin , & next_block , 0 , 0 ) ;
}
if ( ! best_s . mb_intra && s -> mpv_flags & FF_MPV_FLAG_SKIP_RD ) {
int coded = 0 ;
for ( i = 0 ;
i < 6 ;
i ++ ) coded |= s -> block_last_index [ i ] ;
if ( coded ) {
int mx , my ;
memcpy ( s -> mv , best_s . mv , sizeof ( s -> mv ) ) ;
if ( CONFIG_MPEG4_ENCODER && best_s . mv_dir & MV_DIRECT ) {
mx = my = 0 ;
ff_mpeg4_set_direct_mv ( s , mx , my ) ;
}
else if ( best_s . mv_dir & MV_DIR_BACKWARD ) {
mx = s -> mv [ 1 ] [ 0 ] [ 0 ] ;
my = s -> mv [ 1 ] [ 0 ] [ 1 ] ;
}
else {
mx = s -> mv [ 0 ] [ 0 ] [ 0 ] ;
my = s -> mv [ 0 ] [ 0 ] [ 1 ] ;
}
s -> mv_dir = best_s . mv_dir ;
s -> mv_type = best_s . mv_type ;
s -> mb_intra = 0 ;
backup_s . dquant = 0 ;
s -> skipdct = 1 ;
encode_mb_hq ( s , & backup_s , & best_s , CANDIDATE_MB_TYPE_INTER , pb , pb2 , tex_pb , & dmin , & next_block , mx , my ) ;
s -> skipdct = 0 ;
}
}
s -> current_picture . f . qscale_table [ xy ] = best_s . qscale ;
copy_context_after_encode ( s , & best_s , - 1 ) ;
pb_bits_count = put_bits_count ( & s -> pb ) ;
flush_put_bits ( & s -> pb ) ;
avpriv_copy_bits ( & backup_s . pb , bit_buf [ next_block ^ 1 ] , pb_bits_count ) ;
s -> pb = backup_s . pb ;
if ( s -> data_partitioning ) {
pb2_bits_count = put_bits_count ( & s -> pb2 ) ;
flush_put_bits ( & s -> pb2 ) ;
avpriv_copy_bits ( & backup_s . pb2 , bit_buf2 [ next_block ^ 1 ] , pb2_bits_count ) ;
s -> pb2 = backup_s . pb2 ;
tex_pb_bits_count = put_bits_count ( & s -> tex_pb ) ;
flush_put_bits ( & s -> tex_pb ) ;
avpriv_copy_bits ( & backup_s . tex_pb , bit_buf_tex [ next_block ^ 1 ] , tex_pb_bits_count ) ;
s -> tex_pb = backup_s . tex_pb ;
}
s -> last_bits = put_bits_count ( & s -> pb ) ;
if ( CONFIG_H263_ENCODER && s -> out_format == FMT_H263 && s -> pict_type != AV_PICTURE_TYPE_B ) ff_h263_update_motion_val ( s ) ;
if ( next_block == 0 ) {
s -> dsp . put_pixels_tab [ 0 ] [ 0 ] ( s -> dest [ 0 ] , s -> rd_scratchpad , s -> linesize , 16 ) ;
s -> dsp . put_pixels_tab [ 1 ] [ 0 ] ( s -> dest [ 1 ] , s -> rd_scratchpad + 16 * s -> linesize , s -> uvlinesize , 8 ) ;
s -> dsp . put_pixels_tab [ 1 ] [ 0 ] ( s -> dest [ 2 ] , s -> rd_scratchpad + 16 * s -> linesize + 8 , s -> uvlinesize , 8 ) ;
}
if ( s -> avctx -> mb_decision == FF_MB_DECISION_BITS ) ff_MPV_decode_mb ( s , s -> block ) ;
}
else {
int motion_x = 0 , motion_y = 0 ;
s -> mv_type = MV_TYPE_16X16 ;
switch ( mb_type ) {
case CANDIDATE_MB_TYPE_INTRA : s -> mv_dir = 0 ;
s -> mb_intra = 1 ;
motion_x = s -> mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
motion_y = s -> mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
break ;
case CANDIDATE_MB_TYPE_INTER : s -> mv_dir = MV_DIR_FORWARD ;
s -> mb_intra = 0 ;
motion_x = s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> p_mv_table [ xy ] [ 0 ] ;
motion_y = s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> p_mv_table [ xy ] [ 1 ] ;
break ;
case CANDIDATE_MB_TYPE_INTER_I : s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 0 ] [ i ] = s -> p_field_select_table [ i ] [ xy ] ;
s -> mv [ 0 ] [ i ] [ 0 ] = s -> p_field_mv_table [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> p_field_mv_table [ i ] [ j ] [ xy ] [ 1 ] ;
}
break ;
case CANDIDATE_MB_TYPE_INTER4V : s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_8X8 ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
s -> mv [ 0 ] [ i ] [ 0 ] = s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> current_picture . f . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 1 ] ;
}
break ;
case CANDIDATE_MB_TYPE_DIRECT : if ( CONFIG_MPEG4_ENCODER ) {
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT ;
s -> mb_intra = 0 ;
motion_x = s -> b_direct_mv_table [ xy ] [ 0 ] ;
motion_y = s -> b_direct_mv_table [ xy ] [ 1 ] ;
ff_mpeg4_set_direct_mv ( s , motion_x , motion_y ) ;
}
break ;
case CANDIDATE_MB_TYPE_DIRECT0 : if ( CONFIG_MPEG4_ENCODER ) {
s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT ;
s -> mb_intra = 0 ;
ff_mpeg4_set_direct_mv ( s , 0 , 0 ) ;
}
break ;
case CANDIDATE_MB_TYPE_BIDIR : s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD ;
s -> mb_intra = 0 ;
s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> b_bidir_forw_mv_table [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> b_bidir_forw_mv_table [ xy ] [ 1 ] ;
s -> mv [ 1 ] [ 0 ] [ 0 ] = s -> b_bidir_back_mv_table [ xy ] [ 0 ] ;
s -> mv [ 1 ] [ 0 ] [ 1 ] = s -> b_bidir_back_mv_table [ xy ] [ 1 ] ;
break ;
case CANDIDATE_MB_TYPE_BACKWARD : s -> mv_dir = MV_DIR_BACKWARD ;
s -> mb_intra = 0 ;
motion_x = s -> mv [ 1 ] [ 0 ] [ 0 ] = s -> b_back_mv_table [ xy ] [ 0 ] ;
motion_y = s -> mv [ 1 ] [ 0 ] [ 1 ] = s -> b_back_mv_table [ xy ] [ 1 ] ;
break ;
case CANDIDATE_MB_TYPE_FORWARD : s -> mv_dir = MV_DIR_FORWARD ;
s -> mb_intra = 0 ;
motion_x = s -> mv [ 0 ] [ 0 ] [ 0 ] = s -> b_forw_mv_table [ xy ] [ 0 ] ;
motion_y = s -> mv [ 0 ] [ 0 ] [ 1 ] = s -> b_forw_mv_table [ xy ] [ 1 ] ;
break ;
case CANDIDATE_MB_TYPE_FORWARD_I : s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 0 ] [ i ] = s -> b_field_select_table [ 0 ] [ i ] [ xy ] ;
s -> mv [ 0 ] [ i ] [ 0 ] = s -> b_field_mv_table [ 0 ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> b_field_mv_table [ 0 ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
break ;
case CANDIDATE_MB_TYPE_BACKWARD_I : s -> mv_dir = MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ 1 ] [ i ] = s -> b_field_select_table [ 1 ] [ i ] [ xy ] ;
s -> mv [ 1 ] [ i ] [ 0 ] = s -> b_field_mv_table [ 1 ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ 1 ] [ i ] [ 1 ] = s -> b_field_mv_table [ 1 ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
break ;
case CANDIDATE_MB_TYPE_BIDIR_I : s -> mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD ;
s -> mv_type = MV_TYPE_FIELD ;
s -> mb_intra = 0 ;
for ( dir = 0 ;
dir < 2 ;
dir ++ ) {
for ( i = 0 ;
i < 2 ;
i ++ ) {
j = s -> field_select [ dir ] [ i ] = s -> b_field_select_table [ dir ] [ i ] [ xy ] ;
s -> mv [ dir ] [ i ] [ 0 ] = s -> b_field_mv_table [ dir ] [ i ] [ j ] [ xy ] [ 0 ] ;
s -> mv [ dir ] [ i ] [ 1 ] = s -> b_field_mv_table [ dir ] [ i ] [ j ] [ xy ] [ 1 ] ;
}
}
break ;
default : av_log ( s -> avctx , AV_LOG_ERROR , "illegal MB type\n" ) ;
}
encode_mb ( s , motion_x , motion_y ) ;
s -> last_mv_dir = s -> mv_dir ;
if ( CONFIG_H263_ENCODER && s -> out_format == FMT_H263 && s -> pict_type != AV_PICTURE_TYPE_B ) ff_h263_update_motion_val ( s ) ;
ff_MPV_decode_mb ( s , s -> block ) ;
}
if ( s -> mb_intra ) {
s -> p_mv_table [ xy ] [ 0 ] = 0 ;
s -> p_mv_table [ xy ] [ 1 ] = 0 ;
}
if ( s -> flags & CODEC_FLAG_PSNR ) {
int w = 16 ;
int h = 16 ;
if ( s -> mb_x * 16 + 16 > s -> width ) w = s -> width - s -> mb_x * 16 ;
if ( s -> mb_y * 16 + 16 > s -> height ) h = s -> height - s -> mb_y * 16 ;
s -> current_picture . f . error [ 0 ] += sse ( s , s -> new_picture . f . data [ 0 ] + s -> mb_x * 16 + s -> mb_y * s -> linesize * 16 , s -> dest [ 0 ] , w , h , s -> linesize ) ;
s -> current_picture . f . error [ 1 ] += sse ( s , s -> new_picture . f . data [ 1 ] + s -> mb_x * 8 + s -> mb_y * s -> uvlinesize * chr_h , s -> dest [ 1 ] , w >> 1 , h >> s -> chroma_y_shift , s -> uvlinesize ) ;
s -> current_picture . f . error [ 2 ] += sse ( s , s -> new_picture . f . data [ 2 ] + s -> mb_x * 8 + s -> mb_y * s -> uvlinesize * chr_h , s -> dest [ 2 ] , w >> 1 , h >> s -> chroma_y_shift , s -> uvlinesize ) ;
}
if ( s -> loop_filter ) {
if ( CONFIG_H263_ENCODER && s -> out_format == FMT_H263 ) ff_h263_loop_filter ( s ) ;
}
av_dlog ( s -> avctx , "MB %d %d bits\n" , s -> mb_x + s -> mb_y * s -> mb_stride , put_bits_count ( & s -> pb ) ) ;
}
}
/ ot beautiful here but we must write it before flushing so it has to be here if ( CONFIG_MSMPEG4_ENCODER && s -> msmpeg4_version && s -> msmpeg4_version < 4 && s -> pict_type == AV_PICTURE_TYPE_I ) ff_msmpeg4_encode_ext_header ( s ) ;
write_slice_end ( s ) ;
if ( s -> avctx -> rtp_callback ) {
int number_mb = ( mb_y - s -> resync_mb_y ) * s -> mb_width - s -> resync_mb_x ;
pdif = put_bits_ptr ( & s -> pb ) - s -> ptr_lastgob ;
emms_c ( ) ;
s -> avctx -> rtp_callback ( s -> avctx , s -> ptr_lastgob , pdif , number_mb ) ;
}
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static bool ps2_keyboard_need_high_bit_needed ( void * opaque ) {
PS2KbdState * s = opaque ;
return s -> need_high_bit != 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_UnregRejectReason ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 614 "./asn1/h225/h225.cnf" gint32 value ;
h225_packet_info * h225_pi ;
h225_pi = ( h225_packet_info * ) p_get_proto_data ( wmem_packet_scope ( ) , actx -> pinfo , proto_h225 , 0 ) ;
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h225_UnregRejectReason , UnregRejectReason_choice , & value ) ;
if ( h225_pi != NULL ) {
h225_pi -> reason = value ;
}
return offset ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | void check_eol_junk_line ( const char * line ) {
const char * p = line ;
DBUG_ENTER ( "check_eol_junk_line" ) ;
DBUG_PRINT ( "enter" , ( "line: %s" , line ) ) ;
if ( * p && ! strncmp ( p , delimiter , delimiter_length ) ) die ( "Extra delimiter \"%s\" found" , delimiter ) ;
if ( * p && * p != '#' ) {
if ( * p == '\n' ) die ( "Missing delimiter" ) ;
die ( "End of line junk detected: \"%s\"" , p ) ;
}
DBUG_VOID_RETURN ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int TSHttpTxnPushedRespHdrBytesGet ( TSHttpTxn txnp ) {
sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;
HttpSM * sm = ( HttpSM * ) txnp ;
return sm -> pushed_response_hdr_bytes ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static struct cgroup_process_info * lxc_cgroup_process_info_get_self ( struct cgroup_meta_data * meta ) {
struct cgroup_process_info * i ;
i = lxc_cgroup_process_info_getx ( "/proc/self/cgroup" , meta ) ;
if ( ! i ) i = lxc_cgroup_process_info_get ( getpid ( ) , meta ) ;
return i ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void SetPixela ( const Image * restrict image , const Quantum a , Quantum * restrict pixel ) {
if ( image -> channel_map [ aPixelChannel ] . traits != UndefinedPixelTrait ) pixel [ image -> channel_map [ aPixelChannel ] . offset ] = a ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline Quantum GetPixelCb ( const Image * restrict image , const Quantum * restrict pixel ) {
return ( pixel [ image -> channel_map [ CbPixelChannel ] . offset ] ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gpgme_error_t gpgsm_import ( void * engine , gpgme_data_t keydata , gpgme_key_t * keyarray ) {
engine_gpgsm_t gpgsm = engine ;
gpgme_error_t err ;
gpgme_data_encoding_t dataenc ;
int idx ;
if ( ! gpgsm ) return gpg_error ( GPG_ERR_INV_VALUE ) ;
if ( keydata && keyarray ) return gpg_error ( GPG_ERR_INV_VALUE ) ;
dataenc = gpgme_data_get_encoding ( keydata ) ;
if ( keyarray ) {
size_t buflen ;
char * buffer , * p ;
err = gpgsm_assuan_simple_command ( gpgsm -> assuan_ctx , "GETINFO cmd_has_option IMPORT re-import" , NULL , NULL ) ;
if ( err ) return gpg_error ( GPG_ERR_NOT_SUPPORTED ) ;
for ( idx = 0 , buflen = 0 ;
keyarray [ idx ] ;
idx ++ ) {
if ( keyarray [ idx ] -> protocol == GPGME_PROTOCOL_CMS && keyarray [ idx ] -> subkeys && keyarray [ idx ] -> subkeys -> fpr && * keyarray [ idx ] -> subkeys -> fpr ) buflen += strlen ( keyarray [ idx ] -> subkeys -> fpr ) + 1 ;
}
buffer = malloc ( buflen + 1 ) ;
if ( ! buffer ) return gpg_error_from_syserror ( ) ;
for ( idx = 0 , p = buffer ;
keyarray [ idx ] ;
idx ++ ) {
if ( keyarray [ idx ] -> protocol == GPGME_PROTOCOL_CMS && keyarray [ idx ] -> subkeys && keyarray [ idx ] -> subkeys -> fpr && * keyarray [ idx ] -> subkeys -> fpr ) p = stpcpy ( stpcpy ( p , keyarray [ idx ] -> subkeys -> fpr ) , "\n" ) ;
}
err = gpgme_data_new_from_mem ( & gpgsm -> input_helper_data , buffer , buflen , 0 ) ;
if ( err ) {
free ( buffer ) ;
return err ;
}
gpgsm -> input_helper_memory = buffer ;
gpgsm -> input_cb . data = gpgsm -> input_helper_data ;
err = gpgsm_set_fd ( gpgsm , INPUT_FD , map_data_enc ( gpgsm -> input_cb . data ) ) ;
if ( err ) {
gpgme_data_release ( gpgsm -> input_helper_data ) ;
gpgsm -> input_helper_data = NULL ;
free ( gpgsm -> input_helper_memory ) ;
gpgsm -> input_helper_memory = NULL ;
return err ;
}
gpgsm_clear_fd ( gpgsm , OUTPUT_FD ) ;
gpgsm_clear_fd ( gpgsm , MESSAGE_FD ) ;
gpgsm -> inline_data = NULL ;
return start ( gpgsm , "IMPORT --re-import" ) ;
}
else if ( dataenc == GPGME_DATA_ENCODING_URL || dataenc == GPGME_DATA_ENCODING_URL0 || dataenc == GPGME_DATA_ENCODING_URLESC ) {
return gpg_error ( GPG_ERR_NOT_IMPLEMENTED ) ;
}
else {
gpgsm -> input_cb . data = keydata ;
err = gpgsm_set_fd ( gpgsm , INPUT_FD , map_data_enc ( gpgsm -> input_cb . data ) ) ;
if ( err ) return err ;
gpgsm_clear_fd ( gpgsm , OUTPUT_FD ) ;
gpgsm_clear_fd ( gpgsm , MESSAGE_FD ) ;
gpgsm -> inline_data = NULL ;
return start ( gpgsm , "IMPORT" ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void tb_free ( TranslationBlock * tb ) {
if ( tcg_ctx . tb_ctx . nb_tbs > 0 && tb == & tcg_ctx . tb_ctx . tbs [ tcg_ctx . tb_ctx . nb_tbs - 1 ] ) {
tcg_ctx . code_gen_ptr = tb -> tc_ptr ;
tcg_ctx . tb_ctx . nb_tbs -- ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void _UTF16LEFromUnicodeWithOffsets ( UConverterFromUnicodeArgs * pArgs , UErrorCode * pErrorCode ) {
UConverter * cnv ;
const UChar * source ;
char * target ;
int32_t * offsets ;
uint32_t targetCapacity , length , sourceIndex ;
UChar c , trail ;
char overflow [ 4 ] ;
source = pArgs -> source ;
length = ( int32_t ) ( pArgs -> sourceLimit - source ) ;
if ( length <= 0 ) {
return ;
}
cnv = pArgs -> converter ;
if ( cnv -> fromUnicodeStatus == UCNV_NEED_TO_WRITE_BOM ) {
static const char bom [ ] = {
( char ) 0xff , ( char ) 0xfe }
;
ucnv_fromUWriteBytes ( cnv , bom , 2 , & pArgs -> target , pArgs -> targetLimit , & pArgs -> offsets , - 1 , pErrorCode ) ;
cnv -> fromUnicodeStatus = 0 ;
}
target = pArgs -> target ;
if ( target >= pArgs -> targetLimit ) {
* pErrorCode = U_BUFFER_OVERFLOW_ERROR ;
return ;
}
targetCapacity = ( uint32_t ) ( pArgs -> targetLimit - pArgs -> target ) ;
offsets = pArgs -> offsets ;
sourceIndex = 0 ;
if ( ( c = ( UChar ) cnv -> fromUChar32 ) != 0 && U16_IS_TRAIL ( trail = * source ) && targetCapacity >= 4 ) {
++ source ;
-- length ;
target [ 0 ] = ( uint8_t ) c ;
target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;
target [ 2 ] = ( uint8_t ) trail ;
target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;
target += 4 ;
targetCapacity -= 4 ;
if ( offsets != NULL ) {
* offsets ++ = - 1 ;
* offsets ++ = - 1 ;
* offsets ++ = - 1 ;
* offsets ++ = - 1 ;
}
sourceIndex = 1 ;
cnv -> fromUChar32 = c = 0 ;
}
if ( c == 0 ) {
uint32_t count = 2 * length ;
if ( count > targetCapacity ) {
count = targetCapacity & ~ 1 ;
}
targetCapacity -= count ;
count >>= 1 ;
length -= count ;
if ( offsets == NULL ) {
while ( count > 0 ) {
c = * source ++ ;
if ( U16_IS_SINGLE ( c ) ) {
target [ 0 ] = ( uint8_t ) c ;
target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;
target += 2 ;
}
else if ( U16_IS_SURROGATE_LEAD ( c ) && count >= 2 && U16_IS_TRAIL ( trail = * source ) ) {
++ source ;
-- count ;
target [ 0 ] = ( uint8_t ) c ;
target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;
target [ 2 ] = ( uint8_t ) trail ;
target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;
target += 4 ;
}
else {
break ;
}
-- count ;
}
}
else {
while ( count > 0 ) {
c = * source ++ ;
if ( U16_IS_SINGLE ( c ) ) {
target [ 0 ] = ( uint8_t ) c ;
target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;
target += 2 ;
* offsets ++ = sourceIndex ;
* offsets ++ = sourceIndex ++ ;
}
else if ( U16_IS_SURROGATE_LEAD ( c ) && count >= 2 && U16_IS_TRAIL ( trail = * source ) ) {
++ source ;
-- count ;
target [ 0 ] = ( uint8_t ) c ;
target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;
target [ 2 ] = ( uint8_t ) trail ;
target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;
target += 4 ;
* offsets ++ = sourceIndex ;
* offsets ++ = sourceIndex ;
* offsets ++ = sourceIndex ;
* offsets ++ = sourceIndex ;
sourceIndex += 2 ;
}
else {
break ;
}
-- count ;
}
}
if ( count == 0 ) {
if ( length > 0 && targetCapacity > 0 ) {
if ( U16_IS_SINGLE ( c = * source ++ ) ) {
overflow [ 0 ] = ( char ) c ;
overflow [ 1 ] = ( char ) ( c >> 8 ) ;
length = 2 ;
c = 0 ;
}
}
else {
length = 0 ;
c = 0 ;
}
}
else {
targetCapacity += 2 * count ;
}
}
else {
length = 0 ;
}
if ( c != 0 ) {
length = 0 ;
if ( U16_IS_SURROGATE_LEAD ( c ) ) {
if ( source < pArgs -> sourceLimit ) {
if ( U16_IS_TRAIL ( trail = * source ) ) {
++ source ;
overflow [ 0 ] = ( char ) c ;
overflow [ 1 ] = ( char ) ( c >> 8 ) ;
overflow [ 2 ] = ( char ) trail ;
overflow [ 3 ] = ( char ) ( trail >> 8 ) ;
length = 4 ;
c = 0 ;
}
else {
* pErrorCode = U_ILLEGAL_CHAR_FOUND ;
}
}
else {
}
}
else {
* pErrorCode = U_ILLEGAL_CHAR_FOUND ;
}
cnv -> fromUChar32 = c ;
}
if ( length > 0 ) {
ucnv_fromUWriteBytes ( cnv , overflow , length , & target , pArgs -> targetLimit , & offsets , sourceIndex , pErrorCode ) ;
targetCapacity = ( uint32_t ) ( pArgs -> targetLimit - ( char * ) target ) ;
}
if ( U_SUCCESS ( * pErrorCode ) && source < pArgs -> sourceLimit && targetCapacity == 0 ) {
* pErrorCode = U_BUFFER_OVERFLOW_ERROR ;
}
pArgs -> source = source ;
pArgs -> target = target ;
pArgs -> offsets = offsets ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void DB_error ( MYSQL * mysql_arg , const char * when ) {
DBUG_ENTER ( "DB_error" ) ;
maybe_die ( EX_MYSQLERR , "Got error: %d: \"%s\" %s" , mysql_errno ( mysql_arg ) , mysql_error ( mysql_arg ) , when ) ;
DBUG_VOID_RETURN ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static char * tstflags ( u_long val ) {
register char * cp , * s ;
size_t cb ;
register int i ;
register const char * sep ;
sep = "" ;
s = cp = circ_buf [ nextcb ] ;
if ( ++ nextcb >= NUMCB ) nextcb = 0 ;
cb = sizeof ( circ_buf [ 0 ] ) ;
snprintf ( cp , cb , "%02lx" , val ) ;
cp += strlen ( cp ) ;
cb -= strlen ( cp ) ;
if ( ! val ) {
strlcat ( cp , " ok" , cb ) ;
cp += strlen ( cp ) ;
cb -= strlen ( cp ) ;
}
else {
if ( cb ) {
* cp ++ = ' ' ;
cb -- ;
}
for ( i = 0 ;
i < ( int ) COUNTOF ( tstflagnames ) ;
i ++ ) {
if ( val & 0x1 ) {
snprintf ( cp , cb , "%s%s" , sep , tstflagnames [ i ] ) ;
sep = ", " ;
cp += strlen ( cp ) ;
cb -= strlen ( cp ) ;
}
val >>= 1 ;
}
}
if ( cb ) * cp = '\0' ;
return s ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dtap_mm_auth_fail ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
is_uplink = IS_UPLINK_TRUE ;
ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_REJ_CAUSE , NULL ) ;
ELEM_OPT_TLV ( 0x22 , GSM_A_PDU_TYPE_DTAP , DE_AUTH_FAIL_PARAM , 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 | void TSVConnActiveTimeoutSet ( TSVConn connp , TSHRTime timeout ) {
sdk_assert ( sdk_sanity_check_iocore_structure ( connp ) == TS_SUCCESS ) ;
NetVConnection * vc = ( NetVConnection * ) connp ;
vc -> set_active_timeout ( timeout ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int stem_hint_handler ( void * client_data , gx_san_sect * ss ) {
t1_hinter_aux * h = ( t1_hinter_aux * ) client_data ;
if ( ss -> side_mask == 3 ) {
if ( ss -> xl > h -> midx && h -> transpose ) return ( h -> transpose ? t1_hinter__hstem : t1_hinter__vstem ) ( & h -> super , ss -> xr , ss -> xl - ss -> xr ) ;
else return ( h -> transpose ? t1_hinter__hstem : t1_hinter__vstem ) ( & h -> super , ss -> xl , ss -> xr - ss -> xl ) ;
}
else return t1_hinter__overall_hstem ( & h -> super , ss -> xl , ss -> xr - ss -> xl , ss -> side_mask ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( DownloadExtensionTest , DownloadExtensionTest_OnDeterminingFilename_CurDirInvalid ) {
GoOnTheRecord ( ) ;
LoadExtension ( "downloads_split" ) ;
AddFilenameDeterminer ( ) ;
ASSERT_TRUE ( StartEmbeddedTestServer ( ) ) ;
std : : string download_url = embedded_test_server ( ) -> GetURL ( "/slow?0" ) . spec ( ) ;
std : : unique_ptr < base : : Value > result ( RunFunctionAndReturnResult ( new DownloadsDownloadFunction ( ) , base : : StringPrintf ( "[{
\"url\": \"%s\"}
]" , download_url . c_str ( ) ) ) ) ;
ASSERT_TRUE ( result . get ( ) ) ;
int result_id = - 1 ;
ASSERT_TRUE ( result -> GetAsInteger ( & result_id ) ) ;
DownloadItem * item = GetCurrentManager ( ) -> GetDownload ( result_id ) ;
ASSERT_TRUE ( item ) ;
ScopedCancellingItem canceller ( item ) ;
ASSERT_EQ ( download_url , item -> GetOriginalUrl ( ) . spec ( ) ) ;
ASSERT_TRUE ( WaitFor ( downloads : : OnCreated : : kEventName , base : : StringPrintf ( "[{
\"danger\": \"safe\"," " \"incognito\": false," " \"id\": %d," " \"mime\": \"text/plain\"," " \"paused\": false," " \"url\": \"%s\"}
]" , result_id , download_url . c_str ( ) ) ) ) ;
ASSERT_TRUE ( WaitFor ( downloads : : OnDeterminingFilename : : kEventName , base : : StringPrintf ( "[{
\"id\": %d," " \"filename\":\"slow.txt\"}
]" , result_id ) ) ) ;
ASSERT_TRUE ( item -> GetTargetFilePath ( ) . empty ( ) ) ;
ASSERT_EQ ( DownloadItem : : IN_PROGRESS , item -> GetState ( ) ) ;
std : : string error ;
ASSERT_FALSE ( ExtensionDownloadsEventRouter : : DetermineFilename ( browser ( ) -> profile ( ) , false , GetExtensionId ( ) , result_id , base : : FilePath ( FILE_PATH_LITERAL ( "." ) ) , downloads : : FILENAME_CONFLICT_ACTION_UNIQUIFY , & error ) ) ;
EXPECT_STREQ ( errors : : kInvalidFilename , error . c_str ( ) ) ;
ASSERT_TRUE ( WaitFor ( downloads : : OnChanged : : kEventName , base : : StringPrintf ( "[{
\"id\": %d," " \"filename\": {
" " \"previous\": \"\"," " \"current\": \"%s\"}
}
]" , result_id , GetFilename ( "slow.txt" ) . c_str ( ) ) ) ) ;
ASSERT_TRUE ( WaitFor ( downloads : : OnChanged : : kEventName , base : : StringPrintf ( "[{
\"id\": %d," " \"state\": {
" " \"previous\": \"in_progress\"," " \"current\": \"complete\"}
}
]" , result_id ) ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int zzstop ( i_ctx_t * i_ctx_p ) {
os_ptr op = osp ;
uint count ;
check_type ( * op , t_integer ) ;
count = count_to_stopped ( i_ctx_p , op -> value . intval ) ;
if ( count ) {
ref save_result ;
check_op ( 2 ) ;
save_result = op [ - 1 ] ;
pop ( 2 ) ;
pop_estack ( i_ctx_p , count ) ;
op = osp ;
push ( 1 ) ;
* op = save_result ;
return o_pop_estack ;
}
return unmatched_exit ( op , zzstop ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_cip_safety_data ( proto_tree * tree , proto_item * item , tvbuff_t * tvb , int item_length , packet_info * pinfo ) {
int base_length , io_data_size ;
gboolean multicast = ( ( ( pntoh32 ( pinfo -> dst . data ) ) & 0xf0000000 ) == 0xe0000000 ) ;
gboolean server_dir = FALSE ;
enum enip_connid_type conn_type = ECIDT_UNKNOWN ;
enum cip_safety_format_type format = CIP_SAFETY_BASE_FORMAT ;
cip_safety_info_t * safety_info = ( cip_safety_info_t * ) p_get_proto_data ( wmem_file_scope ( ) , pinfo , proto_cipsafety , 0 ) ;
col_set_str ( pinfo -> cinfo , COL_PROTOCOL , "CIP Safety" ) ;
if ( safety_info != NULL ) {
conn_type = safety_info -> conn_type ;
format = safety_info -> format ;
server_dir = safety_info -> server_dir ;
}
base_length = multicast ? 12 : 6 ;
if ( item_length <= base_length ) {
expert_add_info ( pinfo , item , & ei_mal_io ) ;
return ;
}
if ( ( ( conn_type == ECIDT_O2T ) && ( server_dir == FALSE ) ) || ( ( conn_type == ECIDT_T2O ) && ( server_dir == TRUE ) ) ) {
dissect_ack_byte ( tree , tvb , 0 , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_consumer_time_value , tvb , 1 , 2 , ENC_LITTLE_ENDIAN ) ;
switch ( format ) {
case CIP_SAFETY_BASE_FORMAT : proto_tree_add_item ( tree , hf_cipsafety_ack_byte2 , tvb , 3 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , 4 , 2 , ENC_LITTLE_ENDIAN ) ;
break ;
case CIP_SAFETY_EXTENDED_FORMAT : proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , 3 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , 4 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , 5 , 1 , ENC_LITTLE_ENDIAN ) ;
break ;
}
}
else if ( ( ( conn_type == ECIDT_O2T ) && ( server_dir == TRUE ) ) || ( ( conn_type == ECIDT_T2O ) && ( server_dir == FALSE ) ) ) {
switch ( format ) {
case CIP_SAFETY_BASE_FORMAT : if ( item_length - base_length <= 2 ) {
proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length - base_length , ENC_NA ) ;
dissect_mode_byte ( tree , tvb , item_length - base_length , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , item_length - base_length + 1 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s2 , tvb , item_length - base_length + 2 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , item_length - base_length + 3 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , item_length - base_length + 5 , 1 , ENC_LITTLE_ENDIAN ) ;
if ( multicast ) {
dissect_mcast_byte ( tree , tvb , item_length - 6 , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , item_length - 5 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_mcast_byte2 , tvb , item_length - 3 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , item_length - 2 , 2 , ENC_LITTLE_ENDIAN ) ;
}
}
else {
if ( item_length % 2 == 1 ) {
expert_add_info ( pinfo , item , & ei_mal_io ) ;
return ;
}
io_data_size = multicast ? ( ( item_length - 14 ) / 2 ) : ( ( item_length - 8 ) / 2 ) ;
proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , io_data_size , ENC_NA ) ;
dissect_mode_byte ( tree , tvb , io_data_size , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , io_data_size + 1 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_complement_data , tvb , io_data_size + 3 , io_data_size , ENC_NA ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , ( io_data_size * 2 ) + 3 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , ( io_data_size * 2 ) + 5 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , ( io_data_size * 2 ) + 7 , 1 , ENC_LITTLE_ENDIAN ) ;
if ( multicast ) {
dissect_mcast_byte ( tree , tvb , ( io_data_size * 2 ) + 5 , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , ( io_data_size * 2 ) + 6 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_mcast_byte2 , tvb , ( io_data_size * 2 ) + 8 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , ( io_data_size * 2 ) + 9 , 2 , ENC_LITTLE_ENDIAN ) ;
}
}
break ;
case CIP_SAFETY_EXTENDED_FORMAT : if ( item_length - base_length <= 2 ) {
proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length - base_length , ENC_NA ) ;
dissect_mode_byte ( tree , tvb , item_length - base_length , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , item_length - base_length + 1 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , item_length - base_length + 2 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , item_length - base_length + 3 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , item_length - base_length + 5 , 1 , ENC_LITTLE_ENDIAN ) ;
if ( multicast ) {
dissect_mcast_byte ( tree , tvb , item_length - 6 , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , item_length - 5 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , item_length - 3 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , item_length - 2 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , item_length - 1 , 1 , ENC_LITTLE_ENDIAN ) ;
}
}
else {
if ( item_length % 2 == 1 ) {
expert_add_info ( pinfo , item , & ei_mal_io ) ;
return ;
}
io_data_size = multicast ? ( ( item_length - 14 ) / 2 ) : ( ( item_length - 8 ) / 2 ) ;
proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , io_data_size , ENC_NA ) ;
dissect_mode_byte ( tree , tvb , io_data_size , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , io_data_size + 1 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_complement_data , tvb , io_data_size + 3 , io_data_size , ENC_NA ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , ( io_data_size * 2 ) + 3 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , ( io_data_size * 2 ) + 4 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , ( io_data_size * 2 ) + 5 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , ( io_data_size * 2 ) + 7 , 1 , ENC_LITTLE_ENDIAN ) ;
if ( multicast ) {
dissect_mcast_byte ( tree , tvb , ( io_data_size * 2 ) + 8 , pinfo ) ;
proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , ( io_data_size * 2 ) + 9 , 2 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , ( io_data_size * 2 ) + 11 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , ( io_data_size * 2 ) + 12 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , ( io_data_size * 2 ) + 13 , 1 , ENC_LITTLE_ENDIAN ) ;
}
}
break ;
}
}
else {
proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length , ENC_NA ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int parse_CTableColumn ( tvbuff_t * tvb , int offset , proto_tree * parent_tree , proto_tree * pad_tree , struct CTableColumn * col , const char * fmt , ... ) {
static const value_string DBAGGTTYPE [ ] = {
{
0x0 , "DBAGGTTYPE_BYNONE" }
, {
0x1 , "DBAGGTTYPE_SUM" }
, {
0x2 , "DBAGGTTYPE_MAX" }
, {
0x3 , "DBAGGTTYPE_MIN" }
, {
0x4 , "DBAGGTTYPE_AVG" }
, {
0x5 , "DBAGGTTYPE_COUNT" }
, {
0x6 , "DBAGGTTYPE_CHILDCOUNT" }
, {
0x7 , "DBAGGTTYPE_BYFREQ" }
, {
0x8 , "DBAGGTTYPE_FIRST" }
, {
0x9 , "DBAGGTTYPE_DATERANGE" }
, {
0xA , "DBAGGTTYPE_REPRESENTATIVEOF" }
, {
0xB , "DBAGGTTYPE_EDITDISTANCE" }
, {
0 , NULL }
}
;
proto_item * item ;
proto_tree * tree ;
va_list ap ;
struct vtype_data * type ;
enum vType vtype_val = VT_EMPTY ;
enum vType vtype_valhi = VT_EMPTY ;
struct CFullPropSpec v ;
const char * txt ;
guint8 used ;
const char * modifier = "" ;
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_CTableColumn , & item , txt ) ;
offset = parse_CFullPropSpec ( tvb , offset , tree , pad_tree , & v , "PropSpec" ) ;
get_name_from_fullpropspec ( & v , col -> name , PROP_LENGTH ) ;
col -> vtype = tvb_get_letohl ( tvb , offset ) ;
vtype_val = ( enum vType ) col -> vtype ;
vtype_valhi = ( enum vType ) ( col -> vtype & 0xFF00 ) ;
if ( vtype_valhi ) {
if ( vtype_valhi == VT_VECTOR ) {
modifier = "|VT_VECTOR" ;
}
else if ( vtype_valhi == VT_ARRAY ) {
modifier = "|VT_ARRAY" ;
}
else {
modifier = "|(Unknown, possibly error)" ;
}
}
type = vType_get_type ( vtype_val ) ;
DISSECTOR_ASSERT ( type != NULL ) ;
proto_tree_add_string_format_value ( tree , hf_mswsp_ctablecolumn_vtype , tvb , offset , 4 , type -> str , "%s%s" , type -> str , modifier ) ;
offset += 4 ;
used = tvb_get_guint8 ( tvb , offset ) ;
col -> aggregateused = used ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_aggused , tvb , offset , 1 , used ) ;
offset += 1 ;
if ( used ) {
col -> aggregatetype = tvb_get_guint8 ( tvb , offset ) ;
proto_tree_add_string ( tree , hf_mswsp_ctablecolumn_aggtype , tvb , offset , 1 , val_to_str ( col -> aggregatetype , DBAGGTTYPE , "(Unknown: 0x%x)" ) ) ;
offset += 1 ;
}
col -> valueused = tvb_get_guint8 ( tvb , offset ) ;
used = col -> valueused ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_valused , tvb , offset , 1 , used ) ;
offset += 1 ;
if ( used ) {
offset = parse_padding ( tvb , offset , 2 , pad_tree , "padding_Value" ) ;
col -> valueoffset = tvb_get_letohs ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_valoffset , tvb , offset , 2 , col -> valueoffset ) ;
offset += 2 ;
col -> valuesize = tvb_get_letohs ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_valsize , tvb , offset , 2 , col -> valuesize ) ;
offset += 2 ;
}
used = tvb_get_guint8 ( tvb , offset ) ;
col -> statusused = used ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_statused , tvb , offset , 1 , used ) ;
offset += 1 ;
if ( used ) {
offset = parse_padding ( tvb , offset , 2 , pad_tree , "padding_Status" ) ;
col -> statusoffset = tvb_get_letohs ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_statoffset , tvb , offset , 2 , col -> statusoffset ) ;
offset += 2 ;
}
used = tvb_get_guint8 ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_lenused , tvb , offset , 1 , used ) ;
col -> lengthused = used ;
offset += 1 ;
if ( used ) {
offset = parse_padding ( tvb , offset , 2 , pad_tree , "padding_Length" ) ;
col -> lengthoffset = tvb_get_letohs ( tvb , offset ) ;
proto_tree_add_uint ( tree , hf_mswsp_ctablecolumn_lenoffset , tvb , offset , 2 , col -> lengthoffset ) ;
offset += 2 ;
}
proto_item_set_end ( item , tvb , offset ) ;
return offset ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void initial_reordering ( const hb_ot_shape_plan_t * plan , hb_font_t * font , hb_buffer_t * buffer ) {
insert_dotted_circles ( plan , font , buffer ) ;
foreach_syllable ( buffer , start , end ) initial_reordering_syllable ( plan , font -> face , buffer , start , end ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug9992 ( ) {
MYSQL * mysql1 ;
MYSQL_RES * res ;
int rc ;
myheader ( "test_bug9992" ) ;
if ( ! opt_silent ) printf ( "Establishing a connection with option CLIENT_MULTI_STATEMENTS..\n" ) ;
mysql1 = mysql_client_init ( NULL ) ;
if ( ! mysql_real_connect ( mysql1 , opt_host , opt_user , opt_password , opt_db ? opt_db : "test" , opt_port , opt_unix_socket , CLIENT_MULTI_STATEMENTS ) ) {
fprintf ( stderr , "Failed to connect to the database\n" ) ;
DIE_UNLESS ( 0 ) ;
}
rc = mysql_query ( mysql1 , "SHOW TABLES;
SHOW DATABASE;
SELECT 1;
" ) ;
if ( rc ) {
fprintf ( stderr , "[%d] %s\n" , mysql_errno ( mysql1 ) , mysql_error ( mysql1 ) ) ;
DIE_UNLESS ( 0 ) ;
}
if ( ! opt_silent ) printf ( "Testing mysql_store_result/mysql_next_result..\n" ) ;
res = mysql_store_result ( mysql1 ) ;
DIE_UNLESS ( res ) ;
mysql_free_result ( res ) ;
rc = mysql_next_result ( mysql1 ) ;
DIE_UNLESS ( rc == 1 ) ;
if ( ! opt_silent ) fprintf ( stdout , "Got error, as expected:\n [%d] %s\n" , mysql_errno ( mysql1 ) , mysql_error ( mysql1 ) ) ;
mysql_close ( mysql1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int aes_ocb_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_OCB_CTX * octx = EVP_C_DATA ( EVP_AES_OCB_CTX , c ) ;
EVP_CIPHER_CTX * newc ;
EVP_AES_OCB_CTX * new_octx ;
switch ( type ) {
case EVP_CTRL_INIT : octx -> key_set = 0 ;
octx -> iv_set = 0 ;
octx -> ivlen = EVP_CIPHER_CTX_iv_length ( c ) ;
octx -> iv = EVP_CIPHER_CTX_iv_noconst ( c ) ;
octx -> taglen = 16 ;
octx -> data_buf_len = 0 ;
octx -> aad_buf_len = 0 ;
return 1 ;
case EVP_CTRL_AEAD_SET_IVLEN : if ( arg <= 0 || arg > 15 ) return 0 ;
octx -> ivlen = arg ;
return 1 ;
case EVP_CTRL_AEAD_SET_TAG : if ( ! ptr ) {
if ( arg < 0 || arg > 16 ) return 0 ;
octx -> taglen = arg ;
return 1 ;
}
if ( arg != octx -> taglen || EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( octx -> tag , ptr , arg ) ;
return 1 ;
case EVP_CTRL_AEAD_GET_TAG : if ( arg != octx -> taglen || ! EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( ptr , octx -> tag , arg ) ;
return 1 ;
case EVP_CTRL_COPY : newc = ( EVP_CIPHER_CTX * ) ptr ;
new_octx = EVP_C_DATA ( EVP_AES_OCB_CTX , newc ) ;
return CRYPTO_ocb128_copy_ctx ( & new_octx -> ocb , & octx -> ocb , & new_octx -> ksenc . ks , & new_octx -> ksdec . ks ) ;
default : return - 1 ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint16 de_tp_sub_channel ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) {
guint32 curr_offset ;
guchar oct ;
const gchar * str ;
curr_offset = offset ;
oct = tvb_get_guint8 ( tvb , curr_offset ) & 0x3f ;
if ( ( oct & 0x38 ) == 0x38 ) str = "I" ;
else if ( ( oct & 0x38 ) == 0x18 ) str = "F" ;
else if ( ( oct & 0x38 ) == 0x10 ) str = "E" ;
else if ( ( oct & 0x38 ) == 0x08 ) str = "D" ;
else if ( ( oct & 0x3c ) == 0x04 ) str = "C" ;
else if ( ( oct & 0x3e ) == 0x02 ) str = "B" ;
else if ( ( oct & 0x3e ) == 0x00 ) str = "A" ;
else str = "unknown" ;
proto_tree_add_uint_format_value ( tree , hf_gsm_a_dtap_test_loop , tvb , curr_offset , 1 , oct , "%s" , str ) ;
proto_tree_add_item ( tree , hf_gsm_a_dtap_subchannel , tvb , curr_offset , 1 , ENC_NA ) ;
curr_offset += 1 ;
return ( curr_offset - offset ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PKCS8_PRIV_KEY_INFO * d2i_PKCS8_PRIV_KEY_INFO_bio ( BIO * bp , PKCS8_PRIV_KEY_INFO * * p8inf ) {
return ASN1_d2i_bio_of ( PKCS8_PRIV_KEY_INFO , PKCS8_PRIV_KEY_INFO_new , d2i_PKCS8_PRIV_KEY_INFO , bp , p8inf ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug31669 ( ) {
int rc ;
static char buff [ LARGE_BUFFER_SIZE + 1 ] ;
# ifndef EMBEDDED_LIBRARY static char user [ USERNAME_CHAR_LENGTH + 1 ] ;
static char db [ NAME_CHAR_LEN + 1 ] ;
static char query [ LARGE_BUFFER_SIZE * 2 ] ;
# endif MYSQL * l_mysql ;
DBUG_ENTER ( "test_bug31669" ) ;
myheader ( "test_bug31669" ) ;
l_mysql = mysql_client_init ( NULL ) ;
DIE_UNLESS ( l_mysql != NULL ) ;
l_mysql = mysql_real_connect ( l_mysql , opt_host , opt_user , opt_password , current_db , opt_port , opt_unix_socket , 0 ) ;
DIE_UNLESS ( l_mysql != 0 ) ;
rc = mysql_change_user ( l_mysql , NULL , NULL , NULL ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
rc = mysql_change_user ( l_mysql , "" , "" , "" ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
memset ( buff , 'a' , sizeof ( buff ) ) ;
buff [ sizeof ( buff ) - 1 ] = '\0' ;
rc = mysql_change_user ( l_mysql , buff , buff , buff ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
rc = mysql_change_user ( mysql , opt_user , opt_password , current_db ) ;
DIE_UNLESS ( ! rc ) ;
# ifndef EMBEDDED_LIBRARY memset ( db , 'a' , sizeof ( db ) ) ;
db [ NAME_CHAR_LEN ] = 0 ;
strxmov ( query , "CREATE DATABASE IF NOT EXISTS " , db , NullS ) ;
rc = mysql_query ( mysql , query ) ;
myquery ( rc ) ;
memset ( user , 'b' , sizeof ( user ) ) ;
user [ USERNAME_CHAR_LENGTH ] = 0 ;
memset ( buff , 'c' , sizeof ( buff ) ) ;
buff [ LARGE_BUFFER_SIZE ] = 0 ;
strxmov ( query , "GRANT ALL PRIVILEGES ON *.* TO '" , user , "'@'%' IDENTIFIED BY " "'" , buff , "' WITH GRANT OPTION" , NullS ) ;
rc = mysql_query ( mysql , query ) ;
myquery ( rc ) ;
strxmov ( query , "GRANT ALL PRIVILEGES ON *.* TO '" , user , "'@'localhost' IDENTIFIED BY " "'" , buff , "' WITH GRANT OPTION" , NullS ) ;
rc = mysql_query ( mysql , query ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "FLUSH PRIVILEGES" ) ;
myquery ( rc ) ;
rc = mysql_change_user ( l_mysql , user , buff , db ) ;
DIE_UNLESS ( ! rc ) ;
user [ USERNAME_CHAR_LENGTH - 1 ] = 'a' ;
rc = mysql_change_user ( l_mysql , user , buff , db ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
user [ USERNAME_CHAR_LENGTH - 1 ] = 'b' ;
buff [ LARGE_BUFFER_SIZE - 1 ] = 'd' ;
rc = mysql_change_user ( l_mysql , user , buff , db ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
buff [ LARGE_BUFFER_SIZE - 1 ] = 'c' ;
db [ NAME_CHAR_LEN - 1 ] = 'e' ;
rc = mysql_change_user ( l_mysql , user , buff , db ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
db [ NAME_CHAR_LEN - 1 ] = 'a' ;
rc = mysql_change_user ( l_mysql , user , buff , db ) ;
DIE_UNLESS ( ! rc ) ;
rc = mysql_change_user ( l_mysql , user + 1 , buff + 1 , db + 1 ) ;
DIE_UNLESS ( rc ) ;
reconnect ( & l_mysql ) ;
rc = mysql_change_user ( mysql , opt_user , opt_password , current_db ) ;
DIE_UNLESS ( ! rc ) ;
strxmov ( query , "DROP DATABASE " , db , NullS ) ;
rc = mysql_query ( mysql , query ) ;
myquery ( rc ) ;
strxmov ( query , "DELETE FROM mysql.user WHERE User='" , user , "'" , NullS ) ;
rc = mysql_query ( mysql , query ) ;
myquery ( rc ) ;
DIE_UNLESS ( mysql_affected_rows ( mysql ) == 2 ) ;
mysql_close ( l_mysql ) ;
# endif DBUG_VOID_RETURN ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int test_sqrt ( BIO * bp , BN_CTX * ctx ) {
BN_GENCB cb ;
BIGNUM * a , * p , * r ;
int i , j ;
int ret = 0 ;
a = BN_new ( ) ;
p = BN_new ( ) ;
r = BN_new ( ) ;
if ( a == NULL || p == NULL || r == NULL ) goto err ;
BN_GENCB_set ( & cb , genprime_cb , NULL ) ;
for ( i = 0 ;
i < 16 ;
i ++ ) {
if ( i < 8 ) {
unsigned primes [ 8 ] = {
2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 }
;
if ( ! BN_set_word ( p , primes [ i ] ) ) goto err ;
}
else {
if ( ! BN_set_word ( a , 32 ) ) goto err ;
if ( ! BN_set_word ( r , 2 * i + 1 ) ) goto err ;
if ( ! BN_generate_prime_ex ( p , 256 , 0 , a , r , & cb ) ) goto err ;
putc ( '\n' , stderr ) ;
}
p -> neg = rand_neg ( ) ;
for ( j = 0 ;
j < num2 ;
j ++ ) {
if ( ! BN_bntest_rand ( r , 256 , 0 , 3 ) ) goto err ;
if ( ! BN_nnmod ( r , r , p , ctx ) ) goto err ;
if ( ! BN_mod_sqr ( r , r , p , ctx ) ) goto err ;
if ( ! BN_bntest_rand ( a , 256 , 0 , 3 ) ) goto err ;
if ( ! BN_nnmod ( a , a , p , ctx ) ) goto err ;
if ( ! BN_mod_sqr ( a , a , p , ctx ) ) goto err ;
if ( ! BN_mul ( a , a , r , ctx ) ) goto err ;
if ( rand_neg ( ) ) if ( ! BN_sub ( a , a , p ) ) goto err ;
if ( ! BN_mod_sqrt ( r , a , p , ctx ) ) goto err ;
if ( ! BN_mod_sqr ( r , r , p , ctx ) ) goto err ;
if ( ! BN_nnmod ( a , a , p , ctx ) ) goto err ;
if ( BN_cmp ( a , r ) != 0 ) {
fprintf ( stderr , "BN_mod_sqrt failed: a = " ) ;
BN_print_fp ( stderr , a ) ;
fprintf ( stderr , ", r = " ) ;
BN_print_fp ( stderr , r ) ;
fprintf ( stderr , ", p = " ) ;
BN_print_fp ( stderr , p ) ;
fprintf ( stderr , "\n" ) ;
goto err ;
}
putc ( '.' , stderr ) ;
fflush ( stderr ) ;
}
putc ( '\n' , stderr ) ;
fflush ( stderr ) ;
}
ret = 1 ;
err : if ( a != NULL ) BN_free ( a ) ;
if ( p != NULL ) BN_free ( p ) ;
if ( r != NULL ) BN_free ( r ) ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static krb5_error_code process_db_args ( krb5_context context , char * * db_args , xargs_t * xargs , OPERATION optype ) {
int i = 0 ;
krb5_error_code st = 0 ;
char * arg = NULL , * arg_val = NULL ;
char * * dptr = NULL ;
unsigned int arg_val_len = 0 ;
if ( db_args ) {
for ( i = 0 ;
db_args [ i ] ;
++ i ) {
arg = strtok_r ( db_args [ i ] , "=" , & arg_val ) ;
if ( strcmp ( arg , TKTPOLICY_ARG ) == 0 ) {
dptr = & xargs -> tktpolicydn ;
}
else {
if ( strcmp ( arg , USERDN_ARG ) == 0 ) {
if ( optype == MODIFY_PRINCIPAL || xargs -> dn != NULL || xargs -> containerdn != NULL || xargs -> linkdn != NULL ) {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "%s option not supported" ) , arg ) ;
goto cleanup ;
}
dptr = & xargs -> dn ;
}
else if ( strcmp ( arg , CONTAINERDN_ARG ) == 0 ) {
if ( optype == MODIFY_PRINCIPAL || xargs -> dn != NULL || xargs -> containerdn != NULL ) {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "%s option not supported" ) , arg ) ;
goto cleanup ;
}
dptr = & xargs -> containerdn ;
}
else if ( strcmp ( arg , LINKDN_ARG ) == 0 ) {
if ( xargs -> dn != NULL || xargs -> linkdn != NULL ) {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "%s option not supported" ) , arg ) ;
goto cleanup ;
}
dptr = & xargs -> linkdn ;
}
else {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "unknown option: %s" ) , arg ) ;
goto cleanup ;
}
xargs -> dn_from_kbd = TRUE ;
if ( arg_val == NULL || strlen ( arg_val ) == 0 ) {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "%s option value missing" ) , arg ) ;
goto cleanup ;
}
}
if ( arg_val == NULL ) {
st = EINVAL ;
k5_setmsg ( context , st , _ ( "%s option value missing" ) , arg ) ;
goto cleanup ;
}
arg_val_len = strlen ( arg_val ) + 1 ;
if ( strcmp ( arg , TKTPOLICY_ARG ) == 0 ) {
if ( ( st = krb5_ldap_name_to_policydn ( context , arg_val , dptr ) ) != 0 ) goto cleanup ;
}
else {
* dptr = k5memdup ( arg_val , arg_val_len , & st ) ;
if ( * dptr == NULL ) goto cleanup ;
}
}
}
cleanup : return st ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void full_to_model_count ( unsigned int * model_count , unsigned int * full_count ) {
int n ;
model_count [ ZERO_TOKEN ] = full_count [ ZERO_TOKEN ] ;
model_count [ ONE_TOKEN ] = full_count [ ONE_TOKEN ] ;
model_count [ TWO_TOKEN ] = full_count [ TWO_TOKEN ] ;
for ( n = THREE_TOKEN ;
n < EOB_TOKEN ;
++ n ) model_count [ TWO_TOKEN ] += full_count [ n ] ;
model_count [ EOB_MODEL_TOKEN ] = full_count [ EOB_TOKEN ] ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void start_monitoring_file_list ( NautilusDirectory * directory ) {
DirectoryLoadState * state ;
if ( ! directory -> details -> file_list_monitored ) {
g_assert ( ! directory -> details -> directory_load_in_progress ) ;
directory -> details -> file_list_monitored = TRUE ;
nautilus_file_list_ref ( directory -> details -> file_list ) ;
}
if ( directory -> details -> directory_loaded || directory -> details -> directory_load_in_progress != NULL ) {
return ;
}
if ( ! async_job_start ( directory , "file list" ) ) {
return ;
}
mark_all_files_unconfirmed ( directory ) ;
state = g_new0 ( DirectoryLoadState , 1 ) ;
state -> directory = directory ;
state -> cancellable = g_cancellable_new ( ) ;
state -> load_mime_list_hash = istr_set_new ( ) ;
state -> load_file_count = 0 ;
g_assert ( directory -> details -> location != NULL ) ;
state -> load_directory_file = nautilus_directory_get_corresponding_file ( directory ) ;
state -> load_directory_file -> details -> loading_directory = TRUE ;
# ifdef DEBUG_LOAD_DIRECTORY g_message ( "load_directory called to monitor file list of %p" , directory -> details -> location ) ;
# endif directory -> details -> directory_load_in_progress = state ;
g_file_enumerate_children_async ( directory -> details -> location , NAUTILUS_FILE_DEFAULT_ATTRIBUTES , 0 , G_PRIORITY_DEFAULT , state -> cancellable , enumerate_children_callback , state ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | pdf_xobject * pdf_keep_xobject ( fz_context * ctx , pdf_xobject * xobj ) {
return fz_keep_storable ( ctx , & xobj -> storable ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void evhttp_make_header ( struct evhttp_connection * evcon , struct evhttp_request * req ) {
struct evkeyval * header ;
if ( req -> kind == EVHTTP_REQUEST ) {
evhttp_make_header_request ( evcon , req ) ;
}
else {
evhttp_make_header_response ( evcon , req ) ;
}
TAILQ_FOREACH ( header , req -> output_headers , next ) {
evbuffer_add_printf ( evcon -> output_buffer , "%s: %s\r\n" , header -> key , header -> value ) ;
}
evbuffer_add ( evcon -> output_buffer , "\r\n" , 2 ) ;
if ( EVBUFFER_LENGTH ( req -> output_buffer ) > 0 ) {
evbuffer_add_buffer ( evcon -> output_buffer , req -> output_buffer ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( TabDragControllerTest , GestureEndShouldEndDragTest ) {
AddTabAndResetBrowser ( browser ( ) ) ;
TabStrip * tab_strip = GetTabStripForBrowser ( browser ( ) ) ;
Tab * tab1 = tab_strip -> tab_at ( 1 ) ;
gfx : : Point tab_1_center ( tab1 -> width ( ) / 2 , tab1 -> height ( ) / 2 ) ;
ui : : GestureEvent gesture_tap_down ( tab_1_center . x ( ) , tab_1_center . x ( ) , 0 , base : : TimeDelta ( ) , ui : : GestureEventDetails ( ui : : ET_GESTURE_TAP_DOWN ) ) ;
tab_strip -> MaybeStartDrag ( tab1 , gesture_tap_down , tab_strip -> GetSelectionModel ( ) ) ;
EXPECT_TRUE ( TabDragController : : IsActive ( ) ) ;
ui : : GestureEvent gesture_end ( tab_1_center . x ( ) , tab_1_center . x ( ) , 0 , base : : TimeDelta ( ) , ui : : GestureEventDetails ( ui : : ET_GESTURE_END ) ) ;
tab_strip -> OnGestureEvent ( & gesture_end ) ;
EXPECT_FALSE ( TabDragController : : IsActive ( ) ) ;
EXPECT_FALSE ( tab_strip -> IsDragSessionActive ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static floatx80 cpu_set_fp80 ( uint64_t mant , uint16_t upper ) {
CPU_LDoubleU temp ;
temp . l . upper = upper ;
temp . l . lower = mant ;
return temp . d ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int jpc_enc_encodemainhdr ( jpc_enc_t * enc ) {
jpc_siz_t * siz ;
jpc_cod_t * cod ;
jpc_qcd_t * qcd ;
int i ;
long startoff ;
long mainhdrlen ;
jpc_enc_cp_t * cp ;
jpc_qcc_t * qcc ;
jpc_enc_tccp_t * tccp ;
uint_fast16_t cmptno ;
jpc_tsfb_band_t bandinfos [ JPC_MAXBANDS ] ;
jpc_fix_t mctsynweight ;
jpc_enc_tcp_t * tcp ;
jpc_tsfb_t * tsfb ;
jpc_tsfb_band_t * bandinfo ;
uint_fast16_t numbands ;
uint_fast16_t bandno ;
uint_fast16_t rlvlno ;
uint_fast16_t analgain ;
jpc_fix_t absstepsize ;
char buf [ 1024 ] ;
jpc_com_t * com ;
cp = enc -> cp ;
startoff = jas_stream_getrwcount ( enc -> out ) ;
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_SOC ) ) ) {
return - 1 ;
}
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
jas_eprintf ( "cannot write SOC marker\n" ) ;
return - 1 ;
}
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_SIZ ) ) ) {
return - 1 ;
}
siz = & enc -> mrk -> parms . siz ;
siz -> caps = 0 ;
siz -> xoff = cp -> imgareatlx ;
siz -> yoff = cp -> imgareatly ;
siz -> width = cp -> refgrdwidth ;
siz -> height = cp -> refgrdheight ;
siz -> tilexoff = cp -> tilegrdoffx ;
siz -> tileyoff = cp -> tilegrdoffy ;
siz -> tilewidth = cp -> tilewidth ;
siz -> tileheight = cp -> tileheight ;
siz -> numcomps = cp -> numcmpts ;
siz -> comps = jas_alloc2 ( siz -> numcomps , sizeof ( jpc_sizcomp_t ) ) ;
assert ( siz -> comps ) ;
for ( i = 0 ;
i < JAS_CAST ( int , cp -> numcmpts ) ;
++ i ) {
siz -> comps [ i ] . prec = cp -> ccps [ i ] . prec ;
siz -> comps [ i ] . sgnd = cp -> ccps [ i ] . sgnd ;
siz -> comps [ i ] . hsamp = cp -> ccps [ i ] . sampgrdstepx ;
siz -> comps [ i ] . vsamp = cp -> ccps [ i ] . sampgrdstepy ;
}
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
jas_eprintf ( "cannot write SIZ marker\n" ) ;
return - 1 ;
}
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_COM ) ) ) {
return - 1 ;
}
sprintf ( buf , "Creator: JasPer Version %s" , jas_getversion ( ) ) ;
com = & enc -> mrk -> parms . com ;
com -> len = JAS_CAST ( uint_fast16_t , strlen ( buf ) ) ;
com -> regid = JPC_COM_LATIN ;
if ( ! ( com -> data = JAS_CAST ( jas_uchar * , jas_strdup ( buf ) ) ) ) {
abort ( ) ;
}
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
jas_eprintf ( "cannot write COM marker\n" ) ;
return - 1 ;
}
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
# if 0 if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_CRG ) ) ) {
return - 1 ;
}
crg = & enc -> mrk -> parms . crg ;
crg -> comps = jas_alloc2 ( crg -> numcomps , sizeof ( jpc_crgcomp_t ) ) ;
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
jas_eprintf ( "cannot write CRG marker\n" ) ;
return - 1 ;
}
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
# endif tcp = & cp -> tcp ;
tccp = & cp -> tccp ;
for ( cmptno = 0 ;
cmptno < cp -> numcmpts ;
++ cmptno ) {
tsfb = jpc_cod_gettsfb ( tccp -> qmfbid , tccp -> maxrlvls - 1 ) ;
jpc_tsfb_getbands ( tsfb , 0 , 0 , 1 << tccp -> maxrlvls , 1 << tccp -> maxrlvls , bandinfos ) ;
jpc_tsfb_destroy ( tsfb ) ;
mctsynweight = jpc_mct_getsynweight ( tcp -> mctid , cmptno ) ;
numbands = 3 * tccp -> maxrlvls - 2 ;
for ( bandno = 0 , bandinfo = bandinfos ;
bandno < numbands ;
++ bandno , ++ bandinfo ) {
rlvlno = ( bandno ) ? ( ( bandno - 1 ) / 3 + 1 ) : 0 ;
analgain = JPC_NOMINALGAIN ( tccp -> qmfbid , tccp -> maxrlvls , rlvlno , bandinfo -> orient ) ;
if ( ! tcp -> intmode ) {
absstepsize = jpc_fix_div ( jpc_inttofix ( 1 << ( analgain + 1 ) ) , bandinfo -> synenergywt ) ;
}
else {
absstepsize = jpc_inttofix ( 1 ) ;
}
cp -> ccps [ cmptno ] . stepsizes [ bandno ] = jpc_abstorelstepsize ( absstepsize , cp -> ccps [ cmptno ] . prec + analgain ) ;
}
cp -> ccps [ cmptno ] . numstepsizes = numbands ;
}
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_COD ) ) ) {
return - 1 ;
}
cod = & enc -> mrk -> parms . cod ;
cod -> csty = cp -> tccp . csty | cp -> tcp . csty ;
cod -> compparms . csty = cp -> tccp . csty | cp -> tcp . csty ;
cod -> compparms . numdlvls = cp -> tccp . maxrlvls - 1 ;
cod -> compparms . numrlvls = cp -> tccp . maxrlvls ;
cod -> prg = cp -> tcp . prg ;
cod -> numlyrs = cp -> tcp . numlyrs ;
cod -> compparms . cblkwidthval = JPC_COX_CBLKSIZEEXPN ( cp -> tccp . cblkwidthexpn ) ;
cod -> compparms . cblkheightval = JPC_COX_CBLKSIZEEXPN ( cp -> tccp . cblkheightexpn ) ;
cod -> compparms . cblksty = cp -> tccp . cblksty ;
cod -> compparms . qmfbid = cp -> tccp . qmfbid ;
cod -> mctrans = ( cp -> tcp . mctid != JPC_MCT_NONE ) ;
if ( tccp -> csty & JPC_COX_PRT ) {
for ( rlvlno = 0 ;
rlvlno < tccp -> maxrlvls ;
++ rlvlno ) {
cod -> compparms . rlvls [ rlvlno ] . parwidthval = tccp -> prcwidthexpns [ rlvlno ] ;
cod -> compparms . rlvls [ rlvlno ] . parheightval = tccp -> prcheightexpns [ rlvlno ] ;
}
}
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
jas_eprintf ( "cannot write COD marker\n" ) ;
return - 1 ;
}
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_QCD ) ) ) {
return - 1 ;
}
qcd = & enc -> mrk -> parms . qcd ;
qcd -> compparms . qntsty = ( tccp -> qmfbid == JPC_COX_INS ) ? JPC_QCX_SEQNT : JPC_QCX_NOQNT ;
qcd -> compparms . numstepsizes = cp -> ccps [ 0 ] . numstepsizes ;
qcd -> compparms . numguard = cp -> tccp . numgbits ;
qcd -> compparms . stepsizes = cp -> ccps [ 0 ] . stepsizes ;
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
return - 1 ;
}
qcd -> compparms . stepsizes = 0 ;
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
tccp = & cp -> tccp ;
for ( cmptno = 1 ;
cmptno < cp -> numcmpts ;
++ cmptno ) {
if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_QCC ) ) ) {
return - 1 ;
}
qcc = & enc -> mrk -> parms . qcc ;
qcc -> compno = cmptno ;
qcc -> compparms . qntsty = ( tccp -> qmfbid == JPC_COX_INS ) ? JPC_QCX_SEQNT : JPC_QCX_NOQNT ;
qcc -> compparms . numstepsizes = cp -> ccps [ cmptno ] . numstepsizes ;
qcc -> compparms . numguard = cp -> tccp . numgbits ;
qcc -> compparms . stepsizes = cp -> ccps [ cmptno ] . stepsizes ;
if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) {
return - 1 ;
}
qcc -> compparms . stepsizes = 0 ;
jpc_ms_destroy ( enc -> mrk ) ;
enc -> mrk = 0 ;
}
# define MAINTLRLEN 2 mainhdrlen = jas_stream_getrwcount ( enc -> out ) - startoff ;
enc -> len += mainhdrlen ;
if ( enc -> cp -> totalsize != UINT_FAST32_MAX ) {
uint_fast32_t overhead ;
overhead = mainhdrlen + MAINTLRLEN ;
enc -> mainbodysize = ( enc -> cp -> totalsize >= overhead ) ? ( enc -> cp -> totalsize - overhead ) : 0 ;
}
else {
enc -> mainbodysize = UINT_FAST32_MAX ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void long_help ( void ) {
const char * prog ;
const char * p ;
prog = lafe_getprogname ( ) ;
fflush ( stderr ) ;
p = ( strcmp ( prog , "bsdcpio" ) != 0 ) ? "(bsdcpio)" : "" ;
printf ( "%s%s: manipulate archive files\n" , prog , p ) ;
for ( p = long_help_msg ;
* p != '\0' ;
p ++ ) {
if ( * p == '%' ) {
if ( p [ 1 ] == 'p' ) {
fputs ( prog , stdout ) ;
p ++ ;
}
else putchar ( '%' ) ;
}
else putchar ( * p ) ;
}
version ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_pvfs_handle_extent_array ( tvbuff_t * tvb , proto_tree * tree , int offset , packet_info * pinfo ) {
guint32 extent_count ;
guint32 nCount ;
proto_tree * extent_array_tree ;
extent_count = tvb_get_letohl ( tvb , offset ) ;
extent_array_tree = proto_tree_add_subtree_format ( tree , tvb , offset , 4 , ett_pvfs_extent_array_tree , NULL , "Handle Extent Array (count = %d)" , extent_count ) ;
offset += 4 ;
if ( extent_count > 0 ) {
for ( nCount = 0 ;
nCount < extent_count ;
nCount ++ ) offset = dissect_pvfs_handle_extent ( tvb , extent_array_tree , offset , pinfo , nCount ) ;
}
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static decNumber * decCompareOp ( decNumber * res , const decNumber * lhs , const decNumber * rhs , decContext * set , Flag op , uInt * status ) {
# if DECSUBSET decNumber * alloclhs = NULL ;
decNumber * allocrhs = NULL ;
# endif Int result = 0 ;
uByte merged ;
# if DECCHECK if ( decCheckOperands ( res , lhs , rhs , set ) ) return res ;
# endif do {
# if DECSUBSET if ( ! set -> extended ) {
if ( lhs -> digits > set -> digits ) {
alloclhs = decRoundOperand ( lhs , set , status ) ;
if ( alloclhs == NULL ) {
result = BADINT ;
break ;
}
lhs = alloclhs ;
}
if ( rhs -> digits > set -> digits ) {
allocrhs = decRoundOperand ( rhs , set , status ) ;
if ( allocrhs == NULL ) {
result = BADINT ;
break ;
}
rhs = allocrhs ;
}
}
# endif if ( op == COMPTOTAL ) {
if ( decNumberIsNegative ( lhs ) && ! decNumberIsNegative ( rhs ) ) {
result = - 1 ;
break ;
}
if ( ! decNumberIsNegative ( lhs ) && decNumberIsNegative ( rhs ) ) {
result = + 1 ;
break ;
}
}
merged = ( lhs -> bits | rhs -> bits ) & ( DECSNAN | DECNAN ) ;
if ( merged ) {
if ( op == COMPARE ) ;
else if ( op == COMPSIG ) * status |= DEC_Invalid_operation | DEC_sNaN ;
else if ( op == COMPTOTAL ) {
if ( ! decNumberIsNaN ( lhs ) ) result = - 1 ;
else if ( ! decNumberIsNaN ( rhs ) ) result = + 1 ;
else if ( decNumberIsSNaN ( lhs ) && decNumberIsQNaN ( rhs ) ) result = - 1 ;
else if ( decNumberIsQNaN ( lhs ) && decNumberIsSNaN ( rhs ) ) result = + 1 ;
else {
result = decUnitCompare ( lhs -> lsu , D2U ( lhs -> digits ) , rhs -> lsu , D2U ( rhs -> digits ) , 0 ) ;
}
if ( decNumberIsNegative ( lhs ) ) result = - result ;
break ;
}
else if ( merged & DECSNAN ) ;
else {
if ( ! decNumberIsNaN ( lhs ) || ! decNumberIsNaN ( rhs ) ) {
op = COMPMAX ;
if ( lhs -> bits & DECNAN ) result = - 1 ;
else result = + 1 ;
break ;
}
}
op = COMPNAN ;
decNaNs ( res , lhs , rhs , set , status ) ;
break ;
}
if ( op == COMPMAXMAG || op == COMPMINMAG ) result = decCompare ( lhs , rhs , 1 ) ;
else result = decCompare ( lhs , rhs , 0 ) ;
}
while ( 0 ) ;
if ( result == BADINT ) * status |= DEC_Insufficient_storage ;
else {
if ( op == COMPARE || op == COMPSIG || op == COMPTOTAL ) {
if ( op == COMPTOTAL && result == 0 ) {
if ( lhs -> exponent != rhs -> exponent ) {
if ( lhs -> exponent < rhs -> exponent ) result = - 1 ;
else result = + 1 ;
if ( decNumberIsNegative ( lhs ) ) result = - result ;
}
}
uprv_decNumberZero ( res ) ;
if ( result != 0 ) {
* res -> lsu = 1 ;
if ( result < 0 ) res -> bits = DECNEG ;
}
}
else if ( op == COMPNAN ) ;
else {
Int residue = 0 ;
const decNumber * choice ;
if ( result == 0 ) {
uByte slhs = ( lhs -> bits & DECNEG ) ;
uByte srhs = ( rhs -> bits & DECNEG ) ;
# if DECSUBSET if ( ! set -> extended ) {
op = COMPMAX ;
result = + 1 ;
}
else # endif if ( slhs != srhs ) {
if ( slhs ) result = - 1 ;
else result = + 1 ;
}
else if ( slhs && srhs ) {
if ( lhs -> exponent < rhs -> exponent ) result = + 1 ;
else result = - 1 ;
}
else {
if ( lhs -> exponent > rhs -> exponent ) result = + 1 ;
else result = - 1 ;
}
}
if ( op == COMPMIN || op == COMPMINMAG ) result = - result ;
choice = ( result > 0 ? lhs : rhs ) ;
decCopyFit ( res , choice , set , & residue , status ) ;
decFinish ( res , set , & residue , status ) ;
}
}
# if DECSUBSET if ( allocrhs != NULL ) free ( allocrhs ) ;
if ( alloclhs != NULL ) free ( alloclhs ) ;
# endif return res ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void TSHttpTxnErrorBodySet ( TSHttpTxn txnp , char * buf , size_t buflength , char * mimetype ) {
sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;
HttpSM * sm = ( HttpSM * ) txnp ;
HttpTransact : : State * s = & ( sm -> t_state ) ;
s -> free_internal_msg_buffer ( ) ;
ats_free ( s -> internal_msg_buffer_type ) ;
s -> internal_msg_buffer = buf ;
s -> internal_msg_buffer_size = buf ? buflength : 0 ;
s -> internal_msg_buffer_fast_allocator_size = - 1 ;
s -> internal_msg_buffer_type = mimetype ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_IS11172AudioMode ( 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_IS11172AudioMode , IS11172AudioMode_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void qemu_kvm_start_vcpu ( CPUState * cpu ) {
cpu -> thread = g_malloc0 ( sizeof ( QemuThread ) ) ;
cpu -> halt_cond = g_malloc0 ( sizeof ( QemuCond ) ) ;
qemu_cond_init ( cpu -> halt_cond ) ;
qemu_thread_create ( cpu -> thread , qemu_kvm_cpu_thread_fn , cpu , QEMU_THREAD_JOINABLE ) ;
while ( ! cpu -> created ) {
qemu_cond_wait ( & qemu_cpu_cond , & qemu_global_mutex ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | ParseResult validate_hdr_content_length ( HdrHeap * heap , HTTPHdrImpl * hh ) {
MIMEField * content_length_field = mime_hdr_field_find ( hh -> m_fields_impl , MIME_FIELD_CONTENT_LENGTH , MIME_LEN_CONTENT_LENGTH ) ;
if ( content_length_field ) {
if ( mime_hdr_field_find ( hh -> m_fields_impl , MIME_FIELD_TRANSFER_ENCODING , MIME_LEN_TRANSFER_ENCODING ) != nullptr ) {
Debug ( "http" , "Transfer-Encoding header and Content-Length headers the request, removing all Content-Length headers" ) ;
mime_hdr_field_delete ( heap , hh -> m_fields_impl , content_length_field ) ;
return PARSE_RESULT_DONE ;
}
int content_length_len = 0 ;
const char * content_length_val = content_length_field -> value_get ( & content_length_len ) ;
while ( content_length_field -> has_dups ( ) ) {
int content_length_len_2 = 0 ;
const char * content_length_val_2 = content_length_field -> m_next_dup -> value_get ( & content_length_len_2 ) ;
if ( ( content_length_len != content_length_len_2 ) || ( memcmp ( content_length_val , content_length_val_2 , content_length_len ) != 0 ) ) {
Debug ( "http" , "Content-Length headers don't match, returning parse error" ) ;
return PARSE_RESULT_ERROR ;
}
else {
Debug ( "http" , "Deleting duplicate Content-Length header" ) ;
mime_hdr_field_delete ( heap , hh -> m_fields_impl , content_length_field -> m_next_dup , false ) ;
}
}
}
return PARSE_RESULT_DONE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void pdf_run_TD ( fz_context * ctx , pdf_processor * proc , float tx , float ty ) {
pdf_run_processor * pr = ( pdf_run_processor * ) proc ;
pdf_gstate * gstate = pr -> gstate + pr -> gtop ;
gstate -> text . leading = - ty ;
pdf_tos_translate ( & pr -> tos , tx , ty ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void list_to_parameters_foreach ( GAppInfo * application , GList * uris , GList * * ret ) {
ApplicationLaunchParameters * parameters ;
uris = g_list_reverse ( uris ) ;
parameters = application_launch_parameters_new ( application , uris ) ;
* ret = g_list_prepend ( * ret , parameters ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void input_DecoderWait ( decoder_t * p_dec ) {
decoder_owner_sys_t * p_owner = p_dec -> p_owner ;
vlc_mutex_lock ( & p_owner -> lock ) ;
while ( p_owner -> b_waiting && ! p_owner -> b_has_data ) {
block_FifoWake ( p_owner -> p_fifo ) ;
vlc_cond_wait ( & p_owner -> wait_acknowledge , & p_owner -> lock ) ;
}
vlc_mutex_unlock ( & p_owner -> lock ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void config_ttl ( config_tree * ptree ) {
int i = 0 ;
int_node * curr_ttl ;
curr_ttl = HEAD_PFIFO ( ptree -> ttl ) ;
for ( ;
curr_ttl != NULL ;
curr_ttl = curr_ttl -> link ) {
if ( i < COUNTOF ( sys_ttl ) ) sys_ttl [ i ++ ] = ( u_char ) curr_ttl -> i ;
else msyslog ( LOG_INFO , "ttl: Number of TTL entries exceeds %lu. Ignoring TTL %d..." , ( u_long ) COUNTOF ( sys_ttl ) , curr_ttl -> i ) ;
}
sys_ttlmax = i - 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cal_nmvsadcosts_hp ( int * mvsadcost [ 2 ] ) {
int i = 1 ;
mvsadcost [ 0 ] [ 0 ] = 0 ;
mvsadcost [ 1 ] [ 0 ] = 0 ;
do {
double z = 256 * ( 2 * ( log2f ( 8 * i ) + .6 ) ) ;
mvsadcost [ 0 ] [ i ] = ( int ) z ;
mvsadcost [ 1 ] [ i ] = ( int ) z ;
mvsadcost [ 0 ] [ - i ] = ( int ) z ;
mvsadcost [ 1 ] [ - i ] = ( int ) z ;
}
while ( ++ i <= MV_MAX ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void writer_print_section_header ( WriterContext * wctx , int section_id ) {
int parent_section_id ;
wctx -> level ++ ;
av_assert0 ( wctx -> level < SECTION_MAX_NB_LEVELS ) ;
parent_section_id = wctx -> level ? ( wctx -> section [ wctx -> level - 1 ] ) -> id : SECTION_ID_NONE ;
wctx -> nb_item [ wctx -> level ] = 0 ;
wctx -> section [ wctx -> level ] = & wctx -> sections [ section_id ] ;
if ( section_id == SECTION_ID_PACKETS_AND_FRAMES ) {
wctx -> nb_section_packet = wctx -> nb_section_frame = wctx -> nb_section_packet_frame = 0 ;
}
else if ( parent_section_id == SECTION_ID_PACKETS_AND_FRAMES ) {
wctx -> nb_section_packet_frame = section_id == SECTION_ID_PACKET ? wctx -> nb_section_packet : wctx -> nb_section_frame ;
}
if ( wctx -> writer -> print_section_header ) wctx -> writer -> print_section_header ( wctx ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_hextile ( VmncContext * c , uint8_t * dst , const uint8_t * src , int ssize , int w , int h , int stride ) {
int i , j , k ;
int bg = 0 , fg = 0 , rects , color , flags , xy , wh ;
const int bpp = c -> bpp2 ;
uint8_t * dst2 ;
int bw = 16 , bh = 16 ;
const uint8_t * ssrc = src ;
for ( j = 0 ;
j < h ;
j += 16 ) {
dst2 = dst ;
bw = 16 ;
if ( j + 16 > h ) bh = h - j ;
for ( i = 0 ;
i < w ;
i += 16 , dst2 += 16 * bpp ) {
if ( src - ssrc >= ssize ) {
av_log ( c -> avctx , AV_LOG_ERROR , "Premature end of data!\n" ) ;
return - 1 ;
}
if ( i + 16 > w ) bw = w - i ;
flags = * src ++ ;
if ( flags & HT_RAW ) {
if ( src - ssrc > ssize - bw * bh * bpp ) {
av_log ( c -> avctx , AV_LOG_ERROR , "Premature end of data!\n" ) ;
return - 1 ;
}
paint_raw ( dst2 , bw , bh , src , bpp , c -> bigendian , stride ) ;
src += bw * bh * bpp ;
}
else {
if ( flags & HT_BKG ) {
bg = vmnc_get_pixel ( src , bpp , c -> bigendian ) ;
src += bpp ;
}
if ( flags & HT_FG ) {
fg = vmnc_get_pixel ( src , bpp , c -> bigendian ) ;
src += bpp ;
}
rects = 0 ;
if ( flags & HT_SUB ) rects = * src ++ ;
color = ! ! ( flags & HT_CLR ) ;
paint_rect ( dst2 , 0 , 0 , bw , bh , bg , bpp , stride ) ;
if ( src - ssrc > ssize - rects * ( color * bpp + 2 ) ) {
av_log ( c -> avctx , AV_LOG_ERROR , "Premature end of data!\n" ) ;
return - 1 ;
}
for ( k = 0 ;
k < rects ;
k ++ ) {
if ( color ) {
fg = vmnc_get_pixel ( src , bpp , c -> bigendian ) ;
src += bpp ;
}
xy = * src ++ ;
wh = * src ++ ;
paint_rect ( dst2 , xy >> 4 , xy & 0xF , ( wh >> 4 ) + 1 , ( wh & 0xF ) + 1 , fg , bpp , stride ) ;
}
}
}
dst += stride * 16 ;
}
return src - ssrc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( ProfileInfoCacheTest , DownloadHighResAvatarTest ) {
switches : : EnableNewAvatarMenuForTesting ( base : : CommandLine : : ForCurrentProcess ( ) ) ;
ProfileInfoCache profile_info_cache ( g_browser_process -> local_state ( ) , testing_profile_manager_ . profile_manager ( ) -> user_data_dir ( ) ) ;
const size_t kIconIndex = 0 ;
base : : FilePath icon_path = profiles : : GetPathOfHighResAvatarAtIndex ( kIconIndex ) ;
EXPECT_TRUE ( base : : PathExists ( icon_path ) ) ;
EXPECT_TRUE ( base : : DeleteFile ( icon_path , true ) ) ;
EXPECT_FALSE ( base : : PathExists ( icon_path ) ) ;
EXPECT_EQ ( 0U , profile_info_cache . GetNumberOfProfiles ( ) ) ;
base : : FilePath path_1 = GetProfilePath ( "path_1" ) ;
profile_info_cache . AddProfileToCache ( path_1 , ASCIIToUTF16 ( "name_1" ) , base : : string16 ( ) , kIconIndex , std : : string ( ) ) ;
EXPECT_EQ ( 1U , profile_info_cache . GetNumberOfProfiles ( ) ) ;
base : : RunLoop ( ) . RunUntilIdle ( ) ;
EXPECT_EQ ( 0U , profile_info_cache . cached_avatar_images_ . size ( ) ) ;
EXPECT_EQ ( 1U , profile_info_cache . avatar_images_downloads_in_progress_ . size ( ) ) ;
EXPECT_FALSE ( profile_info_cache . GetHighResAvatarOfProfileAtIndex ( 0 ) ) ;
ProfileAvatarDownloader avatar_downloader ( kIconIndex , profile_info_cache . GetPathOfProfileAtIndex ( 0 ) , & profile_info_cache ) ;
SkBitmap bitmap ;
bitmap . allocN32Pixels ( 2 , 2 ) ;
bitmap . eraseColor ( SK_ColorGREEN ) ;
avatar_downloader . OnFetchComplete ( GURL ( "http://www.google.com/avatar.png" ) , & bitmap ) ;
EXPECT_EQ ( 0U , profile_info_cache . avatar_images_downloads_in_progress_ . size ( ) ) ;
std : : string file_name = profiles : : GetDefaultAvatarIconFileNameAtIndex ( kIconIndex ) ;
EXPECT_EQ ( 1U , profile_info_cache . cached_avatar_images_ . size ( ) ) ;
EXPECT_TRUE ( profile_info_cache . GetHighResAvatarOfProfileAtIndex ( 0 ) ) ;
EXPECT_EQ ( profile_info_cache . cached_avatar_images_ [ file_name ] , profile_info_cache . GetHighResAvatarOfProfileAtIndex ( 0 ) ) ;
base : : RunLoop ( ) . RunUntilIdle ( ) ;
EXPECT_NE ( std : : string : : npos , icon_path . MaybeAsASCII ( ) . find ( file_name ) ) ;
EXPECT_TRUE ( base : : PathExists ( icon_path ) ) ;
EXPECT_TRUE ( base : : DeleteFile ( icon_path , true ) ) ;
EXPECT_FALSE ( base : : PathExists ( icon_path ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static struct sk_buff * tipc_get_err_tlv ( char * str ) {
int str_len = strlen ( str ) + 1 ;
struct sk_buff * buf ;
buf = tipc_tlv_alloc ( TLV_SPACE ( str_len ) ) ;
if ( buf ) tipc_add_tlv ( buf , TIPC_TLV_ERROR_STRING , str , str_len ) ;
return buf ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int i2d_ ## name ( type * a , unsigned char * * out ) ;
DECLARE_ASN1_ITEM ( itname ) # define DECLARE_ASN1_ENCODE_FUNCTIONS_const ( type , name ) type * d2i_ ## name ( type * * a , const unsigned char * * in , long len ) ;
int i2d_ ## name ( const type * a , unsigned char * * out ) ;
DECLARE_ASN1_ITEM ( name ) # define DECLARE_ASN1_NDEF_FUNCTION ( name ) int i2d_ ## name ## _NDEF ( name * a , unsigned char * * out ) ;
# define DECLARE_ASN1_FUNCTIONS_const ( name ) DECLARE_ASN1_ALLOC_FUNCTIONS ( name ) DECLARE_ASN1_ENCODE_FUNCTIONS_const ( name , name ) # define DECLARE_ASN1_ALLOC_FUNCTIONS_name ( type , name ) type * name ## _new ( void ) ;
void name ## _free ( type * a ) ;
# define DECLARE_ASN1_PRINT_FUNCTION ( stname ) DECLARE_ASN1_PRINT_FUNCTION_fname ( stname , stname ) # define DECLARE_ASN1_PRINT_FUNCTION_fname ( stname , fname ) int fname ## _print_ctx ( BIO * out , stname * x , int indent , const ASN1_PCTX * pctx ) ;
# define D2I_OF ( type ) type * ( * ) ( type * * , const unsigned char * * , long ) # define I2D_OF ( type ) int ( * ) ( type * , unsigned char * * ) # define I2D_OF_const ( type ) int ( * ) ( const type * , unsigned char * * ) # define CHECKED_D2I_OF ( type , d2i ) ( ( d2i_of_void * ) ( 1 ? d2i : ( ( D2I_OF ( type ) ) 0 ) ) ) # define CHECKED_I2D_OF ( type , i2d ) ( ( i2d_of_void * ) ( 1 ? i2d : ( ( I2D_OF ( type ) ) 0 ) ) ) # define CHECKED_NEW_OF ( type , xnew ) ( ( void * ( * ) ( void ) ) ( 1 ? xnew : ( ( type * ( * ) ( void ) ) 0 ) ) ) # define CHECKED_PTR_OF ( type , p ) ( ( void * ) ( 1 ? p : ( type * ) 0 ) ) # define CHECKED_PPTR_OF ( type , p ) ( ( void * * ) ( 1 ? p : ( type * * ) 0 ) ) # define TYPEDEF_D2I_OF ( type ) typedef type * d2i_of_ ## type ( type * * , const unsigned char * * , long ) # define TYPEDEF_I2D_OF ( type ) typedef int i2d_of_ ## type ( type * , unsigned char * * ) # define TYPEDEF_D2I2D_OF ( type ) TYPEDEF_D2I_OF ( type ) ;
TYPEDEF_I2D_OF ( type ) TYPEDEF_D2I2D_OF ( void ) ;
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION typedef const ASN1_ITEM ASN1_ITEM_EXP ;
# define ASN1_ITEM_ptr ( iptr ) ( iptr ) # define ASN1_ITEM_ref ( iptr ) ( & ( iptr ## _it ) ) # define ASN1_ITEM_rptr ( ref ) ( & ( ref ## _it ) ) # define DECLARE_ASN1_ITEM ( name ) OPENSSL_EXTERN const ASN1_ITEM name ## _it ;
# else typedef const ASN1_ITEM * ASN1_ITEM_EXP ( void ) ;
# define ASN1_ITEM_ptr ( iptr ) ( iptr ( ) ) # define ASN1_ITEM_ref ( iptr ) ( iptr ## _it ) # define ASN1_ITEM_rptr ( ref ) ( ref ## _it ( ) ) # define DECLARE_ASN1_ITEM ( name ) const ASN1_ITEM * name ## _it ( void ) ;
# endif # define ASN1_STRFLGS_ESC_2253 1 # define ASN1_STRFLGS_ESC_CTRL 2 # define ASN1_STRFLGS_ESC_MSB 4 # define ASN1_STRFLGS_ESC_QUOTE 8 # define CHARTYPE_PRINTABLESTRING 0x10 # define CHARTYPE_FIRST_ESC_2253 0x20 # define CHARTYPE_LAST_ESC_2253 0x40 # define ASN1_STRFLGS_UTF8_CONVERT 0x10 # define ASN1_STRFLGS_IGNORE_TYPE 0x20 # define ASN1_STRFLGS_SHOW_TYPE 0x40 # define ASN1_STRFLGS_DUMP_ALL 0x80 # define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 # define ASN1_STRFLGS_DUMP_DER 0x200 # define ASN1_STRFLGS_ESC_2254 0x400 # define ASN1_STRFLGS_RFC2253 ( ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN | ASN1_STRFLGS_DUMP_DER ) DEFINE_STACK_OF ( ASN1_INTEGER ) DEFINE_STACK_OF ( ASN1_GENERALSTRING ) DEFINE_STACK_OF ( ASN1_UTF8STRING ) typedef struct asn1_type_st {
int type ;
union {
char * ptr ;
ASN1_BOOLEAN boolean ;
ASN1_STRING * asn1_string ;
ASN1_OBJECT * object ;
ASN1_INTEGER * integer ;
ASN1_ENUMERATED * enumerated ;
ASN1_BIT_STRING * bit_string ;
ASN1_OCTET_STRING * octet_string ;
ASN1_PRINTABLESTRING * printablestring ;
ASN1_T61STRING * t61string ;
ASN1_IA5STRING * ia5string ;
ASN1_GENERALSTRING * generalstring ;
ASN1_BMPSTRING * bmpstring ;
ASN1_UNIVERSALSTRING * universalstring ;
ASN1_UTCTIME * utctime ;
ASN1_GENERALIZEDTIME * generalizedtime ;
ASN1_VISIBLESTRING * visiblestring ;
ASN1_UTF8STRING * utf8string ;
ASN1_STRING * set ;
ASN1_STRING * sequence ;
ASN1_VALUE * asn1_value ;
}
value ;
}
ASN1_TYPE ;
DEFINE_STACK_OF ( ASN1_TYPE ) typedef STACK_OF ( ASN1_TYPE ) ASN1_SEQUENCE_ANY ;
DECLARE_ASN1_ENCODE_FUNCTIONS_const ( ASN1_SEQUENCE_ANY , ASN1_SEQUENCE_ANY ) DECLARE_ASN1_ENCODE_FUNCTIONS_const ( ASN1_SEQUENCE_ANY , ASN1_SET_ANY ) typedef struct BIT_STRING_BITNAME_st {
int bitnum ;
const char * lname ;
const char * sname ;
}
BIT_STRING_BITNAME ;
# define B_ASN1_TIME B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME # define B_ASN1_PRINTABLE B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING | B_ASN1_SEQUENCE | B_ASN1_UNKNOWN # define B_ASN1_DIRECTORYSTRING B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING | B_ASN1_UTF8STRING # define B_ASN1_DISPLAYTEXT B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING DECLARE_ASN1_FUNCTIONS_fname ( ASN1_TYPE , ASN1_ANY , ASN1_TYPE ) int ASN1_TYPE_get ( const ASN1_TYPE * a ) ;
void ASN1_TYPE_set ( ASN1_TYPE * a , int type , void * value ) ;
int ASN1_TYPE_set1 ( ASN1_TYPE * a , int type , const void * value ) ;
int ASN1_TYPE_cmp ( const ASN1_TYPE * a , const ASN1_TYPE * b ) ;
ASN1_TYPE * ASN1_TYPE_pack_sequence ( const ASN1_ITEM * it , void * s , ASN1_TYPE * * t ) ;
void * ASN1_TYPE_unpack_sequence ( const ASN1_ITEM * it , const ASN1_TYPE * t ) ;
ASN1_OBJECT * ASN1_OBJECT_new ( void ) ;
void ASN1_OBJECT_free ( ASN1_OBJECT * a ) ;
int i2d_ASN1_OBJECT ( const ASN1_OBJECT * a , unsigned char * * pp ) ;
ASN1_OBJECT * d2i_ASN1_OBJECT ( ASN1_OBJECT * * a , const unsigned char * * pp , long length ) ;
DECLARE_ASN1_ITEM ( ASN1_OBJECT ) DEFINE_STACK_OF ( ASN1_OBJECT ) ASN1_STRING * ASN1_STRING_new ( void ) ;
void ASN1_STRING_free ( ASN1_STRING * a ) ;
void ASN1_STRING_clear_free ( ASN1_STRING * a ) ;
int ASN1_STRING_copy ( ASN1_STRING * dst , const ASN1_STRING * str ) ;
ASN1_STRING * ASN1_STRING_dup ( const ASN1_STRING * a ) ;
ASN1_STRING * ASN1_STRING_type_new ( int type ) ;
int ASN1_STRING_cmp ( const ASN1_STRING * a , const ASN1_STRING * b ) ;
int ASN1_STRING_set ( ASN1_STRING * str , const void * data , int len ) ;
void ASN1_STRING_set0 ( ASN1_STRING * str , void * data , int len ) ;
int ASN1_STRING_length ( const ASN1_STRING * x ) ;
void ASN1_STRING_length_set ( ASN1_STRING * x , int n ) ;
int ASN1_STRING_type ( const ASN1_STRING * x ) ;
DEPRECATEDIN_1_1_0 ( unsigned char * ASN1_STRING_data ( ASN1_STRING * x ) ) const unsigned char * ASN1_STRING_get0_data ( const ASN1_STRING * x ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_BIT_STRING ) int ASN1_BIT_STRING_set ( ASN1_BIT_STRING * a , unsigned char * d , int length ) ;
int ASN1_BIT_STRING_set_bit ( ASN1_BIT_STRING * a , int n , int value ) ;
int ASN1_BIT_STRING_get_bit ( const ASN1_BIT_STRING * a , int n ) ;
int ASN1_BIT_STRING_check ( const ASN1_BIT_STRING * a , const unsigned char * flags , int flags_len ) ;
int ASN1_BIT_STRING_name_print ( BIO * out , ASN1_BIT_STRING * bs , BIT_STRING_BITNAME * tbl , int indent ) ;
int ASN1_BIT_STRING_num_asc ( const char * name , BIT_STRING_BITNAME * tbl ) ;
int ASN1_BIT_STRING_set_asc ( ASN1_BIT_STRING * bs , const char * name , int value , BIT_STRING_BITNAME * tbl ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_INTEGER ) ASN1_INTEGER * d2i_ASN1_UINTEGER ( ASN1_INTEGER * * a , const unsigned char * * pp , long length ) ;
ASN1_INTEGER * ASN1_INTEGER_dup ( const ASN1_INTEGER * x ) ;
int ASN1_INTEGER_cmp ( const ASN1_INTEGER * x , const ASN1_INTEGER * y ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_ENUMERATED ) int ASN1_UTCTIME_check ( const ASN1_UTCTIME * a ) ;
ASN1_UTCTIME * ASN1_UTCTIME_set ( ASN1_UTCTIME * s , time_t t ) ;
ASN1_UTCTIME * ASN1_UTCTIME_adj ( ASN1_UTCTIME * s , time_t t , int offset_day , long offset_sec ) ;
int ASN1_UTCTIME_set_string ( ASN1_UTCTIME * s , const char * str ) ;
int ASN1_UTCTIME_cmp_time_t ( const ASN1_UTCTIME * s , time_t t ) ;
int ASN1_GENERALIZEDTIME_check ( const ASN1_GENERALIZEDTIME * a ) ;
ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_set ( ASN1_GENERALIZEDTIME * s , time_t t ) ;
ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_adj ( ASN1_GENERALIZEDTIME * s , time_t t , int offset_day , long offset_sec ) ;
int ASN1_GENERALIZEDTIME_set_string ( ASN1_GENERALIZEDTIME * s , const char * str ) ;
int ASN1_TIME_diff ( int * pday , int * psec , const ASN1_TIME * from , const ASN1_TIME * to ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_OCTET_STRING ) ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup ( const ASN1_OCTET_STRING * a ) ;
int ASN1_OCTET_STRING_cmp ( const ASN1_OCTET_STRING * a , const ASN1_OCTET_STRING * b ) ;
int ASN1_OCTET_STRING_set ( ASN1_OCTET_STRING * str , const unsigned char * data , int len ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_VISIBLESTRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_UNIVERSALSTRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_UTF8STRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_NULL ) DECLARE_ASN1_FUNCTIONS ( ASN1_BMPSTRING ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | u_char * evbuffer_find ( struct evbuffer * buffer , const u_char * what , size_t len ) {
u_char * search = buffer -> buffer , * end = search + buffer -> off ;
u_char * p ;
while ( search < end && ( p = memchr ( search , * what , end - search ) ) != NULL ) {
if ( p + len > end ) break ;
if ( memcmp ( p , what , len ) == 0 ) return ( p ) ;
search = p + 1 ;
}
return ( NULL ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | REGRESSION_TEST ( SDK_API_TSUrlParse ) ( RegressionTest * test , int , int * pstatus ) {
static const char * const urls [ ] = {
"file:///test.dat;
ab?abc=def#abc" , "http://www.example.com/" , "http://abc:[email protected]/" , "http://www.example.com:3426/" , "http://abc:[email protected]:3426/" , "http://www.example.com/homepage.cgi" , "http://www.example.com/homepage.cgi;
ab?abc=def#abc" , "http://abc:[email protected]:3426/homepage.cgi;
ab?abc=def#abc" , "https://abc:[email protected]:3426/homepage.cgi;
ab?abc=def#abc" , "ftp://abc:[email protected]:3426/homepage.cgi;
ab?abc=def#abc" , "file:///c:/test.dat;
ab?abc=def#abc" , "file:///test.dat;
ab?abc=def#abc" , "foo://bar.com/baz/" , "http://a.b.com/xx.jpg?newpath=http://b.c.com" }
;
static int const num_urls = sizeof ( urls ) / sizeof ( urls [ 0 ] ) ;
bool test_passed [ num_urls ] = {
false }
;
const char * start ;
const char * end ;
char * temp ;
int retval ;
TSMBuffer bufp ;
TSMLoc url_loc = ( TSMLoc ) nullptr ;
int length ;
* pstatus = REGRESSION_TEST_INPROGRESS ;
int idx ;
for ( idx = 0 ;
idx < num_urls ;
idx ++ ) {
const char * url = urls [ idx ] ;
bufp = TSMBufferCreate ( ) ;
if ( TSUrlCreate ( bufp , & url_loc ) != TS_SUCCESS ) {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_FAIL , "Cannot create Url for parsing the url" ) ;
if ( TSMBufferDestroy ( bufp ) == TS_ERROR ) {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_FAIL , "Error in Destroying MBuffer" ) ;
}
}
else {
start = url ;
end = url + strlen ( url ) ;
if ( ( retval = TSUrlParse ( bufp , url_loc , & start , end ) ) == TS_PARSE_ERROR ) {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_FAIL , "TSUrlParse returns TS_PARSE_ERROR" ) ;
}
else {
if ( retval == TS_PARSE_DONE ) {
temp = TSUrlStringGet ( bufp , url_loc , & length ) ;
if ( strncmp ( url , temp , length ) == 0 ) {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_PASS , "ok" ) ;
test_passed [ idx ] = true ;
}
else {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_FAIL , "Value's Mismatch" ) ;
}
TSfree ( temp ) ;
}
else {
SDK_RPRINT ( test , "TSUrlParse" , url , TC_FAIL , "Parsing Error" ) ;
}
}
}
TSHandleMLocRelease ( bufp , TS_NULL_MLOC , url_loc ) ;
TSMBufferDestroy ( bufp ) ;
}
for ( idx = 0 ;
idx < num_urls ;
idx ++ ) {
if ( test_passed [ idx ] != true ) {
* pstatus = REGRESSION_TEST_FAILED ;
break ;
}
}
if ( idx >= num_urls ) {
* pstatus = REGRESSION_TEST_PASSED ;
}
return ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint8 fpdu_pad_length ( guint16 ulpdu_length ) {
guint32 length = ulpdu_length + MPA_ULPDU_LENGTH_LEN ;
return ( MPA_ALIGNMENT - ( length % MPA_ALIGNMENT ) ) % MPA_ALIGNMENT ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void usbdev_vm_open ( struct vm_area_struct * vma ) {
struct usb_memory * usbm = vma -> vm_private_data ;
unsigned long flags ;
spin_lock_irqsave ( & usbm -> ps -> lock , flags ) ;
++ usbm -> vma_use_count ;
spin_unlock_irqrestore ( & usbm -> ps -> lock , flags ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ss_lx_init ( QEMUMachineInitArgs * args ) {
ram_addr_t RAM_size = args -> ram_size ;
const char * cpu_model = args -> cpu_model ;
const char * kernel_filename = args -> kernel_filename ;
const char * kernel_cmdline = args -> kernel_cmdline ;
const char * initrd_filename = args -> initrd_filename ;
const char * boot_device = args -> boot_device ;
sun4m_hw_init ( & sun4m_hwdefs [ 5 ] , RAM_size , boot_device , kernel_filename , kernel_cmdline , initrd_filename , cpu_model ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int ztoken_handle_comment ( i_ctx_t * i_ctx_p , scanner_state * sstate , const ref * ptoken , int scan_code , bool save , bool push_file , op_proc_t cont ) {
const char * proc_name ;
scanner_state * pstate ;
os_ptr op ;
ref * ppcproc ;
int code ;
switch ( scan_code ) {
case scan_Comment : proc_name = "%ProcessComment" ;
break ;
case scan_DSC_Comment : proc_name = "%ProcessDSCComment" ;
break ;
default : return_error ( gs_error_Fatal ) ;
}
if ( ostop - osp < 2 ) {
code = ref_stack_extend ( & o_stack , 2 ) ;
if ( code < 0 ) return code ;
}
check_estack ( 3 ) ;
code = name_enter_string ( imemory , proc_name , esp + 3 ) ;
if ( code < 0 ) return code ;
if ( save ) {
pstate = ( scanner_state * ) ialloc_struct ( scanner_state_dynamic , & st_scanner_state_dynamic , "ztoken_handle_comment" ) ;
if ( pstate == 0 ) return_error ( gs_error_VMerror ) ;
( ( scanner_state_dynamic * ) pstate ) -> mem = imemory ;
* pstate = * sstate ;
}
else pstate = sstate ;
if ( ! pstate -> s_pstack ) osp [ 2 ] = * ptoken ;
make_op_estack ( esp + 1 , cont ) ;
make_istruct ( esp + 2 , 0 , pstate ) ;
ppcproc = dict_find_name ( esp + 3 ) ;
if ( ppcproc == 0 ) {
if ( pstate -> s_pstack ) -- osp ;
esp += 2 ;
}
else {
if ( pstate -> s_pstack ) {
op = ++ osp ;
* op = op [ - 1 ] ;
}
else {
op = osp += 2 ;
}
op [ - 1 ] = pstate -> s_file ;
esp [ 3 ] = * ppcproc ;
esp += 3 ;
}
return o_push_estack ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | proto_item * proto_tree_add_eui64 ( proto_tree * tree , int hfindex , tvbuff_t * tvb , gint start , gint length , const guint64 value ) {
proto_item * pi ;
header_field_info * hfinfo ;
CHECK_FOR_NULL_TREE ( tree ) ;
TRY_TO_FAKE_THIS_ITEM ( tree , hfindex , hfinfo ) ;
DISSECTOR_ASSERT_FIELD_TYPE ( hfinfo , FT_EUI64 ) ;
pi = proto_tree_add_pi ( tree , hfinfo , tvb , start , & length ) ;
proto_tree_set_eui64 ( PNODE_FINFO ( pi ) , value ) ;
return pi ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void jpc_qmfb_split_col ( jpc_fix_t * a , int numrows , int stride , int parity ) {
int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ;
jpc_fix_t splitbuf [ QMFB_SPLITBUFSIZE ] ;
jpc_fix_t * buf = splitbuf ;
register jpc_fix_t * srcptr ;
register jpc_fix_t * dstptr ;
register int n ;
register int m ;
int hstartrow ;
if ( bufsize > QMFB_SPLITBUFSIZE ) {
if ( ! ( buf = jas_alloc2 ( bufsize , sizeof ( jpc_fix_t ) ) ) ) {
abort ( ) ;
}
}
if ( numrows >= 2 ) {
hstartrow = ( numrows + 1 - parity ) >> 1 ;
m = numrows - hstartrow ;
n = m ;
dstptr = buf ;
srcptr = & a [ ( 1 - parity ) * stride ] ;
while ( n -- > 0 ) {
* dstptr = * srcptr ;
++ dstptr ;
srcptr += stride << 1 ;
}
dstptr = & a [ ( 1 - parity ) * stride ] ;
srcptr = & a [ ( 2 - parity ) * stride ] ;
n = numrows - m - ( ! parity ) ;
while ( n -- > 0 ) {
* dstptr = * srcptr ;
dstptr += stride ;
srcptr += stride << 1 ;
}
dstptr = & a [ hstartrow * stride ] ;
srcptr = buf ;
n = m ;
while ( n -- > 0 ) {
* dstptr = * srcptr ;
dstptr += stride ;
++ srcptr ;
}
}
if ( buf != splitbuf ) {
jas_free ( buf ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int ipvideo_decode_block_opcode_0xE ( IpvideoContext * s , AVFrame * frame ) {
int y ;
unsigned char pix ;
pix = bytestream2_get_byte ( & s -> stream_ptr ) ;
for ( y = 0 ;
y < 8 ;
y ++ ) {
memset ( s -> pixel_ptr , pix , 8 ) ;
s -> pixel_ptr += s -> stride ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | char * get_opname ( Oid opno ) {
HeapTuple tp ;
tp = SearchSysCache1 ( OPEROID , ObjectIdGetDatum ( opno ) ) ;
if ( HeapTupleIsValid ( tp ) ) {
Form_pg_operator optup = ( Form_pg_operator ) GETSTRUCT ( tp ) ;
char * result ;
result = pstrdup ( NameStr ( optup -> oprname ) ) ;
ReleaseSysCache ( tp ) ;
return result ;
}
else return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int cirrus_do_copy ( CirrusVGAState * s , int dst , int src , int w , int h ) {
int sx = 0 , sy = 0 ;
int dx = 0 , dy = 0 ;
int depth = 0 ;
int notify = 0 ;
if ( * s -> cirrus_rop == cirrus_bitblt_rop_fwd_src || * s -> cirrus_rop == cirrus_bitblt_rop_bkwd_src ) {
int width , height ;
depth = s -> vga . get_bpp ( & s -> vga ) / 8 ;
if ( ! depth ) {
return 0 ;
}
s -> vga . get_resolution ( & s -> vga , & width , & height ) ;
sx = ( src % ABS ( s -> cirrus_blt_srcpitch ) ) / depth ;
sy = ( src / ABS ( s -> cirrus_blt_srcpitch ) ) ;
dx = ( dst % ABS ( s -> cirrus_blt_dstpitch ) ) / depth ;
dy = ( dst / ABS ( s -> cirrus_blt_dstpitch ) ) ;
w /= depth ;
if ( s -> cirrus_blt_dstpitch < 0 ) {
sx -= ( s -> cirrus_blt_width / depth ) - 1 ;
dx -= ( s -> cirrus_blt_width / depth ) - 1 ;
sy -= s -> cirrus_blt_height - 1 ;
dy -= s -> cirrus_blt_height - 1 ;
}
if ( sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 && ( sx + w ) <= width && ( sy + h ) <= height && ( dx + w ) <= width && ( dy + h ) <= height ) {
notify = 1 ;
}
}
( * s -> cirrus_rop ) ( s , s -> cirrus_blt_dstaddr , s -> cirrus_blt_srcaddr , s -> cirrus_blt_dstpitch , s -> cirrus_blt_srcpitch , s -> cirrus_blt_width , s -> cirrus_blt_height ) ;
if ( notify ) {
dpy_gfx_update ( s -> vga . con , dx , dy , s -> cirrus_blt_width / depth , s -> cirrus_blt_height ) ;
}
cirrus_invalidate_region ( s , s -> cirrus_blt_dstaddr , s -> cirrus_blt_dstpitch , s -> cirrus_blt_width , s -> cirrus_blt_height ) ;
return 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static subpicture_t * ParseText ( decoder_t * p_dec , block_t * p_block ) {
decoder_sys_t * p_sys = p_dec -> p_sys ;
subpicture_t * p_spu = NULL ;
char * psz_subtitle = NULL ;
if ( p_block -> i_pts <= VLC_TS_INVALID ) {
msg_Warn ( p_dec , "subtitle without a date" ) ;
return NULL ;
}
if ( p_block -> i_buffer < 1 ) {
msg_Warn ( p_dec , "no subtitle data" ) ;
return NULL ;
}
psz_subtitle = malloc ( p_block -> i_buffer + 1 ) ;
if ( psz_subtitle == NULL ) return NULL ;
memcpy ( psz_subtitle , p_block -> p_buffer , p_block -> i_buffer ) ;
psz_subtitle [ p_block -> i_buffer ] = '\0' ;
if ( p_sys -> iconv_handle == ( vlc_iconv_t ) - 1 ) {
if ( EnsureUTF8 ( psz_subtitle ) == NULL ) {
msg_Err ( p_dec , "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ) ;
}
}
else {
if ( p_sys -> b_autodetect_utf8 ) {
if ( IsUTF8 ( psz_subtitle ) == NULL ) {
msg_Dbg ( p_dec , "invalid UTF-8 sequence: " "disabling UTF-8 subtitles autodetection" ) ;
p_sys -> b_autodetect_utf8 = false ;
}
}
if ( ! p_sys -> b_autodetect_utf8 ) {
size_t inbytes_left = strlen ( psz_subtitle ) ;
size_t outbytes_left = 6 * inbytes_left ;
char * psz_new_subtitle = xmalloc ( outbytes_left + 1 ) ;
char * psz_convert_buffer_out = psz_new_subtitle ;
const char * psz_convert_buffer_in = psz_subtitle ;
size_t ret = vlc_iconv ( p_sys -> iconv_handle , & psz_convert_buffer_in , & inbytes_left , & psz_convert_buffer_out , & outbytes_left ) ;
* psz_convert_buffer_out ++ = '\0' ;
free ( psz_subtitle ) ;
if ( ( ret == ( size_t ) ( - 1 ) ) || inbytes_left ) {
free ( psz_new_subtitle ) ;
msg_Err ( p_dec , "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ) ;
return NULL ;
}
psz_subtitle = realloc ( psz_new_subtitle , psz_convert_buffer_out - psz_new_subtitle ) ;
if ( ! psz_subtitle ) psz_subtitle = psz_new_subtitle ;
}
}
p_spu = decoder_NewSubpictureText ( p_dec ) ;
if ( ! p_spu ) {
free ( psz_subtitle ) ;
return NULL ;
}
p_spu -> i_start = p_block -> i_pts ;
p_spu -> i_stop = p_block -> i_pts + p_block -> i_length ;
p_spu -> b_ephemer = ( p_block -> i_length == 0 ) ;
p_spu -> b_absolute = false ;
subpicture_updater_sys_t * p_spu_sys = p_spu -> updater . p_sys ;
p_spu_sys -> align = SUBPICTURE_ALIGN_BOTTOM | p_sys -> i_align ;
p_spu_sys -> text = StripTags ( psz_subtitle ) ;
if ( var_InheritBool ( p_dec , "subsdec-formatted" ) ) p_spu_sys -> html = CreateHtmlSubtitle ( & p_spu_sys -> align , psz_subtitle ) ;
free ( psz_subtitle ) ;
return p_spu ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const unsigned char * seq_unpack_rle_block ( const unsigned char * src , const unsigned char * src_end , unsigned char * dst , int dst_size ) {
int i , len , sz ;
GetBitContext gb ;
int code_table [ 64 ] ;
init_get_bits ( & gb , src , ( src_end - src ) * 8 ) ;
for ( i = 0 , sz = 0 ;
i < 64 && sz < dst_size ;
i ++ ) {
if ( get_bits_left ( & gb ) < 4 ) return NULL ;
code_table [ i ] = get_sbits ( & gb , 4 ) ;
sz += FFABS ( code_table [ i ] ) ;
}
src += ( get_bits_count ( & gb ) + 7 ) / 8 ;
for ( i = 0 ;
i < 64 && dst_size > 0 ;
i ++ ) {
len = code_table [ i ] ;
if ( len < 0 ) {
len = - len ;
if ( src_end - src < 1 ) return NULL ;
memset ( dst , * src ++ , FFMIN ( len , dst_size ) ) ;
}
else {
if ( src_end - src < len ) return NULL ;
memcpy ( dst , src , FFMIN ( len , dst_size ) ) ;
src += len ;
}
dst += len ;
dst_size -= len ;
}
return src ;
} | 0False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.