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
|
IN_PROC_BROWSER_TEST_F ( UnloadTest , CrossSiteInfiniteBeforeUnloadAsync ) {
if ( base : : CommandLine : : ForCurrentProcess ( ) -> HasSwitch ( switches : : kSingleProcess ) ) return ;
NavigateToDataURL ( INFINITE_BEFORE_UNLOAD_HTML , "infinitebeforeunload" ) ;
NavigateToNolistenersFileTwiceAsync ( ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
kadm5_ret_t kadm5_setkey_principal ( void * server_handle , krb5_principal principal , krb5_keyblock * keyblocks , int n_keys ) {
return kadm5_setkey_principal_3 ( server_handle , principal , FALSE , 0 , NULL , keyblocks , n_keys ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int qemuMonitorJSONSetPassword ( qemuMonitorPtr mon , const char * protocol , const char * password , const char * action_if_connected ) {
int ret ;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand ( "set_password" , "s:protocol" , protocol , "s:password" , password , "s:connected" , action_if_connected , NULL ) ;
virJSONValuePtr reply = NULL ;
if ( ! cmd ) return - 1 ;
ret = qemuMonitorJSONCommand ( mon , cmd , & reply ) ;
if ( ret == 0 ) {
if ( qemuMonitorJSONHasError ( reply , "CommandNotFound" ) ) {
ret = - 2 ;
goto cleanup ;
}
ret = qemuMonitorJSONCheckError ( cmd , reply ) ;
}
cleanup : virJSONValueFree ( cmd ) ;
virJSONValueFree ( reply ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
SPL_METHOD ( SplDoublyLinkedList , isEmpty ) {
long count ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , "" ) == FAILURE ) {
return ;
}
spl_dllist_object_count_elements ( getThis ( ) , & count TSRMLS_CC ) ;
RETURN_BOOL ( count == 0 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static gint protobuf_dissect_unknown_field ( protobuf_desc_t * pb , protobuf_tag_t * tag , packet_info * pinfo , proto_tree * tree , proto_item * * tiptr ) {
gint len ;
gint64 value ;
proto_item * ti ;
switch ( tag -> wire_type ) {
case PROTOBUF_WIRETYPE_VARINT : value = get_varint64 ( pb -> tvb , pb -> offset , pb -> bytes_left , & len ) ;
ti = proto_tree_add_uint64 ( tree , hf_steam_ihs_discovery_unknown_number , pb -> tvb , pb -> offset , len , ( guint64 ) value ) ;
expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_unknown_number , "Unknown numeric protobuf field (wire type %d = %s)" , tag -> wire_type , protobuf_get_wiretype_name ( tag -> wire_type ) ) ;
break ;
case PROTOBUF_WIRETYPE_64BIT : len = 8 ;
ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_number , pb -> tvb , pb -> offset + len , len , ENC_LITTLE_ENDIAN ) ;
expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_unknown_number , "Unknown numeric protobuf field (wire type %d = %s)" , tag -> wire_type , protobuf_get_wiretype_name ( tag -> wire_type ) ) ;
break ;
case PROTOBUF_WIRETYPE_LENGTHDELIMITED : value = get_varint64 ( pb -> tvb , pb -> offset , pb -> bytes_left , & len ) ;
if ( ( guint64 ) value > ( guint64 ) ( pb -> bytes_left - len ) ) {
ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_data , pb -> tvb , pb -> offset + len , pb -> bytes_left - len , ENC_NA ) ;
expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_invalid_length , "Length-delimited field %" G_GUINT64_FORMAT " has length prefix %" G_GUINT64_FORMAT ", but buffer is only %d bytes long." , tag -> field_number , ( guint64 ) value , ( pb -> bytes_left - len ) ) ;
len = pb -> bytes_left ;
}
else {
ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_data , pb -> tvb , pb -> offset + len , ( gint ) value , ENC_NA ) ;
len += ( gint ) value ;
}
expert_add_info ( pinfo , ti , & ei_steam_ihs_discovery_unknown_lengthdelimited ) ;
break ;
case PROTOBUF_WIRETYPE_32BIT : len = 4 ;
ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_number , pb -> tvb , pb -> offset + len , len , ENC_LITTLE_ENDIAN ) ;
expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_unknown_number , "Unknown numeric protobuf field (wire type %d = %s)" , tag -> wire_type , protobuf_get_wiretype_name ( tag -> wire_type ) ) ;
break ;
default : len = pb -> bytes_left ;
ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_data , pb -> tvb , pb -> offset , len , ENC_NA ) ;
expert_add_info ( pinfo , ti , & ei_steam_ihs_discovery_unknown_data ) ;
break ;
}
if ( tiptr != NULL ) {
* tiptr = ti ;
}
return len ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_F ( ExternalProtocolDialogBrowserTest , TestCloseWithChecked ) {
ShowDialog ( ) ;
SetChecked ( true ) ;
EXPECT_TRUE ( dialog_ -> Close ( ) ) ;
EXPECT_TRUE ( called_ ) ;
EXPECT_FALSE ( accept_ ) ;
EXPECT_TRUE ( cancel_ ) ;
EXPECT_FALSE ( dont_block_ ) ;
histogram_tester_ . ExpectTotalCount ( ExternalProtocolHandler : : kRememberCheckboxMetric , 0 ) ;
histogram_tester_ . ExpectTotalCount ( ExternalProtocolHandler : : kHandleStateMetric , 0 ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_BMPString_SIZE_1_512 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_BMPString ( tvb , offset , actx , tree , hf_index , 1 , 512 , FALSE ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void decode ( RA288Context * ractx , float gain , int cb_coef ) {
int i ;
double sumsum ;
float sum , buffer [ 5 ] ;
float * block = ractx -> sp_hist + 70 + 36 ;
float * gain_block = ractx -> gain_hist + 28 ;
memmove ( ractx -> sp_hist + 70 , ractx -> sp_hist + 75 , 36 * sizeof ( * block ) ) ;
sum = 32. ;
for ( i = 0 ;
i < 10 ;
i ++ ) sum -= gain_block [ 9 - i ] * ractx -> gain_lpc [ i ] ;
sum = av_clipf ( sum , 0 , 60 ) ;
sumsum = exp ( sum * 0.1151292546497 ) * gain * ( 1.0 / ( 1 << 23 ) ) ;
for ( i = 0 ;
i < 5 ;
i ++ ) buffer [ i ] = codetable [ cb_coef ] [ i ] * sumsum ;
sum = avpriv_scalarproduct_float_c ( buffer , buffer , 5 ) * ( ( 1 << 24 ) / 5. ) ;
sum = FFMAX ( sum , 1 ) ;
memmove ( gain_block , gain_block + 1 , 9 * sizeof ( * gain_block ) ) ;
gain_block [ 9 ] = 10 * log10 ( sum ) - 32 ;
ff_celp_lp_synthesis_filterf ( block , ractx -> sp_lpc , buffer , 5 , 36 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static UBool action_resolve ( UBiDiTransform * pTransform , UErrorCode * pErrorCode ) {
ubidi_setPara ( pTransform -> pBidi , pTransform -> src , pTransform -> srcLength , pTransform -> pActiveScheme -> baseLevel , NULL , pErrorCode ) ;
return FALSE ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int remoteAddClientStream ( struct qemud_client * client , struct qemud_client_stream * stream , int transmit ) {
struct qemud_client_stream * tmp = client -> streams ;
VIR_DEBUG ( "client=%p proc=%d serial=%d" , client , stream -> procedure , stream -> serial ) ;
if ( virStreamEventAddCallback ( stream -> st , 0 , remoteStreamEvent , client , NULL ) < 0 ) return - 1 ;
if ( tmp ) {
while ( tmp -> next ) tmp = tmp -> next ;
tmp -> next = stream ;
}
else {
client -> streams = stream ;
}
stream -> filter . next = client -> filters ;
client -> filters = & stream -> filter ;
if ( transmit ) stream -> tx = 1 ;
remoteStreamUpdateEvents ( stream ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void dissect_rsvp_dclass ( proto_tree * ti , proto_tree * rsvp_object_tree , tvbuff_t * tvb , int offset , int obj_length , int rsvp_class _U_ , int type ) {
int offset2 = offset + 4 ;
int mylen ;
proto_item_set_text ( ti , "DCLASS: " ) ;
switch ( type ) {
case 1 : proto_tree_add_uint ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type ) ;
for ( mylen = 4 ;
mylen < obj_length ;
mylen += 4 ) {
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_dclass_dscp , tvb , offset + mylen + 3 , 1 , ENC_BIG_ENDIAN ) ;
proto_item_append_text ( ti , "%d%s" , tvb_get_guint8 ( tvb , offset + mylen + 3 ) >> 2 , mylen == obj_length - 4 ? "" : mylen < 16 ? ", " : mylen == 16 ? ", ..." : "" ) ;
}
break ;
default : mylen = obj_length - 4 ;
proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , "Unknown (%u)" , type ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_dclass_data , tvb , offset2 , mylen , ENC_NA ) ;
break ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static SRP_user_pwd * SRP_user_pwd_new ( ) {
SRP_user_pwd * ret = OPENSSL_malloc ( sizeof ( SRP_user_pwd ) ) ;
if ( ret == NULL ) return NULL ;
ret -> N = NULL ;
ret -> g = NULL ;
ret -> s = NULL ;
ret -> v = NULL ;
ret -> id = NULL ;
ret -> info = NULL ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void proto_reg_handoff_applemidi ( void ) {
applemidi_handle = create_dissector_handle ( dissect_applemidi , proto_applemidi ) ;
rtp_handle = find_dissector ( "rtp" ) ;
heur_dissector_add ( "udp" , dissect_applemidi_heur , proto_applemidi ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int output_data ( MLPDecodeContext * m , unsigned int substr , AVFrame * frame , int * got_frame_ptr ) {
AVCodecContext * avctx = m -> avctx ;
SubStream * s = & m -> substream [ substr ] ;
unsigned int i , out_ch = 0 ;
int32_t * data_32 ;
int16_t * data_16 ;
int ret ;
int is32 = ( m -> avctx -> sample_fmt == AV_SAMPLE_FMT_S32 ) ;
if ( m -> avctx -> channels != s -> max_matrix_channel + 1 ) {
av_log ( m -> avctx , AV_LOG_ERROR , "channel count mismatch\n" ) ;
return AVERROR_INVALIDDATA ;
}
if ( ! s -> blockpos ) {
av_log ( avctx , AV_LOG_ERROR , "No samples to output.\n" ) ;
return AVERROR_INVALIDDATA ;
}
frame -> nb_samples = s -> blockpos ;
if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
data_32 = ( int32_t * ) frame -> data [ 0 ] ;
data_16 = ( int16_t * ) frame -> data [ 0 ] ;
for ( i = 0 ;
i < s -> blockpos ;
i ++ ) {
for ( out_ch = 0 ;
out_ch <= s -> max_matrix_channel ;
out_ch ++ ) {
int mat_ch = s -> ch_assign [ out_ch ] ;
int32_t sample = m -> sample_buffer [ i ] [ mat_ch ] << s -> output_shift [ mat_ch ] ;
s -> lossless_check_data ^= ( sample & 0xffffff ) << mat_ch ;
if ( is32 ) * data_32 ++ = sample << 8 ;
else * data_16 ++ = sample >> 8 ;
}
}
* got_frame_ptr = 1 ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int luaD_precall ( lua_State * L , StkId func , int nresults ) {
LClosure * cl ;
ptrdiff_t funcr ;
if ( ! ttisfunction ( func ) ) func = tryfuncTM ( L , func ) ;
funcr = savestack ( L , func ) ;
cl = & clvalue ( func ) -> l ;
L -> ci -> savedpc = L -> savedpc ;
if ( ! cl -> isC ) {
CallInfo * ci ;
StkId st , base ;
Proto * p = cl -> p ;
luaD_checkstack ( L , p -> maxstacksize ) ;
func = restorestack ( L , funcr ) ;
if ( ! p -> is_vararg ) {
base = func + 1 ;
if ( L -> top > base + p -> numparams ) L -> top = base + p -> numparams ;
}
else {
int nargs = cast_int ( L -> top - func ) - 1 ;
base = adjust_varargs ( L , p , nargs ) ;
func = restorestack ( L , funcr ) ;
}
ci = inc_ci ( L ) ;
ci -> func = func ;
L -> base = ci -> base = base ;
ci -> top = L -> base + p -> maxstacksize ;
lua_assert ( ci -> top <= L -> stack_last ) ;
L -> savedpc = p -> code ;
ci -> tailcalls = 0 ;
ci -> nresults = nresults ;
for ( st = L -> top ;
st < ci -> top ;
st ++ ) setnilvalue ( st ) ;
L -> top = ci -> top ;
if ( L -> hookmask & LUA_MASKCALL ) {
L -> savedpc ++ ;
luaD_callhook ( L , LUA_HOOKCALL , - 1 ) ;
L -> savedpc -- ;
}
return PCRLUA ;
}
else {
CallInfo * ci ;
int n ;
luaD_checkstack ( L , LUA_MINSTACK ) ;
ci = inc_ci ( L ) ;
ci -> func = restorestack ( L , funcr ) ;
L -> base = ci -> base = ci -> func + 1 ;
ci -> top = L -> top + LUA_MINSTACK ;
lua_assert ( ci -> top <= L -> stack_last ) ;
ci -> nresults = nresults ;
if ( L -> hookmask & LUA_MASKCALL ) luaD_callhook ( L , LUA_HOOKCALL , - 1 ) ;
lua_unlock ( L ) ;
n = ( * curr_func ( L ) -> c . f ) ( L ) ;
lua_lock ( L ) ;
if ( n < 0 ) return PCRYIELD ;
else {
luaD_poscall ( L , L -> top - n ) ;
return PCRC ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static XMLRPCCmd * createXMLCommand ( const char * name , XMLRPCMethodFunc func ) {
XMLRPCCmd * xml = NULL ;
xml = smalloc ( sizeof ( XMLRPCCmd ) ) ;
xml -> name = sstrdup ( name ) ;
xml -> func = func ;
xml -> mod_name = NULL ;
xml -> core = 0 ;
xml -> next = NULL ;
return xml ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_ConferenceList ( 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_h225_ConferenceList , ConferenceList_sequence ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void parseExpandedNodeId ( proto_tree * tree , tvbuff_t * tvb , packet_info * pinfo , gint * pOffset , const char * szFieldName ) {
static const int * expandednodeid_mask [ ] = {
& hf_opcua_nodeid_encodingmask , & hf_opcua_expandednodeid_mask_serverindex , & hf_opcua_expandednodeid_mask_namespaceuri , NULL }
;
proto_item * ti ;
proto_tree * subtree = proto_tree_add_subtree_format ( tree , tvb , * pOffset , - 1 , ett_opcua_expandednodeid , & ti , "%s: ExpandedNodeId" , szFieldName ) ;
gint iOffset = * pOffset ;
guint8 EncodingMask ;
EncodingMask = tvb_get_guint8 ( tvb , iOffset ) ;
proto_tree_add_bitmask ( subtree , tvb , iOffset , hf_opcua_expandednodeid_mask , ett_opcua_expandednodeid_encodingmask , expandednodeid_mask , ENC_LITTLE_ENDIAN ) ;
iOffset ++ ;
switch ( EncodingMask & 0x0F ) {
case 0x00 : proto_tree_add_item ( subtree , hf_opcua_nodeid_numeric , tvb , iOffset , 1 , ENC_LITTLE_ENDIAN ) ;
iOffset += 1 ;
break ;
case 0x01 : proto_tree_add_item ( subtree , hf_opcua_nodeid_nsindex , tvb , iOffset , 1 , ENC_LITTLE_ENDIAN ) ;
iOffset += 1 ;
proto_tree_add_item ( subtree , hf_opcua_nodeid_numeric , tvb , iOffset , 2 , ENC_LITTLE_ENDIAN ) ;
iOffset += 2 ;
break ;
case 0x02 : proto_tree_add_item ( subtree , hf_opcua_nodeid_nsindex , tvb , iOffset , 2 , ENC_LITTLE_ENDIAN ) ;
iOffset += 2 ;
proto_tree_add_item ( subtree , hf_opcua_nodeid_numeric , tvb , iOffset , 4 , ENC_LITTLE_ENDIAN ) ;
iOffset += 4 ;
break ;
case 0x03 : proto_tree_add_item ( subtree , hf_opcua_nodeid_nsindex , tvb , iOffset , 2 , ENC_LITTLE_ENDIAN ) ;
iOffset += 2 ;
parseString ( subtree , tvb , pinfo , & iOffset , hf_opcua_nodeid_string ) ;
break ;
case 0x04 : proto_tree_add_item ( subtree , hf_opcua_nodeid_nsindex , tvb , iOffset , 2 , ENC_LITTLE_ENDIAN ) ;
iOffset += 2 ;
parseGuid ( subtree , tvb , pinfo , & iOffset , hf_opcua_nodeid_guid ) ;
break ;
case 0x05 : proto_tree_add_item ( subtree , hf_opcua_nodeid_nsindex , tvb , iOffset , 2 , ENC_LITTLE_ENDIAN ) ;
iOffset += 2 ;
parseByteString ( subtree , tvb , pinfo , & iOffset , hf_opcua_nodeid_bytestring ) ;
break ;
}
;
if ( EncodingMask & NODEID_NAMESPACEURIFLAG ) {
parseString ( subtree , tvb , pinfo , & iOffset , hf_opcua_NamespaceUri ) ;
}
if ( EncodingMask & NODEID_SERVERINDEXFLAG ) {
parseUInt32 ( subtree , tvb , pinfo , & iOffset , hf_opcua_ServerIndex ) ;
}
proto_item_set_end ( ti , tvb , iOffset ) ;
* pOffset = iOffset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_OCTET_STRING_SIZE_2_5 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_octet_string ( tvb , offset , actx , tree , hf_index , 2 , 5 , FALSE , NULL ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint8_t * dst , ptrdiff_t stride , const uint8_t * above , const uint8_t * left ) {
type ## _predictor ( dst , stride , size , above , left ) ;
}
# if CONFIG_VP9_HIGHBITDEPTH # define intra_pred_high_sized ( type , size ) void vp9_high_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint16_t * dst , ptrdiff_t stride , const uint16_t * above , const uint16_t * left , int bd ) {
high_ ## type ## _predictor ( dst , stride , size , above , left , bd ) ;
}
# define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) intra_pred_high_sized ( type , 4 ) intra_pred_high_sized ( type , 8 ) intra_pred_high_sized ( type , 16 ) intra_pred_high_sized ( type , 32 ) # else # define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) # endif # if CONFIG_VP9_HIGHBITDEPTH static INLINE void high_d207_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) above ;
( void ) bd ;
for ( r = 0 ;
r < bs - 1 ;
++ r ) {
dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;
}
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( r = 0 ;
r < bs - 2 ;
++ r ) {
dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;
}
dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;
for ( r = bs - 2 ;
r >= 0 ;
-- r ) {
for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;
}
}
static INLINE void high_d63_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) left ;
( void ) bd ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) {
dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] * 2 + above [ r / 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] , 1 ) ;
}
dst += stride ;
}
}
static INLINE void high_d45_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) left ;
( void ) bd ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) {
dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;
}
dst += stride ;
}
}
static INLINE void high_d117_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) bd ;
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 3 ;
r < bs ;
++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;
dst += stride ;
}
}
static INLINE void high_d135_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) bd ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;
dst += stride ;
}
}
static INLINE void high_d153_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
( void ) bd ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;
for ( r = 1 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;
dst ++ ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;
dst += stride ;
}
}
static INLINE void high_v_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r ;
( void ) left ;
( void ) bd ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memcpy ( dst , above , bs * sizeof ( uint16_t ) ) ;
dst += stride ;
}
}
static INLINE void high_h_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r ;
( void ) above ;
( void ) bd ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset16 ( dst , left [ r ] , bs ) ;
dst += stride ;
}
}
static INLINE void high_tm_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r , c ;
int ytop_left = above [ - 1 ] ;
( void ) bd ;
for ( r = 0 ;
r < bs ;
r ++ ) {
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = clip_pixel_high ( left [ r ] + above [ c ] - ytop_left , bd ) ;
dst += stride ;
}
}
static INLINE void high_dc_128_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int r ;
( void ) above ;
( void ) left ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset16 ( dst , 128 << ( bd - 8 ) , bs ) ;
dst += stride ;
}
}
static INLINE void high_dc_left_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int i , r , expected_dc , sum = 0 ;
( void ) above ;
( void ) bd ;
for ( i = 0 ;
i < bs ;
i ++ ) sum += left [ i ] ;
expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset16 ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
static INLINE void high_dc_top_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int i , r , expected_dc , sum = 0 ;
( void ) left ;
( void ) bd ;
for ( i = 0 ;
i < bs ;
i ++ ) sum += above [ i ] ;
expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset16 ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
static INLINE void high_dc_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
int i , r , expected_dc , sum = 0 ;
const int count = 2 * bs ;
( void ) bd ;
for ( i = 0 ;
i < bs ;
i ++ ) {
sum += above [ i ] ;
sum += left [ i ] ;
}
expected_dc = ( sum + ( count >> 1 ) ) / count ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset16 ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
# endif static INLINE void d207_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) above ;
for ( r = 0 ;
r < bs - 1 ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( r = 0 ;
r < bs - 2 ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;
dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;
dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;
for ( r = bs - 2 ;
r >= 0 ;
-- r ) for ( c = 0 ;
c < bs - 2 ;
++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;
}
intra_pred_allsizes ( d207 ) static INLINE void d63_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) left ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] * 2 + above [ r / 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] , 1 ) ;
dst += stride ;
}
}
intra_pred_allsizes ( d63 ) static INLINE void d45_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
( void ) left ;
for ( r = 0 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs ;
++ c ) dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d45 ) static INLINE void d117_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst += stride ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 3 ;
r < bs ;
++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d117 ) static INLINE void d135_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 1 ;
c < bs ;
c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d135 ) static INLINE void d153_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;
for ( r = 1 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;
dst ++ ;
dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
for ( r = 2 ;
r < bs ;
r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
dst ++ ;
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;
dst += stride ;
for ( r = 1 ;
r < bs ;
++ r ) {
for ( c = 0 ;
c < bs - 2 ;
c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;
dst += stride ;
}
}
intra_pred_allsizes ( d153 ) static INLINE void v_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) left ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memcpy ( dst , above , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( v ) static INLINE void h_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) above ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , left [ r ] , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( h ) static INLINE void tm_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r , c ;
int ytop_left = above [ - 1 ] ;
for ( r = 0 ;
r < bs ;
r ++ ) {
for ( c = 0 ;
c < bs ;
c ++ ) dst [ c ] = clip_pixel ( left [ r ] + above [ c ] - ytop_left ) ;
dst += stride ;
}
}
intra_pred_allsizes ( tm ) static INLINE void dc_128_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int r ;
( void ) above ;
( void ) left ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , 128 , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc_128 ) static INLINE void dc_left_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
int i , r , expected_dc , sum = 0 ;
( void ) above ;
for ( i = 0 ;
i < bs ;
i ++ ) sum += left [ i ] ;
expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
for ( r = 0 ;
r < bs ;
r ++ ) {
vpx_memset ( dst , expected_dc , bs ) ;
dst += stride ;
}
}
intra_pred_allsizes ( dc_left )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_nlm3_shareres ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ ) {
return dissect_nlm_shareres ( tvb , 0 , pinfo , tree , 3 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void ipvideo_decode_opcodes ( IpvideoContext * s , AVFrame * frame ) {
int x , y ;
unsigned char opcode ;
int ret ;
GetBitContext gb ;
bytestream2_skip ( & s -> stream_ptr , 14 ) ;
if ( ! s -> is_16bpp ) {
memcpy ( frame -> data [ 1 ] , s -> pal , AVPALETTE_SIZE ) ;
s -> stride = frame -> linesize [ 0 ] ;
}
else {
s -> stride = frame -> linesize [ 0 ] >> 1 ;
s -> mv_ptr = s -> stream_ptr ;
bytestream2_skip ( & s -> mv_ptr , bytestream2_get_le16 ( & s -> stream_ptr ) ) ;
}
s -> line_inc = s -> stride - 8 ;
s -> upper_motion_limit_offset = ( s -> avctx -> height - 8 ) * frame -> linesize [ 0 ] + ( s -> avctx -> width - 8 ) * ( 1 + s -> is_16bpp ) ;
init_get_bits ( & gb , s -> decoding_map , s -> decoding_map_size * 8 ) ;
for ( y = 0 ;
y < s -> avctx -> height ;
y += 8 ) {
for ( x = 0 ;
x < s -> avctx -> width ;
x += 8 ) {
opcode = get_bits ( & gb , 4 ) ;
av_dlog ( s -> avctx , " block @ (%3d, %3d): encoding 0x%X, data ptr offset %d\n" , x , y , opcode , bytestream2_tell ( & s -> stream_ptr ) ) ;
if ( ! s -> is_16bpp ) {
s -> pixel_ptr = frame -> data [ 0 ] + x + y * frame -> linesize [ 0 ] ;
ret = ipvideo_decode_block [ opcode ] ( s , frame ) ;
}
else {
s -> pixel_ptr = frame -> data [ 0 ] + x * 2 + y * frame -> linesize [ 0 ] ;
ret = ipvideo_decode_block16 [ opcode ] ( s , frame ) ;
}
if ( ret != 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , " Interplay video: decode problem on frame %d, @ block (%d, %d)\n" , s -> avctx -> frame_number , x , y ) ;
return ;
}
}
}
if ( bytestream2_get_bytes_left ( & s -> stream_ptr ) > 1 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "Interplay video: decode finished with %d bytes left over\n" , bytestream2_get_bytes_left ( & s -> stream_ptr ) ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int MBS_ReadHeader ( int fd , MBSPatchHeader * header ) {
int s = read ( fd , header , sizeof ( MBSPatchHeader ) ) ;
if ( s != sizeof ( MBSPatchHeader ) ) return READ_ERROR ;
header -> slen = ntohl ( header -> slen ) ;
header -> scrc32 = ntohl ( header -> scrc32 ) ;
header -> dlen = ntohl ( header -> dlen ) ;
header -> cblen = ntohl ( header -> cblen ) ;
header -> difflen = ntohl ( header -> difflen ) ;
header -> extralen = ntohl ( header -> extralen ) ;
struct stat hs ;
s = fstat ( fd , & hs ) ;
if ( s != 0 ) return READ_ERROR ;
if ( memcmp ( header -> tag , "MBDIFF10" , 8 ) != 0 ) return UNEXPECTED_ERROR ;
if ( hs . st_size > INT_MAX ) return UNEXPECTED_ERROR ;
size_t size = static_cast < size_t > ( hs . st_size ) ;
if ( size < sizeof ( MBSPatchHeader ) ) return UNEXPECTED_ERROR ;
size -= sizeof ( MBSPatchHeader ) ;
if ( size < header -> cblen ) return UNEXPECTED_ERROR ;
size -= header -> cblen ;
if ( size < header -> difflen ) return UNEXPECTED_ERROR ;
size -= header -> difflen ;
if ( size < header -> extralen ) return UNEXPECTED_ERROR ;
size -= header -> extralen ;
if ( size != 0 ) return UNEXPECTED_ERROR ;
return OK ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
const char * proto_get_protocol_short_name ( const protocol_t * protocol ) {
if ( protocol == NULL ) return "(none)" ;
return protocol -> short_name ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
CURLcode Curl_http_readwrite_headers ( struct Curl_easy * data , struct connectdata * conn , ssize_t * nread , bool * stop_reading ) {
CURLcode result ;
struct SingleRequest * k = & data -> req ;
do {
size_t rest_length ;
size_t full_length ;
int writetype ;
k -> str_start = k -> str ;
k -> end_ptr = memchr ( k -> str_start , 0x0a , * nread ) ;
if ( ! k -> end_ptr ) {
result = header_append ( data , k , * nread ) ;
if ( result ) return result ;
if ( ! k -> headerline && ( k -> hbuflen > 5 ) ) {
if ( ! checkprotoprefix ( data , conn , data -> state . headerbuff ) ) {
k -> header = FALSE ;
k -> badheader = HEADER_ALLBAD ;
break ;
}
}
break ;
}
rest_length = ( k -> end_ptr - k -> str ) + 1 ;
* nread -= ( ssize_t ) rest_length ;
k -> str = k -> end_ptr + 1 ;
full_length = k -> str - k -> str_start ;
result = header_append ( data , k , full_length ) ;
if ( result ) return result ;
k -> end_ptr = k -> hbufp ;
k -> p = data -> state . headerbuff ;
if ( ! k -> headerline ) {
if ( ( k -> hbuflen > 5 ) && ! checkprotoprefix ( data , conn , data -> state . headerbuff ) ) {
k -> header = FALSE ;
if ( * nread ) k -> badheader = HEADER_PARTHEADER ;
else {
k -> badheader = HEADER_ALLBAD ;
* nread = ( ssize_t ) rest_length ;
}
break ;
}
}
if ( ( 0x0a == * k -> p ) || ( 0x0d == * k -> p ) ) {
size_t headerlen ;
# ifdef CURL_DOES_CONVERSIONS if ( 0x0d == * k -> p ) {
* k -> p = '\r' ;
k -> p ++ ;
}
if ( 0x0a == * k -> p ) {
* k -> p = '\n' ;
k -> p ++ ;
}
# else if ( '\r' == * k -> p ) k -> p ++ ;
if ( '\n' == * k -> p ) k -> p ++ ;
# endif if ( 100 <= k -> httpcode && 199 >= k -> httpcode ) {
switch ( k -> httpcode ) {
case 100 : k -> header = TRUE ;
k -> headerline = 0 ;
if ( k -> exp100 > EXP100_SEND_DATA ) {
k -> exp100 = EXP100_SEND_DATA ;
k -> keepon |= KEEP_SEND ;
}
break ;
case 101 : if ( k -> upgr101 == UPGR101_REQUESTED ) {
infof ( data , "Received 101\n" ) ;
k -> upgr101 = UPGR101_RECEIVED ;
k -> header = TRUE ;
k -> headerline = 0 ;
result = Curl_http2_switched ( conn , k -> str , * nread ) ;
if ( result ) return result ;
* nread = 0 ;
}
else {
k -> header = FALSE ;
}
break ;
default : k -> header = TRUE ;
k -> headerline = 0 ;
break ;
}
}
else {
k -> header = FALSE ;
if ( ( k -> size == - 1 ) && ! k -> chunk && ! conn -> bits . close && ( conn -> httpversion == 11 ) && ! ( conn -> handler -> protocol & CURLPROTO_RTSP ) && data -> set . httpreq != HTTPREQ_HEAD ) {
infof ( data , "no chunk, no close, no size. Assume close to " "signal end\n" ) ;
streamclose ( conn , "HTTP: No end-of-message indicator" ) ;
}
}
# if defined ( USE_NTLM ) if ( conn -> bits . close && ( ( ( data -> req . httpcode == 401 ) && ( conn -> ntlm . state == NTLMSTATE_TYPE2 ) ) || ( ( data -> req . httpcode == 407 ) && ( conn -> proxyntlm . state == NTLMSTATE_TYPE2 ) ) ) ) {
infof ( data , "Connection closure while negotiating auth (HTTP 1.0?)\n" ) ;
data -> state . authproblem = TRUE ;
}
# endif if ( http_should_fail ( conn ) ) {
failf ( data , "The requested URL returned error: %d" , k -> httpcode ) ;
return CURLE_HTTP_RETURNED_ERROR ;
}
writetype = CLIENTWRITE_HEADER ;
if ( data -> set . include_header ) writetype |= CLIENTWRITE_BODY ;
headerlen = k -> p - data -> state . headerbuff ;
result = Curl_client_write ( conn , writetype , data -> state . headerbuff , headerlen ) ;
if ( result ) return result ;
data -> info . header_size += ( long ) headerlen ;
data -> req . headerbytecount += ( long ) headerlen ;
data -> req . deductheadercount = ( 100 <= k -> httpcode && 199 >= k -> httpcode ) ? data -> req . headerbytecount : 0 ;
result = Curl_http_auth_act ( conn ) ;
if ( result ) return result ;
if ( k -> httpcode >= 300 ) {
if ( ( ! conn -> bits . authneg ) && ! conn -> bits . close && ! conn -> bits . rewindaftersend ) {
switch ( data -> set . httpreq ) {
case HTTPREQ_PUT : case HTTPREQ_POST : case HTTPREQ_POST_FORM : if ( ! k -> upload_done ) {
if ( data -> set . http_keep_sending_on_error ) {
infof ( data , "HTTP error before end of send, keep sending\n" ) ;
if ( k -> exp100 > EXP100_SEND_DATA ) {
k -> exp100 = EXP100_SEND_DATA ;
k -> keepon |= KEEP_SEND ;
}
}
else {
infof ( data , "HTTP error before end of send, stop sending\n" ) ;
streamclose ( conn , "Stop sending data before everything sent" ) ;
k -> upload_done = TRUE ;
k -> keepon &= ~ KEEP_SEND ;
if ( data -> state . expect100header ) k -> exp100 = EXP100_FAILED ;
}
}
break ;
default : break ;
}
}
if ( conn -> bits . rewindaftersend ) {
infof ( data , "Keep sending data to get tossed away!\n" ) ;
k -> keepon |= KEEP_SEND ;
}
}
if ( ! k -> header ) {
if ( data -> set . opt_no_body ) * stop_reading = TRUE ;
# ifndef CURL_DISABLE_RTSP else if ( ( conn -> handler -> protocol & CURLPROTO_RTSP ) && ( data -> set . rtspreq == RTSPREQ_DESCRIBE ) && ( k -> size <= - 1 ) ) * stop_reading = TRUE ;
# endif else {
if ( k -> chunk ) k -> maxdownload = k -> size = - 1 ;
}
if ( - 1 != k -> size ) {
Curl_pgrsSetDownloadSize ( data , k -> size ) ;
k -> maxdownload = k -> size ;
}
if ( 0 == k -> maxdownload ) * stop_reading = TRUE ;
if ( * stop_reading ) {
k -> keepon &= ~ KEEP_RECV ;
}
if ( data -> set . verbose ) Curl_debug ( data , CURLINFO_HEADER_IN , k -> str_start , headerlen , conn ) ;
break ;
}
k -> hbufp = data -> state . headerbuff ;
k -> hbuflen = 0 ;
continue ;
}
if ( ! k -> headerline ++ ) {
int httpversion_major ;
int rtspversion_major ;
int nc = 0 ;
# ifdef CURL_DOES_CONVERSIONS # define HEADER1 scratch # define SCRATCHSIZE 21 CURLcode res ;
char scratch [ SCRATCHSIZE + 1 ] ;
strncpy ( & scratch [ 0 ] , k -> p , SCRATCHSIZE ) ;
scratch [ SCRATCHSIZE ] = 0 ;
res = Curl_convert_from_network ( data , & scratch [ 0 ] , SCRATCHSIZE ) ;
if ( res ) return res ;
# else # define HEADER1 k -> p # endif if ( conn -> handler -> protocol & PROTO_FAMILY_HTTP ) {
nc = sscanf ( HEADER1 , " HTTP/%d.%d %d" , & httpversion_major , & conn -> httpversion , & k -> httpcode ) ;
if ( nc == 1 && httpversion_major == 2 && == sscanf ( HEADER1 , " HTTP/2 %d" , & k -> httpcode ) ) {
conn -> httpversion = 0 ;
nc = 3 ;
}
if ( nc == 3 ) {
conn -> httpversion += 10 * httpversion_major ;
if ( k -> upgr101 == UPGR101_RECEIVED ) {
if ( conn -> httpversion != 20 ) infof ( data , "Lying server, not serving HTTP/2\n" ) ;
}
}
else {
nc = sscanf ( HEADER1 , " HTTP %3d" , & k -> httpcode ) ;
conn -> httpversion = 10 ;
if ( ! nc ) {
if ( checkhttpprefix ( data , k -> p ) ) {
nc = 1 ;
k -> httpcode = 200 ;
conn -> httpversion = 10 ;
}
}
}
}
else if ( conn -> handler -> protocol & CURLPROTO_RTSP ) {
nc = sscanf ( HEADER1 , " RTSP/%d.%d %3d" , & rtspversion_major , & conn -> rtspversion , & k -> httpcode ) ;
if ( nc == 3 ) {
conn -> rtspversion += 10 * rtspversion_major ;
conn -> httpversion = 11 ;
}
else {
nc = 0 ;
}
}
if ( nc ) {
data -> info . httpcode = k -> httpcode ;
data -> info . httpversion = conn -> httpversion ;
if ( ! data -> state . httpversion || data -> state . httpversion > conn -> httpversion ) data -> state . httpversion = conn -> httpversion ;
if ( data -> set . http_fail_on_error && ( k -> httpcode >= 400 ) && ( ( k -> httpcode != 401 ) || ! conn -> bits . user_passwd ) && ( ( k -> httpcode != 407 ) || ! conn -> bits . proxy_user_passwd ) ) {
if ( data -> state . resume_from && ( data -> set . httpreq == HTTPREQ_GET ) && ( k -> httpcode == 416 ) ) {
}
else {
print_http_error ( data ) ;
return CURLE_HTTP_RETURNED_ERROR ;
}
}
if ( conn -> httpversion == 10 ) {
infof ( data , "HTTP 1.0, assume close after body\n" ) ;
connclose ( conn , "HTTP/1.0 close after body" ) ;
}
else if ( conn -> httpversion == 20 || ( k -> upgr101 == UPGR101_REQUESTED && k -> httpcode == 101 ) ) {
DEBUGF ( infof ( data , "HTTP/2 found, allow multiplexing\n" ) ) ;
conn -> bundle -> multiuse = BUNDLE_MULTIPLEX ;
}
else if ( conn -> httpversion >= 11 && ! conn -> bits . close ) {
DEBUGF ( infof ( data , "HTTP 1.1 or later with persistent connection, " "pipelining supported\n" ) ) ;
if ( conn -> bundle ) {
if ( ! Curl_pipeline_site_blacklisted ( data , conn ) ) conn -> bundle -> multiuse = BUNDLE_PIPELINING ;
}
}
switch ( k -> httpcode ) {
case 204 : case 304 : if ( data -> set . timecondition ) data -> info . timecond = TRUE ;
k -> size = 0 ;
k -> maxdownload = 0 ;
k -> ignorecl = TRUE ;
break ;
default : break ;
}
}
else {
k -> header = FALSE ;
break ;
}
}
result = Curl_convert_from_network ( data , k -> p , strlen ( k -> p ) ) ;
if ( result ) return result ;
if ( ! k -> ignorecl && ! data -> set . ignorecl && checkprefix ( "Content-Length:" , k -> p ) ) {
curl_off_t contentlength = curlx_strtoofft ( k -> p + 15 , NULL , 10 ) ;
if ( data -> set . max_filesize && contentlength > data -> set . max_filesize ) {
failf ( data , "Maximum file size exceeded" ) ;
return CURLE_FILESIZE_EXCEEDED ;
}
if ( contentlength >= 0 ) {
k -> size = contentlength ;
k -> maxdownload = k -> size ;
Curl_pgrsSetDownloadSize ( data , k -> size ) ;
}
else {
streamclose ( conn , "negative content-length" ) ;
infof ( data , "Negative content-length: %" CURL_FORMAT_CURL_OFF_T ", closing after transfer\n" , contentlength ) ;
}
}
else if ( checkprefix ( "Content-Type:" , k -> p ) ) {
char * contenttype = Curl_copy_header_value ( k -> p ) ;
if ( ! contenttype ) return CURLE_OUT_OF_MEMORY ;
if ( ! * contenttype ) free ( contenttype ) ;
else {
Curl_safefree ( data -> info . contenttype ) ;
data -> info . contenttype = contenttype ;
}
}
else if ( checkprefix ( "Server:" , k -> p ) ) {
if ( conn -> httpversion < 20 ) {
char * server_name = Curl_copy_header_value ( k -> p ) ;
if ( conn -> bundle && ( conn -> bundle -> multiuse == BUNDLE_PIPELINING ) ) {
if ( Curl_pipeline_server_blacklisted ( data , server_name ) ) conn -> bundle -> multiuse = BUNDLE_NO_MULTIUSE ;
}
free ( server_name ) ;
}
}
else if ( ( conn -> httpversion == 10 ) && conn -> bits . httpproxy && Curl_compareheader ( k -> p , "Proxy-Connection:" , "keep-alive" ) ) {
connkeep ( conn , "Proxy-Connection keep-alive" ) ;
infof ( data , "HTTP/1.0 proxy connection set to keep alive!\n" ) ;
}
else if ( ( conn -> httpversion == 11 ) && conn -> bits . httpproxy && Curl_compareheader ( k -> p , "Proxy-Connection:" , "close" ) ) {
connclose ( conn , "Proxy-Connection: asked to close after done" ) ;
infof ( data , "HTTP/1.1 proxy connection set close!\n" ) ;
}
else if ( ( conn -> httpversion == 10 ) && Curl_compareheader ( k -> p , "Connection:" , "keep-alive" ) ) {
connkeep ( conn , "Connection keep-alive" ) ;
infof ( data , "HTTP/1.0 connection set to keep alive!\n" ) ;
}
else if ( Curl_compareheader ( k -> p , "Connection:" , "close" ) ) {
streamclose ( conn , "Connection: close used" ) ;
}
else if ( checkprefix ( "Transfer-Encoding:" , k -> p ) ) {
char * start ;
start = k -> p + 18 ;
for ( ;
;
) {
while ( * start && ( ISSPACE ( * start ) || ( * start == ',' ) ) ) start ++ ;
if ( checkprefix ( "chunked" , start ) ) {
k -> chunk = TRUE ;
Curl_httpchunk_init ( conn ) ;
start += 7 ;
}
if ( k -> auto_decoding ) break ;
if ( checkprefix ( "identity" , start ) ) {
k -> auto_decoding = IDENTITY ;
start += 8 ;
}
else if ( checkprefix ( "deflate" , start ) ) {
k -> auto_decoding = DEFLATE ;
start += 7 ;
}
else if ( checkprefix ( "gzip" , start ) ) {
k -> auto_decoding = GZIP ;
start += 4 ;
}
else if ( checkprefix ( "x-gzip" , start ) ) {
k -> auto_decoding = GZIP ;
start += 6 ;
}
else break ;
}
}
else if ( checkprefix ( "Content-Encoding:" , k -> p ) && data -> set . str [ STRING_ENCODING ] ) {
char * start ;
start = k -> p + 17 ;
while ( * start && ISSPACE ( * start ) ) start ++ ;
if ( checkprefix ( "identity" , start ) ) k -> auto_decoding = IDENTITY ;
else if ( checkprefix ( "deflate" , start ) ) k -> auto_decoding = DEFLATE ;
else if ( checkprefix ( "gzip" , start ) || checkprefix ( "x-gzip" , start ) ) k -> auto_decoding = GZIP ;
}
else if ( checkprefix ( "Content-Range:" , k -> p ) ) {
char * ptr = k -> p + 14 ;
while ( * ptr && ! ISDIGIT ( * ptr ) && * ptr != '*' ) ptr ++ ;
if ( ISDIGIT ( * ptr ) ) {
k -> offset = curlx_strtoofft ( ptr , NULL , 10 ) ;
if ( data -> state . resume_from == k -> offset ) k -> content_range = TRUE ;
}
else data -> state . resume_from = 0 ;
}
# if ! defined ( CURL_DISABLE_COOKIES ) else if ( data -> cookies && checkprefix ( "Set-Cookie:" , k -> p ) ) {
Curl_share_lock ( data , CURL_LOCK_DATA_COOKIE , CURL_LOCK_ACCESS_SINGLE ) ;
Curl_cookie_add ( data , data -> cookies , TRUE , k -> p + 11 , conn -> allocptr . cookiehost ? conn -> allocptr . cookiehost : conn -> host . name , data -> state . path ) ;
Curl_share_unlock ( data , CURL_LOCK_DATA_COOKIE ) ;
}
# endif else if ( checkprefix ( "Last-Modified:" , k -> p ) && ( data -> set . timecondition || data -> set . get_filetime ) ) {
time_t secs = time ( NULL ) ;
k -> timeofdoc = curl_getdate ( k -> p + strlen ( "Last-Modified:" ) , & secs ) ;
if ( data -> set . get_filetime ) data -> info . filetime = ( long ) k -> timeofdoc ;
}
else if ( ( checkprefix ( "WWW-Authenticate:" , k -> p ) && ( 401 == k -> httpcode ) ) || ( checkprefix ( "Proxy-authenticate:" , k -> p ) && ( 407 == k -> httpcode ) ) ) {
bool proxy = ( k -> httpcode == 407 ) ? TRUE : FALSE ;
char * auth = Curl_copy_header_value ( k -> p ) ;
if ( ! auth ) return CURLE_OUT_OF_MEMORY ;
result = Curl_http_input_auth ( conn , proxy , auth ) ;
free ( auth ) ;
if ( result ) return result ;
}
else if ( ( k -> httpcode >= 300 && k -> httpcode < 400 ) && checkprefix ( "Location:" , k -> p ) && ! data -> req . location ) {
char * location = Curl_copy_header_value ( k -> p ) ;
if ( ! location ) return CURLE_OUT_OF_MEMORY ;
if ( ! * location ) free ( location ) ;
else {
data -> req . location = location ;
if ( data -> set . http_follow_location ) {
DEBUGASSERT ( ! data -> req . newurl ) ;
data -> req . newurl = strdup ( data -> req . location ) ;
if ( ! data -> req . newurl ) return CURLE_OUT_OF_MEMORY ;
result = http_perhapsrewind ( conn ) ;
if ( result ) return result ;
}
}
}
else if ( conn -> handler -> protocol & CURLPROTO_RTSP ) {
result = Curl_rtsp_parseheader ( conn , k -> p ) ;
if ( result ) return result ;
}
writetype = CLIENTWRITE_HEADER ;
if ( data -> set . include_header ) writetype |= CLIENTWRITE_BODY ;
if ( data -> set . verbose ) Curl_debug ( data , CURLINFO_HEADER_IN , k -> p , ( size_t ) k -> hbuflen , conn ) ;
result = Curl_client_write ( conn , writetype , k -> p , k -> hbuflen ) ;
if ( result ) return result ;
data -> info . header_size += ( long ) k -> hbuflen ;
data -> req . headerbytecount += ( long ) k -> hbuflen ;
k -> hbufp = data -> state . headerbuff ;
k -> hbuflen = 0 ;
}
while ( * k -> str ) ;
return CURLE_OK ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static VALUE ossl_asn1data_initialize ( VALUE self , VALUE value , VALUE tag , VALUE tag_class ) {
if ( ! SYMBOL_P ( tag_class ) ) ossl_raise ( eASN1Error , "invalid tag class" ) ;
if ( tag_class == sym_UNIVERSAL && NUM2INT ( tag ) > 31 ) ossl_raise ( eASN1Error , "tag number for Universal too large" ) ;
ossl_asn1_set_tag ( self , tag ) ;
ossl_asn1_set_value ( self , value ) ;
ossl_asn1_set_tag_class ( self , tag_class ) ;
ossl_asn1_set_infinite_length ( self , Qfalse ) ;
return self ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void idr_relaxed_filenames ( char * map ) {
int i ;
for ( i = 0x21 ;
i <= 0x2F ;
i ++ ) map [ i ] = 1 ;
for ( i = 0x3A ;
i <= 0x41 ;
i ++ ) map [ i ] = 1 ;
for ( i = 0x5B ;
i <= 0x5E ;
i ++ ) map [ i ] = 1 ;
map [ 0x60 ] = 1 ;
for ( i = 0x7B ;
i <= 0x7E ;
i ++ ) map [ i ] = 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void tb_invalidate_phys_page_range ( tb_page_addr_t start , tb_page_addr_t end , int is_cpu_write_access ) {
TranslationBlock * tb , * tb_next , * saved_tb ;
CPUArchState * env = cpu_single_env ;
CPUState * cpu = NULL ;
tb_page_addr_t tb_start , tb_end ;
PageDesc * p ;
int n ;
# ifdef TARGET_HAS_PRECISE_SMC int current_tb_not_found = is_cpu_write_access ;
TranslationBlock * current_tb = NULL ;
int current_tb_modified = 0 ;
target_ulong current_pc = 0 ;
target_ulong current_cs_base = 0 ;
int current_flags = 0 ;
# endif p = page_find ( start >> TARGET_PAGE_BITS ) ;
if ( ! p ) {
return ;
}
if ( ! p -> code_bitmap && ++ p -> code_write_count >= SMC_BITMAP_USE_THRESHOLD && is_cpu_write_access ) {
build_page_bitmap ( p ) ;
}
if ( env != NULL ) {
cpu = ENV_GET_CPU ( env ) ;
}
tb = p -> first_tb ;
while ( tb != NULL ) {
n = ( uintptr_t ) tb & 3 ;
tb = ( TranslationBlock * ) ( ( uintptr_t ) tb & ~ 3 ) ;
tb_next = tb -> page_next [ n ] ;
if ( n == 0 ) {
tb_start = tb -> page_addr [ 0 ] + ( tb -> pc & ~ TARGET_PAGE_MASK ) ;
tb_end = tb_start + tb -> size ;
}
else {
tb_start = tb -> page_addr [ 1 ] ;
tb_end = tb_start + ( ( tb -> pc + tb -> size ) & ~ TARGET_PAGE_MASK ) ;
}
if ( ! ( tb_end <= start || tb_start >= end ) ) {
# ifdef TARGET_HAS_PRECISE_SMC if ( current_tb_not_found ) {
current_tb_not_found = 0 ;
current_tb = NULL ;
if ( env -> mem_io_pc ) {
current_tb = tb_find_pc ( env -> mem_io_pc ) ;
}
}
if ( current_tb == tb && ( current_tb -> cflags & CF_COUNT_MASK ) != 1 ) {
current_tb_modified = 1 ;
cpu_restore_state_from_tb ( current_tb , env , env -> mem_io_pc ) ;
cpu_get_tb_cpu_state ( env , & current_pc , & current_cs_base , & current_flags ) ;
}
# endif saved_tb = NULL ;
if ( cpu != NULL ) {
saved_tb = cpu -> current_tb ;
cpu -> current_tb = NULL ;
}
tb_phys_invalidate ( tb , - 1 ) ;
if ( cpu != NULL ) {
cpu -> current_tb = saved_tb ;
if ( cpu -> interrupt_request && cpu -> current_tb ) {
cpu_interrupt ( cpu , cpu -> interrupt_request ) ;
}
}
}
tb = tb_next ;
}
# if ! defined ( CONFIG_USER_ONLY ) if ( ! p -> first_tb ) {
invalidate_page_bitmap ( p ) ;
if ( is_cpu_write_access ) {
tlb_unprotect_code_phys ( env , start , env -> mem_io_vaddr ) ;
}
}
# endif # ifdef TARGET_HAS_PRECISE_SMC if ( current_tb_modified ) {
cpu -> current_tb = NULL ;
tb_gen_code ( env , current_pc , current_cs_base , current_flags , 1 ) ;
cpu_resume_from_signal ( env , NULL ) ;
}
# endif }
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST ( AutocompleteMatchTest , Duplicates ) {
struct DuplicateCases {
const wchar_t * input ;
const std : : string url1 ;
const std : : string url2 ;
const bool expected_duplicate ;
}
cases [ ] = {
{
L"g" , "http://www.google.com/" , "https://www.google.com/" , true }
, {
L"g" , "http://www.google.com/" , "http://www.google.com" , true }
, {
L"g" , "http://google.com/" , "http://www.google.com/" , true }
, {
L"g" , "http://www.google.com/" , "HTTP://www.GOOGLE.com/" , true }
, {
L"g" , "http://www.google.com/" , "http://www.google.com" , true }
, {
L"g" , "https://www.google.com/" , "http://google.com" , true }
, {
L"g" , "http://www.google.com/" , "wss://www.google.com/" , false }
, {
L"g" , "http://www.google.com/1" , "http://www.google.com/1/" , false }
, {
L"g" , "http://www.google.com/" , "http://www.google.com/1" , false }
, {
L"g" , "http://www.google.com/" , "http://www.goo.com/" , false }
, {
L"g" , "http://www.google.com/" , "http://w2.google.com/" , false }
, {
L"g" , "http://www.google.com/" , "http://m.google.com/" , false }
, {
L"g" , "http://www.google.com/" , "http://www.google.com/?foo" , false }
, {
L"http://g" , "http://google.com/" , "https://google.com/" , false }
, {
L"http://g" , "http://blah.com/" , "https://blah.com/" , true }
, {
L"http://g" , "http://google.com/1" , "https://google.com/1" , false }
, {
L"http://g hello" , "http://google.com/" , "https://google.com/" , false }
, {
L"hello http://g" , "http://google.com/" , "https://google.com/" , false }
, {
L"hello http://g" , "http://blah.com/" , "https://blah.com/" , true }
, {
L"http://b http://g" , "http://google.com/" , "https://google.com/" , false }
, {
L"http://b http://g" , "http://blah.com/" , "https://blah.com/" , false }
, {
L"x" , "http://xn--1lq90ic7f1rc.cn/" , "https://xn--1lq90ic7f1rc.cn/" , true }
, {
L"http://\x5317 x" , "http://xn--1lq90ic7f1rc.cn/" , "https://xn--1lq90ic7f1rc.cn/" , false }
, {
L"http://\x89c6 x" , "http://xn--1lq90ic7f1rc.cn/" , "https://xn--1lq90ic7f1rc.cn/" , true }
, }
;
for ( size_t i = 0 ;
i < arraysize ( cases ) ;
++ i ) {
SCOPED_TRACE ( "input=" + base : : WideToUTF8 ( cases [ i ] . input ) + " url1=" + cases [ i ] . url1 + " url2=" + cases [ i ] . url2 ) ;
AutocompleteInput input ( base : : WideToUTF16 ( cases [ i ] . input ) , base : : string16 : : npos , std : : string ( ) , GURL ( ) , metrics : : OmniboxEventProto : : INVALID_SPEC , false , false , true , true , false , TestSchemeClassifier ( ) ) ;
AutocompleteMatch m1 ( NULL , 100 , false , AutocompleteMatchType : : URL_WHAT_YOU_TYPED ) ;
m1 . destination_url = GURL ( cases [ i ] . url1 ) ;
m1 . ComputeStrippedDestinationURL ( input , "zh-CN" , NULL ) ;
AutocompleteMatch m2 ( NULL , 100 , false , AutocompleteMatchType : : URL_WHAT_YOU_TYPED ) ;
m2 . destination_url = GURL ( cases [ i ] . url2 ) ;
m2 . ComputeStrippedDestinationURL ( input , "zh-CN" , NULL ) ;
EXPECT_EQ ( cases [ i ] . expected_duplicate , AutocompleteMatch : : DestinationsEqual ( m1 , m2 ) ) ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST_F ( ProfileInfoCacheTest , SetSupervisedUserId ) {
GetCache ( ) -> AddProfileToCache ( GetProfilePath ( "test" ) , ASCIIToUTF16 ( "Test" ) , base : : string16 ( ) , 0 , std : : string ( ) ) ;
EXPECT_FALSE ( GetCache ( ) -> ProfileIsSupervisedAtIndex ( 0 ) ) ;
GetCache ( ) -> SetSupervisedUserIdOfProfileAtIndex ( 0 , "TEST_ID" ) ;
EXPECT_TRUE ( GetCache ( ) -> ProfileIsSupervisedAtIndex ( 0 ) ) ;
EXPECT_EQ ( "TEST_ID" , GetCache ( ) -> GetSupervisedUserIdOfProfileAtIndex ( 0 ) ) ;
ResetCache ( ) ;
EXPECT_TRUE ( GetCache ( ) -> ProfileIsSupervisedAtIndex ( 0 ) ) ;
GetCache ( ) -> SetSupervisedUserIdOfProfileAtIndex ( 0 , std : : string ( ) ) ;
EXPECT_FALSE ( GetCache ( ) -> ProfileIsSupervisedAtIndex ( 0 ) ) ;
EXPECT_EQ ( "" , GetCache ( ) -> GetSupervisedUserIdOfProfileAtIndex ( 0 ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_denoiser_reset_frame_stats ( PICK_MODE_CONTEXT * ctx ) {
ctx -> zeromv_sse = UINT_MAX ;
ctx -> newmv_sse = UINT_MAX ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) {
# define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo {
unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ;
char comment [ 512 ] ;
unsigned int rows , columns , subrows ;
int x_offset , y_offset ;
float x_bits_per_pixel , y_bits_per_pixel ;
unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ;
}
ViffInfo ;
double min_value , scale_factor , value ;
Image * image ;
int bit ;
MagickBooleanType status ;
MagickSizeType number_pixels ;
register IndexPacket * indexes ;
register ssize_t x ;
register PixelPacket * q ;
register ssize_t i ;
register unsigned char * p ;
size_t bytes_per_pixel , max_packets , quantum ;
ssize_t count , y ;
unsigned char * pixels ;
unsigned long lsb_first ;
ViffInfo viff_info ;
assert ( image_info != ( const ImageInfo * ) NULL ) ;
assert ( image_info -> signature == MagickSignature ) ;
if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , "%s" , image_info -> filename ) ;
assert ( exception != ( ExceptionInfo * ) NULL ) ;
assert ( exception -> signature == MagickSignature ) ;
image = AcquireImage ( image_info ) ;
status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ;
if ( status == MagickFalse ) {
image = DestroyImageList ( image ) ;
return ( ( Image * ) NULL ) ;
}
count = ReadBlob ( image , 1 , & viff_info . identifier ) ;
do {
if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , "NotAVIFFImage" ) ;
( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ;
( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ;
( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ;
( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ;
( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ;
( void ) ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ;
viff_info . comment [ 511 ] = '\0' ;
if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , "comment" , viff_info . comment ) ;
if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ;
else image -> endian = MSBEndian ;
viff_info . rows = ReadBlobLong ( image ) ;
viff_info . columns = ReadBlobLong ( image ) ;
viff_info . subrows = ReadBlobLong ( image ) ;
viff_info . x_offset = ( int ) ReadBlobLong ( image ) ;
viff_info . y_offset = ( int ) ReadBlobLong ( image ) ;
viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ;
viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ;
viff_info . location_type = ReadBlobLong ( image ) ;
viff_info . location_dimension = ReadBlobLong ( image ) ;
viff_info . number_of_images = ReadBlobLong ( image ) ;
viff_info . number_data_bands = ReadBlobLong ( image ) ;
viff_info . data_storage_type = ReadBlobLong ( image ) ;
viff_info . data_encode_scheme = ReadBlobLong ( image ) ;
viff_info . map_scheme = ReadBlobLong ( image ) ;
viff_info . map_storage_type = ReadBlobLong ( image ) ;
viff_info . map_rows = ReadBlobLong ( image ) ;
viff_info . map_columns = ReadBlobLong ( image ) ;
viff_info . map_subrows = ReadBlobLong ( image ) ;
viff_info . map_enable = ReadBlobLong ( image ) ;
viff_info . maps_per_cycle = ReadBlobLong ( image ) ;
viff_info . color_space_model = ReadBlobLong ( image ) ;
for ( i = 0 ;
i < 420 ;
i ++ ) ( void ) ReadBlobByte ( image ) ;
if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , "UnexpectedEndOfFile" ) ;
image -> columns = viff_info . rows ;
image -> rows = viff_info . columns ;
image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ;
number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ;
if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
if ( number_pixels == 0 ) ThrowReaderException ( CoderError , "ImageColumnOrRowSizeIsNotSupported" ) ;
if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ;
if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , "DataStorageTypeIsNotSupported" ) ;
if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , "DataEncodingSchemeIsNotSupported" ) ;
if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , "MapStorageTypeIsNotSupported" ) ;
if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , "ColorspaceModelIsNotSupported" ) ;
if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , "LocationTypeIsNotSupported" ) ;
if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , "NumberOfImagesIsNotSupported" ) ;
if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ;
switch ( ( int ) viff_info . map_scheme ) {
case VFF_MS_NONE : {
if ( viff_info . number_data_bands < 3 ) {
if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ;
else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ;
else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ;
if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
}
break ;
}
case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : {
unsigned char * viff_colormap ;
switch ( ( int ) viff_info . map_storage_type ) {
case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ;
break ;
case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ;
break ;
case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ;
break ;
case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ;
break ;
case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ;
break ;
default : bytes_per_pixel = 1 ;
break ;
}
image -> colors = viff_info . map_columns ;
if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
if ( viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ;
viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ;
if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
( void ) ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ;
lsb_first = 1 ;
if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) {
case VFF_MAPTYP_2_BYTE : {
MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ;
break ;
}
case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : {
MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ;
break ;
}
default : break ;
}
for ( i = 0 ;
i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ;
i ++ ) {
switch ( ( int ) viff_info . map_storage_type ) {
case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ;
break ;
case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ;
break ;
case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ;
break ;
case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ;
break ;
default : value = 1.0 * viff_colormap [ i ] ;
break ;
}
if ( i < ( ssize_t ) image -> colors ) {
image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) value ) ;
image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ;
image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ;
}
else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ;
else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ;
}
viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ;
break ;
}
default : ThrowReaderException ( CoderError , "ColormapTypeNotSupported" ) ;
}
image -> matte = viff_info . number_data_bands == 4 ? MagickTrue : MagickFalse ;
image -> storage_class = ( viff_info . number_data_bands < 3 ? PseudoClass : DirectClass ) ;
image -> columns = viff_info . rows ;
image -> rows = viff_info . columns ;
if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ;
status = SetImageExtent ( image , image -> columns , image -> rows ) ;
if ( status == MagickFalse ) {
InheritException ( exception , & image -> exception ) ;
return ( DestroyImageList ( image ) ) ;
}
switch ( ( int ) viff_info . data_storage_type ) {
case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ;
break ;
case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ;
break ;
case VFF_TYP_FLOAT : bytes_per_pixel = 4 ;
break ;
case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ;
break ;
default : bytes_per_pixel = 1 ;
break ;
}
if ( viff_info . data_storage_type == VFF_TYP_BIT ) max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ;
else max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ;
pixels = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( number_pixels , max_packets ) , bytes_per_pixel * sizeof ( * pixels ) ) ;
if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
( void ) ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ;
lsb_first = 1 ;
if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) {
case VFF_TYP_2_BYTE : {
MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ;
break ;
}
case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : {
MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ;
break ;
}
default : break ;
}
min_value = 0.0 ;
scale_factor = 1.0 ;
if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) {
double max_value ;
switch ( ( int ) viff_info . data_storage_type ) {
case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ;
break ;
case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ;
break ;
case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ;
break ;
case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ;
break ;
default : value = 1.0 * pixels [ 0 ] ;
break ;
}
max_value = value ;
min_value = value ;
for ( i = 0 ;
i < ( ssize_t ) max_packets ;
i ++ ) {
switch ( ( int ) viff_info . data_storage_type ) {
case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ;
break ;
case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ;
break ;
case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ;
break ;
case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ;
break ;
default : value = 1.0 * pixels [ i ] ;
break ;
}
if ( value > max_value ) max_value = value ;
else if ( value < min_value ) min_value = value ;
}
if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ;
else if ( min_value == max_value ) {
scale_factor = ( MagickRealType ) QuantumRange / min_value ;
min_value = 0 ;
}
else scale_factor = ( MagickRealType ) QuantumRange / ( max_value - min_value ) ;
}
p = ( unsigned char * ) pixels ;
for ( i = 0 ;
i < ( ssize_t ) max_packets ;
i ++ ) {
switch ( ( int ) viff_info . data_storage_type ) {
case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ;
break ;
case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ;
break ;
case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ;
break ;
case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ;
break ;
default : value = 1.0 * pixels [ i ] ;
break ;
}
if ( viff_info . map_scheme == VFF_MS_NONE ) {
value = ( value - min_value ) * scale_factor ;
if ( value > QuantumRange ) value = QuantumRange ;
else if ( value < 0 ) value = 0 ;
}
* p = ( unsigned char ) ( ( Quantum ) value ) ;
p ++ ;
}
p = ( unsigned char * ) pixels ;
if ( viff_info . data_storage_type == VFF_TYP_BIT ) {
if ( image -> storage_class != PseudoClass ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ;
for ( y = 0 ;
y < ( ssize_t ) image -> rows ;
y ++ ) {
q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ;
if ( q == ( PixelPacket * ) NULL ) break ;
indexes = GetAuthenticIndexQueue ( image ) ;
for ( x = 0 ;
x < ( ssize_t ) ( image -> columns - 7 ) ;
x += 8 ) {
for ( bit = 0 ;
bit < 8 ;
bit ++ ) {
quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ;
SetPixelRed ( q , quantum == 0 ? 0 : QuantumRange ) ;
SetPixelGreen ( q , quantum == 0 ? 0 : QuantumRange ) ;
SetPixelBlue ( q , quantum == 0 ? 0 : QuantumRange ) ;
if ( image -> storage_class == PseudoClass ) SetPixelIndex ( indexes + x + bit , quantum ) ;
}
p ++ ;
}
if ( ( image -> columns % 8 ) != 0 ) {
for ( bit = 0 ;
bit < ( int ) ( image -> columns % 8 ) ;
bit ++ ) {
quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ;
SetPixelRed ( q , quantum == 0 ? 0 : QuantumRange ) ;
SetPixelGreen ( q , quantum == 0 ? 0 : QuantumRange ) ;
SetPixelBlue ( q , quantum == 0 ? 0 : QuantumRange ) ;
if ( image -> storage_class == PseudoClass ) SetPixelIndex ( indexes + x + bit , quantum ) ;
}
p ++ ;
}
if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ;
if ( image -> previous == ( Image * ) NULL ) {
status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ;
if ( status == MagickFalse ) break ;
}
}
}
else if ( image -> storage_class == PseudoClass ) for ( y = 0 ;
y < ( ssize_t ) image -> rows ;
y ++ ) {
q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ;
if ( q == ( PixelPacket * ) NULL ) break ;
indexes = GetAuthenticIndexQueue ( image ) ;
for ( x = 0 ;
x < ( ssize_t ) image -> columns ;
x ++ ) SetPixelIndex ( indexes + x , * p ++ ) ;
if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ;
if ( image -> previous == ( Image * ) NULL ) {
status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ;
if ( status == MagickFalse ) break ;
}
}
else {
number_pixels = ( MagickSizeType ) image -> columns * image -> rows ;
for ( y = 0 ;
y < ( ssize_t ) image -> rows ;
y ++ ) {
q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ;
if ( q == ( PixelPacket * ) NULL ) break ;
for ( x = 0 ;
x < ( ssize_t ) image -> columns ;
x ++ ) {
SetPixelRed ( q , ScaleCharToQuantum ( * p ) ) ;
SetPixelGreen ( q , ScaleCharToQuantum ( * ( p + number_pixels ) ) ) ;
SetPixelBlue ( q , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) ) ;
if ( image -> colors != 0 ) {
ssize_t index ;
index = ( ssize_t ) GetPixelRed ( q ) ;
SetPixelRed ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . red ) ;
index = ( ssize_t ) GetPixelGreen ( q ) ;
SetPixelGreen ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . green ) ;
index = ( ssize_t ) GetPixelRed ( q ) ;
SetPixelBlue ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . blue ) ;
}
SetPixelOpacity ( q , image -> matte != MagickFalse ? QuantumRange - ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueOpacity ) ;
p ++ ;
q ++ ;
}
if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ;
if ( image -> previous == ( Image * ) NULL ) {
status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ;
if ( status == MagickFalse ) break ;
}
}
}
pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ;
if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image ) ;
if ( EOFBlob ( image ) != MagickFalse ) {
ThrowFileException ( exception , CorruptImageError , "UnexpectedEndOfFile" , image -> filename ) ;
break ;
}
if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ;
count = ReadBlob ( image , 1 , & viff_info . identifier ) ;
if ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) {
AcquireNextImage ( image_info , image ) ;
if ( GetNextImageInList ( image ) == ( Image * ) NULL ) {
image = DestroyImageList ( image ) ;
return ( ( Image * ) NULL ) ;
}
image = SyncNextImageInList ( image ) ;
status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ;
if ( status == MagickFalse ) break ;
}
}
while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ;
( void ) CloseBlob ( image ) ;
return ( GetFirstImageInList ( image ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void make_bands ( int16_t * bands , int start , int stop , int num_bands ) {
int k , previous , present ;
float base , prod ;
base = powf ( ( float ) stop / start , 1.0f / num_bands ) ;
prod = start ;
previous = start ;
for ( k = 0 ;
k < num_bands - 1 ;
k ++ ) {
prod *= base ;
present = lrintf ( prod ) ;
bands [ k ] = present - previous ;
previous = present ;
}
bands [ num_bands - 1 ] = stop - previous ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int row_compare ( zval * object1 , zval * object2 TSRMLS_DC ) {
return - 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int qemuMonitorTextScreendump ( qemuMonitorPtr mon , const char * file ) {
char * cmd = NULL ;
char * reply = NULL ;
int ret = - 1 ;
if ( virAsprintf ( & cmd , "screendump %s" , file ) < 0 ) {
virReportOOMError ( ) ;
goto cleanup ;
}
if ( qemuMonitorHMPCommand ( mon , cmd , & reply ) < 0 ) {
qemuReportError ( VIR_ERR_OPERATION_FAILED , "%s" , _ ( "taking screenshot failed" ) ) ;
goto cleanup ;
}
if ( strstr ( reply , "unknown command:" ) ) {
ret = - 2 ;
goto cleanup ;
}
ret = 0 ;
cleanup : VIR_FREE ( reply ) ;
VIR_FREE ( cmd ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int selinux_kernel_module_from_file ( struct file * file ) {
struct common_audit_data ad ;
struct inode_security_struct * isec ;
struct file_security_struct * fsec ;
u32 sid = current_sid ( ) ;
int rc ;
if ( file == NULL ) return avc_has_perm ( sid , sid , SECCLASS_SYSTEM , SYSTEM__MODULE_LOAD , NULL ) ;
ad . type = LSM_AUDIT_DATA_FILE ;
ad . u . file = file ;
fsec = file -> f_security ;
if ( sid != fsec -> sid ) {
rc = avc_has_perm ( sid , fsec -> sid , SECCLASS_FD , FD__USE , & ad ) ;
if ( rc ) return rc ;
}
isec = inode_security ( file_inode ( file ) ) ;
return avc_has_perm ( sid , isec -> sid , SECCLASS_SYSTEM , SYSTEM__MODULE_LOAD , & ad ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void vp9_iwht4x4_16_add_c ( const int16_t * input , uint8_t * dest , int stride ) {
int i ;
int16_t output [ 16 ] ;
int a1 , b1 , c1 , d1 , e1 ;
const int16_t * ip = input ;
int16_t * op = output ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
a1 = ip [ 0 ] >> UNIT_QUANT_SHIFT ;
c1 = ip [ 1 ] >> UNIT_QUANT_SHIFT ;
d1 = ip [ 2 ] >> UNIT_QUANT_SHIFT ;
b1 = ip [ 3 ] >> UNIT_QUANT_SHIFT ;
a1 += c1 ;
d1 -= b1 ;
e1 = ( a1 - d1 ) >> 1 ;
b1 = e1 - b1 ;
c1 = e1 - c1 ;
a1 -= b1 ;
d1 += c1 ;
op [ 0 ] = a1 ;
op [ 1 ] = b1 ;
op [ 2 ] = c1 ;
op [ 3 ] = d1 ;
ip += 4 ;
op += 4 ;
}
ip = output ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
a1 = ip [ 4 * 0 ] ;
c1 = ip [ 4 * 1 ] ;
d1 = ip [ 4 * 2 ] ;
b1 = ip [ 4 * 3 ] ;
a1 += c1 ;
d1 -= b1 ;
e1 = ( a1 - d1 ) >> 1 ;
b1 = e1 - b1 ;
c1 = e1 - c1 ;
a1 -= b1 ;
d1 += c1 ;
dest [ stride * 0 ] = clip_pixel ( dest [ stride * 0 ] + a1 ) ;
dest [ stride * 1 ] = clip_pixel ( dest [ stride * 1 ] + b1 ) ;
dest [ stride * 2 ] = clip_pixel ( dest [ stride * 2 ] + c1 ) ;
dest [ stride * 3 ] = clip_pixel ( dest [ stride * 3 ] + d1 ) ;
ip ++ ;
dest ++ ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void rv40_parse_picture_size ( GetBitContext * gb , int * w , int * h ) {
* w = get_dimension ( gb , rv40_standard_widths ) ;
* h = get_dimension ( gb , rv40_standard_heights ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void nautilus_directory_call_when_ready_internal ( NautilusDirectory * directory , NautilusFile * file , NautilusFileAttributes file_attributes , gboolean wait_for_file_list , NautilusDirectoryCallback directory_callback , NautilusFileCallback file_callback , gpointer callback_data ) {
ReadyCallback callback ;
g_assert ( directory == NULL || NAUTILUS_IS_DIRECTORY ( directory ) ) ;
g_assert ( file == NULL || NAUTILUS_IS_FILE ( file ) ) ;
g_assert ( file != NULL || directory_callback != NULL ) ;
callback . active = TRUE ;
callback . file = file ;
if ( file == NULL ) {
callback . callback . directory = directory_callback ;
}
else {
callback . callback . file = file_callback ;
}
callback . callback_data = callback_data ;
callback . request = nautilus_directory_set_up_request ( file_attributes ) ;
if ( wait_for_file_list ) {
REQUEST_SET_TYPE ( callback . request , REQUEST_FILE_LIST ) ;
}
if ( directory == NULL ) {
ready_callback_call ( NULL , & callback ) ;
return ;
}
if ( g_list_find_custom ( directory -> details -> call_when_ready_list , & callback , ready_callback_key_compare_only_active ) != NULL ) {
if ( file_callback != NULL && directory_callback != NULL ) {
g_warning ( "tried to add a new callback while an old one was pending" ) ;
}
return ;
}
directory -> details -> call_when_ready_list = g_list_prepend ( directory -> details -> call_when_ready_list , g_memdup ( & callback , sizeof ( callback ) ) ) ;
request_counter_add_request ( directory -> details -> call_when_ready_counters , callback . request ) ;
if ( file != NULL ) {
nautilus_directory_add_file_to_work_queue ( directory , file ) ;
}
else {
add_all_files_to_work_queue ( directory ) ;
}
nautilus_directory_async_state_changed ( directory ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int tm_obit ( tm_task_id tid , int * obitval , tm_event_t * event ) {
int rc = TM_SUCCESS ;
task_info * tp ;
struct tcp_chan * chan = NULL ;
if ( ! init_done ) {
rc = TM_BADINIT ;
goto tm_obit_cleanup ;
}
if ( ( tp = find_task ( tid ) ) == NULL ) {
rc = TM_ENOTFOUND ;
goto tm_obit_cleanup ;
}
* event = new_event ( ) ;
if ( startcom ( TM_OBIT , * event , & chan ) != DIS_SUCCESS ) {
rc = TM_ESYSTEM ;
goto tm_obit_cleanup ;
}
if ( diswsi ( chan , tp -> t_node ) != DIS_SUCCESS ) {
rc = TM_ESYSTEM ;
goto tm_obit_cleanup ;
}
if ( diswsi ( chan , tid ) != DIS_SUCCESS ) {
rc = TM_ESYSTEM ;
goto tm_obit_cleanup ;
}
DIS_tcp_wflush ( chan ) ;
add_event ( * event , tp -> t_node , TM_OBIT , ( void * ) obitval ) ;
tm_obit_cleanup : if ( chan != NULL ) DIS_tcp_cleanup ( chan ) ;
return rc ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void x8_update_predictions ( IntraX8Context * const w , const int orient , const int est_run ) {
MpegEncContext * const s = w -> s ;
w -> prediction_table [ s -> mb_x * 2 + ( s -> mb_y & 1 ) ] = ( est_run << 2 ) + 1 * ( orient == 4 ) + 2 * ( orient == 8 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int lxc_cgroup_create_legacy ( struct cgroup_process_info * base_info , const char * name , pid_t pid ) {
struct cgroup_process_info * info_ptr ;
int r ;
for ( info_ptr = base_info ;
info_ptr ;
info_ptr = info_ptr -> next ) {
if ( ! lxc_string_in_array ( "ns" , ( const char * * ) info_ptr -> hierarchy -> subsystems ) ) continue ;
char * tmp = cgroup_rename_nsgroup ( ( const char * ) info_ptr -> designated_mount_point -> mount_point , info_ptr -> cgroup_path , pid , name ) ;
if ( ! tmp ) return - 1 ;
free ( info_ptr -> cgroup_path ) ;
info_ptr -> cgroup_path = tmp ;
r = lxc_grow_array ( ( void * * * ) & info_ptr -> created_paths , & info_ptr -> created_paths_capacity , info_ptr -> created_paths_count + 1 , 8 ) ;
if ( r < 0 ) return - 1 ;
tmp = strdup ( tmp ) ;
if ( ! tmp ) return - 1 ;
info_ptr -> created_paths [ info_ptr -> created_paths_count ++ ] = tmp ;
}
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void e1000e_set_rfctl ( E1000ECore * core , int index , uint32_t val ) {
trace_e1000e_rx_set_rfctl ( val ) ;
if ( ! ( val & E1000_RFCTL_ISCSI_DIS ) ) {
trace_e1000e_wrn_iscsi_filtering_not_supported ( ) ;
}
if ( ! ( val & E1000_RFCTL_NFSW_DIS ) ) {
trace_e1000e_wrn_nfsw_filtering_not_supported ( ) ;
}
if ( ! ( val & E1000_RFCTL_NFSR_DIS ) ) {
trace_e1000e_wrn_nfsr_filtering_not_supported ( ) ;
}
core -> mac [ RFCTL ] = val ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int cinaudio_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
AVFrame * frame = data ;
const uint8_t * buf = avpkt -> data ;
CinAudioContext * cin = avctx -> priv_data ;
const uint8_t * buf_end = buf + avpkt -> size ;
int16_t * samples ;
int delta , ret ;
frame -> nb_samples = avpkt -> size - cin -> initial_decode_frame ;
if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
samples = ( int16_t * ) frame -> data [ 0 ] ;
delta = cin -> delta ;
if ( cin -> initial_decode_frame ) {
cin -> initial_decode_frame = 0 ;
delta = sign_extend ( AV_RL16 ( buf ) , 16 ) ;
buf += 2 ;
* samples ++ = delta ;
}
while ( buf < buf_end ) {
delta += cinaudio_delta16_table [ * buf ++ ] ;
delta = av_clip_int16 ( delta ) ;
* samples ++ = delta ;
}
cin -> delta = delta ;
* got_frame_ptr = 1 ;
return avpkt -> size ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
bool cephx_build_service_ticket_blob ( CephContext * cct , CephXSessionAuthInfo & info , CephXTicketBlob & blob ) {
CephXServiceTicketInfo ticket_info ;
ticket_info . session_key = info . session_key ;
ticket_info . ticket = info . ticket ;
ticket_info . ticket . caps = info . ticket . caps ;
ldout ( cct , 10 ) << "build_service_ticket service " << ceph_entity_type_name ( info . service_id ) << " secret_id " << info . secret_id << " ticket_info.ticket.name=" << ticket_info . ticket . name . to_str ( ) << dendl ;
blob . secret_id = info . secret_id ;
std : : string error ;
if ( ! info . service_secret . get_secret ( ) . length ( ) ) error = "invalid key" ;
else encode_encrypt_enc_bl ( cct , ticket_info , info . service_secret , blob . blob , error ) ;
if ( ! error . empty ( ) ) {
ldout ( cct , - 1 ) << "cephx_build_service_ticket_blob failed with error " << error << dendl ;
return false ;
}
return true ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_rtmpt_tcp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) {
conversation_t * conv ;
rtmpt_conv_t * rconv ;
int cdir ;
struct tcpinfo * tcpinfo ;
if ( data == NULL ) {
return 0 ;
}
tcpinfo = ( struct tcpinfo * ) data ;
conv = find_or_create_conversation ( pinfo ) ;
rconv = ( rtmpt_conv_t * ) conversation_get_proto_data ( conv , proto_rtmpt ) ;
if ( ! rconv ) {
rconv = rtmpt_init_rconv ( conv ) ;
}
cdir = ( addresses_equal ( & conv -> key_ptr -> addr1 , & pinfo -> src ) && addresses_equal ( & conv -> key_ptr -> addr2 , & pinfo -> dst ) && conv -> key_ptr -> port1 == pinfo -> srcport && conv -> key_ptr -> port2 == pinfo -> destport ) ? 0 : 1 ;
dissect_rtmpt_common ( tvb , pinfo , tree , rconv , cdir , tcpinfo -> seq , tcpinfo -> lastackseq ) ;
return tvb_reported_length ( tvb ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int init_dumping ( char * database , int init_func ( char * ) ) {
if ( mysql_select_db ( mysql , database ) ) {
DB_error ( mysql , "when selecting the database" ) ;
return 1 ;
}
if ( ! path && ! opt_xml ) {
if ( opt_databases || opt_alldbs ) {
char quoted_database_buf [ NAME_LEN * 2 + 3 ] ;
char * qdatabase = quote_name ( database , quoted_database_buf , opt_quoted ) ;
print_comment ( md_result_file , 0 , "\n--\n-- Current Database: %s\n--\n" , fix_for_comment ( qdatabase ) ) ;
init_func ( qdatabase ) ;
fprintf ( md_result_file , "\nUSE %s;
\n" , qdatabase ) ;
check_io ( md_result_file ) ;
}
}
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void backward_filter ( RA288Context * ractx , float * hist , float * rec , const float * window , float * lpc , const float * tab , int order , int n , int non_rec , int move_size ) {
float temp [ MAX_BACKWARD_FILTER_ORDER + 1 ] ;
do_hybrid_window ( ractx , order , n , non_rec , temp , hist , rec , window ) ;
if ( ! compute_lpc_coefs ( temp , order , lpc , 0 , 1 , 1 ) ) ractx -> fdsp . vector_fmul ( lpc , lpc , tab , FFALIGN ( order , 16 ) ) ;
memmove ( hist , hist + n , move_size * sizeof ( * hist ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline void qemu_get_be32s ( QEMUFile * f , uint32_t * pv ) {
* pv = qemu_get_be32 ( f ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
proto_item * parseByte ( proto_tree * tree , tvbuff_t * tvb , packet_info * pinfo _U_ , gint * pOffset , int hfIndex ) {
proto_item * item = proto_tree_add_item ( tree , hfIndex , tvb , * pOffset , 1 , ENC_LITTLE_ENDIAN ) ;
* pOffset += 1 ;
return item ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int test_small_prime ( BIO * bp , BN_CTX * ctx ) {
static const int bits = 10 ;
int ret = 0 ;
BIGNUM r ;
BN_init ( & r ) ;
if ( ! BN_generate_prime_ex ( & r , bits , 0 , NULL , NULL , NULL ) ) goto err ;
if ( BN_num_bits ( & r ) != bits ) {
BIO_printf ( bp , "Expected %d bit prime, got %d bit number\n" , bits , BN_num_bits ( & r ) ) ;
goto err ;
}
ret = 1 ;
err : BN_clear ( & r ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void dissect_q931_user_user_ie ( tvbuff_t * tvb , packet_info * pinfo , int offset , int len , proto_tree * tree ) {
guint8 octet ;
tvbuff_t * next_tvb = NULL ;
heur_dtbl_entry_t * hdtbl_entry ;
if ( len == 0 ) return ;
octet = tvb_get_guint8 ( tvb , offset ) ;
proto_tree_add_item ( tree , hf_q931_user_protocol_discriminator , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset += 1 ;
len -= 1 ;
if ( len == 0 ) return ;
switch ( octet ) {
case Q931_PROTOCOL_DISCRIMINATOR_USER : next_tvb = tvb_new_subset_length ( tvb , offset , len ) ;
proto_tree_add_uint_format_value ( tree , hf_q931_user_information_len , tvb , offset , len , len , "%d octets" , len ) ;
if ( ! dissector_try_heuristic ( q931_user_heur_subdissector_list , next_tvb , pinfo , tree , & hdtbl_entry , NULL ) ) {
call_data_dissector ( next_tvb , pinfo , tree ) ;
}
break ;
case Q931_PROTOCOL_DISCRIMINATOR_IA5 : proto_tree_add_item ( tree , hf_q931_user_information_str , tvb , offset , len , ENC_NA | ENC_ASCII ) ;
break ;
default : proto_tree_add_item ( tree , hf_q931_user_information_bytes , tvb , offset , len , ENC_NA ) ;
break ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int vvalue_tvb_get4 ( tvbuff_t * tvb , int offset , void * val ) {
guint32 * ui4 = ( guint32 * ) val ;
* ui4 = tvb_get_letohl ( tvb , offset ) ;
return 4 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static float stability_factor ( const float * isf , const float * isf_past ) {
int i ;
float acc = 0.0 ;
for ( i = 0 ;
i < LP_ORDER - 1 ;
i ++ ) acc += ( isf [ i ] - isf_past [ i ] ) * ( isf [ i ] - isf_past [ i ] ) ;
return FFMAX ( 0.0 , 1.25 - acc * 0.8 * 512 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_usb_video_format ( proto_tree * tree , tvbuff_t * tvb , int offset , guint8 subtype ) {
static const int * interlace_bits [ ] = {
& hf_usb_vid_is_interlaced , & hf_usb_vid_interlaced_fields , & hf_usb_vid_field_1_first , & hf_usb_vid_field_pattern , NULL }
;
proto_item * desc_item ;
guint8 format_index ;
format_index = tvb_get_guint8 ( tvb , offset ) ;
desc_item = proto_tree_get_parent ( tree ) ;
proto_item_append_text ( desc_item , " (Format %u)" , format_index ) ;
proto_tree_add_item ( tree , hf_usb_vid_format_index , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_usb_vid_format_num_frame_descriptors , tvb , offset + 1 , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 2 ;
if ( ( subtype == VS_FORMAT_UNCOMPRESSED ) || ( subtype == VS_FORMAT_FRAME_BASED ) ) {
char fourcc [ 5 ] ;
tvb_memcpy ( tvb , ( guint8 * ) fourcc , offset , 4 ) ;
fourcc [ 4 ] = '\0' ;
proto_item_append_text ( desc_item , ": %s" , fourcc ) ;
proto_tree_add_item ( tree , hf_usb_vid_format_guid , tvb , offset , 16 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_usb_vid_format_bits_per_pixel , tvb , offset + 16 , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 17 ;
}
else if ( subtype == VS_FORMAT_MJPEG ) {
static const int * flags [ ] = {
& hf_usb_vid_mjpeg_fixed_samples , NULL }
;
proto_tree_add_bitmask ( tree , tvb , offset , hf_usb_vid_mjpeg_flags , ett_mjpeg_flags , flags , ENC_NA ) ;
offset ++ ;
}
else {
DISSECTOR_ASSERT_NOT_REACHED ( ) ;
}
proto_tree_add_item ( tree , hf_usb_vid_default_frame_index , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_usb_vid_aspect_ratio_x , tvb , offset + 1 , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_usb_vid_aspect_ratio_y , tvb , offset + 2 , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
# if 0 if ( something ) proto_tree_add_uint_format_value ( tree , hf_usb_vid_interlace_flags , tvb , offset , 1 , tvb_get_guint8 ( tvb , offset ) , "Not applicable" ) ;
# endif proto_tree_add_bitmask ( tree , tvb , offset , hf_usb_vid_interlace_flags , ett_interlace_flags , interlace_bits , ENC_NA ) ;
offset ++ ;
proto_tree_add_item ( tree , hf_usb_vid_copy_protect , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
offset ++ ;
if ( subtype == VS_FORMAT_FRAME_BASED ) {
proto_tree_add_item ( tree , hf_usb_vid_variable_size , tvb , offset , 1 , ENC_NA ) ;
offset ++ ;
}
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void parse_cat_blob ( const char * p ) {
struct object_entry * oe = oe ;
unsigned char sha1 [ 20 ] ;
if ( * p == ':' ) {
oe = find_mark ( parse_mark_ref_eol ( p ) ) ;
if ( ! oe ) die ( "Unknown mark: %s" , command_buf . buf ) ;
hashcpy ( sha1 , oe -> idx . sha1 ) ;
}
else {
if ( get_sha1_hex ( p , sha1 ) ) die ( "Invalid dataref: %s" , command_buf . buf ) ;
if ( p [ 40 ] ) die ( "Garbage after SHA1: %s" , command_buf . buf ) ;
oe = find_object ( sha1 ) ;
}
cat_blob ( oe , sha1 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void print_error ( FILE * where , char * fmt , ... ) {
char temp [ 10000 ] ;
va_list ap ;
va_start ( ap , fmt ) ;
{
vsnprintf ( temp , 9998 , fmt , ap ) ;
}
va_end ( ap ) ;
syslog ( LOG_INFO , temp ) ;
if ( where != NULL ) fprintf ( where , "Das_Watchdog: %s\n" , temp ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
char * PyString_AsString ( register PyObject * op ) {
if ( ! PyString_Check ( op ) ) return string_getbuffer ( op ) ;
return ( ( PyStringObject * ) op ) -> ob_sval ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
PHP_FUNCTION ( locale_get_display_name ) {
get_icu_disp_value_src_php ( DISP_NAME , INTERNAL_FUNCTION_PARAM_PASSTHRU ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void dtls1_clear_record_buffer ( SSL * s ) {
pitem * item ;
for ( item = pqueue_pop ( s -> d1 -> sent_messages ) ;
item != NULL ;
item = pqueue_pop ( s -> d1 -> sent_messages ) ) {
dtls1_hm_fragment_free ( ( hm_fragment * ) item -> data ) ;
pitem_free ( item ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int file_to_archive ( struct cpio * cpio , const char * srcpath ) {
const char * destpath ;
struct archive_entry * entry , * spare ;
size_t len ;
int r ;
entry = archive_entry_new ( ) ;
if ( entry == NULL ) lafe_errc ( 1 , 0 , "Couldn't allocate entry" ) ;
archive_entry_copy_sourcepath ( entry , srcpath ) ;
r = archive_read_disk_entry_from_file ( cpio -> archive_read_disk , entry , - 1 , NULL ) ;
if ( r < ARCHIVE_FAILED ) lafe_errc ( 1 , 0 , "%s" , archive_error_string ( cpio -> archive_read_disk ) ) ;
if ( r < ARCHIVE_OK ) lafe_warnc ( 0 , "%s" , archive_error_string ( cpio -> archive_read_disk ) ) ;
if ( r <= ARCHIVE_FAILED ) {
cpio -> return_value = 1 ;
return ( r ) ;
}
if ( cpio -> uid_override >= 0 ) {
archive_entry_set_uid ( entry , cpio -> uid_override ) ;
archive_entry_set_uname ( entry , cpio -> uname_override ) ;
}
if ( cpio -> gid_override >= 0 ) {
archive_entry_set_gid ( entry , cpio -> gid_override ) ;
archive_entry_set_gname ( entry , cpio -> gname_override ) ;
}
destpath = srcpath ;
if ( cpio -> destdir ) {
len = strlen ( cpio -> destdir ) + strlen ( srcpath ) + 8 ;
if ( len >= cpio -> pass_destpath_alloc ) {
while ( len >= cpio -> pass_destpath_alloc ) {
cpio -> pass_destpath_alloc += 512 ;
cpio -> pass_destpath_alloc *= 2 ;
}
free ( cpio -> pass_destpath ) ;
cpio -> pass_destpath = malloc ( cpio -> pass_destpath_alloc ) ;
if ( cpio -> pass_destpath == NULL ) lafe_errc ( 1 , ENOMEM , "Can't allocate path buffer" ) ;
}
strcpy ( cpio -> pass_destpath , cpio -> destdir ) ;
strcat ( cpio -> pass_destpath , remove_leading_slash ( srcpath ) ) ;
destpath = cpio -> pass_destpath ;
}
if ( cpio -> option_rename ) destpath = cpio_rename ( destpath ) ;
if ( destpath == NULL ) return ( 0 ) ;
archive_entry_copy_pathname ( entry , destpath ) ;
spare = NULL ;
if ( cpio -> linkresolver != NULL && archive_entry_filetype ( entry ) != AE_IFDIR ) {
archive_entry_linkify ( cpio -> linkresolver , & entry , & spare ) ;
}
if ( entry != NULL ) {
r = entry_to_archive ( cpio , entry ) ;
archive_entry_free ( entry ) ;
if ( spare != NULL ) {
if ( r == 0 ) r = entry_to_archive ( cpio , spare ) ;
archive_entry_free ( spare ) ;
}
}
return ( r ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void ps2_write_mouse ( void * opaque , int val ) {
PS2MouseState * s = ( PS2MouseState * ) opaque ;
trace_ps2_write_mouse ( opaque , val ) ;
# ifdef DEBUG_MOUSE printf ( "kbd: write mouse 0x%02x\n" , val ) ;
# endif switch ( s -> common . write_cmd ) {
default : case - 1 : if ( s -> mouse_wrap ) {
if ( val == AUX_RESET_WRAP ) {
s -> mouse_wrap = 0 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
return ;
}
else if ( val != AUX_RESET ) {
ps2_queue ( & s -> common , val ) ;
return ;
}
}
switch ( val ) {
case AUX_SET_SCALE11 : s -> mouse_status &= ~ MOUSE_STATUS_SCALE21 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_SET_SCALE21 : s -> mouse_status |= MOUSE_STATUS_SCALE21 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_SET_STREAM : s -> mouse_status &= ~ MOUSE_STATUS_REMOTE ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_SET_WRAP : s -> mouse_wrap = 1 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_SET_REMOTE : s -> mouse_status |= MOUSE_STATUS_REMOTE ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_GET_TYPE : ps2_queue ( & s -> common , AUX_ACK ) ;
ps2_queue ( & s -> common , s -> mouse_type ) ;
break ;
case AUX_SET_RES : case AUX_SET_SAMPLE : s -> common . write_cmd = val ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_GET_SCALE : ps2_queue ( & s -> common , AUX_ACK ) ;
ps2_queue ( & s -> common , s -> mouse_status ) ;
ps2_queue ( & s -> common , s -> mouse_resolution ) ;
ps2_queue ( & s -> common , s -> mouse_sample_rate ) ;
break ;
case AUX_POLL : ps2_queue ( & s -> common , AUX_ACK ) ;
ps2_mouse_send_packet ( s ) ;
break ;
case AUX_ENABLE_DEV : s -> mouse_status |= MOUSE_STATUS_ENABLED ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_DISABLE_DEV : s -> mouse_status &= ~ MOUSE_STATUS_ENABLED ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_SET_DEFAULT : s -> mouse_sample_rate = 100 ;
s -> mouse_resolution = 2 ;
s -> mouse_status = 0 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
break ;
case AUX_RESET : s -> mouse_sample_rate = 100 ;
s -> mouse_resolution = 2 ;
s -> mouse_status = 0 ;
s -> mouse_type = 0 ;
ps2_queue ( & s -> common , AUX_ACK ) ;
ps2_queue ( & s -> common , 0xaa ) ;
ps2_queue ( & s -> common , s -> mouse_type ) ;
break ;
default : break ;
}
break ;
case AUX_SET_SAMPLE : s -> mouse_sample_rate = val ;
switch ( s -> mouse_detect_state ) {
default : case 0 : if ( val == 200 ) s -> mouse_detect_state = 1 ;
break ;
case 1 : if ( val == 100 ) s -> mouse_detect_state = 2 ;
else if ( val == 200 ) s -> mouse_detect_state = 3 ;
else s -> mouse_detect_state = 0 ;
break ;
case 2 : if ( val == 80 ) s -> mouse_type = 3 ;
s -> mouse_detect_state = 0 ;
break ;
case 3 : if ( val == 80 ) s -> mouse_type = 4 ;
s -> mouse_detect_state = 0 ;
break ;
}
ps2_queue ( & s -> common , AUX_ACK ) ;
s -> common . write_cmd = - 1 ;
break ;
case AUX_SET_RES : s -> mouse_resolution = val ;
ps2_queue ( & s -> common , AUX_ACK ) ;
s -> common . write_cmd = - 1 ;
break ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void encode_frame_size ( VC2EncContext * s ) {
put_bits ( & s -> pb , 1 , ! s -> strict_compliance ) ;
if ( ! s -> strict_compliance ) {
AVCodecContext * avctx = s -> avctx ;
put_vc2_ue_uint ( & s -> pb , avctx -> width ) ;
put_vc2_ue_uint ( & s -> pb , avctx -> height ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int mainwindow_rshrink ( MAIN_WINDOW_REC * window , int count ) {
if ( MAIN_WINDOW_TEXT_WIDTH ( window ) - count < NEW_WINDOW_WIDTH ) return FALSE ;
if ( ! try_rgrow_right ( window , count ) ) {
if ( ! try_rgrow_left ( window , count ) ) return FALSE ;
}
return TRUE ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static value_string_ext * get_control_selector_values ( guint8 entity_id , usb_conv_info_t * usb_conv_info ) {
video_conv_info_t * video_conv_info ;
video_entity_t * entity = NULL ;
value_string_ext * selectors = NULL ;
if ( usb_conv_info == NULL ) return NULL ;
video_conv_info = ( video_conv_info_t * ) usb_conv_info -> class_data ;
if ( video_conv_info ) entity = ( video_entity_t * ) wmem_tree_lookup32 ( video_conv_info -> entities , entity_id ) ;
if ( entity_id == 0 ) {
switch ( usb_conv_info -> interfaceSubclass ) {
case SC_VIDEOCONTROL : selectors = & cs_control_interface_ext ;
break ;
case SC_VIDEOSTREAMING : selectors = & cs_streaming_interface_ext ;
break ;
default : break ;
}
}
else if ( entity ) {
switch ( entity -> subtype ) {
case VC_INPUT_TERMINAL : if ( entity -> terminalType == ITT_CAMERA ) {
selectors = & cs_camera_terminal_ext ;
}
break ;
case VC_PROCESSING_UNIT : selectors = & cs_processing_unit_ext ;
break ;
case VC_SELECTOR_UNIT : selectors = & cs_selector_unit_ext ;
break ;
default : break ;
}
}
return selectors ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_rsl_ie_uic ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
proto_tree * ie_tree ;
guint8 ie_id ;
if ( is_mandatory == FALSE ) {
ie_id = tvb_get_guint8 ( tvb , offset ) ;
if ( ie_id != RSL_IE_UIC ) return offset ;
}
ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_ie_uic , NULL , "UIC IE" ) ;
proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
proto_tree_add_item ( ie_tree , hf_rsl_uic , tvb , offset , 1 , ENC_NA ) ;
offset ++ ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int TSActionDone ( TSAction actionp ) {
return ( ( Action * ) actionp == ACTION_RESULT_DONE ) ? 1 : 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int mace_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
AVFrame * frame = data ;
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
int16_t * * samples ;
MACEContext * ctx = avctx -> priv_data ;
int i , j , k , l , ret ;
int is_mace3 = ( avctx -> codec_id == AV_CODEC_ID_MACE3 ) ;
frame -> nb_samples = 3 * ( buf_size << ( 1 - is_mace3 ) ) / avctx -> channels ;
if ( ( ret = ff_get_buffer ( avctx , frame ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
samples = ( int16_t * * ) frame -> extended_data ;
for ( i = 0 ;
i < avctx -> channels ;
i ++ ) {
int16_t * output = samples [ i ] ;
for ( j = 0 ;
j < buf_size / ( avctx -> channels << is_mace3 ) ;
j ++ ) for ( k = 0 ;
k < ( 1 << is_mace3 ) ;
k ++ ) {
uint8_t pkt = buf [ ( i << is_mace3 ) + ( j * avctx -> channels << is_mace3 ) + k ] ;
uint8_t val [ 2 ] [ 3 ] = {
{
pkt >> 5 , ( pkt >> 3 ) & 3 , pkt & 7 }
, {
pkt & 7 , ( pkt >> 3 ) & 3 , pkt >> 5 }
}
;
for ( l = 0 ;
l < 3 ;
l ++ ) {
if ( is_mace3 ) chomp3 ( & ctx -> chd [ i ] , output , val [ 1 ] [ l ] , l ) ;
else chomp6 ( & ctx -> chd [ i ] , output , val [ 0 ] [ l ] , l ) ;
output += 1 << ( 1 - is_mace3 ) ;
}
}
}
* got_frame_ptr = 1 ;
return buf_size ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int read_segment_id ( vp9_reader * r , const struct segmentation * seg ) {
return vp9_read_tree ( r , vp9_segment_tree , seg -> tree_probs ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void TSCacheHttpInfoRespGet ( TSCacheHttpInfo infop , TSMBuffer * bufp , TSMLoc * obj ) {
CacheHTTPInfo * info = ( CacheHTTPInfo * ) infop ;
* ( reinterpret_cast < HTTPHdr * * > ( bufp ) ) = info -> response_get ( ) ;
* obj = reinterpret_cast < TSMLoc > ( info -> response_get ( ) -> m_http ) ;
sdk_assert ( sdk_sanity_check_mbuffer ( * bufp ) == TS_SUCCESS ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static gboolean proto_item_add_bitmask_tree ( proto_item * item , tvbuff_t * tvb , const int offset , const int len , const gint ett , const int * * fields , const int flags , gboolean first , gboolean use_parent_tree , proto_tree * tree , guint64 value ) {
guint bitshift ;
guint64 available_bits = 0 ;
guint64 tmpval ;
header_field_info * hf ;
if ( len < 0 || len > 8 ) g_assert_not_reached ( ) ;
bitshift = ( 8 - ( guint ) len ) * 8 ;
available_bits = G_GUINT64_CONSTANT ( 0xFFFFFFFFFFFFFFFF ) >> bitshift ;
if ( use_parent_tree == FALSE ) tree = proto_item_add_subtree ( item , ett ) ;
while ( * fields ) {
guint64 present_bits ;
PROTO_REGISTRAR_GET_NTH ( * * fields , hf ) ;
DISSECTOR_ASSERT_HINT ( hf -> bitmask != 0 , hf -> abbrev ) ;
present_bits = available_bits & hf -> bitmask ;
if ( present_bits != hf -> bitmask ) {
fields ++ ;
continue ;
}
switch ( hf -> type ) {
case FT_INT8 : case FT_UINT8 : case FT_INT16 : case FT_UINT16 : case FT_INT24 : case FT_UINT24 : case FT_INT32 : case FT_UINT32 : proto_tree_add_uint ( tree , * * fields , tvb , offset , len , ( guint32 ) value ) ;
break ;
case FT_INT40 : case FT_UINT40 : case FT_INT48 : case FT_UINT48 : case FT_INT56 : case FT_UINT56 : case FT_INT64 : case FT_UINT64 : proto_tree_add_uint64 ( tree , * * fields , tvb , offset , len , value ) ;
break ;
case FT_BOOLEAN : proto_tree_add_boolean64 ( tree , * * fields , tvb , offset , len , value ) ;
break ;
default : DISSECTOR_ASSERT_NOT_REACHED ( ) ;
break ;
}
if ( flags & BMT_NO_APPEND ) {
fields ++ ;
continue ;
}
tmpval = ( value & hf -> bitmask ) >> hfinfo_bitshift ( hf ) ;
switch ( hf -> type ) {
case FT_INT8 : case FT_UINT8 : case FT_INT16 : case FT_UINT16 : case FT_INT24 : case FT_UINT24 : case FT_INT32 : case FT_UINT32 : case FT_INT40 : case FT_UINT40 : case FT_INT48 : case FT_UINT48 : case FT_INT56 : case FT_UINT56 : case FT_INT64 : case FT_UINT64 : if ( hf -> display == BASE_CUSTOM ) {
gchar lbl [ ITEM_LABEL_LENGTH ] ;
const custom_fmt_func_t fmtfunc = ( const custom_fmt_func_t ) hf -> strings ;
DISSECTOR_ASSERT ( fmtfunc ) ;
fmtfunc ( lbl , ( guint32 ) tmpval ) ;
proto_item_append_text ( item , "%s%s: %s" , first ? "" : ", " , hf -> name , lbl ) ;
first = FALSE ;
}
else if ( hf -> strings ) {
proto_item_append_text ( item , "%s%s: %s" , first ? "" : ", " , hf -> name , hf_try_val_to_str_const ( ( guint32 ) tmpval , hf , "Unknown" ) ) ;
first = FALSE ;
}
else if ( ! ( flags & BMT_NO_INT ) ) {
char buf [ 32 ] ;
const char * out ;
if ( ! first ) {
proto_item_append_text ( item , ", " ) ;
}
out = hfinfo_number_value_format ( hf , buf , ( guint32 ) tmpval ) ;
proto_item_append_text ( item , "%s: %s" , hf -> name , out ) ;
first = FALSE ;
}
break ;
case FT_BOOLEAN : if ( hf -> strings && ! ( flags & BMT_NO_TFS ) ) {
const struct true_false_string * tfs = ( const struct true_false_string * ) hf -> strings ;
if ( tmpval ) {
proto_item_append_text ( item , "%s%s: %s" , first ? "" : ", " , hf -> name , tfs -> true_string ) ;
first = FALSE ;
}
else if ( ! ( flags & BMT_NO_FALSE ) ) {
proto_item_append_text ( item , "%s%s: %s" , first ? "" : ", " , hf -> name , tfs -> false_string ) ;
first = FALSE ;
}
}
else if ( hf -> bitmask & value ) {
proto_item_append_text ( item , "%s%s" , first ? "" : ", " , hf -> name ) ;
first = FALSE ;
}
break ;
default : DISSECTOR_ASSERT_NOT_REACHED ( ) ;
break ;
}
fields ++ ;
}
return first ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void pdf_run_CS ( fz_context * ctx , pdf_processor * proc , const char * name , fz_colorspace * colorspace ) {
pdf_run_processor * pr = ( pdf_run_processor * ) proc ;
pr -> dev -> flags &= ~ FZ_DEVFLAG_STROKECOLOR_UNDEFINED ;
if ( ! strcmp ( name , "Pattern" ) ) pdf_set_pattern ( ctx , pr , PDF_STROKE , NULL , NULL ) ;
else pdf_set_colorspace ( ctx , pr , PDF_STROKE , colorspace ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_q931 ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ ) {
dissect_q931_pdu ( tvb , pinfo , tree , FALSE ) ;
return tvb_captured_length ( tvb ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void stream_blob ( uintmax_t len , unsigned char * sha1out , uintmax_t mark ) {
size_t in_sz = 64 * 1024 , out_sz = 64 * 1024 ;
unsigned char * in_buf = xmalloc ( in_sz ) ;
unsigned char * out_buf = xmalloc ( out_sz ) ;
struct object_entry * e ;
unsigned char sha1 [ 20 ] ;
unsigned long hdrlen ;
off_t offset ;
git_SHA_CTX c ;
git_zstream s ;
struct sha1file_checkpoint checkpoint ;
int status = Z_OK ;
if ( ( max_packsize && ( pack_size + 60 + len ) > max_packsize ) || ( pack_size + 60 + len ) < pack_size ) cycle_packfile ( ) ;
sha1file_checkpoint ( pack_file , & checkpoint ) ;
offset = checkpoint . offset ;
hdrlen = snprintf ( ( char * ) out_buf , out_sz , "blob %" PRIuMAX , len ) + 1 ;
if ( out_sz <= hdrlen ) die ( "impossibly large object header" ) ;
git_SHA1_Init ( & c ) ;
git_SHA1_Update ( & c , out_buf , hdrlen ) ;
crc32_begin ( pack_file ) ;
git_deflate_init ( & s , pack_compression_level ) ;
hdrlen = encode_in_pack_object_header ( OBJ_BLOB , len , out_buf ) ;
if ( out_sz <= hdrlen ) die ( "impossibly large object header" ) ;
s . next_out = out_buf + hdrlen ;
s . avail_out = out_sz - hdrlen ;
while ( status != Z_STREAM_END ) {
if ( 0 < len && ! s . avail_in ) {
size_t cnt = in_sz < len ? in_sz : ( size_t ) len ;
size_t n = fread ( in_buf , 1 , cnt , stdin ) ;
if ( ! n && feof ( stdin ) ) die ( "EOF in data (%" PRIuMAX " bytes remaining)" , len ) ;
git_SHA1_Update ( & c , in_buf , n ) ;
s . next_in = in_buf ;
s . avail_in = n ;
len -= n ;
}
status = git_deflate ( & s , len ? 0 : Z_FINISH ) ;
if ( ! s . avail_out || status == Z_STREAM_END ) {
size_t n = s . next_out - out_buf ;
sha1write ( pack_file , out_buf , n ) ;
pack_size += n ;
s . next_out = out_buf ;
s . avail_out = out_sz ;
}
switch ( status ) {
case Z_OK : case Z_BUF_ERROR : case Z_STREAM_END : continue ;
default : die ( "unexpected deflate failure: %d" , status ) ;
}
}
git_deflate_end ( & s ) ;
git_SHA1_Final ( sha1 , & c ) ;
if ( sha1out ) hashcpy ( sha1out , sha1 ) ;
e = insert_object ( sha1 ) ;
if ( mark ) insert_mark ( mark , e ) ;
if ( e -> idx . offset ) {
duplicate_count_by_type [ OBJ_BLOB ] ++ ;
truncate_pack ( & checkpoint ) ;
}
else if ( find_sha1_pack ( sha1 , packed_git ) ) {
e -> type = OBJ_BLOB ;
e -> pack_id = MAX_PACK_ID ;
e -> idx . offset = 1 ;
duplicate_count_by_type [ OBJ_BLOB ] ++ ;
truncate_pack ( & checkpoint ) ;
}
else {
e -> depth = 0 ;
e -> type = OBJ_BLOB ;
e -> pack_id = pack_id ;
e -> idx . offset = offset ;
e -> idx . crc32 = crc32_end ( pack_file ) ;
object_count ++ ;
object_count_by_type [ OBJ_BLOB ] ++ ;
}
free ( in_buf ) ;
free ( out_buf ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_RedundancyEncodingMode ( 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_RedundancyEncodingMode , RedundancyEncodingMode_sequence ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void thumbnail_got_pixbuf ( NautilusDirectory * directory , NautilusFile * file , GdkPixbuf * pixbuf , gboolean tried_original ) {
nautilus_directory_ref ( directory ) ;
nautilus_file_ref ( file ) ;
thumbnail_done ( directory , file , pixbuf , tried_original ) ;
nautilus_file_changed ( file ) ;
nautilus_file_unref ( file ) ;
if ( pixbuf ) {
g_object_unref ( pixbuf ) ;
}
nautilus_directory_unref ( directory ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void proto_reg_handoff_opcua ( void ) {
opcua_handle = create_dissector_handle ( dissect_opcua , proto_opcua ) ;
dissector_add_uint_range_with_preference ( "tcp.port" , OPCUA_PORT_RANGE , opcua_handle ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static gboolean is_reverse_circuit ( guint circuit_id , const iax_call_data * iax_call ) {
guint i ;
for ( i = 0 ;
i < iax_call -> n_reverse_circuit_ids ;
i ++ ) {
if ( circuit_id == iax_call -> reverse_circuit_ids [ i ] ) return TRUE ;
}
return FALSE ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void xmlListClear ( xmlListPtr l ) {
xmlLinkPtr lk ;
if ( l == NULL ) return ;
lk = l -> sentinel -> next ;
while ( lk != l -> sentinel ) {
xmlLinkPtr next = lk -> next ;
xmlLinkDeallocator ( l , lk ) ;
lk = next ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static char * auto_complete ( CHANNEL_REC * channel , const char * line ) {
GList * comp ;
const char * p ;
char * nick , * ret ;
p = strstr ( line , completion_char ) ;
if ( p == NULL ) return NULL ;
nick = g_strndup ( line , ( int ) ( p - line ) ) ;
ret = NULL ;
if ( nicklist_find ( channel , nick ) == NULL ) {
comp = completion_channel_nicks ( channel , nick , NULL ) ;
if ( comp != NULL ) {
ret = g_strconcat ( comp -> data , p , NULL ) ;
g_list_foreach ( comp , ( GFunc ) g_free , NULL ) ;
g_list_free ( comp ) ;
}
}
g_free ( nick ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void show_frame ( WriterContext * w , AVFrame * frame , AVStream * stream , AVFormatContext * fmt_ctx ) {
AVBPrint pbuf ;
char val_str [ 128 ] ;
const char * s ;
int i ;
av_bprint_init ( & pbuf , 1 , AV_BPRINT_SIZE_UNLIMITED ) ;
writer_print_section_header ( w , SECTION_ID_FRAME ) ;
s = av_get_media_type_string ( stream -> codecpar -> codec_type ) ;
if ( s ) print_str ( "media_type" , s ) ;
else print_str_opt ( "media_type" , "unknown" ) ;
print_int ( "stream_index" , stream -> index ) ;
print_int ( "key_frame" , frame -> key_frame ) ;
print_ts ( "pkt_pts" , frame -> pts ) ;
print_time ( "pkt_pts_time" , frame -> pts , & stream -> time_base ) ;
print_ts ( "pkt_dts" , frame -> pkt_dts ) ;
print_time ( "pkt_dts_time" , frame -> pkt_dts , & stream -> time_base ) ;
print_ts ( "best_effort_timestamp" , frame -> best_effort_timestamp ) ;
print_time ( "best_effort_timestamp_time" , frame -> best_effort_timestamp , & stream -> time_base ) ;
print_duration_ts ( "pkt_duration" , frame -> pkt_duration ) ;
print_duration_time ( "pkt_duration_time" , frame -> pkt_duration , & stream -> time_base ) ;
if ( frame -> pkt_pos != - 1 ) print_fmt ( "pkt_pos" , "%" PRId64 , frame -> pkt_pos ) ;
else print_str_opt ( "pkt_pos" , "N/A" ) ;
if ( frame -> pkt_size != - 1 ) print_val ( "pkt_size" , frame -> pkt_size , unit_byte_str ) ;
else print_str_opt ( "pkt_size" , "N/A" ) ;
switch ( stream -> codecpar -> codec_type ) {
AVRational sar ;
case AVMEDIA_TYPE_VIDEO : print_int ( "width" , frame -> width ) ;
print_int ( "height" , frame -> height ) ;
s = av_get_pix_fmt_name ( frame -> format ) ;
if ( s ) print_str ( "pix_fmt" , s ) ;
else print_str_opt ( "pix_fmt" , "unknown" ) ;
sar = av_guess_sample_aspect_ratio ( fmt_ctx , stream , frame ) ;
if ( sar . num ) {
print_q ( "sample_aspect_ratio" , sar , ':' ) ;
}
else {
print_str_opt ( "sample_aspect_ratio" , "N/A" ) ;
}
print_fmt ( "pict_type" , "%c" , av_get_picture_type_char ( frame -> pict_type ) ) ;
print_int ( "coded_picture_number" , frame -> coded_picture_number ) ;
print_int ( "display_picture_number" , frame -> display_picture_number ) ;
print_int ( "interlaced_frame" , frame -> interlaced_frame ) ;
print_int ( "top_field_first" , frame -> top_field_first ) ;
print_int ( "repeat_pict" , frame -> repeat_pict ) ;
if ( frame -> color_range != AVCOL_RANGE_UNSPECIFIED ) print_str ( "color_range" , av_color_range_name ( frame -> color_range ) ) ;
else print_str_opt ( "color_range" , av_color_range_name ( frame -> color_range ) ) ;
if ( frame -> colorspace != AVCOL_SPC_UNSPECIFIED ) print_str ( "color_space" , av_color_space_name ( frame -> colorspace ) ) ;
else print_str_opt ( "color_space" , av_color_space_name ( frame -> colorspace ) ) ;
print_primaries ( w , frame -> color_primaries ) ;
if ( frame -> color_trc != AVCOL_TRC_UNSPECIFIED ) print_str ( "color_transfer" , av_color_transfer_name ( frame -> color_trc ) ) ;
else print_str_opt ( "color_transfer" , av_color_transfer_name ( frame -> color_trc ) ) ;
if ( frame -> chroma_location != AVCHROMA_LOC_UNSPECIFIED ) print_str ( "chroma_location" , av_chroma_location_name ( frame -> chroma_location ) ) ;
else print_str_opt ( "chroma_location" , av_chroma_location_name ( frame -> chroma_location ) ) ;
break ;
case AVMEDIA_TYPE_AUDIO : s = av_get_sample_fmt_name ( frame -> format ) ;
if ( s ) print_str ( "sample_fmt" , s ) ;
else print_str_opt ( "sample_fmt" , "unknown" ) ;
print_int ( "nb_samples" , frame -> nb_samples ) ;
print_int ( "channels" , frame -> channels ) ;
if ( frame -> channel_layout ) {
av_bprint_clear ( & pbuf ) ;
av_bprint_channel_layout ( & pbuf , frame -> channels , frame -> channel_layout ) ;
print_str ( "channel_layout" , pbuf . str ) ;
}
else print_str_opt ( "channel_layout" , "unknown" ) ;
break ;
}
if ( do_show_frame_tags ) show_tags ( w , frame -> metadata , SECTION_ID_FRAME_TAGS ) ;
if ( do_show_log ) show_log ( w , SECTION_ID_FRAME_LOGS , SECTION_ID_FRAME_LOG , do_show_log ) ;
if ( frame -> nb_side_data ) {
writer_print_section_header ( w , SECTION_ID_FRAME_SIDE_DATA_LIST ) ;
for ( i = 0 ;
i < frame -> nb_side_data ;
i ++ ) {
AVFrameSideData * sd = frame -> side_data [ i ] ;
const char * name ;
writer_print_section_header ( w , SECTION_ID_FRAME_SIDE_DATA ) ;
name = av_frame_side_data_name ( sd -> type ) ;
print_str ( "side_data_type" , name ? name : "unknown" ) ;
if ( sd -> type == AV_FRAME_DATA_DISPLAYMATRIX && sd -> size >= 9 * 4 ) {
writer_print_integers ( w , "displaymatrix" , sd -> data , 9 , " %11d" , 3 , 4 , 1 ) ;
print_int ( "rotation" , av_display_rotation_get ( ( int32_t * ) sd -> data ) ) ;
}
else if ( sd -> type == AV_FRAME_DATA_GOP_TIMECODE && sd -> size >= 8 ) {
char tcbuf [ AV_TIMECODE_STR_SIZE ] ;
av_timecode_make_mpeg_tc_string ( tcbuf , * ( int64_t * ) ( sd -> data ) ) ;
print_str ( "timecode" , tcbuf ) ;
}
else if ( sd -> type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ) {
AVMasteringDisplayMetadata * metadata = ( AVMasteringDisplayMetadata * ) sd -> data ;
if ( metadata -> has_primaries ) {
print_q ( "red_x" , metadata -> display_primaries [ 0 ] [ 0 ] , '/' ) ;
print_q ( "red_y" , metadata -> display_primaries [ 0 ] [ 1 ] , '/' ) ;
print_q ( "green_x" , metadata -> display_primaries [ 1 ] [ 0 ] , '/' ) ;
print_q ( "green_y" , metadata -> display_primaries [ 1 ] [ 1 ] , '/' ) ;
print_q ( "blue_x" , metadata -> display_primaries [ 2 ] [ 0 ] , '/' ) ;
print_q ( "blue_y" , metadata -> display_primaries [ 2 ] [ 1 ] , '/' ) ;
print_q ( "white_point_x" , metadata -> white_point [ 0 ] , '/' ) ;
print_q ( "white_point_y" , metadata -> white_point [ 1 ] , '/' ) ;
}
if ( metadata -> has_luminance ) {
print_q ( "min_luminance" , metadata -> min_luminance , '/' ) ;
print_q ( "max_luminance" , metadata -> max_luminance , '/' ) ;
}
}
else if ( sd -> type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL ) {
AVContentLightMetadata * metadata = ( AVContentLightMetadata * ) sd -> data ;
print_int ( "max_content" , metadata -> MaxCLL ) ;
print_int ( "max_average" , metadata -> MaxFALL ) ;
}
else if ( sd -> type == AV_FRAME_DATA_ICC_PROFILE ) {
AVDictionaryEntry * tag = av_dict_get ( sd -> metadata , "name" , NULL , AV_DICT_MATCH_CASE ) ;
if ( tag ) print_str ( tag -> key , tag -> value ) ;
print_int ( "size" , sd -> size ) ;
}
writer_print_section_footer ( w ) ;
}
writer_print_section_footer ( w ) ;
}
writer_print_section_footer ( w ) ;
av_bprint_finalize ( & pbuf , NULL ) ;
fflush ( stdout ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void ff_h263_encode_motion ( MpegEncContext * s , int val , int f_code ) {
int range , bit_size , sign , code , bits ;
if ( val == 0 ) {
code = 0 ;
put_bits ( & s -> pb , ff_mvtab [ code ] [ 1 ] , ff_mvtab [ code ] [ 0 ] ) ;
}
else {
bit_size = f_code - 1 ;
range = 1 << bit_size ;
val = sign_extend ( val , 6 + bit_size ) ;
sign = val >> 31 ;
val = ( val ^ sign ) - sign ;
sign &= 1 ;
val -- ;
code = ( val >> bit_size ) + 1 ;
bits = val & ( range - 1 ) ;
put_bits ( & s -> pb , ff_mvtab [ code ] [ 1 ] + 1 , ( ff_mvtab [ code ] [ 0 ] << 1 ) | sign ) ;
if ( bit_size > 0 ) {
put_bits ( & s -> pb , bit_size , bits ) ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void prplcb_conv_del_users ( PurpleConversation * conv , GList * cbuddies ) {
struct groupchat * gc = conv -> ui_data ;
GList * b ;
for ( b = cbuddies ;
b ;
b = b -> next ) {
imcb_chat_remove_buddy ( gc , b -> data , "" ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int is_response_status_relevant ( modsec_rec * msr , int status ) {
char * my_error_msg = NULL ;
apr_status_t rc ;
char buf [ 32 ] ;
if ( ( msr -> txcfg -> auditlog_relevant_regex == NULL ) || ( msr -> txcfg -> auditlog_relevant_regex == NOT_SET_P ) ) {
return 0 ;
}
apr_snprintf ( buf , sizeof ( buf ) , "%d" , status ) ;
rc = msc_regexec ( msr -> txcfg -> auditlog_relevant_regex , buf , strlen ( buf ) , & my_error_msg ) ;
if ( rc >= 0 ) return 1 ;
if ( rc == PCRE_ERROR_NOMATCH ) return 0 ;
msr_log ( msr , 1 , "Regex processing failed (rc %d): %s" , rc , my_error_msg ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_F ( UnloadTest , BrowserListCloseBeforeUnloadCancel ) {
NavigateToDataURL ( BEFORE_UNLOAD_HTML , "beforeunload" ) ;
UnloadResults unload_results ;
BrowserList : : CloseAllBrowsersWithProfile ( browser ( ) -> profile ( ) , base : : Bind ( & UnloadResults : : AddSuccess , base : : Unretained ( & unload_results ) ) , base : : Bind ( & UnloadResults : : AddAbort , base : : Unretained ( & unload_results ) ) , false ) ;
base : : string16 expected_title = base : : ASCIIToUTF16 ( "cancelled" ) ;
content : : TitleWatcher title_watcher ( browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) , expected_title ) ;
ClickModalDialogButton ( false ) ;
ASSERT_EQ ( expected_title , title_watcher . WaitAndGetTitle ( ) ) ;
EXPECT_EQ ( 0 , unload_results . get_successes ( ) ) ;
EXPECT_EQ ( 1 , unload_results . get_aborts ( ) ) ;
content : : WindowedNotificationObserver window_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , content : : NotificationService : : AllSources ( ) ) ;
chrome : : CloseWindow ( browser ( ) ) ;
ClickModalDialogButton ( true ) ;
window_observer . Wait ( ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_SEQUENCE_OF_TransportAddress ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h225_SEQUENCE_OF_TransportAddress , SEQUENCE_OF_TransportAddress_sequence_of ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int petite_inflate2x_1to9 ( char * buf , uint32_t minrva , uint32_t bufsz , struct cli_exe_section * sections , unsigned int sectcount , uint32_t Imagebase , uint32_t pep , int desc , int version , uint32_t ResRva , uint32_t ResSize ) {
char * adjbuf = buf - minrva ;
char * packed = NULL ;
uint32_t thisrva = 0 , bottom = 0 , enc_ep = 0 , irva = 0 , workdone = 0 , grown = 0x355 , skew = 0x35 ;
int j = 0 , oob , mangled = 0 , check4resources = 0 ;
struct cli_exe_section * usects = NULL ;
void * tmpsct = NULL ;
if ( version == 2 ) packed = adjbuf + sections [ sectcount - 1 ] . rva + 0x1b8 ;
if ( version == 1 ) {
packed = adjbuf + sections [ sectcount - 1 ] . rva + 0x178 ;
grown = 0x323 ;
skew = 0x34 ;
}
while ( 1 ) {
char * ssrc , * ddst ;
uint32_t size , srva ;
int backbytes , oldback , addsize ;
unsigned int backsize ;
if ( ! CLI_ISCONTAINED ( buf , bufsz , packed , 4 ) ) {
if ( usects ) free ( usects ) ;
return 1 ;
}
srva = cli_readint32 ( packed ) ;
if ( ! srva ) {
int t , upd = 1 ;
if ( j <= 0 ) return 1 ;
while ( upd ) {
upd = 0 ;
for ( t = 0 ;
t < j - 1 ;
t ++ ) {
uint32_t trva , trsz , tvsz ;
if ( usects [ t ] . rva <= usects [ t + 1 ] . rva ) continue ;
trva = usects [ t ] . rva ;
trsz = usects [ t ] . rsz ;
tvsz = usects [ t ] . vsz ;
usects [ t ] . rva = usects [ t + 1 ] . rva ;
usects [ t ] . rsz = usects [ t + 1 ] . rsz ;
usects [ t ] . vsz = usects [ t + 1 ] . vsz ;
usects [ t + 1 ] . rva = trva ;
usects [ t + 1 ] . rsz = trsz ;
usects [ t + 1 ] . vsz = tvsz ;
upd = 1 ;
}
}
for ( t = 0 ;
t < j - 1 ;
t ++ ) {
if ( usects [ t ] . vsz != usects [ t + 1 ] . rva - usects [ t ] . rva ) usects [ t ] . vsz = usects [ t + 1 ] . rva - usects [ t ] . rva ;
}
if ( enc_ep ) {
uint32_t virtaddr = pep + 5 + Imagebase , tmpep ;
int rndm = 0 , dummy = 1 ;
char * thunk = adjbuf + irva ;
char * imports ;
if ( version == 2 ) {
while ( dummy && CLI_ISCONTAINED ( buf , bufsz , thunk , 4 ) ) {
uint32_t api ;
if ( ! cli_readint32 ( thunk ) ) {
workdone = 1 ;
break ;
}
imports = adjbuf + cli_readint32 ( thunk ) ;
thunk += 4 ;
dummy = 0 ;
while ( CLI_ISCONTAINED ( buf , bufsz , imports , 4 ) ) {
dummy = 0 ;
imports += 4 ;
if ( ! ( api = cli_readint32 ( imports - 4 ) ) ) {
dummy = 1 ;
break ;
}
if ( ( api != ( api | 0x80000000 ) ) && mangled && -- rndm < 0 ) {
api = virtaddr ;
virtaddr += 5 ;
rndm = virtaddr & 7 ;
}
else {
api = 0xbff01337 ;
}
if ( sections [ sectcount - 1 ] . rva + Imagebase < api ) enc_ep -- ;
if ( api < virtaddr ) enc_ep -- ;
tmpep = ( enc_ep & 0xfffffff8 ) >> 3 & 0x1fffffff ;
enc_ep = ( enc_ep & 7 ) << 29 | tmpep ;
}
}
}
else workdone = 1 ;
enc_ep = pep + 5 + enc_ep ;
if ( workdone == 1 ) {
cli_dbgmsg ( "Petite: Old EP: %x\n" , enc_ep ) ;
}
else {
enc_ep = usects [ 0 ] . rva ;
cli_dbgmsg ( "Petite: In troubles while attempting to decrypt old EP, using bogus %x\n" , enc_ep ) ;
}
}
for ( t = 0 ;
t < j ;
t ++ ) {
usects [ t ] . raw = ( t > 0 ) ? ( usects [ t - 1 ] . raw + usects [ t - 1 ] . rsz ) : 0 ;
if ( usects [ t ] . rsz != 0 ) {
if ( CLI_ISCONTAINED ( buf , bufsz , buf + usects [ t ] . raw , usects [ t ] . rsz ) ) {
memmove ( buf + usects [ t ] . raw , adjbuf + usects [ t ] . rva , usects [ t ] . rsz ) ;
}
else {
cli_dbgmsg ( "Petite: Skipping section %d, Raw: %x, RSize:%x\n" , t , usects [ t ] . raw , usects [ t ] . rsz ) ;
usects [ t ] . raw = t > 0 ? usects [ t - 1 ] . raw : 0 ;
usects [ t ] . rsz = 0 ;
}
}
}
cli_dbgmsg ( "Petite: Sections dump:\n" ) ;
for ( t = 0 ;
t < j ;
t ++ ) cli_dbgmsg ( "Petite: .SECT%d RVA:%x VSize:%x ROffset: %x, RSize:%x\n" , t , usects [ t ] . rva , usects [ t ] . vsz , usects [ t ] . raw , usects [ t ] . rsz ) ;
if ( ! cli_rebuildpe ( buf , usects , j , Imagebase , enc_ep , ResRva , ResSize , desc ) ) {
cli_dbgmsg ( "Petite: Rebuilding failed\n" ) ;
free ( usects ) ;
return 1 ;
}
free ( usects ) ;
return 0 ;
}
size = srva & 0x7fffffff ;
if ( srva != size ) {
check4resources = 0 ;
if ( ! CLI_ISCONTAINED ( buf , bufsz , packed + 4 , 8 ) ) {
if ( usects ) free ( usects ) ;
return 1 ;
}
bottom = cli_readint32 ( packed + 8 ) + 4 ;
ssrc = adjbuf + cli_readint32 ( packed + 4 ) - ( size - 1 ) * 4 ;
ddst = adjbuf + cli_readint32 ( packed + 8 ) - ( size - 1 ) * 4 ;
if ( ! CLI_ISCONTAINED ( buf , bufsz , ssrc , size * 4 ) || ! CLI_ISCONTAINED ( buf , bufsz , ddst , size * 4 ) ) {
if ( usects ) free ( usects ) ;
return 1 ;
}
memmove ( ddst , ssrc , size * 4 ) ;
packed += 0x0c ;
}
else {
uint32_t check1 , check2 ;
uint8_t mydl = 0 ;
uint8_t goback ;
unsigned int q ;
if ( ! CLI_ISCONTAINED ( buf , bufsz , packed + 4 , 8 ) ) {
if ( usects ) free ( usects ) ;
return 1 ;
}
size = cli_readint32 ( packed + 4 ) ;
thisrva = cli_readint32 ( packed + 8 ) ;
packed += 0x10 ;
if ( j >= 96 ) {
cli_dbgmsg ( "Petite: maximum number of sections exceeded, giving up.\n" ) ;
free ( usects ) ;
return 1 ;
}
if ( ! ( tmpsct = cli_realloc ( usects , sizeof ( struct cli_exe_section ) * ( j + 1 ) ) ) ) {
if ( usects ) free ( usects ) ;
return 1 ;
}
usects = ( struct cli_exe_section * ) tmpsct ;
usects [ j ] . rva = thisrva ;
usects [ j ] . rsz = size ;
if ( ( int ) ( bottom - thisrva ) > 0 ) usects [ j ] . vsz = bottom - thisrva ;
else usects [ j ] . vsz = size ;
usects [ j ] . raw = 0 ;
if ( ! size ) {
j ++ ;
continue ;
}
ssrc = adjbuf + srva ;
ddst = adjbuf + thisrva ;
for ( q = 0 ;
q < sectcount ;
q ++ ) {
if ( ! CLI_ISCONTAINED ( sections [ q ] . rva , sections [ q ] . vsz , usects [ j ] . rva , usects [ j ] . vsz ) ) continue ;
if ( ! check4resources ) {
usects [ j ] . rva = sections [ q ] . rva ;
usects [ j ] . rsz = thisrva - sections [ q ] . rva + size ;
}
break ;
}
if ( q == sectcount ) {
free ( usects ) ;
return 1 ;
}
j ++ ;
if ( size < 0x10000 ) {
check1 = 0x0FFFFC060 ;
check2 = 0x0FFFFFC60 ;
goback = 5 ;
}
else if ( size < 0x40000 ) {
check1 = 0x0FFFF8180 ;
check2 = 0x0FFFFF980 ;
goback = 7 ;
}
else {
check1 = 0x0FFFF8300 ;
check2 = 0x0FFFFFB00 ;
goback = 8 ;
}
if ( ! CLI_ISCONTAINED ( buf , bufsz , ssrc , 1 ) || ! CLI_ISCONTAINED ( buf , bufsz , ddst , 1 ) ) {
free ( usects ) ;
return 1 ;
}
size -- ;
* ddst ++ = * ssrc ++ ;
backbytes = 0 ;
oldback = 0 ;
while ( size > 0 ) {
oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ;
if ( oob == - 1 ) {
free ( usects ) ;
return 1 ;
}
if ( ! oob ) {
if ( ! CLI_ISCONTAINED ( buf , bufsz , ssrc , 1 ) || ! CLI_ISCONTAINED ( buf , bufsz , ddst , 1 ) ) {
free ( usects ) ;
return 1 ;
}
* ddst ++ = ( char ) ( ( * ssrc ++ ) ^ ( size & 0xff ) ) ;
size -- ;
}
else {
addsize = 0 ;
backbytes ++ ;
while ( 1 ) {
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
backbytes = backbytes * 2 + oob ;
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
if ( ! oob ) break ;
}
backbytes -= 3 ;
if ( backbytes >= 0 ) {
backsize = goback ;
do {
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
backbytes = backbytes * 2 + oob ;
backsize -- ;
}
while ( backsize ) ;
backbytes ^= 0xffffffff ;
addsize += 1 + ( backbytes < ( int ) check2 ) + ( backbytes < ( int ) check1 ) ;
oldback = backbytes ;
}
else {
backsize = backbytes + 1 ;
backbytes = oldback ;
}
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
backsize = backsize * 2 + oob ;
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
backsize = backsize * 2 + oob ;
if ( ! backsize ) {
backsize ++ ;
while ( 1 ) {
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
backsize = backsize * 2 + oob ;
if ( ( oob = doubledl ( & ssrc , & mydl , buf , bufsz ) ) == - 1 ) {
free ( usects ) ;
return 1 ;
}
if ( ! oob ) break ;
}
backsize += 2 ;
}
backsize += addsize ;
size -= backsize ;
if ( ! CLI_ISCONTAINED ( buf , bufsz , ddst , backsize ) || ! CLI_ISCONTAINED ( buf , bufsz , ddst + backbytes , backsize ) ) {
free ( usects ) ;
return 1 ;
}
while ( backsize -- ) {
* ddst = * ( ddst + backbytes ) ;
ddst ++ ;
}
backbytes = 0 ;
backsize = 0 ;
}
}
if ( j ) {
int strippetite = 0 ;
uint32_t reloc ;
if ( usects [ j - 1 ] . rsz > grown && CLI_ISCONTAINED ( buf , bufsz , ddst - grown + 5 + 0x4f , 8 ) && cli_readint32 ( ddst - grown + 5 + 0x4f ) == 0x645ec033 && cli_readint32 ( ddst - grown + 5 + 0x4f + 4 ) == 0x1b8b188b ) {
reloc = 0 ;
strippetite = 1 ;
}
if ( ! strippetite && usects [ j - 1 ] . rsz > grown + skew && CLI_ISCONTAINED ( buf , bufsz , ddst - grown + 5 + 0x4f - skew , 8 ) && cli_readint32 ( ddst - grown + 5 + 0x4f - skew ) == 0x645ec033 && cli_readint32 ( ddst - grown + 5 + 0x4f + 4 - skew ) == 0x1b8b188b ) {
reloc = skew ;
strippetite = 1 ;
}
if ( strippetite && CLI_ISCONTAINED ( buf , bufsz , ddst - grown + 0x0f - 8 - reloc , 8 ) ) {
uint32_t test1 , test2 ;
test1 = cli_readint32 ( ddst - grown + 0x0f - 8 - reloc ) ^ 0x9d6661aa ;
test2 = cli_readint32 ( ddst - grown + 0x0f - 4 - reloc ) ^ 0xe908c483 ;
cli_dbgmsg ( "Petite: Found petite code in sect%d(%x). Let's strip it.\n" , j - 1 , usects [ j - 1 ] . rva ) ;
if ( test1 == test2 && CLI_ISCONTAINED ( buf , bufsz , ddst - grown + 0x0f - reloc , 0x1c0 - 0x0f + 4 ) ) {
irva = cli_readint32 ( ddst - grown + 0x121 - reloc ) ;
enc_ep = cli_readint32 ( ddst - grown + 0x0f - reloc ) ^ test1 ;
mangled = ( ( uint32_t ) cli_readint32 ( ddst - grown + 0x1c0 - reloc ) != 0x90909090 ) ;
cli_dbgmsg ( "Petite: Encrypted EP: %x | Array of imports: %x\n" , enc_ep , irva ) ;
}
usects [ j - 1 ] . rsz -= grown + reloc ;
}
}
check4resources ++ ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
VIR_ONCE_GLOBAL_INIT ( virLog ) int virLogReset ( void ) {
if ( virLogInitialize ( ) < 0 ) return - 1 ;
virLogLock ( ) ;
virLogResetFilters ( ) ;
virLogResetOutputs ( ) ;
virLogDefaultPriority = VIR_LOG_DEFAULT ;
virLogUnlock ( ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void evhttp_request_dispatch ( struct evhttp_connection * evcon ) {
struct evhttp_request * req = TAILQ_FIRST ( & evcon -> requests ) ;
if ( req == NULL ) return ;
evhttp_connection_stop_detectclose ( evcon ) ;
assert ( evcon -> state == EVCON_IDLE ) ;
evcon -> state = EVCON_WRITING ;
evhttp_make_header ( evcon , req ) ;
evhttp_write_buffer ( evcon , evhttp_write_connectioncb , NULL ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int DMA_write_memory ( int nchan , void * buf , int pos , int size ) {
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void cluster_all_databases ( bool verbose , const char * maintenance_db , const char * host , const char * port , const char * username , enum trivalue prompt_password , const char * progname , bool echo , bool quiet ) {
PGconn * conn ;
PGresult * result ;
PQExpBufferData connstr ;
int i ;
conn = connectMaintenanceDatabase ( maintenance_db , host , port , username , prompt_password , progname ) ;
result = executeQuery ( conn , "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;
" , progname , echo ) ;
PQfinish ( conn ) ;
initPQExpBuffer ( & connstr ) ;
for ( i = 0 ;
i < PQntuples ( result ) ;
i ++ ) {
char * dbname = PQgetvalue ( result , i , 0 ) ;
if ( ! quiet ) {
printf ( _ ( "%s: clustering database \"%s\"\n" ) , progname , dbname ) ;
fflush ( stdout ) ;
}
resetPQExpBuffer ( & connstr ) ;
appendPQExpBuffer ( & connstr , "dbname=" ) ;
appendConnStrVal ( & connstr , dbname ) ;
cluster_one_database ( connstr . data , verbose , NULL , host , port , username , prompt_password , progname , echo ) ;
}
termPQExpBuffer ( & connstr ) ;
PQclear ( result ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static PARTITION_TYPE read_partition ( VP9_COMMON * cm , MACROBLOCKD * xd , int hbs , int mi_row , int mi_col , BLOCK_SIZE bsize , vp9_reader * r ) {
const int ctx = partition_plane_context ( xd , mi_row , mi_col , bsize ) ;
const vp9_prob * const probs = get_partition_probs ( cm , ctx ) ;
const int has_rows = ( mi_row + hbs ) < cm -> mi_rows ;
const int has_cols = ( mi_col + hbs ) < cm -> mi_cols ;
PARTITION_TYPE p ;
if ( has_rows && has_cols ) p = ( PARTITION_TYPE ) vp9_read_tree ( r , vp9_partition_tree , probs ) ;
else if ( ! has_rows && has_cols ) p = vp9_read ( r , probs [ 1 ] ) ? PARTITION_SPLIT : PARTITION_HORZ ;
else if ( has_rows && ! has_cols ) p = vp9_read ( r , probs [ 2 ] ) ? PARTITION_SPLIT : PARTITION_VERT ;
else p = PARTITION_SPLIT ;
if ( ! cm -> frame_parallel_decoding_mode ) ++ cm -> counts . partition [ ctx ] [ p ] ;
return p ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void http_large_delay_cb ( struct evhttp_request * req , void * arg ) {
struct timeval tv ;
timerclear ( & tv ) ;
tv . tv_sec = 3 ;
event_once ( - 1 , EV_TIMEOUT , http_delay_reply , req , & tv ) ;
evhttp_connection_fail ( delayed_client , EVCON_HTTP_EOF ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void gsm_a_dtap_sms_stat_init ( new_stat_tap_ui * new_stat , new_stat_tap_gui_init_cb gui_callback , void * gui_data ) {
gsm_a_stat_init ( new_stat , gui_callback , gui_data , "GSM A-I/F DTAP Short Message Service Statistics" , gsm_a_dtap_msg_sms_strings ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void dissect_payload ( tvbuff_t * tvb , guint32 offset , packet_info * pinfo , proto_tree * iax2_tree , proto_tree * tree , guint32 ts _U_ , gboolean video , iax_packet_data * iax_packet ) {
# if 0 gboolean out_of_order = FALSE ;
# endif tvbuff_t * sub_tvb ;
guint32 codec = iax_packet -> codec ;
guint32 nbytes ;
iax_call_data * iax_call = iax_packet -> call_data ;
if ( offset >= tvb_reported_length ( tvb ) ) {
col_append_str ( pinfo -> cinfo , COL_INFO , ", empty frame" ) ;
return ;
}
sub_tvb = tvb_new_subset_remaining ( tvb , offset ) ;
if ( ! video && iax_call && iax_call -> dataformat != 0 ) {
col_append_fstr ( pinfo -> cinfo , COL_INFO , ", data, format %s" , val_to_str ( iax_call -> dataformat , iax_dataformats , "unknown (0x%02x)" ) ) ;
# if 0 if ( out_of_order ) col_append_str ( pinfo -> cinfo , COL_INFO , " (out-of-order packet)" ) ;
# endif }
else {
col_append_fstr ( pinfo -> cinfo , COL_INFO , ", %s" , val_to_str_ext ( codec , & codec_types_ext , "unknown (0x%02x)" ) ) ;
}
nbytes = tvb_reported_length ( sub_tvb ) ;
proto_tree_add_item ( iax2_tree , hf_iax2_payload_data , sub_tvb , 0 , - 1 , ENC_NA ) ;
iax2_info -> payload_len = nbytes ;
iax2_info -> payload_data = tvb_get_ptr ( sub_tvb , 0 , - 1 ) ;
if ( iax_packet -> call_data ) desegment_iax ( sub_tvb , pinfo , iax2_tree , tree , video , iax_packet ) ;
else process_iax_pdu ( sub_tvb , pinfo , tree , video , iax_packet ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_rsl_ie_link_id ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
proto_tree * ie_tree ;
guint8 octet ;
guint8 ie_id ;
if ( is_mandatory == FALSE ) {
ie_id = tvb_get_guint8 ( tvb , offset ) ;
if ( ie_id != RSL_IE_LINK_ID ) return offset ;
}
ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 2 , ett_ie_link_id , NULL , "Link Identifier IE " ) ;
proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
octet = tvb_get_guint8 ( tvb , offset ) ;
if ( ( octet & 0x20 ) == 0x20 ) {
proto_tree_add_item ( ie_tree , hf_rsl_na , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
return offset ;
}
proto_tree_add_item ( ie_tree , hf_rsl_ch_type , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( ie_tree , hf_rsl_na , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( ie_tree , hf_rsl_prio , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( ie_tree , hf_rsl_sapi , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int i2d_PKCS8PrivateKeyInfo_fp ( FILE * fp , EVP_PKEY * key ) {
PKCS8_PRIV_KEY_INFO * p8inf ;
int ret ;
p8inf = EVP_PKEY2PKCS8 ( key ) ;
if ( ! p8inf ) return 0 ;
ret = i2d_PKCS8_PRIV_KEY_INFO_fp ( fp , p8inf ) ;
PKCS8_PRIV_KEY_INFO_free ( p8inf ) ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void vapic_class_init ( ObjectClass * klass , void * data ) {
SysBusDeviceClass * sc = SYS_BUS_DEVICE_CLASS ( klass ) ;
DeviceClass * dc = DEVICE_CLASS ( klass ) ;
dc -> no_user = 1 ;
dc -> reset = vapic_reset ;
dc -> vmsd = & vmstate_vapic ;
sc -> init = vapic_init ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void nautilus_mime_activate_file ( GtkWindow * parent_window , NautilusWindowSlot * slot , NautilusFile * file , const char * launch_directory , NautilusWindowOpenFlags flags ) {
GList * files ;
g_return_if_fail ( NAUTILUS_IS_FILE ( file ) ) ;
files = g_list_prepend ( NULL , file ) ;
nautilus_mime_activate_files ( parent_window , slot , files , launch_directory , flags , FALSE ) ;
g_list_free ( files ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int decodenetnum ( const char * num , sockaddr_u * netnum ) {
struct addrinfo hints , * ai = NULL ;
int err ;
u_short port ;
const char * cp ;
const char * port_str ;
char * pp ;
char * np ;
char name [ 80 ] ;
REQUIRE ( num != NULL ) ;
if ( strlen ( num ) >= sizeof ( name ) ) {
return 0 ;
}
port_str = NULL ;
if ( '[' != num [ 0 ] ) {
pp = strchr ( num , ':' ) ;
if ( NULL == pp ) cp = num ;
else if ( NULL != strchr ( pp + 1 , ':' ) ) cp = num ;
else {
strlcpy ( name , num , sizeof ( name ) ) ;
cp = name ;
pp = strchr ( cp , ':' ) ;
* pp = '\0' ;
port_str = pp + 1 ;
}
}
else {
cp = num + 1 ;
np = name ;
while ( * cp && ']' != * cp ) * np ++ = * cp ++ ;
* np = 0 ;
if ( ']' == cp [ 0 ] && ':' == cp [ 1 ] && '\0' != cp [ 2 ] ) port_str = & cp [ 2 ] ;
cp = name ;
}
ZERO ( hints ) ;
hints . ai_flags = Z_AI_NUMERICHOST ;
err = getaddrinfo ( cp , "ntp" , & hints , & ai ) ;
if ( err != 0 ) return 0 ;
INSIST ( ai -> ai_addrlen <= sizeof ( * netnum ) ) ;
ZERO ( * netnum ) ;
memcpy ( netnum , ai -> ai_addr , ai -> ai_addrlen ) ;
freeaddrinfo ( ai ) ;
if ( NULL == port_str || 1 != sscanf ( port_str , "%hu" , & port ) ) port = NTP_PORT ;
SET_PORT ( netnum , port ) ;
return 1 ;
}
| 0False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.