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
|
size_t _TSstrlcat ( char * dst , const char * str , size_t siz ) {
return ink_strlcat ( dst , str , siz ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , PayloadSizeIgnoresDownloads ) {
ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
bool prev_io_allowed = base : : ThreadRestrictions : : SetIOAllowed ( true ) ;
{
base : : ScopedTempDir downloads_directory ;
ASSERT_TRUE ( downloads_directory . CreateUniqueTempDir ( ) ) ;
browser ( ) -> profile ( ) -> GetPrefs ( ) -> SetFilePath ( prefs : : kDownloadDefaultDirectory , downloads_directory . GetPath ( ) ) ;
content : : DownloadTestObserverTerminal downloads_observer ( content : : BrowserContext : : GetDownloadManager ( browser ( ) -> profile ( ) ) , 1 , content : : DownloadTestObserver : : ON_DANGEROUS_DOWNLOAD_FAIL ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( "/page_load_metrics/download_anchor_click.html" ) ) ;
downloads_observer . WaitForFinished ( ) ;
}
base : : ThreadRestrictions : : SetIOAllowed ( prev_io_allowed ) ;
NavigateToUntrackedUrl ( ) ;
histogram_tester_ . ExpectUniqueSample ( internal : : kHistogramPageLoadTotalBytes , 0 , 1 ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void UConverter_fromUnicode_HZ_OFFSETS_LOGIC ( UConverterFromUnicodeArgs * args , UErrorCode * err ) {
const UChar * mySource = args -> source ;
char * myTarget = args -> target ;
int32_t * offsets = args -> offsets ;
int32_t mySourceIndex = 0 ;
int32_t myTargetIndex = 0 ;
int32_t targetLength = ( int32_t ) ( args -> targetLimit - myTarget ) ;
int32_t mySourceLength = ( int32_t ) ( args -> sourceLimit - args -> source ) ;
uint32_t targetUniChar = 0x0000 ;
UChar32 mySourceChar = 0x0000 ;
UConverterDataHZ * myConverterData = ( UConverterDataHZ * ) args -> converter -> extraInfo ;
UBool isTargetUCharDBCS = ( UBool ) myConverterData -> isTargetUCharDBCS ;
UBool oldIsTargetUCharDBCS ;
int len = 0 ;
const char * escSeq = NULL ;
if ( args -> converter -> fromUChar32 != 0 && myTargetIndex < targetLength ) {
goto getTrail ;
}
while ( mySourceIndex < mySourceLength ) {
targetUniChar = missingCharMarker ;
if ( myTargetIndex < targetLength ) {
mySourceChar = ( UChar ) mySource [ mySourceIndex ++ ] ;
oldIsTargetUCharDBCS = isTargetUCharDBCS ;
if ( mySourceChar == UCNV_TILDE ) {
len = ESC_LEN ;
escSeq = TILDE_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
continue ;
}
else if ( mySourceChar <= 0x7f ) {
targetUniChar = mySourceChar ;
}
else {
int32_t length = ucnv_MBCSFromUChar32 ( myConverterData -> gbConverter -> sharedData , mySourceChar , & targetUniChar , args -> converter -> useFallback ) ;
if ( length == 2 && ( uint16_t ) ( targetUniChar - 0xa1a1 ) <= ( 0xfdfe - 0xa1a1 ) && ( uint8_t ) ( targetUniChar - 0xa1 ) <= ( 0xfe - 0xa1 ) ) {
targetUniChar -= 0x8080 ;
}
else {
targetUniChar = missingCharMarker ;
}
}
if ( targetUniChar != missingCharMarker ) {
myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS = ( UBool ) ( targetUniChar > 0x00FF ) ;
if ( oldIsTargetUCharDBCS != isTargetUCharDBCS || ! myConverterData -> isEscapeAppended ) {
if ( ! isTargetUCharDBCS ) {
len = ESC_LEN ;
escSeq = SB_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
myConverterData -> isEscapeAppended = TRUE ;
}
else {
len = ESC_LEN ;
escSeq = DB_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
myConverterData -> isEscapeAppended = TRUE ;
}
}
if ( isTargetUCharDBCS ) {
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar >> 8 ) ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) targetUniChar ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) ( targetUniChar >> 8 ) ;
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
else {
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar ) ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
}
else {
if ( U16_IS_SURROGATE ( mySourceChar ) ) {
if ( U16_IS_SURROGATE_LEAD ( mySourceChar ) ) {
args -> converter -> fromUChar32 = mySourceChar ;
getTrail : if ( mySourceIndex < mySourceLength ) {
UChar trail = ( UChar ) args -> source [ mySourceIndex ] ;
if ( U16_IS_TRAIL ( trail ) ) {
++ mySourceIndex ;
mySourceChar = U16_GET_SUPPLEMENTARY ( args -> converter -> fromUChar32 , trail ) ;
args -> converter -> fromUChar32 = 0x00 ;
* err = U_INVALID_CHAR_FOUND ;
}
else {
* err = U_ILLEGAL_CHAR_FOUND ;
}
}
else {
* err = U_ZERO_ERROR ;
}
}
else {
* err = U_ILLEGAL_CHAR_FOUND ;
}
}
else {
* err = U_INVALID_CHAR_FOUND ;
}
args -> converter -> fromUChar32 = mySourceChar ;
break ;
}
}
else {
* err = U_BUFFER_OVERFLOW_ERROR ;
break ;
}
targetUniChar = missingCharMarker ;
}
args -> target += myTargetIndex ;
args -> source += mySourceIndex ;
myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , Ignore204Pages ) {
ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( "/page204.html" ) ) ;
NavigateToUntrackedUrl ( ) ;
EXPECT_TRUE ( NoPageLoadMetricsRecorded ( ) ) << "Recorded metrics: " << GetRecordedPageLoadMetricNames ( ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void nbd_update_server_watch ( void ) {
if ( nbd_can_accept ( ) ) {
if ( server_watch == - 1 ) {
server_watch = qio_channel_add_watch ( QIO_CHANNEL ( server_ioc ) , G_IO_IN , nbd_accept , NULL , NULL ) ;
}
}
else {
if ( server_watch != - 1 ) {
g_source_remove ( server_watch ) ;
server_watch = - 1 ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void xhci_alloc_streams ( XHCIEPContext * epctx , dma_addr_t base ) {
assert ( epctx -> pstreams == NULL ) ;
epctx -> nr_pstreams = 2 << epctx -> max_pstreams ;
epctx -> pstreams = xhci_alloc_stream_contexts ( epctx -> nr_pstreams , base ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static # else auto # endif inline void __attribute__ ( ( unused , always_inline ) ) elf_get_dynamic_info ( struct link_map * l , ElfW ( Dyn ) * temp ) {
ElfW ( Dyn ) * dyn = l -> l_ld ;
ElfW ( Dyn ) * * info ;
# if __ELF_NATIVE_CLASS == 32 typedef Elf32_Word d_tag_utype ;
# elif __ELF_NATIVE_CLASS == 64 typedef Elf64_Xword d_tag_utype ;
# endif # ifndef RTLD_BOOTSTRAP if ( dyn == NULL ) return ;
# endif info = l -> l_info ;
while ( dyn -> d_tag != DT_NULL ) {
if ( ( d_tag_utype ) dyn -> d_tag < DT_NUM ) info [ dyn -> d_tag ] = dyn ;
else if ( dyn -> d_tag >= DT_LOPROC && dyn -> d_tag < DT_LOPROC + DT_THISPROCNUM ) info [ dyn -> d_tag - DT_LOPROC + DT_NUM ] = dyn ;
else if ( ( d_tag_utype ) DT_VERSIONTAGIDX ( dyn -> d_tag ) < DT_VERSIONTAGNUM ) info [ VERSYMIDX ( dyn -> d_tag ) ] = dyn ;
else if ( ( d_tag_utype ) DT_EXTRATAGIDX ( dyn -> d_tag ) < DT_EXTRANUM ) info [ DT_EXTRATAGIDX ( dyn -> d_tag ) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM ] = dyn ;
else if ( ( d_tag_utype ) DT_VALTAGIDX ( dyn -> d_tag ) < DT_VALNUM ) info [ DT_VALTAGIDX ( dyn -> d_tag ) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + DT_EXTRANUM ] = dyn ;
else if ( ( d_tag_utype ) DT_ADDRTAGIDX ( dyn -> d_tag ) < DT_ADDRNUM ) info [ DT_ADDRTAGIDX ( dyn -> d_tag ) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM ] = dyn ;
++ dyn ;
}
# define DL_RO_DYN_TEMP_CNT 8 # ifndef DL_RO_DYN_SECTION if ( l -> l_addr != 0 ) {
ElfW ( Addr ) l_addr = l -> l_addr ;
int cnt = 0 ;
# define ADJUST_DYN_INFO ( tag ) do if ( info [ tag ] != NULL ) {
if ( temp ) {
temp [ cnt ] . d_tag = info [ tag ] -> d_tag ;
temp [ cnt ] . d_un . d_ptr = info [ tag ] -> d_un . d_ptr + l_addr ;
info [ tag ] = temp + cnt ++ ;
}
else info [ tag ] -> d_un . d_ptr += l_addr ;
}
while ( 0 ) ADJUST_DYN_INFO ( DT_HASH ) ;
ADJUST_DYN_INFO ( DT_PLTGOT ) ;
ADJUST_DYN_INFO ( DT_STRTAB ) ;
ADJUST_DYN_INFO ( DT_SYMTAB ) ;
# if ! ELF_MACHINE_NO_RELA ADJUST_DYN_INFO ( DT_RELA ) ;
# endif # if ! ELF_MACHINE_NO_REL ADJUST_DYN_INFO ( DT_REL ) ;
# endif ADJUST_DYN_INFO ( DT_JMPREL ) ;
ADJUST_DYN_INFO ( VERSYMIDX ( DT_VERSYM ) ) ;
ADJUST_DYN_INFO ( DT_ADDRTAGIDX ( DT_GNU_HASH ) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM ) ;
# undef ADJUST_DYN_INFO assert ( cnt <= DL_RO_DYN_TEMP_CNT ) ;
}
# endif if ( info [ DT_PLTREL ] != NULL ) {
# if ELF_MACHINE_NO_RELA assert ( info [ DT_PLTREL ] -> d_un . d_val == DT_REL ) ;
# elif ELF_MACHINE_NO_REL assert ( info [ DT_PLTREL ] -> d_un . d_val == DT_RELA ) ;
# else assert ( info [ DT_PLTREL ] -> d_un . d_val == DT_REL || info [ DT_PLTREL ] -> d_un . d_val == DT_RELA ) ;
# endif }
# if ! ELF_MACHINE_NO_RELA if ( info [ DT_RELA ] != NULL ) assert ( info [ DT_RELAENT ] -> d_un . d_val == sizeof ( ElfW ( Rela ) ) ) ;
# endif # if ! ELF_MACHINE_NO_REL if ( info [ DT_REL ] != NULL ) assert ( info [ DT_RELENT ] -> d_un . d_val == sizeof ( ElfW ( Rel ) ) ) ;
# endif # ifdef RTLD_BOOTSTRAP assert ( info [ VERSYMIDX ( DT_FLAGS_1 ) ] == NULL || info [ VERSYMIDX ( DT_FLAGS_1 ) ] -> d_un . d_val == DF_1_NOW ) ;
assert ( info [ DT_FLAGS ] == NULL || info [ DT_FLAGS ] -> d_un . d_val == DF_BIND_NOW ) ;
assert ( info [ DT_RUNPATH ] == NULL ) ;
assert ( info [ DT_RPATH ] == NULL ) ;
# else if ( info [ DT_FLAGS ] != NULL ) {
l -> l_flags = info [ DT_FLAGS ] -> d_un . d_val ;
if ( l -> l_flags & DF_SYMBOLIC ) info [ DT_SYMBOLIC ] = info [ DT_FLAGS ] ;
if ( l -> l_flags & DF_TEXTREL ) info [ DT_TEXTREL ] = info [ DT_FLAGS ] ;
if ( l -> l_flags & DF_BIND_NOW ) info [ DT_BIND_NOW ] = info [ DT_FLAGS ] ;
}
if ( info [ VERSYMIDX ( DT_FLAGS_1 ) ] != NULL ) {
l -> l_flags_1 = info [ VERSYMIDX ( DT_FLAGS_1 ) ] -> d_un . d_val ;
if ( l -> l_flags_1 & DF_1_NOW ) info [ DT_BIND_NOW ] = info [ VERSYMIDX ( DT_FLAGS_1 ) ] ;
}
if ( info [ DT_RUNPATH ] != NULL ) info [ DT_RPATH ] = NULL ;
# endif }
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static uint32_t U_CALLCONV lenient8IteratorGetState ( const UCharIterator * iter ) {
uint32_t state = ( uint32_t ) ( iter -> start << 1 ) ;
if ( iter -> reservedField != 0 ) {
state |= 1 ;
}
return state ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TSReturnCode TSFetchPageRespGet ( TSHttpTxn txnp , TSMBuffer * bufp , TSMLoc * obj ) {
sdk_assert ( sdk_sanity_check_null_ptr ( ( void * ) bufp ) == TS_SUCCESS ) ;
sdk_assert ( sdk_sanity_check_null_ptr ( ( void * ) obj ) == TS_SUCCESS ) ;
HTTPHdr * hptr = ( HTTPHdr * ) txnp ;
if ( hptr -> valid ( ) ) {
* ( reinterpret_cast < HTTPHdr * * > ( bufp ) ) = hptr ;
* obj = reinterpret_cast < TSMLoc > ( hptr -> m_http ) ;
return sdk_sanity_check_mbuffer ( * bufp ) ;
}
return TS_ERROR ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static const bfd_target * symbolsrec_object_p ( bfd * abfd ) {
void * tdata_save ;
char b [ 2 ] ;
srec_init ( ) ;
if ( bfd_seek ( abfd , ( file_ptr ) 0 , SEEK_SET ) != 0 || bfd_bread ( b , ( bfd_size_type ) 2 , abfd ) != 2 ) return NULL ;
if ( b [ 0 ] != '$' || b [ 1 ] != '$' ) {
bfd_set_error ( bfd_error_wrong_format ) ;
return NULL ;
}
tdata_save = abfd -> tdata . any ;
if ( ! srec_mkobject ( abfd ) || ! srec_scan ( abfd ) ) {
if ( abfd -> tdata . any != tdata_save && abfd -> tdata . any != NULL ) bfd_release ( abfd , abfd -> tdata . any ) ;
abfd -> tdata . any = tdata_save ;
return NULL ;
}
if ( abfd -> symcount > 0 ) abfd -> flags |= HAS_SYMS ;
return abfd -> xvec ;
}
| 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 ] ;
if ( len < EVP_GCM_TLS_EXPLICIT_IV_LEN ) return 0 ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN ;
if ( ! EVP_CIPHER_CTX_encrypting ( c ) ) {
if ( len < EVP_GCM_TLS_TAG_LEN ) return 0 ;
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 )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static Gif_Colormap * read_color_table ( int size , Gif_Reader * grr ) {
Gif_Colormap * gfcm = Gif_NewFullColormap ( size , size ) ;
Gif_Color * c ;
if ( ! gfcm ) return 0 ;
GIF_DEBUG ( ( "colormap(%d) " , size ) ) ;
for ( c = gfcm -> col ;
size ;
size -- , c ++ ) {
c -> gfc_red = gifgetbyte ( grr ) ;
c -> gfc_green = gifgetbyte ( grr ) ;
c -> gfc_blue = gifgetbyte ( grr ) ;
c -> haspixel = 0 ;
}
return gfcm ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void mainwindow_set_size ( MAIN_WINDOW_REC * window , int height , int resize_lower ) {
height -= window -> height ;
if ( height < 0 ) mainwindow_shrink ( window , - height , resize_lower ) ;
else mainwindow_grow ( window , height , resize_lower ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
CPUState * s390_cpu_addr2state ( uint16_t cpu_addr ) {
if ( cpu_addr >= smp_cpus ) {
return NULL ;
}
return ipi_states [ cpu_addr ] ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline bool e1000e_rx_l4_cso_enabled ( E1000ECore * core ) {
return ! ! ( core -> mac [ RXCSUM ] & E1000_RXCSUM_TUOFLD ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
const mbfl_encoding * mbfl_identify_encoding2 ( mbfl_string * string , const mbfl_encoding * * elist , int elistsz , int strict ) {
int i , n , num , bad ;
unsigned char * p ;
mbfl_identify_filter * flist , * filter ;
const mbfl_encoding * encoding ;
flist = ( mbfl_identify_filter * ) mbfl_calloc ( elistsz , sizeof ( mbfl_identify_filter ) ) ;
if ( flist == NULL ) {
return NULL ;
}
num = 0 ;
if ( elist != NULL ) {
for ( i = 0 ;
i < elistsz ;
i ++ ) {
if ( ! mbfl_identify_filter_init2 ( & flist [ num ] , elist [ i ] ) ) {
num ++ ;
}
}
}
n = string -> len ;
p = string -> val ;
if ( p != NULL ) {
bad = 0 ;
while ( n > 0 ) {
for ( i = 0 ;
i < num ;
i ++ ) {
filter = & flist [ i ] ;
if ( ! filter -> flag ) {
( * filter -> filter_function ) ( * p , filter ) ;
if ( filter -> flag ) {
bad ++ ;
}
}
}
if ( ( num - 1 ) <= bad && ! strict ) {
break ;
}
p ++ ;
n -- ;
}
}
encoding = NULL ;
for ( i = 0 ;
i < num ;
i ++ ) {
filter = & flist [ i ] ;
if ( ! filter -> flag ) {
if ( strict && filter -> status ) {
continue ;
}
encoding = filter -> encoding ;
break ;
}
}
if ( ! encoding ) {
for ( i = 0 ;
i < num ;
i ++ ) {
filter = & flist [ i ] ;
if ( ! filter -> flag && ( ! strict || ! filter -> status ) ) {
encoding = filter -> encoding ;
break ;
}
}
}
i = num ;
while ( -- i >= 0 ) {
mbfl_identify_filter_cleanup ( & flist [ i ] ) ;
}
mbfl_free ( ( void * ) flist ) ;
return encoding ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_t38_T_fec_info ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_t38_T_fec_info , T_fec_info_sequence ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
SplinePointList * SplinesFromEntities ( Entity * ent , int * flags , int is_stroked ) {
EntityChar ec ;
memset ( & ec , '\0' , sizeof ( ec ) ) ;
ec . splines = ent ;
return ( SplinesFromEntityChar ( & ec , flags , is_stroked ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void kadmin_getprincs ( int argc , char * argv [ ] ) {
krb5_error_code retval ;
char * expr , * * names ;
int i , count ;
expr = NULL ;
if ( ! ( argc == 1 || ( argc == 2 && ( expr = argv [ 1 ] ) ) ) ) {
fprintf ( stderr , _ ( "usage: get_principals [expression]\n" ) ) ;
return ;
}
retval = kadm5_get_principals ( handle , expr , & names , & count ) ;
if ( retval ) {
com_err ( "get_principals" , retval , _ ( "while retrieving list." ) ) ;
return ;
}
for ( i = 0 ;
i < count ;
i ++ ) printf ( "%s\n" , names [ i ] ) ;
kadm5_free_name_list ( handle , names , count ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
Selectivity scalararraysel_containment ( PlannerInfo * root , Node * leftop , Node * rightop , Oid elemtype , bool isEquality , bool useOr , int varRelid ) {
Selectivity selec ;
VariableStatData vardata ;
Datum constval ;
TypeCacheEntry * typentry ;
FmgrInfo * cmpfunc ;
examine_variable ( root , rightop , varRelid , & vardata ) ;
if ( ! vardata . rel ) {
ReleaseVariableStats ( vardata ) ;
return - 1.0 ;
}
if ( ! IsA ( leftop , Const ) ) {
ReleaseVariableStats ( vardata ) ;
return - 1.0 ;
}
if ( ( ( Const * ) leftop ) -> constisnull ) {
ReleaseVariableStats ( vardata ) ;
return ( Selectivity ) 0.0 ;
}
constval = ( ( Const * ) leftop ) -> constvalue ;
typentry = lookup_type_cache ( elemtype , TYPECACHE_CMP_PROC_FINFO ) ;
if ( ! OidIsValid ( typentry -> cmp_proc_finfo . fn_oid ) ) {
ReleaseVariableStats ( vardata ) ;
return - 1.0 ;
}
cmpfunc = & typentry -> cmp_proc_finfo ;
if ( ! isEquality ) useOr = ! useOr ;
if ( HeapTupleIsValid ( vardata . statsTuple ) && statistic_proc_security_check ( & vardata , cmpfunc -> fn_oid ) ) {
Form_pg_statistic stats ;
Datum * values ;
int nvalues ;
float4 * numbers ;
int nnumbers ;
float4 * hist ;
int nhist ;
stats = ( Form_pg_statistic ) GETSTRUCT ( vardata . statsTuple ) ;
if ( get_attstatsslot ( vardata . statsTuple , elemtype , vardata . atttypmod , STATISTIC_KIND_MCELEM , InvalidOid , NULL , & values , & nvalues , & numbers , & nnumbers ) ) {
if ( useOr || ! get_attstatsslot ( vardata . statsTuple , elemtype , vardata . atttypmod , STATISTIC_KIND_DECHIST , InvalidOid , NULL , NULL , NULL , & hist , & nhist ) ) {
hist = NULL ;
nhist = 0 ;
}
if ( useOr ) selec = mcelem_array_contain_overlap_selec ( values , nvalues , numbers , nnumbers , & constval , 1 , OID_ARRAY_CONTAINS_OP , cmpfunc ) ;
else selec = mcelem_array_contained_selec ( values , nvalues , numbers , nnumbers , & constval , 1 , hist , nhist , OID_ARRAY_CONTAINED_OP , cmpfunc ) ;
if ( hist ) free_attstatsslot ( elemtype , NULL , 0 , hist , nhist ) ;
free_attstatsslot ( elemtype , values , nvalues , numbers , nnumbers ) ;
}
else {
if ( useOr ) selec = mcelem_array_contain_overlap_selec ( NULL , 0 , NULL , 0 , & constval , 1 , OID_ARRAY_CONTAINS_OP , cmpfunc ) ;
else selec = mcelem_array_contained_selec ( NULL , 0 , NULL , 0 , & constval , 1 , NULL , 0 , OID_ARRAY_CONTAINED_OP , cmpfunc ) ;
}
selec *= ( 1.0 - stats -> stanullfrac ) ;
}
else {
if ( useOr ) selec = mcelem_array_contain_overlap_selec ( NULL , 0 , NULL , 0 , & constval , 1 , OID_ARRAY_CONTAINS_OP , cmpfunc ) ;
else selec = mcelem_array_contained_selec ( NULL , 0 , NULL , 0 , & constval , 1 , NULL , 0 , OID_ARRAY_CONTAINED_OP , cmpfunc ) ;
}
ReleaseVariableStats ( vardata ) ;
if ( ! isEquality ) selec = 1.0 - selec ;
CLAMP_PROBABILITY ( selec ) ;
return selec ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static UBool _isVariantSubtag ( const char * s , int32_t len ) {
if ( len < 0 ) {
len = ( int32_t ) uprv_strlen ( s ) ;
}
if ( len >= 5 && len <= 8 && _isAlphaNumericString ( s , len ) ) {
return TRUE ;
}
if ( len == 4 && ISNUMERIC ( * s ) && _isAlphaNumericString ( s + 1 , 3 ) ) {
return TRUE ;
}
return FALSE ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static PyObject * string_slice ( register PyStringObject * a , register Py_ssize_t i , register Py_ssize_t j ) {
if ( i < 0 ) i = 0 ;
if ( j < 0 ) j = 0 ;
if ( j > Py_SIZE ( a ) ) j = Py_SIZE ( a ) ;
if ( i == 0 && j == Py_SIZE ( a ) && PyString_CheckExact ( a ) ) {
Py_INCREF ( a ) ;
return ( PyObject * ) a ;
}
if ( j < i ) j = i ;
return PyString_FromStringAndSize ( a -> ob_sval + i , j - i ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void xhci_calc_iso_kick ( XHCIState * xhci , XHCITransfer * xfer , XHCIEPContext * epctx , uint64_t mfindex ) {
if ( xfer -> trbs [ 0 ] . control & TRB_TR_SIA ) {
uint64_t asap = ( ( mfindex + epctx -> interval - 1 ) & ~ ( epctx -> interval - 1 ) ) ;
if ( asap >= epctx -> mfindex_last && asap <= epctx -> mfindex_last + epctx -> interval * 4 ) {
xfer -> mfindex_kick = epctx -> mfindex_last + epctx -> interval ;
}
else {
xfer -> mfindex_kick = asap ;
}
}
else {
xfer -> mfindex_kick = ( ( xfer -> trbs [ 0 ] . control >> TRB_TR_FRAMEID_SHIFT ) & TRB_TR_FRAMEID_MASK ) << 3 ;
xfer -> mfindex_kick |= mfindex & ~ 0x3fff ;
if ( xfer -> mfindex_kick + 0x100 < mfindex ) {
xfer -> mfindex_kick += 0x4000 ;
}
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int ipvideo_decode_block_opcode_0xB ( IpvideoContext * s , AVFrame * frame ) {
int y ;
for ( y = 0 ;
y < 8 ;
y ++ ) {
bytestream2_get_buffer ( & s -> stream_ptr , s -> pixel_ptr , 8 ) ;
s -> pixel_ptr += s -> stride ;
}
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int strncat_from_utf8_libarchive2 ( struct archive_string * as , const void * _p , size_t len , struct archive_string_conv * sc ) {
const char * s ;
int n ;
char * p ;
char * end ;
uint32_t unicode ;
# if HAVE_WCRTOMB mbstate_t shift_state ;
memset ( & shift_state , 0 , sizeof ( shift_state ) ) ;
# else wctomb ( NULL , L'\0' ) ;
# endif ( void ) sc ;
if ( archive_string_ensure ( as , as -> length + len + 1 ) == NULL ) return ( - 1 ) ;
s = ( const char * ) _p ;
p = as -> s + as -> length ;
end = as -> s + as -> buffer_length - MB_CUR_MAX - 1 ;
while ( ( n = _utf8_to_unicode ( & unicode , s , len ) ) != 0 ) {
wchar_t wc ;
if ( p >= end ) {
as -> length = p - as -> s ;
if ( archive_string_ensure ( as , as -> length + len * 2 + 1 ) == NULL ) return ( - 1 ) ;
p = as -> s + as -> length ;
end = as -> s + as -> buffer_length - MB_CUR_MAX - 1 ;
}
if ( n < 0 ) {
n *= - 1 ;
wc = L'?' ;
}
else wc = ( wchar_t ) unicode ;
s += n ;
len -= n ;
# if HAVE_WCRTOMB n = ( int ) wcrtomb ( p , wc , & shift_state ) ;
# else n = ( int ) wctomb ( p , wc ) ;
# endif if ( n == - 1 ) return ( - 1 ) ;
p += n ;
}
as -> length = p - as -> s ;
as -> s [ as -> length ] = '\0' ;
return ( 0 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void test_rename ( ) {
MYSQL_STMT * stmt ;
const char * query = "rename table t1 to t2, t3 to t4" ;
int rc ;
myheader ( "test_table_rename" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS t1, t2, t3, t4" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , query ) ;
check_stmt ( stmt ) ;
rc = mysql_query ( mysql , "create table t1 (a int)" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute_r ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "rename without t3\n" ) ;
rc = mysql_query ( mysql , "create table t3 (a int)" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "rename with t3\n" ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute_r ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "rename renamed\n" ) ;
rc = mysql_query ( mysql , "rename table t2 to t1, t4 to t3" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
if ( ! opt_silent ) fprintf ( stdout , "rename reverted\n" ) ;
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "DROP TABLE t2, t4" ) ;
myquery ( rc ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static vp9_variance_fn_t get_block_variance_fn ( BLOCK_SIZE bsize ) {
switch ( bsize ) {
case BLOCK_8X8 : return vp9_mse8x8 ;
case BLOCK_16X8 : return vp9_mse16x8 ;
case BLOCK_8X16 : return vp9_mse8x16 ;
default : return vp9_mse16x16 ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int64 fe_recvint64 ( char * buf ) {
int64 result ;
uint32 h32 ;
uint32 l32 ;
memcpy ( & h32 , buf , 4 ) ;
memcpy ( & l32 , buf + 4 , 4 ) ;
h32 = ntohl ( h32 ) ;
l32 = ntohl ( l32 ) ;
result = h32 ;
result <<= 32 ;
result |= l32 ;
return result ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int dtls1_shutdown ( SSL * s ) {
int ret ;
# ifndef OPENSSL_NO_SCTP BIO * wbio ;
wbio = SSL_get_wbio ( s ) ;
if ( wbio != NULL && BIO_dgram_is_sctp ( wbio ) && ! ( s -> shutdown & SSL_SENT_SHUTDOWN ) ) {
ret = BIO_dgram_sctp_wait_for_dry ( wbio ) ;
if ( ret < 0 ) return - 1 ;
if ( ret == 0 ) BIO_ctrl ( SSL_get_wbio ( s ) , BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN , 1 , NULL ) ;
}
# endif ret = ssl3_shutdown ( s ) ;
# ifndef OPENSSL_NO_SCTP BIO_ctrl ( SSL_get_wbio ( s ) , BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN , 0 , NULL ) ;
# endif return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
IN_PROC_BROWSER_TEST_P ( BrowserCloseManagerBrowserTest , TestWithDangerousUrlDownload ) {
std : : unique_ptr < TestDownloadManagerDelegate > test_delegate ( new TestDownloadManagerDelegate ( browser ( ) -> profile ( ) ) ) ;
DownloadCoreServiceFactory : : GetForBrowserContext ( browser ( ) -> profile ( ) ) -> SetDownloadManagerDelegateForTesting ( std : : move ( test_delegate ) ) ;
GURL download_url ( embedded_test_server ( ) -> GetURL ( "/downloads/dangerous/dangerous.swf" ) ) ;
content : : DownloadTestObserverInterrupted observer ( content : : BrowserContext : : GetDownloadManager ( browser ( ) -> profile ( ) ) , 1 , content : : DownloadTestObserver : : ON_DANGEROUS_DOWNLOAD_QUIT ) ;
ui_test_utils : : NavigateToURLWithDisposition ( browser ( ) , GURL ( download_url ) , WindowOpenDisposition : : NEW_BACKGROUND_TAB , ui_test_utils : : BROWSER_TEST_NONE ) ;
observer . WaitForFinished ( ) ;
EXPECT_EQ ( 1 , content : : BrowserContext : : GetDownloadManager ( browser ( ) -> profile ( ) ) -> InProgressCount ( ) ) ;
EXPECT_EQ ( 0 , content : : BrowserContext : : GetDownloadManager ( browser ( ) -> profile ( ) ) -> NonMaliciousInProgressCount ( ) ) ;
RepeatedNotificationObserver close_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , 1 ) ;
TestBrowserCloseManager : : AttemptClose ( TestBrowserCloseManager : : NO_USER_CHOICE ) ;
close_observer . Wait ( ) ;
EXPECT_TRUE ( browser_shutdown : : IsTryingToQuit ( ) ) ;
EXPECT_TRUE ( BrowserList : : GetInstance ( ) -> empty ( ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void xmlInitializeGlobalState ( xmlGlobalStatePtr gs ) {
# ifdef DEBUG_GLOBALS fprintf ( stderr , "Initializing globals at %lu for thread %d\n" , ( unsigned long ) gs , xmlGetThreadId ( ) ) ;
# endif if ( xmlThrDefMutex == NULL ) xmlInitGlobals ( ) ;
xmlMutexLock ( xmlThrDefMutex ) ;
# if defined ( LIBXML_DOCB_ENABLED ) && defined ( LIBXML_LEGACY_ENABLED ) && defined ( LIBXML_SAX1_ENABLED ) initdocbDefaultSAXHandler ( & gs -> docbDefaultSAXHandler ) ;
# endif # if defined ( LIBXML_HTML_ENABLED ) && defined ( LIBXML_LEGACY_ENABLED ) inithtmlDefaultSAXHandler ( & gs -> htmlDefaultSAXHandler ) ;
# endif gs -> oldXMLWDcompatibility = 0 ;
gs -> xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef ;
gs -> xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef ;
# if defined ( LIBXML_SAX1_ENABLED ) && defined ( LIBXML_LEGACY_ENABLED ) initxmlDefaultSAXHandler ( & gs -> xmlDefaultSAXHandler , 1 ) ;
# endif gs -> xmlDefaultSAXLocator . getPublicId = xmlSAX2GetPublicId ;
gs -> xmlDefaultSAXLocator . getSystemId = xmlSAX2GetSystemId ;
gs -> xmlDefaultSAXLocator . getLineNumber = xmlSAX2GetLineNumber ;
gs -> xmlDefaultSAXLocator . getColumnNumber = xmlSAX2GetColumnNumber ;
gs -> xmlDoValidityCheckingDefaultValue = xmlDoValidityCheckingDefaultValueThrDef ;
# if defined ( DEBUG_MEMORY_LOCATION ) | defined ( DEBUG_MEMORY ) gs -> xmlFree = ( xmlFreeFunc ) xmlMemFree ;
gs -> xmlMalloc = ( xmlMallocFunc ) xmlMemMalloc ;
gs -> xmlMallocAtomic = ( xmlMallocFunc ) xmlMemMalloc ;
gs -> xmlRealloc = ( xmlReallocFunc ) xmlMemRealloc ;
gs -> xmlMemStrdup = ( xmlStrdupFunc ) xmlMemoryStrdup ;
# else gs -> xmlFree = ( xmlFreeFunc ) free ;
gs -> xmlMalloc = ( xmlMallocFunc ) malloc ;
gs -> xmlMallocAtomic = ( xmlMallocFunc ) malloc ;
gs -> xmlRealloc = ( xmlReallocFunc ) realloc ;
gs -> xmlMemStrdup = ( xmlStrdupFunc ) xmlStrdup ;
# endif gs -> xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef ;
gs -> xmlIndentTreeOutput = xmlIndentTreeOutputThrDef ;
gs -> xmlTreeIndentString = xmlTreeIndentStringThrDef ;
gs -> xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef ;
gs -> xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef ;
gs -> xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef ;
gs -> xmlParserDebugEntities = xmlParserDebugEntitiesThrDef ;
gs -> xmlParserVersion = LIBXML_VERSION_STRING ;
gs -> xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef ;
gs -> xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef ;
gs -> xmlSubstituteEntitiesDefaultValue = xmlSubstituteEntitiesDefaultValueThrDef ;
gs -> xmlGenericError = xmlGenericErrorThrDef ;
gs -> xmlStructuredError = xmlStructuredErrorThrDef ;
gs -> xmlGenericErrorContext = xmlGenericErrorContextThrDef ;
gs -> xmlStructuredErrorContext = xmlStructuredErrorContextThrDef ;
gs -> xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef ;
gs -> xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef ;
gs -> xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef ;
gs -> xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef ;
memset ( & gs -> xmlLastError , 0 , sizeof ( xmlError ) ) ;
xmlMutexUnlock ( xmlThrDefMutex ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void evdns_requests_pump_waiting_queue ( void ) {
while ( global_requests_inflight < global_max_requests_inflight && global_requests_waiting ) {
struct request * req ;
assert ( req_waiting_head ) ;
if ( req_waiting_head -> next == req_waiting_head ) {
req = req_waiting_head ;
req_waiting_head = NULL ;
}
else {
req = req_waiting_head ;
req -> next -> prev = req -> prev ;
req -> prev -> next = req -> next ;
req_waiting_head = req -> next ;
}
global_requests_waiting -- ;
global_requests_inflight ++ ;
req -> ns = nameserver_pick ( ) ;
request_trans_id_set ( req , transaction_id_pick ( ) ) ;
evdns_request_insert ( req , & req_head ) ;
evdns_request_transmit ( req ) ;
evdns_transmit ( ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void voutf ( struct GlobalConfig * config , const char * prefix , const char * fmt , va_list ap ) {
size_t width = ( 79 - strlen ( prefix ) ) ;
if ( ! config -> mute ) {
size_t len ;
char * ptr ;
char * print_buffer ;
print_buffer = curlx_mvaprintf ( fmt , ap ) ;
if ( ! print_buffer ) return ;
len = strlen ( print_buffer ) ;
ptr = print_buffer ;
while ( len > 0 ) {
fputs ( prefix , config -> errors ) ;
if ( len > width ) {
size_t cut = width - 1 ;
while ( ! ISSPACE ( ptr [ cut ] ) && cut ) {
cut -- ;
}
if ( 0 == cut ) cut = width - 1 ;
( void ) fwrite ( ptr , cut + 1 , 1 , config -> errors ) ;
fputs ( "\n" , config -> errors ) ;
ptr += cut + 1 ;
len -= cut ;
}
else {
fputs ( ptr , config -> errors ) ;
len = 0 ;
}
}
curl_free ( print_buffer ) ;
}
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static long mem_seek ( jas_stream_obj_t * obj , long offset , int origin ) {
jas_stream_memobj_t * m = ( jas_stream_memobj_t * ) obj ;
long newpos ;
switch ( origin ) {
case SEEK_SET : newpos = offset ;
break ;
case SEEK_END : newpos = m -> len_ - offset ;
break ;
case SEEK_CUR : newpos = m -> pos_ + offset ;
break ;
default : abort ( ) ;
break ;
}
if ( newpos < 0 ) {
return - 1 ;
}
m -> pos_ = newpos ;
return m -> pos_ ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
bool start_postmaster ( ClusterInfo * cluster , bool throw_error ) {
char cmd [ MAXPGPATH * 4 + 1000 ] ;
PGconn * conn ;
bool pg_ctl_return = false ;
char socket_string [ MAXPGPATH + 200 ] ;
static bool exit_hook_registered = false ;
if ( ! exit_hook_registered ) {
atexit ( stop_postmaster_atexit ) ;
exit_hook_registered = true ;
}
socket_string [ 0 ] = '\0' ;
# ifdef HAVE_UNIX_SOCKETS strcat ( socket_string , " -c listen_addresses='' -c unix_socket_permissions=0700" ) ;
if ( cluster -> sockdir ) snprintf ( socket_string + strlen ( socket_string ) , sizeof ( socket_string ) - strlen ( socket_string ) , " -c %s='%s'" , ( GET_MAJOR_VERSION ( cluster -> major_version ) < 903 ) ? "unix_socket_directory" : "unix_socket_directories" , cluster -> sockdir ) ;
# endif snprintf ( cmd , sizeof ( cmd ) , "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" -o \"-p %d%s%s %s%s\" start" , cluster -> bindir , SERVER_LOG_FILE , cluster -> pgconfig , cluster -> port , ( cluster -> controldata . cat_ver >= BINARY_UPGRADE_SERVER_FLAG_CAT_VER ) ? " -b" : " -c autovacuum=off -c autovacuum_freeze_max_age=2000000000" , ( cluster == & new_cluster ) ? " -c synchronous_commit=off -c fsync=off -c full_page_writes=off" : "" , cluster -> pgopts ? cluster -> pgopts : "" , socket_string ) ;
pg_ctl_return = exec_prog ( SERVER_START_LOG_FILE , ( strcmp ( SERVER_LOG_FILE , SERVER_START_LOG_FILE ) != 0 ) ? SERVER_LOG_FILE : NULL , false , "%s" , cmd ) ;
if ( ! pg_ctl_return && ! throw_error ) return false ;
if ( pg_ctl_return ) os_info . running_cluster = cluster ;
if ( ( conn = get_db_conn ( cluster , "template1" ) ) == NULL || PQstatus ( conn ) != CONNECTION_OK ) {
pg_log ( PG_REPORT , "\nconnection to database failed: %s\n" , PQerrorMessage ( conn ) ) ;
if ( conn ) PQfinish ( conn ) ;
pg_fatal ( "could not connect to %s postmaster started with the command:\n" "%s\n" , CLUSTER_NAME ( cluster ) , cmd ) ;
}
PQfinish ( conn ) ;
if ( ! pg_ctl_return ) pg_fatal ( "pg_ctl failed to start the %s server, or connection failed\n" , CLUSTER_NAME ( cluster ) ) ;
return true ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
int h , w ;
AVFrame * pic = data ;
const uint8_t * src = avpkt -> data ;
uint8_t * Y1 , * Y2 , * U , * V ;
int ret ;
if ( avpkt -> size < avctx -> width * avctx -> height * 3 / 2 + 16 ) {
av_log ( avctx , AV_LOG_ERROR , "packet too small\n" ) ;
return AVERROR_INVALIDDATA ;
}
if ( ( ret = ff_get_buffer ( avctx , pic , 0 ) ) < 0 ) return ret ;
pic -> pict_type = AV_PICTURE_TYPE_I ;
pic -> key_frame = 1 ;
if ( AV_RL32 ( src ) != 0x01000002 ) {
av_log_ask_for_sample ( avctx , "Unknown frame header %X\n" , AV_RL32 ( src ) ) ;
return AVERROR_PATCHWELCOME ;
}
src += 16 ;
Y1 = pic -> data [ 0 ] ;
Y2 = pic -> data [ 0 ] + pic -> linesize [ 0 ] ;
U = pic -> data [ 1 ] ;
V = pic -> data [ 2 ] ;
for ( h = 0 ;
h < avctx -> height ;
h += 2 ) {
for ( w = 0 ;
w < avctx -> width ;
w += 2 ) {
AV_COPY16 ( Y1 + w , src ) ;
AV_COPY16 ( Y2 + w , src + 2 ) ;
U [ w >> 1 ] = src [ 4 ] + 0x80 ;
V [ w >> 1 ] = src [ 5 ] + 0x80 ;
src += 6 ;
}
Y1 += pic -> linesize [ 0 ] << 1 ;
Y2 += pic -> linesize [ 0 ] << 1 ;
U += pic -> linesize [ 1 ] ;
V += pic -> linesize [ 2 ] ;
}
* got_frame = 1 ;
return avpkt -> size ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void vvalue_strbuf_append_r4 ( wmem_strbuf_t * strbuf , void * ptr ) {
float r4 = * ( float * ) ptr ;
wmem_strbuf_append_printf ( strbuf , "%g" , ( double ) r4 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int xmlrpc_set_options ( int type , const char * value ) {
if ( type == XMLRPC_HTTP_HEADER ) {
if ( ! stricmp ( value , XMLRPC_ON ) ) {
xmlrpc . httpheader = 1 ;
}
if ( ! stricmp ( value , XMLRPC_OFF ) ) {
xmlrpc . httpheader = 0 ;
}
}
if ( type == XMLRPC_ENCODE ) {
if ( value ) {
xmlrpc . encode = sstrdup ( value ) ;
}
}
if ( type == XMLRPC_INTTAG ) {
if ( ! stricmp ( value , XMLRPC_I4 ) ) {
xmlrpc . inttagstart = sstrdup ( "<i4>" ) ;
xmlrpc . inttagend = sstrdup ( "</i4>" ) ;
}
if ( ! stricmp ( value , XMLRPC_INT ) ) {
xmlrpc . inttagstart = sstrdup ( "<int>" ) ;
xmlrpc . inttagend = sstrdup ( "</int>" ) ;
}
}
return 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static bool xhci_get_flag ( XHCIState * xhci , enum xhci_flags bit ) {
return xhci -> flags & ( 1 << bit ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int do_cgroup_get ( const char * cgroup_path , const char * sub_filename , char * value , size_t len ) {
const char * parts [ 3 ] = {
cgroup_path , sub_filename , NULL }
;
char * filename ;
int ret , saved_errno ;
filename = lxc_string_join ( "/" , parts , false ) ;
if ( ! filename ) return - 1 ;
ret = lxc_read_from_file ( filename , value , len ) ;
saved_errno = errno ;
free ( filename ) ;
errno = saved_errno ;
return ret ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int SFHasInstructions ( SplineFont * sf ) {
int i ;
if ( sf -> mm != NULL && sf -> mm -> apple ) sf = sf -> mm -> normal ;
if ( sf -> subfontcnt != 0 ) return ( false ) ;
for ( i = 0 ;
i < sf -> glyphcnt ;
++ i ) if ( sf -> glyphs [ i ] != NULL ) {
if ( strcmp ( sf -> glyphs [ i ] -> name , ".notdef" ) == 0 ) continue ;
if ( sf -> glyphs [ i ] -> ttf_instrs != NULL ) return ( true ) ;
}
return ( false ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static CURLcode output_auth_headers ( struct connectdata * conn , struct auth * authstatus , const char * request , const char * path , bool proxy ) {
const char * auth = NULL ;
CURLcode result = CURLE_OK ;
# if ! defined ( CURL_DISABLE_VERBOSE_STRINGS ) || defined ( USE_SPNEGO ) struct Curl_easy * data = conn -> data ;
# endif # ifdef USE_SPNEGO struct negotiatedata * negdata = proxy ? & data -> state . proxyneg : & data -> state . negotiate ;
# endif # ifdef CURL_DISABLE_CRYPTO_AUTH ( void ) request ;
( void ) path ;
# endif # ifdef USE_SPNEGO negdata -> state = GSS_AUTHNONE ;
if ( ( authstatus -> picked == CURLAUTH_NEGOTIATE ) && negdata -> context && ! GSS_ERROR ( negdata -> status ) ) {
auth = "Negotiate" ;
result = Curl_output_negotiate ( conn , proxy ) ;
if ( result ) return result ;
authstatus -> done = TRUE ;
negdata -> state = GSS_AUTHSENT ;
}
else # endif # ifdef USE_NTLM if ( authstatus -> picked == CURLAUTH_NTLM ) {
auth = "NTLM" ;
result = Curl_output_ntlm ( conn , proxy ) ;
if ( result ) return result ;
}
else # endif # if defined ( USE_NTLM ) && defined ( NTLM_WB_ENABLED ) if ( authstatus -> picked == CURLAUTH_NTLM_WB ) {
auth = "NTLM_WB" ;
result = Curl_output_ntlm_wb ( conn , proxy ) ;
if ( result ) return result ;
}
else # endif # ifndef CURL_DISABLE_CRYPTO_AUTH if ( authstatus -> picked == CURLAUTH_DIGEST ) {
auth = "Digest" ;
result = Curl_output_digest ( conn , proxy , ( const unsigned char * ) request , ( const unsigned char * ) path ) ;
if ( result ) return result ;
}
else # endif if ( authstatus -> picked == CURLAUTH_BASIC ) {
if ( ( proxy && conn -> bits . proxy_user_passwd && ! Curl_checkProxyheaders ( conn , "Proxy-authorization:" ) ) || ( ! proxy && conn -> bits . user_passwd && ! Curl_checkheaders ( conn , "Authorization:" ) ) ) {
auth = "Basic" ;
result = http_output_basic ( conn , proxy ) ;
if ( result ) return result ;
}
authstatus -> done = TRUE ;
}
if ( auth ) {
infof ( data , "%s auth using %s with user '%s'\n" , proxy ? "Proxy" : "Server" , auth , proxy ? ( conn -> proxyuser ? conn -> proxyuser : "" ) : ( conn -> user ? conn -> user : "" ) ) ;
authstatus -> multi = ( ! authstatus -> done ) ? TRUE : FALSE ;
}
else authstatus -> multi = FALSE ;
return CURLE_OK ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int vc1_decode_i_block ( VC1Context * v , int16_t block [ 64 ] , int n , int coded , int codingset ) {
GetBitContext * gb = & v -> s . gb ;
MpegEncContext * s = & v -> s ;
int dc_pred_dir = 0 ;
int i ;
int16_t * dc_val ;
int16_t * ac_val , * ac_val2 ;
int dcdiff ;
if ( n < 4 ) {
dcdiff = get_vlc2 ( & s -> gb , ff_msmp4_dc_luma_vlc [ s -> dc_table_index ] . table , DC_VLC_BITS , 3 ) ;
}
else {
dcdiff = get_vlc2 ( & s -> gb , ff_msmp4_dc_chroma_vlc [ s -> dc_table_index ] . table , DC_VLC_BITS , 3 ) ;
}
if ( dcdiff < 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "Illegal DC VLC\n" ) ;
return - 1 ;
}
if ( dcdiff ) {
if ( dcdiff == 119 ) {
if ( v -> pq == 1 ) dcdiff = get_bits ( gb , 10 ) ;
else if ( v -> pq == 2 ) dcdiff = get_bits ( gb , 9 ) ;
else dcdiff = get_bits ( gb , 8 ) ;
}
else {
if ( v -> pq == 1 ) dcdiff = ( dcdiff << 2 ) + get_bits ( gb , 2 ) - 3 ;
else if ( v -> pq == 2 ) dcdiff = ( dcdiff << 1 ) + get_bits1 ( gb ) - 1 ;
}
if ( get_bits1 ( gb ) ) dcdiff = - dcdiff ;
}
dcdiff += vc1_i_pred_dc ( & v -> s , v -> overlap , v -> pq , n , & dc_val , & dc_pred_dir ) ;
* dc_val = dcdiff ;
if ( n < 4 ) {
block [ 0 ] = dcdiff * s -> y_dc_scale ;
}
else {
block [ 0 ] = dcdiff * s -> c_dc_scale ;
}
if ( ! coded ) {
goto not_coded ;
}
i = 1 ;
{
int last = 0 , skip , value ;
const uint8_t * zz_table ;
int scale ;
int k ;
scale = v -> pq * 2 + v -> halfpq ;
if ( v -> s . ac_pred ) {
if ( ! dc_pred_dir ) zz_table = v -> zz_8x8 [ 2 ] ;
else zz_table = v -> zz_8x8 [ 3 ] ;
}
else zz_table = v -> zz_8x8 [ 1 ] ;
ac_val = s -> ac_val [ 0 ] [ 0 ] + s -> block_index [ n ] * 16 ;
ac_val2 = ac_val ;
if ( dc_pred_dir ) ac_val -= 16 ;
else ac_val -= 16 * s -> block_wrap [ n ] ;
while ( ! last ) {
vc1_decode_ac_coeff ( v , & last , & skip , & value , codingset ) ;
i += skip ;
if ( i > 63 ) break ;
block [ zz_table [ i ++ ] ] = value ;
}
if ( s -> ac_pred ) {
if ( dc_pred_dir ) {
for ( k = 1 ;
k < 8 ;
k ++ ) block [ k << v -> left_blk_sh ] += ac_val [ k ] ;
}
else {
for ( k = 1 ;
k < 8 ;
k ++ ) block [ k << v -> top_blk_sh ] += ac_val [ k + 8 ] ;
}
}
for ( k = 1 ;
k < 8 ;
k ++ ) {
ac_val2 [ k ] = block [ k << v -> left_blk_sh ] ;
ac_val2 [ k + 8 ] = block [ k << v -> top_blk_sh ] ;
}
for ( k = 1 ;
k < 64 ;
k ++ ) if ( block [ k ] ) {
block [ k ] *= scale ;
if ( ! v -> pquantizer ) block [ k ] += ( block [ k ] < 0 ) ? - v -> pq : v -> pq ;
}
if ( s -> ac_pred ) i = 63 ;
}
not_coded : if ( ! coded ) {
int k , scale ;
ac_val = s -> ac_val [ 0 ] [ 0 ] + s -> block_index [ n ] * 16 ;
ac_val2 = ac_val ;
i = 0 ;
scale = v -> pq * 2 + v -> halfpq ;
memset ( ac_val2 , 0 , 16 * 2 ) ;
if ( dc_pred_dir ) {
ac_val -= 16 ;
if ( s -> ac_pred ) memcpy ( ac_val2 , ac_val , 8 * 2 ) ;
}
else {
ac_val -= 16 * s -> block_wrap [ n ] ;
if ( s -> ac_pred ) memcpy ( ac_val2 + 8 , ac_val + 8 , 8 * 2 ) ;
}
if ( s -> ac_pred ) {
if ( dc_pred_dir ) {
for ( k = 1 ;
k < 8 ;
k ++ ) {
block [ k << v -> left_blk_sh ] = ac_val [ k ] * scale ;
if ( ! v -> pquantizer && block [ k << v -> left_blk_sh ] ) block [ k << v -> left_blk_sh ] += ( block [ k << v -> left_blk_sh ] < 0 ) ? - v -> pq : v -> pq ;
}
}
else {
for ( k = 1 ;
k < 8 ;
k ++ ) {
block [ k << v -> top_blk_sh ] = ac_val [ k + 8 ] * scale ;
if ( ! v -> pquantizer && block [ k << v -> top_blk_sh ] ) block [ k << v -> top_blk_sh ] += ( block [ k << v -> top_blk_sh ] < 0 ) ? - v -> pq : v -> pq ;
}
}
i = 63 ;
}
}
s -> block_last_index [ n ] = i ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int decode_slice ( AVCodecContext * avctx , void * tdata ) {
ProresThreadData * td = tdata ;
ProresContext * ctx = avctx -> priv_data ;
int mb_x_pos = td -> x_pos ;
int mb_y_pos = td -> y_pos ;
int pic_num = ctx -> pic_num ;
int slice_num = td -> slice_num ;
int mbs_per_slice = td -> slice_width ;
const uint8_t * buf ;
uint8_t * y_data , * u_data , * v_data ;
AVFrame * pic = ctx -> frame ;
int i , sf , slice_width_factor ;
int slice_data_size , hdr_size , y_data_size , u_data_size , v_data_size ;
int y_linesize , u_linesize , v_linesize ;
buf = ctx -> slice_data [ slice_num ] . index ;
slice_data_size = ctx -> slice_data [ slice_num + 1 ] . index - buf ;
slice_width_factor = av_log2 ( mbs_per_slice ) ;
y_data = pic -> data [ 0 ] ;
u_data = pic -> data [ 1 ] ;
v_data = pic -> data [ 2 ] ;
y_linesize = pic -> linesize [ 0 ] ;
u_linesize = pic -> linesize [ 1 ] ;
v_linesize = pic -> linesize [ 2 ] ;
if ( pic -> interlaced_frame ) {
if ( ! ( pic_num ^ pic -> top_field_first ) ) {
y_data += y_linesize ;
u_data += u_linesize ;
v_data += v_linesize ;
}
y_linesize <<= 1 ;
u_linesize <<= 1 ;
v_linesize <<= 1 ;
}
if ( slice_data_size < 6 ) {
av_log ( avctx , AV_LOG_ERROR , "slice data too small\n" ) ;
return AVERROR_INVALIDDATA ;
}
hdr_size = buf [ 0 ] >> 3 ;
y_data_size = AV_RB16 ( buf + 2 ) ;
u_data_size = AV_RB16 ( buf + 4 ) ;
v_data_size = hdr_size > 7 ? AV_RB16 ( buf + 6 ) : slice_data_size - y_data_size - u_data_size - hdr_size ;
if ( hdr_size + y_data_size + u_data_size + v_data_size > slice_data_size || v_data_size < 0 || hdr_size < 6 ) {
av_log ( avctx , AV_LOG_ERROR , "invalid data size\n" ) ;
return AVERROR_INVALIDDATA ;
}
sf = av_clip ( buf [ 1 ] , 1 , 224 ) ;
sf = sf > 128 ? ( sf - 96 ) << 2 : sf ;
if ( ctx -> qmat_changed || sf != td -> prev_slice_sf ) {
td -> prev_slice_sf = sf ;
for ( i = 0 ;
i < 64 ;
i ++ ) {
td -> qmat_luma_scaled [ ctx -> dsp . idct_permutation [ i ] ] = ctx -> qmat_luma [ i ] * sf ;
td -> qmat_chroma_scaled [ ctx -> dsp . idct_permutation [ i ] ] = ctx -> qmat_chroma [ i ] * sf ;
}
}
decode_slice_plane ( ctx , td , buf + hdr_size , y_data_size , ( uint16_t * ) ( y_data + ( mb_y_pos << 4 ) * y_linesize + ( mb_x_pos << 5 ) ) , y_linesize , mbs_per_slice , 4 , slice_width_factor + 2 , td -> qmat_luma_scaled , 0 ) ;
decode_slice_plane ( ctx , td , buf + hdr_size + y_data_size , u_data_size , ( uint16_t * ) ( u_data + ( mb_y_pos << 4 ) * u_linesize + ( mb_x_pos << ctx -> mb_chroma_factor ) ) , u_linesize , mbs_per_slice , ctx -> num_chroma_blocks , slice_width_factor + ctx -> chroma_factor - 1 , td -> qmat_chroma_scaled , 1 ) ;
decode_slice_plane ( ctx , td , buf + hdr_size + y_data_size + u_data_size , v_data_size , ( uint16_t * ) ( v_data + ( mb_y_pos << 4 ) * v_linesize + ( mb_x_pos << ctx -> mb_chroma_factor ) ) , v_linesize , mbs_per_slice , ctx -> num_chroma_blocks , slice_width_factor + ctx -> chroma_factor - 1 , td -> qmat_chroma_scaled , 1 ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int64_t atol16 ( const char * p , unsigned char_cnt ) {
int64_t l ;
int digit ;
l = 0 ;
while ( char_cnt -- > 0 ) {
if ( * p >= 'a' && * p <= 'f' ) digit = * p - 'a' + 10 ;
else if ( * p >= 'A' && * p <= 'F' ) digit = * p - 'A' + 10 ;
else if ( * p >= '0' && * p <= '9' ) digit = * p - '0' ;
else return ( l ) ;
p ++ ;
l <<= 4 ;
l |= digit ;
}
return ( l ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int test_mod_exp_mont5 ( BIO * bp , BN_CTX * ctx ) {
BIGNUM * a , * p , * m , * d , * e ;
BN_MONT_CTX * mont ;
a = BN_new ( ) ;
p = BN_new ( ) ;
m = BN_new ( ) ;
d = BN_new ( ) ;
e = BN_new ( ) ;
mont = BN_MONT_CTX_new ( ) ;
BN_bntest_rand ( m , 1024 , 0 , 1 ) ;
BN_bntest_rand ( a , 1024 , 0 , 0 ) ;
BN_zero ( p ) ;
if ( ! BN_mod_exp_mont_consttime ( d , a , p , m , ctx , NULL ) ) return 0 ;
if ( ! BN_is_one ( d ) ) {
fprintf ( stderr , "Modular exponentiation test failed!\n" ) ;
return 0 ;
}
BN_bntest_rand ( p , 1024 , 0 , 0 ) ;
BN_zero ( a ) ;
if ( ! BN_mod_exp_mont_consttime ( d , a , p , m , ctx , NULL ) ) return 0 ;
if ( ! BN_is_zero ( d ) ) {
fprintf ( stderr , "Modular exponentiation test failed!\n" ) ;
return 0 ;
}
BN_one ( a ) ;
BN_MONT_CTX_set ( mont , m , ctx ) ;
if ( ! BN_from_montgomery ( e , a , mont , ctx ) ) return 0 ;
if ( ! BN_mod_exp_mont_consttime ( d , e , p , m , ctx , NULL ) ) return 0 ;
if ( ! BN_mod_exp_simple ( a , e , p , m , ctx ) ) return 0 ;
if ( BN_cmp ( a , d ) != 0 ) {
fprintf ( stderr , "Modular exponentiation test failed!\n" ) ;
return 0 ;
}
BN_bntest_rand ( e , 1024 , 0 , 0 ) ;
if ( ! BN_mod_exp_mont_consttime ( d , e , p , m , ctx , NULL ) ) return 0 ;
if ( ! BN_mod_exp_simple ( a , e , p , m , ctx ) ) return 0 ;
if ( BN_cmp ( a , d ) != 0 ) {
fprintf ( stderr , "Modular exponentiation test failed!\n" ) ;
return 0 ;
}
BN_free ( a ) ;
BN_free ( p ) ;
BN_free ( m ) ;
BN_free ( d ) ;
BN_free ( e ) ;
return ( 1 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void test_bug54041_impl ( ) {
int rc ;
MYSQL_STMT * stmt ;
MYSQL_BIND bind ;
DBUG_ENTER ( "test_bug54041" ) ;
myheader ( "test_bug54041" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS t1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE t1 (a INT)" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "SELECT a FROM t1 WHERE a > ?" ) ;
check_stmt ( stmt ) ;
verify_param_count ( stmt , 1 ) ;
memset ( & bind , 0 , sizeof ( bind ) ) ;
bind . buffer_type = MYSQL_TYPE_LONG ;
rc = mysql_stmt_bind_param ( stmt , & bind ) ;
check_execute ( stmt , rc ) ;
stmt -> params [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
rc = mysql_stmt_send_long_data ( stmt , 0 , "data" , 5 ) ;
check_execute ( stmt , rc ) ;
stmt -> params [ 0 ] . buffer_type = MYSQL_TYPE_LONG ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute_r ( stmt , rc ) ;
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS t1" ) ;
myquery ( rc ) ;
DBUG_VOID_RETURN ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
const char * proto_get_protocol_name ( const int proto_id ) {
protocol_t * protocol ;
protocol = find_protocol_by_id ( proto_id ) ;
if ( protocol == NULL ) return NULL ;
return protocol -> name ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int PEM_write_ ## name ( FILE * fp , const type * x ) ;
# define DECLARE_PEM_write_cb_fp ( name , type ) int PEM_write_ ## name ( FILE * fp , type * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
# endif # define DECLARE_PEM_read_bio ( name , type ) type * PEM_read_bio_ ## name ( BIO * bp , type * * x , pem_password_cb * cb , void * u ) ;
# define DECLARE_PEM_write_bio ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , type * x ) ;
# define DECLARE_PEM_write_bio_const ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , const type * x ) ;
# define DECLARE_PEM_write_cb_bio ( name , type ) int PEM_write_bio_ ## name ( BIO * bp , type * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
# define DECLARE_PEM_write ( name , type ) DECLARE_PEM_write_bio ( name , type ) DECLARE_PEM_write_fp ( name , type ) # define DECLARE_PEM_write_const ( name , type ) DECLARE_PEM_write_bio_const ( name , type ) DECLARE_PEM_write_fp_const ( name , type ) # define DECLARE_PEM_write_cb ( name , type ) DECLARE_PEM_write_cb_bio ( name , type ) DECLARE_PEM_write_cb_fp ( name , type ) # define DECLARE_PEM_read ( name , type ) DECLARE_PEM_read_bio ( name , type ) DECLARE_PEM_read_fp ( name , type ) # define DECLARE_PEM_rw ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write ( name , type ) # define DECLARE_PEM_rw_const ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_const ( name , type ) # define DECLARE_PEM_rw_cb ( name , type ) DECLARE_PEM_read ( name , type ) DECLARE_PEM_write_cb ( name , type ) typedef int pem_password_cb ( char * buf , int size , int rwflag , void * userdata ) ;
int PEM_get_EVP_CIPHER_INFO ( char * header , EVP_CIPHER_INFO * cipher ) ;
int PEM_do_header ( EVP_CIPHER_INFO * cipher , unsigned char * data , long * len , pem_password_cb * callback , void * u ) ;
int PEM_read_bio ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len ) ;
# define PEM_FLAG_SECURE 0x1 # define PEM_FLAG_EAY_COMPATIBLE 0x2 # define PEM_FLAG_ONLY_B64 0x4 int PEM_read_bio_ex ( BIO * bp , char * * name , char * * header , unsigned char * * data , long * len , unsigned int flags ) ;
int PEM_bytes_read_bio_secmem ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
int PEM_write_bio ( BIO * bp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
int PEM_bytes_read_bio ( unsigned char * * pdata , long * plen , char * * pnm , const char * name , BIO * bp , pem_password_cb * cb , void * u ) ;
void * PEM_ASN1_read_bio ( d2i_of_void * d2i , const char * name , BIO * bp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write_bio ( i2d_of_void * i2d , const char * name , BIO * bp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cb , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read_bio ( BIO * bp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
int PEM_X509_INFO_write_bio ( BIO * bp , X509_INFO * xi , EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * cd , void * u ) ;
# ifndef OPENSSL_NO_STDIO int PEM_read ( FILE * fp , char * * name , char * * header , unsigned char * * data , long * len ) ;
int PEM_write ( FILE * fp , const char * name , const char * hdr , const unsigned char * data , long len ) ;
void * PEM_ASN1_read ( d2i_of_void * d2i , const char * name , FILE * fp , void * * x , pem_password_cb * cb , void * u ) ;
int PEM_ASN1_write ( i2d_of_void * i2d , const char * name , FILE * fp , void * x , const EVP_CIPHER * enc , unsigned char * kstr , int klen , pem_password_cb * callback , void * u ) ;
STACK_OF ( X509_INFO ) * PEM_X509_INFO_read ( FILE * fp , STACK_OF ( X509_INFO ) * sk , pem_password_cb * cb , void * u ) ;
# endif int PEM_SignInit ( EVP_MD_CTX * ctx , EVP_MD * type ) ;
int PEM_SignUpdate ( EVP_MD_CTX * ctx , unsigned char * d , unsigned int cnt ) ;
int PEM_SignFinal ( EVP_MD_CTX * ctx , unsigned char * sigret , unsigned int * siglen , EVP_PKEY * pkey ) ;
int PEM_def_callback ( char * buf , int num , int rwflag , void * userdata ) ;
void PEM_proc_type ( char * buf , int type ) ;
void PEM_dek_info ( char * buf , const char * type , int len , char * str ) ;
# include < openssl / symhacks . h > DECLARE_PEM_rw ( X509 , X509 ) DECLARE_PEM_rw ( X509_AUX , X509 ) DECLARE_PEM_rw ( X509_REQ , X509_REQ ) DECLARE_PEM_write ( X509_REQ_NEW , X509_REQ ) DECLARE_PEM_rw ( X509_CRL , X509_CRL ) DECLARE_PEM_rw ( PKCS7 , PKCS7 ) DECLARE_PEM_rw ( NETSCAPE_CERT_SEQUENCE , NETSCAPE_CERT_SEQUENCE ) DECLARE_PEM_rw ( PKCS8 , X509_SIG ) DECLARE_PEM_rw ( PKCS8_PRIV_KEY_INFO , PKCS8_PRIV_KEY_INFO ) # ifndef OPENSSL_NO_RSA DECLARE_PEM_rw_cb ( RSAPrivateKey , RSA ) DECLARE_PEM_rw_const ( RSAPublicKey , RSA )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int _ar_read_header ( struct archive_read * a , struct archive_entry * entry , struct ar * ar , const char * h , size_t * unconsumed ) {
char filename [ AR_name_size + 1 ] ;
uint64_t number ;
size_t bsd_name_length , entry_size ;
char * p , * st ;
const void * b ;
int r ;
if ( strncmp ( h + AR_fmag_offset , "`\n" , 2 ) != 0 ) {
archive_set_error ( & a -> archive , EINVAL , "Incorrect file header signature" ) ;
return ( ARCHIVE_FATAL ) ;
}
strncpy ( filename , h + AR_name_offset , AR_name_size ) ;
filename [ AR_name_size ] = '\0' ;
if ( a -> archive . archive_format == ARCHIVE_FORMAT_AR ) {
if ( strncmp ( filename , "#1/" , 3 ) == 0 ) a -> archive . archive_format = ARCHIVE_FORMAT_AR_BSD ;
else if ( strchr ( filename , '/' ) != NULL ) a -> archive . archive_format = ARCHIVE_FORMAT_AR_GNU ;
else if ( strncmp ( filename , "__.SYMDEF" , 9 ) == 0 ) a -> archive . archive_format = ARCHIVE_FORMAT_AR_BSD ;
}
if ( a -> archive . archive_format == ARCHIVE_FORMAT_AR_GNU ) a -> archive . archive_format_name = "ar (GNU/SVR4)" ;
else if ( a -> archive . archive_format == ARCHIVE_FORMAT_AR_BSD ) a -> archive . archive_format_name = "ar (BSD)" ;
else a -> archive . archive_format_name = "ar" ;
p = filename + AR_name_size - 1 ;
while ( p >= filename && * p == ' ' ) {
* p = '\0' ;
p -- ;
}
if ( filename [ 0 ] != '/' && p > filename && * p == '/' ) {
* p = '\0' ;
}
if ( p < filename ) {
archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , "Found entry with empty filename" ) ;
return ( ARCHIVE_FATAL ) ;
}
if ( strcmp ( filename , "//" ) == 0 ) {
ar_parse_common_header ( ar , entry , h ) ;
archive_entry_copy_pathname ( entry , filename ) ;
archive_entry_set_filetype ( entry , AE_IFREG ) ;
number = ar_atol10 ( h + AR_size_offset , AR_size_size ) ;
if ( number > SIZE_MAX ) {
archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , "Filename table too large" ) ;
return ( ARCHIVE_FATAL ) ;
}
entry_size = ( size_t ) number ;
if ( entry_size == 0 ) {
archive_set_error ( & a -> archive , EINVAL , "Invalid string table" ) ;
return ( ARCHIVE_FATAL ) ;
}
if ( ar -> strtab != NULL ) {
archive_set_error ( & a -> archive , EINVAL , "More than one string tables exist" ) ;
return ( ARCHIVE_FATAL ) ;
}
st = malloc ( entry_size ) ;
if ( st == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Can't allocate filename table buffer" ) ;
return ( ARCHIVE_FATAL ) ;
}
ar -> strtab = st ;
ar -> strtab_size = entry_size ;
if ( * unconsumed ) {
__archive_read_consume ( a , * unconsumed ) ;
* unconsumed = 0 ;
}
if ( ( b = __archive_read_ahead ( a , entry_size , NULL ) ) == NULL ) return ( ARCHIVE_FATAL ) ;
memcpy ( st , b , entry_size ) ;
__archive_read_consume ( a , entry_size ) ;
ar -> entry_bytes_remaining = 0 ;
archive_entry_set_size ( entry , ar -> entry_bytes_remaining ) ;
return ( ar_parse_gnu_filename_table ( a ) ) ;
}
if ( filename [ 0 ] == '/' && filename [ 1 ] >= '0' && filename [ 1 ] <= '9' ) {
number = ar_atol10 ( h + AR_name_offset + 1 , AR_name_size - 1 ) ;
if ( ar -> strtab == NULL || number > ar -> strtab_size ) {
archive_set_error ( & a -> archive , EINVAL , "Can't find long filename for GNU/SVR4 archive entry" ) ;
archive_entry_copy_pathname ( entry , filename ) ;
ar_parse_common_header ( ar , entry , h ) ;
return ( ARCHIVE_FATAL ) ;
}
archive_entry_copy_pathname ( entry , & ar -> strtab [ ( size_t ) number ] ) ;
return ( ar_parse_common_header ( ar , entry , h ) ) ;
}
if ( strncmp ( filename , "#1/" , 3 ) == 0 ) {
ar_parse_common_header ( ar , entry , h ) ;
number = ar_atol10 ( h + AR_name_offset + 3 , AR_name_size - 3 ) ;
bsd_name_length = ( size_t ) number ;
if ( number > ( uint64_t ) ( bsd_name_length + 1 ) || ( int64_t ) bsd_name_length > ar -> entry_bytes_remaining ) {
archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , "Bad input file size" ) ;
return ( ARCHIVE_FATAL ) ;
}
ar -> entry_bytes_remaining -= bsd_name_length ;
archive_entry_set_size ( entry , ar -> entry_bytes_remaining ) ;
if ( * unconsumed ) {
__archive_read_consume ( a , * unconsumed ) ;
* unconsumed = 0 ;
}
if ( ( b = __archive_read_ahead ( a , bsd_name_length , NULL ) ) == NULL ) {
archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , "Truncated input file" ) ;
return ( ARCHIVE_FATAL ) ;
}
p = ( char * ) malloc ( bsd_name_length + 1 ) ;
if ( p == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Can't allocate fname buffer" ) ;
return ( ARCHIVE_FATAL ) ;
}
strncpy ( p , b , bsd_name_length ) ;
p [ bsd_name_length ] = '\0' ;
__archive_read_consume ( a , bsd_name_length ) ;
archive_entry_copy_pathname ( entry , p ) ;
free ( p ) ;
return ( ARCHIVE_OK ) ;
}
if ( strcmp ( filename , "/" ) == 0 ) {
archive_entry_copy_pathname ( entry , "/" ) ;
r = ar_parse_common_header ( ar , entry , h ) ;
archive_entry_set_filetype ( entry , AE_IFREG ) ;
return ( r ) ;
}
if ( strcmp ( filename , "__.SYMDEF" ) == 0 ) {
archive_entry_copy_pathname ( entry , filename ) ;
return ( ar_parse_common_header ( ar , entry , h ) ) ;
}
archive_entry_copy_pathname ( entry , filename ) ;
return ( ar_parse_common_header ( ar , entry , h ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int decode_subframe ( TAKDecContext * s , int32_t * decoded , int subframe_size , int prev_subframe_size ) {
LOCAL_ALIGNED_16 ( int16_t , filter , [ MAX_PREDICTORS ] ) ;
GetBitContext * gb = & s -> gb ;
int i , ret ;
int dshift , size , filter_quant , filter_order ;
memset ( filter , 0 , MAX_PREDICTORS * sizeof ( * filter ) ) ;
if ( ! get_bits1 ( gb ) ) return decode_residues ( s , decoded , subframe_size ) ;
filter_order = predictor_sizes [ get_bits ( gb , 4 ) ] ;
if ( prev_subframe_size > 0 && get_bits1 ( gb ) ) {
if ( filter_order > prev_subframe_size ) return AVERROR_INVALIDDATA ;
decoded -= filter_order ;
subframe_size += filter_order ;
if ( filter_order > subframe_size ) return AVERROR_INVALIDDATA ;
}
else {
int lpc_mode ;
if ( filter_order > subframe_size ) return AVERROR_INVALIDDATA ;
lpc_mode = get_bits ( gb , 2 ) ;
if ( lpc_mode > 2 ) return AVERROR_INVALIDDATA ;
if ( ( ret = decode_residues ( s , decoded , filter_order ) ) < 0 ) return ret ;
if ( lpc_mode ) decode_lpc ( decoded , lpc_mode , filter_order ) ;
}
dshift = get_bits_esc4 ( gb ) ;
size = get_bits1 ( gb ) + 6 ;
filter_quant = 10 ;
if ( get_bits1 ( gb ) ) {
filter_quant -= get_bits ( gb , 3 ) + 1 ;
if ( filter_quant < 3 ) return AVERROR_INVALIDDATA ;
}
decode_filter_coeffs ( s , filter_order , size , filter_quant , filter ) ;
if ( ( ret = decode_residues ( s , & decoded [ filter_order ] , subframe_size - filter_order ) ) < 0 ) return ret ;
av_fast_malloc ( & s -> residues , & s -> residues_buf_size , FFALIGN ( subframe_size + 16 , 16 ) * sizeof ( * s -> residues ) ) ;
if ( ! s -> residues ) return AVERROR ( ENOMEM ) ;
memset ( s -> residues , 0 , s -> residues_buf_size ) ;
for ( i = 0 ;
i < filter_order ;
i ++ ) s -> residues [ i ] = * decoded ++ >> dshift ;
for ( i = 0 ;
i < subframe_size - filter_order ;
i ++ ) {
int v = 1 << ( filter_quant - 1 ) ;
v += s -> dsp . scalarproduct_int16 ( & s -> residues [ i ] , filter , FFALIGN ( filter_order , 16 ) ) ;
v = ( av_clip ( v >> filter_quant , - 8192 , 8191 ) << dshift ) - * decoded ;
* decoded ++ = v ;
s -> residues [ filter_order + i ] = v >> dshift ;
}
emms_c ( ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void jpc_ns_fwdlift_col ( jpc_fix_t * a , int numrows , int stride , int parity ) {
jpc_fix_t * lptr ;
jpc_fix_t * hptr ;
register jpc_fix_t * lptr2 ;
register jpc_fix_t * hptr2 ;
register int n ;
int llen ;
llen = ( numrows + 1 - parity ) >> 1 ;
if ( numrows > 1 ) {
lptr = & a [ 0 ] ;
hptr = & a [ llen * stride ] ;
if ( parity ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * ALPHA ) , lptr2 [ 0 ] ) ) ;
++ hptr2 ;
++ lptr2 ;
hptr += stride ;
}
n = numrows - llen - parity - ( parity == ( numrows & 1 ) ) ;
while ( n -- > 0 ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( ALPHA ) , jpc_fix_add ( lptr2 [ 0 ] , lptr2 [ stride ] ) ) ) ;
++ lptr2 ;
++ hptr2 ;
hptr += stride ;
lptr += stride ;
}
if ( parity == ( numrows & 1 ) ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * ALPHA ) , lptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
}
lptr = & a [ 0 ] ;
hptr = & a [ llen * stride ] ;
if ( ! parity ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * BETA ) , hptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
lptr += stride ;
}
n = llen - ( ! parity ) - ( parity != ( numrows & 1 ) ) ;
while ( n -- > 0 ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( BETA ) , jpc_fix_add ( hptr2 [ 0 ] , hptr2 [ stride ] ) ) ) ;
++ lptr2 ;
++ hptr2 ;
lptr += stride ;
hptr += stride ;
}
if ( parity != ( numrows & 1 ) ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * BETA ) , hptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
}
lptr = & a [ 0 ] ;
hptr = & a [ llen * stride ] ;
if ( parity ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * GAMMA ) , lptr2 [ 0 ] ) ) ;
++ hptr2 ;
++ lptr2 ;
hptr += stride ;
}
n = numrows - llen - parity - ( parity == ( numrows & 1 ) ) ;
while ( n -- > 0 ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( GAMMA ) , jpc_fix_add ( lptr2 [ 0 ] , lptr2 [ stride ] ) ) ) ;
++ lptr2 ;
++ hptr2 ;
hptr += stride ;
lptr += stride ;
}
if ( parity == ( numrows & 1 ) ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( hptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * GAMMA ) , lptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
}
lptr = & a [ 0 ] ;
hptr = & a [ llen * stride ] ;
if ( ! parity ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * DELTA ) , hptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
lptr += stride ;
}
n = llen - ( ! parity ) - ( parity != ( numrows & 1 ) ) ;
while ( n -- > 0 ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( DELTA ) , jpc_fix_add ( hptr2 [ 0 ] , hptr2 [ stride ] ) ) ) ;
++ lptr2 ;
++ hptr2 ;
lptr += stride ;
hptr += stride ;
}
if ( parity != ( numrows & 1 ) ) {
lptr2 = lptr ;
hptr2 = hptr ;
jpc_fix_pluseq ( lptr2 [ 0 ] , jpc_fix_mul ( jpc_dbltofix ( 2.0 * DELTA ) , hptr2 [ 0 ] ) ) ;
++ lptr2 ;
++ hptr2 ;
}
# if defined ( WT_DOSCALE ) lptr = & a [ 0 ] ;
n = llen ;
while ( n -- > 0 ) {
lptr2 = lptr ;
lptr2 [ 0 ] = jpc_fix_mul ( lptr2 [ 0 ] , jpc_dbltofix ( LGAIN ) ) ;
++ lptr2 ;
lptr += stride ;
}
hptr = & a [ llen * stride ] ;
n = numrows - llen ;
while ( n -- > 0 ) {
hptr2 = hptr ;
hptr2 [ 0 ] = jpc_fix_mul ( hptr2 [ 0 ] , jpc_dbltofix ( HGAIN ) ) ;
++ hptr2 ;
hptr += stride ;
}
# endif }
else {
# if defined ( WT_LENONE ) if ( parity ) {
lptr2 = & a [ 0 ] ;
lptr2 [ 0 ] = jpc_fix_asl ( lptr2 [ 0 ] , 1 ) ;
++ lptr2 ;
}
# endif }
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST_F ( ExtensionServiceSyncTest , GetSyncDataTerminated ) {
InitializeEmptyExtensionService ( ) ;
InstallCRX ( data_dir ( ) . AppendASCII ( "good.crx" ) , INSTALL_NEW ) ;
TerminateExtension ( good_crx ) ;
const Extension * extension = service ( ) -> GetInstalledExtension ( good_crx ) ;
ASSERT_TRUE ( extension ) ;
extension_sync_service ( ) -> MergeDataAndStartSyncing ( syncer : : EXTENSIONS , syncer : : SyncDataList ( ) , base : : MakeUnique < syncer : : FakeSyncChangeProcessor > ( ) , base : : MakeUnique < syncer : : SyncErrorFactoryMock > ( ) ) ;
syncer : : SyncDataList list = extension_sync_service ( ) -> GetAllSyncData ( syncer : : EXTENSIONS ) ;
ASSERT_EQ ( list . size ( ) , 1U ) ;
std : : unique_ptr < ExtensionSyncData > data = ExtensionSyncData : : CreateFromSyncData ( list [ 0 ] ) ;
ASSERT_TRUE ( data . get ( ) ) ;
EXPECT_EQ ( extension -> id ( ) , data -> id ( ) ) ;
EXPECT_FALSE ( data -> uninstalled ( ) ) ;
EXPECT_EQ ( service ( ) -> IsExtensionEnabled ( good_crx ) , data -> enabled ( ) ) ;
EXPECT_EQ ( extensions : : util : : IsIncognitoEnabled ( good_crx , profile ( ) ) , data -> incognito_enabled ( ) ) ;
EXPECT_EQ ( ExtensionSyncData : : BOOLEAN_UNSET , data -> all_urls_enabled ( ) ) ;
EXPECT_EQ ( data -> version ( ) , * extension -> version ( ) ) ;
EXPECT_EQ ( extensions : : ManifestURL : : GetUpdateURL ( extension ) , data -> update_url ( ) ) ;
EXPECT_EQ ( extension -> name ( ) , data -> name ( ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static block_t * DecoderBlockFlushNew ( ) {
block_t * p_null = block_Alloc ( 128 ) ;
if ( ! p_null ) return NULL ;
p_null -> i_flags |= BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED | BLOCK_FLAG_CORE_FLUSH ;
memset ( p_null -> p_buffer , 0 , p_null -> i_buffer ) ;
return p_null ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void ber_check_value64 ( gint64 value , gint64 min_len , gint64 max_len , asn1_ctx_t * actx , proto_item * item ) {
if ( ( min_len != - 1 ) && ( value < min_len ) ) {
expert_add_info_format ( actx -> pinfo , item , & ei_ber_size_constraint_value , "Size constraint: value too small: %" G_GINT64_MODIFIER "d (%" G_GINT64_MODIFIER "d .. %" G_GINT64_MODIFIER "d)" , value , min_len , max_len ) ;
}
else if ( ( max_len != - 1 ) && ( value > max_len ) ) {
expert_add_info_format ( actx -> pinfo , item , & ei_ber_size_constraint_value , "Size constraint: value too big: %" G_GINT64_MODIFIER "d (%" G_GINT64_MODIFIER "d .. %" G_GINT64_MODIFIER "d)" , value , min_len , max_len ) ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void do_encrypt ( MPI a , MPI b , MPI input , ELG_public_key * pkey ) {
MPI k ;
k = gen_k ( pkey -> p , 1 ) ;
mpi_powm ( a , pkey -> g , k , pkey -> p ) ;
mpi_powm ( b , pkey -> y , k , pkey -> p ) ;
mpi_mulm ( b , b , input , pkey -> p ) ;
# if 0 if ( DBG_CIPHER ) {
log_mpidump ( "elg encrypted y= " , pkey -> y ) ;
log_mpidump ( "elg encrypted p= " , pkey -> p ) ;
log_mpidump ( "elg encrypted k= " , k ) ;
log_mpidump ( "elg encrypted M= " , input ) ;
log_mpidump ( "elg encrypted a= " , a ) ;
log_mpidump ( "elg encrypted b= " , b ) ;
}
# endif mpi_free ( k ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void gst_asf_demux_init ( GstASFDemux * demux ) {
demux -> sinkpad = gst_pad_new_from_static_template ( & gst_asf_demux_sink_template , "sink" ) ;
gst_pad_set_chain_function ( demux -> sinkpad , GST_DEBUG_FUNCPTR ( gst_asf_demux_chain ) ) ;
gst_pad_set_event_function ( demux -> sinkpad , GST_DEBUG_FUNCPTR ( gst_asf_demux_sink_event ) ) ;
gst_pad_set_activate_function ( demux -> sinkpad , GST_DEBUG_FUNCPTR ( gst_asf_demux_activate ) ) ;
gst_pad_set_activatemode_function ( demux -> sinkpad , GST_DEBUG_FUNCPTR ( gst_asf_demux_activate_mode ) ) ;
gst_element_add_pad ( GST_ELEMENT ( demux ) , demux -> sinkpad ) ;
gst_asf_demux_reset ( demux , FALSE ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h225_Connect_UUIE ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 528 "./asn1/h225/h225.cnf" h225_packet_info * h225_pi ;
offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h225_Connect_UUIE , Connect_UUIE_sequence ) ;
# line 532 "./asn1/h225/h225.cnf" h225_pi = ( h225_packet_info * ) p_get_proto_data ( wmem_packet_scope ( ) , actx -> pinfo , proto_h225 , 0 ) ;
if ( h225_pi != NULL ) {
h225_pi -> cs_type = H225_CONNECT ;
if ( contains_faststart == TRUE ) g_snprintf ( h225_pi -> frame_label , 50 , "%s OLC (%s)" , val_to_str ( h225_pi -> cs_type , T_h323_message_body_vals , "<unknown>" ) , h225_pi -> frame_label ) ;
else g_snprintf ( h225_pi -> frame_label , 50 , "%s" , val_to_str ( h225_pi -> cs_type , T_h323_message_body_vals , "<unknown>" ) ) ;
}
return offset ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void redoloca ( struct alltabs * at ) {
int i ;
at -> loca = tmpfile ( ) ;
if ( at -> head . locais32 ) {
for ( i = 0 ;
i <= at -> maxp . numGlyphs ;
++ i ) putlong ( at -> loca , at -> gi . loca [ i ] ) ;
at -> localen = sizeof ( int32 ) * ( at -> maxp . numGlyphs + 1 ) ;
}
else {
for ( i = 0 ;
i <= at -> maxp . numGlyphs ;
++ i ) putshort ( at -> loca , at -> gi . loca [ i ] / 2 ) ;
at -> localen = sizeof ( int16 ) * ( at -> maxp . numGlyphs + 1 ) ;
if ( ftell ( at -> loca ) & 2 ) putshort ( at -> loca , 0 ) ;
}
if ( at -> format != ff_type42 && at -> format != ff_type42cid ) {
free ( at -> gi . loca ) ;
at -> gi . loca = NULL ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_GeneralString ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_GeneralString ( tvb , offset , actx , tree , hf_index ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int ssl3_read_bytes ( SSL * s , int type , int * recvd_type , unsigned char * buf , int len , int peek ) {
int al , i , j , ret ;
unsigned int n , curr_rec , num_recs , read_bytes ;
SSL3_RECORD * rr ;
SSL3_BUFFER * rbuf ;
void ( * cb ) ( const SSL * ssl , int type2 , int val ) = NULL ;
rbuf = & s -> rlayer . rbuf ;
if ( ! SSL3_BUFFER_is_initialised ( rbuf ) ) {
if ( ! ssl3_setup_read_buffer ( s ) ) return ( - 1 ) ;
}
if ( ( type && ( type != SSL3_RT_APPLICATION_DATA ) && ( type != SSL3_RT_HANDSHAKE ) ) || ( peek && ( type != SSL3_RT_APPLICATION_DATA ) ) ) {
SSLerr ( SSL_F_SSL3_READ_BYTES , ERR_R_INTERNAL_ERROR ) ;
return - 1 ;
}
if ( ( type == SSL3_RT_HANDSHAKE ) && ( s -> rlayer . handshake_fragment_len > 0 ) ) {
unsigned char * src = s -> rlayer . handshake_fragment ;
unsigned char * dst = buf ;
unsigned int k ;
n = 0 ;
while ( ( len > 0 ) && ( s -> rlayer . handshake_fragment_len > 0 ) ) {
* dst ++ = * src ++ ;
len -- ;
s -> rlayer . handshake_fragment_len -- ;
n ++ ;
}
for ( k = 0 ;
k < s -> rlayer . handshake_fragment_len ;
k ++ ) s -> rlayer . handshake_fragment [ k ] = * src ++ ;
if ( recvd_type != NULL ) * recvd_type = SSL3_RT_HANDSHAKE ;
return n ;
}
if ( ! ossl_statem_get_in_handshake ( s ) && SSL_in_init ( s ) ) {
i = s -> handshake_func ( s ) ;
if ( i < 0 ) return ( i ) ;
if ( i == 0 ) {
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_SSL_HANDSHAKE_FAILURE ) ;
return ( - 1 ) ;
}
}
start : s -> rwstate = SSL_NOTHING ;
rr = s -> rlayer . rrec ;
num_recs = RECORD_LAYER_get_numrpipes ( & s -> rlayer ) ;
do {
if ( num_recs == 0 ) {
ret = ssl3_get_record ( s ) ;
if ( ret <= 0 ) return ( ret ) ;
num_recs = RECORD_LAYER_get_numrpipes ( & s -> rlayer ) ;
if ( num_recs == 0 ) {
al = SSL_AD_INTERNAL_ERROR ;
SSLerr ( SSL_F_SSL3_READ_BYTES , ERR_R_INTERNAL_ERROR ) ;
goto f_err ;
}
}
for ( curr_rec = 0 ;
curr_rec < num_recs && SSL3_RECORD_is_read ( & rr [ curr_rec ] ) ;
curr_rec ++ ) ;
if ( curr_rec == num_recs ) {
RECORD_LAYER_set_numrpipes ( & s -> rlayer , 0 ) ;
num_recs = 0 ;
curr_rec = 0 ;
}
}
while ( num_recs == 0 ) ;
rr = & rr [ curr_rec ] ;
if ( SSL3_RECORD_get_type ( rr ) != SSL3_RT_ALERT && SSL3_RECORD_get_length ( rr ) != 0 ) s -> rlayer . alert_count = 0 ;
if ( s -> s3 -> change_cipher_spec && ( SSL3_RECORD_get_type ( rr ) != SSL3_RT_HANDSHAKE ) ) {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ) ;
goto f_err ;
}
if ( s -> shutdown & SSL_RECEIVED_SHUTDOWN ) {
SSL3_RECORD_set_length ( rr , 0 ) ;
s -> rwstate = SSL_NOTHING ;
return ( 0 ) ;
}
if ( type == SSL3_RECORD_get_type ( rr ) || ( SSL3_RECORD_get_type ( rr ) == SSL3_RT_CHANGE_CIPHER_SPEC && type == SSL3_RT_HANDSHAKE && recvd_type != NULL ) ) {
if ( SSL_in_init ( s ) && ( type == SSL3_RT_APPLICATION_DATA ) && ( s -> enc_read_ctx == NULL ) ) {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_APP_DATA_IN_HANDSHAKE ) ;
goto f_err ;
}
if ( type == SSL3_RT_HANDSHAKE && SSL3_RECORD_get_type ( rr ) == SSL3_RT_CHANGE_CIPHER_SPEC && s -> rlayer . handshake_fragment_len > 0 ) {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_CCS_RECEIVED_EARLY ) ;
goto f_err ;
}
if ( recvd_type != NULL ) * recvd_type = SSL3_RECORD_get_type ( rr ) ;
if ( len <= 0 ) return ( len ) ;
read_bytes = 0 ;
do {
if ( ( unsigned int ) len - read_bytes > SSL3_RECORD_get_length ( rr ) ) n = SSL3_RECORD_get_length ( rr ) ;
else n = ( unsigned int ) len - read_bytes ;
memcpy ( buf , & ( rr -> data [ rr -> off ] ) , n ) ;
buf += n ;
if ( ! peek ) {
SSL3_RECORD_sub_length ( rr , n ) ;
SSL3_RECORD_add_off ( rr , n ) ;
if ( SSL3_RECORD_get_length ( rr ) == 0 ) {
s -> rlayer . rstate = SSL_ST_READ_HEADER ;
SSL3_RECORD_set_off ( rr , 0 ) ;
SSL3_RECORD_set_read ( rr ) ;
}
}
if ( SSL3_RECORD_get_length ( rr ) == 0 || ( peek && n == SSL3_RECORD_get_length ( rr ) ) ) {
curr_rec ++ ;
rr ++ ;
}
read_bytes += n ;
}
while ( type == SSL3_RT_APPLICATION_DATA && curr_rec < num_recs && read_bytes < ( unsigned int ) len ) ;
if ( read_bytes == 0 ) {
goto start ;
}
if ( ! peek && curr_rec == num_recs && ( s -> mode & SSL_MODE_RELEASE_BUFFERS ) && SSL3_BUFFER_get_left ( rbuf ) == 0 ) ssl3_release_read_buffer ( s ) ;
return read_bytes ;
}
if ( rr -> rec_version == SSL2_VERSION ) {
al = SSL_AD_INTERNAL_ERROR ;
SSLerr ( SSL_F_SSL3_READ_BYTES , ERR_R_INTERNAL_ERROR ) ;
goto f_err ;
}
if ( s -> method -> version == TLS_ANY_VERSION && ( s -> server || rr -> type != SSL3_RT_ALERT ) ) {
s -> version = rr -> rec_version ;
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_UNEXPECTED_MESSAGE ) ;
goto f_err ;
}
{
unsigned int dest_maxlen = 0 ;
unsigned char * dest = NULL ;
unsigned int * dest_len = NULL ;
if ( SSL3_RECORD_get_type ( rr ) == SSL3_RT_HANDSHAKE ) {
dest_maxlen = sizeof s -> rlayer . handshake_fragment ;
dest = s -> rlayer . handshake_fragment ;
dest_len = & s -> rlayer . handshake_fragment_len ;
}
else if ( SSL3_RECORD_get_type ( rr ) == SSL3_RT_ALERT ) {
dest_maxlen = sizeof s -> rlayer . alert_fragment ;
dest = s -> rlayer . alert_fragment ;
dest_len = & s -> rlayer . alert_fragment_len ;
}
if ( dest_maxlen > 0 ) {
n = dest_maxlen - * dest_len ;
if ( SSL3_RECORD_get_length ( rr ) < n ) n = SSL3_RECORD_get_length ( rr ) ;
while ( n -- > 0 ) {
dest [ ( * dest_len ) ++ ] = SSL3_RECORD_get_data ( rr ) [ SSL3_RECORD_get_off ( rr ) ] ;
SSL3_RECORD_add_off ( rr , 1 ) ;
SSL3_RECORD_add_length ( rr , - 1 ) ;
}
if ( * dest_len < dest_maxlen ) {
SSL3_RECORD_set_read ( rr ) ;
goto start ;
}
}
}
if ( ( ! s -> server ) && ( s -> rlayer . handshake_fragment_len >= 4 ) && ( s -> rlayer . handshake_fragment [ 0 ] == SSL3_MT_HELLO_REQUEST ) && ( s -> session != NULL ) && ( s -> session -> cipher != NULL ) ) {
s -> rlayer . handshake_fragment_len = 0 ;
if ( ( s -> rlayer . handshake_fragment [ 1 ] != 0 ) || ( s -> rlayer . handshake_fragment [ 2 ] != 0 ) || ( s -> rlayer . handshake_fragment [ 3 ] != 0 ) ) {
al = SSL_AD_DECODE_ERROR ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_BAD_HELLO_REQUEST ) ;
goto f_err ;
}
if ( s -> msg_callback ) s -> msg_callback ( 0 , s -> version , SSL3_RT_HANDSHAKE , s -> rlayer . handshake_fragment , 4 , s , s -> msg_callback_arg ) ;
if ( SSL_is_init_finished ( s ) && ! ( s -> s3 -> flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS ) && ! s -> s3 -> renegotiate ) {
ssl3_renegotiate ( s ) ;
if ( ssl3_renegotiate_check ( s ) ) {
i = s -> handshake_func ( s ) ;
if ( i < 0 ) return ( i ) ;
if ( i == 0 ) {
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_SSL_HANDSHAKE_FAILURE ) ;
return ( - 1 ) ;
}
if ( ! ( s -> mode & SSL_MODE_AUTO_RETRY ) ) {
if ( SSL3_BUFFER_get_left ( rbuf ) == 0 ) {
BIO * bio ;
s -> rwstate = SSL_READING ;
bio = SSL_get_rbio ( s ) ;
BIO_clear_retry_flags ( bio ) ;
BIO_set_retry_read ( bio ) ;
return ( - 1 ) ;
}
}
}
}
goto start ;
}
if ( s -> server && SSL_is_init_finished ( s ) && ! s -> s3 -> send_connection_binding && ( s -> version > SSL3_VERSION ) && ( s -> rlayer . handshake_fragment_len >= 4 ) && ( s -> rlayer . handshake_fragment [ 0 ] == SSL3_MT_CLIENT_HELLO ) && ( s -> session != NULL ) && ( s -> session -> cipher != NULL ) && ! ( s -> ctx -> options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION ) ) {
SSL3_RECORD_set_length ( rr , 0 ) ;
SSL3_RECORD_set_read ( rr ) ;
ssl3_send_alert ( s , SSL3_AL_WARNING , SSL_AD_NO_RENEGOTIATION ) ;
goto start ;
}
if ( s -> rlayer . alert_fragment_len >= 2 ) {
int alert_level = s -> rlayer . alert_fragment [ 0 ] ;
int alert_descr = s -> rlayer . alert_fragment [ 1 ] ;
s -> rlayer . alert_fragment_len = 0 ;
if ( s -> msg_callback ) s -> msg_callback ( 0 , s -> version , SSL3_RT_ALERT , s -> rlayer . alert_fragment , 2 , s , s -> msg_callback_arg ) ;
if ( s -> info_callback != NULL ) cb = s -> info_callback ;
else if ( s -> ctx -> info_callback != NULL ) cb = s -> ctx -> info_callback ;
if ( cb != NULL ) {
j = ( alert_level << 8 ) | alert_descr ;
cb ( s , SSL_CB_READ_ALERT , j ) ;
}
if ( alert_level == SSL3_AL_WARNING ) {
s -> s3 -> warn_alert = alert_descr ;
SSL3_RECORD_set_read ( rr ) ;
s -> rlayer . alert_count ++ ;
if ( s -> rlayer . alert_count == MAX_WARN_ALERT_COUNT ) {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_TOO_MANY_WARN_ALERTS ) ;
goto f_err ;
}
if ( alert_descr == SSL_AD_CLOSE_NOTIFY ) {
s -> shutdown |= SSL_RECEIVED_SHUTDOWN ;
return ( 0 ) ;
}
else if ( alert_descr == SSL_AD_NO_RENEGOTIATION ) {
al = SSL_AD_HANDSHAKE_FAILURE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_NO_RENEGOTIATION ) ;
goto f_err ;
}
# ifdef SSL_AD_MISSING_SRP_USERNAME else if ( alert_descr == SSL_AD_MISSING_SRP_USERNAME ) return ( 0 ) ;
# endif }
else if ( alert_level == SSL3_AL_FATAL ) {
char tmp [ 16 ] ;
s -> rwstate = SSL_NOTHING ;
s -> s3 -> fatal_alert = alert_descr ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_AD_REASON_OFFSET + alert_descr ) ;
BIO_snprintf ( tmp , sizeof tmp , "%d" , alert_descr ) ;
ERR_add_error_data ( 2 , "SSL alert number " , tmp ) ;
s -> shutdown |= SSL_RECEIVED_SHUTDOWN ;
SSL3_RECORD_set_read ( rr ) ;
SSL_CTX_remove_session ( s -> session_ctx , s -> session ) ;
return ( 0 ) ;
}
else {
al = SSL_AD_ILLEGAL_PARAMETER ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_UNKNOWN_ALERT_TYPE ) ;
goto f_err ;
}
goto start ;
}
if ( s -> shutdown & SSL_SENT_SHUTDOWN ) {
s -> rwstate = SSL_NOTHING ;
SSL3_RECORD_set_length ( rr , 0 ) ;
SSL3_RECORD_set_read ( rr ) ;
return ( 0 ) ;
}
if ( SSL3_RECORD_get_type ( rr ) == SSL3_RT_CHANGE_CIPHER_SPEC ) {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_CCS_RECEIVED_EARLY ) ;
goto f_err ;
}
if ( ( s -> rlayer . handshake_fragment_len >= 4 ) && ! ossl_statem_get_in_handshake ( s ) ) {
if ( SSL_is_init_finished ( s ) && ! ( s -> s3 -> flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS ) ) {
ossl_statem_set_in_init ( s , 1 ) ;
s -> renegotiate = 1 ;
s -> new_session = 1 ;
}
i = s -> handshake_func ( s ) ;
if ( i < 0 ) return ( i ) ;
if ( i == 0 ) {
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_SSL_HANDSHAKE_FAILURE ) ;
return ( - 1 ) ;
}
if ( ! ( s -> mode & SSL_MODE_AUTO_RETRY ) ) {
if ( SSL3_BUFFER_get_left ( rbuf ) == 0 ) {
BIO * bio ;
s -> rwstate = SSL_READING ;
bio = SSL_get_rbio ( s ) ;
BIO_clear_retry_flags ( bio ) ;
BIO_set_retry_read ( bio ) ;
return ( - 1 ) ;
}
}
goto start ;
}
switch ( SSL3_RECORD_get_type ( rr ) ) {
default : if ( s -> version >= TLS1_VERSION && s -> version <= TLS1_1_VERSION ) {
SSL3_RECORD_set_length ( rr , 0 ) ;
SSL3_RECORD_set_read ( rr ) ;
goto start ;
}
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_UNEXPECTED_RECORD ) ;
goto f_err ;
case SSL3_RT_CHANGE_CIPHER_SPEC : case SSL3_RT_ALERT : case SSL3_RT_HANDSHAKE : al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , ERR_R_INTERNAL_ERROR ) ;
goto f_err ;
case SSL3_RT_APPLICATION_DATA : if ( ossl_statem_app_data_allowed ( s ) ) {
s -> s3 -> in_read_app_data = 2 ;
return ( - 1 ) ;
}
else {
al = SSL_AD_UNEXPECTED_MESSAGE ;
SSLerr ( SSL_F_SSL3_READ_BYTES , SSL_R_UNEXPECTED_RECORD ) ;
goto f_err ;
}
}
f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ;
return ( - 1 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_h245_SEQUENCE_SIZE_1_256_OF_RedundancyEncodingCapability ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_constrained_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h245_SEQUENCE_SIZE_1_256_OF_RedundancyEncodingCapability , SEQUENCE_SIZE_1_256_OF_RedundancyEncodingCapability_sequence_of , 1 , 256 , FALSE ) ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int bad_option ( struct superblock_security_struct * sbsec , char flag , u32 old_sid , u32 new_sid ) {
char mnt_flags = sbsec -> flags & SE_MNTMASK ;
if ( sbsec -> flags & SE_SBINITIALIZED ) if ( ! ( sbsec -> flags & flag ) || ( old_sid != new_sid ) ) return 1 ;
if ( ! ( sbsec -> flags & SE_SBINITIALIZED ) ) if ( mnt_flags & flag ) return 1 ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static gboolean is_readable_response ( guint8 opcode ) {
return ( opcode == ATT_OPCODE_READ_RESPONSE || opcode == ATT_OPCODE_READ_BLOB_RESPONSE || opcode == ATT_OPCODE_READ_BY_TYPE_RESPONSE || opcode == ATT_OPCODE_READ_MULTIPLE_RESPONSE ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int evhttp_is_connection_keepalive ( struct evkeyvalq * headers ) {
const char * connection = evhttp_find_header ( headers , "Connection" ) ;
return ( connection != NULL && strncasecmp ( connection , "keep-alive" , 10 ) == 0 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static PyObject * basestring_new ( PyTypeObject * type , PyObject * args , PyObject * kwds ) {
PyErr_SetString ( PyExc_TypeError , "The basestring type cannot be instantiated" ) ;
return NULL ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
inline const UChar * toUCharPtr ( const char16_t * p ) {
# ifdef U_ALIASING_BARRIER U_ALIASING_BARRIER ( p ) ;
# endif return reinterpret_cast < const UChar * > ( p ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void vga_draw_line16_le ( VGACommonState * vga , uint8_t * d , uint32_t addr , int width ) {
int w ;
uint32_t v , r , g , b ;
w = width ;
do {
v = vga_read_word_le ( vga , addr ) ;
r = ( v >> 8 ) & 0xf8 ;
g = ( v >> 3 ) & 0xfc ;
b = ( v << 3 ) & 0xf8 ;
( ( uint32_t * ) d ) [ 0 ] = rgb_to_pixel32 ( r , g , b ) ;
addr += 2 ;
d += 4 ;
}
while ( -- w != 0 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int EVP_DecodeFinal ( EVP_ENCODE_CTX * ctx , unsigned char * out , int * outl ) {
int i ;
* outl = 0 ;
if ( ctx -> num != 0 ) {
i = EVP_DecodeBlock ( out , ctx -> enc_data , ctx -> num ) ;
if ( i < 0 ) return ( - 1 ) ;
ctx -> num = 0 ;
* outl = i ;
return ( 1 ) ;
}
else return ( 1 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST_F ( ProtocolHandlerRegistryTest , TestIsRegistered ) {
ProtocolHandler ph1 = CreateProtocolHandler ( "test" , "test1" ) ;
ProtocolHandler ph2 = CreateProtocolHandler ( "test" , "test2" ) ;
registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ;
registry ( ) -> OnAcceptRegisterProtocolHandler ( ph2 ) ;
ASSERT_TRUE ( registry ( ) -> IsRegistered ( ph1 ) ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
proto_item * proto_tree_add_boolean ( proto_tree * tree , int hfindex , tvbuff_t * tvb , gint start , gint length , guint32 value ) {
proto_item * pi ;
header_field_info * hfinfo ;
CHECK_FOR_NULL_TREE ( tree ) ;
TRY_TO_FAKE_THIS_ITEM ( tree , hfindex , hfinfo ) ;
DISSECTOR_ASSERT_FIELD_TYPE ( hfinfo , FT_BOOLEAN ) ;
pi = proto_tree_add_pi ( tree , hfinfo , tvb , start , & length ) ;
proto_tree_set_boolean ( PNODE_FINFO ( pi ) , value ) ;
return pi ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
void aes_crypt_ecb ( aes_context * ctx , int mode , const unsigned char input [ 16 ] , unsigned char output [ 16 ] ) {
int i ;
unsigned long * RK , X0 , X1 , X2 , X3 , Y0 , Y1 , Y2 , Y3 ;
# if defined ( XYSSL_PADLOCK_C ) && defined ( XYSSL_HAVE_X86 ) if ( padlock_supports ( PADLOCK_ACE ) ) {
if ( padlock_xcryptecb ( ctx , mode , input , output ) == 0 ) return ;
}
# endif if ( ctx == NULL || ctx -> rk == NULL ) return ;
RK = ctx -> rk ;
GET_ULONG_LE ( X0 , input , 0 ) ;
X0 ^= * RK ++ ;
GET_ULONG_LE ( X1 , input , 4 ) ;
X1 ^= * RK ++ ;
GET_ULONG_LE ( X2 , input , 8 ) ;
X2 ^= * RK ++ ;
GET_ULONG_LE ( X3 , input , 12 ) ;
X3 ^= * RK ++ ;
if ( mode == AES_DECRYPT ) {
for ( i = ( ctx -> nr >> 1 ) - 1 ;
i > 0 ;
i -- ) {
AES_RROUND ( Y0 , Y1 , Y2 , Y3 , X0 , X1 , X2 , X3 ) ;
AES_RROUND ( X0 , X1 , X2 , X3 , Y0 , Y1 , Y2 , Y3 ) ;
}
AES_RROUND ( Y0 , Y1 , Y2 , Y3 , X0 , X1 , X2 , X3 ) ;
X0 = * RK ++ ^ ( RSb [ ( Y0 ) & 0xFF ] ) ^ ( RSb [ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb [ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) RSb [ ( Y1 >> 24 ) & 0xFF ] ) << 24 ) ;
X1 = * RK ++ ^ ( RSb [ ( Y1 ) & 0xFF ] ) ^ ( RSb [ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb [ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) RSb [ ( Y2 >> 24 ) & 0xFF ] ) << 24 ) ;
X2 = * RK ++ ^ ( RSb [ ( Y2 ) & 0xFF ] ) ^ ( RSb [ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb [ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) RSb [ ( Y3 >> 24 ) & 0xFF ] ) << 24 ) ;
X3 = * RK ++ ^ ( RSb [ ( Y3 ) & 0xFF ] ) ^ ( RSb [ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb [ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) RSb [ ( Y0 >> 24 ) & 0xFF ] ) << 24 ) ;
}
else {
for ( i = ( ctx -> nr >> 1 ) - 1 ;
i > 0 ;
i -- ) {
AES_FROUND ( Y0 , Y1 , Y2 , Y3 , X0 , X1 , X2 , X3 ) ;
AES_FROUND ( X0 , X1 , X2 , X3 , Y0 , Y1 , Y2 , Y3 ) ;
}
AES_FROUND ( Y0 , Y1 , Y2 , Y3 , X0 , X1 , X2 , X3 ) ;
X0 = * RK ++ ^ ( FSb [ ( Y0 ) & 0xFF ] ) ^ ( FSb [ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb [ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) FSb [ ( Y3 >> 24 ) & 0xFF ] ) << 24 ) ;
X1 = * RK ++ ^ ( FSb [ ( Y1 ) & 0xFF ] ) ^ ( FSb [ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb [ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) FSb [ ( Y0 >> 24 ) & 0xFF ] ) << 24 ) ;
X2 = * RK ++ ^ ( FSb [ ( Y2 ) & 0xFF ] ) ^ ( FSb [ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb [ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) FSb [ ( Y1 >> 24 ) & 0xFF ] ) << 24 ) ;
X3 = * RK ++ ^ ( FSb [ ( Y3 ) & 0xFF ] ) ^ ( FSb [ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb [ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( ( ( unsigned int ) FSb [ ( Y2 >> 24 ) & 0xFF ] ) << 24 ) ;
}
PUT_ULONG_LE ( X0 , output , 0 ) ;
PUT_ULONG_LE ( X1 , output , 4 ) ;
PUT_ULONG_LE ( X2 , output , 8 ) ;
PUT_ULONG_LE ( X3 , output , 12 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
YV12_BUFFER_CONFIG * vp9_scale_if_required ( VP9_COMMON * cm , YV12_BUFFER_CONFIG * unscaled , YV12_BUFFER_CONFIG * scaled ) {
if ( cm -> mi_cols * MI_SIZE != unscaled -> y_width || cm -> mi_rows * MI_SIZE != unscaled -> y_height ) {
scale_and_extend_frame_nonnormative ( unscaled , scaled ) ;
return scaled ;
}
else {
return unscaled ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
Gif_Stream * Gif_FullReadFile ( FILE * f , int read_flags , const char * landmark , Gif_ReadErrorHandler h ) {
Gif_Reader grr ;
if ( ! f ) return 0 ;
grr . f = f ;
grr . pos = 0 ;
grr . is_record = 0 ;
grr . byte_getter = file_byte_getter ;
grr . block_getter = file_block_getter ;
grr . eofer = file_eofer ;
return read_gif ( & grr , read_flags , landmark , h ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static inline bool ipv6_addr_v4mapped ( const struct in6_addr * a ) {
return ( a -> s6_addr32 [ 0 ] | a -> s6_addr32 [ 1 ] | ( a -> s6_addr32 [ 2 ] ^ htonl ( 0x0000ffff ) ) ) == 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void x8_get_prediction ( IntraX8Context * const w ) {
MpegEncContext * const s = w -> s ;
int a , b , c , i ;
w -> edges = 1 * ( ! s -> mb_x ) ;
w -> edges |= 2 * ( ! s -> mb_y ) ;
w -> edges |= 4 * ( s -> mb_x >= ( 2 * s -> mb_width - 1 ) ) ;
switch ( w -> edges & 3 ) {
case 0 : break ;
case 1 : w -> est_run = w -> prediction_table [ ! ( s -> mb_y & 1 ) ] >> 2 ;
w -> orient = 1 ;
return ;
case 2 : w -> est_run = w -> prediction_table [ 2 * s -> mb_x - 2 ] >> 2 ;
w -> orient = 2 ;
return ;
case 3 : w -> est_run = 16 ;
w -> orient = 0 ;
return ;
}
/ o edge cases b = w -> prediction_table [ 2 * s -> mb_x + ! ( s -> mb_y & 1 ) ] ;
a = w -> prediction_table [ 2 * s -> mb_x - 2 + ( s -> mb_y & 1 ) ] ;
c = w -> prediction_table [ 2 * s -> mb_x - 2 + ! ( s -> mb_y & 1 ) ] ;
w -> est_run = FFMIN ( b , a ) ;
if ( ( s -> mb_x & s -> mb_y ) != 0 ) w -> est_run = FFMIN ( c , w -> est_run ) ;
w -> est_run >>= 2 ;
a &= 3 ;
b &= 3 ;
c &= 3 ;
i = ( 0xFFEAF4C4 >> ( 2 * b + 8 * a ) ) & 3 ;
if ( i != 3 ) w -> orient = i ;
else w -> orient = ( 0xFFEAD8 >> ( 2 * c + 8 * ( w -> quant > 12 ) ) ) & 3 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
int EC_GROUP_get_pentanomial_basis ( const EC_GROUP * group , unsigned int * k1 , unsigned int * k2 , unsigned int * k3 ) {
if ( group == NULL ) return 0 ;
if ( EC_GROUP_method_of ( group ) -> group_set_curve != ec_GF2m_simple_group_set_curve || ! ( ( group -> poly [ 0 ] != 0 ) && ( group -> poly [ 1 ] != 0 ) && ( group -> poly [ 2 ] != 0 ) && ( group -> poly [ 3 ] != 0 ) && ( group -> poly [ 4 ] == 0 ) ) ) {
ECerr ( EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS , ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ) ;
return 0 ;
}
if ( k1 ) * k1 = group -> poly [ 3 ] ;
if ( k2 ) * k2 = group -> poly [ 2 ] ;
if ( k3 ) * k3 = group -> poly [ 1 ] ;
return 1 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void fill_picture_parameters ( struct dxva_context * ctx , const H264Context * h , DXVA_PicParams_H264 * pp ) {
const Picture * current_picture = h -> cur_pic_ptr ;
int i , j ;
memset ( pp , 0 , sizeof ( * pp ) ) ;
fill_picture_entry ( & pp -> CurrPic , ff_dxva2_get_surface_index ( ctx , current_picture ) , h -> picture_structure == PICT_BOTTOM_FIELD ) ;
pp -> UsedForReferenceFlags = 0 ;
pp -> NonExistingFrameFlags = 0 ;
for ( i = 0 , j = 0 ;
i < FF_ARRAY_ELEMS ( pp -> RefFrameList ) ;
i ++ ) {
const Picture * r ;
if ( j < h -> short_ref_count ) {
r = h -> short_ref [ j ++ ] ;
}
else {
r = NULL ;
while ( ! r && j < h -> short_ref_count + 16 ) r = h -> long_ref [ j ++ - h -> short_ref_count ] ;
}
if ( r ) {
fill_picture_entry ( & pp -> RefFrameList [ i ] , ff_dxva2_get_surface_index ( ctx , r ) , r -> long_ref != 0 ) ;
if ( ( r -> f . reference & PICT_TOP_FIELD ) && r -> field_poc [ 0 ] != INT_MAX ) pp -> FieldOrderCntList [ i ] [ 0 ] = r -> field_poc [ 0 ] ;
if ( ( r -> f . reference & PICT_BOTTOM_FIELD ) && r -> field_poc [ 1 ] != INT_MAX ) pp -> FieldOrderCntList [ i ] [ 1 ] = r -> field_poc [ 1 ] ;
pp -> FrameNumList [ i ] = r -> long_ref ? r -> pic_id : r -> frame_num ;
if ( r -> f . reference & PICT_TOP_FIELD ) pp -> UsedForReferenceFlags |= 1 << ( 2 * i + 0 ) ;
if ( r -> f . reference & PICT_BOTTOM_FIELD ) pp -> UsedForReferenceFlags |= 1 << ( 2 * i + 1 ) ;
}
else {
pp -> RefFrameList [ i ] . bPicEntry = 0xff ;
pp -> FieldOrderCntList [ i ] [ 0 ] = 0 ;
pp -> FieldOrderCntList [ i ] [ 1 ] = 0 ;
pp -> FrameNumList [ i ] = 0 ;
}
}
pp -> wFrameWidthInMbsMinus1 = h -> mb_width - 1 ;
pp -> wFrameHeightInMbsMinus1 = h -> mb_height - 1 ;
pp -> num_ref_frames = h -> sps . ref_frame_count ;
pp -> wBitFields = ( ( h -> picture_structure != PICT_FRAME ) << 0 ) | ( ( h -> sps . mb_aff && ( h -> picture_structure == PICT_FRAME ) ) << 1 ) | ( h -> sps . residual_color_transform_flag << 2 ) | ( 0 << 3 ) | ( h -> sps . chroma_format_idc << 4 ) | ( ( h -> nal_ref_idc != 0 ) << 6 ) | ( h -> pps . constrained_intra_pred << 7 ) | ( h -> pps . weighted_pred << 8 ) | ( h -> pps . weighted_bipred_idc << 9 ) | ( 1 << 11 ) | ( h -> sps . frame_mbs_only_flag << 12 ) | ( h -> pps . transform_8x8_mode << 13 ) | ( ( h -> sps . level_idc >= 31 ) << 14 ) | ( 1 << 15 ) ;
pp -> bit_depth_luma_minus8 = h -> sps . bit_depth_luma - 8 ;
pp -> bit_depth_chroma_minus8 = h -> sps . bit_depth_chroma - 8 ;
if ( ctx -> workaround & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG ) pp -> Reserved16Bits = 0 ;
else pp -> Reserved16Bits = 3 ;
pp -> StatusReportFeedbackNumber = 1 + ctx -> report_id ++ ;
pp -> CurrFieldOrderCnt [ 0 ] = 0 ;
if ( ( h -> picture_structure & PICT_TOP_FIELD ) && current_picture -> field_poc [ 0 ] != INT_MAX ) pp -> CurrFieldOrderCnt [ 0 ] = current_picture -> field_poc [ 0 ] ;
pp -> CurrFieldOrderCnt [ 1 ] = 0 ;
if ( ( h -> picture_structure & PICT_BOTTOM_FIELD ) && current_picture -> field_poc [ 1 ] != INT_MAX ) pp -> CurrFieldOrderCnt [ 1 ] = current_picture -> field_poc [ 1 ] ;
pp -> pic_init_qs_minus26 = h -> pps . init_qs - 26 ;
pp -> chroma_qp_index_offset = h -> pps . chroma_qp_index_offset [ 0 ] ;
pp -> second_chroma_qp_index_offset = h -> pps . chroma_qp_index_offset [ 1 ] ;
pp -> ContinuationFlag = 1 ;
pp -> pic_init_qp_minus26 = h -> pps . init_qp - 26 ;
pp -> num_ref_idx_l0_active_minus1 = h -> pps . ref_count [ 0 ] - 1 ;
pp -> num_ref_idx_l1_active_minus1 = h -> pps . ref_count [ 1 ] - 1 ;
pp -> Reserved8BitsA = 0 ;
pp -> frame_num = h -> frame_num ;
pp -> log2_max_frame_num_minus4 = h -> sps . log2_max_frame_num - 4 ;
pp -> pic_order_cnt_type = h -> sps . poc_type ;
if ( h -> sps . poc_type == 0 ) pp -> log2_max_pic_order_cnt_lsb_minus4 = h -> sps . log2_max_poc_lsb - 4 ;
else if ( h -> sps . poc_type == 1 ) pp -> delta_pic_order_always_zero_flag = h -> sps . delta_pic_order_always_zero_flag ;
pp -> direct_8x8_inference_flag = h -> sps . direct_8x8_inference_flag ;
pp -> entropy_coding_mode_flag = h -> pps . cabac ;
pp -> pic_order_present_flag = h -> pps . pic_order_present ;
pp -> num_slice_groups_minus1 = h -> pps . slice_group_count - 1 ;
pp -> slice_group_map_type = h -> pps . mb_slice_group_map_type ;
pp -> deblocking_filter_control_present_flag = h -> pps . deblocking_filter_parameters_present ;
pp -> redundant_pic_cnt_present_flag = h -> pps . redundant_pic_cnt_present ;
pp -> Reserved8BitsB = 0 ;
pp -> slice_group_change_rate_minus1 = 0 ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
int base64_decode ( char * bufplain , const char * bufcoded ) {
int nbytesdecoded ;
register const unsigned char * bufin ;
register unsigned char * bufout ;
register int nprbytes ;
bufin = ( const unsigned char * ) bufcoded ;
while ( pr2six [ * ( bufin ++ ) ] <= 63 ) ;
nprbytes = ( bufin - ( const unsigned char * ) bufcoded ) - 1 ;
nbytesdecoded = ( ( nprbytes + 3 ) / 4 ) * 3 ;
bufout = ( unsigned char * ) bufplain ;
bufin = ( const unsigned char * ) bufcoded ;
while ( nprbytes > 4 ) {
* ( bufout ++ ) = ( unsigned char ) ( pr2six [ * bufin ] << 2 | pr2six [ bufin [ 1 ] ] >> 4 ) ;
* ( bufout ++ ) = ( unsigned char ) ( pr2six [ bufin [ 1 ] ] << 4 | pr2six [ bufin [ 2 ] ] >> 2 ) ;
* ( bufout ++ ) = ( unsigned char ) ( pr2six [ bufin [ 2 ] ] << 6 | pr2six [ bufin [ 3 ] ] ) ;
bufin += 4 ;
nprbytes -= 4 ;
}
if ( nprbytes > 1 ) * ( bufout ++ ) = ( unsigned char ) ( pr2six [ * bufin ] << 2 | pr2six [ bufin [ 1 ] ] >> 4 ) ;
if ( nprbytes > 2 ) * ( bufout ++ ) = ( unsigned char ) ( pr2six [ bufin [ 1 ] ] << 4 | pr2six [ bufin [ 2 ] ] >> 2 ) ;
if ( nprbytes > 3 ) * ( bufout ++ ) = ( unsigned char ) ( pr2six [ bufin [ 2 ] ] << 6 | pr2six [ bufin [ 3 ] ] ) ;
nbytesdecoded -= ( 4 - nprbytes ) & 3 ;
bufplain [ nbytesdecoded ] = '\0' ;
return nbytesdecoded ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
TEST_F ( WebUsbDetectorTest , ThreeUsbDeviceAddedAndRemovedDifferentOrder ) {
base : : string16 product_name_1 = base : : UTF8ToUTF16 ( kProductName_1 ) ;
GURL landing_page_1 ( kLandingPage_1 ) ;
scoped_refptr < device : : MockUsbDevice > device_1 ( new device : : MockUsbDevice ( 0 , 1 , "Google" , kProductName_1 , "002" , landing_page_1 ) ) ;
std : : string guid_1 = device_1 -> guid ( ) ;
base : : string16 product_name_2 = base : : UTF8ToUTF16 ( kProductName_2 ) ;
GURL landing_page_2 ( kLandingPage_2 ) ;
scoped_refptr < device : : MockUsbDevice > device_2 ( new device : : MockUsbDevice ( 3 , 4 , "Google" , kProductName_2 , "005" , landing_page_2 ) ) ;
std : : string guid_2 = device_2 -> guid ( ) ;
base : : string16 product_name_3 = base : : UTF8ToUTF16 ( kProductName_3 ) ;
GURL landing_page_3 ( kLandingPage_3 ) ;
scoped_refptr < device : : MockUsbDevice > device_3 ( new device : : MockUsbDevice ( 6 , 7 , "Google" , kProductName_3 , "008" , landing_page_3 ) ) ;
std : : string guid_3 = device_3 -> guid ( ) ;
Initialize ( ) ;
device_client_ . usb_service ( ) -> AddDevice ( device_1 ) ;
message_center : : Notification * notification_1 = message_center_ -> FindVisibleNotificationById ( guid_1 ) ;
ASSERT_TRUE ( notification_1 != nullptr ) ;
base : : string16 expected_title_1 = base : : ASCIIToUTF16 ( "Google Product A detected" ) ;
EXPECT_EQ ( expected_title_1 , notification_1 -> title ( ) ) ;
base : : string16 expected_message_1 = base : : ASCIIToUTF16 ( "Go to www.google.com/A to connect." ) ;
EXPECT_EQ ( expected_message_1 , notification_1 -> message ( ) ) ;
EXPECT_TRUE ( notification_1 -> delegate ( ) != nullptr ) ;
device_client_ . usb_service ( ) -> AddDevice ( device_2 ) ;
message_center : : Notification * notification_2 = message_center_ -> FindVisibleNotificationById ( guid_2 ) ;
ASSERT_TRUE ( notification_2 != nullptr ) ;
base : : string16 expected_title_2 = base : : ASCIIToUTF16 ( "Google Product B detected" ) ;
EXPECT_EQ ( expected_title_2 , notification_2 -> title ( ) ) ;
base : : string16 expected_message_2 = base : : ASCIIToUTF16 ( "Go to www.google.com/B to connect." ) ;
EXPECT_EQ ( expected_message_2 , notification_2 -> message ( ) ) ;
EXPECT_TRUE ( notification_2 -> delegate ( ) != nullptr ) ;
device_client_ . usb_service ( ) -> RemoveDevice ( device_2 ) ;
EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_2 ) == nullptr ) ;
device_client_ . usb_service ( ) -> AddDevice ( device_3 ) ;
message_center : : Notification * notification_3 = message_center_ -> FindVisibleNotificationById ( guid_3 ) ;
ASSERT_TRUE ( notification_3 != nullptr ) ;
base : : string16 expected_title_3 = base : : ASCIIToUTF16 ( "Google Product C detected" ) ;
EXPECT_EQ ( expected_title_3 , notification_3 -> title ( ) ) ;
base : : string16 expected_message_3 = base : : ASCIIToUTF16 ( "Go to www.google.com/C to connect." ) ;
EXPECT_EQ ( expected_message_3 , notification_3 -> message ( ) ) ;
EXPECT_TRUE ( notification_3 -> delegate ( ) != nullptr ) ;
device_client_ . usb_service ( ) -> RemoveDevice ( device_1 ) ;
EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_1 ) == nullptr ) ;
device_client_ . usb_service ( ) -> RemoveDevice ( device_3 ) ;
EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_3 ) == nullptr ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static unsigned int do_16x16_motion_iteration ( VP9_COMP * cpi , const MV * ref_mv , MV * dst_mv , int mb_row , int mb_col ) {
MACROBLOCK * const x = & cpi -> mb ;
MACROBLOCKD * const xd = & x -> e_mbd ;
const MV_SPEED_FEATURES * const mv_sf = & cpi -> sf . mv ;
const vp9_variance_fn_ptr_t v_fn_ptr = cpi -> fn_ptr [ BLOCK_16X16 ] ;
const int tmp_col_min = x -> mv_col_min ;
const int tmp_col_max = x -> mv_col_max ;
const int tmp_row_min = x -> mv_row_min ;
const int tmp_row_max = x -> mv_row_max ;
MV ref_full ;
int sad_list [ 5 ] ;
int step_param = mv_sf -> reduce_first_step_size ;
step_param = MIN ( step_param , MAX_MVSEARCH_STEPS - 2 ) ;
vp9_set_mv_search_range ( x , ref_mv ) ;
ref_full . col = ref_mv -> col >> 3 ;
ref_full . row = ref_mv -> row >> 3 ;
vp9_hex_search ( x , & ref_full , step_param , x -> errorperbit , 0 , cond_sad_list ( cpi , sad_list ) , & v_fn_ptr , 0 , ref_mv , dst_mv ) ;
{
int distortion ;
unsigned int sse ;
cpi -> find_fractional_mv_step ( x , dst_mv , ref_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & v_fn_ptr , 0 , mv_sf -> subpel_iters_per_step , cond_sad_list ( cpi , sad_list ) , NULL , NULL , & distortion , & sse , NULL , 0 , 0 ) ;
}
xd -> mi [ 0 ] -> mbmi . mode = NEWMV ;
xd -> mi [ 0 ] -> mbmi . mv [ 0 ] . as_mv = * dst_mv ;
vp9_build_inter_predictors_sby ( xd , mb_row , mb_col , BLOCK_16X16 ) ;
x -> mv_col_min = tmp_col_min ;
x -> mv_col_max = tmp_col_max ;
x -> mv_row_min = tmp_row_min ;
x -> mv_row_max = tmp_row_max ;
return vp9_sad16x16 ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , xd -> plane [ 0 ] . dst . buf , xd -> plane [ 0 ] . dst . stride ) ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void fill_variance ( int64_t s2 , int64_t s , int c , var * v ) {
v -> sum_square_error = s2 ;
v -> sum_error = s ;
v -> count = c ;
if ( c > 0 ) v -> variance = ( int ) ( 256 * ( v -> sum_square_error - v -> sum_error * v -> sum_error / v -> count ) / v -> count ) ;
else v -> variance = 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_rsl_ie_meas_res_no ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
proto_tree * ie_tree ;
guint8 ie_id ;
if ( is_mandatory == FALSE ) {
ie_id = tvb_get_guint8 ( tvb , offset ) ;
if ( ie_id != RSL_IE_MEAS_RES_NO ) return offset ;
}
ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 2 , ett_ie_meas_res_no , NULL , "Measurement result number IE" ) ;
proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
proto_tree_add_item ( ie_tree , hf_rsl_meas_res_no , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static cmsBool Type_Text_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {
cmsMLU * mlu = ( cmsMLU * ) Ptr ;
cmsUInt32Number size ;
cmsBool rc ;
char * Text ;
size = cmsMLUgetASCII ( mlu , cmsNoLanguage , cmsNoCountry , NULL , 0 ) ;
if ( size == 0 ) return FALSE ;
Text = ( char * ) _cmsMalloc ( self -> ContextID , size ) ;
if ( Text == NULL ) return FALSE ;
cmsMLUgetASCII ( mlu , cmsNoLanguage , cmsNoCountry , Text , size ) ;
rc = io -> Write ( io , size , Text ) ;
_cmsFree ( self -> ContextID , Text ) ;
return rc ;
cmsUNUSED_PARAMETER ( nItems ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static cmsBool _cmsWriteWCharArray ( cmsIOHANDLER * io , cmsUInt32Number n , const wchar_t * Array ) {
cmsUInt32Number i ;
_cmsAssert ( io != NULL ) ;
_cmsAssert ( ! ( Array == NULL && n > 0 ) ) ;
for ( i = 0 ;
i < n ;
i ++ ) {
if ( ! _cmsWriteUInt16Number ( io , ( cmsUInt16Number ) Array [ i ] ) ) return FALSE ;
}
return TRUE ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static const char * cmd_response_body_limit ( cmd_parms * cmd , void * _dcfg , const char * p1 ) {
directory_config * dcfg = ( directory_config * ) _dcfg ;
long int limit ;
limit = strtol ( p1 , NULL , 10 ) ;
if ( ( limit == LONG_MAX ) || ( limit == LONG_MIN ) || ( limit <= 0 ) ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Invalid value for SecResponseBodyLimit: %s" , p1 ) ;
}
if ( limit > RESPONSE_BODY_HARD_LIMIT ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Response size limit can not exceed the hard limit: %li" , RESPONSE_BODY_HARD_LIMIT ) ;
}
dcfg -> of_limit = limit ;
return NULL ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int vaapi_h264_start_frame ( AVCodecContext * avctx , av_unused const uint8_t * buffer , av_unused uint32_t size ) {
H264Context * const h = avctx -> priv_data ;
struct vaapi_context * const vactx = avctx -> hwaccel_context ;
VAPictureParameterBufferH264 * pic_param ;
VAIQMatrixBufferH264 * iq_matrix ;
av_dlog ( avctx , "vaapi_h264_start_frame()\n" ) ;
vactx -> slice_param_size = sizeof ( VASliceParameterBufferH264 ) ;
pic_param = ff_vaapi_alloc_pic_param ( vactx , sizeof ( VAPictureParameterBufferH264 ) ) ;
if ( ! pic_param ) return - 1 ;
fill_vaapi_pic ( & pic_param -> CurrPic , h -> cur_pic_ptr , h -> picture_structure ) ;
if ( fill_vaapi_ReferenceFrames ( pic_param , h ) < 0 ) return - 1 ;
pic_param -> picture_width_in_mbs_minus1 = h -> mb_width - 1 ;
pic_param -> picture_height_in_mbs_minus1 = h -> mb_height - 1 ;
pic_param -> bit_depth_luma_minus8 = h -> sps . bit_depth_luma - 8 ;
pic_param -> bit_depth_chroma_minus8 = h -> sps . bit_depth_chroma - 8 ;
pic_param -> num_ref_frames = h -> sps . ref_frame_count ;
pic_param -> seq_fields . value = 0 ;
pic_param -> seq_fields . bits . chroma_format_idc = h -> sps . chroma_format_idc ;
pic_param -> seq_fields . bits . residual_colour_transform_flag = h -> sps . residual_color_transform_flag ;
pic_param -> seq_fields . bits . gaps_in_frame_num_value_allowed_flag = h -> sps . gaps_in_frame_num_allowed_flag ;
pic_param -> seq_fields . bits . frame_mbs_only_flag = h -> sps . frame_mbs_only_flag ;
pic_param -> seq_fields . bits . mb_adaptive_frame_field_flag = h -> sps . mb_aff ;
pic_param -> seq_fields . bits . direct_8x8_inference_flag = h -> sps . direct_8x8_inference_flag ;
pic_param -> seq_fields . bits . MinLumaBiPredSize8x8 = h -> sps . level_idc >= 31 ;
pic_param -> seq_fields . bits . log2_max_frame_num_minus4 = h -> sps . log2_max_frame_num - 4 ;
pic_param -> seq_fields . bits . pic_order_cnt_type = h -> sps . poc_type ;
pic_param -> seq_fields . bits . log2_max_pic_order_cnt_lsb_minus4 = h -> sps . log2_max_poc_lsb - 4 ;
pic_param -> seq_fields . bits . delta_pic_order_always_zero_flag = h -> sps . delta_pic_order_always_zero_flag ;
pic_param -> num_slice_groups_minus1 = h -> pps . slice_group_count - 1 ;
pic_param -> slice_group_map_type = h -> pps . mb_slice_group_map_type ;
pic_param -> slice_group_change_rate_minus1 = 0 ;
pic_param -> pic_init_qp_minus26 = h -> pps . init_qp - 26 ;
pic_param -> pic_init_qs_minus26 = h -> pps . init_qs - 26 ;
pic_param -> chroma_qp_index_offset = h -> pps . chroma_qp_index_offset [ 0 ] ;
pic_param -> second_chroma_qp_index_offset = h -> pps . chroma_qp_index_offset [ 1 ] ;
pic_param -> pic_fields . value = 0 ;
pic_param -> pic_fields . bits . entropy_coding_mode_flag = h -> pps . cabac ;
pic_param -> pic_fields . bits . weighted_pred_flag = h -> pps . weighted_pred ;
pic_param -> pic_fields . bits . weighted_bipred_idc = h -> pps . weighted_bipred_idc ;
pic_param -> pic_fields . bits . transform_8x8_mode_flag = h -> pps . transform_8x8_mode ;
pic_param -> pic_fields . bits . field_pic_flag = h -> picture_structure != PICT_FRAME ;
pic_param -> pic_fields . bits . constrained_intra_pred_flag = h -> pps . constrained_intra_pred ;
pic_param -> pic_fields . bits . pic_order_present_flag = h -> pps . pic_order_present ;
pic_param -> pic_fields . bits . deblocking_filter_control_present_flag = h -> pps . deblocking_filter_parameters_present ;
pic_param -> pic_fields . bits . redundant_pic_cnt_present_flag = h -> pps . redundant_pic_cnt_present ;
pic_param -> pic_fields . bits . reference_pic_flag = h -> nal_ref_idc != 0 ;
pic_param -> frame_num = h -> frame_num ;
iq_matrix = ff_vaapi_alloc_iq_matrix ( vactx , sizeof ( VAIQMatrixBufferH264 ) ) ;
if ( ! iq_matrix ) return - 1 ;
memcpy ( iq_matrix -> ScalingList4x4 , h -> pps . scaling_matrix4 , sizeof ( iq_matrix -> ScalingList4x4 ) ) ;
memcpy ( iq_matrix -> ScalingList8x8 , h -> pps . scaling_matrix8 , sizeof ( iq_matrix -> ScalingList8x8 ) ) ;
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_usb_video_extension_unit ( proto_tree * tree , tvbuff_t * tvb , int offset ) {
guint8 num_inputs ;
guint8 control_size ;
proto_tree_add_item ( tree , hf_usb_vid_exten_guid , tvb , offset , 16 , ENC_LITTLE_ENDIAN ) ;
proto_tree_add_item ( tree , hf_usb_vid_exten_num_controls , tvb , offset + 16 , 1 , ENC_LITTLE_ENDIAN ) ;
offset += 17 ;
num_inputs = tvb_get_guint8 ( tvb , offset ) ;
proto_tree_add_item ( tree , hf_usb_vid_num_inputs , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
++ offset ;
if ( num_inputs > 0 ) {
proto_tree_add_item ( tree , hf_usb_vid_sources , tvb , offset , num_inputs , ENC_NA ) ;
offset += num_inputs ;
}
control_size = tvb_get_guint8 ( tvb , offset ) ;
proto_tree_add_item ( tree , hf_usb_vid_bControlSize , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
++ offset ;
if ( control_size > 0 ) {
if ( control_size <= proto_registrar_get_length ( hf_usb_vid_bmControl ) ) {
proto_tree_add_item ( tree , hf_usb_vid_bmControl , tvb , offset , control_size , ENC_LITTLE_ENDIAN ) ;
}
else {
proto_tree_add_bytes_format ( tree , hf_usb_vid_bmControl_bytes , tvb , offset , control_size , NULL , "bmControl" ) ;
}
offset += control_size ;
}
proto_tree_add_item ( tree , hf_usb_vid_iExtension , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;
++ offset ;
return offset ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static OFCondition parseUserInfo ( DUL_USERINFO * userInfo , unsigned char * buf , unsigned long * itemLength , unsigned char typeRQorAC , unsigned long availData ) {
unsigned short userLength ;
unsigned long length ;
OFCondition cond = EC_Normal ;
PRV_SCUSCPROLE * role ;
SOPClassExtendedNegotiationSubItem * extNeg = NULL ;
UserIdentityNegotiationSubItem * usrIdent = NULL ;
if ( availData < 4 ) return makeLengthError ( "user info" , availData , 4 ) ;
userInfo -> type = * buf ++ ;
userInfo -> rsv1 = * buf ++ ;
EXTRACT_SHORT_BIG ( buf , userInfo -> length ) ;
buf += 2 ;
userLength = userInfo -> length ;
* itemLength = userLength + 4 ;
if ( availData - 4 < userLength ) return makeLengthError ( "user info" , availData , 0 , userLength ) ;
DCMNET_TRACE ( "Parsing user info field (" << STD_NAMESPACE hex << STD_NAMESPACE setfill ( '0' ) << STD_NAMESPACE setw ( 2 ) << ( unsigned int ) userInfo -> type << STD_NAMESPACE dec << "), Length: " << ( unsigned long ) userInfo -> length ) ;
while ( userLength > 0 ) {
DCMNET_TRACE ( "Parsing remaining " << ( long ) userLength << " bytes of User Information" << OFendl << "Next item type: " << STD_NAMESPACE hex << STD_NAMESPACE setfill ( '0' ) << STD_NAMESPACE setw ( 2 ) << ( unsigned int ) * buf ) ;
switch ( * buf ) {
case DUL_TYPEMAXLENGTH : cond = parseMaxPDU ( & userInfo -> maxLength , buf , & length , userLength ) ;
if ( cond . bad ( ) ) return cond ;
buf += length ;
userLength -= ( unsigned short ) length ;
DCMNET_TRACE ( "Successfully parsed Maximum PDU Length" ) ;
break ;
case DUL_TYPEIMPLEMENTATIONCLASSUID : cond = parseSubItem ( & userInfo -> implementationClassUID , buf , & length , userLength ) ;
if ( cond . bad ( ) ) return cond ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
case DUL_TYPEASYNCOPERATIONS : cond = parseDummy ( buf , & length , userLength ) ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
case DUL_TYPESCUSCPROLE : role = ( PRV_SCUSCPROLE * ) malloc ( sizeof ( PRV_SCUSCPROLE ) ) ;
if ( role == NULL ) return EC_MemoryExhausted ;
cond = parseSCUSCPRole ( role , buf , & length , userLength ) ;
if ( cond . bad ( ) ) return cond ;
LST_Enqueue ( & userInfo -> SCUSCPRoleList , ( LST_NODE * ) role ) ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
case DUL_TYPEIMPLEMENTATIONVERSIONNAME : cond = parseSubItem ( & userInfo -> implementationVersionName , buf , & length , userLength ) ;
if ( cond . bad ( ) ) return cond ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
case DUL_TYPESOPCLASSEXTENDEDNEGOTIATION : extNeg = new SOPClassExtendedNegotiationSubItem ;
if ( extNeg == NULL ) return EC_MemoryExhausted ;
cond = parseExtNeg ( extNeg , buf , & length , userLength ) ;
if ( cond . bad ( ) ) return cond ;
if ( userInfo -> extNegList == NULL ) {
userInfo -> extNegList = new SOPClassExtendedNegotiationSubItemList ;
if ( userInfo -> extNegList == NULL ) return EC_MemoryExhausted ;
}
userInfo -> extNegList -> push_back ( extNeg ) ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
case DUL_TYPENEGOTIATIONOFUSERIDENTITY : if ( typeRQorAC == DUL_TYPEASSOCIATERQ ) usrIdent = new UserIdentityNegotiationSubItemRQ ( ) ;
else usrIdent = new UserIdentityNegotiationSubItemAC ( ) ;
if ( usrIdent == NULL ) return EC_MemoryExhausted ;
cond = usrIdent -> parseFromBuffer ( buf , length , userLength ) ;
if ( cond . bad ( ) ) {
delete usrIdent ;
return cond ;
}
userInfo -> usrIdent = usrIdent ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
default : cond = parseDummy ( buf , & length , userLength ) ;
buf += length ;
userLength -= ( unsigned short ) length ;
break ;
}
}
return EC_Normal ;
}
| 1True
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void test_show_object ( struct object * object , const char * name , void * data ) {
struct bitmap_test_data * tdata = data ;
int bitmap_pos ;
bitmap_pos = bitmap_position ( object -> oid . hash ) ;
if ( bitmap_pos < 0 ) die ( "Object not in bitmap: %s\n" , oid_to_hex ( & object -> oid ) ) ;
bitmap_set ( tdata -> base , bitmap_pos ) ;
display_progress ( tdata -> prg , ++ tdata -> seen ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void cirrus_write_hidden_dac ( CirrusVGAState * s , int reg_value ) {
if ( s -> cirrus_hidden_dac_lockindex == 4 ) {
s -> cirrus_hidden_dac_data = reg_value ;
# if defined ( DEBUG_CIRRUS ) printf ( "cirrus: outport hidden DAC, value %02x\n" , reg_value ) ;
# endif }
s -> cirrus_hidden_dac_lockindex = 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
char * ber_start ( BerElement * ber ) {
return ber -> ber_buf ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int x ( struct vcache * avc , int afun , struct vrequest * areq , \ struct afs_pdata * ain , struct afs_pdata * aout , \ afs_ucred_t * * acred ) DECL_PIOCTL ( PGetFID ) ;
DECL_PIOCTL ( PSetAcl ) ;
DECL_PIOCTL ( PStoreBehind ) ;
DECL_PIOCTL ( PGCPAGs ) ;
DECL_PIOCTL ( PGetAcl ) ;
DECL_PIOCTL ( PNoop ) ;
DECL_PIOCTL ( PBogus ) ;
DECL_PIOCTL ( PGetFileCell ) ;
DECL_PIOCTL ( PGetWSCell ) ;
DECL_PIOCTL ( PGetUserCell ) ;
DECL_PIOCTL ( PSetTokens ) ;
DECL_PIOCTL ( PGetVolumeStatus ) ;
DECL_PIOCTL ( PSetVolumeStatus ) ;
DECL_PIOCTL ( PFlush ) ;
DECL_PIOCTL ( PNewStatMount ) ;
DECL_PIOCTL ( PGetTokens ) ;
DECL_PIOCTL ( PUnlog ) ;
DECL_PIOCTL ( PMariner ) ;
DECL_PIOCTL ( PCheckServers ) ;
DECL_PIOCTL ( PCheckVolNames ) ;
DECL_PIOCTL ( PCheckAuth ) ;
DECL_PIOCTL ( PFindVolume ) ;
DECL_PIOCTL ( PViceAccess ) ;
DECL_PIOCTL ( PSetCacheSize ) ;
DECL_PIOCTL ( PGetCacheSize ) ;
DECL_PIOCTL ( PRemoveCallBack ) ;
DECL_PIOCTL ( PNewCell ) ;
DECL_PIOCTL ( PNewAlias ) ;
DECL_PIOCTL ( PListCells ) ;
DECL_PIOCTL ( PListAliases ) ;
DECL_PIOCTL ( PRemoveMount ) ;
DECL_PIOCTL ( PGetCellStatus ) ;
DECL_PIOCTL ( PSetCellStatus ) ;
DECL_PIOCTL ( PFlushVolumeData ) ;
DECL_PIOCTL ( PFlushAllVolumeData ) ;
DECL_PIOCTL ( PGetVnodeXStatus ) ;
DECL_PIOCTL ( PGetVnodeXStatus2 ) ;
DECL_PIOCTL ( PSetSysName ) ;
DECL_PIOCTL ( PSetSPrefs ) ;
DECL_PIOCTL ( PSetSPrefs33 ) ;
DECL_PIOCTL ( PGetSPrefs ) ;
DECL_PIOCTL ( PExportAfs ) ;
DECL_PIOCTL ( PGag ) ;
DECL_PIOCTL ( PTwiddleRx ) ;
DECL_PIOCTL ( PGetInitParams ) ;
DECL_PIOCTL ( PGetRxkcrypt ) ;
DECL_PIOCTL ( PSetRxkcrypt ) ;
DECL_PIOCTL ( PGetCPrefs ) ;
DECL_PIOCTL ( PSetCPrefs ) ;
DECL_PIOCTL ( PFlushMount ) ;
DECL_PIOCTL ( PRxStatProc ) ;
DECL_PIOCTL ( PRxStatPeer ) ;
DECL_PIOCTL ( PPrefetchFromTape ) ;
DECL_PIOCTL ( PFsCmd ) ;
DECL_PIOCTL ( PCallBackAddr )
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int alloc_tl_data ( krb5_int16 n_tl_data , krb5_tl_data * * tldp ) {
krb5_tl_data * * tlp = tldp ;
int i ;
for ( i = 0 ;
i < n_tl_data ;
i ++ ) {
* tlp = calloc ( 1 , sizeof ( krb5_tl_data ) ) ;
if ( * tlp == NULL ) return ENOMEM ;
memset ( * tlp , 0 , sizeof ( krb5_tl_data ) ) ;
tlp = & ( ( * tlp ) -> tl_data_next ) ;
}
return 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int write_file_descriptors ( struct archive_write * a ) {
struct iso9660 * iso9660 = a -> format_data ;
struct isofile * file ;
int64_t blocks , offset ;
int r ;
blocks = 0 ;
offset = 0 ;
if ( iso9660 -> el_torito . catalog != NULL ) {
r = make_boot_catalog ( a ) ;
if ( r < 0 ) return ( r ) ;
}
if ( iso9660 -> el_torito . boot != NULL ) {
file = iso9660 -> el_torito . boot -> file ;
blocks = file -> content . blocks ;
offset = file -> content . offset_of_temp ;
if ( offset != 0 ) {
r = write_file_contents ( a , offset , blocks << LOGICAL_BLOCK_BITS ) ;
if ( r < 0 ) return ( r ) ;
blocks = 0 ;
offset = 0 ;
}
}
for ( file = iso9660 -> data_file_list . first ;
file != NULL ;
file = file -> datanext ) {
if ( ! file -> write_content ) continue ;
if ( ( offset + ( blocks << LOGICAL_BLOCK_BITS ) ) < file -> content . offset_of_temp ) {
if ( blocks > 0 ) {
r = write_file_contents ( a , offset , blocks << LOGICAL_BLOCK_BITS ) ;
if ( r < 0 ) return ( r ) ;
}
blocks = 0 ;
offset = file -> content . offset_of_temp ;
}
file -> cur_content = & ( file -> content ) ;
do {
blocks += file -> cur_content -> blocks ;
file -> cur_content = file -> cur_content -> next ;
}
while ( file -> cur_content != NULL ) ;
}
if ( blocks > 0 ) {
r = write_file_contents ( a , offset , blocks << LOGICAL_BLOCK_BITS ) ;
if ( r < 0 ) return ( r ) ;
}
return ( ARCHIVE_OK ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static int dissect_zbee_zcl_identify ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) {
proto_tree * payload_tree ;
zbee_zcl_packet * zcl ;
guint offset = 0 ;
guint8 cmd_id ;
gint rem_len ;
if ( data == NULL ) return 0 ;
zcl = ( zbee_zcl_packet * ) data ;
cmd_id = zcl -> cmd_id ;
if ( zcl -> direction == ZBEE_ZCL_FCF_TO_SERVER ) {
col_append_fstr ( pinfo -> cinfo , COL_INFO , "%s, Seq: %u" , val_to_str_const ( cmd_id , zbee_zcl_identify_srv_rx_cmd_names , "Unknown Command" ) , zcl -> tran_seqno ) ;
proto_tree_add_item ( tree , hf_zbee_zcl_identify_srv_rx_cmd_id , tvb , offset , 1 , cmd_id ) ;
rem_len = tvb_reported_length_remaining ( tvb , ++ offset ) ;
if ( rem_len > 0 ) {
payload_tree = proto_tree_add_subtree ( tree , tvb , offset , rem_len , ett_zbee_zcl_identify , NULL , "Payload" ) ;
switch ( cmd_id ) {
case ZBEE_ZCL_CMD_ID_IDENTIFY_IDENTITY : dissect_zcl_identify_identify ( tvb , payload_tree , & offset ) ;
break ;
case ZBEE_ZCL_CMD_ID_IDENTIFY_IDENTITY_QUERY : break ;
default : break ;
}
}
}
else {
col_append_fstr ( pinfo -> cinfo , COL_INFO , "%s, Seq: %u" , val_to_str_const ( cmd_id , zbee_zcl_identify_srv_tx_cmd_names , "Unknown Command" ) , zcl -> tran_seqno ) ;
proto_tree_add_item ( tree , hf_zbee_zcl_identify_srv_tx_cmd_id , tvb , offset , 1 , cmd_id ) ;
rem_len = tvb_reported_length_remaining ( tvb , ++ offset ) ;
if ( rem_len > 0 ) {
payload_tree = proto_tree_add_subtree ( tree , tvb , offset , rem_len , ett_zbee_zcl_identify , NULL , "Payload" ) ;
switch ( cmd_id ) {
case ZBEE_ZCL_CMD_ID_IDENTIFY_IDENTITY_QUERY_RSP : dissect_zcl_identify_identifyqueryrsp ( tvb , payload_tree , & offset ) ;
break ;
default : break ;
}
}
}
return tvb_captured_length ( tvb ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void sbr_neg_odd_64_c ( float * x ) {
union av_intfloat32 * xi = ( union av_intfloat32 * ) x ;
int i ;
for ( i = 1 ;
i < 64 ;
i += 4 ) {
xi [ i + 0 ] . i ^= 1U << 31 ;
xi [ i + 2 ] . i ^= 1U << 31 ;
}
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void xhci_free_streams ( XHCIEPContext * epctx ) {
assert ( epctx -> pstreams != NULL ) ;
g_free ( epctx -> pstreams ) ;
epctx -> pstreams = NULL ;
epctx -> nr_pstreams = 0 ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void generate_new_codebooks ( RoqContext * enc , RoqTempdata * tempData ) {
int i , j ;
RoqCodebooks * codebooks = & tempData -> codebooks ;
int max = enc -> width * enc -> height / 16 ;
uint8_t mb2 [ 3 * 4 ] ;
roq_cell * results4 = av_malloc ( sizeof ( roq_cell ) * MAX_CBS_4x4 * 4 ) ;
uint8_t * yuvClusters = av_malloc ( sizeof ( int ) * max * 6 * 4 ) ;
int * points = av_malloc ( max * 6 * 4 * sizeof ( int ) ) ;
int bias ;
create_clusters ( enc -> frame_to_enc , enc -> width , enc -> height , yuvClusters ) ;
for ( i = 0 ;
i < max * 24 ;
i ++ ) {
bias = ( ( i % 6 ) < 4 ) ? 1 : CHROMA_BIAS ;
points [ i ] = bias * yuvClusters [ i ] ;
}
generate_codebook ( enc , tempData , points , max , results4 , 4 , MAX_CBS_4x4 ) ;
codebooks -> numCB4 = MAX_CBS_4x4 ;
tempData -> closest_cb2 = av_malloc ( max * 4 * sizeof ( int ) ) ;
generate_codebook ( enc , tempData , points , max * 4 , enc -> cb2x2 , 2 , MAX_CBS_2x2 ) ;
codebooks -> numCB2 = MAX_CBS_2x2 ;
for ( i = 0 ;
i < codebooks -> numCB2 ;
i ++ ) unpack_roq_cell ( enc -> cb2x2 + i , codebooks -> unpacked_cb2 + i * 2 * 2 * 3 ) ;
for ( i = 0 ;
i < codebooks -> numCB4 ;
i ++ ) {
for ( j = 0 ;
j < 4 ;
j ++ ) {
unpack_roq_cell ( & results4 [ 4 * i + j ] , mb2 ) ;
index_mb ( mb2 , codebooks -> unpacked_cb2 , codebooks -> numCB2 , & enc -> cb4x4 [ i ] . idx [ j ] , 2 ) ;
}
unpack_roq_qcell ( codebooks -> unpacked_cb2 , enc -> cb4x4 + i , codebooks -> unpacked_cb4 + i * 4 * 4 * 3 ) ;
enlarge_roq_mb4 ( codebooks -> unpacked_cb4 + i * 4 * 4 * 3 , codebooks -> unpacked_cb4_enlarged + i * 8 * 8 * 3 ) ;
}
av_free ( yuvClusters ) ;
av_free ( points ) ;
av_free ( results4 ) ;
}
| 0False
|
Categorize the following code snippet as vulnerable or not. True or False
|
static void rv34_output_i16x16 ( RV34DecContext * r , int8_t * intra_types , int cbp ) {
LOCAL_ALIGNED_16 ( int16_t , block16 , [ 16 ] ) ;
MpegEncContext * s = & r -> s ;
GetBitContext * gb = & s -> gb ;
int q_dc = rv34_qscale_tab [ r -> luma_dc_quant_i [ s -> qscale ] ] , q_ac = rv34_qscale_tab [ s -> qscale ] ;
uint8_t * dst = s -> dest [ 0 ] ;
int16_t * ptr = s -> block [ 0 ] ;
int i , j , itype , has_ac ;
memset ( block16 , 0 , 16 * sizeof ( * block16 ) ) ;
has_ac = rv34_decode_block ( block16 , gb , r -> cur_vlcs , 3 , 0 , q_dc , q_dc , q_ac ) ;
if ( has_ac ) r -> rdsp . rv34_inv_transform ( block16 ) ;
else r -> rdsp . rv34_inv_transform_dc ( block16 ) ;
itype = ittrans16 [ intra_types [ 0 ] ] ;
itype = adjust_pred16 ( itype , r -> avail_cache [ 6 - 4 ] , r -> avail_cache [ 6 - 1 ] ) ;
r -> h . pred16x16 [ itype ] ( dst , s -> linesize ) ;
for ( j = 0 ;
j < 4 ;
j ++ ) {
for ( i = 0 ;
i < 4 ;
i ++ , cbp >>= 1 ) {
int dc = block16 [ i + j * 4 ] ;
if ( cbp & 1 ) {
has_ac = rv34_decode_block ( ptr , gb , r -> cur_vlcs , r -> luma_vlc , 0 , q_ac , q_ac , q_ac ) ;
}
else has_ac = 0 ;
if ( has_ac ) {
ptr [ 0 ] = dc ;
r -> rdsp . rv34_idct_add ( dst + 4 * i , s -> linesize , ptr ) ;
}
else r -> rdsp . rv34_idct_dc_add ( dst + 4 * i , s -> linesize , dc ) ;
}
dst += 4 * s -> linesize ;
}
itype = ittrans16 [ intra_types [ 0 ] ] ;
if ( itype == PLANE_PRED8x8 ) itype = DC_PRED8x8 ;
itype = adjust_pred16 ( itype , r -> avail_cache [ 6 - 4 ] , r -> avail_cache [ 6 - 1 ] ) ;
q_dc = rv34_qscale_tab [ rv34_chroma_quant [ 1 ] [ s -> qscale ] ] ;
q_ac = rv34_qscale_tab [ rv34_chroma_quant [ 0 ] [ s -> qscale ] ] ;
for ( j = 1 ;
j < 3 ;
j ++ ) {
dst = s -> dest [ j ] ;
r -> h . pred8x8 [ itype ] ( dst , s -> uvlinesize ) ;
for ( i = 0 ;
i < 4 ;
i ++ , cbp >>= 1 ) {
uint8_t * pdst ;
if ( ! ( cbp & 1 ) ) continue ;
pdst = dst + ( i & 1 ) * 4 + ( i & 2 ) * 2 * s -> uvlinesize ;
rv34_process_block ( r , pdst , s -> uvlinesize , r -> chroma_vlc , 1 , q_dc , q_ac ) ;
}
}
}
| 0False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.