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 tls_process_cke_ecdhe ( SSL * s , PACKET * pkt , int * al ) {
# ifndef OPENSSL_NO_EC EVP_PKEY * skey = s -> s3 -> tmp . pkey ;
EVP_PKEY * ckey = NULL ;
int ret = 0 ;
if ( PACKET_remaining ( pkt ) == 0L ) {
* al = SSL_AD_HANDSHAKE_FAILURE ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , SSL_R_MISSING_TMP_ECDH_KEY ) ;
goto err ;
}
else {
unsigned int i ;
const unsigned char * data ;
if ( ! PACKET_get_1 ( pkt , & i ) || ! PACKET_get_bytes ( pkt , & data , i ) || PACKET_remaining ( pkt ) != 0 ) {
* al = SSL_AD_DECODE_ERROR ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , SSL_R_LENGTH_MISMATCH ) ;
goto err ;
}
ckey = EVP_PKEY_new ( ) ;
if ( ckey == NULL || EVP_PKEY_copy_parameters ( ckey , skey ) <= 0 ) {
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , ERR_R_EVP_LIB ) ;
goto err ;
}
if ( EVP_PKEY_set1_tls_encodedpoint ( ckey , data , i ) == 0 ) {
* al = SSL_AD_HANDSHAKE_FAILURE ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , ERR_R_EC_LIB ) ;
goto err ;
}
}
if ( ssl_derive ( s , skey , ckey ) == 0 ) {
* al = SSL_AD_INTERNAL_ERROR ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , ERR_R_INTERNAL_ERROR ) ;
goto err ;
}
ret = 1 ;
EVP_PKEY_free ( s -> s3 -> tmp . pkey ) ;
s -> s3 -> tmp . pkey = NULL ;
err : EVP_PKEY_free ( ckey ) ;
return ret ;
# else * al = SSL_AD_INTERNAL_ERROR ;
SSLerr ( SSL_F_TLS_PROCESS_CKE_ECDHE , ERR_R_INTERNAL_ERROR ) ;
return 0 ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_rsvp_policy ( proto_item * ti _U_ , proto_tree * rsvp_object_tree , tvbuff_t * tvb , int offset , int obj_length , int rsvp_class _U_ , int type ) {
int offset2 = offset + 4 ;
proto_tree_add_uint ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_policy_data , tvb , offset2 , obj_length - 4 , ENC_NA ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( UnloadTest , DISABLED_BrowserCloseUnload ) {
LoadUrlAndQuitBrowser ( UNLOAD_HTML , "unload" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void fill_mode_info_sb ( VP9_COMMON * cm , MACROBLOCK * x , int mi_row , int mi_col , BLOCK_SIZE bsize , BLOCK_SIZE subsize , PC_TREE * pc_tree ) {
MACROBLOCKD * xd = & x -> e_mbd ;
int bsl = b_width_log2 ( bsize ) , hbs = ( 1 << bsl ) / 4 ;
PARTITION_TYPE partition = pc_tree -> partitioning ;
assert ( bsize >= BLOCK_8X8 ) ;
if ( mi_row >= cm -> mi_rows || mi_col >= cm -> mi_cols ) return ;
switch ( partition ) {
case PARTITION_NONE : set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ;
* ( xd -> mi [ 0 ] ) = pc_tree -> none . mic ;
duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ;
break ;
case PARTITION_VERT : set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ;
* ( xd -> mi [ 0 ] ) = pc_tree -> vertical [ 0 ] . mic ;
duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ;
if ( mi_col + hbs < cm -> mi_cols ) {
set_modeinfo_offsets ( cm , xd , mi_row , mi_col + hbs ) ;
* ( xd -> mi [ 0 ] ) = pc_tree -> vertical [ 1 ] . mic ;
duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col + hbs , bsize ) ;
}
break ;
case PARTITION_HORZ : set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ;
* ( xd -> mi [ 0 ] ) = pc_tree -> horizontal [ 0 ] . mic ;
duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ;
if ( mi_row + hbs < cm -> mi_rows ) {
set_modeinfo_offsets ( cm , xd , mi_row + hbs , mi_col ) ;
* ( xd -> mi [ 0 ] ) = pc_tree -> horizontal [ 1 ] . mic ;
duplicate_mode_info_in_sb ( cm , xd , mi_row + hbs , mi_col , bsize ) ;
}
break ;
case PARTITION_SPLIT : {
BLOCK_SIZE subsubsize = get_subsize ( subsize , PARTITION_SPLIT ) ;
fill_mode_info_sb ( cm , x , mi_row , mi_col , subsize , subsubsize , pc_tree -> split [ 0 ] ) ;
fill_mode_info_sb ( cm , x , mi_row , mi_col + hbs , subsize , subsubsize , pc_tree -> split [ 1 ] ) ;
fill_mode_info_sb ( cm , x , mi_row + hbs , mi_col , subsize , subsubsize , pc_tree -> split [ 2 ] ) ;
fill_mode_info_sb ( cm , x , mi_row + hbs , mi_col + hbs , subsize , subsubsize , pc_tree -> split [ 3 ] ) ;
break ;
}
default : break ;
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int add_server ( struct manager_ctx * manager , struct server * server ) {
int ret = check_port ( manager , server ) ;
if ( ret == - 1 ) {
LOGE ( "port is not available, please check." ) ;
return - 1 ;
}
bool new = false ;
cork_hash_table_put ( server_table , ( void * ) server -> port , ( void * ) server , & new , NULL , NULL ) ;
char * cmd = construct_command_line ( manager , server ) ;
if ( system ( cmd ) == - 1 ) {
ERROR ( "add_server_system" ) ;
return - 1 ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline uint16_t e1000e_get_reg_index_with_offset ( const uint16_t * mac_reg_access , hwaddr addr ) {
uint16_t index = ( addr & 0x1ffff ) >> 2 ;
return index + ( mac_reg_access [ index ] & 0xfffe ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void prplcb_conn_disconnected ( PurpleConnection * gc ) {
struct im_connection * ic = purple_ic_by_gc ( gc ) ;
if ( ic != NULL ) {
imc_logout ( ic , ! gc -> wants_to_die ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int kq_add ( void * arg , struct event * ev ) {
struct kqop * kqop = arg ;
struct kevent kev ;
if ( ev -> ev_events & EV_SIGNAL ) {
int nsignal = EVENT_SIGNAL ( ev ) ;
assert ( nsignal >= 0 && nsignal < NSIG ) ;
if ( TAILQ_EMPTY ( & kqop -> evsigevents [ nsignal ] ) ) {
struct timespec timeout = {
0 , 0 }
;
memset ( & kev , 0 , sizeof ( kev ) ) ;
kev . ident = nsignal ;
kev . filter = EVFILT_SIGNAL ;
kev . flags = EV_ADD ;
kev . udata = PTR_TO_UDATA ( & kqop -> evsigevents [ nsignal ] ) ;
if ( kevent ( kqop -> kq , & kev , 1 , NULL , 0 , & timeout ) == - 1 ) return ( - 1 ) ;
if ( _evsignal_set_handler ( ev -> ev_base , nsignal , kq_sighandler ) == - 1 ) return ( - 1 ) ;
}
TAILQ_INSERT_TAIL ( & kqop -> evsigevents [ nsignal ] , ev , ev_signal_next ) ;
ev -> ev_flags |= EVLIST_X_KQINKERNEL ;
return ( 0 ) ;
}
if ( ev -> ev_events & EV_READ ) {
memset ( & kev , 0 , sizeof ( kev ) ) ;
kev . ident = ev -> ev_fd ;
kev . filter = EVFILT_READ ;
# ifdef NOTE_EOF kev . fflags = NOTE_EOF ;
# endif kev . flags = EV_ADD ;
if ( ! ( ev -> ev_events & EV_PERSIST ) ) kev . flags |= EV_ONESHOT ;
kev . udata = PTR_TO_UDATA ( ev ) ;
if ( kq_insert ( kqop , & kev ) == - 1 ) return ( - 1 ) ;
ev -> ev_flags |= EVLIST_X_KQINKERNEL ;
}
if ( ev -> ev_events & EV_WRITE ) {
memset ( & kev , 0 , sizeof ( kev ) ) ;
kev . ident = ev -> ev_fd ;
kev . filter = EVFILT_WRITE ;
kev . flags = EV_ADD ;
if ( ! ( ev -> ev_events & EV_PERSIST ) ) kev . flags |= EV_ONESHOT ;
kev . udata = PTR_TO_UDATA ( ev ) ;
if ( kq_insert ( kqop , & kev ) == - 1 ) return ( - 1 ) ;
ev -> ev_flags |= EVLIST_X_KQINKERNEL ;
}
return ( 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | Oid get_typcollation ( Oid typid ) {
HeapTuple tp ;
tp = SearchSysCache1 ( TYPEOID , ObjectIdGetDatum ( typid ) ) ;
if ( HeapTupleIsValid ( tp ) ) {
Form_pg_type typtup = ( Form_pg_type ) GETSTRUCT ( tp ) ;
Oid result ;
result = typtup -> typcollation ;
ReleaseSysCache ( tp ) ;
return result ;
}
else return InvalidOid ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void pxa2xx_ssp_class_init ( ObjectClass * klass , void * data ) {
SysBusDeviceClass * sdc = SYS_BUS_DEVICE_CLASS ( klass ) ;
sdc -> init = pxa2xx_ssp_init ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PHP_FUNCTION ( uwsgi_masterpid ) {
if ( uwsgi . master_process ) {
RETURN_LONG ( uwsgi . workers [ 0 ] . pid ) ;
}
RETURN_LONG ( 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void parseNormalizationCorrections ( const char * filename , UErrorCode * pErrorCode ) {
char * fields [ 4 ] [ 2 ] ;
if ( pErrorCode == NULL || U_FAILURE ( * pErrorCode ) ) {
return ;
}
u_parseDelimitedFile ( filename , ';
' , fields , 4 , normalizationCorrectionsLineFn , NULL , pErrorCode ) ;
if ( U_FAILURE ( * pErrorCode ) && ( * pErrorCode != U_FILE_ACCESS_ERROR ) ) {
fprintf ( stderr , "gensprep error: u_parseDelimitedFile(\"%s\") failed - %s\n" , filename , u_errorName ( * pErrorCode ) ) ;
exit ( * pErrorCode ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void unpause_activation_timed_cancel ( ActivateParameters * parameters ) {
if ( ! parameters -> timed_wait_active ) {
activation_start_timed_cancel ( parameters ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ps2_common_reset ( PS2State * s ) {
s -> write_cmd = - 1 ;
ps2_reset_queue ( s ) ;
s -> update_irq ( s -> update_arg , 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int incomplete_class_has_property ( zval * object , zval * member , int check_empty , const zend_literal * key TSRMLS_DC ) {
incomplete_class_message ( object , E_NOTICE TSRMLS_CC ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int qemuMonitorTextGetVirtType ( qemuMonitorPtr mon , int * virtType ) {
char * reply = NULL ;
* virtType = VIR_DOMAIN_VIRT_QEMU ;
if ( qemuMonitorHMPCommand ( mon , "info kvm" , & reply ) < 0 ) {
qemuReportError ( VIR_ERR_OPERATION_FAILED , "%s" , _ ( "could not query kvm status" ) ) ;
return - 1 ;
}
if ( strstr ( reply , "enabled" ) ) * virtType = VIR_DOMAIN_VIRT_KVM ;
VIR_FREE ( reply ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int kvm_get_supported_msrs ( KVMState * s ) {
static int kvm_supported_msrs ;
int ret = 0 ;
if ( kvm_supported_msrs == 0 ) {
struct kvm_msr_list msr_list , * kvm_msr_list ;
kvm_supported_msrs = - 1 ;
msr_list . nmsrs = 0 ;
ret = kvm_ioctl ( s , KVM_GET_MSR_INDEX_LIST , & msr_list ) ;
if ( ret < 0 && ret != - E2BIG ) {
return ret ;
}
kvm_msr_list = g_malloc0 ( MAX ( 1024 , sizeof ( msr_list ) + msr_list . nmsrs * sizeof ( msr_list . indices [ 0 ] ) ) ) ;
kvm_msr_list -> nmsrs = msr_list . nmsrs ;
ret = kvm_ioctl ( s , KVM_GET_MSR_INDEX_LIST , kvm_msr_list ) ;
if ( ret >= 0 ) {
int i ;
for ( i = 0 ;
i < kvm_msr_list -> nmsrs ;
i ++ ) {
switch ( kvm_msr_list -> indices [ i ] ) {
case MSR_STAR : has_msr_star = true ;
break ;
case MSR_VM_HSAVE_PA : has_msr_hsave_pa = true ;
break ;
case MSR_TSC_AUX : has_msr_tsc_aux = true ;
break ;
case MSR_TSC_ADJUST : has_msr_tsc_adjust = true ;
break ;
case MSR_IA32_TSCDEADLINE : has_msr_tsc_deadline = true ;
break ;
case MSR_IA32_SMBASE : has_msr_smbase = true ;
break ;
case MSR_SMI_COUNT : has_msr_smi_count = true ;
break ;
case MSR_IA32_MISC_ENABLE : has_msr_misc_enable = true ;
break ;
case MSR_IA32_BNDCFGS : has_msr_bndcfgs = true ;
break ;
case MSR_IA32_XSS : has_msr_xss = true ;
break ;
case HV_X64_MSR_CRASH_CTL : has_msr_hv_crash = true ;
break ;
case HV_X64_MSR_RESET : has_msr_hv_reset = true ;
break ;
case HV_X64_MSR_VP_INDEX : has_msr_hv_vpindex = true ;
break ;
case HV_X64_MSR_VP_RUNTIME : has_msr_hv_runtime = true ;
break ;
case HV_X64_MSR_SCONTROL : has_msr_hv_synic = true ;
break ;
case HV_X64_MSR_STIMER0_CONFIG : has_msr_hv_stimer = true ;
break ;
case HV_X64_MSR_TSC_FREQUENCY : has_msr_hv_frequencies = true ;
break ;
case HV_X64_MSR_REENLIGHTENMENT_CONTROL : has_msr_hv_reenlightenment = true ;
break ;
case MSR_IA32_SPEC_CTRL : has_msr_spec_ctrl = true ;
break ;
case MSR_VIRT_SSBD : has_msr_virt_ssbd = true ;
break ;
}
}
}
g_free ( kvm_msr_list ) ;
}
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void prep_NVRAM_init ( void ) {
m48t59_t * nvram ;
nvram = m48t59_init ( 8 , 0x0074 , NVRAM_SIZE ) ;
NVRAM_set_word ( nvram , 0x00 , NVRAM_SIZE >> 10 ) ;
NVRAM_set_byte ( nvram , 0x02 , 0x01 ) ;
NVRAM_set_byte ( nvram , 0x03 , 0x01 ) ;
NVRAM_set_byte ( nvram , 0x08 , 0x00 ) ;
NVRAM_set_byte ( nvram , 0x09 , 'B' ) ;
NVRAM_set_byte ( nvram , 0x0A , 0x00 ) ;
NVRAM_set_byte ( nvram , 0x0B , 0x00 ) ;
NVRAM_set_word ( nvram , 0x0C , 0x01 ) ;
NVRAM_set_word ( nvram , 0x0E , 0x01 ) ;
NVRAM_set_lword ( nvram , 0x20 , 0x00 ) ;
NVRAM_set_lword ( nvram , 0x24 , 0x00 ) ;
NVRAM_set_lword ( nvram , 0x28 , 0x00 ) ;
NVRAM_set_crc ( nvram , 0x1C , 0x0C , 32 ) ;
NVRAM_set_lword ( nvram , 0xC4 , 0x0100 ) ;
NVRAM_set_lword ( nvram , 0xC8 , NVRAM_END - NVRAM_OSAREA_SIZE - NVRAM_CONFSIZE - 0x0100 ) ;
NVRAM_set_lword ( nvram , 0xD4 , NVRAM_END - NVRAM_CONFSIZE ) ;
NVRAM_set_lword ( nvram , 0xD8 , NVRAM_CONFSIZE ) ;
NVRAM_set_lword ( nvram , 0xE8 , NVRAM_END - NVRAM_CONFSIZE - NVRAM_OSAREA_SIZE ) ;
NVRAM_set_lword ( nvram , 0xEC , NVRAM_OSAREA_SIZE ) ;
NVRAM_set_crc ( nvram , 0x04 , 0x00 , NVRAM_END - NVRAM_CONFSIZE - NVRAM_OSAREA_SIZE ) ;
NVRAM_set_crc ( nvram , 0x06 , NVRAM_END - NVRAM_CONFSIZE , NVRAM_CONFSIZE ) ;
} | 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 ] ;
tran_low_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 ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int xps_parse_line_cap ( char * attr ) {
if ( attr ) {
if ( ! strcmp ( attr , "Flat" ) ) return 0 ;
if ( ! strcmp ( attr , "Round" ) ) return 1 ;
if ( ! strcmp ( attr , "Square" ) ) return 2 ;
if ( ! strcmp ( attr , "Triangle" ) ) return 3 ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( SessionRestorePageLoadMetricsBrowserTest , LoadingAfterSessionRestore ) {
ui_test_utils : : NavigateToURL ( browser ( ) , GetTestURL ( ) ) ;
Browser * new_browser = nullptr ;
{
SessionRestorePaintWaiter session_restore_paint_waiter ;
new_browser = QuitBrowserAndRestore ( browser ( ) ) ;
session_restore_paint_waiter . WaitForForegroundTabs ( 1 ) ;
ExpectFirstPaintMetricsTotalCount ( 1 ) ;
}
auto waiter = std : : make_unique < PageLoadMetricsWaiter > ( new_browser -> tab_strip_model ( ) -> GetActiveWebContents ( ) ) ;
waiter -> AddPageExpectation ( TimingField : : FIRST_MEANINGFUL_PAINT ) ;
ui_test_utils : : NavigateToURL ( new_browser , GetTestURL ( ) ) ;
waiter -> Wait ( ) ;
ExpectFirstPaintMetricsTotalCount ( 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void ff_MPV_decode_defaults ( MpegEncContext * s ) {
ff_MPV_common_defaults ( s ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | const char * tok2strary_internal ( register const char * * lp , int n , register const char * fmt , register int v ) {
static char buf [ TOKBUFSIZE ] ;
if ( v >= 0 && v < n && lp [ v ] != NULL ) return lp [ v ] ;
if ( fmt == NULL ) fmt = "#%d" ;
( void ) snprintf ( buf , sizeof ( buf ) , fmt , v ) ;
return ( buf ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) {
return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
}
static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {
OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;
}
static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {
return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;
}
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;
}
static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {
return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;
}
static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {
return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;
}
# define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;
typedef const char * OPENSSL_CSTRING ;
DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char ) DEFINE_SPECIAL_STACK_OF_CONST ( OPENSSL_CSTRING , char ) | 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 ) static int aes_ccm_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_CCM_CTX * cctx = EVP_C_DATA ( EVP_AES_CCM_CTX , c ) ;
switch ( type ) {
case EVP_CTRL_INIT : cctx -> key_set = 0 ;
cctx -> iv_set = 0 ;
cctx -> L = 8 ;
cctx -> M = 12 ;
cctx -> tag_set = 0 ;
cctx -> len_set = 0 ;
cctx -> tls_aad_len = - 1 ;
return 1 ;
case EVP_CTRL_AEAD_TLS1_AAD : if ( arg != EVP_AEAD_TLS1_AAD_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
cctx -> tls_aad_len = arg ;
{
uint16_t len = EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] << 8 | EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] ;
len -= EVP_CCM_TLS_EXPLICIT_IV_LEN ;
if ( ! EVP_CIPHER_CTX_encrypting ( c ) ) len -= cctx -> M ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] = len >> 8 ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] = len & 0xff ;
}
return cctx -> M ;
case EVP_CTRL_CCM_SET_IV_FIXED : if ( arg != EVP_CCM_TLS_FIXED_IV_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_iv_noconst ( c ) , ptr , arg ) ;
return 1 ;
case EVP_CTRL_AEAD_SET_IVLEN : arg = 15 - arg ;
case EVP_CTRL_CCM_SET_L : if ( arg < 2 || arg > 8 ) return 0 ;
cctx -> L = arg ;
return 1 ;
case EVP_CTRL_AEAD_SET_TAG : if ( ( arg & 1 ) || arg < 4 || arg > 16 ) return 0 ;
if ( EVP_CIPHER_CTX_encrypting ( c ) && ptr ) return 0 ;
if ( ptr ) {
cctx -> tag_set = 1 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
}
cctx -> M = arg ;
return 1 ;
case EVP_CTRL_AEAD_GET_TAG : if ( ! EVP_CIPHER_CTX_encrypting ( c ) || ! cctx -> tag_set ) return 0 ;
if ( ! CRYPTO_ccm128_tag ( & cctx -> ccm , ptr , ( size_t ) arg ) ) return 0 ;
cctx -> tag_set = 0 ;
cctx -> iv_set = 0 ;
cctx -> len_set = 0 ;
return 1 ;
case EVP_CTRL_COPY : {
EVP_CIPHER_CTX * out = ptr ;
EVP_AES_CCM_CTX * cctx_out = EVP_C_DATA ( EVP_AES_CCM_CTX , out ) ;
if ( cctx -> ccm . key ) {
if ( cctx -> ccm . key != & cctx -> ks ) return 0 ;
cctx_out -> ccm . key = & cctx_out -> ks ;
}
return 1 ;
}
default : return - 1 ;
}
}
static int aes_ccm_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
EVP_AES_CCM_CTX * cctx = EVP_C_DATA ( EVP_AES_CCM_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 , & cctx -> ks . ks ) ;
CRYPTO_ccm128_init ( & cctx -> ccm , cctx -> M , cctx -> L , & cctx -> ks , ( block128_f ) HWAES_encrypt ) ;
cctx -> str = NULL ;
cctx -> key_set = 1 ;
break ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & cctx -> ks . ks ) ;
CRYPTO_ccm128_init ( & cctx -> ccm , cctx -> M , cctx -> L , & cctx -> ks , ( block128_f ) vpaes_encrypt ) ;
cctx -> str = NULL ;
cctx -> key_set = 1 ;
break ;
}
# endif AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & cctx -> ks . ks ) ;
CRYPTO_ccm128_init ( & cctx -> ccm , cctx -> M , cctx -> L , & cctx -> ks , ( block128_f ) AES_encrypt ) ;
cctx -> str = NULL ;
cctx -> key_set = 1 ;
}
while ( 0 ) ;
if ( iv ) {
memcpy ( EVP_CIPHER_CTX_iv_noconst ( ctx ) , iv , 15 - cctx -> L ) ;
cctx -> iv_set = 1 ;
}
return 1 ;
}
static int aes_ccm_tls_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_CCM_CTX * cctx = EVP_C_DATA ( EVP_AES_CCM_CTX , ctx ) ;
CCM128_CONTEXT * ccm = & cctx -> ccm ;
if ( out != in || len < ( EVP_CCM_TLS_EXPLICIT_IV_LEN + ( size_t ) cctx -> M ) ) return - 1 ;
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) memcpy ( out , EVP_CIPHER_CTX_buf_noconst ( ctx ) , EVP_CCM_TLS_EXPLICIT_IV_LEN ) ;
memcpy ( EVP_CIPHER_CTX_iv_noconst ( ctx ) + EVP_CCM_TLS_FIXED_IV_LEN , in , EVP_CCM_TLS_EXPLICIT_IV_LEN ) ;
len -= EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx -> M ;
if ( CRYPTO_ccm128_setiv ( ccm , EVP_CIPHER_CTX_iv_noconst ( ctx ) , 15 - cctx -> L , len ) ) return - 1 ;
CRYPTO_ccm128_aad ( ccm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , cctx -> tls_aad_len ) ;
in += EVP_CCM_TLS_EXPLICIT_IV_LEN ;
out += EVP_CCM_TLS_EXPLICIT_IV_LEN ;
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( cctx -> str ? CRYPTO_ccm128_encrypt_ccm64 ( ccm , in , out , len , cctx -> str ) : CRYPTO_ccm128_encrypt ( ccm , in , out , len ) ) return - 1 ;
if ( ! CRYPTO_ccm128_tag ( ccm , out + len , cctx -> M ) ) return - 1 ;
return len + EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx -> M ;
}
else {
if ( cctx -> str ? ! CRYPTO_ccm128_decrypt_ccm64 ( ccm , in , out , len , cctx -> str ) : ! CRYPTO_ccm128_decrypt ( ccm , in , out , len ) ) {
unsigned char tag [ 16 ] ;
if ( CRYPTO_ccm128_tag ( ccm , tag , cctx -> M ) ) {
if ( ! CRYPTO_memcmp ( tag , in + len , cctx -> M ) ) return len ;
}
}
OPENSSL_cleanse ( out , len ) ;
return - 1 ;
}
}
static int aes_ccm_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_CCM_CTX * cctx = EVP_C_DATA ( EVP_AES_CCM_CTX , ctx ) ;
CCM128_CONTEXT * ccm = & cctx -> ccm ;
if ( ! cctx -> key_set ) return - 1 ;
if ( cctx -> tls_aad_len >= 0 ) return aes_ccm_tls_cipher ( ctx , out , in , len ) ;
if ( ! cctx -> iv_set ) return - 1 ;
if ( ! EVP_CIPHER_CTX_encrypting ( ctx ) && ! cctx -> tag_set ) return - 1 ;
if ( ! out ) {
if ( ! in ) {
if ( CRYPTO_ccm128_setiv ( ccm , EVP_CIPHER_CTX_iv_noconst ( ctx ) , 15 - cctx -> L , len ) ) return - 1 ;
cctx -> len_set = 1 ;
return len ;
}
if ( ! cctx -> len_set && len ) return - 1 ;
CRYPTO_ccm128_aad ( ccm , in , len ) ;
return len ;
}
if ( ! in ) return 0 ;
if ( ! cctx -> len_set ) {
if ( CRYPTO_ccm128_setiv ( ccm , EVP_CIPHER_CTX_iv_noconst ( ctx ) , 15 - cctx -> L , len ) ) return - 1 ;
cctx -> len_set = 1 ;
}
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( cctx -> str ? CRYPTO_ccm128_encrypt_ccm64 ( ccm , in , out , len , cctx -> str ) : CRYPTO_ccm128_encrypt ( ccm , in , out , len ) ) return - 1 ;
cctx -> tag_set = 1 ;
return len ;
}
else {
int rv = - 1 ;
if ( cctx -> str ? ! CRYPTO_ccm128_decrypt_ccm64 ( ccm , in , out , len , cctx -> str ) : ! CRYPTO_ccm128_decrypt ( ccm , in , out , len ) ) {
unsigned char tag [ 16 ] ;
if ( CRYPTO_ccm128_tag ( ccm , tag , cctx -> M ) ) {
if ( ! CRYPTO_memcmp ( tag , EVP_CIPHER_CTX_buf_noconst ( ctx ) , cctx -> M ) ) rv = len ;
}
}
if ( rv == - 1 ) OPENSSL_cleanse ( out , len ) ;
cctx -> iv_set = 0 ;
cctx -> tag_set = 0 ;
cctx -> len_set = 0 ;
return rv ;
}
}
# define aes_ccm_cleanup NULL BLOCK_CIPHER_custom ( NID_aes , 128 , 1 , 12 , ccm , CCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 192 , 1 , 12 , ccm , CCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( DirectoryIterator , getExtension ) {
spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
char * fname = NULL ;
const char * p ;
size_t flen ;
int idx ;
if ( zend_parse_parameters_none ( ) == FAILURE ) {
return ;
}
php_basename ( intern -> u . dir . entry . d_name , strlen ( intern -> u . dir . entry . d_name ) , NULL , 0 , & fname , & flen TSRMLS_CC ) ;
p = zend_memrchr ( fname , '.' , flen ) ;
if ( p ) {
idx = p - fname ;
RETVAL_STRINGL ( fname + idx + 1 , flen - idx - 1 , 1 ) ;
efree ( fname ) ;
return ;
}
else {
if ( fname ) {
efree ( fname ) ;
}
RETURN_EMPTY_STRING ( ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void record_recent_object ( struct object * obj , const char * name , void * data ) {
sha1_array_append ( & recent_objects , obj -> oid . hash ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_open_direct ( ) {
MYSQL_STMT * stmt ;
MYSQL_RES * result ;
int rc ;
myheader ( "test_open_direct" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_open_direct" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_open_direct(id int, name char(6))" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "INSERT INTO test_open_direct values(10, 'mysql')" ) ;
check_stmt ( stmt ) ;
rc = mysql_query ( mysql , "SELECT * FROM test_open_direct" ) ;
myquery ( rc ) ;
result = mysql_store_result ( mysql ) ;
mytest ( result ) ;
rc = my_process_result_set ( result ) ;
DIE_UNLESS ( rc == 0 ) ;
mysql_free_result ( result ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
verify_st_affected_rows ( stmt , 1 ) ;
rc = mysql_query ( mysql , "SELECT * FROM test_open_direct" ) ;
myquery ( rc ) ;
result = mysql_store_result ( mysql ) ;
mytest ( result ) ;
rc = my_process_result_set ( result ) ;
DIE_UNLESS ( rc == 1 ) ;
mysql_free_result ( result ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
verify_st_affected_rows ( stmt , 1 ) ;
rc = mysql_query ( mysql , "SELECT * FROM test_open_direct" ) ;
myquery ( rc ) ;
result = mysql_store_result ( mysql ) ;
mytest ( result ) ;
rc = my_process_result_set ( result ) ;
DIE_UNLESS ( rc == 2 ) ;
mysql_free_result ( result ) ;
mysql_stmt_close ( stmt ) ;
stmt = mysql_simple_prepare ( mysql , "SELECT * FROM test_open_direct" ) ;
check_stmt ( stmt ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_open_direct(id) VALUES(20)" ) ;
myquery_r ( rc ) ;
rc = mysql_stmt_close ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_open_direct(id) VALUES(20)" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "SELECT * FROM test_open_direct" ) ;
check_stmt ( stmt ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_store_result ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_query ( mysql , "drop table test_open_direct" ) ;
myquery ( rc ) ;
rc = mysql_stmt_close ( stmt ) ;
check_execute ( stmt , rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int TSMimeHdrLengthGet ( TSMBuffer bufp , TSMLoc obj ) {
sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
sdk_assert ( ( sdk_sanity_check_mime_hdr_handle ( obj ) == TS_SUCCESS ) || ( sdk_sanity_check_http_hdr_handle ( obj ) == TS_SUCCESS ) ) ;
MIMEHdrImpl * mh = _hdr_mloc_to_mime_hdr_impl ( obj ) ;
return mime_hdr_length_get ( mh ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int eightsvx_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
EightSvxContext * esc = avctx -> priv_data ;
AVFrame * frame = data ;
int buf_size ;
int ch , ret ;
int is_compr = ( avctx -> codec_id != AV_CODEC_ID_PCM_S8_PLANAR ) ;
if ( avpkt -> data ) {
int hdr_size = is_compr ? 2 : 0 ;
int chan_size = ( avpkt -> size - hdr_size * avctx -> channels ) / avctx -> channels ;
if ( avpkt -> size < hdr_size * avctx -> channels ) {
av_log ( avctx , AV_LOG_ERROR , "packet size is too small\n" ) ;
return AVERROR ( EINVAL ) ;
}
if ( esc -> data [ 0 ] ) {
av_log ( avctx , AV_LOG_ERROR , "unexpected data after first packet\n" ) ;
return AVERROR ( EINVAL ) ;
}
if ( is_compr ) {
esc -> fib_acc [ 0 ] = avpkt -> data [ 1 ] + 128 ;
if ( avctx -> channels == 2 ) esc -> fib_acc [ 1 ] = avpkt -> data [ 2 + chan_size + 1 ] + 128 ;
}
esc -> data_idx = 0 ;
esc -> data_size = chan_size ;
if ( ! ( esc -> data [ 0 ] = av_malloc ( chan_size ) ) ) return AVERROR ( ENOMEM ) ;
if ( avctx -> channels == 2 ) {
if ( ! ( esc -> data [ 1 ] = av_malloc ( chan_size ) ) ) {
av_freep ( & esc -> data [ 0 ] ) ;
return AVERROR ( ENOMEM ) ;
}
}
memcpy ( esc -> data [ 0 ] , & avpkt -> data [ hdr_size ] , chan_size ) ;
if ( avctx -> channels == 2 ) memcpy ( esc -> data [ 1 ] , & avpkt -> data [ 2 * hdr_size + chan_size ] , chan_size ) ;
}
if ( ! esc -> data [ 0 ] ) {
av_log ( avctx , AV_LOG_ERROR , "unexpected empty packet\n" ) ;
return AVERROR ( EINVAL ) ;
}
buf_size = FFMIN ( MAX_FRAME_SIZE , esc -> data_size - esc -> data_idx ) ;
if ( buf_size <= 0 ) {
* got_frame_ptr = 0 ;
return avpkt -> size ;
}
frame -> nb_samples = buf_size * ( is_compr + 1 ) ;
if ( ( ret = ff_get_buffer ( avctx , frame ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
for ( ch = 0 ;
ch < avctx -> channels ;
ch ++ ) {
if ( is_compr ) {
delta_decode ( frame -> data [ ch ] , & esc -> data [ ch ] [ esc -> data_idx ] , buf_size , & esc -> fib_acc [ ch ] , esc -> table ) ;
}
else {
raw_decode ( frame -> data [ ch ] , & esc -> data [ ch ] [ esc -> data_idx ] , buf_size ) ;
}
}
esc -> data_idx += buf_size ;
* got_frame_ptr = 1 ;
return avpkt -> size ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void UnblendFree ( StemInfo * h ) {
while ( h != NULL ) {
chunkfree ( h -> u . unblended , sizeof ( real [ 2 ] [ MmMax ] ) ) ;
h -> u . unblended = NULL ;
h = h -> next ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | relpRetVal relpTcpRcv ( relpTcp_t * pThis , relpOctet_t * pRcvBuf , ssize_t * pLenBuf ) {
ENTER_RELPFUNC ;
RELPOBJ_assert ( pThis , Tcp ) ;
# ifdef ENABLE_TLS int r ;
if ( pThis -> bEnableTLS ) {
r = gnutls_record_recv ( pThis -> session , pRcvBuf , * pLenBuf ) ;
if ( r == GNUTLS_E_INTERRUPTED || r == GNUTLS_E_AGAIN ) {
pThis -> pEngine -> dbgprint ( "librelp: gnutls_record_recv must be retried\n" ) ;
pThis -> rtryOp = relpTCP_RETRY_recv ;
}
else {
if ( r < 0 ) chkGnutlsCode ( pThis , "TLS record reception failed" , RELP_RET_IO_ERR , r ) ;
pThis -> rtryOp = relpTCP_RETRY_none ;
}
* pLenBuf = ( r < 0 ) ? - 1 : r ;
}
else {
# endif * pLenBuf = recv ( pThis -> sock , pRcvBuf , * pLenBuf , MSG_DONTWAIT ) ;
pThis -> pEngine -> dbgprint ( "relpTcpRcv: read %zd bytes from sock %d\n" , * pLenBuf , pThis -> sock ) ;
# ifdef ENABLE_TLS }
# endif LEAVE_RELPFUNC ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static cmsBool Type_ColorantTable_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {
cmsNAMEDCOLORLIST * NamedColorList = ( cmsNAMEDCOLORLIST * ) Ptr ;
int i , nColors ;
nColors = cmsNamedColorCount ( NamedColorList ) ;
if ( ! _cmsWriteUInt32Number ( io , nColors ) ) return FALSE ;
for ( i = 0 ;
i < nColors ;
i ++ ) {
char root [ 33 ] ;
cmsUInt16Number PCS [ 3 ] ;
if ( ! cmsNamedColorInfo ( NamedColorList , i , root , NULL , NULL , PCS , NULL ) ) return 0 ;
root [ 32 ] = 0 ;
if ( ! io -> Write ( io , 32 , root ) ) return FALSE ;
if ( ! _cmsWriteUInt16Array ( io , 3 , PCS ) ) return FALSE ;
}
return TRUE ;
cmsUNUSED_PARAMETER ( nItems ) ;
cmsUNUSED_PARAMETER ( self ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int32 get_typavgwidth ( Oid typid , int32 typmod ) {
int typlen = get_typlen ( typid ) ;
int32 maxwidth ;
if ( typlen > 0 ) return typlen ;
maxwidth = type_maximum_size ( typid , typmod ) ;
if ( maxwidth > 0 ) {
if ( typid == BPCHAROID ) return maxwidth ;
if ( maxwidth <= 32 ) return maxwidth ;
if ( maxwidth < 1000 ) return 32 + ( maxwidth - 32 ) / 2 ;
return 32 + ( 1000 - 32 ) / 2 ;
}
return 32 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | bool mysql_show_grants ( THD * thd , LEX_USER * lex_user ) {
ulong want_access ;
uint counter , index ;
int error = 0 ;
ACL_USER * acl_user ;
ACL_DB * acl_db ;
char buff [ 1024 ] ;
Protocol * protocol = thd -> protocol ;
DBUG_ENTER ( "mysql_show_grants" ) ;
LINT_INIT ( acl_user ) ;
if ( ! initialized ) {
my_error ( ER_OPTION_PREVENTS_STATEMENT , MYF ( 0 ) , "--skip-grant-tables" ) ;
DBUG_RETURN ( TRUE ) ;
}
rw_rdlock ( & LOCK_grant ) ;
VOID ( pthread_mutex_lock ( & acl_cache -> lock ) ) ;
acl_user = find_acl_user ( lex_user -> host . str , lex_user -> user . str , TRUE ) ;
if ( ! acl_user ) {
VOID ( pthread_mutex_unlock ( & acl_cache -> lock ) ) ;
rw_unlock ( & LOCK_grant ) ;
my_error ( ER_NONEXISTING_GRANT , MYF ( 0 ) , lex_user -> user . str , lex_user -> host . str ) ;
DBUG_RETURN ( TRUE ) ;
}
Item_string * field = new Item_string ( "" , 0 , & my_charset_latin1 ) ;
List < Item > field_list ;
field -> name = buff ;
field -> max_length = 1024 ;
strxmov ( buff , "Grants for " , lex_user -> user . str , "@" , lex_user -> host . str , NullS ) ;
field_list . push_back ( field ) ;
if ( protocol -> send_fields ( & field_list , Protocol : : SEND_NUM_ROWS | Protocol : : SEND_EOF ) ) {
VOID ( pthread_mutex_unlock ( & acl_cache -> lock ) ) ;
rw_unlock ( & LOCK_grant ) ;
DBUG_RETURN ( TRUE ) ;
}
{
String global ( buff , sizeof ( buff ) , system_charset_info ) ;
global . length ( 0 ) ;
global . append ( STRING_WITH_LEN ( "GRANT " ) ) ;
want_access = acl_user -> access ;
if ( test_all_bits ( want_access , ( GLOBAL_ACLS & ~ GRANT_ACL ) ) ) global . append ( STRING_WITH_LEN ( "ALL PRIVILEGES" ) ) ;
else if ( ! ( want_access & ~ GRANT_ACL ) ) global . append ( STRING_WITH_LEN ( "USAGE" ) ) ;
else {
bool found = 0 ;
ulong j , test_access = want_access & ~ GRANT_ACL ;
for ( counter = 0 , j = SELECT_ACL ;
j <= GLOBAL_ACLS ;
counter ++ , j <<= 1 ) {
if ( test_access & j ) {
if ( found ) global . append ( STRING_WITH_LEN ( ", " ) ) ;
found = 1 ;
global . append ( command_array [ counter ] , command_lengths [ counter ] ) ;
}
}
}
global . append ( STRING_WITH_LEN ( " ON *.* TO '" ) ) ;
global . append ( lex_user -> user . str , lex_user -> user . length , system_charset_info ) ;
global . append ( STRING_WITH_LEN ( "'@'" ) ) ;
global . append ( lex_user -> host . str , lex_user -> host . length , system_charset_info ) ;
global . append ( '\'' ) ;
if ( acl_user -> salt_len ) {
global . append ( STRING_WITH_LEN ( " IDENTIFIED BY PASSWORD" ) ) ;
if ( ( thd -> security_ctx -> master_access & SUPER_ACL ) == SUPER_ACL ) {
char passwd_buff [ SCRAMBLED_PASSWORD_CHAR_LENGTH + 1 ] ;
if ( acl_user -> salt_len == SCRAMBLE_LENGTH ) make_password_from_salt ( passwd_buff , acl_user -> salt ) ;
else make_password_from_salt_323 ( passwd_buff , ( ulong * ) acl_user -> salt ) ;
global . append ( " \'" ) ;
global . append ( passwd_buff ) ;
global . append ( '\'' ) ;
}
else global . append ( " <secret>" ) ;
}
if ( acl_user -> ssl_type == SSL_TYPE_ANY ) global . append ( STRING_WITH_LEN ( " REQUIRE SSL" ) ) ;
else if ( acl_user -> ssl_type == SSL_TYPE_X509 ) global . append ( STRING_WITH_LEN ( " REQUIRE X509" ) ) ;
else if ( acl_user -> ssl_type == SSL_TYPE_SPECIFIED ) {
int ssl_options = 0 ;
global . append ( STRING_WITH_LEN ( " REQUIRE " ) ) ;
if ( acl_user -> x509_issuer ) {
ssl_options ++ ;
global . append ( STRING_WITH_LEN ( "ISSUER \'" ) ) ;
global . append ( acl_user -> x509_issuer , strlen ( acl_user -> x509_issuer ) ) ;
global . append ( '\'' ) ;
}
if ( acl_user -> x509_subject ) {
if ( ssl_options ++ ) global . append ( ' ' ) ;
global . append ( STRING_WITH_LEN ( "SUBJECT \'" ) ) ;
global . append ( acl_user -> x509_subject , strlen ( acl_user -> x509_subject ) , system_charset_info ) ;
global . append ( '\'' ) ;
}
if ( acl_user -> ssl_cipher ) {
if ( ssl_options ++ ) global . append ( ' ' ) ;
global . append ( STRING_WITH_LEN ( "CIPHER '" ) ) ;
global . append ( acl_user -> ssl_cipher , strlen ( acl_user -> ssl_cipher ) , system_charset_info ) ;
global . append ( '\'' ) ;
}
}
if ( ( want_access & GRANT_ACL ) || ( acl_user -> user_resource . questions || acl_user -> user_resource . updates || acl_user -> user_resource . conn_per_hour || acl_user -> user_resource . user_conn ) ) {
global . append ( STRING_WITH_LEN ( " WITH" ) ) ;
if ( want_access & GRANT_ACL ) global . append ( STRING_WITH_LEN ( " GRANT OPTION" ) ) ;
add_user_option ( & global , acl_user -> user_resource . questions , "MAX_QUERIES_PER_HOUR" ) ;
add_user_option ( & global , acl_user -> user_resource . updates , "MAX_UPDATES_PER_HOUR" ) ;
add_user_option ( & global , acl_user -> user_resource . conn_per_hour , "MAX_CONNECTIONS_PER_HOUR" ) ;
add_user_option ( & global , acl_user -> user_resource . user_conn , "MAX_USER_CONNECTIONS" ) ;
}
protocol -> prepare_for_resend ( ) ;
protocol -> store ( global . ptr ( ) , global . length ( ) , global . charset ( ) ) ;
if ( protocol -> write ( ) ) {
error = - 1 ;
goto end ;
}
}
for ( counter = 0 ;
counter < acl_dbs . elements ;
counter ++ ) {
const char * user , * host ;
acl_db = dynamic_element ( & acl_dbs , counter , ACL_DB * ) ;
if ( ! ( user = acl_db -> user ) ) user = "" ;
if ( ! ( host = acl_db -> host . hostname ) ) host = "" ;
if ( ! strcmp ( lex_user -> user . str , user ) && ! my_strcasecmp ( system_charset_info , lex_user -> host . str , host ) ) {
want_access = acl_db -> access ;
if ( want_access ) {
String db ( buff , sizeof ( buff ) , system_charset_info ) ;
db . length ( 0 ) ;
db . append ( STRING_WITH_LEN ( "GRANT " ) ) ;
if ( test_all_bits ( want_access , ( DB_ACLS & ~ GRANT_ACL ) ) ) db . append ( STRING_WITH_LEN ( "ALL PRIVILEGES" ) ) ;
else if ( ! ( want_access & ~ GRANT_ACL ) ) db . append ( STRING_WITH_LEN ( "USAGE" ) ) ;
else {
int found = 0 , cnt ;
ulong j , test_access = want_access & ~ GRANT_ACL ;
for ( cnt = 0 , j = SELECT_ACL ;
j <= DB_ACLS ;
cnt ++ , j <<= 1 ) {
if ( test_access & j ) {
if ( found ) db . append ( STRING_WITH_LEN ( ", " ) ) ;
found = 1 ;
db . append ( command_array [ cnt ] , command_lengths [ cnt ] ) ;
}
}
}
db . append ( STRING_WITH_LEN ( " ON " ) ) ;
append_identifier ( thd , & db , acl_db -> db , strlen ( acl_db -> db ) ) ;
db . append ( STRING_WITH_LEN ( ".* TO '" ) ) ;
db . append ( lex_user -> user . str , lex_user -> user . length , system_charset_info ) ;
db . append ( STRING_WITH_LEN ( "'@'" ) ) ;
db . append ( host , strlen ( host ) , system_charset_info ) ;
db . append ( '\'' ) ;
if ( want_access & GRANT_ACL ) db . append ( STRING_WITH_LEN ( " WITH GRANT OPTION" ) ) ;
protocol -> prepare_for_resend ( ) ;
protocol -> store ( db . ptr ( ) , db . length ( ) , db . charset ( ) ) ;
if ( protocol -> write ( ) ) {
error = - 1 ;
goto end ;
}
}
}
}
for ( index = 0 ;
index < column_priv_hash . records ;
index ++ ) {
const char * user , * host ;
GRANT_TABLE * grant_table = ( GRANT_TABLE * ) hash_element ( & column_priv_hash , index ) ;
if ( ! ( user = grant_table -> user ) ) user = "" ;
if ( ! ( host = grant_table -> host . hostname ) ) host = "" ;
if ( ! strcmp ( lex_user -> user . str , user ) && ! my_strcasecmp ( system_charset_info , lex_user -> host . str , host ) ) {
ulong table_access = grant_table -> privs ;
if ( ( table_access | grant_table -> cols ) != 0 ) {
String global ( buff , sizeof ( buff ) , system_charset_info ) ;
ulong test_access = ( table_access | grant_table -> cols ) & ~ GRANT_ACL ;
global . length ( 0 ) ;
global . append ( STRING_WITH_LEN ( "GRANT " ) ) ;
if ( test_all_bits ( table_access , ( TABLE_ACLS & ~ GRANT_ACL ) ) ) global . append ( STRING_WITH_LEN ( "ALL PRIVILEGES" ) ) ;
else if ( ! test_access ) global . append ( STRING_WITH_LEN ( "USAGE" ) ) ;
else {
int found = 0 ;
ulong j ;
for ( counter = 0 , j = SELECT_ACL ;
j <= TABLE_ACLS ;
counter ++ , j <<= 1 ) {
if ( test_access & j ) {
if ( found ) global . append ( STRING_WITH_LEN ( ", " ) ) ;
found = 1 ;
global . append ( command_array [ counter ] , command_lengths [ counter ] ) ;
if ( grant_table -> cols ) {
uint found_col = 0 ;
for ( uint col_index = 0 ;
col_index < grant_table -> hash_columns . records ;
col_index ++ ) {
GRANT_COLUMN * grant_column = ( GRANT_COLUMN * ) hash_element ( & grant_table -> hash_columns , col_index ) ;
if ( grant_column -> rights & j ) {
if ( ! found_col ) {
found_col = 1 ;
if ( table_access & j ) {
global . append ( STRING_WITH_LEN ( ", " ) ) ;
global . append ( command_array [ counter ] , command_lengths [ counter ] ) ;
}
global . append ( STRING_WITH_LEN ( " (" ) ) ;
}
else global . append ( STRING_WITH_LEN ( ", " ) ) ;
global . append ( grant_column -> column , grant_column -> key_length , system_charset_info ) ;
}
}
if ( found_col ) global . append ( ')' ) ;
}
}
}
}
global . append ( STRING_WITH_LEN ( " ON " ) ) ;
append_identifier ( thd , & global , grant_table -> db , strlen ( grant_table -> db ) ) ;
global . append ( '.' ) ;
append_identifier ( thd , & global , grant_table -> tname , strlen ( grant_table -> tname ) ) ;
global . append ( STRING_WITH_LEN ( " TO '" ) ) ;
global . append ( lex_user -> user . str , lex_user -> user . length , system_charset_info ) ;
global . append ( STRING_WITH_LEN ( "'@'" ) ) ;
global . append ( host , strlen ( host ) , system_charset_info ) ;
global . append ( '\'' ) ;
if ( table_access & GRANT_ACL ) global . append ( STRING_WITH_LEN ( " WITH GRANT OPTION" ) ) ;
protocol -> prepare_for_resend ( ) ;
protocol -> store ( global . ptr ( ) , global . length ( ) , global . charset ( ) ) ;
if ( protocol -> write ( ) ) {
error = - 1 ;
break ;
}
}
}
}
if ( show_routine_grants ( thd , lex_user , & proc_priv_hash , STRING_WITH_LEN ( "PROCEDURE" ) , buff , sizeof ( buff ) ) ) {
error = - 1 ;
goto end ;
}
if ( show_routine_grants ( thd , lex_user , & func_priv_hash , STRING_WITH_LEN ( "FUNCTION" ) , buff , sizeof ( buff ) ) ) {
error = - 1 ;
goto end ;
}
end : VOID ( pthread_mutex_unlock ( & acl_cache -> lock ) ) ;
rw_unlock ( & LOCK_grant ) ;
my_eof ( thd ) ;
DBUG_RETURN ( error ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void make_key_64 ( u_char * string , u_char * key ) {
int i , seed = 0 ;
for ( i = 0 ;
string [ i ] ;
i ++ ) {
seed ^= ( string [ i ] << ( ( i & 0x03 ) * 8 ) ) ;
}
for ( i = 0 ;
i < 5 * 4 ;
i ++ ) {
seed *= 0x000343fd ;
seed += 0x00269ec3 ;
key [ i ] = seed >> 16 ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ctl_putdata ( const char * dp , unsigned int dlen , int bin ) {
int overhead ;
unsigned int currentlen ;
overhead = 0 ;
if ( ! bin ) {
datanotbinflag = TRUE ;
overhead = 3 ;
if ( datasent ) {
* datapt ++ = ',' ;
datalinelen ++ ;
if ( ( dlen + datalinelen + 1 ) >= MAXDATALINELEN ) {
* datapt ++ = '\r' ;
* datapt ++ = '\n' ;
datalinelen = 0 ;
}
else {
* datapt ++ = ' ' ;
datalinelen ++ ;
}
}
}
while ( dlen + overhead + datapt > dataend ) {
currentlen = MIN ( dlen , ( unsigned int ) ( dataend - datapt ) ) ;
memcpy ( datapt , dp , currentlen ) ;
datapt += currentlen ;
dp += currentlen ;
dlen -= currentlen ;
datalinelen += currentlen ;
ctl_flushpkt ( CTL_MORE ) ;
}
memcpy ( datapt , dp , dlen ) ;
datapt += dlen ;
datalinelen += dlen ;
datasent = TRUE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | 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 ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TSReturnCode sdk_sanity_check_http_parser ( TSHttpParser parser ) {
if ( parser == nullptr ) {
return TS_ERROR ;
}
return TS_SUCCESS ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static unsigned int hb_ucdn_decompose_compatibility ( hb_unicode_funcs_t * ufuncs , hb_codepoint_t u , hb_codepoint_t * decomposed , void * user_data HB_UNUSED ) {
return ucdn_compat_decompose ( u , decomposed ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PHP_FUNCTION ( locale_get_keywords ) {
UEnumeration * e = NULL ;
UErrorCode status = U_ZERO_ERROR ;
const char * kw_key = NULL ;
int32_t kw_key_len = 0 ;
const char * loc_name = NULL ;
int loc_name_len = 0 ;
char * kw_value = NULL ;
int32_t kw_value_len = 100 ;
intl_error_reset ( NULL TSRMLS_CC ) ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , "s" , & loc_name , & loc_name_len ) == FAILURE ) {
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR , "locale_get_keywords: unable to parse input params" , 0 TSRMLS_CC ) ;
RETURN_FALSE ;
}
if ( loc_name_len == 0 ) {
loc_name = intl_locale_get_default ( TSRMLS_C ) ;
}
e = uloc_openKeywords ( loc_name , & status ) ;
if ( e != NULL ) {
array_init ( return_value ) ;
while ( ( kw_key = uenum_next ( e , & kw_key_len , & status ) ) != NULL ) {
kw_value = ecalloc ( 1 , kw_value_len ) ;
kw_value_len = uloc_getKeywordValue ( loc_name , kw_key , kw_value , kw_value_len , & status ) ;
if ( status == U_BUFFER_OVERFLOW_ERROR ) {
status = U_ZERO_ERROR ;
kw_value = erealloc ( kw_value , kw_value_len + 1 ) ;
kw_value_len = uloc_getKeywordValue ( loc_name , kw_key , kw_value , kw_value_len + 1 , & status ) ;
}
else if ( ! U_FAILURE ( status ) ) {
kw_value = erealloc ( kw_value , kw_value_len + 1 ) ;
}
if ( U_FAILURE ( status ) ) {
intl_error_set ( NULL , U_ILLEGAL_ARGUMENT_ERROR , "locale_get_keywords: Error encountered while getting the keyword value for the keyword" , 0 TSRMLS_CC ) ;
if ( kw_value ) {
efree ( kw_value ) ;
}
zval_dtor ( return_value ) ;
RETURN_FALSE ;
}
add_assoc_stringl ( return_value , ( char * ) kw_key , kw_value , kw_value_len , 0 ) ;
}
}
uenum_close ( e ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_pvfs2_lookup_path_response ( tvbuff_t * tvb , proto_tree * tree , int offset , packet_info * pinfo ) {
guint32 nCount = 0 ;
guint32 handle_count = 0 ;
guint32 attr_count = 0 ;
proto_tree * attr_tree ;
offset += 4 ;
handle_count = tvb_get_letohl ( tvb , offset ) ;
proto_tree_add_item ( tree , hf_pvfs_lookup_path_response_handle_count , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;
offset += 4 ;
for ( nCount = 0 ;
nCount < handle_count ;
nCount ++ ) offset = dissect_pvfs_fh ( tvb , offset , pinfo , tree , "handle" , NULL ) ;
offset += 4 ;
attr_count = tvb_get_letohl ( tvb , offset ) ;
attr_tree = proto_tree_add_subtree_format ( tree , tvb , offset , 4 , ett_pvfs_attr , NULL , "Attribute array (total items: %d)" , attr_count ) ;
offset += 4 ;
for ( nCount = 0 ;
nCount < attr_count ;
nCount ++ ) offset = dissect_pvfs_object_attr ( tvb , attr_tree , offset , pinfo ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int fz_colorspace_is_device_gray ( fz_context * ctx , const fz_colorspace * cs ) {
return fz_colorspace_is_device ( ctx , cs ) && fz_colorspace_is_gray ( ctx , cs ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void process_dl_debug ( const char * dl_debug ) {
static const struct {
unsigned char len ;
const char name [ 10 ] ;
const char helptext [ 41 ] ;
unsigned short int mask ;
}
debopts [ ] = {
# define LEN_AND_STR ( str ) sizeof ( str ) - 1 , str {
LEN_AND_STR ( "libs" ) , "display library search paths" , DL_DEBUG_LIBS | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "reloc" ) , "display relocation processing" , DL_DEBUG_RELOC | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "files" ) , "display progress for input file" , DL_DEBUG_FILES | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "symbols" ) , "display symbol table processing" , DL_DEBUG_SYMBOLS | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "bindings" ) , "display information about symbol binding" , DL_DEBUG_BINDINGS | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "versions" ) , "display version dependencies" , DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS }
, {
LEN_AND_STR ( "scopes" ) , "display scope information" , DL_DEBUG_SCOPES }
, {
LEN_AND_STR ( "all" ) , "all previous options combined" , DL_DEBUG_LIBS | DL_DEBUG_RELOC | DL_DEBUG_FILES | DL_DEBUG_SYMBOLS | DL_DEBUG_BINDINGS | DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS | DL_DEBUG_SCOPES }
, {
LEN_AND_STR ( "statistics" ) , "display relocation statistics" , DL_DEBUG_STATISTICS }
, {
LEN_AND_STR ( "unused" ) , "determined unused DSOs" , DL_DEBUG_UNUSED }
, {
LEN_AND_STR ( "help" ) , "display this help message and exit" , DL_DEBUG_HELP }
, }
;
# define ndebopts ( sizeof ( debopts ) / sizeof ( debopts [ 0 ] ) ) while ( * dl_debug != '\0' ) {
if ( * dl_debug != ' ' && * dl_debug != ',' && * dl_debug != ':' ) {
size_t cnt ;
size_t len = 1 ;
while ( dl_debug [ len ] != '\0' && dl_debug [ len ] != ' ' && dl_debug [ len ] != ',' && dl_debug [ len ] != ':' ) ++ len ;
for ( cnt = 0 ;
cnt < ndebopts ;
++ cnt ) if ( debopts [ cnt ] . len == len && memcmp ( dl_debug , debopts [ cnt ] . name , len ) == 0 ) {
GLRO ( dl_debug_mask ) |= debopts [ cnt ] . mask ;
any_debug = 1 ;
break ;
}
if ( cnt == ndebopts ) {
char * copy = strndupa ( dl_debug , len ) ;
_dl_error_printf ( "\ warning: debug option `%s' unknown;
try LD_DEBUG=help\n" , copy ) ;
}
dl_debug += len ;
continue ;
}
++ dl_debug ;
}
if ( GLRO ( dl_debug_mask ) & DL_DEBUG_UNUSED ) {
GLRO ( dl_lazy ) = 0 ;
}
if ( GLRO ( dl_debug_mask ) & DL_DEBUG_HELP ) {
size_t cnt ;
_dl_printf ( "\ Valid options for the LD_DEBUG environment variable are:\n\n" ) ;
for ( cnt = 0 ;
cnt < ndebopts ;
++ cnt ) _dl_printf ( " %.*s%s%s\n" , debopts [ cnt ] . len , debopts [ cnt ] . name , " " + debopts [ cnt ] . len - 3 , debopts [ cnt ] . helptext ) ;
_dl_printf ( "\n\ To direct the debugging output into a file instead of standard output\n\ a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n" ) ;
_exit ( 0 ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | inline void SetDeviceCapabilityState ( GLenum cap , bool enable ) {
switch ( cap ) {
case GL_BLEND : if ( enable_flags . cached_blend == enable && ! ignore_cached_state ) return ;
enable_flags . cached_blend = enable ;
break ;
case GL_CULL_FACE : if ( enable_flags . cached_cull_face == enable && ! ignore_cached_state ) return ;
enable_flags . cached_cull_face = enable ;
break ;
case GL_DEPTH_TEST : if ( enable_flags . cached_depth_test == enable && ! ignore_cached_state ) return ;
enable_flags . cached_depth_test = enable ;
break ;
case GL_DITHER : if ( enable_flags . cached_dither == enable && ! ignore_cached_state ) return ;
enable_flags . cached_dither = enable ;
break ;
case GL_POLYGON_OFFSET_FILL : if ( enable_flags . cached_polygon_offset_fill == enable && ! ignore_cached_state ) return ;
enable_flags . cached_polygon_offset_fill = enable ;
break ;
case GL_SAMPLE_ALPHA_TO_COVERAGE : if ( enable_flags . cached_sample_alpha_to_coverage == enable && ! ignore_cached_state ) return ;
enable_flags . cached_sample_alpha_to_coverage = enable ;
break ;
case GL_SAMPLE_COVERAGE : if ( enable_flags . cached_sample_coverage == enable && ! ignore_cached_state ) return ;
enable_flags . cached_sample_coverage = enable ;
break ;
case GL_SCISSOR_TEST : if ( enable_flags . cached_scissor_test == enable && ! ignore_cached_state ) return ;
enable_flags . cached_scissor_test = enable ;
break ;
case GL_STENCIL_TEST : if ( enable_flags . cached_stencil_test == enable && ! ignore_cached_state ) return ;
enable_flags . cached_stencil_test = enable ;
break ;
case GL_RASTERIZER_DISCARD : if ( enable_flags . cached_rasterizer_discard == enable && ! ignore_cached_state ) return ;
enable_flags . cached_rasterizer_discard = enable ;
break ;
case GL_PRIMITIVE_RESTART_FIXED_INDEX : if ( enable_flags . cached_primitive_restart_fixed_index == enable && ! ignore_cached_state ) return ;
enable_flags . cached_primitive_restart_fixed_index = enable ;
break ;
case GL_MULTISAMPLE_EXT : if ( enable_flags . cached_multisample_ext == enable && ! ignore_cached_state ) return ;
enable_flags . cached_multisample_ext = enable ;
break ;
case GL_SAMPLE_ALPHA_TO_ONE_EXT : if ( enable_flags . cached_sample_alpha_to_one_ext == enable && ! ignore_cached_state ) return ;
enable_flags . cached_sample_alpha_to_one_ext = enable ;
break ;
default : NOTREACHED ( ) ;
return ;
}
if ( enable ) glEnable ( cap ) ;
else glDisable ( cap ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void parse_content_disposition ( struct attachment_istream * astream , const struct message_header_line * hdr ) {
i_free ( astream -> part . content_disposition ) ;
astream -> part . content_disposition = i_strndup ( hdr -> full_value , hdr -> full_value_len ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TSReturnCode TSAIOThreadNumSet ( int thread_num ) {
# if AIO_MODE == AIO_MODE_NATIVE ( void ) thread_num ;
return TS_SUCCESS ;
# else if ( ink_aio_thread_num_set ( thread_num ) ) {
return TS_SUCCESS ;
}
return TS_ERROR ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void * Type_Signature_Read ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsUInt32Number * nItems , cmsUInt32Number SizeOfTag ) {
cmsSignature * SigPtr = ( cmsSignature * ) _cmsMalloc ( self -> ContextID , sizeof ( cmsSignature ) ) ;
if ( SigPtr == NULL ) return NULL ;
if ( ! _cmsReadUInt32Number ( io , SigPtr ) ) return NULL ;
* nItems = 1 ;
return SigPtr ;
cmsUNUSED_PARAMETER ( SizeOfTag ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug1115 ( ) {
MYSQL_STMT * stmt ;
int rc ;
MYSQL_BIND my_bind [ 1 ] ;
ulong length [ 1 ] ;
char szData [ 11 ] ;
char query [ MAX_TEST_QUERY_LENGTH ] ;
myheader ( "test_bug1115" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_select" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_select(\ session_id char(9) NOT NULL, \ a int(8) unsigned NOT NULL, \ b int(5) NOT NULL, \ c int(5) NOT NULL, \ d datetime NOT NULL)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_select VALUES " "(\"abc\", 1, 2, 3, 2003-08-30), " "(\"abd\", 1, 2, 3, 2003-08-30), " "(\"abf\", 1, 2, 3, 2003-08-30), " "(\"abg\", 1, 2, 3, 2003-08-30), " "(\"abh\", 1, 2, 3, 2003-08-30), " "(\"abj\", 1, 2, 3, 2003-08-30), " "(\"abk\", 1, 2, 3, 2003-08-30), " "(\"abl\", 1, 2, 3, 2003-08-30), " "(\"abq\", 1, 2, 3, 2003-08-30) " ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "INSERT INTO test_select VALUES " "(\"abw\", 1, 2, 3, 2003-08-30), " "(\"abe\", 1, 2, 3, 2003-08-30), " "(\"abr\", 1, 2, 3, 2003-08-30), " "(\"abt\", 1, 2, 3, 2003-08-30), " "(\"aby\", 1, 2, 3, 2003-08-30), " "(\"abu\", 1, 2, 3, 2003-08-30), " "(\"abi\", 1, 2, 3, 2003-08-30), " "(\"abo\", 1, 2, 3, 2003-08-30), " "(\"abp\", 1, 2, 3, 2003-08-30), " "(\"abz\", 1, 2, 3, 2003-08-30), " "(\"abx\", 1, 2, 3, 2003-08-30)" ) ;
myquery ( rc ) ;
strmov ( query , "SELECT * FROM test_select WHERE " "CONVERT(session_id USING utf8)= ?" ) ;
stmt = mysql_simple_prepare ( mysql , query ) ;
check_stmt ( stmt ) ;
verify_param_count ( stmt , 1 ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
strmov ( szData , ( char * ) "abc" ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
my_bind [ 0 ] . buffer = ( void * ) szData ;
my_bind [ 0 ] . buffer_length = 10 ;
my_bind [ 0 ] . length = & length [ 0 ] ;
length [ 0 ] = 3 ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = my_process_stmt_result ( stmt ) ;
DIE_UNLESS ( rc == 1 ) ;
strmov ( szData , ( char * ) "venu" ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
my_bind [ 0 ] . buffer = ( void * ) szData ;
my_bind [ 0 ] . buffer_length = 10 ;
my_bind [ 0 ] . length = & length [ 0 ] ;
length [ 0 ] = 4 ;
my_bind [ 0 ] . is_null = 0 ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = my_process_stmt_result ( stmt ) ;
DIE_UNLESS ( rc == 0 ) ;
strmov ( szData , ( char * ) "abc" ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
my_bind [ 0 ] . buffer = ( void * ) szData ;
my_bind [ 0 ] . buffer_length = 10 ;
my_bind [ 0 ] . length = & length [ 0 ] ;
length [ 0 ] = 3 ;
my_bind [ 0 ] . is_null = 0 ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = my_process_stmt_result ( stmt ) ;
DIE_UNLESS ( rc == 1 ) ;
mysql_stmt_close ( stmt ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int imc_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
AVFrame * frame = data ;
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
int ret , i ;
IMCContext * q = avctx -> priv_data ;
LOCAL_ALIGNED_16 ( uint16_t , buf16 , [ IMC_BLOCK_SIZE / 2 ] ) ;
if ( buf_size < IMC_BLOCK_SIZE * avctx -> channels ) {
av_log ( avctx , AV_LOG_ERROR , "frame too small!\n" ) ;
return AVERROR_INVALIDDATA ;
}
frame -> nb_samples = COEFFS ;
if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
for ( i = 0 ;
i < avctx -> channels ;
i ++ ) {
q -> out_samples = ( float * ) frame -> extended_data [ i ] ;
q -> dsp . bswap16_buf ( buf16 , ( const uint16_t * ) buf , IMC_BLOCK_SIZE / 2 ) ;
init_get_bits ( & q -> gb , ( const uint8_t * ) buf16 , IMC_BLOCK_SIZE * 8 ) ;
buf += IMC_BLOCK_SIZE ;
if ( ( ret = imc_decode_block ( avctx , q , i ) ) < 0 ) return ret ;
}
if ( avctx -> channels == 2 ) {
q -> fdsp . butterflies_float ( ( float * ) frame -> extended_data [ 0 ] , ( float * ) frame -> extended_data [ 1 ] , COEFFS ) ;
}
* got_frame_ptr = 1 ;
return IMC_BLOCK_SIZE * avctx -> channels ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cpu_devinit ( const char * cpu_model , unsigned int id , uint64_t prom_addr , qemu_irq * * cpu_irqs ) {
CPUState * cs ;
SPARCCPU * cpu ;
CPUSPARCState * env ;
cpu = cpu_sparc_init ( cpu_model ) ;
if ( cpu == NULL ) {
fprintf ( stderr , "qemu: Unable to find Sparc CPU definition\n" ) ;
exit ( 1 ) ;
}
env = & cpu -> env ;
cpu_sparc_set_id ( env , id ) ;
if ( id == 0 ) {
qemu_register_reset ( main_cpu_reset , cpu ) ;
}
else {
qemu_register_reset ( secondary_cpu_reset , cpu ) ;
cs = CPU ( cpu ) ;
cs -> halted = 1 ;
}
* cpu_irqs = qemu_allocate_irqs ( cpu_set_irq , cpu , MAX_PILS ) ;
env -> prom_addr = prom_addr ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_wl4166_3 ( ) {
int rc ;
MYSQL_STMT * stmt ;
MYSQL_BIND my_bind [ 1 ] ;
MYSQL_TIME tm [ 1 ] ;
myheader ( "test_wl4166_3" ) ;
rc = mysql_query ( mysql , "drop table if exists t1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "create table t1 (year datetime)" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "insert into t1 (year) values (?)" ) ;
check_stmt ( stmt ) ;
verify_param_count ( stmt , 1 ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_DATETIME ;
my_bind [ 0 ] . buffer = & tm [ 0 ] ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
tm [ 0 ] . year = 10000 ;
tm [ 0 ] . month = 1 ;
tm [ 0 ] . day = 1 ;
tm [ 0 ] . hour = 1 ;
tm [ 0 ] . minute = 1 ;
tm [ 0 ] . second = 1 ;
tm [ 0 ] . second_part = 0 ;
tm [ 0 ] . neg = 0 ;
rc = mysql_query ( mysql , "alter table t1 add column c int" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
my_process_warnings ( mysql , 1 ) ;
verify_col_data ( "t1" , "year" , "0000-00-00 00:00:00" ) ;
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "drop table t1" ) ;
myquery ( rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void xps_parse_poly_quadratic_bezier_segment ( fz_context * doc , fz_path * path , fz_xml * root , int stroking , int * skipped_stroke ) {
char * points_att = fz_xml_att ( root , "Points" ) ;
char * is_stroked_att = fz_xml_att ( root , "IsStroked" ) ;
float x [ 2 ] , y [ 2 ] ;
int is_stroked ;
fz_point pt ;
char * s ;
int n ;
if ( ! points_att ) {
fz_warn ( doc , "PolyQuadraticBezierSegment element has no points" ) ;
return ;
}
is_stroked = 1 ;
if ( is_stroked_att && ! strcmp ( is_stroked_att , "false" ) ) is_stroked = 0 ;
if ( ! is_stroked ) * skipped_stroke = 1 ;
s = points_att ;
n = 0 ;
while ( * s != 0 ) {
while ( * s == ' ' ) s ++ ;
s = xps_parse_point ( s , & x [ n ] , & y [ n ] ) ;
n ++ ;
if ( n == 2 ) {
if ( stroking && ! is_stroked ) {
fz_moveto ( doc , path , x [ 1 ] , y [ 1 ] ) ;
}
else {
pt = fz_currentpoint ( doc , path ) ;
fz_curveto ( doc , path , ( pt . x + 2 * x [ 0 ] ) / 3 , ( pt . y + 2 * y [ 0 ] ) / 3 , ( x [ 1 ] + 2 * x [ 0 ] ) / 3 , ( y [ 1 ] + 2 * y [ 0 ] ) / 3 , x [ 1 ] , y [ 1 ] ) ;
}
n = 0 ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void write_codebooks ( RoqContext * enc , RoqTempdata * tempData ) {
int i , j ;
uint8_t * * outp = & enc -> out_buf ;
if ( tempData -> numCB2 ) {
bytestream_put_le16 ( outp , RoQ_QUAD_CODEBOOK ) ;
bytestream_put_le32 ( outp , tempData -> numCB2 * 6 + tempData -> numCB4 * 4 ) ;
bytestream_put_byte ( outp , tempData -> numCB4 ) ;
bytestream_put_byte ( outp , tempData -> numCB2 ) ;
for ( i = 0 ;
i < tempData -> numCB2 ;
i ++ ) {
bytestream_put_buffer ( outp , enc -> cb2x2 [ tempData -> f2i2 [ i ] ] . y , 4 ) ;
bytestream_put_byte ( outp , enc -> cb2x2 [ tempData -> f2i2 [ i ] ] . u ) ;
bytestream_put_byte ( outp , enc -> cb2x2 [ tempData -> f2i2 [ i ] ] . v ) ;
}
for ( i = 0 ;
i < tempData -> numCB4 ;
i ++ ) for ( j = 0 ;
j < 4 ;
j ++ ) bytestream_put_byte ( outp , tempData -> i2f2 [ enc -> cb4x4 [ tempData -> f2i4 [ i ] ] . idx [ j ] ] ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int releaseintf ( struct usb_dev_state * ps , unsigned int ifnum ) {
struct usb_device * dev ;
struct usb_interface * intf ;
int err ;
err = - EINVAL ;
if ( ifnum >= 8 * sizeof ( ps -> ifclaimed ) ) return err ;
dev = ps -> dev ;
intf = usb_ifnum_to_if ( dev , ifnum ) ;
if ( ! intf ) err = - ENOENT ;
else if ( test_and_clear_bit ( ifnum , & ps -> ifclaimed ) ) {
usb_driver_release_interface ( & usbfs_driver , intf ) ;
err = 0 ;
}
return err ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void TSContDestroy ( TSCont contp ) {
sdk_assert ( sdk_sanity_check_iocore_structure ( contp ) == TS_SUCCESS ) ;
INKContInternal * i = ( INKContInternal * ) contp ;
i -> destroy ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int wifi_key_prepare ( char * key_string ) {
int status = - E_INVALID ;
char * ks ;
char * p ;
if ( key_string == NULL ) return - E_INVALID ;
ks = strdup ( key_string ) ;
if ( ( p = strchr ( ks , ':' ) ) != NULL ) * p = 0 ;
if ( ! strcasecmp ( ks , "wep" ) ) {
GBL_WIFI -> wifi_schema = WIFI_WEP ;
status = set_wep_key ( p + 1 ) ;
}
if ( ! strcasecmp ( ks , "wpa" ) ) {
GBL_WIFI -> wifi_schema = WIFI_WPA ;
status = set_wpa_key ( p + 1 ) ;
}
SAFE_FREE ( ks ) ;
return status ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void stp_print ( netdissect_options * ndo , const u_char * p , u_int length ) {
const struct stp_bpdu_ * stp_bpdu ;
u_int mstp_len ;
u_int spb_len ;
stp_bpdu = ( const struct stp_bpdu_ * ) p ;
if ( length < 4 ) goto trunc ;
ND_TCHECK ( stp_bpdu -> protocol_id ) ;
if ( EXTRACT_16BITS ( & stp_bpdu -> protocol_id ) ) {
ND_PRINT ( ( ndo , "unknown STP version, length %u" , length ) ) ;
return ;
}
ND_TCHECK ( stp_bpdu -> protocol_version ) ;
ND_PRINT ( ( ndo , "STP %s" , tok2str ( stp_proto_values , "Unknown STP protocol (0x%02x)" , stp_bpdu -> protocol_version ) ) ) ;
switch ( stp_bpdu -> protocol_version ) {
case STP_PROTO_REGULAR : case STP_PROTO_RAPID : case STP_PROTO_MSTP : case STP_PROTO_SPB : break ;
default : return ;
}
ND_TCHECK ( stp_bpdu -> bpdu_type ) ;
ND_PRINT ( ( ndo , ", %s" , tok2str ( stp_bpdu_type_values , "Unknown BPDU Type (0x%02x)" , stp_bpdu -> bpdu_type ) ) ) ;
switch ( stp_bpdu -> bpdu_type ) {
case STP_BPDU_TYPE_CONFIG : if ( length < sizeof ( struct stp_bpdu_ ) - 1 ) {
goto trunc ;
}
if ( ! stp_print_config_bpdu ( ndo , stp_bpdu , length ) ) goto trunc ;
break ;
case STP_BPDU_TYPE_RSTP : if ( stp_bpdu -> protocol_version == STP_PROTO_RAPID ) {
if ( length < sizeof ( struct stp_bpdu_ ) ) {
goto trunc ;
}
if ( ! stp_print_config_bpdu ( ndo , stp_bpdu , length ) ) goto trunc ;
}
else if ( stp_bpdu -> protocol_version == STP_PROTO_MSTP || stp_bpdu -> protocol_version == STP_PROTO_SPB ) {
if ( length < STP_BPDU_MSTP_MIN_LEN ) {
goto trunc ;
}
ND_TCHECK ( stp_bpdu -> v1_length ) ;
if ( stp_bpdu -> v1_length != 0 ) {
goto trunc ;
}
ND_TCHECK_16BITS ( p + MST_BPDU_VER3_LEN_OFFSET ) ;
mstp_len = EXTRACT_16BITS ( p + MST_BPDU_VER3_LEN_OFFSET ) ;
mstp_len += 2 ;
if ( length < ( sizeof ( struct stp_bpdu_ ) + mstp_len ) ) {
goto trunc ;
}
if ( ! stp_print_mstp_bpdu ( ndo , stp_bpdu , length ) ) goto trunc ;
if ( stp_bpdu -> protocol_version == STP_PROTO_SPB ) {
spb_len = EXTRACT_16BITS ( p + MST_BPDU_VER3_LEN_OFFSET + mstp_len ) ;
spb_len += 2 ;
if ( length < ( sizeof ( struct stp_bpdu_ ) + mstp_len + spb_len ) || spb_len < SPB_BPDU_MIN_LEN ) {
goto trunc ;
}
if ( ! stp_print_spb_bpdu ( ndo , stp_bpdu , ( sizeof ( struct stp_bpdu_ ) + mstp_len ) ) ) goto trunc ;
}
}
break ;
case STP_BPDU_TYPE_TOPO_CHANGE : break ;
default : break ;
}
return ;
trunc : ND_PRINT ( ( ndo , "[|stp %d]" , length ) ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | eth_pkt_types_e vmxnet_tx_pkt_get_packet_type ( struct VmxnetTxPkt * pkt ) {
assert ( pkt ) ;
return pkt -> packet_type ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static PyObject * string_lower ( PyStringObject * self ) {
char * s ;
Py_ssize_t i , n = PyString_GET_SIZE ( self ) ;
PyObject * newobj ;
newobj = PyString_FromStringAndSize ( NULL , n ) ;
if ( ! newobj ) return NULL ;
s = PyString_AS_STRING ( newobj ) ;
Py_MEMCPY ( s , PyString_AS_STRING ( self ) , n ) ;
for ( i = 0 ;
i < n ;
i ++ ) {
int c = Py_CHARMASK ( s [ i ] ) ;
if ( isupper ( c ) ) s [ i ] = _tolower ( c ) ;
}
return newobj ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void flush_unauthorized_files ( const struct cred * cred , struct files_struct * files ) {
struct file * file , * devnull = NULL ;
struct tty_struct * tty ;
int drop_tty = 0 ;
unsigned n ;
tty = get_current_tty ( ) ;
if ( tty ) {
spin_lock ( & tty -> files_lock ) ;
if ( ! list_empty ( & tty -> tty_files ) ) {
struct tty_file_private * file_priv ;
file_priv = list_first_entry ( & tty -> tty_files , struct tty_file_private , list ) ;
file = file_priv -> file ;
if ( file_path_has_perm ( cred , file , FILE__READ | FILE__WRITE ) ) drop_tty = 1 ;
}
spin_unlock ( & tty -> files_lock ) ;
tty_kref_put ( tty ) ;
}
if ( drop_tty ) no_tty ( ) ;
n = iterate_fd ( files , 0 , match_file , cred ) ;
if ( ! n ) return ;
devnull = dentry_open ( & selinux_null , O_RDWR , cred ) ;
if ( IS_ERR ( devnull ) ) devnull = NULL ;
do {
replace_fd ( n - 1 , devnull , 0 ) ;
}
while ( ( n = iterate_fd ( files , n , match_file , cred ) ) != 0 ) ;
if ( devnull ) fput ( devnull ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_NonStandardIdentifier ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 947 "../../asn1/h245/h245.cnf" gint32 value ;
nsiOID = "" ;
h221NonStandard = 0 ;
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_NonStandardIdentifier , NonStandardIdentifier_choice , & value ) ;
switch ( value ) {
case 0 : nsp_handle = dissector_get_string_handle ( nsp_object_dissector_table , nsiOID ) ;
break ;
case 1 : nsp_handle = dissector_get_uint_handle ( nsp_h221_dissector_table , h221NonStandard ) ;
break ;
default : nsp_handle = NULL ;
}
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int main ( int argc , char * argv [ ] ) {
const char * globfile [ ] = {
"one" , "two" , "three" , NULL }
;
char tmpdir [ 32 ] ;
struct passwd * pw ;
const char * cwd ;
int test ;
int fail = 0 ;
int i ;
struct test_case_struct ts ;
if ( argc > 1 ) {
command_line_test ( argv [ 1 ] ) ;
return 0 ;
}
cwd = getcwd ( NULL , 0 ) ;
tmpnam ( tmpdir ) ;
if ( mkdir ( tmpdir , S_IRWXU ) || chdir ( tmpdir ) ) return - 1 ;
else {
int fd ;
for ( i = 0 ;
globfile [ i ] ;
++ i ) if ( ( fd = creat ( globfile [ i ] , S_IRUSR | S_IWUSR ) ) == - 1 || close ( fd ) ) return - 1 ;
}
if ( __app_register_atfork ( register_fork , NULL , NULL ) != 0 ) {
printf ( "Failed to register fork handler.\n" ) ;
return - 1 ;
}
for ( test = 0 ;
test_case [ test ] . retval != - 1 ;
test ++ ) if ( testit ( & test_case [ test ] ) ) ++ fail ;
pw = getpwnam ( "root" ) ;
if ( pw != NULL ) {
ts . retval = 0 ;
ts . env = NULL ;
ts . words = "~root " ;
ts . flags = 0 ;
ts . wordc = 1 ;
ts . wordv [ 0 ] = pw -> pw_dir ;
ts . ifs = IFS ;
if ( testit ( & ts ) ) ++ fail ;
ts . retval = 0 ;
ts . env = pw -> pw_dir ;
ts . words = "${
var#~root}
x" ;
ts . flags = 0 ;
ts . wordc = 1 ;
ts . wordv [ 0 ] = "x" ;
ts . ifs = IFS ;
if ( testit ( & ts ) ) ++ fail ;
}
setenv ( "HOME" , "/dummy/home" , 1 ) ;
ts . retval = 0 ;
ts . env = NULL ;
ts . words = "~ ~/foo" ;
ts . flags = 0 ;
ts . wordc = 2 ;
ts . wordv [ 0 ] = "/dummy/home" ;
ts . wordv [ 1 ] = "/dummy/home/foo" ;
ts . ifs = IFS ;
if ( testit ( & ts ) ) ++ fail ;
pw = getpwuid ( getuid ( ) ) ;
if ( pw != NULL ) {
unsetenv ( "HOME" ) ;
ts . retval = 0 ;
ts . env = NULL ;
ts . words = "~" ;
ts . flags = 0 ;
ts . wordc = 1 ;
ts . wordv [ 0 ] = pw -> pw_dir ;
ts . ifs = IFS ;
if ( testit ( & ts ) ) ++ fail ;
}
puts ( "tests completed, now cleaning up" ) ;
for ( i = 0 ;
globfile [ i ] ;
++ i ) remove ( globfile [ i ] ) ;
if ( cwd == NULL ) cwd = ".." ;
chdir ( cwd ) ;
rmdir ( tmpdir ) ;
printf ( "tests failed: %d\n" , fail ) ;
return fail != 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void e1000e_intrmgr_fire_delayed_interrupts ( E1000ECore * core ) {
trace_e1000e_irq_fire_delayed_interrupts ( ) ;
e1000e_set_interrupt_cause ( core , 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( TemplateURLTest , URLRefTestCount ) {
TemplateURLData data ;
data . SetURL ( "http://foo{
searchTerms}
{
count?}
" ) ;
TemplateURL url ( data ) ;
EXPECT_TRUE ( url . url_ref ( ) . IsValid ( search_terms_data_ ) ) ;
ASSERT_TRUE ( url . url_ref ( ) . SupportsReplacement ( search_terms_data_ ) ) ;
GURL result ( url . url_ref ( ) . ReplaceSearchTerms ( TemplateURLRef : : SearchTermsArgs ( ASCIIToUTF16 ( "X" ) ) , search_terms_data_ ) ) ;
ASSERT_TRUE ( result . is_valid ( ) ) ;
EXPECT_EQ ( "http://foox/" , result . spec ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void nb_resp_corrl ( tvbuff_t * tvb , int offset , proto_tree * tree ) {
proto_tree_add_item ( tree , hf_netb_resp_corrl , tvb , offset + NB_RESP_CORL , 2 , ENC_LITTLE_ENDIAN ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static PyObject * checkPassword ( PyObject * self , PyObject * args ) {
const char * user = NULL ;
const char * pswd = NULL ;
const char * service = NULL ;
const char * default_realm = NULL ;
int result = 0 ;
if ( ! PyArg_ParseTuple ( args , "ssss" , & user , & pswd , & service , & default_realm ) ) return NULL ;
result = authenticate_user_krb5pwd ( user , pswd , service , default_realm ) ;
if ( result ) return Py_INCREF ( Py_True ) , Py_True ;
else return NULL ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int virtio_console_init_pci ( PCIDevice * pci_dev ) {
VirtIOPCIProxy * proxy = DO_UPCAST ( VirtIOPCIProxy , pci_dev , pci_dev ) ;
VirtIODevice * vdev ;
if ( proxy -> class_code != PCI_CLASS_COMMUNICATION_OTHER && proxy -> class_code != PCI_CLASS_DISPLAY_OTHER && proxy -> class_code != PCI_CLASS_OTHERS ) proxy -> class_code = PCI_CLASS_COMMUNICATION_OTHER ;
vdev = virtio_console_init ( & pci_dev -> qdev ) ;
if ( ! vdev ) {
return - 1 ;
}
virtio_init_pci ( proxy , vdev , PCI_VENDOR_ID_REDHAT_QUMRANET , PCI_DEVICE_ID_VIRTIO_CONSOLE , proxy -> class_code , 0x00 ) ;
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void * set_bootinfo_tag ( void * addr , uint32_t tag , uint32_t size , void * data ) {
char * pos = addr ;
put_long ( pos , tag ) ;
pos += 4 ;
put_long ( pos , size + 8 ) ;
pos += 4 ;
memcpy ( pos , data , size ) ;
pos += size ;
return pos ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( BrowsingDataRemoverImplTest , RemoveMultipleTypes ) {
RemoveDownloadsTester downloads_tester ( GetBrowserContext ( ) ) ;
EXPECT_CALL ( * downloads_tester . download_manager ( ) , RemoveDownloadsByURLAndTime ( _ , _ , _ ) ) ;
int removal_mask = BrowsingDataRemover : : REMOVE_DOWNLOADS | BrowsingDataRemover : : REMOVE_COOKIES ;
BlockUntilBrowsingDataRemoved ( base : : Time ( ) , base : : Time : : Max ( ) , removal_mask , false ) ;
EXPECT_EQ ( removal_mask , GetRemovalMask ( ) ) ;
EXPECT_EQ ( BrowsingDataHelper : : UNPROTECTED_WEB , GetOriginTypeMask ( ) ) ;
StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData ( ) ;
EXPECT_EQ ( removal_data . remove_mask , StoragePartition : : REMOVE_DATA_MASK_COOKIES ) ;
EXPECT_EQ ( removal_data . quota_storage_remove_mask , StoragePartition : : QUOTA_MANAGED_STORAGE_MASK_ALL ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cmd_channel_add_modify ( const char * data , gboolean add ) {
GHashTable * optlist ;
CHATNET_REC * chatnetrec ;
CHANNEL_SETUP_REC * rec ;
char * botarg , * botcmdarg , * chatnet , * channel , * password ;
void * free_arg ;
if ( ! cmd_get_params ( data , & free_arg , 3 | PARAM_FLAG_OPTIONS , "channel add" , & optlist , & channel , & chatnet , & password ) ) return ;
if ( * chatnet == '\0' || * channel == '\0' ) {
cmd_param_error ( CMDERR_NOT_ENOUGH_PARAMS ) ;
}
chatnetrec = chatnet_find ( chatnet ) ;
if ( chatnetrec == NULL ) {
printformat ( NULL , NULL , MSGLEVEL_CLIENTNOTICE , TXT_UNKNOWN_CHATNET , chatnet ) ;
cmd_params_free ( free_arg ) ;
return ;
}
botarg = g_hash_table_lookup ( optlist , "bots" ) ;
botcmdarg = g_hash_table_lookup ( optlist , "botcmd" ) ;
rec = channel_setup_find ( channel , chatnet ) ;
if ( rec == NULL ) {
if ( add == FALSE ) {
printformat ( NULL , NULL , MSGLEVEL_CLIENTNOTICE , TXT_CHANSETUP_NOT_FOUND , channel , chatnet ) ;
cmd_params_free ( free_arg ) ;
return ;
}
rec = CHAT_PROTOCOL ( chatnetrec ) -> create_channel_setup ( ) ;
rec -> name = g_strdup ( channel ) ;
rec -> chatnet = g_strdup ( chatnet ) ;
}
else {
if ( g_hash_table_lookup ( optlist , "bots" ) ) g_free_and_null ( rec -> botmasks ) ;
if ( g_hash_table_lookup ( optlist , "botcmd" ) ) g_free_and_null ( rec -> autosendcmd ) ;
if ( * password != '\0' ) g_free_and_null ( rec -> password ) ;
}
if ( g_hash_table_lookup ( optlist , "auto" ) ) rec -> autojoin = TRUE ;
if ( g_hash_table_lookup ( optlist , "noauto" ) ) rec -> autojoin = FALSE ;
if ( botarg != NULL && * botarg != '\0' ) rec -> botmasks = g_strdup ( botarg ) ;
if ( botcmdarg != NULL && * botcmdarg != '\0' ) rec -> autosendcmd = g_strdup ( botcmdarg ) ;
if ( * password != '\0' && g_strcmp0 ( password , "-" ) != 0 ) rec -> password = g_strdup ( password ) ;
signal_emit ( "channel add fill" , 2 , rec , optlist ) ;
channel_setup_create ( rec ) ;
printformat ( NULL , NULL , MSGLEVEL_CLIENTNOTICE , TXT_CHANSETUP_ADDED , channel , chatnet ) ;
cmd_params_free ( free_arg ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_rtmpt_body_scm ( tvbuff_t * tvb , gint offset , proto_tree * rtmpt_tree , guint scm ) {
switch ( scm ) {
case RTMPT_TYPE_CHUNK_SIZE : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_chunksize , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
break ;
case RTMPT_TYPE_ABORT_MESSAGE : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_csid , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
break ;
case RTMPT_TYPE_ACKNOWLEDGEMENT : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_seq , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
break ;
case RTMPT_TYPE_UCM : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_ucm_eventtype , tvb , offset , 2 , ENC_BIG_ENDIAN ) ;
break ;
case RTMPT_TYPE_WINDOW : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_was , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
break ;
case RTMPT_TYPE_PEER_BANDWIDTH : proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_was , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( rtmpt_tree , hf_rtmpt_scm_limittype , tvb , offset + 4 , 1 , ENC_BIG_ENDIAN ) ;
break ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void wordchrs ( struct vars * v ) {
struct state * left ;
struct state * right ;
if ( v -> wordchrs != NULL ) {
NEXT ( ) ;
return ;
}
left = newstate ( v -> nfa ) ;
right = newstate ( v -> nfa ) ;
NOERR ( ) ;
lexword ( v ) ;
NEXT ( ) ;
assert ( v -> savenow != NULL && SEE ( '[' ) ) ;
bracket ( v , left , right ) ;
assert ( ( v -> savenow != NULL && SEE ( ']' ) ) || ISERR ( ) ) ;
NEXT ( ) ;
NOERR ( ) ;
v -> wordchrs = left ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void find_enclosing_mount_callback ( GObject * source_object , GAsyncResult * res , gpointer user_data ) {
GMount * mount ;
MountState * state ;
GFile * location , * root ;
state = user_data ;
if ( state -> directory == NULL ) {
mount_state_free ( state ) ;
return ;
}
mount = g_file_find_enclosing_mount_finish ( G_FILE ( source_object ) , res , NULL ) ;
if ( mount ) {
root = g_mount_get_root ( mount ) ;
location = nautilus_file_get_location ( state -> file ) ;
if ( ! g_file_equal ( location , root ) ) {
g_object_unref ( mount ) ;
mount = NULL ;
}
g_object_unref ( root ) ;
g_object_unref ( location ) ;
}
got_mount ( state , mount ) ;
if ( mount ) {
g_object_unref ( mount ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_rsvp_message_id ( proto_tree * ti , proto_tree * rsvp_object_tree , tvbuff_t * tvb , int offset , int obj_length , int rsvp_class _U_ , int type ) {
int offset2 = offset + 4 ;
switch ( type ) {
case 1 : proto_tree_add_uint ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_message_id_flags , tvb , offset + 4 , 1 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_message_id_epoch , tvb , offset + 5 , 3 , ENC_BIG_ENDIAN ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_message_id_message_id , tvb , offset + 8 , 4 , ENC_BIG_ENDIAN ) ;
proto_item_set_text ( ti , "MESSAGE-ID: %d %s" , tvb_get_ntohl ( tvb , offset + 8 ) , tvb_get_guint8 ( tvb , offset + 4 ) & 1 ? "(Ack Desired)" : "" ) ;
break ;
default : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , "Unknown (%u)" , type ) ;
proto_tree_add_item ( rsvp_object_tree , hf_rsvp_message_id_data , tvb , offset2 , obj_length - 4 , ENC_NA ) ;
break ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void cisco_autorp_print ( netdissect_options * ndo , register const u_char * bp , register u_int len ) {
int type ;
int numrps ;
int hold ;
ND_TCHECK ( bp [ 0 ] ) ;
ND_PRINT ( ( ndo , " auto-rp " ) ) ;
type = bp [ 0 ] ;
switch ( type ) {
case 0x11 : ND_PRINT ( ( ndo , "candidate-advert" ) ) ;
break ;
case 0x12 : ND_PRINT ( ( ndo , "mapping" ) ) ;
break ;
default : ND_PRINT ( ( ndo , "type-0x%02x" , type ) ) ;
break ;
}
ND_TCHECK ( bp [ 1 ] ) ;
numrps = bp [ 1 ] ;
ND_TCHECK2 ( bp [ 2 ] , 2 ) ;
ND_PRINT ( ( ndo , " Hold " ) ) ;
hold = EXTRACT_16BITS ( & bp [ 2 ] ) ;
if ( hold ) unsigned_relts_print ( ndo , EXTRACT_16BITS ( & bp [ 2 ] ) ) ;
else ND_PRINT ( ( ndo , "FOREVER" ) ) ;
bp += 8 ;
len -= 8 ;
while ( numrps -- ) {
int nentries ;
char s ;
ND_TCHECK2 ( bp [ 0 ] , 4 ) ;
ND_PRINT ( ( ndo , " RP %s" , ipaddr_string ( ndo , bp ) ) ) ;
ND_TCHECK ( bp [ 4 ] ) ;
switch ( bp [ 4 ] & 0x3 ) {
case 0 : ND_PRINT ( ( ndo , " PIMv?" ) ) ;
break ;
case 1 : ND_PRINT ( ( ndo , " PIMv1" ) ) ;
break ;
case 2 : ND_PRINT ( ( ndo , " PIMv2" ) ) ;
break ;
case 3 : ND_PRINT ( ( ndo , " PIMv1+2" ) ) ;
break ;
}
if ( bp [ 4 ] & 0xfc ) ND_PRINT ( ( ndo , " [rsvd=0x%02x]" , bp [ 4 ] & 0xfc ) ) ;
ND_TCHECK ( bp [ 5 ] ) ;
nentries = bp [ 5 ] ;
bp += 6 ;
len -= 6 ;
s = ' ' ;
for ( ;
nentries ;
nentries -- ) {
ND_TCHECK2 ( bp [ 0 ] , 6 ) ;
ND_PRINT ( ( ndo , "%c%s%s/%d" , s , bp [ 0 ] & 1 ? "!" : "" , ipaddr_string ( ndo , & bp [ 2 ] ) , bp [ 1 ] ) ) ;
if ( bp [ 0 ] & 0x02 ) {
ND_PRINT ( ( ndo , " bidir" ) ) ;
}
if ( bp [ 0 ] & 0xfc ) {
ND_PRINT ( ( ndo , "[rsvd=0x%02x]" , bp [ 0 ] & 0xfc ) ) ;
}
s = ',' ;
bp += 6 ;
len -= 6 ;
}
}
return ;
trunc : ND_PRINT ( ( ndo , "[|autorp]" ) ) ;
return ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static hb_position_t hb_font_get_glyph_h_advance_nil ( hb_font_t * font , void * font_data HB_UNUSED , hb_codepoint_t glyph , void * user_data HB_UNUSED ) {
if ( font -> parent ) return font -> parent_scale_x_distance ( font -> parent -> get_glyph_h_advance ( glyph ) ) ;
return font -> x_scale ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dtap_mm_imsi_det_ind ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
is_uplink = IS_UPLINK_TRUE ;
ELEM_MAND_V ( GSM_A_PDU_TYPE_COMMON , DE_MS_CM_1 , NULL ) ;
ELEM_MAND_LV ( GSM_A_PDU_TYPE_COMMON , DE_MID , NULL ) ;
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_dtap_extraneous_data ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void write_bootloader ( CPUMIPSState * env , uint8_t * base , int64_t kernel_entry ) {
uint32_t * p ;
p = ( uint32_t * ) base ;
stl_raw ( p ++ , 0x0bf00160 ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( base + 0x500 , 0xbfc00580 ) ;
stl_raw ( base + 0x504 , 0xbfc0083c ) ;
stl_raw ( base + 0x520 , 0xbfc00580 ) ;
stl_raw ( base + 0x52c , 0xbfc00800 ) ;
stl_raw ( base + 0x534 , 0xbfc00808 ) ;
stl_raw ( base + 0x538 , 0xbfc00800 ) ;
stl_raw ( base + 0x53c , 0xbfc00800 ) ;
stl_raw ( base + 0x540 , 0xbfc00800 ) ;
stl_raw ( base + 0x544 , 0xbfc00800 ) ;
stl_raw ( base + 0x548 , 0xbfc00800 ) ;
stl_raw ( base + 0x54c , 0xbfc00800 ) ;
stl_raw ( base + 0x550 , 0xbfc00800 ) ;
stl_raw ( base + 0x554 , 0xbfc00800 ) ;
p = ( uint32_t * ) ( base + 0x580 ) ;
stl_raw ( p ++ , 0x24040002 ) ;
stl_raw ( p ++ , 0x3c1d0000 | ( ( ( ENVP_ADDR - 64 ) >> 16 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x37bd0000 | ( ( ENVP_ADDR - 64 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x3c050000 | ( ( ENVP_ADDR >> 16 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x34a50000 | ( ENVP_ADDR & 0xffff ) ) ;
stl_raw ( p ++ , 0x3c060000 | ( ( ( ENVP_ADDR + 8 ) >> 16 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x34c60000 | ( ( ENVP_ADDR + 8 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x3c070000 | ( loaderparams . ram_size >> 16 ) ) ;
stl_raw ( p ++ , 0x34e70000 | ( loaderparams . ram_size & 0xffff ) ) ;
stl_raw ( p ++ , 0x3c09b400 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c08df00 ) ;
# else stl_raw ( p ++ , 0x340800df ) ;
# endif stl_raw ( p ++ , 0xad280068 ) ;
stl_raw ( p ++ , 0x3c09bbe0 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c08c000 ) ;
# else stl_raw ( p ++ , 0x340800c0 ) ;
# endif stl_raw ( p ++ , 0xad280048 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c084000 ) ;
# else stl_raw ( p ++ , 0x34080040 ) ;
# endif stl_raw ( p ++ , 0xad280050 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c088000 ) ;
# else stl_raw ( p ++ , 0x34080080 ) ;
# endif stl_raw ( p ++ , 0xad280058 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c083f00 ) ;
# else stl_raw ( p ++ , 0x3408003f ) ;
# endif stl_raw ( p ++ , 0xad280060 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c08c100 ) ;
# else stl_raw ( p ++ , 0x340800c1 ) ;
# endif stl_raw ( p ++ , 0xad280080 ) ;
# ifdef TARGET_WORDS_BIGENDIAN stl_raw ( p ++ , 0x3c085e00 ) ;
# else stl_raw ( p ++ , 0x3408005e ) ;
# endif stl_raw ( p ++ , 0xad280088 ) ;
stl_raw ( p ++ , 0x3c1f0000 | ( ( kernel_entry >> 16 ) & 0xffff ) ) ;
stl_raw ( p ++ , 0x37ff0000 | ( kernel_entry & 0xffff ) ) ;
stl_raw ( p ++ , 0x03e00008 ) ;
stl_raw ( p ++ , 0x00000000 ) ;
p = ( uint32_t * ) ( base + 0x800 ) ;
stl_raw ( p ++ , 0x03e00008 ) ;
stl_raw ( p ++ , 0x24020000 ) ;
stl_raw ( p ++ , 0x03e06821 ) ;
stl_raw ( p ++ , 0x00805821 ) ;
stl_raw ( p ++ , 0x00a05021 ) ;
stl_raw ( p ++ , 0x91440000 ) ;
stl_raw ( p ++ , 0x254a0001 ) ;
stl_raw ( p ++ , 0x10800005 ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x0ff0021c ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x08000205 ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x01a00008 ) ;
stl_raw ( p ++ , 0x01602021 ) ;
stl_raw ( p ++ , 0x03e06821 ) ;
stl_raw ( p ++ , 0x00805821 ) ;
stl_raw ( p ++ , 0x00a05021 ) ;
stl_raw ( p ++ , 0x00c06021 ) ;
stl_raw ( p ++ , 0x91440000 ) ;
stl_raw ( p ++ , 0x0ff0021c ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x254a0001 ) ;
stl_raw ( p ++ , 0x258cffff ) ;
stl_raw ( p ++ , 0x1580fffa ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x01a00008 ) ;
stl_raw ( p ++ , 0x01602021 ) ;
stl_raw ( p ++ , 0x3c08b800 ) ;
stl_raw ( p ++ , 0x350803f8 ) ;
stl_raw ( p ++ , 0x91090005 ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x31290040 ) ;
stl_raw ( p ++ , 0x1120fffc ) ;
stl_raw ( p ++ , 0x00000000 ) ;
stl_raw ( p ++ , 0x03e00008 ) ;
stl_raw ( p ++ , 0xa1040000 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int selinux_tun_dev_attach_queue ( void * security ) {
struct tun_security_struct * tunsec = security ;
return avc_has_perm ( current_sid ( ) , tunsec -> sid , SECCLASS_TUN_SOCKET , TUN_SOCKET__ATTACH_QUEUE , NULL ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int yop_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
YopDecContext * s = avctx -> priv_data ;
AVFrame * frame = data ;
int tag , firstcolor , is_odd_frame ;
int ret , i , x , y ;
uint32_t * palette ;
if ( avpkt -> size < 4 + 3 * s -> num_pal_colors ) {
av_log ( avctx , AV_LOG_ERROR , "Packet too small.\n" ) ;
return AVERROR_INVALIDDATA ;
}
ret = ff_get_buffer ( avctx , frame , 0 ) ;
if ( ret < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
if ( ! avctx -> frame_number ) memset ( frame -> data [ 1 ] , 0 , AVPALETTE_SIZE ) ;
s -> dstbuf = frame -> data [ 0 ] ;
s -> dstptr = frame -> data [ 0 ] ;
s -> srcptr = avpkt -> data + 4 ;
s -> src_end = avpkt -> data + avpkt -> size ;
s -> low_nibble = NULL ;
is_odd_frame = avpkt -> data [ 0 ] ;
firstcolor = s -> first_color [ is_odd_frame ] ;
palette = ( uint32_t * ) frame -> data [ 1 ] ;
for ( i = 0 ;
i < s -> num_pal_colors ;
i ++ , s -> srcptr += 3 ) palette [ i + firstcolor ] = ( s -> srcptr [ 0 ] << 18 ) | ( s -> srcptr [ 1 ] << 10 ) | ( s -> srcptr [ 2 ] << 2 ) ;
frame -> palette_has_changed = 1 ;
for ( y = 0 ;
y < avctx -> height ;
y += 2 ) {
for ( x = 0 ;
x < avctx -> width ;
x += 2 ) {
if ( s -> srcptr - avpkt -> data >= avpkt -> size ) {
av_log ( avctx , AV_LOG_ERROR , "Packet too small.\n" ) ;
return AVERROR_INVALIDDATA ;
}
tag = yop_get_next_nibble ( s ) ;
if ( tag != 0xf ) {
ret = yop_paint_block ( s , frame -> linesize [ 0 ] , tag ) ;
if ( ret < 0 ) return ret ;
}
else {
tag = yop_get_next_nibble ( s ) ;
ret = yop_copy_previous_block ( s , frame -> linesize [ 0 ] , tag ) ;
if ( ret < 0 ) return ret ;
}
s -> dstptr += 2 ;
}
s -> dstptr += 2 * frame -> linesize [ 0 ] - x ;
}
* got_frame = 1 ;
return avpkt -> size ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void lag_pred_line ( LagarithContext * l , uint8_t * buf , int width , int stride , int line ) {
int L , TL ;
if ( ! line ) {
L = l -> dsp . add_hfyu_left_prediction ( buf + 1 , buf + 1 , width - 1 , buf [ 0 ] ) ;
}
else {
L = buf [ width - stride - 1 ] ;
if ( line == 1 ) {
TL = l -> avctx -> pix_fmt == AV_PIX_FMT_YUV420P ? buf [ - stride ] : L ;
}
else {
TL = buf [ width - ( 2 * stride ) - 1 ] ;
}
add_lag_median_prediction ( buf , buf - stride , buf , width , & L , & TL ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void encode_color_spec ( VC2EncContext * s ) {
AVCodecContext * avctx = s -> avctx ;
put_bits ( & s -> pb , 1 , ! s -> strict_compliance ) ;
if ( ! s -> strict_compliance ) {
int val ;
put_vc2_ue_uint ( & s -> pb , 0 ) ;
put_bits ( & s -> pb , 1 , 1 ) ;
if ( avctx -> color_primaries == AVCOL_PRI_BT470BG ) val = 2 ;
else if ( avctx -> color_primaries == AVCOL_PRI_SMPTE170M ) val = 1 ;
else if ( avctx -> color_primaries == AVCOL_PRI_SMPTE240M ) val = 1 ;
else val = 0 ;
put_vc2_ue_uint ( & s -> pb , val ) ;
put_bits ( & s -> pb , 1 , 1 ) ;
if ( avctx -> colorspace == AVCOL_SPC_RGB ) val = 3 ;
else if ( avctx -> colorspace == AVCOL_SPC_YCOCG ) val = 2 ;
else if ( avctx -> colorspace == AVCOL_SPC_BT470BG ) val = 1 ;
else val = 0 ;
put_vc2_ue_uint ( & s -> pb , val ) ;
put_bits ( & s -> pb , 1 , 1 ) ;
if ( avctx -> color_trc == AVCOL_TRC_LINEAR ) val = 2 ;
else if ( avctx -> color_trc == AVCOL_TRC_BT1361_ECG ) val = 1 ;
else val = 0 ;
put_vc2_ue_uint ( & s -> pb , val ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int qemuMonitorJSONGetBalloonInfo ( qemuMonitorPtr mon , unsigned long * currmem ) {
int ret ;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand ( "query-balloon" , NULL ) ;
virJSONValuePtr reply = NULL ;
* currmem = 0 ;
if ( ! cmd ) return - 1 ;
ret = qemuMonitorJSONCommand ( mon , cmd , & reply ) ;
if ( ret == 0 ) {
if ( qemuMonitorJSONHasError ( reply , "DeviceNotActive" ) || qemuMonitorJSONHasError ( reply , "KVMMissingCap" ) ) goto cleanup ;
ret = qemuMonitorJSONCheckError ( cmd , reply ) ;
if ( ret == 0 ) {
virJSONValuePtr data ;
unsigned long long mem ;
if ( ! ( data = virJSONValueObjectGet ( reply , "return" ) ) ) {
qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "info balloon reply was missing return data" ) ) ;
ret = - 1 ;
goto cleanup ;
}
if ( virJSONValueObjectGetNumberUlong ( data , "actual" , & mem ) < 0 ) {
qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "info balloon reply was missing balloon data" ) ) ;
ret = - 1 ;
goto cleanup ;
}
* currmem = ( mem / 1024 ) ;
ret = 1 ;
}
}
cleanup : virJSONValueFree ( cmd ) ;
virJSONValueFree ( reply ) ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gpgme_error_t uiserver_cancel ( void * engine ) {
engine_uiserver_t uiserver = engine ;
if ( ! uiserver ) return gpg_error ( GPG_ERR_INV_VALUE ) ;
if ( uiserver -> status_cb . fd != - 1 ) _gpgme_io_close ( uiserver -> status_cb . fd ) ;
if ( uiserver -> input_cb . fd != - 1 ) _gpgme_io_close ( uiserver -> input_cb . fd ) ;
if ( uiserver -> output_cb . fd != - 1 ) _gpgme_io_close ( uiserver -> output_cb . fd ) ;
if ( uiserver -> message_cb . fd != - 1 ) _gpgme_io_close ( uiserver -> message_cb . fd ) ;
if ( uiserver -> assuan_ctx ) {
assuan_release ( uiserver -> assuan_ctx ) ;
uiserver -> assuan_ctx = NULL ;
}
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static struct cgroup_process_info * lxc_cgroupfs_create ( const char * name , const char * path_pattern , struct cgroup_meta_data * meta_data , const char * sub_pattern ) {
char * * cgroup_path_components = NULL ;
char * * p = NULL ;
char * path_so_far = NULL ;
char * * new_cgroup_paths = NULL ;
char * * new_cgroup_paths_sub = NULL ;
struct cgroup_mount_point * mp ;
struct cgroup_hierarchy * h ;
struct cgroup_process_info * base_info = NULL ;
struct cgroup_process_info * info_ptr ;
int saved_errno ;
int r ;
unsigned suffix = 0 ;
bool had_sub_pattern = false ;
size_t i ;
if ( ! is_valid_cgroup ( name ) ) {
ERROR ( "Invalid cgroup name: '%s'" , name ) ;
errno = EINVAL ;
return NULL ;
}
if ( ! strstr ( path_pattern , "%n" ) ) {
ERROR ( "Invalid cgroup path pattern: '%s';
contains no %%n for specifying container name" , path_pattern ) ;
errno = EINVAL ;
return NULL ;
}
base_info = ( path_pattern [ 0 ] == '/' ) ? lxc_cgroup_process_info_get_init ( meta_data ) : lxc_cgroup_process_info_get_self ( meta_data ) ;
if ( ! base_info ) return NULL ;
new_cgroup_paths = calloc ( meta_data -> maximum_hierarchy + 1 , sizeof ( char * ) ) ;
if ( ! new_cgroup_paths ) goto out_initial_error ;
new_cgroup_paths_sub = calloc ( meta_data -> maximum_hierarchy + 1 , sizeof ( char * ) ) ;
if ( ! new_cgroup_paths_sub ) goto out_initial_error ;
for ( info_ptr = base_info ;
info_ptr ;
info_ptr = info_ptr -> next ) {
h = info_ptr -> hierarchy ;
mp = lxc_cgroup_find_mount_point ( h , info_ptr -> cgroup_path , true ) ;
if ( ! mp ) {
ERROR ( "Could not find writable mount point for cgroup hierarchy %d while trying to create cgroup." , h -> index ) ;
goto out_initial_error ;
}
info_ptr -> designated_mount_point = mp ;
if ( lxc_string_in_array ( "ns" , ( const char * * ) h -> subsystems ) ) continue ;
if ( handle_cgroup_settings ( mp , info_ptr -> cgroup_path ) < 0 ) {
ERROR ( "Could not set clone_children to 1 for cpuset hierarchy in parent cgroup." ) ;
goto out_initial_error ;
}
}
cgroup_path_components = lxc_normalize_path ( path_pattern ) ;
if ( ! cgroup_path_components ) goto out_initial_error ;
for ( p = cgroup_path_components ;
* p || ( sub_pattern && ! had_sub_pattern ) ;
p ++ ) {
char * p_eff = * p ? * p : ( char * ) sub_pattern ;
bool contains_name = strstr ( p_eff , "%n" ) ;
char * current_component = NULL ;
char * current_subpath = NULL ;
char * current_entire_path = NULL ;
char * parts [ 3 ] ;
size_t j = 0 ;
i = 0 ;
if ( ! * p ) {
had_sub_pattern = true ;
p -- ;
}
goto find_name_on_this_level ;
cleanup_name_on_this_level : for ( j = 0 , info_ptr = base_info ;
j < i && info_ptr ;
info_ptr = info_ptr -> next , j ++ ) {
r = remove_cgroup ( info_ptr -> designated_mount_point , info_ptr -> created_paths [ info_ptr -> created_paths_count - 1 ] , false ) ;
if ( r < 0 ) WARN ( "could not clean up cgroup we created when trying to create container" ) ;
free ( info_ptr -> created_paths [ info_ptr -> created_paths_count - 1 ] ) ;
info_ptr -> created_paths [ -- info_ptr -> created_paths_count ] = NULL ;
}
if ( current_component != current_subpath ) free ( current_subpath ) ;
if ( current_component != p_eff ) free ( current_component ) ;
current_component = current_subpath = NULL ;
++ suffix ;
find_name_on_this_level : if ( contains_name && suffix > 0 ) {
char * buf = calloc ( strlen ( name ) + 32 , 1 ) ;
if ( ! buf ) goto out_initial_error ;
snprintf ( buf , strlen ( name ) + 32 , "%s-%u" , name , suffix ) ;
current_component = lxc_string_replace ( "%n" , buf , p_eff ) ;
free ( buf ) ;
}
else {
current_component = contains_name ? lxc_string_replace ( "%n" , name , p_eff ) : p_eff ;
}
parts [ 0 ] = path_so_far ;
parts [ 1 ] = current_component ;
parts [ 2 ] = NULL ;
current_subpath = path_so_far ? lxc_string_join ( "/" , ( const char * * ) parts , false ) : current_component ;
for ( i = 0 , info_ptr = base_info ;
info_ptr ;
info_ptr = info_ptr -> next , i ++ ) {
char * parts2 [ 3 ] ;
if ( lxc_string_in_array ( "ns" , ( const char * * ) info_ptr -> hierarchy -> subsystems ) ) continue ;
current_entire_path = NULL ;
parts2 [ 0 ] = ! strcmp ( info_ptr -> cgroup_path , "/" ) ? "" : info_ptr -> cgroup_path ;
parts2 [ 1 ] = current_subpath ;
parts2 [ 2 ] = NULL ;
current_entire_path = lxc_string_join ( "/" , ( const char * * ) parts2 , false ) ;
if ( ! * p ) {
free ( new_cgroup_paths_sub [ i ] ) ;
new_cgroup_paths_sub [ i ] = strdup ( current_entire_path ) ;
if ( ! new_cgroup_paths_sub [ i ] ) goto cleanup_from_error ;
}
else {
free ( new_cgroup_paths [ i ] ) ;
new_cgroup_paths [ i ] = strdup ( current_entire_path ) ;
if ( ! new_cgroup_paths [ i ] ) goto cleanup_from_error ;
}
r = create_cgroup ( info_ptr -> designated_mount_point , current_entire_path ) ;
if ( r < 0 && errno == EEXIST && contains_name ) {
free ( current_entire_path ) ;
current_entire_path = NULL ;
goto cleanup_name_on_this_level ;
}
else if ( r < 0 && errno != EEXIST ) {
SYSERROR ( "Could not create cgroup '%s' in '%s'." , current_entire_path , info_ptr -> designated_mount_point -> mount_point ) ;
goto cleanup_from_error ;
}
else if ( r == 0 ) {
r = lxc_grow_array ( ( void * * * ) & info_ptr -> created_paths , & info_ptr -> created_paths_capacity , info_ptr -> created_paths_count + 1 , 8 ) ;
if ( r < 0 ) goto cleanup_from_error ;
if ( ! init_cpuset_if_needed ( info_ptr -> designated_mount_point , current_entire_path ) ) {
ERROR ( "Failed to initialize cpuset for '%s' in '%s'." , current_entire_path , info_ptr -> designated_mount_point -> mount_point ) ;
goto cleanup_from_error ;
}
info_ptr -> created_paths [ info_ptr -> created_paths_count ++ ] = current_entire_path ;
}
else {
if ( handle_cgroup_settings ( info_ptr -> designated_mount_point , info_ptr -> cgroup_path ) < 0 ) {
ERROR ( "Could not set clone_children to 1 for cpuset hierarchy in pre-existing cgroup." ) ;
goto cleanup_from_error ;
}
if ( ! init_cpuset_if_needed ( info_ptr -> designated_mount_point , info_ptr -> cgroup_path ) ) {
ERROR ( "Failed to initialize cpuset in pre-existing '%s'." , info_ptr -> cgroup_path ) ;
goto cleanup_from_error ;
}
free ( current_entire_path ) ;
current_entire_path = NULL ;
}
}
free ( path_so_far ) ;
path_so_far = strdup ( current_subpath ) ;
if ( ! path_so_far ) goto cleanup_from_error ;
if ( current_component != current_subpath ) free ( current_subpath ) ;
if ( current_component != p_eff ) free ( current_component ) ;
current_component = current_subpath = NULL ;
continue ;
cleanup_from_error : saved_errno = errno ;
if ( current_component != current_subpath ) free ( current_subpath ) ;
if ( current_component != p_eff ) free ( current_component ) ;
free ( current_entire_path ) ;
errno = saved_errno ;
goto out_initial_error ;
}
for ( i = 0 , info_ptr = base_info ;
info_ptr ;
info_ptr = info_ptr -> next , i ++ ) {
if ( lxc_string_in_array ( "ns" , ( const char * * ) info_ptr -> hierarchy -> subsystems ) ) continue ;
free ( info_ptr -> cgroup_path ) ;
info_ptr -> cgroup_path = new_cgroup_paths [ i ] ;
info_ptr -> cgroup_path_sub = new_cgroup_paths_sub [ i ] ;
}
free ( new_cgroup_paths ) ;
free ( new_cgroup_paths_sub ) ;
free ( path_so_far ) ;
lxc_free_array ( ( void * * ) cgroup_path_components , free ) ;
return base_info ;
out_initial_error : saved_errno = errno ;
free ( path_so_far ) ;
lxc_cgroup_process_info_free_and_remove ( base_info ) ;
lxc_free_array ( ( void * * ) new_cgroup_paths , free ) ;
lxc_free_array ( ( void * * ) new_cgroup_paths_sub , free ) ;
lxc_free_array ( ( void * * ) cgroup_path_components , free ) ;
errno = saved_errno ;
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int yop_copy_previous_block ( YopDecContext * s , int linesize , int copy_tag ) {
uint8_t * bufptr ;
bufptr = s -> dstptr + motion_vector [ copy_tag ] [ 0 ] + linesize * motion_vector [ copy_tag ] [ 1 ] ;
if ( bufptr < s -> dstbuf ) {
av_log ( s -> avctx , AV_LOG_ERROR , "YOP: cannot decode, file probably corrupt\n" ) ;
return AVERROR_INVALIDDATA ;
}
s -> dstptr [ 0 ] = bufptr [ 0 ] ;
s -> dstptr [ 1 ] = bufptr [ 1 ] ;
s -> dstptr [ linesize ] = bufptr [ linesize ] ;
s -> dstptr [ linesize + 1 ] = bufptr [ linesize + 1 ] ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint get_diameter_pdu_len ( packet_info * pinfo _U_ , tvbuff_t * tvb , int offset , void * data _U_ ) {
return tvb_get_ntoh24 ( tvb , offset + 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static cmsBool SaveDescription ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsMLU * Text ) {
if ( self -> ICCVersion < 0x4000000 ) {
if ( ! _cmsWriteTypeBase ( io , cmsSigTextDescriptionType ) ) return FALSE ;
return Type_Text_Description_Write ( self , io , Text , 1 ) ;
}
else {
if ( ! _cmsWriteTypeBase ( io , cmsSigMultiLocalizedUnicodeType ) ) return FALSE ;
return Type_MLU_Write ( self , io , Text , 1 ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( RecursiveDirectoryIterator , __construct ) {
spl_filesystem_object_construct ( INTERNAL_FUNCTION_PARAM_PASSTHRU , DIT_CTOR_FLAGS ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static vpx_image_t * img_alloc_helper ( vpx_image_t * img , vpx_img_fmt_t fmt , unsigned int d_w , unsigned int d_h , unsigned int buf_align , unsigned int stride_align , unsigned char * img_data ) {
unsigned int h , w , s , xcs , ycs , bps ;
int align ;
if ( ! buf_align ) buf_align = 1 ;
if ( buf_align & ( buf_align - 1 ) ) goto fail ;
if ( ! stride_align ) stride_align = 1 ;
if ( stride_align & ( stride_align - 1 ) ) goto fail ;
switch ( fmt ) {
case VPX_IMG_FMT_RGB32 : case VPX_IMG_FMT_RGB32_LE : case VPX_IMG_FMT_ARGB : case VPX_IMG_FMT_ARGB_LE : bps = 32 ;
break ;
case VPX_IMG_FMT_RGB24 : case VPX_IMG_FMT_BGR24 : bps = 24 ;
break ;
case VPX_IMG_FMT_RGB565 : case VPX_IMG_FMT_RGB565_LE : case VPX_IMG_FMT_RGB555 : case VPX_IMG_FMT_RGB555_LE : case VPX_IMG_FMT_UYVY : case VPX_IMG_FMT_YUY2 : case VPX_IMG_FMT_YVYU : bps = 16 ;
break ;
case VPX_IMG_FMT_I420 : case VPX_IMG_FMT_YV12 : case VPX_IMG_FMT_VPXI420 : case VPX_IMG_FMT_VPXYV12 : bps = 12 ;
break ;
case VPX_IMG_FMT_I422 : bps = 16 ;
break ;
case VPX_IMG_FMT_I444 : bps = 24 ;
break ;
case VPX_IMG_FMT_I42016 : bps = 24 ;
break ;
case VPX_IMG_FMT_I42216 : bps = 32 ;
break ;
case VPX_IMG_FMT_I44416 : bps = 48 ;
break ;
default : bps = 16 ;
break ;
}
switch ( fmt ) {
case VPX_IMG_FMT_I420 : case VPX_IMG_FMT_YV12 : case VPX_IMG_FMT_VPXI420 : case VPX_IMG_FMT_VPXYV12 : case VPX_IMG_FMT_I422 : case VPX_IMG_FMT_I42016 : case VPX_IMG_FMT_I42216 : xcs = 1 ;
break ;
default : xcs = 0 ;
break ;
}
switch ( fmt ) {
case VPX_IMG_FMT_I420 : case VPX_IMG_FMT_YV12 : case VPX_IMG_FMT_VPXI420 : case VPX_IMG_FMT_VPXYV12 : ycs = 1 ;
break ;
default : ycs = 0 ;
break ;
}
align = ( 1 << xcs ) - 1 ;
w = ( d_w + align ) & ~ align ;
align = ( 1 << ycs ) - 1 ;
h = ( d_h + align ) & ~ align ;
s = ( fmt & VPX_IMG_FMT_PLANAR ) ? w : bps * w / 8 ;
s = ( s + stride_align - 1 ) & ~ ( stride_align - 1 ) ;
if ( ! img ) {
img = ( vpx_image_t * ) calloc ( 1 , sizeof ( vpx_image_t ) ) ;
if ( ! img ) goto fail ;
img -> self_allocd = 1 ;
}
else {
memset ( img , 0 , sizeof ( vpx_image_t ) ) ;
}
img -> img_data = img_data ;
if ( ! img_data ) {
const uint64_t alloc_size = ( fmt & VPX_IMG_FMT_PLANAR ) ? ( uint64_t ) h * s * bps / 8 : ( uint64_t ) h * s ;
if ( alloc_size != ( size_t ) alloc_size ) goto fail ;
img -> img_data = img_buf_memalign ( buf_align , ( size_t ) alloc_size ) ;
img -> img_data_owner = 1 ;
}
if ( ! img -> img_data ) goto fail ;
img -> fmt = fmt ;
img -> bit_depth = ( fmt & VPX_IMG_FMT_HIGH ) ? 16 : 8 ;
img -> w = w ;
img -> h = h ;
img -> x_chroma_shift = xcs ;
img -> y_chroma_shift = ycs ;
img -> bps = bps ;
img -> stride [ VPX_PLANE_Y ] = img -> stride [ VPX_PLANE_ALPHA ] = s ;
img -> stride [ VPX_PLANE_U ] = img -> stride [ VPX_PLANE_V ] = s >> xcs ;
if ( ! vpx_img_set_rect ( img , 0 , 0 , d_w , d_h ) ) return img ;
fail : vpx_img_free ( img ) ;
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline int ivi_scale_mv ( int mv , int mv_scale ) {
return ( mv + ( mv > 0 ) + ( mv_scale - 1 ) ) >> mv_scale ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void CloseEncoder ( vlc_object_t * p_this ) {
encoder_t * p_enc = ( encoder_t * ) p_this ;
encoder_sys_t * p_sys = p_enc -> p_sys ;
if ( p_sys -> p_schro ) schro_encoder_free ( p_sys -> p_schro ) ;
free ( p_sys -> p_format ) ;
if ( p_sys -> p_dts_fifo ) block_FifoRelease ( p_sys -> p_dts_fifo ) ;
block_ChainRelease ( p_sys -> p_chain ) ;
free ( p_sys ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline size_t GetPixelMetaChannels ( const Image * restrict image ) {
return ( image -> number_meta_channels ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_zcl_energy_phase ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_energy_phase_id , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_macro_phase_id , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_expect_duration , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_peak_power , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_energy , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( tree , hf_zbee_zcl_pwr_prof_max_active_delay , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool xhci_er_full ( void * opaque , int version_id ) {
struct XHCIInterrupter * intr = opaque ;
return intr -> er_full ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool gincost_pattern ( IndexOptInfo * index , int indexcol , Oid clause_op , Datum query , GinQualCounts * counts ) {
Oid extractProcOid ;
Oid collation ;
int strategy_op ;
Oid lefttype , righttype ;
int32 nentries = 0 ;
bool * partial_matches = NULL ;
Pointer * extra_data = NULL ;
bool * nullFlags = NULL ;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT ;
int32 i ;
get_op_opfamily_properties ( clause_op , index -> opfamily [ indexcol ] , false , & strategy_op , & lefttype , & righttype ) ;
extractProcOid = get_opfamily_proc ( index -> opfamily [ indexcol ] , index -> opcintype [ indexcol ] , index -> opcintype [ indexcol ] , GIN_EXTRACTQUERY_PROC ) ;
if ( ! OidIsValid ( extractProcOid ) ) {
elog ( ERROR , "missing support function %d for attribute %d of index \"%s\"" , GIN_EXTRACTQUERY_PROC , indexcol + 1 , get_rel_name ( index -> indexoid ) ) ;
}
if ( OidIsValid ( index -> indexcollations [ indexcol ] ) ) collation = index -> indexcollations [ indexcol ] ;
else collation = DEFAULT_COLLATION_OID ;
OidFunctionCall7Coll ( extractProcOid , collation , query , PointerGetDatum ( & nentries ) , UInt16GetDatum ( strategy_op ) , PointerGetDatum ( & partial_matches ) , PointerGetDatum ( & extra_data ) , PointerGetDatum ( & nullFlags ) , PointerGetDatum ( & searchMode ) ) ;
if ( nentries <= 0 && searchMode == GIN_SEARCH_MODE_DEFAULT ) {
return false ;
}
for ( i = 0 ;
i < nentries ;
i ++ ) {
if ( partial_matches && partial_matches [ i ] ) counts -> partialEntries += 100 ;
else counts -> exactEntries ++ ;
counts -> searchEntries ++ ;
}
if ( searchMode == GIN_SEARCH_MODE_INCLUDE_EMPTY ) {
counts -> exactEntries ++ ;
counts -> searchEntries ++ ;
}
else if ( searchMode != GIN_SEARCH_MODE_DEFAULT ) {
counts -> haveFullScan = true ;
}
return true ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug4236 ( ) {
MYSQL_STMT * stmt ;
const char * stmt_text ;
int rc ;
MYSQL_STMT backup ;
myheader ( "test_bug4236" ) ;
stmt = mysql_stmt_init ( mysql ) ;
stmt_text = "SELECT 1" ;
rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ;
check_execute ( stmt , rc ) ;
backup . stmt_id = stmt -> stmt_id ;
stmt -> stmt_id = 0 ;
rc = mysql_stmt_execute ( stmt ) ;
DIE_UNLESS ( rc ) ;
stmt -> stmt_id = backup . stmt_id ;
mysql_stmt_close ( stmt ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static cmsBool Type_Chromaticity_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {
cmsCIExyYTRIPLE * chrm = ( cmsCIExyYTRIPLE * ) Ptr ;
if ( ! _cmsWriteUInt16Number ( io , 3 ) ) return FALSE ;
if ( ! _cmsWriteUInt16Number ( io , 0 ) ) return FALSE ;
if ( ! SaveOneChromaticity ( chrm -> Red . x , chrm -> Red . y , io ) ) return FALSE ;
if ( ! SaveOneChromaticity ( chrm -> Green . x , chrm -> Green . y , io ) ) return FALSE ;
if ( ! SaveOneChromaticity ( chrm -> Blue . x , chrm -> Blue . y , io ) ) return FALSE ;
return TRUE ;
cmsUNUSED_PARAMETER ( nItems ) ;
cmsUNUSED_PARAMETER ( self ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool convert_to_scalar ( Datum value , Oid valuetypid , double * scaledvalue , Datum lobound , Datum hibound , Oid boundstypid , double * scaledlobound , double * scaledhibound ) {
switch ( valuetypid ) {
case BOOLOID : case INT2OID : case INT4OID : case INT8OID : case FLOAT4OID : case FLOAT8OID : case NUMERICOID : case OIDOID : case REGPROCOID : case REGPROCEDUREOID : case REGOPEROID : case REGOPERATOROID : case REGCLASSOID : case REGTYPEOID : case REGCONFIGOID : case REGDICTIONARYOID : case REGROLEOID : case REGNAMESPACEOID : * scaledvalue = convert_numeric_to_scalar ( value , valuetypid ) ;
* scaledlobound = convert_numeric_to_scalar ( lobound , boundstypid ) ;
* scaledhibound = convert_numeric_to_scalar ( hibound , boundstypid ) ;
return true ;
case CHAROID : case BPCHAROID : case VARCHAROID : case TEXTOID : case NAMEOID : {
char * valstr = convert_string_datum ( value , valuetypid ) ;
char * lostr = convert_string_datum ( lobound , boundstypid ) ;
char * histr = convert_string_datum ( hibound , boundstypid ) ;
convert_string_to_scalar ( valstr , scaledvalue , lostr , scaledlobound , histr , scaledhibound ) ;
pfree ( valstr ) ;
pfree ( lostr ) ;
pfree ( histr ) ;
return true ;
}
case BYTEAOID : {
convert_bytea_to_scalar ( value , scaledvalue , lobound , scaledlobound , hibound , scaledhibound ) ;
return true ;
}
case TIMESTAMPOID : case TIMESTAMPTZOID : case ABSTIMEOID : case DATEOID : case INTERVALOID : case RELTIMEOID : case TINTERVALOID : case TIMEOID : case TIMETZOID : * scaledvalue = convert_timevalue_to_scalar ( value , valuetypid ) ;
* scaledlobound = convert_timevalue_to_scalar ( lobound , boundstypid ) ;
* scaledhibound = convert_timevalue_to_scalar ( hibound , boundstypid ) ;
return true ;
case INETOID : case CIDROID : case MACADDROID : * scaledvalue = convert_network_to_scalar ( value , valuetypid ) ;
* scaledlobound = convert_network_to_scalar ( lobound , boundstypid ) ;
* scaledhibound = convert_network_to_scalar ( hibound , boundstypid ) ;
return true ;
}
* scaledvalue = * scaledlobound = * scaledhibound = 0 ;
return false ;
} | 0False
|