instruction
stringclasses
1 value
input
stringlengths
7
89.9k
output
stringlengths
1
20.9k
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-125 struct r_bin_dyldcache_lib_t * r_bin_dyldcache_extract ( struct r_bin_dyldcache_obj_t * bin , int idx , int * nlib ) { ut64 liboff , linkedit_offset ; ut64 dyld_vmbase ; ut32 addend = 0 ; struct r_bin_dyldcache_lib_t * ret = NULL ; struct dyld_cache_image_info * image_infos = NULL ; struct mach_header * mh ; ut...
<FIXS> <FIXE> <FIXS> int sz = bin -> nlibs * sizeof ( struct dyld_cache_image_info ) ; image_infos = malloc ( sz ) ; if ( ! image_infos ) { free ( ret ) ; return NULL ; } r_buf_read_at ( bin -> b , bin -> hdr . startaddr , ( ut8 * ) image_infos , sz ) ; dyld_vmbase = r_buf_read64le ( bin -> b , bin -> hdr . baseaddroff...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-264 void bnep_net_setup ( struct net_device * dev ) { memset ( dev -> broadcast , 0xff , ETH_ALEN ) ; dev -> addr_len = ETH_ALEN ; ether_setup ( dev ) ; <BUGS> <BUGE> dev -> netdev_ops = & bnep_netdev_ops ; dev -> watchdog_timeo = HZ * 2 ; }
<FIXS> dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-000 <BUGS> static ssize_t aio_setup_single_vector ( struct kiocb * kiocb ) <BUGE> { <BUGS> <BUGE> kiocb -> ki_iovec = & kiocb -> ki_inline_vec ; kiocb -> ki_iovec -> iov_base = kiocb -> ki_buf ; <BUGS> kiocb -> ki_iovec -> iov_len = kiocb -> ki_left ; <BUGE> kiocb -> ki_nr_segs = 1 ; kiocb -> ki_cur_seg = 0 ; retur...
<FIXS> static ssize_t aio_setup_single_vector ( int type , struct file * file , struct kiocb * kiocb ) <FIXE> <FIXS> int bytes ; bytes = rw_verify_area ( type , file , & kiocb -> ki_pos , kiocb -> ki_left ) ; if ( bytes < 0 ) return bytes ; <FIXE> <FIXS> kiocb -> ki_iovec -> iov_len = bytes ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-190 static bool snd_ctl_remove_numid_conflict ( struct snd_card * card , unsigned int count ) { struct snd_kcontrol * kctl ; <BUGS> <BUGE> list_for_each_entry ( kctl , & card -> controls , list ) { if ( kctl -> id . numid < card -> last_numid + 1 + count && kctl -> id . numid + kctl -> count > card -> last_numid + ...
<FIXS> if ( card -> last_numid >= UINT_MAX - count ) card -> last_numid = 0 ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-476 static int crypto_rng_init_tfm ( struct crypto_tfm * tfm ) { <BUGS> struct crypto_rng * rng = __crypto_rng_cast ( tfm ) ; struct rng_alg * alg = crypto_rng_alg ( rng ) ; struct old_rng_alg * oalg = crypto_old_rng_alg ( rng ) ; if ( oalg -> rng_make_random ) { rng -> generate = generate ; rng -> seed = rngapi_re...
<FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-200 static void make_response ( struct xen_blkif_ring * ring , u64 id , unsigned short op , int st ) { <BUGS> struct blkif_response resp ; <BUGE> unsigned long flags ; union blkif_back_rings * blk_rings ; int notify ; <BUGS> resp . id = id ; resp . operation = op ; resp . status = st ; <BUGE> spin_lock_irqsave ( & ...
<FIXS> struct blkif_response * resp ; <FIXE> <FIXS> <FIXE> <FIXS> resp = RING_GET_RESPONSE ( & blk_rings -> native , blk_rings -> native . rsp_prod_pvt ) ; <FIXE> <FIXS> resp = RING_GET_RESPONSE ( & blk_rings -> x86_32 , blk_rings -> x86_32 . rsp_prod_pvt ) ; <FIXE> <FIXS> resp = RING_GET_RESPONSE ( & blk_rings -> x86_...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-264 int propagate_mnt ( struct mount * dest_mnt , struct dentry * dest_dentry , struct mount * source_mnt , struct list_head * tree_list ) { <BUGS> <BUGE> struct mount * m , * child ; int ret = 0 ; struct mount * prev_dest_mnt = dest_mnt ; struct mount * prev_src_mnt = source_mnt ; LIST_HEAD ( tmp_list ) ; LIST_HEA...
<FIXS> struct user_namespace * user_ns = current -> nsproxy -> mnt_ns -> user_ns ; <FIXE> <FIXS> if ( m -> mnt_ns -> user_ns != user_ns ) type |= CL_UNPRIVILEGED ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-772 gprincs_ret * get_princs_2_svc ( gprincs_arg * arg , struct svc_req * rqstp ) { static gprincs_ret ret ; char * prime_arg ; <BUGS> gss_buffer_desc client_name , service_name ; <BUGE> OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gprincs_ret , & ret ) ; if ( ( ...
<FIXS> gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; <FIXE> <FIXS> exit_func : <FIXE> <FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-125 static void esis_print ( netdissect_options * ndo , const uint8_t * pptr , u_int length ) { const uint8_t * optr ; u_int li , esis_pdu_type , source_address_length , source_address_number ; const struct esis_header_t * esis_header ; if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , "ES-IS" ) ) ; if ( length <= 2 ) {...
<FIXS> ND_TCHECK ( * tptr ) ; <FIXE> <FIXS> ND_PRINT ( ( ndo , "[|esis]" ) ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-269 static int store_asoundrc ( void ) { fs_build_mnt_dir ( ) ; char * src ; char * dest = RUN_ASOUNDRC_FILE ; FILE * fp = fopen ( dest , "w" ) ; if ( fp ) { fprintf ( fp , "\\n" ) ; SET_PERMS_STREAM ( fp , getuid ( ) , getgid ( ) , 0644 ) ; fclose ( fp ) ; } if ( asprintf ( & src , "%s/.asoundrc" , cfg . homedir )...
<FIXS> copy_file_as_user ( src , dest , getuid ( ) , getgid ( ) , 0644 ) ; <FIXE> <FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-404 static int install_process_keyring ( void ) { struct cred * new ; int ret ; new = prepare_creds ( ) ; if ( ! new ) return - ENOMEM ; ret = install_process_keyring_to_cred ( new ) ; if ( ret < 0 ) { abort_creds ( new ) ; <BUGS> return ret != - EEXIST ? ret : 0 ; <BUGE> } return commit_creds ( new ) ; }
<FIXS> return ret ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-362 SYSCALL_DEFINE5 ( perf_event_open , struct perf_event_attr __user * , attr_uptr , pid_t , pid , int , cpu , int , group_fd , unsigned long , flags ) { struct perf_event * group_leader = NULL , * output_event = NULL ; struct perf_event * event , * sibling ; struct perf_event_attr attr ; struct perf_event_context...
<FIXS> gctx = __perf_event_ctx_lock_double ( group_leader , ctx ) ; <FIXE> <FIXS> } if ( ! ( group_leader -> group_caps & PERF_EV_CAP_SOFTWARE ) ) { if ( gctx != ctx ) { err = - EINVAL ; goto err_locked ; } else { perf_event_ctx_unlock ( group_leader , gctx ) ; move_group = 0 ; } <FIXE> <FIXS> perf_event_ctx_unlock ( g...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-399 static int process_one_ticket ( struct ceph_auth_client * ac , struct ceph_crypto_key * secret , <BUGS> void * * p , void * end , void * dbuf , void * ticket_buf ) <BUGE> { struct ceph_x_info * xi = ac -> private ; int type ; u8 tkt_struct_v , blob_struct_v ; struct ceph_x_ticket_handler * th ; <BUGS> <BUGE> vo...
<FIXS> void * * p , void * end ) <FIXE> <FIXS> void * dbuf = NULL ; <FIXE> <FIXS> void * ticket_buf = NULL ; <FIXE> <FIXS> dlen = ceph_x_decrypt ( secret , p , end , & dbuf , 0 ) ; <FIXE> <FIXS> <FIXE> <FIXS> dlen = ceph_x_decrypt ( & old_key , p , end , & ticket_buf , 0 ) ; <FIXE> <FIXS> tp = ticket_buf ; <FIXE> <FIXS...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-125 static int isis_print_mt_port_cap_subtlv ( netdissect_options * ndo , const uint8_t * tptr , int len ) { int stlv_type , stlv_len ; const struct isis_subtlv_spb_mcid * subtlv_spb_mcid ; int i ; while ( len > 2 ) { <BUGS> <BUGE> stlv_type = * ( tptr ++ ) ; stlv_len = * ( tptr ++ ) ; ND_PRINT ( ( ndo , "\\n\\t %s...
<FIXS> ND_TCHECK2 ( * tptr , 2 ) ; <FIXE> <FIXS> if ( len < stlv_len ) goto trunc ; ND_TCHECK2 ( * ( tptr ) , stlv_len ) ; <FIXE> <FIXS> if ( stlv_len < ISIS_SUBTLV_SPB_MCID_MIN_LEN ) goto trunc ; <FIXE> <FIXS> tptr = tptr + ISIS_SUBTLV_SPB_MCID_MIN_LEN ; len = len - ISIS_SUBTLV_SPB_MCID_MIN_LEN ; stlv_len = stlv_len -...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-000 static void check_1_6_dummy ( kadm5_principal_ent_t entry , long mask , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , char * * passptr ) { int i ; char * password = * passptr ; <BUGS> if ( ! ( mask & KADM5_ATTRIBUTES ) || <BUGE> ! ( entry -> attributes & KRB5_KDB_DISALLOW_ALL_TIX ) ) return ; for ( i = 0 ; ...
<FIXS> if ( password == NULL || ! ( mask & KADM5_ATTRIBUTES ) || <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-17 void bpf_int_jit_compile ( struct bpf_prog * prog ) { struct bpf_binary_header * header = NULL ; int proglen , oldproglen = 0 ; struct jit_context ctx = { } ; u8 * image = NULL ; int * addrs ; int pass ; int i ; if ( ! bpf_jit_enable ) return ; if ( ! prog || ! prog -> len ) return ; addrs = kmalloc ( prog -> le...
<FIXS> for ( pass = 0 ; pass < 10 || image ; pass ++ ) { <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-264 static int em_grp45 ( struct x86_emulate_ctxt * ctxt ) { int rc = X86EMUL_CONTINUE ; switch ( ctxt -> modrm_reg ) { case 2 : { long int old_eip ; old_eip = ctxt -> _eip ; <BUGS> ctxt -> _eip = ctxt -> src . val ; <BUGE> ctxt -> src . val = old_eip ; rc = em_push ( ctxt ) ; break ; } case 4 : <BUGS> ctxt -> _eip...
<FIXS> rc = assign_eip_near ( ctxt , ctxt -> src . val ) ; if ( rc != X86EMUL_CONTINUE ) break ; <FIXE> <FIXS> rc = assign_eip_near ( ctxt , ctxt -> src . val ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-17 static int do_dentry_open ( struct file * f , int ( * open ) ( struct inode * , struct file * ) , const struct cred * cred ) { static const struct file_operations empty_fops = { } ; struct inode * inode ; int error ; f -> f_mode = OPEN_FMODE ( f -> f_flags ) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE ; if ( unli...
<FIXS> <FIXE> <FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-125 static void exif_mnote_data_fuji_load ( ExifMnoteData * en , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataFuji * n = ( ExifMnoteDataFuji * ) en ; ExifLong c ; size_t i , tcount , o , datao ; if ( ! n || ! buf || ! buf_size ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , "ExifMnoteD...
<FIXS> if ( CHECKOVERFLOW ( datao , buf_size , 12 ) ) { <FIXE> <FIXS> if ( CHECKOVERFLOW ( datao , buf_size , 2 ) ) { <FIXE> <FIXS> if ( CHECKOVERFLOW ( o , buf_size , 12 ) ) { <FIXE> <FIXS> if ( exif_format_get_size ( n -> entries [ tcount ] . format ) && buf_size / exif_format_get_size ( n -> entries [ tcount ] . for...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-362 int dccp_v4_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { const struct sockaddr_in * usin = ( struct sockaddr_in * ) uaddr ; struct inet_sock * inet = inet_sk ( sk ) ; struct dccp_sock * dp = dccp_sk ( sk ) ; __be16 orig_sport , orig_dport ; __be32 daddr , nexthop ; struct flowi4 fl4 ;...
<FIXS> struct ip_options_rcu * inet_opt ; <FIXE> <FIXS> inet_opt = rcu_dereference_protected ( inet -> inet_opt , sock_owned_by_user ( sk ) ) ; if ( inet_opt != NULL && inet_opt -> opt . srr ) { <FIXE> <FIXS> nexthop = inet_opt -> opt . faddr ; <FIXE> <FIXS> if ( inet_opt == NULL || ! inet_opt -> opt . srr ) <FIXE> <FI...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-415 const char * util_acl_to_str ( const sc_acl_entry_t * e ) { static char line [ 80 ] , buf [ 20 ] ; unsigned int acl ; if ( e == NULL ) return "N/A" ; line [ 0 ] = 0 ; while ( e != NULL ) { acl = e -> method ; switch ( acl ) { case SC_AC_UNKNOWN : return "N/A" ; case SC_AC_NEVER : return "NEVR" ; case SC_AC_NONE...
<FIXS> strncat ( line , buf , sizeof line ) ; strncat ( line , " " , sizeof line ) ; <FIXE> <FIXS> line [ ( sizeof line ) - 1 ] = '\\0' ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-190 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; <BUGS> int iskew = imagew - tilew ; <BUGE> uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ...
<FIXS> int64 iskew = ( int64 ) imagew - ( int64 ) tilew ; <FIXE> <FIXS> if ( colb > iskew ) { <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-000 LUA_API void lua_sethook ( lua_State * L , lua_Hook func , int mask , int count ) { if ( func == NULL || mask == 0 ) { mask = 0 ; func = NULL ; } <BUGS> if ( isLua ( L -> ci ) ) L -> oldpc = L -> ci -> u . l . savedpc ; <BUGE> L -> hook = func ; L -> basehookcount = count ; resethookcount ( L ) ; L -> hookmask ...
<FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 static l_int32 pixHtmlViewer ( const char * dirin , const char * dirout , const char * rootname , l_int32 thumbwidth , l_int32 viewwidth ) { char * fname , * fullname , * outname ; char * mainname , * linkname , * linknameshort ; char * viewfile , * thumbfile ; char * shtml , * slink ; char charbuf [ 512 ] ; ch...
<FIXS> snprintf ( charbuf , sizeof ( charbuf ) , "%s/%s.html" , dirout , rootname ) ; <FIXE> <FIXS> snprintf ( charbuf , sizeof ( charbuf ) , "%s/%s-links.html" , dirout , rootname ) ; <FIXE> <FIXS> snprintf ( charbuf , sizeof ( charbuf ) , "%s_thumb_%03d" , rootname , index ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-125 void icmp_print ( netdissect_options * ndo , const u_char * bp , u_int plen , const u_char * bp2 , int fragmented ) { char * cp ; const struct icmp * dp ; const struct icmp_ext_t * ext_dp ; const struct ip * ip ; const char * str , * fmt ; const struct ip * oip ; const struct udphdr * ouh ; const uint8_t * obj_...
<FIXS> ND_TCHECK_16BITS ( & ip -> ip_len ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 static int store_icy ( URLContext * h , int size ) { HTTPContext * s = h -> priv_data ; <BUGS> int remaining = s -> icy_metaint - s -> icy_data_read ; if ( remaining < 0 ) <BUGE> return AVERROR_INVALIDDATA ; <BUGS> <BUGE> if ( ! remaining ) { uint8_t ch ; int len = http_read_stream_all ( h , & ch , 1 ) ; if ( l...
<FIXS> uint64_t remaining ; if ( s -> icy_metaint < s -> icy_data_read ) <FIXE> <FIXS> remaining = s -> icy_metaint - s -> icy_data_read ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-200 unsigned paravirt_patch_jmp ( void * insnbuf , const void * target , unsigned long addr , unsigned len ) { struct branch * b = insnbuf ; unsigned long delta = ( unsigned long ) target - ( addr + 5 ) ; <BUGS> if ( len < 5 ) <BUGE> return len ; <BUGS> <BUGE> b -> opcode = 0xe9 ; b -> delta = delta ; return 5 ; } ...
<FIXS> if ( len < 5 ) { # ifdef CONFIG_RETPOLINE WARN_ONCE ( "Failing to patch indirect JMP in %ps\\n" , ( void * ) addr ) ; # endif <FIXE> <FIXS> } <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 static int64_t http_seek_internal ( URLContext * h , int64_t off , int whence , int force_reconnect ) { HTTPContext * s = h -> priv_data ; URLContext * old_hd = s -> hd ; <BUGS> int64_t old_off = s -> off ; <BUGE> uint8_t old_buf [ BUFFER_SIZE ] ; int old_buf_size , ret ; AVDictionary * options = NULL ; if ( wh...
<FIXS> uint64_t old_off = s -> off ; <FIXE> <FIXS> else if ( ( s -> filesize == UINT64_MAX && whence == SEEK_END ) ) <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-59 void lxc_execute_bind_init ( struct lxc_conf * conf ) { int ret ; char path [ PATH_MAX ] , destpath [ PATH_MAX ] , * p ; p = choose_init ( conf -> rootfs . mount ) ; if ( p ) { free ( p ) ; return ; } ret = snprintf ( path , PATH_MAX , SBINDIR "/init.lxc.static" ) ; if ( ret < 0 || ret >= PATH_MAX ) { WARN ( "Pa...
<FIXS> ret = safe_mount ( path , destpath , "none" , MS_BIND , NULL , conf -> rootfs . mount ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 void vp8_loopfilter_frame ( VP8_COMP * cpi , VP8_COMMON * cm ) { const FRAME_TYPE frame_type = cm -> frame_type ; <BUGS> <BUGE> if ( cm -> no_lpf ) { cm -> filter_level = 0 ; } else { struct vpx_usec_timer timer ; vp8_clear_system_state ( ) ; vpx_usec_timer_start ( & timer ) ; <BUGS> if ( cpi -> sf . auto_filte...
<FIXS> int update_any_ref_buffers = 1 ; if ( cpi -> common . refresh_last_frame == 0 && cpi -> common . refresh_golden_frame == 0 && cpi -> common . refresh_alt_ref_frame == 0 ) { update_any_ref_buffers = 0 ; } <FIXE> <FIXS> if ( cpi -> sf . auto_filter == 0 ) { # if CONFIG_TEMPORAL_DENOISING if ( cpi -> oxcf . noise_s...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 <BUGS> int vp8_denoiser_filter_neon ( YV12_BUFFER_CONFIG * mc_running_avg , YV12_BUFFER_CONFIG * running_avg , MACROBLOCK * signal , unsigned int motion_magnitude , int y_offset , int uv_offset ) { const uint8x16_t v_level1_adjustment = vdupq_n_u8 ( ( motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD ) ? 4 : 3 ) ;...
<FIXS> int vp8_denoiser_filter_neon ( unsigned char * mc_running_avg_y , int mc_running_avg_y_stride , unsigned char * running_avg_y , int running_avg_y_stride , unsigned char * sig , int sig_stride , unsigned int motion_magnitude , int increase_denoising ) { int shift_inc = ( increase_denoising && motion_magnitude <= ...
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-20 static ssize_t generic_perform_write ( struct file * file , struct iov_iter * i , loff_t pos ) { struct address_space * mapping = file -> f_mapping ; const struct address_space_operations * a_ops = mapping -> a_ops ; long status = 0 ; ssize_t written = 0 ; unsigned int flags = 0 ; if ( segment_eq ( get_fs ( ) , ...
<FIXS> iov_iter_advance ( i , copied ) ; <FIXE> <FIXS> <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-119 static TEE_Result set_rmem_param ( const struct optee_msg_param_rmem * rmem , struct param_mem * mem ) { <BUGS> <BUGE> uint64_t shm_ref = READ_ONCE ( rmem -> shm_ref ) ; mem -> mobj = mobj_reg_shm_get_by_cookie ( shm_ref ) ; if ( ! mem -> mobj ) return TEE_ERROR_BAD_PARAMETERS ; mem -> offs = READ_ONCE ( rmem -...
<FIXS> size_t req_size = 0 ; <FIXE> <FIXS> if ( ADD_OVERFLOW ( mem -> offs , mem -> size , & req_size ) || mem -> mobj -> size < req_size ) return TEE_ERROR_SECURITY ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-20 static void gimp_write_and_read_file ( Gimp * gimp , gboolean with_unusual_stuff , gboolean compat_paths , gboolean use_gimp_2_8_features ) { GimpImage * image ; GimpImage * loaded_image ; GimpPlugInProcedure * proc ; <BUGS> gchar * filename ; <BUGE> GFile * file ; image = gimp_create_mainimage ( gimp , with_unu...
<FIXS> gchar * filename = NULL ; gint file_handle ; <FIXE> <FIXS> file_handle = g_file_open_tmp ( "gimp-test-XXXXXX.xcf" , & filename , NULL ) ; g_assert ( file_handle != - 1 ) ; close ( file_handle ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-416 static int fscrypt_d_revalidate ( struct dentry * dentry , unsigned int flags ) { struct dentry * dir ; <BUGS> struct fscrypt_info * ci ; <BUGE> int dir_has_key , cached_with_key ; if ( flags & LOOKUP_RCU ) return - ECHILD ; dir = dget_parent ( dentry ) ; if ( ! d_inode ( dir ) -> i_sb -> s_cop -> is_encrypted ...
<FIXS> <FIXE> <FIXS> <FIXE> <FIXS> dir_has_key = ( d_inode ( dir ) -> i_crypt_info != NULL ) ; <FIXE>
Analyze the following vulnerable code snippet and the corresponding CWE ID. Vulnerabilities are marked with <BUGS> and <BUGE> tokens. Fix the vulnerability in the code. Respond with the fixed code for the indicated vulnerability only.
CWE-000 bool_t auth_gssapi_unwrap_data ( OM_uint32 * major , OM_uint32 * minor , gss_ctx_id_t context , uint32_t seq_num , XDR * in_xdrs , bool_t ( * xdr_func ) ( ) , caddr_t xdr_ptr ) { gss_buffer_desc in_buf , out_buf ; XDR temp_xdrs ; uint32_t verf_seq_num ; int conf , qop ; unsigned int length ; PRINTF ( ( "gssapi_...
<FIXS> <FIXE>