instruction
stringclasses 1
value | input
stringlengths 31
235k
| output
class label 2
classes |
---|---|---|
Categorize the following code snippet as vulnerable or not. True or False | static int peer_has_ufo ( VirtIONet * n ) {
if ( ! peer_has_vnet_hdr ( n ) ) return 0 ;
n -> has_ufo = tap_has_ufo ( n -> nic -> nc . peer ) ;
return n -> has_ufo ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool cgroupfs_mount_cgroup ( void * hdata , const char * root , int type ) {
size_t bufsz = strlen ( root ) + sizeof ( "/sys/fs/cgroup" ) ;
char * path = NULL ;
char * * parts = NULL ;
char * dirname = NULL ;
char * abs_path = NULL ;
char * abs_path2 = NULL ;
struct cgfs_data * cgfs_d ;
struct cgroup_process_info * info , * base_info ;
int r , saved_errno = 0 ;
cgfs_d = hdata ;
if ( ! cgfs_d ) return false ;
base_info = cgfs_d -> info ;
if ( type == LXC_AUTO_CGROUP_FULL_NOSPEC ) type = LXC_AUTO_CGROUP_FULL_MIXED ;
else if ( type == LXC_AUTO_CGROUP_NOSPEC ) type = LXC_AUTO_CGROUP_MIXED ;
if ( type < LXC_AUTO_CGROUP_RO || type > LXC_AUTO_CGROUP_FULL_MIXED ) {
ERROR ( "could not mount cgroups into container: invalid type specified internally" ) ;
errno = EINVAL ;
return false ;
}
path = calloc ( 1 , bufsz ) ;
if ( ! path ) return false ;
snprintf ( path , bufsz , "%s/sys/fs/cgroup" , root ) ;
r = safe_mount ( "cgroup_root" , path , "tmpfs" , MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME , "size=10240k,mode=755" , root ) ;
if ( r < 0 ) {
SYSERROR ( "could not mount tmpfs to /sys/fs/cgroup in the container" ) ;
return false ;
}
for ( info = base_info ;
info ;
info = info -> next ) {
size_t subsystem_count , i ;
struct cgroup_mount_point * mp = info -> designated_mount_point ;
if ( ! mp ) mp = lxc_cgroup_find_mount_point ( info -> hierarchy , info -> cgroup_path , true ) ;
if ( ! mp ) {
SYSERROR ( "could not find original mount point for cgroup hierarchy while trying to mount cgroup filesystem" ) ;
goto out_error ;
}
subsystem_count = lxc_array_len ( ( void * * ) info -> hierarchy -> subsystems ) ;
parts = calloc ( subsystem_count + 1 , sizeof ( char * ) ) ;
if ( ! parts ) goto out_error ;
for ( i = 0 ;
i < subsystem_count ;
i ++ ) {
if ( ! strncmp ( info -> hierarchy -> subsystems [ i ] , "name=" , 5 ) ) parts [ i ] = info -> hierarchy -> subsystems [ i ] + 5 ;
else parts [ i ] = info -> hierarchy -> subsystems [ i ] ;
}
dirname = lxc_string_join ( "," , ( const char * * ) parts , false ) ;
if ( ! dirname ) goto out_error ;
abs_path = lxc_append_paths ( path , dirname ) ;
if ( ! abs_path ) goto out_error ;
r = mkdir_p ( abs_path , 0755 ) ;
if ( r < 0 && errno != EEXIST ) {
SYSERROR ( "could not create cgroup subsystem directory /sys/fs/cgroup/%s" , dirname ) ;
goto out_error ;
}
abs_path2 = lxc_append_paths ( abs_path , info -> cgroup_path ) ;
if ( ! abs_path2 ) goto out_error ;
if ( type == LXC_AUTO_CGROUP_FULL_RO || type == LXC_AUTO_CGROUP_FULL_RW || type == LXC_AUTO_CGROUP_FULL_MIXED ) {
if ( strcmp ( mp -> mount_prefix , "/" ) != 0 ) {
ERROR ( "could not automatically mount cgroup-full to /sys/fs/cgroup/%s: host has no mount point for this cgroup filesystem that has access to the root cgroup" , dirname ) ;
goto out_error ;
}
r = mount ( mp -> mount_point , abs_path , "none" , MS_BIND , 0 ) ;
if ( r < 0 ) {
SYSERROR ( "error bind-mounting %s to %s" , mp -> mount_point , abs_path ) ;
goto out_error ;
}
if ( type == LXC_AUTO_CGROUP_FULL_RO || type == LXC_AUTO_CGROUP_FULL_MIXED ) {
r = mount ( NULL , abs_path , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error re-mounting %s readonly" , abs_path ) ;
goto out_error ;
}
}
if ( type == LXC_AUTO_CGROUP_FULL_MIXED ) {
r = mount ( abs_path2 , abs_path2 , NULL , MS_BIND , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error bind-mounting %s onto itself" , abs_path2 ) ;
goto out_error ;
}
r = mount ( NULL , abs_path2 , NULL , MS_REMOUNT | MS_BIND , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error re-mounting %s readwrite" , abs_path2 ) ;
goto out_error ;
}
}
}
else {
r = mkdir_p ( abs_path2 , 0755 ) ;
if ( r < 0 && errno != EEXIST ) {
SYSERROR ( "could not create cgroup directory /sys/fs/cgroup/%s%s" , dirname , info -> cgroup_path ) ;
goto out_error ;
}
if ( type == LXC_AUTO_CGROUP_MIXED || type == LXC_AUTO_CGROUP_RO ) {
r = mount ( abs_path , abs_path , NULL , MS_BIND , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error bind-mounting %s onto itself" , abs_path ) ;
goto out_error ;
}
r = mount ( NULL , abs_path , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error re-mounting %s readonly" , abs_path ) ;
goto out_error ;
}
}
free ( abs_path ) ;
abs_path = NULL ;
abs_path = cgroup_to_absolute_path ( mp , info -> cgroup_path , NULL ) ;
if ( ! abs_path ) goto out_error ;
r = mount ( abs_path , abs_path2 , "none" , MS_BIND , 0 ) ;
if ( r < 0 ) {
SYSERROR ( "error bind-mounting %s to %s" , abs_path , abs_path2 ) ;
goto out_error ;
}
if ( type == LXC_AUTO_CGROUP_RO ) {
r = mount ( NULL , abs_path2 , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL ) ;
if ( r < 0 ) {
SYSERROR ( "error re-mounting %s readonly" , abs_path2 ) ;
goto out_error ;
}
}
}
free ( abs_path ) ;
free ( abs_path2 ) ;
abs_path = NULL ;
abs_path2 = NULL ;
if ( subsystem_count > 1 ) {
for ( i = 0 ;
i < subsystem_count ;
i ++ ) {
abs_path = lxc_append_paths ( path , parts [ i ] ) ;
if ( ! abs_path ) goto out_error ;
r = symlink ( dirname , abs_path ) ;
if ( r < 0 ) WARN ( "could not create symlink %s -> %s in /sys/fs/cgroup of container" , parts [ i ] , dirname ) ;
free ( abs_path ) ;
abs_path = NULL ;
}
}
free ( dirname ) ;
free ( parts ) ;
dirname = NULL ;
parts = NULL ;
}
free ( path ) ;
return true ;
out_error : saved_errno = errno ;
free ( path ) ;
free ( dirname ) ;
free ( parts ) ;
free ( abs_path ) ;
free ( abs_path2 ) ;
errno = saved_errno ;
return false ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cleanup_key_data ( context , count , data ) krb5_context context ;
int count ;
krb5_key_data * data ;
{
int i , j ;
for ( i = 0 ;
i < count ;
i ++ ) for ( j = 0 ;
j < data [ i ] . key_data_ver ;
j ++ ) if ( data [ i ] . key_data_length [ j ] ) krb5_db_free ( context , data [ i ] . key_data_contents [ j ] ) ;
krb5_db_free ( context , data ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_AddConnectionReq ( 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_AddConnectionReq , AddConnectionReq_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( SSLErrorAssistantTest , MitMSoftwareMatching ) {
ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
auto config_proto = std : : make_unique < chrome_browser_ssl : : SSLErrorAssistantConfig > ( ) ;
config_proto -> set_version_id ( kLargeVersionId ) ;
chrome_browser_ssl : : MITMSoftware * filter = config_proto -> add_mitm_software ( ) ;
filter -> set_name ( "Basic Check" ) ;
filter -> set_issuer_common_name_regex ( "Misconfig Software" ) ;
filter -> set_issuer_organization_regex ( "Test Company" ) ;
filter = config_proto -> add_mitm_software ( ) ;
filter -> set_name ( "Regex Check" ) ;
filter -> set_issuer_common_name_regex ( "ij[a-z]+n opqrs" ) ;
filter -> set_issuer_organization_regex ( "abc de[a-z0-9]gh [a-z]+" ) ;
error_assistant ( ) -> SetErrorAssistantProto ( std : : move ( config_proto ) ) ;
TestMITMSoftwareMatchFromString ( kMisconfigSoftwareCert , "Basic Check" ) ;
TestMITMSoftwareMatchFromString ( kMisconfigSoftwareRegexCheckCert , "Regex Check" ) ;
error_assistant ( ) -> ResetForTesting ( ) ;
config_proto . reset ( new chrome_browser_ssl : : SSLErrorAssistantConfig ( ) ) ;
config_proto -> set_version_id ( kLargeVersionId ) ;
filter = config_proto -> add_mitm_software ( ) ;
filter -> set_name ( "Incorrect common name" ) ;
filter -> set_issuer_common_name_regex ( "Misconfig Sotware" ) ;
filter -> set_issuer_organization_regex ( "Test Company" ) ;
filter = config_proto -> add_mitm_software ( ) ;
filter -> set_name ( "Incorrect company name" ) ;
filter -> set_issuer_common_name_regex ( "Misconfig Software" ) ;
filter -> set_issuer_organization_regex ( "Tst Company" ) ;
error_assistant ( ) -> SetErrorAssistantProto ( std : : move ( config_proto ) ) ;
TestMITMSoftwareMatchFromString ( kMisconfigSoftwareCert , "" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void generate_nonce ( struct recvbuf * rbufp , char * nonce , size_t nonce_octets ) {
u_int32 derived ;
derived = derive_nonce ( & rbufp -> recv_srcadr , rbufp -> recv_time . l_ui , rbufp -> recv_time . l_uf ) ;
snprintf ( nonce , nonce_octets , "%08x%08x%08x" , rbufp -> recv_time . l_ui , rbufp -> recv_time . l_uf , derived ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( ExternalProtocolHandlerTest , DISABLED_TestLaunchSchemeUnknownChromeUnknown ) {
DoTest ( ExternalProtocolHandler : : UNKNOWN , shell_integration : : UNKNOWN_DEFAULT , Action : : PROMPT ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | const EVP_CIPHER * EVP_aes_ ## keylen ## _ ## mode ( void ) \ {
return & aes_ ## keylen ## _ ## mode ;
}
# endif # if defined ( OPENSSL_CPUID_OBJ ) && ( defined ( __arm__ ) || defined ( __arm ) || defined ( __aarch64__ ) ) # include "arm_arch.h" # if __ARM_MAX_ARCH__ >= 7 # if defined ( BSAES_ASM ) # define BSAES_CAPABLE ( OPENSSL_armcap_P & ARMV7_NEON ) # endif # if defined ( VPAES_ASM ) # define VPAES_CAPABLE ( OPENSSL_armcap_P & ARMV7_NEON ) # endif # define HWAES_CAPABLE ( OPENSSL_armcap_P & ARMV8_AES ) # define HWAES_set_encrypt_key aes_v8_set_encrypt_key # define HWAES_set_decrypt_key aes_v8_set_decrypt_key # define HWAES_encrypt aes_v8_encrypt # define HWAES_decrypt aes_v8_decrypt # define HWAES_cbc_encrypt aes_v8_cbc_encrypt # define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks # endif # endif # if defined ( HWAES_CAPABLE ) int HWAES_set_encrypt_key ( const unsigned char * userKey , const int bits , AES_KEY * key ) ;
int HWAES_set_decrypt_key ( const unsigned char * userKey , const int bits , AES_KEY * key ) ;
void HWAES_encrypt ( const unsigned char * in , unsigned char * out , const AES_KEY * key ) ;
void HWAES_decrypt ( const unsigned char * in , unsigned char * out , const AES_KEY * key ) ;
void HWAES_cbc_encrypt ( const unsigned char * in , unsigned char * out , size_t length , const AES_KEY * key , unsigned char * ivec , const int enc ) ;
void HWAES_ctr32_encrypt_blocks ( const unsigned char * in , unsigned char * out , size_t len , const AES_KEY * key , const unsigned char ivec [ 16 ] ) ;
void HWAES_xts_encrypt ( const unsigned char * inp , unsigned char * out , size_t len , const AES_KEY * key1 , const AES_KEY * key2 , const unsigned char iv [ 16 ] ) ;
void HWAES_xts_decrypt ( const unsigned char * inp , unsigned char * out , size_t len , const AES_KEY * key1 , const AES_KEY * key2 , const unsigned char iv [ 16 ] ) ;
# endif # define BLOCK_CIPHER_generic_pack ( nid , keylen , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 16 , 16 , cbc , cbc , CBC , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 16 , 0 , ecb , ecb , ECB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , ofb128 , ofb , OFB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb128 , cfb , CFB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb1 , cfb1 , CFB , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb8 , cfb8 , CFB , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , ctr , ctr , CTR , flags ) static int aes_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
int ret , mode ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
mode = EVP_CIPHER_CTX_mode ( ctx ) ;
if ( ( mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE ) && ! enc ) {
# ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
ret = HWAES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) HWAES_decrypt ;
dat -> stream . cbc = NULL ;
# ifdef HWAES_cbc_encrypt if ( mode == EVP_CIPH_CBC_MODE ) dat -> stream . cbc = ( cbc128_f ) HWAES_cbc_encrypt ;
# endif }
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE && mode == EVP_CIPH_CBC_MODE ) {
ret = AES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_decrypt ;
dat -> stream . cbc = ( cbc128_f ) bsaes_cbc_encrypt ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
ret = vpaes_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) vpaes_decrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) vpaes_cbc_encrypt : NULL ;
}
else # endif {
ret = AES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_decrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) AES_cbc_encrypt : NULL ;
}
}
else # ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
ret = HWAES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) HWAES_encrypt ;
dat -> stream . cbc = NULL ;
# ifdef HWAES_cbc_encrypt if ( mode == EVP_CIPH_CBC_MODE ) dat -> stream . cbc = ( cbc128_f ) HWAES_cbc_encrypt ;
else # endif # ifdef HWAES_ctr32_encrypt_blocks if ( mode == EVP_CIPH_CTR_MODE ) dat -> stream . ctr = ( ctr128_f ) HWAES_ctr32_encrypt_blocks ;
else # endif ( void ) 0 ;
}
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE && mode == EVP_CIPH_CTR_MODE ) {
ret = AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_encrypt ;
dat -> stream . ctr = ( ctr128_f ) bsaes_ctr32_encrypt_blocks ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
ret = vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) vpaes_encrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) vpaes_cbc_encrypt : NULL ;
}
else # endif {
ret = AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_encrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) AES_cbc_encrypt : NULL ;
# ifdef AES_CTR_ASM if ( mode == EVP_CIPH_CTR_MODE ) dat -> stream . ctr = ( ctr128_f ) AES_ctr32_encrypt ;
# endif }
if ( ret < 0 ) {
EVPerr ( EVP_F_AES_INIT_KEY , EVP_R_AES_KEY_SETUP_FAILED ) ;
return 0 ;
}
return 1 ;
}
static int aes_cbc_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( dat -> stream . cbc ) ( * dat -> stream . cbc ) ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_encrypting ( ctx ) ) ;
else if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) CRYPTO_cbc128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , dat -> block ) ;
else CRYPTO_cbc128_decrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , dat -> block ) ;
return 1 ;
}
static int aes_ecb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
size_t bl = EVP_CIPHER_CTX_block_size ( ctx ) ;
size_t i ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( len < bl ) return 1 ;
for ( i = 0 , len -= bl ;
i <= len ;
i += bl ) ( * dat -> block ) ( in + i , out + i , & dat -> ks ) ;
return 1 ;
}
static int aes_ofb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_ofb128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb8_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_8_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb1_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( EVP_CIPHER_CTX_test_flags ( ctx , EVP_CIPH_FLAG_LENGTH_BITS ) ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
while ( len >= MAXBITCHUNK ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , MAXBITCHUNK * 8 , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
len -= MAXBITCHUNK ;
}
if ( len ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , len * 8 , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
}
return 1 ;
}
static int aes_ctr_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
unsigned int num = EVP_CIPHER_CTX_num ( ctx ) ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( dat -> stream . ctr ) CRYPTO_ctr128_encrypt_ctr32 ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_buf_noconst ( ctx ) , & num , dat -> stream . ctr ) ;
else CRYPTO_ctr128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_buf_noconst ( ctx ) , & num , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
BLOCK_CIPHER_generic_pack ( NID_aes , 128 , 0 ) BLOCK_CIPHER_generic_pack ( NID_aes , 192 , 0 ) BLOCK_CIPHER_generic_pack ( NID_aes , 256 , 0 ) static int aes_gcm_cleanup ( EVP_CIPHER_CTX * c ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , c ) ;
OPENSSL_cleanse ( & gctx -> gcm , sizeof ( gctx -> gcm ) ) ;
if ( gctx -> iv != EVP_CIPHER_CTX_iv_noconst ( c ) ) OPENSSL_free ( gctx -> iv ) ;
return 1 ;
}
static void ctr64_inc ( unsigned char * counter ) {
int n = 8 ;
unsigned char c ;
do {
-- n ;
c = counter [ n ] ;
++ c ;
counter [ n ] = c ;
if ( c ) return ;
}
while ( n ) ;
}
static int aes_gcm_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , c ) ;
switch ( type ) {
case EVP_CTRL_INIT : gctx -> key_set = 0 ;
gctx -> iv_set = 0 ;
gctx -> ivlen = EVP_CIPHER_CTX_iv_length ( c ) ;
gctx -> iv = EVP_CIPHER_CTX_iv_noconst ( c ) ;
gctx -> taglen = - 1 ;
gctx -> iv_gen = 0 ;
gctx -> tls_aad_len = - 1 ;
return 1 ;
case EVP_CTRL_AEAD_SET_IVLEN : if ( arg <= 0 ) return 0 ;
if ( ( arg > EVP_MAX_IV_LENGTH ) && ( arg > gctx -> ivlen ) ) {
if ( gctx -> iv != EVP_CIPHER_CTX_iv_noconst ( c ) ) OPENSSL_free ( gctx -> iv ) ;
gctx -> iv = OPENSSL_malloc ( arg ) ;
if ( gctx -> iv == NULL ) return 0 ;
}
gctx -> ivlen = arg ;
return 1 ;
case EVP_CTRL_AEAD_SET_TAG : if ( arg <= 0 || arg > 16 || EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
gctx -> taglen = arg ;
return 1 ;
case EVP_CTRL_AEAD_GET_TAG : if ( arg <= 0 || arg > 16 || ! EVP_CIPHER_CTX_encrypting ( c ) || gctx -> taglen < 0 ) return 0 ;
memcpy ( ptr , EVP_CIPHER_CTX_buf_noconst ( c ) , arg ) ;
return 1 ;
case EVP_CTRL_GCM_SET_IV_FIXED : if ( arg == - 1 ) {
memcpy ( gctx -> iv , ptr , gctx -> ivlen ) ;
gctx -> iv_gen = 1 ;
return 1 ;
}
if ( ( arg < 4 ) || ( gctx -> ivlen - arg ) < 8 ) return 0 ;
if ( arg ) memcpy ( gctx -> iv , ptr , arg ) ;
if ( EVP_CIPHER_CTX_encrypting ( c ) && RAND_bytes ( gctx -> iv + arg , gctx -> ivlen - arg ) <= 0 ) return 0 ;
gctx -> iv_gen = 1 ;
return 1 ;
case EVP_CTRL_GCM_IV_GEN : if ( gctx -> iv_gen == 0 || gctx -> key_set == 0 ) return 0 ;
CRYPTO_gcm128_setiv ( & gctx -> gcm , gctx -> iv , gctx -> ivlen ) ;
if ( arg <= 0 || arg > gctx -> ivlen ) arg = gctx -> ivlen ;
memcpy ( ptr , gctx -> iv + gctx -> ivlen - arg , arg ) ;
ctr64_inc ( gctx -> iv + gctx -> ivlen - 8 ) ;
gctx -> iv_set = 1 ;
return 1 ;
case EVP_CTRL_GCM_SET_IV_INV : if ( gctx -> iv_gen == 0 || gctx -> key_set == 0 || EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( gctx -> iv + gctx -> ivlen - arg , ptr , arg ) ;
CRYPTO_gcm128_setiv ( & gctx -> gcm , gctx -> iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
return 1 ;
case EVP_CTRL_AEAD_TLS1_AAD : if ( arg != EVP_AEAD_TLS1_AAD_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
gctx -> tls_aad_len = arg ;
{
unsigned int len = EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] << 8 | EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN ;
if ( ! EVP_CIPHER_CTX_encrypting ( c ) ) len -= EVP_GCM_TLS_TAG_LEN ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] = len >> 8 ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] = len & 0xff ;
}
return EVP_GCM_TLS_TAG_LEN ;
case EVP_CTRL_COPY : {
EVP_CIPHER_CTX * out = ptr ;
EVP_AES_GCM_CTX * gctx_out = EVP_C_DATA ( EVP_AES_GCM_CTX , out ) ;
if ( gctx -> gcm . key ) {
if ( gctx -> gcm . key != & gctx -> ks ) return 0 ;
gctx_out -> gcm . key = & gctx_out -> ks ;
}
if ( gctx -> iv == EVP_CIPHER_CTX_iv_noconst ( c ) ) gctx_out -> iv = EVP_CIPHER_CTX_iv_noconst ( out ) ;
else {
gctx_out -> iv = OPENSSL_malloc ( gctx -> ivlen ) ;
if ( gctx_out -> iv == NULL ) return 0 ;
memcpy ( gctx_out -> iv , gctx -> iv , gctx -> ivlen ) ;
}
return 1 ;
}
default : return - 1 ;
}
}
static int aes_gcm_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
if ( ! iv && ! key ) return 1 ;
if ( key ) {
do {
# ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
HWAES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) HWAES_encrypt ) ;
# ifdef HWAES_ctr32_encrypt_blocks gctx -> ctr = ( ctr128_f ) HWAES_ctr32_encrypt_blocks ;
# else gctx -> ctr = NULL ;
# endif break ;
}
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE ) {
AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) AES_encrypt ) ;
gctx -> ctr = ( ctr128_f ) bsaes_ctr32_encrypt_blocks ;
break ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) vpaes_encrypt ) ;
gctx -> ctr = NULL ;
break ;
}
else # endif ( void ) 0 ;
AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) AES_encrypt ) ;
# ifdef AES_CTR_ASM gctx -> ctr = ( ctr128_f ) AES_ctr32_encrypt ;
# else gctx -> ctr = NULL ;
# endif }
while ( 0 ) ;
if ( iv == NULL && gctx -> iv_set ) iv = gctx -> iv ;
if ( iv ) {
CRYPTO_gcm128_setiv ( & gctx -> gcm , iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
}
gctx -> key_set = 1 ;
}
else {
if ( gctx -> key_set ) CRYPTO_gcm128_setiv ( & gctx -> gcm , iv , gctx -> ivlen ) ;
else memcpy ( gctx -> iv , iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
gctx -> iv_gen = 0 ;
}
return 1 ;
}
static int aes_gcm_tls_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
int rv = - 1 ;
if ( out != in || len < ( EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ) ) return - 1 ;
if ( EVP_CIPHER_CTX_ctrl ( ctx , EVP_CIPHER_CTX_encrypting ( ctx ) ? EVP_CTRL_GCM_IV_GEN : EVP_CTRL_GCM_SET_IV_INV , EVP_GCM_TLS_EXPLICIT_IV_LEN , out ) <= 0 ) goto err ;
if ( CRYPTO_gcm128_aad ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , gctx -> tls_aad_len ) ) goto err ;
in += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
out += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 32 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 32 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
out += len ;
CRYPTO_gcm128_tag ( & gctx -> gcm , out , EVP_GCM_TLS_TAG_LEN ) ;
rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
}
else {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 16 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 16 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
CRYPTO_gcm128_tag ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , EVP_GCM_TLS_TAG_LEN ) ;
if ( CRYPTO_memcmp ( EVP_CIPHER_CTX_buf_noconst ( ctx ) , in + len , EVP_GCM_TLS_TAG_LEN ) ) {
OPENSSL_cleanse ( out , len ) ;
goto err ;
}
rv = len ;
}
err : gctx -> iv_set = 0 ;
gctx -> tls_aad_len = - 1 ;
return rv ;
}
static int aes_gcm_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
if ( ! gctx -> key_set ) return - 1 ;
if ( gctx -> tls_aad_len >= 0 ) return aes_gcm_tls_cipher ( ctx , out , in , len ) ;
if ( ! gctx -> iv_set ) return - 1 ;
if ( in ) {
if ( out == NULL ) {
if ( CRYPTO_gcm128_aad ( & gctx -> gcm , in , len ) ) return - 1 ;
}
else if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 32 && AES_GCM_ASM ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_encrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) return - 1 ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 32 && AES_GCM_ASM2 ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) return - 1 ;
}
}
else {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 16 && AES_GCM_ASM ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_decrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) return - 1 ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 16 && AES_GCM_ASM2 ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) return - 1 ;
}
}
return len ;
}
else {
if ( ! EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> taglen < 0 ) return - 1 ;
if ( CRYPTO_gcm128_finish ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , gctx -> taglen ) != 0 ) return - 1 ;
gctx -> iv_set = 0 ;
return 0 ;
}
CRYPTO_gcm128_tag ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , 16 ) ;
gctx -> taglen = 16 ;
gctx -> iv_set = 0 ;
return 0 ;
}
}
# define CUSTOM_FLAGS ( EVP_CIPH_FLAG_DEFAULT_ASN1 \ | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \ | EVP_CIPH_CUSTOM_COPY ) BLOCK_CIPHER_custom ( NID_aes , 128 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 192 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 256 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) static int aes_xts_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_XTS_CTX * xctx = EVP_C_DATA ( EVP_AES_XTS_CTX , c ) ;
if ( type == EVP_CTRL_COPY ) {
EVP_CIPHER_CTX * out = ptr ;
EVP_AES_XTS_CTX * xctx_out = EVP_C_DATA ( EVP_AES_XTS_CTX , out ) ;
if ( xctx -> xts . key1 ) {
if ( xctx -> xts . key1 != & xctx -> ks1 ) return 0 ;
xctx_out -> xts . key1 = & xctx_out -> ks1 ;
}
if ( xctx -> xts . key2 ) {
if ( xctx -> xts . key2 != & xctx -> ks2 ) return 0 ;
xctx_out -> xts . key2 = & xctx_out -> ks2 ;
}
return 1 ;
}
else if ( type != EVP_CTRL_INIT ) return - 1 ;
xctx -> xts . key1 = NULL ;
xctx -> xts . key2 = NULL ;
return 1 ;
}
static int aes_xts_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
EVP_AES_XTS_CTX * xctx = EVP_C_DATA ( EVP_AES_XTS_CTX , ctx ) ;
if ( ! iv && ! key ) return 1 ;
if ( key ) do {
# ifdef AES_XTS_ASM xctx -> stream = enc ? AES_xts_encrypt : AES_xts_decrypt ;
# else xctx -> stream = NULL ;
# endif # ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
if ( enc ) {
HWAES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) HWAES_encrypt ;
# ifdef HWAES_xts_encrypt xctx -> stream = HWAES_xts_encrypt ;
# endif }
else {
HWAES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) HWAES_decrypt ;
# ifdef HWAES_xts_decrypt xctx -> stream = HWAES_xts_decrypt ;
# endif }
HWAES_set_encrypt_key ( key + EVP_CIPHER_CTX_key_length ( ctx ) / 2 , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks2 . ks ) ;
xctx -> xts . block2 = ( block128_f ) HWAES_encrypt ;
xctx -> xts . key1 = & xctx -> ks1 ;
break ;
}
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE ) xctx -> stream = enc ? bsaes_xts_encrypt : bsaes_xts_decrypt ;
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
if ( enc ) {
vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) vpaes_encrypt ;
}
else {
vpaes_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) vpaes_decrypt ;
}
vpaes_set_encrypt_key ( key + EVP_CIPHER_CTX_key_length ( ctx ) / 2 , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks2 . ks ) ;
xctx -> xts . block2 = ( block128_f ) vpaes_encrypt ;
xctx -> xts . key1 = & xctx -> ks1 ;
break ;
}
else # endif ( void ) 0 ;
if ( enc ) {
AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) AES_encrypt ;
}
else {
AES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks1 . ks ) ;
xctx -> xts . block1 = ( block128_f ) AES_decrypt ;
}
AES_set_encrypt_key ( key + EVP_CIPHER_CTX_key_length ( ctx ) / 2 , EVP_CIPHER_CTX_key_length ( ctx ) * 4 , & xctx -> ks2 . ks ) ;
xctx -> xts . block2 = ( block128_f ) AES_encrypt ;
xctx -> xts . key1 = & xctx -> ks1 ;
}
while ( 0 ) ;
if ( iv ) {
xctx -> xts . key2 = & xctx -> ks2 ;
memcpy ( EVP_CIPHER_CTX_iv_noconst ( ctx ) , iv , 16 ) ;
}
return 1 ;
}
static int aes_xts_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_XTS_CTX * xctx = EVP_C_DATA ( EVP_AES_XTS_CTX , ctx ) ;
if ( ! xctx -> xts . key1 || ! xctx -> xts . key2 ) return 0 ;
if ( ! out || ! in || len < AES_BLOCK_SIZE ) return 0 ;
if ( xctx -> stream ) ( * xctx -> stream ) ( in , out , len , xctx -> xts . key1 , xctx -> xts . key2 , EVP_CIPHER_CTX_iv_noconst ( ctx ) ) ;
else if ( CRYPTO_xts128_encrypt ( & xctx -> xts , EVP_CIPHER_CTX_iv_noconst ( ctx ) , in , out , len , EVP_CIPHER_CTX_encrypting ( ctx ) ) ) return 0 ;
return 1 ;
}
# define aes_xts_cleanup NULL # define XTS_FLAGS ( EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \ | EVP_CIPH_CUSTOM_COPY ) BLOCK_CIPHER_custom ( NID_aes , 128 , 1 , 16 , xts , XTS , XTS_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 256 , 1 , 16 , xts , XTS , XTS_FLAGS ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int cirrus_vga_read_cr ( CirrusVGAState * s , unsigned reg_index ) {
switch ( reg_index ) {
case 0x00 : case 0x01 : case 0x02 : case 0x03 : case 0x04 : case 0x05 : case 0x06 : case 0x07 : case 0x08 : case 0x09 : case 0x0a : case 0x0b : case 0x0c : case 0x0d : case 0x0e : case 0x0f : case 0x10 : case 0x11 : case 0x12 : case 0x13 : case 0x14 : case 0x15 : case 0x16 : case 0x17 : case 0x18 : return s -> vga . cr [ s -> vga . cr_index ] ;
case 0x24 : return ( s -> vga . ar_flip_flop << 7 ) ;
case 0x19 : case 0x1a : case 0x1b : case 0x1c : case 0x1d : case 0x22 : case 0x25 : case 0x27 : return s -> vga . cr [ s -> vga . cr_index ] ;
case 0x26 : return s -> vga . ar_index & 0x3f ;
break ;
default : # ifdef DEBUG_CIRRUS printf ( "cirrus: inport cr_index %02x\n" , reg_index ) ;
# endif return 0xff ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void reset_fpf_position ( TWO_PASS * p , const FIRSTPASS_STATS * position ) {
p -> stats_in = position ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( FullscreenControllerStateUnitTest , CapturedFullscreenedTabTransferredBetweenBrowserWindows ) {
content : : WebContentsDelegate * const wc_delegate = static_cast < content : : WebContentsDelegate * > ( browser ( ) ) ;
ASSERT_TRUE ( wc_delegate -> EmbedsFullscreenWidget ( ) ) ;
AddTab ( browser ( ) , GURL ( url : : kAboutBlankURL ) ) ;
AddTab ( browser ( ) , GURL ( url : : kAboutBlankURL ) ) ;
content : : WebContents * const tab = browser ( ) -> tab_strip_model ( ) -> GetWebContentsAt ( 0 ) ;
browser ( ) -> tab_strip_model ( ) -> ActivateTabAt ( 0 , true ) ;
const gfx : : Size kCaptureSize ( 1280 , 720 ) ;
tab -> IncrementCapturerCount ( kCaptureSize ) ;
ASSERT_FALSE ( browser ( ) -> window ( ) -> IsFullscreen ( ) ) ;
ASSERT_FALSE ( wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
ASSERT_FALSE ( GetFullscreenController ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
ASSERT_TRUE ( InvokeEvent ( TAB_FULLSCREEN_TRUE ) ) ;
EXPECT_FALSE ( browser ( ) -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_TRUE ( wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_FALSE ( GetFullscreenController ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
const scoped_ptr < BrowserWindow > second_browser_window ( CreateBrowserWindow ( ) ) ;
const scoped_ptr < Browser > second_browser ( CreateBrowser ( browser ( ) -> profile ( ) , browser ( ) -> type ( ) , false , browser ( ) -> host_desktop_type ( ) , second_browser_window . get ( ) ) ) ;
AddTab ( second_browser . get ( ) , GURL ( url : : kAboutBlankURL ) ) ;
content : : WebContentsDelegate * const second_wc_delegate = static_cast < content : : WebContentsDelegate * > ( second_browser . get ( ) ) ;
browser ( ) -> tab_strip_model ( ) -> DetachWebContentsAt ( 0 ) ;
second_browser -> tab_strip_model ( ) -> InsertWebContentsAt ( 0 , tab , TabStripModel : : ADD_ACTIVE ) ;
EXPECT_FALSE ( browser ( ) -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_FALSE ( second_browser -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_TRUE ( wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_TRUE ( second_wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_FALSE ( GetFullscreenController ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
EXPECT_FALSE ( second_browser -> fullscreen_controller ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
second_browser -> tab_strip_model ( ) -> DetachWebContentsAt ( 0 ) ;
browser ( ) -> tab_strip_model ( ) -> InsertWebContentsAt ( 0 , tab , TabStripModel : : ADD_ACTIVE ) ;
EXPECT_FALSE ( browser ( ) -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_FALSE ( second_browser -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_TRUE ( wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_TRUE ( second_wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_FALSE ( GetFullscreenController ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
EXPECT_FALSE ( second_browser -> fullscreen_controller ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
ASSERT_TRUE ( InvokeEvent ( TAB_FULLSCREEN_FALSE ) ) ;
EXPECT_FALSE ( browser ( ) -> window ( ) -> IsFullscreen ( ) ) ;
EXPECT_FALSE ( wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_FALSE ( second_wc_delegate -> IsFullscreenForTabOrPending ( tab ) ) ;
EXPECT_FALSE ( GetFullscreenController ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
EXPECT_FALSE ( second_browser -> fullscreen_controller ( ) -> IsWindowFullscreenForTabOrPending ( ) ) ;
second_browser -> tab_strip_model ( ) -> CloseAllTabs ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_nlm1_granted ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) {
return dissect_nlm_granted ( tvb , 0 , pinfo , tree , 1 , ( rpc_call_info_value * ) data ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int cont_test_handler ( TSCont contp , TSEvent event , void * edata ) {
TSHttpTxn txnp = ( TSHttpTxn ) edata ;
ConnectTestData * data = nullptr ;
int request_id = - 1 ;
CHECK_SPURIOUS_EVENT ( contp , event , edata ) ;
data = ( ConnectTestData * ) TSContDataGet ( contp ) ;
TSReleaseAssert ( data -> magic == MAGIC_ALIVE ) ;
TSReleaseAssert ( ( data -> test_case == TEST_CASE_CONNECT_ID1 ) || ( data -> test_case == TEST_CASE_CONNECT_ID2 ) ) ;
TSDebug ( UTDBG_TAG , "Calling cont_test_handler with event %s (%d)" , TSHttpEventNameLookup ( event ) , event ) ;
switch ( event ) {
case TS_EVENT_HTTP_READ_REQUEST_HDR : TSDebug ( UTDBG_TAG , "cont_test_handler: event READ_REQUEST" ) ;
request_id = get_request_id ( txnp ) ;
TSReleaseAssert ( request_id != - 1 ) ;
TSDebug ( UTDBG_TAG , "cont_test_handler: Request id = %d" , request_id ) ;
if ( ( request_id != TEST_CASE_CONNECT_ID1 ) && ( request_id != TEST_CASE_CONNECT_ID2 ) ) {
TSDebug ( UTDBG_TAG , "This is not an event for this test !" ) ;
TSHttpTxnReenable ( txnp , TS_EVENT_HTTP_CONTINUE ) ;
goto done ;
}
if ( ( request_id == TEST_CASE_CONNECT_ID1 ) && ( data -> test_case == TEST_CASE_CONNECT_ID1 ) ) {
TSDebug ( UTDBG_TAG , "Calling TSHttpTxnIntercept" ) ;
TSHttpTxnIntercept ( data -> os -> accept_cont , txnp ) ;
}
else if ( ( request_id == TEST_CASE_CONNECT_ID2 ) && ( data -> test_case == TEST_CASE_CONNECT_ID2 ) ) {
TSDebug ( UTDBG_TAG , "Calling TSHttpTxnServerIntercept" ) ;
TSHttpTxnServerIntercept ( data -> os -> accept_cont , txnp ) ;
}
TSHttpTxnReenable ( txnp , TS_EVENT_HTTP_CONTINUE ) ;
break ;
case TS_EVENT_TIMEOUT : if ( data -> browser -> status == REQUEST_INPROGRESS ) {
TSDebug ( UTDBG_TAG , "Browser still waiting response..." ) ;
TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
}
else {
char * body_response = get_body_ptr ( data -> browser -> response ) ;
const char * body_expected ;
if ( data -> test_case == TEST_CASE_CONNECT_ID1 ) {
body_expected = "Body for response 9" ;
}
else {
body_expected = "Body for response 10" ;
}
TSDebug ( UTDBG_TAG , "Body Response = \n|%s|\nBody Expected = \n|%s|" , body_response ? body_response : "*NULL*" , body_expected ) ;
if ( ! body_response || strncmp ( body_response , body_expected , strlen ( body_expected ) ) != 0 ) {
if ( data -> test_case == TEST_CASE_CONNECT_ID1 ) {
SDK_RPRINT ( data -> test , "TSHttpConnect" , "TestCase1" , TC_FAIL , "Unexpected response" ) ;
SDK_RPRINT ( data -> test , "TSHttpTxnIntercept" , "TestCase1" , TC_FAIL , "Unexpected response" ) ;
}
else {
SDK_RPRINT ( data -> test , "TSHttpConnect" , "TestCase2" , TC_FAIL , "Unexpected response" ) ;
SDK_RPRINT ( data -> test , "TSHttpTxnServerIntercept" , "TestCase2" , TC_FAIL , "Unexpected response" ) ;
}
* ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
}
else {
if ( data -> test_case == TEST_CASE_CONNECT_ID1 ) {
SDK_RPRINT ( data -> test , "TSHttpConnect" , "TestCase1" , TC_PASS , "ok" ) ;
SDK_RPRINT ( data -> test , "TSHttpTxnIntercept" , "TestCase1" , TC_PASS , "ok" ) ;
}
else {
SDK_RPRINT ( data -> test , "TSHttpConnect" , "TestCase2" , TC_PASS , "ok" ) ;
SDK_RPRINT ( data -> test , "TSHttpTxnServerIntercept" , "TestCase2" , TC_PASS , "ok" ) ;
}
* ( data -> pstatus ) = REGRESSION_TEST_PASSED ;
}
synclient_txn_delete ( data -> browser ) ;
synserver_delete ( data -> os ) ;
data -> os = nullptr ;
data -> magic = MAGIC_DEAD ;
TSfree ( data ) ;
TSContDataSet ( contp , nullptr ) ;
}
break ;
default : * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
SDK_RPRINT ( data -> test , "TSHttpConnect" , "TestCase1 or 2" , TC_FAIL , "Unexpected event %d" , event ) ;
break ;
}
done : return TS_EVENT_IMMEDIATE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void xsltCompileAttr ( xsltStylesheetPtr style , xmlAttrPtr attr ) {
const xmlChar * str ;
const xmlChar * cur ;
xmlChar * ret = NULL ;
xmlChar * expr = NULL ;
xsltAttrVTPtr avt ;
int i = 0 , lastavt = 0 ;
if ( ( style == NULL ) || ( attr == NULL ) || ( attr -> children == NULL ) ) return ;
if ( ( attr -> children -> type != XML_TEXT_NODE ) || ( attr -> children -> next != NULL ) ) {
xsltTransformError ( NULL , style , attr -> parent , "Attribute '%s': The content is expected to be a single text " "node when compiling an AVT.\n" , attr -> name ) ;
style -> errors ++ ;
return ;
}
str = attr -> children -> content ;
if ( ( xmlStrchr ( str , '{
' ) == NULL ) && ( xmlStrchr ( str , '}
' ) == NULL ) ) return ;
# ifdef WITH_XSLT_DEBUG_AVT xsltGenericDebug ( xsltGenericDebugContext , "Found AVT %s: %s\n" , attr -> name , str ) ;
# endif if ( attr -> psvi != NULL ) {
# ifdef WITH_XSLT_DEBUG_AVT xsltGenericDebug ( xsltGenericDebugContext , "AVT %s: already compiled\n" , attr -> name ) ;
# endif return ;
}
avt = xsltNewAttrVT ( style ) ;
if ( avt == NULL ) return ;
attr -> psvi = avt ;
avt -> nsList = xmlGetNsList ( attr -> doc , attr -> parent ) ;
if ( avt -> nsList != NULL ) {
while ( avt -> nsList [ i ] != NULL ) i ++ ;
}
avt -> nsNr = i ;
cur = str ;
while ( * cur != 0 ) {
if ( * cur == '{
' ) {
if ( * ( cur + 1 ) == '{
' ) {
cur ++ ;
ret = xmlStrncat ( ret , str , cur - str ) ;
cur ++ ;
str = cur ;
continue ;
}
if ( * ( cur + 1 ) == '}
' ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
cur += 2 ;
str = cur ;
continue ;
}
if ( ( ret != NULL ) || ( cur - str > 0 ) ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
str = cur ;
if ( avt -> nb_seg == 0 ) avt -> strstart = 1 ;
if ( ( avt = xsltSetAttrVTsegment ( avt , ( void * ) ret ) ) == NULL ) goto error ;
ret = NULL ;
lastavt = 0 ;
}
cur ++ ;
while ( ( * cur != 0 ) && ( * cur != '}
' ) ) {
if ( ( * cur == '\'' ) || ( * cur == '"' ) ) {
char delim = * ( cur ++ ) ;
while ( ( * cur != 0 ) && ( * cur != delim ) ) cur ++ ;
if ( * cur != 0 ) cur ++ ;
}
else cur ++ ;
}
if ( * cur == 0 ) {
xsltTransformError ( NULL , style , attr -> parent , "Attribute '%s': The AVT has an unmatched '{
'.\n" , attr -> name ) ;
style -> errors ++ ;
goto error ;
}
str ++ ;
expr = xmlStrndup ( str , cur - str ) ;
if ( expr == NULL ) {
XSLT_TODO goto error ;
}
else {
xmlXPathCompExprPtr comp ;
comp = xsltXPathCompile ( style , expr ) ;
if ( comp == NULL ) {
xsltTransformError ( NULL , style , attr -> parent , "Attribute '%s': Failed to compile the expression " "'%s' in the AVT.\n" , attr -> name , expr ) ;
style -> errors ++ ;
goto error ;
}
if ( avt -> nb_seg == 0 ) avt -> strstart = 0 ;
if ( lastavt == 1 ) {
if ( ( avt = xsltSetAttrVTsegment ( avt , NULL ) ) == NULL ) goto error ;
}
if ( ( avt = xsltSetAttrVTsegment ( avt , ( void * ) comp ) ) == NULL ) goto error ;
lastavt = 1 ;
xmlFree ( expr ) ;
expr = NULL ;
}
cur ++ ;
str = cur ;
}
else if ( * cur == '}
' ) {
cur ++ ;
if ( * cur == '}
' ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
cur ++ ;
str = cur ;
continue ;
}
else {
xsltTransformError ( NULL , style , attr -> parent , "Attribute '%s': The AVT has an unmatched '}
'.\n" , attr -> name ) ;
goto error ;
}
}
else cur ++ ;
}
if ( ( ret != NULL ) || ( cur - str > 0 ) ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
str = cur ;
if ( avt -> nb_seg == 0 ) avt -> strstart = 1 ;
if ( ( avt = xsltSetAttrVTsegment ( avt , ( void * ) ret ) ) == NULL ) goto error ;
ret = NULL ;
}
error : if ( avt == NULL ) {
xsltTransformError ( NULL , style , attr -> parent , "xsltCompileAttr: malloc problem\n" ) ;
}
else {
if ( attr -> psvi != avt ) {
attr -> psvi = avt ;
style -> attVTs = avt ;
}
}
if ( ret != NULL ) xmlFree ( ret ) ;
if ( expr != NULL ) xmlFree ( expr ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void txfm_rd_in_plane ( MACROBLOCK * x , int * rate , int64_t * distortion , int * skippable , int64_t * sse , int64_t ref_best_rd , int plane , BLOCK_SIZE bsize , TX_SIZE tx_size , int use_fast_coef_casting ) {
MACROBLOCKD * const xd = & x -> e_mbd ;
const struct macroblockd_plane * const pd = & xd -> plane [ plane ] ;
struct rdcost_block_args args ;
vp9_zero ( args ) ;
args . x = x ;
args . best_rd = ref_best_rd ;
args . use_fast_coef_costing = use_fast_coef_casting ;
if ( plane == 0 ) xd -> mi [ 0 ] -> mbmi . tx_size = tx_size ;
vp9_get_entropy_contexts ( bsize , tx_size , pd , args . t_above , args . t_left ) ;
args . so = get_scan ( xd , tx_size , pd -> plane_type , 0 ) ;
vp9_foreach_transformed_block_in_plane ( xd , bsize , plane , block_rd_txfm , & args ) ;
if ( args . skip ) {
* rate = INT_MAX ;
* distortion = INT64_MAX ;
* sse = INT64_MAX ;
* skippable = 0 ;
}
else {
* distortion = args . this_dist ;
* rate = args . this_rate ;
* sse = args . this_sse ;
* skippable = vp9_is_skippable_in_plane ( x , bsize , plane ) ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( ContentSettingBubbleDialogTest , InvokeDialog_plugins ) {
RunDialog ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_MultiplexEntryRejectionDescriptions ( 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_MultiplexEntryRejectionDescriptions , MultiplexEntryRejectionDescriptions_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int do_16x16_zerozero_search ( VP9_COMP * cpi , int_mv * dst_mv ) {
MACROBLOCK * const x = & cpi -> mb ;
MACROBLOCKD * const xd = & x -> e_mbd ;
unsigned int err ;
err = vp9_sad16x16 ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , xd -> plane [ 0 ] . pre [ 0 ] . buf , xd -> plane [ 0 ] . pre [ 0 ] . stride ) ;
dst_mv -> as_int = 0 ;
return err ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int32_t ultag_getExtlangSize ( const ULanguageTag * langtag ) {
int32_t size = 0 ;
int32_t i ;
for ( i = 0 ;
i < MAXEXTLANG ;
i ++ ) {
if ( langtag -> extlang [ i ] ) {
size ++ ;
}
}
return size ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void encode_block ( int plane , int block , BLOCK_SIZE plane_bsize , TX_SIZE tx_size , void * arg ) {
struct encode_b_args * const args = arg ;
MACROBLOCK * const x = args -> x ;
MACROBLOCKD * const xd = & x -> e_mbd ;
struct optimize_ctx * const ctx = args -> ctx ;
struct macroblock_plane * const p = & x -> plane [ plane ] ;
struct macroblockd_plane * const pd = & xd -> plane [ plane ] ;
int16_t * const dqcoeff = BLOCK_OFFSET ( pd -> dqcoeff , block ) ;
int i , j ;
uint8_t * dst ;
ENTROPY_CONTEXT * a , * l ;
txfrm_block_to_raster_xy ( plane_bsize , tx_size , block , & i , & j ) ;
dst = & pd -> dst . buf [ 4 * j * pd -> dst . stride + 4 * i ] ;
a = & ctx -> ta [ plane ] [ i ] ;
l = & ctx -> tl [ plane ] [ j ] ;
if ( x -> zcoeff_blk [ tx_size ] [ block ] && plane == 0 ) {
p -> eobs [ block ] = 0 ;
* a = * l = 0 ;
return ;
}
if ( ! x -> skip_recode ) {
if ( max_txsize_lookup [ plane_bsize ] == tx_size ) {
if ( x -> skip_txfm [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] == 0 ) {
if ( x -> quant_fp ) vp9_xform_quant_fp ( x , plane , block , plane_bsize , tx_size ) ;
else vp9_xform_quant ( x , plane , block , plane_bsize , tx_size ) ;
}
else if ( x -> skip_txfm [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] == 2 ) {
vp9_xform_quant_dc ( x , plane , block , plane_bsize , tx_size ) ;
}
else {
p -> eobs [ block ] = 0 ;
* a = * l = 0 ;
return ;
}
}
else {
vp9_xform_quant ( x , plane , block , plane_bsize , tx_size ) ;
}
}
if ( x -> optimize && ( ! x -> skip_recode || ! x -> skip_optimize ) ) {
const int ctx = combine_entropy_contexts ( * a , * l ) ;
* a = * l = optimize_b ( x , plane , block , tx_size , ctx ) > 0 ;
}
else {
* a = * l = p -> eobs [ block ] > 0 ;
}
if ( p -> eobs [ block ] ) * ( args -> skip ) = 0 ;
if ( x -> skip_encode || p -> eobs [ block ] == 0 ) return ;
switch ( tx_size ) {
case TX_32X32 : vp9_idct32x32_add ( dqcoeff , dst , pd -> dst . stride , p -> eobs [ block ] ) ;
break ;
case TX_16X16 : vp9_idct16x16_add ( dqcoeff , dst , pd -> dst . stride , p -> eobs [ block ] ) ;
break ;
case TX_8X8 : vp9_idct8x8_add ( dqcoeff , dst , pd -> dst . stride , p -> eobs [ block ] ) ;
break ;
case TX_4X4 : x -> itxm_add ( dqcoeff , dst , pd -> dst . stride , p -> eobs [ block ] ) ;
break ;
default : assert ( 0 && "Invalid transform size" ) ;
break ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | mbfl_string * mbfl_html_numeric_entity ( mbfl_string * string , mbfl_string * result , int * convmap , int mapsize , int type ) {
struct collector_htmlnumericentity_data pc ;
mbfl_memory_device device ;
mbfl_convert_filter * encoder ;
int n ;
unsigned char * p ;
if ( string == NULL || result == NULL ) {
return NULL ;
}
mbfl_string_init ( result ) ;
result -> no_language = string -> no_language ;
result -> no_encoding = string -> no_encoding ;
mbfl_memory_device_init ( & device , string -> len , 0 ) ;
pc . decoder = mbfl_convert_filter_new ( mbfl_no_encoding_wchar , string -> no_encoding , mbfl_memory_device_output , 0 , & device ) ;
if ( type == 0 ) {
encoder = mbfl_convert_filter_new ( string -> no_encoding , mbfl_no_encoding_wchar , collector_encode_htmlnumericentity , 0 , & pc ) ;
}
else if ( type == 2 ) {
encoder = mbfl_convert_filter_new ( string -> no_encoding , mbfl_no_encoding_wchar , collector_encode_hex_htmlnumericentity , 0 , & pc ) ;
}
else {
encoder = mbfl_convert_filter_new ( string -> no_encoding , mbfl_no_encoding_wchar , collector_decode_htmlnumericentity , ( int ( * ) ( void * ) ) mbfl_filt_decode_htmlnumericentity_flush , & pc ) ;
}
if ( pc . decoder == NULL || encoder == NULL ) {
mbfl_convert_filter_delete ( encoder ) ;
mbfl_convert_filter_delete ( pc . decoder ) ;
return NULL ;
}
pc . status = 0 ;
pc . cache = 0 ;
pc . digit = 0 ;
pc . convmap = convmap ;
pc . mapsize = mapsize ;
p = string -> val ;
n = string -> len ;
if ( p != NULL ) {
while ( n > 0 ) {
if ( ( * encoder -> filter_function ) ( * p ++ , encoder ) < 0 ) {
break ;
}
n -- ;
}
}
mbfl_convert_filter_flush ( encoder ) ;
mbfl_convert_filter_flush ( pc . decoder ) ;
result = mbfl_memory_device_result ( & device , result ) ;
mbfl_convert_filter_delete ( encoder ) ;
mbfl_convert_filter_delete ( pc . decoder ) ;
return result ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void * xcalloc ( size_t num , size_t size ) {
void * ptr = malloc ( num * size ) ;
if ( ptr ) {
memset ( ptr , '\0' , ( num * size ) ) ;
}
return ptr ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | bool Curl_compareheader ( const char * headerline , const char * header , const char * content ) {
size_t hlen = strlen ( header ) ;
size_t clen ;
size_t len ;
const char * start ;
const char * end ;
if ( ! Curl_raw_nequal ( headerline , header , hlen ) ) return FALSE ;
start = & headerline [ hlen ] ;
while ( * start && ISSPACE ( * start ) ) start ++ ;
end = strchr ( start , '\r' ) ;
if ( ! end ) {
end = strchr ( start , '\n' ) ;
if ( ! end ) end = strchr ( start , '\0' ) ;
}
len = end - start ;
clen = strlen ( content ) ;
for ( ;
len >= clen ;
len -- , start ++ ) {
if ( Curl_raw_nequal ( start , content , clen ) ) return TRUE ;
}
return FALSE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int nntp_check_children ( struct Context * ctx , const char * msgid ) {
struct NntpData * nntp_data = ctx -> data ;
struct ChildCtx cc ;
char buf [ STRING ] ;
int rc ;
bool quiet ;
void * hc = NULL ;
if ( ! nntp_data || ! nntp_data -> nserv ) return - 1 ;
if ( nntp_data -> first_message > nntp_data -> last_loaded ) return 0 ;
cc . ctx = ctx ;
cc . num = 0 ;
cc . max = 10 ;
cc . child = mutt_mem_malloc ( sizeof ( anum_t ) * cc . max ) ;
snprintf ( buf , sizeof ( buf ) , "XPAT References %u-%u *%s*\r\n" , nntp_data -> first_message , nntp_data -> last_loaded , msgid ) ;
rc = nntp_fetch_lines ( nntp_data , buf , sizeof ( buf ) , NULL , fetch_children , & cc ) ;
if ( rc ) {
FREE ( & cc . child ) ;
if ( rc > 0 ) {
if ( mutt_str_strncmp ( "500" , buf , 3 ) != 0 ) mutt_error ( "XPAT: %s" , buf ) ;
else {
mutt_error ( _ ( "Unable to find child articles because server does not " "support XPAT command." ) ) ;
}
}
return - 1 ;
}
quiet = ctx -> quiet ;
ctx -> quiet = true ;
# ifdef USE_HCACHE hc = nntp_hcache_open ( nntp_data ) ;
# endif for ( int i = 0 ;
i < cc . num ;
i ++ ) {
rc = nntp_fetch_headers ( ctx , hc , cc . child [ i ] , cc . child [ i ] , 1 ) ;
if ( rc < 0 ) break ;
}
# ifdef USE_HCACHE mutt_hcache_close ( hc ) ;
# endif ctx -> quiet = quiet ;
FREE ( & cc . child ) ;
return ( rc < 0 ) ? - 1 : 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void pdf_run_ET ( fz_context * ctx , pdf_processor * proc ) {
pdf_run_processor * pr = ( pdf_run_processor * ) proc ;
pdf_flush_text ( ctx , pr ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void insertionSort ( char * array , int32_t length , int32_t itemSize , UComparator * cmp , const void * context , UErrorCode * pErrorCode ) {
UAlignedMemory v [ STACK_ITEM_SIZE / sizeof ( UAlignedMemory ) + 1 ] ;
void * pv ;
if ( itemSize <= STACK_ITEM_SIZE ) {
pv = v ;
}
else {
pv = uprv_malloc ( itemSize ) ;
if ( pv == NULL ) {
* pErrorCode = U_MEMORY_ALLOCATION_ERROR ;
return ;
}
}
doInsertionSort ( array , length , itemSize , cmp , context , pv ) ;
if ( pv != v ) {
uprv_free ( pv ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void joint_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int_mv * frame_mv , int mi_row , int mi_col , int_mv single_newmv [ MAX_REF_FRAMES ] , int * rate_mv ) {
const int pw = 4 * num_4x4_blocks_wide_lookup [ bsize ] ;
const int ph = 4 * num_4x4_blocks_high_lookup [ bsize ] ;
MACROBLOCKD * xd = & x -> e_mbd ;
MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ;
const int refs [ 2 ] = {
mbmi -> ref_frame [ 0 ] , mbmi -> ref_frame [ 1 ] < 0 ? 0 : mbmi -> ref_frame [ 1 ] }
;
int_mv ref_mv [ 2 ] ;
int ite , ref ;
uint8_t * second_pred = vpx_memalign ( 16 , pw * ph * sizeof ( uint8_t ) ) ;
const InterpKernel * kernel = vp9_get_interp_kernel ( mbmi -> interp_filter ) ;
struct buf_2d backup_yv12 [ 2 ] [ MAX_MB_PLANE ] ;
struct buf_2d scaled_first_yv12 = xd -> plane [ 0 ] . pre [ 0 ] ;
int last_besterr [ 2 ] = {
INT_MAX , INT_MAX }
;
const YV12_BUFFER_CONFIG * const scaled_ref_frame [ 2 ] = {
vp9_get_scaled_ref_frame ( cpi , mbmi -> ref_frame [ 0 ] ) , vp9_get_scaled_ref_frame ( cpi , mbmi -> ref_frame [ 1 ] ) }
;
for ( ref = 0 ;
ref < 2 ;
++ ref ) {
ref_mv [ ref ] = mbmi -> ref_mvs [ refs [ ref ] ] [ 0 ] ;
if ( scaled_ref_frame [ ref ] ) {
int i ;
for ( i = 0 ;
i < MAX_MB_PLANE ;
i ++ ) backup_yv12 [ ref ] [ i ] = xd -> plane [ i ] . pre [ ref ] ;
vp9_setup_pre_planes ( xd , ref , scaled_ref_frame [ ref ] , mi_row , mi_col , NULL ) ;
}
frame_mv [ refs [ ref ] ] . as_int = single_newmv [ refs [ ref ] ] . as_int ;
}
for ( ite = 0 ;
ite < 4 ;
ite ++ ) {
struct buf_2d ref_yv12 [ 2 ] ;
int bestsme = INT_MAX ;
int sadpb = x -> sadperbit16 ;
MV tmp_mv ;
int search_range = 3 ;
int tmp_col_min = x -> mv_col_min ;
int tmp_col_max = x -> mv_col_max ;
int tmp_row_min = x -> mv_row_min ;
int tmp_row_max = x -> mv_row_max ;
int id = ite % 2 ;
ref_yv12 [ 0 ] = xd -> plane [ 0 ] . pre [ 0 ] ;
ref_yv12 [ 1 ] = xd -> plane [ 0 ] . pre [ 1 ] ;
vp9_build_inter_predictor ( ref_yv12 [ ! id ] . buf , ref_yv12 [ ! id ] . stride , second_pred , pw , & frame_mv [ refs [ ! id ] ] . as_mv , & xd -> block_refs [ ! id ] -> sf , pw , ph , 0 , kernel , MV_PRECISION_Q3 , mi_col * MI_SIZE , mi_row * MI_SIZE ) ;
if ( id ) xd -> plane [ 0 ] . pre [ 0 ] = ref_yv12 [ id ] ;
vp9_set_mv_search_range ( x , & ref_mv [ id ] . as_mv ) ;
tmp_mv = frame_mv [ refs [ id ] ] . as_mv ;
tmp_mv . col >>= 3 ;
tmp_mv . row >>= 3 ;
bestsme = vp9_refining_search_8p_c ( x , & tmp_mv , sadpb , search_range , & cpi -> fn_ptr [ bsize ] , & ref_mv [ id ] . as_mv , second_pred ) ;
if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_av_var ( x , & tmp_mv , & ref_mv [ id ] . as_mv , second_pred , & cpi -> fn_ptr [ bsize ] , 1 ) ;
x -> mv_col_min = tmp_col_min ;
x -> mv_col_max = tmp_col_max ;
x -> mv_row_min = tmp_row_min ;
x -> mv_row_max = tmp_row_max ;
if ( bestsme < INT_MAX ) {
int dis ;
unsigned int sse ;
bestsme = cpi -> find_fractional_mv_step ( x , & tmp_mv , & ref_mv [ id ] . as_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , 0 , cpi -> sf . mv . subpel_iters_per_step , NULL , x -> nmvjointcost , x -> mvcost , & dis , & sse , second_pred , pw , ph ) ;
}
if ( id ) xd -> plane [ 0 ] . pre [ 0 ] = scaled_first_yv12 ;
if ( bestsme < last_besterr [ id ] ) {
frame_mv [ refs [ id ] ] . as_mv = tmp_mv ;
last_besterr [ id ] = bestsme ;
}
else {
break ;
}
}
* rate_mv = 0 ;
for ( ref = 0 ;
ref < 2 ;
++ ref ) {
if ( scaled_ref_frame [ ref ] ) {
int i ;
for ( i = 0 ;
i < MAX_MB_PLANE ;
i ++ ) xd -> plane [ i ] . pre [ ref ] = backup_yv12 [ ref ] [ i ] ;
}
* rate_mv += vp9_mv_bit_cost ( & frame_mv [ refs [ ref ] ] . as_mv , & mbmi -> ref_mvs [ refs [ ref ] ] [ 0 ] . as_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ;
}
vpx_free ( second_pred ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void vp9_encode_frame ( VP9_COMP * cpi ) {
VP9_COMMON * const cm = & cpi -> common ;
RD_OPT * const rd_opt = & cpi -> rd ;
if ( ! frame_is_intra_only ( cm ) ) {
if ( ( cm -> ref_frame_sign_bias [ ALTREF_FRAME ] == cm -> ref_frame_sign_bias [ GOLDEN_FRAME ] ) || ( cm -> ref_frame_sign_bias [ ALTREF_FRAME ] == cm -> ref_frame_sign_bias [ LAST_FRAME ] ) ) {
cm -> allow_comp_inter_inter = 0 ;
}
else {
cm -> allow_comp_inter_inter = 1 ;
cm -> comp_fixed_ref = ALTREF_FRAME ;
cm -> comp_var_ref [ 0 ] = LAST_FRAME ;
cm -> comp_var_ref [ 1 ] = GOLDEN_FRAME ;
}
}
if ( cpi -> sf . frame_parameter_update ) {
int i ;
const MV_REFERENCE_FRAME frame_type = get_frame_type ( cpi ) ;
int64_t * const mode_thrs = rd_opt -> prediction_type_threshes [ frame_type ] ;
int64_t * const filter_thrs = rd_opt -> filter_threshes [ frame_type ] ;
int * const tx_thrs = rd_opt -> tx_select_threshes [ frame_type ] ;
const int is_alt_ref = frame_type == ALTREF_FRAME ;
if ( is_alt_ref || ! cm -> allow_comp_inter_inter ) cm -> reference_mode = SINGLE_REFERENCE ;
else if ( mode_thrs [ COMPOUND_REFERENCE ] > mode_thrs [ SINGLE_REFERENCE ] && mode_thrs [ COMPOUND_REFERENCE ] > mode_thrs [ REFERENCE_MODE_SELECT ] && check_dual_ref_flags ( cpi ) && cpi -> static_mb_pct == 100 ) cm -> reference_mode = COMPOUND_REFERENCE ;
else if ( mode_thrs [ SINGLE_REFERENCE ] > mode_thrs [ REFERENCE_MODE_SELECT ] ) cm -> reference_mode = SINGLE_REFERENCE ;
else cm -> reference_mode = REFERENCE_MODE_SELECT ;
if ( cm -> interp_filter == SWITCHABLE ) cm -> interp_filter = get_interp_filter ( filter_thrs , is_alt_ref ) ;
encode_frame_internal ( cpi ) ;
for ( i = 0 ;
i < REFERENCE_MODES ;
++ i ) mode_thrs [ i ] = ( mode_thrs [ i ] + rd_opt -> comp_pred_diff [ i ] / cm -> MBs ) / 2 ;
for ( i = 0 ;
i < SWITCHABLE_FILTER_CONTEXTS ;
++ i ) filter_thrs [ i ] = ( filter_thrs [ i ] + rd_opt -> filter_diff [ i ] / cm -> MBs ) / 2 ;
for ( i = 0 ;
i < TX_MODES ;
++ i ) {
int64_t pd = rd_opt -> tx_select_diff [ i ] ;
if ( i == TX_MODE_SELECT ) pd -= RDCOST ( cpi -> mb . rdmult , cpi -> mb . rddiv , 2048 * ( TX_SIZES - 1 ) , 0 ) ;
tx_thrs [ i ] = ( tx_thrs [ i ] + ( int ) ( pd / cm -> MBs ) ) / 2 ;
}
if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) {
int single_count_zero = 0 ;
int comp_count_zero = 0 ;
for ( i = 0 ;
i < COMP_INTER_CONTEXTS ;
i ++ ) {
single_count_zero += cm -> counts . comp_inter [ i ] [ 0 ] ;
comp_count_zero += cm -> counts . comp_inter [ i ] [ 1 ] ;
}
if ( comp_count_zero == 0 ) {
cm -> reference_mode = SINGLE_REFERENCE ;
vp9_zero ( cm -> counts . comp_inter ) ;
}
else if ( single_count_zero == 0 ) {
cm -> reference_mode = COMPOUND_REFERENCE ;
vp9_zero ( cm -> counts . comp_inter ) ;
}
}
if ( cm -> tx_mode == TX_MODE_SELECT ) {
int count4x4 = 0 ;
int count8x8_lp = 0 , count8x8_8x8p = 0 ;
int count16x16_16x16p = 0 , count16x16_lp = 0 ;
int count32x32 = 0 ;
for ( i = 0 ;
i < TX_SIZE_CONTEXTS ;
++ i ) {
count4x4 += cm -> counts . tx . p32x32 [ i ] [ TX_4X4 ] ;
count4x4 += cm -> counts . tx . p16x16 [ i ] [ TX_4X4 ] ;
count4x4 += cm -> counts . tx . p8x8 [ i ] [ TX_4X4 ] ;
count8x8_lp += cm -> counts . tx . p32x32 [ i ] [ TX_8X8 ] ;
count8x8_lp += cm -> counts . tx . p16x16 [ i ] [ TX_8X8 ] ;
count8x8_8x8p += cm -> counts . tx . p8x8 [ i ] [ TX_8X8 ] ;
count16x16_16x16p += cm -> counts . tx . p16x16 [ i ] [ TX_16X16 ] ;
count16x16_lp += cm -> counts . tx . p32x32 [ i ] [ TX_16X16 ] ;
count32x32 += cm -> counts . tx . p32x32 [ i ] [ TX_32X32 ] ;
}
if ( count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 && count32x32 == 0 ) {
cm -> tx_mode = ALLOW_8X8 ;
reset_skip_tx_size ( cm , TX_8X8 ) ;
}
else if ( count8x8_8x8p == 0 && count16x16_16x16p == 0 && count8x8_lp == 0 && count16x16_lp == 0 && count32x32 == 0 ) {
cm -> tx_mode = ONLY_4X4 ;
reset_skip_tx_size ( cm , TX_4X4 ) ;
}
else if ( count8x8_lp == 0 && count16x16_lp == 0 && count4x4 == 0 ) {
cm -> tx_mode = ALLOW_32X32 ;
}
else if ( count32x32 == 0 && count8x8_lp == 0 && count4x4 == 0 ) {
cm -> tx_mode = ALLOW_16X16 ;
reset_skip_tx_size ( cm , TX_16X16 ) ;
}
}
}
else {
cm -> reference_mode = SINGLE_REFERENCE ;
encode_frame_internal ( cpi ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_zcl_identify_identifyqueryrsp ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {
proto_tree_add_item ( tree , hf_zbee_zcl_identify_identify_timeout , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | unsigned int dtls_raw_hello_verify_request ( unsigned char * buf , unsigned char * cookie , unsigned char cookie_len ) {
unsigned int msg_len ;
unsigned char * p ;
p = buf ;
* ( p ++ ) = DTLS1_VERSION >> 8 ;
* ( p ++ ) = DTLS1_VERSION & 0xFF ;
* ( p ++ ) = ( unsigned char ) cookie_len ;
memcpy ( p , cookie , cookie_len ) ;
p += cookie_len ;
msg_len = p - buf ;
return msg_len ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline int get_current_cpu ( ARMMPTimerState * s ) {
if ( current_cpu -> cpu_index >= s -> num_cpu ) {
hw_error ( "arm_mptimer: num-cpu %d but this cpu is %d!\n" , s -> num_cpu , current_cpu -> cpu_index ) ;
}
return current_cpu -> cpu_index ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int xmlHashRemoveEntry2 ( xmlHashTablePtr table , const xmlChar * name , const xmlChar * name2 , xmlHashDeallocator f ) {
return ( xmlHashRemoveEntry3 ( table , name , name2 , NULL , f ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_Q2931Address ( 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_Q2931Address , Q2931Address_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_u3v_read_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 ;
const gchar * address_string = NULL ;
gboolean is_custom_register = FALSE ;
gboolean have_address = ( 0 != gencp_trans -> cmd_frame ) ;
proto_item * item = NULL ;
guint offset = startoffset ;
guint byte_count = ( length ) ;
addr = gencp_trans -> address ;
dissect_u3v_register_bases ( addr , tvb , startoffset , u3v_conv_info ) ;
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_ack_readmem_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 ( is_known_bootstrap_register ( addr , u3v_conv_info ) ) {
dissect_u3v_register ( addr , u3v_telegram_tree , tvb , offset , byte_count , u3v_conv_info ) ;
}
else {
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_custom_memory_data , tvb , startoffset , length , ENC_NA ) ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int libevt_record_values_free ( libevt_record_values_t * * record_values , libcerror_error_t * * error ) {
static char * function = "libevt_record_values_free" ;
int result = 1 ;
if ( record_values == NULL ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_ARGUMENTS , LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE , "%s: invalid record values." , function ) ;
return ( - 1 ) ;
}
if ( * record_values != NULL ) {
if ( ( * record_values ) -> source_name != NULL ) {
if ( libfvalue_value_free ( & ( ( * record_values ) -> source_name ) , error ) != 1 ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED , "%s: unable to free source name value." , function ) ;
result = - 1 ;
}
}
if ( ( * record_values ) -> computer_name != NULL ) {
if ( libfvalue_value_free ( & ( ( * record_values ) -> computer_name ) , error ) != 1 ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED , "%s: unable to free computer name value." , function ) ;
result = - 1 ;
}
}
if ( ( * record_values ) -> user_security_identifier != NULL ) {
if ( libfvalue_value_free ( & ( ( * record_values ) -> user_security_identifier ) , error ) != 1 ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED , "%s: unable to free user security identifier (SID)." , function ) ;
result = - 1 ;
}
}
if ( ( * record_values ) -> strings != NULL ) {
if ( libfvalue_value_free ( & ( ( * record_values ) -> strings ) , error ) != 1 ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED , "%s: unable to free strings." , function ) ;
result = - 1 ;
}
}
if ( ( * record_values ) -> data != NULL ) {
if ( libfvalue_value_free ( & ( ( * record_values ) -> data ) , error ) != 1 ) {
libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED , "%s: unable to free data." , function ) ;
result = - 1 ;
}
}
memory_free ( * record_values ) ;
* record_values = NULL ;
}
return ( result ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void evdns_set_transaction_id_fn ( ev_uint16_t ( * fn ) ( void ) ) {
if ( fn ) trans_id_function = fn ;
else trans_id_function = default_transaction_id_fn ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_TunnelledProtocolAlternateIdentifier ( 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_TunnelledProtocolAlternateIdentifier , TunnelledProtocolAlternateIdentifier_sequence ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void hb_set_set ( hb_set_t * set , const hb_set_t * other ) {
set -> set ( other ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int show_queries ( THD * thd , SHOW_VAR * var , char * buff ) {
var -> type = SHOW_LONGLONG ;
var -> value = ( char * ) & thd -> query_id ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void count_children_done ( NautilusDirectory * directory , NautilusFile * count_file , gboolean succeeded , int count ) {
g_assert ( NAUTILUS_IS_FILE ( count_file ) ) ;
count_file -> details -> directory_count_is_up_to_date = TRUE ;
if ( ! succeeded ) {
count_file -> details -> directory_count_failed = TRUE ;
count_file -> details -> got_directory_count = FALSE ;
count_file -> details -> directory_count = 0 ;
}
else {
count_file -> details -> directory_count_failed = FALSE ;
count_file -> details -> got_directory_count = TRUE ;
count_file -> details -> directory_count = count ;
}
directory -> details -> count_in_progress = NULL ;
nautilus_file_changed ( count_file ) ;
async_job_end ( directory , "directory count" ) ;
nautilus_directory_async_state_changed ( directory ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | gx_device * gx_device_reloc_ptr ( gx_device * dev , gc_state_t * gcst ) {
if ( dev == 0 || dev -> memory == 0 ) return dev ;
return RELOC_OBJ ( dev ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static uint32_t e1000e_mac_read_clr4 ( E1000ECore * core , int index ) {
uint32_t ret = core -> mac [ index ] ;
core -> mac [ index ] = 0 ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void truemotion1_decode_16bit ( TrueMotion1Context * s ) {
int y ;
int pixels_left ;
unsigned int predictor_pair ;
unsigned int horiz_pred ;
unsigned int * vert_pred ;
unsigned int * current_pixel_pair ;
unsigned char * current_line = s -> frame . data [ 0 ] ;
int keyframe = s -> flags & FLAG_KEYFRAME ;
const unsigned char * mb_change_bits = s -> mb_change_bits ;
unsigned char mb_change_byte ;
unsigned char mb_change_byte_mask ;
int mb_change_index ;
int index_stream_index = 0 ;
int index ;
memset ( s -> vert_pred , 0 , s -> avctx -> width * sizeof ( unsigned int ) ) ;
GET_NEXT_INDEX ( ) ;
for ( y = 0 ;
y < s -> avctx -> height ;
y ++ ) {
horiz_pred = 0 ;
current_pixel_pair = ( unsigned int * ) current_line ;
vert_pred = s -> vert_pred ;
mb_change_index = 0 ;
mb_change_byte = mb_change_bits [ mb_change_index ++ ] ;
mb_change_byte_mask = 0x01 ;
pixels_left = s -> avctx -> width ;
while ( pixels_left > 0 ) {
if ( keyframe || ( ( mb_change_byte & mb_change_byte_mask ) == 0 ) ) {
switch ( y & 3 ) {
case 0 : if ( s -> block_width == 2 ) {
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
}
else {
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
}
break ;
case 1 : case 3 : APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
break ;
case 2 : if ( s -> block_type == BLOCK_2x2 ) {
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
}
else if ( s -> block_type == BLOCK_4x2 ) {
APPLY_C_PREDICTOR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
}
else {
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
APPLY_Y_PREDICTOR ( ) ;
OUTPUT_PIXEL_PAIR ( ) ;
}
break ;
}
}
else {
* vert_pred ++ = * current_pixel_pair ++ ;
horiz_pred = * current_pixel_pair - * vert_pred ;
* vert_pred ++ = * current_pixel_pair ++ ;
}
if ( ! keyframe ) {
mb_change_byte_mask <<= 1 ;
if ( ! mb_change_byte_mask ) {
mb_change_byte = mb_change_bits [ mb_change_index ++ ] ;
mb_change_byte_mask = 0x01 ;
}
}
pixels_left -= 4 ;
}
if ( ( ( y + 1 ) & 3 ) == 0 ) mb_change_bits += s -> mb_change_bits_row_size ;
current_line += s -> frame . linesize [ 0 ] ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | size_t strlen_utf8 ( const char * s ) {
u_char c ;
size_t len = 0 ;
while ( ( c = * s ++ ) ) {
if ( ( c & 0xC0 ) != 0x80 ) ++ len ;
}
return len ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_INTEGER_1_1130 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 1130U , NULL , FALSE ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | fz_cmm_instance * fz_cmm_new_instance ( fz_context * ctx ) {
if ( ctx && ctx -> colorspace && ctx -> colorspace -> cmm ) return ctx -> colorspace -> cmm -> new_instance ( ctx ) ;
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gint dissect_as_if_format_type_body ( tvbuff_t * tvb , gint offset , packet_info * pinfo _U_ , proto_tree * tree , usb_conv_info_t * usb_conv_info ) {
audio_conv_info_t * audio_conv_info ;
gint offset_start ;
guint8 SamFreqType ;
guint8 format_type ;
audio_conv_info = ( audio_conv_info_t * ) usb_conv_info -> class_data ;
if ( ! audio_conv_info ) return 0 ;
offset_start = offset ;
proto_tree_add_item ( tree , hf_as_if_ft_formattype , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
format_type = tvb_get_guint8 ( tvb , offset ) ;
offset ++ ;
switch ( format_type ) {
case 1 : proto_tree_add_item ( tree , hf_as_if_ft_nrchannels , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 1 ;
proto_tree_add_item ( tree , hf_as_if_ft_subframesize , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 1 ;
proto_tree_add_item ( tree , hf_as_if_ft_bitresolution , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 1 ;
proto_tree_add_item ( tree , hf_as_if_ft_samfreqtype , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
SamFreqType = tvb_get_guint8 ( tvb , offset ) ;
offset ++ ;
if ( SamFreqType == 0 ) {
proto_tree_add_item ( tree , hf_as_if_ft_lowersamfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
proto_tree_add_item ( tree , hf_as_if_ft_uppersamfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
}
else {
while ( SamFreqType ) {
proto_tree_add_item ( tree , hf_as_if_ft_samfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
SamFreqType -- ;
}
}
break ;
case 2 : proto_tree_add_item ( tree , hf_as_if_ft_maxbitrate , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;
offset += 2 ;
proto_tree_add_item ( tree , hf_as_if_ft_samplesperframe , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;
offset += 2 ;
proto_tree_add_item ( tree , hf_as_if_ft_samfreqtype , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
SamFreqType = tvb_get_guint8 ( tvb , offset ) ;
offset ++ ;
if ( SamFreqType == 0 ) {
proto_tree_add_item ( tree , hf_as_if_ft_lowersamfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
proto_tree_add_item ( tree , hf_as_if_ft_uppersamfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
}
else {
while ( SamFreqType ) {
proto_tree_add_item ( tree , hf_as_if_ft_samfreq , tvb , offset , 3 , ENC_LITTLE_ENDIAN ) ;
offset += 3 ;
SamFreqType -- ;
}
}
break ;
default : break ;
}
return offset - offset_start ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , PaintInDynamicChildFrame ) {
ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
auto waiter = CreatePageLoadMetricsWaiter ( ) ;
waiter -> AddPageExpectation ( TimingField : : FIRST_LAYOUT ) ;
waiter -> AddPageExpectation ( TimingField : : LOAD_EVENT ) ;
waiter -> AddSubFrameExpectation ( TimingField : : FIRST_PAINT ) ;
waiter -> AddSubFrameExpectation ( TimingField : : FIRST_CONTENTFUL_PAINT ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( "/page_load_metrics/dynamic_iframe.html" ) ) ;
waiter -> Wait ( ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHistogramFirstLayout , 1 ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHistogramLoad , 1 ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHistogramFirstPaint , 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | sf_count_t psf_fwrite ( const void * ptr , sf_count_t bytes , sf_count_t items , SF_PRIVATE * psf ) {
sf_count_t total = 0 ;
ssize_t count ;
if ( bytes == 0 || items == 0 ) return 0 ;
if ( psf -> virtual_io ) return psf -> vio . write ( ptr , bytes * items , psf -> vio_user_data ) / bytes ;
items *= bytes ;
if ( items <= 0 ) return 0 ;
while ( items > 0 ) {
count = ( items > SENSIBLE_SIZE ) ? SENSIBLE_SIZE : items ;
count = write ( psf -> file . filedes , ( ( const char * ) ptr ) + total , count ) ;
if ( count == - 1 ) {
if ( errno == EINTR ) continue ;
psf_log_syserr ( psf , errno ) ;
break ;
}
;
if ( count == 0 ) break ;
total += count ;
items -= count ;
}
;
if ( psf -> is_pipe ) psf -> pipeoffset += total ;
return total / bytes ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void vc2_subband_dwt_53 ( VC2TransformContext * t , dwtcoef * data , ptrdiff_t stride , int width , int height ) {
int x , y ;
dwtcoef * synth = t -> buffer , * synthl = synth , * datal = data ;
const ptrdiff_t synth_width = width << 1 ;
const ptrdiff_t synth_height = height << 1 ;
for ( y = 0 ;
y < synth_height ;
y ++ ) {
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] = datal [ x ] << 1 ;
synthl += synth_width ;
datal += stride ;
}
synthl = synth ;
for ( y = 0 ;
y < synth_height ;
y ++ ) {
for ( x = 0 ;
x < width - 1 ;
x ++ ) synthl [ 2 * x + 1 ] -= ( synthl [ 2 * x ] + synthl [ 2 * x + 2 ] + 1 ) >> 1 ;
synthl [ synth_width - 1 ] -= ( 2 * synthl [ synth_width - 2 ] + 1 ) >> 1 ;
synthl [ 0 ] += ( 2 * synthl [ 1 ] + 2 ) >> 2 ;
for ( x = 1 ;
x < width - 1 ;
x ++ ) synthl [ 2 * x ] += ( synthl [ 2 * x - 1 ] + synthl [ 2 * x + 1 ] + 2 ) >> 2 ;
synthl [ synth_width - 2 ] += ( synthl [ synth_width - 3 ] + synthl [ synth_width - 1 ] + 2 ) >> 2 ;
synthl += synth_width ;
}
synthl = synth + synth_width ;
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] -= ( synthl [ x - synth_width ] + synthl [ x + synth_width ] + 1 ) >> 1 ;
synthl = synth + ( synth_width << 1 ) ;
for ( y = 1 ;
y < height - 1 ;
y ++ ) {
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x + synth_width ] -= ( synthl [ x ] + synthl [ x + synth_width * 2 ] + 1 ) >> 1 ;
synthl += ( synth_width << 1 ) ;
}
synthl = synth + ( synth_height - 1 ) * synth_width ;
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] -= ( 2 * synthl [ x - synth_width ] + 1 ) >> 1 ;
synthl = synth ;
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] += ( 2 * synthl [ synth_width + x ] + 2 ) >> 2 ;
synthl = synth + ( synth_width << 1 ) ;
for ( y = 1 ;
y < height - 1 ;
y ++ ) {
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] += ( synthl [ x + synth_width ] + synthl [ x - synth_width ] + 2 ) >> 2 ;
synthl += ( synth_width << 1 ) ;
}
synthl = synth + ( synth_height - 2 ) * synth_width ;
for ( x = 0 ;
x < synth_width ;
x ++ ) synthl [ x ] += ( synthl [ x - synth_width ] + synthl [ x + synth_width ] + 2 ) >> 2 ;
deinterleave ( data , stride , width , height , synth ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void fts_parse_mail_header ( struct fts_mail_build_context * ctx , const struct message_block * raw_block ) {
const struct message_header_line * hdr = raw_block -> hdr ;
if ( strcasecmp ( hdr -> name , "Content-Type" ) == 0 ) fts_build_parse_content_type ( ctx , hdr ) ;
else if ( strcasecmp ( hdr -> name , "Content-Disposition" ) == 0 ) fts_build_parse_content_disposition ( ctx , hdr ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void vmsvga_fill_rect ( struct vmsvga_state_s * s , uint32_t c , int x , int y , int w , int h ) {
DisplaySurface * surface = qemu_console_surface ( s -> vga . con ) ;
int bypl = surface_stride ( surface ) ;
int width = surface_bytes_per_pixel ( surface ) * w ;
int line = h ;
int column ;
uint8_t * fst ;
uint8_t * dst ;
uint8_t * src ;
uint8_t col [ 4 ] ;
col [ 0 ] = c ;
col [ 1 ] = c >> 8 ;
col [ 2 ] = c >> 16 ;
col [ 3 ] = c >> 24 ;
fst = s -> vga . vram_ptr + surface_bytes_per_pixel ( surface ) * x + bypl * y ;
if ( line -- ) {
dst = fst ;
src = col ;
for ( column = width ;
column > 0 ;
column -- ) {
* ( dst ++ ) = * ( src ++ ) ;
if ( src - col == surface_bytes_per_pixel ( surface ) ) {
src = col ;
}
}
dst = fst ;
for ( ;
line > 0 ;
line -- ) {
dst += bypl ;
memcpy ( dst , fst , width ) ;
}
}
vmsvga_update_rect_delayed ( s , x , y , w , h ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int udp6_ufo_send_check ( struct sk_buff * skb ) {
struct ipv6hdr * ipv6h ;
struct udphdr * uh ;
if ( ! pskb_may_pull ( skb , sizeof ( * uh ) ) ) return - EINVAL ;
ipv6h = ipv6_hdr ( skb ) ;
uh = udp_hdr ( skb ) ;
uh -> check = ~ csum_ipv6_magic ( & ipv6h -> saddr , & ipv6h -> daddr , skb -> len , IPPROTO_UDP , 0 ) ;
skb -> csum_start = skb_transport_header ( skb ) - skb -> head ;
skb -> csum_offset = offsetof ( struct udphdr , check ) ;
skb -> ip_summed = CHECKSUM_PARTIAL ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline int mpeg4_is_resync ( MpegEncContext * s ) {
int bits_count = get_bits_count ( & s -> gb ) ;
int v = show_bits ( & s -> gb , 16 ) ;
if ( s -> workaround_bugs & FF_BUG_NO_PADDING ) {
return 0 ;
}
while ( v <= 0xFF ) {
if ( s -> pict_type == AV_PICTURE_TYPE_B || ( v >> ( 8 - s -> pict_type ) != 1 ) || s -> partitioned_frame ) break ;
skip_bits ( & s -> gb , 8 + s -> pict_type ) ;
bits_count += 8 + s -> pict_type ;
v = show_bits ( & s -> gb , 16 ) ;
}
if ( bits_count + 8 >= s -> gb . size_in_bits ) {
v >>= 8 ;
v |= 0x7F >> ( 7 - ( bits_count & 7 ) ) ;
if ( v == 0x7F ) return 1 ;
}
else {
if ( v == ff_mpeg4_resync_prefix [ bits_count & 7 ] ) {
int len ;
GetBitContext gb = s -> gb ;
skip_bits ( & s -> gb , 1 ) ;
align_get_bits ( & s -> gb ) ;
for ( len = 0 ;
len < 32 ;
len ++ ) {
if ( get_bits1 ( & s -> gb ) ) break ;
}
s -> gb = gb ;
if ( len >= ff_mpeg4_get_video_packet_prefix_length ( s ) ) return 1 ;
}
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void free_icc ( fz_context * ctx , fz_colorspace * cs ) {
fz_iccprofile * profile = cs -> data ;
fz_drop_buffer ( ctx , profile -> buffer ) ;
fz_cmm_fin_profile ( ctx , profile ) ;
fz_free ( ctx , profile ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_free_store_result ( ) {
MYSQL_STMT * stmt ;
MYSQL_BIND my_bind [ 1 ] ;
char c2 [ 5 ] ;
ulong bl1 , l2 ;
int rc , c1 , bc1 ;
myheader ( "test_free_store_result" ) ;
rc = mysql_query ( mysql , "drop table if exists test_free_result" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "create table test_free_result(c1 int primary key auto_increment)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "insert into test_free_result values(), (), ()" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "select * from test_free_result" ) ;
check_stmt ( stmt ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_LONG ;
my_bind [ 0 ] . buffer = ( void * ) & bc1 ;
my_bind [ 0 ] . buffer_length = 0 ;
my_bind [ 0 ] . is_null = 0 ;
my_bind [ 0 ] . length = & bl1 ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_bind_result ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_store_result ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
c2 [ 0 ] = '\0' ;
l2 = 0 ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
my_bind [ 0 ] . buffer = ( void * ) c2 ;
my_bind [ 0 ] . buffer_length = 7 ;
my_bind [ 0 ] . is_null = 0 ;
my_bind [ 0 ] . length = & l2 ;
rc = mysql_stmt_fetch_column ( stmt , my_bind , 0 , 0 ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n col 1: %s(%ld)" , c2 , l2 ) ;
DIE_UNLESS ( strncmp ( c2 , "1" , 1 ) == 0 && l2 == 1 ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
c1 = 0 , l2 = 0 ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_LONG ;
my_bind [ 0 ] . buffer = ( void * ) & c1 ;
my_bind [ 0 ] . buffer_length = 0 ;
my_bind [ 0 ] . is_null = 0 ;
my_bind [ 0 ] . length = & l2 ;
rc = mysql_stmt_fetch_column ( stmt , my_bind , 0 , 0 ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n col 0: %d(%ld)" , c1 , l2 ) ;
DIE_UNLESS ( c1 == 2 && l2 == 4 ) ;
rc = mysql_stmt_free_result ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_query ( mysql , "drop table test_free_result" ) ;
myquery ( rc ) ;
mysql_stmt_close ( stmt ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void exchange_uv ( MpegEncContext * s ) {
int16_t ( * tmp ) [ 64 ] ;
tmp = s -> pblocks [ 4 ] ;
s -> pblocks [ 4 ] = s -> pblocks [ 5 ] ;
s -> pblocks [ 5 ] = tmp ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void setup_frame_size ( VP9_COMMON * cm , struct vp9_read_bit_buffer * rb ) {
int width , height ;
vp9_read_frame_size ( rb , & width , & height ) ;
resize_context_buffers ( cm , width , height ) ;
setup_display_size ( cm , rb ) ;
if ( vp9_realloc_frame_buffer ( get_frame_new_buffer ( cm ) , cm -> width , cm -> height , cm -> subsampling_x , cm -> subsampling_y , # if CONFIG_VP9_HIGHBITDEPTH cm -> use_highbitdepth , # endif VP9_DEC_BORDER_IN_PIXELS , & cm -> frame_bufs [ cm -> new_fb_idx ] . raw_frame_buffer , cm -> get_fb_cb , cm -> cb_priv ) ) {
vpx_internal_error ( & cm -> error , VPX_CODEC_MEM_ERROR , "Failed to allocate frame buffer" ) ;
}
cm -> frame_bufs [ cm -> new_fb_idx ] . buf . bit_depth = ( unsigned int ) cm -> bit_depth ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int selinux_sem_alloc_security ( struct sem_array * sma ) {
struct ipc_security_struct * isec ;
struct common_audit_data ad ;
u32 sid = current_sid ( ) ;
int rc ;
rc = ipc_alloc_security ( current , & sma -> sem_perm , SECCLASS_SEM ) ;
if ( rc ) return rc ;
isec = sma -> sem_perm . security ;
ad . type = LSM_AUDIT_DATA_IPC ;
ad . u . ipc_id = sma -> sem_perm . key ;
rc = avc_has_perm ( sid , isec -> sid , SECCLASS_SEM , SEM__CREATE , & ad ) ;
if ( rc ) {
ipc_free_security ( & sma -> sem_perm ) ;
return rc ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | double histogram_selectivity ( VariableStatData * vardata , FmgrInfo * opproc , Datum constval , bool varonleft , int min_hist_size , int n_skip , int * hist_size ) {
double result ;
Datum * values ;
int nvalues ;
Assert ( n_skip >= 0 ) ;
Assert ( min_hist_size > 2 * n_skip ) ;
if ( HeapTupleIsValid ( vardata -> statsTuple ) && statistic_proc_security_check ( vardata , opproc -> fn_oid ) && get_attstatsslot ( vardata -> statsTuple , vardata -> atttype , vardata -> atttypmod , STATISTIC_KIND_HISTOGRAM , InvalidOid , NULL , & values , & nvalues , NULL , NULL ) ) {
* hist_size = nvalues ;
if ( nvalues >= min_hist_size ) {
int nmatch = 0 ;
int i ;
for ( i = n_skip ;
i < nvalues - n_skip ;
i ++ ) {
if ( varonleft ? DatumGetBool ( FunctionCall2Coll ( opproc , DEFAULT_COLLATION_OID , values [ i ] , constval ) ) : DatumGetBool ( FunctionCall2Coll ( opproc , DEFAULT_COLLATION_OID , constval , values [ i ] ) ) ) nmatch ++ ;
}
result = ( ( double ) nmatch ) / ( ( double ) ( nvalues - 2 * n_skip ) ) ;
}
else result = - 1 ;
free_attstatsslot ( vardata -> atttype , values , nvalues , NULL , 0 ) ;
}
else {
* hist_size = 0 ;
result = - 1 ;
}
return result ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void IRQ_setbit ( IRQQueue * q , int n_IRQ ) {
set_bit ( n_IRQ , q -> queue ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static Datum ExecEvalArray ( ArrayExprState * astate , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) {
ArrayExpr * arrayExpr = ( ArrayExpr * ) astate -> xprstate . expr ;
ArrayType * result ;
ListCell * element ;
Oid element_type = arrayExpr -> element_typeid ;
int ndims = 0 ;
int dims [ MAXDIM ] ;
int lbs [ MAXDIM ] ;
* isNull = false ;
if ( isDone ) * isDone = ExprSingleResult ;
if ( ! arrayExpr -> multidims ) {
int nelems ;
Datum * dvalues ;
bool * dnulls ;
int i = 0 ;
ndims = 1 ;
nelems = list_length ( astate -> elements ) ;
if ( nelems == 0 ) return PointerGetDatum ( construct_empty_array ( element_type ) ) ;
dvalues = ( Datum * ) palloc ( nelems * sizeof ( Datum ) ) ;
dnulls = ( bool * ) palloc ( nelems * sizeof ( bool ) ) ;
foreach ( element , astate -> elements ) {
ExprState * e = ( ExprState * ) lfirst ( element ) ;
dvalues [ i ] = ExecEvalExpr ( e , econtext , & dnulls [ i ] , NULL ) ;
i ++ ;
}
dims [ 0 ] = nelems ;
lbs [ 0 ] = 1 ;
result = construct_md_array ( dvalues , dnulls , ndims , dims , lbs , element_type , astate -> elemlength , astate -> elembyval , astate -> elemalign ) ;
}
else {
int nbytes = 0 ;
int nitems = 0 ;
int outer_nelems = 0 ;
int elem_ndims = 0 ;
int * elem_dims = NULL ;
int * elem_lbs = NULL ;
bool firstone = true ;
bool havenulls = false ;
bool haveempty = false ;
char * * subdata ;
bits8 * * subbitmaps ;
int * subbytes ;
int * subnitems ;
int i ;
int32 dataoffset ;
char * dat ;
int iitem ;
i = list_length ( astate -> elements ) ;
subdata = ( char * * ) palloc ( i * sizeof ( char * ) ) ;
subbitmaps = ( bits8 * * ) palloc ( i * sizeof ( bits8 * ) ) ;
subbytes = ( int * ) palloc ( i * sizeof ( int ) ) ;
subnitems = ( int * ) palloc ( i * sizeof ( int ) ) ;
foreach ( element , astate -> elements ) {
ExprState * e = ( ExprState * ) lfirst ( element ) ;
bool eisnull ;
Datum arraydatum ;
ArrayType * array ;
int this_ndims ;
arraydatum = ExecEvalExpr ( e , econtext , & eisnull , NULL ) ;
if ( eisnull ) {
haveempty = true ;
continue ;
}
array = DatumGetArrayTypeP ( arraydatum ) ;
if ( element_type != ARR_ELEMTYPE ( array ) ) ereport ( ERROR , ( errcode ( ERRCODE_DATATYPE_MISMATCH ) , errmsg ( "cannot merge incompatible arrays" ) , errdetail ( "Array with element type %s cannot be " "included in ARRAY construct with element type %s." , format_type_be ( ARR_ELEMTYPE ( array ) ) , format_type_be ( element_type ) ) ) ) ;
this_ndims = ARR_NDIM ( array ) ;
if ( this_ndims <= 0 ) {
haveempty = true ;
continue ;
}
if ( firstone ) {
elem_ndims = this_ndims ;
ndims = elem_ndims + 1 ;
if ( ndims <= 0 || ndims > MAXDIM ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( "number of array dimensions (%d) exceeds " \ "the maximum allowed (%d)" , ndims , MAXDIM ) ) ) ;
elem_dims = ( int * ) palloc ( elem_ndims * sizeof ( int ) ) ;
memcpy ( elem_dims , ARR_DIMS ( array ) , elem_ndims * sizeof ( int ) ) ;
elem_lbs = ( int * ) palloc ( elem_ndims * sizeof ( int ) ) ;
memcpy ( elem_lbs , ARR_LBOUND ( array ) , elem_ndims * sizeof ( int ) ) ;
firstone = false ;
}
else {
if ( elem_ndims != this_ndims || memcmp ( elem_dims , ARR_DIMS ( array ) , elem_ndims * sizeof ( int ) ) != 0 || memcmp ( elem_lbs , ARR_LBOUND ( array ) , elem_ndims * sizeof ( int ) ) != 0 ) ereport ( ERROR , ( errcode ( ERRCODE_ARRAY_SUBSCRIPT_ERROR ) , errmsg ( "multidimensional arrays must have array " "expressions with matching dimensions" ) ) ) ;
}
subdata [ outer_nelems ] = ARR_DATA_PTR ( array ) ;
subbitmaps [ outer_nelems ] = ARR_NULLBITMAP ( array ) ;
subbytes [ outer_nelems ] = ARR_SIZE ( array ) - ARR_DATA_OFFSET ( array ) ;
nbytes += subbytes [ outer_nelems ] ;
subnitems [ outer_nelems ] = ArrayGetNItems ( this_ndims , ARR_DIMS ( array ) ) ;
nitems += subnitems [ outer_nelems ] ;
havenulls |= ARR_HASNULL ( array ) ;
outer_nelems ++ ;
}
if ( haveempty ) {
if ( ndims == 0 ) return PointerGetDatum ( construct_empty_array ( element_type ) ) ;
ereport ( ERROR , ( errcode ( ERRCODE_ARRAY_SUBSCRIPT_ERROR ) , errmsg ( "multidimensional arrays must have array " "expressions with matching dimensions" ) ) ) ;
}
dims [ 0 ] = outer_nelems ;
lbs [ 0 ] = 1 ;
for ( i = 1 ;
i < ndims ;
i ++ ) {
dims [ i ] = elem_dims [ i - 1 ] ;
lbs [ i ] = elem_lbs [ i - 1 ] ;
}
if ( havenulls ) {
dataoffset = ARR_OVERHEAD_WITHNULLS ( ndims , nitems ) ;
nbytes += dataoffset ;
}
else {
dataoffset = 0 ;
nbytes += ARR_OVERHEAD_NONULLS ( ndims ) ;
}
result = ( ArrayType * ) palloc ( nbytes ) ;
SET_VARSIZE ( result , nbytes ) ;
result -> ndim = ndims ;
result -> dataoffset = dataoffset ;
result -> elemtype = element_type ;
memcpy ( ARR_DIMS ( result ) , dims , ndims * sizeof ( int ) ) ;
memcpy ( ARR_LBOUND ( result ) , lbs , ndims * sizeof ( int ) ) ;
dat = ARR_DATA_PTR ( result ) ;
iitem = 0 ;
for ( i = 0 ;
i < outer_nelems ;
i ++ ) {
memcpy ( dat , subdata [ i ] , subbytes [ i ] ) ;
dat += subbytes [ i ] ;
if ( havenulls ) array_bitmap_copy ( ARR_NULLBITMAP ( result ) , iitem , subbitmaps [ i ] , 0 , subnitems [ i ] ) ;
iitem += subnitems [ i ] ;
}
}
return PointerGetDatum ( result ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool GetQueryResult ( PGconn * conn , const char * progname ) {
PGresult * result ;
SetCancelConn ( conn ) ;
while ( ( result = PQgetResult ( conn ) ) != NULL ) {
if ( PQresultStatus ( result ) != PGRES_COMMAND_OK ) {
char * sqlState = PQresultErrorField ( result , PG_DIAG_SQLSTATE ) ;
fprintf ( stderr , _ ( "%s: vacuuming of database \"%s\" failed: %s" ) , progname , PQdb ( conn ) , PQerrorMessage ( conn ) ) ;
if ( sqlState && strcmp ( sqlState , ERRCODE_UNDEFINED_TABLE ) != 0 ) {
PQclear ( result ) ;
return false ;
}
}
PQclear ( result ) ;
}
ResetCancelConn ( ) ;
return true ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void fast_cmyk_to_gray ( fz_context * ctx , fz_pixmap * dst , fz_pixmap * src , fz_colorspace * prf , const fz_default_colorspaces * default_cs , const fz_color_params * color_params , int copy_spots ) {
unsigned char * s = src -> samples ;
unsigned char * d = dst -> samples ;
size_t w = src -> w ;
int h = src -> h ;
int sn = src -> n ;
int ss = src -> s ;
int sa = src -> alpha ;
int dn = dst -> n ;
int ds = dst -> s ;
int da = dst -> alpha ;
ptrdiff_t d_line_inc = dst -> stride - w * dn ;
ptrdiff_t s_line_inc = src -> stride - w * sn ;
if ( ( copy_spots && ss != ds ) || ( ! da && sa ) ) {
assert ( "This should never happen" == NULL ) ;
fz_throw ( ctx , FZ_ERROR_GENERIC , "Cannot convert between incompatible pixmaps" ) ;
}
if ( ( int ) w < 0 || h < 0 ) return ;
if ( d_line_inc == 0 && s_line_inc == 0 ) {
w *= h ;
h = 1 ;
}
if ( ss == 0 && ds == 0 ) {
if ( da ) {
if ( sa ) {
while ( h -- ) {
size_t ww = w ;
while ( ww -- ) {
unsigned char c = fz_mul255 ( s [ 0 ] , 77 ) ;
unsigned char m = fz_mul255 ( s [ 1 ] , 150 ) ;
unsigned char y = fz_mul255 ( s [ 2 ] , 28 ) ;
d [ 0 ] = 255 - ( unsigned char ) fz_mini ( c + m + y + s [ 3 ] , 255 ) ;
d [ 1 ] = s [ 4 ] ;
s += 5 ;
d += 2 ;
}
d += d_line_inc ;
s += s_line_inc ;
}
}
else {
while ( h -- ) {
size_t ww = w ;
while ( ww -- ) {
unsigned char c = fz_mul255 ( s [ 0 ] , 77 ) ;
unsigned char m = fz_mul255 ( s [ 1 ] , 150 ) ;
unsigned char y = fz_mul255 ( s [ 2 ] , 28 ) ;
d [ 0 ] = 255 - ( unsigned char ) fz_mini ( c + m + y + s [ 3 ] , 255 ) ;
d [ 1 ] = 255 ;
s += 3 ;
d += 2 ;
}
d += d_line_inc ;
s += s_line_inc ;
}
}
}
else {
while ( h -- ) {
size_t ww = w ;
while ( ww -- ) {
unsigned char c = fz_mul255 ( s [ 0 ] , 77 ) ;
unsigned char m = fz_mul255 ( s [ 1 ] , 150 ) ;
unsigned char y = fz_mul255 ( s [ 2 ] , 28 ) ;
d [ 0 ] = 255 - ( unsigned char ) fz_mini ( c + m + y + s [ 3 ] , 255 ) ;
s += 4 ;
d ++ ;
}
d += d_line_inc ;
s += s_line_inc ;
}
}
}
else if ( copy_spots ) {
while ( h -- ) {
int i ;
size_t ww = w ;
while ( ww -- ) {
unsigned char c = fz_mul255 ( s [ 0 ] , 77 ) ;
unsigned char m = fz_mul255 ( s [ 1 ] , 150 ) ;
unsigned char y = fz_mul255 ( s [ 2 ] , 28 ) ;
d [ 0 ] = 255 - ( unsigned char ) fz_mini ( c + m + y + s [ 3 ] , 255 ) ;
s += 4 ;
d ++ ;
for ( i = ss ;
i > 0 ;
i -- ) * d ++ = * s ++ ;
if ( da ) * d ++ = sa ? * s ++ : 255 ;
}
d += d_line_inc ;
s += s_line_inc ;
}
}
else {
while ( h -- ) {
size_t ww = w ;
while ( ww -- ) {
unsigned char c = fz_mul255 ( 255 - s [ 0 ] , 77 ) ;
unsigned char m = fz_mul255 ( 255 - s [ 1 ] , 150 ) ;
unsigned char y = fz_mul255 ( 255 - s [ 2 ] , 28 ) ;
d [ 0 ] = ( unsigned char ) fz_maxi ( s [ 3 ] - c - m - y , 0 ) ;
s += sn ;
d += dn ;
if ( da ) d [ - 1 ] = sa ? s [ - 1 ] : 255 ;
}
d += d_line_inc ;
s += s_line_inc ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int mbfl_strpos ( mbfl_string * haystack , mbfl_string * needle , int offset , int reverse ) {
int result ;
mbfl_string _haystack_u8 , _needle_u8 ;
const mbfl_string * haystack_u8 , * needle_u8 = NULL ;
const unsigned char * u8_tbl ;
if ( haystack == NULL || haystack -> val == NULL || needle == NULL || needle -> val == NULL ) {
return - 8 ;
}
{
const mbfl_encoding * u8_enc ;
u8_enc = mbfl_no2encoding ( mbfl_no_encoding_utf8 ) ;
if ( u8_enc == NULL || u8_enc -> mblen_table == NULL ) {
return - 8 ;
}
u8_tbl = u8_enc -> mblen_table ;
}
if ( haystack -> no_encoding != mbfl_no_encoding_utf8 ) {
mbfl_string_init ( & _haystack_u8 ) ;
haystack_u8 = mbfl_convert_encoding ( haystack , & _haystack_u8 , mbfl_no_encoding_utf8 ) ;
if ( haystack_u8 == NULL ) {
result = - 4 ;
goto out ;
}
}
else {
haystack_u8 = haystack ;
}
if ( needle -> no_encoding != mbfl_no_encoding_utf8 ) {
mbfl_string_init ( & _needle_u8 ) ;
needle_u8 = mbfl_convert_encoding ( needle , & _needle_u8 , mbfl_no_encoding_utf8 ) ;
if ( needle_u8 == NULL ) {
result = - 4 ;
goto out ;
}
}
else {
needle_u8 = needle ;
}
if ( needle_u8 -> len < 1 ) {
result = - 8 ;
goto out ;
}
result = - 1 ;
if ( haystack_u8 -> len < needle_u8 -> len ) {
goto out ;
}
if ( ! reverse ) {
unsigned int jtbl [ 1 << ( sizeof ( unsigned char ) * 8 ) ] ;
unsigned int needle_u8_len = needle_u8 -> len ;
unsigned int i ;
const unsigned char * p , * q , * e ;
const unsigned char * haystack_u8_val = haystack_u8 -> val , * needle_u8_val = needle_u8 -> val ;
for ( i = 0 ;
i < sizeof ( jtbl ) / sizeof ( * jtbl ) ;
++ i ) {
jtbl [ i ] = needle_u8_len + 1 ;
}
for ( i = 0 ;
i < needle_u8_len - 1 ;
++ i ) {
jtbl [ needle_u8_val [ i ] ] = needle_u8_len - i ;
}
e = haystack_u8_val + haystack_u8 -> len ;
p = haystack_u8_val ;
while ( -- offset >= 0 ) {
if ( p >= e ) {
result = - 16 ;
goto out ;
}
p += u8_tbl [ * p ] ;
}
p += needle_u8_len ;
if ( p > e ) {
goto out ;
}
while ( p <= e ) {
const unsigned char * pv = p ;
q = needle_u8_val + needle_u8_len ;
for ( ;
;
) {
if ( q == needle_u8_val ) {
result = 0 ;
while ( p > haystack_u8_val ) {
unsigned char c = * -- p ;
if ( c < 0x80 ) {
++ result ;
}
else if ( ( c & 0xc0 ) != 0x80 ) {
++ result ;
}
}
goto out ;
}
if ( * -- q != * -- p ) {
break ;
}
}
p += jtbl [ * p ] ;
if ( p <= pv ) {
p = pv + 1 ;
}
}
}
else {
unsigned int jtbl [ 1 << ( sizeof ( unsigned char ) * 8 ) ] ;
unsigned int needle_u8_len = needle_u8 -> len , needle_len = 0 ;
unsigned int i ;
const unsigned char * p , * e , * q , * qe ;
const unsigned char * haystack_u8_val = haystack_u8 -> val , * needle_u8_val = needle_u8 -> val ;
for ( i = 0 ;
i < sizeof ( jtbl ) / sizeof ( * jtbl ) ;
++ i ) {
jtbl [ i ] = needle_u8_len ;
}
for ( i = needle_u8_len - 1 ;
i > 0 ;
-- i ) {
unsigned char c = needle_u8_val [ i ] ;
jtbl [ c ] = i ;
if ( c < 0x80 ) {
++ needle_len ;
}
else if ( ( c & 0xc0 ) != 0x80 ) {
++ needle_len ;
}
}
{
unsigned char c = needle_u8_val [ 0 ] ;
if ( c < 0x80 ) {
++ needle_len ;
}
else if ( ( c & 0xc0 ) != 0x80 ) {
++ needle_len ;
}
}
e = haystack_u8_val ;
p = e + haystack_u8 -> len ;
qe = needle_u8_val + needle_u8_len ;
if ( offset < 0 ) {
if ( - offset > needle_len ) {
offset += needle_len ;
while ( offset < 0 ) {
unsigned char c ;
if ( p <= e ) {
result = - 16 ;
goto out ;
}
c = * ( -- p ) ;
if ( c < 0x80 ) {
++ offset ;
}
else if ( ( c & 0xc0 ) != 0x80 ) {
++ offset ;
}
}
}
}
else {
const unsigned char * ee = haystack_u8_val + haystack_u8 -> len ;
while ( -- offset >= 0 ) {
if ( e >= ee ) {
result = - 16 ;
goto out ;
}
e += u8_tbl [ * e ] ;
}
}
if ( p < e + needle_u8_len ) {
goto out ;
}
p -= needle_u8_len ;
while ( p >= e ) {
const unsigned char * pv = p ;
q = needle_u8_val ;
for ( ;
;
) {
if ( q == qe ) {
result = 0 ;
p -= needle_u8_len ;
while ( p > haystack_u8_val ) {
unsigned char c = * -- p ;
if ( c < 0x80 ) {
++ result ;
}
else if ( ( c & 0xc0 ) != 0x80 ) {
++ result ;
}
}
goto out ;
}
if ( * q != * p ) {
break ;
}
++ p , ++ q ;
}
p -= jtbl [ * p ] ;
if ( p >= pv ) {
p = pv - 1 ;
}
}
}
out : if ( haystack_u8 == & _haystack_u8 ) {
mbfl_string_clear ( & _haystack_u8 ) ;
}
if ( needle_u8 == & _needle_u8 ) {
mbfl_string_clear ( & _needle_u8 ) ;
}
return result ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int sockstat_seq_show ( struct seq_file * seq , void * v ) {
struct net * net = seq -> private ;
int orphans , sockets ;
local_bh_disable ( ) ;
orphans = percpu_counter_sum_positive ( & tcp_orphan_count ) ;
sockets = proto_sockets_allocated_sum_positive ( & tcp_prot ) ;
local_bh_enable ( ) ;
socket_seq_show ( seq ) ;
seq_printf ( seq , "TCP: inuse %d orphan %d tw %d alloc %d mem %ld\n" , sock_prot_inuse_get ( net , & tcp_prot ) , orphans , tcp_death_row . tw_count , sockets , proto_memory_allocated ( & tcp_prot ) ) ;
seq_printf ( seq , "UDP: inuse %d mem %ld\n" , sock_prot_inuse_get ( net , & udp_prot ) , proto_memory_allocated ( & udp_prot ) ) ;
seq_printf ( seq , "UDPLITE: inuse %d\n" , sock_prot_inuse_get ( net , & udplite_prot ) ) ;
seq_printf ( seq , "RAW: inuse %d\n" , sock_prot_inuse_get ( net , & raw_prot ) ) ;
seq_printf ( seq , "FRAG: inuse %d memory %d\n" , ip_frag_nqueues ( net ) , ip_frag_mem ( net ) ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const fz_colorspace * fz_source_colorspace_cm ( fz_context * ctx , const fz_colorspace * cs ) {
while ( cs ) {
if ( fz_colorspace_is_icc ( ctx , cs ) ) return cs ;
if ( fz_colorspace_is_cal ( ctx , cs ) ) return cs ;
cs = fz_colorspace_base ( ctx , cs ) ;
}
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int findcmd ( const char * str , struct xcmd * clist1 , struct xcmd * clist2 , struct xcmd * * cmd ) {
struct xcmd * cl ;
int clen ;
int nmatch ;
struct xcmd * nearmatch = NULL ;
struct xcmd * clist ;
clen = strlen ( str ) ;
nmatch = 0 ;
if ( clist1 != 0 ) clist = clist1 ;
else if ( clist2 != 0 ) clist = clist2 ;
else return 0 ;
again : for ( cl = clist ;
cl -> keyword != 0 ;
cl ++ ) {
if ( * str != * ( cl -> keyword ) ) continue ;
if ( strncmp ( str , cl -> keyword , ( unsigned ) clen ) == 0 ) {
if ( * ( ( cl -> keyword ) + clen ) == '\0' ) {
* cmd = cl ;
return 1 ;
}
nmatch ++ ;
nearmatch = cl ;
}
}
if ( clist == clist1 && clist2 != 0 ) {
clist = clist2 ;
goto again ;
}
if ( nmatch == 1 ) {
* cmd = nearmatch ;
return 1 ;
}
return nmatch ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | gpg_err_code_t _gcry_ecc_ecdsa_verify ( gcry_mpi_t input , ECC_public_key * pkey , gcry_mpi_t r , gcry_mpi_t s ) {
gpg_err_code_t err = 0 ;
gcry_mpi_t hash , h , h1 , h2 , x ;
mpi_point_struct Q , Q1 , Q2 ;
mpi_ec_t ctx ;
unsigned int nbits ;
if ( ! ( mpi_cmp_ui ( r , 0 ) > 0 && mpi_cmp ( r , pkey -> E . n ) < 0 ) ) return GPG_ERR_BAD_SIGNATURE ;
if ( ! ( mpi_cmp_ui ( s , 0 ) > 0 && mpi_cmp ( s , pkey -> E . n ) < 0 ) ) return GPG_ERR_BAD_SIGNATURE ;
nbits = mpi_get_nbits ( pkey -> E . n ) ;
err = _gcry_dsa_normalize_hash ( input , & hash , nbits ) ;
if ( err ) return err ;
h = mpi_alloc ( 0 ) ;
h1 = mpi_alloc ( 0 ) ;
h2 = mpi_alloc ( 0 ) ;
x = mpi_alloc ( 0 ) ;
point_init ( & Q ) ;
point_init ( & Q1 ) ;
point_init ( & Q2 ) ;
ctx = _gcry_mpi_ec_p_internal_new ( pkey -> E . model , pkey -> E . dialect , 0 , pkey -> E . p , pkey -> E . a , pkey -> E . b ) ;
mpi_invm ( h , s , pkey -> E . n ) ;
mpi_mulm ( h1 , hash , h , pkey -> E . n ) ;
_gcry_mpi_ec_mul_point ( & Q1 , h1 , & pkey -> E . G , ctx ) ;
mpi_mulm ( h2 , r , h , pkey -> E . n ) ;
_gcry_mpi_ec_mul_point ( & Q2 , h2 , & pkey -> Q , ctx ) ;
_gcry_mpi_ec_add_points ( & Q , & Q1 , & Q2 , ctx ) ;
if ( ! mpi_cmp_ui ( Q . z , 0 ) ) {
if ( DBG_CIPHER ) log_debug ( "ecc verify: Rejected\n" ) ;
err = GPG_ERR_BAD_SIGNATURE ;
goto leave ;
}
if ( _gcry_mpi_ec_get_affine ( x , NULL , & Q , ctx ) ) {
if ( DBG_CIPHER ) log_debug ( "ecc verify: Failed to get affine coordinates\n" ) ;
err = GPG_ERR_BAD_SIGNATURE ;
goto leave ;
}
mpi_mod ( x , x , pkey -> E . n ) ;
if ( mpi_cmp ( x , r ) ) {
if ( DBG_CIPHER ) {
log_mpidump ( " x" , x ) ;
log_mpidump ( " r" , r ) ;
log_mpidump ( " s" , s ) ;
}
err = GPG_ERR_BAD_SIGNATURE ;
goto leave ;
}
leave : _gcry_mpi_ec_free ( ctx ) ;
point_free ( & Q2 ) ;
point_free ( & Q1 ) ;
point_free ( & Q ) ;
mpi_free ( x ) ;
mpi_free ( h2 ) ;
mpi_free ( h1 ) ;
mpi_free ( h ) ;
if ( hash != input ) mpi_free ( hash ) ;
return err ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int xmlListPushBack ( xmlListPtr l , void * data ) {
xmlLinkPtr lkPlace , lkNew ;
if ( l == NULL ) return ( 0 ) ;
lkPlace = l -> sentinel -> prev ;
if ( NULL == ( lkNew = ( xmlLinkPtr ) xmlMalloc ( sizeof ( xmlLink ) ) ) ) {
xmlGenericError ( xmlGenericErrorContext , "Cannot initialize memory for new link" ) ;
return ( 0 ) ;
}
lkNew -> data = data ;
lkNew -> next = lkPlace -> next ;
( lkPlace -> next ) -> prev = lkNew ;
lkPlace -> next = lkNew ;
lkNew -> prev = lkPlace ;
return 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | gcry_error_t gcry_mpi_aprint ( enum gcry_mpi_format format , unsigned char * * buffer , size_t * nwritten , struct gcry_mpi * a ) {
size_t n ;
gcry_error_t rc ;
* buffer = NULL ;
rc = gcry_mpi_print ( format , NULL , 0 , & n , a ) ;
if ( rc ) return rc ;
* buffer = mpi_is_secure ( a ) ? gcry_malloc_secure ( n ? n : 1 ) : gcry_malloc ( n ? n : 1 ) ;
if ( ! * buffer ) return gpg_error_from_syserror ( ) ;
rc = gcry_mpi_print ( format , * buffer , n , & n , a ) ;
if ( rc ) {
gcry_free ( * buffer ) ;
* buffer = NULL ;
}
else if ( nwritten ) * nwritten = n ;
return rc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | Node * get_typdefault ( Oid typid ) {
HeapTuple typeTuple ;
Form_pg_type type ;
Datum datum ;
bool isNull ;
Node * expr ;
typeTuple = SearchSysCache1 ( TYPEOID , ObjectIdGetDatum ( typid ) ) ;
if ( ! HeapTupleIsValid ( typeTuple ) ) elog ( ERROR , "cache lookup failed for type %u" , typid ) ;
type = ( Form_pg_type ) GETSTRUCT ( typeTuple ) ;
datum = SysCacheGetAttr ( TYPEOID , typeTuple , Anum_pg_type_typdefaultbin , & isNull ) ;
if ( ! isNull ) {
expr = stringToNode ( TextDatumGetCString ( datum ) ) ;
}
else {
datum = SysCacheGetAttr ( TYPEOID , typeTuple , Anum_pg_type_typdefault , & isNull ) ;
if ( ! isNull ) {
char * strDefaultVal ;
strDefaultVal = TextDatumGetCString ( datum ) ;
datum = OidInputFunctionCall ( type -> typinput , strDefaultVal , getTypeIOParam ( typeTuple ) , - 1 ) ;
expr = ( Node * ) makeConst ( typid , - 1 , type -> typcollation , type -> typlen , datum , false , type -> typbyval ) ;
pfree ( strDefaultVal ) ;
}
else {
expr = NULL ;
}
}
ReleaseSysCache ( typeTuple ) ;
return expr ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void mgcpCallerID ( gchar * signalStr , gchar * * callerId ) {
gchar * * arrayStr ;
if ( signalStr == NULL ) return ;
arrayStr = g_strsplit ( signalStr , "\"" , 10 ) ;
if ( arrayStr [ 0 ] == NULL ) return ;
if ( strstr ( arrayStr [ 0 ] , "ci(" ) && ( arrayStr [ 1 ] != NULL ) ) {
g_free ( * callerId ) ;
* callerId = g_strdup ( arrayStr [ 1 ] ) ;
}
g_strfreev ( arrayStr ) ;
return ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ohci_roothub_reset ( OHCIState * ohci ) {
OHCIPort * port ;
int i ;
ohci_bus_stop ( ohci ) ;
ohci -> rhdesc_a = OHCI_RHA_NPS | ohci -> num_ports ;
ohci -> rhdesc_b = 0x0 ;
ohci -> rhstatus = 0 ;
for ( i = 0 ;
i < ohci -> num_ports ;
i ++ ) {
port = & ohci -> rhport [ i ] ;
port -> ctrl = 0 ;
if ( port -> port . dev && port -> port . dev -> attached ) {
usb_port_reset ( & port -> port ) ;
}
}
if ( ohci -> async_td ) {
usb_cancel_packet ( & ohci -> usb_packet ) ;
ohci -> async_td = 0 ;
}
ohci_stop_endpoints ( ohci ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static ossl_inline unsigned long lh_ ## type ## _num_items ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_num_items ( ( OPENSSL_LHASH * ) lh ) ;
}
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 ) ;
# ifdef _MSC_VER # pragma warning ( push ) # pragma warning ( disable : 4090 ) # endif DEFINE_LHASH_OF ( OPENSSL_CSTRING ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | int ff_msmpeg4_coded_block_pred ( MpegEncContext * s , int n , uint8_t * * coded_block_ptr ) {
int xy , wrap , pred , a , b , c ;
xy = s -> block_index [ n ] ;
wrap = s -> b8_stride ;
a = s -> coded_block [ xy - 1 ] ;
b = s -> coded_block [ xy - 1 - wrap ] ;
c = s -> coded_block [ xy - wrap ] ;
if ( b == c ) {
pred = a ;
}
else {
pred = c ;
}
* coded_block_ptr = & s -> coded_block [ xy ] ;
return pred ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | bool send_chal_reply ( connection_t * c ) {
char hash [ EVP_MAX_MD_SIZE * 2 + 1 ] ;
EVP_MD_CTX * ctx ;
ctx = EVP_MD_CTX_create ( ) ;
if ( ! ctx ) {
abort ( ) ;
}
if ( ! EVP_DigestInit ( ctx , c -> indigest ) || ! EVP_DigestUpdate ( ctx , c -> mychallenge , RSA_size ( myself -> connection -> rsa_key ) ) || ! EVP_DigestFinal ( ctx , ( unsigned char * ) hash , NULL ) ) {
EVP_MD_CTX_destroy ( ctx ) ;
logger ( LOG_ERR , "Error during calculation of response for %s (%s): %s" , c -> name , c -> hostname , ERR_error_string ( ERR_get_error ( ) , NULL ) ) ;
return false ;
}
EVP_MD_CTX_destroy ( ctx ) ;
bin2hex ( hash , hash , EVP_MD_size ( c -> indigest ) ) ;
hash [ EVP_MD_size ( c -> indigest ) * 2 ] = '\0' ;
return send_request ( c , "%d %s" , CHAL_REPLY , hash ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_USER_LEVEL_CTR ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep ) {
proto_tree * subtree ;
proto_item * item ;
guint32 level ;
if ( di -> conformant_run ) return offset ;
subtree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_USER_LEVEL_CTR , & item , "User level container" ) ;
offset = dissect_ndr_uint32 ( tvb , offset , pinfo , subtree , di , drep , hf_level , & level ) ;
switch ( level ) {
case 1 : offset = dissect_ndr_pointer ( tvb , offset , pinfo , subtree , di , drep , dissect_USER_LEVEL_1 , NDR_POINTER_UNIQUE , "User level 1" , - 1 ) ;
break ;
default : expert_add_info_format ( pinfo , item , & ei_level , "Info level %d not decoded" , level ) ;
break ;
}
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int selinux_netlink_send ( struct sock * sk , struct sk_buff * skb ) {
return selinux_nlmsg_perm ( sk , skb ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void U_CALLCONV ucnv_UTF8FromUTF8 ( UConverterFromUnicodeArgs * pFromUArgs , UConverterToUnicodeArgs * pToUArgs , UErrorCode * pErrorCode ) {
UConverter * utf8 ;
const uint8_t * source , * sourceLimit ;
uint8_t * target ;
int32_t targetCapacity ;
int32_t count ;
int8_t oldToULength , toULength , toULimit ;
UChar32 c ;
uint8_t b , t1 , t2 ;
utf8 = pToUArgs -> converter ;
source = ( uint8_t * ) pToUArgs -> source ;
sourceLimit = ( uint8_t * ) pToUArgs -> sourceLimit ;
target = ( uint8_t * ) pFromUArgs -> target ;
targetCapacity = ( int32_t ) ( pFromUArgs -> targetLimit - pFromUArgs -> target ) ;
c = ( UChar32 ) utf8 -> toUnicodeStatus ;
if ( c != 0 ) {
toULength = oldToULength = utf8 -> toULength ;
toULimit = ( int8_t ) utf8 -> mode ;
}
else {
toULength = oldToULength = toULimit = 0 ;
}
count = ( int32_t ) ( sourceLimit - source ) + oldToULength ;
if ( count < toULimit ) {
}
else if ( targetCapacity < toULimit ) {
* pErrorCode = U_USING_DEFAULT_WARNING ;
return ;
}
else {
int32_t i ;
if ( count > targetCapacity ) {
count = targetCapacity ;
}
i = 0 ;
while ( i < 3 && i < ( count - toULimit ) ) {
b = source [ count - oldToULength - i - 1 ] ;
if ( U8_IS_TRAIL ( b ) ) {
++ i ;
}
else {
if ( i < U8_COUNT_TRAIL_BYTES ( b ) ) {
count -= i + 1 ;
}
break ;
}
}
}
if ( c != 0 ) {
utf8 -> toUnicodeStatus = 0 ;
utf8 -> toULength = 0 ;
goto moreBytes ;
}
while ( count > 0 ) {
b = * source ++ ;
if ( ( int8_t ) b >= 0 ) {
* target ++ = b ;
-- count ;
continue ;
}
else {
if ( b > 0xe0 ) {
if ( ( t1 = source [ 0 ] ) >= 0x80 && ( ( b < 0xed && ( t1 <= 0xbf ) ) || ( b == 0xed && ( t1 <= 0x9f ) ) ) && ( t2 = source [ 1 ] ) >= 0x80 && t2 <= 0xbf ) {
source += 2 ;
* target ++ = b ;
* target ++ = t1 ;
* target ++ = t2 ;
count -= 3 ;
continue ;
}
}
else if ( b < 0xe0 ) {
if ( b >= 0xc2 && ( t1 = * source ) >= 0x80 && t1 <= 0xbf ) {
++ source ;
* target ++ = b ;
* target ++ = t1 ;
count -= 2 ;
continue ;
}
}
else if ( b == 0xe0 ) {
if ( ( t1 = source [ 0 ] ) >= 0xa0 && t1 <= 0xbf && ( t2 = source [ 1 ] ) >= 0x80 && t2 <= 0xbf ) {
source += 2 ;
* target ++ = b ;
* target ++ = t1 ;
* target ++ = t2 ;
count -= 3 ;
continue ;
}
}
oldToULength = 0 ;
toULength = 1 ;
toULimit = U8_COUNT_TRAIL_BYTES ( b ) + 1 ;
c = b ;
moreBytes : while ( toULength < toULimit ) {
if ( source < sourceLimit ) {
b = * source ;
if ( U8_IS_TRAIL ( b ) ) {
++ source ;
++ toULength ;
c = ( c << 6 ) + b ;
}
else {
break ;
}
}
else {
source -= ( toULength - oldToULength ) ;
while ( oldToULength < toULength ) {
utf8 -> toUBytes [ oldToULength ++ ] = * source ++ ;
}
utf8 -> toUnicodeStatus = c ;
utf8 -> toULength = toULength ;
utf8 -> mode = toULimit ;
pToUArgs -> source = ( char * ) source ;
pFromUArgs -> target = ( char * ) target ;
return ;
}
}
if ( toULength == toULimit && ( toULength == 3 || toULength == 2 ) && ( c -= utf8_offsets [ toULength ] ) >= utf8_minLegal [ toULength ] && ( c <= 0xd7ff || 0xe000 <= c ) ) {
}
else if ( toULength == toULimit && toULength == 4 && ( 0x10000 <= ( c -= utf8_offsets [ 4 ] ) && c <= 0x10ffff ) ) {
}
else {
source -= ( toULength - oldToULength ) ;
while ( oldToULength < toULength ) {
utf8 -> toUBytes [ oldToULength ++ ] = * source ++ ;
}
utf8 -> toULength = toULength ;
pToUArgs -> source = ( char * ) source ;
pFromUArgs -> target = ( char * ) target ;
* pErrorCode = U_ILLEGAL_CHAR_FOUND ;
return ;
}
{
int8_t i ;
for ( i = 0 ;
i < oldToULength ;
++ i ) {
* target ++ = utf8 -> toUBytes [ i ] ;
}
source -= ( toULength - oldToULength ) ;
for ( ;
i < toULength ;
++ i ) {
* target ++ = * source ++ ;
}
count -= toULength ;
}
}
}
if ( U_SUCCESS ( * pErrorCode ) && source < sourceLimit ) {
if ( target == ( const uint8_t * ) pFromUArgs -> targetLimit ) {
* pErrorCode = U_BUFFER_OVERFLOW_ERROR ;
}
else {
b = * source ;
toULimit = U8_COUNT_TRAIL_BYTES ( b ) + 1 ;
if ( toULimit > ( sourceLimit - source ) ) {
toULength = 0 ;
c = b ;
for ( ;
;
) {
utf8 -> toUBytes [ toULength ++ ] = b ;
if ( ++ source == sourceLimit ) {
utf8 -> toUnicodeStatus = c ;
utf8 -> toULength = toULength ;
utf8 -> mode = toULimit ;
break ;
}
else if ( ! U8_IS_TRAIL ( b = * source ) ) {
utf8 -> toULength = toULength ;
* pErrorCode = U_ILLEGAL_CHAR_FOUND ;
break ;
}
c = ( c << 6 ) + b ;
}
}
else {
* pErrorCode = U_USING_DEFAULT_WARNING ;
}
}
}
pToUArgs -> source = ( char * ) source ;
pFromUArgs -> target = ( char * ) target ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static char * CreateHtmlSubtitle ( int * pi_align , char * psz_subtitle ) {
char * psz_tag = malloc ( 1 ) ;
if ( psz_tag == NULL ) return NULL ;
char * psz_html = malloc ( 1 ) ;
if ( psz_html == NULL ) {
free ( psz_tag ) ;
return NULL ;
}
psz_tag [ 0 ] = '\0' ;
psz_html [ 0 ] = '\0' ;
bool b_has_align = false ;
HtmlPut ( & psz_html , "<text>" ) ;
while ( * psz_subtitle ) {
if ( * psz_subtitle == '\n' ) {
HtmlPut ( & psz_html , "<br/>" ) ;
psz_subtitle ++ ;
}
else if ( * psz_subtitle == '<' ) {
if ( ! strncasecmp ( psz_subtitle , "<br/>" , 5 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<br/>" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "<b>" , 3 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<b>" ) ;
HtmlPut ( & psz_tag , "b" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "<i>" , 3 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<i>" ) ;
HtmlPut ( & psz_tag , "i" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "<u>" , 3 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<u>" ) ;
HtmlPut ( & psz_tag , "u" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "<s>" , 3 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<s>" ) ;
HtmlPut ( & psz_tag , "s" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "<font " , 6 ) ) {
const char * psz_attribs [ ] = {
"face=" , "family=" , "size=" , "color=" , "outline-color=" , "shadow-color=" , "outline-level=" , "shadow-level=" , "back-color=" , "alpha=" , NULL }
;
HtmlCopy ( & psz_html , & psz_subtitle , "<font " ) ;
HtmlPut ( & psz_tag , "f" ) ;
while ( * psz_subtitle != '>' && * psz_subtitle ) {
int k ;
while ( * psz_subtitle == ' ' ) psz_subtitle ++ ;
for ( k = 0 ;
psz_attribs [ k ] ;
k ++ ) {
int i_len = strlen ( psz_attribs [ k ] ) ;
if ( ! strncasecmp ( psz_subtitle , psz_attribs [ k ] , i_len ) ) {
HtmlPut ( & psz_html , psz_attribs [ k ] ) ;
psz_subtitle += i_len ;
while ( * psz_subtitle == ' ' ) psz_subtitle ++ ;
if ( * psz_subtitle == '"' ) {
psz_subtitle ++ ;
i_len = strcspn ( psz_subtitle , "\"" ) ;
}
else if ( * psz_subtitle == '\'' ) {
psz_subtitle ++ ;
i_len = strcspn ( psz_subtitle , "'" ) ;
}
else {
i_len = strcspn ( psz_subtitle , " \t>" ) ;
}
HtmlPut ( & psz_html , "\"" ) ;
HtmlNPut ( & psz_html , psz_subtitle , i_len ) ;
HtmlPut ( & psz_html , "\"" ) ;
psz_subtitle += i_len ;
if ( * psz_subtitle == '\"' || * psz_subtitle == '\'' ) psz_subtitle ++ ;
break ;
}
}
if ( psz_attribs [ k ] == NULL ) {
int i_len = strcspn ( psz_subtitle , "\"" ) ;
if ( psz_subtitle [ i_len ] == '\"' ) {
i_len += 1 + strcspn ( & psz_subtitle [ i_len + 1 ] , "\"" ) ;
if ( psz_subtitle [ i_len ] == '\"' ) i_len ++ ;
}
if ( i_len == 0 && * psz_subtitle != '\0' ) psz_subtitle ++ ;
psz_subtitle += i_len ;
}
HtmlNPut ( & psz_html , psz_subtitle , strspn ( psz_subtitle , " " ) ) ;
}
HtmlPut ( & psz_html , ">" ) ;
if ( * psz_subtitle == '\0' ) break ;
psz_subtitle ++ ;
}
else if ( ! strncmp ( psz_subtitle , "</" , 2 ) ) {
bool b_match = false ;
bool b_ignore = false ;
int i_len = ( psz_tag ? strlen ( psz_tag ) : 0 ) - 1 ;
char * psz_lastTag = NULL ;
if ( i_len >= 0 ) {
psz_lastTag = psz_tag + i_len ;
i_len = 0 ;
switch ( * psz_lastTag ) {
case 'b' : b_match = ! strncasecmp ( psz_subtitle , "</b>" , 4 ) ;
i_len = 4 ;
break ;
case 'i' : b_match = ! strncasecmp ( psz_subtitle , "</i>" , 4 ) ;
i_len = 4 ;
break ;
case 'u' : b_match = ! strncasecmp ( psz_subtitle , "</u>" , 4 ) ;
i_len = 4 ;
break ;
case 's' : b_match = ! strncasecmp ( psz_subtitle , "</s>" , 4 ) ;
i_len = 4 ;
break ;
case 'f' : b_match = ! strncasecmp ( psz_subtitle , "</font>" , 7 ) ;
i_len = 7 ;
break ;
case 'I' : i_len = strcspn ( psz_subtitle , ">" ) ;
b_match = psz_subtitle [ i_len ] == '>' ;
b_ignore = true ;
if ( b_match ) i_len ++ ;
break ;
}
}
if ( ! b_match ) {
free ( psz_html ) ;
psz_html = NULL ;
break ;
}
* psz_lastTag = '\0' ;
if ( ! b_ignore ) HtmlNPut ( & psz_html , psz_subtitle , i_len ) ;
psz_subtitle += i_len ;
}
else if ( ( psz_subtitle [ 1 ] < 'a' || psz_subtitle [ 1 ] > 'z' ) && ( psz_subtitle [ 1 ] < 'A' || psz_subtitle [ 1 ] > 'Z' ) ) {
HtmlPut ( & psz_html , "<
" ) ;
psz_subtitle ++ ;
}
else {
char * psz_stop = psz_subtitle + 1 + strcspn ( & psz_subtitle [ 1 ] , "<>" ) ;
char * psz_closing = strstr ( psz_subtitle , "/>" ) ;
if ( psz_closing && psz_closing < psz_stop ) {
psz_subtitle = & psz_closing [ 2 ] ;
}
else if ( * psz_stop == '>' ) {
char psz_match [ 256 ] ;
snprintf ( psz_match , sizeof ( psz_match ) , "</%s" , & psz_subtitle [ 1 ] ) ;
psz_match [ strcspn ( psz_match , " \t>" ) ] = '\0' ;
if ( strstr ( psz_subtitle , psz_match ) ) {
psz_subtitle = & psz_stop [ 1 ] ;
HtmlPut ( & psz_tag , "I" ) ;
}
else {
int i_len = psz_stop + 1 - psz_subtitle ;
for ( ;
i_len > 0 ;
i_len -- , psz_subtitle ++ ) {
if ( * psz_subtitle == '<' ) HtmlPut ( & psz_html , "<
" ) ;
else if ( * psz_subtitle == '>' ) HtmlPut ( & psz_html , ">
" ) ;
else HtmlNPut ( & psz_html , psz_subtitle , 1 ) ;
}
}
}
else {
HtmlPut ( & psz_html , "<
" ) ;
psz_subtitle ++ ;
}
}
}
else if ( * psz_subtitle == '&' ) {
if ( ! strncasecmp ( psz_subtitle , "<
" , 4 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "<
" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , ">
" , 4 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , ">
" ) ;
}
else if ( ! strncasecmp ( psz_subtitle , "&
" , 5 ) ) {
HtmlCopy ( & psz_html , & psz_subtitle , "&
" ) ;
}
else {
HtmlPut ( & psz_html , "&
" ) ;
psz_subtitle ++ ;
}
}
else if ( * psz_subtitle == '>' ) {
HtmlPut ( & psz_html , ">
" ) ;
psz_subtitle ++ ;
}
else if ( psz_subtitle [ 0 ] == '{
' && psz_subtitle [ 1 ] == '\\' && strchr ( psz_subtitle , '}
' ) ) {
if ( ! b_has_align && ! strncmp ( psz_subtitle , "{
\\an" , 4 ) && psz_subtitle [ 4 ] >= '1' && psz_subtitle [ 4 ] <= '9' && psz_subtitle [ 5 ] == '}
' ) {
static const int pi_vertical [ 3 ] = {
SUBPICTURE_ALIGN_BOTTOM , 0 , SUBPICTURE_ALIGN_TOP }
;
static const int pi_horizontal [ 3 ] = {
SUBPICTURE_ALIGN_LEFT , 0 , SUBPICTURE_ALIGN_RIGHT }
;
const int i_id = psz_subtitle [ 4 ] - '1' ;
b_has_align = true ;
* pi_align = pi_vertical [ i_id / 3 ] | pi_horizontal [ i_id % 3 ] ;
}
psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
}
else if ( psz_subtitle [ 0 ] == '{
' && ( psz_subtitle [ 1 ] == 'Y' || psz_subtitle [ 1 ] == 'y' ) && psz_subtitle [ 2 ] == ':' && strchr ( psz_subtitle , '}
' ) ) {
if ( psz_subtitle [ 3 ] == 'i' ) {
HtmlPut ( & psz_html , "<i>" ) ;
HtmlPut ( & psz_tag , "i" ) ;
}
if ( psz_subtitle [ 3 ] == 'b' ) {
HtmlPut ( & psz_html , "<b>" ) ;
HtmlPut ( & psz_tag , "b" ) ;
}
if ( psz_subtitle [ 3 ] == 'u' ) {
HtmlPut ( & psz_html , "<u>" ) ;
HtmlPut ( & psz_tag , "u" ) ;
}
psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
}
else if ( psz_subtitle [ 0 ] == '{
' && psz_subtitle [ 1 ] != '\0' && psz_subtitle [ 2 ] == ':' && strchr ( psz_subtitle , '}
' ) ) {
psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
}
else if ( psz_subtitle [ 0 ] == '\\' && psz_subtitle [ 1 ] ) {
if ( psz_subtitle [ 1 ] == 'N' || psz_subtitle [ 1 ] == 'n' ) {
HtmlPut ( & psz_html , "<br/>" ) ;
psz_subtitle += 2 ;
}
else if ( psz_subtitle [ 1 ] == 'h' ) {
HtmlPut ( & psz_html , NO_BREAKING_SPACE ) ;
psz_subtitle += 2 ;
}
else {
HtmlPut ( & psz_html , "\\" ) ;
psz_subtitle ++ ;
}
}
else {
HtmlNPut ( & psz_html , psz_subtitle , 1 ) ;
# if 0 if ( * psz_html ) {
# error This test does not make sense . if ( ( * psz_html == ' ' || * psz_html == '\t' ) && ( * ( psz_html - 1 ) == ' ' || * ( psz_html - 1 ) == '\t' ) ) {
HtmlPut ( & psz_html , NO_BREAKING_SPACE ) ;
psz_html -- ;
}
}
# endif psz_subtitle ++ ;
}
}
while ( psz_tag && * psz_tag ) {
char * psz_last = & psz_tag [ strlen ( psz_tag ) - 1 ] ;
switch ( * psz_last ) {
case 'b' : HtmlPut ( & psz_html , "</b>" ) ;
break ;
case 'i' : HtmlPut ( & psz_html , "</i>" ) ;
break ;
case 'u' : HtmlPut ( & psz_html , "</u>" ) ;
break ;
case 's' : HtmlPut ( & psz_html , "</s>" ) ;
break ;
case 'f' : HtmlPut ( & psz_html , "</font>" ) ;
break ;
case 'I' : break ;
}
* psz_last = '\0' ;
}
HtmlPut ( & psz_html , "</text>" ) ;
free ( psz_tag ) ;
return psz_html ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void t1_done_loader ( T1_Loader loader ) {
T1_Parser parser = & loader -> parser ;
T1_Release_Table ( & loader -> encoding_table ) ;
T1_Release_Table ( & loader -> charstrings ) ;
T1_Release_Table ( & loader -> glyph_names ) ;
T1_Release_Table ( & loader -> swap_table ) ;
T1_Release_Table ( & loader -> subrs ) ;
T1_Finalize_Parser ( parser ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static char * yystpcpy ( char * yydest , const char * yysrc ) # else static char * yystpcpy ( yydest , yysrc ) char * yydest ;
const char * yysrc ;
# endif {
char * yyd = yydest ;
const char * yys = yysrc ;
while ( ( * yyd ++ = * yys ++ ) != '\0' ) continue ;
return yyd - 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void get_agg_clause_costs ( PlannerInfo * root , Node * clause , AggSplit aggsplit , AggClauseCosts * costs ) {
get_agg_clause_costs_context context ;
context . root = root ;
context . aggsplit = aggsplit ;
context . costs = costs ;
( void ) get_agg_clause_costs_walker ( clause , & context ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint16 de_bcc_compr_otdi ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) {
proto_tree_add_item ( tree , hf_gsm_a_dtap_bcc_compr_otdi , tvb , offset , len , ENC_NA ) ;
return len ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( HttpsEngagementPageLoadMetricsBrowserTest , BackgroundThenForeground_Https ) {
StartHttpsServer ( false ) ;
base : : TimeDelta upper_bound = NavigateInBackgroundAndCloseInForegroundWithTiming ( https_test_server_ -> GetURL ( "/simple.html" ) ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHttpEngagementHistogram , 0 ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementHistogram , 1 ) ;
int32_t bucket_min = histogram_tester_ . GetAllSamples ( internal : : kHttpsEngagementHistogram ) [ 0 ] . min ;
EXPECT_GE ( upper_bound . InMilliseconds ( ) , bucket_min ) ;
EXPECT_LT ( 0 , bucket_min ) ;
FakeUserMetricsUpload ( ) ;
histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementSessionPercentage , 1 ) ;
int32_t ratio_bucket = histogram_tester_ . GetAllSamples ( internal : : kHttpsEngagementSessionPercentage ) [ 0 ] . min ;
EXPECT_EQ ( 100 , ratio_bucket ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static rtmpt_conv_t * rtmpt_init_rconv ( conversation_t * conv ) {
rtmpt_conv_t * rconv = wmem_new ( wmem_file_scope ( ) , rtmpt_conv_t ) ;
conversation_add_proto_data ( conv , proto_rtmpt , rconv ) ;
rconv -> seqs [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> seqs [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> frags [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> frags [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> ids [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> ids [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> packets [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> packets [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> chunksize [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> chunksize [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> txids [ 0 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
rconv -> txids [ 1 ] = wmem_tree_new ( wmem_file_scope ( ) ) ;
return rconv ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int kvm_get_apic ( X86CPU * cpu ) {
DeviceState * apic = cpu -> apic_state ;
struct kvm_lapic_state kapic ;
int ret ;
if ( apic && kvm_irqchip_in_kernel ( ) ) {
ret = kvm_vcpu_ioctl ( CPU ( cpu ) , KVM_GET_LAPIC , & kapic ) ;
if ( ret < 0 ) {
return ret ;
}
kvm_get_apic_state ( apic , & kapic ) ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const char * cmd_rule_update_action_by_id ( cmd_parms * cmd , void * _dcfg , const char * p1 , const char * p2 ) {
int offset = 0 , rule_id = atoi ( p1 ) ;
char * opt = strchr ( p1 , ':' ) ;
char * savedptr = NULL ;
char * param = apr_pstrdup ( cmd -> pool , p1 ) ;
if ( ( rule_id == LONG_MAX ) || ( rule_id == LONG_MIN ) || ( rule_id <= 0 ) ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Invalid value for ID for update action: %s" , p1 ) ;
}
if ( opt != NULL ) {
opt ++ ;
offset = atoi ( opt ) ;
opt = apr_strtok ( param , ":" , & savedptr ) ;
return update_rule_action ( cmd , ( directory_config * ) _dcfg , ( const char * ) opt , p2 , offset ) ;
}
return update_rule_action ( cmd , ( directory_config * ) _dcfg , p1 , p2 , offset ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int fn_print ( netdissect_options * ndo , register const u_char * s , register const u_char * ep ) {
register int ret ;
register u_char c ;
ret = 1 ;
while ( ep == NULL || s < ep ) {
c = * s ++ ;
if ( c == '\0' ) {
ret = 0 ;
break ;
}
if ( ! ND_ISASCII ( c ) ) {
c = ND_TOASCII ( c ) ;
ND_PRINT ( ( ndo , "M-" ) ) ;
}
if ( ! ND_ISPRINT ( c ) ) {
c ^= 0x40 ;
ND_PRINT ( ( ndo , "^" ) ) ;
}
ND_PRINT ( ( ndo , "%c" , c ) ) ;
}
return ( ret ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void check_initial_width ( VP9_COMP * cpi , int subsampling_x , int subsampling_y ) {
VP9_COMMON * const cm = & cpi -> common ;
if ( ! cpi -> initial_width ) {
cm -> subsampling_x = subsampling_x ;
cm -> subsampling_y = subsampling_y ;
alloc_raw_frame_buffers ( cpi ) ;
alloc_ref_frame_buffers ( cpi ) ;
alloc_util_frame_buffers ( cpi ) ;
init_motion_estimation ( cpi ) ;
cpi -> initial_width = cm -> width ;
cpi -> initial_height = cm -> height ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | extern int as_mysql_modify_resv ( mysql_conn_t * mysql_conn , slurmdb_reservation_rec_t * resv ) {
MYSQL_RES * result = NULL ;
MYSQL_ROW row ;
int rc = SLURM_SUCCESS ;
char * cols = NULL , * vals = NULL , * extra = NULL , * query = NULL ;
time_t start = 0 , now = time ( NULL ) ;
int i ;
int set = 0 ;
char * resv_req_inx [ ] = {
"assoclist" , "time_start" , "time_end" , "resv_name" , "nodelist" , "node_inx" , "flags" , "tres" }
;
enum {
RESV_ASSOCS , RESV_START , RESV_END , RESV_NAME , RESV_NODES , RESV_NODE_INX , RESV_FLAGS , RESV_TRES , RESV_COUNT }
;
if ( ! resv ) {
error ( "No reservation was given to edit" ) ;
return SLURM_ERROR ;
}
if ( ! resv -> id ) {
error ( "We need an id to edit a reservation." ) ;
return SLURM_ERROR ;
}
if ( ! resv -> time_start ) {
error ( "We need a start time to edit a reservation." ) ;
return SLURM_ERROR ;
}
if ( ! resv -> cluster || ! resv -> cluster [ 0 ] ) {
error ( "We need a cluster name to edit a reservation." ) ;
return SLURM_ERROR ;
}
if ( ! resv -> time_start_prev ) {
error ( "We need a time to check for last " "start of reservation." ) ;
return SLURM_ERROR ;
}
xstrfmtcat ( cols , "%s" , resv_req_inx [ 0 ] ) ;
for ( i = 1 ;
i < RESV_COUNT ;
i ++ ) {
xstrfmtcat ( cols , ", %s" , resv_req_inx [ i ] ) ;
}
query = xstrdup_printf ( "select %s from \"%s_%s\" where id_resv=%u " "and (time_start=%ld || time_start=%ld) " "and deleted=0 order by time_start desc " "limit 1 FOR UPDATE;
" , cols , resv -> cluster , resv_table , resv -> id , resv -> time_start , resv -> time_start_prev ) ;
try_again : debug4 ( "%d(%s:%d) query\n%s" , mysql_conn -> conn , THIS_FILE , __LINE__ , query ) ;
if ( ! ( result = mysql_db_query_ret ( mysql_conn , query , 0 ) ) ) {
rc = SLURM_ERROR ;
goto end_it ;
}
if ( ! ( row = mysql_fetch_row ( result ) ) ) {
rc = SLURM_ERROR ;
mysql_free_result ( result ) ;
error ( "There is no reservation by id %u, " "time_start %ld, and cluster '%s'" , resv -> id , resv -> time_start_prev , resv -> cluster ) ;
if ( ! set && resv -> time_end ) {
xfree ( query ) ;
query = xstrdup_printf ( "select %s from \"%s_%s\" where id_resv=%u " "and time_start <= %ld and deleted=0 " "order by time_start desc " "limit 1;
" , cols , resv -> cluster , resv_table , resv -> id , resv -> time_end ) ;
set = 1 ;
goto try_again ;
}
goto end_it ;
}
start = slurm_atoul ( row [ RESV_START ] ) ;
xfree ( query ) ;
xfree ( cols ) ;
set = 0 ;
if ( ! resv -> name && row [ RESV_NAME ] && row [ RESV_NAME ] [ 0 ] ) resv -> name = xstrdup ( row [ RESV_NAME ] ) ;
if ( resv -> assocs ) set = 1 ;
else if ( row [ RESV_ASSOCS ] && row [ RESV_ASSOCS ] [ 0 ] ) resv -> assocs = xstrdup ( row [ RESV_ASSOCS ] ) ;
if ( resv -> flags != NO_VAL ) set = 1 ;
else resv -> flags = slurm_atoul ( row [ RESV_FLAGS ] ) ;
if ( resv -> nodes ) set = 1 ;
else if ( row [ RESV_NODES ] && row [ RESV_NODES ] [ 0 ] ) {
resv -> nodes = xstrdup ( row [ RESV_NODES ] ) ;
resv -> node_inx = xstrdup ( row [ RESV_NODE_INX ] ) ;
}
if ( ! resv -> time_end ) resv -> time_end = slurm_atoul ( row [ RESV_END ] ) ;
if ( resv -> tres_str ) set = 1 ;
else if ( row [ RESV_TRES ] && row [ RESV_TRES ] [ 0 ] ) resv -> tres_str = xstrdup ( row [ RESV_TRES ] ) ;
mysql_free_result ( result ) ;
_setup_resv_limits ( resv , & cols , & vals , & extra ) ;
if ( ( start > now ) || ! set ) {
query = xstrdup_printf ( "update \"%s_%s\" set deleted=0%s " "where deleted=0 and id_resv=%u " "and time_start=%ld;
" , resv -> cluster , resv_table , extra , resv -> id , start ) ;
}
else {
query = xstrdup_printf ( "update \"%s_%s\" set time_end=%ld " "where deleted=0 && id_resv=%u " "and time_start=%ld;
" , resv -> cluster , resv_table , resv -> time_start - 1 , resv -> id , start ) ;
xstrfmtcat ( query , "insert into \"%s_%s\" (id_resv%s) " "values (%u%s) " "on duplicate key update deleted=0%s;
" , resv -> cluster , resv_table , cols , resv -> id , vals , extra ) ;
}
if ( debug_flags & DEBUG_FLAG_DB_RESV ) DB_DEBUG ( mysql_conn -> conn , "query\n%s" , query ) ;
rc = mysql_db_query ( mysql_conn , query ) ;
end_it : xfree ( query ) ;
xfree ( cols ) ;
xfree ( vals ) ;
xfree ( extra ) ;
return rc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
AnsiContext * s = avctx -> priv_data ;
uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
const uint8_t * buf_end = buf + buf_size ;
int ret , i , count ;
ret = avctx -> reget_buffer ( avctx , & s -> frame ) ;
if ( ret < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
if ( ! avctx -> frame_number ) {
memset ( s -> frame . data [ 0 ] , 0 , avctx -> height * FFABS ( s -> frame . linesize [ 0 ] ) ) ;
memset ( s -> frame . data [ 1 ] , 0 , AVPALETTE_SIZE ) ;
}
s -> frame . pict_type = AV_PICTURE_TYPE_I ;
s -> frame . palette_has_changed = 1 ;
memcpy ( s -> frame . data [ 1 ] , ff_cga_palette , 16 * 4 ) ;
while ( buf < buf_end ) {
switch ( s -> state ) {
case STATE_NORMAL : switch ( buf [ 0 ] ) {
case 0x00 : case 0x07 : case 0x1A : break ;
case 0x08 : s -> x = FFMAX ( s -> x - 1 , 0 ) ;
break ;
case 0x09 : i = s -> x / FONT_WIDTH ;
count = ( ( i + 8 ) & ~ 7 ) - i ;
for ( i = 0 ;
i < count ;
i ++ ) draw_char ( avctx , ' ' ) ;
break ;
case 0x0A : hscroll ( avctx ) ;
case 0x0D : s -> x = 0 ;
break ;
case 0x0C : erase_screen ( avctx ) ;
break ;
case 0x1B : s -> state = STATE_ESCAPE ;
break ;
default : draw_char ( avctx , buf [ 0 ] ) ;
}
break ;
case STATE_ESCAPE : if ( buf [ 0 ] == '[' ) {
s -> state = STATE_CODE ;
s -> nb_args = 0 ;
s -> args [ 0 ] = 0 ;
}
else {
s -> state = STATE_NORMAL ;
draw_char ( avctx , 0x1B ) ;
continue ;
}
break ;
case STATE_CODE : switch ( buf [ 0 ] ) {
case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : if ( s -> nb_args < MAX_NB_ARGS ) s -> args [ s -> nb_args ] = s -> args [ s -> nb_args ] * 10 + buf [ 0 ] - '0' ;
break ;
case ';
' : s -> nb_args ++ ;
if ( s -> nb_args < MAX_NB_ARGS ) s -> args [ s -> nb_args ] = 0 ;
break ;
case 'M' : s -> state = STATE_MUSIC_PREAMBLE ;
break ;
case '=' : case '?' : break ;
default : if ( s -> nb_args > MAX_NB_ARGS ) av_log ( avctx , AV_LOG_WARNING , "args overflow (%i)\n" , s -> nb_args ) ;
if ( s -> nb_args < MAX_NB_ARGS && s -> args [ s -> nb_args ] ) s -> nb_args ++ ;
if ( ( ret = execute_code ( avctx , buf [ 0 ] ) ) < 0 ) return ret ;
s -> state = STATE_NORMAL ;
}
break ;
case STATE_MUSIC_PREAMBLE : if ( buf [ 0 ] == 0x0E || buf [ 0 ] == 0x1B ) s -> state = STATE_NORMAL ;
break ;
}
buf ++ ;
}
* got_frame = 1 ;
* ( AVFrame * ) data = s -> frame ;
return buf_size ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( DirectoryIterator , current ) {
if ( zend_parse_parameters_none ( ) == FAILURE ) {
return ;
}
RETURN_ZVAL ( getThis ( ) , 1 , 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void e1000e_set_16bit ( E1000ECore * core , int index , uint32_t val ) {
core -> mac [ index ] = val & 0xffff ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int32_t u_printf_char_handler ( const u_printf_stream_handler * handler , void * context , ULocaleBundle * formatBundle , const u_printf_spec_info * info , const ufmt_args * args ) {
( void ) formatBundle ;
UChar s [ U16_MAX_LENGTH + 1 ] ;
int32_t len = 1 , written ;
unsigned char arg = ( unsigned char ) ( args [ 0 ] . int64Value ) ;
ufmt_defaultCPToUnicode ( ( const char * ) & arg , 2 , s , UPRV_LENGTHOF ( s ) ) ;
if ( arg != 0 ) {
len = u_strlen ( s ) ;
}
written = handler -> pad_and_justify ( context , info , s , len ) ;
return written ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_T_h223_al_type_al2WithoutSequenceNumbers ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 304 "../../asn1/h245/h245.cnf" if ( h223_lc_params_temp ) h223_lc_params_temp -> al_type = al2WithoutSequenceNumbers ;
offset = dissect_per_null ( tvb , offset , actx , tree , hf_index ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | extern int main ( int argc , char * argv [ ] ) {
# if ! UCONFIG_NO_IDNA char * filename = NULL ;
# endif const char * srcDir = NULL , * destDir = NULL , * icuUniDataDir = NULL ;
const char * bundleName = NULL , * inputFileName = NULL ;
char * basename = NULL ;
int32_t sprepOptions = 0 ;
UErrorCode errorCode = U_ZERO_ERROR ;
U_MAIN_INIT_ARGS ( argc , argv ) ;
options [ DESTDIR ] . value = u_getDataDirectory ( ) ;
options [ SOURCEDIR ] . value = "" ;
options [ UNICODE_VERSION ] . value = "0" ;
options [ BUNDLE_NAME ] . value = DATA_NAME ;
options [ NORMALIZE ] . value = "" ;
argc = u_parseArgs ( argc , argv , UPRV_LENGTHOF ( options ) , options ) ;
if ( argc < 0 ) {
fprintf ( stderr , "error in command line argument \"%s\"\n" , argv [ - argc ] ) ;
}
if ( argc < 0 || options [ HELP ] . doesOccur || options [ HELP_QUESTION_MARK ] . doesOccur ) {
return printHelp ( argc , argv ) ;
}
beVerbose = options [ VERBOSE ] . doesOccur ;
haveCopyright = options [ COPYRIGHT ] . doesOccur ;
srcDir = options [ SOURCEDIR ] . value ;
destDir = options [ DESTDIR ] . value ;
bundleName = options [ BUNDLE_NAME ] . value ;
if ( options [ NORMALIZE ] . doesOccur ) {
icuUniDataDir = options [ NORMALIZE ] . value ;
}
else {
icuUniDataDir = options [ NORM_CORRECTION_DIR ] . value ;
}
if ( argc < 2 ) {
return printHelp ( argc , argv ) ;
}
else {
inputFileName = argv [ 1 ] ;
}
if ( ! options [ UNICODE_VERSION ] . doesOccur ) {
return printHelp ( argc , argv ) ;
}
if ( options [ ICUDATADIR ] . doesOccur ) {
u_setDataDirectory ( options [ ICUDATADIR ] . value ) ;
}
# if UCONFIG_NO_IDNA fprintf ( stderr , "gensprep writes dummy " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE " because UCONFIG_NO_IDNA is set, \n" "see icu/source/common/unicode/uconfig.h\n" ) ;
generateData ( destDir , bundleName ) ;
# else setUnicodeVersion ( options [ UNICODE_VERSION ] . value ) ;
filename = ( char * ) uprv_malloc ( uprv_strlen ( srcDir ) + uprv_strlen ( inputFileName ) + ( icuUniDataDir == NULL ? 0 : uprv_strlen ( icuUniDataDir ) ) + 40 ) ;
if ( uprv_strchr ( srcDir , U_FILE_SEP_CHAR ) == NULL && uprv_strchr ( srcDir , U_FILE_ALT_SEP_CHAR ) == NULL ) {
filename [ 0 ] = '.' ;
filename [ 1 ] = U_FILE_SEP_CHAR ;
uprv_strcpy ( filename + 2 , srcDir ) ;
}
else {
uprv_strcpy ( filename , srcDir ) ;
}
basename = filename + uprv_strlen ( filename ) ;
if ( basename > filename && * ( basename - 1 ) != U_FILE_SEP_CHAR ) {
* basename ++ = U_FILE_SEP_CHAR ;
}
init ( ) ;
uprv_strcpy ( basename , inputFileName ) ;
parseMappings ( filename , FALSE , & errorCode ) ;
if ( U_FAILURE ( errorCode ) ) {
fprintf ( stderr , "Could not open file %s for reading. Error: %s \n" , filename , u_errorName ( errorCode ) ) ;
return errorCode ;
}
if ( options [ NORMALIZE ] . doesOccur ) {
uprv_strcpy ( filename , icuUniDataDir ) ;
basename = filename + uprv_strlen ( filename ) ;
if ( basename > filename && * ( basename - 1 ) != U_FILE_SEP_CHAR ) {
* basename ++ = U_FILE_SEP_CHAR ;
}
* basename ++ = U_FILE_SEP_CHAR ;
uprv_strcpy ( basename , NORM_CORRECTIONS_FILE_NAME ) ;
parseNormalizationCorrections ( filename , & errorCode ) ;
if ( U_FAILURE ( errorCode ) ) {
fprintf ( stderr , "Could not open file %s for reading \n" , filename ) ;
return errorCode ;
}
sprepOptions |= _SPREP_NORMALIZATION_ON ;
}
if ( options [ CHECK_BIDI ] . doesOccur ) {
sprepOptions |= _SPREP_CHECK_BIDI_ON ;
}
setOptions ( sprepOptions ) ;
if ( U_SUCCESS ( errorCode ) ) {
generateData ( destDir , bundleName ) ;
cleanUpData ( ) ;
}
uprv_free ( filename ) ;
u_cleanup ( ) ;
# endif return errorCode ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int PEM_write_ ## name ( FILE * fp , type * x ) ;
# define DECLARE_PEM_write_fp_const ( name , type ) int PEM_write_ ## name ( FILE * fp , const type * x ) ;
# define DECLARE_PEM_write_cb_fp ( name , type ) int PEM_write_ ## name ( FILE * fp , type * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
# endif # define DECLARE_PEM_read_bio ( name , type ) type * PEM_read_bio_ ## name ( BIO * bp , type * * x , pem_password_cb * cb , void * u ) ;
# define DECLARE_PEM_write_bio ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , type * x ) ;
# define DECLARE_PEM_write_bio_const ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , const type * x ) ;
# define DECLARE_PEM_write_cb_bio ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , type * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
# define DECLARE_PEM_write ( name , type ) DECLARE_PEM_write_bio ( name , type ) DECLARE_PEM_write_fp ( name , type ) # define DECLARE_PEM_write_const ( name , type ) DECLARE_PEM_write_bio_const ( name , type ) DECLARE_PEM_write_fp_const ( name , type ) # define DECLARE_PEM_write_cb ( name , type ) DECLARE_PEM_write_cb_bio ( name , type ) DECLARE_PEM_write_cb_fp ( name , type ) # define DECLARE_PEM_read ( name , type ) DECLARE_PEM_read_bio ( name , type ) DECLARE_PEM_read_fp ( name , type ) # define DECLARE_PEM_rw ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write ( name , type ) # define DECLARE_PEM_rw_const ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_const ( name , type ) # define DECLARE_PEM_rw_cb ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_cb ( name , type ) typedef int pem_password_cb ( char * buf , int size , int rwflag , void * userdata ) ;
int PEM_get_EVP_CIPHER_INFO ( char * header , EVP_CIPHER_INFO * cipher ) ;
int PEM_do_header ( EVP_CIPHER_INFO * cipher , unsigned char * data , long * len , pem_password_cb * callback , void * u ) ;
int PEM_read_bio ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len ) ;
# define PEM_FLAG_SECURE 0x1 # define PEM_FLAG_EAY_COMPATIBLE 0x2 # define PEM_FLAG_ONLY_B64 0x4 int PEM_read_bio_ex ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len , unsigned int flags ) ;
int PEM_bytes_read_bio_secmem ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
int PEM_write_bio ( BIO * bp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
int PEM_bytes_read_bio ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
void * PEM_ASN1_read_bio ( d2i_of_void * d2i , const char * name , BIO * bp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write_bio ( i2d_of_void * i2d , const char * name , BIO * bp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read_bio ( BIO * bp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
int PEM_X509_INFO_write_bio ( BIO * bp , X509_INFO * xi , EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cd , void * u ) ;
# ifndef OPENSSL_NO_STDIO int PEM_read ( FILE * fp , char * * name , char * * header , unsigned char * * data , long * len ) ;
int PEM_write ( FILE * fp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
void * PEM_ASN1_read ( d2i_of_void * d2i , const char * name , FILE * fp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write ( i2d_of_void * i2d , const char * name , FILE * fp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * callback , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read ( FILE * fp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
# endif int PEM_SignInit ( EVP_MD_CTX * ctx , EVP_MD * type ) ;
int PEM_SignUpdate ( EVP_MD_CTX * ctx , unsigned char * d , unsigned int cnt ) ;
int PEM_SignFinal ( EVP_MD_CTX * ctx , unsigned char * sigret , unsigned int * siglen , EVP_PKEY * pkey ) ;
int PEM_def_callback ( char * buf , int num , int rwflag , void * userdata ) ;
void PEM_proc_type ( char * buf , int type ) ;
void PEM_dek_info ( char * buf , const char * type , int len , char * str ) ;
# include < openssl / symhacks . h > DECLARE_PEM_rw ( X509 , X509 ) DECLARE_PEM_rw ( X509_AUX , X509 ) DECLARE_PEM_rw ( X509_REQ , X509_REQ ) DECLARE_PEM_write ( X509_REQ_NEW , X509_REQ ) DECLARE_PEM_rw ( X509_CRL , X509_CRL ) DECLARE_PEM_rw ( PKCS7 , PKCS7 ) DECLARE_PEM_rw ( NETSCAPE_CERT_SEQUENCE , NETSCAPE_CERT_SEQUENCE ) DECLARE_PEM_rw ( PKCS8 , X509_SIG ) DECLARE_PEM_rw ( PKCS8_PRIV_KEY_INFO , PKCS8_PRIV_KEY_INFO ) # ifndef OPENSSL_NO_RSA DECLARE_PEM_rw_cb ( RSAPrivateKey , RSA ) DECLARE_PEM_rw_const ( RSAPublicKey , RSA ) DECLARE_PEM_rw ( RSA_PUBKEY , RSA ) # endif # ifndef OPENSSL_NO_DSA DECLARE_PEM_rw_cb ( DSAPrivateKey , DSA ) DECLARE_PEM_rw ( DSA_PUBKEY , DSA ) DECLARE_PEM_rw_const ( DSAparams , DSA ) # endif # ifndef OPENSSL_NO_EC DECLARE_PEM_rw_const ( ECPKParameters , EC_GROUP ) DECLARE_PEM_rw_cb ( ECPrivateKey , EC_KEY ) DECLARE_PEM_rw ( EC_PUBKEY , EC_KEY ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static OFCondition parseSCUSCPRole ( PRV_SCUSCPROLE * role , unsigned char * buf , unsigned long * length , unsigned long availData ) {
unsigned short UIDLength ;
if ( availData < 8 ) return makeLengthError ( "SCU-SCP role list" , availData , 8 ) ;
role -> type = * buf ++ ;
role -> rsv1 = * buf ++ ;
EXTRACT_SHORT_BIG ( buf , role -> length ) ;
buf += 2 ;
EXTRACT_SHORT_BIG ( buf , UIDLength ) ;
buf += 2 ;
if ( availData - 4 < role -> length ) return makeLengthError ( "SCU-SCP role list" , availData , 0 , role -> length ) ;
if ( role -> length < 4 ) return makeLengthError ( "SCU-SCP role list UID" , role -> length , 4 ) ;
if ( role -> length - 4 < UIDLength ) return makeLengthError ( "SCU-SCP role list UID" , role -> length , 0 , UIDLength ) ;
( void ) memcpy ( role -> SOPClassUID , buf , UIDLength ) ;
role -> SOPClassUID [ UIDLength ] = '\0' ;
buf += UIDLength ;
role -> SCURole = * buf ++ ;
role -> SCPRole = * buf ++ ;
* length = 2 + 2 + role -> length ;
DCMNET_TRACE ( "Subitem parse: Type " << STD_NAMESPACE hex << STD_NAMESPACE setfill ( '0' ) << STD_NAMESPACE setw ( 2 ) << ( unsigned int ) role -> type << STD_NAMESPACE dec << ", Length " << STD_NAMESPACE setw ( 4 ) << ( int ) role -> length << ", Content: " << role -> SOPClassUID << " " << ( int ) role -> SCURole << " " << ( int ) role -> SCPRole ) ;
return EC_Normal ;
} | 1True
|