instruction
stringclasses 1
value | input
stringlengths 31
235k
| output
class label 2
classes |
---|---|---|
Categorize the following code snippet as vulnerable or not. True or False | static void * Type_Dictionary_Dup ( struct _cms_typehandler_struct * self , const void * Ptr , cmsUInt32Number n ) {
return ( void * ) cmsDictDup ( ( cmsHANDLE ) Ptr ) ;
cmsUNUSED_PARAMETER ( n ) ;
cmsUNUSED_PARAMETER ( self ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int mime_parse_time ( const char * & buf , const char * end , int * hour , int * min , int * sec ) {
if ( ! mime_parse_integer ( buf , end , hour ) ) {
return 0 ;
}
if ( ! mime_parse_integer ( buf , end , min ) ) {
return 0 ;
}
if ( ! mime_parse_integer ( buf , end , sec ) ) {
return 0 ;
}
return 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void free_statement ( pdo_stmt_t * stmt TSRMLS_DC ) {
if ( stmt -> bound_params ) {
zend_hash_destroy ( stmt -> bound_params ) ;
FREE_HASHTABLE ( stmt -> bound_params ) ;
stmt -> bound_params = NULL ;
}
if ( stmt -> bound_param_map ) {
zend_hash_destroy ( stmt -> bound_param_map ) ;
FREE_HASHTABLE ( stmt -> bound_param_map ) ;
stmt -> bound_param_map = NULL ;
}
if ( stmt -> bound_columns ) {
zend_hash_destroy ( stmt -> bound_columns ) ;
FREE_HASHTABLE ( stmt -> bound_columns ) ;
stmt -> bound_columns = NULL ;
}
if ( stmt -> methods && stmt -> methods -> dtor ) {
stmt -> methods -> dtor ( stmt TSRMLS_CC ) ;
}
if ( stmt -> query_string ) {
efree ( stmt -> query_string ) ;
}
if ( stmt -> columns ) {
int i ;
struct pdo_column_data * cols = stmt -> columns ;
for ( i = 0 ;
i < stmt -> column_count ;
i ++ ) {
if ( cols [ i ] . name ) {
efree ( cols [ i ] . name ) ;
cols [ i ] . name = NULL ;
}
}
efree ( stmt -> columns ) ;
stmt -> columns = NULL ;
}
if ( stmt -> fetch . into && stmt -> default_fetch_type == PDO_FETCH_INTO ) {
FREE_ZVAL ( stmt -> fetch . into ) ;
stmt -> fetch . into = NULL ;
}
do_fetch_opt_finish ( stmt , 1 TSRMLS_CC ) ;
zend_objects_store_del_ref ( & stmt -> database_object_handle TSRMLS_CC ) ;
if ( stmt -> dbh ) {
php_pdo_dbh_delref ( stmt -> dbh TSRMLS_CC ) ;
}
zend_object_std_dtor ( & stmt -> std TSRMLS_CC ) ;
efree ( stmt ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( NativeBackendLibsecretTest , RemoveNonexistentLogin ) {
NativeBackendLibsecret backend ( 42 ) ;
VerifiedAdd ( & backend , form_google_ ) ;
EXPECT_EQ ( 1u , global_mock_libsecret_items -> size ( ) ) ;
if ( ! global_mock_libsecret_items -> empty ( ) ) CheckMockSecretItem ( ( * global_mock_libsecret_items ) [ 0 ] , form_google_ , "chrome-42" ) ;
PasswordStoreChangeList changes ;
EXPECT_TRUE ( backend . RemoveLogin ( form_isc_ , & changes ) ) ;
CheckPasswordChanges ( PasswordStoreChangeList ( ) , changes ) ;
ScopedVector < autofill : : PasswordForm > form_list ;
EXPECT_TRUE ( backend . GetAutofillableLogins ( & form_list ) ) ;
EXPECT_EQ ( 1u , form_list . size ( ) ) ;
form_list . clear ( ) ;
EXPECT_EQ ( 1u , global_mock_libsecret_items -> size ( ) ) ;
if ( ! global_mock_libsecret_items -> empty ( ) ) CheckMockSecretItem ( ( * global_mock_libsecret_items ) [ 0 ] , form_google_ , "chrome-42" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ber_prompt ( packet_info * pinfo _U_ , gchar * result ) {
g_snprintf ( result , MAX_DECODE_AS_PROMPT_LEN , "Decode ASN.1 file as" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void useNormalConnectTimeout ( socket_handle_t sock ) {
int res_rcv ;
# ifdef _WIN32 const DWORD socket_timeout = 0 ;
unsigned long non_blocking = 0 ;
res_rcv = setsockopt ( sock , SOL_SOCKET , SO_RCVTIMEO , ( const char * ) & socket_timeout , sizeof ( socket_timeout ) ) ;
ioctlsocket ( sock , FIONBIO , & non_blocking ) ;
# else const struct timeval socket_timeout = {
. tv_sec = SOCKET_RW_TIMEOUT_MS / 1000 , . tv_usec = ( SOCKET_RW_TIMEOUT_MS % 1000 ) * 1000 }
;
res_rcv = setsockopt ( sock , SOL_SOCKET , SO_RCVTIMEO , & socket_timeout , sizeof ( socket_timeout ) ) ;
# endif if ( res_rcv != 0 ) g_debug ( "Can't set socket timeout, using default" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void ntpd_set_tod_using ( const char * which ) {
char line [ 128 ] ;
snprintf ( line , sizeof ( line ) , "settimeofday=\"%s\"" , which ) ;
set_sys_var ( line , strlen ( line ) + 1 , RO ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | sim_node * create_sim_node ( attr_val_fifo * init_opts , server_info_fifo * servers ) {
sim_node * my_node ;
my_node = emalloc ( sizeof ( * my_node ) ) ;
my_node -> init_opts = init_opts ;
my_node -> servers = servers ;
return my_node ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int event_base_set ( struct event_base * base , struct event * ev ) {
if ( ev -> ev_flags != EVLIST_INIT ) return ( - 1 ) ;
ev -> ev_base = base ;
ev -> ev_pri = base -> nactivequeues / 2 ;
return ( 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_InfoRequest ( 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_InfoRequest , InfoRequest_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int mpeg4_decode_partitioned_mb ( MpegEncContext * s , int16_t block [ 6 ] [ 64 ] ) {
int cbp , mb_type ;
const int xy = s -> mb_x + s -> mb_y * s -> mb_stride ;
mb_type = s -> current_picture . mb_type [ xy ] ;
cbp = s -> cbp_table [ xy ] ;
s -> use_intra_dc_vlc = s -> qscale < s -> intra_dc_threshold ;
if ( s -> current_picture . qscale_table [ xy ] != s -> qscale ) {
ff_set_qscale ( s , s -> current_picture . qscale_table [ xy ] ) ;
}
if ( s -> pict_type == AV_PICTURE_TYPE_P || s -> pict_type == AV_PICTURE_TYPE_S ) {
int i ;
for ( i = 0 ;
i < 4 ;
i ++ ) {
s -> mv [ 0 ] [ i ] [ 0 ] = s -> current_picture . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 0 ] ;
s -> mv [ 0 ] [ i ] [ 1 ] = s -> current_picture . motion_val [ 0 ] [ s -> block_index [ i ] ] [ 1 ] ;
}
s -> mb_intra = IS_INTRA ( mb_type ) ;
if ( IS_SKIP ( mb_type ) ) {
for ( i = 0 ;
i < 6 ;
i ++ ) s -> block_last_index [ i ] = - 1 ;
s -> mv_dir = MV_DIR_FORWARD ;
s -> mv_type = MV_TYPE_16X16 ;
if ( s -> pict_type == AV_PICTURE_TYPE_S && s -> vol_sprite_usage == GMC_SPRITE ) {
s -> mcsel = 1 ;
s -> mb_skipped = 0 ;
}
else {
s -> mcsel = 0 ;
s -> mb_skipped = 1 ;
}
}
else if ( s -> mb_intra ) {
s -> ac_pred = IS_ACPRED ( s -> current_picture . mb_type [ xy ] ) ;
}
else if ( ! s -> mb_intra ) {
s -> mv_dir = MV_DIR_FORWARD ;
if ( IS_8X8 ( mb_type ) ) {
s -> mv_type = MV_TYPE_8X8 ;
}
else {
s -> mv_type = MV_TYPE_16X16 ;
}
}
}
else {
s -> mb_intra = 1 ;
s -> ac_pred = IS_ACPRED ( s -> current_picture . mb_type [ xy ] ) ;
}
if ( ! IS_SKIP ( mb_type ) ) {
int i ;
s -> dsp . clear_blocks ( s -> block [ 0 ] ) ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
if ( mpeg4_decode_block ( s , block [ i ] , i , cbp & 32 , s -> mb_intra , s -> rvlc ) < 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "texture corrupted at %d %d %d\n" , s -> mb_x , s -> mb_y , s -> mb_intra ) ;
return - 1 ;
}
cbp += cbp ;
}
}
if ( -- s -> mb_num_left <= 0 ) {
if ( mpeg4_is_resync ( s ) ) return SLICE_END ;
else return SLICE_NOEND ;
}
else {
if ( mpeg4_is_resync ( s ) ) {
const int delta = s -> mb_x + 1 == s -> mb_width ? 2 : 1 ;
if ( s -> cbp_table [ xy + delta ] ) return SLICE_END ;
}
return SLICE_OK ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline int pfkey_mode_to_xfrm ( int mode ) {
switch ( mode ) {
case IPSEC_MODE_ANY : case IPSEC_MODE_TRANSPORT : return XFRM_MODE_TRANSPORT ;
case IPSEC_MODE_TUNNEL : return XFRM_MODE_TUNNEL ;
case IPSEC_MODE_BEET : return XFRM_MODE_BEET ;
default : return - 1 ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void combined_read_cb ( int fd , short event , void * arg ) {
struct both * both = arg ;
char buf [ 128 ] ;
int len ;
len = read ( fd , buf , sizeof ( buf ) ) ;
if ( len == - 1 ) fprintf ( stderr , "%s: read\n" , __func__ ) ;
if ( len <= 0 ) return ;
both -> nread += len ;
if ( event_add ( & both -> ev , NULL ) == - 1 ) exit ( 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline int get_bitsz ( GetBitContext * s , int n ) {
return n ? get_bits ( s , n ) : 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int aes_gcm_tls_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
int rv = - 1 ;
if ( out != in || len < ( EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ) ) return - 1 ;
if ( EVP_CIPHER_CTX_ctrl ( ctx , EVP_CIPHER_CTX_encrypting ( ctx ) ? EVP_CTRL_GCM_IV_GEN : EVP_CTRL_GCM_SET_IV_INV , EVP_GCM_TLS_EXPLICIT_IV_LEN , out ) <= 0 ) goto err ;
if ( CRYPTO_gcm128_aad ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , gctx -> tls_aad_len ) ) goto err ;
in += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
out += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 32 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 32 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
out += len ;
CRYPTO_gcm128_tag ( & gctx -> gcm , out , EVP_GCM_TLS_TAG_LEN ) ;
rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
}
else {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 16 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 16 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
CRYPTO_gcm128_tag ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , EVP_GCM_TLS_TAG_LEN ) ;
if ( CRYPTO_memcmp ( EVP_CIPHER_CTX_buf_noconst ( ctx ) , in + len , EVP_GCM_TLS_TAG_LEN ) ) {
OPENSSL_cleanse ( out , len ) ;
goto err ;
}
rv = len ;
}
err : gctx -> iv_set = 0 ;
gctx -> tls_aad_len = - 1 ;
return rv ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void destroy_setvar_fifo ( setvar_fifo * fifo ) {
setvar_node * sv ;
if ( fifo != NULL ) {
do {
UNLINK_FIFO ( sv , * fifo , link ) ;
if ( sv != NULL ) {
free ( sv -> var ) ;
free ( sv -> val ) ;
free ( sv ) ;
}
}
while ( sv != NULL ) ;
free ( fifo ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void virtio_pci_config_writel ( void * opaque , uint32_t addr , uint32_t val ) {
VirtIOPCIProxy * proxy = opaque ;
uint32_t config = VIRTIO_PCI_CONFIG ( & proxy -> pci_dev ) ;
addr -= proxy -> addr ;
if ( addr < config ) {
virtio_ioport_write ( proxy , addr , val ) ;
return ;
}
addr -= config ;
virtio_config_writel ( proxy -> vdev , addr , val ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int seconds_count_format_time_units ( int seconds ) {
int minutes ;
int hours ;
if ( seconds < 0 ) {
seconds = 0 ;
}
if ( seconds < 60 ) {
return seconds ;
}
if ( seconds < 60 * 60 ) {
minutes = seconds / 60 ;
return minutes ;
}
hours = seconds / ( 60 * 60 ) ;
if ( seconds < 60 * 60 * 4 ) {
minutes = ( seconds - hours * 60 * 60 ) / 60 ;
return minutes + hours ;
}
return hours ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int handle__publish ( struct mosquitto_db * db , struct mosquitto * context ) {
char * topic ;
mosquitto__payload_uhpa payload ;
uint32_t payloadlen ;
uint8_t dup , qos , retain ;
uint16_t mid = 0 ;
int rc = 0 ;
uint8_t header = context -> in_packet . command ;
int res = 0 ;
struct mosquitto_msg_store * stored = NULL ;
int len ;
int slen ;
char * topic_mount ;
# ifdef WITH_BRIDGE char * topic_temp ;
int i ;
struct mosquitto__bridge_topic * cur_topic ;
bool match ;
# endif payload . ptr = NULL ;
dup = ( header & 0x08 ) >> 3 ;
qos = ( header & 0x06 ) >> 1 ;
if ( qos == 3 ) {
log__printf ( NULL , MOSQ_LOG_INFO , "Invalid QoS in PUBLISH from %s, disconnecting." , context -> id ) ;
return 1 ;
}
retain = ( header & 0x01 ) ;
if ( packet__read_string ( & context -> in_packet , & topic , & slen ) ) return 1 ;
if ( ! slen ) {
mosquitto__free ( topic ) ;
return 1 ;
}
# ifdef WITH_BRIDGE if ( context -> bridge && context -> bridge -> topics && context -> bridge -> topic_remapping ) {
for ( i = 0 ;
i < context -> bridge -> topic_count ;
i ++ ) {
cur_topic = & context -> bridge -> topics [ i ] ;
if ( ( cur_topic -> direction == bd_both || cur_topic -> direction == bd_in ) && ( cur_topic -> remote_prefix || cur_topic -> local_prefix ) ) {
rc = mosquitto_topic_matches_sub ( cur_topic -> remote_topic , topic , & match ) ;
if ( rc ) {
mosquitto__free ( topic ) ;
return rc ;
}
if ( match ) {
if ( cur_topic -> remote_prefix ) {
if ( ! strncmp ( cur_topic -> remote_prefix , topic , strlen ( cur_topic -> remote_prefix ) ) ) {
topic_temp = mosquitto__strdup ( topic + strlen ( cur_topic -> remote_prefix ) ) ;
if ( ! topic_temp ) {
mosquitto__free ( topic ) ;
return MOSQ_ERR_NOMEM ;
}
mosquitto__free ( topic ) ;
topic = topic_temp ;
}
}
if ( cur_topic -> local_prefix ) {
len = strlen ( topic ) + strlen ( cur_topic -> local_prefix ) + 1 ;
topic_temp = mosquitto__malloc ( len + 1 ) ;
if ( ! topic_temp ) {
mosquitto__free ( topic ) ;
return MOSQ_ERR_NOMEM ;
}
snprintf ( topic_temp , len , "%s%s" , cur_topic -> local_prefix , topic ) ;
topic_temp [ len ] = '\0' ;
mosquitto__free ( topic ) ;
topic = topic_temp ;
}
break ;
}
}
}
}
# endif if ( mosquitto_pub_topic_check ( topic ) != MOSQ_ERR_SUCCESS ) {
mosquitto__free ( topic ) ;
return 1 ;
}
if ( mosquitto_validate_utf8 ( topic , strlen ( topic ) ) != MOSQ_ERR_SUCCESS ) {
mosquitto__free ( topic ) ;
return 1 ;
}
if ( qos > 0 ) {
if ( packet__read_uint16 ( & context -> in_packet , & mid ) ) {
mosquitto__free ( topic ) ;
return 1 ;
}
}
payloadlen = context -> in_packet . remaining_length - context -> in_packet . pos ;
G_PUB_BYTES_RECEIVED_INC ( payloadlen ) ;
if ( context -> listener && context -> listener -> mount_point ) {
len = strlen ( context -> listener -> mount_point ) + strlen ( topic ) + 1 ;
topic_mount = mosquitto__malloc ( len + 1 ) ;
if ( ! topic_mount ) {
mosquitto__free ( topic ) ;
return MOSQ_ERR_NOMEM ;
}
snprintf ( topic_mount , len , "%s%s" , context -> listener -> mount_point , topic ) ;
topic_mount [ len ] = '\0' ;
mosquitto__free ( topic ) ;
topic = topic_mount ;
}
if ( payloadlen ) {
if ( db -> config -> message_size_limit && payloadlen > db -> config -> message_size_limit ) {
log__printf ( NULL , MOSQ_LOG_DEBUG , "Dropped too large PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))" , context -> id , dup , qos , retain , mid , topic , ( long ) payloadlen ) ;
goto process_bad_message ;
}
if ( UHPA_ALLOC ( payload , payloadlen + 1 ) == 0 ) {
mosquitto__free ( topic ) ;
return MOSQ_ERR_NOMEM ;
}
if ( packet__read_bytes ( & context -> in_packet , UHPA_ACCESS ( payload , payloadlen ) , payloadlen ) ) {
mosquitto__free ( topic ) ;
UHPA_FREE ( payload , payloadlen ) ;
return 1 ;
}
}
rc = mosquitto_acl_check ( db , context , topic , MOSQ_ACL_WRITE ) ;
if ( rc == MOSQ_ERR_ACL_DENIED ) {
log__printf ( NULL , MOSQ_LOG_DEBUG , "Denied PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))" , context -> id , dup , qos , retain , mid , topic , ( long ) payloadlen ) ;
goto process_bad_message ;
}
else if ( rc != MOSQ_ERR_SUCCESS ) {
mosquitto__free ( topic ) ;
UHPA_FREE ( payload , payloadlen ) ;
return rc ;
}
log__printf ( NULL , MOSQ_LOG_DEBUG , "Received PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))" , context -> id , dup , qos , retain , mid , topic , ( long ) payloadlen ) ;
if ( qos > 0 ) {
db__message_store_find ( context , mid , & stored ) ;
}
if ( ! stored ) {
dup = 0 ;
if ( db__message_store ( db , context -> id , mid , topic , qos , payloadlen , & payload , retain , & stored , 0 ) ) {
return 1 ;
}
}
else {
mosquitto__free ( topic ) ;
topic = stored -> topic ;
dup = 1 ;
}
switch ( qos ) {
case 0 : if ( sub__messages_queue ( db , context -> id , topic , qos , retain , & stored ) ) rc = 1 ;
break ;
case 1 : if ( sub__messages_queue ( db , context -> id , topic , qos , retain , & stored ) ) rc = 1 ;
if ( send__puback ( context , mid ) ) rc = 1 ;
break ;
case 2 : if ( ! dup ) {
res = db__message_insert ( db , context , mid , mosq_md_in , qos , retain , stored ) ;
}
else {
res = 0 ;
}
if ( ! res ) {
if ( send__pubrec ( context , mid ) ) rc = 1 ;
}
else if ( res == 1 ) {
rc = 1 ;
}
break ;
}
return rc ;
process_bad_message : mosquitto__free ( topic ) ;
UHPA_FREE ( payload , payloadlen ) ;
switch ( qos ) {
case 0 : return MOSQ_ERR_SUCCESS ;
case 1 : return send__puback ( context , mid ) ;
case 2 : db__message_store_find ( context , mid , & stored ) ;
if ( ! stored ) {
if ( db__message_store ( db , context -> id , mid , NULL , qos , 0 , NULL , false , & stored , 0 ) ) {
return 1 ;
}
res = db__message_insert ( db , context , mid , mosq_md_in , qos , false , stored ) ;
}
else {
res = 0 ;
}
if ( ! res ) {
res = send__pubrec ( context , mid ) ;
}
return res ;
}
return 1 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void _SCSUOpen ( UConverter * cnv , UConverterLoadArgs * pArgs , UErrorCode * pErrorCode ) {
const char * locale = pArgs -> locale ;
if ( pArgs -> onlyTestIsLoadable ) {
return ;
}
cnv -> extraInfo = uprv_malloc ( sizeof ( SCSUData ) ) ;
if ( cnv -> extraInfo != NULL ) {
if ( locale != NULL && locale [ 0 ] == 'j' && locale [ 1 ] == 'a' && ( locale [ 2 ] == 0 || locale [ 2 ] == '_' ) ) {
( ( SCSUData * ) cnv -> extraInfo ) -> locale = l_ja ;
}
else {
( ( SCSUData * ) cnv -> extraInfo ) -> locale = lGeneric ;
}
_SCSUReset ( cnv , UCNV_RESET_BOTH ) ;
}
else {
* pErrorCode = U_MEMORY_ALLOCATION_ERROR ;
}
cnv -> subUChars [ 0 ] = 0xfffd ;
cnv -> subCharLen = - 1 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void tgq_decode_mb ( TgqContext * s , int mb_y , int mb_x ) {
int mode ;
int i ;
int8_t dc [ 6 ] ;
mode = bytestream2_get_byte ( & s -> gb ) ;
if ( mode > 12 ) {
GetBitContext gb ;
init_get_bits ( & gb , s -> gb . buffer , FFMIN ( s -> gb . buffer_end - s -> gb . buffer , mode ) * 8 ) ;
for ( i = 0 ;
i < 6 ;
i ++ ) tgq_decode_block ( s , s -> block [ i ] , & gb ) ;
tgq_idct_put_mb ( s , s -> block , mb_x , mb_y ) ;
bytestream2_skip ( & s -> gb , mode ) ;
}
else {
if ( mode == 3 ) {
memset ( dc , bytestream2_get_byte ( & s -> gb ) , 4 ) ;
dc [ 4 ] = bytestream2_get_byte ( & s -> gb ) ;
dc [ 5 ] = bytestream2_get_byte ( & s -> gb ) ;
}
else if ( mode == 6 ) {
bytestream2_get_buffer ( & s -> gb , dc , 6 ) ;
}
else if ( mode == 12 ) {
for ( i = 0 ;
i < 6 ;
i ++ ) {
dc [ i ] = bytestream2_get_byte ( & s -> gb ) ;
bytestream2_skip ( & s -> gb , 1 ) ;
}
}
else {
av_log ( s -> avctx , AV_LOG_ERROR , "unsupported mb mode %i\n" , mode ) ;
}
tgq_idct_put_mb_dconly ( s , mb_x , mb_y , dc ) ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int processCompressOptions ( char * opt ) {
if ( streq ( opt , "none" ) ) compression = COMPRESSION_NONE ;
else if ( streq ( opt , "packbits" ) ) compression = COMPRESSION_PACKBITS ;
else if ( strneq ( opt , "jpeg" , 4 ) ) {
char * cp = strchr ( opt , ':' ) ;
compression = COMPRESSION_JPEG ;
while ( cp ) {
if ( isdigit ( ( int ) cp [ 1 ] ) ) quality = atoi ( cp + 1 ) ;
else if ( cp [ 1 ] == 'r' ) jpegcolormode = JPEGCOLORMODE_RAW ;
else usage ( ) ;
cp = strchr ( cp + 1 , ':' ) ;
}
}
else if ( strneq ( opt , "lzw" , 3 ) ) {
char * cp = strchr ( opt , ':' ) ;
if ( cp ) predictor = atoi ( cp + 1 ) ;
compression = COMPRESSION_LZW ;
}
else if ( strneq ( opt , "zip" , 3 ) ) {
char * cp = strchr ( opt , ':' ) ;
if ( cp ) predictor = atoi ( cp + 1 ) ;
compression = COMPRESSION_DEFLATE ;
}
else return ( 0 ) ;
return ( 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int is_background ( const VP9_COMP * cpi , const TileInfo * const tile , int mi_row , int mi_col ) {
const int row8x8_remaining = tile -> mi_row_end - mi_row ;
const int col8x8_remaining = tile -> mi_col_end - mi_col ;
const int x = mi_col * MI_SIZE ;
const int y = mi_row * MI_SIZE ;
const int src_stride = cpi -> Source -> y_stride ;
const uint8_t * const src = & cpi -> Source -> y_buffer [ y * src_stride + x ] ;
const int pre_stride = cpi -> Last_Source -> y_stride ;
const uint8_t * const pre = & cpi -> Last_Source -> y_buffer [ y * pre_stride + x ] ;
int this_sad = 0 ;
int threshold = 0 ;
if ( row8x8_remaining >= MI_BLOCK_SIZE && col8x8_remaining >= MI_BLOCK_SIZE ) {
this_sad = cpi -> fn_ptr [ BLOCK_64X64 ] . sdf ( src , src_stride , pre , pre_stride ) ;
threshold = ( 1 << 12 ) ;
}
else {
int r , c ;
for ( r = 0 ;
r < row8x8_remaining ;
r += 2 ) for ( c = 0 ;
c < col8x8_remaining ;
c += 2 ) this_sad += cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src , src_stride , pre , pre_stride ) ;
threshold = ( row8x8_remaining * col8x8_remaining ) << 6 ;
}
return this_sad < 2 * threshold ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void help ( const char * progname ) {
printf ( _ ( "%s cleans and analyzes a PostgreSQL database.\n\n" ) , progname ) ;
printf ( _ ( "Usage:\n" ) ) ;
printf ( _ ( " %s [OPTION]... [DBNAME]\n" ) , progname ) ;
printf ( _ ( "\nOptions:\n" ) ) ;
printf ( _ ( " -a, --all vacuum all databases\n" ) ) ;
printf ( _ ( " -d, --dbname=DBNAME database to vacuum\n" ) ) ;
printf ( _ ( " -e, --echo show the commands being sent to the server\n" ) ) ;
printf ( _ ( " -f, --full do full vacuuming\n" ) ) ;
printf ( _ ( " -F, --freeze freeze row transaction information\n" ) ) ;
printf ( _ ( " -j, --jobs=NUM use this many concurrent connections to vacuum\n" ) ) ;
printf ( _ ( " -q, --quiet don't write any messages\n" ) ) ;
printf ( _ ( " -t, --table='TABLE[(COLUMNS)]' vacuum specific table(s) only\n" ) ) ;
printf ( _ ( " -v, --verbose write a lot of output\n" ) ) ;
printf ( _ ( " -V, --version output version information, then exit\n" ) ) ;
printf ( _ ( " -z, --analyze update optimizer statistics\n" ) ) ;
printf ( _ ( " -Z, --analyze-only only update optimizer statistics;
no vacuum\n" ) ) ;
printf ( _ ( " --analyze-in-stages only update optimizer statistics, in multiple\n" " stages for faster results;
no vacuum\n" ) ) ;
printf ( _ ( " -?, --help show this help, then exit\n" ) ) ;
printf ( _ ( "\nConnection options:\n" ) ) ;
printf ( _ ( " -h, --host=HOSTNAME database server host or socket directory\n" ) ) ;
printf ( _ ( " -p, --port=PORT database server port\n" ) ) ;
printf ( _ ( " -U, --username=USERNAME user name to connect as\n" ) ) ;
printf ( _ ( " -w, --no-password never prompt for password\n" ) ) ;
printf ( _ ( " -W, --password force password prompt\n" ) ) ;
printf ( _ ( " --maintenance-db=DBNAME alternate maintenance database\n" ) ) ;
printf ( _ ( "\nRead the description of the SQL command VACUUM for details.\n" ) ) ;
printf ( _ ( "\nReport bugs to <[email protected]>.\n" ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int aes_ccm_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_CCM_CTX * cctx = EVP_C_DATA ( EVP_AES_CCM_CTX , c ) ;
switch ( type ) {
case EVP_CTRL_INIT : cctx -> key_set = 0 ;
cctx -> iv_set = 0 ;
cctx -> L = 8 ;
cctx -> M = 12 ;
cctx -> tag_set = 0 ;
cctx -> len_set = 0 ;
cctx -> tls_aad_len = - 1 ;
return 1 ;
case EVP_CTRL_AEAD_TLS1_AAD : if ( arg != EVP_AEAD_TLS1_AAD_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
cctx -> tls_aad_len = arg ;
{
uint16_t len = EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] << 8 | EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] ;
len -= EVP_CCM_TLS_EXPLICIT_IV_LEN ;
if ( ! EVP_CIPHER_CTX_encrypting ( c ) ) len -= cctx -> M ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] = len >> 8 ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] = len & 0xff ;
}
return cctx -> M ;
case EVP_CTRL_CCM_SET_IV_FIXED : if ( arg != EVP_CCM_TLS_FIXED_IV_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_iv_noconst ( c ) , ptr , arg ) ;
return 1 ;
case EVP_CTRL_AEAD_SET_IVLEN : arg = 15 - arg ;
case EVP_CTRL_CCM_SET_L : if ( arg < 2 || arg > 8 ) return 0 ;
cctx -> L = arg ;
return 1 ;
case EVP_CTRL_AEAD_SET_TAG : if ( ( arg & 1 ) || arg < 4 || arg > 16 ) return 0 ;
if ( EVP_CIPHER_CTX_encrypting ( c ) && ptr ) return 0 ;
if ( ptr ) {
cctx -> tag_set = 1 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
}
cctx -> M = arg ;
return 1 ;
case EVP_CTRL_AEAD_GET_TAG : if ( ! EVP_CIPHER_CTX_encrypting ( c ) || ! cctx -> tag_set ) return 0 ;
if ( ! CRYPTO_ccm128_tag ( & cctx -> ccm , ptr , ( size_t ) arg ) ) return 0 ;
cctx -> tag_set = 0 ;
cctx -> iv_set = 0 ;
cctx -> len_set = 0 ;
return 1 ;
case EVP_CTRL_COPY : {
EVP_CIPHER_CTX * out = ptr ;
EVP_AES_CCM_CTX * cctx_out = EVP_C_DATA ( EVP_AES_CCM_CTX , out ) ;
if ( cctx -> ccm . key ) {
if ( cctx -> ccm . key != & cctx -> ks ) return 0 ;
cctx_out -> ccm . key = & cctx_out -> ks ;
}
return 1 ;
}
default : return - 1 ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static COMMANDS * find_command ( char * name ) {
uint len ;
char * end ;
DBUG_ENTER ( "find_command" ) ;
DBUG_ASSERT ( name != NULL ) ;
DBUG_PRINT ( "enter" , ( "name: '%s'" , name ) ) ;
while ( my_isspace ( charset_info , * name ) ) name ++ ;
if ( ( ! real_binary_mode && strstr ( name , "\\g" ) ) || ( strstr ( name , delimiter ) && ! is_delimiter_command ( name , DELIMITER_NAME_LEN ) ) ) DBUG_RETURN ( ( COMMANDS * ) 0 ) ;
if ( ( end = strcont ( name , " \t" ) ) ) {
len = ( uint ) ( end - name ) ;
while ( my_isspace ( charset_info , * end ) ) end ++ ;
if ( ! * end ) end = 0 ;
}
else len = ( uint ) strlen ( name ) ;
int index = - 1 ;
if ( real_binary_mode ) {
if ( is_delimiter_command ( name , len ) ) index = delimiter_index ;
}
else {
for ( uint i = 0 ;
commands [ i ] . func ;
i ++ ) {
if ( ! my_strnncoll ( & my_charset_latin1 , ( uchar * ) name , len , ( uchar * ) commands [ i ] . name , len ) && ( commands [ i ] . name [ len ] == '\0' ) && ( ! end || commands [ i ] . takes_params ) ) {
index = i ;
break ;
}
}
}
if ( index >= 0 ) {
DBUG_PRINT ( "exit" , ( "found command: %s" , commands [ index ] . name ) ) ;
DBUG_RETURN ( & commands [ index ] ) ;
}
DBUG_RETURN ( ( COMMANDS * ) 0 ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int xhci_fire_ctl_transfer ( XHCIState * xhci , XHCITransfer * xfer ) {
XHCITRB * trb_setup , * trb_status ;
uint8_t bmRequestType ;
trb_setup = & xfer -> trbs [ 0 ] ;
trb_status = & xfer -> trbs [ xfer -> trb_count - 1 ] ;
trace_usb_xhci_xfer_start ( xfer , xfer -> epctx -> slotid , xfer -> epctx -> epid , xfer -> streamid ) ;
if ( TRB_TYPE ( * trb_status ) == TR_EVDATA && xfer -> trb_count > 2 ) {
trb_status -- ;
}
if ( TRB_TYPE ( * trb_setup ) != TR_SETUP ) {
DPRINTF ( "xhci: ep0 first TD not SETUP: %d\n" , TRB_TYPE ( * trb_setup ) ) ;
return - 1 ;
}
if ( TRB_TYPE ( * trb_status ) != TR_STATUS ) {
DPRINTF ( "xhci: ep0 last TD not STATUS: %d\n" , TRB_TYPE ( * trb_status ) ) ;
return - 1 ;
}
if ( ! ( trb_setup -> control & TRB_TR_IDT ) ) {
DPRINTF ( "xhci: Setup TRB doesn't have IDT set\n" ) ;
return - 1 ;
}
if ( ( trb_setup -> status & 0x1ffff ) != 8 ) {
DPRINTF ( "xhci: Setup TRB has bad length (%d)\n" , ( trb_setup -> status & 0x1ffff ) ) ;
return - 1 ;
}
bmRequestType = trb_setup -> parameter ;
xfer -> in_xfer = bmRequestType & USB_DIR_IN ;
xfer -> iso_xfer = false ;
xfer -> timed_xfer = false ;
if ( xhci_setup_packet ( xfer ) < 0 ) {
return - 1 ;
}
xfer -> packet . parameter = trb_setup -> parameter ;
usb_handle_packet ( xfer -> packet . ep -> dev , & xfer -> packet ) ;
xhci_try_complete_packet ( xfer ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( FullscreenControllerInteractiveTest , MAYBE_MouseLockSilentAfterTargetUnlock ) {
ASSERT_TRUE ( test_server ( ) -> Start ( ) ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , test_server ( ) -> GetURL ( kFullscreenMouseLockHTML ) ) ;
ASSERT_FALSE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_1 , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_TRUE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( IsMouseLockPermissionRequested ( ) ) ;
ASSERT_FALSE ( IsMouseLocked ( ) ) ;
AcceptCurrentFullscreenOrMouseLockRequest ( ) ;
ASSERT_TRUE ( IsMouseLocked ( ) ) ;
ASSERT_TRUE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_U , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_FALSE ( IsMouseLocked ( ) ) ;
ASSERT_FALSE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_1 , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_TRUE ( IsMouseLocked ( ) ) ;
ASSERT_FALSE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_U , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_FALSE ( IsMouseLocked ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_D , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_TRUE ( IsMouseLocked ( ) ) ;
ASSERT_FALSE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_ESCAPE , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_FALSE ( IsMouseLocked ( ) ) ;
ASSERT_TRUE ( ui_test_utils : : SendKeyPressAndWait ( browser ( ) , ui : : VKEY_1 , false , false , false , false , chrome : : NOTIFICATION_MOUSE_LOCK_CHANGED , content : : NotificationService : : AllSources ( ) ) ) ;
ASSERT_TRUE ( IsFullscreenBubbleDisplayed ( ) ) ;
ASSERT_TRUE ( IsMouseLocked ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int qemuMonitorJSONChangeMedia ( qemuMonitorPtr mon , const char * dev_name , const char * newmedia , const char * format ) {
int ret ;
virJSONValuePtr cmd ;
if ( format ) cmd = qemuMonitorJSONMakeCommand ( "change" , "s:device" , dev_name , "s:target" , newmedia , "s:arg" , format , NULL ) ;
else cmd = qemuMonitorJSONMakeCommand ( "change" , "s:device" , dev_name , "s:target" , newmedia , NULL ) ;
virJSONValuePtr reply = NULL ;
if ( ! cmd ) return - 1 ;
ret = qemuMonitorJSONCommand ( mon , cmd , & reply ) ;
if ( ret == 0 ) ret = qemuMonitorJSONCheckError ( cmd , reply ) ;
virJSONValueFree ( cmd ) ;
virJSONValueFree ( reply ) ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void xsltFreeLocales ( void ) {
# ifdef XSLT_LOCALE_WINAPI xmlRMutexLock ( xsltLocaleMutex ) ;
xmlFree ( xsltLocaleList ) ;
xsltLocaleList = NULL ;
xmlRMutexUnlock ( xsltLocaleMutex ) ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static u16 transaction_id_pick ( void ) {
for ( ;
;
) {
const struct request * req = req_head , * started_at ;
u16 trans_id = trans_id_function ( ) ;
if ( trans_id == 0xffff ) continue ;
req = started_at = req_head ;
if ( req ) {
do {
if ( req -> trans_id == trans_id ) break ;
req = req -> next ;
}
while ( req != started_at ) ;
}
if ( req == started_at ) return trans_id ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int best_effort_strncat_in_locale ( struct archive_string * as , const void * _p , size_t length , struct archive_string_conv * sc ) {
size_t remaining ;
const uint8_t * itp ;
int return_value = 0 ;
if ( sc -> same ) {
if ( archive_string_append ( as , _p , length ) == NULL ) return ( - 1 ) ;
return ( invalid_mbs ( _p , length , sc ) ) ;
}
remaining = length ;
itp = ( const uint8_t * ) _p ;
while ( * itp && remaining > 0 ) {
if ( * itp > 127 ) {
if ( sc -> flag & SCONV_TO_UTF8 ) {
if ( archive_string_append ( as , utf8_replacement_char , sizeof ( utf8_replacement_char ) ) == NULL ) {
__archive_errx ( 1 , "Out of memory" ) ;
}
}
else {
archive_strappend_char ( as , '?' ) ;
}
return_value = - 1 ;
}
else {
archive_strappend_char ( as , * itp ) ;
}
++ itp ;
}
return ( return_value ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void set_num_731 ( unsigned char * p , uint32_t value ) {
archive_le32enc ( p , value ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int get_file_params_count_resume ( char * * params , int paramcount ) {
int pos , best ;
if ( * params [ 0 ] == '"' ) {
for ( pos = 0 ;
pos < paramcount - 2 ;
pos ++ ) {
if ( strlen ( params [ pos ] ) == 0 ) continue ;
if ( params [ pos ] [ strlen ( params [ pos ] ) - 1 ] == '"' && get_params_match_resume ( params , pos + 1 ) ) return pos + 1 ;
}
}
best = paramcount - 2 ;
for ( pos = paramcount - 2 ;
pos > 0 ;
pos -- ) {
if ( get_params_match_resume ( params , pos ) ) best = pos ;
}
return best ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void mark_desktop_file_executable_task_thread_func ( GTask * task , gpointer source_object , gpointer task_data , GCancellable * cancellable ) {
MarkTrustedJob * job = task_data ;
CommonJob * common ;
common = ( CommonJob * ) job ;
nautilus_progress_info_start ( job -> common . progress ) ;
mark_desktop_file_executable ( common , cancellable , job -> file , job -> interactive ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const char * integer32_avp ( diam_ctx_t * c , diam_avp_t * a , tvbuff_t * tvb , diam_sub_dis_t * diam_sub_dis_inf _U_ ) {
char * label = NULL ;
proto_item * pi ;
gint length = tvb_reported_length ( tvb ) ;
if ( length == 4 ) {
if ( c -> tree ) {
pi = proto_tree_add_item ( c -> tree , a -> hf_value , tvb , 0 , length , ENC_BIG_ENDIAN ) ;
label = ( char * ) wmem_alloc ( wmem_packet_scope ( ) , ITEM_LABEL_LENGTH + 1 ) ;
proto_item_fill_label ( PITEM_FINFO ( pi ) , label ) ;
label = strstr ( label , ": " ) + 2 ;
}
}
else {
pi = proto_tree_add_bytes_format ( c -> tree , hf_diameter_avp_data_wrong_length , tvb , 0 , length , NULL , "Error! Bad Integer32 Length" ) ;
expert_add_info_format ( c -> pinfo , pi , & ei_diameter_avp_len , "Bad Integer32 Length (%u)" , length ) ;
PROTO_ITEM_SET_GENERATED ( pi ) ;
}
return label ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int config_module_parser_apply_changes ( struct config_module_parser * dest , const struct config_filter_parser * src , pool_t pool , const char * * error_r ) {
const char * conflict_key ;
unsigned int i ;
for ( i = 0 ;
dest [ i ] . root != NULL ;
i ++ ) {
if ( settings_parser_apply_changes ( dest [ i ] . parser , src -> parsers [ i ] . parser , pool , error_r == NULL ? NULL : & conflict_key ) < 0 ) {
i_assert ( error_r != NULL ) ;
* error_r = t_strdup_printf ( "Conflict in setting %s " "found from filter at %s" , conflict_key , src -> file_and_line ) ;
return - 1 ;
}
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( ShortcutsBackendTest , DeleteShortcuts ) {
InitBackend ( ) ;
ShortcutsDatabase : : Shortcut shortcut1 ( "BD85DBA2-8C29-49F9-84AE-48E1E90880DF" , base : : ASCIIToUTF16 ( "goog" ) , MatchCoreForTesting ( "http://www.google.com" ) , base : : Time : : Now ( ) , 100 ) ;
EXPECT_TRUE ( AddShortcut ( shortcut1 ) ) ;
ShortcutsDatabase : : Shortcut shortcut2 ( "BD85DBA2-8C29-49F9-84AE-48E1E90880E0" , base : : ASCIIToUTF16 ( "gle" ) , MatchCoreForTesting ( "http://www.google.com" ) , base : : Time : : Now ( ) , 100 ) ;
EXPECT_TRUE ( AddShortcut ( shortcut2 ) ) ;
ShortcutsDatabase : : Shortcut shortcut3 ( "BD85DBA2-8C29-49F9-84AE-48E1E90880E1" , base : : ASCIIToUTF16 ( "sp" ) , MatchCoreForTesting ( "http://www.sport.com" ) , base : : Time : : Now ( ) , 10 ) ;
EXPECT_TRUE ( AddShortcut ( shortcut3 ) ) ;
ShortcutsDatabase : : Shortcut shortcut4 ( "BD85DBA2-8C29-49F9-84AE-48E1E90880E2" , base : : ASCIIToUTF16 ( "mov" ) , MatchCoreForTesting ( "http://www.film.com" ) , base : : Time : : Now ( ) , 10 ) ;
EXPECT_TRUE ( AddShortcut ( shortcut4 ) ) ;
ASSERT_EQ ( 4U , shortcuts_map ( ) . size ( ) ) ;
EXPECT_EQ ( shortcut1 . id , shortcuts_map ( ) . find ( shortcut1 . text ) -> second . id ) ;
EXPECT_EQ ( shortcut2 . id , shortcuts_map ( ) . find ( shortcut2 . text ) -> second . id ) ;
EXPECT_EQ ( shortcut3 . id , shortcuts_map ( ) . find ( shortcut3 . text ) -> second . id ) ;
EXPECT_EQ ( shortcut4 . id , shortcuts_map ( ) . find ( shortcut4 . text ) -> second . id ) ;
EXPECT_TRUE ( DeleteShortcutsWithURL ( shortcut1 . match_core . destination_url ) ) ;
ASSERT_EQ ( 2U , shortcuts_map ( ) . size ( ) ) ;
EXPECT_EQ ( 0U , shortcuts_map ( ) . count ( shortcut1 . text ) ) ;
EXPECT_EQ ( 0U , shortcuts_map ( ) . count ( shortcut2 . text ) ) ;
const ShortcutsBackend : : ShortcutMap : : const_iterator shortcut3_iter ( shortcuts_map ( ) . find ( shortcut3 . text ) ) ;
ASSERT_TRUE ( shortcut3_iter != shortcuts_map ( ) . end ( ) ) ;
EXPECT_EQ ( shortcut3 . id , shortcut3_iter -> second . id ) ;
const ShortcutsBackend : : ShortcutMap : : const_iterator shortcut4_iter ( shortcuts_map ( ) . find ( shortcut4 . text ) ) ;
ASSERT_TRUE ( shortcut4_iter != shortcuts_map ( ) . end ( ) ) ;
EXPECT_EQ ( shortcut4 . id , shortcut4_iter -> second . id ) ;
ShortcutsDatabase : : ShortcutIDs deleted_ids ;
deleted_ids . push_back ( shortcut3 . id ) ;
deleted_ids . push_back ( shortcut4 . id ) ;
EXPECT_TRUE ( DeleteShortcutsWithIDs ( deleted_ids ) ) ;
ASSERT_EQ ( 0U , shortcuts_map ( ) . size ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_T_raw ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 881 "./asn1/h225/h225.cnf" tvbuff_t * value_tvb ;
gef_ctx_t * gefx ;
proto_item * ti ;
offset = dissect_per_octet_string ( tvb , offset , actx , tree , hf_index , NO_BOUND , NO_BOUND , FALSE , & value_tvb ) ;
gefx = gef_ctx_get ( actx -> private_data ) ;
if ( gefx ) {
ti = proto_tree_add_string ( tree , hf_h225_debug_dissector_try_string , tvb , offset >> 3 , 0 , gefx -> key ) ;
PROTO_ITEM_SET_HIDDEN ( ti ) ;
dissector_try_string ( gef_content_dissector_table , gefx -> key , value_tvb , actx -> pinfo , tree , actx ) ;
}
return offset ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static bool contain_mutable_functions_checker ( Oid func_id , void * context ) {
return ( func_volatile ( func_id ) != PROVOLATILE_IMMUTABLE ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int mem_word_get_bits_rectangle ( gx_device * dev , const gs_int_rect * prect , gs_get_bits_params_t * params , gs_int_rect * * unread ) {
gx_device_memory * const mdev = ( gx_device_memory * ) dev ;
byte * src ;
uint dev_raster = gx_device_raster ( dev , 1 ) ;
int x = prect -> p . x ;
int w = prect -> q . x - x ;
int y = prect -> p . y ;
int h = prect -> q . y - y ;
int bit_x , bit_w ;
int code ;
fit_fill_xywh ( dev , x , y , w , h ) ;
if ( w <= 0 || h <= 0 ) {
x = y = w = h = 0 ;
}
bit_x = x * dev -> color_info . depth ;
bit_w = w * dev -> color_info . depth ;
src = scan_line_base ( mdev , y ) ;
mem_swap_byte_rect ( src , dev_raster , bit_x , bit_w , h , false ) ;
code = mem_get_bits_rectangle ( dev , prect , params , unread ) ;
mem_swap_byte_rect ( src , dev_raster , bit_x , bit_w , h , false ) ;
return code ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int evdns_request_transmit_to ( struct request * req , struct nameserver * server ) {
struct sockaddr_in sin ;
int r ;
memset ( & sin , 0 , sizeof ( sin ) ) ;
sin . sin_addr . s_addr = req -> ns -> address ;
sin . sin_port = req -> ns -> port ;
sin . sin_family = AF_INET ;
r = sendto ( server -> socket , req -> request , req -> request_len , 0 , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ;
if ( r < 0 ) {
int err = last_error ( server -> socket ) ;
if ( error_is_eagain ( err ) ) return 1 ;
nameserver_failed ( req -> ns , strerror ( err ) ) ;
return 2 ;
}
else if ( r != ( int ) req -> request_len ) {
return 1 ;
}
else {
return 0 ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | GSList * mainwindows_get_line ( MAIN_WINDOW_REC * rec ) {
MAIN_WINDOW_REC * win ;
GSList * list ;
list = NULL ;
for ( win = mainwindows_find_left ( rec , FALSE ) ;
win != NULL ;
win = mainwindows_find_left ( win , FALSE ) ) {
list = g_slist_append ( list , win ) ;
}
if ( rec != NULL ) list = g_slist_append ( list , rec ) ;
for ( win = mainwindows_find_right ( rec , FALSE ) ;
win != NULL ;
win = mainwindows_find_right ( win , FALSE ) ) {
list = g_slist_append ( list , win ) ;
}
return list ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void evhttp_read_firstline ( struct evhttp_connection * evcon , struct evhttp_request * req ) {
enum message_read_status res ;
res = evhttp_parse_firstline ( req , evcon -> input_buffer ) ;
if ( res == DATA_CORRUPTED ) {
event_debug ( ( "%s: bad header lines on %d\n" , __func__ , evcon -> fd ) ) ;
evhttp_connection_fail ( evcon , EVCON_HTTP_INVALID_HEADER ) ;
return ;
}
else if ( res == MORE_DATA_EXPECTED ) {
evhttp_add_event ( & evcon -> ev , evcon -> timeout , HTTP_READ_TIMEOUT ) ;
return ;
}
evcon -> state = EVCON_READING_HEADERS ;
evhttp_read_header ( evcon , req ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( ExternalProtocolHandlerTest , TestGetBlockStateUnknown ) {
ExternalProtocolHandler : : BlockState block_state = ExternalProtocolHandler : : GetBlockState ( "tel" , profile_ . get ( ) ) ;
EXPECT_EQ ( ExternalProtocolHandler : : UNKNOWN , block_state ) ;
EXPECT_TRUE ( local_state_ -> GetDictionary ( prefs : : kExcludedSchemes ) -> empty ( ) ) ;
EXPECT_TRUE ( profile_ -> GetPrefs ( ) -> GetDictionary ( prefs : : kExcludedSchemes ) -> empty ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int write_output ( void ) {
int fd ;
struct filter_op * fop ;
struct filter_header fh ;
size_t ninst , i ;
u_char * data ;
ninst = compile_tree ( & fop ) ;
if ( fop == NULL ) return - E_NOTHANDLED ;
fd = open ( EF_GBL_OPTIONS -> output_file , O_CREAT | O_RDWR | O_TRUNC | O_BINARY , 0644 ) ;
ON_ERROR ( fd , - 1 , "Can't create file %s" , EF_GBL_OPTIONS -> output_file ) ;
fprintf ( stdout , " Writing output to \'%s\' " , EF_GBL_OPTIONS -> output_file ) ;
fflush ( stdout ) ;
fh . magic = htons ( EC_FILTER_MAGIC ) ;
strncpy ( fh . version , EC_VERSION , sizeof ( fh . version ) ) ;
fh . data = sizeof ( fh ) ;
data = create_data_segment ( & fh , fop , ninst ) ;
write ( fd , & fh , sizeof ( struct filter_header ) ) ;
write ( fd , data , fh . code - fh . data ) ;
for ( i = 0 ;
i <= ninst ;
i ++ ) {
print_progress_bar ( & fop [ i ] ) ;
write ( fd , & fop [ i ] , sizeof ( struct filter_op ) ) ;
}
close ( fd ) ;
fprintf ( stdout , " done.\n\n" ) ;
fprintf ( stdout , " -> Script encoded into %d instructions.\n\n" , ( int ) ( i - 1 ) ) ;
return E_SUCCESS ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_SET_SIZE_1_256_OF_CommunicationModeTableEntry ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_constrained_set_of ( tvb , offset , actx , tree , hf_index , ett_h245_SET_SIZE_1_256_OF_CommunicationModeTableEntry , SET_SIZE_1_256_OF_CommunicationModeTableEntry_set_of , 1 , 256 , FALSE ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void write_crash_report ( const char * err ) {
char * loc = git_pathdup ( "fast_import_crash_%" PRIuMAX , ( uintmax_t ) getpid ( ) ) ;
FILE * rpt = fopen ( loc , "w" ) ;
struct branch * b ;
unsigned long lu ;
struct recent_command * rc ;
if ( ! rpt ) {
error ( "can't write crash report %s: %s" , loc , strerror ( errno ) ) ;
free ( loc ) ;
return ;
}
fprintf ( stderr , "fast-import: dumping crash report to %s\n" , loc ) ;
fprintf ( rpt , "fast-import crash report:\n" ) ;
fprintf ( rpt , " fast-import process: %" PRIuMAX "\n" , ( uintmax_t ) getpid ( ) ) ;
fprintf ( rpt , " parent process : %" PRIuMAX "\n" , ( uintmax_t ) getppid ( ) ) ;
fprintf ( rpt , " at %s\n" , show_date ( time ( NULL ) , 0 , DATE_MODE ( LOCAL ) ) ) ;
fputc ( '\n' , rpt ) ;
fputs ( "fatal: " , rpt ) ;
fputs ( err , rpt ) ;
fputc ( '\n' , rpt ) ;
fputc ( '\n' , rpt ) ;
fputs ( "Most Recent Commands Before Crash\n" , rpt ) ;
fputs ( "---------------------------------\n" , rpt ) ;
for ( rc = cmd_hist . next ;
rc != & cmd_hist ;
rc = rc -> next ) {
if ( rc -> next == & cmd_hist ) fputs ( "* " , rpt ) ;
else fputs ( " " , rpt ) ;
fputs ( rc -> buf , rpt ) ;
fputc ( '\n' , rpt ) ;
}
fputc ( '\n' , rpt ) ;
fputs ( "Active Branch LRU\n" , rpt ) ;
fputs ( "-----------------\n" , rpt ) ;
fprintf ( rpt , " active_branches = %lu cur, %lu max\n" , cur_active_branches , max_active_branches ) ;
fputc ( '\n' , rpt ) ;
fputs ( " pos clock name\n" , rpt ) ;
fputs ( " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" , rpt ) ;
for ( b = active_branches , lu = 0 ;
b ;
b = b -> active_next_branch ) fprintf ( rpt , " %2lu) %6" PRIuMAX " %s\n" , ++ lu , b -> last_commit , b -> name ) ;
fputc ( '\n' , rpt ) ;
fputs ( "Inactive Branches\n" , rpt ) ;
fputs ( "-----------------\n" , rpt ) ;
for ( lu = 0 ;
lu < branch_table_sz ;
lu ++ ) {
for ( b = branch_table [ lu ] ;
b ;
b = b -> table_next_branch ) write_branch_report ( rpt , b ) ;
}
if ( first_tag ) {
struct tag * tg ;
fputc ( '\n' , rpt ) ;
fputs ( "Annotated Tags\n" , rpt ) ;
fputs ( "--------------\n" , rpt ) ;
for ( tg = first_tag ;
tg ;
tg = tg -> next_tag ) {
fputs ( sha1_to_hex ( tg -> sha1 ) , rpt ) ;
fputc ( ' ' , rpt ) ;
fputs ( tg -> name , rpt ) ;
fputc ( '\n' , rpt ) ;
}
}
fputc ( '\n' , rpt ) ;
fputs ( "Marks\n" , rpt ) ;
fputs ( "-----\n" , rpt ) ;
if ( export_marks_file ) fprintf ( rpt , " exported to %s\n" , export_marks_file ) ;
else dump_marks_helper ( rpt , 0 , marks ) ;
fputc ( '\n' , rpt ) ;
fputs ( "-------------------\n" , rpt ) ;
fputs ( "END OF CRASH REPORT\n" , rpt ) ;
fclose ( rpt ) ;
free ( loc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int qio_channel_websock_decode_header ( QIOChannelWebsock * ioc , Error * * errp ) {
unsigned char opcode , fin , has_mask ;
size_t header_size ;
size_t payload_len ;
QIOChannelWebsockHeader * header = ( QIOChannelWebsockHeader * ) ioc -> encinput . buffer ;
if ( ioc -> payload_remain ) {
error_setg ( errp , "Decoding header but %zu bytes of payload remain" , ioc -> payload_remain ) ;
qio_channel_websock_write_close ( ioc , QIO_CHANNEL_WEBSOCK_STATUS_SERVER_ERR , "internal server error" ) ;
return - 1 ;
}
if ( ioc -> encinput . offset < QIO_CHANNEL_WEBSOCK_HEADER_LEN_7_BIT ) {
return QIO_CHANNEL_ERR_BLOCK ;
}
fin = header -> b0 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_FIN ;
opcode = header -> b0 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE ;
has_mask = header -> b1 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_HAS_MASK ;
payload_len = header -> b1 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_PAYLOAD_LEN ;
if ( opcode ) {
ioc -> opcode = opcode ;
}
else {
opcode = ioc -> opcode ;
}
trace_qio_channel_websock_header_partial_decode ( ioc , payload_len , fin , opcode , ( int ) has_mask ) ;
if ( opcode == QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE ) {
return 0 ;
}
if ( ! fin ) {
if ( opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME ) {
error_setg ( errp , "only binary websocket frames may be fragmented" ) ;
qio_channel_websock_write_close ( ioc , QIO_CHANNEL_WEBSOCK_STATUS_POLICY , "only binary frames may be fragmented" ) ;
return - 1 ;
}
}
else {
if ( opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME && opcode != QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE && opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PING && opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PONG ) {
error_setg ( errp , "unsupported opcode: %#04x;
only binary, close, " "ping, and pong websocket frames are supported" , opcode ) ;
qio_channel_websock_write_close ( ioc , QIO_CHANNEL_WEBSOCK_STATUS_INVALID_DATA , "only binary, close, ping, and pong frames are supported" ) ;
return - 1 ;
}
}
if ( ! has_mask ) {
error_setg ( errp , "client websocket frames must be masked" ) ;
qio_channel_websock_write_close ( ioc , QIO_CHANNEL_WEBSOCK_STATUS_PROTOCOL_ERR , "client frames must be masked" ) ;
return - 1 ;
}
if ( payload_len < QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT ) {
ioc -> payload_remain = payload_len ;
header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_7_BIT ;
ioc -> mask = header -> u . m ;
}
else if ( opcode & QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK ) {
error_setg ( errp , "websocket control frame is too large" ) ;
qio_channel_websock_write_close ( ioc , QIO_CHANNEL_WEBSOCK_STATUS_PROTOCOL_ERR , "control frame is too large" ) ;
return - 1 ;
}
else if ( payload_len == QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT && ioc -> encinput . offset >= QIO_CHANNEL_WEBSOCK_HEADER_LEN_16_BIT ) {
ioc -> payload_remain = be16_to_cpu ( header -> u . s16 . l16 ) ;
header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_16_BIT ;
ioc -> mask = header -> u . s16 . m16 ;
}
else if ( payload_len == QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_64_BIT && ioc -> encinput . offset >= QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT ) {
ioc -> payload_remain = be64_to_cpu ( header -> u . s64 . l64 ) ;
header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT ;
ioc -> mask = header -> u . s64 . m64 ;
}
else {
return QIO_CHANNEL_ERR_BLOCK ;
}
trace_qio_channel_websock_header_full_decode ( ioc , header_size , ioc -> payload_remain , ioc -> mask . u ) ;
buffer_advance ( & ioc -> encinput , header_size ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void rfbReleaseClientIterator ( rfbClientIteratorPtr iterator ) {
IF_PTHREADS ( if ( iterator -> next ) rfbDecrClientRef ( iterator -> next ) ) ;
free ( iterator ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ImportIndexQuantum ( const Image * image , QuantumInfo * quantum_info , const MagickSizeType number_pixels , const unsigned char * magick_restrict p , Quantum * magick_restrict q , ExceptionInfo * exception ) {
MagickBooleanType range_exception ;
register ssize_t x ;
ssize_t bit ;
unsigned int pixel ;
if ( image -> storage_class != PseudoClass ) {
( void ) ThrowMagickException ( exception , GetMagickModule ( ) , ImageError , "ColormappedImageRequired" , "`%s'" , image -> filename ) ;
return ;
}
range_exception = MagickFalse ;
switch ( quantum_info -> depth ) {
case 1 : {
register unsigned char pixel ;
for ( x = 0 ;
x < ( ( ssize_t ) number_pixels - 7 ) ;
x += 8 ) {
for ( bit = 0 ;
bit < 8 ;
bit ++ ) {
if ( quantum_info -> min_is_white == MagickFalse ) pixel = ( unsigned char ) ( ( ( * p ) & ( 1 << ( 7 - bit ) ) ) == 0 ? 0x00 : 0x01 ) ;
else pixel = ( unsigned char ) ( ( ( * p ) & ( 1 << ( 7 - bit ) ) ) != 0 ? 0x00 : 0x01 ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
q += GetPixelChannels ( image ) ;
}
p ++ ;
}
for ( bit = 0 ;
bit < ( ssize_t ) ( number_pixels % 8 ) ;
bit ++ ) {
if ( quantum_info -> min_is_white == MagickFalse ) pixel = ( unsigned char ) ( ( ( * p ) & ( 1 << ( 7 - bit ) ) ) == 0 ? 0x00 : 0x01 ) ;
else pixel = ( unsigned char ) ( ( ( * p ) & ( 1 << ( 7 - bit ) ) ) != 0 ? 0x00 : 0x01 ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 4 : {
register unsigned char pixel ;
for ( x = 0 ;
x < ( ( ssize_t ) number_pixels - 1 ) ;
x += 2 ) {
pixel = ( unsigned char ) ( ( * p >> 4 ) & 0xf ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
q += GetPixelChannels ( image ) ;
pixel = ( unsigned char ) ( ( * p ) & 0xf ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p ++ ;
q += GetPixelChannels ( image ) ;
}
for ( bit = 0 ;
bit < ( ssize_t ) ( number_pixels % 2 ) ;
bit ++ ) {
pixel = ( unsigned char ) ( ( * p ++ >> 4 ) & 0xf ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 8 : {
unsigned char pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushCharPixel ( p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 16 : {
unsigned short pixel ;
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , ClampToQuantum ( ( double ) QuantumRange * HalfToSinglePrecision ( pixel ) ) , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 32 : {
unsigned int pixel ;
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
float pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushFloatPixel ( quantum_info , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , ClampToQuantum ( pixel ) , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
case 64 : {
if ( quantum_info -> format == FloatingPointQuantumFormat ) {
double pixel ;
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushDoublePixel ( quantum_info , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , ClampToQuantum ( pixel ) , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
}
default : {
for ( x = 0 ;
x < ( ssize_t ) number_pixels ;
x ++ ) {
p = PushQuantumPixel ( quantum_info , p , & pixel ) ;
SetPixelIndex ( image , PushColormapIndex ( image , pixel , & range_exception ) , q ) ;
SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) GetPixelIndex ( image , q ) , q ) ;
p += quantum_info -> pad ;
q += GetPixelChannels ( image ) ;
}
break ;
}
}
if ( range_exception != MagickFalse ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , "InvalidColormapIndex" , "`%s'" , image -> filename ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int xmlListAppend ( xmlListPtr l , void * data ) {
xmlLinkPtr lkPlace , lkNew ;
if ( l == NULL ) return ( 1 ) ;
lkPlace = xmlListHigherSearch ( l , data ) ;
lkNew = ( xmlLinkPtr ) xmlMalloc ( sizeof ( xmlLink ) ) ;
if ( lkNew == NULL ) {
xmlGenericError ( xmlGenericErrorContext , "Cannot initialize memory for new link" ) ;
return ( 1 ) ;
}
lkNew -> data = data ;
lkNew -> next = lkPlace -> next ;
( lkPlace -> next ) -> prev = lkNew ;
lkPlace -> next = lkNew ;
lkNew -> prev = lkPlace ;
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static proto_item * ber_add_bad_length_error ( packet_info * pinfo , proto_tree * tree , const char * name , tvbuff_t * tvb , const gint start , gint length ) {
proto_item * ti ;
ti = proto_tree_add_string_format ( tree , hf_ber_error , tvb , start , length , "illegal_length" , "%s: length of item (%d) is not valid" , name , length ) ;
expert_add_info_format ( pinfo , ti , & ei_ber_error_length , "Length of item (%d) is not valid" , length ) ;
return ti ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int set_directory_record_rr ( unsigned char * bp , int dr_len , struct isoent * isoent , struct iso9660 * iso9660 , enum dir_rec_type t ) {
unsigned char rr_flag ;
# define RR_USE_PX 0x01 # define RR_USE_PN 0x02 # define RR_USE_SL 0x04 # define RR_USE_NM 0x08 # define RR_USE_CL 0x10 # define RR_USE_PL 0x20 # define RR_USE_RE 0x40 # define RR_USE_TF 0x80 int length ;
struct ctl_extr_rec ctl ;
struct isoent * rr_parent , * pxent ;
struct isofile * file ;
bp = extra_open_record ( bp , dr_len , isoent , & ctl ) ;
if ( t == DIR_REC_PARENT ) {
rr_parent = isoent -> rr_parent ;
pxent = isoent -> parent ;
if ( rr_parent != NULL ) isoent = rr_parent ;
else isoent = isoent -> parent ;
}
else {
rr_parent = NULL ;
pxent = isoent ;
}
file = isoent -> file ;
if ( t != DIR_REC_NORMAL ) {
rr_flag = RR_USE_PX | RR_USE_TF ;
if ( rr_parent != NULL ) rr_flag |= RR_USE_PL ;
}
else {
rr_flag = RR_USE_PX | RR_USE_NM | RR_USE_TF ;
if ( archive_entry_filetype ( file -> entry ) == AE_IFLNK ) rr_flag |= RR_USE_SL ;
if ( isoent -> rr_parent != NULL ) rr_flag |= RR_USE_RE ;
if ( isoent -> rr_child != NULL ) rr_flag |= RR_USE_CL ;
if ( archive_entry_filetype ( file -> entry ) == AE_IFCHR || archive_entry_filetype ( file -> entry ) == AE_IFBLK ) rr_flag |= RR_USE_PN ;
# ifdef COMPAT_MKISOFS if ( isoent -> virtual && isoent -> parent == iso9660 -> primary . rootent && strcmp ( isoent -> file -> basename . s , "rr_moved" ) == 0 ) rr_flag |= RR_USE_RE ;
# endif }
if ( t == DIR_REC_SELF && isoent == isoent -> parent ) {
length = 7 ;
if ( bp != NULL ) {
bp [ 1 ] = 'S' ;
bp [ 2 ] = 'P' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
bp [ 5 ] = 0xBE ;
bp [ 6 ] = 0xEF ;
bp [ 7 ] = 0 ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
length = 5 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'R' ;
bp [ 2 ] = 'R' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
bp [ 5 ] = rr_flag ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
if ( rr_flag & RR_USE_NM ) {
size_t nmlen = file -> basename . length ;
const char * nm = file -> basename . s ;
size_t nmmax ;
if ( extra_space ( & ctl ) < 6 ) bp = extra_next_record ( & ctl , 6 ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'N' ;
bp [ 2 ] = 'M' ;
bp [ 4 ] = 1 ;
}
nmmax = extra_space ( & ctl ) ;
if ( nmmax > 0xff ) nmmax = 0xff ;
while ( nmlen + 5 > nmmax ) {
length = ( int ) nmmax ;
if ( bp != NULL ) {
bp [ 3 ] = length ;
bp [ 5 ] = 0x01 ;
memcpy ( bp + 6 , nm , length - 5 ) ;
bp += length ;
}
nmlen -= length - 5 ;
nm += length - 5 ;
extra_tell_used_size ( & ctl , length ) ;
if ( extra_space ( & ctl ) < 6 ) {
bp = extra_next_record ( & ctl , 6 ) ;
nmmax = extra_space ( & ctl ) ;
if ( nmmax > 0xff ) nmmax = 0xff ;
}
if ( bp != NULL ) {
bp [ 1 ] = 'N' ;
bp [ 2 ] = 'M' ;
bp [ 4 ] = 1 ;
}
}
length = 5 + ( int ) nmlen ;
if ( bp != NULL ) {
bp [ 3 ] = length ;
bp [ 5 ] = 0 ;
memcpy ( bp + 6 , nm , nmlen ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_PX ) {
length = 44 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
mode_t mode ;
int64_t uid ;
int64_t gid ;
mode = archive_entry_mode ( file -> entry ) ;
uid = archive_entry_uid ( file -> entry ) ;
gid = archive_entry_gid ( file -> entry ) ;
if ( iso9660 -> opt . rr == OPT_RR_USEFUL ) {
mode |= 0444 ;
# if ! defined ( _WIN32 ) && ! defined ( __CYGWIN__ ) if ( mode & 0111 ) # endif mode |= 0111 ;
mode &= ~ 0222 ;
mode &= ~ 07000 ;
}
bp [ 1 ] = 'P' ;
bp [ 2 ] = 'X' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
set_num_733 ( bp + 5 , mode ) ;
set_num_733 ( bp + 13 , archive_entry_nlink ( file -> entry ) ) ;
set_num_733 ( bp + 21 , ( uint32_t ) uid ) ;
set_num_733 ( bp + 29 , ( uint32_t ) gid ) ;
if ( pxent -> dir ) set_num_733 ( bp + 37 , pxent -> dir_location ) ;
else if ( file -> hardlink_target != NULL ) set_num_733 ( bp + 37 , file -> hardlink_target -> cur_content -> location ) ;
else set_num_733 ( bp + 37 , file -> cur_content -> location ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_SL ) {
const char * sl ;
char sl_last ;
if ( extra_space ( & ctl ) < 7 ) bp = extra_next_record ( & ctl , 7 ) ;
sl = file -> symlink . s ;
sl_last = '\0' ;
if ( bp != NULL ) {
bp [ 1 ] = 'S' ;
bp [ 2 ] = 'L' ;
bp [ 4 ] = 1 ;
}
for ( ;
;
) {
unsigned char * nc , * cf , * cl , cldmy = 0 ;
int sllen , slmax ;
slmax = extra_space ( & ctl ) ;
if ( slmax > 0xff ) slmax = 0xff ;
if ( bp != NULL ) nc = & bp [ 6 ] ;
else nc = NULL ;
cf = cl = NULL ;
sllen = 0 ;
while ( * sl && sllen + 11 < slmax ) {
if ( sl_last == '\0' && sl [ 0 ] == '/' ) {
if ( nc != NULL ) {
cf = nc ++ ;
* cf = 0x08 ;
* nc ++ = 0 ;
}
sllen += 2 ;
sl ++ ;
sl_last = '/' ;
cl = NULL ;
continue ;
}
if ( ( ( sl_last == '\0' || sl_last == '/' ) && sl [ 0 ] == '.' && sl [ 1 ] == '.' && ( sl [ 2 ] == '/' || sl [ 2 ] == '\0' ) ) || ( sl [ 0 ] == '/' && sl [ 1 ] == '.' && sl [ 2 ] == '.' && ( sl [ 3 ] == '/' || sl [ 3 ] == '\0' ) ) ) {
if ( nc != NULL ) {
cf = nc ++ ;
* cf = 0x04 ;
* nc ++ = 0 ;
}
sllen += 2 ;
if ( sl [ 0 ] == '/' ) sl += 3 ;
else sl += 2 ;
sl_last = '.' ;
cl = NULL ;
continue ;
}
if ( ( ( sl_last == '\0' || sl_last == '/' ) && sl [ 0 ] == '.' && ( sl [ 1 ] == '/' || sl [ 1 ] == '\0' ) ) || ( sl [ 0 ] == '/' && sl [ 1 ] == '.' && ( sl [ 2 ] == '/' || sl [ 2 ] == '\0' ) ) ) {
if ( nc != NULL ) {
cf = nc ++ ;
* cf = 0x02 ;
* nc ++ = 0 ;
}
sllen += 2 ;
if ( sl [ 0 ] == '/' ) sl += 2 ;
else sl ++ ;
sl_last = '.' ;
cl = NULL ;
continue ;
}
if ( sl [ 0 ] == '/' || cl == NULL ) {
if ( nc != NULL ) {
cf = nc ++ ;
* cf = 0 ;
cl = nc ++ ;
* cl = 0 ;
}
else cl = & cldmy ;
sllen += 2 ;
if ( sl [ 0 ] == '/' ) {
sl_last = * sl ++ ;
continue ;
}
}
sl_last = * sl ++ ;
if ( nc != NULL ) {
* nc ++ = sl_last ;
( * cl ) ++ ;
}
sllen ++ ;
}
if ( * sl ) {
length = 5 + sllen ;
if ( bp != NULL ) {
* cf |= 0x01 ;
bp [ 3 ] = length ;
bp [ 5 ] = 0x01 ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
if ( extra_space ( & ctl ) < 11 ) bp = extra_next_record ( & ctl , 11 ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'S' ;
bp [ 2 ] = 'L' ;
bp [ 4 ] = 1 ;
}
}
else {
length = 5 + sllen ;
if ( bp != NULL ) {
bp [ 3 ] = length ;
bp [ 5 ] = 0 ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
break ;
}
}
}
if ( rr_flag & RR_USE_TF ) {
# define TF_CREATION 0x01 # define TF_MODIFY 0x02 # define TF_ACCESS 0x04 # define TF_ATTRIBUTES 0x08 # define TF_BACKUP 0x10 # define TF_EXPIRATION 0x20 # define TF_EFFECTIVE 0x40 # define TF_LONG_FORM 0x80 unsigned char tf_flags ;
length = 5 ;
tf_flags = 0 ;
# ifndef COMPAT_MKISOFS if ( archive_entry_birthtime_is_set ( file -> entry ) && archive_entry_birthtime ( file -> entry ) <= archive_entry_mtime ( file -> entry ) ) {
length += 7 ;
tf_flags |= TF_CREATION ;
}
# endif if ( archive_entry_mtime_is_set ( file -> entry ) ) {
length += 7 ;
tf_flags |= TF_MODIFY ;
}
if ( archive_entry_atime_is_set ( file -> entry ) ) {
length += 7 ;
tf_flags |= TF_ACCESS ;
}
if ( archive_entry_ctime_is_set ( file -> entry ) ) {
length += 7 ;
tf_flags |= TF_ATTRIBUTES ;
}
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'T' ;
bp [ 2 ] = 'F' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
bp [ 5 ] = tf_flags ;
bp += 5 ;
if ( tf_flags & TF_CREATION ) {
set_time_915 ( bp + 1 , archive_entry_birthtime ( file -> entry ) ) ;
bp += 7 ;
}
if ( tf_flags & TF_MODIFY ) {
set_time_915 ( bp + 1 , archive_entry_mtime ( file -> entry ) ) ;
bp += 7 ;
}
if ( tf_flags & TF_ACCESS ) {
set_time_915 ( bp + 1 , archive_entry_atime ( file -> entry ) ) ;
bp += 7 ;
}
if ( tf_flags & TF_ATTRIBUTES ) {
set_time_915 ( bp + 1 , archive_entry_ctime ( file -> entry ) ) ;
bp += 7 ;
}
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_RE ) {
length = 4 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'R' ;
bp [ 2 ] = 'E' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_PL ) {
length = 12 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'P' ;
bp [ 2 ] = 'L' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
set_num_733 ( bp + 5 , rr_parent -> dir_location ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_CL ) {
length = 12 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'C' ;
bp [ 2 ] = 'L' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
set_num_733 ( bp + 5 , isoent -> rr_child -> dir_location ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( rr_flag & RR_USE_PN ) {
length = 20 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
uint64_t dev ;
bp [ 1 ] = 'P' ;
bp [ 2 ] = 'N' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
dev = ( uint64_t ) archive_entry_rdev ( file -> entry ) ;
set_num_733 ( bp + 5 , ( uint32_t ) ( dev >> 32 ) ) ;
set_num_733 ( bp + 13 , ( uint32_t ) ( dev & 0xFFFFFFFF ) ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( file -> zisofs . header_size ) {
length = 16 ;
if ( extra_space ( & ctl ) < length ) bp = extra_next_record ( & ctl , length ) ;
if ( bp != NULL ) {
bp [ 1 ] = 'Z' ;
bp [ 2 ] = 'F' ;
bp [ 3 ] = length ;
bp [ 4 ] = 1 ;
bp [ 5 ] = 'p' ;
bp [ 6 ] = 'z' ;
bp [ 7 ] = file -> zisofs . header_size ;
bp [ 8 ] = file -> zisofs . log2_bs ;
set_num_733 ( bp + 9 , file -> zisofs . uncompressed_size ) ;
bp += length ;
}
extra_tell_used_size ( & ctl , length ) ;
}
if ( t == DIR_REC_SELF && isoent == isoent -> parent ) {
length = RR_CE_SIZE ;
if ( bp != NULL ) set_SUSP_CE ( bp + 1 , iso9660 -> location_rrip_er , 0 , RRIP_ER_SIZE ) ;
extra_tell_used_size ( & ctl , length ) ;
}
extra_close_record ( & ctl , 0 ) ;
return ( ctl . dr_len ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_u3v_write_mem_ack ( proto_tree * u3v_telegram_tree , tvbuff_t * tvb , packet_info * pinfo , gint startoffset , gint length , u3v_conv_info_t * u3v_conv_info , gencp_transaction_t * gencp_trans ) {
guint64 addr = 0 ;
gint offset = startoffset ;
const gchar * address_string = NULL ;
gboolean is_custom_register = FALSE ;
gboolean have_address = ( 0 != gencp_trans -> cmd_frame ) ;
proto_item * item = NULL ;
addr = gencp_trans -> address ;
if ( have_address ) {
address_string = get_register_name_from_address ( addr , & is_custom_register , u3v_conv_info ) ;
col_append_fstr ( pinfo -> cinfo , COL_INFO , "%s" , address_string ) ;
}
item = proto_tree_add_item ( u3v_telegram_tree , hf_u3v_scd_writemem_ack , tvb , startoffset , length , ENC_NA ) ;
u3v_telegram_tree = proto_item_add_subtree ( item , ett_u3v_payload_cmd ) ;
if ( have_address ) {
item = proto_tree_add_uint64 ( u3v_telegram_tree , hf_u3v_address , tvb , 0 , 0 , addr ) ;
PROTO_ITEM_SET_GENERATED ( item ) ;
}
if ( length == 4 ) {
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_reserved , tvb , offset , 2 , ENC_NA ) ;
offset += 2 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_count , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int adb_forward ( char * serial_number , const char * adb_server_ip , unsigned short * adb_server_tcp_port , unsigned short local_tcp_port , unsigned short server_tcp_port ) {
socket_handle_t sock ;
int result ;
static char helpful_packet [ PACKET_LENGTH ] ;
static const char * adb_forward_template = "%04x" "%s%s:forward:tcp:%05u;
tcp:%05u" ;
sock = adb_connect ( adb_server_ip , adb_server_tcp_port ) ;
if ( sock == INVALID_SOCKET ) return EXIT_CODE_INVALID_SOCKET_5 ;
result = g_snprintf ( helpful_packet , PACKET_LENGTH , adb_forward_template , ( serial_number ) ? 5 + 7 + strlen ( serial_number ) + 28 : 4 + 28 , ( serial_number ) ? "host-serial:" : "host" , ( serial_number ) ? serial_number : "" , local_tcp_port , server_tcp_port ) ;
if ( result <= 0 || result > PACKET_LENGTH ) {
errmsg_print ( "ERROR: Error while completing adb packet" ) ;
closesocket ( sock ) ;
return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_12 ;
}
result = adb_send ( sock , helpful_packet ) ;
closesocket ( sock ) ;
return result ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static byte * i_alloc_byte_array ( gs_memory_t * mem , uint num_elements , uint elt_size , client_name_t cname ) {
gs_ref_memory_t * const imem = ( gs_ref_memory_t * ) mem ;
obj_header_t * obj ;
# ifdef MEMENTO if ( Memento_failThisEvent ( ) ) return NULL ;
# endif obj = alloc_obj ( imem , ( ulong ) num_elements * elt_size , & st_bytes , ALLOC_DIRECT , cname ) ;
if_debug6m ( 'A' , mem , "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n" , alloc_trace_space ( imem ) , client_name_string ( cname ) , ( ulong ) num_elements * elt_size , num_elements , elt_size , ( ulong ) obj ) ;
return ( byte * ) obj ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int imc_decode_block ( AVCodecContext * avctx , IMCContext * q , int ch ) {
int stream_format_code ;
int imc_hdr , i , j , ret ;
int flag ;
int bits , summer ;
int counter , bitscount ;
IMCChannel * chctx = q -> chctx + ch ;
imc_hdr = get_bits ( & q -> gb , 9 ) ;
if ( imc_hdr & 0x18 ) {
av_log ( avctx , AV_LOG_ERROR , "frame header check failed!\n" ) ;
av_log ( avctx , AV_LOG_ERROR , "got %X.\n" , imc_hdr ) ;
return AVERROR_INVALIDDATA ;
}
stream_format_code = get_bits ( & q -> gb , 3 ) ;
if ( stream_format_code & 1 ) {
av_log_ask_for_sample ( avctx , "Stream format %X is not supported\n" , stream_format_code ) ;
return AVERROR_PATCHWELCOME ;
}
if ( stream_format_code & 0x04 ) chctx -> decoder_reset = 1 ;
if ( chctx -> decoder_reset ) {
for ( i = 0 ;
i < BANDS ;
i ++ ) chctx -> old_floor [ i ] = 1.0 ;
for ( i = 0 ;
i < COEFFS ;
i ++ ) chctx -> CWdecoded [ i ] = 0 ;
chctx -> decoder_reset = 0 ;
}
flag = get_bits1 ( & q -> gb ) ;
imc_read_level_coeffs ( q , stream_format_code , chctx -> levlCoeffBuf ) ;
if ( stream_format_code & 0x4 ) imc_decode_level_coefficients ( q , chctx -> levlCoeffBuf , chctx -> flcoeffs1 , chctx -> flcoeffs2 ) ;
else imc_decode_level_coefficients2 ( q , chctx -> levlCoeffBuf , chctx -> old_floor , chctx -> flcoeffs1 , chctx -> flcoeffs2 ) ;
memcpy ( chctx -> old_floor , chctx -> flcoeffs1 , 32 * sizeof ( float ) ) ;
counter = 0 ;
for ( i = 0 ;
i < BANDS ;
i ++ ) {
if ( chctx -> levlCoeffBuf [ i ] == 16 ) {
chctx -> bandWidthT [ i ] = 0 ;
counter ++ ;
}
else chctx -> bandWidthT [ i ] = band_tab [ i + 1 ] - band_tab [ i ] ;
}
memset ( chctx -> bandFlagsBuf , 0 , BANDS * sizeof ( int ) ) ;
for ( i = 0 ;
i < BANDS - 1 ;
i ++ ) {
if ( chctx -> bandWidthT [ i ] ) chctx -> bandFlagsBuf [ i ] = get_bits1 ( & q -> gb ) ;
}
imc_calculate_coeffs ( q , chctx -> flcoeffs1 , chctx -> flcoeffs2 , chctx -> bandWidthT , chctx -> flcoeffs3 , chctx -> flcoeffs5 ) ;
bitscount = 0 ;
if ( stream_format_code & 0x2 ) {
bitscount += 15 ;
chctx -> bitsBandT [ 0 ] = 5 ;
chctx -> CWlengthT [ 0 ] = 5 ;
chctx -> CWlengthT [ 1 ] = 5 ;
chctx -> CWlengthT [ 2 ] = 5 ;
for ( i = 1 ;
i < 4 ;
i ++ ) {
bits = ( chctx -> levlCoeffBuf [ i ] == 16 ) ? 0 : 5 ;
chctx -> bitsBandT [ i ] = bits ;
for ( j = band_tab [ i ] ;
j < band_tab [ i + 1 ] ;
j ++ ) {
chctx -> CWlengthT [ j ] = bits ;
bitscount += bits ;
}
}
}
if ( avctx -> codec_id == AV_CODEC_ID_IAC ) {
bitscount += ! ! chctx -> bandWidthT [ BANDS - 1 ] ;
if ( ! ( stream_format_code & 0x2 ) ) bitscount += 16 ;
}
if ( ( ret = bit_allocation ( q , chctx , stream_format_code , 512 - bitscount - get_bits_count ( & q -> gb ) , flag ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "Bit allocations failed\n" ) ;
chctx -> decoder_reset = 1 ;
return ret ;
}
for ( i = 0 ;
i < BANDS ;
i ++ ) {
chctx -> sumLenArr [ i ] = 0 ;
chctx -> skipFlagRaw [ i ] = 0 ;
for ( j = band_tab [ i ] ;
j < band_tab [ i + 1 ] ;
j ++ ) chctx -> sumLenArr [ i ] += chctx -> CWlengthT [ j ] ;
if ( chctx -> bandFlagsBuf [ i ] ) if ( ( ( ( band_tab [ i + 1 ] - band_tab [ i ] ) * 1.5 ) > chctx -> sumLenArr [ i ] ) && ( chctx -> sumLenArr [ i ] > 0 ) ) chctx -> skipFlagRaw [ i ] = 1 ;
}
imc_get_skip_coeff ( q , chctx ) ;
for ( i = 0 ;
i < BANDS ;
i ++ ) {
chctx -> flcoeffs6 [ i ] = chctx -> flcoeffs1 [ i ] ;
if ( chctx -> bandFlagsBuf [ i ] && ( band_tab [ i + 1 ] - band_tab [ i ] ) != chctx -> skipFlagCount [ i ] ) {
chctx -> flcoeffs6 [ i ] *= q -> sqrt_tab [ band_tab [ i + 1 ] - band_tab [ i ] ] / q -> sqrt_tab [ ( band_tab [ i + 1 ] - band_tab [ i ] - chctx -> skipFlagCount [ i ] ) ] ;
}
}
bits = summer = 0 ;
for ( i = 0 ;
i < BANDS ;
i ++ ) {
if ( chctx -> bandFlagsBuf [ i ] ) {
for ( j = band_tab [ i ] ;
j < band_tab [ i + 1 ] ;
j ++ ) {
if ( chctx -> skipFlags [ j ] ) {
summer += chctx -> CWlengthT [ j ] ;
chctx -> CWlengthT [ j ] = 0 ;
}
}
bits += chctx -> skipFlagBits [ i ] ;
summer -= chctx -> skipFlagBits [ i ] ;
}
}
imc_adjust_bit_allocation ( q , chctx , summer ) ;
for ( i = 0 ;
i < BANDS ;
i ++ ) {
chctx -> sumLenArr [ i ] = 0 ;
for ( j = band_tab [ i ] ;
j < band_tab [ i + 1 ] ;
j ++ ) if ( ! chctx -> skipFlags [ j ] ) chctx -> sumLenArr [ i ] += chctx -> CWlengthT [ j ] ;
}
memset ( chctx -> codewords , 0 , sizeof ( chctx -> codewords ) ) ;
if ( imc_get_coeffs ( q , chctx ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "Read coefficients failed\n" ) ;
chctx -> decoder_reset = 1 ;
return AVERROR_INVALIDDATA ;
}
if ( inverse_quant_coeff ( q , chctx , stream_format_code ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "Inverse quantization of coefficients failed\n" ) ;
chctx -> decoder_reset = 1 ;
return AVERROR_INVALIDDATA ;
}
memset ( chctx -> skipFlags , 0 , sizeof ( chctx -> skipFlags ) ) ;
imc_imdct256 ( q , chctx , avctx -> channels ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static afs_int32 newEntry ( struct rx_call * call , char aname [ ] , afs_int32 flag , afs_int32 oid , afs_int32 * aid , afs_int32 * cid ) {
afs_int32 code ;
struct ubik_trans * tt ;
int admin ;
char cname [ PR_MAXNAMELEN ] ;
stolower ( aname ) ;
code = Initdb ( ) ;
if ( code ) return code ;
code = ubik_BeginTrans ( dbase , UBIK_WRITETRANS , & tt ) ;
if ( code ) return code ;
code = ubik_SetLock ( tt , 1 , 1 , LOCKWRITE ) ;
if ( code ) ABORT_WITH ( tt , code ) ;
code = read_DbHeader ( tt ) ;
if ( code ) ABORT_WITH ( tt , code ) ;
code = WhoIsThisWithName ( call , tt , cid , cname ) ;
if ( code != 2 ) {
if ( code ) ABORT_WITH ( tt , PRPERM ) ;
admin = IsAMemberOf ( tt , * cid , SYSADMINID ) ;
}
else {
admin = ( ( ! restricted && ! strcmp ( aname , cname ) ) ) || IsAMemberOf ( tt , * cid , SYSADMINID ) ;
oid = * cid = SYSADMINID ;
}
if ( ! CreateOK ( tt , * cid , oid , flag , admin ) ) ABORT_WITH ( tt , PRPERM ) ;
code = CreateEntry ( tt , aname , aid , 0 , flag , oid , * cid ) ;
if ( code != PRSUCCESS ) ABORT_WITH ( tt , code ) ;
code = ubik_EndTrans ( tt ) ;
if ( code ) return code ;
return PRSUCCESS ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static GFile * get_target_file ( GFile * src , GFile * dest_dir , const char * dest_fs_type , gboolean same_fs ) {
return get_target_file_with_custom_name ( src , dest_dir , dest_fs_type , same_fs , NULL ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int arm_mptimer_init ( SysBusDevice * dev ) {
ARMMPTimerState * s = FROM_SYSBUS ( ARMMPTimerState , dev ) ;
int i ;
if ( s -> num_cpu < 1 || s -> num_cpu > MAX_CPUS ) {
hw_error ( "%s: num-cpu must be between 1 and %d\n" , __func__ , MAX_CPUS ) ;
}
memory_region_init_io ( & s -> iomem , OBJECT ( s ) , & arm_thistimer_ops , s , "arm_mptimer_timer" , 0x20 ) ;
sysbus_init_mmio ( dev , & s -> iomem ) ;
for ( i = 0 ;
i < s -> num_cpu ;
i ++ ) {
TimerBlock * tb = & s -> timerblock [ i ] ;
tb -> timer = qemu_new_timer_ns ( vm_clock , timerblock_tick , tb ) ;
sysbus_init_irq ( dev , & tb -> irq ) ;
memory_region_init_io ( & tb -> iomem , OBJECT ( s ) , & timerblock_ops , tb , "arm_mptimer_timerblock" , 0x20 ) ;
sysbus_init_mmio ( dev , & tb -> iomem ) ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint32 get_uint_value ( proto_tree * tree , tvbuff_t * tvb , gint offset , gint length , const guint encoding ) {
guint32 value ;
gboolean length_error ;
switch ( length ) {
case 1 : value = tvb_get_guint8 ( tvb , offset ) ;
break ;
case 2 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letohs ( tvb , offset ) : tvb_get_ntohs ( tvb , offset ) ;
break ;
case 3 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh24 ( tvb , offset ) : tvb_get_ntoh24 ( tvb , offset ) ;
break ;
case 4 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letohl ( tvb , offset ) : tvb_get_ntohl ( tvb , offset ) ;
break ;
default : if ( length < 1 ) {
length_error = TRUE ;
value = 0 ;
}
else {
length_error = FALSE ;
value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letohl ( tvb , offset ) : tvb_get_ntohl ( tvb , offset ) ;
}
report_type_length_mismatch ( tree , "an unsigned integer" , length , length_error ) ;
break ;
}
return value ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_T_mobileMultilinkFrameCapability ( 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_T_mobileMultilinkFrameCapability , T_mobileMultilinkFrameCapability_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_CmdR_multiplex ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_CmdR_multiplex , CmdR_multiplex_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int pfkey_sadb_addr2xfrm_addr ( const struct sadb_address * addr , xfrm_address_t * xaddr ) {
return pfkey_sockaddr_extract ( ( struct sockaddr * ) ( addr + 1 ) , xaddr ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline bool is_ra ( hb_codepoint_t u ) {
for ( unsigned int i = 0 ;
i < ARRAY_LENGTH ( ra_chars ) ;
i ++ ) if ( u == ra_chars [ i ] ) return true ;
return false ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void * Type_ViewingConditions_Read ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsUInt32Number * nItems , cmsUInt32Number SizeOfTag ) {
cmsICCViewingConditions * vc = NULL ;
vc = ( cmsICCViewingConditions * ) _cmsMallocZero ( self -> ContextID , sizeof ( cmsICCViewingConditions ) ) ;
if ( vc == NULL ) return NULL ;
* nItems = 0 ;
if ( ! _cmsReadXYZNumber ( io , & vc -> IlluminantXYZ ) ) goto Error ;
if ( ! _cmsReadXYZNumber ( io , & vc -> SurroundXYZ ) ) goto Error ;
if ( ! _cmsReadUInt32Number ( io , & vc -> IlluminantType ) ) goto Error ;
* nItems = 1 ;
return ( void * ) vc ;
Error : if ( vc != NULL ) _cmsFree ( self -> ContextID , vc ) ;
return NULL ;
cmsUNUSED_PARAMETER ( SizeOfTag ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void xhci_intx_update ( XHCIState * xhci ) {
PCIDevice * pci_dev = PCI_DEVICE ( xhci ) ;
int level = 0 ;
if ( msix_enabled ( pci_dev ) || msi_enabled ( pci_dev ) ) {
return ;
}
if ( xhci -> intr [ 0 ] . iman & IMAN_IP && xhci -> intr [ 0 ] . iman & IMAN_IE && xhci -> usbcmd & USBCMD_INTE ) {
level = 1 ;
}
trace_usb_xhci_irq_intx ( level ) ;
pci_set_irq ( pci_dev , level ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | bool message_decoder_decode_next_block ( struct message_decoder_context * ctx , struct message_block * input , struct message_block * output ) {
if ( input -> part != ctx -> prev_part ) {
message_decoder_decode_reset ( ctx ) ;
}
output -> part = input -> part ;
ctx -> prev_part = input -> part ;
if ( input -> hdr != NULL ) {
output -> size = 0 ;
return message_decode_header ( ctx , input -> hdr , output ) ;
}
else if ( input -> size != 0 ) return message_decode_body ( ctx , input , output ) ;
else {
output -> hdr = NULL ;
output -> size = 0 ;
message_decode_body_init_charset ( ctx , input -> part ) ;
return TRUE ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int EVP_DecodeBlock ( unsigned char * t , const unsigned char * f , int n ) {
int i , ret = 0 , a , b , c , d ;
unsigned long l ;
while ( ( conv_ascii2bin ( * f ) == B64_WS ) && ( n > 0 ) ) {
f ++ ;
n -- ;
}
while ( ( n > 3 ) && ( B64_NOT_BASE64 ( conv_ascii2bin ( f [ n - 1 ] ) ) ) ) n -- ;
if ( n % 4 != 0 ) return ( - 1 ) ;
for ( i = 0 ;
i < n ;
i += 4 ) {
a = conv_ascii2bin ( * ( f ++ ) ) ;
b = conv_ascii2bin ( * ( f ++ ) ) ;
c = conv_ascii2bin ( * ( f ++ ) ) ;
d = conv_ascii2bin ( * ( f ++ ) ) ;
if ( ( a & 0x80 ) || ( b & 0x80 ) || ( c & 0x80 ) || ( d & 0x80 ) ) return ( - 1 ) ;
l = ( ( ( ( unsigned long ) a ) << 18L ) | ( ( ( unsigned long ) b ) << 12L ) | ( ( ( unsigned long ) c ) << 6L ) | ( ( ( unsigned long ) d ) ) ) ;
* ( t ++ ) = ( unsigned char ) ( l >> 16L ) & 0xff ;
* ( t ++ ) = ( unsigned char ) ( l >> 8L ) & 0xff ;
* ( t ++ ) = ( unsigned char ) ( l ) & 0xff ;
ret += 3 ;
}
return ( ret ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static float tilt_factor ( float * lpc_n , float * lpc_d ) {
float rh0 , rh1 ;
float impulse_buffer [ LP_FILTER_ORDER + AMR_TILT_RESPONSE ] = {
0 }
;
float * hf = impulse_buffer + LP_FILTER_ORDER ;
hf [ 0 ] = 1.0 ;
memcpy ( hf + 1 , lpc_n , sizeof ( float ) * LP_FILTER_ORDER ) ;
ff_celp_lp_synthesis_filterf ( hf , lpc_d , hf , AMR_TILT_RESPONSE , LP_FILTER_ORDER ) ;
rh0 = avpriv_scalarproduct_float_c ( hf , hf , AMR_TILT_RESPONSE ) ;
rh1 = avpriv_scalarproduct_float_c ( hf , hf + 1 , AMR_TILT_RESPONSE - 1 ) ;
return rh1 >= 0.0 ? rh1 / rh0 * AMR_TILT_GAMMA_T : 0.0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int mpeg_field_start ( MpegEncContext * s , const uint8_t * buf , int buf_size ) {
AVCodecContext * avctx = s -> avctx ;
Mpeg1Context * s1 = ( Mpeg1Context * ) s ;
if ( s -> first_field || s -> picture_structure == PICT_FRAME ) {
AVFrameSideData * pan_scan ;
if ( ff_MPV_frame_start ( s , avctx ) < 0 ) return - 1 ;
ff_mpeg_er_frame_start ( s ) ;
s -> current_picture_ptr -> f . repeat_pict = 0 ;
if ( s -> repeat_first_field ) {
if ( s -> progressive_sequence ) {
if ( s -> top_field_first ) s -> current_picture_ptr -> f . repeat_pict = 4 ;
else s -> current_picture_ptr -> f . repeat_pict = 2 ;
}
else if ( s -> progressive_frame ) {
s -> current_picture_ptr -> f . repeat_pict = 1 ;
}
}
pan_scan = av_frame_new_side_data ( & s -> current_picture_ptr -> f , AV_FRAME_DATA_PANSCAN , sizeof ( s1 -> pan_scan ) ) ;
if ( ! pan_scan ) return AVERROR ( ENOMEM ) ;
memcpy ( pan_scan -> data , & s1 -> pan_scan , sizeof ( s1 -> pan_scan ) ) ;
if ( HAVE_THREADS && ( avctx -> active_thread_type & FF_THREAD_FRAME ) ) ff_thread_finish_setup ( avctx ) ;
}
else {
int i ;
if ( ! s -> current_picture_ptr ) {
av_log ( s -> avctx , AV_LOG_ERROR , "first field missing\n" ) ;
return - 1 ;
}
if ( s -> avctx -> hwaccel && ( s -> avctx -> slice_flags & SLICE_FLAG_ALLOW_FIELD ) ) {
if ( s -> avctx -> hwaccel -> end_frame ( s -> avctx ) < 0 ) av_log ( avctx , AV_LOG_ERROR , "hardware accelerator failed to decode first field\n" ) ;
}
for ( i = 0 ;
i < 4 ;
i ++ ) {
s -> current_picture . f . data [ i ] = s -> current_picture_ptr -> f . data [ i ] ;
if ( s -> picture_structure == PICT_BOTTOM_FIELD ) {
s -> current_picture . f . data [ i ] += s -> current_picture_ptr -> f . linesize [ i ] ;
}
}
}
if ( avctx -> hwaccel ) {
if ( avctx -> hwaccel -> start_frame ( avctx , buf , buf_size ) < 0 ) return - 1 ;
}
if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration ) if ( ff_xvmc_field_start ( s , avctx ) < 0 ) return - 1 ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int64_t atol8 ( const char * p , unsigned char_cnt ) {
int64_t l ;
int digit ;
l = 0 ;
while ( char_cnt -- > 0 ) {
if ( * p >= '0' && * p <= '7' ) digit = * p - '0' ;
else return ( l ) ;
p ++ ;
l <<= 3 ;
l |= digit ;
}
return ( l ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int cdxl_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * pkt ) {
CDXLVideoContext * c = avctx -> priv_data ;
AVFrame * const p = data ;
int ret , w , h , encoding , aligned_width , buf_size = pkt -> size ;
const uint8_t * buf = pkt -> data ;
if ( buf_size < 32 ) return AVERROR_INVALIDDATA ;
encoding = buf [ 1 ] & 7 ;
c -> format = buf [ 1 ] & 0xE0 ;
w = AV_RB16 ( & buf [ 14 ] ) ;
h = AV_RB16 ( & buf [ 16 ] ) ;
c -> bpp = buf [ 19 ] ;
c -> palette_size = AV_RB16 ( & buf [ 20 ] ) ;
c -> palette = buf + 32 ;
c -> video = c -> palette + c -> palette_size ;
c -> video_size = buf_size - c -> palette_size - 32 ;
if ( c -> palette_size > 512 ) return AVERROR_INVALIDDATA ;
if ( buf_size < c -> palette_size + 32 ) return AVERROR_INVALIDDATA ;
if ( c -> bpp < 1 ) return AVERROR_INVALIDDATA ;
if ( c -> format != BIT_PLANAR && c -> format != BIT_LINE ) {
av_log_ask_for_sample ( avctx , "unsupported pixel format: 0x%0x\n" , c -> format ) ;
return AVERROR_PATCHWELCOME ;
}
if ( ( ret = av_image_check_size ( w , h , 0 , avctx ) ) < 0 ) return ret ;
if ( w != avctx -> width || h != avctx -> height ) avcodec_set_dimensions ( avctx , w , h ) ;
aligned_width = FFALIGN ( c -> avctx -> width , 16 ) ;
c -> padded_bits = aligned_width - c -> avctx -> width ;
if ( c -> video_size < aligned_width * avctx -> height * c -> bpp / 8 ) return AVERROR_INVALIDDATA ;
if ( ! encoding && c -> palette_size && c -> bpp <= 8 ) {
avctx -> pix_fmt = AV_PIX_FMT_PAL8 ;
}
else if ( encoding == 1 && ( c -> bpp == 6 || c -> bpp == 8 ) ) {
if ( c -> palette_size != ( 1 << ( c -> bpp - 1 ) ) ) return AVERROR_INVALIDDATA ;
avctx -> pix_fmt = AV_PIX_FMT_BGR24 ;
}
else {
av_log_ask_for_sample ( avctx , "unsupported encoding %d and bpp %d\n" , encoding , c -> bpp ) ;
return AVERROR_PATCHWELCOME ;
}
if ( ( ret = ff_get_buffer ( avctx , p , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
p -> pict_type = AV_PICTURE_TYPE_I ;
if ( encoding ) {
av_fast_padded_malloc ( & c -> new_video , & c -> new_video_size , h * w + FF_INPUT_BUFFER_PADDING_SIZE ) ;
if ( ! c -> new_video ) return AVERROR ( ENOMEM ) ;
if ( c -> bpp == 8 ) cdxl_decode_ham8 ( c , p ) ;
else cdxl_decode_ham6 ( c , p ) ;
}
else {
cdxl_decode_rgb ( c , p ) ;
}
* got_frame = 1 ;
return buf_size ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void netbios_add_session_init_flags ( tvbuff_t * tvb , proto_tree * tree , int offset ) {
proto_tree * field_tree ;
proto_item * tf ;
tf = proto_tree_add_item ( tree , hf_netb_flags , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
field_tree = proto_item_add_subtree ( tf , ett_netb_flags ) ;
proto_tree_add_item ( field_tree , hf_netb_flags_send_no_ack , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( field_tree , hf_netb_largest_frame , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( field_tree , hf_netb_version , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static clump_t * clump_splay_remove ( clump_t * cp , gs_ref_memory_t * imem ) {
clump_t * replacement ;
if ( cp -> left == NULL ) {
replacement = cp -> right ;
}
else if ( cp -> right == NULL ) {
replacement = cp -> left ;
}
else {
replacement = cp -> left ;
while ( replacement -> right ) replacement = replacement -> right ;
( void ) clump_splay_remove ( replacement , imem ) ;
if ( cp -> left ) cp -> left -> parent = replacement ;
cp -> right -> parent = replacement ;
replacement -> left = cp -> left ;
replacement -> right = cp -> right ;
}
if ( cp -> parent ) {
if ( cp -> parent -> left == cp ) cp -> parent -> left = replacement ;
else cp -> parent -> right = replacement ;
}
else imem -> root = replacement ;
if ( replacement ) replacement -> parent = cp -> parent ;
return replacement ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_T_makeTerminalBroadcasterResponse ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_T_makeTerminalBroadcasterResponse , T_makeTerminalBroadcasterResponse_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int cook_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 ;
COOKContext * q = avctx -> priv_data ;
float * * samples = NULL ;
int i , ret ;
int offset = 0 ;
int chidx = 0 ;
if ( buf_size < avctx -> block_align ) return buf_size ;
if ( q -> discarded_packets >= 2 ) {
frame -> nb_samples = q -> samples_per_channel ;
if ( ( ret = ff_get_buffer ( avctx , frame ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
samples = ( float * * ) frame -> extended_data ;
}
q -> subpacket [ 0 ] . size = avctx -> block_align ;
for ( i = 1 ;
i < q -> num_subpackets ;
i ++ ) {
q -> subpacket [ i ] . size = 2 * buf [ avctx -> block_align - q -> num_subpackets + i ] ;
q -> subpacket [ 0 ] . size -= q -> subpacket [ i ] . size + 1 ;
if ( q -> subpacket [ 0 ] . size < 0 ) {
av_log ( avctx , AV_LOG_DEBUG , "frame subpacket size total > avctx->block_align!\n" ) ;
return AVERROR_INVALIDDATA ;
}
}
for ( i = 0 ;
i < q -> num_subpackets ;
i ++ ) {
q -> subpacket [ i ] . bits_per_subpacket = ( q -> subpacket [ i ] . size * 8 ) >> q -> subpacket [ i ] . bits_per_subpdiv ;
q -> subpacket [ i ] . ch_idx = chidx ;
av_log ( avctx , AV_LOG_DEBUG , "subpacket[%i] size %i js %i %i block_align %i\n" , i , q -> subpacket [ i ] . size , q -> subpacket [ i ] . joint_stereo , offset , avctx -> block_align ) ;
if ( ( ret = decode_subpacket ( q , & q -> subpacket [ i ] , buf + offset , samples ) ) < 0 ) return ret ;
offset += q -> subpacket [ i ] . size ;
chidx += q -> subpacket [ i ] . num_channels ;
av_log ( avctx , AV_LOG_DEBUG , "subpacket[%i] %i %i\n" , i , q -> subpacket [ i ] . size * 8 , get_bits_count ( & q -> gb ) ) ;
}
if ( q -> discarded_packets < 2 ) {
q -> discarded_packets ++ ;
* got_frame_ptr = 0 ;
return avctx -> block_align ;
}
* got_frame_ptr = 1 ;
return avctx -> block_align ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | Oid get_opfamily_proc ( Oid opfamily , Oid lefttype , Oid righttype , int16 procnum ) {
HeapTuple tp ;
Form_pg_amproc amproc_tup ;
RegProcedure result ;
tp = SearchSysCache4 ( AMPROCNUM , ObjectIdGetDatum ( opfamily ) , ObjectIdGetDatum ( lefttype ) , ObjectIdGetDatum ( righttype ) , Int16GetDatum ( procnum ) ) ;
if ( ! HeapTupleIsValid ( tp ) ) return InvalidOid ;
amproc_tup = ( Form_pg_amproc ) GETSTRUCT ( tp ) ;
result = amproc_tup -> amproc ;
ReleaseSysCache ( tp ) ;
return result ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void e1000e_set_psrctl ( E1000ECore * core , int index , uint32_t val ) {
if ( ( val & E1000_PSRCTL_BSIZE0_MASK ) == 0 ) {
hw_error ( "e1000e: PSRCTL.BSIZE0 cannot be zero" ) ;
}
if ( ( val & E1000_PSRCTL_BSIZE1_MASK ) == 0 ) {
hw_error ( "e1000e: PSRCTL.BSIZE1 cannot be zero" ) ;
}
core -> mac [ PSRCTL ] = val ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TSReturnCode # if TS_USE_TLS_NPN TSNetAcceptNamedProtocol ( TSCont contp , const char * protocol ) {
sdk_assert ( protocol != nullptr ) ;
sdk_assert ( contp != nullptr ) ;
sdk_assert ( sdk_sanity_check_continuation ( contp ) == TS_SUCCESS ) ;
if ( ! ssl_register_protocol ( protocol , ( INKContInternal * ) contp ) ) {
ssl_unregister_protocol ( protocol , ( INKContInternal * ) contp ) ;
return TS_ERROR ;
}
return TS_SUCCESS ;
}
# else TSNetAcceptNamedProtocol ( TSCont , const char * ) {
return TS_ERROR ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | char * xmlrpc_string ( char * buf , const char * value ) {
char encoded [ XMLRPC_BUFSIZE ] ;
* buf = '\0' ;
xmlrpc_char_encode ( encoded , value ) ;
snprintf ( buf , XMLRPC_BUFSIZE , "<string>%s</string>" , encoded ) ;
return buf ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_p_frame ( FourXContext * f , const uint8_t * buf , int length ) {
int x , y ;
const int width = f -> avctx -> width ;
const int height = f -> avctx -> height ;
uint16_t * src = ( uint16_t * ) f -> last_picture -> data [ 0 ] ;
uint16_t * dst = ( uint16_t * ) f -> current_picture -> data [ 0 ] ;
const int stride = f -> current_picture -> linesize [ 0 ] >> 1 ;
unsigned int bitstream_size , bytestream_size , wordstream_size , extra , bytestream_offset , wordstream_offset ;
if ( f -> version > 1 ) {
extra = 20 ;
bitstream_size = AV_RL32 ( buf + 8 ) ;
wordstream_size = AV_RL32 ( buf + 12 ) ;
bytestream_size = AV_RL32 ( buf + 16 ) ;
}
else {
extra = 0 ;
bitstream_size = AV_RL16 ( buf - 4 ) ;
wordstream_size = AV_RL16 ( buf - 2 ) ;
bytestream_size = FFMAX ( length - bitstream_size - wordstream_size , 0 ) ;
}
if ( bitstream_size + bytestream_size + wordstream_size + extra != length || bitstream_size > ( 1 << 26 ) || bytestream_size > ( 1 << 26 ) || wordstream_size > ( 1 << 26 ) ) {
av_log ( f -> avctx , AV_LOG_ERROR , "lengths %d %d %d %d\n" , bitstream_size , bytestream_size , wordstream_size , bitstream_size + bytestream_size + wordstream_size - length ) ;
return AVERROR_INVALIDDATA ;
}
av_fast_malloc ( & f -> bitstream_buffer , & f -> bitstream_buffer_size , bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE ) ;
if ( ! f -> bitstream_buffer ) return AVERROR ( ENOMEM ) ;
f -> dsp . bswap_buf ( f -> bitstream_buffer , ( const uint32_t * ) ( buf + extra ) , bitstream_size / 4 ) ;
memset ( ( uint8_t * ) f -> bitstream_buffer + bitstream_size , 0 , FF_INPUT_BUFFER_PADDING_SIZE ) ;
init_get_bits ( & f -> gb , f -> bitstream_buffer , 8 * bitstream_size ) ;
wordstream_offset = extra + bitstream_size ;
bytestream_offset = extra + bitstream_size + wordstream_size ;
bytestream2_init ( & f -> g2 , buf + wordstream_offset , length - wordstream_offset ) ;
bytestream2_init ( & f -> g , buf + bytestream_offset , length - bytestream_offset ) ;
init_mv ( f ) ;
for ( y = 0 ;
y < height ;
y += 8 ) {
for ( x = 0 ;
x < width ;
x += 8 ) decode_p_block ( f , dst + x , src + x , 3 , 3 , stride ) ;
src += 8 * stride ;
dst += 8 * stride ;
}
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | double TSdrandom ( ) {
return this_ethread ( ) -> generator . drandom ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void deep_count_one ( DeepCountState * state , GFileInfo * info ) {
NautilusFile * file ;
GFile * subdir ;
gboolean is_seen_inode ;
const char * fs_id ;
if ( should_skip_file ( NULL , info ) ) {
return ;
}
is_seen_inode = seen_inode ( state , info ) ;
if ( ! is_seen_inode ) {
mark_inode_as_seen ( state , info ) ;
}
file = state -> directory -> details -> deep_count_file ;
if ( g_file_info_get_file_type ( info ) == G_FILE_TYPE_DIRECTORY ) {
file -> details -> deep_directory_count += 1 ;
fs_id = g_file_info_get_attribute_string ( info , G_FILE_ATTRIBUTE_ID_FILESYSTEM ) ;
if ( g_strcmp0 ( fs_id , state -> fs_id ) == 0 ) {
subdir = g_file_get_child ( state -> deep_count_location , g_file_info_get_name ( info ) ) ;
state -> deep_count_subdirectories = g_list_prepend ( state -> deep_count_subdirectories , subdir ) ;
}
}
else {
file -> details -> deep_file_count += 1 ;
}
if ( ! is_seen_inode && g_file_info_has_attribute ( info , G_FILE_ATTRIBUTE_STANDARD_SIZE ) ) {
file -> details -> deep_size += g_file_info_get_size ( info ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | struct config_connection * config_connection_create ( int fd ) {
struct config_connection * conn ;
conn = i_new ( struct config_connection , 1 ) ;
conn -> fd = fd ;
conn -> input = i_stream_create_fd ( fd , MAX_INBUF_SIZE , FALSE ) ;
conn -> output = o_stream_create_fd ( fd , ( size_t ) - 1 , FALSE ) ;
o_stream_set_no_error_handling ( conn -> output , TRUE ) ;
conn -> io = io_add ( fd , IO_READ , config_connection_input , conn ) ;
DLLIST_PREPEND ( & config_connections , conn ) ;
return conn ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int ra288_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 ;
float * out ;
int i , ret ;
RA288Context * ractx = avctx -> priv_data ;
GetBitContext gb ;
if ( buf_size < avctx -> block_align ) {
av_log ( avctx , AV_LOG_ERROR , "Error! Input buffer is too small [%d<%d]\n" , buf_size , avctx -> block_align ) ;
return AVERROR_INVALIDDATA ;
}
frame -> nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME ;
if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
out = ( float * ) frame -> data [ 0 ] ;
init_get_bits ( & gb , buf , avctx -> block_align * 8 ) ;
for ( i = 0 ;
i < RA288_BLOCKS_PER_FRAME ;
i ++ ) {
float gain = amptable [ get_bits ( & gb , 3 ) ] ;
int cb_coef = get_bits ( & gb , 6 + ( i & 1 ) ) ;
decode ( ractx , gain , cb_coef ) ;
memcpy ( out , & ractx -> sp_hist [ 70 + 36 ] , RA288_BLOCK_SIZE * sizeof ( * out ) ) ;
out += RA288_BLOCK_SIZE ;
if ( ( i & 7 ) == 3 ) {
backward_filter ( ractx , ractx -> sp_hist , ractx -> sp_rec , syn_window , ractx -> sp_lpc , syn_bw_tab , 36 , 40 , 35 , 70 ) ;
backward_filter ( ractx , ractx -> gain_hist , ractx -> gain_rec , gain_window , ractx -> gain_lpc , gain_bw_tab , 10 , 8 , 20 , 28 ) ;
}
}
* got_frame_ptr = 1 ;
return avctx -> block_align ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int xhci_epmask_to_eps_with_streams ( XHCIState * xhci , unsigned int slotid , uint32_t epmask , XHCIEPContext * * epctxs , USBEndpoint * * eps ) {
XHCISlot * slot ;
XHCIEPContext * epctx ;
USBEndpoint * ep ;
int i , j ;
assert ( slotid >= 1 && slotid <= xhci -> numslots ) ;
slot = & xhci -> slots [ slotid - 1 ] ;
for ( i = 2 , j = 0 ;
i <= 31 ;
i ++ ) {
if ( ! ( epmask & ( 1u << i ) ) ) {
continue ;
}
epctx = slot -> eps [ i - 1 ] ;
ep = xhci_epid_to_usbep ( epctx ) ;
if ( ! epctx || ! epctx -> nr_pstreams || ! ep ) {
continue ;
}
if ( epctxs ) {
epctxs [ j ] = epctx ;
}
eps [ j ++ ] = ep ;
}
return j ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static FILE * NeedsUCS2Table ( SplineFont * sf , int * ucs2len , EncMap * map , int issymbol ) {
uint32 * avail = malloc ( 65536 * sizeof ( uint32 ) ) ;
int i , j , l ;
int segcnt , cnt = 0 , delta , rpos ;
struct cmapseg {
uint16 start , end ;
uint16 delta ;
uint16 rangeoff ;
}
* cmapseg ;
uint16 * ranges ;
SplineChar * sc ;
FILE * format4 = tmpfile ( ) ;
memset ( avail , 0xff , 65536 * sizeof ( uint32 ) ) ;
if ( map -> enc -> is_unicodebmp || map -> enc -> is_unicodefull ) {
int gid ;
for ( i = 0 ;
i < 65536 && i < map -> enccount ;
++ i ) if ( ( gid = map -> map [ i ] ) != - 1 && sf -> glyphs [ gid ] != NULL && sf -> glyphs [ gid ] -> ttf_glyph != - 1 ) {
avail [ i ] = gid ;
++ cnt ;
}
}
else {
struct altuni * altuni ;
for ( i = 0 ;
i < sf -> glyphcnt ;
++ i ) {
if ( ( sc = sf -> glyphs [ i ] ) != NULL && sc -> ttf_glyph != - 1 ) {
if ( sc -> unicodeenc >= 0 && sc -> unicodeenc <= 0xffff ) {
avail [ sc -> unicodeenc ] = i ;
++ cnt ;
}
for ( altuni = sc -> altuni ;
altuni != NULL ;
altuni = altuni -> next ) {
if ( altuni -> unienc <= 0xffff && altuni -> vs == - 1 && altuni -> fid == 0 ) {
avail [ altuni -> unienc ] = i ;
++ cnt ;
}
}
}
}
}
if ( issymbol ) {
memset ( avail , 0xff , 0xf020 * sizeof ( uint32 ) ) ;
memset ( avail + 0xf100 , 0xff , 0x0eff * sizeof ( uint32 ) ) ;
}
j = - 1 ;
for ( i = segcnt = 0 ;
i < 65536 ;
++ i ) {
if ( avail [ i ] != 0xffffffff && j == - 1 ) {
j = i ;
++ segcnt ;
}
else if ( j != - 1 && avail [ i ] == 0xffffffff ) j = - 1 ;
}
cmapseg = calloc ( segcnt + 1 , sizeof ( struct cmapseg ) ) ;
ranges = malloc ( cnt * sizeof ( int16 ) ) ;
j = - 1 ;
for ( i = segcnt = 0 ;
i < 65536 ;
++ i ) {
if ( avail [ i ] != 0xffffffff && j == - 1 ) {
j = i ;
cmapseg [ segcnt ] . start = j ;
++ segcnt ;
}
else if ( j != - 1 && avail [ i ] == 0xffffffff ) {
cmapseg [ segcnt - 1 ] . end = i - 1 ;
j = - 1 ;
}
}
if ( j != - 1 ) cmapseg [ segcnt - 1 ] . end = i - 1 ;
cmapseg [ segcnt ] . start = cmapseg [ segcnt ] . end = 0xffff ;
cmapseg [ segcnt ++ ] . delta = 1 ;
rpos = 0 ;
for ( i = 0 ;
i < segcnt - 1 ;
++ i ) {
l = avail [ cmapseg [ i ] . start ] ;
sc = sf -> glyphs [ l ] ;
delta = sc -> ttf_glyph - cmapseg [ i ] . start ;
for ( j = cmapseg [ i ] . start ;
j <= cmapseg [ i ] . end ;
++ j ) {
l = avail [ j ] ;
sc = sf -> glyphs [ l ] ;
if ( delta != sc -> ttf_glyph - j ) break ;
}
if ( j > cmapseg [ i ] . end ) cmapseg [ i ] . delta = delta ;
else {
cmapseg [ i ] . rangeoff = ( rpos + ( segcnt - i ) ) * sizeof ( int16 ) ;
for ( j = cmapseg [ i ] . start ;
j <= cmapseg [ i ] . end ;
++ j ) {
l = avail [ j ] ;
sc = sf -> glyphs [ l ] ;
ranges [ rpos ++ ] = sc -> ttf_glyph ;
}
}
}
free ( avail ) ;
putshort ( format4 , 4 ) ;
putshort ( format4 , ( 8 + 4 * segcnt + rpos ) * sizeof ( int16 ) ) ;
putshort ( format4 , 0 ) ;
putshort ( format4 , 2 * segcnt ) ;
for ( j = 0 , i = 1 ;
i <= segcnt ;
i <<= 1 , ++ j ) ;
putshort ( format4 , i ) ;
putshort ( format4 , j - 1 ) ;
putshort ( format4 , 2 * segcnt - i ) ;
for ( i = 0 ;
i < segcnt ;
++ i ) putshort ( format4 , cmapseg [ i ] . end ) ;
putshort ( format4 , 0 ) ;
for ( i = 0 ;
i < segcnt ;
++ i ) putshort ( format4 , cmapseg [ i ] . start ) ;
for ( i = 0 ;
i < segcnt ;
++ i ) putshort ( format4 , cmapseg [ i ] . delta ) ;
for ( i = 0 ;
i < segcnt ;
++ i ) putshort ( format4 , cmapseg [ i ] . rangeoff ) ;
for ( i = 0 ;
i < rpos ;
++ i ) putshort ( format4 , ranges [ i ] ) ;
free ( ranges ) ;
free ( cmapseg ) ;
* ucs2len = ftell ( format4 ) ;
return ( format4 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( TemplateURLParserTest , TestEmptyKeyword ) {
ASSERT_NO_FATAL_FAILURE ( ParseFile ( "empty_keyword.xml" , nullptr ) ) ;
ASSERT_TRUE ( template_url_ ) ;
EXPECT_EQ ( ASCIIToUTF16 ( "Example" ) , template_url_ -> short_name ( ) ) ;
EXPECT_EQ ( "https://www.example.com/search?q={
searchTerms}
" , template_url_ -> url ( ) ) ;
EXPECT_EQ ( ASCIIToUTF16 ( "example.com" ) , template_url_ -> keyword ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_Nlpid ( 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_Nlpid , Nlpid_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | extern int name ( int , locale_t ) __THROW __exctype_l ( isalnum_l ) ;
__exctype_l ( isalpha_l ) ;
__exctype_l ( iscntrl_l ) ;
__exctype_l ( isdigit_l ) ;
__exctype_l ( islower_l ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static bluetooth_uuid_t get_service_uuid_from_handle ( packet_info * pinfo , guint32 handle , bluetooth_data_t * bluetooth_data ) {
wmem_tree_key_t key [ 4 ] ;
guint32 frame_number ;
handle_data_t * handle_data ;
wmem_tree_t * sub_wmemtree ;
bluetooth_uuid_t uuid ;
memset ( & uuid , 0 , sizeof uuid ) ;
frame_number = pinfo -> num ;
key [ 0 ] . length = 1 ;
key [ 0 ] . key = & bluetooth_data -> interface_id ;
key [ 1 ] . length = 1 ;
key [ 1 ] . key = & bluetooth_data -> adapter_id ;
key [ 2 ] . length = 1 ;
key [ 2 ] . key = & handle ;
key [ 3 ] . length = 0 ;
key [ 3 ] . key = NULL ;
while ( handle > 0 ) {
sub_wmemtree = ( wmem_tree_t * ) wmem_tree_lookup32_array ( handle_to_uuid , key ) ;
handle_data = ( sub_wmemtree ) ? ( handle_data_t * ) wmem_tree_lookup32_le ( sub_wmemtree , frame_number ) : NULL ;
if ( handle_data && handle_data -> type == ATTRIBUTE_TYPE_SERVICE ) {
uuid = handle_data -> uuid ;
return uuid ;
}
handle -= 1 ;
}
return uuid ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | Item_result item_cmp_type ( Item_result a , Item_result b ) {
if ( a == STRING_RESULT && b == STRING_RESULT ) return STRING_RESULT ;
if ( a == INT_RESULT && b == INT_RESULT ) return INT_RESULT ;
else if ( a == ROW_RESULT || b == ROW_RESULT ) return ROW_RESULT ;
else if ( a == TIME_RESULT || b == TIME_RESULT ) return TIME_RESULT ;
if ( ( a == INT_RESULT || a == DECIMAL_RESULT ) && ( b == INT_RESULT || b == DECIMAL_RESULT ) ) return DECIMAL_RESULT ;
return REAL_RESULT ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static ossl_inline void lh_ ## type ## _node_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_node_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline void lh_ ## type ## _node_usage_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_node_usage_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline void lh_ ## type ## _stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline unsigned long lh_ ## type ## _get_down_load ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_get_down_load ( ( OPENSSL_LHASH * ) lh ) ;
}
static ossl_inline void lh_ ## type ## _set_down_load ( LHASH_OF ( type ) * lh , unsigned long dl ) {
OPENSSL_LH_set_down_load ( ( OPENSSL_LHASH * ) lh , dl ) ;
}
static ossl_inline void lh_ ## type ## _doall ( LHASH_OF ( type ) * lh , void ( * doall ) ( type * ) ) {
OPENSSL_LH_doall ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNC ) doall ) ;
}
LHASH_OF ( type ) # define IMPLEMENT_LHASH_DOALL_ARG_CONST ( type , argtype ) int_implement_lhash_doall ( type , argtype , const type ) # define IMPLEMENT_LHASH_DOALL_ARG ( type , argtype ) int_implement_lhash_doall ( type , argtype , type ) # define int_implement_lhash_doall ( type , argtype , cbargtype ) static ossl_inline void lh_ ## type ## _doall_ ## argtype ( LHASH_OF ( type ) * lh , void ( * fn ) ( cbargtype * , argtype * ) , argtype * arg ) {
OPENSSL_LH_doall_arg ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNCARG ) fn , ( void * ) arg ) ;
}
LHASH_OF ( type ) DEFINE_LHASH_OF ( OPENSSL_STRING ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( HistoryQuickProviderTest , VisitCountMatches ) {
std : : vector < std : : string > expected_urls ;
expected_urls . push_back ( "http://visitedest.com/y/a" ) ;
expected_urls . push_back ( "http://visitedest.com/y/b" ) ;
expected_urls . push_back ( "http://visitedest.com/x/c" ) ;
RunTest ( ASCIIToUTF16 ( "visitedest" ) , false , expected_urls , true , ASCIIToUTF16 ( "visitedest.com/y/a" ) , ASCIIToUTF16 ( ".com/y/a" ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void prplcb_privacy_permit_added ( PurpleAccount * account , const char * name ) {
struct im_connection * ic = purple_ic_by_pa ( account ) ;
if ( ! g_slist_find_custom ( ic -> permit , name , ( GCompareFunc ) ic -> acc -> prpl -> handle_cmp ) ) {
ic -> permit = g_slist_prepend ( ic -> permit , g_strdup ( name ) ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int mbfl_buffer_converter_feed2 ( mbfl_buffer_converter * convd , mbfl_string * string , int * loc ) {
int n ;
unsigned char * p ;
mbfl_convert_filter * filter ;
int ( * filter_function ) ( int c , mbfl_convert_filter * filter ) ;
if ( convd == NULL || string == NULL ) {
return - 1 ;
}
mbfl_memory_device_realloc ( & convd -> device , convd -> device . pos + string -> len , string -> len / 4 ) ;
n = string -> len ;
p = string -> val ;
filter = convd -> filter1 ;
if ( filter != NULL ) {
filter_function = filter -> filter_function ;
while ( n > 0 ) {
if ( ( * filter_function ) ( * p ++ , filter ) < 0 ) {
if ( loc ) {
* loc = p - string -> val ;
}
return - 1 ;
}
n -- ;
}
}
if ( loc ) {
* loc = p - string -> val ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void config_filter_parsers_free ( struct config_module_parser * parsers ) {
unsigned int i ;
for ( i = 0 ;
parsers [ i ] . root != NULL ;
i ++ ) settings_parser_deinit ( & parsers [ i ] . parser ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static uint64_t _get_db_index ( mysql_conn_t * mysql_conn , time_t submit , uint32_t jobid , uint32_t associd ) {
MYSQL_RES * result = NULL ;
MYSQL_ROW row ;
uint64_t db_index = 0 ;
char * query = xstrdup_printf ( "select job_db_inx from \"%s_%s\" where " "time_submit=%d and id_job=%u " "and id_assoc=%u" , mysql_conn -> cluster_name , job_table , ( int ) submit , jobid , associd ) ;
if ( ! ( result = mysql_db_query_ret ( mysql_conn , query , 0 ) ) ) {
xfree ( query ) ;
return 0 ;
}
xfree ( query ) ;
row = mysql_fetch_row ( result ) ;
if ( ! row ) {
mysql_free_result ( result ) ;
debug4 ( "We can't get a db_index for this combo, " "time_submit=%d and id_job=%u and id_assoc=%u. " "We must not have heard about the start yet, " "no big deal, we will get one right after this." , ( int ) submit , jobid , associd ) ;
return 0 ;
}
db_index = slurm_atoull ( row [ 0 ] ) ;
mysql_free_result ( result ) ;
return db_index ;
} | 0False
|