{ "cells": [ { "cell_type": "code", "execution_count": 21, "id": "47d4a8c0-2a8a-4ef2-b311-d0d5368e83e1", "metadata": {}, "outputs": [], "source": [ "from datasets import load_dataset\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 22, "id": "b449c5cc-5d95-40c3-bed8-c99838a8e231", "metadata": {}, "outputs": [], "source": [ "dataset = load_dataset(\"MickyMike/cvefixes_bigvul\")" ] }, { "cell_type": "code", "execution_count": 23, "id": "7b6a0fa6-2742-4e3b-b996-eb84e8659180", "metadata": {}, "outputs": [], "source": [ "train_df = pd.DataFrame(list(dataset['train']))\n", "test_df = pd.DataFrame(list(dataset['test']))" ] }, { "cell_type": "code", "execution_count": 24, "id": "a055760c-bb9c-442e-ad81-7e7296389117", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0cwe_idsourcetargetproject_and_commit_idcve_idoriginal_addresstime
00CWE-000CWE-000 static void unix_release_sock ( struct...<S2SV_ModStart> ) ; } unix_dgram_peer_wake_dis...torvalds@linux/7d267278a9ece963d77eefec6163022...CVE-2013-7446https://github.com/torvalds/linux/commit/7d267...2015-12-28T11:59Z
11CWE-200CWE-200 static void snd_timer_user_tinterrupt ...<S2SV_ModStart> resolution ) { memset ( & r1 ,...torvalds@linux/e4ec8cc8039a7063e24204299b462bd...CVE-2016-4578https://github.com/torvalds/linux/commit/e4ec8...2016-05-23T10:59Z
22CWE-119CWE-119 static void store_coding_context ( MAC...<S2SV_ModStart> int mode_index , <S2SV_ModEnd>...external@libvpx/5a9753fca56f0eeb9f61e342b2fccf...CVE-2016-1621https://android.googlesource.com/platform/exte...2016-03-12T21:59Z
33CWE-000CWE-000 static int ext4_write_begin ( struct f...<S2SV_ModStart> = page ; if ( ext4_should_dior...torvalds@linux/744692dc059845b2a3022119871846e...CVE-2015-8324https://github.com/torvalds/linux/commit/74469...2016-05-02T10:59Z
44CWE-119CWE-119 <S2SV_StartBug> int16_t vp9_ac_quant (...<S2SV_ModStart> , int delta , vpx_bit_depth_t ...external@libvpx/5a9753fca56f0eeb9f61e342b2fccf...CVE-2016-1621https://android.googlesource.com/platform/exte...2016-03-12T21:59Z
\n", "
" ], "text/plain": [ " Unnamed: 0 cwe_id source \\\n", "0 0 CWE-000 CWE-000 static void unix_release_sock ( struct... \n", "1 1 CWE-200 CWE-200 static void snd_timer_user_tinterrupt ... \n", "2 2 CWE-119 CWE-119 static void store_coding_context ( MAC... \n", "3 3 CWE-000 CWE-000 static int ext4_write_begin ( struct f... \n", "4 4 CWE-119 CWE-119 int16_t vp9_ac_quant (... \n", "\n", " target \\\n", "0 ) ; } unix_dgram_peer_wake_dis... \n", "1 resolution ) { memset ( & r1 ,... \n", "2 int mode_index , ... \n", "3 = page ; if ( ext4_should_dior... \n", "4 , int delta , vpx_bit_depth_t ... \n", "\n", " project_and_commit_id cve_id \\\n", "0 torvalds@linux/7d267278a9ece963d77eefec6163022... CVE-2013-7446 \n", "1 torvalds@linux/e4ec8cc8039a7063e24204299b462bd... CVE-2016-4578 \n", "2 external@libvpx/5a9753fca56f0eeb9f61e342b2fccf... CVE-2016-1621 \n", "3 torvalds@linux/744692dc059845b2a3022119871846e... CVE-2015-8324 \n", "4 external@libvpx/5a9753fca56f0eeb9f61e342b2fccf... CVE-2016-1621 \n", "\n", " original_address time \n", "0 https://github.com/torvalds/linux/commit/7d267... 2015-12-28T11:59Z \n", "1 https://github.com/torvalds/linux/commit/e4ec8... 2016-05-23T10:59Z \n", "2 https://android.googlesource.com/platform/exte... 2016-03-12T21:59Z \n", "3 https://github.com/torvalds/linux/commit/74469... 2016-05-02T10:59Z \n", "4 https://android.googlesource.com/platform/exte... 2016-03-12T21:59Z " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_df.head()" ] }, { "cell_type": "code", "execution_count": 25, "id": "ecbd5fd2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0cwe_idsourcetargetproject_and_commit_idcve_idoriginal_addresstime
00CWE-119CWE-119 bool initiate_stratum ( struct pool * ...<S2SV_ModStart> if ( ! valid_hex ( nonce1 ) <S...sgminer-dev@sgminer/e1c5050734123973b99d181c45...CVE-2014-4502https://github.com/sgminer-dev/sgminer/commit/...2014-07-23T14:55Z
11CWE-125CWE-125 void eap_print ( netdissect_options * ...<S2SV_ModStart> case EAP_FRAME_TYPE_PACKET : N...the-tcpdump-group@tcpdump/985122081165753c7442...CVE-2017-13015https://github.com/the-tcpdump-group/tcpdump/c...2017-09-14T06:29Z
22CWE-401CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,...<S2SV_ModStart> op_mutex ) ; kfree_skb ( skb )...torvalds@linux/728c1e2a05e4b5fc52fab3421dce772...CVE-2019-19074https://github.com/torvalds/linux/commit/728c1...2019-11-18T06:15Z
33CWE-399CWE-399 static int yam_ioctl ( struct net_devi...<S2SV_ModStart> case SIOCYAMGCFG : memset ( & ...torvalds@linux/8e3fbf870481eb53b2d3a322d1fc395...CVE-2014-1446https://github.com/torvalds/linux/commit/8e3fb...2014-01-18T22:55Z
44CWE-189CWE-189 static struct sk_buff * udp6_ufo_fragm...<S2SV_ModStart> ; if ( skb -> mac_header <S2SV...torvalds@linux/0e033e04c2678dbbe74a46b23fffb7b...CVE-2013-4563https://github.com/torvalds/linux/commit/0e033...2013-11-20T13:19Z
\n", "
" ], "text/plain": [ " Unnamed: 0 cwe_id source \\\n", "0 0 CWE-119 CWE-119 bool initiate_stratum ( struct pool * ... \n", "1 1 CWE-125 CWE-125 void eap_print ( netdissect_options * ... \n", "2 2 CWE-401 CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,... \n", "3 3 CWE-399 CWE-399 static int yam_ioctl ( struct net_devi... \n", "4 4 CWE-189 CWE-189 static struct sk_buff * udp6_ufo_fragm... \n", "\n", " target \\\n", "0 if ( ! valid_hex ( nonce1 ) case EAP_FRAME_TYPE_PACKET : N... \n", "2 op_mutex ) ; kfree_skb ( skb )... \n", "3 case SIOCYAMGCFG : memset ( & ... \n", "4 ; if ( skb -> mac_header static void show_objec...\n", "Name: source, dtype: object\n", "train_df source: 2560 CWE-119 static void show_objec...\n", "Name: source, dtype: object\n", "train cve: ['CVE-2016-2324'], test_cve: ['CVE-2016-2315']\n", "source equal: [ True]\n", "fix equal: [ True]\n", "\n" ] } ], "source": [ "for source in common_source:\n", " test_source = test_df[test_df['source'] == source]['source']\n", " train_source = train_df[train_df['source'] == source]['source']\n", "\n", " test_cve = test_df[test_df['source'] == source]['cve_id']\n", " train_cve = train_df[train_df['source'] == source]['cve_id']\n", "\n", " test_fix = test_df[test_df['source'] == source]['target']\n", " train_fix = train_df[train_df['source'] == source]['target']\n", "\n", " if not train_cve.unique() == test_cve.unique():\n", " print(f'test_df source: {test_source}')\n", " print(f'train_df source: {train_source}')\n", " print(f'train cve: {train_cve.unique()}, test_cve: {test_cve.unique()}')\n", " print(f'source equal: {test_source.unique() == train_source.unique()}')\n", " print(f'fix equal: {train_fix.unique() == test_fix.unique()}')\n", " print()" ] }, { "cell_type": "code", "execution_count": 30, "id": "ce5a5fa3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Intersection: 798\n", "Disjoint Test Set Size: (819, 8)\n" ] } ], "source": [ "train_sources = set(train_df['source'])\n", "test_sources = set(test_df['source'])\n", "\n", "# Find the 'source' values that are only in test_sources\n", "disjoint_sources = test_sources - train_sources\n", "\n", "# Create disjoint_test by filtering test_df based on disjoint_sources\n", "disjoint_test = test_df[test_df['source'].isin(disjoint_sources)]\n", "print(f'Intersection: {test_df.shape[0] - disjoint_test.shape[0]}')\n", "\n", "# Reset the index of the resulting DataFrame\n", "disjoint_test = disjoint_test.drop_duplicates(subset=['source'])\n", "disjoint_test = disjoint_test.reset_index(drop=True)\n", "print(f'Disjoint Test Set Size: {disjoint_test.shape}')\n" ] }, { "cell_type": "code", "execution_count": 31, "id": "b3a5d778", "metadata": {}, "outputs": [], "source": [ "test_source = set(disjoint_test['source'])\n", "train_source = set(train_df['source'])\n", "\n", "common_source = test_source.intersection(train_source)\n", "\n", "assert len(common_source) == 0" ] }, { "cell_type": "code", "execution_count": 32, "id": "1c9d356f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1615 943\n", "True\n" ] } ], "source": [ "print(len(test_df.source.unique()), len(test_df.cve_id.unique()))\n", "print(any(t_id in disjoint_test.cve_id.unique() for t_id in train_df.cve_id.unique()))" ] }, { "cell_type": "code", "execution_count": 33, "id": "144724b5", "metadata": {}, "outputs": [], "source": [ "import re" ] }, { "cell_type": "code", "execution_count": 34, "id": "5aea4dcb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CVE-2014-5353\n", "train: 0 CWE-476 static krb5_error_code krb5_ldap_get_p...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static krb5_error_code krb5_ldap_get_p...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-11506\n", "train: 0 CWE-119 int sr_do_ioctl ( Scsi_CD * cd , struc...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 int sr_do_ioctl ( Scsi_CD * cd , struc...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-1870\n", "train: 0 CWE-200 static unsigned create_oops_dump_dirs ...\n", "1 CWE-200 static void ParseCommon ( map_string_t...\n", "2 CWE-200 static int run_post_create ( const cha...\n", "3 CWE-200 int main ( int argc , char * * argv ) ...\n", "4 CWE-200 static void save_bt_to_dump_dir ( cons...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 char * problem_data_save ( problem_dat...\n", "1 CWE-200 static int create_problem_dir ( GHashT...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 char * problem_data_save ( problem_dat...\n", "1 CWE-200 static int create_problem_dir ( GHashT...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-11447\n", "train: 0 CWE-772 static Image * ReadSCREENSHOTImage ( c...\n", "Name: source, dtype: object\n", "test: 0 CWE-772 static Image * ReadSCREENSHOTImage ( c...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-772 static Image * ReadSCREENSHOTImage ( c...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-0824\n", "train: 0 CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_pic_...\n", "1 CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_d_sl...\n", "2 CWE-254 void impeg2d_next_code ( dec_state_t *...\n", "3 CWE-254 void impeg2d_peek_next_start_code ( de...\n", "4 CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_slic...\n", "5 CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_pic_...\n", "6 CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_seq_...\n", "7 CWE-254 void impeg2d_flush_ext_and_user_data (...\n", "8 CWE-254 UWORD16 impeg2d_get_mb_addr_incr ( str...\n", "Name: source, dtype: object\n", "test: 0 CWE-254 void impeg2d_dec_user_data ( dec_state...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-254 void impeg2d_dec_user_data ( dec_state...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-0842\n", "train: 0 CWE-119 WORD32 ih264d_read_mmco_commands ( str...\n", "1 CWE-119 WORD32 ih264d_parse_pslice ( dec_struc...\n", "2 CWE-119 WORD32 ih264d_parse_bslice ( dec_struc...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 WORD32 ih264d_parse_islice ( dec_struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 WORD32 ih264d_parse_islice ( dec_struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-14175\n", "train: 0 CWE-834 static unsigned int XB...\n", "1 CWE-834 static unsigned int XB...\n", "2 CWE-834 static Image * ReadXBMImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-834 static Image * ReadXBMImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-834 static Image * ReadXBMImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-14882\n", "train: 0 CWE-125 static void mldv2_report_print ( netdi...\n", "1 CWE-125 static void rpl_print ( netdissect_opt...\n", "2 CWE-125 static void rpl_dao_print ( netdissect...\n", "3 CWE-125 static void icmp6_nodeinfo_print ( net...\n", "4 CWE-125 static void icmp6_rrenum_print ( netdi...\n", "5 CWE-125 static void rpl_dio_printopt ( netdiss...\n", "6 CWE-125 void icmp6_print ( netdissect_options ...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static void rpl_dio_print ( netdissect...\n", "1 CWE-125 static void rpl_daoack_print ( netdiss...\n", "2 CWE-125 static void mldv2_query_print ( netdis...\n", "3 CWE-125 static void icmp6_opt_print ( netdisse...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static void rpl_dio_print ( netdissect...\n", "1 CWE-125 static void rpl_daoack_print ( netdiss...\n", "2 CWE-125 static void mldv2_query_print ( netdis...\n", "3 CWE-125 static void icmp6_opt_print ( netdisse...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-13113\n", "train: 0 CWE-416 static void exif_mnote_data_canon_load...\n", "1 CWE-416 static void exif_mnote_data_olympus_lo...\n", "2 CWE-416 static void exif_mnote_data_pentax_loa...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static void exif_mnote_data_fuji_load ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 static void exif_mnote_data_fuji_load ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-4131\n", "train: 0 CWE-189 static void static void int xml_init ( modsec_...\n", "2 CWE-611 void * create_directory_config ( apr_p...\n", "Name: source, dtype: object\n", "test: 0 CWE-611 static const char * cmd_hash_engine ( ...\n", "1 CWE-611 void * merge_directory_configs ( apr_p...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-611 static const char * cmd_hash_engine ( ...\n", "1 CWE-611 void * merge_directory_configs ( apr_p...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-5077\n", "train: 0 CWE-476 void sctp_assoc_update ( struct sctp_a...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 void sctp_assoc_update ( struct sctp_a...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-5207\n", "train: 0 CWE-264 static int do_remount ( struct path * ...\n", "1 CWE-264 static struct mount * clone_mnt ( stru...\n", "2 CWE-264 static int do_new_mount ( struct path ...\n", "3 CWE-269 static int do_new_mount ( struct path ...\n", "Name: source, dtype: object\n", "test: 0 CWE-269 static struct mount * clone_mnt ( stru...\n", "1 CWE-269 static int do_remount ( struct path * ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-10638\n", "train: 0 CWE-200 __be32 ipv6_proxy_select_ident ( struc...\n", "1 CWE-200 void __ip_select_ident ( struct iphdr ...\n", "2 CWE-326 __be32 ipv6_select_ident ( struct net ...\n", "3 CWE-200 __be32 ipv6_select_ident ( struct net ...\n", "4 CWE-200 static u32 __ipv6_sele...\n", "5 CWE-200 void __ip_select_ident ( struct net * ...\n", "6 CWE-200 static __net_init int setup_net ( stru...\n", "7 CWE-200 static void ipv6_select_ident ( struct...\n", "8 CWE-326 static u32 __ipv6_sele...\n", "9 CWE-326 __be32 ipv6_proxy_select_ident ( struc...\n", "Name: source, dtype: object\n", "test: 0 CWE-326 void __ip_select_ident ( struct net * ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2021-32020\n", "train: 0 CWE-119 void * pvPortMalloc ( size_t xWantedSi...\n", "1 CWE-119 void * pvPortMalloc ( size_t xWantedSi...\n", "2 CWE-119 void * pvPortMalloc ( size_t xWantedSi...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 void * pvPortMalloc ( size_t xWantedSi...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 void * pvPortMalloc ( size_t xWantedSi...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-3673\n", "train: 0 CWE-20 sctp_disposition_t sctp_sf_do_asconf ( ...\n", "1 CWE-399 struct sctp_chunk * sctp_process_ascon...\n", "2 CWE-399 sctp_disposition_t sctp_sf_do_asconf_a...\n", "3 CWE-399 sctp_disposition_t sctp_sf_do_asconf (...\n", "4 CWE-20 sctp_disposition_t sctp_sf_do_asconf_ac...\n", "5 CWE-399 int sctp_verify_asconf...\n", "6 CWE-20 int sctp_verify_asconf ...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 struct sctp_chunk * sctp_process_asconf...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-17807\n", "train: 0 CWE-862 static struct key * construct_key_and_...\n", "1 CWE-862 static struct key * construct_key_and_...\n", "Name: source, dtype: object\n", "test: 0 CWE-862 static void construct_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-862 static void construct_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-6874\n", "train: 0 CWE-362 static struct ucounts * get_ucounts ( ...\n", "1 CWE-416 static void put_ucounts ( struct ucoun...\n", "2 CWE-362 static void put_ucounts ( struct ucoun...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static struct ucounts * get_ucounts ( ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-13045\n", "train: 0 CWE-416 static void destroy_server_connect ( S...\n", "1 CWE-416 static void sig_server_setup_fill_chat...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static void sig_server_connect_copy ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 static void sig_server_connect_copy ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-7526\n", "train: 0 CWE-787 static void InsertRow ( unsigned char ...\n", "1 CWE-787 static Image * ReadWPGImage ( const Im...\n", "2 CWE-787 static void InsertRow ( Image * image ...\n", "3 CWE-787 static void InsertRow ( Image * image ...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static void InsertRow ( unsigned char ...\n", "1 CWE-787 static Image * ReadWPGImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 static void InsertRow ( unsigned char ...\n", "1 CWE-787 static Image * ReadWPGImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-0835\n", "train: 0 CWE-119 void impeg2d_dec_pnb_m...\n", "1 CWE-119 void impeg2d_dec_pic_data_thread ( dec...\n", "2 CWE-119 void impeg2d_dec_p_mb_...\n", "3 CWE-119 WORD32 impeg2d_get_slice_pos ( dec_sta...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 IMPEG2D_ERROR_CODES_T impeg2d_dec_p_b_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 IMPEG2D_ERROR_CODES_T impeg2d_dec_p_b_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-11218\n", "train: 0 CWE-119 int mp_pack ( lua_State * L ) { int na...\n", "1 CWE-787 int mp_pack ( lua_State * L ) { int na...\n", "2 CWE-119 void mp_encode_lua_table_as_array ( lu...\n", "3 CWE-119 int mp_pack ( lua_State * L ) { int na...\n", "4 CWE-787 void mp_encode_lua_table_as_map ( lua_...\n", "5 CWE-787 void mp_decode_to_lua_array ( lua_Stat...\n", "6 CWE-119 void mp_encode_lua_table_as_map ( lua_...\n", "7 CWE-787 int mp_pack ( lua_State * L ) { int na...\n", "8 CWE-787 void mp_encode_lua_table_as_array ( lu...\n", "9 CWE-119 void mp_decode_to_lua_array ( lua_Stat...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 int mp_unpack_full ( lua_State * L , i...\n", "1 CWE-119 int mp_unpack_full ( lua_State * L , i...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 int mp_unpack_full ( lua_State * L , i...\n", "1 CWE-119 int mp_unpack_full ( lua_State * L , i...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-8631\n", "train: 0 CWE-772 generic_ret * setkey_principal3_2_svc ...\n", "1 CWE-772 generic_ret * init_2_svc ( krb5_ui_4 *...\n", "2 CWE-772 generic_ret * modify_principal_2_svc (...\n", "3 CWE-772 generic_ret * delete_principal_2_svc (...\n", "4 CWE-772 generic_ret * create_policy_2_svc ( cp...\n", "5 CWE-772 gpol_ret * get_policy_2_svc ( gpol_arg...\n", "6 CWE-772 generic_ret * modify_policy_2_svc ( mp...\n", "7 CWE-772 generic_ret * create_principal3_2_svc ...\n", "8 CWE-772 gprinc_ret * get_principal_2_svc ( gpr...\n", "9 CWE-772 generic_ret * setkey_principal_2_svc (...\n", "10 CWE-772 generic_ret * set_string_2_svc ( sstri...\n", "11 CWE-772 gpols_ret * get_pols_2_svc ( gpols_arg...\n", "12 CWE-772 chrand_ret * chrand_principal_2_svc ( ...\n", "13 CWE-772 chrand_ret * chrand_principal3_2_svc (...\n", "14 CWE-772 gprincs_ret * get_princs_2_svc ( gprin...\n", "15 CWE-772 generic_ret * rename_principal_2_svc (...\n", "16 CWE-772 generic_ret * chpass_principal3_2_svc ...\n", "17 CWE-772 generic_ret * purgekeys_2_svc ( purgek...\n", "18 CWE-772 generic_ret * delete_policy_2_svc ( dp...\n", "19 CWE-772 generic_ret * setv4key_principal_2_svc...\n", "20 CWE-772 generic_ret * create_principal_2_svc (...\n", "21 CWE-772 generic_ret * chpass_principal_2_svc (...\n", "Name: source, dtype: object\n", "test: 0 CWE-772 getprivs_ret * get_privs_2_svc ( krb5_...\n", "1 CWE-772 gstrings_ret * get_strings_2_svc ( gst...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-772 getprivs_ret * get_privs_2_svc ( krb5_...\n", "1 CWE-772 gstrings_ret * get_strings_2_svc ( gst...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-9949\n", "train: 0 CWE-787 grub_ssize_t grub_fshelp_read_file ( g...\n", "1 CWE-787 static int grub_ext2_iterate_dir ( gru...\n", "2 CWE-787 static grub_disk_addr_t grub_ext2_read...\n", "3 CWE-787 grub_ssize_t grub_fshelp_read_file ( g...\n", "4 CWE-787 static int grub_ext2_iterate_dir ( gru...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static int _server_handle_vCont ( libg...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 static int _server_handle_vCont ( libg...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-3145\n", "train: 0 CWE-125 static u64 __skb_get_nlattr_nest ( u64...\n", "1 CWE-125 static u64 __skb_get_nlattr ( u64 ctx ...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 static u64 __skb_get_nlattr ( u64 ctx ...\n", "1 CWE-189 static u64 __skb_get_nlattr_nest ( u64...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-19275\n", "train: 0 CWE-125 static int PARSER_FLAGS ( PyCompilerFl...\n", "1 CWE-125 static stmt_ty ast_for_funcdef ( struc...\n", "2 CWE-125 static stmt_ty ast_for...\n", "3 CWE-125 static int count_comp_fors ( struct co...\n", "4 CWE-125 node * PyParser_ParseFileObject ( FILE...\n", " ... \n", "89 CWE-125 PyMODINIT_FUNC PyInit__ast3 ( void ) {...\n", "90 CWE-125 static identifier new_identifier ( con...\n", "91 CWE-125 stmt_ty Assign ( asdl_...\n", "92 CWE-125 int obj2ast_comprehension ( PyObject *...\n", "93 CWE-125 mod_ty PyAST_obj2mod ( PyObject * ast ...\n", "Name: source, Length: 94, dtype: object\n", "test: 0 CWE-125 PyObject * ast2obj_arg ( void * _o ) {...\n", "1 CWE-125 static expr_ty fstring_compile_expr ( ...\n", "2 CWE-125 static asdl_seq * ast_for_comprehensio...\n", "3 CWE-125 mod_ty Module ( asdl_s...\n", "4 CWE-125 static void ast_dealloc ( AST_object *...\n", "5 CWE-125 int obj2ast_mod ( PyObject * obj , mod...\n", "6 CWE-125 static int fstring_find_literal ( cons...\n", "7 CWE-125 static stmt_ty ast_for_funcdef_impl ( ...\n", "8 CWE-125 PyObject * ast2obj_mod ( void * _o ) {...\n", "9 CWE-125 static PyObject * decode_unicode_with_...\n", "10 CWE-125 static PyObject * ast_type_reduce ( Py...\n", "11 CWE-125 PyObject * ast2obj_excepthandler ( voi...\n", "12 CWE-125 static int add_attributes ( PyTypeObje...\n", "13 CWE-125 static stmt_ty ast_for_expr_stmt ( str...\n", "14 CWE-125 static int num_stmts ( const node * n ...\n", "15 CWE-125 static int forbidden_name ( struct com...\n", "16 CWE-125 static int handle_keywordonly_args ( s...\n", "17 CWE-125 stmt_ty AsyncFor ( exp...\n", "18 CWE-125 static arguments_ty ast_for_arguments ...\n", "19 CWE-125 static int handle_keywordonly_args ( s...\n", "20 CWE-125 static stmt_ty ast_for...\n", "21 CWE-125 PyObject * ast2obj_alias ( void * _o )...\n", "22 CWE-125 static expr_ty ast_for_atom ( struct c...\n", "23 CWE-125 static int init_types ( void ) { stati...\n", "24 CWE-125 int obj2ast_slice ( PyObject * obj , s...\n", "25 CWE-125 static struct tok_state * tok_new ( vo...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 PyObject * ast2obj_arg ( void * _o ) {...\n", "1 CWE-125 static expr_ty fstring_compile_expr ( ...\n", "2 CWE-125 static asdl_seq * ast_for_comprehensio...\n", "3 CWE-125 mod_ty Module ( asdl_s...\n", "4 CWE-125 static void ast_dealloc ( AST_object *...\n", "5 CWE-125 int obj2ast_mod ( PyObject * obj , mod...\n", "6 CWE-125 static int fstring_find_literal ( cons...\n", "7 CWE-125 static stmt_ty ast_for_funcdef_impl ( ...\n", "8 CWE-125 PyObject * ast2obj_mod ( void * _o ) {...\n", "9 CWE-125 static PyObject * decode_unicode_with_...\n", "10 CWE-125 static PyObject * ast_type_reduce ( Py...\n", "11 CWE-125 PyObject * ast2obj_excepthandler ( voi...\n", "12 CWE-125 static int add_attributes ( PyTypeObje...\n", "13 CWE-125 static stmt_ty ast_for_expr_stmt ( str...\n", "14 CWE-125 static int num_stmts ( const node * n ...\n", "15 CWE-125 static int forbidden_name ( struct com...\n", "16 CWE-125 static int handle_keywordonly_args ( s...\n", "17 CWE-125 stmt_ty AsyncFor ( exp...\n", "18 CWE-125 static arguments_ty ast_for_arguments ...\n", "19 CWE-125 static int handle_keywordonly_args ( s...\n", "20 CWE-125 static stmt_ty ast_for...\n", "21 CWE-125 PyObject * ast2obj_alias ( void * _o )...\n", "22 CWE-125 static expr_ty ast_for_atom ( struct c...\n", "23 CWE-125 static int init_types ( void ) { stati...\n", "24 CWE-125 int obj2ast_slice ( PyObject * obj , s...\n", "25 CWE-125 static struct tok_state * tok_new ( vo...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-7670\n", "train: 0 CWE-444 bool agoo_ws_create_req ( agooCon c , ...\n", "1 CWE-444 static void * listen_loop ( void * x )...\n", "2 CWE-444 void request_init ( VALUE mod ) { req_...\n", "3 CWE-444 agooCon agoo_con_create ( agooErr err ...\n", "4 CWE-444 static void add_header_value ( VALUE h...\n", "Name: source, dtype: object\n", "test: 0 CWE-444 static HeadReturn con_header_read ( ag...\n", "1 CWE-444 VALUE request_env ( agooReq req , VALU...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-444 static HeadReturn con_header_read ( ag...\n", "1 CWE-444 VALUE request_env ( agooReq req , VALU...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-5827\n", "train: 0 CWE-190 static void addArgumentToVtab ( Parse ...\n", "1 CWE-190 SQLITE_PRIVATE void sqlite3VtabBeginPa...\n", "2 CWE-190 SQLITE_PRIVATE VList * sqlite3VListAdd...\n", "3 CWE-190 static MatchinfoBuffer * fts3MIBufferN...\n", "4 CWE-190 SQLITE_PRIVATE With * sqlite3WithAdd (...\n", "5 CWE-190 SQLITE_PRIVATE int sqlite3VdbeSorterWr...\n", "6 CWE-190 static int vdbePmaReadBlob ( PmaReader...\n", "7 CWE-190 SQLITE_PRIVATE void * sqlite3ArrayAllo...\n", "8 CWE-190 static int growOpArray ( Vdbe * v , in...\n", "9 CWE-190 SQLITE_PRIVATE SrcList * sqlite3SrcLis...\n", "10 CWE-190 int sqlite3Fts3InitTokenizer ( Fts3Has...\n", "11 CWE-190 SQLITE_PRIVATE ExprList * sqlite3ExprL...\n", "12 CWE-190 static int setupLookaside ( sqlite3 * ...\n", "13 CWE-190 static int growVTrans ( sqlite3 * db )...\n", "14 CWE-190 SQLITE_PRIVATE int sqlite3VtabEponymou...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static void addModuleA...\n", "1 CWE-190 static int fts3tokFilterMethod ( sqlit...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static void addModuleA...\n", "1 CWE-190 static int fts3tokFilterMethod ( sqlit...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-11595\n", "train: 0 CWE-119 void jshGetPinString ( char * result ,...\n", "1 CWE-119 void jslTokenAsString ( int token , ch...\n", "2 CWE-119 void jshGetPinString ( char * result ,...\n", "3 CWE-119 void jslTokenAsString ( int token , ch...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 void ftoa_bounded_extr...\n", "1 CWE-119 void jslGetTokenString ( char * str , ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 void ftoa_bounded_extr...\n", "1 CWE-119 void jslGetTokenString ( char * str , ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20182\n", "train: 0 CWE-119 static RD_BOOL mcs_recv_connect_respon...\n", "1 CWE-119 RD_BOOL ber_parse_head...\n", "2 CWE-119 static RD_BOOL mcs_parse_domain_params...\n", "3 CWE-119 static int process_plane ( uint8 * in ...\n", "4 CWE-119 static void process_secondary_order ( ...\n", "5 CWE-119 static void lspci_process ( STREAM s )...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 RD_BOOL cssp_read_tsrequest ( STREAM t...\n", "1 CWE-119 static void cliprdr_process ( STREAM s...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 RD_BOOL cssp_read_tsrequest ( STREAM t...\n", "1 CWE-119 static void cliprdr_process ( STREAM s...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-3610\n", "train: 0 CWE-264 static int wrmsr_interception ( struct...\n", "1 CWE-000 int kvm_set_msr ( struct kvm_vcpu * vc...\n", "2 CWE-000 static int wrmsr_interception ( struct...\n", "3 CWE-264 int kvm_set_msr ( struct kvm_vcpu * vc...\n", "4 CWE-000 static int handle_wrmsr ( struct kvm_v...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static int handle_wrmsr ( struct kvm_v...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-13095\n", "train: 0 CWE-787 xfs_failaddr_t xfs_dinode_verify ( str...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 xfs_failaddr_t xfs_dinode_verify ( str...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2011-0991\n", "train: 0 CWE-399 void mono_reflection_create_dynamic_me...\n", "1 CWE-399 void mono_gc_init ( void ) { Initializ...\n", "2 CWE-399 void mono_runtime_shutdown ( void ) { ...\n", "3 CWE-399 void mono_gc_cleanup ( void ) { # ifde...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 static guint32 finalizer_thread ( gpoi...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 static guint32 finalizer_thread ( gpoi...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-6767\n", "train: 0 CWE-125 int ParseRiffHeaderConfig ( FILE * inf...\n", "1 CWE-119 int ParseRiffHeaderConfig ( FILE * inf...\n", "2 CWE-125 int WriteRiffHeader ( FILE * outfile ,...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int WriteRiffHeader ( FILE * outfile ,...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-13006\n", "train: 0 CWE-125 static void l2tp_frami...\n", "1 CWE-125 static void l2tp_avp_print ( netdissec...\n", "2 CWE-125 static void l2tp_proto...\n", "3 CWE-125 static void l2tp_msgty...\n", "4 CWE-125 static void l2tp_beare...\n", "5 CWE-125 static void l2tp_proxy...\n", "6 CWE-125 static void l2tp_beare...\n", "7 CWE-125 static void l2tp_q931_cc_print ( netdi...\n", "8 CWE-125 static void l2tp_frami...\n", "9 CWE-125 static void l2tp_accm_...\n", "10 CWE-125 static void l2tp_result_code_print ( n...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static void l2tp_ppp_discon_cc_print (...\n", "1 CWE-125 static void l2tp_call_...\n", "2 CWE-125 static void l2tp_proxy...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static void l2tp_ppp_discon_cc_print (...\n", "1 CWE-125 static void l2tp_call_...\n", "2 CWE-125 static void l2tp_proxy...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-9289\n", "train: 0 CWE-119 static int cx24116_send_diseqc_msg ( s...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static int cx24116_send_diseqc_msg ( s...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-19645\n", "train: 0 CWE-674 static int renameColum...\n", "1 CWE-674 static int renameUnmapSelectCb ( Walke...\n", "2 CWE-674 static void renameTableFunc ( sqlite3_...\n", "3 CWE-674 static void renameColumnFunc ( sqlite3...\n", "Name: source, dtype: object\n", "test: 0 CWE-674 static int renameTableSelectCb ( Walke...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-674 static int renameTableSelectCb ( Walke...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-3647\n", "train: 0 CWE-000 static int em_loop ( struct x86_emulat...\n", "1 CWE-000 static inline void jmp...\n", "2 CWE-264 static int load_segment_descriptor ( s...\n", "3 CWE-000 static int em_jcxz ( struct x86_emulat...\n", "4 CWE-000 static int em_call ( struct x86_emulat...\n", "5 CWE-000 int x86_emulate_insn ( struct x86_emul...\n", "6 CWE-000 static int load_state_from_tss16 ( str...\n", "7 CWE-264 static int em_jcxz ( struct x86_emulat...\n", "8 CWE-264 static int em_ret_near_imm ( struct x8...\n", "9 CWE-000 static int em_ret_near_imm ( struct x8...\n", "10 CWE-000 static int em_ret ( struct x86_emulate...\n", "11 CWE-000 static int __load_segment_descriptor (...\n", "12 CWE-000 static int em_ret_far ( struct x86_emu...\n", "13 CWE-264 static int load_state_from_tss16 ( str...\n", "14 CWE-264 static inline void jmp...\n", "15 CWE-264 static int em_grp45 ( struct x86_emula...\n", "16 CWE-000 static int em_jmp_far ( struct x86_emu...\n", "17 CWE-264 int x86_emulate_insn ( struct x86_emul...\n", "18 CWE-264 static int load_state_from_tss32 ( str...\n", "19 CWE-264 static int em_ret_far ( struct x86_emu...\n", "20 CWE-264 static int em_call_far ( struct x86_em...\n", "21 CWE-000 static int load_state_from_tss32 ( str...\n", "22 CWE-264 static int em_ret ( struct x86_emulate...\n", "23 CWE-000 static int load_segment_descriptor ( s...\n", "24 CWE-264 static int em_call ( struct x86_emulat...\n", "25 CWE-000 static int em_sysexit ( struct x86_emu...\n", "26 CWE-264 static int em_jmp_far ( struct x86_emu...\n", "27 CWE-264 static inline void ass...\n", "28 CWE-264 static int __load_segment_descriptor (...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static inline void ass...\n", "1 CWE-000 static int em_call_far ( struct x86_em...\n", "2 CWE-264 static int em_sysexit ( struct x86_emu...\n", "3 CWE-000 static int em_grp45 ( struct x86_emula...\n", "4 CWE-264 static int em_loop ( struct x86_emulat...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-19905\n", "train: 0 CWE-120 int parse_sym_line ( buf , which_set )...\n", "Name: source, dtype: object\n", "test: 0 CWE-120 boolean proc_wizkit_line ( buf ) char ...\n", "1 CWE-120 boolean parse_config_line ( origbuf ) ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-120 boolean proc_wizkit_line ( buf ) char ...\n", "1 CWE-120 boolean parse_config_line ( origbuf ) ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-6903\n", "train: 0 CWE-269 qboolean S_AL_Init ( soundInterface_t ...\n", "1 CWE-000 void Com_WriteConfig_f ( void ) { char...\n", "2 CWE-000 long FS_FOpenFileRead ( const char * f...\n", "3 CWE-000 void Com_WriteConfig_f ( void ) { char...\n", "4 CWE-269 long FS_FOpenFileRead ( const char * f...\n", "5 CWE-269 void * Sys_LoadDll ( const char * name...\n", "6 CWE-269 long FS_FOpenFileRead ( const char * f...\n", "7 CWE-000 long FS_FOpenFileRead ( const char * f...\n", "8 CWE-000 qboolean S_AL_Init ( soundInterface_t ...\n", "9 CWE-000 void Con_Dump_f ( void ) { int l , x ,...\n", "10 CWE-269 void Con_Dump_f ( void ) { int l , x ,...\n", "11 CWE-000 long FS_FOpenFileRead ( const char * f...\n", "12 CWE-269 void Com_WriteConfig_f ( void ) { char...\n", "13 CWE-269 qboolean S_AL_Init ( soundInterface_t ...\n", "14 CWE-000 qboolean S_AL_Init ( soundInterface_t ...\n", "15 CWE-000 void Con_Dump_f ( void ) { int l , x ,...\n", "16 CWE-000 void Com_WriteConfig_f ( void ) { char...\n", "17 CWE-000 void * Sys_LoadDll ( const char * name...\n", "18 CWE-269 qboolean S_AL_Init ( soundInterface_t ...\n", "19 CWE-269 long FS_FOpenFileRead ( const char * f...\n", "20 CWE-000 void * Sys_LoadDll ( const char * name...\n", "21 CWE-269 void Com_WriteConfig_f ( void ) { char...\n", "22 CWE-269 void Con_Dump_f ( void ) { int l , x ,...\n", "23 CWE-269 void * Sys_LoadDll ( const char * name...\n", "24 CWE-269 void * Sys_LoadDll ( const char * name...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 qboolean S_AL_Init ( soundInterface_t ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-12897\n", "train: 0 CWE-125 static void handle_ppp ( netdissect_op...\n", "1 CWE-125 u_int fr_print ( netdissect_options * ...\n", "2 CWE-125 int llc_print ( netdissect_options * n...\n", "3 CWE-125 u_int atm_if_print ( netdissect_option...\n", "4 CWE-125 void isoclns_print ( netdissect_option...\n", "5 CWE-125 static void gre_print_0 ( netdissect_o...\n", "6 CWE-125 u_int fr_print ( netdissect_options * ...\n", "7 CWE-125 u_int null_if_print ( netdissect_optio...\n", "8 CWE-125 u_int chdlc_print ( netdissect_options...\n", "9 CWE-125 int llc_print ( netdissect_options * n...\n", "10 CWE-125 u_int chdlc_print ( netdissect_options...\n", "11 CWE-125 u_int atm_if_print ( netdissect_option...\n", "12 CWE-125 void mpls_print ( netdissect_options *...\n", "13 CWE-125 void mpls_print ( netdissect_options *...\n", "14 CWE-125 static void handle_ppp ( netdissect_op...\n", "15 CWE-125 void isoclns_print ( netdissect_option...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 int ethertype_print ( netdissect_optio...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 int ethertype_print ( netdissect_optio...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-5472\n", "train: 0 CWE-20 static int parse_rock_ridge_inode_inter...\n", "1 CWE-20 static int parse_rock_ridge_inode_inter...\n", "2 CWE-20 int parse_rock_ridge_in...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int isofs_read_i...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static int isofs_read_i...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3839\n", "train: 0 CWE-284 static uint16_t transmit_data ( serial...\n", "1 CWE-284 static int skt_read ( int fd , void * ...\n", "2 CWE-284 static inline int btif_hl_select_wake_...\n", "3 CWE-284 static void sync_lockstate_on_connect ...\n", "4 CWE-284 static void * btif_hl_select_thread ( ...\n", "5 CWE-284 static sent_status_t send_data_to_app ...\n", "6 CWE-284 void btsock_l2cap_signaled ( int fd , ...\n", "7 CWE-284 void btif_hl_select_monitor_callback (...\n", "8 CWE-284 static BOOLEAN flush_incoming_que_on_w...\n", "9 CWE-284 static int skt_write ( int fd , const ...\n", "10 CWE-284 int btpan_tap_open ( ) { struct ifreq ...\n", "11 CWE-284 int btsock_thread_post_cmd ( int h , i...\n", "12 CWE-284 static inline int btif_hl_close_select...\n", "13 CWE-284 static int tap_if_down ( const char * ...\n", "14 CWE-284 ssize_t socket_read ( const socket_t *...\n", "15 CWE-284 static inline int accept_server_socket...\n", "16 CWE-284 static void btif_fetch_local_bdaddr ( ...\n", "17 CWE-284 static ssize_t in_read ( struct audio_...\n", "18 CWE-284 int btsock_thread_exit ( int h ) { if ...\n", "19 CWE-284 static bool write_hci_command ( hci_pa...\n", "20 CWE-284 static int accept_server_socket ( int ...\n", "21 CWE-284 static int uhid_write ( int fd , const...\n", "22 CWE-284 int btsock_thread_add_fd ( int h , int...\n", "23 CWE-284 static int adev_open_output_stream ( s...\n", "24 CWE-284 static void * listen_fn_ ( UNUSED_ATTR...\n", "25 CWE-284 static void uipc_check_interrupt_locke...\n", "26 CWE-284 static void * btif_hh_poll_event_threa...\n", "27 CWE-284 static ssize_t out_write ( struct audi...\n", "28 CWE-284 static int a2dp_command ( struct a2dp_...\n", "29 CWE-284 static inline void uipc_wakeup_locked ...\n", "30 CWE-284 ssize_t socket_write ( const socket_t ...\n", "31 CWE-284 static inline int btif_hl_select_wakeu...\n", "32 CWE-284 static int uhid_event ( btif_hh_device...\n", "33 CWE-284 static void inbound_data_waiting ( voi...\n", "34 CWE-284 ssize_t socket_bytes_available ( const...\n", "35 CWE-284 static void btsnoop_write ( const void...\n", "36 CWE-284 static void a2dp_open_ctrl_path ( stru...\n", "37 CWE-284 static int process_cmd_sock ( int h ) ...\n", "38 CWE-284 UINT32 UIPC_Read ( tUIPC_CH_ID ch_id ,...\n", "39 CWE-284 void btsnoop_net_write ( const void * ...\n", "40 CWE-284 void bta_hl_co_put_rx_data ( UINT8 app...\n", "41 CWE-284 int sock_send_fd ( int sock_fd , const...\n", "42 CWE-284 static reactor_status_t run_reactor ( ...\n", "43 CWE-284 static void uipc_flush_ch_locked ( tUI...\n", "44 CWE-284 static inline void set_socket_blocking...\n", "45 CWE-284 bool semaphore_try_wait ( semaphore_t ...\n", "46 CWE-284 socket_t * socket_accept ( const socke...\n", "47 CWE-284 static int tap_if_up ( const char * de...\n", "48 CWE-284 int bta_co_rfc_data_outgoing ( void * ...\n", "49 CWE-284 static void command_timed_out ( UNUSED...\n", "50 CWE-284 bool btsock_thread_remove_fd_and_close...\n", "51 CWE-284 int btsock_thread_wakeup ( int h ) { i...\n", "52 CWE-284 static void toggle_os_keylockstates ( ...\n", "53 CWE-284 int send_event ( int fd , uint16_t typ...\n", "54 CWE-284 int bta_co_rfc_data_outgoing_size ( vo...\n", "Name: source, dtype: object\n", "test: 0 CWE-284 static bool has_byte ( const eager_rea...\n", "1 CWE-284 void bta_hh_co_open ( UINT8 dev_handle...\n", "2 CWE-284 static void btif_dm_upstreams_evt ( UI...\n", "3 CWE-284 BOOLEAN UIPC_Send ( tUIPC_CH_ID ch_id ...\n", "4 CWE-284 bool config_save ( const config_t * co...\n", "5 CWE-284 static void uipc_read_task ( void * ar...\n", "6 CWE-284 void close_uinput ( void ) { BTIF_TRAC...\n", "7 CWE-284 void GKI_delay ( UINT32 timeout_ms ) {...\n", "8 CWE-284 static uint16_t transmit_data_on ( int...\n", "9 CWE-284 int sock_recv_all ( int sock_fd , uint...\n", "10 CWE-284 static inline int btif_hl_select_close...\n", "11 CWE-284 int uinput_create ( char * name ) { st...\n", "12 CWE-284 int btpan_tap_send ( int tap_fd , cons...\n", "13 CWE-284 static void * sock_poll_thread ( void ...\n", "14 CWE-284 void btsock_rfc_signaled ( UNUSED_ATTR...\n", "15 CWE-284 ssize_t socket_write_and_transfer_fd (...\n", "16 CWE-284 int sock_send_all ( int sock_fd , cons...\n", "17 CWE-284 static void update_logging ( ) { bool ...\n", "18 CWE-284 static int a2dp_ctrl_receive ( struct ...\n", "19 CWE-284 static void btu_exec_tap_fd_read ( voi...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-284 static bool has_byte ( const eager_rea...\n", "1 CWE-284 void bta_hh_co_open ( UINT8 dev_handle...\n", "2 CWE-284 static void btif_dm_upstreams_evt ( UI...\n", "3 CWE-284 BOOLEAN UIPC_Send ( tUIPC_CH_ID ch_id ...\n", "4 CWE-284 bool config_save ( const config_t * co...\n", "5 CWE-284 static void uipc_read_task ( void * ar...\n", "6 CWE-284 void close_uinput ( void ) { BTIF_TRAC...\n", "7 CWE-284 void GKI_delay ( UINT32 timeout_ms ) {...\n", "8 CWE-284 static uint16_t transmit_data_on ( int...\n", "9 CWE-284 int sock_recv_all ( int sock_fd , uint...\n", "10 CWE-284 static inline int btif_hl_select_close...\n", "11 CWE-284 int uinput_create ( char * name ) { st...\n", "12 CWE-284 int btpan_tap_send ( int tap_fd , cons...\n", "13 CWE-284 static void * sock_poll_thread ( void ...\n", "14 CWE-284 void btsock_rfc_signaled ( UNUSED_ATTR...\n", "15 CWE-284 ssize_t socket_write_and_transfer_fd (...\n", "16 CWE-284 int sock_send_all ( int sock_fd , cons...\n", "17 CWE-284 static void update_logging ( ) { bool ...\n", "18 CWE-284 static int a2dp_ctrl_receive ( struct ...\n", "19 CWE-284 static void btu_exec_tap_fd_read ( voi...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-10012\n", "train: 0 CWE-119 void monitor_apply_keystate ( struct m...\n", "1 CWE-119 void ssh_kex2 ( char * host , struct s...\n", "2 CWE-119 struct monitor * monitor_init ( void )...\n", "3 CWE-119 static int newkeys_from_blob ( struct ...\n", "4 CWE-119 int ssh_packet_get_state ( struct ssh ...\n", "5 CWE-119 static int ssh_packet_set_postauth ( s...\n", "6 CWE-119 int ssh_packet_set_state ( struct ssh ...\n", "7 CWE-119 static void do_ssh2_kex ( void ) { cha...\n", "8 CWE-119 void monitor_apply_keystate ( struct m...\n", "9 CWE-119 static int privsep_preauth ( Authctxt ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int newkeys_to_blob ( struct ss...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int newkeys_to_blob ( struct ss...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3841\n", "train: 0 CWE-416 static struct sock * dccp_v6_request_r...\n", "1 CWE-416 static struct dst_entry * inet6_csk_ro...\n", "2 CWE-264 struct dst_entry * inet6_csk_route_req...\n", "3 CWE-264 int udpv6_sendmsg ( struct sock * sk ,...\n", "4 CWE-264 static int tcp_v6_connect ( struct soc...\n", "5 CWE-264 static struct sock * dccp_v6_request_r...\n", "6 CWE-264 static int rawv6_sendmsg ( struct sock...\n", "7 CWE-416 static int do_ipv6_setsockopt ( struct...\n", "8 CWE-416 struct dst_entry * inet6_csk_route_req...\n", "9 CWE-264 static int do_ipv6_setsockopt ( struct...\n", "10 CWE-416 int inet6_csk_xmit ( struct sock * sk ...\n", "11 CWE-264 static int dccp_v6_connect ( struct so...\n", "12 CWE-416 static int dccp_v6_send_response ( con...\n", "13 CWE-264 static struct sock * tcp_v6_syn_recv_s...\n", "14 CWE-264 struct sock * cookie_v6_check ( struct...\n", "15 CWE-264 void inet6_destroy_sock ( struct sock ...\n", "16 CWE-264 struct ipv6_txoptions * ipv6_renew_opt...\n", "17 CWE-264 struct ipv6_txoptions * ipv6_dup_optio...\n", "18 CWE-264 static int __ip6_datagram_connect ( st...\n", "19 CWE-264 int inet6_csk_xmit ( struct sock * sk ...\n", "20 CWE-416 static int dccp_v6_connect ( struct so...\n", "21 CWE-264 int inet6_sk_rebuild_header ( struct s...\n", "22 CWE-264 static struct dst_entry * inet6_csk_ro...\n", "23 CWE-416 static struct ipv6_txoptions * ipv6_up...\n", "24 CWE-416 struct sock * cookie_v6_check ( struct...\n", "25 CWE-416 static int __ip6_datagram_connect ( st...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 int inet6_sk_rebuild_header ( struct s...\n", "1 CWE-264 static int tcp_v6_send_synack ( const ...\n", "2 CWE-416 struct ipv6_txoptions * ipv6_renew_opt...\n", "3 CWE-264 static int dccp_v6_send_response ( con...\n", "4 CWE-416 void inet6_destroy_sock ( struct sock ...\n", "5 CWE-416 static int do_ipv6_getsockopt ( struct...\n", "6 CWE-264 static int do_ipv6_getsockopt ( struct...\n", "7 CWE-416 struct ipv6_txoptions * ipv6_dup_optio...\n", "8 CWE-416 static int rawv6_sendmsg ( struct sock...\n", "9 CWE-264 static struct ipv6_txoptions * ipv6_up...\n", "10 CWE-264 static int l2tp_ip6_sendmsg ( struct s...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-264 static int tcp_v6_send_synack ( const ...\n", "1 CWE-416 static int do_ipv6_getsockopt ( struct...\n", "2 CWE-264 static int do_ipv6_getsockopt ( struct...\n", "3 CWE-264 static int l2tp_ip6_sendmsg ( struct s...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9533\n", "train: 0 CWE-787 static int loadImage ( TIFF * in , str...\n", "1 CWE-787 static int reverseSamplesBytes ( uint1...\n", "2 CWE-787 int TIFFFlushData1 ( TIFF * tif ) { if...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 tsize_t t2p_readwrite_pdf_image ( T2P ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 tsize_t t2p_readwrite_pdf_image ( T2P ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-11833\n", "train: 0 CWE-200 static int ext4_ext_split ( handle_t *...\n", "1 CWE-908 static int ext4_ext_grow_indepth ( han...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 static int ext4_ext_grow_indepth ( han...\n", "1 CWE-908 static int ext4_ext_split ( handle_t *...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-5354\n", "train: 0 CWE-000 krb5_error_code krb5_ldap_put_principa...\n", "1 CWE-000 krb5_error_code krb5_ldap_put_principa...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static struct berval * * krb5_encode_k...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static struct berval * * krb5_encode_k...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20406\n", "train: 0 CWE-190 static PyObject * _Unp...\n", "1 CWE-190 static PyMemoTable * PyMemoTable_Copy ...\n", "2 CWE-190 static int _PyMemoTabl...\n", "3 CWE-190 static int PyMemoTable_Set ( PyMemoTab...\n", "4 CWE-190 static PyMemoEntry * _PyMemoTable_Look...\n", "5 CWE-190 static PyObject * _pickle_PicklerMemoP...\n", "6 CWE-190 static int Unpickler_set_memo ( Unpick...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int _Unpickler_...\n", "1 CWE-190 static int _Unpickler_...\n", "2 CWE-190 static PyObject * _pickle_UnpicklerMem...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static int _Unpickler_...\n", "1 CWE-190 static int _Unpickler_...\n", "2 CWE-190 static PyObject * _pickle_UnpicklerMem...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-13146\n", "train: 0 CWE-772 static Image * ReadMATImage ( const Im...\n", "1 CWE-772 static Image * ReadMATImageV4 ( const ...\n", "Name: source, dtype: object\n", "test: 0 CWE-772 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-772 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-10677\n", "train: 0 CWE-787 static int DecodeGifImg ( struct ngifl...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int DecodeGifImg ( struct ngifl...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-10057\n", "train: 0 CWE-119 MagickBooleanType sixel_decode ( unsig...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 MagickBooleanType sixel_decode ( unsig...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 MagickBooleanType sixel_decode ( unsig...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-4119\n", "train: 0 CWE-476 BOOL transport_accept_nla ( rdpTranspo...\n", "1 CWE-476 void * sspi_SecureHandleGetLowerPointe...\n", "2 CWE-476 void * sspi_SecureHandleGetLowerPointe...\n", "3 CWE-476 rdpCredssp * credssp_new ( freerdp * i...\n", "4 CWE-476 static int peer_recv_callback ( rdpTra...\n", "5 CWE-476 void * sspi_SecureHandleGetUpperPointe...\n", "6 CWE-476 static int peer_recv_callback ( rdpTra...\n", "7 CWE-476 BOOL transport_accept_nla ( rdpTranspo...\n", "8 CWE-476 rdpCredssp * credssp_new ( freerdp * i...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 BOOL transport_connect_nla ( rdpTransp...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-476 BOOL transport_connect_nla ( rdpTransp...\n", "Name: source, dtype: object\n", "###\n", "CVE-2012-0036\n", "train: 0 CWE-89 static CURLcode imap_parse_url_path ( s...\n", "1 CWE-89 static CURLcode smtp_connect ( struct c...\n", "2 CWE-89 char * curl_easy_escape ( CURL * handle...\n", "3 CWE-89 static CURLcode pop3_parse_url_path ( s...\n", "4 CWE-89 static CURLcode imap_parse_url_path ( s...\n", "Name: source, dtype: object\n", "test: 0 CWE-89 char * curl_easy_unescape ( CURL * hand...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-89 char * curl_easy_unescape ( CURL * hand...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-11008\n", "train: 0 CWE-522 static int check_submodule_url ( const...\n", "Name: source, dtype: object\n", "test: 0 CWE-522 int credential_from_url_gently ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-522 int credential_from_url_gently ( struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-7339\n", "train: 0 CWE-476 static int rds_ib_laddr_check ( __be32...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 static int rds_ib_laddr_check ( __be32...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-1335\n", "train: 0 CWE-59 static int mount_autodev ( const char *...\n", "1 CWE-59 static int setup_ttydir_console ( const...\n", "2 CWE-59 static int setup_dev_console ( const st...\n", "3 CWE-59 static bool cgroupfs_mount_cgroup ( voi...\n", "4 CWE-59 static bool cgroupfs_mount_cgroup ( voi...\n", "5 CWE-59 void lxc_execute_bind_init ( struct lxc...\n", "6 CWE-59 static int mount_autodev ( const char *...\n", "7 CWE-59 void lxc_execute_bind_init ( struct lxc...\n", "8 CWE-59 int mount_proc_if_needed ( const char *...\n", "9 CWE-59 static int lxc_mount_auto_mounts ( stru...\n", "10 CWE-59 static int mount_entry ( const char * f...\n", "11 CWE-59 static int setup_dev_console ( const st...\n", "12 CWE-59 static int mount_entry_on_absolute_root...\n", "13 CWE-59 static inline int mount_entry_on_generi...\n", "14 CWE-59 static int fill_autodev ( const struct ...\n", "15 CWE-59 static int setup_ttydir_console ( const...\n", "Name: source, dtype: object\n", "test: 0 CWE-59 static int mount_entry_on_relative_root...\n", "1 CWE-59 static inline int mount_entry_on_system...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-59 static int mount_entry_on_relative_root...\n", "1 CWE-59 static inline int mount_entry_on_system...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9685\n", "train: 0 CWE-400 int xfs_attr3_leaf_list_int ( struct x...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 int xfs_attr_shortform_list ( xfs_attr...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-400 int xfs_attr_shortform_list ( xfs_attr...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-4303\n", "train: 0 CWE-119 static const char * pa...\n", "1 CWE-119 cJSON * cJSON_CreateBool ( int b ) { c...\n", "2 CWE-119 void iperf_on_connect ( struct iperf_t...\n", "3 CWE-119 static char * print_ar...\n", "4 CWE-119 char * cJSON_PrintUnformatted ( cJSON ...\n", "5 CWE-119 void cJSON_Delete ( cJSON * c ) { cJSO...\n", "6 CWE-119 cJSON * cJSON_DetachItemFromObject ( c...\n", "7 CWE-119 static char * print_st...\n", "8 CWE-119 static const char * pa...\n", "9 CWE-119 static int get_results ( struct iperf_...\n", "10 CWE-119 void cJSON_ReplaceItemInArray ( cJSON ...\n", "11 CWE-119 cJSON * cJSON_CreateIn...\n", "12 CWE-119 static int cJSON_strcasecmp ( const ch...\n", "13 CWE-119 cJSON * cJSON_Parse ( const char * val...\n", "14 CWE-119 const char * cJSON_GetErrorPtr ( void ...\n", "15 CWE-119 cJSON * cJSON_CreateArray ( void ) { c...\n", "16 CWE-119 static char * print_nu...\n", "17 CWE-119 cJSON * cJSON_CreateString ( const cha...\n", "18 CWE-119 void cJSON_ReplaceItemInObject ( cJSON...\n", "19 CWE-119 int cJSON_GetArraySize ( cJSON * array...\n", "20 CWE-119 static int send_results ( struct iperf...\n", "21 CWE-119 void cJSON_DeleteItemFromObject ( cJSO...\n", "22 CWE-119 static const char * skip ( const char ...\n", "23 CWE-119 static char * print_va...\n", "24 CWE-119 cJSON * cJSON_CreateNull ( void ) { cJ...\n", "25 CWE-119 cJSON * iperf_json_printf ( const char...\n", "26 CWE-119 static cJSON * create_reference ( cJSO...\n", "27 CWE-119 void cJSON_AddItemToArray ( cJSON * ar...\n", "28 CWE-119 static const char * parse_number ( cJS...\n", "29 CWE-119 static void suffix_object ( cJSON * pr...\n", "30 CWE-119 cJSON * cJSON_CreateTrue ( void ) { cJ...\n", "31 CWE-119 char * cJSON_Print ( cJSON * item ) { ...\n", "32 CWE-119 static const char * pa...\n", "33 CWE-119 static const char * pa...\n", "34 CWE-119 void cJSON_AddItemToObject ( cJSON * o...\n", "35 CWE-119 static char * cJSON_strdup ( const cha...\n", "36 CWE-119 cJSON * cJSON_CreateFalse ( void ) { c...\n", "37 CWE-119 static int send_parameters ( struct ip...\n", "38 CWE-119 cJSON * cJSON_DetachItemFromArray ( cJ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * a...\n", "1 CWE-119 cJSON * cJSON_GetObjectItem ( cJSON * ...\n", "2 CWE-119 void cJSON_AddItemReferenceToObject ( ...\n", "3 CWE-119 cJSON * cJSON_CreateStringArray ( cons...\n", "4 CWE-119 void cJSON_AddItemReferenceToArray ( c...\n", "5 CWE-119 void cJSON_DeleteItemFromArray ( cJSON...\n", "6 CWE-119 static char * print_st...\n", "7 CWE-119 static char * print_ob...\n", "8 CWE-119 cJSON * cJSON_CreateObject ( void ) { ...\n", "9 CWE-119 cJSON * cJSON_CreateFl...\n", "10 CWE-119 static cJSON * cJSON_New_Item ( void )...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * a...\n", "1 CWE-119 cJSON * cJSON_GetObjectItem ( cJSON * ...\n", "2 CWE-119 void cJSON_AddItemReferenceToObject ( ...\n", "3 CWE-119 cJSON * cJSON_CreateStringArray ( cons...\n", "4 CWE-119 void cJSON_AddItemReferenceToArray ( c...\n", "5 CWE-119 void cJSON_DeleteItemFromArray ( cJSON...\n", "6 CWE-119 static char * print_st...\n", "7 CWE-119 static char * print_ob...\n", "8 CWE-119 cJSON * cJSON_CreateObject ( void ) { ...\n", "9 CWE-119 cJSON * cJSON_CreateFl...\n", "10 CWE-119 static cJSON * cJSON_New_Item ( void )...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20460\n", "train: 0 CWE-119 static bool parseOperands ( char * str...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static bool parseOperands ( char * str...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2013-0281\n", "train: 0 CWE-399 gboolean cib_notify_client ( gpointer ...\n", "1 CWE-399 static void do_local_notify ( xmlNode ...\n", "2 CWE-399 static void do_local_notify ( xmlNode ...\n", "3 CWE-399 int cib_remote_perform_op ( cib_t * ci...\n", "4 CWE-399 void crm...\n", "5 CWE-399 xmlNode * cib_tls_sig...\n", "2 CWE-399 int cib_remote_signon ( cib_t * cib , ...\n", "3 CWE-399 void cib_remote_connection_destroy ( g...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 int cib_connect ( gboolean full ) { in...\n", "1 CWE-399 static int cib_tls_sig...\n", "2 CWE-399 int cib_remote_signon ( cib_t * cib , ...\n", "3 CWE-399 void cib_remote_connection_destroy ( g...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-9016\n", "train: 0 CWE-362 struct request * blk_mq_tag_to_rq ( st...\n", "1 CWE-264 static void bt_for_each ( struct blk_m...\n", "2 CWE-264 struct request * blk_mq_tag_to_rq ( st...\n", "3 CWE-362 static bool blk_kick_flush ( struct re...\n", "4 CWE-264 static void bt_tags_for_each ( struct ...\n", "5 CWE-264 static bool blk_kick_flush ( struct re...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 static void bt_tags_for_each ( struct ...\n", "1 CWE-362 static void flush_end_io ( struct requ...\n", "2 CWE-362 static void bt_for_each ( struct blk_m...\n", "3 CWE-264 static void flush_end_io ( struct requ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 static void flush_end_io ( struct requ...\n", "1 CWE-264 static void flush_end_io ( struct requ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-15861\n", "train: 0 CWE-59 int add_mibfile ( const...\n", "1 CWE-59 int add_mibdir ( const char * dirname )...\n", "Name: source, dtype: object\n", "test: 0 CWE-59 void shutdown_mib ( void ) { unload_all...\n", "1 CWE-59 void netsnmp_init_mib ( void ) { const ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-59 void shutdown_mib ( void ) { unload_all...\n", "1 CWE-59 void netsnmp_init_mib ( void ) { const ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-5358\n", "train: 0 CWE-20 static void dissect_pktap ( tvbuff_t * ...\n", "1 CWE-20 static void dissect_rpcap_packet ( tvbu...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static void dissect_ppi ( tvbuff_t * tv...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static void dissect_ppi ( tvbuff_t * tv...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-12232\n", "train: 0 CWE-362 static int sockfs_setattr ( struct den...\n", "1 CWE-362 void sock_release ( struct socket * so...\n", "2 CWE-362 static int sockfs_setattr ( struct den...\n", "3 CWE-362 void sock_release ( struct socket * so...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 static int sock_close ( struct inode *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 static int sock_close ( struct inode *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-31616\n", "train: 0 CWE-120 uint8_t ethereum_extractThorchainData ...\n", "Name: source, dtype: object\n", "test: 0 CWE-120 bool zx_confirmZxLiquidTx ( uint32_t d...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-120 bool zx_confirmZxLiquidTx ( uint32_t d...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-12135\n", "train: 0 CWE-190 int mongo_env_write_so...\n", "1 CWE-190 static int bson_validate_string ( bson...\n", "2 CWE-190 static bcon_error_t bson_append_bcon_w...\n", "3 CWE-190 static mongo_message *...\n", "4 CWE-190 int bson_check_string ( bson * b , con...\n", "5 CWE-190 int mongo_env_read_soc...\n", "6 CWE-190 static char * mongo_da...\n", "7 CWE-190 static int bson_string...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int mongo_cursor_get_more ( mon...\n", "1 CWE-190 int bson_check_field_name ( bson * b ,...\n", "2 CWE-190 MONGO_EXPORT int mongo_insert_batch ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static int mongo_cursor_get_more ( mon...\n", "1 CWE-190 int bson_check_field_name ( bson * b ,...\n", "2 CWE-190 MONGO_EXPORT int mongo_insert_batch ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-14466\n", "train: 0 CWE-125 static void rx_cache_insert ( netdisse...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static int rx_cache_find ( const struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static int rx_cache_find ( const struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-18844\n", "train: 0 CWE-617 static void pci_emul_capwrite ( struct...\n", "1 CWE-617 static void pci_cfgrw ( struct vmctx *...\n", "2 CWE-617 struct pci_vdev * pci_get_vdev_info ( ...\n", "3 CWE-617 static void update_bar_address ( struc...\n", "4 CWE-617 void pci_lintr_assert ( struct pci_vde...\n", "5 CWE-617 int pci_emul_add_capability ( struct p...\n", "6 CWE-617 void pci_lintr_deassert ( struct pci_v...\n", "7 CWE-617 static void pci_emul_cmdsts_write ( st...\n", "8 CWE-617 static void pci_lintr_route ( struct p...\n", "9 CWE-617 static int pci_emul_mem_handler ( stru...\n", "10 CWE-617 static void void pci...\n", "17 CWE-617 void deinit_pci ( struct vmctx * ctx )...\n", "18 CWE-617 static int pci_emul_mem_handler ( stru...\n", "19 CWE-617 static void pci_bus_write_dsdt ( int b...\n", "20 CWE-617 static int pci_emul_alloc_resource ( u...\n", "Name: source, dtype: object\n", "test: 0 CWE-617 int pci_emul_add_msicap ( struct pci_v...\n", "1 CWE-617 static void static void static VALUE read_memo...\n", "1 CWE-611 void init_xml_relax_ng ( ) { VALUE nok...\n", "2 CWE-611 void init_xml_schema ( ) { VALUE nokog...\n", "3 CWE-611 static VALUE from_docu...\n", "4 CWE-611 static VALUE from_docu...\n", "Name: source, dtype: object\n", "test: 0 CWE-611 static VALUE read_memo...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-611 static VALUE read_memo...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-4646\n", "train: 0 CWE-20 int read_xattrs_from_disk ( int fd , st...\n", "1 CWE-20 static int read_fragmen...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int parse_exports_table ( long l...\n", "1 CWE-20 int read_filesystem_tables_4 ( ) { void set_header ( Http...\n", "3 CWE-352 void set_content_type ( HttpResponse r...\n", "4 CWE-352 static boolean_t is_authenticated ( Ht...\n", "5 CWE-352 static void print_buttons ( HttpReques...\n", "6 CWE-352 static void doGet ( HttpRequest req , ...\n", "7 CWE-352 static void doPost ( HttpRequest req ,...\n", "8 CWE-352 static HttpResponse create_HttpRespons...\n", "Name: source, dtype: object\n", "test: 0 CWE-352 static void _send ( Socket_T S , const...\n", "1 CWE-352 static void do_runtime ( HttpRequest r...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-352 static void _send ( Socket_T S , const...\n", "1 CWE-352 static void do_runtime ( HttpRequest r...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9537\n", "train: 0 CWE-119 static int reverseSamplesBytes ( uint1...\n", "1 CWE-119 int TIFFFlushData1 ( TIFF * tif ) { if...\n", "2 CWE-119 tsize_t t2p_readwrite_pdf_image ( T2P ...\n", "Name: source, dtype: object\n", "test: Series([], Name: source, dtype: object)\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-8788\n", "train: 0 CWE-787 static void nsc_encode...\n", "1 CWE-787 void nsc_encode ( NSC_...\n", "2 CWE-787 static void nsc_encode...\n", "3 CWE-787 BOOL nsc_process_message ( NSC_CONTEXT...\n", "4 CWE-787 static void nsc_encode...\n", "5 CWE-787 static void nsc_rle_de...\n", "6 CWE-787 static void nsc_decode...\n", "7 CWE-787 static void nsc_rle_de...\n", "8 CWE-787 static void nsc_encode...\n", "9 CWE-787 static UINT32 nsc_rle_...\n", "10 CWE-787 static void nsc_decode...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static void nsc_encode...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 static void nsc_encode...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-17407\n", "train: 0 CWE-119 static void t1_check_unusual_charstrin...\n", "1 CWE-119 static void t1_check_unusual_charstrin...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static void t1_check_unusual_charstrin...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static void t1_check_unusual_charstrin...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-12062\n", "train: 0 CWE-20 void sink ( int argc , char * * argv , ...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 void sink ( int argc , char * * argv , ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 void sink ( int argc , char * * argv , ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-20892\n", "train: 0 CWE-415 static struct usmStateReference * usm_...\n", "1 CWE-415 static void usm_free_usmStateReference...\n", "2 CWE-415 static netsnmp_pdu * _clone_pdu_header...\n", "Name: source, dtype: object\n", "test: 0 CWE-415 void init_usm ( void ) { struct snmp_s...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-415 void init_usm ( void ) { struct snmp_s...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-7308\n", "train: 0 CWE-189 static int sanitize_ptr_alu ( struct b...\n", "1 CWE-189 static int do_check ( struct bpf_verif...\n", "2 CWE-189 static struct bpf_verifier_state * pus...\n", "3 CWE-189 static struct bpf_verifier_state * pus...\n", "4 CWE-189 static int adjust_ptr_min_max_vals ( s...\n", "5 CWE-189 static int check_cond_jmp_op ( struct ...\n", "6 CWE-189 static int do_check ( struct bpf_verif...\n", "7 CWE-189 static int adjust_scalar_min_max_vals ...\n", "8 CWE-189 static int sanitize_ptr_alu ( struct b...\n", "9 CWE-189 static int check_cond_jmp_op ( struct ...\n", "10 CWE-189 static bool states_equal ( struct bpf_...\n", "11 CWE-189 static int adjust_scalar_min_max_vals ...\n", "12 CWE-189 static int adjust_ptr_min_max_vals ( s...\n", "13 CWE-189 static int fixup_bpf_calls ( struct bp...\n", "14 CWE-189 static bool states_equal ( struct bpf_...\n", "15 CWE-189 static int fixup_bpf_calls ( struct bp...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 static int copy_verifier_state ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-189 static int copy_verifier_state ( struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-0203\n", "train: 0 CWE-416 static __always_inline int __do_follow...\n", "1 CWE-416 static void * proc_pid_follow_link ( s...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static __always_inline int __do_follow_...\n", "1 CWE-20 static void * proc_pid_follow_link ( st...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-5210\n", "train: 0 CWE-120 void choose_windows ( s ) const char *...\n", "Name: source, dtype: object\n", "test: 0 CWE-120 static void process_options ( argc , a...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-120 static void process_options ( argc , a...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-6787\n", "train: 0 CWE-264 static void perf_remove_from_owner ( s...\n", "1 CWE-264 void perf_event_enable ( struct perf_e...\n", "2 CWE-264 static void perf_event_for_each ( stru...\n", "3 CWE-264 static int perf_event_read_group ( str...\n", "4 CWE-264 SYSCALL_DEFINE5 ( perf_event_open , st...\n", "5 CWE-264 int perf_event_refresh ( struct perf_e...\n", "6 CWE-264 int perf_event_task_disable ( void ) <...\n", "7 CWE-264 int perf_event_task_enable ( void ) static int set_registe...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int set_registe...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9538\n", "train: 0 CWE-190 static int readSeparateStripsIntoBuffe...\n", "1 CWE-190 static int readSeparateStripsIntoBuffe...\n", "2 CWE-190 static int readContigStripsIntoBuffer ...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int tiffcp ( TIFF * in , TIFF *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static int tiffcp ( TIFF * in , TIFF *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-17805\n", "train: 0 CWE-20 static int encrypt ( struct blkcipher_d...\n", "1 CWE-20 static int encrypt ( struct blkcipher_d...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int encrypt ( struct blkcipher_d...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static int encrypt ( struct blkcipher_d...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-11171\n", "train: 0 CWE-835 static Status accept_xsmp_connection (...\n", "1 CWE-835 static void gsm_xsmp_client_disconnect...\n", "2 CWE-835 static void gsm_xsmp_client_disconnect...\n", "3 CWE-835 static Status accept_xsmp_connection (...\n", "4 CWE-835 void gsm_xsmp_client_connect ( GsmXSMP...\n", "5 CWE-835 G_DEFINE_TYPE ( GsmXsmpServer , gsm_xs...\n", "Name: source, dtype: object\n", "test: 0 CWE-835 static void setup_connection ( GsmXSMP...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-835 static void setup_connection ( GsmXSMP...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-8952\n", "train: 0 CWE-19 static void ext4_xattr_release_block ( ...\n", "1 CWE-19 void ext4_xattr_destroy...\n", "2 CWE-19 static int ext4_xattr_block_get ( struc...\n", "3 CWE-19 static struct buffer_head * ext4_xattr_...\n", "4 CWE-19 int ext2_xattr_get ( struct inode * ino...\n", "5 CWE-19 static int ext4_xattr_block_set ( handl...\n", "6 CWE-19 static int ext2_xattr_list ( struct den...\n", "7 CWE-19 static void ext2_put_super ( struct sup...\n", "8 CWE-19 void ext4_xattr_destroy...\n", "9 CWE-19 static int ext4_xattr_block_get ( struc...\n", "10 CWE-19 static int ext4_fill_super ( struct sup...\n", "11 CWE-19 static struct buffer_head * ext2_xattr_...\n", "12 CWE-19 int ext2_xattr_set ( struct inode * ino...\n", "13 CWE-19 static void ext4_xattr_release_block ( ...\n", "14 CWE-19 static int ext2_fill_super ( struct sup...\n", "15 CWE-19 void ext2_xattr_delete_inode ( struct i...\n", "16 CWE-19 struct mb_cache * ext2_xattr_c...\n", "18 CWE-19 static int ext4_xattr_block_set ( handl...\n", "19 CWE-19 struct mb_cache * ext4_xattr_...\n", "1 CWE-19 static int ext2_xattr_set2 ( struct ino...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-19 static void ext4_xattr_...\n", "1 CWE-19 static int ext2_xattr_set2 ( struct ino...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-18672\n", "train: 0 CWE-354 static void recovery_abort ( void ) { ...\n", "1 CWE-354 bool recovery_cipher_abort ( void ) void imap_quote_string ...\n", "2 CWE-77 static int compile_search ( struct Cont...\n", "3 CWE-78 static void cmd_parse_lsub ( struct Ima...\n", "4 CWE-78 void imap_quote_string ...\n", "5 CWE-78 enum ImapAuthRes imap_auth_login ( stru...\n", "6 CWE-78 void imap_munge_mbox_name ( struct Imap...\n", "7 CWE-77 enum ImapAuthRes imap_auth_login ( stru...\n", "8 CWE-77 void imap_munge_mbox_name ( struct Imap...\n", "Name: source, dtype: object\n", "test: 0 CWE-77 static void cmd_parse_lsub ( struct Ima...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-4014\n", "train: 0 CWE-264 int generic_permission ( struct inode ...\n", "1 CWE-264 static inline int check_sticky ( struc...\n", "2 CWE-264 STATIC int xfs_ioctl_setattr ( xfs_ino...\n", "3 CWE-264 static inline int check_sticky ( struc...\n", "4 CWE-264 void setattr_copy ( struct inode * ino...\n", "5 CWE-264 void setattr_copy ( struct inode * ino...\n", "6 CWE-264 STATIC int xfs_ioctl_setattr ( xfs_ino...\n", "7 CWE-264 bool inode_owner_or_capable ( const st...\n", "8 CWE-264 int generic_permission ( struct inode ...\n", "9 CWE-264 bool inode_owner_or_capable ( const st...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 int inode_change_ok ( const struct ino...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-264 int inode_change_ok ( const struct ino...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20169\n", "train: 0 CWE-400 int __usb_get_extra_descriptor ( char ...\n", "1 CWE-400 static int hwahc_security_create ( str...\n", "2 CWE-400 static int hwahc_security_create ( str...\n", "3 CWE-400 int __usb_get_extra_descriptor ( char ...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 static int usb_enumerate_device_otg ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-400 static int usb_enumerate_device_otg ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-8543\n", "train: 0 CWE-000 static int inet6_create ( struct net *...\n", "1 CWE-000 static int irda_create ( struct net * ...\n", "2 CWE-000 static int inet_create ( struct net * ...\n", "3 CWE-000 static int dn_create ( struct net * ne...\n", "4 CWE-000 static int inet6_create ( struct net *...\n", "5 CWE-000 static int dn_create ( struct net * ne...\n", "6 CWE-000 static int irda_create ( struct net * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int ax25_create ( struct net * ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int ax25_create ( struct net * ...\n", "Name: source, dtype: object\n", "###\n", "None\n", "train: Series([], Name: source, dtype: object)\n", "test: Series([], Name: source, dtype: object)\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-15649\n", "train: 0 CWE-362 static int packet_do_bind ( struct soc...\n", "1 CWE-362 static int packet_do_bind ( struct soc...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 static int fanout_add ( struct sock * ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 static int fanout_add ( struct sock * ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-5940\n", "train: 0 CWE-269 static void copy_xauthority ( void ) {...\n", "1 CWE-269 static void skel ( const char * homedi...\n", "2 CWE-269 static int store_asoundrc ( void ) { f...\n", "3 CWE-269 static int store_asoundrc ( void ) { f...\n", "4 CWE-269 static void skel ( const char * homedi...\n", "5 CWE-269 static void copy_xauthority ( void ) {...\n", "6 CWE-269 static void copy_asoundrc ( void ) { c...\n", "Name: source, dtype: object\n", "test: 0 CWE-269 static void skel ( const char * homedi...\n", "1 CWE-269 static void copy_asoundrc ( void ) { c...\n", "2 CWE-269 static int store_xauthority ( void ) {...\n", "3 CWE-269 static int store_xauthority ( void ) {...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-269 static void skel ( const char * homedi...\n", "1 CWE-269 static void copy_asoundrc ( void ) { c...\n", "2 CWE-269 static int store_xauthority ( void ) {...\n", "3 CWE-269 static int store_xauthority ( void ) {...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-6262\n", "train: 0 CWE-134 rrd_info_t * rrd_graph_v ( int argc , ...\n", "1 CWE-134 int print_calc ( image_desc_t * im ) {...\n", "2 CWE-134 int bad_format_imginfo ( char * fmt ) ...\n", "3 CWE-134 void rrd_graph_options ( int argc , ch...\n", "4 CWE-134 rrd_info_t * rrd_graph_v ( int argc , ...\n", "Name: source, dtype: object\n", "test: 0 CWE-134 int print_calc ( image_desc_t * im ) {...\n", "1 CWE-134 static int bad_format_...\n", "2 CWE-134 void rrd_graph_options ( int argc , ch...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-134 int print_calc ( image_desc_t * im ) {...\n", "1 CWE-134 static int bad_format_...\n", "2 CWE-134 void rrd_graph_options ( int argc , ch...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-15473\n", "train: 0 CWE-362 static int userauth_pubkey ( struct ss...\n", "1 CWE-362 static int userauth_hostbased ( struct...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 static int userauth_hostbased ( struct...\n", "1 CWE-200 static int userauth_pubkey ( struct ss...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-0393\n", "train: 0 CWE-000 void vp8mt_de_alloc_temp_buffers ( VP8...\n", "1 CWE-000 static void setup_token_decoder ( VP8D...\n", "2 CWE-000 void vp8_decoder_remove_threads ( VP8D...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 int vp8_remove_decoder_instances ( str...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 int vp8_remove_decoder_instances ( str...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-12210\n", "train: 0 CWE-000 static void parse_cfg ( int flags , in...\n", "1 CWE-000 int pam_sm_authenticate ( pam_handle_t...\n", "2 CWE-200 int pam_sm_authenticate ( pam_handle_t...\n", "3 CWE-200 int get_devices_from_authfile ( const ...\n", "4 CWE-000 int get_devices_from_authfile ( const ...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 static void parse_cfg ( int flags , in...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2012-1179\n", "train: 0 CWE-264 static int walk_pmd_range ( pud_t * pu...\n", "1 CWE-264 static inline unsigned long zap_pmd_ra...\n", "2 CWE-264 static inline int check_pmd_range ( st...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static void mincore_pmd_range ( struct...\n", "1 CWE-264 static inline int unuse_pmd_range ( st...\n", "2 CWE-264 static void mark_screen_rdonly ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-264 static void mincore_pmd_range ( struct...\n", "1 CWE-264 static inline int unuse_pmd_range ( st...\n", "2 CWE-264 static void mark_screen_rdonly ( struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-13217\n", "train: 0 CWE-119 static int lookup1_values ( int entrie...\n", "1 CWE-119 static float * get_window ( vorb * f ,...\n", "2 CWE-119 static int start_decoder ( vorb * f ) ...\n", "3 CWE-119 static __forceinline void draw_line ( ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int vorbis_finish_frame ( stb_v...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int vorbis_finish_frame ( stb_v...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-2647\n", "train: 0 CWE-476 key_ref_t key_create_or_update ( key_r...\n", "1 CWE-476 struct key * key_get_instantiation_aut...\n", "2 CWE-476 key_ref_t keyring_search ( key_ref_t k...\n", "3 CWE-476 static int asymmetric_key_match_prepar...\n", "4 CWE-476 static int asymmetric_key_match_prepar...\n", "5 CWE-476 key_ref_t keyring_search ( key_ref_t k...\n", "6 CWE-476 key_ref_t key_create_or_update ( key_r...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 struct key * request_key_and_link ( st...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-476 struct key * request_key_and_link ( st...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-11599\n", "train: 0 CWE-362 void uverbs_user_mmap_disassociate ( s...\n", "1 CWE-362 static int userfaultfd_unregister ( st...\n", "2 CWE-362 static int userfaultfd_release ( struc...\n", "3 CWE-667 void uverbs_user_mmap_disassociate ( s...\n", "4 CWE-362 static void userfaultfd_event_wait_com...\n", "5 CWE-667 static int userfaultfd_release ( struc...\n", "6 CWE-667 static void userfaultfd_event_wait_com...\n", "7 CWE-362 static int userfaultfd_register ( stru...\n", "8 CWE-362 struct vm_area_struct * find_extend_vm...\n", "9 CWE-667 static int userfaultfd_register ( stru...\n", "10 CWE-667 struct vm_area_struct * find_extend_vm...\n", "Name: source, dtype: object\n", "test: 0 CWE-667 static int userfaultfd_unregister ( st...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-11413\n", "train: 0 CWE-674 void js_RegExp_prototype_exec ( js_Sta...\n", "1 CWE-674 static void Sp_split_regexp ( js_State...\n", "2 CWE-400 static void Sp_replace_regexp ( js_Sta...\n", "3 CWE-674 static int match ( Rei...\n", "4 CWE-400 static void Sp_split_regexp ( js_State...\n", "5 CWE-400 void js_RegExp_prototype_exec ( js_Sta...\n", "6 CWE-674 static void Rp_test ( js_State * J ) {...\n", "7 CWE-400 static void Sp_match ( js_State * J ) ...\n", "8 CWE-400 static int match ( Rei...\n", "9 CWE-674 static void Sp_replace_regexp ( js_Sta...\n", "10 CWE-400 static void Rp_test ( js_State * J ) {...\n", "11 CWE-674 static void Sp_match ( js_State * J ) ...\n", "Name: source, dtype: object\n", "test: 0 CWE-674 static void Sp_search ( js_State * J )...\n", "1 CWE-674 int regexec ( Reprog * prog , const ch...\n", "2 CWE-400 int regexec ( Reprog * prog , const ch...\n", "3 CWE-400 static void Sp_search ( js_State * J )...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-674 static void Sp_search ( js_State * J )...\n", "1 CWE-674 int regexec ( Reprog * prog , const ch...\n", "2 CWE-400 int regexec ( Reprog * prog , const ch...\n", "3 CWE-400 static void Sp_search ( js_State * J )...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-24371\n", "train: 0 CWE-763 void luaC_barrier_ ( lua_State * L , G...\n", "1 CWE-763 static void youngcollection ( lua_Stat...\n", "2 CWE-763 static void atomic2gen...\n", "Name: source, dtype: object\n", "test: 0 CWE-763 static int remarkupvals ( global_State...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-763 static int remarkupvals ( global_State...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-26788\n", "train: 0 CWE-20 void httpClientParseQopParam ( const Ht...\n", "1 CWE-20 void enc624j600UpdateMacConfig ( NetInt...\n", "2 CWE-20 error_t mqttSnClientDis...\n", "3 CWE-20 void tcpUpdateRetransmitQueue ( Socket ...\n", "4 CWE-20 TcpOption * tcpGetOption ( TcpHeader * ...\n", " ... \n", "61 CWE-20 error_t httpCheckCharset ( const char_t...\n", "62 CWE-20 error_t ssiProcessExecCommand ( HttpCon...\n", "63 CWE-20 error_t coapClientWriteBody ( CoapClien...\n", "64 CWE-20 bool_t enc624j600IrqHandler ( NetInterf...\n", "65 CWE-20 error_t nicSendPacket ( NetInterface * ...\n", "Name: source, Length: 66, dtype: object\n", "test: 0 CWE-20 error_t coapClientSetRxBlockSize ( Coap...\n", "1 CWE-20 error_t enc28j60SendPacket ( NetInterfa...\n", "2 CWE-20 error_t tja1100Init ( NetInterface * in...\n", "3 CWE-20 error_t httpParseRequestLine ( HttpConn...\n", "4 CWE-20 void httpParseAuthorizationField ( Http...\n", "5 CWE-20 bool_t ksz8851IrqHandler ( NetInterface...\n", "6 CWE-20 error_t ksz8851Init ( NetInterface * in...\n", "7 CWE-20 error_t ksz8851SendPacket ( NetInterfac...\n", "8 CWE-20 void enc28j60WritePhyReg ( NetInterface...\n", "9 CWE-20 error_t webSocketParseAuthenticateField...\n", "10 CWE-20 error_t rawSocketReceiveIpPacket ( Sock...\n", "11 CWE-20 error_t enc624j600UpdateMacAddrFilter (...\n", "12 CWE-20 error_t tja1101Init ( NetInterface * in...\n", "13 CWE-20 error_t httpClientSetQueryString ( Http...\n", "14 CWE-20 error_t enc624j600ReceivePacket ( NetIn...\n", "15 CWE-20 error_t ksz8851ReceivePacket ( NetInter...\n", "16 CWE-20 error_t enc624j600Init ( NetInterface *...\n", "17 CWE-20 error_t httpParseParam ( const char_t *...\n", "18 CWE-20 uint16_t dm9000ReadPhyReg ( uint8_t add...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 error_t coapClientSetRxBlockSize ( Coap...\n", "1 CWE-20 error_t enc28j60SendPacket ( NetInterfa...\n", "2 CWE-20 error_t tja1100Init ( NetInterface * in...\n", "3 CWE-20 error_t httpParseRequestLine ( HttpConn...\n", "4 CWE-20 void httpParseAuthorizationField ( Http...\n", "5 CWE-20 bool_t ksz8851IrqHandler ( NetInterface...\n", "6 CWE-20 error_t ksz8851Init ( NetInterface * in...\n", "7 CWE-20 error_t ksz8851SendPacket ( NetInterfac...\n", "8 CWE-20 void enc28j60WritePhyReg ( NetInterface...\n", "9 CWE-20 error_t webSocketParseAuthenticateField...\n", "10 CWE-20 error_t rawSocketReceiveIpPacket ( Sock...\n", "11 CWE-20 error_t enc624j600UpdateMacAddrFilter (...\n", "12 CWE-20 error_t tja1101Init ( NetInterface * in...\n", "13 CWE-20 error_t httpClientSetQueryString ( Http...\n", "14 CWE-20 error_t enc624j600ReceivePacket ( NetIn...\n", "15 CWE-20 error_t ksz8851ReceivePacket ( NetInter...\n", "16 CWE-20 error_t enc624j600Init ( NetInterface *...\n", "17 CWE-20 error_t httpParseParam ( const char_t *...\n", "18 CWE-20 uint16_t dm9000ReadPhyReg ( uint8_t add...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-15173\n", "train: 0 CWE-119 int l2tp_packet_send ( int sock , stru...\n", "1 CWE-119 int l2tp_recv ( int fd , struct l2tp_p...\n", "2 CWE-119 void l2tp_packet_print ( const struct ...\n", "3 CWE-119 struct l2tp_packet_t * l2tp_packet_all...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int decode_avp ( struct l2tp_av...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int decode_avp ( struct l2tp_av...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-16166\n", "train: 0 CWE-200 void update_process_times ( int user_t...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 void add_interrupt_randomness ( int ir...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 void add_interrupt_randomness ( int ir...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-0546\n", "train: 0 CWE-000 static int list_tables ( MYSQL * mysql...\n", "1 CWE-000 static int list_table_status ( MYSQL *...\n", "2 CWE-000 static int check_options ( int argc , ...\n", "3 CWE-000 static int list_dbs ( MYSQL * mysql , ...\n", "4 CWE-000 void print_arrays_for ( char * set ) {...\n", "5 CWE-000 static int list_fields ( MYSQL * mysql...\n", "6 CWE-000 static void usage ( void ) { PRINT_VER...\n", "7 CWE-000 static int efind ( name ) char * name ...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int process_options ( int argc ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int process_options ( int argc ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3760\n", "train: 0 CWE-20 bool adapter_enable_disable ( ) { int e...\n", "1 CWE-20 int main ( int argc , char * * argv ) {...\n", "2 CWE-20 static int enable ( voi...\n", "3 CWE-20 void bdt_enable ( void ) { bdt_log ( \"E...\n", "4 CWE-20 static future_t * init ( void ) { pthre...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 bt_status_t btif_storage_add_bonded_dev...\n", "1 CWE-20 static int remove_bond ( const bt_bdadd...\n", "2 CWE-20 int main ( int argc , char * * argv ) {...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 bt_status_t btif_storage_add_bonded_dev...\n", "1 CWE-20 static int remove_bond ( const bt_bdadd...\n", "2 CWE-20 int main ( int argc , char * * argv ) {...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20786\n", "train: 0 CWE-476 static VTermScreen * screen_new ( VTer...\n", "1 CWE-476 VTerm * vterm_new_with_allocator ( int...\n", "2 CWE-476 static ScreenCell * realloc_buffer ( V...\n", "3 CWE-476 VTermState * vterm_obtain_state ( VTer...\n", "4 CWE-476 static VTermState * vterm_state_new ( ...\n", "5 CWE-476 INTERNAL void vterm_allocator_free ( V...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 static int resize ( int new_rows , int...\n", "1 CWE-476 INTERNAL void vterm_screen_free ( VTer...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-476 static int resize ( int new_rows , int...\n", "1 CWE-476 INTERNAL void vterm_screen_free ( VTer...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-1182\n", "train: 0 CWE-000 SYSCALL_DEFINE3 ( rt_sigqueueinfo , pi...\n", "1 CWE-000 SYSCALL_DEFINE3 ( rt_sigqueueinfo , pi...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 long do_rt_tgsigqueueinfo ( pid_t tgid...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 long do_rt_tgsigqueueinfo ( pid_t tgid...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-17546\n", "train: 0 CWE-787 static int gtStripContig ( TIFFRGBAIma...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static int gtStripSeparate ( TIFFRGBAI...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 static int gtStripSeparate ( TIFFRGBAI...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-8852\n", "train: 0 CWE-000 static int http_rxchunk ( struct http ...\n", "1 CWE-000 static uint16_t http_dissect_hdrs ( st...\n", "2 CWE-000 static uint16_t http_splitline ( struc...\n", "3 CWE-000 static void http_splitheader ( struct ...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 uint16_t http_DissectRequest ( struct ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 uint16_t http_DissectRequest ( struct ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-10066\n", "train: 0 CWE-119 static Image * ReadAAIImage ( const Im...\n", "1 CWE-120 MagickExport void * AcquireAlignedMemo...\n", "2 CWE-119 static Image * ReadBGRImage ( const Im...\n", "3 CWE-119 static Image * ReadDCMImage ( const Im...\n", "4 CWE-119 static Image * ReadGRAYImage ( const I...\n", "5 CWE-119 static Image * ReadHDRImage ( const Im...\n", "6 CWE-119 static Image * ReadHALDImage ( const I...\n", "7 CWE-119 static Image * ReadGIFImage ( const Im...\n", "8 CWE-120 static Image * ReadLABELImage ( const ...\n", "9 CWE-119 static Image * ReadFITSImage ( const I...\n", "10 CWE-119 static Image * ReadARTImage ( const Im...\n", "11 CWE-119 static Image * ReadDIBImage ( const Im...\n", "12 CWE-119 static Image * ReadFAXImage ( const Im...\n", "13 CWE-119 static Image * ReadCINImage ( const Im...\n", "14 CWE-119 static Image * ReadCUTImage ( const Im...\n", "15 CWE-119 static Image * ReadBMPImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-120 static Image * ReadVIFFImage ( const I...\n", "1 CWE-119 static Image * ReadCMYKImage ( const I...\n", "2 CWE-119 static Image * ReadDDSImage ( const Im...\n", "3 CWE-119 static Image * ReadDPXImage ( const Im...\n", "4 CWE-120 MagickExport void * AcquireQuantumMemo...\n", "5 CWE-119 static Image * ReadAVSImage ( const Im...\n", "6 CWE-119 static Image * ReadHRZImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-120 static Image * ReadVIFFImage ( const I...\n", "1 CWE-119 static Image * ReadCMYKImage ( const I...\n", "2 CWE-119 static Image * ReadDDSImage ( const Im...\n", "3 CWE-119 static Image * ReadDPXImage ( const Im...\n", "4 CWE-120 MagickExport void * AcquireQuantumMemo...\n", "5 CWE-119 static Image * ReadAVSImage ( const Im...\n", "6 CWE-119 static Image * ReadHRZImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-9756\n", "train: 0 CWE-369 sf_count_t psf_fwrite ( const void * p...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 sf_count_t psf_fwrite ( const void * p...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-9708\n", "train: 0 CWE-000 static int traceLogDirective ( MaState...\n", "1 CWE-000 static int closeVirtualHostDirective (...\n", "2 CWE-000 PUBLIC void mprDefaultLogHandler ( cch...\n", "3 CWE-000 static int cacheDirective ( MaState * ...\n", "4 CWE-000 static int requireDirective ( MaState ...\n", "5 CWE-000 static int parseFileInner ( MaState * ...\n", "6 CWE-000 static int crossOriginDirective ( MaSt...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int makeDirDirective ( MaState ...\n", "1 CWE-000 static int sessionCookieDirective ( Ma...\n", "2 CWE-000 static int virtualHostDirective ( MaSt...\n", "3 CWE-000 static void addFormVars ( cchar * buf ...\n", "4 CWE-000 static int errorLogDirective ( MaState...\n", "5 CWE-000 static int traceDirective ( MaState * ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int makeDirDirective ( MaState ...\n", "1 CWE-000 static int sessionCookieDirective ( Ma...\n", "2 CWE-000 static int virtualHostDirective ( MaSt...\n", "3 CWE-000 static void addFormVars ( cchar * buf ...\n", "4 CWE-000 static int errorLogDirective ( MaState...\n", "5 CWE-000 static int traceDirective ( MaState * ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-17456\n", "train: 0 CWE-20 static int fsck_gitmodules_fn ( const c...\n", "1 CWE-88 static int fsck_gitmodules_fn ( const c...\n", "2 CWE-88 static int fsck_gitmodules_fn ( const c...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int fsck_gitmodules_fn ( const c...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-9763\n", "train: 0 CWE-119 static grub_err_t read_foo ( struct gr...\n", "1 CWE-119 void grubfs_free ( GrubFS * gf ) { if ...\n", "2 CWE-119 static int cmd_mount ( void * data , c...\n", "3 CWE-119 static struct grub_ext4_extent_header ...\n", "4 CWE-119 static grub_err_t find_file ( const ch...\n", "5 CWE-119 static grub_err_t read_foo ( struct gr...\n", "6 CWE-119 void grubfs_free ( GrubFS * gf ) { if ...\n", "7 CWE-119 static grub_err_t find_file ( const ch...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static grub_disk_addr_t grub_ext2_read...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static grub_disk_addr_t grub_ext2_read...\n", "Name: source, dtype: object\n", "###\n", "CVE-2012-2893\n", "train: 0 CWE-399 xmlAttrPtr xsltAttrTemplateProcess ( x...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 xmlAttrPtr xsltAttrListTemplateProcess...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 xmlAttrPtr xsltAttrListTemplateProcess...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-2016\n", "train: 0 CWE-269 void virtio_config_writew ( VirtIODevi...\n", "1 CWE-269 void virtio_config_writeb ( VirtIODevi...\n", "2 CWE-269 void virtio_config_writel ( VirtIODevi...\n", "3 CWE-269 uint32_t virtio_config_readl ( VirtIOD...\n", "4 CWE-269 uint32_t virtio_config_readw ( VirtIOD...\n", "Name: source, dtype: object\n", "test: 0 CWE-269 uint32_t virtio_config_readb ( VirtIOD...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-269 uint32_t virtio_config_readb ( VirtIOD...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-7271\n", "train: 0 CWE-20 static int llc_ui_recvmsg ( struct kioc...\n", "1 CWE-20 static int atalk_recvmsg ( struct kiocb...\n", "2 CWE-20 static int ipx_recvmsg ( struct kiocb *...\n", "3 CWE-20 static int sco_sock_recvmsg ( struct ki...\n", "4 CWE-20 int rxrpc_recvmsg ( struct kiocb * iocb...\n", "5 CWE-20 static int rfcomm_sock_recvmsg ( struct...\n", "6 CWE-20 static int netlink_recvmsg ( struct kio...\n", "7 CWE-20 static int hci_sock_recvmsg ( struct ki...\n", "8 CWE-20 static int x25_recvmsg ( struct kiocb *...\n", "9 CWE-20 static int nr_recvmsg ( struct kiocb * ...\n", "10 CWE-20 static int pppoe_recvmsg ( struct kiocb...\n", "11 CWE-20 static int caif_seqpkt_recvmsg ( struct...\n", "12 CWE-20 static int hci_sock_recvmsg ( struct ki...\n", "13 CWE-20 static int pppoe_recvmsg ( struct kiocb...\n", "14 CWE-20 static int irda_recvmsg_dgram ( struct ...\n", "15 CWE-20 static int ipx_recvmsg ( struct kiocb *...\n", "16 CWE-20 static int atalk_recvmsg ( struct kiocb...\n", "17 CWE-20 static int irda_recvmsg_stream ( struct...\n", "18 CWE-20 static int vsock_stream_recvmsg ( struc...\n", "19 CWE-20 static int pppol2tp_recvmsg ( struct ki...\n", "20 CWE-20 static int rose_recvmsg ( struct kiocb ...\n", "21 CWE-20 static int iucv_sock_recvmsg ( struct k...\n", "22 CWE-20 static int llc_ui_recvmsg ( struct kioc...\n", "23 CWE-20 int bt_sock_recvmsg ( struct kiocb * io...\n", "24 CWE-20 static int caif_seqpkt_recvmsg ( struct...\n", "25 CWE-20 static int recv_stream ( struct kiocb *...\n", "26 CWE-20 static int rfcomm_sock_recvmsg ( struct...\n", "27 CWE-20 static int nr_recvmsg ( struct kiocb * ...\n", "28 CWE-20 static int pfkey_recvmsg ( struct kiocb...\n", "29 CWE-20 static int iucv_sock_recvmsg ( struct k...\n", "30 CWE-20 static int irda_recvmsg_dgram ( struct ...\n", "31 CWE-20 static int unix_stream_recvmsg ( struct...\n", "32 CWE-20 static int pppol2tp_recvmsg ( struct ki...\n", "33 CWE-20 static int sco_sock_recvmsg ( struct ki...\n", "34 CWE-20 static int llcp_sock_recvmsg ( struct k...\n", "35 CWE-20 static int packet_recvmsg ( struct kioc...\n", "36 CWE-20 int bt_sock_stream_recvmsg ( struct kio...\n", "37 CWE-20 static int netlink_recvmsg ( struct kio...\n", "38 CWE-20 static int llcp_sock_recvmsg ( struct k...\n", "39 CWE-20 int vcc_recvmsg ( struct kiocb * iocb ,...\n", "40 CWE-20 int verify_compat_iovec ( struct msghdr...\n", "41 CWE-20 static int irda_recvmsg_stream ( struct...\n", "42 CWE-20 static int mISDN_sock_recvmsg ( struct ...\n", "43 CWE-20 static int mISDN_sock_recvmsg ( struct ...\n", "44 CWE-20 static int pfkey_recvmsg ( struct kiocb...\n", "45 CWE-20 static int caif_stream_recvmsg ( struct...\n", "46 CWE-20 static int hash_recvmsg ( struct kiocb ...\n", "47 CWE-20 int verify_compat_iovec ( struct msghdr...\n", "48 CWE-20 int verify_iovec ( struct msghdr * m , ...\n", "49 CWE-20 static void unix_copy_addr ( struct msg...\n", "50 CWE-20 static int unix_dgram_recvmsg ( struct ...\n", "51 CWE-20 static int rawsock_recvmsg ( struct kio...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int skcipher_recvmsg ( struct ki...\n", "1 CWE-20 static int recv_msg ( struct kiocb * io...\n", "2 CWE-20 static int vmci_transport_dgram_dequeue...\n", "3 CWE-20 static int ___sys_recvmsg ( struct sock...\n", "4 CWE-20 int rds_recvmsg ( struct kiocb * iocb ,...\n", "5 CWE-20 SYSCALL_DEFINE6 ( recvfrom , int , fd ,...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static int skcipher_recvmsg ( struct ki...\n", "1 CWE-20 static int recv_msg ( struct kiocb * io...\n", "2 CWE-20 static int vmci_transport_dgram_dequeue...\n", "3 CWE-20 static int ___sys_recvmsg ( struct sock...\n", "4 CWE-20 int rds_recvmsg ( struct kiocb * iocb ,...\n", "5 CWE-20 SYSCALL_DEFINE6 ( recvfrom , int , fd ,...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-1476\n", "train: 0 CWE-189 int midi_synth_load_patch ( int dev , ...\n", "1 CWE-189 static int opl3_load_patch ( int dev ,...\n", "2 CWE-189 static int opl3_load_patch ( int dev ,...\n", "3 CWE-189 int midi_synth_load_patch ( int dev , ...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 int sequencer_write ( int dev , struct...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-189 int sequencer_write ( int dev , struct...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-4655\n", "train: 0 CWE-189 static int snd_ctl_elem_add ( struct s...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int snd_ctl_elem_add ( struct s...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2013-4350\n", "train: 0 CWE-310 static void sctp_v6_get_dst ( struct s...\n", "Name: source, dtype: object\n", "test: 0 CWE-310 static int sctp_v6_xmit ( struct sk_bu...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-310 static int sctp_v6_xmit ( struct sk_bu...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-21381\n", "train: 0 CWE-74 static gboolean export_desktop_file ( c...\n", "Name: source, dtype: object\n", "test: 0 CWE-74 static gboolean export_desktop_file ( c...\n", "1 CWE-74 static gboolean export_desktop_file ( c...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-74 static gboolean export_desktop_file ( c...\n", "1 CWE-74 static gboolean export_desktop_file ( c...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-1010319\n", "train: 0 CWE-665 int ParseWave64HeaderConfig ( FILE * i...\n", "Name: source, dtype: object\n", "test: 0 CWE-908 int ParseWave64HeaderConfig ( FILE * i...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-4653\n", "train: 0 CWE-416 static int snd_ctl_tlv_ioctl ( struct ...\n", "1 CWE-000 int snd_ctl_replace ( struct snd_card ...\n", "2 CWE-000 static int snd_ctl_elem_write ( struct...\n", "3 CWE-000 int snd_ctl_add ( struct snd_card * ca...\n", "4 CWE-000 static int snd_ctl_tlv_ioctl ( struct ...\n", "5 CWE-416 int snd_ctl_replace ( struct snd_card ...\n", "6 CWE-416 static int snd_ctl_elem_write ( struct...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 int snd_ctl_add ( struct snd_card * ca...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-12607\n", "train: 0 CWE-347 void pointZZ_pDouble ( PointZZ_p * rop...\n", "1 CWE-347 void pointZZ_pAdd ( PointZZ_p * rop , ...\n", "Name: source, dtype: object\n", "test: 0 CWE-347 void pointZZ_pMul ( Po...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-347 void pointZZ_pMul ( Po...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-3985\n", "train: 0 CWE-119 void * getHTTPResponse ( int s , int *...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 void * getHTTPResponse ( int s , int *...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-3646\n", "train: 0 CWE-264 static bool nested_vmx_exit_handled ( ...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static bool nested_vmx_exit_handled ( ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2011-1575\n", "train: 0 CWE-399 int sfgets ( void ) { struct pollfd pf...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 void parser ( void ) { char * arg ; # ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 void parser ( void ) { char * arg ; # ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-4324\n", "train: 0 CWE-000 struct nfs_open_contex...\n", "1 CWE-000 int nfs4_open_revalidate ( struct inod...\n", "2 CWE-000 static int nfs4_open_r...\n", "3 CWE-000 static void nfs_set_op...\n", "4 CWE-000 static struct nfs4_sta...\n", "5 CWE-000 static struct nfs4_opendata * nfs4_ope...\n", "6 CWE-000 static int _nfs4_do_open_reclaim ( str...\n", "7 CWE-000 static int can_open_ca...\n", "8 CWE-000 static int _nfs4_do_op...\n", "9 CWE-000 static struct nfs4_state * nfs4_openda...\n", "10 CWE-000 static struct nfs4_state * nfs4_try_op...\n", "11 CWE-000 static void nfs4_open_confirm_release ...\n", "12 CWE-000 static void nfs4_open_release ( void *...\n", "13 CWE-000 struct nfs_open_contex...\n", "14 CWE-000 void nfs4_close_state ...\n", "15 CWE-000 static int nfs4_proc_create ( struct i...\n", "16 CWE-000 static int encode_open_downgrade ( str...\n", "17 CWE-000 static void nfs4_open_prepare ( struct...\n", "18 CWE-000 static int can_open_de...\n", "19 CWE-000 void nfs4_close_sync (...\n", "20 CWE-000 struct dentry * nfs4_atomic_open ( str...\n", "21 CWE-000 static void update_ope...\n", "22 CWE-000 static void encode_sha...\n", "23 CWE-000 static struct nfs4_opendata * nfs4_ope...\n", "24 CWE-000 int nfs4_do_close ( struct path * path...\n", "25 CWE-000 static void __nfs4_clo...\n", "26 CWE-000 static void __update_o...\n", "27 CWE-000 static void nfs4_close_done ( struct r...\n", "28 CWE-000 static void nfs4_retur...\n", "29 CWE-000 static int nfs4_intent...\n", "30 CWE-000 static void nfs4_close_prepare ( struc...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static void nfs_set_op...\n", "1 CWE-000 void nfs4_state_set_mo...\n", "2 CWE-000 static inline void encode_openhdr ( st...\n", "3 CWE-000 static int update_open...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static void nfs_set_op...\n", "1 CWE-000 void nfs4_state_set_mo...\n", "2 CWE-000 static inline void encode_openhdr ( st...\n", "3 CWE-000 static int update_open...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-27138\n", "train: 0 CWE-000 int fit_image_verify ( const void * fi...\n", "1 CWE-000 int fit_config_verify_...\n", "2 CWE-000 int fit_check_format ( const void * fi...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int fit_image_verify_sig ( cons...\n", "1 CWE-000 int fit_image_load ( bootm_headers_t *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int fit_image_verify_sig ( cons...\n", "1 CWE-000 int fit_image_load ( bootm_headers_t *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-28374\n", "train: 0 CWE-22 static int target_xcopy_parse_target_de...\n", "1 CWE-22 static int target_xcopy_locate_se_dev_e...\n", "2 CWE-22 static int target_xcopy...\n", "Name: source, dtype: object\n", "test: 0 CWE-22 static void xcopy_pt_undepend_remotedev...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-22 static void xcopy_pt_undepend_remotedev...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9391\n", "train: 0 CWE-000 int jpc_bitstream_putbits ( jpc_bitstr...\n", "1 CWE-000 int jpc_bitstream_putbits ( jpc_bitstr...\n", "2 CWE-000 long jpc_bitstream_getbits ( jpc_bitst...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int jpc_qcd_dumpparms ( jpc_ms_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int jpc_qcd_dumpparms ( jpc_ms_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-14147\n", "train: 0 CWE-190 static size_t optsize ( lua_State * L ...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static void controloptions ( lua_State...\n", "1 CWE-190 static int getnum ( co...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static void controloptions ( lua_State...\n", "1 CWE-190 static int getnum ( co...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-6346\n", "train: 0 CWE-416 static void fanout_release ( struct so...\n", "1 CWE-362 static void fanout_release ( struct so...\n", "2 CWE-362 static int fanout_add ( struct sock * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static int fanout_add ( struct sock * ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-20839\n", "train: 0 CWE-255 static int verify_source_vc ( char * *...\n", "1 CWE-255 static int find_source_vc ( char * * r...\n", "2 CWE-255 int vt_reset_keyboard ( int fd ) { void * H264SwDecMalloc...\n", "2 CWE-119 void * H264SwDecMalloc...\n", "3 CWE-119 int main ( int argc , char * * argv ) ...\n", "4 CWE-119 void * H264SwDecMalloc...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 H264SwDecRet H264SwDecInit ( H264SwDec...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 H264SwDecRet H264SwDecInit ( H264SwDec...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-20016\n", "train: 0 CWE-787 static int directblockRead ( struct RE...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 MYSOFA_EXPORT struct MYSOFA_HRTF * mys...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 MYSOFA_EXPORT struct MYSOFA_HRTF * mys...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-9304\n", "train: 0 CWE-674 int yyparse ( void * yyscanner , RE_LE...\n", "Name: source, dtype: object\n", "test: 0 CWE-674 static void yydestruct ( const char * ...\n", "1 CWE-674 int yr_re_ast_create ( RE_AST * * re_a...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-674 static void yydestruct ( const char * ...\n", "1 CWE-674 int yr_re_ast_create ( RE_AST * * re_a...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9539\n", "train: 0 CWE-125 static int readContigTilesIntoBuffer (...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int readContigTilesIntoBuffer (...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-7115\n", "train: 0 CWE-119 int add_packetdata ( struct mt_packet ...\n", "1 CWE-119 static void handle_data_packet ( struc...\n", "2 CWE-119 int mndp_add_attribute ( struct mt_pac...\n", "3 CWE-119 int add_control_packet ( struct mt_pac...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int handle_packet ( unsigned ch...\n", "1 CWE-119 static void user_login ( struct mt_con...\n", "2 CWE-119 static void send_auth ( char * usernam...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int handle_packet ( unsigned ch...\n", "1 CWE-119 static void user_login ( struct mt_con...\n", "2 CWE-119 static void send_auth ( char * usernam...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3745\n", "train: 0 CWE-119 int effect_command ( effect_handle_t s...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int fx_command ( effect_handle_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int fx_command ( effect_handle_...\n", "Name: source, dtype: object\n", "###\n", "CVE-1999-0199\n", "train: 0 CWE-252 size_t _dl_dst_count ( const char * na...\n", "1 CWE-252 void vsyslog ( pri , fmt , ap ) int pr...\n", "2 CWE-252 static void init_syntax_once ( ) { reg...\n", "Name: source, dtype: object\n", "test: 0 CWE-252 char * _dl_dst_substitute ( struct lin...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-252 char * _dl_dst_substitute ( struct lin...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-2491\n", "train: 0 CWE-399 static void nlmclnt_unlock_callback ( ...\n", "1 CWE-400 static void call_bind_status ( struct ...\n", "2 CWE-399 static void rpc_init_task ( struct rpc...\n", "3 CWE-400 static void rpc_init_task ( struct rpc...\n", "4 CWE-399 static void call_bind_status ( struct ...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 static void nlmclnt_unlock_callback ( ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-9496\n", "train: 0 CWE-787 WORD32 ixheaacd_real_synth_filt ( ia_e...\n", "1 CWE-787 VOID ixheaacd_shiftrountine_with_rnd_h...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 WORD32 ixheaacd_complex_anal_filt ( ia...\n", "1 CWE-787 WORD32 ixheaacd_qmf_hbe_data_reinit ( ...\n", "2 CWE-787 VOID ixheaacd_esbr_radix4bfly ( const ...\n", "3 CWE-787 VOID ixheaacd_esbr_postradixcompute2 (...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 WORD32 ixheaacd_complex_anal_filt ( ia...\n", "1 CWE-787 WORD32 ixheaacd_qmf_hbe_data_reinit ( ...\n", "2 CWE-787 VOID ixheaacd_esbr_radix4bfly ( const ...\n", "3 CWE-787 VOID ixheaacd_esbr_postradixcompute2 (...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-3804\n", "train: 0 CWE-20 static char * static int cipso_v4_de...\n", "2 CWE-362 int ip_options_echo ( struct ip_option...\n", "3 CWE-362 struct sock * tcp_v4_syn_recv_sock ( s...\n", "4 CWE-362 static struct rtable * icmp_route_look...\n", "5 CWE-362 static struct ip_optio...\n", "6 CWE-362 static struct ip_optio...\n", "7 CWE-362 void cipso_v4_sock_delattr ( struct so...\n", "8 CWE-362 static void icmp_reply ( struct icmp_b...\n", "9 CWE-362 struct sock * dccp_v4_request_recv_soc...\n", "10 CWE-362 static int do_ip_getsockopt ( struct s...\n", "11 CWE-362 int dccp_v4_connect ( struct sock * sk...\n", "12 CWE-362 int udp_sendmsg ( struct kiocb * iocb ...\n", "13 CWE-362 int inet_sk_rebuild_header ( struct so...\n", "14 CWE-362 void ip_send_reply ( struct sock * sk ...\n", "15 CWE-362 int tcp_v4_connect ( struct sock * sk ...\n", "16 CWE-362 static int raw_sendmsg ( struct kiocb ...\n", "17 CWE-362 int cipso_v4_req_setattr ( struct requ...\n", "18 CWE-362 static int l2tp_ip_sendmsg ( struct ki...\n", "19 CWE-362 int ip_queue_xmit ( struct sk_buff * s...\n", "20 CWE-362 int dccp_v4_connect ( struct sock * sk...\n", "21 CWE-362 static struct sock * tcp_v6_syn_recv_s...\n", "22 CWE-362 static struct sock * dccp_v6_request_r...\n", "23 CWE-362 static struct sock * dccp_v6_request_r...\n", "24 CWE-362 int ip_options_get ( s...\n", "25 CWE-362 static int inet_sk_reselect_saddr ( st...\n", "26 CWE-362 int ip_build_and_send_pkt ( struct sk_...\n", "27 CWE-362 int cipso_v4_sock_getattr ( struct soc...\n", "28 CWE-362 int cipso_v4_sock_setattr ( struct soc...\n", "29 CWE-362 struct dst_entry * inet_csk_route_req ...\n", "30 CWE-362 void inet_sock_destruct ( struct sock ...\n", "31 CWE-362 static int ip_setup_cork ( struct sock...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 int ip_options_get_fro...\n", "1 CWE-362 void icmp_send ( struct sk_buff * skb_...\n", "2 CWE-362 struct sock * cookie_v4_check ( struct...\n", "3 CWE-362 static int ip_options_...\n", "4 CWE-362 void cipso_v4_req_delattr ( struct req...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 int ip_options_get_fro...\n", "1 CWE-362 void icmp_send ( struct sk_buff * skb_...\n", "2 CWE-362 struct sock * cookie_v4_check ( struct...\n", "3 CWE-362 static int ip_options_...\n", "4 CWE-362 void cipso_v4_req_delattr ( struct req...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-0077\n", "train: 0 CWE-787 static int get_rx_bufs ( struct vhost_...\n", "1 CWE-787 static void handle_rx ( struct vhost_n...\n", "2 CWE-20 static void handle_rx ( struct vhost_ne...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int get_rx_bufs ( struct vhost_v...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-13112\n", "train: 0 CWE-125 static void exif_mnote_data_olympus_lo...\n", "1 CWE-125 static void exif_mnote_data_canon_load...\n", "2 CWE-125 static void exif_mnote_data_pentax_loa...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static void exif_mnote_data_fuji_load ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static void exif_mnote_data_fuji_load ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-11811\n", "train: 0 CWE-416 static int try_smi_init ( struct smi_i...\n", "1 CWE-416 int ipmi_si_port_setup ( struct si_sm_...\n", "2 CWE-416 int ipmi_si_port_setup ( struct si_sm_...\n", "3 CWE-416 static int try_smi_init ( struct smi_i...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 int ipmi_si_mem_setup ( struct si_sm_i...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 int ipmi_si_mem_setup ( struct si_sm_i...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-6663\n", "train: 0 CWE-362 int my_redel ( const char * org_name ,...\n", "1 CWE-362 int my_redel ( const char * org_name ,...\n", "2 CWE-362 int mi_repair ( MI_CHECK * param , reg...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 int mi_repair_parallel ( MI_CHECK * pa...\n", "1 CWE-362 static int myisamchk ( MI_CHECK * para...\n", "2 CWE-362 int mi_sort_index ( MI...\n", "3 CWE-362 int mi_repair_by_sort ( MI_CHECK * par...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 int mi_repair_parallel ( MI_CHECK * pa...\n", "1 CWE-362 static int myisamchk ( MI_CHECK * para...\n", "2 CWE-362 int mi_sort_index ( MI...\n", "3 CWE-362 int mi_repair_by_sort ( MI_CHECK * par...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-2695\n", "train: 0 CWE-763 static OM_uint32 acc_ctx_new ( OM_uint...\n", "1 CWE-763 static OM_uint32 acc_ctx_hints ( OM_ui...\n", "Name: source, dtype: object\n", "test: 0 CWE-763 static OM_uint32 init_ctx_new ( OM_uin...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-763 static OM_uint32 init_ctx_new ( OM_uin...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-6197\n", "train: 0 CWE-20 static int ovl_remove_upper ( struct de...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int ovl_rename2 ( struct inode *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static int ovl_rename2 ( struct inode *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-16425\n", "train: 0 CWE-415 static int read_private_key ( RSA * rs...\n", "1 CWE-415 static int sc_pkcs15emu_sc_hsm_init ( ...\n", "2 CWE-415 static int gemsafe_get_cert_len ( sc_c...\n", "3 CWE-415 static int tcos_select_file ( sc_card_...\n", "4 CWE-415 static int muscle_list_files ( sc_card...\n", "5 CWE-415 static int read_public_key ( RSA * rsa...\n", "6 CWE-415 const char * util_acl_to_str ( const s...\n", "7 CWE-415 int sc_file_set_sec_attr ( sc_file_t *...\n", "8 CWE-415 int read_file ( struct sc_card * card ...\n", "Name: source, dtype: object\n", "test: 0 CWE-415 static int cac_get_serial_nr_from_CUID...\n", "1 CWE-415 static int sc_pkcs15emu_esteid_init ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-415 static int cac_get_serial_nr_from_CUID...\n", "1 CWE-415 static int sc_pkcs15emu_esteid_init ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-1621\n", "train: 0 CWE-119 static void store_coding_context ( MAC...\n", "1 CWE-119 int16_t vp9_ac_quant (...\n", "2 CWE-119 void vp9_encode_frame ( VP9_COMP * cpi...\n", "3 CWE-119 static vpx_codec_err_t ctrl_set_scale_...\n", "4 CWE-119 void vp8_create_common ( VP8_COMMON * ...\n", " ... \n", "580 CWE-119 void vp9_encode_mv ( V...\n", "581 CWE-119 void vp9_setup_past_independence ( VP9...\n", "582 CWE-119 void vp8_yv12_extend_frame_borders_c (...\n", "583 CWE-119 static int64_t rd_sbuv_dcpred ( const ...\n", "584 CWE-119 static void update_best_mode ( BEST_MO...\n", "Name: source, Length: 585, dtype: object\n", "test: 0 CWE-119 static void fdct16 ( c...\n", "1 CWE-119 static void search_fil...\n", "2 CWE-119 static void encode_mv_...\n", "3 CWE-119 static int detect_tran...\n", "4 CWE-119 vpx_codec_err_t vpx_codec_enc_config_d...\n", " ... \n", "135 CWE-119 static int decode_unif...\n", "136 CWE-119 void vp9_cost_tokens_s...\n", "137 CWE-119 static REFERENCE_MODE read_block_refer...\n", "138 CWE-119 static struct stream_state * new_strea...\n", "139 CWE-119 static void first_pass_motion_search (...\n", "Name: source, Length: 140, dtype: object\n", "filtered: 0 CWE-119 static void fdct16 ( c...\n", "1 CWE-119 static void search_fil...\n", "2 CWE-119 static void encode_mv_...\n", "3 CWE-119 static int detect_tran...\n", "4 CWE-119 vpx_codec_err_t vpx_codec_enc_config_d...\n", " ... \n", "135 CWE-119 static int decode_unif...\n", "136 CWE-119 void vp9_cost_tokens_s...\n", "137 CWE-119 static REFERENCE_MODE read_block_refer...\n", "138 CWE-119 static struct stream_state * new_strea...\n", "139 CWE-119 static void first_pass_motion_search (...\n", "Name: source, Length: 140, dtype: object\n", "###\n", "CVE-2015-8324\n", "train: 0 CWE-000 static int ext4_write_begin ( struct f...\n", "1 CWE-000 static int parse_options ( char * opti...\n", "2 CWE-000 int ext4_ext_insert_extent ( handle_t ...\n", "3 CWE-000 static int ext4_ext_handle_uninitializ...\n", "4 CWE-000 static void ext4_end_io_work ( struct ...\n", "5 CWE-000 int ext4_ext_insert_extent ( handle_t ...\n", "6 CWE-000 static int ext4_writepage ( struct pag...\n", "7 CWE-000 static void dump_completed_IO ( struct...\n", "8 CWE-000 int ext4_ext_get_blocks ( handle_t * h...\n", "9 CWE-000 static void ext4_end_io_dio ( struct k...\n", "10 CWE-000 static ssize_t ext4_ext_direct_IO ( in...\n", "11 CWE-000 static int ext4_show_options ( struct ...\n", "12 CWE-000 static void mpage_put_bnr_to_bhs ( str...\n", "13 CWE-000 static int ext4_get_block_write ( stru...\n", "14 CWE-000 static void ext4_free_io_end ( ext4_io...\n", "15 CWE-000 static ext4_io_end_t *...\n", "16 CWE-000 int flush_completed_IO ( struct inode ...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int ext4_end_io_nolock ( ext4_i...\n", "1 CWE-000 static int mpage_da_map_blocks ( struc...\n", "2 CWE-000 static void ext4_invalidatepage ( stru...\n", "3 CWE-000 static struct inode * ext4_alloc_inode...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static int ext4_end_io_nolock ( ext4_i...\n", "1 CWE-000 static int mpage_da_map_blocks ( struc...\n", "2 CWE-000 static void ext4_invalidatepage ( stru...\n", "3 CWE-000 static struct inode * ext4_alloc_inode...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-5592\n", "train: 0 CWE-346 void receive_carbon ( void * * state )...\n", "1 CWE-20 static gboolean _handle_carbons ( xmpp_...\n", "Name: source, dtype: object\n", "test: 0 CWE-346 static gboolean _handle_carbons ( xmpp...\n", "1 CWE-20 void receive_carbon ( void * * state ) ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2019-16347\n", "train: 0 CWE-787 static void WritePixels ( struct ngifl...\n", "1 CWE-119 static void WritePixels ( struct ngifl...\n", "2 CWE-119 static void WritePixel ( struct ngifli...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static void WritePixel ( struct ngifli...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-9644\n", "train: 0 CWE-264 struct crypto_template * crypto_lookup...\n", "Name: source, dtype: object\n", "test: 0 CWE-269 struct crypto_template * crypto_lookup...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-10021\n", "train: 0 CWE-000 static void sas_eh_finish_cmd ( struct...\n", "1 CWE-000 static void sas_eh_handle_sas_errors (...\n", "2 CWE-000 static void sas_eh_handle_sas_errors (...\n", "3 CWE-000 static void sas_eh_finish_cmd ( struct...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static void sas_scsi_clear_queue_lu ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 static void sas_scsi_clear_queue_lu ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-11383\n", "train: 0 CWE-908 static void cmd_anal_esil ( RCore * co...\n", "1 CWE-416 static void cmd_anal_esil ( RCore * co...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 INST_HANDLER ( cpse ) { int r = ( buf ...\n", "1 CWE-908 INST_HANDLER ( cpse ) { int r = ( buf ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 INST_HANDLER ( cpse ) { int r = ( buf ...\n", "1 CWE-908 INST_HANDLER ( cpse ) { int r = ( buf ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-16643\n", "train: 0 CWE-20 static Image * ReadPICTImage ( const Im...\n", "1 CWE-20 static Image * ReadPWPImage ( const Ima...\n", "2 CWE-252 static Image * ReadCALSImage ( const I...\n", "3 CWE-252 static Image * ReadDCMImage ( const Im...\n", "4 CWE-252 static Image * ReadPWPImage ( const Im...\n", "5 CWE-20 static Image * ReadDCMImage ( const Ima...\n", "6 CWE-20 static Image * ReadCALSImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-252 static Image * ReadPICTImage ( const I...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-5283\n", "train: 0 CWE-119 static __init int sctp_init ( void ) {...\n", "1 CWE-119 static __init int sctp_init ( void ) {...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static __exit void sctp_exit ( void ) ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static __exit void sctp_exit ( void ) ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-7448\n", "train: 0 CWE-22 void wiki_handle_http_request ( HttpReq...\n", "1 CWE-22 void wiki_handle_http_request ( HttpReq...\n", "Name: source, dtype: object\n", "test: 0 CWE-22 void wiki_handle_rest_call ( HttpReques...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-22 void wiki_handle_rest_call ( HttpReques...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-5669\n", "train: 0 CWE-20 long do_shmat ( int shmid , char __user...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 long do_shmat ( int shmid , char __use...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-9907\n", "train: 0 CWE-20 static MagickBooleanType ReadDXT3 ( Ima...\n", "1 CWE-20 static MagickBooleanType ReadUncompress...\n", "2 CWE-20 static MagickBooleanType ReadDXT5 ( Ima...\n", "3 CWE-20 static void ComputePrincipleComponent (...\n", "4 CWE-20 static MagickBooleanType ReadUncompress...\n", "5 CWE-20 static Image * ReadDDSImage ( const Ima...\n", "6 CWE-20 static inline void VectorClamp ( DDSVec...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static inline void VectorClamp3 ( DDSVe...\n", "1 CWE-20 static MagickBooleanType ReadDXT1 ( Ima...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static inline void VectorClamp3 ( DDSVe...\n", "1 CWE-20 static MagickBooleanType ReadDXT1 ( Ima...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-4098\n", "train: 0 CWE-119 static long gfs2_fallocate ( struct fi...\n", "1 CWE-119 static long gfs2_fallocate ( struct fi...\n", "2 CWE-119 static int fallocate_chunk ( struct in...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int gfs2_bmap_alloc ( struct in...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int gfs2_bmap_alloc ( struct in...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-11487\n", "train: 0 CWE-416 static struct page * follow_pmd_mask (...\n", "1 CWE-416 static struct page * follow_pmd_mask (...\n", "2 CWE-416 static int get_gate_page ( struct mm_s...\n", "3 CWE-416 long follow_hugetlb_page ( struct mm_s...\n", "4 CWE-416 long follow_hugetlb_page ( struct mm_s...\n", "5 CWE-416 static struct page * follow_pmd_mask (...\n", "6 CWE-416 static struct page * follow_page_pte (...\n", "7 CWE-416 static void buffer_pip...\n", "8 CWE-416 static int link_pipe ( struct pipe_ino...\n", "9 CWE-416 static struct page * follow_page_pte (...\n", "10 CWE-416 void generic_pipe_buf_...\n", "11 CWE-416 static void buffer_pip...\n", "12 CWE-416 static int get_gate_page ( struct mm_s...\n", "13 CWE-416 static struct page * follow_page_pte (...\n", "14 CWE-416 static int splice_pipe_to_pipe ( struc...\n", "15 CWE-416 static int get_gate_page ( struct mm_s...\n", "16 CWE-416 long follow_hugetlb_page ( struct mm_s...\n", "17 CWE-416 static int link_pipe ( struct pipe_ino...\n", "18 CWE-416 void generic_pipe_buf_...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static int splice_pipe_to_pipe ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 static int splice_pipe_to_pipe ( struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-13137\n", "train: 0 CWE-401 static Image * ReadPSImage ( const Ima...\n", "1 CWE-399 static Image * ReadPSImage ( const Ima...\n", "2 CWE-401 static Image * ReadPSImage ( const Ima...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 static Image * ReadPSImage ( const Ima...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-1000115\n", "train: 0 CWE-400 static void settings_init ( void ) { s...\n", "1 CWE-20 int main ( int argc , char * * argv ) {...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 int main ( int argc , char * * argv ) ...\n", "1 CWE-20 static void settings_init ( void ) { se...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-4608\n", "train: 0 CWE-119 int lzo1x_decompress_safe ( const unsi...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 int lzo1x_decompress_safe ( const unsi...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2012-0058\n", "train: 0 CWE-399 static void kiocb_batc...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 long do_io_submit ( aio_context_t ctx_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 long do_io_submit ( aio_context_t ctx_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-25016\n", "train: 0 CWE-732 char * * prepenv ( con...\n", "Name: source, dtype: object\n", "test: 0 CWE-732 static struct env * cr...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-732 static struct env * cr...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-13111\n", "train: 0 CWE-119 static bool static int ion_handle_...\n", "2 CWE-416 void ion_free ( struct ion_client * cl...\n", "3 CWE-416 static long ion_ioctl ( struct file * ...\n", "4 CWE-416 static int ion_handle_...\n", "5 CWE-416 static struct ion_hand...\n", "6 CWE-264 void ion_free ( struct ion_client * cl...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static struct ion_hand...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-2523\n", "train: 0 CWE-20 static int dccp_error ( struct net * ne...\n", "1 CWE-20 static int dccp_error ( struct net * ne...\n", "2 CWE-20 static int dccp_packet ( struct nf_conn...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static bool dccp_new ( struct nf_conn *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static bool dccp_new ( struct nf_conn *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-4532\n", "train: 0 CWE-119 static void stellaris_enet_unrealize (...\n", "1 CWE-119 static void stellaris_enet_class_init ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int stellaris_enet_init ( SysBu...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int stellaris_enet_init ( SysBu...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20459\n", "train: 0 CWE-125 static bool parseOperands ( char * str...\n", "1 CWE-125 static bool parseOperands ( char * str...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 ut32 armass_assemble ( const char * st...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 ut32 armass_assemble ( const char * st...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-7177\n", "train: 0 CWE-358 static void DefragTrackerInit ( Defrag...\n", "Name: source, dtype: object\n", "test: 0 CWE-358 void DefragRegisterTests ( void ) { # ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-358 void DefragRegisterTests ( void ) { # ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-13223\n", "train: 0 CWE-617 static __forceinline void draw_line ( ...\n", "1 CWE-617 static int vorbis_finish_frame ( stb_v...\n", "2 CWE-617 static int start_decoder ( vorb * f ) ...\n", "3 CWE-617 static float * get_window ( vorb * f ,...\n", "Name: source, dtype: object\n", "test: Series([], Name: source, dtype: object)\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-18397\n", "train: 0 CWE-000 static int userfaultfd_unregister ( st...\n", "1 CWE-863 static int userfaultfd_unregister ( st...\n", "2 CWE-863 static int userfaultfd_register ( stru...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 static int userfaultfd_register ( stru...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2012-0044\n", "train: 0 CWE-190 int drm_mode_dirtyfb_ioctl ( struct dr...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 int drm_mode_dirtyfb_ioctl ( struct dr...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-9906\n", "train: 0 CWE-416 static int my_login ( pTHX_ SV * dbh ,...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 int dbd_db_login ( SV * dbh , imp_dbh_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 int dbd_db_login ( SV * dbh , imp_dbh_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-21309\n", "train: 0 CWE-190 sds sdsMakeRoomFor ( sds s , size_t ad...\n", "1 CWE-190 void * zmalloc ( size_...\n", "2 CWE-190 void * zrealloc ( void...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 void * zcalloc ( size_...\n", "1 CWE-190 sds sdsnewlen ( const void * init , si...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 void * zcalloc ( size_...\n", "1 CWE-190 sds sdsnewlen ( const void * init , si...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-9620\n", "train: 0 CWE-399 protected struct magic_set * file_ms_a...\n", "1 CWE-399 protected struct magic_set * file_ms_a...\n", "2 CWE-399 public int magic_setparam ( struct mag...\n", "3 CWE-399 public int magic_setparam ( struct mag...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 public int magic_getparam ( struct mag...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-399 public int magic_getparam ( struct mag...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-20230\n", "train: 0 CWE-295 NOEXPORT char * parse_...\n", "1 CWE-295 NOEXPORT char * base64 ( int encode , ...\n", "2 CWE-295 DH * get_dh2048 ( void ) { static unsi...\n", "3 CWE-295 int main_configure ( char * arg1 , cha...\n", "4 CWE-295 int ssl_init ( void ) { # if OPENSSL_V...\n", "5 CWE-295 NOEXPORT void transfer ( CLI * c ) { i...\n", "6 CWE-295 NOEXPORT void print_cipher ( CLI * c )...\n", "7 CWE-295 void options_apply ( ) { unsigned num ...\n", "8 CWE-295 void main_cleanup ( ) { # ifdef USE_OS...\n", "9 CWE-295 void options_free ( ) ...\n", "10 CWE-295 void log_flush ( LOG_MODE new_mode ) {...\n", "11 CWE-295 int options_parse ( CONF_TYPE type ) {...\n", "12 CWE-295 void options_defaults ( ) { SERVICE_OP...\n", "13 CWE-295 NOEXPORT char * parse_service_option (...\n", "14 CWE-295 int bind_ports ( void ...\n", "15 CWE-295 int context_init ( SERVICE_OPTIONS * s...\n", "Name: source, dtype: object\n", "test: 0 CWE-295 NOEXPORT int verify_callback ( int pre...\n", "1 CWE-295 int options_cmdline ( char * arg1 , ch...\n", "2 CWE-295 NOEXPORT int init_section ( int eof , ...\n", "3 CWE-295 void unbind_ports ( vo...\n", "4 CWE-295 NOEXPORT int options_file ( char * pat...\n", "5 CWE-295 NOEXPORT char * pgsql_server ( CLI * c...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-295 NOEXPORT int verify_callback ( int pre...\n", "1 CWE-295 int options_cmdline ( char * arg1 , ch...\n", "2 CWE-295 NOEXPORT int init_section ( int eof , ...\n", "3 CWE-295 void unbind_ports ( vo...\n", "4 CWE-295 NOEXPORT int options_file ( char * pat...\n", "5 CWE-295 NOEXPORT char * pgsql_server ( CLI * c...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-27097\n", "train: 0 CWE-000 int fit_check_format ( const void * fi...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 int fdt_find_regions ( const void * fd...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 int fdt_find_regions ( const void * fd...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-11463\n", "train: 0 CWE-399 static int archive_read_format_zip_cle...\n", "Name: source, dtype: object\n", "test: 0 CWE-401 static int archive_read_format_zip_cle...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-6887\n", "train: 0 CWE-119 int CLASS parse_tiff_ifd ( int base ) ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int CLASS parse_jpeg ( int offset ) { ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 int CLASS parse_jpeg ( int offset ) { ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-7537\n", "train: 0 CWE-125 static Image * ReadPDBImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static Image * ReadPDBImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static Image * ReadPDBImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-10051\n", "train: 0 CWE-416 static Image * ReadPWPImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static Image * ReadPWPImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 static Image * ReadPWPImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-8109\n", "train: 0 CWE-264 static const char * lua_authz_parse ( ...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static authz_status lua_authz_check ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-264 static authz_status lua_authz_check ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-10966\n", "train: 0 CWE-416 static void nick_hash_remove ( CHANNEL...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 char * my_asctime ( time_t t ) { struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 char * my_asctime ( time_t t ) { struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3179\n", "train: 0 CWE-388 void processRequest ( struct reqelem *...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 void processRequest ( struct reqelem *...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2011-4081\n", "train: 0 CWE-000 static int ghash_update ( struct shash...\n", "1 CWE-476 static int ghash_update ( struct shash...\n", "2 CWE-000 static int ghash_final ( struct shash_...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 static int ghash_final ( struct shash_...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2014-3570\n", "train: 0 CWE-310 void bn_sqr_comba4 ( BN_ULONG * r , co...\n", "1 CWE-310 void bn_mul_comba8 ( BN_ULONG * r , BN...\n", "2 CWE-310 int test_sqr ( BIO * bp , BN_CTX * ctx...\n", "3 CWE-310 void bn_mul_comba4 ( BN_ULONG * r , BN...\n", "Name: source, dtype: object\n", "test: 0 CWE-310 void bn_sqr_comba8 ( BN_ULONG * r , co...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-310 void bn_sqr_comba8 ( BN_ULONG * r , co...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-3905\n", "train: 0 CWE-119 static int translate_hex_string ( char...\n", "1 CWE-119 int main ( int argc , char * argv [ ] ...\n", "2 CWE-119 static int check_line_charstring ( voi...\n", "3 CWE-119 int main ( int argc , char * argv [ ] ...\n", "4 CWE-119 int main ( int argc , char * argv [ ] ...\n", "5 CWE-119 void process_pfa ( FILE * ifp , const ...\n", "6 CWE-119 void process_pfa ( FILE * ifp , const ...\n", "7 CWE-119 static int translate_hex_string ( char...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static void t1mac_output_ascii ( char ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static void t1mac_output_ascii ( char ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-9098\n", "train: 0 CWE-200 static Image * ReadRLEImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-908 static Image * ReadRLEImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-0555\n", "train: 0 CWE-200 WORD32 ih264d_mark_err_slice_skip ( de...\n", "1 CWE-200 WORD32 ih264d_start_of_pic ( dec_struc...\n", "2 CWE-200 WORD32 ih264d_video_decode ( iv_obj_t ...\n", "3 CWE-200 WORD32 ih264d_parse_decode_slice ( UWO...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 WORD32 ih264d_parse_nal_unit ( iv_obj_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 WORD32 ih264d_parse_nal_unit ( iv_obj_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-3637\n", "train: 0 CWE-20 static void m_stop ( struct seq_file * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 static void m_stop ( struct seq_file *...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2013-1773\n", "train: 0 CWE-119 static void kvp_respond_to_host ( char...\n", "1 CWE-119 static int xlate_to_uni ( const unsign...\n", "2 CWE-119 static int xlate_to_uni ( const unsign...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int utf8s_to_utf16s ( ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 int utf8s_to_utf16s ( ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-13308\n", "train: 0 CWE-787 static MagickBooleanType EncodeImage (...\n", "1 CWE-119 static MagickBooleanType EncodeImage (...\n", "2 CWE-119 static MagickBooleanType EncodeImage (...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static MagickBooleanType EncodeImage (...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2012-0879\n", "train: 0 CWE-20 NORET_TYPE void do_exit ( long code ) {...\n", "1 CWE-20 static struct task_struct * copy_proces...\n", "2 CWE-400 void exit_io_context (...\n", "3 CWE-20 void exit_io_context ( void ) { struct ...\n", "4 CWE-400 NORET_TYPE void do_exit ( long code ) ...\n", "5 CWE-400 static struct task_struct * copy_proce...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 void exit_io_context ( void ) { struct...\n", "1 CWE-20 void exit_io_context ( ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-15224\n", "train: 0 CWE-552 ssize_t oe_recvfrom ( int sockfd , voi...\n", "1 CWE-552 static ssize_t _epoll_readv ( oe_fd_t ...\n", "2 CWE-552 static ssize_t _consolefs_readv ( oe_f...\n", "3 CWE-552 static ssize_t _hostsock_send ( oe_fd_...\n", "4 CWE-552 static ssize_t _hostsock_recvmsg ( oe_...\n", "5 CWE-552 static ssize_t _hostsock_writev ( oe_f...\n", "6 CWE-552 static ssize_t _hostsock_sendto ( oe_f...\n", "7 CWE-552 int oe_iov_sync ( const struct oe_iove...\n", "8 CWE-552 static ssize_t _hostsock_recvfrom ( oe...\n", "9 CWE-552 static ssize_t _consolefs_writev ( oe_...\n", "10 CWE-552 static ssize_t _epoll_writev ( oe_fd_t...\n", "11 CWE-552 static int _hostsock_getsockopt ( oe_f...\n", "12 CWE-552 static int _hostsock_getsockname ( oe_...\n", "13 CWE-552 static ssize_t _consolefs_read ( oe_fd...\n", "14 CWE-552 static ssize_t _epoll_read ( oe_fd_t *...\n", "15 CWE-552 int oe_iov_pack ( const struct oe_iove...\n", "16 CWE-552 static ssize_t _hostsock_sendmsg ( oe_...\n", "17 CWE-552 static ssize_t _hostsock_readv ( oe_fd...\n", "18 CWE-552 static long _syscall ( long num , long...\n", "19 CWE-552 static ssize_t _consolefs_write ( oe_f...\n", "Name: source, dtype: object\n", "test: 0 CWE-552 static int _hostresolver_getaddrinfo (...\n", "1 CWE-552 static ssize_t _hostsock_recv ( oe_fd_...\n", "2 CWE-552 static ssize_t _epoll_write ( oe_fd_t ...\n", "3 CWE-552 static int _hostsock_getpeername ( oe_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-552 static int _hostresolver_getaddrinfo (...\n", "1 CWE-552 static ssize_t _hostsock_recv ( oe_fd_...\n", "2 CWE-552 static ssize_t _epoll_write ( oe_fd_t ...\n", "3 CWE-552 static int _hostsock_getpeername ( oe_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-9995\n", "train: 0 CWE-119 static int decompress_i ( AVCodecConte...\n", "1 CWE-119 static int decompress_i ( AVCodecConte...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int decode_unit ( SCPRContext *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int decode_unit ( SCPRContext *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-9728\n", "train: 0 CWE-119 static int udf_symlink_filler ( struct...\n", "1 CWE-119 static int udf_pc_to_char ( struct sup...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int udf_read_inode ( struct ino...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int udf_read_inode ( struct ino...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-13014\n", "train: 0 CWE-125 void wb_print ( netdissect_options * n...\n", "1 CWE-125 void wb_print ( netdissect_options * n...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static int wb_prep ( netdissect_option...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static int wb_prep ( netdissect_option...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-14223\n", "train: 0 CWE-400 static int asf_build_simple_index ( AV...\n", "Name: source, dtype: object\n", "test: 0 CWE-399 static int asf_build_simple_index ( AV...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-17854\n", "train: 0 CWE-190 static int adjust_ptr_min_max_vals ( s...\n", "1 CWE-190 static int adjust_ptr_min_max_vals ( s...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int adjust_scalar_min_max_vals ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static int adjust_scalar_min_max_vals ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-5418\n", "train: 0 CWE-20 static int create_filesystem_object ( s...\n", "1 CWE-20 static int cleanup_pathname ( struct ar...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static int check_symlinks ( struct arch...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 static int check_symlinks ( struct arch...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-9003\n", "train: 0 CWE-416 static void free_user ( struct kref * ...\n", "1 CWE-416 static void free_user ( struct kref * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 int ipmi_destroy_user ( struct ipmi_us...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 int ipmi_destroy_user ( struct ipmi_us...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-3741\n", "train: 0 CWE-20 void ih264d_init_decoder ( void * ps_de...\n", "1 CWE-20 WORD32 ih264d_mark_err_slice_skip ( dec...\n", "2 CWE-20 WORD32 ih264d_video_decode ( iv_obj_t *...\n", "3 CWE-20 WORD32 ih264d_start_of_pic ( dec_struct...\n", "4 CWE-20 WORD32 ih264d_parse_decode_slice ( UWOR...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 WORD32 ih264d_mark_err_slice_skip ( dec...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 WORD32 ih264d_mark_err_slice_skip ( dec...\n", "Name: source, dtype: object\n", "###\n", "CVE-2012-6545\n", "train: 0 CWE-200 static int rfcomm_sock_getsockopt ( st...\n", "1 CWE-200 static int rfcomm_sock_getsockopt ( st...\n", "2 CWE-200 static int rfcomm_get_dev_list ( void ...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 static int rfcomm_sock_getname ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 static int rfcomm_sock_getname ( struc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-13690\n", "train: 0 CWE-125 static const u_char * ikev2_auth_print...\n", "1 CWE-125 static const u_char * ikev2_ke_print (...\n", "2 CWE-125 static const u_char * ikev2_ke_print (...\n", "3 CWE-125 static const u_char * ikev2_auth_print...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static const u_char * ikev2_ID_print (...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static const u_char * ikev2_ID_print (...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-4502\n", "train: 0 CWE-119 bool initiate_stratum ( struct pool * ...\n", "1 CWE-119 bool initiate_stratum ( struct pool * ...\n", "2 CWE-119 bool initiate_stratum ( struct pool * ...\n", "3 CWE-119 static bool parse_reconnect ( struct p...\n", "4 CWE-119 bool initiate_stratum ( struct pool * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static bool parse_notify ( struct pool...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static bool parse_notify ( struct pool...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-7191\n", "train: 0 CWE-476 static int tun_set_iff ( struct net * ...\n", "1 CWE-476 static int tun_set_iff ( struct net * ...\n", "2 CWE-476 static int tun_set_iff ( struct net * ...\n", "3 CWE-476 static int tun_set_iff ( struct net * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 static int dev_get_val...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-476 static int dev_get_val...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-2898\n", "train: 0 CWE-200 static int packet_recvmsg ( struct kio...\n", "1 CWE-200 static int tpacket_rcv ( struct sk_buf...\n", "2 CWE-264 static int tpacket_rcv ( struct sk_buf...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static int packet_recvmsg ( struct kio...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-10060\n", "train: 0 CWE-20 static MagickBooleanType ConcatenateIma...\n", "Name: source, dtype: object\n", "test: 0 CWE-252 static MagickBooleanType ConcatenateIm...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-19854\n", "train: 0 CWE-200 static int crypto_report_akcipher ( st...\n", "1 CWE-000 static int crypto_report_comp ( struct...\n", "2 CWE-200 static int crypto_report_one ( struct ...\n", "3 CWE-200 static int crypto_report_acomp ( struc...\n", "4 CWE-000 static int crypto_report_acomp ( struc...\n", "5 CWE-000 static int crypto_report_akcipher ( st...\n", "6 CWE-000 static int crypto_report_cipher ( stru...\n", "7 CWE-200 static int crypto_report_comp ( struct...\n", "8 CWE-000 static int crypto_report_one ( struct ...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 static int crypto_report_kpp ( struct ...\n", "1 CWE-000 static int crypto_report_kpp ( struct ...\n", "2 CWE-200 static int crypto_report_cipher ( stru...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 static int crypto_report_kpp ( struct ...\n", "1 CWE-000 static int crypto_report_kpp ( struct ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-4621\n", "train: 0 CWE-835 inline void update_rq_clock ( struct r...\n", "1 CWE-000 static void check_preempt_curr ( struc...\n", "2 CWE-835 static void check_preempt_curr ( struc...\n", "Name: source, dtype: object\n", "test: 0 CWE-835 static void put_prev_task ( struct rq ...\n", "1 CWE-000 static void put_prev_task ( struct rq ...\n", "2 CWE-000 inline void update_rq_clock ( struct r...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-835 static void put_prev_task ( struct rq ...\n", "1 CWE-000 static void put_prev_task ( struct rq ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-0589\n", "train: 0 CWE-119 IHEVCD_ERROR_T ihevcd_parse_slice_data...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 IHEVCD_ERROR_T ihevcd_cabac_init ( cab...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 IHEVCD_ERROR_T ihevcd_cabac_init ( cab...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9586\n", "train: 0 CWE-119 static int dprintf_formatf ( void * da...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int test ( char * URL ) { int errors =...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 int test ( char * URL ) { int errors =...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-11080\n", "train: 0 CWE-400 int main ( ) { CU_pSuite pSuite = NULL...\n", "1 CWE-400 static int session_new ( nghttp2_sessi...\n", "2 CWE-400 ssize_t nghttp2_session_mem_recv ( ngh...\n", "3 CWE-400 static int nghttp2_session_upgrade_int...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 ssize_t nghttp2_session_mem_recv ( ngh...\n", "1 CWE-400 const char * nghttp2_strerror ( int er...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-400 ssize_t nghttp2_session_mem_recv ( ngh...\n", "1 CWE-400 const char * nghttp2_strerror ( int er...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-17568\n", "train: 0 CWE-190 int rpc_pack ( rpc_pkg * pkg , void * ...\n", "1 CWE-190 void nw_cache_free ( nw_cache * cache ...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static int on_http_message_complete ( ...\n", "1 CWE-190 void nw_buf_free ( nw_buf_pool * pool ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static int on_http_message_complete ( ...\n", "1 CWE-190 void nw_buf_free ( nw_buf_pool * pool ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-4112\n", "train: 0 CWE-264 static struct net_device * _init_airo_...\n", "1 CWE-264 void vlan_setup ( struct net_device * ...\n", "2 CWE-000 static void ifb_setup ( struct net_dev...\n", "3 CWE-264 static void tun_net_init ( struct net_...\n", "4 CWE-000 void vlan_setup ( struct net_device * ...\n", "5 CWE-264 void macvlan_common_setup ( struct net...\n", "6 CWE-000 void bnep_net_setup ( struct net_devic...\n", "7 CWE-264 static void veth_setup ( struct net_de...\n", "8 CWE-000 static void bond_setup ( struct net_de...\n", "9 CWE-000 void hostap_setup_dev ( struct net_dev...\n", "10 CWE-000 static struct net_device * _init_airo_...\n", "11 CWE-000 static void l2tp_eth_dev_setup ( struc...\n", "12 CWE-264 static void ieee80211_if_setup ( struc...\n", "13 CWE-000 static void veth_setup ( struct net_de...\n", "14 CWE-264 static int fr_add_pvc ( struct net_dev...\n", "15 CWE-264 void bnep_net_setup ( struct net_devic...\n", "16 CWE-264 void hostap_setup_dev ( struct net_dev...\n", "17 CWE-000 static void tun_net_init ( struct net_...\n", "18 CWE-000 void macvlan_common_setup ( struct net...\n", "19 CWE-264 static void bond_setup ( struct net_de...\n", "20 CWE-264 static void _isdn_setup ( struct net_d...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static void l2tp_eth_dev_setup ( struc...\n", "1 CWE-000 static void ieee80211_if_setup ( struc...\n", "2 CWE-000 static void _isdn_setup ( struct net_d...\n", "3 CWE-264 static void ifb_setup ( struct net_dev...\n", "4 CWE-000 static int fr_add_pvc ( struct net_dev...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2017-8062\n", "train: 0 CWE-119 static int tt_s2_4600_frontend_attach ...\n", "1 CWE-119 static int su3000_i2c_transfer ( struc...\n", "2 CWE-119 static int su3000_i2c_transfer ( struc...\n", "3 CWE-119 static int su3000_power_ctrl ( struct ...\n", "4 CWE-119 static int su3000_power_ctrl ( struct ...\n", "5 CWE-119 static int t220_fronte...\n", "6 CWE-119 static int m88rs2000_f...\n", "7 CWE-119 static int t220_fronte...\n", "8 CWE-119 static int tt_s2_4600_frontend_attach ...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int su3000_fron...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int su3000_fron...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-2918\n", "train: 0 CWE-400 static void perf_log_throttle ( struct...\n", "1 CWE-400 int do_mathemu ( struct pt_regs * regs...\n", "2 CWE-400 asmlinkage void do_sparc_fault ( struc...\n", "3 CWE-399 static void emulate_load_store_insn ( ...\n", "4 CWE-400 asmlinkage void kernel_unaligned_trap ...\n", "5 CWE-400 int do_fpu_inst ( unsigned short inst ...\n", "6 CWE-399 asmlinkage void do_ade ( struct pt_reg...\n", "7 CWE-399 static int cop1Emulate ( struct pt_reg...\n", "8 CWE-400 int vis_emul ( struct pt_regs * regs ,...\n", "9 CWE-400 static void record_and_restart ( struc...\n", "10 CWE-400 asmlinkage void user_unaligned_trap ( ...\n", "11 CWE-399 static void perf_event_interrupt ( str...\n", "12 CWE-399 static void record_and_restart ( struc...\n", "13 CWE-400 static int cop1Emulate ( struct pt_reg...\n", "14 CWE-400 int handle_ldf_stq ( u32 insn , struct...\n", "15 CWE-399 static void perf_event_interrupt ( str...\n", "16 CWE-400 void handle_lddfmna ( struct pt_regs *...\n", "17 CWE-400 int perf_output_begin ( struct perf_ou...\n", "18 CWE-399 int do_fpu_inst ( unsigned short inst ...\n", "19 CWE-400 asmlinkage void kernel_unaligned_trap ...\n", "20 CWE-400 int handle_popc ( u32 insn , struct pt...\n", "21 CWE-400 static void alpha_perf_event_irq_handl...\n", "22 CWE-400 static enum hrtimer_restart perf_sweve...\n", "23 CWE-400 static int swp_handler ( struct pt_reg...\n", "24 CWE-399 static int misaligned_store ( struct p...\n", "25 CWE-399 static int simulate_sync ( struct pt_r...\n", "26 CWE-400 void ptrace_triggered ...\n", "27 CWE-400 static int x86_pmu_handle_irq ( struct...\n", "28 CWE-400 static void perf_event_interrupt ( str...\n", "29 CWE-400 static int misaligned_fpu_load ( struc...\n", "30 CWE-400 static int simulate_rdhwr ( struct pt_...\n", "31 CWE-400 static void ptrace_tri...\n", "32 CWE-400 int perf_event_overflo...\n", "33 CWE-400 static int __perf_even...\n", "34 CWE-399 static int swp_handler ( struct pt_reg...\n", "35 CWE-400 static void perf_swevent_event ( struc...\n", "36 CWE-400 static void perf_event_read_event ( st...\n", "37 CWE-400 static void emulate_load_store_insn ( ...\n", "38 CWE-400 static int simulate_sync ( struct pt_r...\n", "39 CWE-400 static void perf_event...\n", "40 CWE-400 static inline int do_exception ( struc...\n", "41 CWE-400 int do_mathemu ( struct pt_regs * regs...\n", "42 CWE-400 static int simulate_llsc ( struct pt_r...\n", "43 CWE-399 void ptrace_triggered ...\n", "44 CWE-400 static void perf_swevent_overflow ( st...\n", "45 CWE-399 static void handle_associated_event ( ...\n", "46 CWE-400 void handle_ld_nf ( u32 insn , struct ...\n", "47 CWE-400 static int misaligned_load ( struct pt...\n", "48 CWE-399 static int simulate_llsc ( struct pt_r...\n", "49 CWE-400 asmlinkage void do_ade ( struct pt_reg...\n", "50 CWE-400 static void sample_hbp...\n", "51 CWE-400 static int misaligned_fpu_store ( stru...\n", "52 CWE-400 static void perf_event_interrupt ( str...\n", "53 CWE-400 static void record_and_restart ( struc...\n", "54 CWE-400 static void handle_associated_event ( ...\n", "55 CWE-400 static void do_perf_sw_event ( enum pe...\n", "56 CWE-400 void handle_stdfmna ( struct pt_regs *...\n", "Name: source, dtype: object\n", "test: 0 CWE-400 void __perf_sw_event (...\n", "1 CWE-399 static void record_and_restart ( struc...\n", "2 CWE-400 int handle_unaligned_access ( insn_siz...\n", "3 CWE-400 asmlinkage void do_page_fault ( struct...\n", "4 CWE-399 int handle_unaligned_access ( insn_siz...\n", "5 CWE-400 static void kgdb_hw_ov...\n", "6 CWE-399 static int misaligned_fpu_store ( stru...\n", "7 CWE-400 static void perf_event_task_output ( s...\n", "8 CWE-400 static void perf_event_comm_output ( s...\n", "9 CWE-399 static int misaligned_load ( struct pt...\n", "10 CWE-399 static int simulate_rdhwr ( struct pt_...\n", "11 CWE-399 static void alpha_perf_event_irq_handl...\n", "12 CWE-400 static void perf_output_wakeup ( struc...\n", "13 CWE-400 static void perf_event_mmap_output ( s...\n", "14 CWE-400 static int misaligned_store ( struct p...\n", "15 CWE-399 static int misaligned_fpu_load ( struc...\n", "16 CWE-399 static inline int do_exception ( struc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-400 void __perf_sw_event (...\n", "1 CWE-400 int handle_unaligned_access ( insn_siz...\n", "2 CWE-400 asmlinkage void do_page_fault ( struct...\n", "3 CWE-399 int handle_unaligned_access ( insn_siz...\n", "4 CWE-400 static void kgdb_hw_ov...\n", "5 CWE-400 static void perf_event_task_output ( s...\n", "6 CWE-400 static void perf_event_comm_output ( s...\n", "7 CWE-400 static void perf_output_wakeup ( struc...\n", "8 CWE-400 static void perf_event_mmap_output ( s...\n", "Name: source, dtype: object\n", "###\n", "CVE-2014-2669\n", "train: 0 CWE-189 TSQuery QTN2QT ( QTNode * in ) { TSQue...\n", "1 CWE-189 Pairs * hstoreArrayToPairs ( ArrayType...\n", "2 CWE-189 Datum lquery_in ( PG_FUNCTION_ARGS ) {...\n", "3 CWE-189 Datum bit_in ( PG_FUNCTION_ARGS ) { ch...\n", "4 CWE-189 static void findoprnd ( ITEM * ptr , i...\n", "5 CWE-189 Datum ltree_in ( PG_FUNCTION_ARGS ) { ...\n", "6 CWE-189 TSQuery parse_tsquery ( char * buf , P...\n", "7 CWE-189 static void findoprnd ( ITEM * ptr , i...\n", "8 CWE-189 Datum bqarr_in ( PG_FUNCTION_ARGS ) { ...\n", "9 CWE-189 Datum poly_in ( PG_FUNCTION_ARGS ) { c...\n", "10 CWE-189 static int32 makepol ( QPRS_STATE * st...\n", "11 CWE-189 Datum varbit_in ( PG_FUNCTION_ARGS ) {...\n", "12 CWE-189 Datum ltree_in ( PG_FUNCTION_ARGS ) { ...\n", "13 CWE-189 static ltxtquery * queryin ( char * bu...\n", "14 CWE-189 static VarBit * bit_catenate ( VarBit ...\n", "15 CWE-189 TSQuery parse_tsquery ( char * buf , P...\n", "16 CWE-189 Datum hstore_from_array ( PG_FUNCTION_...\n", "17 CWE-189 Datum hstore_from_arrays ( PG_FUNCTION...\n", "18 CWE-189 Datum hstore_from_record ( PG_FUNCTION...\n", "19 CWE-189 Datum hstore_from_arrays ( PG_FUNCTION...\n", "20 CWE-189 Datum txid_current_snapshot ( PG_FUNCT...\n", "21 CWE-189 TSQuery QTN2QT ( QTNode * in ) { TSQue...\n", "22 CWE-189 static void findoprnd ( ITEM * ptr , i...\n", "23 CWE-189 Datum path_in ( PG_FUNCTION_ARGS ) { c...\n", "24 CWE-189 Datum bqarr_in ( PG_FUNCTION_ARGS ) { ...\n", "25 CWE-189 Pairs * hstoreArrayToPairs ( ArrayType...\n", "26 CWE-189 Datum path_in ( PG_FUNCTION_ARGS ) { c...\n", "27 CWE-189 Datum poly_in ( PG_FUNCTION_ARGS ) { c...\n", "28 CWE-189 Datum hstore_from_record ( PG_FUNCTION...\n", "29 CWE-189 static int32 makepol ( QPRS_STATE * st...\n", "30 CWE-189 static void findoprnd ( ITEM * ptr , i...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 Datum hstore_recv ( PG_FUNCTION_ARGS )...\n", "1 CWE-189 Datum txid_snapshot_recv ( PG_FUNCTION...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-189 Datum hstore_recv ( PG_FUNCTION_ARGS )...\n", "1 CWE-189 Datum txid_snapshot_recv ( PG_FUNCTION...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-3731\n", "train: 0 CWE-125 static int aes_gcm_ctrl ( EVP_CIPHER_C...\n", "1 CWE-125 static int aes_ccm_ctrl ( EVP_CIPHER_C...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static int chacha20_poly1305_ctrl ( EV...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static int chacha20_poly1305_ctrl ( EV...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-0178\n", "train: 0 CWE-20 void addReply ( redisClient * c , robj ...\n", "1 CWE-20 int dsOpen ( void ) { struct stat sb ; ...\n", "2 CWE-20 void beforeSleep ( struct aeEventLoop *...\n", "3 CWE-20 sds genRedisInfoString ( void ) { sds i...\n", "4 CWE-20 void initServer ( ) { int j ; signal ( ...\n", "5 CWE-20 int prepareForShutdown ( ) { redisLog (...\n", "6 CWE-20 void initServerConfig ( ) { server . po...\n", "7 CWE-20 void freeClient ( redisClient * c ) { l...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 int processCommand ( redisClient * c ) ...\n", "1 CWE-20 int serverCron ( struct aeEventLoop * e...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-20 int processCommand ( redisClient * c ) ...\n", "1 CWE-20 int serverCron ( struct aeEventLoop * e...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-36316\n", "train: 0 CWE-120 static int pad_pkcs2 ( bn_t m , int * ...\n", "1 CWE-120 static int pad_basic ( bn_t m , int * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-120 static int pad_pkcs1 ( bn_t m , int * ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-120 static int pad_pkcs1 ( bn_t m , int * ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-7586\n", "train: 0 CWE-119 static int header_gets ( SF_PRIVATE * ...\n", "1 CWE-119 static inline void header_put_be_3byte...\n", "2 CWE-119 SNDFILE * sf_open_virtual ( SF_VIRTUAL...\n", "3 CWE-119 static inline void header_put_le_short...\n", "4 CWE-119 static inline void header_put_le_int (...\n", "5 CWE-119 int psf_binheader_readf ( SF_PRIVATE *...\n", "6 CWE-119 SNDFILE * sf_open_fd ( int fd , int mo...\n", "7 CWE-119 int id3_skip ( SF_PRIVATE * psf ) { un...\n", "8 CWE-119 static int header_read ( SF_PRIVATE * ...\n", "9 CWE-119 static int psf_close ( SF_PRIVATE * ps...\n", "10 CWE-119 static inline void header_put_byte ( S...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static void header_seek ( SF_PRIVATE *...\n", "1 CWE-119 int psf_binheader_writef ( SF_PRIVATE ...\n", "2 CWE-119 static inline void header_put_be_short...\n", "3 CWE-119 static inline void header_put_le_3byte...\n", "4 CWE-119 SNDFILE * sf_open ( const char * path ...\n", "5 CWE-119 void psf_asciiheader_printf ( SF_PRIVA...\n", "6 CWE-119 static inline void header_put_be_int (...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static void header_seek ( SF_PRIVATE *...\n", "1 CWE-119 int psf_binheader_writef ( SF_PRIVATE ...\n", "2 CWE-119 static inline void header_put_be_short...\n", "3 CWE-119 static inline void header_put_le_3byte...\n", "4 CWE-119 SNDFILE * sf_open ( const char * path ...\n", "5 CWE-119 void psf_asciiheader_printf ( SF_PRIVA...\n", "6 CWE-119 static inline void header_put_be_int (...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-12887\n", "train: 0 CWE-401 static int8_t parse_ext_option ( uint1...\n", "Name: source, dtype: object\n", "test: 0 CWE-401 static int8_t sn_coap_parser_options_p...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-401 static int8_t sn_coap_parser_options_p...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-16909\n", "train: 0 CWE-119 void CLASS parse_fuji ( int offset ) {...\n", "1 CWE-119 void CLASS identify ( ) { static const...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 void CLASS panasonic_load_raw ( ) { in...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 void CLASS panasonic_load_raw ( ) { in...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-7097\n", "train: 0 CWE-285 int ocfs2_set_acl ( handle_t * handle ...\n", "1 CWE-285 int orangefs_set_acl ( struct inode * ...\n", "2 CWE-285 int __gfs2_set_acl ( struct inode * in...\n", "3 CWE-285 int ocfs2_set_acl ( handle_t * handle ...\n", "4 CWE-285 int orangefs_set_acl ( struct inode * ...\n", "5 CWE-285 int jffs2_set_acl ( struct inode * ino...\n", "6 CWE-285 int ext2_set_acl ( struct inode * inod...\n", "7 CWE-285 int hfsplus_set_posix_acl ( struct ino...\n", "8 CWE-285 static int __f2fs_set_acl ( struct ino...\n", "9 CWE-285 static int __ext4_set_acl ( handle_t *...\n", "10 CWE-285 int hfsplus_set_posix_acl ( struct ino...\n", "11 CWE-285 static int __jfs_set_acl ( tid_t tid ,...\n", "12 CWE-285 int __gfs2_set_acl ( struct inode * in...\n", "13 CWE-285 static int __f2fs_set_acl ( struct ino...\n", "14 CWE-285 static int __reiserfs_set_acl ( struct...\n", "15 CWE-285 static int __btrfs_set_acl ( struct bt...\n", "16 CWE-285 static int __ext4_set_acl ( handle_t *...\n", "17 CWE-285 int jffs2_set_acl ( struct inode * ino...\n", "18 CWE-285 int xfs_set_acl ( struct inode * inode...\n", "19 CWE-285 static int v9fs_xattr_set_acl ( const ...\n", "20 CWE-285 int ext2_set_acl ( struct inode * inod...\n", "Name: source, dtype: object\n", "test: 0 CWE-285 int ceph_set_acl ( struct inode * inod...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-285 int ceph_set_acl ( struct inode * inod...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-16300\n", "train: 0 CWE-674 static void bgp_update_print ( netdiss...\n", "Name: source, dtype: object\n", "test: 0 CWE-674 static int bgp_attr_print ( netdissect...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-674 static int bgp_attr_print ( netdissect...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-7186\n", "train: 0 CWE-119 l_int32 gplotMakeOutput ( GPLOT * gplo...\n", "1 CWE-119 GPLOT * gplotCreate ( const char * roo...\n", "2 CWE-787 PTA * ptaReadStream ( FILE * fp ) { ch...\n", "3 CWE-119 l_int32 gplotAddPlot ( GPLOT * gplot ,...\n", "4 CWE-119 l_int32 gplotGenCommandFile ( GPLOT * ...\n", "5 CWE-119 SEL * selReadStream ( FILE * fp ) { ch...\n", "6 CWE-119 GPLOT * gplotRead ( const char * filen...\n", "7 CWE-787 GPLOT * gplotCreate ( const char * roo...\n", "8 CWE-787 l_int32 gplotGenCommandFile ( GPLOT * ...\n", "9 CWE-119 char * selaGetCombName ( SELA * sela ,...\n", "10 CWE-787 GPLOT * gplotRead ( const char * filen...\n", "11 CWE-787 l_int32 gplotMakeOutput ( GPLOT * gplo...\n", "12 CWE-787 char * selaGetCombName ( SELA * sela ,...\n", "13 CWE-787 SEL * selReadStream ( FILE * fp ) { ch...\n", "14 CWE-787 int main ( int argc , char * * argv ) ...\n", "15 CWE-787 l_int32 gplotAddPlot ( GPLOT * gplot ,...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 PTA * ptaReadStream ( FILE * fp ) { ch...\n", "1 CWE-119 int main ( int argc , char * * argv ) ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-10200\n", "train: 0 CWE-264 static int l2tp_ip6_bind ( struct sock...\n", "1 CWE-416 static int l2tp_ip6_bind ( struct sock...\n", "2 CWE-264 static int l2tp_ip_bind ( struct sock ...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static int l2tp_ip_bind ( struct sock ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-15888\n", "train: 0 CWE-416 void luaT_adjustvarargs ( lua_State * ...\n", "1 CWE-416 void luaD_call ( lua_State * L , StkId...\n", "2 CWE-416 void luaV_execute ( lua_State * L , Ca...\n", "3 CWE-416 void luaT_getvarargs ( lua_State * L ,...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 void luaD_shrinkstack ( lua_State * L ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-416 void luaD_shrinkstack ( lua_State * L ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-0642\n", "train: 0 CWE-000 IHEVCD_ERROR_T ihevcd_mv_buf_mgr_add_b...\n", "1 CWE-000 IHEVCD_ERROR_T ihevcd_parse_slice_head...\n", "Name: source, dtype: object\n", "test: 0 CWE-000 WORD32 ihevcd_ref_list ( codec_t * ps_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-000 WORD32 ihevcd_ref_list ( codec_t * ps_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-13272\n", "train: 0 CWE-264 static void ptrace_link ( struct task_...\n", "Name: source, dtype: object\n", "test: 0 CWE-269 static void ptrace_link ( struct task_...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-8900\n", "train: 0 CWE-20 static Image * ReadHDRImage ( const Ima...\n", "Name: source, dtype: object\n", "test: 0 CWE-835 static Image * ReadHDRImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-0849\n", "train: 0 CWE-189 int sysMapFile ( const char * fn , Mem...\n", "1 CWE-189 static int sysMapBlockFile ( FILE * ma...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 static int sysMapFD ( int fd , MemMapp...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-189 static int sysMapFD ( int fd , MemMapp...\n", "Name: source, dtype: object\n", "###\n", "CVE-2013-2128\n", "train: 0 CWE-400 int tcp_read_sock ( struct sock * sk ,...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int tcp_read_sock ( struct sock * sk ,...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2016-10071\n", "train: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-8800\n", "train: 0 CWE-787 STREAM sec_recv ( RD_BOOL * is_fastpat...\n", "1 CWE-787 static void rdpsnd_process_training ( ...\n", "2 CWE-787 static void rdpsnddbg_process ( STREAM...\n", "3 CWE-787 static void process_secondary_order ( ...\n", "4 CWE-787 static void rdpdr_process ( STREAM s )...\n", "5 CWE-787 static RD_BOOL seamless_process_line (...\n", "6 CWE-787 static void seamless_process ( STREAM ...\n", "7 CWE-787 static void lspci_process ( STREAM s )...\n", "8 CWE-787 static int process_plane ( uint8 * in ...\n", "9 CWE-787 static void process_demand_active ( ST...\n", "10 CWE-787 void rdp_in_unistr ( STREAM s , int in...\n", "11 CWE-787 static void cliprdr_process ( STREAM s...\n", "12 CWE-787 void sec_decrypt ( uint8 * data , int ...\n", "13 CWE-787 RD_BOOL cssp_read_tsrequest ( STREAM t...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 void process_bitmap_updates ( STREAM s...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 void process_bitmap_updates ( STREAM s...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-12652\n", "train: 0 CWE-362 static int mptctl_even...\n", "1 CWE-362 static int mptctl_even...\n", "2 CWE-362 static int mptctl_repl...\n", "3 CWE-362 static int mptctl_read...\n", "4 CWE-362 static int mptctl_do_f...\n", "5 CWE-362 static int mptctl_even...\n", "6 CWE-362 static int mptctl_do_m...\n", "7 CWE-362 static int mptctl_hp_t...\n", "8 CWE-362 static long __mptctl_ioctl ( struct fi...\n", "9 CWE-362 static int mptctl_gett...\n", "10 CWE-362 static int mptctl_do_r...\n", "11 CWE-362 static int mptctl_hp_h...\n", "12 CWE-362 static int mptctl_fw_d...\n", "Name: source, dtype: object\n", "test: 0 CWE-362 static int mptctl_geti...\n", "1 CWE-362 static int mptctl_mpt_...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-362 static int mptctl_geti...\n", "1 CWE-362 static int mptctl_mpt_...\n", "Name: source, dtype: object\n", "###\n", "CVE-2021-31262\n", "train: 0 CWE-476 static GF_AV1Config * AV1_DuplicateCon...\n", "Name: source, dtype: object\n", "test: 0 CWE-476 void AV1_RewriteESDescriptorEx ( GF_MP...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-476 void AV1_RewriteESDescriptorEx ( GF_MP...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-10070\n", "train: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static Image * ReadMATImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2016-9557\n", "train: 0 CWE-190 int jas_matrix_resize ...\n", "1 CWE-190 jas_image_t * jpg_decode ( jas_stream_...\n", "2 CWE-190 static int jas_iccputs...\n", "3 CWE-190 jas_image_t * jas_image_create0 ( ) { ...\n", "4 CWE-190 static int pgx_gethdr ( jas_stream_t *...\n", "5 CWE-190 int mif_validate ( jas_stream_t * in )...\n", "6 CWE-190 static inline long dec...\n", "7 CWE-190 jas_image_t * jas_image_create ( int n...\n", "8 CWE-190 int jas_memdump ( FILE * out , void * ...\n", "9 CWE-190 jas_matrix_t * jas_seq2d_input ( FILE ...\n", "10 CWE-190 void jas_matrix_bindsu...\n", "11 CWE-190 int bmp_validate ( jas_stream_t * in )...\n", "12 CWE-190 int jas_seq2d_output ( jas_matrix_t * ...\n", "13 CWE-190 void jas_matrix_asl ( jas_matrix_t * m...\n", "14 CWE-190 jas_image_t * bmp_decode ( jas_stream_...\n", "15 CWE-190 static void jas_stream_initbuf ( jas_s...\n", "16 CWE-190 int jas_matrix_cmp ( jas_matrix_t * ma...\n", "17 CWE-190 static int jas_iccgetuint16 ( jas_stre...\n", "18 CWE-190 static int jas_iccgetuint16 ( jas_stre...\n", "19 CWE-190 void jas_matrix_setall ( jas_matrix_t ...\n", "20 CWE-190 static int jpc_ppm_getparms ( jpc_ms_t...\n", "21 CWE-190 static int jas_iccgetu...\n", "22 CWE-190 int jas_memdump ( FILE * out , void * ...\n", "23 CWE-190 int jpg_validate ( jas_stream_t * in )...\n", "24 CWE-190 static int jas_iccgetu...\n", "25 CWE-190 static int jas_iccputs...\n", "26 CWE-190 static inline ulong en...\n", "27 CWE-190 jas_matrix_t * jas_seq...\n", "28 CWE-190 static int jpc_ppm_putparms ( jpc_ms_t...\n", "29 CWE-190 void jas_seq2d_bindsub...\n", "30 CWE-190 jas_seq2d_t * jas_seq2d_copy ( jas_seq...\n", "31 CWE-190 int pgx_validate ( jas_stream_t * in )...\n", "32 CWE-190 static int jpg_dec_parseopts ( char * ...\n", "33 CWE-190 static int jas_iccgetuint64 ( jas_stre...\n", "34 CWE-190 static int jas_iccgetuint32 ( jas_stre...\n", "35 CWE-190 jas_matrix_t * jas_matrix_copy ( jas_m...\n", "36 CWE-190 jas_iccprof_t * jas_ic...\n", "37 CWE-190 int main ( int argc , char * * argv ) ...\n", "38 CWE-190 static int putint ( jas_stream_t * out...\n", "39 CWE-190 jas_image_t * jp2_decode ( jas_stream_...\n", "40 CWE-190 jpc_ms_t * jpc_getms ( jas_stream_t * ...\n", "41 CWE-190 static int jas_iccputu...\n", "42 CWE-190 jas_matrix_t * jas_mat...\n", "43 CWE-190 void jas_matrix_divpow2 ( jas_matrix_t...\n", "44 CWE-190 static int jas_iccgetsint32 ( jas_stre...\n", "Name: source, dtype: object\n", "test: 0 CWE-190 static jas_image_cmpt_t * jas_image_cm...\n", "1 CWE-190 int ras_validate ( jas_stream_t * in )...\n", "2 CWE-190 void jas_matrix_clip ( jas_matrix_t * ...\n", "3 CWE-190 jpc_streamlist_t * jpc_ppmstabtostream...\n", "4 CWE-190 void jas_matrix_asr ( jas_matrix_t * m...\n", "5 CWE-190 int pnm_validate ( jas_stream_t * in )...\n", "6 CWE-190 static mif_hdr_t * mif_hdr_get ( jas_s...\n", "7 CWE-190 static int jpc_enc_encodemainhdr ( jpc...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-190 static jas_image_cmpt_t * jas_image_cm...\n", "1 CWE-190 int ras_validate ( jas_stream_t * in )...\n", "2 CWE-190 void jas_matrix_clip ( jas_matrix_t * ...\n", "3 CWE-190 jpc_streamlist_t * jpc_ppmstabtostream...\n", "4 CWE-190 void jas_matrix_asr ( jas_matrix_t * m...\n", "5 CWE-190 int pnm_validate ( jas_stream_t * in )...\n", "6 CWE-190 static mif_hdr_t * mif_hdr_get ( jas_s...\n", "7 CWE-190 static int jpc_enc_encodemainhdr ( jpc...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-14464\n", "train: 0 CWE-125 static int lmp_print_data_link_subobjs...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 void lmp_print ( netdissect_options * ...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 void lmp_print ( netdissect_options * ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-20685\n", "train: 0 CWE-863 void sink ( int argc , char * * argv )...\n", "Name: source, dtype: object\n", "test: 0 CWE-706 void sink ( int argc , char * * argv )...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-8958\n", "train: 0 CWE-125 static Image * ReadSUNImage ( const Im...\n", "1 CWE-125 static Image * ReadSUNImage ( const Im...\n", "2 CWE-125 static Image * ReadSUNImage ( const Im...\n", "3 CWE-125 static Image * ReadSUNImage ( const Im...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 static Image * ReadSUNImage ( const Im...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 static Image * ReadSUNImage ( const Im...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-7374\n", "train: 0 CWE-476 static void put_crypt_info ( struct fs...\n", "1 CWE-416 int fscrypt_setup_filename ( struct in...\n", "2 CWE-416 int fscrypt_get_encryption_info ( stru...\n", "3 CWE-476 int fscrypt_get_encryption_info ( stru...\n", "4 CWE-476 static int validate_user_key ( struct ...\n", "5 CWE-416 static int validate_user_key ( struct ...\n", "6 CWE-476 static int fscrypt_d_revalidate ( stru...\n", "7 CWE-476 int fscrypt_setup_filename ( struct in...\n", "8 CWE-416 static void put_crypt_info ( struct fs...\n", "Name: source, dtype: object\n", "test: 0 CWE-416 static int fscrypt_d_revalidate ( stru...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-14359\n", "train: 0 CWE-120 int mutt_b64_decode ( ...\n", "1 CWE-120 void test_base64_lengths ( void ) { co...\n", "2 CWE-120 enum ImapAuthRes imap_auth_cram_md5 ( ...\n", "3 CWE-119 static char * rfc2047_decode_word ( co...\n", "4 CWE-120 static char * rfc2047_decode_word ( co...\n", "5 CWE-119 void test_base64_decode ( void ) { cha...\n", "6 CWE-119 enum ImapAuthRes imap_auth_cram_md5 ( ...\n", "7 CWE-120 enum ImapAuthRes imap_auth_gss ( struc...\n", "8 CWE-119 void test_base64_lengths ( void ) { co...\n", "9 CWE-119 enum ImapAuthRes imap_auth_gss ( struc...\n", "10 CWE-120 void test_base64_decode ( void ) { cha...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 int mutt_b64_decode ( ...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2015-5224\n", "train: 0 CWE-264 int main ( int argc , char * * argv ) ...\n", "1 CWE-000 int xmkstemp ( char * ...\n", "2 CWE-000 int setpwnam ( struct ...\n", "3 CWE-264 static int save_new_data ( struct chfn...\n", "4 CWE-000 int main ( int argc , char * * argv ) ...\n", "5 CWE-264 int xmkstemp ( char * ...\n", "Name: source, dtype: object\n", "test: 0 CWE-264 static FILE * pw_tmpfile ( int lockfd ...\n", "1 CWE-000 static FILE * pw_tmpfile ( int lockfd ...\n", "2 CWE-264 int setpwnam ( struct ...\n", "3 CWE-000 static int save_new_data ( struct chfn...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-264 static FILE * pw_tmpfile ( int lockfd ...\n", "1 CWE-000 static FILE * pw_tmpfile ( int lockfd ...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-0814\n", "train: 0 CWE-200 long vorbis_book_decodev_set ( codeboo...\n", "Name: source, dtype: object\n", "test: 0 CWE-200 long vorbis_book_decodev_add ( codeboo...\n", "1 CWE-200 int res_unpack ( vorbis_info_residue *...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-200 long vorbis_book_decodev_add ( codeboo...\n", "1 CWE-200 int res_unpack ( vorbis_info_residue *...\n", "Name: source, dtype: object\n", "###\n", "CVE-2020-28196\n", "train: 0 CWE-674 static krb5_error_code split_der ( asn...\n", "1 CWE-674 static krb5_error_code decode_atype ( ...\n", "2 CWE-674 static krb5_error_code get_tag ( const...\n", "3 CWE-674 static krb5_error_code decode_sequence...\n", "Name: source, dtype: object\n", "test: 0 CWE-674 krb5_error_code k5_asn1_full_decode ( ...\n", "1 CWE-674 static krb5_error_code decode_sequence...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-674 krb5_error_code k5_asn1_full_decode ( ...\n", "1 CWE-674 static krb5_error_code decode_sequence...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-9996\n", "train: 0 CWE-119 static int cdxl_decode_frame ( AVCodec...\n", "1 CWE-119 static int cdxl_decode_frame ( AVCodec...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 static int cdxl_decode_frame ( AVCodec...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 static int cdxl_decode_frame ( AVCodec...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-9497\n", "train: 0 CWE-787 IMPEG2D_ERROR_CODES_T impeg2d_dec_seq_...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 void impeg2d_dec_hdr ( void * pv_dec ,...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 void impeg2d_dec_hdr ( void * pv_dec ,...\n", "Name: source, dtype: object\n", "###\n", "CVE-2019-12589\n", "train: 0 CWE-284 void preproc_mount_mnt_dir ( void ) { ...\n", "1 CWE-732 void fslib_copy_libs ( const char * fu...\n", "2 CWE-732 int sandbox ( void * sandbox_arg ) { (...\n", "3 CWE-732 void preproc_mount_mnt_dir ( void ) { ...\n", "4 CWE-284 int sandbox ( void * sandbox_arg ) { (...\n", "Name: source, dtype: object\n", "test: 0 CWE-284 void fslib_copy_libs ( const char * fu...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2018-16391\n", "train: 0 CWE-119 static int read_private_key ( RSA * rs...\n", "1 CWE-119 int read_file ( struct sc_card * card ...\n", "2 CWE-119 static int cac_get_serial_nr_from_CUID...\n", "3 CWE-119 int sc_file_set_sec_attr ( sc_file_t *...\n", "4 CWE-119 static int tcos_select_file ( sc_card_...\n", "5 CWE-119 static int sc_pkcs15emu_esteid_init ( ...\n", "6 CWE-119 static int muscle_list_files ( sc_card...\n", "7 CWE-119 static int sc_pkcs15emu_sc_hsm_init ( ...\n", "8 CWE-119 const char * util_acl_to_str ( const s...\n", "9 CWE-119 static int read_public_key ( RSA * rsa...\n", "Name: source, dtype: object\n", "test: Series([], Name: source, dtype: object)\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-15121\n", "train: 0 CWE-78 int r_bin_pdb_download ( RCore * core ,...\n", "1 CWE-78 static inline int r_sys_mkdirp ( char *...\n", "2 CWE-78 bool all_tests ( ) { mu_run_test ( test...\n", "3 CWE-78 R_API char * r_socket_http_get ( const ...\n", "4 CWE-78 static int download ( struct SPDBDownlo...\n", "Name: source, dtype: object\n", "test: 0 CWE-78 R_API char * r_socket_http_post ( const...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-78 R_API char * r_socket_http_post ( const...\n", "Name: source, dtype: object\n", "###\n", "CVE-2018-16644\n", "train: 0 CWE-119 static Image * ReadDCMImage ( const Im...\n", "1 CWE-20 static Image * ReadPICTImage ( const Im...\n", "2 CWE-119 static Image * ReadPICTImage ( const I...\n", "Name: source, dtype: object\n", "test: 0 CWE-20 static Image * ReadDCMImage ( const Ima...\n", "Name: source, dtype: object\n", "filtered: Series([], Name: source, dtype: object)\n", "###\n", "CVE-2020-11089\n", "train: 0 CWE-125 int nego_recv ( rdpTransport * transpo...\n", "1 CWE-125 static UINT serial_process_irp_create ...\n", "2 CWE-125 static UINT printer_process_irp_write ...\n", "3 CWE-125 static UINT parallel_process_irp_creat...\n", "4 CWE-125 static UINT serial_process_irp_write (...\n", "5 CWE-125 static wStream * rdg_receive_packet ( ...\n", "6 CWE-125 static UINT drive_process_irp_write ( ...\n", "Name: source, dtype: object\n", "test: 0 CWE-125 void nego_process_nego...\n", "1 CWE-125 static UINT rdpei_recv_pdu ( RDPEI_CHA...\n", "2 CWE-125 void nego_process_nego...\n", "3 CWE-125 void nego_process_nego...\n", "4 CWE-125 BOOL nego_read_request ( rdpNego * neg...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-125 void nego_process_nego...\n", "1 CWE-125 static UINT rdpei_recv_pdu ( RDPEI_CHA...\n", "2 CWE-125 void nego_process_nego...\n", "3 CWE-125 void nego_process_nego...\n", "4 CWE-125 BOOL nego_read_request ( rdpNego * neg...\n", "Name: source, dtype: object\n", "###\n", "CVE-2011-3209\n", "train: 0 CWE-189 void jiffies_to_timespec ( const unsig...\n", "1 CWE-189 int do_adjtimex ( struct timex * txc )...\n", "2 CWE-189 void jiffies_to_timeval ( const unsign...\n", "3 CWE-189 static __inline__ void jiffies_to_comp...\n", "4 CWE-189 struct timespec ns_to_timespec ( const...\n", "5 CWE-189 static void sgi_timer_get ( struct k_i...\n", "6 CWE-189 static int sgi_timer_set ( struct k_it...\n", "7 CWE-189 void jiffies_to_timespec ( const unsig...\n", "8 CWE-189 void jiffies_to_timeval ( const unsign...\n", "9 CWE-189 static void sample_to_timespec ( const...\n", "10 CWE-189 static void sgi_timer_get ( struct k_i...\n", "11 CWE-189 static __inline__ void jiffies_to_comp...\n", "12 CWE-189 static int sgi_clock_set ( clockid_t c...\n", "13 CWE-189 static int sgi_clock_set ( clockid_t c...\n", "14 CWE-189 struct timespec ns_to_timespec ( const...\n", "15 CWE-189 int do_adjtimex ( struct timex * txc )...\n", "Name: source, dtype: object\n", "test: 0 CWE-189 static inline void jiffies_to_compat_t...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-189 static inline void jiffies_to_compat_t...\n", "Name: source, dtype: object\n", "###\n", "CVE-2015-7510\n", "train: 0 CWE-119 enum nss_status _nss_mymachines_getgrn...\n", "1 CWE-119 enum nss_status _nss_mymachines_getgrn...\n", "Name: source, dtype: object\n", "test: 0 CWE-119 enum nss_status _nss_mymachines_getpwn...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-119 enum nss_status _nss_mymachines_getpwn...\n", "Name: source, dtype: object\n", "###\n", "CVE-2017-1000251\n", "train: 0 CWE-787 static inline int l2cap_config_req ( s...\n", "1 CWE-787 static int l2cap_parse_conf_req ( stru...\n", "2 CWE-787 static int l2cap_sock_listen ( struct ...\n", "3 CWE-787 static int l2cap_sock_connect ( struct...\n", "4 CWE-787 static inline int l2cap_config_rsp ( s...\n", "5 CWE-787 static inline int l2cap_connect_rsp ( ...\n", "Name: source, dtype: object\n", "test: 0 CWE-787 static int l2cap_build_conf_req ( stru...\n", "Name: source, dtype: object\n", "filtered: 0 CWE-787 static int l2cap_build_conf_req ( stru...\n", "Name: source, dtype: object\n", "###\n" ] } ], "source": [ "test_cve = set(disjoint_test['cve_id'])\n", "train_cve = set(train_df['cve_id'])\n", "common_cve = test_cve.intersection(train_cve)\n", "\n", "for cve in common_cve:\n", " print(cve)\n", " train_source = train_df[train_df.cve_id == cve].reset_index(drop=True).source\n", " test_source = disjoint_test[disjoint_test.cve_id == cve].reset_index(drop=True).source\n", "\n", " pattern = r'CWE-\\d+\\s(.*)'\n", " train_matches = train_source.str.extract(pattern)\n", " test_matches = test_source.str.extract(pattern)\n", "\n", " train_set = set(train_matches[0])\n", " test_set = set(test_matches[0])\n", "\n", " disjoint_test = disjoint_test[~(disjoint_test['source'].str.extract(pattern)[0].isin(train_set))]\n", " filtered_source = disjoint_test[disjoint_test.cve_id == cve].reset_index(drop=True).source\n", " print(f'train: {train_source}')\n", " print(f'test: {test_source}')\n", " print(f'filtered: {filtered_source}')\n", "\n", " print('###')" ] }, { "cell_type": "code", "execution_count": 35, "id": "278adce5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((692, 8), (1706, 8))" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "disjoint_test.shape, test_df.shape" ] }, { "cell_type": "code", "execution_count": null, "id": "fe0fb0d5", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "d7606a98", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 36, "id": "2d1cc97a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cwe_idsourcetargetproject_and_commit_idcve_idoriginal_addresstimeprogram_id
0CWE-401CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,...<S2SV_ModStart> op_mutex ) ; kfree_skb ( skb )...torvalds@linux/728c1e2a05e4b5fc52fab3421dce772...CVE-2019-19074https://github.com/torvalds/linux/commit/728c1...2019-11-18T06:15Zprogram_6779
1CWE-189CWE-189 static struct sk_buff * udp6_ufo_fragm...<S2SV_ModStart> ; if ( skb -> mac_header <S2SV...torvalds@linux/0e033e04c2678dbbe74a46b23fffb7b...CVE-2013-4563https://github.com/torvalds/linux/commit/0e033...2013-11-20T13:19Zprogram_6781
2CWE-416CWE-416 void CleanWriters ( GF_List * writers ...<S2SV_ModStart> writers , 0 ) ; gf_list_del_it...gpac@gpac/5aba27604d957e960d8069d85ccaf868f8a7...CVE-2020-35980https://github.com/gpac/gpac/commit/5aba27604d...2021-04-21T16:15Zprogram_6784
3CWE-119CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * a...<S2SV_ModStart> c = array ? array -> child : 0...esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e50...CVE-2016-4303https://github.com/esnet/iperf/commit/91f2fa59...2016-09-26T14:59Zprogram_6787
4CWE-400CWE-400 <S2SV_StartBug> void __perf_sw_event (...<S2SV_ModStart> u64 nr , <S2SV_ModEnd> struct ...torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e9...CVE-2011-2918https://github.com/torvalds/linux/commit/a8b0c...2012-05-24T23:55Zprogram_6790
\n", "
" ], "text/plain": [ " cwe_id source \\\n", "0 CWE-401 CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,... \n", "1 CWE-189 CWE-189 static struct sk_buff * udp6_ufo_fragm... \n", "2 CWE-416 CWE-416 void CleanWriters ( GF_List * writers ... \n", "3 CWE-119 CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * a... \n", "4 CWE-400 CWE-400 void __perf_sw_event (... \n", "\n", " target \\\n", "0 op_mutex ) ; kfree_skb ( skb )... \n", "1 ; if ( skb -> mac_header writers , 0 ) ; gf_list_del_it... \n", "3 c = array ? array -> child : 0... \n", "4 u64 nr , struct ... \n", "\n", " project_and_commit_id cve_id \\\n", "0 torvalds@linux/728c1e2a05e4b5fc52fab3421dce772... CVE-2019-19074 \n", "1 torvalds@linux/0e033e04c2678dbbe74a46b23fffb7b... CVE-2013-4563 \n", "2 gpac@gpac/5aba27604d957e960d8069d85ccaf868f8a7... CVE-2020-35980 \n", "3 esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e50... CVE-2016-4303 \n", "4 torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e9... CVE-2011-2918 \n", "\n", " original_address time \\\n", "0 https://github.com/torvalds/linux/commit/728c1... 2019-11-18T06:15Z \n", "1 https://github.com/torvalds/linux/commit/0e033... 2013-11-20T13:19Z \n", "2 https://github.com/gpac/gpac/commit/5aba27604d... 2021-04-21T16:15Z \n", "3 https://github.com/esnet/iperf/commit/91f2fa59... 2016-09-26T14:59Z \n", "4 https://github.com/torvalds/linux/commit/a8b0c... 2012-05-24T23:55Z \n", "\n", " program_id \n", "0 program_6779 \n", "1 program_6781 \n", "2 program_6784 \n", "3 program_6787 \n", "4 program_6790 " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "disjoint_test.head()" ] }, { "cell_type": "code", "execution_count": 37, "id": "9792e509", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cwe_idsourcetargetproject_and_commit_idcve_idoriginal_addresstimeprogram_id
0CWE-000CWE-000 static void unix_release_sock ( struct...<S2SV_ModStart> ) ; } unix_dgram_peer_wake_dis...torvalds@linux/7d267278a9ece963d77eefec6163022...CVE-2013-7446https://github.com/torvalds/linux/commit/7d267...2015-12-28T11:59Zprogram_1
1CWE-200CWE-200 static void snd_timer_user_tinterrupt ...<S2SV_ModStart> resolution ) { memset ( & r1 ,...torvalds@linux/e4ec8cc8039a7063e24204299b462bd...CVE-2016-4578https://github.com/torvalds/linux/commit/e4ec8...2016-05-23T10:59Zprogram_2
2CWE-119CWE-119 static void store_coding_context ( MAC...<S2SV_ModStart> int mode_index , <S2SV_ModEnd>...external@libvpx/5a9753fca56f0eeb9f61e342b2fccf...CVE-2016-1621https://android.googlesource.com/platform/exte...2016-03-12T21:59Zprogram_3
3CWE-000CWE-000 static int ext4_write_begin ( struct f...<S2SV_ModStart> = page ; if ( ext4_should_dior...torvalds@linux/744692dc059845b2a3022119871846e...CVE-2015-8324https://github.com/torvalds/linux/commit/74469...2016-05-02T10:59Zprogram_4
4CWE-119CWE-119 <S2SV_StartBug> int16_t vp9_ac_quant (...<S2SV_ModStart> , int delta , vpx_bit_depth_t ...external@libvpx/5a9753fca56f0eeb9f61e342b2fccf...CVE-2016-1621https://android.googlesource.com/platform/exte...2016-03-12T21:59Zprogram_5
\n", "
" ], "text/plain": [ " cwe_id source \\\n", "0 CWE-000 CWE-000 static void unix_release_sock ( struct... \n", "1 CWE-200 CWE-200 static void snd_timer_user_tinterrupt ... \n", "2 CWE-119 CWE-119 static void store_coding_context ( MAC... \n", "3 CWE-000 CWE-000 static int ext4_write_begin ( struct f... \n", "4 CWE-119 CWE-119 int16_t vp9_ac_quant (... \n", "\n", " target \\\n", "0 ) ; } unix_dgram_peer_wake_dis... \n", "1 resolution ) { memset ( & r1 ,... \n", "2 int mode_index , ... \n", "3 = page ; if ( ext4_should_dior... \n", "4 , int delta , vpx_bit_depth_t ... \n", "\n", " project_and_commit_id cve_id \\\n", "0 torvalds@linux/7d267278a9ece963d77eefec6163022... CVE-2013-7446 \n", "1 torvalds@linux/e4ec8cc8039a7063e24204299b462bd... CVE-2016-4578 \n", "2 external@libvpx/5a9753fca56f0eeb9f61e342b2fccf... CVE-2016-1621 \n", "3 torvalds@linux/744692dc059845b2a3022119871846e... CVE-2015-8324 \n", "4 external@libvpx/5a9753fca56f0eeb9f61e342b2fccf... CVE-2016-1621 \n", "\n", " original_address time \\\n", "0 https://github.com/torvalds/linux/commit/7d267... 2015-12-28T11:59Z \n", "1 https://github.com/torvalds/linux/commit/e4ec8... 2016-05-23T10:59Z \n", "2 https://android.googlesource.com/platform/exte... 2016-03-12T21:59Z \n", "3 https://github.com/torvalds/linux/commit/74469... 2016-05-02T10:59Z \n", "4 https://android.googlesource.com/platform/exte... 2016-03-12T21:59Z \n", "\n", " program_id \n", "0 program_1 \n", "1 program_2 \n", "2 program_3 \n", "3 program_4 \n", "4 program_5 " ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_df.head()" ] }, { "cell_type": "code", "execution_count": 38, "id": "4373114a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cwe_idsourcetargetproject_and_commit_idcve_idoriginal_addresstimeprogram_id
0CWE-119CWE-119 bool initiate_stratum ( struct pool * ...<S2SV_ModStart> if ( ! valid_hex ( nonce1 ) <S...sgminer-dev@sgminer/e1c5050734123973b99d181c45...CVE-2014-4502https://github.com/sgminer-dev/sgminer/commit/...2014-07-23T14:55Zprogram_6777
1CWE-125CWE-125 void eap_print ( netdissect_options * ...<S2SV_ModStart> case EAP_FRAME_TYPE_PACKET : N...the-tcpdump-group@tcpdump/985122081165753c7442...CVE-2017-13015https://github.com/the-tcpdump-group/tcpdump/c...2017-09-14T06:29Zprogram_6778
2CWE-401CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,...<S2SV_ModStart> op_mutex ) ; kfree_skb ( skb )...torvalds@linux/728c1e2a05e4b5fc52fab3421dce772...CVE-2019-19074https://github.com/torvalds/linux/commit/728c1...2019-11-18T06:15Zprogram_6779
3CWE-399CWE-399 static int yam_ioctl ( struct net_devi...<S2SV_ModStart> case SIOCYAMGCFG : memset ( & ...torvalds@linux/8e3fbf870481eb53b2d3a322d1fc395...CVE-2014-1446https://github.com/torvalds/linux/commit/8e3fb...2014-01-18T22:55Zprogram_6780
4CWE-189CWE-189 static struct sk_buff * udp6_ufo_fragm...<S2SV_ModStart> ; if ( skb -> mac_header <S2SV...torvalds@linux/0e033e04c2678dbbe74a46b23fffb7b...CVE-2013-4563https://github.com/torvalds/linux/commit/0e033...2013-11-20T13:19Zprogram_6781
\n", "
" ], "text/plain": [ " cwe_id source \\\n", "0 CWE-119 CWE-119 bool initiate_stratum ( struct pool * ... \n", "1 CWE-125 CWE-125 void eap_print ( netdissect_options * ... \n", "2 CWE-401 CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi ,... \n", "3 CWE-399 CWE-399 static int yam_ioctl ( struct net_devi... \n", "4 CWE-189 CWE-189 static struct sk_buff * udp6_ufo_fragm... \n", "\n", " target \\\n", "0 if ( ! valid_hex ( nonce1 ) case EAP_FRAME_TYPE_PACKET : N... \n", "2 op_mutex ) ; kfree_skb ( skb )... \n", "3 case SIOCYAMGCFG : memset ( & ... \n", "4 ; if ( skb -> mac_header Rec . RecordLength ) ; if ( Rec . RecordLength > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\"\n", "\n", "Sources:\n", "0: CWE-400 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; one = 1 ; image = AcquireImage ( image_info ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , \"EncryptedWPGImageFileNotSupported\" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; Rec2 . RecordLength = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> x_resolution = BitmapHeader1 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> x_resolution = BitmapHeader2 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , \"UnableToDecompressImage\" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ReplaceImageInList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { size_t one ; one = 1 ; image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( BImgBuff , i , image , bpp ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; } } Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , \"ImageFileDoesNotContainAnyImageData\" ) ; return ( image ) ; }\n", "\n", "1: CWE-400 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; one = 1 ; image = AcquireImage ( image_info , exception ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , \"EncryptedWPGImageFileNotSupported\" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; Rec2 . RecordLength = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> resolution . x = BitmapHeader1 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> resolution . x = BitmapHeader2 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp , exception ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , \"UnableToDecompressImage\" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ReplaceImageInList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( image , BImgBuff , i , bpp , exception ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp , exception ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; } } Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , \"ImageFileDoesNotContainAnyImageData\" ) ; return ( image ) ; }\n", "\n", "\n", "Target: * nlh ; struct module * module ; = false ; module = cb -> module ; skb = cb -> skb ; ; module_put ( module ) ; ; consume_skb ( skb ) ;\n", "\n", "Sources:\n", "0: CWE-415 static int netlink_dump ( struct sock * sk ) { struct netlink_sock * nlk = nlk_sk ( sk ) ; struct netlink_callback * cb ; struct sk_buff * skb = NULL ; struct nlmsghdr * nlh ; int len , err = - ENOBUFS ; int alloc_min_size ; int alloc_size ; mutex_lock ( nlk -> cb_mutex ) ; if ( ! nlk -> cb_running ) { err = - EINVAL ; goto errout_skb ; } if ( atomic_read ( & sk -> sk_rmem_alloc ) >= sk -> sk_rcvbuf ) goto errout_skb ; cb = & nlk -> cb ; alloc_min_size = max_t ( int , cb -> min_dump_alloc , NLMSG_GOODSIZE ) ; if ( alloc_min_size < nlk -> max_recvmsg_len ) { alloc_size = nlk -> max_recvmsg_len ; skb = alloc_skb ( alloc_size , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; } if ( ! skb ) { alloc_size = alloc_min_size ; skb = alloc_skb ( alloc_size , GFP_KERNEL ) ; } if ( ! skb ) goto errout_skb ; skb_reserve ( skb , skb_tailroom ( skb ) - alloc_size ) ; netlink_skb_set_owner_r ( skb , sk ) ; len = cb -> dump ( skb , cb ) ; if ( len > 0 ) { mutex_unlock ( nlk -> cb_mutex ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; return 0 ; } nlh = nlmsg_put_answer ( skb , cb , NLMSG_DONE , sizeof ( len ) , NLM_F_MULTI ) ; if ( ! nlh ) goto errout_skb ; nl_dump_check_consistent ( cb , nlh ) ; memcpy ( nlmsg_data ( nlh ) , & len , sizeof ( len ) ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; if ( cb -> done ) cb -> done ( cb ) ; nlk -> cb_running = false ; mutex_unlock ( nlk -> cb_mutex ) ; module_put ( cb -> module ) ; consume_skb ( cb -> skb ) ; return 0 ; errout_skb : mutex_unlock ( nlk -> cb_mutex ) ; kfree_skb ( skb ) ; return err ; }\n", "\n", "1: CWE-362 static int netlink_dump ( struct sock * sk ) { struct netlink_sock * nlk = nlk_sk ( sk ) ; struct netlink_callback * cb ; struct sk_buff * skb = NULL ; struct nlmsghdr * nlh ; int len , err = - ENOBUFS ; int alloc_min_size ; int alloc_size ; mutex_lock ( nlk -> cb_mutex ) ; if ( ! nlk -> cb_running ) { err = - EINVAL ; goto errout_skb ; } if ( atomic_read ( & sk -> sk_rmem_alloc ) >= sk -> sk_rcvbuf ) goto errout_skb ; cb = & nlk -> cb ; alloc_min_size = max_t ( int , cb -> min_dump_alloc , NLMSG_GOODSIZE ) ; if ( alloc_min_size < nlk -> max_recvmsg_len ) { alloc_size = nlk -> max_recvmsg_len ; skb = alloc_skb ( alloc_size , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; } if ( ! skb ) { alloc_size = alloc_min_size ; skb = alloc_skb ( alloc_size , GFP_KERNEL ) ; } if ( ! skb ) goto errout_skb ; skb_reserve ( skb , skb_tailroom ( skb ) - alloc_size ) ; netlink_skb_set_owner_r ( skb , sk ) ; len = cb -> dump ( skb , cb ) ; if ( len > 0 ) { mutex_unlock ( nlk -> cb_mutex ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; return 0 ; } nlh = nlmsg_put_answer ( skb , cb , NLMSG_DONE , sizeof ( len ) , NLM_F_MULTI ) ; if ( ! nlh ) goto errout_skb ; nl_dump_check_consistent ( cb , nlh ) ; memcpy ( nlmsg_data ( nlh ) , & len , sizeof ( len ) ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; if ( cb -> done ) cb -> done ( cb ) ; nlk -> cb_running = false ; mutex_unlock ( nlk -> cb_mutex ) ; module_put ( cb -> module ) ; consume_skb ( cb -> skb ) ; return 0 ; errout_skb : mutex_unlock ( nlk -> cb_mutex ) ; kfree_skb ( skb ) ; return err ; }\n", "\n", "\n", "Target: CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED CVAR_LATCH ) ; if ( COM_CompareExtension ( s_alDriver -> string , \".pk3\" ) ) { Com_Printf ( \"RejectingDLLnamed\\\\\"%s\\\\\"\" , s_alDriver -> string ) ; return qfalse ; }\n", "\n", "Sources:\n", "0: CWE-269 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( \"s_alPrecache\" , \"1\" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( \"s_alGain\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( \"s_alSources\" , \"96\" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( \"s_alDopplerFactor\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( \"s_alDopplerSpeed\" , \"9000\" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( \"s_alMinDistance\" , \"120\" , CVAR_CHEAT ) ; s_alMaxDistance = Cvar_Get ( \"s_alMaxDistance\" , \"1024\" , CVAR_CHEAT ) ; s_alRolloff = Cvar_Get ( \"s_alRolloff\" , \"2\" , CVAR_CHEAT ) ; s_alGraceDistance = Cvar_Get ( \"s_alGraceDistance\" , \"512\" , CVAR_CHEAT ) ; s_alDriver = Cvar_Get ( \"s_alDriver\" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( \"s_alInputDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( \"s_alDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { Com_Printf ( \"Failedtoloadlibrary:\\\\\"%s\\\\\".\\\\n\" , s_alDriver -> string ) ; if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATE_ALL_EXT\" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATION_EXT\" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = \"\" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , \"GenericHardware\" ) ) device = \"GenericSoftware\" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , \"\\\\n\" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( \"s_alAvailableDevices\" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( \"FailedtoopenOpenALdevice\\'%s\\',tryingdefault.\\\\n\" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( \"FailedtoopenOpenALdevice.\\\\n\" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( \"FailedtocreateOpenALcontext.\\\\n\" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( \"s_alCapture\" , \"1\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledbyuser(\\'+sets_alCapture1\\'toenable)\\\\n\" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledforMumblesupport\\\\n\" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , \"ALC_EXT_capture\" ) ) # endif { Com_Printf ( \"NoALC_EXT_capturesupport,can\\'trecordaudio.\\\\n\" ) ; } else { char inputdevicenames [ 16384 ] = \"\" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , \"\\\\n\" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( \"s_alAvailableInputDevices\" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( \"OpenALdefaultcapturedeviceis\\'%s\\'\\\\n\" , defaultinputdevice ? defaultinputdevice : \"none\" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( \"FailedtoopenOpenALInputdevice\\'%s\\',tryingdefault.\\\\n\" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( \"OpenALcapturedevice%s.\\\\n\" , ( alCaptureDevice == NULL ) ? \"failedtoopen\" : \"opened\" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }\n", "\n", "1: CWE-000 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( \"s_alPrecache\" , \"1\" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( \"s_alGain\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( \"s_alSources\" , \"96\" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( \"s_alDopplerFactor\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( \"s_alDopplerSpeed\" , \"9000\" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( \"s_alMinDistance\" , \"120\" , CVAR_CHEAT ) ; s_alMaxDistance = Cvar_Get ( \"s_alMaxDistance\" , \"1024\" , CVAR_CHEAT ) ; s_alRolloff = Cvar_Get ( \"s_alRolloff\" , \"2\" , CVAR_CHEAT ) ; s_alGraceDistance = Cvar_Get ( \"s_alGraceDistance\" , \"512\" , CVAR_CHEAT ) ; s_alDriver = Cvar_Get ( \"s_alDriver\" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( \"s_alInputDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( \"s_alDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { Com_Printf ( \"Failedtoloadlibrary:\\\\\"%s\\\\\".\\\\n\" , s_alDriver -> string ) ; if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATE_ALL_EXT\" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATION_EXT\" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = \"\" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , \"GenericHardware\" ) ) device = \"GenericSoftware\" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , \"\\\\n\" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( \"s_alAvailableDevices\" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( \"FailedtoopenOpenALdevice\\'%s\\',tryingdefault.\\\\n\" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( \"FailedtoopenOpenALdevice.\\\\n\" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( \"FailedtocreateOpenALcontext.\\\\n\" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( \"s_alCapture\" , \"1\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledbyuser(\\'+sets_alCapture1\\'toenable)\\\\n\" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledforMumblesupport\\\\n\" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , \"ALC_EXT_capture\" ) ) # endif { Com_Printf ( \"NoALC_EXT_capturesupport,can\\'trecordaudio.\\\\n\" ) ; } else { char inputdevicenames [ 16384 ] = \"\" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , \"\\\\n\" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( \"s_alAvailableInputDevices\" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( \"OpenALdefaultcapturedeviceis\\'%s\\'\\\\n\" , defaultinputdevice ? defaultinputdevice : \"none\" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( \"FailedtoopenOpenALInputdevice\\'%s\\',tryingdefault.\\\\n\" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( \"OpenALcapturedevice%s.\\\\n\" , ( alCaptureDevice == NULL ) ? \"failedtoopen\" : \"opened\" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }\n", "\n", "2: CWE-269 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( \"s_alPrecache\" , \"1\" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( \"s_alGain\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( \"s_alSources\" , \"128\" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( \"s_alDopplerFactor\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( \"s_alDopplerSpeed\" , \"9000\" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( \"s_alMinDistance\" , \"256\" , CVAR_ARCHIVE ) ; s_alMaxDistance = Cvar_Get ( \"s_alMaxDistance\" , \"1024\" , CVAR_ARCHIVE ) ; s_alRolloff = Cvar_Get ( \"s_alRolloff\" , \"1.3\" , CVAR_ARCHIVE ) ; s_alGraceDistance = Cvar_Get ( \"s_alGraceDistance\" , \"512\" , CVAR_ARCHIVE ) ; s_alTalkAnims = Cvar_Get ( \"s_alTalkAnims\" , \"160\" , CVAR_ARCHIVE ) ; s_alDriver = Cvar_Get ( \"s_alDriver\" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( \"s_alInputDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( \"s_alDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { # if defined ( _WIN32 ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"OpenAL64.dll\" ) ) { # elif defined ( __APPLE__ ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"/System/Library/Frameworks/OpenAL.framework/OpenAL\" ) ) { # else if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { # endif return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATE_ALL_EXT\" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATION_EXT\" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = \"\" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , \"GenericHardware\" ) ) device = \"GenericSoftware\" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , \"\\\\n\" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( \"s_alAvailableDevices\" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( \"FailedtoopenOpenALdevice\\'%s\\',tryingdefault.\\\\n\" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( \"FailedtoopenOpenALdevice.\\\\n\" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( \"FailedtocreateOpenALcontext.\\\\n\" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; Com_Printf ( \"Allocated%dsources.\\\\n\" , srcCount ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( \"s_alCapture\" , \"1\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledbyuser(\\'+sets_alCapture1\\'toenable)\\\\n\" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledforMumblesupport\\\\n\" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , \"ALC_EXT_capture\" ) ) # endif { Com_Printf ( \"NoALC_EXT_capturesupport,can\\'trecordaudio.\\\\n\" ) ; } else { char inputdevicenames [ 16384 ] = \"\" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , \"\\\\n\" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( \"s_alAvailableInputDevices\" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( \"OpenALdefaultcapturedeviceis\\'%s\\'\\\\n\" , defaultinputdevice ? defaultinputdevice : \"none\" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( \"FailedtoopenOpenALInputdevice\\'%s\\',tryingdefault.\\\\n\" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( \"OpenALcapturedevice%s.\\\\n\" , ( alCaptureDevice == NULL ) ? \"failedtoopen\" : \"opened\" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartSoundEx = S_AL_StartSoundEx ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> FadeStreamingSound = S_AL_FadeStreamingSound ; si -> FadeAllSounds = S_AL_FadeAllSounds ; si -> StartStreamingSound = S_AL_StartStreamingSound ; si -> StopEntStreamingSound = S_AL_StopEntStreamingSound ; si -> GetVoiceAmplitude = S_AL_GetVoiceAmplitude ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }\n", "\n", "3: CWE-000 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( \"s_alPrecache\" , \"1\" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( \"s_alGain\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( \"s_alSources\" , \"128\" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( \"s_alDopplerFactor\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( \"s_alDopplerSpeed\" , \"9000\" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( \"s_alMinDistance\" , \"256\" , CVAR_ARCHIVE ) ; s_alMaxDistance = Cvar_Get ( \"s_alMaxDistance\" , \"1024\" , CVAR_ARCHIVE ) ; s_alRolloff = Cvar_Get ( \"s_alRolloff\" , \"1.3\" , CVAR_ARCHIVE ) ; s_alGraceDistance = Cvar_Get ( \"s_alGraceDistance\" , \"512\" , CVAR_ARCHIVE ) ; s_alTalkAnims = Cvar_Get ( \"s_alTalkAnims\" , \"160\" , CVAR_ARCHIVE ) ; s_alDriver = Cvar_Get ( \"s_alDriver\" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( \"s_alInputDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( \"s_alDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { # if defined ( _WIN32 ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"OpenAL64.dll\" ) ) { # elif defined ( __APPLE__ ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"/System/Library/Frameworks/OpenAL.framework/OpenAL\" ) ) { # else if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { # endif return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATE_ALL_EXT\" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATION_EXT\" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = \"\" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , \"GenericHardware\" ) ) device = \"GenericSoftware\" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , \"\\\\n\" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( \"s_alAvailableDevices\" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( \"FailedtoopenOpenALdevice\\'%s\\',tryingdefault.\\\\n\" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( \"FailedtoopenOpenALdevice.\\\\n\" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( \"FailedtocreateOpenALcontext.\\\\n\" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; Com_Printf ( \"Allocated%dsources.\\\\n\" , srcCount ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( \"s_alCapture\" , \"1\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledbyuser(\\'+sets_alCapture1\\'toenable)\\\\n\" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledforMumblesupport\\\\n\" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , \"ALC_EXT_capture\" ) ) # endif { Com_Printf ( \"NoALC_EXT_capturesupport,can\\'trecordaudio.\\\\n\" ) ; } else { char inputdevicenames [ 16384 ] = \"\" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , \"\\\\n\" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( \"s_alAvailableInputDevices\" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( \"OpenALdefaultcapturedeviceis\\'%s\\'\\\\n\" , defaultinputdevice ? defaultinputdevice : \"none\" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( \"FailedtoopenOpenALInputdevice\\'%s\\',tryingdefault.\\\\n\" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( \"OpenALcapturedevice%s.\\\\n\" , ( alCaptureDevice == NULL ) ? \"failedtoopen\" : \"opened\" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartSoundEx = S_AL_StartSoundEx ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> FadeStreamingSound = S_AL_FadeStreamingSound ; si -> FadeAllSounds = S_AL_FadeAllSounds ; si -> StartStreamingSound = S_AL_StartStreamingSound ; si -> StopEntStreamingSound = S_AL_StopEntStreamingSound ; si -> GetVoiceAmplitude = S_AL_GetVoiceAmplitude ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }\n", "\n", "4: CWE-269 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( \"s_alPrecache\" , \"1\" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( \"s_alGain\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( \"s_alSources\" , \"128\" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( \"s_alDopplerFactor\" , \"1.0\" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( \"s_alDopplerSpeed\" , \"9000\" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( \"s_alMinDistance\" , \"120\" , CVAR_CHEAT ) ; s_alMaxDistance = Cvar_Get ( \"s_alMaxDistance\" , \"1024\" , CVAR_CHEAT ) ; s_alRolloff = Cvar_Get ( \"s_alRolloff\" , \"2\" , CVAR_CHEAT ) ; s_alGraceDistance = Cvar_Get ( \"s_alGraceDistance\" , \"512\" , CVAR_CHEAT ) ; s_alDriver = Cvar_Get ( \"s_alDriver\" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( \"s_alInputDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( \"s_alDevice\" , \"\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { # if defined ( _WIN32 ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"OpenAL64.dll\" ) ) { # elif defined ( __APPLE__ ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( \"/System/Library/Frameworks/OpenAL.framework/OpenAL\" ) ) { # else if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { # endif return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATE_ALL_EXT\" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , \"ALC_ENUMERATION_EXT\" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = \"\" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , \"GenericHardware\" ) ) device = \"GenericSoftware\" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , \"\\\\n\" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( \"s_alAvailableDevices\" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( \"FailedtoopenOpenALdevice\\'%s\\',tryingdefault.\\\\n\" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( \"FailedtoopenOpenALdevice.\\\\n\" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( \"FailedtocreateOpenALcontext.\\\\n\" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; Com_Printf ( \"Allocated%dsources.\\\\n\" , srcCount ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( \"s_alCapture\" , \"1\" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledbyuser(\\'+sets_alCapture1\\'toenable)\\\\n\" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( \"OpenALcapturesupportdisabledforMumblesupport\\\\n\" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , \"ALC_EXT_capture\" ) ) # endif { Com_Printf ( \"NoALC_EXT_capturesupport,can\\'trecordaudio.\\\\n\" ) ; } else { char inputdevicenames [ 16384 ] = \"\" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , \"\\\\n\" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( \"s_alAvailableInputDevices\" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( \"OpenALdefaultcapturedeviceis\\'%s\\'\\\\n\" , defaultinputdevice ? defaultinputdevice : \"none\" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( \"FailedtoopenOpenALInputdevice\\'%s\\',tryingdefault.\\\\n\" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( \"OpenALcapturedevice%s.\\\\n\" , ( alCaptureDevice == NULL ) ? \"failedtoopen\" : \"opened\" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartSoundEx = S_AL_StartSoundEx ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> StartStreamingSound = S_AL_StartStreamingSound ; si -> GetVoiceAmplitude = S_AL_GetVoiceAmplitude ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }\n", "\n", "\n", "Target: & 0xFFFFFFFF ; int remaining ; ) continue ; remaining = avpriv_dnxhd_get_frame_size ; if ( remaining <= 0 0 ) { remaining = dnxhd_get_hr_frame_size ; if ( remaining <= 0 <= 0 ) continue ; } dctx -> remaining = remaining ; if ( buf_size\n", "\n", "Sources:\n", "0: CWE-476 static int dnxhd_find_frame_end ( DNXHDParserContext * dctx , const uint8_t * buf , int buf_size ) { ParseContext * pc = & dctx -> pc ; uint64_t state = pc -> state64 ; int pic_found = pc -> frame_start_found ; int i = 0 ; int interlaced = dctx -> interlaced ; int cur_field = dctx -> cur_field ; if ( ! pic_found ) { for ( i = 0 ; i < buf_size ; i ++ ) { state = ( state << 8 ) | buf [ i ] ; if ( ff_dnxhd_check_header_prefix ( state & 0xffffffffff00LL ) != 0 ) { i ++ ; pic_found = 1 ; interlaced = ( state & 2 ) >> 1 ; cur_field = state & 1 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; break ; } } } if ( pic_found && ! dctx -> remaining ) { if ( ! buf_size ) return 0 ; for ( ; i < buf_size ; i ++ ) { dctx -> cur_byte ++ ; state = ( state << 8 ) | buf [ i ] ; if ( dctx -> cur_byte == 24 ) { dctx -> h = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 26 ) { dctx -> w = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 42 ) { int cid = ( state >> 32 ) & 0xFFFFFFFF ; if ( cid <= 0 ) continue ; dctx -> remaining = avpriv_dnxhd_get_frame_size ( cid ) ; if ( dctx -> remaining <= 0 ) { dctx -> remaining = dnxhd_get_hr_frame_size ( cid , dctx -> w , dctx -> h ) ; if ( dctx -> remaining <= 0 ) return dctx -> remaining ; } if ( buf_size - i >= dctx -> remaining && ( ! dctx -> interlaced || dctx -> cur_field ) ) { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> interlaced = interlaced ; dctx -> cur_field = 0 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } else { dctx -> remaining -= buf_size ; } } } } else if ( pic_found ) { if ( dctx -> remaining > buf_size ) { dctx -> remaining -= buf_size ; } else { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> interlaced = interlaced ; dctx -> cur_field = 0 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } } pc -> frame_start_found = pic_found ; pc -> state64 = state ; dctx -> interlaced = interlaced ; dctx -> cur_field = cur_field ; return END_NOT_FOUND ; }\n", "\n", "1: CWE-476 static int dnxhd_find_frame_end ( DNXHDParserContext * dctx , const uint8_t * buf , int buf_size ) { ParseContext * pc = & dctx -> pc ; uint64_t state = pc -> state64 ; int pic_found = pc -> frame_start_found ; int i = 0 ; if ( ! pic_found ) { for ( i = 0 ; i < buf_size ; i ++ ) { state = ( state << 8 ) | buf [ i ] ; if ( ff_dnxhd_check_header_prefix ( state & 0xffffffffff00LL ) != 0 ) { i ++ ; pic_found = 1 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; break ; } } } if ( pic_found && ! dctx -> remaining ) { if ( ! buf_size ) return 0 ; for ( ; i < buf_size ; i ++ ) { dctx -> cur_byte ++ ; state = ( state << 8 ) | buf [ i ] ; if ( dctx -> cur_byte == 24 ) { dctx -> h = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 26 ) { dctx -> w = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 42 ) { int cid = ( state >> 32 ) & 0xFFFFFFFF ; if ( cid <= 0 ) continue ; dctx -> remaining = avpriv_dnxhd_get_frame_size ( cid ) ; if ( dctx -> remaining <= 0 ) { dctx -> remaining = dnxhd_get_hr_frame_size ( cid , dctx -> w , dctx -> h ) ; if ( dctx -> remaining <= 0 ) return dctx -> remaining ; } if ( buf_size - i + 47 >= dctx -> remaining ) { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } else { dctx -> remaining -= buf_size ; } } } } else if ( pic_found ) { if ( dctx -> remaining > buf_size ) { dctx -> remaining -= buf_size ; } else { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } } pc -> frame_start_found = pic_found ; pc -> state64 = state ; return END_NOT_FOUND ; }\n", "\n", "\n", "Target: off = offset , last_off offset ) ) ; last_off = off ; } } if ( off < last_off ) { THROW ( ReportedBoundsError ) ; } last_off = off ;\n", "\n", "Sources:\n", "0: CWE-119 static guint32 parse_wbxml_attribute_list_defined ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 level , guint8 * codepage_attr , const wbxml_decoding * map ) { guint32 tvb_len = tvb_reported_length ( tvb ) ; guint32 off = offset ; guint32 len ; guint str_len ; guint32 ent ; guint32 idx ; guint8 peek ; guint8 attr_save_known = 0 ; const char * attr_save_literal = NULL ; DebugLog ( ( \"parse_wbxml_attr_defined(level=%u,offset=%u)\\\\n\" , level , offset ) ) ; while ( off < tvb_len ) { peek = tvb_get_guint8 ( tvb , off ) ; DebugLog ( ( \"ATTR:(topofwhile)level=%3u,peek=0x%02X,\" \"off=%u,tvb_len=%u\\\\n\" , level , peek , off , tvb_len ) ) ; if ( ( peek & 0x3F ) < 5 ) switch ( peek ) { case 0x00 : * codepage_attr = tvb_get_guint8 ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 2 , \"|Attr|A-->%3d\" \"|SWITCH_PAGE(Attrcodepage)|\" , * codepage_attr ) ; off += 2 ; break ; case 0x01 : off ++ ; DebugLog ( ( \"ATTR:level=%u,Return:len=%u\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|ENTITY\" \"|%s\\'&#%u;\\'\" , level , * codepage_attr , Indent ( level ) , ent ) ; off += 1 + len ; break ; case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|STR_I(Inlinestring)\" \"|%s\\\\\\'%s\\\\\\'\" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x04 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; attr_save_known = 0 ; attr_save_literal = tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|LITERAL(LiteralAttribute)\" \"|%s<%s/>\" , level , * codepage_attr , Indent ( level ) , attr_save_literal ) ; off += 1 + len ; break ; case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|EXT_I_%1x(ExtensionToken)\" \"|%s(%s:\\\\\\'%s\\\\\\')\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , map_token ( map -> global , 0 , peek ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; { char * s ; if ( map -> ext_t [ peek & 0x03 ] ) s = ( map -> ext_t [ peek & 0x03 ] ) ( tvb , idx , str_tbl ) ; else s = wmem_strdup_printf ( wmem_packet_scope ( ) , \"EXT_T_%1x(%s)\" , peek & 0x03 , map_token ( map -> global , 0 , peek ) ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|EXT_T_%1x(ExtensionToken)\" \"|%s%s)\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , s ) ; } off += 1 + len ; break ; case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|STR_T(Tablerefstring)\" \"|%s\\\\\\'%s\\\\\\'\" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|EXT_%1x(ExtensionToken)\" \"|%s(%s)\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , map_token ( map -> global , 0 , peek ) ) ; off ++ ; break ; case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) { char * str ; if ( attr_save_known ) { if ( map -> opaque_binary_attr ) { str = map -> opaque_binary_attr ( tvb , off + 1 , attr_save_known , * codepage_attr , & len ) ; } else { str = default_opaque_binary_attr ( tvb , off + 1 , attr_save_known , * codepage_attr , & len ) ; } } else { if ( map -> opaque_literal_tag ) { str = map -> opaque_literal_attr ( tvb , off + 1 , attr_save_literal , * codepage_attr , & len ) ; } else { str = default_opaque_literal_attr ( tvb , off + 1 , attr_save_literal , * codepage_attr , & len ) ; } } proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|OPAQUE(Opaquedata)\" \"|%s%s\" , level , * codepage_attr , Indent ( level ) , str ) ; off += 1 + len ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|RESERVED_2(InvalidToken!)\" \"|WBXML1.0parsingstopshere.\" , level , * codepage_attr ) ; off = tvb_len ; DebugLog ( ( \"ATTR:level=%u,Return:len=%u\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; } break ; default : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|%-10s(InvalidToken!)\" \"|WBXMLparsingstopshere.\" , level , * codepage_attr , val_to_str_ext ( peek , & vals_wbxml1x_global_tokens_ext , \"(unknown0x%x)\" ) ) ; off = tvb_len ; break ; } else { if ( peek & 0x80 ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|KnownattrValue0x%02X\" \"|%s%s\" , level , * codepage_attr , peek & 0x7f , Indent ( level ) , map_token ( map -> attrValue , * codepage_attr , peek ) ) ; off ++ ; } else { attr_save_known = peek & 0x7f ; proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|KnownattrStart0x%02X\" \"|%s%s\" , level , * codepage_attr , attr_save_known , Indent ( level ) , map_token ( map -> attrStart , * codepage_attr , peek ) ) ; off ++ ; } } } DebugLog ( ( \"ATTR:level=%u,Return:len=%u(endoffunctionbody)\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; }\n", "\n", "1: CWE-119 static guint32 parse_wbxml_tag_defined ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 * level , guint8 * codepage_stag , guint8 * codepage_attr , const wbxml_decoding * map ) { guint32 tvb_len = tvb_reported_length ( tvb ) ; guint32 off = offset ; guint32 len ; guint str_len ; guint32 ent ; guint32 idx ; guint8 peek ; guint32 tag_len ; guint8 tag_save_known = 0 ; guint8 tag_new_known = 0 ; const char * tag_save_literal ; const char * tag_new_literal ; guint8 parsing_tag_content = FALSE ; tag_save_literal = NULL ; DebugLog ( ( \"parse_wbxml_tag_defined(level=%u,offset=%u)\\\\n\" , * level , offset ) ) ; while ( off < tvb_len ) { peek = tvb_get_guint8 ( tvb , off ) ; DebugLog ( ( \"STAG:(topofwhile)level=%3u,peek=0x%02X,off=%u,tvb_len=%u\\\\n\" , * level , peek , off , tvb_len ) ) ; if ( ( peek & 0x3F ) < 4 ) switch ( peek ) { case 0x00 : * codepage_stag = tvb_get_guint8 ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 2 , \"|Tag|T-->%3d\" \"|SWITCH_PAGE(Tagcodepage)\" \"|\" , * codepage_stag ) ; off += 2 ; break ; case 0x01 : if ( tag_save_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|END(KnownTag0x%02X)\" \"|%s\" , * level , * codepage_stag , tag_save_known , Indent ( * level ) , tag_save_literal ) ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|END(LiteralTag)\" \"|%s\" , * level , * codepage_stag , Indent ( * level ) , tag_save_literal ? tag_save_literal : \"\" ) ; } ( * level ) -- ; off ++ ; DebugLog ( ( \"STAG:level=%u,Return:len=%u\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|ENTITY\" \"|%s\\'&#%u;\\'\" , * level , * codepage_stag , Indent ( * level ) , ent ) ; off += 1 + len ; break ; case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|STR_I(Inlinestring)\" \"|%s\\\\\\'%s\\\\\\'\" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|EXT_I_%1x(ExtensionToken)\" \"|%s(%s:\\\\\\'%s\\\\\\')\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , map_token ( map -> global , 0 , peek ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x43 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|PI(XMLProcessingInstruction)\" \"|%s= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(PI)\" \"|%s?>\" , * level , * codepage_stag , Indent ( * level ) ) ; break ; case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; { char * s ; if ( map -> ext_t [ peek & 0x03 ] ) s = ( map -> ext_t [ peek & 0x03 ] ) ( tvb , idx , str_tbl ) ; else s = wmem_strdup_printf ( wmem_packet_scope ( ) , \"EXT_T_%1x(%s)\" , peek & 0x03 , map_token ( map -> global , 0 , peek ) ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|EXT_T_%1x(ExtensionToken)\" \"|%s%s\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , s ) ; } off += 1 + len ; break ; case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|STR_T(Tablerefstring)\" \"|%s\\\\\\'%s\\\\\\'\" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|EXT_%1x(ExtensionToken)\" \"|%s(%s)\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , map_token ( map -> global , 0 , peek ) ) ; off ++ ; break ; case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) { char * str ; if ( tag_save_known ) { if ( map -> opaque_binary_tag ) { str = map -> opaque_binary_tag ( tvb , off + 1 , tag_save_known , * codepage_stag , & len ) ; } else { str = default_opaque_binary_tag ( tvb , off + 1 , tag_save_known , * codepage_stag , & len ) ; } } else { if ( map -> opaque_literal_tag ) { str = map -> opaque_literal_tag ( tvb , off + 1 , tag_save_literal , * codepage_stag , & len ) ; } else { str = default_opaque_literal_tag ( tvb , off + 1 , tag_save_literal , * codepage_stag , & len ) ; } } proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|OPAQUE(Opaquedata)\" \"|%s%s\" , * level , * codepage_stag , Indent ( * level ) , str ) ; off += 1 + len ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|RESERVED_2(InvalidToken!)\" \"|WBXML1.0parsingstopshere.\" , * level , * codepage_stag ) ; off = tvb_len ; DebugLog ( ( \"STAG:level=%u,Return:len=%u\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; } break ; } else { tag_len = 0 ; if ( ( peek & 0x3F ) == 4 ) { DebugLog ( ( \"STAG:LITERALtag(peek=0x%02X,off=%u)-TableReffollows!\\\\n\" , peek , off ) ) ; idx = tvb_get_guintvar ( tvb , off + 1 , & tag_len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; tag_new_literal = ( const gchar * ) tvb_get_ptr ( tvb , str_tbl + idx , str_len ) ; tag_new_known = 0 ; } else { tag_new_known = peek & 0x3F ; tag_new_literal = map_token ( map -> tags , * codepage_stag , tag_new_known ) ; } if ( peek & 0x40 ) { if ( parsing_tag_content ) { DebugLog ( ( \"STAG:TaginTag-RECURSE!(off=%u)\\\\n\" , off ) ) ; ( * level ) ++ ; len = parse_wbxml_tag_defined ( tree , tvb , off , str_tbl , level , codepage_stag , codepage_attr , map ) ; off += len ; } else { if ( ( peek & 0x3F ) == 4 ) { tag_save_literal = tag_new_literal ; tag_save_known = 0 ; } else { tag_save_known = tag_new_known ; tag_save_literal = tag_new_literal ; } if ( peek & 0x80 ) { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(AC)\" \"|%s<%s\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_AC(Literaltag)(AC)\" \"|%s<%s\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ; off += len ; if ( off >= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(attributelist)\" \"|%s>\" , * level , * codepage_stag , Indent ( * level ) ) ; } else { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(.C)\" \"|%s<%s>\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_C(LiteralTag)(.C)\" \"|%s<%s>\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } } parsing_tag_content = TRUE ; DebugLog ( ( \"TaginTag-Norecursionthistime!(off=%u)\\\\n\" , off ) ) ; } } else { DebugLog ( ( \"inTag-Norecursion!(off=%u)\\\\n\" , off ) ) ; ( * level ) ++ ; if ( peek & 0x80 ) { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(A.)\" \"|%s<%s\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ; off += len ; if ( off > tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(KnownTag)\" \"|%s/>\" , * level , * codepage_stag , Indent ( * level ) ) ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_A(LiteralTag)(A.)\" \"|%s<%s\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ; off += len ; if ( off >= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(LiteralTag)\" \"|%s/>\" , * level , * codepage_stag , Indent ( * level ) ) ; } } else { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02x(..)\" \"|%s<%s/>\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL(LiteralTag)(..)\" \"|%s<%s/>\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } } ( * level ) -- ; } } } DebugLog ( ( \"STAG:level=%u,Return:len=%u(endoffunctionbody)\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; }\n", "\n", "2: CWE-119 static guint32 parse_wbxml_tag ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 * level , guint8 * codepage_stag , guint8 * codepage_attr ) { guint32 tvb_len = tvb_reported_length ( tvb ) ; guint32 off = offset ; guint32 len ; guint str_len ; guint32 ent ; guint32 idx ; guint8 peek ; guint32 tag_len ; guint8 tag_save_known = 0 ; guint8 tag_new_known = 0 ; const char * tag_save_literal ; const char * tag_new_literal ; char * tag_save_buf = NULL ; char * tag_new_buf = NULL ; guint8 parsing_tag_content = FALSE ; tag_save_literal = NULL ; DebugLog ( ( \"parse_wbxml_tag(level=%u,offset=%u)\\\\n\" , * level , offset ) ) ; while ( off < tvb_len ) { peek = tvb_get_guint8 ( tvb , off ) ; DebugLog ( ( \"STAG:(topofwhile)level=%3u,peek=0x%02X,off=%u,tvb_len=%u\\\\n\" , * level , peek , off , tvb_len ) ) ; if ( ( peek & 0x3F ) < 4 ) switch ( peek ) { case 0x00 : * codepage_stag = tvb_get_guint8 ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 2 , \"|Tag|T-->%3d\" \"|SWITCH_PAGE(Tagcodepage)\" \"|\" , * codepage_stag ) ; off += 2 ; break ; case 0x01 : if ( tag_save_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|END(KnownTag0x%02X)\" \"|%s\" , * level , * codepage_stag , tag_save_known , Indent ( * level ) , tag_save_literal ) ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|END(LiteralTag)\" \"|%s\" , * level , * codepage_stag , Indent ( * level ) , tag_save_literal ? tag_save_literal : \"\" ) ; } ( * level ) -- ; off ++ ; DebugLog ( ( \"STAG:level=%u,Return:len=%u\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|ENTITY\" \"|%s\\'&#%u;\\'\" , * level , * codepage_stag , Indent ( * level ) , ent ) ; off += 1 + len ; break ; case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|STR_I(Inlinestring)\" \"|%s\\\\\\'%s\\\\\\'\" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|EXT_I_%1x(ExtensionToken)\" \"|%s(Inlinestringextension:\\\\\\'%s\\\\\\')\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x43 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|PI(XMLProcessingInstruction)\" \"|%s= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(PI)\" \"|%s?>\" , * level , * codepage_stag , Indent ( * level ) ) ; break ; case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|EXT_T_%1x(ExtensionToken)\" \"|%s(ExtensionToken,integervalue:%u)\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , idx ) ; off += 1 + len ; break ; case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Tag|T%3d\" \"|STR_T(Tablerefstring)\" \"|%s\\\\\\'%s\\\\\\'\" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|EXT_%1x(ExtensionToken)\" \"|%s(Single-byteextension)\" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) ) ; off ++ ; break ; case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) { idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len + idx , \"%3d|Tag|T%3d\" \"|OPAQUE(Opaquedata)\" \"|%s(%dbytesofopaquedata)\" , * level , * codepage_stag , Indent ( * level ) , idx ) ; off += 1 + len + idx ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|RESERVED_2(InvalidToken!)\" \"|WBXML1.0parsingstopshere.\" , * level , * codepage_stag ) ; off = tvb_len ; DebugLog ( ( \"STAG:level=%u,Return:len=%u\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; } break ; } else { tag_len = 0 ; if ( ( peek & 0x3F ) == 4 ) { DebugLog ( ( \"STAG:LITERALtag(peek=0x%02X,off=%u)\" \"-TableReffollows!\\\\n\" , peek , off ) ) ; idx = tvb_get_guintvar ( tvb , off + 1 , & tag_len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; tag_new_literal = ( const gchar * ) tvb_get_ptr ( tvb , str_tbl + idx , str_len ) ; tag_new_known = 0 ; } else { tag_new_known = peek & 0x3F ; tag_new_buf = wmem_strdup_printf ( wmem_packet_scope ( ) , \"Tag_0x%02X\" , tag_new_known ) ; tag_new_literal = tag_new_buf ; } if ( peek & 0x40 ) { if ( parsing_tag_content ) { DebugLog ( ( \"STAG:TaginTag-RECURSE!(off=%u)\\\\n\" , off ) ) ; ( * level ) ++ ; len = parse_wbxml_tag ( tree , tvb , off , str_tbl , level , codepage_stag , codepage_attr ) ; off += len ; } else { if ( ( peek & 0x3F ) == 4 ) { tag_save_literal = tag_new_literal ; tag_save_known = 0 ; } else { tag_save_known = tag_new_known ; tag_save_buf = wmem_strdup_printf ( wmem_packet_scope ( ) , \"Tag_0x%02X\" , tag_new_known ) ; tag_save_literal = tag_save_buf ; } if ( peek & 0x80 ) { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(AC)\" \"|%s<%s\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_AC(Literaltag)(AC)\" \"|%s<%s\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } len = parse_wbxml_attribute_list ( tree , tvb , off , str_tbl , * level , codepage_attr ) ; off += len ; if ( off >= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:\" \"len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(attributelist)\" \"|%s>\" , * level , * codepage_stag , Indent ( * level ) ) ; } else { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(.C)\" \"|%s<%s>\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_C(LiteralTag)(.C)\" \"|%s<%s>\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } } parsing_tag_content = TRUE ; DebugLog ( ( \"TaginTag-Norecursionthistime!\" \"(off=%u)\\\\n\" , off ) ) ; } } else { DebugLog ( ( \"inTag-Norecursion!(off=%u)\\\\n\" , off ) ) ; ( * level ) ++ ; if ( peek & 0x80 ) { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02X(A.)\" \"|%s<%s\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; len = parse_wbxml_attribute_list ( tree , tvb , off , str_tbl , * level , codepage_attr ) ; off += len ; if ( off >= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:\" \"len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(KnownTag)\" \"|%s/>\" , * level , * codepage_stag , Indent ( * level ) ) ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL_A(LiteralTag)(A.)\" \"|%s<%s\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; len = parse_wbxml_attribute_list ( tree , tvb , off , str_tbl , * level , codepage_attr ) ; off += len ; if ( off >= tvb_len ) { DebugLog ( ( \"STAG:level=%u,ThrowException:\" \"len=%u(shortframe)\\\\n\" , * level , off - offset ) ) ; THROW ( ReportedBoundsError ) ; } proto_tree_add_text ( tree , tvb , off - 1 , 1 , \"%3d|Tag|T%3d\" \"|END(LiteralTag)\" \"|%s/>\" , * level , * codepage_stag , Indent ( * level ) ) ; } } else { if ( tag_new_known ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|KnownTag0x%02x(..)\" \"|%s<%s/>\" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Tag|T%3d\" \"|LITERAL(LiteralTag)(..)\" \"|%s<%s/>\" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ; off += 1 + tag_len ; } } ( * level ) -- ; } } } DebugLog ( ( \"STAG:level=%u,Return:len=%u(endoffunctionbody)\\\\n\" , * level , off - offset ) ) ; return ( off - offset ) ; }\n", "\n", "3: CWE-119 static guint32 parse_wbxml_attribute_list ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 level , guint8 * codepage_attr ) { guint32 tvb_len = tvb_reported_length ( tvb ) ; guint32 off = offset ; guint32 len ; guint str_len ; guint32 ent ; guint32 idx ; guint8 peek ; DebugLog ( ( \"parse_wbxml_attr(level=%u,offset=%u)\\\\n\" , level , offset ) ) ; while ( off < tvb_len ) { peek = tvb_get_guint8 ( tvb , off ) ; DebugLog ( ( \"ATTR:(topofwhile)level=%3u,peek=0x%02X,\" \"off=%u,tvb_len=%u\\\\n\" , level , peek , off , tvb_len ) ) ; if ( ( peek & 0x3F ) < 5 ) switch ( peek ) { case 0x00 : * codepage_attr = tvb_get_guint8 ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 2 , \"|Attr|A-->%3d\" \"|SWITCH_PAGE(Attrcodepage)|\" , * codepage_attr ) ; off += 2 ; break ; case 0x01 : off ++ ; DebugLog ( ( \"ATTR:level=%u,Return:len=%u\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|ENTITY\" \"|%s\\'&#%u;\\'\" , level , * codepage_attr , Indent ( level ) , ent ) ; off += 1 + len ; break ; case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|STR_I(Inlinestring)\" \"|%s\\\\\\'%s\\\\\\'\" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x04 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|LITERAL(LiteralAttribute)\" \"|%s<%s/>\" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|EXT_I_%1x(ExtensionToken)\" \"|%s(Inlinestringextension:\\\\\\'%s\\\\\\')\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|EXT_T_%1x(ExtensionToken)\" \"|%s(ExtensionToken,integervalue:%u)\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , idx ) ; off += 1 + len ; break ; case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , \"%3d|Attr|A%3d\" \"|STR_T(Tablerefstring)\" \"|%s\\\\\\'%s\\\\\\'\" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|EXT_%1x(ExtensionToken)\" \"|%s(Single-byteextension)\" , level , * codepage_attr , peek & 0x0f , Indent ( level ) ) ; off ++ ; break ; case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) { idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len + idx , \"%3d|Attr|A%3d\" \"|OPAQUE(Opaquedata)\" \"|%s(%dbytesofopaquedata)\" , level , * codepage_attr , Indent ( level ) , idx ) ; off += 1 + len + idx ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|RESERVED_2(InvalidToken!)\" \"|WBXML1.0parsingstopshere.\" , level , * codepage_attr ) ; off = tvb_len ; DebugLog ( ( \"ATTR:level=%u,Return:len=%u\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; } break ; default : proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|%-10s(InvalidToken!)\" \"|WBXMLparsingstopshere.\" , level , * codepage_attr , val_to_str_ext ( peek , & vals_wbxml1x_global_tokens_ext , \"(unknown0x%x)\" ) ) ; off = tvb_len ; break ; } else { if ( peek & 0x80 ) { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|KnownattrValue0x%02X\" \"|%sattrValue_0x%02X\" , level , * codepage_attr , peek & 0x7f , Indent ( level ) , peek ) ; off ++ ; } else { proto_tree_add_text ( tree , tvb , off , 1 , \"%3d|Attr|A%3d\" \"|KnownattrStart0x%02X\" \"|%sattrStart_0x%02X\" , level , * codepage_attr , peek & 0x7f , Indent ( level ) , peek ) ; off ++ ; } } } DebugLog ( ( \"ATTR:level=%u,Return:len=%u(endoffunctionbody)\\\\n\" , level , off - offset ) ) ; return ( off - offset ) ; }\n", "\n", "\n", "Target: aclp -> acl_cnt ) ; if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED\n", "\n", "Sources:\n", "0: CWE-190 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; }\n", "\n", "1: CWE-189 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; }\n", "\n", "\n", "Target: * ctx , va_list args )\n", "\n", "Sources:\n", "0: CWE-119 static vpx_codec_err_t ctrl_set_scale_mode ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_scaling_mode_t * const mode = va_arg ( args , vpx_scaling_mode_t * ) ; if ( mode ) { const int res = vp9_set_internal_size ( ctx -> cpi , ( VPX_SCALING ) mode -> h_scaling_mode , ( VPX_SCALING ) mode -> v_scaling_mode ) ; return ( res == 0 ) ? VPX_CODEC_OK : VPX_CODEC_INVALID_PARAM ; } else { return VPX_CODEC_INVALID_PARAM ; } }\n", "\n", "1: CWE-119 static vpx_codec_err_t ctrl_use_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { const int reference_flag = va_arg ( args , int ) ; vp9_use_as_reference ( ctx -> cpi , reference_flag ) ; return VPX_CODEC_OK ; }\n", "\n", "2: CWE-119 static vpx_codec_err_t ctrl_copy_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * const frame = va_arg ( args , vpx_ref_frame_t * ) ; if ( frame != NULL ) { YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; vp9_copy_reference_enc ( ctx -> cpi , ref_frame_to_vp9_reframe ( frame -> frame_type ) , & sd ) ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } }\n", "\n", "3: CWE-119 static vpx_codec_err_t ctrl_set_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * const frame = va_arg ( args , vpx_ref_frame_t * ) ; if ( frame != NULL ) { YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; vp9_set_reference_enc ( ctx -> cpi , ref_frame_to_vp9_reframe ( frame -> frame_type ) , & sd ) ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } }\n", "\n", "4: CWE-119 static vpx_codec_err_t ctrl_update_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { const int ref_frame_flags = va_arg ( args , int ) ; vp9_update_reference ( ctx -> cpi , ref_frame_flags ) ; return VPX_CODEC_OK ; }\n", "\n", "5: CWE-119 static vpx_codec_err_t ctrl_update_entropy ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { const int update = va_arg ( args , int ) ; vp9_update_entropy ( ctx -> cpi , update ) ; return VPX_CODEC_OK ; }\n", "\n", "\n", "Target: * object , const char * const char * name , void *\n", "\n", "Sources:\n", "0: CWE-119 static void show_object ( struct object * object , struct strbuf * path , const char * last , void * data ) { struct bitmap * base = data ; bitmap_set ( base , find_object_pos ( object -> oid . hash ) ) ; mark_as_seen ( object ) ; }\n", "\n", "1: CWE-119 static void test_show_object ( struct object * object , struct strbuf * path , const char * last , void * data ) { struct bitmap_test_data * tdata = data ; int bitmap_pos ; bitmap_pos = bitmap_position ( object -> oid . hash ) ; if ( bitmap_pos < 0 ) die ( \"Objectnotinbitmap:%s\\\\n\" , oid_to_hex ( & object -> oid ) ) ; bitmap_set ( tdata -> base , bitmap_pos ) ; display_progress ( tdata -> prg , ++ tdata -> seen ) ; }\n", "\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Target: 0.0 ) ; ( void ) CloneString ( & draw_info -> geometry , geometry ) ;\n", "\n", "Sources:\n", "0: CWE-399 static Image * ReadCAPTIONImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char * caption , geometry [ MaxTextExtent ] , * property , * text ; const char * gravity , * option ; DrawInfo * draw_info ; Image * image ; MagickBooleanType split , status ; register ssize_t i ; size_t height , width ; TypeMetric metrics ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; ( void ) ResetImagePage ( image , \"0x0+0+0\" ) ; option = GetImageOption ( image_info , \"filename\" ) ; if ( option == ( const char * ) NULL ) property = InterpretImageProperties ( image_info , image , image_info -> filename ) ; else if ( LocaleNCompare ( option , \"caption:\" , 8 ) == 0 ) property = InterpretImageProperties ( image_info , image , option + 8 ) ; else property = InterpretImageProperties ( image_info , image , option ) ; ( void ) SetImageProperty ( image , \"caption\" , property ) ; property = DestroyString ( property ) ; caption = ConstantString ( GetImageProperty ( image , \"caption\" ) ) ; draw_info = CloneDrawInfo ( image_info , ( DrawInfo * ) NULL ) ; ( void ) CloneString ( & draw_info -> text , caption ) ; gravity = GetImageOption ( image_info , \"gravity\" ) ; if ( gravity != ( char * ) NULL ) draw_info -> gravity = ( GravityType ) ParseCommandOption ( MagickGravityOptions , MagickFalse , gravity ) ; split = MagickFalse ; status = MagickTrue ; if ( image -> columns == 0 ) { text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; image -> columns = width ; } if ( image -> rows == 0 ) { split = MagickTrue ; text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; image -> rows = ( size_t ) ( ( i + 1 ) * ( metrics . ascent - metrics . descent + draw_info -> interline_spacing + draw_info -> stroke_width ) + 0.5 ) ; } if ( status != MagickFalse ) status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( SetImageBackgroundColor ( image ) == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( ( fabs ( image_info -> pointsize ) < MagickEpsilon ) && ( strlen ( caption ) > 0 ) ) { double high , low ; for ( ; ; draw_info -> pointsize *= 2.0 ) { text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; ( void ) status ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width >= image -> columns ) && ( height >= image -> rows ) ) break ; } else if ( ( ( image -> columns != 0 ) && ( width >= image -> columns ) ) || ( ( image -> rows != 0 ) && ( height >= image -> rows ) ) ) break ; } high = draw_info -> pointsize ; for ( low = 1.0 ; ( high - low ) > 0.5 ; ) { draw_info -> pointsize = ( low + high ) / 2.0 ; text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width < image -> columns ) && ( height < image -> rows ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } else if ( ( ( image -> columns != 0 ) && ( width < image -> columns ) ) || ( ( image -> rows != 0 ) && ( height < image -> rows ) ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } draw_info -> pointsize = floor ( ( low + high ) / 2.0 - 0.5 ) ; } i = FormatMagickCaption ( image , draw_info , split , & metrics , & caption ) ; ( void ) CloneString ( & draw_info -> text , caption ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , MagickMax ( draw_info -> direction == RightToLeftDirection ? image -> columns - metrics . bounds . x2 : - metrics . bounds . x1 , 0.0 ) , draw_info -> gravity == UndefinedGravity ? metrics . ascent : 0.0 ) ; draw_info -> geometry = AcquireString ( geometry ) ; status = AnnotateImage ( image , draw_info ) ; if ( image_info -> pointsize == 0.0 ) { char pointsize [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pointsize , MaxTextExtent , \"%.20g\" , draw_info -> pointsize ) ; ( void ) SetImageProperty ( image , \"caption:pointsize\" , pointsize ) ; } draw_info = DestroyDrawInfo ( draw_info ) ; caption = DestroyString ( caption ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-399 static Image * ReadLABELImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char geometry [ MaxTextExtent ] , * property ; const char * label ; DrawInfo * draw_info ; Image * image ; MagickBooleanType status ; TypeMetric metrics ; size_t height , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; ( void ) ResetImagePage ( image , \"0x0+0+0\" ) ; property = InterpretImageProperties ( image_info , image , image_info -> filename ) ; ( void ) SetImageProperty ( image , \"label\" , property ) ; property = DestroyString ( property ) ; label = GetImageProperty ( image , \"label\" ) ; draw_info = CloneDrawInfo ( image_info , ( DrawInfo * ) NULL ) ; draw_info -> text = ConstantString ( label ) ; metrics . width = 0 ; metrics . ascent = 0.0 ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; if ( ( image -> columns == 0 ) && ( image -> rows == 0 ) ) { image -> columns = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; image -> rows = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; } else if ( ( strlen ( label ) > 0 ) && ( ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) || ( fabs ( image_info -> pointsize ) < MagickEpsilon ) ) ) { double high , low ; for ( ; ; draw_info -> pointsize *= 2.0 ) { ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width >= image -> columns ) && ( height >= image -> rows ) ) break ; } else if ( ( ( image -> columns != 0 ) && ( width >= image -> columns ) ) || ( ( image -> rows != 0 ) && ( height >= image -> rows ) ) ) break ; } high = draw_info -> pointsize ; for ( low = 1.0 ; ( high - low ) > 0.5 ; ) { draw_info -> pointsize = ( low + high ) / 2.0 ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width < image -> columns ) && ( height < image -> rows ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } else if ( ( ( image -> columns != 0 ) && ( width < image -> columns ) ) || ( ( image -> rows != 0 ) && ( height < image -> rows ) ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } draw_info -> pointsize = ( low + high ) / 2.0 - 0.5 ; } status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( image -> columns == 0 ) image -> columns = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; if ( image -> columns == 0 ) image -> columns = ( size_t ) floor ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) floor ( metrics . ascent - metrics . descent + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) floor ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( SetImageBackgroundColor ( image ) == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , draw_info -> direction == RightToLeftDirection ? image -> columns - metrics . bounds . x2 : 0.0 , draw_info -> gravity == UndefinedGravity ? metrics . ascent : 0.0 ) ; draw_info -> geometry = AcquireString ( geometry ) ; status = AnnotateImage ( image , draw_info ) ; if ( image_info -> pointsize == 0.0 ) { char pointsize [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pointsize , MaxTextExtent , \"%.20g\" , draw_info -> pointsize ) ; ( void ) SetImageProperty ( image , \"label:pointsize\" , pointsize ) ; } draw_info = DestroyDrawInfo ( draw_info ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ; if ( ! ctx -> gf128 ) return - ENOKEY ; if (\n", "\n", "Sources:\n", "0: CWE-000 static int ghash_update ( struct shash_desc * desc , const u8 * src , unsigned int srclen ) { struct ghash_desc_ctx * dctx = shash_desc_ctx ( desc ) ; struct ghash_ctx * ctx = crypto_shash_ctx ( desc -> tfm ) ; u8 * dst = dctx -> buffer ; if ( dctx -> bytes ) { int n = min ( srclen , dctx -> bytes ) ; u8 * pos = dst + ( GHASH_BLOCK_SIZE - dctx -> bytes ) ; dctx -> bytes -= n ; srclen -= n ; while ( n -- ) * pos ++ ^= * src ++ ; if ( ! dctx -> bytes ) gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; } while ( srclen >= GHASH_BLOCK_SIZE ) { crypto_xor ( dst , src , GHASH_BLOCK_SIZE ) ; gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; src += GHASH_BLOCK_SIZE ; srclen -= GHASH_BLOCK_SIZE ; } if ( srclen ) { dctx -> bytes = GHASH_BLOCK_SIZE - srclen ; while ( srclen -- ) * dst ++ ^= * src ++ ; } return 0 ; }\n", "\n", "1: CWE-476 static int ghash_update ( struct shash_desc * desc , const u8 * src , unsigned int srclen ) { struct ghash_desc_ctx * dctx = shash_desc_ctx ( desc ) ; struct ghash_ctx * ctx = crypto_shash_ctx ( desc -> tfm ) ; u8 * dst = dctx -> buffer ; if ( dctx -> bytes ) { int n = min ( srclen , dctx -> bytes ) ; u8 * pos = dst + ( GHASH_BLOCK_SIZE - dctx -> bytes ) ; dctx -> bytes -= n ; srclen -= n ; while ( n -- ) * pos ++ ^= * src ++ ; if ( ! dctx -> bytes ) gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; } while ( srclen >= GHASH_BLOCK_SIZE ) { crypto_xor ( dst , src , GHASH_BLOCK_SIZE ) ; gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; src += GHASH_BLOCK_SIZE ; srclen -= GHASH_BLOCK_SIZE ; } if ( srclen ) { dctx -> bytes = GHASH_BLOCK_SIZE - srclen ; while ( srclen -- ) * dst ++ ^= * src ++ ; } return 0 ; }\n", "\n", "\n", "Target: const Image * images ) { const Image * next ; MagickPixelPacket * * j ; size_t columns , ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ) AcquireQuantumMemory ( columns , sizeof ( ssize_t ) columns ; j ) GetMagickPixelPacket ( images , & pixels\n", "\n", "Sources:\n", "0: CWE-787 static MagickPixelPacket * * AcquirePixelThreadSet ( const Image * image ) { MagickPixelPacket * * pixels ; register ssize_t i , j ; size_t number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( MagickPixelPacket * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( MagickPixelPacket * * ) NULL ) return ( ( MagickPixelPacket * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { pixels [ i ] = ( MagickPixelPacket * ) AcquireQuantumMemory ( image -> columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( MagickPixelPacket * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) GetMagickPixelPacket ( image , & pixels [ i ] [ j ] ) ; } return ( pixels ) ; }\n", "\n", "1: CWE-119 static MagickPixelPacket * * AcquirePixelThreadSet ( const Image * image ) { MagickPixelPacket * * pixels ; register ssize_t i , j ; size_t number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( MagickPixelPacket * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( MagickPixelPacket * * ) NULL ) return ( ( MagickPixelPacket * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { pixels [ i ] = ( MagickPixelPacket * ) AcquireQuantumMemory ( image -> columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( MagickPixelPacket * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) GetMagickPixelPacket ( image , & pixels [ i ] [ j ] ) ; } return ( pixels ) ; }\n", "\n", "\n", "Target: p . str , false ) , delim , false p . str , false p . str , false p . str , false\n", "\n", "Sources:\n", "0: CWE-78 static int compile_search ( struct Context * ctx , const struct Pattern * pat , struct Buffer * buf ) { if ( do_search ( pat , 0 ) == 0 ) return 0 ; if ( pat -> not ) mutt_buffer_addstr ( buf , \"NOT\" ) ; if ( pat -> child ) { int clauses ; clauses = do_search ( pat -> child , 1 ) ; if ( clauses > 0 ) { const struct Pattern * clause = pat -> child ; mutt_buffer_addch ( buf , '(' ) ; while ( clauses ) { if ( do_search ( clause , 0 ) ) { if ( pat -> op == MUTT_OR && clauses > 1 ) mutt_buffer_addstr ( buf , \"OR\" ) ; clauses -- ; if ( compile_search ( ctx , clause , buf ) < 0 ) return - 1 ; if ( clauses ) mutt_buffer_addch ( buf , '' ) ; } clause = clause -> next ; } mutt_buffer_addch ( buf , ')' ) ; } } else { char term [ STRING ] ; char * delim = NULL ; switch ( pat -> op ) { case MUTT_HEADER : mutt_buffer_addstr ( buf , \"HEADER\" ) ; delim = strchr ( pat -> p . str , ':' ) ; if ( ! delim ) { mutt_error ( _ ( \"Headersearchwithoutheadername:%s\" ) , pat -> p . str ) ; return - 1 ; } * delim = '\\\\0' ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; mutt_buffer_addch ( buf , '' ) ; * delim = ':' ; delim ++ ; SKIPWS ( delim ) ; imap_quote_string ( term , sizeof ( term ) , delim ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_BODY : mutt_buffer_addstr ( buf , \"BODY\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_WHOLE_MSG : mutt_buffer_addstr ( buf , \"TEXT\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_SERVERSEARCH : { struct ImapData * idata = ctx -> data ; if ( ! mutt_bit_isset ( idata -> capabilities , X_GM_EXT1 ) ) { mutt_error ( _ ( \"Server-sidecustomsearchnotsupported:%s\" ) , pat -> p . str ) ; return - 1 ; } } mutt_buffer_addstr ( buf , \"X-GM-RAW\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; } } return 0 ; }\n", "\n", "1: CWE-77 static int compile_search ( struct Context * ctx , const struct Pattern * pat , struct Buffer * buf ) { if ( do_search ( pat , 0 ) == 0 ) return 0 ; if ( pat -> not ) mutt_buffer_addstr ( buf , \"NOT\" ) ; if ( pat -> child ) { int clauses ; clauses = do_search ( pat -> child , 1 ) ; if ( clauses > 0 ) { const struct Pattern * clause = pat -> child ; mutt_buffer_addch ( buf , '(' ) ; while ( clauses ) { if ( do_search ( clause , 0 ) ) { if ( pat -> op == MUTT_OR && clauses > 1 ) mutt_buffer_addstr ( buf , \"OR\" ) ; clauses -- ; if ( compile_search ( ctx , clause , buf ) < 0 ) return - 1 ; if ( clauses ) mutt_buffer_addch ( buf , '' ) ; } clause = clause -> next ; } mutt_buffer_addch ( buf , ')' ) ; } } else { char term [ STRING ] ; char * delim = NULL ; switch ( pat -> op ) { case MUTT_HEADER : mutt_buffer_addstr ( buf , \"HEADER\" ) ; delim = strchr ( pat -> p . str , ':' ) ; if ( ! delim ) { mutt_error ( _ ( \"Headersearchwithoutheadername:%s\" ) , pat -> p . str ) ; return - 1 ; } * delim = '\\\\0' ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; mutt_buffer_addch ( buf , '' ) ; * delim = ':' ; delim ++ ; SKIPWS ( delim ) ; imap_quote_string ( term , sizeof ( term ) , delim ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_BODY : mutt_buffer_addstr ( buf , \"BODY\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_WHOLE_MSG : mutt_buffer_addstr ( buf , \"TEXT\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_SERVERSEARCH : { struct ImapData * idata = ctx -> data ; if ( ! mutt_bit_isset ( idata -> capabilities , X_GM_EXT1 ) ) { mutt_error ( _ ( \"Server-sidecustomsearchnotsupported:%s\" ) , pat -> p . str ) ; return - 1 ; } } mutt_buffer_addstr ( buf , \"X-GM-RAW\" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; } } return 0 ; }\n", "\n", "\n", "Target: vcpu -> mmio_cur_fragment >= vcpu -> mmio_nr_fragments\n", "\n", "Sources:\n", "0: CWE-119 static int complete_emulated_mmio ( struct kvm_vcpu * vcpu ) { struct kvm_run * run = vcpu -> run ; struct kvm_mmio_fragment * frag ; unsigned len ; BUG_ON ( ! vcpu -> mmio_needed ) ; frag = & vcpu -> mmio_fragments [ vcpu -> mmio_cur_fragment ] ; len = min ( 8u , frag -> len ) ; if ( ! vcpu -> mmio_is_write ) memcpy ( frag -> data , run -> mmio . data , len ) ; if ( frag -> len <= 8 ) { frag ++ ; vcpu -> mmio_cur_fragment ++ ; } else { frag -> data += len ; frag -> gpa += len ; frag -> len -= len ; } if ( vcpu -> mmio_cur_fragment == vcpu -> mmio_nr_fragments ) { vcpu -> mmio_needed = 0 ; if ( vcpu -> mmio_is_write ) return 1 ; vcpu -> mmio_read_completed = 1 ; return complete_emulated_io ( vcpu ) ; } run -> exit_reason = KVM_EXIT_MMIO ; run -> mmio . phys_addr = frag -> gpa ; if ( vcpu -> mmio_is_write ) memcpy ( run -> mmio . data , frag -> data , min ( 8u , frag -> len ) ) ; run -> mmio . len = min ( 8u , frag -> len ) ; run -> mmio . is_write = vcpu -> mmio_is_write ; vcpu -> arch . complete_userspace_io = complete_emulated_mmio ; return 0 ; }\n", "\n", "1: CWE-120 static int complete_emulated_mmio ( struct kvm_vcpu * vcpu ) { struct kvm_run * run = vcpu -> run ; struct kvm_mmio_fragment * frag ; unsigned len ; BUG_ON ( ! vcpu -> mmio_needed ) ; frag = & vcpu -> mmio_fragments [ vcpu -> mmio_cur_fragment ] ; len = min ( 8u , frag -> len ) ; if ( ! vcpu -> mmio_is_write ) memcpy ( frag -> data , run -> mmio . data , len ) ; if ( frag -> len <= 8 ) { frag ++ ; vcpu -> mmio_cur_fragment ++ ; } else { frag -> data += len ; frag -> gpa += len ; frag -> len -= len ; } if ( vcpu -> mmio_cur_fragment == vcpu -> mmio_nr_fragments ) { vcpu -> mmio_needed = 0 ; if ( vcpu -> mmio_is_write ) return 1 ; vcpu -> mmio_read_completed = 1 ; return complete_emulated_io ( vcpu ) ; } run -> exit_reason = KVM_EXIT_MMIO ; run -> mmio . phys_addr = frag -> gpa ; if ( vcpu -> mmio_is_write ) memcpy ( run -> mmio . data , frag -> data , min ( 8u , frag -> len ) ) ; run -> mmio . len = min ( 8u , frag -> len ) ; run -> mmio . is_write = vcpu -> mmio_is_write ; vcpu -> arch . complete_userspace_io = complete_emulated_mmio ; return 0 ; }\n", "\n", "\n", "Target: , & rlen , 0\n", "\n", "Sources:\n", "0: CWE-674 static krb5_error_code split_der ( asn1buf * buf , uint8_t * const * der , size_t len , taginfo * tag_out ) { krb5_error_code ret ; const uint8_t * contents , * remainder ; size_t clen , rlen ; ret = get_tag ( * der , len , tag_out , & contents , & clen , & remainder , & rlen ) ; if ( ret ) return ret ; if ( rlen != 0 ) return ASN1_BAD_LENGTH ; insert_bytes ( buf , contents , clen ) ; return 0 ; }\n", "\n", "1: CWE-674 static krb5_error_code decode_atype ( const taginfo * t , const uint8_t * asn1 , size_t len , const struct atype_info * a , void * val ) { krb5_error_code ret ; switch ( a -> type ) { case atype_fn : { const struct fn_info * fn = a -> tinfo ; assert ( fn -> dec != NULL ) ; return fn -> dec ( t , asn1 , len , val ) ; } case atype_sequence : return decode_sequence ( asn1 , len , a -> tinfo , val ) ; case atype_ptr : { const struct ptr_info * ptrinfo = a -> tinfo ; void * ptr = LOADPTR ( val , ptrinfo ) ; assert ( ptrinfo -> basetype != NULL ) ; if ( ptr != NULL ) { return decode_atype ( t , asn1 , len , ptrinfo -> basetype , ptr ) ; } else { ret = decode_atype_to_ptr ( t , asn1 , len , ptrinfo -> basetype , & ptr ) ; if ( ret ) return ret ; STOREPTR ( ptr , ptrinfo , val ) ; break ; } } case atype_offset : { const struct offset_info * off = a -> tinfo ; assert ( off -> basetype != NULL ) ; return decode_atype ( t , asn1 , len , off -> basetype , ( char * ) val + off -> dataoff ) ; } case atype_optional : { const struct optional_info * opt = a -> tinfo ; return decode_atype ( t , asn1 , len , opt -> basetype , val ) ; } case atype_counted : { const struct counted_info * counted = a -> tinfo ; void * dataptr = ( char * ) val + counted -> dataoff ; size_t count ; assert ( counted -> basetype != NULL ) ; ret = decode_cntype ( t , asn1 , len , counted -> basetype , dataptr , & count ) ; if ( ret ) return ret ; return store_count ( count , counted , val ) ; } case atype_tagged_thing : { const struct tagged_info * tag = a -> tinfo ; taginfo inner_tag ; const taginfo * tp = t ; const uint8_t * rem ; size_t rlen ; if ( ! tag -> implicit ) { ret = get_tag ( asn1 , len , & inner_tag , & asn1 , & len , & rem , & rlen ) ; if ( ret ) return ret ; tp = & inner_tag ; if ( ! check_atype_tag ( tag -> basetype , tp ) ) return ASN1_BAD_ID ; } return decode_atype ( tp , asn1 , len , tag -> basetype , val ) ; } case atype_bool : { intmax_t intval ; ret = k5_asn1_decode_bool ( asn1 , len , & intval ) ; if ( ret ) return ret ; return store_int ( intval , a -> size , val ) ; } case atype_int : { intmax_t intval ; ret = k5_asn1_decode_int ( asn1 , len , & intval ) ; if ( ret ) return ret ; return store_int ( intval , a -> size , val ) ; } case atype_uint : { uintmax_t intval ; ret = k5_asn1_decode_uint ( asn1 , len , & intval ) ; if ( ret ) return ret ; return store_uint ( intval , a -> size , val ) ; } case atype_int_immediate : { const struct immediate_info * imm = a -> tinfo ; intmax_t intval ; ret = k5_asn1_decode_int ( asn1 , len , & intval ) ; if ( ret ) return ret ; if ( intval != imm -> val && imm -> err != 0 ) return imm -> err ; break ; } default : assert ( a -> type != atype_nullterm_sequence_of ) ; assert ( a -> type != atype_nonempty_nullterm_sequence_of ) ; assert ( a -> type > atype_min ) ; assert ( a -> type < atype_max ) ; abort ( ) ; } return 0 ; }\n", "\n", "\n", "Target: value ) ; if ( ! strcmp ( key , \"path\" ) && value && looks_like_command_line_option ( value ) ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_PATH , \"disallowedsubmodulepath:%s\" , value ) ;\n", "\n", "Sources:\n", "0: CWE-20 static int fsck_gitmodules_fn ( const char * var , const char * value , void * vdata ) { struct fsck_gitmodules_data * data = vdata ; const char * subsection , * key ; int subsection_len ; char * name ; if ( parse_config_key ( var , \"submodule\" , & subsection , & subsection_len , & key ) < 0 || ! subsection ) return 0 ; name = xmemdupz ( subsection , subsection_len ) ; if ( check_submodule_name ( name ) < 0 ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_NAME , \"disallowedsubmodulename:%s\" , name ) ; if ( ! strcmp ( key , \"url\" ) && value && looks_like_command_line_option ( value ) ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_URL , \"disallowedsubmoduleurl:%s\" , value ) ; free ( name ) ; return 0 ; }\n", "\n", "1: CWE-88 static int fsck_gitmodules_fn ( const char * var , const char * value , void * vdata ) { struct fsck_gitmodules_data * data = vdata ; const char * subsection , * key ; int subsection_len ; char * name ; if ( parse_config_key ( var , \"submodule\" , & subsection , & subsection_len , & key ) < 0 || ! subsection ) return 0 ; name = xmemdupz ( subsection , subsection_len ) ; if ( check_submodule_name ( name ) < 0 ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_NAME , \"disallowedsubmodulename:%s\" , name ) ; if ( ! strcmp ( key , \"url\" ) && value && looks_like_command_line_option ( value ) ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_URL , \"disallowedsubmoduleurl:%s\" , value ) ; free ( name ) ; return 0 ; }\n", "\n", "\n", "Target: const node * n0 , bool is_async ) { is_async ) { const node * const n = is_async ? CHILD ( n0 , 1 ) : n0 ; , LINENO ( n0 ) , n0 -> n_col_offset ,\n", "\n", "Sources:\n", "0: CWE-125 static stmt_ty ast_for_with_stmt ( struct compiling * c , const node * n , int is_async ) { int i , n_items , nch_minus_type , has_type_comment ; asdl_seq * items , * body ; string type_comment ; if ( is_async && c -> c_feature_version < 5 ) { ast_error ( c , n , \"AsyncwithstatementsareonlysupportedinPython3.5andgreater\" ) ; return NULL ; } REQ ( n , with_stmt ) ; has_type_comment = TYPE ( CHILD ( n , NCH ( n ) - 2 ) ) == TYPE_COMMENT ; nch_minus_type = NCH ( n ) - has_type_comment ; n_items = ( nch_minus_type - 2 ) / 2 ; items = _Ta3_asdl_seq_new ( n_items , c -> c_arena ) ; if ( ! items ) return NULL ; for ( i = 1 ; i < nch_minus_type - 2 ; i += 2 ) { withitem_ty item = ast_for_with_item ( c , CHILD ( n , i ) ) ; if ( ! item ) return NULL ; asdl_seq_SET ( items , ( i - 1 ) / 2 , item ) ; } body = ast_for_suite ( c , CHILD ( n , NCH ( n ) - 1 ) ) ; if ( ! body ) return NULL ; if ( has_type_comment ) type_comment = NEW_TYPE_COMMENT ( CHILD ( n , NCH ( n ) - 2 ) ) ; else type_comment = NULL ; if ( is_async ) return AsyncWith ( items , body , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; else return With ( items , body , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; }\n", "\n", "1: CWE-125 static stmt_ty ast_for_for_stmt ( struct compiling * c , const node * n , int is_async ) { asdl_seq * _target , * seq = NULL , * suite_seq ; expr_ty expression ; expr_ty target , first ; const node * node_target ; int has_type_comment ; string type_comment ; if ( is_async && c -> c_feature_version < 5 ) { ast_error ( c , n , \"AsyncforloopsareonlysupportedinPython3.5andgreater\" ) ; return NULL ; } REQ ( n , for_stmt ) ; has_type_comment = TYPE ( CHILD ( n , 5 ) ) == TYPE_COMMENT ; if ( NCH ( n ) == 9 + has_type_comment ) { seq = ast_for_suite ( c , CHILD ( n , 8 + has_type_comment ) ) ; if ( ! seq ) return NULL ; } node_target = CHILD ( n , 1 ) ; _target = ast_for_exprlist ( c , node_target , Store ) ; if ( ! _target ) return NULL ; first = ( expr_ty ) asdl_seq_GET ( _target , 0 ) ; if ( NCH ( node_target ) == 1 ) target = first ; else target = Tuple ( _target , Store , first -> lineno , first -> col_offset , c -> c_arena ) ; expression = ast_for_testlist ( c , CHILD ( n , 3 ) ) ; if ( ! expression ) return NULL ; suite_seq = ast_for_suite ( c , CHILD ( n , 5 + has_type_comment ) ) ; if ( ! suite_seq ) return NULL ; if ( has_type_comment ) type_comment = NEW_TYPE_COMMENT ( CHILD ( n , 5 ) ) ; else type_comment = NULL ; if ( is_async ) return AsyncFor ( target , expression , suite_seq , seq , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; else return For ( target , expression , suite_seq , seq , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; }\n", "\n", "\n", "Target: tag ) { return tags -> rqs tag ] ; } \n", "\n", "Sources:\n", "0: CWE-362 struct request * blk_mq_tag_to_rq ( struct blk_mq_tags * tags , unsigned int tag ) { struct request * rq = tags -> rqs [ tag ] ; struct blk_flush_queue * fq = blk_get_flush_queue ( rq -> q , rq -> mq_ctx ) ; if ( ! is_flush_request ( rq , fq , tag ) ) return rq ; return fq -> flush_rq ; }\n", "\n", "1: CWE-264 struct request * blk_mq_tag_to_rq ( struct blk_mq_tags * tags , unsigned int tag ) { struct request * rq = tags -> rqs [ tag ] ; struct blk_flush_queue * fq = blk_get_flush_queue ( rq -> q , rq -> mq_ctx ) ; if ( ! is_flush_request ( rq , fq , tag ) ) return rq ; return fq -> flush_rq ; }\n", "\n", "\n", "Target: = htonl ( INADDR_LOOPBACK ) ; saddr\n", "\n", "Sources:\n", "0: CWE-284 int socket_create ( uint16_t port ) { int sfd = - 1 ; int yes = 1 ; # ifdef WIN32 WSADATA wsa_data ; if ( ! wsa_init ) { if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsa_data ) != ERROR_SUCCESS ) { fprintf ( stderr , \"WSAStartupfailed!\\\\n\" ) ; ExitProcess ( - 1 ) ; } wsa_init = 1 ; } # endif struct sockaddr_in saddr ; if ( 0 > ( sfd = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP ) ) ) { perror ( \"socket()\" ) ; return - 1 ; } if ( setsockopt ( sfd , SOL_SOCKET , SO_REUSEADDR , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( \"setsockopt()\" ) ; socket_close ( sfd ) ; return - 1 ; } # ifdef SO_NOSIGPIPE if ( setsockopt ( sfd , SOL_SOCKET , SO_NOSIGPIPE , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( \"setsockopt()\" ) ; socket_close ( sfd ) ; return - 1 ; } # endif memset ( ( void * ) & saddr , 0 , sizeof ( saddr ) ) ; saddr . sin_family = AF_INET ; saddr . sin_addr . s_addr = htonl ( INADDR_ANY ) ; saddr . sin_port = htons ( port ) ; if ( 0 > bind ( sfd , ( struct sockaddr * ) & saddr , sizeof ( saddr ) ) ) { perror ( \"bind()\" ) ; socket_close ( sfd ) ; return - 1 ; } if ( listen ( sfd , 1 ) == - 1 ) { perror ( \"listen()\" ) ; socket_close ( sfd ) ; return - 1 ; } return sfd ; }\n", "\n", "1: CWE-284 int socket_create ( uint16_t port ) { int sfd = - 1 ; int yes = 1 ; # ifdef WIN32 WSADATA wsa_data ; if ( ! wsa_init ) { if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsa_data ) != ERROR_SUCCESS ) { fprintf ( stderr , \"WSAStartupfailed!\\\\n\" ) ; ExitProcess ( - 1 ) ; } wsa_init = 1 ; } # endif struct sockaddr_in saddr ; if ( 0 > ( sfd = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP ) ) ) { perror ( \"socket()\" ) ; return - 1 ; } if ( setsockopt ( sfd , SOL_SOCKET , SO_REUSEADDR , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( \"setsockopt()\" ) ; socket_close ( sfd ) ; return - 1 ; } memset ( ( void * ) & saddr , 0 , sizeof ( saddr ) ) ; saddr . sin_family = AF_INET ; saddr . sin_addr . s_addr = htonl ( INADDR_ANY ) ; saddr . sin_port = htons ( port ) ; if ( 0 > bind ( sfd , ( struct sockaddr * ) & saddr , sizeof ( saddr ) ) ) { perror ( \"bind()\" ) ; socket_close ( sfd ) ; return - 1 ; } if ( listen ( sfd , 1 ) == - 1 ) { perror ( \"listen()\" ) ; socket_close ( sfd ) ; return - 1 ; } return sfd ; }\n", "\n", "\n", "Target: tmp ) { request -> ssids [ i ] . ssid_len = nla_len ( attr ) ; ) ) ; i ++ ;\n", "\n", "Sources:\n", "0: CWE-119 static int nl80211_start_sched_scan ( struct sk_buff * skb , struct genl_info * info ) { struct cfg80211_sched_scan_request * request ; struct cfg80211_registered_device * rdev = info -> user_ptr [ 0 ] ; struct net_device * dev = info -> user_ptr [ 1 ] ; struct nlattr * attr ; struct wiphy * wiphy ; int err , tmp , n_ssids = 0 , n_channels , i ; u32 interval ; enum ieee80211_band band ; size_t ie_len ; if ( ! ( rdev -> wiphy . flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN ) || ! rdev -> ops -> sched_scan_start ) return - EOPNOTSUPP ; if ( ! is_valid_ie_attr ( info -> attrs [ NL80211_ATTR_IE ] ) ) return - EINVAL ; if ( rdev -> sched_scan_req ) return - EINPROGRESS ; if ( ! info -> attrs [ NL80211_ATTR_SCHED_SCAN_INTERVAL ] ) return - EINVAL ; interval = nla_get_u32 ( info -> attrs [ NL80211_ATTR_SCHED_SCAN_INTERVAL ] ) ; if ( interval == 0 ) return - EINVAL ; wiphy = & rdev -> wiphy ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { n_channels = validate_scan_freqs ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) ; if ( ! n_channels ) return - EINVAL ; } else { n_channels = 0 ; for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) if ( wiphy -> bands [ band ] ) n_channels += wiphy -> bands [ band ] -> n_channels ; } if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , tmp ) n_ssids ++ ; if ( n_ssids > wiphy -> max_scan_ssids ) return - EINVAL ; if ( info -> attrs [ NL80211_ATTR_IE ] ) ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; else ie_len = 0 ; if ( ie_len > wiphy -> max_scan_ie_len ) return - EINVAL ; request = kzalloc ( sizeof ( * request ) + sizeof ( * request -> ssids ) * n_ssids + sizeof ( * request -> channels ) * n_channels + ie_len , GFP_KERNEL ) ; if ( ! request ) return - ENOMEM ; if ( n_ssids ) request -> ssids = ( void * ) & request -> channels [ n_channels ] ; request -> n_ssids = n_ssids ; if ( ie_len ) { if ( request -> ssids ) request -> ie = ( void * ) ( request -> ssids + n_ssids ) ; else request -> ie = ( void * ) ( request -> channels + n_channels ) ; } i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] , tmp ) { struct ieee80211_channel * chan ; chan = ieee80211_get_channel ( wiphy , nla_get_u32 ( attr ) ) ; if ( ! chan ) { err = - EINVAL ; goto out_free ; } if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } else { for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) { int j ; if ( ! wiphy -> bands [ band ] ) continue ; for ( j = 0 ; j < wiphy -> bands [ band ] -> n_channels ; j ++ ) { struct ieee80211_channel * chan ; chan = & wiphy -> bands [ band ] -> channels [ j ] ; if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } } if ( ! i ) { err = - EINVAL ; goto out_free ; } request -> n_channels = i ; i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , tmp ) { if ( request -> ssids [ i ] . ssid_len > IEEE80211_MAX_SSID_LEN ) { err = - EINVAL ; goto out_free ; } memcpy ( request -> ssids [ i ] . ssid , nla_data ( attr ) , nla_len ( attr ) ) ; request -> ssids [ i ] . ssid_len = nla_len ( attr ) ; i ++ ; } } if ( info -> attrs [ NL80211_ATTR_IE ] ) { request -> ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; memcpy ( ( void * ) request -> ie , nla_data ( info -> attrs [ NL80211_ATTR_IE ] ) , request -> ie_len ) ; } request -> dev = dev ; request -> wiphy = & rdev -> wiphy ; request -> interval = interval ; err = rdev -> ops -> sched_scan_start ( & rdev -> wiphy , dev , request ) ; if ( ! err ) { rdev -> sched_scan_req = request ; nl80211_send_sched_scan ( rdev , dev , NL80211_CMD_START_SCHED_SCAN ) ; goto out ; } out_free : kfree ( request ) ; out : return err ; }\n", "\n", "1: CWE-119 static int nl80211_trigger_scan ( struct sk_buff * skb , struct genl_info * info ) { struct cfg80211_registered_device * rdev = info -> user_ptr [ 0 ] ; struct net_device * dev = info -> user_ptr [ 1 ] ; struct cfg80211_scan_request * request ; struct nlattr * attr ; struct wiphy * wiphy ; int err , tmp , n_ssids = 0 , n_channels , i ; enum ieee80211_band band ; size_t ie_len ; if ( ! is_valid_ie_attr ( info -> attrs [ NL80211_ATTR_IE ] ) ) return - EINVAL ; wiphy = & rdev -> wiphy ; if ( ! rdev -> ops -> scan ) return - EOPNOTSUPP ; if ( rdev -> scan_req ) return - EBUSY ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { n_channels = validate_scan_freqs ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) ; if ( ! n_channels ) return - EINVAL ; } else { n_channels = 0 ; for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) if ( wiphy -> bands [ band ] ) n_channels += wiphy -> bands [ band ] -> n_channels ; } if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , tmp ) n_ssids ++ ; if ( n_ssids > wiphy -> max_scan_ssids ) return - EINVAL ; if ( info -> attrs [ NL80211_ATTR_IE ] ) ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; else ie_len = 0 ; if ( ie_len > wiphy -> max_scan_ie_len ) return - EINVAL ; request = kzalloc ( sizeof ( * request ) + sizeof ( * request -> ssids ) * n_ssids + sizeof ( * request -> channels ) * n_channels + ie_len , GFP_KERNEL ) ; if ( ! request ) return - ENOMEM ; if ( n_ssids ) request -> ssids = ( void * ) & request -> channels [ n_channels ] ; request -> n_ssids = n_ssids ; if ( ie_len ) { if ( request -> ssids ) request -> ie = ( void * ) ( request -> ssids + n_ssids ) ; else request -> ie = ( void * ) ( request -> channels + n_channels ) ; } i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] , tmp ) { struct ieee80211_channel * chan ; chan = ieee80211_get_channel ( wiphy , nla_get_u32 ( attr ) ) ; if ( ! chan ) { err = - EINVAL ; goto out_free ; } if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } else { for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) { int j ; if ( ! wiphy -> bands [ band ] ) continue ; for ( j = 0 ; j < wiphy -> bands [ band ] -> n_channels ; j ++ ) { struct ieee80211_channel * chan ; chan = & wiphy -> bands [ band ] -> channels [ j ] ; if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } } if ( ! i ) { err = - EINVAL ; goto out_free ; } request -> n_channels = i ; i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , tmp ) { if ( request -> ssids [ i ] . ssid_len > IEEE80211_MAX_SSID_LEN ) { err = - EINVAL ; goto out_free ; } memcpy ( request -> ssids [ i ] . ssid , nla_data ( attr ) , nla_len ( attr ) ) ; request -> ssids [ i ] . ssid_len = nla_len ( attr ) ; i ++ ; } } if ( info -> attrs [ NL80211_ATTR_IE ] ) { request -> ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; memcpy ( ( void * ) request -> ie , nla_data ( info -> attrs [ NL80211_ATTR_IE ] ) , request -> ie_len ) ; } request -> dev = dev ; request -> wiphy = & rdev -> wiphy ; rdev -> scan_req = request ; err = rdev -> ops -> scan ( & rdev -> wiphy , dev , request ) ; if ( ! err ) { nl80211_send_scan_start ( rdev , dev ) ; dev_hold ( dev ) ; } else { out_free : rdev -> scan_req = NULL ; kfree ( request ) ; } return err ; }\n", "\n", "\n", "Target: goto out_key2 ; if ( match_futex ( & q . key , & key2 ) ) { ret = - EINVAL ; goto out_put_keys ; }\n", "\n", "Sources:\n", "0: CWE-264 static int futex_wait_requeue_pi ( u32 __user * uaddr , unsigned int flags , u32 val , ktime_t * abs_time , u32 bitset , u32 __user * uaddr2 ) { struct hrtimer_sleeper timeout , * to = NULL ; struct rt_mutex_waiter rt_waiter ; struct rt_mutex * pi_mutex = NULL ; struct futex_hash_bucket * hb ; union futex_key key2 = FUTEX_KEY_INIT ; struct futex_q q = futex_q_init ; int res , ret ; if ( uaddr == uaddr2 ) return - EINVAL ; if ( ! bitset ) return - EINVAL ; if ( abs_time ) { to = & timeout ; hrtimer_init_on_stack ( & to -> timer , ( flags & FLAGS_CLOCKRT ) ? CLOCK_REALTIME : CLOCK_MONOTONIC , HRTIMER_MODE_ABS ) ; hrtimer_init_sleeper ( to , current ) ; hrtimer_set_expires_range_ns ( & to -> timer , * abs_time , current -> timer_slack_ns ) ; } debug_rt_mutex_init_waiter ( & rt_waiter ) ; RB_CLEAR_NODE ( & rt_waiter . pi_tree_entry ) ; RB_CLEAR_NODE ( & rt_waiter . tree_entry ) ; rt_waiter . task = NULL ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , VERIFY_WRITE ) ; if ( unlikely ( ret != 0 ) ) goto out ; q . bitset = bitset ; q . rt_waiter = & rt_waiter ; q . requeue_pi_key = & key2 ; ret = futex_wait_setup ( uaddr , val , flags , & q , & hb ) ; if ( ret ) goto out_key2 ; futex_wait_queue_me ( hb , & q , to ) ; spin_lock ( & hb -> lock ) ; ret = handle_early_requeue_pi_wakeup ( hb , & q , & key2 , to ) ; spin_unlock ( & hb -> lock ) ; if ( ret ) goto out_put_keys ; if ( ! q . rt_waiter ) { if ( q . pi_state && ( q . pi_state -> owner != current ) ) { spin_lock ( q . lock_ptr ) ; ret = fixup_pi_state_owner ( uaddr2 , & q , current ) ; spin_unlock ( q . lock_ptr ) ; } } else { WARN_ON ( ! q . pi_state ) ; pi_mutex = & q . pi_state -> pi_mutex ; ret = rt_mutex_finish_proxy_lock ( pi_mutex , to , & rt_waiter , 1 ) ; debug_rt_mutex_free_waiter ( & rt_waiter ) ; spin_lock ( q . lock_ptr ) ; res = fixup_owner ( uaddr2 , & q , ! ret ) ; if ( res ) ret = ( res < 0 ) ? res : 0 ; unqueue_me_pi ( & q ) ; } if ( ret == - EFAULT ) { if ( pi_mutex && rt_mutex_owner ( pi_mutex ) == current ) rt_mutex_unlock ( pi_mutex ) ; } else if ( ret == - EINTR ) { ret = - EWOULDBLOCK ; } out_put_keys : put_futex_key ( & q . key ) ; out_key2 : put_futex_key ( & key2 ) ; out : if ( to ) { hrtimer_cancel ( & to -> timer ) ; destroy_hrtimer_on_stack ( & to -> timer ) ; } return ret ; }\n", "\n", "1: CWE-269 static int futex_wait_requeue_pi ( u32 __user * uaddr , unsigned int flags , u32 val , ktime_t * abs_time , u32 bitset , u32 __user * uaddr2 ) { struct hrtimer_sleeper timeout , * to = NULL ; struct rt_mutex_waiter rt_waiter ; struct rt_mutex * pi_mutex = NULL ; struct futex_hash_bucket * hb ; union futex_key key2 = FUTEX_KEY_INIT ; struct futex_q q = futex_q_init ; int res , ret ; if ( uaddr == uaddr2 ) return - EINVAL ; if ( ! bitset ) return - EINVAL ; if ( abs_time ) { to = & timeout ; hrtimer_init_on_stack ( & to -> timer , ( flags & FLAGS_CLOCKRT ) ? CLOCK_REALTIME : CLOCK_MONOTONIC , HRTIMER_MODE_ABS ) ; hrtimer_init_sleeper ( to , current ) ; hrtimer_set_expires_range_ns ( & to -> timer , * abs_time , current -> timer_slack_ns ) ; } debug_rt_mutex_init_waiter ( & rt_waiter ) ; RB_CLEAR_NODE ( & rt_waiter . pi_tree_entry ) ; RB_CLEAR_NODE ( & rt_waiter . tree_entry ) ; rt_waiter . task = NULL ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , VERIFY_WRITE ) ; if ( unlikely ( ret != 0 ) ) goto out ; q . bitset = bitset ; q . rt_waiter = & rt_waiter ; q . requeue_pi_key = & key2 ; ret = futex_wait_setup ( uaddr , val , flags , & q , & hb ) ; if ( ret ) goto out_key2 ; futex_wait_queue_me ( hb , & q , to ) ; spin_lock ( & hb -> lock ) ; ret = handle_early_requeue_pi_wakeup ( hb , & q , & key2 , to ) ; spin_unlock ( & hb -> lock ) ; if ( ret ) goto out_put_keys ; if ( ! q . rt_waiter ) { if ( q . pi_state && ( q . pi_state -> owner != current ) ) { spin_lock ( q . lock_ptr ) ; ret = fixup_pi_state_owner ( uaddr2 , & q , current ) ; spin_unlock ( q . lock_ptr ) ; } } else { WARN_ON ( ! q . pi_state ) ; pi_mutex = & q . pi_state -> pi_mutex ; ret = rt_mutex_finish_proxy_lock ( pi_mutex , to , & rt_waiter , 1 ) ; debug_rt_mutex_free_waiter ( & rt_waiter ) ; spin_lock ( q . lock_ptr ) ; res = fixup_owner ( uaddr2 , & q , ! ret ) ; if ( res ) ret = ( res < 0 ) ? res : 0 ; unqueue_me_pi ( & q ) ; } if ( ret == - EFAULT ) { if ( pi_mutex && rt_mutex_owner ( pi_mutex ) == current ) rt_mutex_unlock ( pi_mutex ) ; } else if ( ret == - EINTR ) { ret = - EWOULDBLOCK ; } out_put_keys : put_futex_key ( & q . key ) ; out_key2 : put_futex_key ( & key2 ) ; out : if ( to ) { hrtimer_cancel ( & to -> timer ) ; destroy_hrtimer_on_stack ( & to -> timer ) ; } return ret ; }\n", "\n", "\n", "Target: p , length ) ; break\n", "\n", "Sources:\n", "0: CWE-125 static void handle_ppp ( netdissect_options * ndo , u_int proto , const u_char * p , int length ) { if ( ( proto & 0xff00 ) == 0x7e00 ) { ppp_hdlc ( ndo , p - 1 , length ) ; return ; } switch ( proto ) { case PPP_LCP : case PPP_IPCP : case PPP_OSICP : case PPP_MPLSCP : case PPP_IPV6CP : case PPP_CCP : case PPP_BACP : handle_ctrl_proto ( ndo , proto , p , length ) ; break ; case PPP_ML : handle_mlppp ( ndo , p , length ) ; break ; case PPP_CHAP : handle_chap ( ndo , p , length ) ; break ; case PPP_PAP : handle_pap ( ndo , p , length ) ; break ; case PPP_BAP : handle_bap ( ndo , p , length ) ; break ; case ETHERTYPE_IP : case PPP_VJNC : case PPP_IP : ip_print ( ndo , p , length ) ; break ; case ETHERTYPE_IPV6 : case PPP_IPV6 : ip6_print ( ndo , p , length ) ; break ; case ETHERTYPE_IPX : case PPP_IPX : ipx_print ( ndo , p , length ) ; break ; case PPP_OSI : isoclns_print ( ndo , p , length , length ) ; break ; case PPP_MPLS_UCAST : case PPP_MPLS_MCAST : mpls_print ( ndo , p , length ) ; break ; case PPP_COMP : ND_PRINT ( ( ndo , \"compressedPPPdata\" ) ) ; break ; default : ND_PRINT ( ( ndo , \"%s\" , tok2str ( ppptype2str , \"unknownPPPprotocol(0x%04x)\" , proto ) ) ) ; print_unknown_data ( ndo , p , \"\\\\n\\\\t\" , length ) ; break ; } }\n", "\n", "1: CWE-125 u_int null_if_print ( netdissect_options * ndo , const struct pcap_pkthdr * h , const u_char * p ) { u_int length = h -> len ; u_int caplen = h -> caplen ; u_int family ; if ( caplen < NULL_HDRLEN ) { ND_PRINT ( ( ndo , \"[|null]\" ) ) ; return ( NULL_HDRLEN ) ; } memcpy ( ( char * ) & family , ( const char * ) p , sizeof ( family ) ) ; if ( ( family & 0xFFFF0000 ) != 0 ) family = SWAPLONG ( family ) ; if ( ndo -> ndo_eflag ) null_hdr_print ( ndo , family , length ) ; length -= NULL_HDRLEN ; caplen -= NULL_HDRLEN ; p += NULL_HDRLEN ; switch ( family ) { case BSD_AFNUM_INET : ip_print ( ndo , p , length ) ; break ; case BSD_AFNUM_INET6_BSD : case BSD_AFNUM_INET6_FREEBSD : case BSD_AFNUM_INET6_DARWIN : ip6_print ( ndo , p , length ) ; break ; case BSD_AFNUM_ISO : isoclns_print ( ndo , p , length , caplen ) ; break ; case BSD_AFNUM_APPLETALK : atalk_print ( ndo , p , length ) ; break ; case BSD_AFNUM_IPX : ipx_print ( ndo , p , length ) ; break ; default : if ( ! ndo -> ndo_eflag ) null_hdr_print ( ndo , family , length + NULL_HDRLEN ) ; if ( ! ndo -> ndo_suppress_default_print ) ND_DEFAULTPRINT ( p , caplen ) ; } return ( NULL_HDRLEN ) ; }\n", "\n", "2: CWE-125 void mpls_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const u_char * p ; uint32_t label_entry ; uint16_t label_stack_depth = 0 ; enum mpls_packet_type pt = PT_UNKNOWN ; p = bp ; ND_PRINT ( ( ndo , \"MPLS\" ) ) ; do { ND_TCHECK2 ( * p , sizeof ( label_entry ) ) ; if ( length < sizeof ( label_entry ) ) { ND_PRINT ( ( ndo , \"[|MPLS],length%u\" , length ) ) ; return ; } label_entry = EXTRACT_32BITS ( p ) ; ND_PRINT ( ( ndo , \"%s(label%u\" , ( label_stack_depth && ndo -> ndo_vflag ) ? \"\\\\n\\\\t\" : \"\" , MPLS_LABEL ( label_entry ) ) ) ; label_stack_depth ++ ; if ( ndo -> ndo_vflag && MPLS_LABEL ( label_entry ) < sizeof ( mpls_labelname ) / sizeof ( mpls_labelname [ 0 ] ) ) ND_PRINT ( ( ndo , \"(%s)\" , mpls_labelname [ MPLS_LABEL ( label_entry ) ] ) ) ; ND_PRINT ( ( ndo , \",exp%u\" , MPLS_EXP ( label_entry ) ) ) ; if ( MPLS_STACK ( label_entry ) ) ND_PRINT ( ( ndo , \",[S]\" ) ) ; ND_PRINT ( ( ndo , \",ttl%u)\" , MPLS_TTL ( label_entry ) ) ) ; p += sizeof ( label_entry ) ; length -= sizeof ( label_entry ) ; } while ( ! MPLS_STACK ( label_entry ) ) ; switch ( MPLS_LABEL ( label_entry ) ) { case 0 : case 3 : pt = PT_IPV4 ; break ; case 2 : pt = PT_IPV6 ; break ; default : ND_TCHECK ( * p ) ; if ( length < 1 ) { return ; } switch ( * p ) { case 0x45 : case 0x46 : case 0x47 : case 0x48 : case 0x49 : case 0x4a : case 0x4b : case 0x4c : case 0x4d : case 0x4e : case 0x4f : pt = PT_IPV4 ; break ; case 0x60 : case 0x61 : case 0x62 : case 0x63 : case 0x64 : case 0x65 : case 0x66 : case 0x67 : case 0x68 : case 0x69 : case 0x6a : case 0x6b : case 0x6c : case 0x6d : case 0x6e : case 0x6f : pt = PT_IPV6 ; break ; case 0x81 : case 0x82 : case 0x83 : pt = PT_OSI ; break ; default : break ; } } if ( pt == PT_UNKNOWN ) { if ( ! ndo -> ndo_suppress_default_print ) ND_DEFAULTPRINT ( p , length ) ; return ; } ND_PRINT ( ( ndo , ndo -> ndo_vflag ? \"\\\\n\\\\t\" : \"\" ) ) ; switch ( pt ) { case PT_IPV4 : ip_print ( ndo , p , length ) ; break ; case PT_IPV6 : ip6_print ( ndo , p , length ) ; break ; case PT_OSI : isoclns_print ( ndo , p , length , length ) ; break ; default : break ; } return ; trunc : ND_PRINT ( ( ndo , \"[|MPLS]\" ) ) ; }\n", "\n", "\n", "Target: in -> data [ plane ] && in -> linesize\n", "\n", "Sources:\n", "0: CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { unsigned x , y ; AVFilterContext * ctx = inlink -> dst ; VignetteContext * s = ctx -> priv ; AVFilterLink * outlink = inlink -> dst -> outputs [ 0 ] ; AVFrame * out ; out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; if ( s -> eval_mode == EVAL_MODE_FRAME ) update_context ( s , inlink , in ) ; if ( s -> desc -> flags & AV_PIX_FMT_FLAG_RGB ) { uint8_t * dst = out -> data [ 0 ] ; const uint8_t * src = in -> data [ 0 ] ; const float * fmap = s -> fmap ; const int dst_linesize = out -> linesize [ 0 ] ; const int src_linesize = in -> linesize [ 0 ] ; const int fmap_linesize = s -> fmap_linesize ; for ( y = 0 ; y < inlink -> h ; y ++ ) { uint8_t * dstp = dst ; const uint8_t * srcp = src ; for ( x = 0 ; x < inlink -> w ; x ++ , dstp += 3 , srcp += 3 ) { const float f = fmap [ x ] ; dstp [ 0 ] = av_clip_uint8 ( srcp [ 0 ] * f + get_dither_value ( s ) ) ; dstp [ 1 ] = av_clip_uint8 ( srcp [ 1 ] * f + get_dither_value ( s ) ) ; dstp [ 2 ] = av_clip_uint8 ( srcp [ 2 ] * f + get_dither_value ( s ) ) ; } dst += dst_linesize ; src += src_linesize ; fmap += fmap_linesize ; } } else { int plane ; for ( plane = 0 ; plane < 4 && in -> data [ plane ] ; plane ++ ) { uint8_t * dst = out -> data [ plane ] ; const uint8_t * src = in -> data [ plane ] ; const float * fmap = s -> fmap ; const int dst_linesize = out -> linesize [ plane ] ; const int src_linesize = in -> linesize [ plane ] ; const int fmap_linesize = s -> fmap_linesize ; const int chroma = plane == 1 || plane == 2 ; const int hsub = chroma ? s -> desc -> log2_chroma_w : 0 ; const int vsub = chroma ? s -> desc -> log2_chroma_h : 0 ; const int w = FF_CEIL_RSHIFT ( inlink -> w , hsub ) ; const int h = FF_CEIL_RSHIFT ( inlink -> h , vsub ) ; for ( y = 0 ; y < h ; y ++ ) { uint8_t * dstp = dst ; const uint8_t * srcp = src ; for ( x = 0 ; x < w ; x ++ ) { const double dv = get_dither_value ( s ) ; if ( chroma ) * dstp ++ = av_clip_uint8 ( fmap [ x << hsub ] * ( * srcp ++ - 127 ) + 127 + dv ) ; else * dstp ++ = av_clip_uint8 ( fmap [ x ] * * srcp ++ + dv ) ; } dst += dst_linesize ; src += src_linesize ; fmap += fmap_linesize << vsub ; } } } return ff_filter_frame ( outlink , out ) ; }\n", "\n", "1: CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { DelogoContext * s = inlink -> dst -> priv ; AVFilterLink * outlink = inlink -> dst -> outputs [ 0 ] ; const AVPixFmtDescriptor * desc = av_pix_fmt_desc_get ( inlink -> format ) ; AVFrame * out ; int hsub0 = desc -> log2_chroma_w ; int vsub0 = desc -> log2_chroma_h ; int direct = 0 ; int plane ; AVRational sar ; if ( av_frame_is_writable ( in ) ) { direct = 1 ; out = in ; } else { out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; } sar = in -> sample_aspect_ratio ; if ( ! sar . num ) sar . num = sar . den = 1 ; for ( plane = 0 ; plane < 4 && in -> data [ plane ] ; plane ++ ) { int hsub = plane == 1 || plane == 2 ? hsub0 : 0 ; int vsub = plane == 1 || plane == 2 ? vsub0 : 0 ; apply_delogo ( out -> data [ plane ] , out -> linesize [ plane ] , in -> data [ plane ] , in -> linesize [ plane ] , FF_CEIL_RSHIFT ( inlink -> w , hsub ) , FF_CEIL_RSHIFT ( inlink -> h , vsub ) , sar , s -> x >> hsub , s -> y >> vsub , FF_CEIL_RSHIFT ( s -> w + ( s -> x & ( ( 1 << hsub ) - 1 ) ) , hsub ) , FF_CEIL_RSHIFT ( s -> h + ( s -> y & ( ( 1 << vsub ) - 1 ) ) , vsub ) , s -> band >> FFMIN ( hsub , vsub ) , s -> show , direct ) ; } if ( ! direct ) av_frame_free ( & in ) ; return ff_filter_frame ( outlink , out ) ; }\n", "\n", "\n", "Target: static\n", "\n", "Sources:\n", "0: CWE-125 int ntlm_read_message_fields ( wStream * s , NTLM_MESSAGE_FIELDS * fields ) { if ( Stream_GetRemainingLength ( s ) < 8 ) return - 1 ; Stream_Read_UINT16 ( s , fields -> Len ) ; Stream_Read_UINT16 ( s , fields -> MaxLen ) ; Stream_Read_UINT32 ( s , fields -> BufferOffset ) ; return 1 ; }\n", "\n", "1: CWE-125 void ntlm_write_message_fields ( wStream * s , NTLM_MESSAGE_FIELDS * fields ) { if ( fields -> MaxLen < 1 ) fields -> MaxLen = fields -> Len ; Stream_Write_UINT16 ( s , fields -> Len ) ; Stream_Write_UINT16 ( s , fields -> MaxLen ) ; Stream_Write_UINT32 ( s , fields -> BufferOffset ) ; }\n", "\n", "2: CWE-125 int ntlm_read_message_header ( wStream * s , NTLM_MESSAGE_HEADER * header ) { if ( Stream_GetRemainingLength ( s ) < 12 ) return - 1 ; Stream_Read ( s , header -> Signature , 8 ) ; Stream_Read_UINT32 ( s , header -> MessageType ) ; if ( strncmp ( ( char * ) header -> Signature , NTLM_SIGNATURE , 8 ) != 0 ) return - 1 ; return 1 ; }\n", "\n", "3: CWE-125 void ntlm_print_negotiate_flags ( UINT32 flags ) { int i ; const char * str ; WLog_INFO ( TAG , \"negotiateFlags\\\\\"0x%08\" PRIX32 \"\\\\\"\" , flags ) ; for ( i = 31 ; i >= 0 ; i -- ) { if ( ( flags >> i ) & 1 ) { str = NTLM_NEGOTIATE_STRINGS [ ( 31 - i ) ] ; WLog_INFO ( TAG , \"\\\\t%s(%d),\" , str , ( 31 - i ) ) ; } } }\n", "\n", "4: CWE-125 void ntlm_populate_message_header ( NTLM_MESSAGE_HEADER * header , UINT32 MessageType ) { CopyMemory ( header -> Signature , NTLM_SIGNATURE , sizeof ( NTLM_SIGNATURE ) ) ; header -> MessageType = MessageType ; }\n", "\n", "5: CWE-119 int release_vp9_frame_buffer ( void * cb_priv , vpx_codec_frame_buffer_t * fb ) { struct ExternalFrameBuffer * const ext_fb = ( struct ExternalFrameBuffer * ) fb -> priv ; ( void ) cb_priv ; ext_fb -> in_use = 0 ; return 0 ; }\n", "\n", "6: CWE-119 void validate_positive_rational ( const char * msg , struct vpx_rational * rat ) { if ( rat -> den < 0 ) { rat -> num *= - 1 ; rat -> den *= - 1 ; } if ( rat -> num < 0 ) die ( \"Error:%smustbepositive\\\\n\" , msg ) ; if ( ! rat -> den ) die ( \"Error:%shaszerodenominator\\\\n\" , msg ) ; }\n", "\n", "7: CWE-125 void ntlm_free_message_fields_buffer ( NTLM_MESSAGE_FIELDS * fields ) { if ( fields ) { if ( fields -> Buffer ) { free ( fields -> Buffer ) ; fields -> Len = 0 ; fields -> MaxLen = 0 ; fields -> Buffer = NULL ; fields -> BufferOffset = 0 ; } } }\n", "\n", "8: CWE-119 int check_fragments_for_errors ( VP8D_COMP * pbi ) { if ( ! pbi -> ec_active && pbi -> fragments . count <= 1 && pbi -> fragments . sizes [ 0 ] == 0 ) { VP8_COMMON * cm = & pbi -> common ; if ( cm -> fb_idx_ref_cnt [ cm -> lst_fb_idx ] > 1 ) { const int prev_idx = cm -> lst_fb_idx ; cm -> fb_idx_ref_cnt [ prev_idx ] -- ; cm -> lst_fb_idx = get_free_fb ( cm ) ; vp8_yv12_copy_frame ( & cm -> yv12_fb [ prev_idx ] , & cm -> yv12_fb [ cm -> lst_fb_idx ] ) ; } cm -> yv12_fb [ cm -> lst_fb_idx ] . corrupted = 1 ; cm -> show_frame = 0 ; return 0 ; } return 1 ; }\n", "\n", "9: CWE-125 void ntlm_write_message_fields_buffer ( wStream * s , NTLM_MESSAGE_FIELDS * fields ) { if ( fields -> Len > 0 ) { Stream_SetPosition ( s , fields -> BufferOffset ) ; Stream_Write ( s , fields -> Buffer , fields -> Len ) ; } }\n", "\n", "10: CWE-119 void fadst16_sse2 ( __m128i * in0 , __m128i * in1 ) { fadst16_8col ( in0 ) ; fadst16_8col ( in1 ) ; array_transpose_16x16 ( in0 , in1 ) ; }\n", "\n", "11: CWE-119 void fdct16_sse2 ( __m128i * in0 , __m128i * in1 ) { fdct16_8col ( in0 ) ; fdct16_8col ( in1 ) ; array_transpose_16x16 ( in0 , in1 ) ; }\n", "\n", "12: CWE-119 int fourcc_is_ivf ( const char detect [ 4 ] ) { if ( memcmp ( detect , \"DKIF\" , 4 ) == 0 ) { return 1 ; } return 0 ; }\n", "\n", "13: CWE-119 int read_frame ( struct VpxInputContext * input_ctx , vpx_image_t * img ) { FILE * f = input_ctx -> file ; y4m_input * y4m = & input_ctx -> y4m ; int shortread = 0 ; if ( input_ctx -> file_type == FILE_TYPE_Y4M ) { if ( y4m_input_fetch_frame ( y4m , f , img ) < 1 ) return 0 ; } else { shortread = read_yuv_frame ( input_ctx , img ) ; } return ! shortread ; }\n", "\n", "14: CWE-125 void ntlm_print_message_fields ( NTLM_MESSAGE_FIELDS * fields , const char * name ) { WLog_DBG ( TAG , \"%s(Len:%\" PRIu16 \"MaxLen:%\" PRIu16 \"BufferOffset:%\" PRIu32 \")\" , name , fields -> Len , fields -> MaxLen , fields -> BufferOffset ) ; if ( fields -> Len > 0 ) winpr_HexDump ( TAG , WLOG_DEBUG , fields -> Buffer , fields -> Len ) ; }\n", "\n", "15: CWE-119 int get_down2_steps ( int in_length , int out_length ) { int steps = 0 ; int proj_in_length ; while ( ( proj_in_length = get_down2_length ( in_length , 1 ) ) >= out_length ) { ++ steps ; in_length = proj_in_length ; } return steps ; }\n", "\n", "16: CWE-119 void byteSwap ( UWORD32 * buf , unsigned words ) { md5byte * p ; int i = 1 ; if ( * ( char * ) & i == 1 ) return ; p = ( md5byte * ) buf ; do { * buf ++ = ( UWORD32 ) ( ( unsigned ) p [ 3 ] << 8 | p [ 2 ] ) << 16 | ( ( unsigned ) p [ 1 ] << 8 | p [ 0 ] ) ; p += 4 ; } while ( -- words ) ; }\n", "\n", "17: CWE-125 void ntlm_write_message_header ( wStream * s , NTLM_MESSAGE_HEADER * header ) { Stream_Write ( s , header -> Signature , sizeof ( NTLM_SIGNATURE ) ) ; Stream_Write_UINT32 ( s , header -> MessageType ) ; }\n", "\n", "\n", "Target: = port ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ;\n", "\n", "Sources:\n", "0: CWE-264 static struct net_device * _init_airo_card ( unsigned short irq , int port , int is_pcmcia , struct pci_dev * pci , struct device * dmdev ) { struct net_device * dev ; struct airo_info * ai ; int i , rc ; CapabilityRid cap_rid ; dev = alloc_netdev ( sizeof ( * ai ) , \"\" , ether_setup ) ; if ( ! dev ) { airo_print_err ( \"\" , \"Couldn\\'talloc_etherdev\" ) ; return NULL ; } ai = dev -> ml_priv = netdev_priv ( dev ) ; ai -> wifidev = NULL ; ai -> flags = 1 << FLAG_RADIO_DOWN ; ai -> jobs = 0 ; ai -> dev = dev ; if ( pci && ( pci -> device == 0x5000 || pci -> device == 0xa504 ) ) { airo_print_dbg ( \"\" , \"FoundanMPI350card\" ) ; set_bit ( FLAG_MPI , & ai -> flags ) ; } spin_lock_init ( & ai -> aux_lock ) ; sema_init ( & ai -> sem , 1 ) ; ai -> config . len = 0 ; ai -> pci = pci ; init_waitqueue_head ( & ai -> thr_wait ) ; ai -> tfm = NULL ; add_airo_dev ( ai ) ; if ( airo_networks_allocate ( ai ) ) goto err_out_free ; airo_networks_initialize ( ai ) ; skb_queue_head_init ( & ai -> txq ) ; if ( test_bit ( FLAG_MPI , & ai -> flags ) ) dev -> netdev_ops = & mpi_netdev_ops ; else dev -> netdev_ops = & airo_netdev_ops ; dev -> wireless_handlers = & airo_handler_def ; ai -> wireless_data . spy_data = & ai -> spy_data ; dev -> wireless_data = & ai -> wireless_data ; dev -> irq = irq ; dev -> base_addr = port ; SET_NETDEV_DEV ( dev , dmdev ) ; reset_card ( dev , 1 ) ; msleep ( 400 ) ; if ( ! is_pcmcia ) { if ( ! request_region ( dev -> base_addr , 64 , DRV_NAME ) ) { rc = - EBUSY ; airo_print_err ( dev -> name , \"Couldn\\'trequestregion\" ) ; goto err_out_nets ; } } if ( test_bit ( FLAG_MPI , & ai -> flags ) ) { if ( mpi_map_card ( ai , pci ) ) { airo_print_err ( \"\" , \"Couldnotmapmemory\" ) ; goto err_out_res ; } } if ( probe ) { if ( setup_card ( ai , dev -> dev_addr , 1 ) != SUCCESS ) { airo_print_err ( dev -> name , \"MACcouldnotbeenabled\" ) ; rc = - EIO ; goto err_out_map ; } } else if ( ! test_bit ( FLAG_MPI , & ai -> flags ) ) { ai -> bap_read = fast_bap_read ; set_bit ( FLAG_FLASHING , & ai -> flags ) ; } strcpy ( dev -> name , \"eth%d\" ) ; rc = register_netdev ( dev ) ; if ( rc ) { airo_print_err ( dev -> name , \"Couldn\\'tregister_netdev\" ) ; goto err_out_map ; } ai -> wifidev = init_wifidev ( ai , dev ) ; if ( ! ai -> wifidev ) goto err_out_reg ; rc = readCapabilityRid ( ai , & cap_rid , 1 ) ; if ( rc != SUCCESS ) { rc = - EIO ; goto err_out_wifi ; } ai -> wep_capable = ( cap_rid . softCap & cpu_to_le16 ( 0x02 ) ) ? 1 : 0 ; ai -> max_wep_idx = ( cap_rid . softCap & cpu_to_le16 ( 0x80 ) ) ? 3 : 0 ; airo_print_info ( dev -> name , \"Firmwareversion%x.%x.%02d\" , ( ( le16_to_cpu ( cap_rid . softVer ) >> 8 ) & 0xF ) , ( le16_to_cpu ( cap_rid . softVer ) & 0xFF ) , le16_to_cpu ( cap_rid . softSubVer ) ) ; if ( le16_to_cpu ( cap_rid . softVer ) > 0x530 || ( le16_to_cpu ( cap_rid . softVer ) == 0x530 && le16_to_cpu ( cap_rid . softSubVer ) >= 17 ) ) { airo_print_info ( ai -> dev -> name , \"WPAsupported.\" ) ; set_bit ( FLAG_WPA_CAPABLE , & ai -> flags ) ; ai -> bssListFirst = RID_WPA_BSSLISTFIRST ; ai -> bssListNext = RID_WPA_BSSLISTNEXT ; ai -> bssListRidLen = sizeof ( BSSListRid ) ; } else { airo_print_info ( ai -> dev -> name , \"WPAunsupportedwithfirmware\" \"versionsolderthan5.30.17.\" ) ; ai -> bssListFirst = RID_BSSLISTFIRST ; ai -> bssListNext = RID_BSSLISTNEXT ; ai -> bssListRidLen = sizeof ( BSSListRid ) - sizeof ( BSSListRidExtra ) ; } set_bit ( FLAG_REGISTERED , & ai -> flags ) ; airo_print_info ( dev -> name , \"MACenabled%pM\" , dev -> dev_addr ) ; if ( probe && ! test_bit ( FLAG_MPI , & ai -> flags ) ) for ( i = 0 ; i < MAX_FIDS ; i ++ ) ai -> fids [ i ] = transmit_allocate ( ai , AIRO_DEF_MTU , i >= MAX_FIDS / 2 ) ; if ( setup_proc_entry ( dev , dev -> ml_priv ) < 0 ) goto err_out_wifi ; return dev ; err_out_wifi : unregister_netdev ( ai -> wifidev ) ; free_netdev ( ai -> wifidev ) ; err_out_reg : unregister_netdev ( dev ) ; err_out_map : if ( test_bit ( FLAG_MPI , & ai -> flags ) && pci ) { pci_free_consistent ( pci , PCI_SHARED_LEN , ai -> shared , ai -> shared_dma ) ; iounmap ( ai -> pciaux ) ; iounmap ( ai -> pcimem ) ; mpi_unmap_card ( ai -> pci ) ; } err_out_res : if ( ! is_pcmcia ) release_region ( dev -> base_addr , 64 ) ; err_out_nets : airo_networks_free ( ai ) ; err_out_free : del_airo_dev ( ai ) ; free_netdev ( dev ) ; return NULL ; }\n", "\n", "1: CWE-000 static struct net_device * _init_airo_card ( unsigned short irq , int port , int is_pcmcia , struct pci_dev * pci , struct device * dmdev ) { struct net_device * dev ; struct airo_info * ai ; int i , rc ; CapabilityRid cap_rid ; dev = alloc_netdev ( sizeof ( * ai ) , \"\" , ether_setup ) ; if ( ! dev ) { airo_print_err ( \"\" , \"Couldn\\'talloc_etherdev\" ) ; return NULL ; } ai = dev -> ml_priv = netdev_priv ( dev ) ; ai -> wifidev = NULL ; ai -> flags = 1 << FLAG_RADIO_DOWN ; ai -> jobs = 0 ; ai -> dev = dev ; if ( pci && ( pci -> device == 0x5000 || pci -> device == 0xa504 ) ) { airo_print_dbg ( \"\" , \"FoundanMPI350card\" ) ; set_bit ( FLAG_MPI , & ai -> flags ) ; } spin_lock_init ( & ai -> aux_lock ) ; sema_init ( & ai -> sem , 1 ) ; ai -> config . len = 0 ; ai -> pci = pci ; init_waitqueue_head ( & ai -> thr_wait ) ; ai -> tfm = NULL ; add_airo_dev ( ai ) ; if ( airo_networks_allocate ( ai ) ) goto err_out_free ; airo_networks_initialize ( ai ) ; skb_queue_head_init ( & ai -> txq ) ; if ( test_bit ( FLAG_MPI , & ai -> flags ) ) dev -> netdev_ops = & mpi_netdev_ops ; else dev -> netdev_ops = & airo_netdev_ops ; dev -> wireless_handlers = & airo_handler_def ; ai -> wireless_data . spy_data = & ai -> spy_data ; dev -> wireless_data = & ai -> wireless_data ; dev -> irq = irq ; dev -> base_addr = port ; SET_NETDEV_DEV ( dev , dmdev ) ; reset_card ( dev , 1 ) ; msleep ( 400 ) ; if ( ! is_pcmcia ) { if ( ! request_region ( dev -> base_addr , 64 , DRV_NAME ) ) { rc = - EBUSY ; airo_print_err ( dev -> name , \"Couldn\\'trequestregion\" ) ; goto err_out_nets ; } } if ( test_bit ( FLAG_MPI , & ai -> flags ) ) { if ( mpi_map_card ( ai , pci ) ) { airo_print_err ( \"\" , \"Couldnotmapmemory\" ) ; goto err_out_res ; } } if ( probe ) { if ( setup_card ( ai , dev -> dev_addr , 1 ) != SUCCESS ) { airo_print_err ( dev -> name , \"MACcouldnotbeenabled\" ) ; rc = - EIO ; goto err_out_map ; } } else if ( ! test_bit ( FLAG_MPI , & ai -> flags ) ) { ai -> bap_read = fast_bap_read ; set_bit ( FLAG_FLASHING , & ai -> flags ) ; } strcpy ( dev -> name , \"eth%d\" ) ; rc = register_netdev ( dev ) ; if ( rc ) { airo_print_err ( dev -> name , \"Couldn\\'tregister_netdev\" ) ; goto err_out_map ; } ai -> wifidev = init_wifidev ( ai , dev ) ; if ( ! ai -> wifidev ) goto err_out_reg ; rc = readCapabilityRid ( ai , & cap_rid , 1 ) ; if ( rc != SUCCESS ) { rc = - EIO ; goto err_out_wifi ; } ai -> wep_capable = ( cap_rid . softCap & cpu_to_le16 ( 0x02 ) ) ? 1 : 0 ; ai -> max_wep_idx = ( cap_rid . softCap & cpu_to_le16 ( 0x80 ) ) ? 3 : 0 ; airo_print_info ( dev -> name , \"Firmwareversion%x.%x.%02d\" , ( ( le16_to_cpu ( cap_rid . softVer ) >> 8 ) & 0xF ) , ( le16_to_cpu ( cap_rid . softVer ) & 0xFF ) , le16_to_cpu ( cap_rid . softSubVer ) ) ; if ( le16_to_cpu ( cap_rid . softVer ) > 0x530 || ( le16_to_cpu ( cap_rid . softVer ) == 0x530 && le16_to_cpu ( cap_rid . softSubVer ) >= 17 ) ) { airo_print_info ( ai -> dev -> name , \"WPAsupported.\" ) ; set_bit ( FLAG_WPA_CAPABLE , & ai -> flags ) ; ai -> bssListFirst = RID_WPA_BSSLISTFIRST ; ai -> bssListNext = RID_WPA_BSSLISTNEXT ; ai -> bssListRidLen = sizeof ( BSSListRid ) ; } else { airo_print_info ( ai -> dev -> name , \"WPAunsupportedwithfirmware\" \"versionsolderthan5.30.17.\" ) ; ai -> bssListFirst = RID_BSSLISTFIRST ; ai -> bssListNext = RID_BSSLISTNEXT ; ai -> bssListRidLen = sizeof ( BSSListRid ) - sizeof ( BSSListRidExtra ) ; } set_bit ( FLAG_REGISTERED , & ai -> flags ) ; airo_print_info ( dev -> name , \"MACenabled%pM\" , dev -> dev_addr ) ; if ( probe && ! test_bit ( FLAG_MPI , & ai -> flags ) ) for ( i = 0 ; i < MAX_FIDS ; i ++ ) ai -> fids [ i ] = transmit_allocate ( ai , AIRO_DEF_MTU , i >= MAX_FIDS / 2 ) ; if ( setup_proc_entry ( dev , dev -> ml_priv ) < 0 ) goto err_out_wifi ; return dev ; err_out_wifi : unregister_netdev ( ai -> wifidev ) ; free_netdev ( ai -> wifidev ) ; err_out_reg : unregister_netdev ( dev ) ; err_out_map : if ( test_bit ( FLAG_MPI , & ai -> flags ) && pci ) { pci_free_consistent ( pci , PCI_SHARED_LEN , ai -> shared , ai -> shared_dma ) ; iounmap ( ai -> pciaux ) ; iounmap ( ai -> pcimem ) ; mpi_unmap_card ( ai -> pci ) ; } err_out_res : if ( ! is_pcmcia ) release_region ( dev -> base_addr , 64 ) ; err_out_nets : airo_networks_free ( ai ) ; err_out_free : del_airo_dev ( ai ) ; free_netdev ( dev ) ; return NULL ; }\n", "\n", "\n", "Target: c_dest ) ; snd_use_lock_use ( & new_port -> use_lock ) ; = num ; sprintf ( new_port -> name , \"port-%d\" , num ) ; client -> ports_mutex ) ; return\n", "\n", "Sources:\n", "0: CWE-362 struct snd_seq_client_port * snd_seq_create_port ( struct snd_seq_client * client , int port ) { unsigned long flags ; struct snd_seq_client_port * new_port , * p ; int num = - 1 ; if ( snd_BUG_ON ( ! client ) ) return NULL ; if ( client -> num_ports >= SNDRV_SEQ_MAX_PORTS ) { pr_warn ( \"ALSA:seq:toomanyportsforclient%d\\\\n\" , client -> number ) ; return NULL ; } new_port = kzalloc ( sizeof ( * new_port ) , GFP_KERNEL ) ; if ( ! new_port ) return NULL ; new_port -> addr . client = client -> number ; new_port -> addr . port = - 1 ; new_port -> owner = THIS_MODULE ; sprintf ( new_port -> name , \"port-%d\" , num ) ; snd_use_lock_init ( & new_port -> use_lock ) ; port_subs_info_init ( & new_port -> c_src ) ; port_subs_info_init ( & new_port -> c_dest ) ; num = port >= 0 ? port : 0 ; mutex_lock ( & client -> ports_mutex ) ; write_lock_irqsave ( & client -> ports_lock , flags ) ; list_for_each_entry ( p , & client -> ports_list_head , list ) { if ( p -> addr . port > num ) break ; if ( port < 0 ) num = p -> addr . port + 1 ; } list_add_tail ( & new_port -> list , & p -> list ) ; client -> num_ports ++ ; new_port -> addr . port = num ; write_unlock_irqrestore ( & client -> ports_lock , flags ) ; mutex_unlock ( & client -> ports_mutex ) ; sprintf ( new_port -> name , \"port-%d\" , num ) ; return new_port ; }\n", "\n", "1: CWE-416 struct snd_seq_client_port * snd_seq_create_port ( struct snd_seq_client * client , int port ) { unsigned long flags ; struct snd_seq_client_port * new_port , * p ; int num = - 1 ; if ( snd_BUG_ON ( ! client ) ) return NULL ; if ( client -> num_ports >= SNDRV_SEQ_MAX_PORTS ) { pr_warn ( \"ALSA:seq:toomanyportsforclient%d\\\\n\" , client -> number ) ; return NULL ; } new_port = kzalloc ( sizeof ( * new_port ) , GFP_KERNEL ) ; if ( ! new_port ) return NULL ; new_port -> addr . client = client -> number ; new_port -> addr . port = - 1 ; new_port -> owner = THIS_MODULE ; sprintf ( new_port -> name , \"port-%d\" , num ) ; snd_use_lock_init ( & new_port -> use_lock ) ; port_subs_info_init ( & new_port -> c_src ) ; port_subs_info_init ( & new_port -> c_dest ) ; num = port >= 0 ? port : 0 ; mutex_lock ( & client -> ports_mutex ) ; write_lock_irqsave ( & client -> ports_lock , flags ) ; list_for_each_entry ( p , & client -> ports_list_head , list ) { if ( p -> addr . port > num ) break ; if ( port < 0 ) num = p -> addr . port + 1 ; } list_add_tail ( & new_port -> list , & p -> list ) ; client -> num_ports ++ ; new_port -> addr . port = num ; write_unlock_irqrestore ( & client -> ports_lock , flags ) ; mutex_unlock ( & client -> ports_mutex ) ; sprintf ( new_port -> name , \"port-%d\" , num ) ; return new_port ; }\n", "\n", "\n", "Target: ) return ; crypto_free_skcipher ( ci\n", "\n", "Sources:\n", "0: CWE-476 static void put_crypt_info ( struct fscrypt_info * ci ) { if ( ! ci ) return ; key_put ( ci -> ci_keyring_key ) ; crypto_free_skcipher ( ci -> ci_ctfm ) ; kmem_cache_free ( fscrypt_info_cachep , ci ) ; }\n", "\n", "1: CWE-416 static void put_crypt_info ( struct fscrypt_info * ci ) { if ( ! ci ) return ; key_put ( ci -> ci_keyring_key ) ; crypto_free_skcipher ( ci -> ci_ctfm ) ; kmem_cache_free ( fscrypt_info_cachep , ci ) ; }\n", "\n", "\n", "Target: prevhdr ) ; if ( unfrag_ip6hlen < 0 ) return ERR_PTR ( unfrag_ip6hlen ) ;\n", "\n", "Sources:\n", "0: CWE-125 static struct sk_buff * ipv6_gso_segment ( struct sk_buff * skb , netdev_features_t features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; struct ipv6hdr * ipv6h ; const struct net_offload * ops ; int proto ; struct frag_hdr * fptr ; unsigned int unfrag_ip6hlen ; unsigned int payload_len ; u8 * prevhdr ; int offset = 0 ; bool encap , udpfrag ; int nhoff ; bool gso_partial ; skb_reset_network_header ( skb ) ; nhoff = skb_network_header ( skb ) - skb_mac_header ( skb ) ; if ( unlikely ( ! pskb_may_pull ( skb , sizeof ( * ipv6h ) ) ) ) goto out ; encap = SKB_GSO_CB ( skb ) -> encap_level > 0 ; if ( encap ) features &= skb -> dev -> hw_enc_features ; SKB_GSO_CB ( skb ) -> encap_level += sizeof ( * ipv6h ) ; ipv6h = ipv6_hdr ( skb ) ; __skb_pull ( skb , sizeof ( * ipv6h ) ) ; segs = ERR_PTR ( - EPROTONOSUPPORT ) ; proto = ipv6_gso_pull_exthdrs ( skb , ipv6h -> nexthdr ) ; if ( skb -> encapsulation && skb_shinfo ( skb ) -> gso_type & ( SKB_GSO_IPXIP4 | SKB_GSO_IPXIP6 ) ) udpfrag = proto == IPPROTO_UDP && encap ; else udpfrag = proto == IPPROTO_UDP && ! skb -> encapsulation ; ops = rcu_dereference ( inet6_offloads [ proto ] ) ; if ( likely ( ops && ops -> callbacks . gso_segment ) ) { skb_reset_transport_header ( skb ) ; segs = ops -> callbacks . gso_segment ( skb , features ) ; } if ( IS_ERR_OR_NULL ( segs ) ) goto out ; gso_partial = ! ! ( skb_shinfo ( segs ) -> gso_type & SKB_GSO_PARTIAL ) ; for ( skb = segs ; skb ; skb = skb -> next ) { ipv6h = ( struct ipv6hdr * ) ( skb_mac_header ( skb ) + nhoff ) ; if ( gso_partial ) payload_len = skb_shinfo ( skb ) -> gso_size + SKB_GSO_CB ( skb ) -> data_offset + skb -> head - ( unsigned char * ) ( ipv6h + 1 ) ; else payload_len = skb -> len - nhoff - sizeof ( * ipv6h ) ; ipv6h -> payload_len = htons ( payload_len ) ; skb -> network_header = ( u8 * ) ipv6h - skb -> head ; if ( udpfrag ) { unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; fptr = ( struct frag_hdr * ) ( ( u8 * ) ipv6h + unfrag_ip6hlen ) ; fptr -> frag_off = htons ( offset ) ; if ( skb -> next ) fptr -> frag_off |= htons ( IP6_MF ) ; offset += ( ntohs ( ipv6h -> payload_len ) - sizeof ( struct frag_hdr ) ) ; } if ( encap ) skb_reset_inner_headers ( skb ) ; } out : return segs ; }\n", "\n", "1: CWE-125 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , netdev_features_t features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * packet_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; __wsum csum ; int tnl_hlen ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; if ( ! skb_shinfo ( skb ) -> ip6_frag_id ) ipv6_proxy_select_ident ( dev_net ( skb -> dev ) , skb ) ; segs = NULL ; goto out ; } if ( skb -> encapsulation && skb_shinfo ( skb ) -> gso_type & ( SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL_CSUM ) ) segs = skb_udp_tunnel_segment ( skb , features , true ) ; else { const struct ipv6hdr * ipv6h ; struct udphdr * uh ; if ( ! pskb_may_pull ( skb , sizeof ( struct udphdr ) ) ) goto out ; uh = udp_hdr ( skb ) ; ipv6h = ipv6_hdr ( skb ) ; uh -> check = 0 ; csum = skb_checksum ( skb , 0 , skb -> len , 0 ) ; uh -> check = udp_v6_check ( skb -> len , & ipv6h -> saddr , & ipv6h -> daddr , csum ) ; if ( uh -> check == 0 ) uh -> check = CSUM_MANGLED_0 ; skb -> ip_summed = CHECKSUM_NONE ; if ( ! skb -> encap_hdr_csum ) features |= NETIF_F_HW_CSUM ; tnl_hlen = skb_tnl_header_len ( skb ) ; if ( skb -> mac_header < ( tnl_hlen + frag_hdr_sz ) ) { if ( gso_pskb_expand_head ( skb , tnl_hlen + frag_hdr_sz ) ) goto out ; } unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = ( skb_network_header ( skb ) - skb_mac_header ( skb ) ) + unfrag_ip6hlen + tnl_hlen ; packet_start = ( u8 * ) skb -> head + SKB_GSO_CB ( skb ) -> mac_offset ; memmove ( packet_start - frag_hdr_sz , packet_start , unfrag_len ) ; SKB_GSO_CB ( skb ) -> mac_offset -= frag_hdr_sz ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; if ( ! skb_shinfo ( skb ) -> ip6_frag_id ) ipv6_proxy_select_ident ( dev_net ( skb -> dev ) , skb ) ; fptr -> identification = skb_shinfo ( skb ) -> ip6_frag_id ; segs = skb_segment ( skb , features ) ; } out : return segs ; }\n", "\n", "\n", "Target: u_char * dat , u_int length ) dat ; if ( length < 4 ) { ND_PRINT ( ( ndo , \"AVPtooshort\" ) ) ; return ; }\n", "\n", "Sources:\n", "0: CWE-125 static void l2tp_framing_cap_print ( netdissect_options * ndo , const u_char * dat ) { const uint32_t * ptr = ( const uint32_t * ) dat ; if ( EXTRACT_32BITS ( ptr ) & L2TP_FRAMING_CAP_ASYNC_MASK ) { ND_PRINT ( ( ndo , \"A\" ) ) ; } if ( EXTRACT_32BITS ( ptr ) & L2TP_FRAMING_CAP_SYNC_MASK ) { ND_PRINT ( ( ndo , \"S\" ) ) ; } }\n", "\n", "1: CWE-125 static void l2tp_bearer_type_print ( netdissect_options * ndo , const u_char * dat ) { const uint32_t * ptr = ( const uint32_t * ) dat ; if ( EXTRACT_32BITS ( ptr ) & L2TP_BEARER_TYPE_ANALOG_MASK ) { ND_PRINT ( ( ndo , \"A\" ) ) ; } if ( EXTRACT_32BITS ( ptr ) & L2TP_BEARER_TYPE_DIGITAL_MASK ) { ND_PRINT ( ( ndo , \"D\" ) ) ; } }\n", "\n", "2: CWE-125 static void l2tp_bearer_cap_print ( netdissect_options * ndo , const u_char * dat ) { const uint32_t * ptr = ( const uint32_t * ) dat ; if ( EXTRACT_32BITS ( ptr ) & L2TP_BEARER_CAP_ANALOG_MASK ) { ND_PRINT ( ( ndo , \"A\" ) ) ; } if ( EXTRACT_32BITS ( ptr ) & L2TP_BEARER_CAP_DIGITAL_MASK ) { ND_PRINT ( ( ndo , \"D\" ) ) ; } }\n", "\n", "3: CWE-125 static void l2tp_framing_type_print ( netdissect_options * ndo , const u_char * dat ) { const uint32_t * ptr = ( const uint32_t * ) dat ; if ( EXTRACT_32BITS ( ptr ) & L2TP_FRAMING_TYPE_ASYNC_MASK ) { ND_PRINT ( ( ndo , \"A\" ) ) ; } if ( EXTRACT_32BITS ( ptr ) & L2TP_FRAMING_TYPE_SYNC_MASK ) { ND_PRINT ( ( ndo , \"S\" ) ) ; } }\n", "\n", "\n", "Target: ; if ( HeapOverflowSanityCheck ( count ,\n", "\n", "Sources:\n", "0: CWE-119 MagickExport void * AcquireQuantumMemory ( const size_t count , const size_t quantum ) { size_t extent ; if ( CheckMemoryOverflow ( count , quantum ) != MagickFalse ) return ( ( void * ) NULL ) ; extent = count * quantum ; return ( AcquireMagickMemory ( extent ) ) ; }\n", "\n", "1: CWE-120 MagickExport void * AcquireAlignedMemory ( const size_t count , const size_t quantum ) { # define AlignedExtent ( size , alignment ) ( ( ( size ) + ( ( alignment ) - 1 ) ) & ~ ( ( alignment ) - 1 ) ) size_t alignment , extent , size ; void * memory ; if ( CheckMemoryOverflow ( count , quantum ) != MagickFalse ) return ( ( void * ) NULL ) ; memory = NULL ; alignment = CACHE_LINE_SIZE ; size = count * quantum ; extent = AlignedExtent ( size , alignment ) ; if ( ( size == 0 ) || ( alignment < sizeof ( void * ) ) || ( extent < size ) ) return ( ( void * ) NULL ) ; # if defined ( MAGICKCORE_HAVE_POSIX_MEMALIGN ) if ( posix_memalign ( & memory , alignment , extent ) != 0 ) memory = NULL ; # elif defined ( MAGICKCORE_HAVE__ALIGNED_MALLOC ) memory = _aligned_malloc ( extent , alignment ) ; # else { void * p ; extent = ( size + alignment - 1 ) + sizeof ( void * ) ; if ( extent > size ) { p = malloc ( extent ) ; if ( p != NULL ) { memory = ( void * ) AlignedExtent ( ( size_t ) p + sizeof ( void * ) , alignment ) ; * ( ( void * * ) memory - 1 ) = p ; } } } # endif return ( memory ) ; }\n", "\n", "2: CWE-119 MagickExport void * AcquireAlignedMemory ( const size_t count , const size_t quantum ) { # define AlignedExtent ( size , alignment ) ( ( ( size ) + ( ( alignment ) - 1 ) ) & ~ ( ( alignment ) - 1 ) ) size_t alignment , extent , size ; void * memory ; if ( CheckMemoryOverflow ( count , quantum ) != MagickFalse ) return ( ( void * ) NULL ) ; memory = NULL ; alignment = CACHE_LINE_SIZE ; size = count * quantum ; extent = AlignedExtent ( size , alignment ) ; if ( ( size == 0 ) || ( alignment < sizeof ( void * ) ) || ( extent < size ) ) return ( ( void * ) NULL ) ; # if defined ( MAGICKCORE_HAVE_POSIX_MEMALIGN ) if ( posix_memalign ( & memory , alignment , extent ) != 0 ) memory = NULL ; # elif defined ( MAGICKCORE_HAVE__ALIGNED_MALLOC ) memory = _aligned_malloc ( extent , alignment ) ; # else { void * p ; extent = ( size + alignment - 1 ) + sizeof ( void * ) ; if ( extent > size ) { p = malloc ( extent ) ; if ( p != NULL ) { memory = ( void * ) AlignedExtent ( ( size_t ) p + sizeof ( void * ) , alignment ) ; * ( ( void * * ) memory - 1 ) = p ; } } } # endif return ( memory ) ; }\n", "\n", "\n", "Target: tp ) ; xfs_iunlock ( ip , XFS_ILOCK_EXCL ) ;\n", "\n", "Sources:\n", "0: CWE-400 int xfs_setattr_nonsize ( struct xfs_inode * ip , struct iattr * iattr , int flags ) { xfs_mount_t * mp = ip -> i_mount ; struct inode * inode = VFS_I ( ip ) ; int mask = iattr -> ia_valid ; xfs_trans_t * tp ; int error ; kuid_t uid = GLOBAL_ROOT_UID , iuid = GLOBAL_ROOT_UID ; kgid_t gid = GLOBAL_ROOT_GID , igid = GLOBAL_ROOT_GID ; struct xfs_dquot * udqp = NULL , * gdqp = NULL ; struct xfs_dquot * olddquot1 = NULL , * olddquot2 = NULL ; ASSERT ( ( mask & ATTR_SIZE ) == 0 ) ; if ( XFS_IS_QUOTA_ON ( mp ) && ( mask & ( ATTR_UID | ATTR_GID ) ) ) { uint qflags = 0 ; if ( ( mask & ATTR_UID ) && XFS_IS_UQUOTA_ON ( mp ) ) { uid = iattr -> ia_uid ; qflags |= XFS_QMOPT_UQUOTA ; } else { uid = inode -> i_uid ; } if ( ( mask & ATTR_GID ) && XFS_IS_GQUOTA_ON ( mp ) ) { gid = iattr -> ia_gid ; qflags |= XFS_QMOPT_GQUOTA ; } else { gid = inode -> i_gid ; } ASSERT ( udqp == NULL ) ; ASSERT ( gdqp == NULL ) ; error = xfs_qm_vop_dqalloc ( ip , xfs_kuid_to_uid ( uid ) , xfs_kgid_to_gid ( gid ) , xfs_get_projid ( ip ) , qflags , & udqp , & gdqp , NULL ) ; if ( error ) return error ; } error = xfs_trans_alloc ( mp , & M_RES ( mp ) -> tr_ichange , 0 , 0 , 0 , & tp ) ; if ( error ) goto out_dqrele ; xfs_ilock ( ip , XFS_ILOCK_EXCL ) ; xfs_trans_ijoin ( tp , ip , 0 ) ; if ( mask & ( ATTR_UID | ATTR_GID ) ) { iuid = inode -> i_uid ; igid = inode -> i_gid ; gid = ( mask & ATTR_GID ) ? iattr -> ia_gid : igid ; uid = ( mask & ATTR_UID ) ? iattr -> ia_uid : iuid ; if ( XFS_IS_QUOTA_RUNNING ( mp ) && ( ( XFS_IS_UQUOTA_ON ( mp ) && ! uid_eq ( iuid , uid ) ) || ( XFS_IS_GQUOTA_ON ( mp ) && ! gid_eq ( igid , gid ) ) ) ) { ASSERT ( tp ) ; error = xfs_qm_vop_chown_reserve ( tp , ip , udqp , gdqp , NULL , capable ( CAP_FOWNER ) ? XFS_QMOPT_FORCE_RES : 0 ) ; if ( error ) goto out_cancel ; } } if ( mask & ( ATTR_UID | ATTR_GID ) ) { if ( ( inode -> i_mode & ( S_ISUID | S_ISGID ) ) && ! capable ( CAP_FSETID ) ) inode -> i_mode &= ~ ( S_ISUID | S_ISGID ) ; if ( ! uid_eq ( iuid , uid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_UQUOTA_ON ( mp ) ) { ASSERT ( mask & ATTR_UID ) ; ASSERT ( udqp ) ; olddquot1 = xfs_qm_vop_chown ( tp , ip , & ip -> i_udquot , udqp ) ; } ip -> i_d . di_uid = xfs_kuid_to_uid ( uid ) ; inode -> i_uid = uid ; } if ( ! gid_eq ( igid , gid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_GQUOTA_ON ( mp ) ) { ASSERT ( xfs_sb_version_has_pquotino ( & mp -> m_sb ) || ! XFS_IS_PQUOTA_ON ( mp ) ) ; ASSERT ( mask & ATTR_GID ) ; ASSERT ( gdqp ) ; olddquot2 = xfs_qm_vop_chown ( tp , ip , & ip -> i_gdquot , gdqp ) ; } ip -> i_d . di_gid = xfs_kgid_to_gid ( gid ) ; inode -> i_gid = gid ; } } if ( mask & ATTR_MODE ) xfs_setattr_mode ( ip , iattr ) ; if ( mask & ( ATTR_ATIME | ATTR_CTIME | ATTR_MTIME ) ) xfs_setattr_time ( ip , iattr ) ; xfs_trans_log_inode ( tp , ip , XFS_ILOG_CORE ) ; XFS_STATS_INC ( mp , xs_ig_attrchg ) ; if ( mp -> m_flags & XFS_MOUNT_WSYNC ) xfs_trans_set_sync ( tp ) ; error = xfs_trans_commit ( tp ) ; xfs_iunlock ( ip , XFS_ILOCK_EXCL ) ; xfs_qm_dqrele ( olddquot1 ) ; xfs_qm_dqrele ( olddquot2 ) ; xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; if ( error ) return error ; if ( ( mask & ATTR_MODE ) && ! ( flags & XFS_ATTR_NOACL ) ) { error = posix_acl_chmod ( inode , inode -> i_mode ) ; if ( error ) return error ; } return 0 ; out_cancel : xfs_trans_cancel ( tp ) ; out_dqrele : xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; return error ; }\n", "\n", "1: CWE-399 int xfs_setattr_nonsize ( struct xfs_inode * ip , struct iattr * iattr , int flags ) { xfs_mount_t * mp = ip -> i_mount ; struct inode * inode = VFS_I ( ip ) ; int mask = iattr -> ia_valid ; xfs_trans_t * tp ; int error ; kuid_t uid = GLOBAL_ROOT_UID , iuid = GLOBAL_ROOT_UID ; kgid_t gid = GLOBAL_ROOT_GID , igid = GLOBAL_ROOT_GID ; struct xfs_dquot * udqp = NULL , * gdqp = NULL ; struct xfs_dquot * olddquot1 = NULL , * olddquot2 = NULL ; ASSERT ( ( mask & ATTR_SIZE ) == 0 ) ; if ( XFS_IS_QUOTA_ON ( mp ) && ( mask & ( ATTR_UID | ATTR_GID ) ) ) { uint qflags = 0 ; if ( ( mask & ATTR_UID ) && XFS_IS_UQUOTA_ON ( mp ) ) { uid = iattr -> ia_uid ; qflags |= XFS_QMOPT_UQUOTA ; } else { uid = inode -> i_uid ; } if ( ( mask & ATTR_GID ) && XFS_IS_GQUOTA_ON ( mp ) ) { gid = iattr -> ia_gid ; qflags |= XFS_QMOPT_GQUOTA ; } else { gid = inode -> i_gid ; } ASSERT ( udqp == NULL ) ; ASSERT ( gdqp == NULL ) ; error = xfs_qm_vop_dqalloc ( ip , xfs_kuid_to_uid ( uid ) , xfs_kgid_to_gid ( gid ) , xfs_get_projid ( ip ) , qflags , & udqp , & gdqp , NULL ) ; if ( error ) return error ; } error = xfs_trans_alloc ( mp , & M_RES ( mp ) -> tr_ichange , 0 , 0 , 0 , & tp ) ; if ( error ) goto out_dqrele ; xfs_ilock ( ip , XFS_ILOCK_EXCL ) ; xfs_trans_ijoin ( tp , ip , 0 ) ; if ( mask & ( ATTR_UID | ATTR_GID ) ) { iuid = inode -> i_uid ; igid = inode -> i_gid ; gid = ( mask & ATTR_GID ) ? iattr -> ia_gid : igid ; uid = ( mask & ATTR_UID ) ? iattr -> ia_uid : iuid ; if ( XFS_IS_QUOTA_RUNNING ( mp ) && ( ( XFS_IS_UQUOTA_ON ( mp ) && ! uid_eq ( iuid , uid ) ) || ( XFS_IS_GQUOTA_ON ( mp ) && ! gid_eq ( igid , gid ) ) ) ) { ASSERT ( tp ) ; error = xfs_qm_vop_chown_reserve ( tp , ip , udqp , gdqp , NULL , capable ( CAP_FOWNER ) ? XFS_QMOPT_FORCE_RES : 0 ) ; if ( error ) goto out_cancel ; } } if ( mask & ( ATTR_UID | ATTR_GID ) ) { if ( ( inode -> i_mode & ( S_ISUID | S_ISGID ) ) && ! capable ( CAP_FSETID ) ) inode -> i_mode &= ~ ( S_ISUID | S_ISGID ) ; if ( ! uid_eq ( iuid , uid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_UQUOTA_ON ( mp ) ) { ASSERT ( mask & ATTR_UID ) ; ASSERT ( udqp ) ; olddquot1 = xfs_qm_vop_chown ( tp , ip , & ip -> i_udquot , udqp ) ; } ip -> i_d . di_uid = xfs_kuid_to_uid ( uid ) ; inode -> i_uid = uid ; } if ( ! gid_eq ( igid , gid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_GQUOTA_ON ( mp ) ) { ASSERT ( xfs_sb_version_has_pquotino ( & mp -> m_sb ) || ! XFS_IS_PQUOTA_ON ( mp ) ) ; ASSERT ( mask & ATTR_GID ) ; ASSERT ( gdqp ) ; olddquot2 = xfs_qm_vop_chown ( tp , ip , & ip -> i_gdquot , gdqp ) ; } ip -> i_d . di_gid = xfs_kgid_to_gid ( gid ) ; inode -> i_gid = gid ; } } if ( mask & ATTR_MODE ) xfs_setattr_mode ( ip , iattr ) ; if ( mask & ( ATTR_ATIME | ATTR_CTIME | ATTR_MTIME ) ) xfs_setattr_time ( ip , iattr ) ; xfs_trans_log_inode ( tp , ip , XFS_ILOG_CORE ) ; XFS_STATS_INC ( mp , xs_ig_attrchg ) ; if ( mp -> m_flags & XFS_MOUNT_WSYNC ) xfs_trans_set_sync ( tp ) ; error = xfs_trans_commit ( tp ) ; xfs_iunlock ( ip , XFS_ILOCK_EXCL ) ; xfs_qm_dqrele ( olddquot1 ) ; xfs_qm_dqrele ( olddquot2 ) ; xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; if ( error ) return error ; if ( ( mask & ATTR_MODE ) && ! ( flags & XFS_ATTR_NOACL ) ) { error = posix_acl_chmod ( inode , inode -> i_mode ) ; if ( error ) return error ; } return 0 ; out_cancel : xfs_trans_cancel ( tp ) ; out_dqrele : xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; return error ; }\n", "\n", "\n", "Target: 0 ; # else ( void ) mb_idx ; # = 1 ; memset ( xd -> = 1 ; memset ( xd -> . mb_skip_coeff ) memset ( xd -> dst_stride ) ; memset ( b -> qcoeff ) ; memset ( b -> qcoeff ) ; memset ( b ->\n", "\n", "Sources:\n", "0: CWE-119 static void mt_decode_macroblock ( VP8D_COMP * pbi , MACROBLOCKD * xd , unsigned int mb_idx ) { MB_PREDICTION_MODE mode ; int i ; # if CONFIG_ERROR_CONCEALMENT int corruption_detected = 0 ; # endif if ( xd -> mode_info_context -> mbmi . mb_skip_coeff ) { vp8_reset_mb_tokens_context ( xd ) ; } else if ( ! vp8dx_bool_error ( xd -> current_bc ) ) { int eobtotal ; eobtotal = vp8_decode_mb_tokens ( pbi , xd ) ; xd -> mode_info_context -> mbmi . mb_skip_coeff = ( eobtotal == 0 ) ; } mode = xd -> mode_info_context -> mbmi . mode ; if ( xd -> segmentation_enabled ) vp8_mb_init_dequantizer ( pbi , xd ) ; # if CONFIG_ERROR_CONCEALMENT if ( pbi -> ec_active ) { int throw_residual ; throw_residual = ( ! pbi -> independent_partitions && pbi -> frame_corrupt_residual ) ; throw_residual = ( throw_residual || vp8dx_bool_error ( xd -> current_bc ) ) ; if ( ( mb_idx >= pbi -> mvs_corrupt_from_mb || throw_residual ) ) { pbi -> frame_corrupt_residual = 1 ; vpx_memset ( xd -> qcoeff , 0 , sizeof ( xd -> qcoeff ) ) ; vp8_conceal_corrupt_mb ( xd ) ; corruption_detected = 1 ; vpx_memset ( xd -> eobs , 0 , 25 ) ; } } # endif if ( xd -> mode_info_context -> mbmi . ref_frame == INTRA_FRAME ) { vp8_build_intra_predictors_mbuv_s ( xd , xd -> recon_above [ 1 ] , xd -> recon_above [ 2 ] , xd -> recon_left [ 1 ] , xd -> recon_left [ 2 ] , xd -> recon_left_stride [ 1 ] , xd -> dst . u_buffer , xd -> dst . v_buffer , xd -> dst . uv_stride ) ; if ( mode != B_PRED ) { vp8_build_intra_predictors_mby_s ( xd , xd -> recon_above [ 0 ] , xd -> recon_left [ 0 ] , xd -> recon_left_stride [ 0 ] , xd -> dst . y_buffer , xd -> dst . y_stride ) ; } else { short * DQC = xd -> dequant_y1 ; int dst_stride = xd -> dst . y_stride ; if ( xd -> mode_info_context -> mbmi . mb_skip_coeff ) vpx_memset ( xd -> eobs , 0 , 25 ) ; intra_prediction_down_copy ( xd , xd -> recon_above [ 0 ] + 16 ) ; for ( i = 0 ; i < 16 ; i ++ ) { BLOCKD * b = & xd -> block [ i ] ; unsigned char * dst = xd -> dst . y_buffer + b -> offset ; B_PREDICTION_MODE b_mode = xd -> mode_info_context -> bmi [ i ] . as_mode ; unsigned char * Above ; unsigned char * yleft ; int left_stride ; unsigned char top_left ; if ( i < 4 && pbi -> common . filter_level ) Above = xd -> recon_above [ 0 ] + b -> offset ; else Above = dst - dst_stride ; if ( i % 4 == 0 && pbi -> common . filter_level ) { yleft = xd -> recon_left [ 0 ] + i ; left_stride = 1 ; } else { yleft = dst - 1 ; left_stride = dst_stride ; } if ( ( i == 4 || i == 8 || i == 12 ) && pbi -> common . filter_level ) top_left = * ( xd -> recon_left [ 0 ] + i - 1 ) ; else top_left = Above [ - 1 ] ; vp8_intra4x4_predict ( Above , yleft , left_stride , b_mode , dst , dst_stride , top_left ) ; if ( xd -> eobs [ i ] ) { if ( xd -> eobs [ i ] > 1 ) { vp8_dequant_idct_add ( b -> qcoeff , DQC , dst , dst_stride ) ; } else { vp8_dc_only_idct_add ( b -> qcoeff [ 0 ] * DQC [ 0 ] , dst , dst_stride , dst , dst_stride ) ; vpx_memset ( b -> qcoeff , 0 , 2 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } } } } } else { vp8_build_inter_predictors_mb ( xd ) ; } # if CONFIG_ERROR_CONCEALMENT if ( corruption_detected ) { return ; } # endif if ( ! xd -> mode_info_context -> mbmi . mb_skip_coeff ) { if ( mode != B_PRED ) { short * DQC = xd -> dequant_y1 ; if ( mode != SPLITMV ) { BLOCKD * b = & xd -> block [ 24 ] ; if ( xd -> eobs [ 24 ] > 1 ) { vp8_dequantize_b ( b , xd -> dequant_y2 ) ; vp8_short_inv_walsh4x4 ( & b -> dqcoeff [ 0 ] , xd -> qcoeff ) ; vpx_memset ( b -> qcoeff , 0 , 16 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } else { b -> dqcoeff [ 0 ] = b -> qcoeff [ 0 ] * xd -> dequant_y2 [ 0 ] ; vp8_short_inv_walsh4x4_1 ( & b -> dqcoeff [ 0 ] , xd -> qcoeff ) ; vpx_memset ( b -> qcoeff , 0 , 2 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } DQC = xd -> dequant_y1_dc ; } vp8_dequant_idct_add_y_block ( xd -> qcoeff , DQC , xd -> dst . y_buffer , xd -> dst . y_stride , xd -> eobs ) ; } vp8_dequant_idct_add_uv_block ( xd -> qcoeff + 16 * 16 , xd -> dequant_uv , xd -> dst . u_buffer , xd -> dst . v_buffer , xd -> dst . uv_stride , xd -> eobs + 16 ) ; } }\n", "\n", "1: CWE-119 static void decode_macroblock ( VP8D_COMP * pbi , MACROBLOCKD * xd , unsigned int mb_idx ) { MB_PREDICTION_MODE mode ; int i ; # if CONFIG_ERROR_CONCEALMENT int corruption_detected = 0 ; # endif if ( xd -> mode_info_context -> mbmi . mb_skip_coeff ) { vp8_reset_mb_tokens_context ( xd ) ; } else if ( ! vp8dx_bool_error ( xd -> current_bc ) ) { int eobtotal ; eobtotal = vp8_decode_mb_tokens ( pbi , xd ) ; xd -> mode_info_context -> mbmi . mb_skip_coeff = ( eobtotal == 0 ) ; } mode = xd -> mode_info_context -> mbmi . mode ; if ( xd -> segmentation_enabled ) vp8_mb_init_dequantizer ( pbi , xd ) ; # if CONFIG_ERROR_CONCEALMENT if ( pbi -> ec_active ) { int throw_residual ; throw_residual = ( ! pbi -> independent_partitions && pbi -> frame_corrupt_residual ) ; throw_residual = ( throw_residual || vp8dx_bool_error ( xd -> current_bc ) ) ; if ( ( mb_idx >= pbi -> mvs_corrupt_from_mb || throw_residual ) ) { pbi -> frame_corrupt_residual = 1 ; vpx_memset ( xd -> qcoeff , 0 , sizeof ( xd -> qcoeff ) ) ; vp8_conceal_corrupt_mb ( xd ) ; corruption_detected = 1 ; vpx_memset ( xd -> eobs , 0 , 25 ) ; } } # endif if ( xd -> mode_info_context -> mbmi . ref_frame == INTRA_FRAME ) { vp8_build_intra_predictors_mbuv_s ( xd , xd -> recon_above [ 1 ] , xd -> recon_above [ 2 ] , xd -> recon_left [ 1 ] , xd -> recon_left [ 2 ] , xd -> recon_left_stride [ 1 ] , xd -> dst . u_buffer , xd -> dst . v_buffer , xd -> dst . uv_stride ) ; if ( mode != B_PRED ) { vp8_build_intra_predictors_mby_s ( xd , xd -> recon_above [ 0 ] , xd -> recon_left [ 0 ] , xd -> recon_left_stride [ 0 ] , xd -> dst . y_buffer , xd -> dst . y_stride ) ; } else { short * DQC = xd -> dequant_y1 ; int dst_stride = xd -> dst . y_stride ; if ( xd -> mode_info_context -> mbmi . mb_skip_coeff ) vpx_memset ( xd -> eobs , 0 , 25 ) ; intra_prediction_down_copy ( xd , xd -> recon_above [ 0 ] + 16 ) ; for ( i = 0 ; i < 16 ; i ++ ) { BLOCKD * b = & xd -> block [ i ] ; unsigned char * dst = xd -> dst . y_buffer + b -> offset ; B_PREDICTION_MODE b_mode = xd -> mode_info_context -> bmi [ i ] . as_mode ; unsigned char * Above = dst - dst_stride ; unsigned char * yleft = dst - 1 ; int left_stride = dst_stride ; unsigned char top_left = Above [ - 1 ] ; vp8_intra4x4_predict ( Above , yleft , left_stride , b_mode , dst , dst_stride , top_left ) ; if ( xd -> eobs [ i ] ) { if ( xd -> eobs [ i ] > 1 ) { vp8_dequant_idct_add ( b -> qcoeff , DQC , dst , dst_stride ) ; } else { vp8_dc_only_idct_add ( b -> qcoeff [ 0 ] * DQC [ 0 ] , dst , dst_stride , dst , dst_stride ) ; vpx_memset ( b -> qcoeff , 0 , 2 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } } } } } else { vp8_build_inter_predictors_mb ( xd ) ; } # if CONFIG_ERROR_CONCEALMENT if ( corruption_detected ) { return ; } # endif if ( ! xd -> mode_info_context -> mbmi . mb_skip_coeff ) { if ( mode != B_PRED ) { short * DQC = xd -> dequant_y1 ; if ( mode != SPLITMV ) { BLOCKD * b = & xd -> block [ 24 ] ; if ( xd -> eobs [ 24 ] > 1 ) { vp8_dequantize_b ( b , xd -> dequant_y2 ) ; vp8_short_inv_walsh4x4 ( & b -> dqcoeff [ 0 ] , xd -> qcoeff ) ; vpx_memset ( b -> qcoeff , 0 , 16 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } else { b -> dqcoeff [ 0 ] = b -> qcoeff [ 0 ] * xd -> dequant_y2 [ 0 ] ; vp8_short_inv_walsh4x4_1 ( & b -> dqcoeff [ 0 ] , xd -> qcoeff ) ; vpx_memset ( b -> qcoeff , 0 , 2 * sizeof ( b -> qcoeff [ 0 ] ) ) ; } DQC = xd -> dequant_y1_dc ; } vp8_dequant_idct_add_y_block ( xd -> qcoeff , DQC , xd -> dst . y_buffer , xd -> dst . y_stride , xd -> eobs ) ; } vp8_dequant_idct_add_uv_block ( xd -> qcoeff + 16 * 16 , xd -> dequant_uv , xd -> dst . u_buffer , xd -> dst . v_buffer , xd -> dst . uv_stride , xd -> eobs + 16 ) ; } }\n", "\n", "\n", "Target: ; if ( kvm_set_msr ( & svm\n", "\n", "Sources:\n", "0: CWE-264 static int wrmsr_interception ( struct vcpu_svm * svm ) { struct msr_data msr ; u32 ecx = svm -> vcpu . arch . regs [ VCPU_REGS_RCX ] ; u64 data = ( svm -> vcpu . arch . regs [ VCPU_REGS_RAX ] & - 1u ) | ( ( u64 ) ( svm -> vcpu . arch . regs [ VCPU_REGS_RDX ] & - 1u ) << 32 ) ; msr . data = data ; msr . index = ecx ; msr . host_initiated = false ; svm -> next_rip = kvm_rip_read ( & svm -> vcpu ) + 2 ; if ( svm_set_msr ( & svm -> vcpu , & msr ) ) { trace_kvm_msr_write_ex ( ecx , data ) ; kvm_inject_gp ( & svm -> vcpu , 0 ) ; } else { trace_kvm_msr_write ( ecx , data ) ; skip_emulated_instruction ( & svm -> vcpu ) ; } return 1 ; }\n", "\n", "1: CWE-000 static int wrmsr_interception ( struct vcpu_svm * svm ) { struct msr_data msr ; u32 ecx = svm -> vcpu . arch . regs [ VCPU_REGS_RCX ] ; u64 data = ( svm -> vcpu . arch . regs [ VCPU_REGS_RAX ] & - 1u ) | ( ( u64 ) ( svm -> vcpu . arch . regs [ VCPU_REGS_RDX ] & - 1u ) << 32 ) ; msr . data = data ; msr . index = ecx ; msr . host_initiated = false ; svm -> next_rip = kvm_rip_read ( & svm -> vcpu ) + 2 ; if ( svm_set_msr ( & svm -> vcpu , & msr ) ) { trace_kvm_msr_write_ex ( ecx , data ) ; kvm_inject_gp ( & svm -> vcpu , 0 ) ; } else { trace_kvm_msr_write ( ecx , data ) ; skip_emulated_instruction ( & svm -> vcpu ) ; } return 1 ; }\n", "\n", "\n", "Target: { return SECURE_ELEMENT_ERROR_NPE ; } if ( encJoinAcceptSize > LORAMAC_JOIN_ACCEPT_FRAME_MAX_SIZE ) { return SECURE_ELEMENT_ERROR_BUF_SIZE\n", "\n", "Sources:\n", "0: CWE-120 SecureElementStatus_t SecureElementProcessJoinAccept ( JoinReqIdentifier_t joinReqType , uint8_t * joinEui , uint16_t devNonce , uint8_t * encJoinAccept , uint8_t encJoinAcceptSize , uint8_t * decJoinAccept , uint8_t * versionMinor ) { SecureElementStatus_t status = SECURE_ELEMENT_ERROR ; if ( ( encJoinAccept == NULL ) || ( decJoinAccept == NULL ) || ( versionMinor == NULL ) ) { return SECURE_ELEMENT_ERROR_NPE ; } KeyIdentifier_t encKeyID = NWK_KEY ; if ( joinReqType != JOIN_REQ ) { encKeyID = J_S_ENC_KEY ; } uint8_t micHeader10 [ 1 ] = { 0x20 } ; lr1110_crypto_process_join_accept ( & LR1110 , ( lr1110_crypto_status_t * ) & status , convert_key_id_from_se_to_lr1110 ( encKeyID ) , convert_key_id_from_se_to_lr1110 ( NWK_KEY ) , ( lr1110_crypto_lorawan_version_t ) 0 , micHeader10 , encJoinAccept + 1 , encJoinAcceptSize - 1 , decJoinAccept + 1 ) ; if ( status == SECURE_ELEMENT_SUCCESS ) { * versionMinor = ( ( decJoinAccept [ 11 ] & 0x80 ) == 0x80 ) ? 1 : 0 ; if ( * versionMinor == 0 ) { return SECURE_ELEMENT_SUCCESS ; } } # if ( USE_LRWAN_1_1_X_CRYPTO == 1 ) uint8_t micHeader11 [ JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ] = { 0 } ; uint16_t bufItr = 0 ; micHeader11 [ bufItr ++ ] = ( uint8_t ) joinReqType ; memcpyr ( micHeader11 + bufItr , joinEui , LORAMAC_JOIN_EUI_FIELD_SIZE ) ; bufItr += LORAMAC_JOIN_EUI_FIELD_SIZE ; micHeader11 [ bufItr ++ ] = devNonce & 0xFF ; micHeader11 [ bufItr ++ ] = ( devNonce >> 8 ) & 0xFF ; micHeader11 [ bufItr ++ ] = 0x20 ; lr1110_crypto_process_join_accept ( & LR1110 , ( lr1110_crypto_status_t * ) & status , convert_key_id_from_se_to_lr1110 ( encKeyID ) , convert_key_id_from_se_to_lr1110 ( J_S_INT_KEY ) , ( lr1110_crypto_lorawan_version_t ) 1 , micHeader11 , encJoinAccept + 1 , encJoinAcceptSize - 1 , decJoinAccept + 1 ) ; if ( status == SECURE_ELEMENT_SUCCESS ) { * versionMinor = ( ( decJoinAccept [ 11 ] & 0x80 ) == 0x80 ) ? 1 : 0 ; if ( * versionMinor == 1 ) { return SECURE_ELEMENT_SUCCESS ; } } # endif return status ; }\n", "\n", "1: CWE-120 SecureElementStatus_t SecureElementProcessJoinAccept ( JoinReqIdentifier_t joinReqType , uint8_t * joinEui , uint16_t devNonce , uint8_t * encJoinAccept , uint8_t encJoinAcceptSize , uint8_t * decJoinAccept , uint8_t * versionMinor ) { if ( ( encJoinAccept == NULL ) || ( decJoinAccept == NULL ) || ( versionMinor == NULL ) ) { return SECURE_ELEMENT_ERROR_NPE ; } KeyIdentifier_t encKeyID = NWK_KEY ; if ( joinReqType != JOIN_REQ ) { encKeyID = J_S_ENC_KEY ; } memcpy1 ( decJoinAccept , encJoinAccept , encJoinAcceptSize ) ; if ( SecureElementAesEncrypt ( encJoinAccept + LORAMAC_MHDR_FIELD_SIZE , encJoinAcceptSize - LORAMAC_MHDR_FIELD_SIZE , encKeyID , decJoinAccept + LORAMAC_MHDR_FIELD_SIZE ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_ENCRYPT ; } * versionMinor = ( ( decJoinAccept [ 11 ] & 0x80 ) == 0x80 ) ? 1 : 0 ; uint32_t mic = 0 ; mic = ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE ] << 0 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 1 ] << 8 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 2 ] << 16 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 3 ] << 24 ) ; if ( * versionMinor == 0 ) { if ( SecureElementVerifyAesCmac ( decJoinAccept , ( encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE ) , mic , NWK_KEY ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_CMAC ; } } # if ( USE_LRWAN_1_1_X_CRYPTO == 1 ) else if ( * versionMinor == 1 ) { uint8_t micHeader11 [ JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ] = { 0 } ; uint16_t bufItr = 0 ; micHeader11 [ bufItr ++ ] = ( uint8_t ) joinReqType ; memcpyr ( micHeader11 + bufItr , joinEui , LORAMAC_JOIN_EUI_FIELD_SIZE ) ; bufItr += LORAMAC_JOIN_EUI_FIELD_SIZE ; micHeader11 [ bufItr ++ ] = devNonce & 0xFF ; micHeader11 [ bufItr ++ ] = ( devNonce >> 8 ) & 0xFF ; uint8_t localBuffer [ LORAMAC_JOIN_ACCEPT_FRAME_MAX_SIZE + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ] = { 0 } ; memcpy1 ( localBuffer , micHeader11 , JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ) ; memcpy1 ( localBuffer + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET - 1 , decJoinAccept , encJoinAcceptSize ) ; if ( SecureElementVerifyAesCmac ( localBuffer , encJoinAcceptSize + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET - LORAMAC_MHDR_FIELD_SIZE - LORAMAC_MIC_FIELD_SIZE , mic , J_S_INT_KEY ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_CMAC ; } } # endif else { return SECURE_ELEMENT_ERROR_INVALID_LORAWAM_SPEC_VERSION ; } return SECURE_ELEMENT_SUCCESS ; }\n", "\n", "\n", "Target: ; # else ( void ) flags ;\n", "\n", "Sources:\n", "0: CWE-119 int vp8dx_get_raw_frame ( VP8D_COMP * pbi , YV12_BUFFER_CONFIG * sd , int64_t * time_stamp , int64_t * time_end_stamp , vp8_ppflags_t * flags ) { int ret = - 1 ; if ( pbi -> ready_for_new_data == 1 ) return ret ; if ( pbi -> common . show_frame == 0 ) return ret ; pbi -> ready_for_new_data = 1 ; * time_stamp = pbi -> last_time_stamp ; * time_end_stamp = 0 ; # if CONFIG_POSTPROC ret = vp8_post_proc_frame ( & pbi -> common , sd , flags ) ; # else if ( pbi -> common . frame_to_show ) { * sd = * pbi -> common . frame_to_show ; sd -> y_width = pbi -> common . Width ; sd -> y_height = pbi -> common . Height ; sd -> uv_height = pbi -> common . Height / 2 ; ret = 0 ; } else { ret = - 1 ; } # endif vp8_clear_system_state ( ) ; return ret ; }\n", "\n", "1: CWE-119 int vp8_get_preview_raw_frame ( VP8_COMP * cpi , YV12_BUFFER_CONFIG * dest , vp8_ppflags_t * flags ) { if ( cpi -> common . refresh_alt_ref_frame ) return - 1 ; else { int ret ; # if CONFIG_MULTITHREAD if ( cpi -> b_lpf_running ) { sem_wait ( & cpi -> h_event_end_lpf ) ; cpi -> b_lpf_running = 0 ; } # endif # if CONFIG_POSTPROC cpi -> common . show_frame_mi = cpi -> common . mi ; ret = vp8_post_proc_frame ( & cpi -> common , dest , flags ) ; # else if ( cpi -> common . frame_to_show ) { * dest = * cpi -> common . frame_to_show ; dest -> y_width = cpi -> common . Width ; dest -> y_height = cpi -> common . Height ; dest -> uv_height = cpi -> common . Height / 2 ; ret = 0 ; } else { ret = - 1 ; } # endif vp8_clear_system_state ( ) ; return ret ; } }\n", "\n", "\n", "Target: ) AcquireQuantumMemory ( MagickMax ( number_pixels , max_packets ) , bytes_per_pixel * sizeof\n", "\n", "Sources:\n", "0: CWE-125 static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo { unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ; char comment [ 512 ] ; unsigned int rows , columns , subrows ; int x_offset , y_offset ; float x_bits_per_pixel , y_bits_per_pixel ; unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ; } ViffInfo ; double min_value , scale_factor , value ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_pixel , max_packets , quantum ; ssize_t count , y ; unsigned char * pixels ; unsigned long lsb_first ; ViffInfo viff_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & viff_info . identifier ) ; do { if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , \"NotAVIFFImage\" ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ; count = ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ; viff_info . comment [ 511 ] = '\\\\0' ; if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , \"comment\" , viff_info . comment , exception ) ; if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ; else image -> endian = MSBEndian ; viff_info . rows = ReadBlobLong ( image ) ; viff_info . columns = ReadBlobLong ( image ) ; viff_info . subrows = ReadBlobLong ( image ) ; viff_info . x_offset = ( int ) ReadBlobLong ( image ) ; viff_info . y_offset = ( int ) ReadBlobLong ( image ) ; viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . location_type = ReadBlobLong ( image ) ; viff_info . location_dimension = ReadBlobLong ( image ) ; viff_info . number_of_images = ReadBlobLong ( image ) ; viff_info . number_data_bands = ReadBlobLong ( image ) ; viff_info . data_storage_type = ReadBlobLong ( image ) ; viff_info . data_encode_scheme = ReadBlobLong ( image ) ; viff_info . map_scheme = ReadBlobLong ( image ) ; viff_info . map_storage_type = ReadBlobLong ( image ) ; viff_info . map_rows = ReadBlobLong ( image ) ; viff_info . map_columns = ReadBlobLong ( image ) ; viff_info . map_subrows = ReadBlobLong ( image ) ; viff_info . map_enable = ReadBlobLong ( image ) ; viff_info . maps_per_cycle = ReadBlobLong ( image ) ; viff_info . color_space_model = ReadBlobLong ( image ) ; for ( i = 0 ; i < 420 ; i ++ ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ; number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ; if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( number_pixels == 0 ) ThrowReaderException ( CoderError , \"ImageColumnOrRowSizeIsNotSupported\" ) ; if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"DataStorageTypeIsNotSupported\" ) ; if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"MapStorageTypeIsNotSupported\" ) ; if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , \"ColorspaceModelIsNotSupported\" ) ; if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , \"LocationTypeIsNotSupported\" ) ; if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , \"NumberOfImagesIsNotSupported\" ) ; if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ; switch ( ( int ) viff_info . map_scheme ) { case VFF_MS_NONE : { if ( viff_info . number_data_bands < 3 ) { if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ; else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ; else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ; status = AcquireImageColormap ( image , image -> colors , exception ) ; if ( status == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : { unsigned char * viff_colormap ; switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ; break ; case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } image -> colors = viff_info . map_columns ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ; if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : { MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : { MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } default : break ; } for ( i = 0 ; i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ; i ++ ) { switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ; break ; default : value = 1.0 * viff_colormap [ i ] ; break ; } if ( i < ( ssize_t ) image -> colors ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ; break ; } default : ThrowReaderException ( CoderError , \"ColormapTypeNotSupported\" ) ; } image -> alpha_trait = viff_info . number_data_bands == 4 ? BlendPixelTrait : UndefinedPixelTrait ; image -> storage_class = ( viff_info . number_data_bands < 3 ? PseudoClass : DirectClass ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_TYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } if ( viff_info . data_storage_type == VFF_TYP_BIT ) max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ; else max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( max_packets , bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : { MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ; break ; } case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : { MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ; break ; } default : break ; } min_value = 0.0 ; scale_factor = 1.0 ; if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) { double max_value ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ; break ; default : value = 1.0 * pixels [ 0 ] ; break ; } max_value = value ; min_value = value ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( value > max_value ) max_value = value ; else if ( value < min_value ) min_value = value ; } if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ; else if ( min_value == max_value ) { scale_factor = ( double ) QuantumRange / min_value ; min_value = 0 ; } else scale_factor = ( double ) QuantumRange / ( max_value - min_value ) ; } p = ( unsigned char * ) pixels ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( viff_info . map_scheme == VFF_MS_NONE ) { value = ( value - min_value ) * scale_factor ; if ( value > QuantumRange ) value = QuantumRange ; else if ( value < 0 ) value = 0 ; } * p = ( unsigned char ) ( ( Quantum ) value ) ; p ++ ; } p = ( unsigned char * ) pixels ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( int ) ( image -> columns % 8 ) ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else if ( image -> storage_class == PseudoClass ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else { number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * ( p + number_pixels ) ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) , q ) ; if ( image -> colors != 0 ) { ssize_t index ; index = ( ssize_t ) GetPixelRed ( image , q ) ; SetPixelRed ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . red , q ) ; index = ( ssize_t ) GetPixelGreen ( image , q ) ; SetPixelGreen ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . green , q ) ; index = ( ssize_t ) GetPixelBlue ( image , q ) ; SetPixelBlue ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . blue , q ) ; } SetPixelAlpha ( image , image -> alpha_trait != UndefinedPixelTrait ? ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueAlpha , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; count = ReadBlob ( image , 1 , & viff_info . identifier ) ; if ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-125 static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo { unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ; char comment [ 512 ] ; unsigned int rows , columns , subrows ; int x_offset , y_offset ; float x_bits_per_pixel , y_bits_per_pixel ; unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ; } ViffInfo ; double min_value , scale_factor , value ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register IndexPacket * indexes ; register ssize_t x ; register PixelPacket * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_pixel , max_packets , quantum ; ssize_t count , y ; unsigned char * pixels ; unsigned long lsb_first ; ViffInfo viff_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & viff_info . identifier ) ; do { if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , \"NotAVIFFImage\" ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ; ( void ) ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ; viff_info . comment [ 511 ] = '\\\\0' ; if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , \"comment\" , viff_info . comment ) ; if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ; else image -> endian = MSBEndian ; viff_info . rows = ReadBlobLong ( image ) ; viff_info . columns = ReadBlobLong ( image ) ; viff_info . subrows = ReadBlobLong ( image ) ; viff_info . x_offset = ( int ) ReadBlobLong ( image ) ; viff_info . y_offset = ( int ) ReadBlobLong ( image ) ; viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . location_type = ReadBlobLong ( image ) ; viff_info . location_dimension = ReadBlobLong ( image ) ; viff_info . number_of_images = ReadBlobLong ( image ) ; viff_info . number_data_bands = ReadBlobLong ( image ) ; viff_info . data_storage_type = ReadBlobLong ( image ) ; viff_info . data_encode_scheme = ReadBlobLong ( image ) ; viff_info . map_scheme = ReadBlobLong ( image ) ; viff_info . map_storage_type = ReadBlobLong ( image ) ; viff_info . map_rows = ReadBlobLong ( image ) ; viff_info . map_columns = ReadBlobLong ( image ) ; viff_info . map_subrows = ReadBlobLong ( image ) ; viff_info . map_enable = ReadBlobLong ( image ) ; viff_info . maps_per_cycle = ReadBlobLong ( image ) ; viff_info . color_space_model = ReadBlobLong ( image ) ; for ( i = 0 ; i < 420 ; i ++ ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ; number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ; if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( number_pixels == 0 ) ThrowReaderException ( CoderError , \"ImageColumnOrRowSizeIsNotSupported\" ) ; if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"DataStorageTypeIsNotSupported\" ) ; if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"MapStorageTypeIsNotSupported\" ) ; if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , \"ColorspaceModelIsNotSupported\" ) ; if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , \"LocationTypeIsNotSupported\" ) ; if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , \"NumberOfImagesIsNotSupported\" ) ; if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ; switch ( ( int ) viff_info . map_scheme ) { case VFF_MS_NONE : { if ( viff_info . number_data_bands < 3 ) { if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ; else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ; else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : { unsigned char * viff_colormap ; switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ; break ; case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } image -> colors = viff_info . map_columns ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ; if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : { MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : { MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } default : break ; } for ( i = 0 ; i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ; i ++ ) { switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ; break ; default : value = 1.0 * viff_colormap [ i ] ; break ; } if ( i < ( ssize_t ) image -> colors ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ; break ; } default : ThrowReaderException ( CoderError , \"ColormapTypeNotSupported\" ) ; } image -> matte = viff_info . number_data_bands == 4 ? MagickTrue : MagickFalse ; image -> storage_class = ( viff_info . number_data_bands < 3 ? PseudoClass : DirectClass ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_TYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } if ( viff_info . data_storage_type == VFF_TYP_BIT ) max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ; else max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( max_packets , bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : { MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ; break ; } case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : { MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ; break ; } default : break ; } min_value = 0.0 ; scale_factor = 1.0 ; if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) { double max_value ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ; break ; default : value = 1.0 * pixels [ 0 ] ; break ; } max_value = value ; min_value = value ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( value > max_value ) max_value = value ; else if ( value < min_value ) min_value = value ; } if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ; else if ( min_value == max_value ) { scale_factor = ( MagickRealType ) QuantumRange / min_value ; min_value = 0 ; } else scale_factor = ( MagickRealType ) QuantumRange / ( max_value - min_value ) ; } p = ( unsigned char * ) pixels ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( viff_info . map_scheme == VFF_MS_NONE ) { value = ( value - min_value ) * scale_factor ; if ( value > QuantumRange ) value = QuantumRange ; else if ( value < 0 ) value = 0 ; } * p = ( unsigned char ) ( ( Quantum ) value ) ; p ++ ; } p = ( unsigned char * ) pixels ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { if ( image -> storage_class != PseudoClass ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( q , quantum == 0 ? 0 : QuantumRange ) ; SetPixelGreen ( q , quantum == 0 ? 0 : QuantumRange ) ; SetPixelBlue ( q , quantum == 0 ? 0 : QuantumRange ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( indexes + x + bit , quantum ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( int ) ( image -> columns % 8 ) ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( q , quantum == 0 ? 0 : QuantumRange ) ; SetPixelGreen ( q , quantum == 0 ? 0 : QuantumRange ) ; SetPixelBlue ( q , quantum == 0 ? 0 : QuantumRange ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( indexes + x + bit , quantum ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else if ( image -> storage_class == PseudoClass ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) SetPixelIndex ( indexes + x , * p ++ ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else { number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( * p ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * ( p + number_pixels ) ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) ) ; if ( image -> colors != 0 ) { ssize_t index ; index = ( ssize_t ) GetPixelRed ( q ) ; SetPixelRed ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . red ) ; index = ( ssize_t ) GetPixelGreen ( q ) ; SetPixelGreen ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . green ) ; index = ( ssize_t ) GetPixelRed ( q ) ; SetPixelBlue ( q , image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , index ) ] . blue ) ; } SetPixelOpacity ( q , image -> matte != MagickFalse ? QuantumRange - ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueOpacity ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; count = ReadBlob ( image , 1 , & viff_info . identifier ) ; if ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs ,\n", "\n", "Sources:\n", "0: CWE-400 int do_mathemu ( struct pt_regs * regs , struct fpustate * f ) { unsigned long pc = regs -> tpc ; unsigned long tstate = regs -> tstate ; u32 insn = 0 ; int type = 0 ; # define TYPE ( ftt , r , ru , b , bu , a , au ) type = ( au << 2 ) | ( a << 0 ) | ( bu << 5 ) | ( b << 3 ) | ( ru << 8 ) | ( r << 6 ) | ( ftt << 9 ) int freg ; static u64 zero [ 2 ] = { 0L , 0L } ; int flags ; FP_DECL_EX ; FP_DECL_S ( SA ) ; FP_DECL_S ( SB ) ; FP_DECL_S ( SR ) ; FP_DECL_D ( DA ) ; FP_DECL_D ( DB ) ; FP_DECL_D ( DR ) ; FP_DECL_Q ( QA ) ; FP_DECL_Q ( QB ) ; FP_DECL_Q ( QR ) ; int IR ; long XR , xfsr ; if ( tstate & TSTATE_PRIV ) die_if_kernel ( \"unfinished/unimplementedFPopfromkernel\" , regs ) ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; if ( test_thread_flag ( TIF_32BIT ) ) pc = ( u32 ) pc ; if ( get_user ( insn , ( u32 __user * ) pc ) != - EFAULT ) { if ( ( insn & 0xc1f80000 ) == 0x81a00000 ) { switch ( ( insn >> 5 ) & 0x1ff ) { case FMOVQ : case FNEGQ : case FABSQ : TYPE ( 3 , 3 , 0 , 3 , 0 , 0 , 0 ) ; break ; case FSQRTQ : TYPE ( 3 , 3 , 1 , 3 , 1 , 0 , 0 ) ; break ; case FADDQ : case FSUBQ : case FMULQ : case FDIVQ : TYPE ( 3 , 3 , 1 , 3 , 1 , 3 , 1 ) ; break ; case FDMULQ : TYPE ( 3 , 3 , 1 , 2 , 1 , 2 , 1 ) ; break ; case FQTOX : TYPE ( 3 , 2 , 0 , 3 , 1 , 0 , 0 ) ; break ; case FXTOQ : TYPE ( 3 , 3 , 1 , 2 , 0 , 0 , 0 ) ; break ; case FQTOS : TYPE ( 3 , 1 , 1 , 3 , 1 , 0 , 0 ) ; break ; case FQTOD : TYPE ( 3 , 2 , 1 , 3 , 1 , 0 , 0 ) ; break ; case FITOQ : TYPE ( 3 , 3 , 1 , 1 , 0 , 0 , 0 ) ; break ; case FSTOQ : TYPE ( 3 , 3 , 1 , 1 , 1 , 0 , 0 ) ; break ; case FDTOQ : TYPE ( 3 , 3 , 1 , 2 , 1 , 0 , 0 ) ; break ; case FQTOI : TYPE ( 3 , 1 , 0 , 3 , 1 , 0 , 0 ) ; break ; case FSQRTS : { unsigned long x = current_thread_info ( ) -> xfsr [ 0 ] ; x = ( x >> 14 ) & 0xf ; TYPE ( x , 1 , 1 , 1 , 1 , 0 , 0 ) ; break ; } case FSQRTD : { unsigned long x = current_thread_info ( ) -> xfsr [ 0 ] ; x = ( x >> 14 ) & 0xf ; TYPE ( x , 2 , 1 , 2 , 1 , 0 , 0 ) ; break ; } case FADDD : case FSUBD : case FMULD : case FDIVD : TYPE ( 2 , 2 , 1 , 2 , 1 , 2 , 1 ) ; break ; case FADDS : case FSUBS : case FMULS : case FDIVS : TYPE ( 2 , 1 , 1 , 1 , 1 , 1 , 1 ) ; break ; case FSMULD : TYPE ( 2 , 2 , 1 , 1 , 1 , 1 , 1 ) ; break ; case FSTOX : TYPE ( 2 , 2 , 0 , 1 , 1 , 0 , 0 ) ; break ; case FDTOX : TYPE ( 2 , 2 , 0 , 2 , 1 , 0 , 0 ) ; break ; case FDTOS : TYPE ( 2 , 1 , 1 , 2 , 1 , 0 , 0 ) ; break ; case FSTOD : TYPE ( 2 , 2 , 1 , 1 , 1 , 0 , 0 ) ; break ; case FSTOI : TYPE ( 2 , 1 , 0 , 1 , 1 , 0 , 0 ) ; break ; case FDTOI : TYPE ( 2 , 1 , 0 , 2 , 1 , 0 , 0 ) ; break ; case FXTOS : TYPE ( 2 , 1 , 1 , 2 , 0 , 0 , 0 ) ; break ; case FXTOD : TYPE ( 2 , 2 , 1 , 2 , 0 , 0 , 0 ) ; break ; # if 0 case FITOS : TYPE ( 2 , 1 , 1 , 1 , 0 , 0 , 0 ) ; break ; # endif case FITOD : TYPE ( 2 , 2 , 1 , 1 , 0 , 0 , 0 ) ; break ; } } else if ( ( insn & 0xc1f80000 ) == 0x81a80000 ) { IR = 2 ; switch ( ( insn >> 5 ) & 0x1ff ) { case FCMPQ : TYPE ( 3 , 0 , 0 , 3 , 1 , 3 , 1 ) ; break ; case FCMPEQ : TYPE ( 3 , 0 , 0 , 3 , 1 , 3 , 1 ) ; break ; case FMOVQ0 : case FMOVQ1 : case FMOVQ2 : case FMOVQ3 : if ( ! ( ( insn >> 11 ) & 3 ) ) XR = current_thread_info ( ) -> xfsr [ 0 ] >> 10 ; else XR = current_thread_info ( ) -> xfsr [ 0 ] >> ( 30 + ( ( insn >> 10 ) & 0x6 ) ) ; XR &= 3 ; IR = 0 ; switch ( ( insn >> 14 ) & 0x7 ) { case 1 : if ( XR ) IR = 1 ; break ; case 2 : if ( XR == 1 || XR == 2 ) IR = 1 ; break ; case 3 : if ( XR & 1 ) IR = 1 ; break ; case 4 : if ( XR == 1 ) IR = 1 ; break ; case 5 : if ( XR & 2 ) IR = 1 ; break ; case 6 : if ( XR == 2 ) IR = 1 ; break ; case 7 : if ( XR == 3 ) IR = 1 ; break ; } if ( ( insn >> 14 ) & 8 ) IR ^= 1 ; break ; case FMOVQI : case FMOVQX : XR = regs -> tstate >> 32 ; if ( ( insn >> 5 ) & 0x80 ) XR >>= 4 ; XR &= 0xf ; IR = 0 ; freg = ( ( XR >> 2 ) ^ XR ) & 2 ; switch ( ( insn >> 14 ) & 0x7 ) { case 1 : if ( XR & 4 ) IR = 1 ; break ; case 2 : if ( ( XR & 4 ) || freg ) IR = 1 ; break ; case 3 : if ( freg ) IR = 1 ; break ; case 4 : if ( XR & 5 ) IR = 1 ; break ; case 5 : if ( XR & 1 ) IR = 1 ; break ; case 6 : if ( XR & 8 ) IR = 1 ; break ; case 7 : if ( XR & 2 ) IR = 1 ; break ; } if ( ( insn >> 14 ) & 8 ) IR ^= 1 ; break ; case FMOVQZ : case FMOVQLE : case FMOVQLZ : case FMOVQNZ : case FMOVQGZ : case FMOVQGE : freg = ( insn >> 14 ) & 0x1f ; if ( ! freg ) XR = 0 ; else if ( freg < 16 ) XR = regs -> u_regs [ freg ] ; else if ( test_thread_flag ( TIF_32BIT ) ) { struct reg_window32 __user * win32 ; flushw_user ( ) ; win32 = ( struct reg_window32 __user * ) ( ( unsigned long ) ( ( u32 ) regs -> u_regs [ UREG_FP ] ) ) ; get_user ( XR , & win32 -> locals [ freg - 16 ] ) ; } else { struct reg_window __user * win ; flushw_user ( ) ; win = ( struct reg_window __user * ) ( regs -> u_regs [ UREG_FP ] + STACK_BIAS ) ; get_user ( XR , & win -> locals [ freg - 16 ] ) ; } IR = 0 ; switch ( ( insn >> 10 ) & 3 ) { case 1 : if ( ! XR ) IR = 1 ; break ; case 2 : if ( XR <= 0 ) IR = 1 ; break ; case 3 : if ( XR < 0 ) IR = 1 ; break ; } if ( ( insn >> 10 ) & 4 ) IR ^= 1 ; break ; } if ( IR == 0 ) { current_thread_info ( ) -> xfsr [ 0 ] &= ~ ( FSR_CEXC_MASK ) ; regs -> tpc = regs -> tnpc ; regs -> tnpc += 4 ; return 1 ; } else if ( IR == 1 ) { insn = ( insn & 0x3e00001f ) | 0x81a00060 ; TYPE ( 3 , 3 , 0 , 3 , 0 , 0 , 0 ) ; } } } if ( type ) { argp rs1 = NULL , rs2 = NULL , rd = NULL ; freg = ( current_thread_info ( ) -> xfsr [ 0 ] >> 14 ) & 0xf ; if ( freg != ( type >> 9 ) ) goto err ; current_thread_info ( ) -> xfsr [ 0 ] &= ~ 0x1c000 ; freg = ( ( insn >> 14 ) & 0x1f ) ; switch ( type & 0x3 ) { case 3 : if ( freg & 2 ) { current_thread_info ( ) -> xfsr [ 0 ] |= ( 6 << 14 ) ; goto err ; } case 2 : freg = ( ( freg & 1 ) << 5 ) | ( freg & 0x1e ) ; case 1 : rs1 = ( argp ) & f -> regs [ freg ] ; flags = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & flags ) ) rs1 = ( argp ) & zero ; break ; } switch ( type & 0x7 ) { case 7 : FP_UNPACK_QP ( QA , rs1 ) ; break ; case 6 : FP_UNPACK_DP ( DA , rs1 ) ; break ; case 5 : FP_UNPACK_SP ( SA , rs1 ) ; break ; } freg = ( insn & 0x1f ) ; switch ( ( type >> 3 ) & 0x3 ) { case 3 : if ( freg & 2 ) { current_thread_info ( ) -> xfsr [ 0 ] |= ( 6 << 14 ) ; goto err ; } case 2 : freg = ( ( freg & 1 ) << 5 ) | ( freg & 0x1e ) ; case 1 : rs2 = ( argp ) & f -> regs [ freg ] ; flags = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & flags ) ) rs2 = ( argp ) & zero ; break ; } switch ( ( type >> 3 ) & 0x7 ) { case 7 : FP_UNPACK_QP ( QB , rs2 ) ; break ; case 6 : FP_UNPACK_DP ( DB , rs2 ) ; break ; case 5 : FP_UNPACK_SP ( SB , rs2 ) ; break ; } freg = ( ( insn >> 25 ) & 0x1f ) ; switch ( ( type >> 6 ) & 0x3 ) { case 3 : if ( freg & 2 ) { current_thread_info ( ) -> xfsr [ 0 ] |= ( 6 << 14 ) ; goto err ; } case 2 : freg = ( ( freg & 1 ) << 5 ) | ( freg & 0x1e ) ; case 1 : rd = ( argp ) & f -> regs [ freg ] ; flags = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & FPRS_FEF ) ) { current_thread_info ( ) -> fpsaved [ 0 ] = FPRS_FEF ; current_thread_info ( ) -> gsr [ 0 ] = 0 ; } if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & flags ) ) { if ( freg < 32 ) memset ( f -> regs , 0 , 32 * sizeof ( u32 ) ) ; else memset ( f -> regs + 32 , 0 , 32 * sizeof ( u32 ) ) ; } current_thread_info ( ) -> fpsaved [ 0 ] |= flags ; break ; } switch ( ( insn >> 5 ) & 0x1ff ) { case FADDS : FP_ADD_S ( SR , SA , SB ) ; break ; case FADDD : FP_ADD_D ( DR , DA , DB ) ; break ; case FADDQ : FP_ADD_Q ( QR , QA , QB ) ; break ; case FSUBS : FP_SUB_S ( SR , SA , SB ) ; break ; case FSUBD : FP_SUB_D ( DR , DA , DB ) ; break ; case FSUBQ : FP_SUB_Q ( QR , QA , QB ) ; break ; case FMULS : FP_MUL_S ( SR , SA , SB ) ; break ; case FSMULD : FP_CONV ( D , S , 1 , 1 , DA , SA ) ; FP_CONV ( D , S , 1 , 1 , DB , SB ) ; case FMULD : FP_MUL_D ( DR , DA , DB ) ; break ; case FDMULQ : FP_CONV ( Q , D , 2 , 1 , QA , DA ) ; FP_CONV ( Q , D , 2 , 1 , QB , DB ) ; case FMULQ : FP_MUL_Q ( QR , QA , QB ) ; break ; case FDIVS : FP_DIV_S ( SR , SA , SB ) ; break ; case FDIVD : FP_DIV_D ( DR , DA , DB ) ; break ; case FDIVQ : FP_DIV_Q ( QR , QA , QB ) ; break ; case FSQRTS : FP_SQRT_S ( SR , SB ) ; break ; case FSQRTD : FP_SQRT_D ( DR , DB ) ; break ; case FSQRTQ : FP_SQRT_Q ( QR , QB ) ; break ; case FMOVQ : rd -> q [ 0 ] = rs2 -> q [ 0 ] ; rd -> q [ 1 ] = rs2 -> q [ 1 ] ; break ; case FABSQ : rd -> q [ 0 ] = rs2 -> q [ 0 ] & 0x7fffffffffffffffUL ; rd -> q [ 1 ] = rs2 -> q [ 1 ] ; break ; case FNEGQ : rd -> q [ 0 ] = rs2 -> q [ 0 ] ^ 0x8000000000000000UL ; rd -> q [ 1 ] = rs2 -> q [ 1 ] ; break ; case FSTOI : FP_TO_INT_S ( IR , SB , 32 , 1 ) ; break ; case FDTOI : FP_TO_INT_D ( IR , DB , 32 , 1 ) ; break ; case FQTOI : FP_TO_INT_Q ( IR , QB , 32 , 1 ) ; break ; case FSTOX : FP_TO_INT_S ( XR , SB , 64 , 1 ) ; break ; case FDTOX : FP_TO_INT_D ( XR , DB , 64 , 1 ) ; break ; case FQTOX : FP_TO_INT_Q ( XR , QB , 64 , 1 ) ; break ; case FITOQ : IR = rs2 -> s ; FP_FROM_INT_Q ( QR , IR , 32 , int ) ; break ; case FXTOQ : XR = rs2 -> d ; FP_FROM_INT_Q ( QR , XR , 64 , long ) ; break ; case FXTOS : XR = rs2 -> d ; FP_FROM_INT_S ( SR , XR , 64 , long ) ; break ; case FXTOD : XR = rs2 -> d ; FP_FROM_INT_D ( DR , XR , 64 , long ) ; break ; # if 0 case FITOS : IR = rs2 -> s ; FP_FROM_INT_S ( SR , IR , 32 , int ) ; break ; # endif case FITOD : IR = rs2 -> s ; FP_FROM_INT_D ( DR , IR , 32 , int ) ; break ; case FSTOD : FP_CONV ( D , S , 1 , 1 , DR , SB ) ; break ; case FSTOQ : FP_CONV ( Q , S , 2 , 1 , QR , SB ) ; break ; case FDTOQ : FP_CONV ( Q , D , 2 , 1 , QR , DB ) ; break ; case FDTOS : FP_CONV ( S , D , 1 , 1 , SR , DB ) ; break ; case FQTOS : FP_CONV ( S , Q , 1 , 2 , SR , QB ) ; break ; case FQTOD : FP_CONV ( D , Q , 1 , 2 , DR , QB ) ; break ; case FCMPQ : case FCMPEQ : FP_CMP_Q ( XR , QB , QA , 3 ) ; if ( XR == 3 && ( ( ( insn >> 5 ) & 0x1ff ) == FCMPEQ || FP_ISSIGNAN_Q ( QA ) || FP_ISSIGNAN_Q ( QB ) ) ) FP_SET_EXCEPTION ( FP_EX_INVALID ) ; } if ( ! FP_INHIBIT_RESULTS ) { switch ( ( type >> 6 ) & 0x7 ) { case 0 : xfsr = current_thread_info ( ) -> xfsr [ 0 ] ; if ( XR == - 1 ) XR = 2 ; switch ( freg & 3 ) { case 0 : xfsr &= ~ 0xc00 ; xfsr |= ( XR << 10 ) ; break ; case 1 : xfsr &= ~ 0x300000000UL ; xfsr |= ( XR << 32 ) ; break ; case 2 : xfsr &= ~ 0xc00000000UL ; xfsr |= ( XR << 34 ) ; break ; case 3 : xfsr &= ~ 0x3000000000UL ; xfsr |= ( XR << 36 ) ; break ; } current_thread_info ( ) -> xfsr [ 0 ] = xfsr ; break ; case 1 : rd -> s = IR ; break ; case 2 : rd -> d = XR ; break ; case 5 : FP_PACK_SP ( rd , SR ) ; break ; case 6 : FP_PACK_DP ( rd , DR ) ; break ; case 7 : FP_PACK_QP ( rd , QR ) ; break ; } } if ( _fex != 0 ) return record_exception ( regs , _fex ) ; current_thread_info ( ) -> xfsr [ 0 ] &= ~ ( FSR_CEXC_MASK ) ; regs -> tpc = regs -> tnpc ; regs -> tnpc += 4 ; return 1 ; } err : return 0 ; }\n", "\n", "1: CWE-399 static void emulate_load_store_insn ( struct pt_regs * regs , void __user * addr , unsigned int __user * pc ) { union mips_instruction insn ; unsigned long value ; unsigned int res ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; __get_user ( insn . word , pc ) ; switch ( insn . i_format . opcode ) { case ll_op : case lld_op : case sc_op : case scd_op : case ldl_op : case ldr_op : case lwl_op : case lwr_op : case sdl_op : case sdr_op : case swl_op : case swr_op : case lb_op : case lbu_op : case sb_op : goto sigbus ; case lh_op : if ( ! access_ok ( VERIFY_READ , addr , 2 ) ) goto sigbus ; __asm__ __volatile__ ( \".set\\\\tnoat\\\\n\" # ifdef __BIG_ENDIAN \"1:\\\\tlb\\\\t%0,0(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,1(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlb\\\\t%0,1(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,0(%2)\\\\n\\\\t\" # endif \"sll\\\\t%0,0x8\\\\n\\\\t\" \"or\\\\t%0,$1\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.set\\\\tat\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lw_op : if ( ! access_ok ( VERIFY_READ , addr , 4 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tlwl\\\\t%0,(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlwl\\\\t%0,3(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lhu_op : if ( ! access_ok ( VERIFY_READ , addr , 2 ) ) goto sigbus ; __asm__ __volatile__ ( \".set\\\\tnoat\\\\n\" # ifdef __BIG_ENDIAN \"1:\\\\tlbu\\\\t%0,0(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,1(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlbu\\\\t%0,1(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,0(%2)\\\\n\\\\t\" # endif \"sll\\\\t%0,0x8\\\\n\\\\t\" \"or\\\\t%0,$1\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.set\\\\tat\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lwu_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_READ , addr , 4 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tlwl\\\\t%0,(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlwl\\\\t%0,3(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"dsll\\\\t%0,%0,32\\\\n\\\\t\" \"dsrl\\\\t%0,%0,32\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; # endif goto sigill ; case ld_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_READ , addr , 8 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tldl\\\\t%0,(%2)\\\\n\" \"2:\\\\tldr\\\\t%0,7(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tldl\\\\t%0,7(%2)\\\\n\" \"2:\\\\tldr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; # endif goto sigill ; case sh_op : if ( ! access_ok ( VERIFY_WRITE , addr , 2 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \".set\\\\tnoat\\\\n\" \"1:\\\\tsb\\\\t%1,1(%2)\\\\n\\\\t\" \"srl\\\\t$1,%1,0x8\\\\n\" \"2:\\\\tsb\\\\t$1,0(%2)\\\\n\\\\t\" \".set\\\\tat\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \".set\\\\tnoat\\\\n\" \"1:\\\\tsb\\\\t%1,0(%2)\\\\n\\\\t\" \"srl\\\\t$1,%1,0x8\\\\n\" \"2:\\\\tsb\\\\t$1,1(%2)\\\\n\\\\t\" \".set\\\\tat\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; case sw_op : if ( ! access_ok ( VERIFY_WRITE , addr , 4 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tswl\\\\t%1,(%2)\\\\n\" \"2:\\\\tswr\\\\t%1,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tswl\\\\t%1,3(%2)\\\\n\" \"2:\\\\tswr\\\\t%1,(%2)\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; case sd_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_WRITE , addr , 8 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tsdl\\\\t%1,(%2)\\\\n\" \"2:\\\\tsdr\\\\t%1,7(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tsdl\\\\t%1,7(%2)\\\\n\" \"2:\\\\tsdr\\\\t%1,(%2)\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; # endif goto sigill ; case lwc1_op : case ldc1_op : case swc1_op : case sdc1_op : goto sigbus ; case lwc2_op : cu2_notifier_call_chain ( CU2_LWC2_OP , regs ) ; break ; case ldc2_op : cu2_notifier_call_chain ( CU2_LDC2_OP , regs ) ; break ; case swc2_op : cu2_notifier_call_chain ( CU2_SWC2_OP , regs ) ; break ; case sdc2_op : cu2_notifier_call_chain ( CU2_SDC2_OP , regs ) ; break ; default : goto sigill ; } # ifdef CONFIG_DEBUG_FS unaligned_instructions ++ ; # endif return ; fault : if ( fixup_exception ( regs ) ) return ; die_if_kernel ( \"Unhandledkernelunalignedaccess\" , regs ) ; force_sig ( SIGSEGV , current ) ; return ; sigbus : die_if_kernel ( \"Unhandledkernelunalignedaccess\" , regs ) ; force_sig ( SIGBUS , current ) ; return ; sigill : die_if_kernel ( \"Unhandledkernelunalignedaccessorinvalidinstruction\" , regs ) ; force_sig ( SIGILL , current ) ; }\n", "\n", "2: CWE-400 int do_fpu_inst ( unsigned short inst , struct pt_regs * regs ) { struct task_struct * tsk = current ; struct sh_fpu_soft_struct * fpu = & ( tsk -> thread . xstate -> softfpu ) ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; if ( ! ( task_thread_info ( tsk ) -> status & TS_USEDFPU ) ) { fpu_init ( fpu ) ; task_thread_info ( tsk ) -> status |= TS_USEDFPU ; } return fpu_emulate ( inst , fpu , regs ) ; }\n", "\n", "3: CWE-399 int do_fpu_inst ( unsigned short inst , struct pt_regs * regs ) { struct task_struct * tsk = current ; struct sh_fpu_soft_struct * fpu = & ( tsk -> thread . xstate -> softfpu ) ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; if ( ! ( task_thread_info ( tsk ) -> status & TS_USEDFPU ) ) { fpu_init ( fpu ) ; task_thread_info ( tsk ) -> status |= TS_USEDFPU ; } return fpu_emulate ( inst , fpu , regs ) ; }\n", "\n", "4: CWE-400 int handle_popc ( u32 insn , struct pt_regs * regs ) { u64 value ; int ret , i , rd = ( ( insn >> 25 ) & 0x1f ) ; int from_kernel = ( regs -> tstate & TSTATE_PRIV ) != 0 ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; if ( insn & 0x2000 ) { maybe_flush_windows ( 0 , 0 , rd , from_kernel ) ; value = sign_extend_imm13 ( insn ) ; } else { maybe_flush_windows ( 0 , insn & 0x1f , rd , from_kernel ) ; value = fetch_reg ( insn & 0x1f , regs ) ; } for ( ret = 0 , i = 0 ; i < 16 ; i ++ ) { ret += popc_helper [ value & 0xf ] ; value >>= 4 ; } if ( rd < 16 ) { if ( rd ) regs -> u_regs [ rd ] = ret ; } else { if ( test_thread_flag ( TIF_32BIT ) ) { struct reg_window32 __user * win32 ; win32 = ( struct reg_window32 __user * ) ( ( unsigned long ) ( ( u32 ) regs -> u_regs [ UREG_FP ] ) ) ; put_user ( ret , & win32 -> locals [ rd - 16 ] ) ; } else { struct reg_window __user * win ; win = ( struct reg_window __user * ) ( regs -> u_regs [ UREG_FP ] + STACK_BIAS ) ; put_user ( ret , & win -> locals [ rd - 16 ] ) ; } } advance ( regs ) ; return 1 ; }\n", "\n", "5: CWE-400 static void emulate_load_store_insn ( struct pt_regs * regs , void __user * addr , unsigned int __user * pc ) { union mips_instruction insn ; unsigned long value ; unsigned int res ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; __get_user ( insn . word , pc ) ; switch ( insn . i_format . opcode ) { case ll_op : case lld_op : case sc_op : case scd_op : case ldl_op : case ldr_op : case lwl_op : case lwr_op : case sdl_op : case sdr_op : case swl_op : case swr_op : case lb_op : case lbu_op : case sb_op : goto sigbus ; case lh_op : if ( ! access_ok ( VERIFY_READ , addr , 2 ) ) goto sigbus ; __asm__ __volatile__ ( \".set\\\\tnoat\\\\n\" # ifdef __BIG_ENDIAN \"1:\\\\tlb\\\\t%0,0(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,1(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlb\\\\t%0,1(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,0(%2)\\\\n\\\\t\" # endif \"sll\\\\t%0,0x8\\\\n\\\\t\" \"or\\\\t%0,$1\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.set\\\\tat\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lw_op : if ( ! access_ok ( VERIFY_READ , addr , 4 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tlwl\\\\t%0,(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlwl\\\\t%0,3(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lhu_op : if ( ! access_ok ( VERIFY_READ , addr , 2 ) ) goto sigbus ; __asm__ __volatile__ ( \".set\\\\tnoat\\\\n\" # ifdef __BIG_ENDIAN \"1:\\\\tlbu\\\\t%0,0(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,1(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlbu\\\\t%0,1(%2)\\\\n\" \"2:\\\\tlbu\\\\t$1,0(%2)\\\\n\\\\t\" # endif \"sll\\\\t%0,0x8\\\\n\\\\t\" \"or\\\\t%0,$1\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.set\\\\tat\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; case lwu_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_READ , addr , 4 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tlwl\\\\t%0,(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tlwl\\\\t%0,3(%2)\\\\n\" \"2:\\\\tlwr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"dsll\\\\t%0,%0,32\\\\n\\\\t\" \"dsrl\\\\t%0,%0,32\\\\n\\\\t\" \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; # endif goto sigill ; case ld_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_READ , addr , 8 ) ) goto sigbus ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tldl\\\\t%0,(%2)\\\\n\" \"2:\\\\tldr\\\\t%0,7(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tldl\\\\t%0,7(%2)\\\\n\" \"2:\\\\tldr\\\\t%0,(%2)\\\\n\\\\t\" # endif \"li\\\\t%1,0\\\\n\" \"3:\\\\t.section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%1,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=&r\" ( value ) , \"=r\" ( res ) : \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; regs -> regs [ insn . i_format . rt ] = value ; break ; # endif goto sigill ; case sh_op : if ( ! access_ok ( VERIFY_WRITE , addr , 2 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \".set\\\\tnoat\\\\n\" \"1:\\\\tsb\\\\t%1,1(%2)\\\\n\\\\t\" \"srl\\\\t$1,%1,0x8\\\\n\" \"2:\\\\tsb\\\\t$1,0(%2)\\\\n\\\\t\" \".set\\\\tat\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \".set\\\\tnoat\\\\n\" \"1:\\\\tsb\\\\t%1,0(%2)\\\\n\\\\t\" \"srl\\\\t$1,%1,0x8\\\\n\" \"2:\\\\tsb\\\\t$1,1(%2)\\\\n\\\\t\" \".set\\\\tat\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; case sw_op : if ( ! access_ok ( VERIFY_WRITE , addr , 4 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tswl\\\\t%1,(%2)\\\\n\" \"2:\\\\tswr\\\\t%1,3(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tswl\\\\t%1,3(%2)\\\\n\" \"2:\\\\tswr\\\\t%1,(%2)\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; case sd_op : # ifdef CONFIG_64BIT if ( ! access_ok ( VERIFY_WRITE , addr , 8 ) ) goto sigbus ; value = regs -> regs [ insn . i_format . rt ] ; __asm__ __volatile__ ( # ifdef __BIG_ENDIAN \"1:\\\\tsdl\\\\t%1,(%2)\\\\n\" \"2:\\\\tsdr\\\\t%1,7(%2)\\\\n\\\\t\" # endif # ifdef __LITTLE_ENDIAN \"1:\\\\tsdl\\\\t%1,7(%2)\\\\n\" \"2:\\\\tsdr\\\\t%1,(%2)\\\\n\\\\t\" # endif \"li\\\\t%0,0\\\\n\" \"3:\\\\n\\\\t\" \".section\\\\t.fixup,\\\\\"ax\\\\\"\\\\n\\\\t\" \"4:\\\\tli\\\\t%0,%3\\\\n\\\\t\" \"j\\\\t3b\\\\n\\\\t\" \".previous\\\\n\\\\t\" \".section\\\\t__ex_table,\\\\\"a\\\\\"\\\\n\\\\t\" STR ( PTR ) \"\\\\t1b,4b\\\\n\\\\t\" STR ( PTR ) \"\\\\t2b,4b\\\\n\\\\t\" \".previous\" : \"=r\" ( res ) : \"r\" ( value ) , \"r\" ( addr ) , \"i\" ( - EFAULT ) ) ; if ( res ) goto fault ; compute_return_epc ( regs ) ; break ; # endif goto sigill ; case lwc1_op : case ldc1_op : case swc1_op : case sdc1_op : goto sigbus ; case lwc2_op : cu2_notifier_call_chain ( CU2_LWC2_OP , regs ) ; break ; case ldc2_op : cu2_notifier_call_chain ( CU2_LDC2_OP , regs ) ; break ; case swc2_op : cu2_notifier_call_chain ( CU2_SWC2_OP , regs ) ; break ; case sdc2_op : cu2_notifier_call_chain ( CU2_SDC2_OP , regs ) ; break ; default : goto sigill ; } # ifdef CONFIG_DEBUG_FS unaligned_instructions ++ ; # endif return ; fault : if ( fixup_exception ( regs ) ) return ; die_if_kernel ( \"Unhandledkernelunalignedaccess\" , regs ) ; force_sig ( SIGSEGV , current ) ; return ; sigbus : die_if_kernel ( \"Unhandledkernelunalignedaccess\" , regs ) ; force_sig ( SIGBUS , current ) ; return ; sigill : die_if_kernel ( \"Unhandledkernelunalignedaccessorinvalidinstruction\" , regs ) ; force_sig ( SIGILL , current ) ; }\n", "\n", "6: CWE-400 int do_mathemu ( struct pt_regs * regs , struct task_struct * fpt ) { int i ; int retcode = 0 ; unsigned long insn ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; # ifdef DEBUG_MATHEMU printk ( \"Indo_mathemu()...pcis%08lx\\\\n\" , regs -> pc ) ; printk ( \"fpqdepthis%ld\\\\n\" , fpt -> thread . fpqdepth ) ; for ( i = 0 ; i < fpt -> thread . fpqdepth ; i ++ ) printk ( \"%d:%08lxat%08lx\\\\n\" , i , fpt -> thread . fpqueue [ i ] . insn , ( unsigned long ) fpt -> thread . fpqueue [ i ] . insn_addr ) ; # endif if ( fpt -> thread . fpqdepth == 0 ) { # ifdef DEBUG_MATHEMU printk ( \"precisetrapat%08lx\\\\n\" , regs -> pc ) ; # endif if ( ! get_user ( insn , ( u32 __user * ) regs -> pc ) ) { retcode = do_one_mathemu ( insn , & fpt -> thread . fsr , fpt -> thread . float_regs ) ; if ( retcode ) { regs -> pc = regs -> npc ; regs -> npc += 4 ; } } return retcode ; } for ( i = 0 ; i < fpt -> thread . fpqdepth ; i ++ ) { retcode = do_one_mathemu ( fpt -> thread . fpqueue [ i ] . insn , & ( fpt -> thread . fsr ) , fpt -> thread . float_regs ) ; if ( ! retcode ) break ; } if ( retcode ) fpt -> thread . fsr &= ~ ( 0x3000 | FSR_CEXC_MASK ) ; else fpt -> thread . fsr &= ~ 0x3000 ; fpt -> thread . fpqdepth = 0 ; return retcode ; }\n", "\n", "\n", "Target: crypto_report_akcipher rakcipher ; strncpy ( rakcipher .\n", "\n", "Sources:\n", "0: CWE-200 static int crypto_report_akcipher ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_akcipher rakcipher ; strlcpy ( rakcipher . type , \"akcipher\" , sizeof ( rakcipher . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_AKCIPHER , sizeof ( struct crypto_report_akcipher ) , & rakcipher ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "1: CWE-000 static int crypto_report_akcipher ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_akcipher rakcipher ; strlcpy ( rakcipher . type , \"akcipher\" , sizeof ( rakcipher . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_AKCIPHER , sizeof ( struct crypto_report_akcipher ) , & rakcipher ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "\n", "Target: char * src , bool quote_backtick ) { const char * quote = \"`\\\\\"\\\\\\\\\" ; if ( ! quote_backtick ) quote ++ ; char *\n", "\n", "Sources:\n", "0: CWE-77 void imap_quote_string ( char * dest , size_t dlen , const char * src ) { static const char quote [ ] = \"\\\\\"\\\\\\\\\" ; char * pt = dest ; const char * s = src ; * pt ++ = \\'\"\\' ; dlen -= 2 ; for ( ; * s && dlen ; s ++ ) { if ( strchr ( quote , * s ) ) { dlen -= 2 ; if ( dlen == 0 ) break ; * pt ++ = '\\\\\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \\'\"\\' ; * pt = '\\\\0' ; }\n", "\n", "1: CWE-78 void imap_quote_string ( char * dest , size_t dlen , const char * src ) { static const char quote [ ] = \"\\\\\"\\\\\\\\\" ; char * pt = dest ; const char * s = src ; * pt ++ = \\'\"\\' ; dlen -= 2 ; for ( ; * s && dlen ; s ++ ) { if ( strchr ( quote , * s ) ) { dlen -= 2 ; if ( dlen == 0 ) break ; * pt ++ = '\\\\\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \\'\"\\' ; * pt = '\\\\0' ; }\n", "\n", "\n", "Target: \n", "\n", "Sources:\n", "0: CWE-119 cJSON * cJSON_CreateBool ( int b ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = b ? cJSON_True : cJSON_False ; return item ; }\n", "\n", "1: CWE-787 static MagickBooleanType ReadPSDChannelRLE ( Image * image , const PSDInfo * psd_info , const ssize_t type , MagickOffsetType * sizes , ExceptionInfo * exception ) { MagickBooleanType status ; size_t length , row_size ; ssize_t count , y ; unsigned char * compact_pixels , * pixels ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"layerdataisRLEcompressed\" ) ; row_size = GetPSDRowSize ( image ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( row_size , sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowBinaryException ( ResourceLimitError , \"MemoryAllocationFailed\" , image -> filename ) ; length = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) if ( ( MagickOffsetType ) length < sizes [ y ] ) length = ( size_t ) sizes [ y ] ; if ( length > row_size + 256 ) { pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; ThrowBinaryException ( ResourceLimitError , \"InvalidLength\" , image -> filename ) ; } compact_pixels = ( unsigned char * ) AcquireQuantumMemory ( length , sizeof ( * pixels ) ) ; if ( compact_pixels == ( unsigned char * ) NULL ) { pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; ThrowBinaryException ( ResourceLimitError , \"MemoryAllocationFailed\" , image -> filename ) ; } ( void ) ResetMagickMemory ( compact_pixels , 0 , length * sizeof ( * compact_pixels ) ) ; status = MagickTrue ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { status = MagickFalse ; count = ReadBlob ( image , ( size_t ) sizes [ y ] , compact_pixels ) ; if ( count != ( ssize_t ) sizes [ y ] ) break ; count = DecodePSDPixels ( ( size_t ) sizes [ y ] , compact_pixels , ( ssize_t ) ( image -> depth == 1 ? 123456 : image -> depth ) , row_size , pixels ) ; if ( count != ( ssize_t ) row_size ) break ; status = ReadPSDChannelPixels ( image , psd_info -> channels , y , type , pixels , exception ) ; if ( status == MagickFalse ) break ; } compact_pixels = ( unsigned char * ) RelinquishMagickMemory ( compact_pixels ) ; pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; return ( status ) ; }\n", "\n", "2: CWE-476 void jp2_box_dump ( jp2_box_t * box , FILE * out ) { jp2_boxinfo_t * boxinfo ; boxinfo = jp2_boxinfolookup ( box -> type ) ; assert ( boxinfo ) ; fprintf ( out , \"JP2box:\" ) ; fprintf ( out , \"type=%c%s%c(0x%08\" PRIxFAST32 \");length=%\" PRIuFAST32 \"\\\\n\" , \\'\"\\' , boxinfo -> name , \\'\"\\' , box -> type , box -> len ) ; if ( box -> ops -> dumpdata ) { ( * box -> ops -> dumpdata ) ( box , out ) ; } }\n", "\n", "3: CWE-119 static int cJSON_strcasecmp ( const char * s1 , const char * s2 ) { if ( ! s1 ) return ( s1 == s2 ) ? 0 : 1 ; if ( ! s2 ) return 1 ; for ( ; tolower ( * s1 ) == tolower ( * s2 ) ; ++ s1 , ++ s2 ) if ( * s1 == 0 ) return 0 ; return tolower ( * ( const unsigned char * ) s1 ) - tolower ( * ( const unsigned char * ) s2 ) ; }\n", "\n", "4: CWE-125 static const ut8 * r_bin_dwarf_parse_comp_unit ( Sdb * s , const ut8 * obuf , RBinDwarfCompUnit * cu , const RBinDwarfDebugAbbrev * da , size_t offset , const ut8 * debug_str , size_t debug_str_len ) { const ut8 * buf = obuf , * buf_end = obuf + ( cu -> hdr . length - 7 ) ; ut64 abbr_code ; size_t i ; if ( cu -> hdr . length > debug_str_len ) { return NULL ; } while ( buf && buf < buf_end && buf >= obuf ) { if ( cu -> length && cu -> capacity == cu -> length ) { r_bin_dwarf_expand_cu ( cu ) ; } buf = r_uleb128 ( buf , buf_end - buf , & abbr_code ) ; if ( abbr_code > da -> length || ! buf ) { return NULL ; } r_bin_dwarf_init_die ( & cu -> dies [ cu -> length ] ) ; if ( ! abbr_code ) { cu -> dies [ cu -> length ] . abbrev_code = 0 ; cu -> length ++ ; buf ++ ; continue ; } cu -> dies [ cu -> length ] . abbrev_code = abbr_code ; cu -> dies [ cu -> length ] . tag = da -> decls [ abbr_code - 1 ] . tag ; abbr_code += offset ; if ( da -> capacity < abbr_code ) { return NULL ; } for ( i = 0 ; i < da -> decls [ abbr_code - 1 ] . length ; i ++ ) { if ( cu -> dies [ cu -> length ] . length == cu -> dies [ cu -> length ] . capacity ) { r_bin_dwarf_expand_die ( & cu -> dies [ cu -> length ] ) ; } if ( i >= cu -> dies [ cu -> length ] . capacity || i >= da -> decls [ abbr_code - 1 ] . capacity ) { eprintf ( \"Warning:malformeddwarfattributecapacitydoesn\\'tmatchlength\\\\n\" ) ; break ; } memset ( & cu -> dies [ cu -> length ] . attr_values [ i ] , 0 , sizeof ( cu -> dies [ cu -> length ] . attr_values [ i ] ) ) ; buf = r_bin_dwarf_parse_attr_value ( buf , buf_end - buf , & da -> decls [ abbr_code - 1 ] . specs [ i ] , & cu -> dies [ cu -> length ] . attr_values [ i ] , & cu -> hdr , debug_str , debug_str_len ) ; if ( cu -> dies [ cu -> length ] . attr_values [ i ] . name == DW_AT_comp_dir ) { const char * name = cu -> dies [ cu -> length ] . attr_values [ i ] . encoding . str_struct . string ; sdb_set ( s , \"DW_AT_comp_dir\" , name , 0 ) ; } cu -> dies [ cu -> length ] . length ++ ; } cu -> length ++ ; } return buf ; }\n", "\n", "5: CWE-119 cJSON * cJSON_CreateArray ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_Array ; return item ; }\n", "\n", "6: CWE-119 void vp9_iht4x4_16_add_sse2 ( const int16_t * input , uint8_t * dest , int stride , int tx_type ) { __m128i in [ 2 ] ; const __m128i zero = _mm_setzero_si128 ( ) ; const __m128i eight = _mm_set1_epi16 ( 8 ) ; in [ 0 ] = _mm_loadu_si128 ( ( const __m128i * ) ( input ) ) ; in [ 1 ] = _mm_loadu_si128 ( ( const __m128i * ) ( input + 8 ) ) ; switch ( tx_type ) { case 0 : idct4_sse2 ( in ) ; idct4_sse2 ( in ) ; break ; case 1 : idct4_sse2 ( in ) ; iadst4_sse2 ( in ) ; break ; case 2 : iadst4_sse2 ( in ) ; idct4_sse2 ( in ) ; break ; case 3 : iadst4_sse2 ( in ) ; iadst4_sse2 ( in ) ; break ; default : assert ( 0 ) ; break ; } in [ 0 ] = _mm_add_epi16 ( in [ 0 ] , eight ) ; in [ 1 ] = _mm_add_epi16 ( in [ 1 ] , eight ) ; in [ 0 ] = _mm_srai_epi16 ( in [ 0 ] , 4 ) ; in [ 1 ] = _mm_srai_epi16 ( in [ 1 ] , 4 ) ; { __m128i d0 = _mm_cvtsi32_si128 ( * ( const int * ) ( dest ) ) ; __m128i d2 = _mm_cvtsi32_si128 ( * ( const int * ) ( dest + stride * 2 ) ) ; d0 = _mm_unpacklo_epi32 ( d0 , _mm_cvtsi32_si128 ( * ( const int * ) ( dest + stride ) ) ) ; d2 = _mm_unpacklo_epi32 ( d2 , _mm_cvtsi32_si128 ( * ( const int * ) ( dest + stride * 3 ) ) ) ; d0 = _mm_unpacklo_epi8 ( d0 , zero ) ; d2 = _mm_unpacklo_epi8 ( d2 , zero ) ; d0 = _mm_add_epi16 ( d0 , in [ 0 ] ) ; d2 = _mm_add_epi16 ( d2 , in [ 1 ] ) ; d0 = _mm_packus_epi16 ( d0 , d2 ) ; * ( int * ) dest = _mm_cvtsi128_si32 ( d0 ) ; d0 = _mm_srli_si128 ( d0 , 4 ) ; * ( int * ) ( dest + stride ) = _mm_cvtsi128_si32 ( d0 ) ; d0 = _mm_srli_si128 ( d0 , 4 ) ; * ( int * ) ( dest + stride * 2 ) = _mm_cvtsi128_si32 ( d0 ) ; d0 = _mm_srli_si128 ( d0 , 4 ) ; * ( int * ) ( dest + stride * 3 ) = _mm_cvtsi128_si32 ( d0 ) ; } }\n", "\n", "7: CWE-476 static GF_AV1Config * AV1_DuplicateConfig ( GF_AV1Config const * const cfg ) { u32 i = 0 ; GF_AV1Config * out = gf_malloc ( sizeof ( GF_AV1Config ) ) ; out -> marker = cfg -> marker ; out -> version = cfg -> version ; out -> seq_profile = cfg -> seq_profile ; out -> seq_level_idx_0 = cfg -> seq_level_idx_0 ; out -> seq_tier_0 = cfg -> seq_tier_0 ; out -> high_bitdepth = cfg -> high_bitdepth ; out -> twelve_bit = cfg -> twelve_bit ; out -> monochrome = cfg -> monochrome ; out -> chroma_subsampling_x = cfg -> chroma_subsampling_x ; out -> chroma_subsampling_y = cfg -> chroma_subsampling_y ; out -> chroma_sample_position = cfg -> chroma_sample_position ; out -> initial_presentation_delay_present = cfg -> initial_presentation_delay_present ; out -> initial_presentation_delay_minus_one = cfg -> initial_presentation_delay_minus_one ; out -> obu_array = gf_list_new ( ) ; for ( i = 0 ; i < gf_list_count ( cfg -> obu_array ) ; ++ i ) { GF_AV1_OBUArrayEntry * dst = gf_malloc ( sizeof ( GF_AV1_OBUArrayEntry ) ) , * src = gf_list_get ( cfg -> obu_array , i ) ; dst -> obu_length = src -> obu_length ; dst -> obu_type = src -> obu_type ; dst -> obu = gf_malloc ( ( size_t ) dst -> obu_length ) ; memcpy ( dst -> obu , src -> obu , ( size_t ) src -> obu_length ) ; gf_list_add ( out -> obu_array , dst ) ; } return out ; }\n", "\n", "8: CWE-119 void cJSON_DeleteItemFromObject ( cJSON * object , const char * string ) { cJSON_Delete ( cJSON_DetachItemFromObject ( object , string ) ) ; }\n", "\n", "9: CWE-119 static const char * skip ( const char * in ) { while ( in && * in && ( unsigned char ) * in <= 32 ) in ++ ; return in ; }\n", "\n", "10: CWE-119 cJSON * cJSON_CreateNull ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_NULL ; return item ; }\n", "\n", "11: CWE-125 static int fstring_find_expr ( const char * * str , const char * end , int raw , int recurse_lvl , expr_ty * expression , struct compiling * c , const node * n ) { const char * expr_start ; const char * expr_end ; expr_ty simple_expression ; expr_ty format_spec = NULL ; int conversion = - 1 ; char quote_char = 0 ; int string_type = 0 ; Py_ssize_t nested_depth = 0 ; char parenstack [ MAXLEVEL ] ; if ( recurse_lvl >= 2 ) { ast_error ( c , n , \"f-string:expressionsnestedtoodeeply\" ) ; return - 1 ; } assert ( * * str == '{' ) ; * str += 1 ; expr_start = * str ; for ( ; * str < end ; ( * str ) ++ ) { char ch ; assert ( nested_depth >= 0 ) ; assert ( * str >= expr_start && * str < end ) ; if ( quote_char ) assert ( string_type == 1 || string_type == 3 ) ; else assert ( string_type == 0 ) ; ch = * * str ; if ( ch == '\\\\\\\\' ) { ast_error ( c , n , \"f-stringexpressionpart\" \"cannotincludeabackslash\" ) ; return - 1 ; } if ( quote_char ) { if ( ch == quote_char ) { if ( string_type == 3 ) { if ( * str + 2 < end && * ( * str + 1 ) == ch && * ( * str + 2 ) == ch ) { * str += 2 ; string_type = 0 ; quote_char = 0 ; continue ; } } else { quote_char = 0 ; string_type = 0 ; continue ; } } } else if ( ch == '\\\\'' || ch == \\'\"\\' ) { if ( * str + 2 < end && * ( * str + 1 ) == ch && * ( * str + 2 ) == ch ) { string_type = 3 ; * str += 2 ; } else { string_type = 1 ; } quote_char = ch ; } else if ( ch == '[' || ch == '{' || ch == '(' ) { if ( nested_depth >= MAXLEVEL ) { ast_error ( c , n , \"f-string:toomanynestedparenthesis\" ) ; return - 1 ; } parenstack [ nested_depth ] = ch ; nested_depth ++ ; } else if ( ch == '#' ) { ast_error ( c , n , \"f-stringexpressionpartcannotinclude\\'#\\'\" ) ; return - 1 ; } else if ( nested_depth == 0 && ( ch == '!' || ch == ':' || ch == '}' ) ) { if ( ch == '!' && * str + 1 < end && * ( * str + 1 ) == '=' ) { continue ; } break ; } else if ( ch == ']' || ch == '}' || ch == ')' ) { if ( ! nested_depth ) { ast_error ( c , n , \"f-string:unmatched\\'%c\\'\" , ch ) ; return - 1 ; } nested_depth -- ; int opening = parenstack [ nested_depth ] ; if ( ! ( ( opening == '(' && ch == ')' ) || ( opening == '[' && ch == ']' ) || ( opening == '{' && ch == '}' ) ) ) { ast_error ( c , n , \"f-string:closingparenthesis\\'%c\\'\" \"doesnotmatchopeningparenthesis\\'%c\\'\" , ch , opening ) ; return - 1 ; } } else { } } expr_end = * str ; if ( quote_char ) { ast_error ( c , n , \"f-string:unterminatedstring\" ) ; return - 1 ; } if ( nested_depth ) { int opening = parenstack [ nested_depth - 1 ] ; ast_error ( c , n , \"f-string:unmatched\\'%c\\'\" , opening ) ; return - 1 ; } if ( * str >= end ) goto unexpected_end_of_string ; simple_expression = fstring_compile_expr ( expr_start , expr_end , c , n ) ; if ( ! simple_expression ) return - 1 ; if ( * * str == '!' ) { * str += 1 ; if ( * str >= end ) goto unexpected_end_of_string ; conversion = * * str ; * str += 1 ; if ( ! ( conversion == 's' || conversion == 'r' || conversion == 'a' ) ) { ast_error ( c , n , \"f-string:invalidconversioncharacter:\" \"expected\\'s\\',\\'r\\',or\\'a\\'\" ) ; return - 1 ; } } if ( * str >= end ) goto unexpected_end_of_string ; if ( * * str == ':' ) { * str += 1 ; if ( * str >= end ) goto unexpected_end_of_string ; format_spec = fstring_parse ( str , end , raw , recurse_lvl + 1 , c , n ) ; if ( ! format_spec ) return - 1 ; } if ( * str >= end || * * str != '}' ) goto unexpected_end_of_string ; assert ( * str < end ) ; assert ( * * str == '}' ) ; * str += 1 ; * expression = FormattedValue ( simple_expression , conversion , format_spec , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; if ( ! * expression ) return - 1 ; return 0 ; unexpected_end_of_string : ast_error ( c , n , \"f-string:expecting\\'}\\'\" ) ; return - 1 ; }\n", "\n", "12: CWE-125 int jpc_dec_decodepkts ( jpc_dec_t * dec , jas_stream_t * pkthdrstream , jas_stream_t * in ) { jpc_dec_tile_t * tile ; jpc_pi_t * pi ; int ret ; tile = dec -> curtile ; pi = tile -> pi ; for ( ; ; ) { if ( ! tile -> pkthdrstream || jas_stream_peekc ( tile -> pkthdrstream ) == EOF ) { switch ( jpc_dec_lookahead ( in ) ) { case JPC_MS_EOC : case JPC_MS_SOT : return 0 ; break ; case JPC_MS_SOP : case JPC_MS_EPH : case 0 : break ; default : return - 1 ; break ; } } if ( ( ret = jpc_pi_next ( pi ) ) ) { return ret ; } if ( dec -> maxpkts >= 0 && dec -> numpkts >= dec -> maxpkts ) { jas_eprintf ( \"warning:stoppingdecodeprematurelyasrequested\\\\n\" ) ; return 0 ; } if ( jas_getdbglevel ( ) >= 1 ) { jas_eprintf ( \"packetoffset=%08ldprg=%dcmptno=%02d\" \"rlvlno=%02dprcno=%03dlyrno=%02d\\\\n\" , ( long ) jas_stream_getrwcount ( in ) , jpc_pi_prg ( pi ) , jpc_pi_cmptno ( pi ) , jpc_pi_rlvlno ( pi ) , jpc_pi_prcno ( pi ) , jpc_pi_lyrno ( pi ) ) ; } if ( jpc_dec_decodepkt ( dec , pkthdrstream , in , jpc_pi_cmptno ( pi ) , jpc_pi_rlvlno ( pi ) , jpc_pi_prcno ( pi ) , jpc_pi_lyrno ( pi ) ) ) { return - 1 ; } ++ dec -> numpkts ; } return 0 ; }\n", "\n", "13: CWE-119 void cJSON_AddItemToArray ( cJSON * array , cJSON * item ) { cJSON * c = array -> child ; if ( ! item ) return ; if ( ! c ) { array -> child = item ; } else { while ( c && c -> next ) c = c -> next ; suffix_object ( c , item ) ; } }\n", "\n", "14: CWE-119 static void suffix_object ( cJSON * prev , cJSON * item ) { prev -> next = item ; item -> prev = prev ; }\n", "\n", "15: CWE-119 cJSON * cJSON_CreateTrue ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_True ; return item ; }\n", "\n", "16: CWE-125 static stmt_ty ast_for_import_stmt ( struct compiling * c , const node * n ) { int lineno ; int col_offset ; int i ; asdl_seq * aliases ; REQ ( n , import_stmt ) ; lineno = LINENO ( n ) ; col_offset = n -> n_col_offset ; n = CHILD ( n , 0 ) ; if ( TYPE ( n ) == import_name ) { n = CHILD ( n , 1 ) ; REQ ( n , dotted_as_names ) ; aliases = _Py_asdl_seq_new ( ( NCH ( n ) + 1 ) / 2 , c -> c_arena ) ; if ( ! aliases ) return NULL ; for ( i = 0 ; i < NCH ( n ) ; i += 2 ) { alias_ty import_alias = alias_for_import_name ( c , CHILD ( n , i ) , 1 ) ; if ( ! import_alias ) return NULL ; asdl_seq_SET ( aliases , i / 2 , import_alias ) ; } return Import ( aliases , lineno , col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } else if ( TYPE ( n ) == import_from ) { int n_children ; int idx , ndots = 0 ; const node * n_copy = n ; alias_ty mod = NULL ; identifier modname = NULL ; for ( idx = 1 ; idx < NCH ( n ) ; idx ++ ) { if ( TYPE ( CHILD ( n , idx ) ) == dotted_name ) { mod = alias_for_import_name ( c , CHILD ( n , idx ) , 0 ) ; if ( ! mod ) return NULL ; idx ++ ; break ; } else if ( TYPE ( CHILD ( n , idx ) ) == ELLIPSIS ) { ndots += 3 ; continue ; } else if ( TYPE ( CHILD ( n , idx ) ) != DOT ) { break ; } ndots ++ ; } idx ++ ; switch ( TYPE ( CHILD ( n , idx ) ) ) { case STAR : n = CHILD ( n , idx ) ; n_children = 1 ; break ; case LPAR : n = CHILD ( n , idx + 1 ) ; n_children = NCH ( n ) ; break ; case import_as_names : n = CHILD ( n , idx ) ; n_children = NCH ( n ) ; if ( n_children % 2 == 0 ) { ast_error ( c , n , \"trailingcommanotallowedwithout\" \"surroundingparentheses\" ) ; return NULL ; } break ; default : ast_error ( c , n , \"Unexpectednode-typeinfrom-import\" ) ; return NULL ; } aliases = _Py_asdl_seq_new ( ( n_children + 1 ) / 2 , c -> c_arena ) ; if ( ! aliases ) return NULL ; if ( TYPE ( n ) == STAR ) { alias_ty import_alias = alias_for_import_name ( c , n , 1 ) ; if ( ! import_alias ) return NULL ; asdl_seq_SET ( aliases , 0 , import_alias ) ; } else { for ( i = 0 ; i < NCH ( n ) ; i += 2 ) { alias_ty import_alias = alias_for_import_name ( c , CHILD ( n , i ) , 1 ) ; if ( ! import_alias ) return NULL ; asdl_seq_SET ( aliases , i / 2 , import_alias ) ; } } if ( mod != NULL ) modname = mod -> name ; return ImportFrom ( modname , aliases , ndots , lineno , col_offset , n_copy -> n_end_lineno , n_copy -> n_end_col_offset , c -> c_arena ) ; } PyErr_Format ( PyExc_SystemError , \"unknownimportstatement:startswithcommand\\'%s\\'\" , STR ( CHILD ( n , 0 ) ) ) ; return NULL ; }\n", "\n", "17: CWE-732 static M_bool M_fs_check_overwrite_allowed ( const char * p1 , const char * p2 , M_uint32 mode ) { M_fs_info_t * info = NULL ; char * pold = NULL ; char * pnew = NULL ; M_fs_type_t type ; M_bool ret = M_TRUE ; if ( mode & M_FS_FILE_MODE_OVERWRITE ) return M_TRUE ; if ( M_fs_info ( & info , p1 , M_FS_PATH_INFO_FLAGS_BASIC ) != M_FS_ERROR_SUCCESS ) return M_FALSE ; type = M_fs_info_get_type ( info ) ; M_fs_info_destroy ( info ) ; if ( type != M_FS_TYPE_DIR ) { if ( M_fs_perms_can_access ( p2 , M_FS_PERMS_MODE_NONE ) == M_FS_ERROR_SUCCESS ) { ret = M_FALSE ; goto done ; } } pold = M_fs_path_basename ( p1 , M_FS_SYSTEM_AUTO ) ; pnew = M_fs_path_join ( p2 , pnew , M_FS_SYSTEM_AUTO ) ; if ( M_fs_perms_can_access ( pnew , M_FS_PERMS_MODE_NONE ) == M_FS_ERROR_SUCCESS ) { ret = M_FALSE ; goto done ; } done : M_free ( pnew ) ; M_free ( pold ) ; return ret ; }\n", "\n", "18: CWE-119 void jpc_qmfb_join_colgrp ( jpc_fix_t * a , int numrows , int stride , int parity ) { int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ; jpc_fix_t joinbuf [ QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE ] ; jpc_fix_t * buf = joinbuf ; jpc_fix_t * srcptr ; jpc_fix_t * dstptr ; register jpc_fix_t * srcptr2 ; register jpc_fix_t * dstptr2 ; register int n ; register int i ; int hstartcol ; if ( bufsize > QMFB_JOINBUFSIZE ) { if ( ! ( buf = jas_alloc3 ( bufsize , JPC_QMFB_COLGRPSIZE , sizeof ( jpc_fix_t ) ) ) ) { abort ( ) ; } } hstartcol = ( numrows + 1 - parity ) >> 1 ; n = hstartcol ; srcptr = & a [ 0 ] ; dstptr = buf ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } srcptr += stride ; dstptr += JPC_QMFB_COLGRPSIZE ; } srcptr = & a [ hstartcol * stride ] ; dstptr = & a [ ( 1 - parity ) * stride ] ; n = numrows - hstartcol ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += 2 * stride ; srcptr += stride ; } srcptr = buf ; dstptr = & a [ parity * stride ] ; n = hstartcol ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += 2 * stride ; srcptr += JPC_QMFB_COLGRPSIZE ; } if ( buf != joinbuf ) { jas_free ( buf ) ; } }\n", "\n", "19: CWE-119 static int search_old_relocation ( struct reloc_struct_t * reloc_table , ut32 addr_to_patch , int n_reloc ) { int i ; for ( i = 0 ; i < n_reloc ; i ++ ) { if ( addr_to_patch == reloc_table [ i ] . data_offset ) { return i ; } } return - 1 ; }\n", "\n", "20: CWE-119 void cJSON_AddItemToObject ( cJSON * object , const char * string , cJSON * item ) { if ( ! item ) return ; if ( item -> string ) cJSON_free ( item -> string ) ; item -> string = cJSON_strdup ( string ) ; cJSON_AddItemToArray ( object , item ) ; }\n", "\n", "21: CWE-119 static char * cJSON_strdup ( const char * str ) { size_t len ; char * copy ; len = strlen ( str ) + 1 ; if ( ! ( copy = ( char * ) cJSON_malloc ( len ) ) ) return 0 ; memcpy ( copy , str , len ) ; return copy ; }\n", "\n", "22: CWE-119 cJSON * cJSON_CreateFalse ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_False ; return item ; }\n", "\n", "23: CWE-125 static int jpc_pi_nextrlcp ( register jpc_pi_t * pi ) { jpc_pchg_t * pchg ; int * prclyrno ; pchg = pi -> pchg ; if ( ! pi -> prgvolfirst ) { assert ( pi -> prcno < pi -> pirlvl -> numprcs ) ; prclyrno = & pi -> pirlvl -> prclyrnos [ pi -> prcno ] ; goto skip ; } else { pi -> prgvolfirst = 0 ; } for ( pi -> rlvlno = pchg -> rlvlnostart ; pi -> rlvlno < pi -> maxrlvls && pi -> rlvlno < pchg -> rlvlnoend ; ++ pi -> rlvlno ) { for ( pi -> lyrno = 0 ; pi -> lyrno < pi -> numlyrs && pi -> lyrno < JAS_CAST ( int , pchg -> lyrnoend ) ; ++ pi -> lyrno ) { for ( pi -> compno = pchg -> compnostart , pi -> picomp = & pi -> picomps [ pi -> compno ] ; pi -> compno < pi -> numcomps && pi -> compno < JAS_CAST ( int , pchg -> compnoend ) ; ++ pi -> compno , ++ pi -> picomp ) { if ( pi -> rlvlno >= pi -> picomp -> numrlvls ) { continue ; } pi -> pirlvl = & pi -> picomp -> pirlvls [ pi -> rlvlno ] ; for ( pi -> prcno = 0 , prclyrno = pi -> pirlvl -> prclyrnos ; pi -> prcno < pi -> pirlvl -> numprcs ; ++ pi -> prcno , ++ prclyrno ) { if ( pi -> lyrno >= * prclyrno ) { * prclyrno = pi -> lyrno ; ++ ( * prclyrno ) ; return 0 ; } skip : ; } } } } return 1 ; }\n", "\n", "24: CWE-125 static int parsestr ( struct compiling * c , const node * n , int * bytesmode , int * rawmode , PyObject * * result , const char * * fstr , Py_ssize_t * fstrlen ) { size_t len ; const char * s = STR ( n ) ; int quote = Py_CHARMASK ( * s ) ; int fmode = 0 ; * bytesmode = 0 ; * rawmode = 0 ; * result = NULL ; * fstr = NULL ; if ( Py_ISALPHA ( quote ) ) { while ( ! * bytesmode || ! * rawmode ) { if ( quote == 'b' || quote == 'B' ) { quote = * ++ s ; * bytesmode = 1 ; } else if ( quote == 'u' || quote == 'U' ) { quote = * ++ s ; } else if ( quote == 'r' || quote == 'R' ) { quote = * ++ s ; * rawmode = 1 ; } else if ( quote == 'f' || quote == 'F' ) { quote = * ++ s ; fmode = 1 ; } else { break ; } } } if ( fmode && * bytesmode ) { PyErr_BadInternalCall ( ) ; return - 1 ; } if ( quote != '\\\\'' && quote != \\'\\\\\"\\' ) { PyErr_BadInternalCall ( ) ; return - 1 ; } s ++ ; len = strlen ( s ) ; if ( len > INT_MAX ) { PyErr_SetString ( PyExc_OverflowError , \"stringtoparseistoolong\" ) ; return - 1 ; } if ( s [ -- len ] != quote ) { PyErr_BadInternalCall ( ) ; return - 1 ; } if ( len >= 4 && s [ 0 ] == quote && s [ 1 ] == quote ) { s += 2 ; len -= 2 ; if ( s [ -- len ] != quote || s [ -- len ] != quote ) { PyErr_BadInternalCall ( ) ; return - 1 ; } } if ( fmode ) { * fstr = s ; * fstrlen = len ; return 0 ; } * rawmode = * rawmode || strchr ( s , '\\\\\\\\' ) == NULL ; if ( * bytesmode ) { const char * ch ; for ( ch = s ; * ch ; ch ++ ) { if ( Py_CHARMASK ( * ch ) >= 0x80 ) { ast_error ( c , n , \"bytescanonlycontainASCII\" \"literalcharacters.\" ) ; return - 1 ; } } if ( * rawmode ) * result = PyBytes_FromStringAndSize ( s , len ) ; else * result = decode_bytes_with_escapes ( c , n , s , len ) ; } else { if ( * rawmode ) * result = PyUnicode_DecodeUTF8Stateful ( s , len , NULL , NULL ) ; else * result = decode_unicode_with_escapes ( c , n , s , len ) ; } return * result == NULL ? - 1 : 0 ; }\n", "\n", "\n", "Target: ; # if ENABLE_BGP_VNC_ATTR bgp_packet_mpattr_tea ( bgp\n", "\n", "Sources:\n", "0: CWE-000 bgp_size_t bgp_packet_attribute ( struct bgp * bgp , struct peer * peer , struct stream * s , struct attr * attr , struct bpacket_attr_vec_arr * vecarr , struct prefix * p , afi_t afi , safi_t safi , struct peer * from , struct prefix_rd * prd , mpls_label_t * label , uint32_t num_labels , int addpath_encode , uint32_t addpath_tx_id ) { size_t cp ; size_t aspath_sizep ; struct aspath * aspath ; int send_as4_path = 0 ; int send_as4_aggregator = 0 ; int use32bit = ( CHECK_FLAG ( peer -> cap , PEER_CAP_AS4_RCV ) ) ? 1 : 0 ; if ( ! bgp ) bgp = peer -> bgp ; cp = stream_get_endp ( s ) ; if ( p && ! ( ( afi == AFI_IP && safi == SAFI_UNICAST ) && ! peer_cap_enhe ( peer , afi , safi ) ) ) { size_t mpattrlen_pos = 0 ; mpattrlen_pos = bgp_packet_mpattr_start ( s , peer , afi , safi , vecarr , attr ) ; bgp_packet_mpattr_prefix ( s , afi , safi , p , prd , label , num_labels , addpath_encode , addpath_tx_id , attr ) ; bgp_packet_mpattr_end ( s , mpattrlen_pos ) ; } stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_ORIGIN ) ; stream_putc ( s , 1 ) ; stream_putc ( s , attr -> origin ) ; if ( peer -> sort == BGP_PEER_EBGP && ( ! CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_AS_PATH_UNCHANGED ) || attr -> aspath -> segments == NULL ) && ( ! CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_RSERVER_CLIENT ) ) ) { aspath = aspath_dup ( attr -> aspath ) ; aspath = aspath_delete_confed_seq ( aspath ) ; if ( CHECK_FLAG ( bgp -> config , BGP_CONFIG_CONFEDERATION ) ) { aspath = aspath_add_seq ( aspath , bgp -> confed_id ) ; } else { if ( peer -> change_local_as ) { if ( ! CHECK_FLAG ( peer -> flags , PEER_FLAG_LOCAL_AS_REPLACE_AS ) ) { aspath = aspath_add_seq ( aspath , peer -> local_as ) ; } aspath = aspath_add_seq ( aspath , peer -> change_local_as ) ; } else { aspath = aspath_add_seq ( aspath , peer -> local_as ) ; } } } else if ( peer -> sort == BGP_PEER_CONFED ) { aspath = aspath_dup ( attr -> aspath ) ; aspath = aspath_add_confed_seq ( aspath , peer -> local_as ) ; } else aspath = attr -> aspath ; stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_AS_PATH ) ; aspath_sizep = stream_get_endp ( s ) ; stream_putw ( s , 0 ) ; stream_putw_at ( s , aspath_sizep , aspath_put ( s , aspath , use32bit ) ) ; if ( ! use32bit && aspath_has_as4 ( aspath ) ) send_as4_path = 1 ; if ( afi == AFI_IP && safi == SAFI_UNICAST && ! peer_cap_enhe ( peer , afi , safi ) ) { if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_NEXT_HOP ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_NEXT_HOP ) ; bpacket_attr_vec_arr_set_vec ( vecarr , BGP_ATTR_VEC_NH , s , attr ) ; stream_putc ( s , 4 ) ; stream_put_ipv4 ( s , attr -> nexthop . s_addr ) ; } else if ( peer_cap_enhe ( from , afi , safi ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_NEXT_HOP ) ; bpacket_attr_vec_arr_set_vec ( vecarr , BGP_ATTR_VEC_NH , s , NULL ) ; stream_putc ( s , 4 ) ; stream_put_ipv4 ( s , 0 ) ; } } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_MULTI_EXIT_DISC ) || bgp -> maxmed_active ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_MULTI_EXIT_DISC ) ; stream_putc ( s , 4 ) ; stream_putl ( s , ( bgp -> maxmed_active ? bgp -> maxmed_value : attr -> med ) ) ; } if ( peer -> sort == BGP_PEER_IBGP || peer -> sort == BGP_PEER_CONFED ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_LOCAL_PREF ) ; stream_putc ( s , 4 ) ; stream_putl ( s , attr -> local_pref ) ; } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_ATOMIC_AGGREGATE ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_ATOMIC_AGGREGATE ) ; stream_putc ( s , 0 ) ; } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_AGGREGATOR ) ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_AGGREGATOR ) ; if ( use32bit ) { stream_putc ( s , 8 ) ; stream_putl ( s , attr -> aggregator_as ) ; } else { stream_putc ( s , 6 ) ; if ( attr -> aggregator_as > 65535 ) { stream_putw ( s , BGP_AS_TRANS ) ; send_as4_aggregator = 1 ; } else stream_putw ( s , ( uint16_t ) attr -> aggregator_as ) ; } stream_put_ipv4 ( s , attr -> aggregator_addr . s_addr ) ; } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_COMMUNITIES ) ) ) { if ( attr -> community -> size * 4 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_COMMUNITIES ) ; stream_putw ( s , attr -> community -> size * 4 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_COMMUNITIES ) ; stream_putc ( s , attr -> community -> size * 4 ) ; } stream_put ( s , attr -> community -> val , attr -> community -> size * 4 ) ; } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_LARGE_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_LARGE_COMMUNITIES ) ) ) { if ( lcom_length ( attr -> lcommunity ) > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_LARGE_COMMUNITIES ) ; stream_putw ( s , lcom_length ( attr -> lcommunity ) ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_LARGE_COMMUNITIES ) ; stream_putc ( s , lcom_length ( attr -> lcommunity ) ) ; } stream_put ( s , attr -> lcommunity -> val , lcom_length ( attr -> lcommunity ) ) ; } if ( peer -> sort == BGP_PEER_IBGP && from && from -> sort == BGP_PEER_IBGP ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_ORIGINATOR_ID ) ; stream_putc ( s , 4 ) ; if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_ORIGINATOR_ID ) ) stream_put_in_addr ( s , & attr -> originator_id ) ; else stream_put_in_addr ( s , & from -> remote_id ) ; stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_CLUSTER_LIST ) ; if ( attr -> cluster ) { stream_putc ( s , attr -> cluster -> length + 4 ) ; if ( bgp -> config & BGP_CONFIG_CLUSTER_ID ) stream_put_in_addr ( s , & bgp -> cluster_id ) ; else stream_put_in_addr ( s , & bgp -> router_id ) ; stream_put ( s , attr -> cluster -> list , attr -> cluster -> length ) ; } else { stream_putc ( s , 4 ) ; if ( bgp -> config & BGP_CONFIG_CLUSTER_ID ) stream_put_in_addr ( s , & bgp -> cluster_id ) ; else stream_put_in_addr ( s , & bgp -> router_id ) ; } } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_EXT_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_EXT_COMMUNITIES ) ) ) { if ( peer -> sort == BGP_PEER_IBGP || peer -> sort == BGP_PEER_CONFED ) { if ( attr -> ecommunity -> size * 8 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putw ( s , attr -> ecommunity -> size * 8 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putc ( s , attr -> ecommunity -> size * 8 ) ; } stream_put ( s , attr -> ecommunity -> val , attr -> ecommunity -> size * 8 ) ; } else { uint8_t * pnt ; int tbit ; int ecom_tr_size = 0 ; int i ; for ( i = 0 ; i < attr -> ecommunity -> size ; i ++ ) { pnt = attr -> ecommunity -> val + ( i * 8 ) ; tbit = * pnt ; if ( CHECK_FLAG ( tbit , ECOMMUNITY_FLAG_NON_TRANSITIVE ) ) continue ; ecom_tr_size ++ ; } if ( ecom_tr_size ) { if ( ecom_tr_size * 8 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putw ( s , ecom_tr_size * 8 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putc ( s , ecom_tr_size * 8 ) ; } for ( i = 0 ; i < attr -> ecommunity -> size ; i ++ ) { pnt = attr -> ecommunity -> val + ( i * 8 ) ; tbit = * pnt ; if ( CHECK_FLAG ( tbit , ECOMMUNITY_FLAG_NON_TRANSITIVE ) ) continue ; stream_put ( s , pnt , 8 ) ; } } } } if ( safi == SAFI_LABELED_UNICAST ) { if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_PREFIX_SID ) ) { uint32_t label_index ; label_index = attr -> label_index ; if ( label_index != BGP_INVALID_LABEL_INDEX ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_PREFIX_SID ) ; stream_putc ( s , 10 ) ; stream_putc ( s , BGP_PREFIX_SID_LABEL_INDEX ) ; stream_putw ( s , BGP_PREFIX_SID_LABEL_INDEX_LENGTH ) ; stream_putc ( s , 0 ) ; stream_putw ( s , 0 ) ; stream_putl ( s , label_index ) ; } } } if ( send_as4_path ) { aspath = aspath_delete_confed_seq ( aspath ) ; stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_AS4_PATH ) ; aspath_sizep = stream_get_endp ( s ) ; stream_putw ( s , 0 ) ; stream_putw_at ( s , aspath_sizep , aspath_put ( s , aspath , 1 ) ) ; } if ( aspath != attr -> aspath ) aspath_free ( aspath ) ; if ( send_as4_aggregator ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_AS4_AGGREGATOR ) ; stream_putc ( s , 8 ) ; stream_putl ( s , attr -> aggregator_as ) ; stream_put_ipv4 ( s , attr -> aggregator_addr . s_addr ) ; } if ( ( ( afi == AFI_IP || afi == AFI_IP6 ) && ( safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN ) ) || ( afi == AFI_L2VPN && safi == SAFI_EVPN ) ) { bgp_packet_mpattr_tea ( bgp , peer , s , attr , BGP_ATTR_ENCAP ) ; # if ENABLE_BGP_VNC bgp_packet_mpattr_tea ( bgp , peer , s , attr , BGP_ATTR_VNC ) ; # endif } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_PMSI_TUNNEL ) ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_PMSI_TUNNEL ) ; stream_putc ( s , 9 ) ; stream_putc ( s , 0 ) ; stream_putc ( s , PMSI_TNLTYPE_INGR_REPL ) ; stream_put ( s , & ( attr -> label ) , BGP_LABEL_BYTES ) ; stream_put_ipv4 ( s , attr -> nexthop . s_addr ) ; } if ( attr -> transit ) stream_put ( s , attr -> transit -> val , attr -> transit -> length ) ; return stream_get_endp ( s ) - cp ; }\n", "\n", "1: CWE-436 bgp_size_t bgp_packet_attribute ( struct bgp * bgp , struct peer * peer , struct stream * s , struct attr * attr , struct bpacket_attr_vec_arr * vecarr , struct prefix * p , afi_t afi , safi_t safi , struct peer * from , struct prefix_rd * prd , mpls_label_t * label , uint32_t num_labels , int addpath_encode , uint32_t addpath_tx_id ) { size_t cp ; size_t aspath_sizep ; struct aspath * aspath ; int send_as4_path = 0 ; int send_as4_aggregator = 0 ; int use32bit = ( CHECK_FLAG ( peer -> cap , PEER_CAP_AS4_RCV ) ) ? 1 : 0 ; if ( ! bgp ) bgp = peer -> bgp ; cp = stream_get_endp ( s ) ; if ( p && ! ( ( afi == AFI_IP && safi == SAFI_UNICAST ) && ! peer_cap_enhe ( peer , afi , safi ) ) ) { size_t mpattrlen_pos = 0 ; mpattrlen_pos = bgp_packet_mpattr_start ( s , peer , afi , safi , vecarr , attr ) ; bgp_packet_mpattr_prefix ( s , afi , safi , p , prd , label , num_labels , addpath_encode , addpath_tx_id , attr ) ; bgp_packet_mpattr_end ( s , mpattrlen_pos ) ; } stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_ORIGIN ) ; stream_putc ( s , 1 ) ; stream_putc ( s , attr -> origin ) ; if ( peer -> sort == BGP_PEER_EBGP && ( ! CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_AS_PATH_UNCHANGED ) || attr -> aspath -> segments == NULL ) && ( ! CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_RSERVER_CLIENT ) ) ) { aspath = aspath_dup ( attr -> aspath ) ; aspath = aspath_delete_confed_seq ( aspath ) ; if ( CHECK_FLAG ( bgp -> config , BGP_CONFIG_CONFEDERATION ) ) { aspath = aspath_add_seq ( aspath , bgp -> confed_id ) ; } else { if ( peer -> change_local_as ) { if ( ! CHECK_FLAG ( peer -> flags , PEER_FLAG_LOCAL_AS_REPLACE_AS ) ) { aspath = aspath_add_seq ( aspath , peer -> local_as ) ; } aspath = aspath_add_seq ( aspath , peer -> change_local_as ) ; } else { aspath = aspath_add_seq ( aspath , peer -> local_as ) ; } } } else if ( peer -> sort == BGP_PEER_CONFED ) { aspath = aspath_dup ( attr -> aspath ) ; aspath = aspath_add_confed_seq ( aspath , peer -> local_as ) ; } else aspath = attr -> aspath ; stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_AS_PATH ) ; aspath_sizep = stream_get_endp ( s ) ; stream_putw ( s , 0 ) ; stream_putw_at ( s , aspath_sizep , aspath_put ( s , aspath , use32bit ) ) ; if ( ! use32bit && aspath_has_as4 ( aspath ) ) send_as4_path = 1 ; if ( afi == AFI_IP && safi == SAFI_UNICAST && ! peer_cap_enhe ( peer , afi , safi ) ) { if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_NEXT_HOP ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_NEXT_HOP ) ; bpacket_attr_vec_arr_set_vec ( vecarr , BGP_ATTR_VEC_NH , s , attr ) ; stream_putc ( s , 4 ) ; stream_put_ipv4 ( s , attr -> nexthop . s_addr ) ; } else if ( peer_cap_enhe ( from , afi , safi ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_NEXT_HOP ) ; bpacket_attr_vec_arr_set_vec ( vecarr , BGP_ATTR_VEC_NH , s , NULL ) ; stream_putc ( s , 4 ) ; stream_put_ipv4 ( s , 0 ) ; } } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_MULTI_EXIT_DISC ) || bgp -> maxmed_active ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_MULTI_EXIT_DISC ) ; stream_putc ( s , 4 ) ; stream_putl ( s , ( bgp -> maxmed_active ? bgp -> maxmed_value : attr -> med ) ) ; } if ( peer -> sort == BGP_PEER_IBGP || peer -> sort == BGP_PEER_CONFED ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_LOCAL_PREF ) ; stream_putc ( s , 4 ) ; stream_putl ( s , attr -> local_pref ) ; } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_ATOMIC_AGGREGATE ) ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_ATOMIC_AGGREGATE ) ; stream_putc ( s , 0 ) ; } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_AGGREGATOR ) ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_AGGREGATOR ) ; if ( use32bit ) { stream_putc ( s , 8 ) ; stream_putl ( s , attr -> aggregator_as ) ; } else { stream_putc ( s , 6 ) ; if ( attr -> aggregator_as > 65535 ) { stream_putw ( s , BGP_AS_TRANS ) ; send_as4_aggregator = 1 ; } else stream_putw ( s , ( uint16_t ) attr -> aggregator_as ) ; } stream_put_ipv4 ( s , attr -> aggregator_addr . s_addr ) ; } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_COMMUNITIES ) ) ) { if ( attr -> community -> size * 4 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_COMMUNITIES ) ; stream_putw ( s , attr -> community -> size * 4 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_COMMUNITIES ) ; stream_putc ( s , attr -> community -> size * 4 ) ; } stream_put ( s , attr -> community -> val , attr -> community -> size * 4 ) ; } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_LARGE_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_LARGE_COMMUNITIES ) ) ) { if ( lcom_length ( attr -> lcommunity ) > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_LARGE_COMMUNITIES ) ; stream_putw ( s , lcom_length ( attr -> lcommunity ) ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_LARGE_COMMUNITIES ) ; stream_putc ( s , lcom_length ( attr -> lcommunity ) ) ; } stream_put ( s , attr -> lcommunity -> val , lcom_length ( attr -> lcommunity ) ) ; } if ( peer -> sort == BGP_PEER_IBGP && from && from -> sort == BGP_PEER_IBGP ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_ORIGINATOR_ID ) ; stream_putc ( s , 4 ) ; if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_ORIGINATOR_ID ) ) stream_put_in_addr ( s , & attr -> originator_id ) ; else stream_put_in_addr ( s , & from -> remote_id ) ; stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , BGP_ATTR_CLUSTER_LIST ) ; if ( attr -> cluster ) { stream_putc ( s , attr -> cluster -> length + 4 ) ; if ( bgp -> config & BGP_CONFIG_CLUSTER_ID ) stream_put_in_addr ( s , & bgp -> cluster_id ) ; else stream_put_in_addr ( s , & bgp -> router_id ) ; stream_put ( s , attr -> cluster -> list , attr -> cluster -> length ) ; } else { stream_putc ( s , 4 ) ; if ( bgp -> config & BGP_CONFIG_CLUSTER_ID ) stream_put_in_addr ( s , & bgp -> cluster_id ) ; else stream_put_in_addr ( s , & bgp -> router_id ) ; } } if ( CHECK_FLAG ( peer -> af_flags [ afi ] [ safi ] , PEER_FLAG_SEND_EXT_COMMUNITY ) && ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_EXT_COMMUNITIES ) ) ) { if ( peer -> sort == BGP_PEER_IBGP || peer -> sort == BGP_PEER_CONFED ) { if ( attr -> ecommunity -> size * 8 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putw ( s , attr -> ecommunity -> size * 8 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putc ( s , attr -> ecommunity -> size * 8 ) ; } stream_put ( s , attr -> ecommunity -> val , attr -> ecommunity -> size * 8 ) ; } else { uint8_t * pnt ; int tbit ; int ecom_tr_size = 0 ; int i ; for ( i = 0 ; i < attr -> ecommunity -> size ; i ++ ) { pnt = attr -> ecommunity -> val + ( i * 8 ) ; tbit = * pnt ; if ( CHECK_FLAG ( tbit , ECOMMUNITY_FLAG_NON_TRANSITIVE ) ) continue ; ecom_tr_size ++ ; } if ( ecom_tr_size ) { if ( ecom_tr_size * 8 > 255 ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putw ( s , ecom_tr_size * 8 ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_EXT_COMMUNITIES ) ; stream_putc ( s , ecom_tr_size * 8 ) ; } for ( i = 0 ; i < attr -> ecommunity -> size ; i ++ ) { pnt = attr -> ecommunity -> val + ( i * 8 ) ; tbit = * pnt ; if ( CHECK_FLAG ( tbit , ECOMMUNITY_FLAG_NON_TRANSITIVE ) ) continue ; stream_put ( s , pnt , 8 ) ; } } } } if ( safi == SAFI_LABELED_UNICAST ) { if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_PREFIX_SID ) ) { uint32_t label_index ; label_index = attr -> label_index ; if ( label_index != BGP_INVALID_LABEL_INDEX ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_PREFIX_SID ) ; stream_putc ( s , 10 ) ; stream_putc ( s , BGP_PREFIX_SID_LABEL_INDEX ) ; stream_putw ( s , BGP_PREFIX_SID_LABEL_INDEX_LENGTH ) ; stream_putc ( s , 0 ) ; stream_putw ( s , 0 ) ; stream_putl ( s , label_index ) ; } } } if ( send_as4_path ) { aspath = aspath_delete_confed_seq ( aspath ) ; stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , BGP_ATTR_AS4_PATH ) ; aspath_sizep = stream_get_endp ( s ) ; stream_putw ( s , 0 ) ; stream_putw_at ( s , aspath_sizep , aspath_put ( s , aspath , 1 ) ) ; } if ( aspath != attr -> aspath ) aspath_free ( aspath ) ; if ( send_as4_aggregator ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_AS4_AGGREGATOR ) ; stream_putc ( s , 8 ) ; stream_putl ( s , attr -> aggregator_as ) ; stream_put_ipv4 ( s , attr -> aggregator_addr . s_addr ) ; } if ( ( ( afi == AFI_IP || afi == AFI_IP6 ) && ( safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN ) ) || ( afi == AFI_L2VPN && safi == SAFI_EVPN ) ) { bgp_packet_mpattr_tea ( bgp , peer , s , attr , BGP_ATTR_ENCAP ) ; # if ENABLE_BGP_VNC bgp_packet_mpattr_tea ( bgp , peer , s , attr , BGP_ATTR_VNC ) ; # endif } if ( attr -> flag & ATTR_FLAG_BIT ( BGP_ATTR_PMSI_TUNNEL ) ) { stream_putc ( s , BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS ) ; stream_putc ( s , BGP_ATTR_PMSI_TUNNEL ) ; stream_putc ( s , 9 ) ; stream_putc ( s , 0 ) ; stream_putc ( s , PMSI_TNLTYPE_INGR_REPL ) ; stream_put ( s , & ( attr -> label ) , BGP_LABEL_BYTES ) ; stream_put_ipv4 ( s , attr -> nexthop . s_addr ) ; } if ( attr -> transit ) stream_put ( s , attr -> transit -> val , attr -> transit -> length ) ; return stream_get_endp ( s ) - cp ; }\n", "\n", "\n", "Target: static = _mm_set1_epi16 ( ( int16_t )\n", "\n", "Sources:\n", "0: CWE-119 void fadst4_sse2 ( __m128i * in ) { const __m128i k__sinpi_p01_p02 = pair_set_epi16 ( sinpi_1_9 , sinpi_2_9 ) ; const __m128i k__sinpi_p04_m01 = pair_set_epi16 ( sinpi_4_9 , - sinpi_1_9 ) ; const __m128i k__sinpi_p03_p04 = pair_set_epi16 ( sinpi_3_9 , sinpi_4_9 ) ; const __m128i k__sinpi_m03_p02 = pair_set_epi16 ( - sinpi_3_9 , sinpi_2_9 ) ; const __m128i k__sinpi_p03_p03 = _mm_set1_epi16 ( sinpi_3_9 ) ; const __m128i kZero = _mm_set1_epi16 ( 0 ) ; const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32 ( DCT_CONST_ROUNDING ) ; __m128i u [ 8 ] , v [ 8 ] ; __m128i in7 = _mm_add_epi16 ( in [ 0 ] , in [ 1 ] ) ; u [ 0 ] = _mm_unpacklo_epi16 ( in [ 0 ] , in [ 1 ] ) ; u [ 1 ] = _mm_unpacklo_epi16 ( in [ 2 ] , in [ 3 ] ) ; u [ 2 ] = _mm_unpacklo_epi16 ( in7 , kZero ) ; u [ 3 ] = _mm_unpacklo_epi16 ( in [ 2 ] , kZero ) ; u [ 4 ] = _mm_unpacklo_epi16 ( in [ 3 ] , kZero ) ; v [ 0 ] = _mm_madd_epi16 ( u [ 0 ] , k__sinpi_p01_p02 ) ; v [ 1 ] = _mm_madd_epi16 ( u [ 1 ] , k__sinpi_p03_p04 ) ; v [ 2 ] = _mm_madd_epi16 ( u [ 2 ] , k__sinpi_p03_p03 ) ; v [ 3 ] = _mm_madd_epi16 ( u [ 0 ] , k__sinpi_p04_m01 ) ; v [ 4 ] = _mm_madd_epi16 ( u [ 1 ] , k__sinpi_m03_p02 ) ; v [ 5 ] = _mm_madd_epi16 ( u [ 3 ] , k__sinpi_p03_p03 ) ; v [ 6 ] = _mm_madd_epi16 ( u [ 4 ] , k__sinpi_p03_p03 ) ; u [ 0 ] = _mm_add_epi32 ( v [ 0 ] , v [ 1 ] ) ; u [ 1 ] = _mm_sub_epi32 ( v [ 2 ] , v [ 6 ] ) ; u [ 2 ] = _mm_add_epi32 ( v [ 3 ] , v [ 4 ] ) ; u [ 3 ] = _mm_sub_epi32 ( u [ 2 ] , u [ 0 ] ) ; u [ 4 ] = _mm_slli_epi32 ( v [ 5 ] , 2 ) ; u [ 5 ] = _mm_sub_epi32 ( u [ 4 ] , v [ 5 ] ) ; u [ 6 ] = _mm_add_epi32 ( u [ 3 ] , u [ 5 ] ) ; v [ 0 ] = _mm_add_epi32 ( u [ 0 ] , k__DCT_CONST_ROUNDING ) ; v [ 1 ] = _mm_add_epi32 ( u [ 1 ] , k__DCT_CONST_ROUNDING ) ; v [ 2 ] = _mm_add_epi32 ( u [ 2 ] , k__DCT_CONST_ROUNDING ) ; v [ 3 ] = _mm_add_epi32 ( u [ 6 ] , k__DCT_CONST_ROUNDING ) ; u [ 0 ] = _mm_srai_epi32 ( v [ 0 ] , DCT_CONST_BITS ) ; u [ 1 ] = _mm_srai_epi32 ( v [ 1 ] , DCT_CONST_BITS ) ; u [ 2 ] = _mm_srai_epi32 ( v [ 2 ] , DCT_CONST_BITS ) ; u [ 3 ] = _mm_srai_epi32 ( v [ 3 ] , DCT_CONST_BITS ) ; in [ 0 ] = _mm_packs_epi32 ( u [ 0 ] , u [ 2 ] ) ; in [ 1 ] = _mm_packs_epi32 ( u [ 1 ] , u [ 3 ] ) ; transpose_4x4 ( in ) ; }\n", "\n", "1: CWE-119 void fdct8_sse2 ( __m128i * in ) { const __m128i k__cospi_p16_p16 = _mm_set1_epi16 ( cospi_16_64 ) ; const __m128i k__cospi_p16_m16 = pair_set_epi16 ( cospi_16_64 , - cospi_16_64 ) ; const __m128i k__cospi_p24_p08 = pair_set_epi16 ( cospi_24_64 , cospi_8_64 ) ; const __m128i k__cospi_m08_p24 = pair_set_epi16 ( - cospi_8_64 , cospi_24_64 ) ; const __m128i k__cospi_p28_p04 = pair_set_epi16 ( cospi_28_64 , cospi_4_64 ) ; const __m128i k__cospi_m04_p28 = pair_set_epi16 ( - cospi_4_64 , cospi_28_64 ) ; const __m128i k__cospi_p12_p20 = pair_set_epi16 ( cospi_12_64 , cospi_20_64 ) ; const __m128i k__cospi_m20_p12 = pair_set_epi16 ( - cospi_20_64 , cospi_12_64 ) ; const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32 ( DCT_CONST_ROUNDING ) ; __m128i u0 , u1 , u2 , u3 , u4 , u5 , u6 , u7 ; __m128i v0 , v1 , v2 , v3 , v4 , v5 , v6 , v7 ; __m128i s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ; s0 = _mm_add_epi16 ( in [ 0 ] , in [ 7 ] ) ; s1 = _mm_add_epi16 ( in [ 1 ] , in [ 6 ] ) ; s2 = _mm_add_epi16 ( in [ 2 ] , in [ 5 ] ) ; s3 = _mm_add_epi16 ( in [ 3 ] , in [ 4 ] ) ; s4 = _mm_sub_epi16 ( in [ 3 ] , in [ 4 ] ) ; s5 = _mm_sub_epi16 ( in [ 2 ] , in [ 5 ] ) ; s6 = _mm_sub_epi16 ( in [ 1 ] , in [ 6 ] ) ; s7 = _mm_sub_epi16 ( in [ 0 ] , in [ 7 ] ) ; u0 = _mm_add_epi16 ( s0 , s3 ) ; u1 = _mm_add_epi16 ( s1 , s2 ) ; u2 = _mm_sub_epi16 ( s1 , s2 ) ; u3 = _mm_sub_epi16 ( s0 , s3 ) ; v0 = _mm_unpacklo_epi16 ( u0 , u1 ) ; v1 = _mm_unpackhi_epi16 ( u0 , u1 ) ; v2 = _mm_unpacklo_epi16 ( u2 , u3 ) ; v3 = _mm_unpackhi_epi16 ( u2 , u3 ) ; u0 = _mm_madd_epi16 ( v0 , k__cospi_p16_p16 ) ; u1 = _mm_madd_epi16 ( v1 , k__cospi_p16_p16 ) ; u2 = _mm_madd_epi16 ( v0 , k__cospi_p16_m16 ) ; u3 = _mm_madd_epi16 ( v1 , k__cospi_p16_m16 ) ; u4 = _mm_madd_epi16 ( v2 , k__cospi_p24_p08 ) ; u5 = _mm_madd_epi16 ( v3 , k__cospi_p24_p08 ) ; u6 = _mm_madd_epi16 ( v2 , k__cospi_m08_p24 ) ; u7 = _mm_madd_epi16 ( v3 , k__cospi_m08_p24 ) ; v0 = _mm_add_epi32 ( u0 , k__DCT_CONST_ROUNDING ) ; v1 = _mm_add_epi32 ( u1 , k__DCT_CONST_ROUNDING ) ; v2 = _mm_add_epi32 ( u2 , k__DCT_CONST_ROUNDING ) ; v3 = _mm_add_epi32 ( u3 , k__DCT_CONST_ROUNDING ) ; v4 = _mm_add_epi32 ( u4 , k__DCT_CONST_ROUNDING ) ; v5 = _mm_add_epi32 ( u5 , k__DCT_CONST_ROUNDING ) ; v6 = _mm_add_epi32 ( u6 , k__DCT_CONST_ROUNDING ) ; v7 = _mm_add_epi32 ( u7 , k__DCT_CONST_ROUNDING ) ; u0 = _mm_srai_epi32 ( v0 , DCT_CONST_BITS ) ; u1 = _mm_srai_epi32 ( v1 , DCT_CONST_BITS ) ; u2 = _mm_srai_epi32 ( v2 , DCT_CONST_BITS ) ; u3 = _mm_srai_epi32 ( v3 , DCT_CONST_BITS ) ; u4 = _mm_srai_epi32 ( v4 , DCT_CONST_BITS ) ; u5 = _mm_srai_epi32 ( v5 , DCT_CONST_BITS ) ; u6 = _mm_srai_epi32 ( v6 , DCT_CONST_BITS ) ; u7 = _mm_srai_epi32 ( v7 , DCT_CONST_BITS ) ; in [ 0 ] = _mm_packs_epi32 ( u0 , u1 ) ; in [ 2 ] = _mm_packs_epi32 ( u4 , u5 ) ; in [ 4 ] = _mm_packs_epi32 ( u2 , u3 ) ; in [ 6 ] = _mm_packs_epi32 ( u6 , u7 ) ; u0 = _mm_unpacklo_epi16 ( s6 , s5 ) ; u1 = _mm_unpackhi_epi16 ( s6 , s5 ) ; v0 = _mm_madd_epi16 ( u0 , k__cospi_p16_m16 ) ; v1 = _mm_madd_epi16 ( u1 , k__cospi_p16_m16 ) ; v2 = _mm_madd_epi16 ( u0 , k__cospi_p16_p16 ) ; v3 = _mm_madd_epi16 ( u1 , k__cospi_p16_p16 ) ; u0 = _mm_add_epi32 ( v0 , k__DCT_CONST_ROUNDING ) ; u1 = _mm_add_epi32 ( v1 , k__DCT_CONST_ROUNDING ) ; u2 = _mm_add_epi32 ( v2 , k__DCT_CONST_ROUNDING ) ; u3 = _mm_add_epi32 ( v3 , k__DCT_CONST_ROUNDING ) ; v0 = _mm_srai_epi32 ( u0 , DCT_CONST_BITS ) ; v1 = _mm_srai_epi32 ( u1 , DCT_CONST_BITS ) ; v2 = _mm_srai_epi32 ( u2 , DCT_CONST_BITS ) ; v3 = _mm_srai_epi32 ( u3 , DCT_CONST_BITS ) ; u0 = _mm_packs_epi32 ( v0 , v1 ) ; u1 = _mm_packs_epi32 ( v2 , v3 ) ; s0 = _mm_add_epi16 ( s4 , u0 ) ; s1 = _mm_sub_epi16 ( s4 , u0 ) ; s2 = _mm_sub_epi16 ( s7 , u1 ) ; s3 = _mm_add_epi16 ( s7 , u1 ) ; u0 = _mm_unpacklo_epi16 ( s0 , s3 ) ; u1 = _mm_unpackhi_epi16 ( s0 , s3 ) ; u2 = _mm_unpacklo_epi16 ( s1 , s2 ) ; u3 = _mm_unpackhi_epi16 ( s1 , s2 ) ; v0 = _mm_madd_epi16 ( u0 , k__cospi_p28_p04 ) ; v1 = _mm_madd_epi16 ( u1 , k__cospi_p28_p04 ) ; v2 = _mm_madd_epi16 ( u2 , k__cospi_p12_p20 ) ; v3 = _mm_madd_epi16 ( u3 , k__cospi_p12_p20 ) ; v4 = _mm_madd_epi16 ( u2 , k__cospi_m20_p12 ) ; v5 = _mm_madd_epi16 ( u3 , k__cospi_m20_p12 ) ; v6 = _mm_madd_epi16 ( u0 , k__cospi_m04_p28 ) ; v7 = _mm_madd_epi16 ( u1 , k__cospi_m04_p28 ) ; u0 = _mm_add_epi32 ( v0 , k__DCT_CONST_ROUNDING ) ; u1 = _mm_add_epi32 ( v1 , k__DCT_CONST_ROUNDING ) ; u2 = _mm_add_epi32 ( v2 , k__DCT_CONST_ROUNDING ) ; u3 = _mm_add_epi32 ( v3 , k__DCT_CONST_ROUNDING ) ; u4 = _mm_add_epi32 ( v4 , k__DCT_CONST_ROUNDING ) ; u5 = _mm_add_epi32 ( v5 , k__DCT_CONST_ROUNDING ) ; u6 = _mm_add_epi32 ( v6 , k__DCT_CONST_ROUNDING ) ; u7 = _mm_add_epi32 ( v7 , k__DCT_CONST_ROUNDING ) ; v0 = _mm_srai_epi32 ( u0 , DCT_CONST_BITS ) ; v1 = _mm_srai_epi32 ( u1 , DCT_CONST_BITS ) ; v2 = _mm_srai_epi32 ( u2 , DCT_CONST_BITS ) ; v3 = _mm_srai_epi32 ( u3 , DCT_CONST_BITS ) ; v4 = _mm_srai_epi32 ( u4 , DCT_CONST_BITS ) ; v5 = _mm_srai_epi32 ( u5 , DCT_CONST_BITS ) ; v6 = _mm_srai_epi32 ( u6 , DCT_CONST_BITS ) ; v7 = _mm_srai_epi32 ( u7 , DCT_CONST_BITS ) ; in [ 1 ] = _mm_packs_epi32 ( v0 , v1 ) ; in [ 3 ] = _mm_packs_epi32 ( v4 , v5 ) ; in [ 5 ] = _mm_packs_epi32 ( v2 , v3 ) ; in [ 7 ] = _mm_packs_epi32 ( v6 , v7 ) ; array_transpose_8x8 ( in , in ) ; }\n", "\n", "2: CWE-119 void fdct4_sse2 ( __m128i * in ) { const __m128i k__cospi_p16_p16 = _mm_set1_epi16 ( cospi_16_64 ) ; const __m128i k__cospi_p16_m16 = pair_set_epi16 ( cospi_16_64 , - cospi_16_64 ) ; const __m128i k__cospi_p08_p24 = pair_set_epi16 ( cospi_8_64 , cospi_24_64 ) ; const __m128i k__cospi_p24_m08 = pair_set_epi16 ( cospi_24_64 , - cospi_8_64 ) ; const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32 ( DCT_CONST_ROUNDING ) ; __m128i u [ 4 ] , v [ 4 ] ; u [ 0 ] = _mm_unpacklo_epi16 ( in [ 0 ] , in [ 1 ] ) ; u [ 1 ] = _mm_unpacklo_epi16 ( in [ 3 ] , in [ 2 ] ) ; v [ 0 ] = _mm_add_epi16 ( u [ 0 ] , u [ 1 ] ) ; v [ 1 ] = _mm_sub_epi16 ( u [ 0 ] , u [ 1 ] ) ; u [ 0 ] = _mm_madd_epi16 ( v [ 0 ] , k__cospi_p16_p16 ) ; u [ 1 ] = _mm_madd_epi16 ( v [ 0 ] , k__cospi_p16_m16 ) ; u [ 2 ] = _mm_madd_epi16 ( v [ 1 ] , k__cospi_p08_p24 ) ; u [ 3 ] = _mm_madd_epi16 ( v [ 1 ] , k__cospi_p24_m08 ) ; v [ 0 ] = _mm_add_epi32 ( u [ 0 ] , k__DCT_CONST_ROUNDING ) ; v [ 1 ] = _mm_add_epi32 ( u [ 1 ] , k__DCT_CONST_ROUNDING ) ; v [ 2 ] = _mm_add_epi32 ( u [ 2 ] , k__DCT_CONST_ROUNDING ) ; v [ 3 ] = _mm_add_epi32 ( u [ 3 ] , k__DCT_CONST_ROUNDING ) ; u [ 0 ] = _mm_srai_epi32 ( v [ 0 ] , DCT_CONST_BITS ) ; u [ 1 ] = _mm_srai_epi32 ( v [ 1 ] , DCT_CONST_BITS ) ; u [ 2 ] = _mm_srai_epi32 ( v [ 2 ] , DCT_CONST_BITS ) ; u [ 3 ] = _mm_srai_epi32 ( v [ 3 ] , DCT_CONST_BITS ) ; in [ 0 ] = _mm_packs_epi32 ( u [ 0 ] , u [ 1 ] ) ; in [ 1 ] = _mm_packs_epi32 ( u [ 2 ] , u [ 3 ] ) ; transpose_4x4 ( in ) ; }\n", "\n", "3: CWE-119 void fadst8_sse2 ( __m128i * in ) { const __m128i k__cospi_p02_p30 = pair_set_epi16 ( cospi_2_64 , cospi_30_64 ) ; const __m128i k__cospi_p30_m02 = pair_set_epi16 ( cospi_30_64 , - cospi_2_64 ) ; const __m128i k__cospi_p10_p22 = pair_set_epi16 ( cospi_10_64 , cospi_22_64 ) ; const __m128i k__cospi_p22_m10 = pair_set_epi16 ( cospi_22_64 , - cospi_10_64 ) ; const __m128i k__cospi_p18_p14 = pair_set_epi16 ( cospi_18_64 , cospi_14_64 ) ; const __m128i k__cospi_p14_m18 = pair_set_epi16 ( cospi_14_64 , - cospi_18_64 ) ; const __m128i k__cospi_p26_p06 = pair_set_epi16 ( cospi_26_64 , cospi_6_64 ) ; const __m128i k__cospi_p06_m26 = pair_set_epi16 ( cospi_6_64 , - cospi_26_64 ) ; const __m128i k__cospi_p08_p24 = pair_set_epi16 ( cospi_8_64 , cospi_24_64 ) ; const __m128i k__cospi_p24_m08 = pair_set_epi16 ( cospi_24_64 , - cospi_8_64 ) ; const __m128i k__cospi_m24_p08 = pair_set_epi16 ( - cospi_24_64 , cospi_8_64 ) ; const __m128i k__cospi_p16_m16 = pair_set_epi16 ( cospi_16_64 , - cospi_16_64 ) ; const __m128i k__cospi_p16_p16 = _mm_set1_epi16 ( cospi_16_64 ) ; const __m128i k__const_0 = _mm_set1_epi16 ( 0 ) ; const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32 ( DCT_CONST_ROUNDING ) ; __m128i u0 , u1 , u2 , u3 , u4 , u5 , u6 , u7 , u8 , u9 , u10 , u11 , u12 , u13 , u14 , u15 ; __m128i v0 , v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 ; __m128i w0 , w1 , w2 , w3 , w4 , w5 , w6 , w7 , w8 , w9 , w10 , w11 , w12 , w13 , w14 , w15 ; __m128i s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ; __m128i in0 , in1 , in2 , in3 , in4 , in5 , in6 , in7 ; in0 = in [ 7 ] ; in1 = in [ 0 ] ; in2 = in [ 5 ] ; in3 = in [ 2 ] ; in4 = in [ 3 ] ; in5 = in [ 4 ] ; in6 = in [ 1 ] ; in7 = in [ 6 ] ; s0 = _mm_unpacklo_epi16 ( in0 , in1 ) ; s1 = _mm_unpackhi_epi16 ( in0 , in1 ) ; s2 = _mm_unpacklo_epi16 ( in2 , in3 ) ; s3 = _mm_unpackhi_epi16 ( in2 , in3 ) ; s4 = _mm_unpacklo_epi16 ( in4 , in5 ) ; s5 = _mm_unpackhi_epi16 ( in4 , in5 ) ; s6 = _mm_unpacklo_epi16 ( in6 , in7 ) ; s7 = _mm_unpackhi_epi16 ( in6 , in7 ) ; u0 = _mm_madd_epi16 ( s0 , k__cospi_p02_p30 ) ; u1 = _mm_madd_epi16 ( s1 , k__cospi_p02_p30 ) ; u2 = _mm_madd_epi16 ( s0 , k__cospi_p30_m02 ) ; u3 = _mm_madd_epi16 ( s1 , k__cospi_p30_m02 ) ; u4 = _mm_madd_epi16 ( s2 , k__cospi_p10_p22 ) ; u5 = _mm_madd_epi16 ( s3 , k__cospi_p10_p22 ) ; u6 = _mm_madd_epi16 ( s2 , k__cospi_p22_m10 ) ; u7 = _mm_madd_epi16 ( s3 , k__cospi_p22_m10 ) ; u8 = _mm_madd_epi16 ( s4 , k__cospi_p18_p14 ) ; u9 = _mm_madd_epi16 ( s5 , k__cospi_p18_p14 ) ; u10 = _mm_madd_epi16 ( s4 , k__cospi_p14_m18 ) ; u11 = _mm_madd_epi16 ( s5 , k__cospi_p14_m18 ) ; u12 = _mm_madd_epi16 ( s6 , k__cospi_p26_p06 ) ; u13 = _mm_madd_epi16 ( s7 , k__cospi_p26_p06 ) ; u14 = _mm_madd_epi16 ( s6 , k__cospi_p06_m26 ) ; u15 = _mm_madd_epi16 ( s7 , k__cospi_p06_m26 ) ; w0 = _mm_add_epi32 ( u0 , u8 ) ; w1 = _mm_add_epi32 ( u1 , u9 ) ; w2 = _mm_add_epi32 ( u2 , u10 ) ; w3 = _mm_add_epi32 ( u3 , u11 ) ; w4 = _mm_add_epi32 ( u4 , u12 ) ; w5 = _mm_add_epi32 ( u5 , u13 ) ; w6 = _mm_add_epi32 ( u6 , u14 ) ; w7 = _mm_add_epi32 ( u7 , u15 ) ; w8 = _mm_sub_epi32 ( u0 , u8 ) ; w9 = _mm_sub_epi32 ( u1 , u9 ) ; w10 = _mm_sub_epi32 ( u2 , u10 ) ; w11 = _mm_sub_epi32 ( u3 , u11 ) ; w12 = _mm_sub_epi32 ( u4 , u12 ) ; w13 = _mm_sub_epi32 ( u5 , u13 ) ; w14 = _mm_sub_epi32 ( u6 , u14 ) ; w15 = _mm_sub_epi32 ( u7 , u15 ) ; v0 = _mm_add_epi32 ( w0 , k__DCT_CONST_ROUNDING ) ; v1 = _mm_add_epi32 ( w1 , k__DCT_CONST_ROUNDING ) ; v2 = _mm_add_epi32 ( w2 , k__DCT_CONST_ROUNDING ) ; v3 = _mm_add_epi32 ( w3 , k__DCT_CONST_ROUNDING ) ; v4 = _mm_add_epi32 ( w4 , k__DCT_CONST_ROUNDING ) ; v5 = _mm_add_epi32 ( w5 , k__DCT_CONST_ROUNDING ) ; v6 = _mm_add_epi32 ( w6 , k__DCT_CONST_ROUNDING ) ; v7 = _mm_add_epi32 ( w7 , k__DCT_CONST_ROUNDING ) ; v8 = _mm_add_epi32 ( w8 , k__DCT_CONST_ROUNDING ) ; v9 = _mm_add_epi32 ( w9 , k__DCT_CONST_ROUNDING ) ; v10 = _mm_add_epi32 ( w10 , k__DCT_CONST_ROUNDING ) ; v11 = _mm_add_epi32 ( w11 , k__DCT_CONST_ROUNDING ) ; v12 = _mm_add_epi32 ( w12 , k__DCT_CONST_ROUNDING ) ; v13 = _mm_add_epi32 ( w13 , k__DCT_CONST_ROUNDING ) ; v14 = _mm_add_epi32 ( w14 , k__DCT_CONST_ROUNDING ) ; v15 = _mm_add_epi32 ( w15 , k__DCT_CONST_ROUNDING ) ; u0 = _mm_srai_epi32 ( v0 , DCT_CONST_BITS ) ; u1 = _mm_srai_epi32 ( v1 , DCT_CONST_BITS ) ; u2 = _mm_srai_epi32 ( v2 , DCT_CONST_BITS ) ; u3 = _mm_srai_epi32 ( v3 , DCT_CONST_BITS ) ; u4 = _mm_srai_epi32 ( v4 , DCT_CONST_BITS ) ; u5 = _mm_srai_epi32 ( v5 , DCT_CONST_BITS ) ; u6 = _mm_srai_epi32 ( v6 , DCT_CONST_BITS ) ; u7 = _mm_srai_epi32 ( v7 , DCT_CONST_BITS ) ; u8 = _mm_srai_epi32 ( v8 , DCT_CONST_BITS ) ; u9 = _mm_srai_epi32 ( v9 , DCT_CONST_BITS ) ; u10 = _mm_srai_epi32 ( v10 , DCT_CONST_BITS ) ; u11 = _mm_srai_epi32 ( v11 , DCT_CONST_BITS ) ; u12 = _mm_srai_epi32 ( v12 , DCT_CONST_BITS ) ; u13 = _mm_srai_epi32 ( v13 , DCT_CONST_BITS ) ; u14 = _mm_srai_epi32 ( v14 , DCT_CONST_BITS ) ; u15 = _mm_srai_epi32 ( v15 , DCT_CONST_BITS ) ; in [ 0 ] = _mm_packs_epi32 ( u0 , u1 ) ; in [ 1 ] = _mm_packs_epi32 ( u2 , u3 ) ; in [ 2 ] = _mm_packs_epi32 ( u4 , u5 ) ; in [ 3 ] = _mm_packs_epi32 ( u6 , u7 ) ; in [ 4 ] = _mm_packs_epi32 ( u8 , u9 ) ; in [ 5 ] = _mm_packs_epi32 ( u10 , u11 ) ; in [ 6 ] = _mm_packs_epi32 ( u12 , u13 ) ; in [ 7 ] = _mm_packs_epi32 ( u14 , u15 ) ; s0 = _mm_add_epi16 ( in [ 0 ] , in [ 2 ] ) ; s1 = _mm_add_epi16 ( in [ 1 ] , in [ 3 ] ) ; s2 = _mm_sub_epi16 ( in [ 0 ] , in [ 2 ] ) ; s3 = _mm_sub_epi16 ( in [ 1 ] , in [ 3 ] ) ; u0 = _mm_unpacklo_epi16 ( in [ 4 ] , in [ 5 ] ) ; u1 = _mm_unpackhi_epi16 ( in [ 4 ] , in [ 5 ] ) ; u2 = _mm_unpacklo_epi16 ( in [ 6 ] , in [ 7 ] ) ; u3 = _mm_unpackhi_epi16 ( in [ 6 ] , in [ 7 ] ) ; v0 = _mm_madd_epi16 ( u0 , k__cospi_p08_p24 ) ; v1 = _mm_madd_epi16 ( u1 , k__cospi_p08_p24 ) ; v2 = _mm_madd_epi16 ( u0 , k__cospi_p24_m08 ) ; v3 = _mm_madd_epi16 ( u1 , k__cospi_p24_m08 ) ; v4 = _mm_madd_epi16 ( u2 , k__cospi_m24_p08 ) ; v5 = _mm_madd_epi16 ( u3 , k__cospi_m24_p08 ) ; v6 = _mm_madd_epi16 ( u2 , k__cospi_p08_p24 ) ; v7 = _mm_madd_epi16 ( u3 , k__cospi_p08_p24 ) ; w0 = _mm_add_epi32 ( v0 , v4 ) ; w1 = _mm_add_epi32 ( v1 , v5 ) ; w2 = _mm_add_epi32 ( v2 , v6 ) ; w3 = _mm_add_epi32 ( v3 , v7 ) ; w4 = _mm_sub_epi32 ( v0 , v4 ) ; w5 = _mm_sub_epi32 ( v1 , v5 ) ; w6 = _mm_sub_epi32 ( v2 , v6 ) ; w7 = _mm_sub_epi32 ( v3 , v7 ) ; v0 = _mm_add_epi32 ( w0 , k__DCT_CONST_ROUNDING ) ; v1 = _mm_add_epi32 ( w1 , k__DCT_CONST_ROUNDING ) ; v2 = _mm_add_epi32 ( w2 , k__DCT_CONST_ROUNDING ) ; v3 = _mm_add_epi32 ( w3 , k__DCT_CONST_ROUNDING ) ; v4 = _mm_add_epi32 ( w4 , k__DCT_CONST_ROUNDING ) ; v5 = _mm_add_epi32 ( w5 , k__DCT_CONST_ROUNDING ) ; v6 = _mm_add_epi32 ( w6 , k__DCT_CONST_ROUNDING ) ; v7 = _mm_add_epi32 ( w7 , k__DCT_CONST_ROUNDING ) ; u0 = _mm_srai_epi32 ( v0 , DCT_CONST_BITS ) ; u1 = _mm_srai_epi32 ( v1 , DCT_CONST_BITS ) ; u2 = _mm_srai_epi32 ( v2 , DCT_CONST_BITS ) ; u3 = _mm_srai_epi32 ( v3 , DCT_CONST_BITS ) ; u4 = _mm_srai_epi32 ( v4 , DCT_CONST_BITS ) ; u5 = _mm_srai_epi32 ( v5 , DCT_CONST_BITS ) ; u6 = _mm_srai_epi32 ( v6 , DCT_CONST_BITS ) ; u7 = _mm_srai_epi32 ( v7 , DCT_CONST_BITS ) ; s4 = _mm_packs_epi32 ( u0 , u1 ) ; s5 = _mm_packs_epi32 ( u2 , u3 ) ; s6 = _mm_packs_epi32 ( u4 , u5 ) ; s7 = _mm_packs_epi32 ( u6 , u7 ) ; u0 = _mm_unpacklo_epi16 ( s2 , s3 ) ; u1 = _mm_unpackhi_epi16 ( s2 , s3 ) ; u2 = _mm_unpacklo_epi16 ( s6 , s7 ) ; u3 = _mm_unpackhi_epi16 ( s6 , s7 ) ; v0 = _mm_madd_epi16 ( u0 , k__cospi_p16_p16 ) ; v1 = _mm_madd_epi16 ( u1 , k__cospi_p16_p16 ) ; v2 = _mm_madd_epi16 ( u0 , k__cospi_p16_m16 ) ; v3 = _mm_madd_epi16 ( u1 , k__cospi_p16_m16 ) ; v4 = _mm_madd_epi16 ( u2 , k__cospi_p16_p16 ) ; v5 = _mm_madd_epi16 ( u3 , k__cospi_p16_p16 ) ; v6 = _mm_madd_epi16 ( u2 , k__cospi_p16_m16 ) ; v7 = _mm_madd_epi16 ( u3 , k__cospi_p16_m16 ) ; u0 = _mm_add_epi32 ( v0 , k__DCT_CONST_ROUNDING ) ; u1 = _mm_add_epi32 ( v1 , k__DCT_CONST_ROUNDING ) ; u2 = _mm_add_epi32 ( v2 , k__DCT_CONST_ROUNDING ) ; u3 = _mm_add_epi32 ( v3 , k__DCT_CONST_ROUNDING ) ; u4 = _mm_add_epi32 ( v4 , k__DCT_CONST_ROUNDING ) ; u5 = _mm_add_epi32 ( v5 , k__DCT_CONST_ROUNDING ) ; u6 = _mm_add_epi32 ( v6 , k__DCT_CONST_ROUNDING ) ; u7 = _mm_add_epi32 ( v7 , k__DCT_CONST_ROUNDING ) ; v0 = _mm_srai_epi32 ( u0 , DCT_CONST_BITS ) ; v1 = _mm_srai_epi32 ( u1 , DCT_CONST_BITS ) ; v2 = _mm_srai_epi32 ( u2 , DCT_CONST_BITS ) ; v3 = _mm_srai_epi32 ( u3 , DCT_CONST_BITS ) ; v4 = _mm_srai_epi32 ( u4 , DCT_CONST_BITS ) ; v5 = _mm_srai_epi32 ( u5 , DCT_CONST_BITS ) ; v6 = _mm_srai_epi32 ( u6 , DCT_CONST_BITS ) ; v7 = _mm_srai_epi32 ( u7 , DCT_CONST_BITS ) ; s2 = _mm_packs_epi32 ( v0 , v1 ) ; s3 = _mm_packs_epi32 ( v2 , v3 ) ; s6 = _mm_packs_epi32 ( v4 , v5 ) ; s7 = _mm_packs_epi32 ( v6 , v7 ) ; in [ 0 ] = s0 ; in [ 1 ] = _mm_sub_epi16 ( k__const_0 , s4 ) ; in [ 2 ] = s6 ; in [ 3 ] = _mm_sub_epi16 ( k__const_0 , s2 ) ; in [ 4 ] = s3 ; in [ 5 ] = _mm_sub_epi16 ( k__const_0 , s7 ) ; in [ 6 ] = s5 ; in [ 7 ] = _mm_sub_epi16 ( k__const_0 , s1 ) ; array_transpose_8x8 ( in , in ) ; }\n", "\n", "\n", "Target: ( decoder -> codec_interface ( ) ) , decoder -> codec_interface ( ) ,\n", "\n", "Sources:\n", "0: CWE-119 int main ( int argc , char * * argv ) { int frame_cnt = 0 ; FILE * outfile = NULL ; vpx_codec_ctx_t codec ; VpxVideoReader * reader = NULL ; const VpxInterface * decoder = NULL ; const VpxVideoInfo * info = NULL ; exec_name = argv [ 0 ] ; if ( argc != 3 ) die ( \"Invalidnumberofarguments.\" ) ; reader = vpx_video_reader_open ( argv [ 1 ] ) ; if ( ! reader ) die ( \"Failedtoopen%sforreading.\" , argv [ 1 ] ) ; if ( ! ( outfile = fopen ( argv [ 2 ] , \"wb\" ) ) ) die ( \"Failedtoopen%sforwriting.\" , argv [ 2 ] ) ; info = vpx_video_reader_get_info ( reader ) ; decoder = get_vpx_decoder_by_fourcc ( info -> codec_fourcc ) ; if ( ! decoder ) die ( \"Unknowninputcodec.\" ) ; printf ( \"Using%s\\\\n\" , vpx_codec_iface_name ( decoder -> interface ( ) ) ) ; if ( vpx_codec_dec_init ( & codec , decoder -> interface ( ) , NULL , 0 ) ) die_codec ( & codec , \"Failedtoinitializedecoder.\" ) ; while ( vpx_video_reader_read_frame ( reader ) ) { vpx_codec_iter_t iter = NULL ; vpx_image_t * img = NULL ; size_t frame_size = 0 ; const unsigned char * frame = vpx_video_reader_get_frame ( reader , & frame_size ) ; if ( vpx_codec_decode ( & codec , frame , ( unsigned int ) frame_size , NULL , 0 ) ) die_codec ( & codec , \"Failedtodecodeframe.\" ) ; while ( ( img = vpx_codec_get_frame ( & codec , & iter ) ) != NULL ) { vpx_img_write ( img , outfile ) ; ++ frame_cnt ; } } printf ( \"Processed%dframes.\\\\n\" , frame_cnt ) ; if ( vpx_codec_destroy ( & codec ) ) die_codec ( & codec , \"Failedtodestroycodec\" ) ; printf ( \"Play:ffplay-frawvideo-pix_fmtyuv420p-s%dx%d%s\\\\n\" , info -> frame_width , info -> frame_height , argv [ 2 ] ) ; vpx_video_reader_close ( reader ) ; fclose ( outfile ) ; return EXIT_SUCCESS ; }\n", "\n", "1: CWE-119 int main ( int argc , char * * argv ) { int frame_cnt = 0 ; FILE * outfile = NULL ; vpx_codec_ctx_t codec ; VpxVideoReader * reader = NULL ; const VpxVideoInfo * info = NULL ; const VpxInterface * decoder = NULL ; exec_name = argv [ 0 ] ; if ( argc != 3 ) die ( \"Invalidnumberofarguments.\" ) ; reader = vpx_video_reader_open ( argv [ 1 ] ) ; if ( ! reader ) die ( \"Failedtoopen%sforreading.\" , argv [ 1 ] ) ; if ( ! ( outfile = fopen ( argv [ 2 ] , \"wb\" ) ) ) die ( \"Failedtoopen%sforwriting.\" , argv [ 2 ] ) ; info = vpx_video_reader_get_info ( reader ) ; decoder = get_vpx_decoder_by_fourcc ( info -> codec_fourcc ) ; if ( ! decoder ) die ( \"Unknowninputcodec.\" ) ; printf ( \"Using%s\\\\n\" , vpx_codec_iface_name ( decoder -> interface ( ) ) ) ; if ( vpx_codec_dec_init ( & codec , decoder -> interface ( ) , NULL , 0 ) ) die_codec ( & codec , \"Failedtoinitializedecoder\" ) ; while ( vpx_video_reader_read_frame ( reader ) ) { vpx_codec_iter_t iter = NULL ; vpx_image_t * img = NULL ; size_t frame_size = 0 ; const unsigned char * frame = vpx_video_reader_get_frame ( reader , & frame_size ) ; if ( vpx_codec_decode ( & codec , frame , ( unsigned int ) frame_size , NULL , 0 ) ) die_codec ( & codec , \"Failedtodecodeframe\" ) ; while ( ( img = vpx_codec_get_frame ( & codec , & iter ) ) != NULL ) { unsigned char digest [ 16 ] ; get_image_md5 ( img , digest ) ; print_md5 ( outfile , digest ) ; fprintf ( outfile , \"img-%dx%d-%04d.i420\\\\n\" , img -> d_w , img -> d_h , ++ frame_cnt ) ; } } printf ( \"Processed%dframes.\\\\n\" , frame_cnt ) ; if ( vpx_codec_destroy ( & codec ) ) die_codec ( & codec , \"Failedtodestroycodec.\" ) ; vpx_video_reader_close ( reader ) ; fclose ( outfile ) ; return EXIT_SUCCESS ; }\n", "\n", "2: CWE-119 int main ( int argc , char * * argv ) { int frame_cnt = 0 ; FILE * outfile = NULL ; vpx_codec_ctx_t codec ; const VpxInterface * decoder = NULL ; VpxVideoReader * reader = NULL ; const VpxVideoInfo * info = NULL ; int n = 0 ; int m = 0 ; int is_range = 0 ; char * nptr = NULL ; exec_name = argv [ 0 ] ; if ( argc != 4 ) die ( \"Invalidnumberofarguments.\" ) ; reader = vpx_video_reader_open ( argv [ 1 ] ) ; if ( ! reader ) die ( \"Failedtoopen%sforreading.\" , argv [ 1 ] ) ; if ( ! ( outfile = fopen ( argv [ 2 ] , \"wb\" ) ) ) die ( \"Failedtoopen%sforwriting.\" , argv [ 2 ] ) ; n = strtol ( argv [ 3 ] , & nptr , 0 ) ; m = strtol ( nptr + 1 , NULL , 0 ) ; is_range = ( * nptr == '-' ) ; if ( ! n || ! m || ( * nptr != '-' && * nptr != '/' ) ) die ( \"Couldn\\'tparsepattern%s.\\\\n\" , argv [ 3 ] ) ; info = vpx_video_reader_get_info ( reader ) ; decoder = get_vpx_decoder_by_fourcc ( info -> codec_fourcc ) ; if ( ! decoder ) die ( \"Unknowninputcodec.\" ) ; printf ( \"Using%s\\\\n\" , vpx_codec_iface_name ( decoder -> interface ( ) ) ) ; if ( vpx_codec_dec_init ( & codec , decoder -> interface ( ) , NULL , 0 ) ) die_codec ( & codec , \"Failedtoinitializedecoder.\" ) ; while ( vpx_video_reader_read_frame ( reader ) ) { vpx_codec_iter_t iter = NULL ; vpx_image_t * img = NULL ; size_t frame_size = 0 ; int skip ; const unsigned char * frame = vpx_video_reader_get_frame ( reader , & frame_size ) ; if ( vpx_codec_decode ( & codec , frame , ( unsigned int ) frame_size , NULL , 0 ) ) die_codec ( & codec , \"Failedtodecodeframe.\" ) ; ++ frame_cnt ; skip = ( is_range && frame_cnt >= n && frame_cnt <= m ) || ( ! is_range && m - ( frame_cnt - 1 ) % m <= n ) ; if ( ! skip ) { putc ( '.' , stdout ) ; while ( ( img = vpx_codec_get_frame ( & codec , & iter ) ) != NULL ) vpx_img_write ( img , outfile ) ; } else { putc ( 'X' , stdout ) ; } fflush ( stdout ) ; } printf ( \"Processed%dframes.\\\\n\" , frame_cnt ) ; if ( vpx_codec_destroy ( & codec ) ) die_codec ( & codec , \"Failedtodestroycodec.\" ) ; printf ( \"Play:ffplay-frawvideo-pix_fmtyuv420p-s%dx%d%s\\\\n\" , info -> frame_width , info -> frame_height , argv [ 2 ] ) ; vpx_video_reader_close ( reader ) ; fclose ( outfile ) ; return EXIT_SUCCESS ; }\n", "\n", "3: CWE-119 int main ( int argc , char * * argv ) { int frame_cnt = 0 ; FILE * outfile = NULL ; vpx_codec_ctx_t codec ; vpx_codec_err_t res ; VpxVideoReader * reader = NULL ; const VpxInterface * decoder = NULL ; const VpxVideoInfo * info = NULL ; exec_name = argv [ 0 ] ; if ( argc != 3 ) die ( \"Invalidnumberofarguments.\" ) ; reader = vpx_video_reader_open ( argv [ 1 ] ) ; if ( ! reader ) die ( \"Failedtoopen%sforreading.\" , argv [ 1 ] ) ; if ( ! ( outfile = fopen ( argv [ 2 ] , \"wb\" ) ) ) die ( \"Failedtoopen%sforwriting\" , argv [ 2 ] ) ; info = vpx_video_reader_get_info ( reader ) ; decoder = get_vpx_decoder_by_fourcc ( info -> codec_fourcc ) ; if ( ! decoder ) die ( \"Unknowninputcodec.\" ) ; printf ( \"Using%s\\\\n\" , vpx_codec_iface_name ( decoder -> interface ( ) ) ) ; res = vpx_codec_dec_init ( & codec , decoder -> interface ( ) , NULL , VPX_CODEC_USE_POSTPROC ) ; if ( res == VPX_CODEC_INCAPABLE ) die_codec ( & codec , \"Postprocnotsupportedbythisdecoder.\" ) ; if ( res ) die_codec ( & codec , \"Failedtoinitializedecoder.\" ) ; while ( vpx_video_reader_read_frame ( reader ) ) { vpx_codec_iter_t iter = NULL ; vpx_image_t * img = NULL ; size_t frame_size = 0 ; const unsigned char * frame = vpx_video_reader_get_frame ( reader , & frame_size ) ; ++ frame_cnt ; if ( frame_cnt % 30 == 1 ) { vp8_postproc_cfg_t pp = { 0 , 0 , 0 } ; if ( vpx_codec_control ( & codec , VP8_SET_POSTPROC , & pp ) ) die_codec ( & codec , \"Failedtoturnoffpostproc.\" ) ; } else if ( frame_cnt % 30 == 16 ) { vp8_postproc_cfg_t pp = { VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE , 4 , 0 } ; if ( vpx_codec_control ( & codec , VP8_SET_POSTPROC , & pp ) ) die_codec ( & codec , \"Failedtoturnonpostproc.\" ) ; } ; if ( vpx_codec_decode ( & codec , frame , ( unsigned int ) frame_size , NULL , 15000 ) ) die_codec ( & codec , \"Failedtodecodeframe\" ) ; while ( ( img = vpx_codec_get_frame ( & codec , & iter ) ) != NULL ) { vpx_img_write ( img , outfile ) ; } } printf ( \"Processed%dframes.\\\\n\" , frame_cnt ) ; if ( vpx_codec_destroy ( & codec ) ) die_codec ( & codec , \"Failedtodestroycodec\" ) ; printf ( \"Play:ffplay-frawvideo-pix_fmtyuv420p-s%dx%d%s\\\\n\" , info -> frame_width , info -> frame_height , argv [ 2 ] ) ; vpx_video_reader_close ( reader ) ; fclose ( outfile ) ; return EXIT_SUCCESS ; }\n", "\n", "\n", "Target: priv_flags &= ~ ( IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING ) ; dev ->\n", "\n", "Sources:\n", "0: CWE-264 void vlan_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> priv_flags |= IFF_802_1Q_VLAN ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; dev -> tx_queue_len = 0 ; dev -> netdev_ops = & vlan_netdev_ops ; dev -> destructor = free_netdev ; dev -> ethtool_ops = & vlan_ethtool_ops ; memset ( dev -> broadcast , 0 , ETH_ALEN ) ; }\n", "\n", "1: CWE-000 void vlan_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> priv_flags |= IFF_802_1Q_VLAN ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; dev -> tx_queue_len = 0 ; dev -> netdev_ops = & vlan_netdev_ops ; dev -> destructor = free_netdev ; dev -> ethtool_ops = & vlan_ethtool_ops ; memset ( dev -> broadcast , 0 , ETH_ALEN ) ; }\n", "\n", "2: CWE-264 void macvlan_common_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; dev -> netdev_ops = & macvlan_netdev_ops ; dev -> destructor = free_netdev ; dev -> header_ops = & macvlan_hard_header_ops , dev -> ethtool_ops = & macvlan_ethtool_ops ; }\n", "\n", "3: CWE-000 void macvlan_common_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; dev -> netdev_ops = & macvlan_netdev_ops ; dev -> destructor = free_netdev ; dev -> header_ops = & macvlan_hard_header_ops , dev -> ethtool_ops = & macvlan_ethtool_ops ; }\n", "\n", "\n", "Target: struct va_format vaf ; va_start ( dev ) , func , line , ( \"[0000:00:00.0]:[%s:%d]:%pV\" , func , line ,\n", "\n", "Sources:\n", "0: CWE-125 void qedi_dbg_info ( struct qedi_dbg_ctx * qedi , const char * func , u32 line , u32 level , const char * fmt , ... ) { va_list va ; struct va_format vaf ; char nfunc [ 32 ] ; memset ( nfunc , 0 , sizeof ( nfunc ) ) ; memcpy ( nfunc , func , sizeof ( nfunc ) - 1 ) ; va_start ( va , fmt ) ; vaf . fmt = fmt ; vaf . va = & va ; if ( ! ( qedi_dbg_log & level ) ) goto ret ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_info ( \"[%s]:[%s:%d]:%d:%pV\" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_info ( \"[0000:00:00.0]:[%s:%d]:%pV\" , nfunc , line , & vaf ) ; ret : va_end ( va ) ; }\n", "\n", "1: CWE-125 void qedi_dbg_err ( struct qedi_dbg_ctx * qedi , const char * func , u32 line , const char * fmt , ... ) { va_list va ; struct va_format vaf ; char nfunc [ 32 ] ; memset ( nfunc , 0 , sizeof ( nfunc ) ) ; memcpy ( nfunc , func , sizeof ( nfunc ) - 1 ) ; va_start ( va , fmt ) ; vaf . fmt = fmt ; vaf . va = & va ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_err ( \"[%s]:[%s:%d]:%d:%pV\" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_err ( \"[0000:00:00.0]:[%s:%d]:%pV\" , nfunc , line , & vaf ) ; va_end ( va ) ; }\n", "\n", "2: CWE-125 void qedi_dbg_warn ( struct qedi_dbg_ctx * qedi , const char * func , u32 line , const char * fmt , ... ) { va_list va ; struct va_format vaf ; char nfunc [ 32 ] ; memset ( nfunc , 0 , sizeof ( nfunc ) ) ; memcpy ( nfunc , func , sizeof ( nfunc ) - 1 ) ; va_start ( va , fmt ) ; vaf . fmt = fmt ; vaf . va = & va ; if ( ! ( qedi_dbg_log & QEDI_LOG_WARN ) ) goto ret ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_warn ( \"[%s]:[%s:%d]:%d:%pV\" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_warn ( \"[0000:00:00.0]:[%s:%d]:%pV\" , nfunc , line , & vaf ) ; ret : va_end ( va ) ; }\n", "\n", "3: CWE-125 void qedi_dbg_notice ( struct qedi_dbg_ctx * qedi , const char * func , u32 line , const char * fmt , ... ) { va_list va ; struct va_format vaf ; char nfunc [ 32 ] ; memset ( nfunc , 0 , sizeof ( nfunc ) ) ; memcpy ( nfunc , func , sizeof ( nfunc ) - 1 ) ; va_start ( va , fmt ) ; vaf . fmt = fmt ; vaf . va = & va ; if ( ! ( qedi_dbg_log & QEDI_LOG_NOTICE ) ) goto ret ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_notice ( \"[%s]:[%s:%d]:%d:%pV\" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_notice ( \"[0000:00:00.0]:[%s:%d]:%pV\" , nfunc , line , & vaf ) ; ret : va_end ( va ) ; }\n", "\n", "\n", "Target: Com_Printf ( \"Usage:writeconfig\\\\n\" ) ; return ; } if ( ! COM_CompareExtension ( filename , \".cfg\" ) ) { Com_Printf ( \"Com_WriteConfig_f:Onlythe\\\\\".cfg\\\\\"extensionissupportedbythiscommand!\\\\n\"\n", "\n", "Sources:\n", "0: CWE-000 void Com_WriteConfig_f ( void ) { char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"Usage:writeconfig\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".cfg\" ) ; Com_Printf ( \"Writing%s.\\\\n\" , filename ) ; Com_WriteConfigToFile ( filename ) ; }\n", "\n", "1: CWE-269 void Com_WriteConfig_f ( void ) { char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"Usage:writeconfig\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".cfg\" ) ; Com_Printf ( \"Writing%s.\\\\n\" , filename ) ; Com_WriteConfigToFile ( filename ) ; }\n", "\n", "\n", "Target: locked_vma ) { if ( page == check_page ) { mlock_vma_page ( page ) ; = SWAP_MLOCK ; } else if ( trylock_page ( page ) ) { mlock_vma_page ( page ) ; unlock_page ( page ) ; }\n", "\n", "Sources:\n", "0: CWE-264 static int try_to_unmap_cluster ( unsigned long cursor , unsigned int * mapcount , struct vm_area_struct * vma , struct page * check_page ) { struct mm_struct * mm = vma -> vm_mm ; pmd_t * pmd ; pte_t * pte ; pte_t pteval ; spinlock_t * ptl ; struct page * page ; unsigned long address ; unsigned long mmun_start ; unsigned long mmun_end ; unsigned long end ; int ret = SWAP_AGAIN ; int locked_vma = 0 ; address = ( vma -> vm_start + cursor ) & CLUSTER_MASK ; end = address + CLUSTER_SIZE ; if ( address < vma -> vm_start ) address = vma -> vm_start ; if ( end > vma -> vm_end ) end = vma -> vm_end ; pmd = mm_find_pmd ( mm , address ) ; if ( ! pmd ) return ret ; mmun_start = address ; mmun_end = end ; mmu_notifier_invalidate_range_start ( mm , mmun_start , mmun_end ) ; if ( down_read_trylock ( & vma -> vm_mm -> mmap_sem ) ) { locked_vma = ( vma -> vm_flags & VM_LOCKED ) ; if ( ! locked_vma ) up_read ( & vma -> vm_mm -> mmap_sem ) ; } pte = pte_offset_map_lock ( mm , pmd , address , & ptl ) ; update_hiwater_rss ( mm ) ; for ( ; address < end ; pte ++ , address += PAGE_SIZE ) { if ( ! pte_present ( * pte ) ) continue ; page = vm_normal_page ( vma , address , * pte ) ; BUG_ON ( ! page || PageAnon ( page ) ) ; if ( locked_vma ) { mlock_vma_page ( page ) ; if ( page == check_page ) ret = SWAP_MLOCK ; continue ; } if ( ptep_clear_flush_young_notify ( vma , address , pte ) ) continue ; flush_cache_page ( vma , address , pte_pfn ( * pte ) ) ; pteval = ptep_clear_flush ( vma , address , pte ) ; if ( page -> index != linear_page_index ( vma , address ) ) { pte_t ptfile = pgoff_to_pte ( page -> index ) ; if ( pte_soft_dirty ( pteval ) ) pte_file_mksoft_dirty ( ptfile ) ; set_pte_at ( mm , address , pte , ptfile ) ; } if ( pte_dirty ( pteval ) ) set_page_dirty ( page ) ; page_remove_rmap ( page ) ; page_cache_release ( page ) ; dec_mm_counter ( mm , MM_FILEPAGES ) ; ( * mapcount ) -- ; } pte_unmap_unlock ( pte - 1 , ptl ) ; mmu_notifier_invalidate_range_end ( mm , mmun_start , mmun_end ) ; if ( locked_vma ) up_read ( & vma -> vm_mm -> mmap_sem ) ; return ret ; }\n", "\n", "1: CWE-400 static int try_to_unmap_cluster ( unsigned long cursor , unsigned int * mapcount , struct vm_area_struct * vma , struct page * check_page ) { struct mm_struct * mm = vma -> vm_mm ; pmd_t * pmd ; pte_t * pte ; pte_t pteval ; spinlock_t * ptl ; struct page * page ; unsigned long address ; unsigned long mmun_start ; unsigned long mmun_end ; unsigned long end ; int ret = SWAP_AGAIN ; int locked_vma = 0 ; address = ( vma -> vm_start + cursor ) & CLUSTER_MASK ; end = address + CLUSTER_SIZE ; if ( address < vma -> vm_start ) address = vma -> vm_start ; if ( end > vma -> vm_end ) end = vma -> vm_end ; pmd = mm_find_pmd ( mm , address ) ; if ( ! pmd ) return ret ; mmun_start = address ; mmun_end = end ; mmu_notifier_invalidate_range_start ( mm , mmun_start , mmun_end ) ; if ( down_read_trylock ( & vma -> vm_mm -> mmap_sem ) ) { locked_vma = ( vma -> vm_flags & VM_LOCKED ) ; if ( ! locked_vma ) up_read ( & vma -> vm_mm -> mmap_sem ) ; } pte = pte_offset_map_lock ( mm , pmd , address , & ptl ) ; update_hiwater_rss ( mm ) ; for ( ; address < end ; pte ++ , address += PAGE_SIZE ) { if ( ! pte_present ( * pte ) ) continue ; page = vm_normal_page ( vma , address , * pte ) ; BUG_ON ( ! page || PageAnon ( page ) ) ; if ( locked_vma ) { mlock_vma_page ( page ) ; if ( page == check_page ) ret = SWAP_MLOCK ; continue ; } if ( ptep_clear_flush_young_notify ( vma , address , pte ) ) continue ; flush_cache_page ( vma , address , pte_pfn ( * pte ) ) ; pteval = ptep_clear_flush ( vma , address , pte ) ; if ( page -> index != linear_page_index ( vma , address ) ) { pte_t ptfile = pgoff_to_pte ( page -> index ) ; if ( pte_soft_dirty ( pteval ) ) pte_file_mksoft_dirty ( ptfile ) ; set_pte_at ( mm , address , pte , ptfile ) ; } if ( pte_dirty ( pteval ) ) set_page_dirty ( page ) ; page_remove_rmap ( page ) ; page_cache_release ( page ) ; dec_mm_counter ( mm , MM_FILEPAGES ) ; ( * mapcount ) -- ; } pte_unmap_unlock ( pte - 1 , ptl ) ; mmu_notifier_invalidate_range_end ( mm , mmun_start , mmun_end ) ; if ( locked_vma ) up_read ( & vma -> vm_mm -> mmap_sem ) ; return ret ; }\n", "\n", "\n", "Target: 6 ) ) { MATLAB_KO : clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( CorruptImageError \"ImproperImageHeader\" ) ; }\n", "\n", "Sources:\n", "0: CWE-772 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; register Quantum * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"enter\" ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } quantum_info = ( QuantumInfo * ) NULL ; clone_info = ( ImageInfo * ) NULL ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( strncmp ( MATLAB_HDR . identific , \"MATLAB\" , 6 ) != 0 ) { image2 = ReadMATImageV4 ( image_info , image , exception ) ; if ( image2 == NULL ) goto MATLAB_KO ; image = image2 ; goto END_OF_READING ; } MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Endian%c%c\" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , \"IM\" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , \"MI\" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , \"MATLAB\" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; if ( MATLAB_HDR . ObjectSize + filepos > GetBlobSize ( image ) ) goto MATLAB_KO ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; clone_info = CloneImageInfo ( image_info ) ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = decompress_block ( image , & MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; ( void ) ReadBlobXXXLong ( image2 ) ; if ( z != 3 ) ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; Frames = ReadBlobXXXLong ( image2 ) ; if ( Frames == 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; break ; default : ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATLAB_HDR.StructureClass%d\" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , \"UnsupportedCellTypeInTheMatrix\" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATLAB_HDR.CellType:%.20g\" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , \"quantum:format\" , \"floating-point\" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , \"quantum:format\" , \"floating-point\" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , \"IncompatibleSizeOfDouble\" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , \"UnsupportedCellTypeInTheMatrix\" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( unsigned long ) ldblk * MATLAB_HDR . SizeY > MATLAB_HDR . ObjectSize ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { image -> type = GrayscaleType ; SetImageColorspace ( image , GRAYColorspace , exception ) ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ResetMagickMemory ( BImgBuff , 0 , ldblk * sizeof ( double ) ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATsetimagepixelsreturnsunexpectedNULLonarow%u.\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATcannotreadscanrow%ufromafile.\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATfailedtoImportQuantumPixelsforarow%u\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( image , q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATfailedtosyncimagepixelsforarow%u\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( image , ( double * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( image , ( float * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image , exception ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( ( image2 != NULL ) && ( image2 != image ) ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } } RelinquishMagickMemory ( BImgBuff ) ; if ( quantum_info != ( QuantumInfo * ) NULL ) quantum_info = DestroyQuantumInfo ( quantum_info ) ; END_OF_READING : if ( clone_info ) clone_info = DestroyImageInfo ( clone_info ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"return\" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; return ( image ) ; }\n", "\n", "1: CWE-772 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; PixelPacket * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; size_t Unknown6 ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"enter\" ) ; quantum_info = ( QuantumInfo * ) NULL ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = ( ImageInfo * ) NULL ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( strncmp ( MATLAB_HDR . identific , \"MATLAB\" , 6 ) != 0 ) { image2 = ReadMATImageV4 ( image_info , image , exception ) ; if ( image2 == NULL ) goto MATLAB_KO ; image = image2 ; goto END_OF_READING ; } MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Endian%c%c\" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , \"IM\" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , \"MI\" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , \"MATLAB\" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; if ( MATLAB_HDR . ObjectSize + filepos > GetBlobSize ( image ) ) goto MATLAB_KO ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; clone_info = CloneImageInfo ( image_info ) ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = decompress_block ( image , & MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; Unknown6 = ReadBlobXXXLong ( image2 ) ; ( void ) Unknown6 ; if ( z != 3 ) ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; Frames = ReadBlobXXXLong ( image2 ) ; if ( Frames == 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; break ; default : ThrowReaderException ( CoderError , \"MultidimensionalMatricesAreNotSupported\" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATLAB_HDR.StructureClass%d\" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , \"UnsupportedCellTypeInTheMatrix\" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATLAB_HDR.CellType:%.20g\" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , \"quantum:format\" , \"floating-point\" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , \"quantum:format\" , \"floating-point\" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , \"IncompatibleSizeOfDouble\" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , \"UnsupportedCellTypeInTheMatrix\" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( unsigned long ) ldblk * MATLAB_HDR . SizeY > MATLAB_HDR . ObjectSize ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { SetImageColorspace ( image , GRAYColorspace ) ; image -> type = GrayscaleType ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ResetMagickMemory ( BImgBuff , 0 , ldblk * sizeof ( double ) ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATsetimagepixelsreturnsunexpectedNULLonarow%u.\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATcannotreadscanrow%ufromafile.\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATfailedtoImportQuantumPixelsforarow%u\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"MATfailedtosyncimagepixelsforarow%u\" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( ( double * ) BImgBuff , i , image , MinVal , MaxVal ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( ( float * ) BImgBuff , i , image , MinVal , MaxVal ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) unlink ( clone_info -> filename ) ; } } } } RelinquishMagickMemory ( BImgBuff ) ; if ( quantum_info != ( QuantumInfo * ) NULL ) quantum_info = DestroyQuantumInfo ( quantum_info ) ; END_OF_READING : if ( clone_info ) clone_info = DestroyImageInfo ( clone_info ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"return\" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; return ( image ) ; }\n", "\n", "\n", "Target: ) ) { if ( uri_ptr [ alias_len ] == '.' ) { char * s = uri_ptr + alias_len + 1 ; if ( * s == '.' ) ++ s ; if ( * s == '/' || * s == '\\\\0' ) { size_t vlen = buffer_string_length ( ds -> value ) ; if ( 0 != alias_len && ds -> key -> ptr [ alias_len - 1 ] != '/' && 0 != vlen && ds -> value -> ptr [ vlen - 1 ] == '/' ) { con -> http_status = 403 ; return HANDLER_FINISHED ; } } }\n", "\n", "Sources:\n", "0: CWE-22 PHYSICALPATH_FUNC ( mod_alias_physical_handler ) { plugin_data * p = p_d ; int uri_len , basedir_len ; char * uri_ptr ; size_t k ; if ( buffer_is_empty ( con -> physical . path ) ) return HANDLER_GO_ON ; mod_alias_patch_connection ( srv , con , p ) ; basedir_len = buffer_string_length ( con -> physical . basedir ) ; if ( '/' == con -> physical . basedir -> ptr [ basedir_len - 1 ] ) -- basedir_len ; uri_len = buffer_string_length ( con -> physical . path ) - basedir_len ; uri_ptr = con -> physical . path -> ptr + basedir_len ; for ( k = 0 ; k < p -> conf . alias -> used ; k ++ ) { data_string * ds = ( data_string * ) p -> conf . alias -> data [ k ] ; int alias_len = buffer_string_length ( ds -> key ) ; if ( alias_len > uri_len ) continue ; if ( buffer_is_empty ( ds -> key ) ) continue ; if ( 0 == ( con -> conf . force_lowercase_filenames ? strncasecmp ( uri_ptr , ds -> key -> ptr , alias_len ) : strncmp ( uri_ptr , ds -> key -> ptr , alias_len ) ) ) { buffer_copy_buffer ( con -> physical . basedir , ds -> value ) ; buffer_copy_buffer ( srv -> tmp_buf , ds -> value ) ; buffer_append_string ( srv -> tmp_buf , uri_ptr + alias_len ) ; buffer_copy_buffer ( con -> physical . path , srv -> tmp_buf ) ; return HANDLER_GO_ON ; } } return HANDLER_GO_ON ; }\n", "\n", "1: CWE-000 PHYSICALPATH_FUNC ( mod_alias_physical_handler ) { plugin_data * p = p_d ; int uri_len , basedir_len ; char * uri_ptr ; size_t k ; if ( buffer_is_empty ( con -> physical . path ) ) return HANDLER_GO_ON ; mod_alias_patch_connection ( srv , con , p ) ; basedir_len = buffer_string_length ( con -> physical . basedir ) ; if ( '/' == con -> physical . basedir -> ptr [ basedir_len - 1 ] ) -- basedir_len ; uri_len = buffer_string_length ( con -> physical . path ) - basedir_len ; uri_ptr = con -> physical . path -> ptr + basedir_len ; for ( k = 0 ; k < p -> conf . alias -> used ; k ++ ) { data_string * ds = ( data_string * ) p -> conf . alias -> data [ k ] ; int alias_len = buffer_string_length ( ds -> key ) ; if ( alias_len > uri_len ) continue ; if ( buffer_is_empty ( ds -> key ) ) continue ; if ( 0 == ( con -> conf . force_lowercase_filenames ? strncasecmp ( uri_ptr , ds -> key -> ptr , alias_len ) : strncmp ( uri_ptr , ds -> key -> ptr , alias_len ) ) ) { buffer_copy_buffer ( con -> physical . basedir , ds -> value ) ; buffer_copy_buffer ( srv -> tmp_buf , ds -> value ) ; buffer_append_string ( srv -> tmp_buf , uri_ptr + alias_len ) ; buffer_copy_buffer ( con -> physical . path , srv -> tmp_buf ) ; return HANDLER_GO_ON ; } } return HANDLER_GO_ON ; }\n", "\n", "\n", "Target: NULL ; } if ( * flags & PyPARSE_TYPE_COMMENTS ) { tok -> type_comments = 1 ; }\n", "\n", "Sources:\n", "0: CWE-125 node * PyParser_ParseFileObject ( FILE * fp , PyObject * filename , const char * enc , grammar * g , int start , const char * ps1 , const char * ps2 , perrdetail * err_ret , int * flags ) { struct tok_state * tok ; if ( initerr ( err_ret , filename ) < 0 ) return NULL ; if ( ( tok = PyTokenizer_FromFile ( fp , enc , ps1 , ps2 ) ) == NULL ) { err_ret -> error = E_NOMEM ; return NULL ; } # ifndef PGEN Py_INCREF ( err_ret -> filename ) ; tok -> filename = err_ret -> filename ; # endif return parsetok ( tok , g , start , err_ret , flags ) ; }\n", "\n", "1: CWE-125 node * PyParser_ParseStringObject ( const char * s , PyObject * filename , grammar * g , int start , perrdetail * err_ret , int * flags ) { struct tok_state * tok ; int exec_input = start == file_input ; if ( initerr ( err_ret , filename ) < 0 ) return NULL ; if ( * flags & PyPARSE_IGNORE_COOKIE ) tok = PyTokenizer_FromUTF8 ( s , exec_input ) ; else tok = PyTokenizer_FromString ( s , exec_input ) ; if ( tok == NULL ) { err_ret -> error = PyErr_Occurred ( ) ? E_DECODE : E_NOMEM ; return NULL ; } # ifndef PGEN Py_INCREF ( err_ret -> filename ) ; tok -> filename = err_ret -> filename ; # endif return parsetok ( tok , g , start , err_ret , flags ) ; }\n", "\n", "\n", "Target: { char * start , * 0 ; } start = var -> ptr + var -> already_scanned ; = memchr ( start , '&' , -> end - start ) ; if eof ) { var -> already_scanned = var -> end - var -> ptr ; end ) ; var -> already_scanned = 0 ;\n", "\n", "Sources:\n", "0: CWE-400 static zend_bool add_post_var ( zval * arr , post_var_data_t * var , zend_bool eof TSRMLS_DC ) { char * ksep , * vsep , * val ; size_t klen , vlen ; unsigned int new_vlen ; if ( var -> ptr >= var -> end ) { return 0 ; } vsep = memchr ( var -> ptr , '&' , var -> end - var -> ptr ) ; if ( ! vsep ) { if ( ! eof ) { return 0 ; } else { vsep = var -> end ; } } ksep = memchr ( var -> ptr , '=' , vsep - var -> ptr ) ; if ( ksep ) { * ksep = '\\\\0' ; klen = ksep - var -> ptr ; vlen = vsep - ++ ksep ; } else { ksep = \"\" ; klen = vsep - var -> ptr ; vlen = 0 ; } php_url_decode ( var -> ptr , klen ) ; val = estrndup ( ksep , vlen ) ; if ( vlen ) { vlen = php_url_decode ( val , vlen ) ; } if ( sapi_module . input_filter ( PARSE_POST , var -> ptr , & val , vlen , & new_vlen TSRMLS_CC ) ) { php_register_variable_safe ( var -> ptr , val , new_vlen , arr TSRMLS_CC ) ; } efree ( val ) ; var -> ptr = vsep + ( vsep != var -> end ) ; return 1 ; }\n", "\n", "1: CWE-400 static zend_bool add_post_var ( zval * arr , post_var_data_t * var , zend_bool eof ) { char * ksep , * vsep , * val ; size_t klen , vlen ; size_t new_vlen ; if ( var -> ptr >= var -> end ) { return 0 ; } vsep = memchr ( var -> ptr , '&' , var -> end - var -> ptr ) ; if ( ! vsep ) { if ( ! eof ) { return 0 ; } else { vsep = var -> end ; } } ksep = memchr ( var -> ptr , '=' , vsep - var -> ptr ) ; if ( ksep ) { * ksep = '\\\\0' ; klen = ksep - var -> ptr ; vlen = vsep - ++ ksep ; } else { ksep = \"\" ; klen = vsep - var -> ptr ; vlen = 0 ; } php_url_decode ( var -> ptr , klen ) ; val = estrndup ( ksep , vlen ) ; if ( vlen ) { vlen = php_url_decode ( val , vlen ) ; } if ( sapi_module . input_filter ( PARSE_POST , var -> ptr , & val , vlen , & new_vlen ) ) { php_register_variable_safe ( var -> ptr , val , new_vlen , arr ) ; } efree ( val ) ; var -> ptr = vsep + ( vsep != var -> end ) ; return 1 ; }\n", "\n", "\n", "Target: ) ) { pr_debug ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\"\n", "\n", "Sources:\n", "0: CWE-119 static int check_entry_size_and_hooks ( struct ip6t_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ip6t_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ip6t_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ip6t_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } err = check_entry ( e ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_err ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "1: CWE-119 static inline int check_entry_size_and_hooks ( struct arpt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct arpt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct arpt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct arpt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } err = check_entry ( e ) ; if ( err ) return err ; for ( h = 0 ; h < NF_ARP_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_err ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "2: CWE-119 static int check_entry_size_and_hooks ( struct ipt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ipt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ipt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ipt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } err = check_entry ( e ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_err ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "\n", "Target: * handle ; mutex_lock ( & client -> lock ) ; handle = ion_handle_get_by_id_nolock ( client , handle ) ) { mutex_unlock ( & client -> lock ) ; handle ) ; } ion_free_nolock ( client , handle ) ; ion_handle_put_nolock ( handle ) ; mutex_unlock ( & client -> lock ) ; break\n", "\n", "Sources:\n", "0: CWE-264 static long ion_ioctl ( struct file * filp , unsigned int cmd , unsigned long arg ) { struct ion_client * client = filp -> private_data ; struct ion_device * dev = client -> dev ; struct ion_handle * cleanup_handle = NULL ; int ret = 0 ; unsigned int dir ; union { struct ion_fd_data fd ; struct ion_allocation_data allocation ; struct ion_handle_data handle ; struct ion_custom_data custom ; } data ; dir = ion_ioctl_dir ( cmd ) ; if ( _IOC_SIZE ( cmd ) > sizeof ( data ) ) return - EINVAL ; if ( dir & _IOC_WRITE ) if ( copy_from_user ( & data , ( void __user * ) arg , _IOC_SIZE ( cmd ) ) ) return - EFAULT ; switch ( cmd ) { case ION_IOC_ALLOC : { struct ion_handle * handle ; handle = ion_alloc ( client , data . allocation . len , data . allocation . align , data . allocation . heap_id_mask , data . allocation . flags ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data . allocation . handle = handle -> id ; cleanup_handle = handle ; break ; } case ION_IOC_FREE : { struct ion_handle * handle ; handle = ion_handle_get_by_id ( client , data . handle . handle ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; ion_free ( client , handle ) ; ion_handle_put ( handle ) ; break ; } case ION_IOC_SHARE : case ION_IOC_MAP : { struct ion_handle * handle ; handle = ion_handle_get_by_id ( client , data . handle . handle ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data . fd . fd = ion_share_dma_buf_fd ( client , handle ) ; ion_handle_put ( handle ) ; if ( data . fd . fd < 0 ) ret = data . fd . fd ; break ; } case ION_IOC_IMPORT : { struct ion_handle * handle ; handle = ion_import_dma_buf_fd ( client , data . fd . fd ) ; if ( IS_ERR ( handle ) ) ret = PTR_ERR ( handle ) ; else data . handle . handle = handle -> id ; break ; } case ION_IOC_SYNC : { ret = ion_sync_for_device ( client , data . fd . fd ) ; break ; } case ION_IOC_CUSTOM : { if ( ! dev -> custom_ioctl ) return - ENOTTY ; ret = dev -> custom_ioctl ( client , data . custom . cmd , data . custom . arg ) ; break ; } default : return - ENOTTY ; } if ( dir & _IOC_READ ) { if ( copy_to_user ( ( void __user * ) arg , & data , _IOC_SIZE ( cmd ) ) ) { if ( cleanup_handle ) ion_free ( client , cleanup_handle ) ; return - EFAULT ; } } return ret ; }\n", "\n", "1: CWE-416 static long ion_ioctl ( struct file * filp , unsigned int cmd , unsigned long arg ) { struct ion_client * client = filp -> private_data ; struct ion_device * dev = client -> dev ; struct ion_handle * cleanup_handle = NULL ; int ret = 0 ; unsigned int dir ; union { struct ion_fd_data fd ; struct ion_allocation_data allocation ; struct ion_handle_data handle ; struct ion_custom_data custom ; } data ; dir = ion_ioctl_dir ( cmd ) ; if ( _IOC_SIZE ( cmd ) > sizeof ( data ) ) return - EINVAL ; if ( dir & _IOC_WRITE ) if ( copy_from_user ( & data , ( void __user * ) arg , _IOC_SIZE ( cmd ) ) ) return - EFAULT ; switch ( cmd ) { case ION_IOC_ALLOC : { struct ion_handle * handle ; handle = ion_alloc ( client , data . allocation . len , data . allocation . align , data . allocation . heap_id_mask , data . allocation . flags ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data . allocation . handle = handle -> id ; cleanup_handle = handle ; break ; } case ION_IOC_FREE : { struct ion_handle * handle ; handle = ion_handle_get_by_id ( client , data . handle . handle ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; ion_free ( client , handle ) ; ion_handle_put ( handle ) ; break ; } case ION_IOC_SHARE : case ION_IOC_MAP : { struct ion_handle * handle ; handle = ion_handle_get_by_id ( client , data . handle . handle ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data . fd . fd = ion_share_dma_buf_fd ( client , handle ) ; ion_handle_put ( handle ) ; if ( data . fd . fd < 0 ) ret = data . fd . fd ; break ; } case ION_IOC_IMPORT : { struct ion_handle * handle ; handle = ion_import_dma_buf_fd ( client , data . fd . fd ) ; if ( IS_ERR ( handle ) ) ret = PTR_ERR ( handle ) ; else data . handle . handle = handle -> id ; break ; } case ION_IOC_SYNC : { ret = ion_sync_for_device ( client , data . fd . fd ) ; break ; } case ION_IOC_CUSTOM : { if ( ! dev -> custom_ioctl ) return - ENOTTY ; ret = dev -> custom_ioctl ( client , data . custom . cmd , data . custom . arg ) ; break ; } default : return - ENOTTY ; } if ( dir & _IOC_READ ) { if ( copy_to_user ( ( void __user * ) arg , & data , _IOC_SIZE ( cmd ) ) ) { if ( cleanup_handle ) ion_free ( client , cleanup_handle ) ; return - EFAULT ; } } return ret ; }\n", "\n", "\n", "Target: ; if ( plen ) { ret\n", "\n", "Sources:\n", "0: CWE-476 long keyctl_update_key ( key_serial_t id , const void __user * _payload , size_t plen ) { key_ref_t key_ref ; void * payload ; long ret ; ret = - EINVAL ; if ( plen > PAGE_SIZE ) goto error ; payload = NULL ; if ( _payload ) { ret = - ENOMEM ; payload = kmalloc ( plen , GFP_KERNEL ) ; if ( ! payload ) goto error ; ret = - EFAULT ; if ( copy_from_user ( payload , _payload , plen ) != 0 ) goto error2 ; } key_ref = lookup_user_key ( id , 0 , KEY_NEED_WRITE ) ; if ( IS_ERR ( key_ref ) ) { ret = PTR_ERR ( key_ref ) ; goto error2 ; } ret = key_update ( key_ref , payload , plen ) ; key_ref_put ( key_ref ) ; error2 : kfree ( payload ) ; error : return ret ; }\n", "\n", "1: CWE-476 SYSCALL_DEFINE5 ( add_key , const char __user * , _type , const char __user * , _description , const void __user * , _payload , size_t , plen , key_serial_t , ringid ) { key_ref_t keyring_ref , key_ref ; char type [ 32 ] , * description ; void * payload ; long ret ; ret = - EINVAL ; if ( plen > 1024 * 1024 - 1 ) goto error ; ret = key_get_type_from_user ( type , _type , sizeof ( type ) ) ; if ( ret < 0 ) goto error ; description = NULL ; if ( _description ) { description = strndup_user ( _description , KEY_MAX_DESC_SIZE ) ; if ( IS_ERR ( description ) ) { ret = PTR_ERR ( description ) ; goto error ; } if ( ! * description ) { kfree ( description ) ; description = NULL ; } else if ( ( description [ 0 ] == '.' ) && ( strncmp ( type , \"keyring\" , 7 ) == 0 ) ) { ret = - EPERM ; goto error2 ; } } payload = NULL ; if ( _payload ) { ret = - ENOMEM ; payload = kvmalloc ( plen , GFP_KERNEL ) ; if ( ! payload ) goto error2 ; ret = - EFAULT ; if ( copy_from_user ( payload , _payload , plen ) != 0 ) goto error3 ; } keyring_ref = lookup_user_key ( ringid , KEY_LOOKUP_CREATE , KEY_NEED_WRITE ) ; if ( IS_ERR ( keyring_ref ) ) { ret = PTR_ERR ( keyring_ref ) ; goto error3 ; } key_ref = key_create_or_update ( keyring_ref , type , description , payload , plen , KEY_PERM_UNDEF , KEY_ALLOC_IN_QUOTA ) ; if ( ! IS_ERR ( key_ref ) ) { ret = key_ref_to_ptr ( key_ref ) -> serial ; key_ref_put ( key_ref ) ; } else { ret = PTR_ERR ( key_ref ) ; } key_ref_put ( keyring_ref ) ; error3 : kvfree ( payload ) ; error2 : kfree ( description ) ; error : return ret ; }\n", "\n", "\n", "Target: ( args -> rmtvaluelen ) ; xfs_trans_log_buf\n", "\n", "Sources:\n", "0: CWE-19 int xfs_attr3_leaf_clearflag ( struct xfs_da_args * args ) { struct xfs_attr_leafblock * leaf ; struct xfs_attr_leaf_entry * entry ; struct xfs_attr_leaf_name_remote * name_rmt ; struct xfs_buf * bp ; int error ; # ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr ; xfs_attr_leaf_name_local_t * name_loc ; int namelen ; char * name ; # endif trace_xfs_attr_leaf_clearflag ( args ) ; error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno , - 1 , & bp ) ; if ( error ) return ( error ) ; leaf = bp -> b_addr ; entry = & xfs_attr3_leaf_entryp ( leaf ) [ args -> index ] ; ASSERT ( entry -> flags & XFS_ATTR_INCOMPLETE ) ; # ifdef DEBUG xfs_attr3_leaf_hdr_from_disk ( & ichdr , leaf ) ; ASSERT ( args -> index < ichdr . count ) ; ASSERT ( args -> index >= 0 ) ; if ( entry -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf , args -> index ) ; namelen = name_loc -> namelen ; name = ( char * ) name_loc -> nameval ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf , args -> index ) ; namelen = name_rmt -> namelen ; name = ( char * ) name_rmt -> name ; } ASSERT ( be32_to_cpu ( entry -> hashval ) == args -> hashval ) ; ASSERT ( namelen == args -> namelen ) ; ASSERT ( memcmp ( name , args -> name , namelen ) == 0 ) ; # endif entry -> flags &= ~ XFS_ATTR_INCOMPLETE ; xfs_trans_log_buf ( args -> trans , bp , XFS_DA_LOGRANGE ( leaf , entry , sizeof ( * entry ) ) ) ; if ( args -> rmtblkno ) { ASSERT ( ( entry -> flags & XFS_ATTR_LOCAL ) == 0 ) ; name_rmt = xfs_attr3_leaf_name_remote ( leaf , args -> index ) ; name_rmt -> valueblk = cpu_to_be32 ( args -> rmtblkno ) ; name_rmt -> valuelen = cpu_to_be32 ( args -> valuelen ) ; xfs_trans_log_buf ( args -> trans , bp , XFS_DA_LOGRANGE ( leaf , name_rmt , sizeof ( * name_rmt ) ) ) ; } return xfs_trans_roll ( & args -> trans , args -> dp ) ; }\n", "\n", "1: CWE-19 int xfs_attr3_leaf_flipflags ( struct xfs_da_args * args ) { struct xfs_attr_leafblock * leaf1 ; struct xfs_attr_leafblock * leaf2 ; struct xfs_attr_leaf_entry * entry1 ; struct xfs_attr_leaf_entry * entry2 ; struct xfs_attr_leaf_name_remote * name_rmt ; struct xfs_buf * bp1 ; struct xfs_buf * bp2 ; int error ; # ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr1 ; struct xfs_attr3_icleaf_hdr ichdr2 ; xfs_attr_leaf_name_local_t * name_loc ; int namelen1 , namelen2 ; char * name1 , * name2 ; # endif trace_xfs_attr_leaf_flipflags ( args ) ; error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno , - 1 , & bp1 ) ; if ( error ) return error ; if ( args -> blkno2 != args -> blkno ) { error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno2 , - 1 , & bp2 ) ; if ( error ) return error ; } else { bp2 = bp1 ; } leaf1 = bp1 -> b_addr ; entry1 = & xfs_attr3_leaf_entryp ( leaf1 ) [ args -> index ] ; leaf2 = bp2 -> b_addr ; entry2 = & xfs_attr3_leaf_entryp ( leaf2 ) [ args -> index2 ] ; # ifdef DEBUG xfs_attr3_leaf_hdr_from_disk ( & ichdr1 , leaf1 ) ; ASSERT ( args -> index < ichdr1 . count ) ; ASSERT ( args -> index >= 0 ) ; xfs_attr3_leaf_hdr_from_disk ( & ichdr2 , leaf2 ) ; ASSERT ( args -> index2 < ichdr2 . count ) ; ASSERT ( args -> index2 >= 0 ) ; if ( entry1 -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf1 , args -> index ) ; namelen1 = name_loc -> namelen ; name1 = ( char * ) name_loc -> nameval ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf1 , args -> index ) ; namelen1 = name_rmt -> namelen ; name1 = ( char * ) name_rmt -> name ; } if ( entry2 -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf2 , args -> index2 ) ; namelen2 = name_loc -> namelen ; name2 = ( char * ) name_loc -> nameval ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf2 , args -> index2 ) ; namelen2 = name_rmt -> namelen ; name2 = ( char * ) name_rmt -> name ; } ASSERT ( be32_to_cpu ( entry1 -> hashval ) == be32_to_cpu ( entry2 -> hashval ) ) ; ASSERT ( namelen1 == namelen2 ) ; ASSERT ( memcmp ( name1 , name2 , namelen1 ) == 0 ) ; # endif ASSERT ( entry1 -> flags & XFS_ATTR_INCOMPLETE ) ; ASSERT ( ( entry2 -> flags & XFS_ATTR_INCOMPLETE ) == 0 ) ; entry1 -> flags &= ~ XFS_ATTR_INCOMPLETE ; xfs_trans_log_buf ( args -> trans , bp1 , XFS_DA_LOGRANGE ( leaf1 , entry1 , sizeof ( * entry1 ) ) ) ; if ( args -> rmtblkno ) { ASSERT ( ( entry1 -> flags & XFS_ATTR_LOCAL ) == 0 ) ; name_rmt = xfs_attr3_leaf_name_remote ( leaf1 , args -> index ) ; name_rmt -> valueblk = cpu_to_be32 ( args -> rmtblkno ) ; name_rmt -> valuelen = cpu_to_be32 ( args -> valuelen ) ; xfs_trans_log_buf ( args -> trans , bp1 , XFS_DA_LOGRANGE ( leaf1 , name_rmt , sizeof ( * name_rmt ) ) ) ; } entry2 -> flags |= XFS_ATTR_INCOMPLETE ; xfs_trans_log_buf ( args -> trans , bp2 , XFS_DA_LOGRANGE ( leaf2 , entry2 , sizeof ( * entry2 ) ) ) ; if ( ( entry2 -> flags & XFS_ATTR_LOCAL ) == 0 ) { name_rmt = xfs_attr3_leaf_name_remote ( leaf2 , args -> index2 ) ; name_rmt -> valueblk = 0 ; name_rmt -> valuelen = 0 ; xfs_trans_log_buf ( args -> trans , bp2 , XFS_DA_LOGRANGE ( leaf2 , name_rmt , sizeof ( * name_rmt ) ) ) ; } error = xfs_trans_roll ( & args -> trans , args -> dp ) ; return error ; }\n", "\n", "\n", "Target: NULL , NULL , true\n", "\n", "Sources:\n", "0: CWE-476 static noinline int btrfs_ioctl_resize ( struct file * file , void __user * arg ) { struct inode * inode = file_inode ( file ) ; struct btrfs_fs_info * fs_info = btrfs_sb ( inode -> i_sb ) ; u64 new_size ; u64 old_size ; u64 devid = 1 ; struct btrfs_root * root = BTRFS_I ( inode ) -> root ; struct btrfs_ioctl_vol_args * vol_args ; struct btrfs_trans_handle * trans ; struct btrfs_device * device = NULL ; char * sizestr ; char * retptr ; char * devstr = NULL ; int ret = 0 ; int mod = 0 ; if ( ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; ret = mnt_want_write_file ( file ) ; if ( ret ) return ret ; if ( test_and_set_bit ( BTRFS_FS_EXCL_OP , & fs_info -> flags ) ) { mnt_drop_write_file ( file ) ; return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS ; } vol_args = memdup_user ( arg , sizeof ( * vol_args ) ) ; if ( IS_ERR ( vol_args ) ) { ret = PTR_ERR ( vol_args ) ; goto out ; } vol_args -> name [ BTRFS_PATH_NAME_MAX ] = '\\\\0' ; sizestr = vol_args -> name ; devstr = strchr ( sizestr , ':' ) ; if ( devstr ) { sizestr = devstr + 1 ; * devstr = '\\\\0' ; devstr = vol_args -> name ; ret = kstrtoull ( devstr , 10 , & devid ) ; if ( ret ) goto out_free ; if ( ! devid ) { ret = - EINVAL ; goto out_free ; } btrfs_info ( fs_info , \"resizingdevid%llu\" , devid ) ; } device = btrfs_find_device ( fs_info -> fs_devices , devid , NULL , NULL ) ; if ( ! device ) { btrfs_info ( fs_info , \"resizerunabletofinddevice%llu\" , devid ) ; ret = - ENODEV ; goto out_free ; } if ( ! test_bit ( BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state ) ) { btrfs_info ( fs_info , \"resizerunabletoapplyonreadonlydevice%llu\" , devid ) ; ret = - EPERM ; goto out_free ; } if ( ! strcmp ( sizestr , \"max\" ) ) new_size = device -> bdev -> bd_inode -> i_size ; else { if ( sizestr [ 0 ] == '-' ) { mod = - 1 ; sizestr ++ ; } else if ( sizestr [ 0 ] == '+' ) { mod = 1 ; sizestr ++ ; } new_size = memparse ( sizestr , & retptr ) ; if ( * retptr != '\\\\0' || new_size == 0 ) { ret = - EINVAL ; goto out_free ; } } if ( test_bit ( BTRFS_DEV_STATE_REPLACE_TGT , & device -> dev_state ) ) { ret = - EPERM ; goto out_free ; } old_size = btrfs_device_get_total_bytes ( device ) ; if ( mod < 0 ) { if ( new_size > old_size ) { ret = - EINVAL ; goto out_free ; } new_size = old_size - new_size ; } else if ( mod > 0 ) { if ( new_size > ULLONG_MAX - old_size ) { ret = - ERANGE ; goto out_free ; } new_size = old_size + new_size ; } if ( new_size < SZ_256M ) { ret = - EINVAL ; goto out_free ; } if ( new_size > device -> bdev -> bd_inode -> i_size ) { ret = - EFBIG ; goto out_free ; } new_size = round_down ( new_size , fs_info -> sectorsize ) ; btrfs_info_in_rcu ( fs_info , \"newsizefor%sis%llu\" , rcu_str_deref ( device -> name ) , new_size ) ; if ( new_size > old_size ) { trans = btrfs_start_transaction ( root , 0 ) ; if ( IS_ERR ( trans ) ) { ret = PTR_ERR ( trans ) ; goto out_free ; } ret = btrfs_grow_device ( trans , device , new_size ) ; btrfs_commit_transaction ( trans ) ; } else if ( new_size < old_size ) { ret = btrfs_shrink_device ( device , new_size ) ; } out_free : kfree ( vol_args ) ; out : clear_bit ( BTRFS_FS_EXCL_OP , & fs_info -> flags ) ; mnt_drop_write_file ( file ) ; return ret ; }\n", "\n", "1: CWE-476 int btrfs_scrub_progress ( struct btrfs_fs_info * fs_info , u64 devid , struct btrfs_scrub_progress * progress ) { struct btrfs_device * dev ; struct scrub_ctx * sctx = NULL ; mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; dev = btrfs_find_device ( fs_info -> fs_devices , devid , NULL , NULL ) ; if ( dev ) sctx = dev -> scrub_ctx ; if ( sctx ) memcpy ( progress , & sctx -> stat , sizeof ( * progress ) ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; return dev ? ( sctx ? 0 : - ENOTCONN ) : - ENODEV ; }\n", "\n", "2: CWE-476 int btrfs_scrub_dev ( struct btrfs_fs_info * fs_info , u64 devid , u64 start , u64 end , struct btrfs_scrub_progress * progress , int readonly , int is_dev_replace ) { struct scrub_ctx * sctx ; int ret ; struct btrfs_device * dev ; unsigned int nofs_flag ; if ( btrfs_fs_closing ( fs_info ) ) return - EINVAL ; if ( fs_info -> nodesize > BTRFS_STRIPE_LEN ) { btrfs_err ( fs_info , \"scrub:sizeassumptionnodesize<=BTRFS_STRIPE_LEN(%d<=%d)fails\" , fs_info -> nodesize , BTRFS_STRIPE_LEN ) ; return - EINVAL ; } if ( fs_info -> sectorsize != PAGE_SIZE ) { btrfs_err_rl ( fs_info , \"scrub:sizeassumptionsectorsize!=PAGE_SIZE(%d!=%lu)fails\" , fs_info -> sectorsize , PAGE_SIZE ) ; return - EINVAL ; } if ( fs_info -> nodesize > PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK || fs_info -> sectorsize > PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK ) { btrfs_err ( fs_info , \"scrub:sizeassumptionnodesizeandsectorsize<=SCRUB_MAX_PAGES_PER_BLOCK(%d<=%d&&%d<=%d)fails\" , fs_info -> nodesize , SCRUB_MAX_PAGES_PER_BLOCK , fs_info -> sectorsize , SCRUB_MAX_PAGES_PER_BLOCK ) ; return - EINVAL ; } sctx = scrub_setup_ctx ( fs_info , is_dev_replace ) ; if ( IS_ERR ( sctx ) ) return PTR_ERR ( sctx ) ; mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; dev = btrfs_find_device ( fs_info -> fs_devices , devid , NULL , NULL ) ; if ( ! dev || ( test_bit ( BTRFS_DEV_STATE_MISSING , & dev -> dev_state ) && ! is_dev_replace ) ) { mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - ENODEV ; goto out_free_ctx ; } if ( ! is_dev_replace && ! readonly && ! test_bit ( BTRFS_DEV_STATE_WRITEABLE , & dev -> dev_state ) ) { mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; btrfs_err_in_rcu ( fs_info , \"scrub:device%sisnotwritable\" , rcu_str_deref ( dev -> name ) ) ; ret = - EROFS ; goto out_free_ctx ; } mutex_lock ( & fs_info -> scrub_lock ) ; if ( ! test_bit ( BTRFS_DEV_STATE_IN_FS_METADATA , & dev -> dev_state ) || test_bit ( BTRFS_DEV_STATE_REPLACE_TGT , & dev -> dev_state ) ) { mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - EIO ; goto out_free_ctx ; } down_read ( & fs_info -> dev_replace . rwsem ) ; if ( dev -> scrub_ctx || ( ! is_dev_replace && btrfs_dev_replace_is_ongoing ( & fs_info -> dev_replace ) ) ) { up_read ( & fs_info -> dev_replace . rwsem ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - EINPROGRESS ; goto out_free_ctx ; } up_read ( & fs_info -> dev_replace . rwsem ) ; ret = scrub_workers_get ( fs_info , is_dev_replace ) ; if ( ret ) { mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; goto out_free_ctx ; } sctx -> readonly = readonly ; dev -> scrub_ctx = sctx ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; __scrub_blocked_if_needed ( fs_info ) ; atomic_inc ( & fs_info -> scrubs_running ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; nofs_flag = memalloc_nofs_save ( ) ; if ( ! is_dev_replace ) { mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = scrub_supers ( sctx , dev ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; } if ( ! ret ) ret = scrub_enumerate_chunks ( sctx , dev , start , end ) ; memalloc_nofs_restore ( nofs_flag ) ; wait_event ( sctx -> list_wait , atomic_read ( & sctx -> bios_in_flight ) == 0 ) ; atomic_dec ( & fs_info -> scrubs_running ) ; wake_up ( & fs_info -> scrub_pause_wait ) ; wait_event ( sctx -> list_wait , atomic_read ( & sctx -> workers_pending ) == 0 ) ; if ( progress ) memcpy ( progress , & sctx -> stat , sizeof ( * progress ) ) ; mutex_lock ( & fs_info -> scrub_lock ) ; dev -> scrub_ctx = NULL ; scrub_workers_put ( fs_info ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; scrub_put_ctx ( sctx ) ; return ret ; out_free_ctx : scrub_free_ctx ( sctx ) ; return ret ; }\n", "\n", "\n", "Target: ) ; goto out2 ; } error nd ) ; out2 :\n", "\n", "Sources:\n", "0: CWE-000 static struct file * path_openat ( int dfd , struct filename * pathname , struct nameidata * nd , const struct open_flags * op , int flags ) { struct file * file ; struct path path ; int opened = 0 ; int error ; file = get_empty_filp ( ) ; if ( IS_ERR ( file ) ) return file ; file -> f_flags = op -> open_flag ; if ( unlikely ( file -> f_flags & __O_TMPFILE ) ) { error = do_tmpfile ( dfd , pathname , nd , flags , op , file , & opened ) ; goto out ; } error = path_init ( dfd , pathname , flags , nd ) ; if ( unlikely ( error ) ) goto out ; error = do_last ( nd , & path , file , op , & opened , pathname ) ; while ( unlikely ( error > 0 ) ) { struct path link = path ; void * cookie ; if ( ! ( nd -> flags & LOOKUP_FOLLOW ) ) { path_put_conditional ( & path , nd ) ; path_put ( & nd -> path ) ; error = - ELOOP ; break ; } error = may_follow_link ( & link , nd ) ; if ( unlikely ( error ) ) break ; nd -> flags |= LOOKUP_PARENT ; nd -> flags &= ~ ( LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_EXCL ) ; error = follow_link ( & link , nd , & cookie ) ; if ( unlikely ( error ) ) break ; error = do_last ( nd , & path , file , op , & opened , pathname ) ; put_link ( nd , & link , cookie ) ; } out : path_cleanup ( nd ) ; if ( ! ( opened & FILE_OPENED ) ) { BUG_ON ( ! error ) ; put_filp ( file ) ; } if ( unlikely ( error ) ) { if ( error == - EOPENSTALE ) { if ( flags & LOOKUP_RCU ) error = - ECHILD ; else error = - ESTALE ; } file = ERR_PTR ( error ) ; } return file ; }\n", "\n", "1: CWE-416 static struct file * path_openat ( int dfd , struct filename * pathname , struct nameidata * nd , const struct open_flags * op , int flags ) { struct file * file ; struct path path ; int opened = 0 ; int error ; file = get_empty_filp ( ) ; if ( IS_ERR ( file ) ) return file ; file -> f_flags = op -> open_flag ; if ( unlikely ( file -> f_flags & __O_TMPFILE ) ) { error = do_tmpfile ( dfd , pathname , nd , flags , op , file , & opened ) ; goto out ; } error = path_init ( dfd , pathname , flags , nd ) ; if ( unlikely ( error ) ) goto out ; error = do_last ( nd , & path , file , op , & opened , pathname ) ; while ( unlikely ( error > 0 ) ) { struct path link = path ; void * cookie ; if ( ! ( nd -> flags & LOOKUP_FOLLOW ) ) { path_put_conditional ( & path , nd ) ; path_put ( & nd -> path ) ; error = - ELOOP ; break ; } error = may_follow_link ( & link , nd ) ; if ( unlikely ( error ) ) break ; nd -> flags |= LOOKUP_PARENT ; nd -> flags &= ~ ( LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_EXCL ) ; error = follow_link ( & link , nd , & cookie ) ; if ( unlikely ( error ) ) break ; error = do_last ( nd , & path , file , op , & opened , pathname ) ; put_link ( nd , & link , cookie ) ; } out : path_cleanup ( nd ) ; if ( ! ( opened & FILE_OPENED ) ) { BUG_ON ( ! error ) ; put_filp ( file ) ; } if ( unlikely ( error ) ) { if ( error == - EOPENSTALE ) { if ( flags & LOOKUP_RCU ) error = - ECHILD ; else error = - ESTALE ; } file = ERR_PTR ( error ) ; } return file ; }\n", "\n", "\n", "Target: , tag ) \\\\\\n{ if ( palette tag ) ; \\\\\\n} Image * image goto NoMemory ; ( void ) memset ( BImgBuff , 0 , ( size_t ) ldblk * sizeof ( * BImgBuff ) ) ;\n", "\n", "Sources:\n", "0: CWE-20 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowCUTReaderException ( severity , tag ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( severity , tag ) ; } Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; register Quantum * q ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping != MagickFalse ) goto Finish ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , \".PAL\" , ( size_t ) ( MagickPathExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , \".pal\" , ( size_t ) ( MagickPathExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info -> filename [ i ] = '\\\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info , exception ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , \"AH\" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) { NoMemory : ThrowCUTReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) memset ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( image , depth , BImgBuff , i , exception ) ; } ( void ) SyncImage ( image , exception ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( SetImageGray ( image , exception ) != MagickFalse ) ) { if ( GetCutColors ( image , exception ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( image , q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( image , QuantumRange , q ) ; SetPixelGreen ( image , QuantumRange , q ) ; SetPixelBlue ( image , QuantumRange , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-908 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowCUTReaderException ( severity , tag ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( severity , tag ) ; } Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; register Quantum * q ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping != MagickFalse ) goto Finish ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , \".PAL\" , ( size_t ) ( MagickPathExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , \".pal\" , ( size_t ) ( MagickPathExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info -> filename [ i ] = '\\\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info , exception ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , \"AH\" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) { NoMemory : ThrowCUTReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) memset ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( image , depth , BImgBuff , i , exception ) ; } ( void ) SyncImage ( image , exception ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( SetImageGray ( image , exception ) != MagickFalse ) ) { if ( GetCutColors ( image , exception ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( image , q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( image , QuantumRange , q ) ; SetPixelGreen ( image , QuantumRange , q ) ; SetPixelBlue ( image , QuantumRange , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "2: CWE-20 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowCUTReaderException ( severity , tag ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( severity , tag ) ; } Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; PixelPacket * q ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping != MagickFalse ) goto Finish ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , \".PAL\" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , \".pal\" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info -> filename [ i ] = '\\\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , \"AH\" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) { NoMemory : ThrowCUTReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) memset ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( depth , BImgBuff , i , image ) ; } ( void ) SyncImage ( image ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( SetImageGray ( image , & image -> exception ) != MagickFalse ) ) { if ( GetCutColors ( image ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( q , QuantumRange ) ; SetPixelGreen ( q , QuantumRange ) ; SetPixelBlue ( q , QuantumRange ) ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "3: CWE-908 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowCUTReaderException ( severity , tag ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( severity , tag ) ; } Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; PixelPacket * q ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowCUTReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping != MagickFalse ) goto Finish ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , \".PAL\" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , \".pal\" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info -> filename [ i ] = '\\\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , \"rb\" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , \"AH\" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) { NoMemory : ThrowCUTReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) memset ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( depth , BImgBuff , i , image ) ; } ( void ) SyncImage ( image ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( SetImageGray ( image , & image -> exception ) != MagickFalse ) ) { if ( GetCutColors ( image ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( q , QuantumRange ) ; SetPixelGreen ( q , QuantumRange ) ; SetPixelBlue ( q , QuantumRange ) ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: -> fp -> user , scm -> fp ->\n", "\n", "Sources:\n", "0: CWE-399 static int unix_attach_fds ( struct scm_cookie * scm , struct sk_buff * skb ) { int i ; unsigned char max_level = 0 ; int unix_sock_count = 0 ; if ( too_many_unix_fds ( current ) ) return - ETOOMANYREFS ; for ( i = scm -> fp -> count - 1 ; i >= 0 ; i -- ) { struct sock * sk = unix_get_socket ( scm -> fp -> fp [ i ] ) ; if ( sk ) { unix_sock_count ++ ; max_level = max ( max_level , unix_sk ( sk ) -> recursion_level ) ; } } if ( unlikely ( max_level > MAX_RECURSION_LEVEL ) ) return - ETOOMANYREFS ; UNIXCB ( skb ) . fp = scm_fp_dup ( scm -> fp ) ; if ( ! UNIXCB ( skb ) . fp ) return - ENOMEM ; for ( i = scm -> fp -> count - 1 ; i >= 0 ; i -- ) unix_inflight ( scm -> fp -> fp [ i ] ) ; return max_level ; }\n", "\n", "1: CWE-399 static void unix_detach_fds ( struct scm_cookie * scm , struct sk_buff * skb ) { int i ; scm -> fp = UNIXCB ( skb ) . fp ; UNIXCB ( skb ) . fp = NULL ; for ( i = scm -> fp -> count - 1 ; i >= 0 ; i -- ) unix_notinflight ( scm -> fp -> fp [ i ] ) ; }\n", "\n", "\n", "Target: command , * largs = NULL , * return - EINVAL ; if ( current != task ) return - EACCES '\\\\0' ) { largs = args = kmalloc ( size + 1 , GFP_KERNEL ) ; if ( ! args ) return - ) return - ENOMEM ; memcpy ( args , value , size ) ; args [ size ] = '\\\\0' ; } error = - EINVAL ; args = strim ( args ) ; command = strsep ( & args , \"\" ) ; if ( ! args ) goto out ; args = skip_spaces ( args ) ; if ( ! * args ) goto out ; arg_size = size - ( args - ( char * ) value ) ; if ( strcmp ( name , \"current\" ) == 0 ) { if ( strcmp ( command , \"changehat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permhat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , AA_DO_TEST ) ; } else if ( strcmp ( command , \"changeprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , AA_DO_TEST ) ; } else goto fail ; } else if ( strcmp ( name , \"exec\" ) == 0 ) { if ( strcmp ( command , \"exec\" ) == 0 ) error = aa_setprocattr_changeprofile ( args , AA_ONEXEC , ! AA_DO_TEST AA_DO_TEST ) ; else goto fail ; } else goto fail ; goto fail ; if ( ! error ) error = size ; out : kfree ( largs ) ; return error . error = error = NULL ) ; goto out ; } \n", "\n", "Sources:\n", "0: CWE-119 static int apparmor_setprocattr ( struct task_struct * task , char * name , void * value , size_t size ) { struct common_audit_data sa ; struct apparmor_audit_data aad = { 0 , } ; char * command , * args = value ; size_t arg_size ; int error ; if ( size == 0 ) return - EINVAL ; if ( args [ size - 1 ] != '\\\\0' ) { if ( size == PAGE_SIZE ) return - EINVAL ; args [ size ] = '\\\\0' ; } if ( current != task ) return - EACCES ; args = value ; args = strim ( args ) ; command = strsep ( & args , \"\" ) ; if ( ! args ) return - EINVAL ; args = skip_spaces ( args ) ; if ( ! * args ) return - EINVAL ; arg_size = size - ( args - ( char * ) value ) ; if ( strcmp ( name , \"current\" ) == 0 ) { if ( strcmp ( command , \"changehat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permhat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , AA_DO_TEST ) ; } else if ( strcmp ( command , \"changeprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , AA_DO_TEST ) ; } else goto fail ; } else if ( strcmp ( name , \"exec\" ) == 0 ) { if ( strcmp ( command , \"exec\" ) == 0 ) error = aa_setprocattr_changeprofile ( args , AA_ONEXEC , ! AA_DO_TEST ) ; else goto fail ; } else return - EINVAL ; if ( ! error ) error = size ; return error ; fail : sa . type = LSM_AUDIT_DATA_NONE ; sa . aad = & aad ; aad . profile = aa_current_profile ( ) ; aad . op = OP_SETPROCATTR ; aad . info = name ; aad . error = - EINVAL ; aa_audit_msg ( AUDIT_APPARMOR_DENIED , & sa , NULL ) ; return - EINVAL ; }\n", "\n", "1: CWE-264 static int apparmor_setprocattr ( struct task_struct * task , char * name , void * value , size_t size ) { struct common_audit_data sa ; struct apparmor_audit_data aad = { 0 , } ; char * command , * args = value ; size_t arg_size ; int error ; if ( size == 0 ) return - EINVAL ; if ( args [ size - 1 ] != '\\\\0' ) { if ( size == PAGE_SIZE ) return - EINVAL ; args [ size ] = '\\\\0' ; } if ( current != task ) return - EACCES ; args = value ; args = strim ( args ) ; command = strsep ( & args , \"\" ) ; if ( ! args ) return - EINVAL ; args = skip_spaces ( args ) ; if ( ! * args ) return - EINVAL ; arg_size = size - ( args - ( char * ) value ) ; if ( strcmp ( name , \"current\" ) == 0 ) { if ( strcmp ( command , \"changehat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permhat\" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , AA_DO_TEST ) ; } else if ( strcmp ( command , \"changeprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , ! AA_DO_TEST ) ; } else if ( strcmp ( command , \"permprofile\" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , AA_DO_TEST ) ; } else goto fail ; } else if ( strcmp ( name , \"exec\" ) == 0 ) { if ( strcmp ( command , \"exec\" ) == 0 ) error = aa_setprocattr_changeprofile ( args , AA_ONEXEC , ! AA_DO_TEST ) ; else goto fail ; } else return - EINVAL ; if ( ! error ) error = size ; return error ; fail : sa . type = LSM_AUDIT_DATA_NONE ; sa . aad = & aad ; aad . profile = aa_current_profile ( ) ; aad . op = OP_SETPROCATTR ; aad . info = name ; aad . error = - EINVAL ; aa_audit_msg ( AUDIT_APPARMOR_DENIED , & sa , NULL ) ; return - EINVAL ; }\n", "\n", "\n", "Target: ) vendor_ie ; if ( le16_to_cpu ( ie -> ie_length ) + vs_ie -> len + 2 > IEEE_MAX_IE_SIZE ) return - EINVAL ;\n", "\n", "Sources:\n", "0: CWE-120 static int mwifiex_update_vs_ie ( const u8 * ies , int ies_len , struct mwifiex_ie * * ie_ptr , u16 mask , unsigned int oui , u8 oui_type ) { struct ieee_types_header * vs_ie ; struct mwifiex_ie * ie = * ie_ptr ; const u8 * vendor_ie ; vendor_ie = cfg80211_find_vendor_ie ( oui , oui_type , ies , ies_len ) ; if ( vendor_ie ) { if ( ! * ie_ptr ) { * ie_ptr = kzalloc ( sizeof ( struct mwifiex_ie ) , GFP_KERNEL ) ; if ( ! * ie_ptr ) return - ENOMEM ; ie = * ie_ptr ; } vs_ie = ( struct ieee_types_header * ) vendor_ie ; memcpy ( ie -> ie_buffer + le16_to_cpu ( ie -> ie_length ) , vs_ie , vs_ie -> len + 2 ) ; le16_unaligned_add_cpu ( & ie -> ie_length , vs_ie -> len + 2 ) ; ie -> mgmt_subtype_mask = cpu_to_le16 ( mask ) ; ie -> ie_index = cpu_to_le16 ( MWIFIEX_AUTO_IDX_MASK ) ; } * ie_ptr = ie ; return 0 ; }\n", "\n", "1: CWE-787 static int mwifiex_update_vs_ie ( const u8 * ies , int ies_len , struct mwifiex_ie * * ie_ptr , u16 mask , unsigned int oui , u8 oui_type ) { struct ieee_types_header * vs_ie ; struct mwifiex_ie * ie = * ie_ptr ; const u8 * vendor_ie ; vendor_ie = cfg80211_find_vendor_ie ( oui , oui_type , ies , ies_len ) ; if ( vendor_ie ) { if ( ! * ie_ptr ) { * ie_ptr = kzalloc ( sizeof ( struct mwifiex_ie ) , GFP_KERNEL ) ; if ( ! * ie_ptr ) return - ENOMEM ; ie = * ie_ptr ; } vs_ie = ( struct ieee_types_header * ) vendor_ie ; memcpy ( ie -> ie_buffer + le16_to_cpu ( ie -> ie_length ) , vs_ie , vs_ie -> len + 2 ) ; le16_unaligned_add_cpu ( & ie -> ie_length , vs_ie -> len + 2 ) ; ie -> mgmt_subtype_mask = cpu_to_le16 ( mask ) ; ie -> ie_index = cpu_to_le16 ( MWIFIEX_AUTO_IDX_MASK ) ; } * ie_ptr = ie ; return 0 ; }\n", "\n", "\n", "Target: -> enable ( false\n", "\n", "Sources:\n", "0: CWE-20 bool adapter_enable_disable ( ) { int error ; CALL_AND_WAIT ( error = bt_interface -> enable ( ) , adapter_state_changed ) ; TASSERT ( error == BT_STATUS_SUCCESS , \"ErrorenablingBluetooth:%d\" , error ) ; TASSERT ( adapter_get_state ( ) == BT_STATE_ON , \"Adapterdidnotturnon.\" ) ; CALL_AND_WAIT ( error = bt_interface -> disable ( ) , adapter_state_changed ) ; TASSERT ( error == BT_STATUS_SUCCESS , \"ErrordisablingBluetooth:%d\" , error ) ; TASSERT ( adapter_get_state ( ) == BT_STATE_OFF , \"Adapterdidnotturnoff.\" ) ; return true ; }\n", "\n", "1: CWE-20 void bdt_enable ( void ) { bdt_log ( \"ENABLEBT\" ) ; if ( bt_enabled ) { bdt_log ( \"Bluetoothisalreadyenabled\" ) ; return ; } status = sBtInterface -> enable ( ) ; check_return_status ( status ) ; }\n", "\n", "\n", "Target: base ; } kfree ( clk_src ) ;\n", "\n", "Sources:\n", "0: CWE-401 struct clock_source * dce110_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce110_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "1: CWE-401 struct clock_source * dce80_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce110_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "2: CWE-401 struct clock_source * dce100_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce110_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "3: CWE-401 struct clock_source * dcn10_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce112_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "4: CWE-401 struct clock_source * dce112_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce112_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "5: CWE-401 struct clock_source * dcn20_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( struct dce110_clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dcn20_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "6: CWE-401 static struct clock_source * dce120_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( * clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce112_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; }\n", "\n", "\n", "Target: ( buf = g_try_malloc0 ( size )\n", "\n", "Sources:\n", "0: CWE-908 void * vips_tracked_malloc ( size_t size ) { void * buf ; vips_tracked_init ( ) ; size += 16 ; if ( ! ( buf = g_try_malloc ( size ) ) ) { # ifdef DEBUG g_assert_not_reached ( ) ; # endif vips_error ( \"vips_tracked\" , _ ( \"outofmemory---size==%dMB\" ) , ( int ) ( size / ( 1024.0 * 1024.0 ) ) ) ; g_warning ( _ ( \"outofmemory---size==%dMB\" ) , ( int ) ( size / ( 1024.0 * 1024.0 ) ) ) ; return ( NULL ) ; } g_mutex_lock ( vips_tracked_mutex ) ; * ( ( size_t * ) buf ) = size ; buf = ( void * ) ( ( char * ) buf + 16 ) ; vips_tracked_mem += size ; if ( vips_tracked_mem > vips_tracked_mem_highwater ) vips_tracked_mem_highwater = vips_tracked_mem ; vips_tracked_allocs += 1 ; # ifdef DEBUG_VERBOSE printf ( \"vips_tracked_malloc:%p,%zdbytes\\\\n\" , buf , size ) ; # endif g_mutex_unlock ( vips_tracked_mutex ) ; VIPS_GATE_MALLOC ( size ) ; return ( buf ) ; }\n", "\n", "1: CWE-200 void * vips_tracked_malloc ( size_t size ) { void * buf ; vips_tracked_init ( ) ; size += 16 ; if ( ! ( buf = g_try_malloc ( size ) ) ) { # ifdef DEBUG g_assert_not_reached ( ) ; # endif vips_error ( \"vips_tracked\" , _ ( \"outofmemory---size==%dMB\" ) , ( int ) ( size / ( 1024.0 * 1024.0 ) ) ) ; g_warning ( _ ( \"outofmemory---size==%dMB\" ) , ( int ) ( size / ( 1024.0 * 1024.0 ) ) ) ; return ( NULL ) ; } g_mutex_lock ( vips_tracked_mutex ) ; * ( ( size_t * ) buf ) = size ; buf = ( void * ) ( ( char * ) buf + 16 ) ; vips_tracked_mem += size ; if ( vips_tracked_mem > vips_tracked_mem_highwater ) vips_tracked_mem_highwater = vips_tracked_mem ; vips_tracked_allocs += 1 ; # ifdef DEBUG_VERBOSE printf ( \"vips_tracked_malloc:%p,%zdbytes\\\\n\" , buf , size ) ; # endif g_mutex_unlock ( vips_tracked_mutex ) ; VIPS_GATE_MALLOC ( size ) ; return ( buf ) ; }\n", "\n", "\n", "Target: ) { int result ; int ; } } result = js_regexec ( re , opts ) ; if ( result < 0 ) js_error ( J , \"regexecfailed\" ) ; if ( result == 0\n", "\n", "Sources:\n", "0: CWE-674 void js_RegExp_prototype_exec ( js_State * J , js_Regexp * re , const char * text ) { int i ; int opts ; Resub m ; opts = 0 ; if ( re -> flags & JS_REGEXP_G ) { if ( re -> last > strlen ( text ) ) { re -> last = 0 ; js_pushnull ( J ) ; return ; } if ( re -> last > 0 ) { text += re -> last ; opts |= REG_NOTBOL ; } } if ( ! js_regexec ( re -> prog , text , & m , opts ) ) { js_newarray ( J ) ; js_pushstring ( J , text ) ; js_setproperty ( J , - 2 , \"input\" ) ; js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; js_setproperty ( J , - 2 , \"index\" ) ; for ( i = 0 ; i < m . nsub ; ++ i ) { js_pushlstring ( J , m . sub [ i ] . sp , m . sub [ i ] . ep - m . sub [ i ] . sp ) ; js_setindex ( J , - 2 , i ) ; } if ( re -> flags & JS_REGEXP_G ) re -> last = re -> last + ( m . sub [ 0 ] . ep - text ) ; return ; } if ( re -> flags & JS_REGEXP_G ) re -> last = 0 ; js_pushnull ( J ) ; }\n", "\n", "1: CWE-400 void js_RegExp_prototype_exec ( js_State * J , js_Regexp * re , const char * text ) { int i ; int opts ; Resub m ; opts = 0 ; if ( re -> flags & JS_REGEXP_G ) { if ( re -> last > strlen ( text ) ) { re -> last = 0 ; js_pushnull ( J ) ; return ; } if ( re -> last > 0 ) { text += re -> last ; opts |= REG_NOTBOL ; } } if ( ! js_regexec ( re -> prog , text , & m , opts ) ) { js_newarray ( J ) ; js_pushstring ( J , text ) ; js_setproperty ( J , - 2 , \"input\" ) ; js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; js_setproperty ( J , - 2 , \"index\" ) ; for ( i = 0 ; i < m . nsub ; ++ i ) { js_pushlstring ( J , m . sub [ i ] . sp , m . sub [ i ] . ep - m . sub [ i ] . sp ) ; js_setindex ( J , - 2 , i ) ; } if ( re -> flags & JS_REGEXP_G ) re -> last = re -> last + ( m . sub [ 0 ] . ep - text ) ; return ; } if ( re -> flags & JS_REGEXP_G ) re -> last = 0 ; js_pushnull ( J ) ; }\n", "\n", "\n", "Target: sctp_ierror_t ret ; if ( ! net -> sctp . auth_enable || ! new_asoc -> peer . auth_capable ) { kfree_skb ( chunk -> auth_chunk ) ; sctp_association_free ( new_asoc ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; }\n", "\n", "Sources:\n", "0: CWE-476 sctp_disposition_t sctp_sf_do_5_1D_ce ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * chunk = arg ; struct sctp_association * new_asoc ; sctp_init_chunk_t * peer_init ; struct sctp_chunk * repl ; struct sctp_ulpevent * ev , * ai_ev = NULL ; int error = 0 ; struct sctp_chunk * err_chk_p ; struct sock * sk ; if ( ep == sctp_sk ( net -> sctp . ctl_sock ) -> ep ) { SCTP_INC_STATS ( net , SCTP_MIB_OUTOFBLUES ) ; return sctp_sf_tabort_8_4_8 ( net , ep , asoc , type , arg , commands ) ; } if ( ! sctp_chunk_length_valid ( chunk , sizeof ( sctp_chunkhdr_t ) ) ) return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; sk = ep -> base . sk ; if ( ! sctp_sstate ( sk , LISTENING ) || ( sctp_style ( sk , TCP ) && sk_acceptq_is_full ( sk ) ) ) return sctp_sf_tabort_8_4_8 ( net , ep , asoc , type , arg , commands ) ; chunk -> subh . cookie_hdr = ( struct sctp_signed_cookie * ) chunk -> skb -> data ; if ( ! pskb_pull ( chunk -> skb , ntohs ( chunk -> chunk_hdr -> length ) - sizeof ( sctp_chunkhdr_t ) ) ) goto nomem ; new_asoc = sctp_unpack_cookie ( ep , asoc , chunk , GFP_ATOMIC , & error , & err_chk_p ) ; if ( ! new_asoc ) { switch ( error ) { case - SCTP_IERROR_NOMEM : goto nomem ; case - SCTP_IERROR_STALE_COOKIE : sctp_send_stale_cookie_err ( net , ep , asoc , chunk , commands , err_chk_p ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; case - SCTP_IERROR_BAD_SIG : default : return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } } peer_init = & chunk -> subh . cookie_hdr -> c . peer_init [ 0 ] ; if ( ! sctp_process_init ( new_asoc , chunk , & chunk -> subh . cookie_hdr -> c . peer_addr , peer_init , GFP_ATOMIC ) ) goto nomem_init ; error = sctp_auth_asoc_init_active_key ( new_asoc , GFP_ATOMIC ) ; if ( error ) goto nomem_init ; if ( chunk -> auth_chunk ) { struct sctp_chunk auth ; sctp_ierror_t ret ; auth . skb = chunk -> auth_chunk ; auth . asoc = chunk -> asoc ; auth . sctp_hdr = chunk -> sctp_hdr ; auth . chunk_hdr = ( sctp_chunkhdr_t * ) skb_push ( chunk -> auth_chunk , sizeof ( sctp_chunkhdr_t ) ) ; skb_pull ( chunk -> auth_chunk , sizeof ( sctp_chunkhdr_t ) ) ; auth . transport = chunk -> transport ; ret = sctp_sf_authenticate ( net , ep , new_asoc , type , & auth ) ; kfree_skb ( chunk -> auth_chunk ) ; if ( ret != SCTP_IERROR_NO_ERROR ) { sctp_association_free ( new_asoc ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } } repl = sctp_make_cookie_ack ( new_asoc , chunk ) ; if ( ! repl ) goto nomem_init ; ev = sctp_ulpevent_make_assoc_change ( new_asoc , 0 , SCTP_COMM_UP , 0 , new_asoc -> c . sinit_num_ostreams , new_asoc -> c . sinit_max_instreams , NULL , GFP_ATOMIC ) ; if ( ! ev ) goto nomem_ev ; if ( new_asoc -> peer . adaptation_ind ) { ai_ev = sctp_ulpevent_make_adaptation_indication ( new_asoc , GFP_ATOMIC ) ; if ( ! ai_ev ) goto nomem_aiev ; } sctp_add_cmd_sf ( commands , SCTP_CMD_NEW_ASOC , SCTP_ASOC ( new_asoc ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_NEW_STATE , SCTP_STATE ( SCTP_STATE_ESTABLISHED ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_CURRESTAB ) ; SCTP_INC_STATS ( net , SCTP_MIB_PASSIVEESTABS ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_HB_TIMERS_START , SCTP_NULL ( ) ) ; if ( new_asoc -> timeouts [ SCTP_EVENT_TIMEOUT_AUTOCLOSE ] ) sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_START , SCTP_TO ( SCTP_EVENT_TIMEOUT_AUTOCLOSE ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( repl ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_EVENT_ULP , SCTP_ULPEVENT ( ev ) ) ; if ( ai_ev ) sctp_add_cmd_sf ( commands , SCTP_CMD_EVENT_ULP , SCTP_ULPEVENT ( ai_ev ) ) ; return SCTP_DISPOSITION_CONSUME ; nomem_aiev : sctp_ulpevent_free ( ev ) ; nomem_ev : sctp_chunk_free ( repl ) ; nomem_init : sctp_association_free ( new_asoc ) ; nomem : return SCTP_DISPOSITION_NOMEM ; }\n", "\n", "1: CWE-20 sctp_disposition_t sctp_sf_do_5_1D_ce ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * chunk = arg ; struct sctp_association * new_asoc ; sctp_init_chunk_t * peer_init ; struct sctp_chunk * repl ; struct sctp_ulpevent * ev , * ai_ev = NULL ; int error = 0 ; struct sctp_chunk * err_chk_p ; struct sock * sk ; if ( ep == sctp_sk ( net -> sctp . ctl_sock ) -> ep ) { SCTP_INC_STATS ( net , SCTP_MIB_OUTOFBLUES ) ; return sctp_sf_tabort_8_4_8 ( net , ep , asoc , type , arg , commands ) ; } if ( ! sctp_chunk_length_valid ( chunk , sizeof ( sctp_chunkhdr_t ) ) ) return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; sk = ep -> base . sk ; if ( ! sctp_sstate ( sk , LISTENING ) || ( sctp_style ( sk , TCP ) && sk_acceptq_is_full ( sk ) ) ) return sctp_sf_tabort_8_4_8 ( net , ep , asoc , type , arg , commands ) ; chunk -> subh . cookie_hdr = ( struct sctp_signed_cookie * ) chunk -> skb -> data ; if ( ! pskb_pull ( chunk -> skb , ntohs ( chunk -> chunk_hdr -> length ) - sizeof ( sctp_chunkhdr_t ) ) ) goto nomem ; new_asoc = sctp_unpack_cookie ( ep , asoc , chunk , GFP_ATOMIC , & error , & err_chk_p ) ; if ( ! new_asoc ) { switch ( error ) { case - SCTP_IERROR_NOMEM : goto nomem ; case - SCTP_IERROR_STALE_COOKIE : sctp_send_stale_cookie_err ( net , ep , asoc , chunk , commands , err_chk_p ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; case - SCTP_IERROR_BAD_SIG : default : return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } } peer_init = & chunk -> subh . cookie_hdr -> c . peer_init [ 0 ] ; if ( ! sctp_process_init ( new_asoc , chunk , & chunk -> subh . cookie_hdr -> c . peer_addr , peer_init , GFP_ATOMIC ) ) goto nomem_init ; error = sctp_auth_asoc_init_active_key ( new_asoc , GFP_ATOMIC ) ; if ( error ) goto nomem_init ; if ( chunk -> auth_chunk ) { struct sctp_chunk auth ; sctp_ierror_t ret ; auth . skb = chunk -> auth_chunk ; auth . asoc = chunk -> asoc ; auth . sctp_hdr = chunk -> sctp_hdr ; auth . chunk_hdr = ( sctp_chunkhdr_t * ) skb_push ( chunk -> auth_chunk , sizeof ( sctp_chunkhdr_t ) ) ; skb_pull ( chunk -> auth_chunk , sizeof ( sctp_chunkhdr_t ) ) ; auth . transport = chunk -> transport ; ret = sctp_sf_authenticate ( net , ep , new_asoc , type , & auth ) ; kfree_skb ( chunk -> auth_chunk ) ; if ( ret != SCTP_IERROR_NO_ERROR ) { sctp_association_free ( new_asoc ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } } repl = sctp_make_cookie_ack ( new_asoc , chunk ) ; if ( ! repl ) goto nomem_init ; ev = sctp_ulpevent_make_assoc_change ( new_asoc , 0 , SCTP_COMM_UP , 0 , new_asoc -> c . sinit_num_ostreams , new_asoc -> c . sinit_max_instreams , NULL , GFP_ATOMIC ) ; if ( ! ev ) goto nomem_ev ; if ( new_asoc -> peer . adaptation_ind ) { ai_ev = sctp_ulpevent_make_adaptation_indication ( new_asoc , GFP_ATOMIC ) ; if ( ! ai_ev ) goto nomem_aiev ; } sctp_add_cmd_sf ( commands , SCTP_CMD_NEW_ASOC , SCTP_ASOC ( new_asoc ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_NEW_STATE , SCTP_STATE ( SCTP_STATE_ESTABLISHED ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_CURRESTAB ) ; SCTP_INC_STATS ( net , SCTP_MIB_PASSIVEESTABS ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_HB_TIMERS_START , SCTP_NULL ( ) ) ; if ( new_asoc -> timeouts [ SCTP_EVENT_TIMEOUT_AUTOCLOSE ] ) sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_START , SCTP_TO ( SCTP_EVENT_TIMEOUT_AUTOCLOSE ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( repl ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_EVENT_ULP , SCTP_ULPEVENT ( ev ) ) ; if ( ai_ev ) sctp_add_cmd_sf ( commands , SCTP_CMD_EVENT_ULP , SCTP_ULPEVENT ( ai_ev ) ) ; return SCTP_DISPOSITION_CONSUME ; nomem_aiev : sctp_ulpevent_free ( ev ) ; nomem_ev : sctp_chunk_free ( repl ) ; nomem_init : sctp_association_free ( new_asoc ) ; nomem : return SCTP_DISPOSITION_NOMEM ; }\n", "\n", "\n", "Target: } ret = fscrypt_get_encryption_info ( dir )\n", "\n", "Sources:\n", "0: CWE-416 int fscrypt_setup_filename ( struct inode * dir , const struct qstr * iname , int lookup , struct fscrypt_name * fname ) { int ret = 0 , bigname = 0 ; memset ( fname , 0 , sizeof ( struct fscrypt_name ) ) ; fname -> usr_fname = iname ; if ( ! dir -> i_sb -> s_cop -> is_encrypted ( dir ) || fscrypt_is_dot_dotdot ( iname ) ) { fname -> disk_name . name = ( unsigned char * ) iname -> name ; fname -> disk_name . len = iname -> len ; return 0 ; } ret = fscrypt_get_crypt_info ( dir ) ; if ( ret && ret != - EOPNOTSUPP ) return ret ; if ( dir -> i_crypt_info ) { ret = fscrypt_fname_alloc_buffer ( dir , iname -> len , & fname -> crypto_buf ) ; if ( ret ) return ret ; ret = fname_encrypt ( dir , iname , & fname -> crypto_buf ) ; if ( ret ) goto errout ; fname -> disk_name . name = fname -> crypto_buf . name ; fname -> disk_name . len = fname -> crypto_buf . len ; return 0 ; } if ( ! lookup ) return - ENOKEY ; if ( iname -> name [ 0 ] == '_' ) bigname = 1 ; if ( ( bigname && ( iname -> len != 33 ) ) || ( ! bigname && ( iname -> len > 43 ) ) ) return - ENOENT ; fname -> crypto_buf . name = kmalloc ( 32 , GFP_KERNEL ) ; if ( fname -> crypto_buf . name == NULL ) return - ENOMEM ; ret = digest_decode ( iname -> name + bigname , iname -> len - bigname , fname -> crypto_buf . name ) ; if ( ret < 0 ) { ret = - ENOENT ; goto errout ; } fname -> crypto_buf . len = ret ; if ( bigname ) { memcpy ( & fname -> hash , fname -> crypto_buf . name , 4 ) ; memcpy ( & fname -> minor_hash , fname -> crypto_buf . name + 4 , 4 ) ; } else { fname -> disk_name . name = fname -> crypto_buf . name ; fname -> disk_name . len = fname -> crypto_buf . len ; } return 0 ; errout : fscrypt_fname_free_buffer ( & fname -> crypto_buf ) ; return ret ; }\n", "\n", "1: CWE-476 int fscrypt_setup_filename ( struct inode * dir , const struct qstr * iname , int lookup , struct fscrypt_name * fname ) { int ret = 0 , bigname = 0 ; memset ( fname , 0 , sizeof ( struct fscrypt_name ) ) ; fname -> usr_fname = iname ; if ( ! dir -> i_sb -> s_cop -> is_encrypted ( dir ) || fscrypt_is_dot_dotdot ( iname ) ) { fname -> disk_name . name = ( unsigned char * ) iname -> name ; fname -> disk_name . len = iname -> len ; return 0 ; } ret = fscrypt_get_crypt_info ( dir ) ; if ( ret && ret != - EOPNOTSUPP ) return ret ; if ( dir -> i_crypt_info ) { ret = fscrypt_fname_alloc_buffer ( dir , iname -> len , & fname -> crypto_buf ) ; if ( ret ) return ret ; ret = fname_encrypt ( dir , iname , & fname -> crypto_buf ) ; if ( ret ) goto errout ; fname -> disk_name . name = fname -> crypto_buf . name ; fname -> disk_name . len = fname -> crypto_buf . len ; return 0 ; } if ( ! lookup ) return - ENOKEY ; if ( iname -> name [ 0 ] == '_' ) bigname = 1 ; if ( ( bigname && ( iname -> len != 33 ) ) || ( ! bigname && ( iname -> len > 43 ) ) ) return - ENOENT ; fname -> crypto_buf . name = kmalloc ( 32 , GFP_KERNEL ) ; if ( fname -> crypto_buf . name == NULL ) return - ENOMEM ; ret = digest_decode ( iname -> name + bigname , iname -> len - bigname , fname -> crypto_buf . name ) ; if ( ret < 0 ) { ret = - ENOENT ; goto errout ; } fname -> crypto_buf . len = ret ; if ( bigname ) { memcpy ( & fname -> hash , fname -> crypto_buf . name , 4 ) ; memcpy ( & fname -> minor_hash , fname -> crypto_buf . name + 4 , 4 ) ; } else { fname -> disk_name . name = fname -> crypto_buf . name ; fname -> disk_name . len = fname -> crypto_buf . len ; } return 0 ; errout : fscrypt_fname_free_buffer ( & fname -> crypto_buf ) ; return ret ; }\n", "\n", "\n", "Target: { if ( js_doregexec ( J , re -> prog { if ( js_doregexec ( J , re -> prog\n", "\n", "Sources:\n", "0: CWE-674 static void Sp_split_regexp ( js_State * J ) { js_Regexp * re ; const char * text ; int limit , len , k ; const char * p , * a , * b , * c , * e ; Resub m ; text = checkstring ( J , 0 ) ; re = js_toregexp ( J , 1 ) ; limit = js_isdefined ( J , 2 ) ? js_tointeger ( J , 2 ) : 1 << 30 ; js_newarray ( J ) ; len = 0 ; e = text + strlen ( text ) ; if ( e == text ) { if ( js_regexec ( re -> prog , text , & m , 0 ) ) { if ( len == limit ) return ; js_pushliteral ( J , \"\" ) ; js_setindex ( J , - 2 , 0 ) ; } return ; } p = a = text ; while ( a < e ) { if ( js_regexec ( re -> prog , a , & m , a > text ? REG_NOTBOL : 0 ) ) break ; b = m . sub [ 0 ] . sp ; c = m . sub [ 0 ] . ep ; if ( b == p ) { ++ a ; continue ; } if ( len == limit ) return ; js_pushlstring ( J , p , b - p ) ; js_setindex ( J , - 2 , len ++ ) ; for ( k = 1 ; k < m . nsub ; ++ k ) { if ( len == limit ) return ; js_pushlstring ( J , m . sub [ k ] . sp , m . sub [ k ] . ep - m . sub [ k ] . sp ) ; js_setindex ( J , - 2 , len ++ ) ; } a = p = c ; } if ( len == limit ) return ; js_pushstring ( J , p ) ; js_setindex ( J , - 2 , len ) ; }\n", "\n", "1: CWE-400 static void Sp_split_regexp ( js_State * J ) { js_Regexp * re ; const char * text ; int limit , len , k ; const char * p , * a , * b , * c , * e ; Resub m ; text = checkstring ( J , 0 ) ; re = js_toregexp ( J , 1 ) ; limit = js_isdefined ( J , 2 ) ? js_tointeger ( J , 2 ) : 1 << 30 ; js_newarray ( J ) ; len = 0 ; e = text + strlen ( text ) ; if ( e == text ) { if ( js_regexec ( re -> prog , text , & m , 0 ) ) { if ( len == limit ) return ; js_pushliteral ( J , \"\" ) ; js_setindex ( J , - 2 , 0 ) ; } return ; } p = a = text ; while ( a < e ) { if ( js_regexec ( re -> prog , a , & m , a > text ? REG_NOTBOL : 0 ) ) break ; b = m . sub [ 0 ] . sp ; c = m . sub [ 0 ] . ep ; if ( b == p ) { ++ a ; continue ; } if ( len == limit ) return ; js_pushlstring ( J , p , b - p ) ; js_setindex ( J , - 2 , len ++ ) ; for ( k = 1 ; k < m . nsub ; ++ k ) { if ( len == limit ) return ; js_pushlstring ( J , m . sub [ k ] . sp , m . sub [ k ] . ep - m . sub [ k ] . sp ) ; js_setindex ( J , - 2 , len ++ ) ; } a = p = c ; } if ( len == limit ) return ; js_pushstring ( J , p ) ; js_setindex ( J , - 2 , len ) ; }\n", "\n", "\n", "Target: & ds64_chunk , sizeof ( DS64Chunk ) , & bcount || bcount != sizeof ( DS64Chunk ) ) { error_line & ds64_chunk , sizeof ( DS64Chunk ) ) ) {\n", "\n", "Sources:\n", "0: CWE-125 int ParseRiffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int is_rf64 = ! strncmp ( fourcc , \"RF64\" , 4 ) , got_ds64 = 0 ; int64_t total_samples = 0 , infilesize ; RiffChunkHeader riff_chunk_header ; ChunkHeader chunk_header ; WaveHeader WaveHeader ; DS64Chunk ds64_chunk ; uint32_t bcount ; CLEAR ( WaveHeader ) ; CLEAR ( ds64_chunk ) ; infilesize = DoGetFileSize ( infile ) ; if ( ! is_rf64 && infilesize >= 4294967296LL && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) ) { error_line ( \"can\\'thandle.WAVfileslargerthan4GB(non-standard)!\" ) ; return WAVPACK_SOFT_ERROR ; } memcpy ( & riff_chunk_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & riff_chunk_header ) + 4 , sizeof ( RiffChunkHeader ) - 4 , & bcount ) || bcount != sizeof ( RiffChunkHeader ) - 4 || strncmp ( riff_chunk_header . formType , \"WAVE\" , 4 ) ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & riff_chunk_header , sizeof ( RiffChunkHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if ( ! DoReadFile ( infile , & chunk_header , sizeof ( ChunkHeader ) , & bcount ) || bcount != sizeof ( ChunkHeader ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & chunk_header , sizeof ( ChunkHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & chunk_header , ChunkHeaderFormat ) ; if ( ! strncmp ( chunk_header . ckID , \"ds64\" , 4 ) ) { if ( chunk_header . ckSize < sizeof ( DS64Chunk ) || ! DoReadFile ( infile , & ds64_chunk , chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & ds64_chunk , chunk_header . ckSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } got_ds64 = 1 ; WavpackLittleEndianToNative ( & ds64_chunk , DS64ChunkFormat ) ; if ( debug_logging_mode ) error_line ( \"DS64:riffSize=%lld,dataSize=%lld,sampleCount=%lld,table_length=%d\" , ( long long ) ds64_chunk . riffSize64 , ( long long ) ds64_chunk . dataSize64 , ( long long ) ds64_chunk . sampleCount64 , ds64_chunk . tableLength ) ; if ( ds64_chunk . tableLength * sizeof ( CS64Chunk ) != chunk_header . ckSize - sizeof ( DS64Chunk ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } while ( ds64_chunk . tableLength -- ) { CS64Chunk cs64_chunk ; if ( ! DoReadFile ( infile , & cs64_chunk , sizeof ( CS64Chunk ) , & bcount ) || bcount != sizeof ( CS64Chunk ) || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & cs64_chunk , sizeof ( CS64Chunk ) ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } } } else if ( ! strncmp ( chunk_header . ckID , \"fmt\" , 4 ) ) { int supported = TRUE , format ; if ( chunk_header . ckSize < 16 || chunk_header . ckSize > sizeof ( WaveHeader ) || ! DoReadFile ( infile , & WaveHeader , chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & WaveHeader , chunk_header . ckSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & WaveHeader , WaveHeaderFormat ) ; if ( debug_logging_mode ) { error_line ( \"formattagsize=%d\" , chunk_header . ckSize ) ; error_line ( \"FormatTag=%x,NumChannels=%d,BitsPerSample=%d\" , WaveHeader . FormatTag , WaveHeader . NumChannels , WaveHeader . BitsPerSample ) ; error_line ( \"BlockAlign=%d,SampleRate=%d,BytesPerSecond=%d\" , WaveHeader . BlockAlign , WaveHeader . SampleRate , WaveHeader . BytesPerSecond ) ; if ( chunk_header . ckSize > 16 ) error_line ( \"cbSize=%d,ValidBitsPerSample=%d\" , WaveHeader . cbSize , WaveHeader . ValidBitsPerSample ) ; if ( chunk_header . ckSize > 20 ) error_line ( \"ChannelMask=%x,SubFormat=%d\" , WaveHeader . ChannelMask , WaveHeader . SubFormat ) ; } if ( chunk_header . ckSize > 16 && WaveHeader . cbSize == 2 ) config -> qmode |= QMODE_ADOBE_MODE ; format = ( WaveHeader . FormatTag == 0xfffe && chunk_header . ckSize == 40 ) ? WaveHeader . SubFormat : WaveHeader . FormatTag ; config -> bits_per_sample = ( chunk_header . ckSize == 40 && WaveHeader . ValidBitsPerSample ) ? WaveHeader . ValidBitsPerSample : WaveHeader . BitsPerSample ; if ( format != 1 && format != 3 ) supported = FALSE ; if ( format == 3 && config -> bits_per_sample != 32 ) supported = FALSE ; if ( ! WaveHeader . NumChannels || WaveHeader . NumChannels > 256 || WaveHeader . BlockAlign / WaveHeader . NumChannels < ( config -> bits_per_sample + 7 ) / 8 || WaveHeader . BlockAlign / WaveHeader . NumChannels > 4 || WaveHeader . BlockAlign % WaveHeader . NumChannels ) supported = FALSE ; if ( config -> bits_per_sample < 1 || config -> bits_per_sample > 32 ) supported = FALSE ; if ( ! supported ) { error_line ( \"%sisanunsupported.WAVformat!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( chunk_header . ckSize < 40 ) { if ( ! config -> channel_mask && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { if ( WaveHeader . NumChannels <= 2 ) config -> channel_mask = 0x5 - WaveHeader . NumChannels ; else if ( WaveHeader . NumChannels <= 18 ) config -> channel_mask = ( 1 << WaveHeader . NumChannels ) - 1 ; else config -> channel_mask = 0x3ffff ; } } else if ( WaveHeader . ChannelMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( \"thisWAVfilealreadyhaschannelorderinformation!\" ) ; return WAVPACK_SOFT_ERROR ; } else if ( WaveHeader . ChannelMask ) config -> channel_mask = WaveHeader . ChannelMask ; if ( format == 3 ) config -> float_norm_exp = 127 ; else if ( ( config -> qmode & QMODE_ADOBE_MODE ) && WaveHeader . BlockAlign / WaveHeader . NumChannels == 4 ) { if ( WaveHeader . BitsPerSample == 24 ) config -> float_norm_exp = 127 + 23 ; else if ( WaveHeader . BitsPerSample == 32 ) config -> float_norm_exp = 127 + 15 ; } if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( \"dataformat:normalized32-bitfloatingpoint\" ) ; else if ( config -> float_norm_exp ) error_line ( \"dataformat:32-bitfloatingpoint(Audition%d:%dfloattype1)\" , config -> float_norm_exp - 126 , 150 - config -> float_norm_exp ) ; else error_line ( \"dataformat:%d-bitintegersstoredin%dbyte(s)\" , config -> bits_per_sample , WaveHeader . BlockAlign / WaveHeader . NumChannels ) ; } } else if ( ! strncmp ( chunk_header . ckID , \"data\" , 4 ) ) { int64_t data_chunk_size = ( got_ds64 && chunk_header . ckSize == ( uint32_t ) - 1 ) ? ds64_chunk . dataSize64 : chunk_header . ckSize ; if ( ! WaveHeader . NumChannels || ( is_rf64 && ! got_ds64 ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && infilesize - data_chunk_size > 16777216 ) { error_line ( \"this.WAVfilehasover16MBofextraRIFFdata,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( config -> qmode & QMODE_IGNORE_LENGTH ) { if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / WaveHeader . BlockAlign ; else total_samples = - 1 ; } else { total_samples = data_chunk_size / WaveHeader . BlockAlign ; if ( got_ds64 && total_samples != ds64_chunk . sampleCount64 ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ! total_samples ) { error_line ( \"this.WAVfilehasnoaudiosamples,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( \"%shastoomanysamplesforWavPack!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } config -> bytes_per_sample = WaveHeader . BlockAlign / WaveHeader . NumChannels ; config -> num_channels = WaveHeader . NumChannels ; config -> sample_rate = WaveHeader . SampleRate ; break ; } else { int bytes_to_copy = ( chunk_header . ckSize + 1 ) & ~ 1L ; char * buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( \"extraunknownchunk\\\\\"%c%c%c%c\\\\\"of%dbytes\" , chunk_header . ckID [ 0 ] , chunk_header . ckID [ 1 ] , chunk_header . ckID [ 2 ] , chunk_header . ckID [ 3 ] , chunk_header . ckSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( \"%s:%s\" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; }\n", "\n", "1: CWE-119 int ParseRiffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int is_rf64 = ! strncmp ( fourcc , \"RF64\" , 4 ) , got_ds64 = 0 ; int64_t total_samples = 0 , infilesize ; RiffChunkHeader riff_chunk_header ; ChunkHeader chunk_header ; WaveHeader WaveHeader ; DS64Chunk ds64_chunk ; uint32_t bcount ; CLEAR ( WaveHeader ) ; CLEAR ( ds64_chunk ) ; infilesize = DoGetFileSize ( infile ) ; if ( ! is_rf64 && infilesize >= 4294967296LL && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) ) { error_line ( \"can\\'thandle.WAVfileslargerthan4GB(non-standard)!\" ) ; return WAVPACK_SOFT_ERROR ; } memcpy ( & riff_chunk_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & riff_chunk_header ) + 4 , sizeof ( RiffChunkHeader ) - 4 , & bcount ) || bcount != sizeof ( RiffChunkHeader ) - 4 || strncmp ( riff_chunk_header . formType , \"WAVE\" , 4 ) ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & riff_chunk_header , sizeof ( RiffChunkHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if ( ! DoReadFile ( infile , & chunk_header , sizeof ( ChunkHeader ) , & bcount ) || bcount != sizeof ( ChunkHeader ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & chunk_header , sizeof ( ChunkHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & chunk_header , ChunkHeaderFormat ) ; if ( ! strncmp ( chunk_header . ckID , \"ds64\" , 4 ) ) { if ( chunk_header . ckSize < sizeof ( DS64Chunk ) || ! DoReadFile ( infile , & ds64_chunk , chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & ds64_chunk , chunk_header . ckSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } got_ds64 = 1 ; WavpackLittleEndianToNative ( & ds64_chunk , DS64ChunkFormat ) ; if ( debug_logging_mode ) error_line ( \"DS64:riffSize=%lld,dataSize=%lld,sampleCount=%lld,table_length=%d\" , ( long long ) ds64_chunk . riffSize64 , ( long long ) ds64_chunk . dataSize64 , ( long long ) ds64_chunk . sampleCount64 , ds64_chunk . tableLength ) ; if ( ds64_chunk . tableLength * sizeof ( CS64Chunk ) != chunk_header . ckSize - sizeof ( DS64Chunk ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } while ( ds64_chunk . tableLength -- ) { CS64Chunk cs64_chunk ; if ( ! DoReadFile ( infile , & cs64_chunk , sizeof ( CS64Chunk ) , & bcount ) || bcount != sizeof ( CS64Chunk ) || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & cs64_chunk , sizeof ( CS64Chunk ) ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } } } else if ( ! strncmp ( chunk_header . ckID , \"fmt\" , 4 ) ) { int supported = TRUE , format ; if ( chunk_header . ckSize < 16 || chunk_header . ckSize > sizeof ( WaveHeader ) || ! DoReadFile ( infile , & WaveHeader , chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & WaveHeader , chunk_header . ckSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & WaveHeader , WaveHeaderFormat ) ; if ( debug_logging_mode ) { error_line ( \"formattagsize=%d\" , chunk_header . ckSize ) ; error_line ( \"FormatTag=%x,NumChannels=%d,BitsPerSample=%d\" , WaveHeader . FormatTag , WaveHeader . NumChannels , WaveHeader . BitsPerSample ) ; error_line ( \"BlockAlign=%d,SampleRate=%d,BytesPerSecond=%d\" , WaveHeader . BlockAlign , WaveHeader . SampleRate , WaveHeader . BytesPerSecond ) ; if ( chunk_header . ckSize > 16 ) error_line ( \"cbSize=%d,ValidBitsPerSample=%d\" , WaveHeader . cbSize , WaveHeader . ValidBitsPerSample ) ; if ( chunk_header . ckSize > 20 ) error_line ( \"ChannelMask=%x,SubFormat=%d\" , WaveHeader . ChannelMask , WaveHeader . SubFormat ) ; } if ( chunk_header . ckSize > 16 && WaveHeader . cbSize == 2 ) config -> qmode |= QMODE_ADOBE_MODE ; format = ( WaveHeader . FormatTag == 0xfffe && chunk_header . ckSize == 40 ) ? WaveHeader . SubFormat : WaveHeader . FormatTag ; config -> bits_per_sample = ( chunk_header . ckSize == 40 && WaveHeader . ValidBitsPerSample ) ? WaveHeader . ValidBitsPerSample : WaveHeader . BitsPerSample ; if ( format != 1 && format != 3 ) supported = FALSE ; if ( format == 3 && config -> bits_per_sample != 32 ) supported = FALSE ; if ( ! WaveHeader . NumChannels || WaveHeader . NumChannels > 256 || WaveHeader . BlockAlign / WaveHeader . NumChannels < ( config -> bits_per_sample + 7 ) / 8 || WaveHeader . BlockAlign / WaveHeader . NumChannels > 4 || WaveHeader . BlockAlign % WaveHeader . NumChannels ) supported = FALSE ; if ( config -> bits_per_sample < 1 || config -> bits_per_sample > 32 ) supported = FALSE ; if ( ! supported ) { error_line ( \"%sisanunsupported.WAVformat!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( chunk_header . ckSize < 40 ) { if ( ! config -> channel_mask && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { if ( WaveHeader . NumChannels <= 2 ) config -> channel_mask = 0x5 - WaveHeader . NumChannels ; else if ( WaveHeader . NumChannels <= 18 ) config -> channel_mask = ( 1 << WaveHeader . NumChannels ) - 1 ; else config -> channel_mask = 0x3ffff ; } } else if ( WaveHeader . ChannelMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( \"thisWAVfilealreadyhaschannelorderinformation!\" ) ; return WAVPACK_SOFT_ERROR ; } else if ( WaveHeader . ChannelMask ) config -> channel_mask = WaveHeader . ChannelMask ; if ( format == 3 ) config -> float_norm_exp = 127 ; else if ( ( config -> qmode & QMODE_ADOBE_MODE ) && WaveHeader . BlockAlign / WaveHeader . NumChannels == 4 ) { if ( WaveHeader . BitsPerSample == 24 ) config -> float_norm_exp = 127 + 23 ; else if ( WaveHeader . BitsPerSample == 32 ) config -> float_norm_exp = 127 + 15 ; } if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( \"dataformat:normalized32-bitfloatingpoint\" ) ; else if ( config -> float_norm_exp ) error_line ( \"dataformat:32-bitfloatingpoint(Audition%d:%dfloattype1)\" , config -> float_norm_exp - 126 , 150 - config -> float_norm_exp ) ; else error_line ( \"dataformat:%d-bitintegersstoredin%dbyte(s)\" , config -> bits_per_sample , WaveHeader . BlockAlign / WaveHeader . NumChannels ) ; } } else if ( ! strncmp ( chunk_header . ckID , \"data\" , 4 ) ) { int64_t data_chunk_size = ( got_ds64 && chunk_header . ckSize == ( uint32_t ) - 1 ) ? ds64_chunk . dataSize64 : chunk_header . ckSize ; if ( ! WaveHeader . NumChannels || ( is_rf64 && ! got_ds64 ) ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && infilesize - data_chunk_size > 16777216 ) { error_line ( \"this.WAVfilehasover16MBofextraRIFFdata,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( config -> qmode & QMODE_IGNORE_LENGTH ) { if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / WaveHeader . BlockAlign ; else total_samples = - 1 ; } else { total_samples = data_chunk_size / WaveHeader . BlockAlign ; if ( got_ds64 && total_samples != ds64_chunk . sampleCount64 ) { error_line ( \"%sisnotavalid.WAVfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ! total_samples ) { error_line ( \"this.WAVfilehasnoaudiosamples,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( \"%shastoomanysamplesforWavPack!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } config -> bytes_per_sample = WaveHeader . BlockAlign / WaveHeader . NumChannels ; config -> num_channels = WaveHeader . NumChannels ; config -> sample_rate = WaveHeader . SampleRate ; break ; } else { int bytes_to_copy = ( chunk_header . ckSize + 1 ) & ~ 1L ; char * buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( \"extraunknownchunk\\\\\"%c%c%c%c\\\\\"of%dbytes\" , chunk_header . ckID [ 0 ] , chunk_header . ckID [ 1 ] , chunk_header . ckID [ 2 ] , chunk_header . ckID [ 3 ] , chunk_header . ckSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( \"%s:%s\" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; }\n", "\n", "\n", "Target: out2 , out1 , sizeof ( out2 ) out2 , out1 , sizeof ( out2 )\n", "\n", "Sources:\n", "0: CWE-120 void test_base64_lengths ( void ) { const char * in = \"FuseMuse\" ; char out1 [ 32 ] ; char out2 [ 32 ] ; size_t enclen ; int declen ; enclen = mutt_b64_encode ( out1 , in , 0 , 32 ) ; if ( ! TEST_CHECK ( enclen == 0 ) ) { TEST_MSG ( \"Expected:%zu\" , 0 ) ; TEST_MSG ( \"Actual:%zu\" , enclen ) ; } out1 [ 0 ] = '\\\\0' ; declen = mutt_b64_decode ( out2 , out1 ) ; if ( ! TEST_CHECK ( declen == - 1 ) ) { TEST_MSG ( \"Expected:%zu\" , - 1 ) ; TEST_MSG ( \"Actual:%zu\" , declen ) ; } for ( size_t i = 1 ; i <= 8 ; ++ i ) { enclen = mutt_b64_encode ( out1 , in , i , 32 ) ; size_t exp = ( ( i + 2 ) / 3 ) << 2 ; if ( ! TEST_CHECK ( enclen == exp ) ) { TEST_MSG ( \"Expected:%zu\" , exp ) ; TEST_MSG ( \"Actual:%zu\" , enclen ) ; } declen = mutt_b64_decode ( out2 , out1 ) ; if ( ! TEST_CHECK ( declen == i ) ) { TEST_MSG ( \"Expected:%zu\" , i ) ; TEST_MSG ( \"Actual:%zu\" , declen ) ; } out2 [ declen ] = '\\\\0' ; if ( ! TEST_CHECK ( strncmp ( out2 , in , i ) == 0 ) ) { TEST_MSG ( \"Expected:%s\" , in ) ; TEST_MSG ( \"Actual:%s\" , out2 ) ; } } }\n", "\n", "1: CWE-119 void test_base64_lengths ( void ) { const char * in = \"FuseMuse\" ; char out1 [ 32 ] ; char out2 [ 32 ] ; size_t enclen ; int declen ; enclen = mutt_b64_encode ( out1 , in , 0 , 32 ) ; if ( ! TEST_CHECK ( enclen == 0 ) ) { TEST_MSG ( \"Expected:%zu\" , 0 ) ; TEST_MSG ( \"Actual:%zu\" , enclen ) ; } out1 [ 0 ] = '\\\\0' ; declen = mutt_b64_decode ( out2 , out1 ) ; if ( ! TEST_CHECK ( declen == - 1 ) ) { TEST_MSG ( \"Expected:%zu\" , - 1 ) ; TEST_MSG ( \"Actual:%zu\" , declen ) ; } for ( size_t i = 1 ; i <= 8 ; ++ i ) { enclen = mutt_b64_encode ( out1 , in , i , 32 ) ; size_t exp = ( ( i + 2 ) / 3 ) << 2 ; if ( ! TEST_CHECK ( enclen == exp ) ) { TEST_MSG ( \"Expected:%zu\" , exp ) ; TEST_MSG ( \"Actual:%zu\" , enclen ) ; } declen = mutt_b64_decode ( out2 , out1 ) ; if ( ! TEST_CHECK ( declen == i ) ) { TEST_MSG ( \"Expected:%zu\" , i ) ; TEST_MSG ( \"Actual:%zu\" , declen ) ; } out2 [ declen ] = '\\\\0' ; if ( ! TEST_CHECK ( strncmp ( out2 , in , i ) == 0 ) ) { TEST_MSG ( \"Expected:%s\" , in ) ; TEST_MSG ( \"Actual:%s\" , out2 ) ; } } }\n", "\n", "\n", "Target: ( sk ) ; struct ipv6_txoptions * opt -> hop_limit ; opt = rcu_dereference ( np -> np -> opt ) ; if ( opt ) { opt = ipv6_dup_options ( newsk , opt ) ; RCU_INIT_POINTER ( newnp -> opt , opt ) ; } inet_csk ( newsk ; if ( opt ) inet_csk ( -> icsk_ext_hdr_len = opt -> opt_nflen -> opt_nflen + opt -> opt_flen opt -> opt_flen ; dccp_sync_mss (\n", "\n", "Sources:\n", "0: CWE-416 static struct sock * dccp_v6_request_recv_sock ( const struct sock * sk , struct sk_buff * skb , struct request_sock * req , struct dst_entry * dst , struct request_sock * req_unhash , bool * own_req ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; struct ipv6_pinfo * newnp ; const struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * newinet ; struct dccp6_sock * newdp6 ; struct sock * newsk ; if ( skb -> protocol == htons ( ETH_P_IP ) ) { newsk = dccp_v4_request_recv_sock ( sk , skb , req , dst , req_unhash , own_req ) ; if ( newsk == NULL ) return NULL ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; newnp -> saddr = newsk -> sk_v6_rcv_saddr ; inet_csk ( newsk ) -> icsk_af_ops = & dccp_ipv6_mapped ; newsk -> sk_backlog_rcv = dccp_v4_do_rcv ; newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; dccp_sync_mss ( newsk , inet_csk ( newsk ) -> icsk_pmtu_cookie ) ; return newsk ; } if ( sk_acceptq_is_full ( sk ) ) goto out_overflow ; if ( ! dst ) { struct flowi6 fl6 ; dst = inet6_csk_route_req ( sk , & fl6 , req , IPPROTO_DCCP ) ; if ( ! dst ) goto out ; } newsk = dccp_create_openreq_child ( sk , req , skb ) ; if ( newsk == NULL ) goto out_nonewsk ; __ip6_dst_store ( newsk , dst , NULL , NULL ) ; newsk -> sk_route_caps = dst -> dev -> features & ~ ( NETIF_F_IP_CSUM | NETIF_F_TSO ) ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; newsk -> sk_v6_daddr = ireq -> ir_v6_rmt_addr ; newnp -> saddr = ireq -> ir_v6_loc_addr ; newsk -> sk_v6_rcv_saddr = ireq -> ir_v6_loc_addr ; newsk -> sk_bound_dev_if = ireq -> ir_iif ; newinet -> inet_opt = NULL ; newnp -> rxopt . all = np -> rxopt . all ; newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; if ( np -> opt != NULL ) newnp -> opt = ipv6_dup_options ( newsk , np -> opt ) ; inet_csk ( newsk ) -> icsk_ext_hdr_len = 0 ; if ( newnp -> opt != NULL ) inet_csk ( newsk ) -> icsk_ext_hdr_len = ( newnp -> opt -> opt_nflen + newnp -> opt -> opt_flen ) ; dccp_sync_mss ( newsk , dst_mtu ( dst ) ) ; newinet -> inet_daddr = newinet -> inet_saddr = LOOPBACK4_IPV6 ; newinet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( __inet_inherit_port ( sk , newsk ) < 0 ) { inet_csk_prepare_forced_close ( newsk ) ; dccp_done ( newsk ) ; goto out ; } * own_req = inet_ehash_nolisten ( newsk , req_to_sk ( req_unhash ) ) ; if ( * own_req && ireq -> pktopts ) { newnp -> pktoptions = skb_clone ( ireq -> pktopts , GFP_ATOMIC ) ; consume_skb ( ireq -> pktopts ) ; ireq -> pktopts = NULL ; if ( newnp -> pktoptions ) skb_set_owner_r ( newnp -> pktoptions , newsk ) ; } return newsk ; out_overflow : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENOVERFLOWS ) ; out_nonewsk : dst_release ( dst ) ; out : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENDROPS ) ; return NULL ; }\n", "\n", "1: CWE-264 static struct sock * dccp_v6_request_recv_sock ( const struct sock * sk , struct sk_buff * skb , struct request_sock * req , struct dst_entry * dst , struct request_sock * req_unhash , bool * own_req ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; struct ipv6_pinfo * newnp ; const struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * newinet ; struct dccp6_sock * newdp6 ; struct sock * newsk ; if ( skb -> protocol == htons ( ETH_P_IP ) ) { newsk = dccp_v4_request_recv_sock ( sk , skb , req , dst , req_unhash , own_req ) ; if ( newsk == NULL ) return NULL ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; newnp -> saddr = newsk -> sk_v6_rcv_saddr ; inet_csk ( newsk ) -> icsk_af_ops = & dccp_ipv6_mapped ; newsk -> sk_backlog_rcv = dccp_v4_do_rcv ; newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; dccp_sync_mss ( newsk , inet_csk ( newsk ) -> icsk_pmtu_cookie ) ; return newsk ; } if ( sk_acceptq_is_full ( sk ) ) goto out_overflow ; if ( ! dst ) { struct flowi6 fl6 ; dst = inet6_csk_route_req ( sk , & fl6 , req , IPPROTO_DCCP ) ; if ( ! dst ) goto out ; } newsk = dccp_create_openreq_child ( sk , req , skb ) ; if ( newsk == NULL ) goto out_nonewsk ; __ip6_dst_store ( newsk , dst , NULL , NULL ) ; newsk -> sk_route_caps = dst -> dev -> features & ~ ( NETIF_F_IP_CSUM | NETIF_F_TSO ) ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; newsk -> sk_v6_daddr = ireq -> ir_v6_rmt_addr ; newnp -> saddr = ireq -> ir_v6_loc_addr ; newsk -> sk_v6_rcv_saddr = ireq -> ir_v6_loc_addr ; newsk -> sk_bound_dev_if = ireq -> ir_iif ; newinet -> inet_opt = NULL ; newnp -> rxopt . all = np -> rxopt . all ; newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; if ( np -> opt != NULL ) newnp -> opt = ipv6_dup_options ( newsk , np -> opt ) ; inet_csk ( newsk ) -> icsk_ext_hdr_len = 0 ; if ( newnp -> opt != NULL ) inet_csk ( newsk ) -> icsk_ext_hdr_len = ( newnp -> opt -> opt_nflen + newnp -> opt -> opt_flen ) ; dccp_sync_mss ( newsk , dst_mtu ( dst ) ) ; newinet -> inet_daddr = newinet -> inet_saddr = LOOPBACK4_IPV6 ; newinet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( __inet_inherit_port ( sk , newsk ) < 0 ) { inet_csk_prepare_forced_close ( newsk ) ; dccp_done ( newsk ) ; goto out ; } * own_req = inet_ehash_nolisten ( newsk , req_to_sk ( req_unhash ) ) ; if ( * own_req && ireq -> pktopts ) { newnp -> pktoptions = skb_clone ( ireq -> pktopts , GFP_ATOMIC ) ; consume_skb ( ireq -> pktopts ) ; ireq -> pktopts = NULL ; if ( newnp -> pktoptions ) skb_set_owner_r ( newnp -> pktoptions , newsk ) ; } return newsk ; out_overflow : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENOVERFLOWS ) ; out_nonewsk : dst_release ( dst ) ; out : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENDROPS ) ; return NULL ; }\n", "\n", "\n", "Target: 0 ) { struct snd_ctl_elem_id id = kctl -> id ; SNDRV_CTL_EVENT_MASK_TLV , & id ) ;\n", "\n", "Sources:\n", "0: CWE-416 static int snd_ctl_tlv_ioctl ( struct snd_ctl_file * file , struct snd_ctl_tlv __user * _tlv , int op_flag ) { struct snd_card * card = file -> card ; struct snd_ctl_tlv tlv ; struct snd_kcontrol * kctl ; struct snd_kcontrol_volatile * vd ; unsigned int len ; int err = 0 ; if ( copy_from_user ( & tlv , _tlv , sizeof ( tlv ) ) ) return - EFAULT ; if ( tlv . length < sizeof ( unsigned int ) * 2 ) return - EINVAL ; down_read ( & card -> controls_rwsem ) ; kctl = snd_ctl_find_numid ( card , tlv . numid ) ; if ( kctl == NULL ) { err = - ENOENT ; goto __kctl_end ; } if ( kctl -> tlv . p == NULL ) { err = - ENXIO ; goto __kctl_end ; } vd = & kctl -> vd [ tlv . numid - kctl -> id . numid ] ; if ( ( op_flag == 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_READ ) == 0 ) || ( op_flag > 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE ) == 0 ) || ( op_flag < 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND ) == 0 ) ) { err = - ENXIO ; goto __kctl_end ; } if ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK ) { if ( vd -> owner != NULL && vd -> owner != file ) { err = - EPERM ; goto __kctl_end ; } err = kctl -> tlv . c ( kctl , op_flag , tlv . length , _tlv -> tlv ) ; if ( err > 0 ) { up_read ( & card -> controls_rwsem ) ; snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_TLV , & kctl -> id ) ; return 0 ; } } else { if ( op_flag ) { err = - ENXIO ; goto __kctl_end ; } len = kctl -> tlv . p [ 1 ] + 2 * sizeof ( unsigned int ) ; if ( tlv . length < len ) { err = - ENOMEM ; goto __kctl_end ; } if ( copy_to_user ( _tlv -> tlv , kctl -> tlv . p , len ) ) err = - EFAULT ; } __kctl_end : up_read ( & card -> controls_rwsem ) ; return err ; }\n", "\n", "1: CWE-000 static int snd_ctl_tlv_ioctl ( struct snd_ctl_file * file , struct snd_ctl_tlv __user * _tlv , int op_flag ) { struct snd_card * card = file -> card ; struct snd_ctl_tlv tlv ; struct snd_kcontrol * kctl ; struct snd_kcontrol_volatile * vd ; unsigned int len ; int err = 0 ; if ( copy_from_user ( & tlv , _tlv , sizeof ( tlv ) ) ) return - EFAULT ; if ( tlv . length < sizeof ( unsigned int ) * 2 ) return - EINVAL ; down_read ( & card -> controls_rwsem ) ; kctl = snd_ctl_find_numid ( card , tlv . numid ) ; if ( kctl == NULL ) { err = - ENOENT ; goto __kctl_end ; } if ( kctl -> tlv . p == NULL ) { err = - ENXIO ; goto __kctl_end ; } vd = & kctl -> vd [ tlv . numid - kctl -> id . numid ] ; if ( ( op_flag == 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_READ ) == 0 ) || ( op_flag > 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE ) == 0 ) || ( op_flag < 0 && ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND ) == 0 ) ) { err = - ENXIO ; goto __kctl_end ; } if ( vd -> access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK ) { if ( vd -> owner != NULL && vd -> owner != file ) { err = - EPERM ; goto __kctl_end ; } err = kctl -> tlv . c ( kctl , op_flag , tlv . length , _tlv -> tlv ) ; if ( err > 0 ) { up_read ( & card -> controls_rwsem ) ; snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_TLV , & kctl -> id ) ; return 0 ; } } else { if ( op_flag ) { err = - ENXIO ; goto __kctl_end ; } len = kctl -> tlv . p [ 1 ] + 2 * sizeof ( unsigned int ) ; if ( tlv . length < len ) { err = - ENOMEM ; goto __kctl_end ; } if ( copy_to_user ( _tlv -> tlv , kctl -> tlv . p , len ) ) err = - EFAULT ; } __kctl_end : up_read ( & card -> controls_rwsem ) ; return err ; }\n", "\n", "\n", "Target: struct fscrypt_info * crypt_info ; struct fscrypt_context ctx ; struct crypto_skcipher * ctfm ; const char * cipher_str ; int keysize ; u8 * raw_key = NULL ; int res ; if ( inode -> i_crypt_info inode -> i_crypt_info ) return 0 ; res = fscrypt_initialize ( inode -> i_sb -> s_cop -> flags ) ; if ( res ) return res if ( ! inode -> i_sb -> s_cop -> get_context ) return - EOPNOTSUPP ; res = inode -> i_sb -> s_cop -> get_context ( inode , & ctx , sizeof ( ctx ) ) ; if ( res < 0 ) { if ( ! fscrypt_dummy_context_enabled ( inode ) || inode -> i_sb -> s_cop -> is_encrypted ( inode ) ) return res ; memset ( & ctx , 0 , sizeof ( ctx ) ) ; ctx . format = FS_ENCRYPTION_CONTEXT_FORMAT_V1 ; ctx . contents_encryption_mode = FS_ENCRYPTION_MODE_AES_256_XTS ; ctx . filenames_encryption_mode = FS_ENCRYPTION_MODE_AES_256_CTS ; memset ( ctx . master_key_descriptor , 0x42 , FS_KEY_DESCRIPTOR_SIZE ) ; } else if ( res != sizeof ( ctx ) ) { return - EINVAL ; } if ( ctx . format != FS_ENCRYPTION_CONTEXT_FORMAT_V1 ) return - EINVAL ; if ( ctx . flags & ~ FS_POLICY_FLAGS_VALID ) return - EINVAL ; crypt_info = kmem_cache_alloc ( fscrypt_info_cachep , GFP_NOFS ) ; if ( ! crypt_info ) return - ENOMEM ; crypt_info -> ci_flags = ctx . flags ; crypt_info -> ci_data_mode = ctx . contents_encryption_mode ; crypt_info -> ci_filename_mode = ctx . filenames_encryption_mode ; crypt_info -> ci_ctfm = NULL ; memcpy ( crypt_info -> ci_master_key , ctx . master_key_descriptor , sizeof ( crypt_info -> ci_master_key ) ) ; res = determine_cipher_type ( crypt_info , inode , & cipher_str , & keysize ) ; if ( res ) goto out ; res = - ENOMEM ; raw_key = kmalloc ( FS_MAX_KEY_SIZE , GFP_NOFS ) ; if ( ! raw_key ) goto out ; res = validate_user_key ( crypt_info , & ctx , raw_key , FS_KEY_DESC_PREFIX ) ; if ( res && inode -> i_sb -> s_cop -> key_prefix ) { int res2 = validate_user_key ( crypt_info , & ctx , raw_key , inode -> i_sb -> s_cop -> key_prefix ) ; if ( res2 ) { if ( res2 == - ENOKEY ) res = - ENOKEY ; goto out ; } } else if ( res ) { goto out ; } ctfm = crypto_alloc_skcipher ( cipher_str , 0 , 0 ) ; if ( ! ctfm || IS_ERR ( ctfm ) ) { res = ctfm ? PTR_ERR ( ctfm ) : - ENOMEM ; printk ( KERN_DEBUG \"%s:error%d(inode%u)allocatingcryptotfm\\\\n\" , __func__ , res , ( unsigned ) inode -> i_ino ) ; goto out ; } crypt_info -> ci_ctfm = ctfm ; crypto_skcipher_clear_flags ( ctfm , ~ 0 ) ; crypto_skcipher_set_flags ( ctfm , CRYPTO_TFM_REQ_WEAK_KEY ) ; res = crypto_skcipher_setkey ( ctfm , raw_key , keysize ) ; if ( res ) goto out ; if ( cmpxchg ( & inode -> i_crypt_info , NULL , crypt_info ) == NULL ) crypt_info = NULL ; out : if ( res == - ENOKEY ) res = 0 ; put_crypt_info ( crypt_info ) ; kzfree ( raw_key ) ; return res ; } \n", "\n", "Sources:\n", "0: CWE-416 int fscrypt_get_encryption_info ( struct inode * inode ) { struct fscrypt_info * ci = inode -> i_crypt_info ; if ( ! ci || ( ci -> ci_keyring_key && ( ci -> ci_keyring_key -> flags & ( ( 1 << KEY_FLAG_INVALIDATED ) | ( 1 << KEY_FLAG_REVOKED ) | ( 1 << KEY_FLAG_DEAD ) ) ) ) ) return fscrypt_get_crypt_info ( inode ) ; return 0 ; }\n", "\n", "1: CWE-476 int fscrypt_get_encryption_info ( struct inode * inode ) { struct fscrypt_info * ci = inode -> i_crypt_info ; if ( ! ci || ( ci -> ci_keyring_key && ( ci -> ci_keyring_key -> flags & ( ( 1 << KEY_FLAG_INVALIDATED ) | ( 1 << KEY_FLAG_REVOKED ) | ( 1 << KEY_FLAG_DEAD ) ) ) ) ) return fscrypt_get_crypt_info ( inode ) ; return 0 ; }\n", "\n", "\n", "Target: , 1 , regs , addr\n", "\n", "Sources:\n", "0: CWE-400 asmlinkage void kernel_unaligned_trap ( struct pt_regs * regs , unsigned int insn ) { enum direction dir = decode_direction ( insn ) ; int size = decode_access_size ( regs , insn ) ; int orig_asi , asi ; current_thread_info ( ) -> kern_una_regs = regs ; current_thread_info ( ) -> kern_una_insn = insn ; orig_asi = asi = decode_asi ( insn , regs ) ; if ( asi == ASI_AIUS ) { kernel_mna_trap_fault ( 0 ) ; return ; } log_unaligned ( regs ) ; if ( ! ok_for_kernel ( insn ) || dir == both ) { printk ( \"Unsupportedunalignedload/storetrapforkernel\" \"at<%016lx>.\\\\n\" , regs -> tpc ) ; unaligned_panic ( \"Kerneldoesfpu/atomic\" \"unalignedload/store.\" , regs ) ; kernel_mna_trap_fault ( 0 ) ; } else { unsigned long addr , * reg_addr ; int err ; addr = compute_effective_address ( regs , insn , ( ( insn >> 25 ) & 0x1f ) ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , addr ) ; switch ( asi ) { case ASI_NL : case ASI_AIUPL : case ASI_AIUSL : case ASI_PL : case ASI_SL : case ASI_PNFL : case ASI_SNFL : asi &= ~ 0x08 ; break ; } switch ( dir ) { case load : reg_addr = fetch_reg_addr ( ( ( insn >> 25 ) & 0x1f ) , regs ) ; err = do_int_load ( reg_addr , size , ( unsigned long * ) addr , decode_signedness ( insn ) , asi ) ; if ( likely ( ! err ) && unlikely ( asi != orig_asi ) ) { unsigned long val_in = * reg_addr ; switch ( size ) { case 2 : val_in = swab16 ( val_in ) ; break ; case 4 : val_in = swab32 ( val_in ) ; break ; case 8 : val_in = swab64 ( val_in ) ; break ; case 16 : default : BUG ( ) ; break ; } * reg_addr = val_in ; } break ; case store : err = do_int_store ( ( ( insn >> 25 ) & 0x1f ) , size , ( unsigned long * ) addr , regs , asi , orig_asi ) ; break ; default : panic ( \"Impossiblekernelunalignedtrap.\" ) ; } if ( unlikely ( err ) ) kernel_mna_trap_fault ( 1 ) ; else advance ( regs ) ; } }\n", "\n", "1: CWE-400 asmlinkage void user_unaligned_trap ( struct pt_regs * regs , unsigned int insn ) { enum direction dir ; if ( ! ( current -> thread . flags & SPARC_FLAG_UNALIGNED ) || ( ( ( insn >> 30 ) & 3 ) != 3 ) ) goto kill_user ; dir = decode_direction ( insn ) ; if ( ! ok_for_user ( regs , insn , dir ) ) { goto kill_user ; } else { int err , size = decode_access_size ( insn ) ; unsigned long addr ; if ( floating_point_load_or_store_p ( insn ) ) { printk ( \"UserFPUload/storeunalignedunsupported.\\\\n\" ) ; goto kill_user ; } addr = compute_effective_address ( regs , insn ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , addr ) ; switch ( dir ) { case load : err = do_int_load ( fetch_reg_addr ( ( ( insn >> 25 ) & 0x1f ) , regs ) , size , ( unsigned long * ) addr , decode_signedness ( insn ) ) ; break ; case store : err = do_int_store ( ( ( insn >> 25 ) & 0x1f ) , size , ( unsigned long * ) addr , regs ) ; break ; case both : printk ( \"UnalignedSWAPunsupported.\\\\n\" ) ; err = - EFAULT ; break ; default : unaligned_panic ( \"Impossibleuserunalignedtrap.\" ) ; goto out ; } if ( err ) goto kill_user ; else advance ( regs ) ; goto out ; } kill_user : user_mna_trap_fault ( regs , insn ) ; out : ; }\n", "\n", "2: CWE-400 asmlinkage void kernel_unaligned_trap ( struct pt_regs * regs , unsigned int insn ) { enum direction dir = decode_direction ( insn ) ; int size = decode_access_size ( insn ) ; if ( ! ok_for_kernel ( insn ) || dir == both ) { printk ( \"Unsupportedunalignedload/storetrapforkernelat<%08lx>.\\\\n\" , regs -> pc ) ; unaligned_panic ( \"Wheee.Kerneldoesfpu/atomicunalignedload/store.\" ) ; } else { unsigned long addr = compute_effective_address ( regs , insn ) ; int err ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , addr ) ; switch ( dir ) { case load : err = do_int_load ( fetch_reg_addr ( ( ( insn >> 25 ) & 0x1f ) , regs ) , size , ( unsigned long * ) addr , decode_signedness ( insn ) ) ; break ; case store : err = do_int_store ( ( ( insn >> 25 ) & 0x1f ) , size , ( unsigned long * ) addr , regs ) ; break ; default : panic ( \"Impossiblekernelunalignedtrap.\" ) ; } if ( err ) kernel_mna_trap_fault ( regs , insn ) ; else advance ( regs ) ; } }\n", "\n", "\n", "Target: ] & 0x40 && i > 0\n", "\n", "Sources:\n", "0: CWE-125 void bit_write_MC ( Bit_Chain * dat , BITCODE_MC val ) { int i , j ; int negative = 0 ; unsigned char byte [ 5 ] ; BITCODE_UMC mask = 0x0000007f ; BITCODE_UMC value = ( BITCODE_UMC ) val ; if ( val < 0 ) { negative = 1 ; value = ( BITCODE_UMC ) - val ; } for ( i = 4 , j = 0 ; i >= 0 ; i -- , j += 7 ) { byte [ i ] = ( unsigned char ) ( ( value & mask ) >> j ) ; byte [ i ] |= 0x80 ; mask = mask << 7 ; } for ( i = 0 ; i < 4 ; i ++ ) if ( byte [ i ] & 0x7f ) break ; if ( byte [ i ] & 0x40 ) i -- ; byte [ i ] &= 0x7f ; if ( negative ) byte [ i ] |= 0x40 ; for ( j = 4 ; j >= i ; j -- ) bit_write_RC ( dat , byte [ j ] ) ; }\n", "\n", "1: CWE-125 void bit_write_UMC ( Bit_Chain * dat , BITCODE_UMC val ) { int i , j ; int negative ; unsigned char byte [ 5 ] ; BITCODE_UMC mask ; BITCODE_UMC value ; value = val ; mask = 0x0000007f ; for ( i = 4 , j = 0 ; i >= 0 ; i -- , j += 7 ) { byte [ i ] = ( unsigned char ) ( ( value & mask ) >> j ) ; byte [ i ] |= 0x80 ; mask = mask << 7 ; } for ( i = 0 ; i < 4 ; i ++ ) if ( byte [ i ] & 0x7f ) break ; if ( byte [ i ] & 0x40 ) i -- ; byte [ i ] &= 0x7f ; for ( j = 4 ; j >= i ; j -- ) bit_write_RC ( dat , byte [ j ] ) ; }\n", "\n", "\n", "Target: static inline int jmp_rel ( struct rel ) { return\n", "\n", "Sources:\n", "0: CWE-000 static inline void jmp_rel ( struct x86_emulate_ctxt * ctxt , int rel ) { assign_eip_near ( ctxt , ctxt -> _eip + rel ) ; }\n", "\n", "1: CWE-264 static inline void jmp_rel ( struct x86_emulate_ctxt * ctxt , int rel ) { assign_eip_near ( ctxt , ctxt -> _eip + rel ) ; }\n", "\n", "\n", "Target: rate_ie ) { if ( rate_ie -> len > MWIFIEX_SUPPORTED_RATES ) return ; ( rate_ie ) { if ( rate_ie -> len > MWIFIEX_SUPPORTED_RATES - rate_len ) return ; len ) ; }\n", "\n", "Sources:\n", "0: CWE-120 void mwifiex_set_uap_rates ( struct mwifiex_uap_bss_param * bss_cfg , struct cfg80211_ap_settings * params ) { struct ieee_types_header * rate_ie ; int var_offset = offsetof ( struct ieee80211_mgmt , u . beacon . variable ) ; const u8 * var_pos = params -> beacon . head + var_offset ; int len = params -> beacon . head_len - var_offset ; u8 rate_len = 0 ; rate_ie = ( void * ) cfg80211_find_ie ( WLAN_EID_SUPP_RATES , var_pos , len ) ; if ( rate_ie ) { memcpy ( bss_cfg -> rates , rate_ie + 1 , rate_ie -> len ) ; rate_len = rate_ie -> len ; } rate_ie = ( void * ) cfg80211_find_ie ( WLAN_EID_EXT_SUPP_RATES , params -> beacon . tail , params -> beacon . tail_len ) ; if ( rate_ie ) memcpy ( bss_cfg -> rates + rate_len , rate_ie + 1 , rate_ie -> len ) ; return ; }\n", "\n", "1: CWE-787 void mwifiex_set_uap_rates ( struct mwifiex_uap_bss_param * bss_cfg , struct cfg80211_ap_settings * params ) { struct ieee_types_header * rate_ie ; int var_offset = offsetof ( struct ieee80211_mgmt , u . beacon . variable ) ; const u8 * var_pos = params -> beacon . head + var_offset ; int len = params -> beacon . head_len - var_offset ; u8 rate_len = 0 ; rate_ie = ( void * ) cfg80211_find_ie ( WLAN_EID_SUPP_RATES , var_pos , len ) ; if ( rate_ie ) { memcpy ( bss_cfg -> rates , rate_ie + 1 , rate_ie -> len ) ; rate_len = rate_ie -> len ; } rate_ie = ( void * ) cfg80211_find_ie ( WLAN_EID_EXT_SUPP_RATES , params -> beacon . tail , params -> beacon . tail_len ) ; if ( rate_ie ) memcpy ( bss_cfg -> rates + rate_len , rate_ie + 1 , rate_ie -> len ) ; return ; }\n", "\n", "\n", "Target: ) ) ; hdr -> sadb_msg_reserved = 0 ;\n", "\n", "Sources:\n", "0: CWE-119 static int key_notify_sa_flush ( const struct km_event * c ) { struct sk_buff * skb ; struct sadb_msg * hdr ; skb = alloc_skb ( sizeof ( struct sadb_msg ) + 16 , GFP_ATOMIC ) ; if ( ! skb ) return - ENOBUFS ; hdr = ( struct sadb_msg * ) skb_put ( skb , sizeof ( struct sadb_msg ) ) ; hdr -> sadb_msg_satype = pfkey_proto2satype ( c -> data . proto ) ; hdr -> sadb_msg_type = SADB_FLUSH ; hdr -> sadb_msg_seq = c -> seq ; hdr -> sadb_msg_pid = c -> portid ; hdr -> sadb_msg_version = PF_KEY_V2 ; hdr -> sadb_msg_errno = ( uint8_t ) 0 ; hdr -> sadb_msg_len = ( sizeof ( struct sadb_msg ) / sizeof ( uint64_t ) ) ; pfkey_broadcast ( skb , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; return 0 ; }\n", "\n", "1: CWE-119 static int key_notify_policy_flush ( const struct km_event * c ) { struct sk_buff * skb_out ; struct sadb_msg * hdr ; skb_out = alloc_skb ( sizeof ( struct sadb_msg ) + 16 , GFP_ATOMIC ) ; if ( ! skb_out ) return - ENOBUFS ; hdr = ( struct sadb_msg * ) skb_put ( skb_out , sizeof ( struct sadb_msg ) ) ; hdr -> sadb_msg_type = SADB_X_SPDFLUSH ; hdr -> sadb_msg_seq = c -> seq ; hdr -> sadb_msg_pid = c -> portid ; hdr -> sadb_msg_version = PF_KEY_V2 ; hdr -> sadb_msg_errno = ( uint8_t ) 0 ; hdr -> sadb_msg_satype = SADB_SATYPE_UNSPEC ; hdr -> sadb_msg_len = ( sizeof ( struct sadb_msg ) / sizeof ( uint64_t ) ) ; pfkey_broadcast ( skb_out , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; return 0 ; }\n", "\n", "\n", "Target: skb ) { struct in6_addr buf return 0 ; id = __ipv6_select_ident ( net , & addrs [\n", "\n", "Sources:\n", "0: CWE-200 __be32 ipv6_proxy_select_ident ( struct net * net , struct sk_buff * skb ) { static u32 ip6_proxy_idents_hashrnd __read_mostly ; struct in6_addr buf [ 2 ] ; struct in6_addr * addrs ; u32 id ; addrs = skb_header_pointer ( skb , skb_network_offset ( skb ) + offsetof ( struct ipv6hdr , saddr ) , sizeof ( buf ) , buf ) ; if ( ! addrs ) return 0 ; net_get_random_once ( & ip6_proxy_idents_hashrnd , sizeof ( ip6_proxy_idents_hashrnd ) ) ; id = __ipv6_select_ident ( net , ip6_proxy_idents_hashrnd , & addrs [ 1 ] , & addrs [ 0 ] ) ; return htonl ( id ) ; }\n", "\n", "1: CWE-326 __be32 ipv6_proxy_select_ident ( struct net * net , struct sk_buff * skb ) { static u32 ip6_proxy_idents_hashrnd __read_mostly ; struct in6_addr buf [ 2 ] ; struct in6_addr * addrs ; u32 id ; addrs = skb_header_pointer ( skb , skb_network_offset ( skb ) + offsetof ( struct ipv6hdr , saddr ) , sizeof ( buf ) , buf ) ; if ( ! addrs ) return 0 ; net_get_random_once ( & ip6_proxy_idents_hashrnd , sizeof ( ip6_proxy_idents_hashrnd ) ) ; id = __ipv6_select_ident ( net , ip6_proxy_idents_hashrnd , & addrs [ 1 ] , & addrs [ 0 ] ) ; return htonl ( id ) ; }\n", "\n", "\n", "Target: ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; }\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadAAIImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; register ssize_t x ; register PixelPacket * q ; register unsigned char * p ; size_t height , length , width ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } width = ReadBlobLSBLong ( image ) ; height = ReadBlobLSBLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( width == 0UL ) || ( height == 0UL ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { image -> columns = width ; image -> rows = height ; image -> depth = 8 ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 4 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; length = ( size_t ) 4 * image -> columns ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( ( size_t ) count != length ) ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; p = pixels ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( * p == 254 ) * p = 255 ; SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( q -> opacity != OpaqueOpacity ) image -> matte = MagickTrue ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; width = ReadBlobLSBLong ( image ) ; height = ReadBlobLSBLong ( image ) ; if ( ( width != 0UL ) && ( height != 0UL ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( width != 0UL ) && ( height != 0UL ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-119 static Image * ReadBGRImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * canvas_image , * image ; MagickBooleanType status ; MagickOffsetType scene ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; size_t length ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , \"MustSpecifyImageSize\" ) ; if ( image_info -> interlace != PartitionInterlace ) { status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , ( MagickSizeType ) image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; } canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod ) ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = GetQuantumPixels ( quantum_info ) ; quantum_type = BGRQuantum ; if ( LocaleCompare ( image_info -> magick , \"BGRA\" ) == 0 ) { quantum_type = BGRAQuantum ; image -> matte = MagickTrue ; } if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) break ; } } count = 0 ; length = 0 ; scene = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; switch ( image_info -> interlace ) { case NoInterlace : default : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; SetPixelGreen ( q , GetPixelGreen ( p ) ) ; SetPixelBlue ( q , GetPixelBlue ( p ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } break ; } case LineInterlace : { static QuantumType quantum_types [ 4 ] = { BlueQuantum , GreenQuantum , RedQuantum , AlphaQuantum } ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } for ( i = 0 ; i < ( ssize_t ) ( image -> matte != MagickFalse ? 4 : 3 ) ; i ++ ) { quantum_type = quantum_types [ i ] ; q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( quantum_type ) { case RedQuantum : { SetPixelRed ( q , GetPixelRed ( p ) ) ; break ; } case GreenQuantum : { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; break ; } case BlueQuantum : { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; break ; } case OpacityQuantum : { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; break ; } case AlphaQuantum : { SetPixelAlpha ( q , GetPixelAlpha ( p ) ) ; break ; } default : break ; } p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case PlaneInterlace : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , RedQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , GreenQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 6 ) ; if ( status == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 6 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , AlphaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 6 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 6 , 6 ) ; if ( status == MagickFalse ) break ; } break ; } case PartitionInterlace : { AppendImageFormat ( \"B\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , ( MagickSizeType ) image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; length = GetQuantumExtent ( canvas_image , quantum_info , BlueQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"G\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , GreenQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , GreenQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"R\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , RedQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"A\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , AlphaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 5 ) ; if ( status == MagickFalse ) break ; } } ( void ) CloseBlob ( image ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 5 ) ; if ( status == MagickFalse ) break ; } break ; } } SetQuantumImageType ( image , quantum_type ) ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( count == ( ssize_t ) length ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } scene ++ ; } while ( count == ( ssize_t ) length ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; InheritException ( & image -> exception , & canvas_image -> exception ) ; canvas_image = DestroyImage ( canvas_image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "2: CWE-119 static Image * ReadGRAYImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * canvas_image , * image ; MagickBooleanType status ; MagickOffsetType scene ; QuantumInfo * quantum_info ; QuantumType quantum_type ; size_t length ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , \"MustSpecifyImageSize\" ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , ( size_t ) image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; SetImageColorspace ( image , GRAYColorspace ) ; canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod ) ; quantum_type = GrayQuantum ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = GetQuantumPixels ( quantum_info ) ; if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) break ; } } scene = 0 ; count = 0 ; length = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; SetImageColorspace ( image , GRAYColorspace ) ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register ssize_t x ; register PixelPacket * restrict q ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; SetPixelGreen ( q , GetPixelGreen ( p ) ) ; SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } SetQuantumImageType ( image , quantum_type ) ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( count == ( ssize_t ) length ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } scene ++ ; } while ( count == ( ssize_t ) length ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; InheritException ( & image -> exception , & canvas_image -> exception ) ; canvas_image = DestroyImage ( canvas_image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "3: CWE-119 static Image * ReadGIFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define BitSet ( byte , bit ) ( ( ( byte ) & ( bit ) ) == ( bit ) ) # define LSBFirstOrder ( x , y ) ( ( ( y ) << 8 ) | ( x ) ) Image * image , * meta_image ; int number_extensionss = 0 ; MagickBooleanType status ; RectangleInfo page ; register ssize_t i ; register unsigned char * p ; size_t delay , dispose , duration , global_colors , image_count , iterations , one ; ssize_t count , opacity ; unsigned char background , c , flag , * global_colormap , header [ MaxTextExtent ] , magick [ 12 ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 6 , magick ) ; if ( ( count != 6 ) || ( ( LocaleNCompare ( ( char * ) magick , \"GIF87\" , 5 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , \"GIF89\" , 5 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; page . width = ReadBlobLSBShort ( image ) ; page . height = ReadBlobLSBShort ( image ) ; flag = ( unsigned char ) ReadBlobByte ( image ) ; background = ( unsigned char ) ReadBlobByte ( image ) ; c = ( unsigned char ) ReadBlobByte ( image ) ; one = 1 ; global_colors = one << ( ( ( size_t ) flag & 0x07 ) + 1 ) ; global_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( global_colors , 256 ) , 3UL * sizeof ( * global_colormap ) ) ; if ( global_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( BitSet ( ( int ) flag , 0x80 ) != 0 ) count = ReadBlob ( image , ( size_t ) ( 3 * global_colors ) , global_colormap ) ; delay = 0 ; dispose = 0 ; duration = 0 ; iterations = 1 ; opacity = ( - 1 ) ; image_count = 0 ; meta_image = AcquireImage ( image_info ) ; for ( ; ; ) { count = ReadBlob ( image , 1 , & c ) ; if ( count != 1 ) break ; if ( c == ( unsigned char ) ';' ) break ; if ( c == ( unsigned char ) '!' ) { count = ReadBlob ( image , 1 , & c ) ; if ( count != 1 ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadExtensionBlock\" ) ; } switch ( c ) { case 0xf9 : { while ( ReadBlobBlock ( image , header ) != 0 ) ; dispose = ( size_t ) ( header [ 0 ] >> 2 ) ; delay = ( size_t ) ( ( header [ 2 ] << 8 ) | header [ 1 ] ) ; if ( ( ssize_t ) ( header [ 0 ] & 0x01 ) == 0x01 ) opacity = ( ssize_t ) header [ 3 ] ; break ; } case 0xfe : { char * comments ; size_t length ; comments = AcquireString ( ( char * ) NULL ) ; for ( length = 0 ; ; length += count ) { count = ( ssize_t ) ReadBlobBlock ( image , header ) ; if ( count == 0 ) break ; header [ count ] = '\\\\0' ; ( void ) ConcatenateString ( & comments , ( const char * ) header ) ; } ( void ) SetImageProperty ( meta_image , \"comment\" , comments ) ; comments = DestroyString ( comments ) ; break ; } case 0xff : { MagickBooleanType loop ; loop = MagickFalse ; if ( ReadBlobBlock ( image , header ) != 0 ) loop = LocaleNCompare ( ( char * ) header , \"NETSCAPE2.0\" , 11 ) == 0 ? MagickTrue : MagickFalse ; if ( loop != MagickFalse ) { while ( ReadBlobBlock ( image , header ) != 0 ) iterations = ( size_t ) ( ( header [ 2 ] << 8 ) | header [ 1 ] ) ; break ; } else { char name [ MaxTextExtent ] ; int block_length , info_length , reserved_length ; MagickBooleanType i8bim , icc , iptc , magick ; StringInfo * profile ; unsigned char * info ; icc = LocaleNCompare ( ( char * ) header , \"ICCRGBG1012\" , 11 ) == 0 ? MagickTrue : MagickFalse ; magick = LocaleNCompare ( ( char * ) header , \"ImageMagick\" , 11 ) == 0 ? MagickTrue : MagickFalse ; i8bim = LocaleNCompare ( ( char * ) header , \"MGK8BIM0000\" , 11 ) == 0 ? MagickTrue : MagickFalse ; iptc = LocaleNCompare ( ( char * ) header , \"MGKIPTC0000\" , 11 ) == 0 ? MagickTrue : MagickFalse ; number_extensionss ++ ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"ReadingGIFapplicationextension\" ) ; info = ( unsigned char * ) AcquireQuantumMemory ( 255UL , sizeof ( * info ) ) ; reserved_length = 255 ; for ( info_length = 0 ; ; ) { block_length = ( int ) ReadBlobBlock ( image , & info [ info_length ] ) ; if ( block_length == 0 ) break ; info_length += block_length ; if ( info_length > ( reserved_length - 255 ) ) { reserved_length += 4096 ; info = ( unsigned char * ) ResizeQuantumMemory ( info , ( size_t ) reserved_length , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } } profile = BlobToStringInfo ( info , ( size_t ) info_length ) ; if ( profile == ( StringInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( i8bim != MagickFalse ) ( void ) CopyMagickString ( name , \"8bim\" , sizeof ( name ) ) ; else if ( icc != MagickFalse ) ( void ) CopyMagickString ( name , \"icc\" , sizeof ( name ) ) ; else if ( iptc != MagickFalse ) ( void ) CopyMagickString ( name , \"iptc\" , sizeof ( name ) ) ; else if ( magick != MagickFalse ) { ( void ) CopyMagickString ( name , \"magick\" , sizeof ( name ) ) ; image -> gamma = StringToDouble ( ( char * ) info + 6 , ( char * * ) NULL ) ; } else ( void ) FormatLocaleString ( name , sizeof ( name ) , \"gif:%.11s\" , header ) ; info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; if ( magick == MagickFalse ) ( void ) SetImageProfile ( meta_image , name , profile ) ; profile = DestroyStringInfo ( profile ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"profilename=%s\" , name ) ; } break ; } default : { while ( ReadBlobBlock ( image , header ) != 0 ) ; break ; } } } if ( c != ( unsigned char ) ',' ) continue ; if ( image_count != 0 ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; } image_count ++ ; meta_image -> scene = image -> scene ; CloneImageProperties ( image , meta_image ) ; DestroyImageProperties ( meta_image ) ; CloneImageProfiles ( image , meta_image ) ; DestroyImageProfiles ( meta_image ) ; image -> storage_class = PseudoClass ; image -> compression = LZWCompression ; page . x = ( ssize_t ) ReadBlobLSBShort ( image ) ; page . y = ( ssize_t ) ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; image -> depth = 8 ; flag = ( unsigned char ) ReadBlobByte ( image ) ; image -> interlace = BitSet ( ( int ) flag , 0x40 ) != 0 ? GIFInterlace : NoInterlace ; image -> colors = BitSet ( ( int ) flag , 0x80 ) == 0 ? global_colors : one << ( ( size_t ) ( flag & 0x07 ) + 1 ) ; if ( opacity >= ( ssize_t ) image -> colors ) opacity = ( - 1 ) ; image -> page . width = page . width ; image -> page . height = page . height ; image -> page . y = page . y ; image -> page . x = page . x ; image -> delay = delay ; image -> iterations = iterations ; image -> ticks_per_second = 100 ; image -> dispose = ( DisposeType ) dispose ; image -> matte = opacity >= 0 ? MagickTrue : MagickFalse ; delay = 0 ; dispose = 0 ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; } if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } if ( BitSet ( ( int ) flag , 0x80 ) == 0 ) { p = global_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( * p ++ ) ; if ( i == opacity ) { image -> colormap [ i ] . opacity = ( Quantum ) TransparentOpacity ; image -> transparent_color = image -> colormap [ opacity ] ; } } image -> background_color = image -> colormap [ MagickMin ( background , image -> colors - 1 ) ] ; } else { unsigned char * colormap ; colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , 3 * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } count = ReadBlob ( image , ( 3 * image -> colors ) * sizeof ( * colormap ) , colormap ) ; if ( count != ( ssize_t ) ( 3 * image -> colors ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } p = colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( * p ++ ) ; if ( i == opacity ) image -> colormap [ i ] . opacity = ( Quantum ) TransparentOpacity ; } colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; } if ( image -> gamma == 1.0 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) if ( IsGrayPixel ( image -> colormap + i ) == MagickFalse ) break ; ( void ) SetImageColorspace ( image , i == ( ssize_t ) image -> colors ? GRAYColorspace : RGBColorspace ) ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( image_info -> ping != MagickFalse ) status = PingGIFImage ( image ) ; else status = DecodeImage ( image , opacity ) ; if ( ( image_info -> ping == MagickFalse ) && ( status == MagickFalse ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } duration += image -> delay * image -> iterations ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; opacity = ( - 1 ) ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) image -> scene - 1 , image -> scene ) ; if ( status == MagickFalse ) break ; } image -> duration = duration ; meta_image = DestroyImage ( meta_image ) ; global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "4: CWE-119 static Image * ReadFITSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct _FITSInfo { MagickBooleanType extend , simple ; int bits_per_pixel , columns , rows , number_axes , number_planes ; double min_data , max_data , zero , scale ; EndianType endian ; } FITSInfo ; char * comment , keyword [ 9 ] , property [ MaxTextExtent ] , value [ 73 ] ; double pixel , scale ; FITSInfo fits_info ; Image * image ; int c ; MagickBooleanType status ; MagickSizeType number_pixels ; register ssize_t i , x ; register PixelPacket * q ; ssize_t count , scene , y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & fits_info , 0 , sizeof ( fits_info ) ) ; fits_info . extend = MagickFalse ; fits_info . simple = MagickFalse ; fits_info . bits_per_pixel = 8 ; fits_info . columns = 1 ; fits_info . rows = 1 ; fits_info . rows = 1 ; fits_info . number_planes = 1 ; fits_info . min_data = 0.0 ; fits_info . max_data = 0.0 ; fits_info . zero = 0.0 ; fits_info . scale = 1.0 ; fits_info . endian = MSBEndian ; for ( comment = ( char * ) NULL ; EOFBlob ( image ) == MagickFalse ; ) { for ( ; EOFBlob ( image ) == MagickFalse ; ) { register char * p ; count = ReadBlob ( image , 8 , ( unsigned char * ) keyword ) ; if ( count != 8 ) break ; for ( i = 0 ; i < 8 ; i ++ ) { if ( isspace ( ( int ) ( ( unsigned char ) keyword [ i ] ) ) != 0 ) break ; keyword [ i ] = tolower ( ( int ) ( ( unsigned char ) keyword [ i ] ) ) ; } keyword [ i ] = '\\\\0' ; count = ReadBlob ( image , 72 , ( unsigned char * ) value ) ; value [ 72 ] = '\\\\0' ; if ( count != 72 ) break ; p = value ; if ( * p == '=' ) { p += 2 ; while ( isspace ( ( int ) ( ( unsigned char ) * p ) ) != 0 ) p ++ ; } if ( LocaleCompare ( keyword , \"end\" ) == 0 ) break ; if ( LocaleCompare ( keyword , \"extend\" ) == 0 ) fits_info . extend = ( * p == 'T' ) || ( * p == 't' ) ? MagickTrue : MagickFalse ; if ( LocaleCompare ( keyword , \"simple\" ) == 0 ) fits_info . simple = ( * p == 'T' ) || ( * p == 't' ) ? MagickTrue : MagickFalse ; if ( LocaleCompare ( keyword , \"bitpix\" ) == 0 ) fits_info . bits_per_pixel = StringToLong ( p ) ; if ( LocaleCompare ( keyword , \"naxis\" ) == 0 ) fits_info . number_axes = StringToLong ( p ) ; if ( LocaleCompare ( keyword , \"naxis1\" ) == 0 ) fits_info . columns = StringToLong ( p ) ; if ( LocaleCompare ( keyword , \"naxis2\" ) == 0 ) fits_info . rows = StringToLong ( p ) ; if ( LocaleCompare ( keyword , \"naxis3\" ) == 0 ) fits_info . number_planes = StringToLong ( p ) ; if ( LocaleCompare ( keyword , \"datamax\" ) == 0 ) fits_info . max_data = StringToDouble ( p , ( char * * ) NULL ) ; if ( LocaleCompare ( keyword , \"datamin\" ) == 0 ) fits_info . min_data = StringToDouble ( p , ( char * * ) NULL ) ; if ( LocaleCompare ( keyword , \"bzero\" ) == 0 ) fits_info . zero = StringToDouble ( p , ( char * * ) NULL ) ; if ( LocaleCompare ( keyword , \"bscale\" ) == 0 ) fits_info . scale = StringToDouble ( p , ( char * * ) NULL ) ; if ( LocaleCompare ( keyword , \"comment\" ) == 0 ) { if ( comment == ( char * ) NULL ) comment = ConstantString ( p ) ; else ( void ) ConcatenateString ( & comment , p ) ; } if ( LocaleCompare ( keyword , \"xendian\" ) == 0 ) { if ( LocaleNCompare ( p , \"big\" , 3 ) == 0 ) fits_info . endian = MSBEndian ; else fits_info . endian = LSBEndian ; } ( void ) FormatLocaleString ( property , MaxTextExtent , \"fits:%s\" , keyword ) ; ( void ) SetImageProperty ( image , property , p ) ; } c = 0 ; while ( ( ( TellBlob ( image ) % FITSBlocksize ) != 0 ) && ( c != EOF ) ) c = ReadBlobByte ( image ) ; if ( fits_info . extend == MagickFalse ) break ; number_pixels = ( MagickSizeType ) fits_info . columns * fits_info . rows ; if ( ( fits_info . simple != MagickFalse ) && ( fits_info . number_axes >= 1 ) && ( fits_info . number_axes <= 4 ) && ( number_pixels != 0 ) ) break ; } if ( comment != ( char * ) NULL ) { ( void ) SetImageProperty ( image , \"comment\" , comment ) ; comment = DestroyString ( comment ) ; } if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; number_pixels = ( MagickSizeType ) fits_info . columns * fits_info . rows ; if ( ( fits_info . simple == MagickFalse ) || ( fits_info . number_axes < 1 ) || ( fits_info . number_axes > 4 ) || ( number_pixels == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; for ( scene = 0 ; scene < ( ssize_t ) fits_info . number_planes ; scene ++ ) { image -> columns = ( size_t ) fits_info . columns ; image -> rows = ( size_t ) fits_info . rows ; image -> depth = ( size_t ) ( fits_info . bits_per_pixel < 0 ? - 1 : 1 ) * fits_info . bits_per_pixel ; image -> endian = fits_info . endian ; image -> scene = ( size_t ) scene ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) SetImageColorspace ( image , GRAYColorspace ) ; if ( ( fits_info . min_data == 0.0 ) && ( fits_info . max_data == 0.0 ) ) { if ( fits_info . zero == 0.0 ) ( void ) GetFITSPixelExtrema ( image , fits_info . bits_per_pixel , & fits_info . min_data , & fits_info . max_data ) ; else fits_info . max_data = GetFITSPixelRange ( ( size_t ) fits_info . bits_per_pixel ) ; } else fits_info . max_data = GetFITSPixelRange ( ( size_t ) fits_info . bits_per_pixel ) ; scale = QuantumRange / ( fits_info . max_data - fits_info . min_data ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = GetFITSPixel ( image , fits_info . bits_per_pixel ) ; if ( ( image -> depth == 16 ) || ( image -> depth == 32 ) || ( image -> depth == 64 ) ) SetFITSUnsignedPixels ( 1 , image -> depth , image -> endian , ( unsigned char * ) & pixel ) ; SetPixelRed ( q , ClampToQuantum ( scale * ( fits_info . scale * ( pixel - fits_info . min_data ) + fits_info . zero ) ) ) ; SetPixelGreen ( q , GetPixelRed ( q ) ) ; SetPixelBlue ( q , GetPixelRed ( q ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( fits_info . number_planes - 1 ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "5: CWE-119 static Image * ReadBMPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { BMPInfo bmp_info ; Image * image ; IndexPacket index ; MagickBooleanType status ; MagickOffsetType offset , start_position ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register PixelPacket * q ; register ssize_t i , x ; register unsigned char * p ; size_t bit , blue , bytes_per_line , green , length , red ; ssize_t count , y ; unsigned char magick [ 12 ] , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & bmp_info , 0 , sizeof ( bmp_info ) ) ; bmp_info . ba_offset = 0 ; start_position = 0 ; count = ReadBlob ( image , 2 , magick ) ; do { LongPixelPacket shift ; PixelPacket quantum_bits ; size_t profile_data , profile_size ; if ( bmp_info . ba_offset == 0 ) start_position = TellBlob ( image ) - 2 ; bmp_info . ba_offset = 0 ; while ( LocaleNCompare ( ( char * ) magick , \"BA\" , 2 ) == 0 ) { bmp_info . file_size = ReadBlobLSBLong ( image ) ; bmp_info . ba_offset = ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) break ; } if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Magick:%c%c\" , magick [ 0 ] , magick [ 1 ] ) ; if ( ( count == 0 ) || ( ( LocaleNCompare ( ( char * ) magick , \"BM\" , 2 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , \"CI\" , 2 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; bmp_info . file_size = ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"File_sizeinheader:%ubytes\" , bmp_info . file_size ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; bmp_info . size = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"BMPsize:%u\" , bmp_info . size ) ; if ( bmp_info . size == 12 ) { ( void ) CopyMagickString ( image -> magick , \"BMP2\" , MaxTextExtent ) ; bmp_info . width = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . x_pixels = 0 ; bmp_info . y_pixels = 0 ; bmp_info . number_colors = 0 ; bmp_info . compression = BI_RGB ; bmp_info . image_size = 0 ; bmp_info . alpha_mask = 0 ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:OS/2Bitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; } } else { if ( bmp_info . size < 40 ) ThrowReaderException ( CorruptImageError , \"NonOS2HeaderSizeError\" ) ; bmp_info . width = ( ssize_t ) ( ( int ) ReadBlobLSBLong ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( int ) ReadBlobLSBLong ( image ) ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . compression = ReadBlobLSBLong ( image ) ; bmp_info . image_size = ReadBlobLSBLong ( image ) ; bmp_info . x_pixels = ReadBlobLSBLong ( image ) ; bmp_info . y_pixels = ReadBlobLSBLong ( image ) ; bmp_info . number_colors = ReadBlobLSBLong ( image ) ; bmp_info . colors_important = ReadBlobLSBLong ( image ) ; profile_data = 0 ; profile_size = 0 ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:MSWindowsbitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Bitsperpixel:%.20g\" , ( double ) bmp_info . bits_per_pixel ) ; switch ( ( int ) bmp_info . compression ) { case BI_RGB : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RGB\" ) ; break ; } case BI_RLE4 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE4\" ) ; break ; } case BI_RLE8 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE8\" ) ; break ; } case BI_BITFIELDS : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_BITFIELDS\" ) ; break ; } case BI_PNG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_PNG\" ) ; break ; } case BI_JPEG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_JPEG\" ) ; break ; } default : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:UNKNOWN(%u)\" , bmp_info . compression ) ; } } ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Numberofcolors:%u\" , bmp_info . number_colors ) ; } bmp_info . red_mask = ReadBlobLSBLong ( image ) ; bmp_info . green_mask = ReadBlobLSBLong ( image ) ; bmp_info . blue_mask = ReadBlobLSBLong ( image ) ; if ( bmp_info . size > 40 ) { double sum ; bmp_info . alpha_mask = ReadBlobLSBLong ( image ) ; bmp_info . colorspace = ( int ) ReadBlobLSBLong ( image ) ; # define BMP_DENOM ( ( double ) 0x40000000 ) bmp_info . red_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; sum = bmp_info . red_primary . x + bmp_info . red_primary . y + bmp_info . red_primary . z ; bmp_info . red_primary . x /= sum ; bmp_info . red_primary . y /= sum ; image -> chromaticity . red_primary . x = bmp_info . red_primary . x ; image -> chromaticity . red_primary . y = bmp_info . red_primary . y ; sum = bmp_info . green_primary . x + bmp_info . green_primary . y + bmp_info . green_primary . z ; bmp_info . green_primary . x /= sum ; bmp_info . green_primary . y /= sum ; image -> chromaticity . green_primary . x = bmp_info . green_primary . x ; image -> chromaticity . green_primary . y = bmp_info . green_primary . y ; sum = bmp_info . blue_primary . x + bmp_info . blue_primary . y + bmp_info . blue_primary . z ; bmp_info . blue_primary . x /= sum ; bmp_info . blue_primary . y /= sum ; image -> chromaticity . blue_primary . x = bmp_info . blue_primary . x ; image -> chromaticity . blue_primary . y = bmp_info . blue_primary . y ; bmp_info . gamma_scale . x = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . y = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . z = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; image -> gamma = ( bmp_info . gamma_scale . x + bmp_info . gamma_scale . y + bmp_info . gamma_scale . z ) / 3.0 ; } else ( void ) CopyMagickString ( image -> magick , \"BMP3\" , MaxTextExtent ) ; if ( bmp_info . size > 108 ) { size_t intent ; intent = ReadBlobLSBLong ( image ) ; switch ( ( int ) intent ) { case LCS_GM_BUSINESS : { image -> rendering_intent = SaturationIntent ; break ; } case LCS_GM_GRAPHICS : { image -> rendering_intent = RelativeIntent ; break ; } case LCS_GM_IMAGES : { image -> rendering_intent = PerceptualIntent ; break ; } case LCS_GM_ABS_COLORIMETRIC : { image -> rendering_intent = AbsoluteIntent ; break ; } } profile_data = ReadBlobLSBLong ( image ) ; profile_size = ReadBlobLSBLong ( image ) ; ( void ) profile_data ; ( void ) profile_size ; ( void ) ReadBlobLSBLong ( image ) ; } } if ( ( MagickSizeType ) bmp_info . file_size > GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; else if ( ( MagickSizeType ) bmp_info . file_size < GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageWarning , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; if ( bmp_info . width <= 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . height == 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . planes != 1 ) ThrowReaderException ( CorruptImageError , \"StaticPlanesValueNotEqualToOne\" ) ; if ( ( bmp_info . bits_per_pixel != 1 ) && ( bmp_info . bits_per_pixel != 4 ) && ( bmp_info . bits_per_pixel != 8 ) && ( bmp_info . bits_per_pixel != 16 ) && ( bmp_info . bits_per_pixel != 24 ) && ( bmp_info . bits_per_pixel != 32 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; if ( bmp_info . bits_per_pixel < 16 && bmp_info . number_colors > ( 1U << bmp_info . bits_per_pixel ) ) { ThrowReaderException ( CorruptImageError , \"UnrecognizedNumberOfColors\" ) ; } if ( ( bmp_info . compression == 1 ) && ( bmp_info . bits_per_pixel != 8 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 2 ) && ( bmp_info . bits_per_pixel != 4 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 3 ) && ( bmp_info . bits_per_pixel < 16 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; switch ( bmp_info . compression ) { case BI_RGB : case BI_RLE8 : case BI_RLE4 : case BI_BITFIELDS : break ; case BI_JPEG : ThrowReaderException ( CoderError , \"JPEGCompressNotSupported\" ) ; case BI_PNG : ThrowReaderException ( CoderError , \"PNGCompressNotSupported\" ) ; default : ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } image -> columns = ( size_t ) MagickAbsoluteValue ( bmp_info . width ) ; image -> rows = ( size_t ) MagickAbsoluteValue ( bmp_info . height ) ; image -> depth = bmp_info . bits_per_pixel <= 8 ? bmp_info . bits_per_pixel : 8 ; image -> matte = ( ( bmp_info . alpha_mask != 0 ) && ( bmp_info . compression == BI_BITFIELDS ) ) || ( bmp_info . bits_per_pixel == 32 ) ? MagickTrue : MagickFalse ; if ( bmp_info . bits_per_pixel < 16 ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = bmp_info . number_colors ; one = 1 ; if ( image -> colors == 0 ) image -> colors = one << bmp_info . bits_per_pixel ; } if ( image -> storage_class == PseudoClass ) { unsigned char * bmp_colormap ; size_t packet_size ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingcolormapof%.20gcolors\" , ( double ) image -> colors ) ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; bmp_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) image -> colors , 4 * sizeof ( * bmp_colormap ) ) ; if ( bmp_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( bmp_info . size == 12 ) || ( bmp_info . size == 64 ) ) packet_size = 3 ; else packet_size = 4 ; offset = SeekBlob ( image , start_position + 14 + bmp_info . size , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; count = ReadBlob ( image , packet_size * image -> colors , bmp_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; p = bmp_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; } image -> x_resolution = ( double ) bmp_info . x_pixels / 100.0 ; image -> y_resolution = ( double ) bmp_info . y_pixels / 100.0 ; image -> units = PixelsPerCentimeterResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; offset = SeekBlob ( image , start_position + bmp_info . offset_bits , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( bmp_info . compression == BI_RLE4 ) bmp_info . bits_per_pixel <<= 1 ; bytes_per_line = 4 * ( ( image -> columns * bmp_info . bits_per_pixel + 31 ) / 32 ) ; length = ( size_t ) bytes_per_line * image -> rows ; pixel_info = AcquireVirtualMemory ( ( size_t ) image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( bmp_info . compression == BI_RGB ) || ( bmp_info . compression == BI_BITFIELDS ) ) { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingpixels(%.20gbytes)\" , ( double ) length ) ; count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } } else { status = DecodeImage ( image , bmp_info . compression , pixels ) ; if ( status == MagickFalse ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToRunlengthDecodeImage\" ) ; } } if ( bmp_info . compression == BI_RGB ) { bmp_info . alpha_mask = image -> matte != MagickFalse ? 0xff000000U : 0U ; bmp_info . red_mask = 0x00ff0000U ; bmp_info . green_mask = 0x0000ff00U ; bmp_info . blue_mask = 0x000000ffU ; if ( bmp_info . bits_per_pixel == 16 ) { bmp_info . red_mask = 0x00007c00U ; bmp_info . green_mask = 0x000003e0U ; bmp_info . blue_mask = 0x0000001fU ; } } if ( ( bmp_info . bits_per_pixel == 16 ) || ( bmp_info . bits_per_pixel == 32 ) ) { register size_t sample ; ( void ) ResetMagickMemory ( & shift , 0 , sizeof ( shift ) ) ; ( void ) ResetMagickMemory ( & quantum_bits , 0 , sizeof ( quantum_bits ) ) ; if ( bmp_info . red_mask != 0 ) while ( ( ( bmp_info . red_mask << shift . red ) & 0x80000000UL ) == 0 ) shift . red ++ ; if ( bmp_info . green_mask != 0 ) while ( ( ( bmp_info . green_mask << shift . green ) & 0x80000000UL ) == 0 ) shift . green ++ ; if ( bmp_info . blue_mask != 0 ) while ( ( ( bmp_info . blue_mask << shift . blue ) & 0x80000000UL ) == 0 ) shift . blue ++ ; if ( bmp_info . alpha_mask != 0 ) while ( ( ( bmp_info . alpha_mask << shift . opacity ) & 0x80000000UL ) == 0 ) shift . opacity ++ ; sample = shift . red ; while ( ( ( bmp_info . red_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . red = ClampToQuantum ( ( MagickRealType ) sample - shift . red ) ; sample = shift . green ; while ( ( ( bmp_info . green_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . green = ClampToQuantum ( ( MagickRealType ) sample - shift . green ) ; sample = shift . blue ; while ( ( ( bmp_info . blue_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . blue = ClampToQuantum ( ( MagickRealType ) sample - shift . blue ) ; sample = shift . opacity ; while ( ( ( bmp_info . alpha_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . opacity = ClampToQuantum ( ( MagickRealType ) sample - shift . opacity ) ; } switch ( bmp_info . bits_per_pixel ) { case 1 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( IndexPacket ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; q ++ ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( IndexPacket ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; break ; } case 4 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x0f ) ; SetPixelIndex ( indexes + x , index ) ; index = ConstrainColormapIndex ( image , * p & 0x0f ) ; SetPixelIndex ( indexes + x + 1 , index ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf ) ; SetPixelIndex ( indexes + x , index ) ; p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; break ; } case 8 : { if ( ( bmp_info . compression == BI_RLE8 ) || ( bmp_info . compression == BI_RLE4 ) ) bytes_per_line = image -> columns ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = ( ssize_t ) image -> columns ; x != 0 ; -- x ) { index = ConstrainColormapIndex ( image , * p ) ; SetPixelIndex ( indexes , index ) ; indexes ++ ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; break ; } case 16 : { size_t alpha , pixel ; if ( bmp_info . compression != BI_RGB && bmp_info . compression != BI_BITFIELDS ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 2 * ( image -> columns + image -> columns % 2 ) ; image -> storage_class = DirectClass ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( size_t ) ( * p ++ ) ; pixel |= ( * p ++ ) << 8 ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 5 ) red |= ( ( red & 0xe000 ) >> 5 ) ; if ( quantum_bits . red <= 8 ) red |= ( ( red & 0xff00 ) >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 5 ) green |= ( ( green & 0xe000 ) >> 5 ) ; if ( quantum_bits . green == 6 ) green |= ( ( green & 0xc000 ) >> 6 ) ; if ( quantum_bits . green <= 8 ) green |= ( ( green & 0xff00 ) >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 5 ) blue |= ( ( blue & 0xe000 ) >> 5 ) ; if ( quantum_bits . blue <= 8 ) blue |= ( ( blue & 0xff00 ) >> 8 ) ; alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . opacity ) >> 16 ; if ( quantum_bits . opacity <= 8 ) alpha |= ( ( alpha & 0xff00 ) >> 8 ) ; SetPixelRed ( q , ScaleShortToQuantum ( ( unsigned short ) red ) ) ; SetPixelGreen ( q , ScaleShortToQuantum ( ( unsigned short ) green ) ) ; SetPixelBlue ( q , ScaleShortToQuantum ( ( unsigned short ) blue ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleShortToQuantum ( ( unsigned short ) alpha ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 24 : { bytes_per_line = 4 * ( ( image -> columns * 24 + 31 ) / 32 ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 32 : { if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { size_t alpha , pixel ; p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( size_t ) ( * p ++ ) ; pixel |= ( ( size_t ) * p ++ << 8 ) ; pixel |= ( ( size_t ) * p ++ << 16 ) ; pixel |= ( ( size_t ) * p ++ << 24 ) ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 8 ) red |= ( red >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 8 ) green |= ( green >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 8 ) blue |= ( blue >> 8 ) ; alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . opacity ) >> 16 ; if ( quantum_bits . opacity == 8 ) alpha |= ( alpha >> 8 ) ; SetPixelRed ( q , ScaleShortToQuantum ( ( unsigned short ) red ) ) ; SetPixelGreen ( q , ScaleShortToQuantum ( ( unsigned short ) green ) ) ; SetPixelBlue ( q , ScaleShortToQuantum ( ( unsigned short ) blue ) ) ; SetPixelAlpha ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleShortToQuantum ( ( unsigned short ) alpha ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } default : { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( bmp_info . height < 0 ) { Image * flipped_image ; flipped_image = FlipImage ( image , exception ) ; if ( flipped_image != ( Image * ) NULL ) { DuplicateBlob ( flipped_image , image ) ; image = DestroyImage ( image ) ; image = flipped_image ; } } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; * magick = '\\\\0' ; if ( bmp_info . ba_offset != 0 ) { offset = SeekBlob ( image , ( MagickOffsetType ) bmp_info . ba_offset , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } count = ReadBlob ( image , 2 , magick ) ; if ( ( count == 2 ) && ( IsBMP ( magick , 2 ) != MagickFalse ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( IsBMP ( magick , 2 ) != MagickFalse ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ; if ( n2size < 1 ) { applog (\n", "\n", "Sources:\n", "0: CWE-119 bool initiate_stratum ( struct pool * pool ) { char s [ RBUFSIZE ] , * sret = NULL , * nonce1 , * sessionid ; json_t * val = NULL , * res_val , * err_val ; bool ret = false , recvd = false ; json_error_t err ; int n2size ; if ( ! setup_stratum_curl ( pool ) ) goto out ; resend : if ( pool -> sessionid ) sprintf ( s , \"{\\\\\"id\\\\\":%d,\\\\\"method\\\\\":\\\\\"mining.subscribe\\\\\",\\\\\"params\\\\\":[\\\\\"%s\\\\\"]}\" , swork_id ++ , pool -> sessionid ) ; else sprintf ( s , \"{\\\\\"id\\\\\":%d,\\\\\"method\\\\\":\\\\\"mining.subscribe\\\\\",\\\\\"params\\\\\":[]}\" , swork_id ++ ) ; if ( ! __stratum_send ( pool , s , strlen ( s ) ) ) { applog ( LOG_DEBUG , \"Failedtosendsininitiate_stratum\" ) ; goto out ; } if ( ! socket_full ( pool , true ) ) { applog ( LOG_DEBUG , \"Timedoutwaitingforresponseininitiate_stratum\" ) ; goto out ; } sret = recv_line ( pool ) ; if ( ! sret ) goto out ; recvd = true ; val = JSON_LOADS ( sret , & err ) ; free ( sret ) ; if ( ! val ) { applog ( LOG_INFO , \"JSONdecodefailed(%d):%s\" , err . line , err . text ) ; goto out ; } res_val = json_object_get ( val , \"result\" ) ; err_val = json_object_get ( val , \"error\" ) ; if ( ! res_val || json_is_null ( res_val ) || ( err_val && ! json_is_null ( err_val ) ) ) { char * ss ; if ( err_val ) ss = json_dumps ( err_val , JSON_INDENT ( 3 ) ) ; else ss = strdup ( \"(unknownreason)\" ) ; applog ( LOG_INFO , \"JSON-RPCdecodefailed:%s\" , ss ) ; free ( ss ) ; goto out ; } sessionid = json_array_string ( json_array_get ( res_val , 0 ) , 1 ) ; if ( ! sessionid ) { applog ( LOG_INFO , \"Failedtogetsessionidininitiate_stratum\" ) ; goto out ; } nonce1 = json_array_string ( res_val , 1 ) ; if ( ! nonce1 ) { applog ( LOG_INFO , \"Failedtogetnonce1ininitiate_stratum\" ) ; free ( sessionid ) ; goto out ; } n2size = json_integer_value ( json_array_get ( res_val , 2 ) ) ; if ( ! n2size ) { applog ( LOG_INFO , \"Failedtogetn2sizeininitiate_stratum\" ) ; free ( sessionid ) ; free ( nonce1 ) ; goto out ; } mutex_lock ( & pool -> pool_lock ) ; pool -> sessionid = sessionid ; free ( pool -> nonce1 ) ; pool -> nonce1 = nonce1 ; pool -> n1_len = strlen ( nonce1 ) / 2 ; pool -> n2size = n2size ; mutex_unlock ( & pool -> pool_lock ) ; applog ( LOG_DEBUG , \"Pool%dstratumsessionid:%s\" , pool -> pool_no , pool -> sessionid ) ; ret = true ; out : if ( val ) json_decref ( val ) ; if ( ret ) { if ( ! pool -> stratum_url ) pool -> stratum_url = pool -> sockaddr_url ; pool -> stratum_active = true ; pool -> swork . diff = 1 ; if ( opt_protocol ) { applog ( LOG_DEBUG , \"Pool%dconfirmedmining.subscribewithextranonce1%sextran2size%d\" , pool -> pool_no , pool -> nonce1 , pool -> n2size ) ; } } else { if ( recvd && pool -> sessionid ) { mutex_lock ( & pool -> pool_lock ) ; free ( pool -> sessionid ) ; free ( pool -> nonce1 ) ; pool -> sessionid = pool -> nonce1 = NULL ; mutex_unlock ( & pool -> pool_lock ) ; applog ( LOG_DEBUG , \"Failedtoresumestratum,tryingafresh\" ) ; goto resend ; } applog ( LOG_DEBUG , \"Initiatestratumfailed\" ) ; if ( pool -> sock != INVSOCK ) { shutdown ( pool -> sock , SHUT_RDWR ) ; pool -> sock = INVSOCK ; } } return ret ; }\n", "\n", "1: CWE-119 bool initiate_stratum ( struct pool * pool ) { bool ret = false , recvd = false , noresume = false , sockd = false ; char s [ RBUFSIZE ] , * sret = NULL , * nonce1 , * sessionid ; json_t * val = NULL , * res_val , * err_val ; json_error_t err ; int n2size ; resend : if ( ! setup_stratum_socket ( pool ) ) { applog ( LOG_INFO , \"setup_stratum_socket()on%sfailed\" , get_pool_name ( pool ) ) ; sockd = false ; goto out ; } sockd = true ; if ( recvd ) { clear_sock ( pool ) ; sprintf ( s , \"{\\\\\"id\\\\\":%d,\\\\\"method\\\\\":\\\\\"mining.subscribe\\\\\",\\\\\"params\\\\\":[]}\" , swork_id ++ ) ; } else { if ( pool -> sessionid ) sprintf ( s , \"{\\\\\"id\\\\\":%d,\\\\\"method\\\\\":\\\\\"mining.subscribe\\\\\",\\\\\"params\\\\\":[\\\\\"\" PACKAGE \"/\" VERSION \"\\\\\",\\\\\"%s\\\\\"]}\" , swork_id ++ , pool -> sessionid ) ; else sprintf ( s , \"{\\\\\"id\\\\\":%d,\\\\\"method\\\\\":\\\\\"mining.subscribe\\\\\",\\\\\"params\\\\\":[\\\\\"\" PACKAGE \"/\" VERSION \"\\\\\"]}\" , swork_id ++ ) ; } if ( __stratum_send ( pool , s , strlen ( s ) ) != SEND_OK ) { applog ( LOG_DEBUG , \"Failedtosendsininitiate_stratum\" ) ; goto out ; } if ( ! socket_full ( pool , DEFAULT_SOCKWAIT ) ) { applog ( LOG_DEBUG , \"Timedoutwaitingforresponseininitiate_stratum\" ) ; goto out ; } sret = recv_line ( pool ) ; if ( ! sret ) goto out ; recvd = true ; val = JSON_LOADS ( sret , & err ) ; free ( sret ) ; if ( ! val ) { applog ( LOG_INFO , \"JSONdecodefailed(%d):%s\" , err . line , err . text ) ; goto out ; } res_val = json_object_get ( val , \"result\" ) ; err_val = json_object_get ( val , \"error\" ) ; if ( ! res_val || json_is_null ( res_val ) || ( err_val && ! json_is_null ( err_val ) ) ) { char * ss ; if ( err_val ) ss = json_dumps ( err_val , JSON_INDENT ( 3 ) ) ; else ss = strdup ( \"(unknownreason)\" ) ; applog ( LOG_INFO , \"JSON-RPCdecodefailed:%s\" , ss ) ; free ( ss ) ; goto out ; } sessionid = get_sessionid ( res_val ) ; if ( ! sessionid ) applog ( LOG_DEBUG , \"Failedtogetsessionidininitiate_stratum\" ) ; nonce1 = json_array_string ( res_val , 1 ) ; if ( ! nonce1 ) { applog ( LOG_INFO , \"Failedtogetnonce1ininitiate_stratum\" ) ; free ( sessionid ) ; goto out ; } n2size = json_integer_value ( json_array_get ( res_val , 2 ) ) ; if ( ! n2size ) { applog ( LOG_INFO , \"Failedtogetn2sizeininitiate_stratum\" ) ; free ( sessionid ) ; free ( nonce1 ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; pool -> sessionid = sessionid ; pool -> nonce1 = nonce1 ; pool -> n1_len = strlen ( nonce1 ) / 2 ; free ( pool -> nonce1bin ) ; pool -> nonce1bin = ( unsigned char * ) calloc ( pool -> n1_len , 1 ) ; if ( unlikely ( ! pool -> nonce1bin ) ) quithere ( 1 , \"Failedtocallocpool->nonce1bin\" ) ; hex2bin ( pool -> nonce1bin , pool -> nonce1 , pool -> n1_len ) ; pool -> n2size = n2size ; cg_wunlock ( & pool -> data_lock ) ; if ( sessionid ) applog ( LOG_DEBUG , \"%sstratumsessionid:%s\" , get_pool_name ( pool ) , pool -> sessionid ) ; ret = true ; out : if ( ret ) { if ( ! pool -> stratum_url ) pool -> stratum_url = pool -> sockaddr_url ; pool -> stratum_active = true ; pool -> swork . diff = 1 ; if ( opt_protocol ) { applog ( LOG_DEBUG , \"%sconfirmedmining.subscribewithextranonce1%sextran2size%d\" , get_pool_name ( pool ) , pool -> nonce1 , pool -> n2size ) ; } } else { if ( recvd && ! noresume ) { cg_wlock ( & pool -> data_lock ) ; free ( pool -> sessionid ) ; free ( pool -> nonce1 ) ; pool -> sessionid = pool -> nonce1 = NULL ; cg_wunlock ( & pool -> data_lock ) ; applog ( LOG_DEBUG , \"Failedtoresumestratum,tryingafresh\" ) ; noresume = true ; json_decref ( val ) ; goto resend ; } applog ( LOG_DEBUG , \"Initiatingstratumfailedon%s\" , get_pool_name ( pool ) ) ; if ( sockd ) { applog ( LOG_DEBUG , \"Suspendingstratumon%s\" , get_pool_name ( pool ) ) ; suspend_stratum ( pool ) ; } } json_decref ( val ) ; return ret ; }\n", "\n", "\n", "Target: u1_num_mbs ++ ; u1_num_mbsNby2 ++ ; ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ;\n", "\n", "Sources:\n", "0: CWE-119 WORD32 ih264d_parse_inter_slice_data_cabac ( dec_struct_t * ps_dec , dec_slice_params_t * ps_slice , UWORD16 u2_first_mb_in_slice ) { UWORD32 uc_more_data_flag ; WORD32 i2_cur_mb_addr ; UWORD32 u1_num_mbs , u1_num_mbsNby2 , u1_mb_idx ; UWORD32 u1_mbaff ; UWORD32 u1_num_mbs_next , u1_end_of_row ; const UWORD16 i2_pic_wdin_mbs = ps_dec -> u2_frm_wd_in_mbs ; UWORD32 u1_slice_end = 0 ; UWORD32 u1_tfr_n_mb = 0 ; UWORD32 u1_decode_nmb = 0 ; deblk_mb_t * ps_cur_deblk_mb ; dec_mb_info_t * ps_cur_mb_info ; parse_pmbarams_t * ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; UWORD32 u1_inter_mb_skip_type ; UWORD32 u1_inter_mb_type ; UWORD32 u1_deblk_mb_type ; UWORD32 u1_mb_threshold ; dec_bit_stream_t * const ps_bitstrm = ps_dec -> ps_bitstrm ; WORD32 ret = OK ; if ( ps_slice -> u1_slice_type == P_SLICE ) { u1_inter_mb_skip_type = CAB_P_SKIP ; u1_inter_mb_type = P_MB ; u1_deblk_mb_type = D_INTER_MB ; u1_mb_threshold = 5 ; } else { u1_inter_mb_skip_type = CAB_B_SKIP ; u1_inter_mb_type = B_MB ; u1_deblk_mb_type = D_B_SLICE ; u1_mb_threshold = 23 ; } i2_cur_mb_addr = u2_first_mb_in_slice ; ps_dec -> u1_qp = ps_slice -> u1_slice_qp ; ih264d_update_qp ( ps_dec , 0 ) ; u1_mb_idx = ps_dec -> u1_mb_idx ; u1_num_mbs = u1_mb_idx ; u1_num_mbsNby2 = 0 ; u1_mbaff = ps_slice -> u1_mbaff_frame_flag ; i2_cur_mb_addr = u2_first_mb_in_slice << u1_mbaff ; uc_more_data_flag = 1 ; if ( ps_bitstrm -> u4_ofst & 0x07 ) { ps_bitstrm -> u4_ofst += 8 ; ps_bitstrm -> u4_ofst &= 0xFFFFFFF8 ; } ret = ih264d_init_cabac_dec_envirnoment ( & ( ps_dec -> s_cab_dec_env ) , ps_bitstrm ) ; if ( ret != OK ) return ret ; ps_dec -> i1_prev_mb_qp_delta = 0 ; while ( ! u1_slice_end ) { UWORD8 u1_mb_type ; UWORD32 u4_mb_skip ; ps_dec -> pv_prev_mb_parse_tu_coeff_data = ps_dec -> pv_parse_tu_coeff_data ; if ( i2_cur_mb_addr > ps_dec -> ps_cur_sps -> u2_max_mb_addr ) { ret = ERROR_MB_ADDRESS_T ; break ; } ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs ; ps_dec -> u4_num_mbs_cur_nmb = u1_num_mbs ; ps_cur_mb_info -> u1_Mux = 0 ; ps_dec -> u4_num_pmbair = ( u1_num_mbs >> u1_mbaff ) ; ps_cur_deblk_mb = ps_dec -> ps_deblk_mbn + u1_num_mbs ; ps_cur_mb_info -> u1_end_of_slice = 0 ; ps_parse_mb_data -> u1_num_part = 1 ; ps_parse_mb_data -> u1_isI_mb = 0 ; u4_mb_skip = ps_dec -> pf_get_mb_info ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , 1 ) ; ps_cur_mb_info -> u1_tran_form8x8 = 0 ; ps_cur_mb_info -> ps_curmb -> u1_tran_form8x8 = 0 ; if ( ps_dec -> u4_app_disable_deblk_frm == 0 ) ih264d_set_deblocking_parameters ( ps_cur_deblk_mb , ps_slice , ps_dec -> u1_mb_ngbr_availablity , ps_dec -> u1_cur_mb_fld_dec_flag ) ; if ( u4_mb_skip ) { memset ( ps_dec -> ps_curr_ctxt_mb_info , 0 , sizeof ( ctxt_inc_mb_info_t ) ) ; ps_dec -> ps_curr_ctxt_mb_info -> u1_mb_type = u1_inter_mb_skip_type ; MEMSET_16BYTES ( & ps_dec -> pu1_left_mv_ctxt_inc [ 0 ] [ 0 ] , 0 ) ; * ( ( UWORD32 * ) ps_dec -> pi1_left_ref_idx_ctxt_inc ) = 0 ; * ( ps_dec -> pu1_left_yuv_dc_csbp ) = 0 ; ps_dec -> i1_prev_mb_qp_delta = 0 ; ps_cur_mb_info -> u1_mb_type = MB_SKIP ; ps_cur_mb_info -> u1_cbp = 0 ; { parse_part_params_t * ps_part_info = ps_dec -> ps_part ; ps_part_info -> u1_is_direct = PART_DIRECT_16x16 ; ps_part_info -> u1_sub_mb_num = 0 ; ps_dec -> ps_part ++ ; } ih264d_update_nnz_for_skipmb ( ps_dec , ps_cur_mb_info , CABAC ) ; ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; } else { u1_mb_type = ih264d_parse_mb_type_cabac ( ps_dec ) ; ps_cur_mb_info -> u1_mb_type = u1_mb_type ; if ( u1_mb_type > ( 25 + u1_mb_threshold ) ) return ERROR_MB_TYPE ; if ( u1_mb_type < u1_mb_threshold ) { ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; * ( ps_dec -> pu1_left_yuv_dc_csbp ) &= 0x6 ; ret = ps_dec -> pf_parse_inter_mb ( ps_dec , ps_cur_mb_info , u1_num_mbs , u1_num_mbsNby2 ) ; if ( ret != OK ) return ret ; ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; } else { ps_parse_mb_data -> u1_num_part = 0 ; ps_parse_mb_data -> u1_isI_mb = 1 ; if ( ( 25 + u1_mb_threshold ) == u1_mb_type ) { ps_cur_mb_info -> ps_curmb -> u1_mb_type = I_PCM_MB ; ret = ih264d_parse_ipcm_mb ( ps_dec , ps_cur_mb_info , u1_num_mbs ) ; if ( ret != OK ) return ret ; ps_cur_deblk_mb -> u1_mb_qp = 0 ; } else { if ( u1_mb_type == u1_mb_threshold ) ps_cur_mb_info -> ps_curmb -> u1_mb_type = I_4x4_MB ; else ps_cur_mb_info -> ps_curmb -> u1_mb_type = I_16x16_MB ; ret = ih264d_parse_imb_cabac ( ps_dec , ps_cur_mb_info , ( UWORD8 ) ( u1_mb_type - u1_mb_threshold ) ) ; if ( ret != OK ) return ret ; ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; } ps_cur_deblk_mb -> u1_mb_type |= D_INTRA_MB ; } } if ( u1_mbaff ) { ih264d_update_mbaff_left_nnz ( ps_dec , ps_cur_mb_info ) ; } i2_cur_mb_addr ++ ; if ( ps_cur_mb_info -> u1_topmb && u1_mbaff ) uc_more_data_flag = 1 ; else { uc_more_data_flag = ih264d_decode_terminate ( & ps_dec -> s_cab_dec_env , ps_bitstrm ) ; uc_more_data_flag = ! uc_more_data_flag ; COPYTHECONTEXT ( \"DecodeSliceterm\" , ! uc_more_data_flag ) ; } u1_num_mbs ++ ; ps_dec -> u2_total_mbs_coded ++ ; u1_num_mbsNby2 ++ ; ps_parse_mb_data ++ ; u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = ! uc_more_data_flag ; u1_tfr_n_mb = ( u1_num_mbs == ps_dec -> u1_recon_mb_grp ) || u1_end_of_row || u1_slice_end ; u1_decode_nmb = u1_tfr_n_mb || u1_slice_end ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( u1_decode_nmb ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; u1_num_mbsNby2 = 0 ; { ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; } } if ( u1_decode_nmb ) { if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } if ( u1_tfr_n_mb ) u1_num_mbs = 0 ; u1_mb_idx = u1_num_mbs ; ps_dec -> u1_mb_idx = u1_num_mbs ; } } ps_dec -> u4_num_mbs_cur_nmb = 0 ; ps_dec -> ps_cur_slice -> u4_mbs_in_slice = i2_cur_mb_addr - ( u2_first_mb_in_slice << u1_mbaff ) ; return ret ; }\n", "\n", "1: CWE-119 WORD32 ih264d_parse_inter_slice_data_cavlc ( dec_struct_t * ps_dec , dec_slice_params_t * ps_slice , UWORD16 u2_first_mb_in_slice ) { UWORD32 uc_more_data_flag ; WORD32 i2_cur_mb_addr ; UWORD32 u1_num_mbs , u1_num_mbsNby2 , u1_mb_idx ; UWORD32 i2_mb_skip_run ; UWORD32 u1_read_mb_type ; UWORD32 u1_mbaff ; UWORD32 u1_num_mbs_next , u1_end_of_row ; const UWORD32 i2_pic_wdin_mbs = ps_dec -> u2_frm_wd_in_mbs ; UWORD32 u1_slice_end = 0 ; UWORD32 u1_tfr_n_mb = 0 ; UWORD32 u1_decode_nmb = 0 ; dec_bit_stream_t * const ps_bitstrm = ps_dec -> ps_bitstrm ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; deblk_mb_t * ps_cur_deblk_mb ; dec_mb_info_t * ps_cur_mb_info ; parse_pmbarams_t * ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; UWORD32 u1_inter_mb_type ; UWORD32 u1_deblk_mb_type ; UWORD32 u1_mb_threshold ; WORD32 ret = OK ; if ( ps_slice -> u1_slice_type == P_SLICE ) { u1_inter_mb_type = P_MB ; u1_deblk_mb_type = D_INTER_MB ; u1_mb_threshold = 5 ; } else { u1_inter_mb_type = B_MB ; u1_deblk_mb_type = D_B_SLICE ; u1_mb_threshold = 23 ; } ps_dec -> u1_qp = ps_slice -> u1_slice_qp ; ih264d_update_qp ( ps_dec , 0 ) ; u1_mb_idx = ps_dec -> u1_mb_idx ; u1_num_mbs = u1_mb_idx ; u1_num_mbsNby2 = 0 ; u1_mbaff = ps_slice -> u1_mbaff_frame_flag ; i2_cur_mb_addr = u2_first_mb_in_slice << u1_mbaff ; i2_mb_skip_run = 0 ; uc_more_data_flag = 1 ; u1_read_mb_type = 0 ; while ( ! u1_slice_end ) { UWORD8 u1_mb_type ; ps_dec -> pv_prev_mb_parse_tu_coeff_data = ps_dec -> pv_parse_tu_coeff_data ; if ( i2_cur_mb_addr > ps_dec -> ps_cur_sps -> u2_max_mb_addr ) { ret = ERROR_MB_ADDRESS_T ; break ; } ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs ; ps_dec -> u4_num_mbs_cur_nmb = u1_num_mbs ; ps_cur_mb_info -> u1_Mux = 0 ; ps_dec -> u4_num_pmbair = ( u1_num_mbs >> u1_mbaff ) ; ps_cur_deblk_mb = ps_dec -> ps_deblk_mbn + u1_num_mbs ; ps_cur_mb_info -> u1_end_of_slice = 0 ; ps_parse_mb_data -> u1_num_part = 1 ; ps_parse_mb_data -> u1_isI_mb = 0 ; if ( ( ! i2_mb_skip_run ) && ( ! u1_read_mb_type ) ) { UWORD32 u4_bitstream_offset = * pu4_bitstrm_ofst ; UWORD32 u4_word , u4_ldz ; NEXTBITS_32 ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_ldz = CLZ ( u4_word ) ; u4_bitstream_offset += ( u4_ldz + 1 ) ; u4_word = 0 ; if ( u4_ldz ) { GETBITS ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf , u4_ldz ) ; } * pu4_bitstrm_ofst = u4_bitstream_offset ; i2_mb_skip_run = ( ( 1 << u4_ldz ) + u4_word - 1 ) ; COPYTHECONTEXT ( \"mb_skip_run\" , i2_mb_skip_run ) ; uc_more_data_flag = MORE_RBSP_DATA ( ps_bitstrm ) ; u1_read_mb_type = uc_more_data_flag ; } ps_dec -> pf_get_mb_info ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , i2_mb_skip_run ) ; if ( ps_dec -> u4_app_disable_deblk_frm == 0 ) ih264d_set_deblocking_parameters ( ps_cur_deblk_mb , ps_slice , ps_dec -> u1_mb_ngbr_availablity , ps_dec -> u1_cur_mb_fld_dec_flag ) ; if ( i2_mb_skip_run ) { ps_dec -> i1_prev_mb_qp_delta = 0 ; ps_dec -> u1_sub_mb_num = 0 ; ps_cur_mb_info -> u1_mb_type = MB_SKIP ; ps_cur_mb_info -> u1_mb_mc_mode = PRED_16x16 ; ps_cur_mb_info -> u1_cbp = 0 ; { parse_part_params_t * ps_part_info = ps_dec -> ps_part ; ps_part_info -> u1_is_direct = PART_DIRECT_16x16 ; ps_part_info -> u1_sub_mb_num = 0 ; ps_dec -> ps_part ++ ; } ih264d_update_nnz_for_skipmb ( ps_dec , ps_cur_mb_info , CAVLC ) ; ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; i2_mb_skip_run -- ; } else { u1_read_mb_type = 0 ; { UWORD32 u4_bitstream_offset = * pu4_bitstrm_ofst ; UWORD32 u4_word , u4_ldz , u4_temp ; NEXTBITS_32 ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_ldz = CLZ ( u4_word ) ; u4_bitstream_offset += ( u4_ldz + 1 ) ; u4_word = 0 ; if ( u4_ldz ) GETBITS ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf , u4_ldz ) ; * pu4_bitstrm_ofst = u4_bitstream_offset ; u4_temp = ( ( 1 << u4_ldz ) + u4_word - 1 ) ; if ( u4_temp > ( UWORD32 ) ( 25 + u1_mb_threshold ) ) return ERROR_MB_TYPE ; u1_mb_type = u4_temp ; COPYTHECONTEXT ( \"u1_mb_type\" , u1_mb_type ) ; } ps_cur_mb_info -> u1_mb_type = u1_mb_type ; if ( u1_mb_type < u1_mb_threshold ) { ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; ret = ps_dec -> pf_parse_inter_mb ( ps_dec , ps_cur_mb_info , u1_num_mbs , u1_num_mbsNby2 ) ; if ( ret != OK ) return ret ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; } else { ps_parse_mb_data -> u1_num_part = 0 ; ps_parse_mb_data -> u1_isI_mb = 1 ; if ( ( 25 + u1_mb_threshold ) == u1_mb_type ) { ps_cur_mb_info -> ps_curmb -> u1_mb_type = I_PCM_MB ; ret = ih264d_parse_ipcm_mb ( ps_dec , ps_cur_mb_info , u1_num_mbs ) ; if ( ret != OK ) return ret ; ps_dec -> u1_qp = 0 ; } else { ret = ih264d_parse_imb_cavlc ( ps_dec , ps_cur_mb_info , u1_num_mbs , ( UWORD8 ) ( u1_mb_type - u1_mb_threshold ) ) ; if ( ret != OK ) return ret ; } ps_cur_deblk_mb -> u1_mb_type |= D_INTRA_MB ; } uc_more_data_flag = MORE_RBSP_DATA ( ps_bitstrm ) ; } ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; if ( u1_mbaff ) { ih264d_update_mbaff_left_nnz ( ps_dec , ps_cur_mb_info ) ; } i2_cur_mb_addr ++ ; u1_num_mbs ++ ; ps_dec -> u2_total_mbs_coded ++ ; u1_num_mbsNby2 ++ ; ps_parse_mb_data ++ ; u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = ( ! ( uc_more_data_flag || i2_mb_skip_run ) ) ; u1_tfr_n_mb = ( u1_num_mbs == ps_dec -> u1_recon_mb_grp ) || u1_end_of_row || u1_slice_end ; u1_decode_nmb = u1_tfr_n_mb || u1_slice_end ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( u1_decode_nmb ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; u1_num_mbsNby2 = 0 ; { ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; } } if ( u1_decode_nmb ) { if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } if ( u1_tfr_n_mb ) u1_num_mbs = 0 ; u1_mb_idx = u1_num_mbs ; ps_dec -> u1_mb_idx = u1_num_mbs ; } } ps_dec -> u4_num_mbs_cur_nmb = 0 ; ps_dec -> ps_cur_slice -> u4_mbs_in_slice = i2_cur_mb_addr - ( u2_first_mb_in_slice << u1_mbaff ) ; return ret ; }\n", "\n", "\n", "Target: SOL_PPPOL2TP ) return - EINVAL ; if (\n", "\n", "Sources:\n", "0: CWE-269 static int pppol2tp_getsockopt ( struct socket * sock , int level , int optname , char __user * optval , int __user * optlen ) { struct sock * sk = sock -> sk ; struct l2tp_session * session ; struct l2tp_tunnel * tunnel ; int val , len ; int err ; struct pppol2tp_session * ps ; if ( level != SOL_PPPOL2TP ) return udp_prot . getsockopt ( sk , level , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; len = min_t ( unsigned int , len , sizeof ( int ) ) ; if ( len < 0 ) return - EINVAL ; err = - ENOTCONN ; if ( sk -> sk_user_data == NULL ) goto end ; err = - EBADF ; session = pppol2tp_sock_to_session ( sk ) ; if ( session == NULL ) goto end ; ps = l2tp_session_priv ( session ) ; if ( ( session -> session_id == 0 ) && ( session -> peer_session_id == 0 ) ) { err = - EBADF ; tunnel = l2tp_sock_to_tunnel ( ps -> tunnel_sock ) ; if ( tunnel == NULL ) goto end_put_sess ; err = pppol2tp_tunnel_getsockopt ( sk , tunnel , optname , & val ) ; sock_put ( ps -> tunnel_sock ) ; } else err = pppol2tp_session_getsockopt ( sk , session , optname , & val ) ; err = - EFAULT ; if ( put_user ( len , optlen ) ) goto end_put_sess ; if ( copy_to_user ( ( void __user * ) optval , & val , len ) ) goto end_put_sess ; err = 0 ; end_put_sess : sock_put ( sk ) ; end : return err ; }\n", "\n", "1: CWE-264 static int pppol2tp_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct l2tp_session * session ; struct l2tp_tunnel * tunnel ; struct pppol2tp_session * ps ; int val ; int err ; if ( level != SOL_PPPOL2TP ) return udp_prot . setsockopt ( sk , level , optname , optval , optlen ) ; if ( optlen < sizeof ( int ) ) return - EINVAL ; if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; err = - ENOTCONN ; if ( sk -> sk_user_data == NULL ) goto end ; err = - EBADF ; session = pppol2tp_sock_to_session ( sk ) ; if ( session == NULL ) goto end ; ps = l2tp_session_priv ( session ) ; if ( ( session -> session_id == 0 ) && ( session -> peer_session_id == 0 ) ) { err = - EBADF ; tunnel = l2tp_sock_to_tunnel ( ps -> tunnel_sock ) ; if ( tunnel == NULL ) goto end_put_sess ; err = pppol2tp_tunnel_setsockopt ( sk , tunnel , optname , val ) ; sock_put ( ps -> tunnel_sock ) ; } else err = pppol2tp_session_setsockopt ( sk , session , optname , val ) ; err = 0 ; end_put_sess : sock_put ( sk ) ; end : return err ; }\n", "\n", "2: CWE-269 static int pppol2tp_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct l2tp_session * session ; struct l2tp_tunnel * tunnel ; struct pppol2tp_session * ps ; int val ; int err ; if ( level != SOL_PPPOL2TP ) return udp_prot . setsockopt ( sk , level , optname , optval , optlen ) ; if ( optlen < sizeof ( int ) ) return - EINVAL ; if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; err = - ENOTCONN ; if ( sk -> sk_user_data == NULL ) goto end ; err = - EBADF ; session = pppol2tp_sock_to_session ( sk ) ; if ( session == NULL ) goto end ; ps = l2tp_session_priv ( session ) ; if ( ( session -> session_id == 0 ) && ( session -> peer_session_id == 0 ) ) { err = - EBADF ; tunnel = l2tp_sock_to_tunnel ( ps -> tunnel_sock ) ; if ( tunnel == NULL ) goto end_put_sess ; err = pppol2tp_tunnel_setsockopt ( sk , tunnel , optname , val ) ; sock_put ( ps -> tunnel_sock ) ; } else err = pppol2tp_session_setsockopt ( sk , session , optname , val ) ; err = 0 ; end_put_sess : sock_put ( sk ) ; end : return err ; }\n", "\n", "3: CWE-264 static int pppol2tp_getsockopt ( struct socket * sock , int level , int optname , char __user * optval , int __user * optlen ) { struct sock * sk = sock -> sk ; struct l2tp_session * session ; struct l2tp_tunnel * tunnel ; int val , len ; int err ; struct pppol2tp_session * ps ; if ( level != SOL_PPPOL2TP ) return udp_prot . getsockopt ( sk , level , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; len = min_t ( unsigned int , len , sizeof ( int ) ) ; if ( len < 0 ) return - EINVAL ; err = - ENOTCONN ; if ( sk -> sk_user_data == NULL ) goto end ; err = - EBADF ; session = pppol2tp_sock_to_session ( sk ) ; if ( session == NULL ) goto end ; ps = l2tp_session_priv ( session ) ; if ( ( session -> session_id == 0 ) && ( session -> peer_session_id == 0 ) ) { err = - EBADF ; tunnel = l2tp_sock_to_tunnel ( ps -> tunnel_sock ) ; if ( tunnel == NULL ) goto end_put_sess ; err = pppol2tp_tunnel_getsockopt ( sk , tunnel , optname , & val ) ; sock_put ( ps -> tunnel_sock ) ; } else err = pppol2tp_session_getsockopt ( sk , session , optname , & val ) ; err = - EFAULT ; if ( put_user ( len , optlen ) ) goto end_put_sess ; if ( copy_to_user ( ( void __user * ) optval , & val , len ) ) goto end_put_sess ; err = 0 ; end_put_sess : sock_put ( sk ) ; end : return err ; }\n", "\n", "\n", "Target: NullS ) ; SSL_SET_OPTIONS ( & mysql ) ; if ( opt_protocol\n", "\n", "Sources:\n", "0: CWE-284 int main ( int argc , char * * argv ) { int error ; my_bool first_argument_uses_wildcards = 0 ; char * wild ; MYSQL mysql ; MY_INIT ( argv [ 0 ] ) ; my_getopt_use_args_separator = TRUE ; if ( load_defaults ( \"my\" , load_default_groups , & argc , & argv ) ) exit ( 1 ) ; my_getopt_use_args_separator = FALSE ; get_options ( & argc , & argv ) ; wild = 0 ; if ( argc ) { char * pos = argv [ argc - 1 ] , * to ; for ( to = pos ; * pos ; pos ++ , to ++ ) { switch ( * pos ) { case '*' : * pos = '%' ; first_argument_uses_wildcards = 1 ; break ; case '?' : * pos = '_' ; first_argument_uses_wildcards = 1 ; break ; case '%' : case '_' : first_argument_uses_wildcards = 1 ; break ; case '\\\\\\\\' : pos ++ ; default : break ; } * to = * pos ; } * to = * pos ; } if ( first_argument_uses_wildcards ) wild = argv [ -- argc ] ; else if ( argc == 3 ) wild = argv [ -- argc ] ; if ( argc > 2 ) { fprintf ( stderr , \"%s:Toomanyarguments\\\\n\" , my_progname ) ; exit ( 1 ) ; } mysql_init ( & mysql ) ; if ( opt_compress ) mysql_options ( & mysql , MYSQL_OPT_COMPRESS , NullS ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( & mysql , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( & mysql , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( & mysql , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } mysql_options ( & mysql , MYSQL_OPT_SSL_VERIFY_SERVER_CERT , ( char * ) & opt_ssl_verify_server_cert ) ; # endif if ( opt_protocol ) mysql_options ( & mysql , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; if ( opt_bind_addr ) mysql_options ( & mysql , MYSQL_OPT_BIND , opt_bind_addr ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( & mysql , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif mysql_options ( & mysql , MYSQL_SET_CHARSET_NAME , default_charset ) ; if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( & mysql , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( & mysql , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( & mysql , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( & mysql , MYSQL_OPT_CONNECT_ATTR_ADD , \"program_name\" , \"mysqlshow\" ) ; if ( ! ( mysql_real_connect ( & mysql , host , user , opt_password , ( first_argument_uses_wildcards ) ? \"\" : argv [ 0 ] , opt_mysql_port , opt_mysql_unix_port , 0 ) ) ) { fprintf ( stderr , \"%s:%s\\\\n\" , my_progname , mysql_error ( & mysql ) ) ; exit ( 1 ) ; } mysql . reconnect = 1 ; switch ( argc ) { case 0 : error = list_dbs ( & mysql , wild ) ; break ; case 1 : if ( opt_status ) error = list_table_status ( & mysql , argv [ 0 ] , wild ) ; else error = list_tables ( & mysql , argv [ 0 ] , wild ) ; break ; default : if ( opt_status && ! wild ) error = list_table_status ( & mysql , argv [ 0 ] , argv [ 1 ] ) ; else error = list_fields ( & mysql , argv [ 0 ] , argv [ 1 ] , wild ) ; break ; } mysql_close ( & mysql ) ; my_free ( opt_password ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) my_free ( shared_memory_base_name ) ; # endif my_end ( my_end_arg ) ; exit ( error ? 1 : 0 ) ; return 0 ; }\n", "\n", "1: CWE-284 int main ( int argc , char * * argv ) { MYSQL mysql ; option_string * eptr ; MY_INIT ( argv [ 0 ] ) ; my_getopt_use_args_separator = TRUE ; if ( load_defaults ( \"my\" , load_default_groups , & argc , & argv ) ) { my_end ( 0 ) ; exit ( 1 ) ; } my_getopt_use_args_separator = FALSE ; defaults_argv = argv ; if ( get_options ( & argc , & argv ) ) { free_defaults ( defaults_argv ) ; my_end ( 0 ) ; exit ( 1 ) ; } if ( auto_generate_sql ) srandom ( ( uint ) time ( NULL ) ) ; delimiter_length = strlen ( delimiter ) ; if ( argc > 2 ) { fprintf ( stderr , \"%s:Toomanyarguments\\\\n\" , my_progname ) ; free_defaults ( defaults_argv ) ; my_end ( 0 ) ; exit ( 1 ) ; } mysql_init ( & mysql ) ; if ( opt_compress ) mysql_options ( & mysql , MYSQL_OPT_COMPRESS , NullS ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( & mysql , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( & mysql , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( & mysql , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } # endif if ( opt_protocol ) mysql_options ( & mysql , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( & mysql , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif mysql_options ( & mysql , MYSQL_SET_CHARSET_NAME , default_charset ) ; if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( & mysql , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( & mysql , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( & mysql , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( & mysql , MYSQL_OPT_CONNECT_ATTR_ADD , \"program_name\" , \"mysqlslap\" ) ; if ( using_opt_enable_cleartext_plugin ) mysql_options ( & mysql , MYSQL_ENABLE_CLEARTEXT_PLUGIN , ( char * ) & opt_enable_cleartext_plugin ) ; if ( ! opt_only_print ) { if ( ! ( mysql_real_connect ( & mysql , host , user , opt_password , NULL , opt_mysql_port , opt_mysql_unix_port , connect_flags ) ) ) { fprintf ( stderr , \"%s:Errorwhenconnectingtoserver:%s\\\\n\" , my_progname , mysql_error ( & mysql ) ) ; free_defaults ( defaults_argv ) ; my_end ( 0 ) ; exit ( 1 ) ; } } pthread_mutex_init ( & counter_mutex , NULL ) ; pthread_cond_init ( & count_threshhold , NULL ) ; pthread_mutex_init ( & sleeper_mutex , NULL ) ; pthread_cond_init ( & sleep_threshhold , NULL ) ; eptr = engine_options ; do { uint * current ; if ( verbose >= 2 ) printf ( \"StartingConcurrencyTest\\\\n\" ) ; if ( * concurrency ) { for ( current = concurrency ; current && * current ; current ++ ) concurrency_loop ( & mysql , * current , eptr ) ; } else { uint infinite = 1 ; do { concurrency_loop ( & mysql , infinite , eptr ) ; } while ( infinite ++ ) ; } if ( ! opt_preserve ) drop_schema ( & mysql , create_schema_string ) ; } while ( eptr ? ( eptr = eptr -> next ) : 0 ) ; pthread_mutex_destroy ( & counter_mutex ) ; pthread_cond_destroy ( & count_threshhold ) ; pthread_mutex_destroy ( & sleeper_mutex ) ; pthread_cond_destroy ( & sleep_threshhold ) ; if ( ! opt_only_print ) mysql_close ( & mysql ) ; my_free ( opt_password ) ; my_free ( concurrency ) ; statement_cleanup ( create_statements ) ; statement_cleanup ( query_statements ) ; statement_cleanup ( pre_statements ) ; statement_cleanup ( post_statements ) ; option_cleanup ( engine_options ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) my_free ( shared_memory_base_name ) ; # endif free_defaults ( defaults_argv ) ; my_end ( my_end_arg ) ; return 0 ; }\n", "\n", "\n", "Target: ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; if ( WPG_Palette . StartIndex > WPG_Palette . NumOfEntries\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; one = 1 ; image = AcquireImage ( image_info , exception ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , \"EncryptedWPGImageFileNotSupported\" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; Rec2 . RecordLength = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( Rec . RecordLength > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> resolution . x = BitmapHeader1 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> resolution . x = BitmapHeader2 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp <= 16 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp , exception ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , \"UnableToDecompressImage\" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ReplaceImageInList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( image , BImgBuff , i , bpp , exception ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp , exception ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; } } Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , \"ImageFileDoesNotContainAnyImageData\" ) ; return ( image ) ; }\n", "\n", "1: CWE-119 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; one = 1 ; image = AcquireImage ( image_info ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , \"EncryptedWPGImageFileNotSupported\" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; Rec2 . RecordLength = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( Rec . RecordLength > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> x_resolution = BitmapHeader1 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> x_resolution = BitmapHeader2 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp <= 16 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , \"UnableToDecompressImage\" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ReplaceImageInList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , \"InvalidColormapIndex\" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { size_t one ; one = 1 ; image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( BImgBuff , i , image , bpp ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; } } Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , \"ImageFileDoesNotContainAnyImageData\" ) ; return ( image ) ; }\n", "\n", "\n", "Target: ; if ( js_doregexec ( J , re -> prog if ( ! js_doregexec ( J , re -> prog\n", "\n", "Sources:\n", "0: CWE-400 static void Sp_replace_regexp ( js_State * J ) { js_Regexp * re ; const char * source , * s , * r ; js_Buffer * sb = NULL ; int n , x ; Resub m ; source = checkstring ( J , 0 ) ; re = js_toregexp ( J , 1 ) ; if ( js_regexec ( re -> prog , source , & m , 0 ) ) { js_copy ( J , 0 ) ; return ; } re -> last = 0 ; loop : s = m . sub [ 0 ] . sp ; n = m . sub [ 0 ] . ep - m . sub [ 0 ] . sp ; if ( js_iscallable ( J , 2 ) ) { js_copy ( J , 2 ) ; js_pushundefined ( J ) ; for ( x = 0 ; m . sub [ x ] . sp ; ++ x ) js_pushlstring ( J , m . sub [ x ] . sp , m . sub [ x ] . ep - m . sub [ x ] . sp ) ; js_pushnumber ( J , s - source ) ; js_copy ( J , 0 ) ; js_call ( J , 2 + x ) ; r = js_tostring ( J , - 1 ) ; js_putm ( J , & sb , source , s ) ; js_puts ( J , & sb , r ) ; js_pop ( J , 1 ) ; } else { r = js_tostring ( J , 2 ) ; js_putm ( J , & sb , source , s ) ; while ( * r ) { if ( * r == '$' ) { switch ( * ( ++ r ) ) { case 0 : -- r ; case '$' : js_putc ( J , & sb , '$' ) ; break ; case '`' : js_putm ( J , & sb , source , s ) ; break ; case '\\\\'' : js_puts ( J , & sb , s + n ) ; break ; case '&' : js_putm ( J , & sb , s , s + n ) ; break ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : x = * r - '0' ; if ( r [ 1 ] >= '0' && r [ 1 ] <= '9' ) x = x * 10 + * ( ++ r ) - '0' ; if ( x > 0 && x < m . nsub ) { js_putm ( J , & sb , m . sub [ x ] . sp , m . sub [ x ] . ep ) ; } else { js_putc ( J , & sb , '$' ) ; if ( x > 10 ) { js_putc ( J , & sb , '0' + x / 10 ) ; js_putc ( J , & sb , '0' + x % 10 ) ; } else { js_putc ( J , & sb , '0' + x ) ; } } break ; default : js_putc ( J , & sb , '$' ) ; js_putc ( J , & sb , * r ) ; break ; } ++ r ; } else { js_putc ( J , & sb , * r ++ ) ; } } } if ( re -> flags & JS_REGEXP_G ) { source = m . sub [ 0 ] . ep ; if ( n == 0 ) { if ( * source ) js_putc ( J , & sb , * source ++ ) ; else goto end ; } if ( ! js_regexec ( re -> prog , source , & m , REG_NOTBOL ) ) goto loop ; } end : js_puts ( J , & sb , s + n ) ; js_putc ( J , & sb , 0 ) ; if ( js_try ( J ) ) { js_free ( J , sb ) ; js_throw ( J ) ; } js_pushstring ( J , sb ? sb -> s : \"\" ) ; js_endtry ( J ) ; js_free ( J , sb ) ; }\n", "\n", "1: CWE-674 static void Sp_replace_regexp ( js_State * J ) { js_Regexp * re ; const char * source , * s , * r ; js_Buffer * sb = NULL ; int n , x ; Resub m ; source = checkstring ( J , 0 ) ; re = js_toregexp ( J , 1 ) ; if ( js_regexec ( re -> prog , source , & m , 0 ) ) { js_copy ( J , 0 ) ; return ; } re -> last = 0 ; loop : s = m . sub [ 0 ] . sp ; n = m . sub [ 0 ] . ep - m . sub [ 0 ] . sp ; if ( js_iscallable ( J , 2 ) ) { js_copy ( J , 2 ) ; js_pushundefined ( J ) ; for ( x = 0 ; m . sub [ x ] . sp ; ++ x ) js_pushlstring ( J , m . sub [ x ] . sp , m . sub [ x ] . ep - m . sub [ x ] . sp ) ; js_pushnumber ( J , s - source ) ; js_copy ( J , 0 ) ; js_call ( J , 2 + x ) ; r = js_tostring ( J , - 1 ) ; js_putm ( J , & sb , source , s ) ; js_puts ( J , & sb , r ) ; js_pop ( J , 1 ) ; } else { r = js_tostring ( J , 2 ) ; js_putm ( J , & sb , source , s ) ; while ( * r ) { if ( * r == '$' ) { switch ( * ( ++ r ) ) { case 0 : -- r ; case '$' : js_putc ( J , & sb , '$' ) ; break ; case '`' : js_putm ( J , & sb , source , s ) ; break ; case '\\\\'' : js_puts ( J , & sb , s + n ) ; break ; case '&' : js_putm ( J , & sb , s , s + n ) ; break ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : x = * r - '0' ; if ( r [ 1 ] >= '0' && r [ 1 ] <= '9' ) x = x * 10 + * ( ++ r ) - '0' ; if ( x > 0 && x < m . nsub ) { js_putm ( J , & sb , m . sub [ x ] . sp , m . sub [ x ] . ep ) ; } else { js_putc ( J , & sb , '$' ) ; if ( x > 10 ) { js_putc ( J , & sb , '0' + x / 10 ) ; js_putc ( J , & sb , '0' + x % 10 ) ; } else { js_putc ( J , & sb , '0' + x ) ; } } break ; default : js_putc ( J , & sb , '$' ) ; js_putc ( J , & sb , * r ) ; break ; } ++ r ; } else { js_putc ( J , & sb , * r ++ ) ; } } } if ( re -> flags & JS_REGEXP_G ) { source = m . sub [ 0 ] . ep ; if ( n == 0 ) { if ( * source ) js_putc ( J , & sb , * source ++ ) ; else goto end ; } if ( ! js_regexec ( re -> prog , source , & m , REG_NOTBOL ) ) goto loop ; } end : js_puts ( J , & sb , s + n ) ; js_putc ( J , & sb , 0 ) ; if ( js_try ( J ) ) { js_free ( J , sb ) ; js_throw ( J ) ; } js_pushstring ( J , sb ? sb -> s : \"\" ) ; js_endtry ( J ) ; js_free ( J , sb ) ; }\n", "\n", "\n", "Target: ; gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; OM_uint32 minor_stat prime_arg ) ; exit_func : gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; free_server_handle ( handle\n", "\n", "Sources:\n", "0: CWE-772 generic_ret * setkey_principal3_2_svc ( setkey3_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_SETKEY , arg -> princ , NULL ) ) { ret . code = kadm5_setkey_principal_3 ( ( void * ) handle , arg -> princ , arg -> keepold , arg -> n_ks_tuple , arg -> ks_tuple , arg -> keyblocks , arg -> n_keys ) ; } else { log_unauth ( \"kadm5_setkey_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_SETKEY ; } if ( ret . code != KADM5_AUTH_SETKEY ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_setkey_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "1: CWE-772 generic_ret * create_principal3_2_svc ( cprinc3_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; restriction_t * rp ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> rec . principal , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_ADD , arg -> rec . principal , & rp ) || kadm5int_acl_impose_restrictions ( handle -> context , & arg -> rec , & arg -> mask , rp ) ) { ret . code = KADM5_AUTH_ADD ; log_unauth ( \"kadm5_create_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_create_principal_3 ( ( void * ) handle , & arg -> rec , arg -> mask , arg -> n_ks_tuple , arg -> ks_tuple , arg -> passwd ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_create_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "2: CWE-772 chrand_ret * chrand_principal_2_svc ( chrand_arg * arg , struct svc_req * rqstp ) { static chrand_ret ret ; krb5_keyblock * k ; int nkeys ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_chrand_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; funcname = \"kadm5_randkey_principal\" ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) ) { ret . code = randkey_principal_wrapper_3 ( ( void * ) handle , arg -> princ , FALSE , 0 , NULL , & k , & nkeys ) ; } else if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_CHANGEPW , arg -> princ , NULL ) ) { ret . code = kadm5_randkey_principal ( ( void * ) handle , arg -> princ , & k , & nkeys ) ; } else { log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_CHANGEPW ; } if ( ret . code == KADM5_OK ) { ret . keys = k ; ret . n_keys = nkeys ; } if ( ret . code != KADM5_AUTH_CHANGEPW ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "3: CWE-772 chrand_ret * chrand_principal3_2_svc ( chrand3_arg * arg , struct svc_req * rqstp ) { static chrand_ret ret ; krb5_keyblock * k ; int nkeys ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_chrand_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; funcname = \"kadm5_randkey_principal\" ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) ) { ret . code = randkey_principal_wrapper_3 ( ( void * ) handle , arg -> princ , arg -> keepold , arg -> n_ks_tuple , arg -> ks_tuple , & k , & nkeys ) ; } else if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_CHANGEPW , arg -> princ , NULL ) ) { ret . code = kadm5_randkey_principal_3 ( ( void * ) handle , arg -> princ , arg -> keepold , arg -> n_ks_tuple , arg -> ks_tuple , & k , & nkeys ) ; } else { log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_CHANGEPW ; } if ( ret . code == KADM5_OK ) { ret . keys = k ; ret . n_keys = nkeys ; } if ( ret . code != KADM5_AUTH_CHANGEPW ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "4: CWE-772 generic_ret * chpass_principal3_2_svc ( chpass3_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) ) { ret . code = chpass_principal_wrapper_3 ( ( void * ) handle , arg -> princ , arg -> keepold , arg -> n_ks_tuple , arg -> ks_tuple , arg -> pass ) ; } else if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_CHANGEPW , arg -> princ , NULL ) ) { ret . code = kadm5_chpass_principal_3 ( ( void * ) handle , arg -> princ , arg -> keepold , arg -> n_ks_tuple , arg -> ks_tuple , arg -> pass ) ; } else { log_unauth ( \"kadm5_chpass_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_CHANGEPW ; } if ( ret . code != KADM5_AUTH_CHANGEPW ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_chpass_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "5: CWE-772 generic_ret * create_principal_2_svc ( cprinc_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; restriction_t * rp ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> rec . principal , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_ADD , arg -> rec . principal , & rp ) || kadm5int_acl_impose_restrictions ( handle -> context , & arg -> rec , & arg -> mask , rp ) ) { ret . code = KADM5_AUTH_ADD ; log_unauth ( \"kadm5_create_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_create_principal ( ( void * ) handle , & arg -> rec , arg -> mask , arg -> passwd ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_create_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "6: CWE-772 generic_ret * chpass_principal_2_svc ( chpass_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) ) { ret . code = chpass_principal_wrapper_3 ( ( void * ) handle , arg -> princ , FALSE , 0 , NULL , arg -> pass ) ; } else if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_CHANGEPW , arg -> princ , NULL ) ) { ret . code = kadm5_chpass_principal ( ( void * ) handle , arg -> princ , arg -> pass ) ; } else { log_unauth ( \"kadm5_chpass_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_CHANGEPW ; } if ( ret . code != KADM5_AUTH_CHANGEPW ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_chpass_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "\n", "Target: { if ( osStrchr ( topicName , == NULL && osStrchr ( topicName ,\n", "\n", "Sources:\n", "0: CWE-20 bool_t mqttSnClientIsShortTopicName ( const char_t * topicName ) { bool_t res ; res = FALSE ; if ( osStrlen ( topicName ) == 2 ) { if ( strchr ( topicName , '#' ) == NULL && strchr ( topicName , '+' ) == NULL ) { res = TRUE ; } } return res ; }\n", "\n", "1: CWE-20 error_t mqttSnClientSubscribe ( MqttSnClientContext * context , const char_t * topicName , MqttSnQosLevel qos ) { error_t error ; systime_t time ; if ( context == NULL || topicName == NULL ) return ERROR_INVALID_PARAMETER ; error = NO_ERROR ; while ( ! error ) { time = osGetSystemTime ( ) ; if ( context -> state == MQTT_SN_CLIENT_STATE_ACTIVE ) { mqttSnClientGenerateMessageId ( context ) ; context -> startTime = time ; error = mqttSnClientSendSubscribe ( context , topicName , qos ) ; } else if ( context -> state == MQTT_SN_CLIENT_STATE_SENDING_REQ ) { if ( timeCompare ( time , context -> startTime + context -> timeout ) >= 0 ) { context -> state = MQTT_SN_CLIENT_STATE_DISCONNECTING ; error = ERROR_TIMEOUT ; } else if ( timeCompare ( time , context -> retransmitStartTime + MQTT_SN_CLIENT_RETRY_TIMEOUT ) >= 0 ) { error = mqttSnClientSendSubscribe ( context , topicName , qos ) ; } else { error = mqttSnClientProcessEvents ( context , MQTT_SN_CLIENT_TICK_INTERVAL ) ; } } else if ( context -> state == MQTT_SN_CLIENT_STATE_RESP_RECEIVED ) { context -> state = MQTT_SN_CLIENT_STATE_ACTIVE ; if ( context -> msgType == MQTT_SN_MSG_TYPE_SUBACK ) { if ( context -> returnCode == MQTT_SN_RETURN_CODE_ACCEPTED ) { if ( strchr ( topicName , '#' ) == NULL && strchr ( topicName , '+' ) == NULL ) { error = mqttSnClientAddTopic ( context , topicName , context -> topicId ) ; } break ; } else { error = ERROR_REQUEST_REJECTED ; } } else { error = ERROR_UNEXPECTED_RESPONSE ; } } else { error = ERROR_NOT_CONNECTED ; } } return error ; }\n", "\n", "\n", "Target: long len ; qboolean isLocalConfig ; \"Filesystemcallmadewithoutinitialization\" ) ; isLocalConfig = ! strcmp ( filename , \"autoexec.cfg\" ) || ! strcmp ( filename , Q3CONFIG_CFG ) ; next ) { if ( isLocalConfig && search -> pack ) continue ;\n", "\n", "Sources:\n", "0: CWE-000 long FS_FOpenFileRead ( const char * filename , fileHandle_t * file , qboolean uniqueFILE ) { searchpath_t * search ; long len ; if ( ! fs_searchpaths ) Com_Error ( ERR_FATAL , \"Filesystemcallmadewithoutinitialization\" ) ; for ( search = fs_searchpaths ; search ; search = search -> next ) { len = FS_FOpenFileReadDir ( filename , search , file , uniqueFILE , qfalse ) ; if ( file == NULL ) { if ( len > 0 ) return len ; } else { if ( len >= 0 && * file ) return len ; } } # ifdef FS_MISSING if ( missingFiles ) fprintf ( missingFiles , \"%s\\\\n\" , filename ) ; # endif if ( file ) { * file = 0 ; return - 1 ; } else { return 0 ; } }\n", "\n", "1: CWE-269 long FS_FOpenFileRead ( const char * filename , fileHandle_t * file , qboolean uniqueFILE ) { searchpath_t * search ; long len ; if ( ! fs_searchpaths ) Com_Error ( ERR_FATAL , \"Filesystemcallmadewithoutinitialization\" ) ; for ( search = fs_searchpaths ; search ; search = search -> next ) { len = FS_FOpenFileReadDir ( filename , search , file , uniqueFILE , qfalse ) ; if ( file == NULL ) { if ( len > 0 ) return len ; } else { if ( len >= 0 && * file ) return len ; } } # ifdef FS_MISSING if ( missingFiles ) fprintf ( missingFiles , \"%s\\\\n\" , filename ) ; # endif if ( file ) { * file = 0 ; return - 1 ; } else { return 0 ; } }\n", "\n", "\n", "Target: walk ) { unsigned char * vec = walk -> private ; unsigned long nr = ( end - addr ) >> PAGE_SHIFT ; memset ( vec , 0 , nr ) ; -> private += nr ; return 0\n", "\n", "Sources:\n", "0: CWE-200 static int mincore_unmapped_range ( unsigned long addr , unsigned long end , struct mm_walk * walk ) { walk -> private += __mincore_unmapped_range ( addr , end , walk -> vma , walk -> private ) ; return 0 ; }\n", "\n", "1: CWE-319 static int mincore_unmapped_range ( unsigned long addr , unsigned long end , struct mm_walk * walk ) { walk -> private += __mincore_unmapped_range ( addr , end , walk -> vma , walk -> private ) ; return 0 ; }\n", "\n", "\n", "Target: dev ) ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ;\n", "\n", "Sources:\n", "0: CWE-264 static void tun_net_init ( struct net_device * dev ) { struct tun_struct * tun = netdev_priv ( dev ) ; switch ( tun -> flags & TUN_TYPE_MASK ) { case TUN_TUN_DEV : dev -> netdev_ops = & tun_netdev_ops ; dev -> hard_header_len = 0 ; dev -> addr_len = 0 ; dev -> mtu = 1500 ; dev -> type = ARPHRD_NONE ; dev -> flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST ; dev -> tx_queue_len = TUN_READQ_SIZE ; break ; case TUN_TAP_DEV : dev -> netdev_ops = & tap_netdev_ops ; ether_setup ( dev ) ; random_ether_addr ( dev -> dev_addr ) ; dev -> tx_queue_len = TUN_READQ_SIZE ; break ; } }\n", "\n", "1: CWE-000 static void tun_net_init ( struct net_device * dev ) { struct tun_struct * tun = netdev_priv ( dev ) ; switch ( tun -> flags & TUN_TYPE_MASK ) { case TUN_TUN_DEV : dev -> netdev_ops = & tun_netdev_ops ; dev -> hard_header_len = 0 ; dev -> addr_len = 0 ; dev -> mtu = 1500 ; dev -> type = ARPHRD_NONE ; dev -> flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST ; dev -> tx_queue_len = TUN_READQ_SIZE ; break ; case TUN_TAP_DEV : dev -> netdev_ops = & tap_netdev_ops ; ether_setup ( dev ) ; random_ether_addr ( dev -> dev_addr ) ; dev -> tx_queue_len = TUN_READQ_SIZE ; break ; } }\n", "\n", "\n", "Target: ; if ( pmd_none_or_trans_huge_or_clear_bad ( pmd )\n", "\n", "Sources:\n", "0: CWE-264 static int walk_pmd_range ( pud_t * pud , unsigned long addr , unsigned long end , struct mm_walk * walk ) { pmd_t * pmd ; unsigned long next ; int err = 0 ; pmd = pmd_offset ( pud , addr ) ; do { again : next = pmd_addr_end ( addr , end ) ; if ( pmd_none ( * pmd ) ) { if ( walk -> pte_hole ) err = walk -> pte_hole ( addr , next , walk ) ; if ( err ) break ; continue ; } if ( walk -> pmd_entry ) err = walk -> pmd_entry ( pmd , addr , next , walk ) ; if ( err ) break ; if ( ! walk -> pte_entry ) continue ; split_huge_page_pmd ( walk -> mm , pmd ) ; if ( pmd_none_or_clear_bad ( pmd ) ) goto again ; err = walk_pte_range ( pmd , addr , next , walk ) ; if ( err ) break ; } while ( pmd ++ , addr = next , addr != end ) ; return err ; }\n", "\n", "1: CWE-264 static inline int check_pmd_range ( struct vm_area_struct * vma , pud_t * pud , unsigned long addr , unsigned long end , const nodemask_t * nodes , unsigned long flags , void * private ) { pmd_t * pmd ; unsigned long next ; pmd = pmd_offset ( pud , addr ) ; do { next = pmd_addr_end ( addr , end ) ; split_huge_page_pmd ( vma -> vm_mm , pmd ) ; if ( pmd_none_or_clear_bad ( pmd ) ) continue ; if ( check_pte_range ( vma , pmd , addr , next , nodes , flags , private ) ) return - EIO ; } while ( pmd ++ , addr = next , addr != end ) ; return 0 ; }\n", "\n", "\n", "Target: ) == 1 && ps_stream -> u4_offset < ps_stream -> u4_max_offset\n", "\n", "Sources:\n", "0: CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_pic_hdr ( dec_state_t * ps_dec ) { stream_t * ps_stream ; ps_stream = & ps_dec -> s_bit_stream ; impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; impeg2d_bit_stream_get ( ps_stream , 10 ) ; ps_dec -> e_pic_type = ( e_pic_type_t ) impeg2d_bit_stream_get ( ps_stream , 3 ) ; if ( ( ps_dec -> e_pic_type < I_PIC ) || ( ps_dec -> e_pic_type > D_PIC ) ) { impeg2d_next_code ( ps_dec , PICTURE_START_CODE ) ; return IMPEG2D_INVALID_PIC_TYPE ; } impeg2d_bit_stream_get ( ps_stream , 16 ) ; if ( ps_dec -> e_pic_type == P_PIC || ps_dec -> e_pic_type == B_PIC ) { ps_dec -> u2_full_pel_forw_vector = impeg2d_bit_stream_get_bit ( ps_stream ) ; ps_dec -> u2_forw_f_code = impeg2d_bit_stream_get ( ps_stream , 3 ) ; } if ( ps_dec -> e_pic_type == B_PIC ) { ps_dec -> u2_full_pel_back_vector = impeg2d_bit_stream_get_bit ( ps_stream ) ; ps_dec -> u2_back_f_code = impeg2d_bit_stream_get ( ps_stream , 3 ) ; } if ( ps_dec -> u2_is_mpeg2 == 0 ) { ps_dec -> au2_f_code [ 0 ] [ 0 ] = ps_dec -> au2_f_code [ 0 ] [ 1 ] = ps_dec -> u2_forw_f_code ; ps_dec -> au2_f_code [ 1 ] [ 0 ] = ps_dec -> au2_f_code [ 1 ] [ 1 ] = ps_dec -> u2_back_f_code ; } while ( impeg2d_bit_stream_nxt ( ps_stream , 1 ) == 1 ) { impeg2d_bit_stream_get ( ps_stream , 9 ) ; } impeg2d_bit_stream_get_bit ( ps_stream ) ; impeg2d_next_start_code ( ps_dec ) ; return ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; }\n", "\n", "1: CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_slice ( dec_state_t * ps_dec ) { stream_t * ps_stream ; UWORD32 u4_slice_vertical_position ; UWORD32 u4_slice_vertical_position_extension ; IMPEG2D_ERROR_CODES_T e_error ; ps_stream = & ps_dec -> s_bit_stream ; impeg2d_bit_stream_flush ( ps_stream , START_CODE_PREFIX_LEN ) ; u4_slice_vertical_position = impeg2d_bit_stream_get ( ps_stream , 8 ) ; if ( u4_slice_vertical_position > 2800 ) { u4_slice_vertical_position_extension = impeg2d_bit_stream_get ( ps_stream , 3 ) ; u4_slice_vertical_position += ( u4_slice_vertical_position_extension << 7 ) ; } if ( ( u4_slice_vertical_position > ps_dec -> u2_num_vert_mb ) || ( u4_slice_vertical_position == 0 ) ) { return IMPEG2D_INVALID_VERT_SIZE ; } u4_slice_vertical_position -- ; if ( ps_dec -> u2_mb_y != u4_slice_vertical_position ) { ps_dec -> u2_mb_y = u4_slice_vertical_position ; ps_dec -> u2_mb_x = 0 ; } ps_dec -> u2_first_mb = 1 ; { UWORD16 u2_quant_scale_code ; u2_quant_scale_code = impeg2d_bit_stream_get ( ps_stream , 5 ) ; ps_dec -> u1_quant_scale = ( ps_dec -> u2_q_scale_type ) ? gau1_impeg2_non_linear_quant_scale [ u2_quant_scale_code ] : ( u2_quant_scale_code << 1 ) ; } if ( impeg2d_bit_stream_nxt ( ps_stream , 1 ) == 1 ) { impeg2d_bit_stream_flush ( ps_stream , 9 ) ; while ( impeg2d_bit_stream_nxt ( ps_stream , 1 ) == 1 ) { impeg2d_bit_stream_flush ( ps_stream , 9 ) ; } } impeg2d_bit_stream_get_bit ( ps_stream ) ; ps_dec -> u2_def_dc_pred [ Y_LUMA ] = 128 << ps_dec -> u2_intra_dc_precision ; ps_dec -> u2_def_dc_pred [ U_CHROMA ] = 128 << ps_dec -> u2_intra_dc_precision ; ps_dec -> u2_def_dc_pred [ V_CHROMA ] = 128 << ps_dec -> u2_intra_dc_precision ; e_error = ps_dec -> pf_decode_slice ( ps_dec ) ; if ( ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE != e_error ) { return e_error ; } if ( ps_dec -> u2_mb_y < ps_dec -> u2_num_vert_mb ) impeg2d_next_start_code ( ps_dec ) ; return ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; }\n", "\n", "\n", "Target: -> it_overrun += hrtimer_forward ( timer\n", "\n", "Sources:\n", "0: CWE-190 static enum hrtimer_restart posix_timer_fn ( struct hrtimer * timer ) { struct k_itimer * timr ; unsigned long flags ; int si_private = 0 ; enum hrtimer_restart ret = HRTIMER_NORESTART ; timr = container_of ( timer , struct k_itimer , it . real . timer ) ; spin_lock_irqsave ( & timr -> it_lock , flags ) ; timr -> it_active = 0 ; if ( timr -> it_interval != 0 ) si_private = ++ timr -> it_requeue_pending ; if ( posix_timer_event ( timr , si_private ) ) { if ( timr -> it_interval != 0 ) { ktime_t now = hrtimer_cb_get_time ( timer ) ; # ifdef CONFIG_HIGH_RES_TIMERS { ktime_t kj = NSEC_PER_SEC / HZ ; if ( timr -> it_interval < kj ) now = ktime_add ( now , kj ) ; } # endif timr -> it_overrun += ( unsigned int ) hrtimer_forward ( timer , now , timr -> it_interval ) ; ret = HRTIMER_RESTART ; ++ timr -> it_requeue_pending ; timr -> it_active = 1 ; } } unlock_timer ( timr , flags ) ; return ret ; }\n", "\n", "1: CWE-190 static void common_hrtimer_rearm ( struct k_itimer * timr ) { struct hrtimer * timer = & timr -> it . real . timer ; if ( ! timr -> it_interval ) return ; timr -> it_overrun += ( unsigned int ) hrtimer_forward ( timer , timer -> base -> get_time ( ) , timr -> it_interval ) ; hrtimer_restart ( timer ) ; }\n", "\n", "\n", "Target: if ( ! list_empty ( & asoc -> asocs ) ) { list_del\n", "\n", "Sources:\n", "0: CWE-000 void sctp_association_free ( struct sctp_association * asoc ) { struct sock * sk = asoc -> base . sk ; struct sctp_transport * transport ; struct list_head * pos , * temp ; int i ; if ( ! asoc -> temp ) { list_del ( & asoc -> asocs ) ; if ( sctp_style ( sk , TCP ) && sctp_sstate ( sk , LISTENING ) ) sk -> sk_ack_backlog -- ; } asoc -> base . dead = true ; sctp_outq_free ( & asoc -> outqueue ) ; sctp_ulpq_free ( & asoc -> ulpq ) ; sctp_inq_free ( & asoc -> base . inqueue ) ; sctp_tsnmap_free ( & asoc -> peer . tsn_map ) ; sctp_ssnmap_free ( asoc -> ssnmap ) ; sctp_bind_addr_free ( & asoc -> base . bind_addr ) ; for ( i = SCTP_EVENT_TIMEOUT_NONE ; i < SCTP_NUM_TIMEOUT_TYPES ; ++ i ) { if ( del_timer ( & asoc -> timers [ i ] ) ) sctp_association_put ( asoc ) ; } kfree ( asoc -> peer . cookie ) ; kfree ( asoc -> peer . peer_random ) ; kfree ( asoc -> peer . peer_chunks ) ; kfree ( asoc -> peer . peer_hmacs ) ; list_for_each_safe ( pos , temp , & asoc -> peer . transport_addr_list ) { transport = list_entry ( pos , struct sctp_transport , transports ) ; list_del_rcu ( pos ) ; sctp_transport_free ( transport ) ; } asoc -> peer . transport_count = 0 ; sctp_asconf_queue_teardown ( asoc ) ; if ( asoc -> asconf_addr_del_pending != NULL ) kfree ( asoc -> asconf_addr_del_pending ) ; sctp_auth_destroy_keys ( & asoc -> endpoint_shared_keys ) ; sctp_auth_key_put ( asoc -> asoc_shared_key ) ; sctp_association_put ( asoc ) ; }\n", "\n", "1: CWE-20 void sctp_association_free ( struct sctp_association * asoc ) { struct sock * sk = asoc -> base . sk ; struct sctp_transport * transport ; struct list_head * pos , * temp ; int i ; if ( ! asoc -> temp ) { list_del ( & asoc -> asocs ) ; if ( sctp_style ( sk , TCP ) && sctp_sstate ( sk , LISTENING ) ) sk -> sk_ack_backlog -- ; } asoc -> base . dead = true ; sctp_outq_free ( & asoc -> outqueue ) ; sctp_ulpq_free ( & asoc -> ulpq ) ; sctp_inq_free ( & asoc -> base . inqueue ) ; sctp_tsnmap_free ( & asoc -> peer . tsn_map ) ; sctp_ssnmap_free ( asoc -> ssnmap ) ; sctp_bind_addr_free ( & asoc -> base . bind_addr ) ; for ( i = SCTP_EVENT_TIMEOUT_NONE ; i < SCTP_NUM_TIMEOUT_TYPES ; ++ i ) { if ( del_timer ( & asoc -> timers [ i ] ) ) sctp_association_put ( asoc ) ; } kfree ( asoc -> peer . cookie ) ; kfree ( asoc -> peer . peer_random ) ; kfree ( asoc -> peer . peer_chunks ) ; kfree ( asoc -> peer . peer_hmacs ) ; list_for_each_safe ( pos , temp , & asoc -> peer . transport_addr_list ) { transport = list_entry ( pos , struct sctp_transport , transports ) ; list_del_rcu ( pos ) ; sctp_transport_free ( transport ) ; } asoc -> peer . transport_count = 0 ; sctp_asconf_queue_teardown ( asoc ) ; if ( asoc -> asconf_addr_del_pending != NULL ) kfree ( asoc -> asconf_addr_del_pending ) ; sctp_auth_destroy_keys ( & asoc -> endpoint_shared_keys ) ; sctp_auth_key_put ( asoc -> asoc_shared_key ) ; sctp_association_put ( asoc ) ; }\n", "\n", "\n", "Target: slow ) ; cond_resched ( ) ; msg ->\n", "\n", "Sources:\n", "0: CWE-399 int udpv6_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; int is_udp4 ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ipv6_recv_error ( sk , msg , len , addr_len ) ; if ( np -> rxpmtu && np -> rxopt . bits . rxpmtu ) return ipv6_recv_rxpmtu ( sk , msg , len , addr_len ) ; try_again : skb = __skb_recv_datagram ( sk , flags | ( noblock ? MSG_DONTWAIT : 0 ) , & peeked , & off , & err ) ; if ( ! skb ) goto out ; ulen = skb -> len - sizeof ( struct udphdr ) ; copied = len ; if ( copied > ulen ) copied = ulen ; else if ( copied < ulen ) msg -> msg_flags |= MSG_TRUNC ; is_udp4 = ( skb -> protocol == htons ( ETH_P_IP ) ) ; if ( copied < ulen || UDP_SKB_CB ( skb ) -> partial_cov ) { if ( udp_lib_checksum_complete ( skb ) ) goto csum_copy_err ; } if ( skb_csum_unnecessary ( skb ) ) err = skb_copy_datagram_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udpv6_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) { if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; } sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) { DECLARE_SOCKADDR ( struct sockaddr_in6 * , sin6 , msg -> msg_name ) ; sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = udp_hdr ( skb ) -> source ; sin6 -> sin6_flowinfo = 0 ; if ( is_udp4 ) { ipv6_addr_set_v4mapped ( ip_hdr ( skb ) -> saddr , & sin6 -> sin6_addr ) ; sin6 -> sin6_scope_id = 0 ; } else { sin6 -> sin6_addr = ipv6_hdr ( skb ) -> saddr ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , inet6_iif ( skb ) ) ; } * addr_len = sizeof ( * sin6 ) ; } if ( np -> rxopt . all ) ip6_datagram_recv_common_ctl ( sk , msg , skb ) ; if ( is_udp4 ) { if ( inet -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; } else { if ( np -> rxopt . all ) ip6_datagram_recv_specific_ctl ( sk , msg , skb ) ; } err = copied ; if ( flags & MSG_TRUNC ) err = ulen ; out_free : skb_free_datagram_locked ( sk , skb ) ; out : return err ; csum_copy_err : slow = lock_sock_fast ( sk ) ; if ( ! skb_kill_datagram ( sk , skb , flags ) ) { if ( is_udp4 ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } else { UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } } unlock_sock_fast ( sk , slow ) ; if ( noblock ) return - EAGAIN ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; }\n", "\n", "1: CWE-399 int udp_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; DECLARE_SOCKADDR ( struct sockaddr_in * , sin , msg -> msg_name ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ip_recv_error ( sk , msg , len , addr_len ) ; try_again : skb = __skb_recv_datagram ( sk , flags | ( noblock ? MSG_DONTWAIT : 0 ) , & peeked , & off , & err ) ; if ( ! skb ) goto out ; ulen = skb -> len - sizeof ( struct udphdr ) ; copied = len ; if ( copied > ulen ) copied = ulen ; else if ( copied < ulen ) msg -> msg_flags |= MSG_TRUNC ; if ( copied < ulen || UDP_SKB_CB ( skb ) -> partial_cov ) { if ( udp_lib_checksum_complete ( skb ) ) goto csum_copy_err ; } if ( skb_csum_unnecessary ( skb ) ) err = skb_copy_datagram_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udp_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( sin ) { sin -> sin_family = AF_INET ; sin -> sin_port = udp_hdr ( skb ) -> source ; sin -> sin_addr . s_addr = ip_hdr ( skb ) -> saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; * addr_len = sizeof ( * sin ) ; } if ( inet -> cmsg_flags ) ip_cmsg_recv_offset ( msg , skb , sizeof ( struct udphdr ) ) ; err = copied ; if ( flags & MSG_TRUNC ) err = ulen ; out_free : skb_free_datagram_locked ( sk , skb ) ; out : return err ; csum_copy_err : slow = lock_sock_fast ( sk ) ; if ( ! skb_kill_datagram ( sk , skb , flags ) ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } unlock_sock_fast ( sk , slow ) ; if ( noblock ) return - EAGAIN ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; }\n", "\n", "\n", "Target: ; if ( addr -> l2tp_family ; if ( ! sock_flag ( sk , SOCK_ZAPPED ) ) goto out_unlock ; if (\n", "\n", "Sources:\n", "0: CWE-264 static int l2tp_ip6_bind ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sockaddr_l2tpip6 * addr = ( struct sockaddr_l2tpip6 * ) uaddr ; struct net * net = sock_net ( sk ) ; __be32 v4addr = 0 ; int addr_type ; int err ; if ( ! sock_flag ( sk , SOCK_ZAPPED ) ) return - EINVAL ; if ( addr -> l2tp_family != AF_INET6 ) return - EINVAL ; if ( addr_len < sizeof ( * addr ) ) return - EINVAL ; addr_type = ipv6_addr_type ( & addr -> l2tp_addr ) ; if ( addr_type == IPV6_ADDR_MAPPED ) return - EADDRNOTAVAIL ; if ( addr_type & IPV6_ADDR_MULTICAST ) return - EADDRNOTAVAIL ; err = - EADDRINUSE ; read_lock_bh ( & l2tp_ip6_lock ) ; if ( __l2tp_ip6_bind_lookup ( net , & addr -> l2tp_addr , sk -> sk_bound_dev_if , addr -> l2tp_conn_id ) ) goto out_in_use ; read_unlock_bh ( & l2tp_ip6_lock ) ; lock_sock ( sk ) ; err = - EINVAL ; if ( sk -> sk_state != TCP_CLOSE ) goto out_unlock ; rcu_read_lock ( ) ; if ( addr_type != IPV6_ADDR_ANY ) { struct net_device * dev = NULL ; if ( addr_type & IPV6_ADDR_LINKLOCAL ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && addr -> l2tp_scope_id ) { sk -> sk_bound_dev_if = addr -> l2tp_scope_id ; } if ( ! sk -> sk_bound_dev_if ) goto out_unlock_rcu ; err = - ENODEV ; dev = dev_get_by_index_rcu ( sock_net ( sk ) , sk -> sk_bound_dev_if ) ; if ( ! dev ) goto out_unlock_rcu ; } v4addr = LOOPBACK4_IPV6 ; err = - EADDRNOTAVAIL ; if ( ! ipv6_chk_addr ( sock_net ( sk ) , & addr -> l2tp_addr , dev , 0 ) ) goto out_unlock_rcu ; } rcu_read_unlock ( ) ; inet -> inet_rcv_saddr = inet -> inet_saddr = v4addr ; sk -> sk_v6_rcv_saddr = addr -> l2tp_addr ; np -> saddr = addr -> l2tp_addr ; l2tp_ip6_sk ( sk ) -> conn_id = addr -> l2tp_conn_id ; write_lock_bh ( & l2tp_ip6_lock ) ; sk_add_bind_node ( sk , & l2tp_ip6_bind_table ) ; sk_del_node_init ( sk ) ; write_unlock_bh ( & l2tp_ip6_lock ) ; sock_reset_flag ( sk , SOCK_ZAPPED ) ; release_sock ( sk ) ; return 0 ; out_unlock_rcu : rcu_read_unlock ( ) ; out_unlock : release_sock ( sk ) ; return err ; out_in_use : read_unlock_bh ( & l2tp_ip6_lock ) ; return err ; }\n", "\n", "1: CWE-416 static int l2tp_ip6_bind ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sockaddr_l2tpip6 * addr = ( struct sockaddr_l2tpip6 * ) uaddr ; struct net * net = sock_net ( sk ) ; __be32 v4addr = 0 ; int addr_type ; int err ; if ( ! sock_flag ( sk , SOCK_ZAPPED ) ) return - EINVAL ; if ( addr -> l2tp_family != AF_INET6 ) return - EINVAL ; if ( addr_len < sizeof ( * addr ) ) return - EINVAL ; addr_type = ipv6_addr_type ( & addr -> l2tp_addr ) ; if ( addr_type == IPV6_ADDR_MAPPED ) return - EADDRNOTAVAIL ; if ( addr_type & IPV6_ADDR_MULTICAST ) return - EADDRNOTAVAIL ; err = - EADDRINUSE ; read_lock_bh ( & l2tp_ip6_lock ) ; if ( __l2tp_ip6_bind_lookup ( net , & addr -> l2tp_addr , sk -> sk_bound_dev_if , addr -> l2tp_conn_id ) ) goto out_in_use ; read_unlock_bh ( & l2tp_ip6_lock ) ; lock_sock ( sk ) ; err = - EINVAL ; if ( sk -> sk_state != TCP_CLOSE ) goto out_unlock ; rcu_read_lock ( ) ; if ( addr_type != IPV6_ADDR_ANY ) { struct net_device * dev = NULL ; if ( addr_type & IPV6_ADDR_LINKLOCAL ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && addr -> l2tp_scope_id ) { sk -> sk_bound_dev_if = addr -> l2tp_scope_id ; } if ( ! sk -> sk_bound_dev_if ) goto out_unlock_rcu ; err = - ENODEV ; dev = dev_get_by_index_rcu ( sock_net ( sk ) , sk -> sk_bound_dev_if ) ; if ( ! dev ) goto out_unlock_rcu ; } v4addr = LOOPBACK4_IPV6 ; err = - EADDRNOTAVAIL ; if ( ! ipv6_chk_addr ( sock_net ( sk ) , & addr -> l2tp_addr , dev , 0 ) ) goto out_unlock_rcu ; } rcu_read_unlock ( ) ; inet -> inet_rcv_saddr = inet -> inet_saddr = v4addr ; sk -> sk_v6_rcv_saddr = addr -> l2tp_addr ; np -> saddr = addr -> l2tp_addr ; l2tp_ip6_sk ( sk ) -> conn_id = addr -> l2tp_conn_id ; write_lock_bh ( & l2tp_ip6_lock ) ; sk_add_bind_node ( sk , & l2tp_ip6_bind_table ) ; sk_del_node_init ( sk ) ; write_unlock_bh ( & l2tp_ip6_lock ) ; sock_reset_flag ( sk , SOCK_ZAPPED ) ; release_sock ( sk ) ; return 0 ; out_unlock_rcu : rcu_read_unlock ( ) ; out_unlock : release_sock ( sk ) ; return err ; out_in_use : read_unlock_bh ( & l2tp_ip6_lock ) ; return err ; }\n", "\n", "\n", "Target: ) ) ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ) ;\n", "\n", "Sources:\n", "0: CWE-000 static int userfaultfd_unregister ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_range uffdio_unregister ; unsigned long new_flags ; bool found ; unsigned long start , end , vma_end ; const void __user * buf = ( void __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_unregister , buf , sizeof ( uffdio_unregister ) ) ) goto out ; ret = validate_range ( mm , uffdio_unregister . start , uffdio_unregister . len ) ; if ( ret ) goto out ; start = uffdio_unregister . start ; end = start + uffdio_unregister . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; ret = - EINVAL ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; if ( ! vma -> vm_userfaultfd_ctx . ctx ) goto skip ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; if ( userfaultfd_missing ( vma ) ) { struct userfaultfd_wake_range range ; range . start = start ; range . len = vma_end - start ; wake_userfault ( vma -> vm_userfaultfd_ctx . ctx , & range ) ; } new_flags = vma -> vm_flags & ~ ( VM_UFFD_MISSING | VM_UFFD_WP ) ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , NULL_VM_UFFD_CTX ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; out : return ret ; }\n", "\n", "1: CWE-863 static int userfaultfd_unregister ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_range uffdio_unregister ; unsigned long new_flags ; bool found ; unsigned long start , end , vma_end ; const void __user * buf = ( void __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_unregister , buf , sizeof ( uffdio_unregister ) ) ) goto out ; ret = validate_range ( mm , uffdio_unregister . start , uffdio_unregister . len ) ; if ( ret ) goto out ; start = uffdio_unregister . start ; end = start + uffdio_unregister . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; ret = - EINVAL ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; if ( ! vma -> vm_userfaultfd_ctx . ctx ) goto skip ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; if ( userfaultfd_missing ( vma ) ) { struct userfaultfd_wake_range range ; range . start = start ; range . len = vma_end - start ; wake_userfault ( vma -> vm_userfaultfd_ctx . ctx , & range ) ; } new_flags = vma -> vm_flags & ~ ( VM_UFFD_MISSING | VM_UFFD_WP ) ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , NULL_VM_UFFD_CTX ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; out : return ret ; }\n", "\n", "\n", "Target: int ion_handle_put ( ; ret = ion_handle_put_nolock ( handle ) ; mutex_unlock\n", "\n", "Sources:\n", "0: CWE-264 static int ion_handle_put ( struct ion_handle * handle ) { struct ion_client * client = handle -> client ; int ret ; mutex_lock ( & client -> lock ) ; ret = kref_put ( & handle -> ref , ion_handle_destroy ) ; mutex_unlock ( & client -> lock ) ; return ret ; }\n", "\n", "1: CWE-416 static int ion_handle_put ( struct ion_handle * handle ) { struct ion_client * client = handle -> client ; int ret ; mutex_lock ( & client -> lock ) ; ret = kref_put ( & handle -> ref , ion_handle_destroy ) ; mutex_unlock ( & client -> lock ) ; return ret ; }\n", "\n", "\n", "Target: ; gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; OM_uint32 minor_stat prime_arg ) ; exit_func : service_name ) ; free_server_handle ( handle\n", "\n", "Sources:\n", "0: CWE-772 generic_ret * modify_principal_2_svc ( mprinc_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; restriction_t * rp ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> rec . principal , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_MODIFY , arg -> rec . principal , & rp ) || kadm5int_acl_impose_restrictions ( handle -> context , & arg -> rec , & arg -> mask , rp ) ) { ret . code = KADM5_AUTH_MODIFY ; log_unauth ( \"kadm5_modify_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_modify_principal ( ( void * ) handle , & arg -> rec , arg -> mask ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_modify_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "1: CWE-772 generic_ret * delete_principal_2_svc ( dprinc_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_DELETE , arg -> princ , NULL ) ) { ret . code = KADM5_AUTH_DELETE ; log_unauth ( \"kadm5_delete_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_delete_principal ( ( void * ) handle , arg -> princ ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_delete_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "2: CWE-772 gprinc_ret * get_principal_2_svc ( gprinc_arg * arg , struct svc_req * rqstp ) { static gprinc_ret ret ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gprinc_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; funcname = \"kadm5_get_principal\" ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) && ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_INQUIRE , arg -> princ , NULL ) ) ) { ret . code = KADM5_AUTH_GET ; log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_get_principal ( handle , arg -> princ , & ret . rec , arg -> mask ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "3: CWE-772 generic_ret * setkey_principal_2_svc ( setkey_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_SETKEY , arg -> princ , NULL ) ) { ret . code = kadm5_setkey_principal ( ( void * ) handle , arg -> princ , arg -> keyblocks , arg -> n_keys ) ; } else { log_unauth ( \"kadm5_setkey_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_SETKEY ; } if ( ret . code != KADM5_AUTH_SETKEY ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_setkey_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "4: CWE-772 generic_ret * set_string_2_svc ( sstring_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_MODIFY , arg -> princ , NULL ) ) { ret . code = KADM5_AUTH_MODIFY ; log_unauth ( \"kadm5_mod_strings\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_set_string ( ( void * ) handle , arg -> princ , arg -> key , arg -> value ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_mod_strings\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "5: CWE-772 generic_ret * purgekeys_2_svc ( purgekeys_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; funcname = \"kadm5_purgekeys\" ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) && ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_MODIFY , arg -> princ , NULL ) ) ) { ret . code = KADM5_AUTH_MODIFY ; log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_purgekeys ( ( void * ) handle , arg -> princ , arg -> keepkvno ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "6: CWE-772 generic_ret * setv4key_principal_2_svc ( setv4key_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_SETKEY , arg -> princ , NULL ) ) { ret . code = kadm5_setv4key_principal ( ( void * ) handle , arg -> princ , arg -> keyblock ) ; } else { log_unauth ( \"kadm5_setv4key_principal\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_SETKEY ; } if ( ret . code != KADM5_AUTH_SETKEY ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_setv4key_principal\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "\n", "Target: ) ) ; rcu_read_lock ( ) ; ( fl6 , rcu_dereference ( np -> opt ) final ) ; rcu_read_unlock ( ) ;\n", "\n", "Sources:\n", "0: CWE-416 static struct dst_entry * inet6_csk_route_socket ( struct sock * sk , struct flowi6 * fl6 ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * final_p , final ; struct dst_entry * dst ; memset ( fl6 , 0 , sizeof ( * fl6 ) ) ; fl6 -> flowi6_proto = sk -> sk_protocol ; fl6 -> daddr = sk -> sk_v6_daddr ; fl6 -> saddr = np -> saddr ; fl6 -> flowlabel = np -> flow_label ; IP6_ECN_flow_xmit ( sk , fl6 -> flowlabel ) ; fl6 -> flowi6_oif = sk -> sk_bound_dev_if ; fl6 -> flowi6_mark = sk -> sk_mark ; fl6 -> fl6_sport = inet -> inet_sport ; fl6 -> fl6_dport = inet -> inet_dport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( fl6 ) ) ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; dst = __inet6_csk_dst_check ( sk , np -> dst_cookie ) ; if ( ! dst ) { dst = ip6_dst_lookup_flow ( sk , fl6 , final_p ) ; if ( ! IS_ERR ( dst ) ) __inet6_csk_dst_store ( sk , dst , NULL , NULL ) ; } return dst ; }\n", "\n", "1: CWE-264 static struct dst_entry * inet6_csk_route_socket ( struct sock * sk , struct flowi6 * fl6 ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * final_p , final ; struct dst_entry * dst ; memset ( fl6 , 0 , sizeof ( * fl6 ) ) ; fl6 -> flowi6_proto = sk -> sk_protocol ; fl6 -> daddr = sk -> sk_v6_daddr ; fl6 -> saddr = np -> saddr ; fl6 -> flowlabel = np -> flow_label ; IP6_ECN_flow_xmit ( sk , fl6 -> flowlabel ) ; fl6 -> flowi6_oif = sk -> sk_bound_dev_if ; fl6 -> flowi6_mark = sk -> sk_mark ; fl6 -> fl6_sport = inet -> inet_sport ; fl6 -> fl6_dport = inet -> inet_dport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( fl6 ) ) ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; dst = __inet6_csk_dst_check ( sk , np -> dst_cookie ) ; if ( ! dst ) { dst = ip6_dst_lookup_flow ( sk , fl6 , final_p ) ; if ( ! IS_ERR ( dst ) ) __inet6_csk_dst_store ( sk , dst , NULL , NULL ) ; } return dst ; }\n", "\n", "\n", "Target: -> ir_v6_rmt_addr ; rcu_read_lock ( ) ; ( fl6 , rcu_dereference ( np -> opt ) final ) ; rcu_read_unlock ( ) ;\n", "\n", "Sources:\n", "0: CWE-264 struct dst_entry * inet6_csk_route_req ( const struct sock * sk , struct flowi6 * fl6 , const struct request_sock * req , u8 proto ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; const struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * final_p , final ; struct dst_entry * dst ; memset ( fl6 , 0 , sizeof ( * fl6 ) ) ; fl6 -> flowi6_proto = proto ; fl6 -> daddr = ireq -> ir_v6_rmt_addr ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; fl6 -> saddr = ireq -> ir_v6_loc_addr ; fl6 -> flowi6_oif = ireq -> ir_iif ; fl6 -> flowi6_mark = ireq -> ir_mark ; fl6 -> fl6_dport = ireq -> ir_rmt_port ; fl6 -> fl6_sport = htons ( ireq -> ir_num ) ; security_req_classify_flow ( req , flowi6_to_flowi ( fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , fl6 , final_p ) ; if ( IS_ERR ( dst ) ) return NULL ; return dst ; }\n", "\n", "1: CWE-416 struct dst_entry * inet6_csk_route_req ( const struct sock * sk , struct flowi6 * fl6 , const struct request_sock * req , u8 proto ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; const struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * final_p , final ; struct dst_entry * dst ; memset ( fl6 , 0 , sizeof ( * fl6 ) ) ; fl6 -> flowi6_proto = proto ; fl6 -> daddr = ireq -> ir_v6_rmt_addr ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; fl6 -> saddr = ireq -> ir_v6_loc_addr ; fl6 -> flowi6_oif = ireq -> ir_iif ; fl6 -> flowi6_mark = ireq -> ir_mark ; fl6 -> fl6_dport = ireq -> ir_rmt_port ; fl6 -> fl6_sport = htons ( ireq -> ir_num ) ; security_req_classify_flow ( req , flowi6_to_flowi ( fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , fl6 , final_p ) ; if ( IS_ERR ( dst ) ) return NULL ; return dst ; }\n", "\n", "\n", "Target: req_u -> req ; lock_sock ( sk ) out ; } spin_lock ( & ) ; } if ( pg_vec ) free_pg_vec ( pg_vec , order , req -> tp_block_nr ) ; out : sk ) ; return err ;\n", "\n", "Sources:\n", "0: CWE-416 static int packet_set_ring ( struct sock * sk , union tpacket_req_u * req_u , int closing , int tx_ring ) { struct pgv * pg_vec = NULL ; struct packet_sock * po = pkt_sk ( sk ) ; int was_running , order = 0 ; struct packet_ring_buffer * rb ; struct sk_buff_head * rb_queue ; __be16 num ; int err = - EINVAL ; struct tpacket_req * req = & req_u -> req ; if ( ! closing && tx_ring && ( po -> tp_version > TPACKET_V2 ) ) { net_warn_ratelimited ( \"Tx-ringisnotsupported.\\\\n\" ) ; goto out ; } rb = tx_ring ? & po -> tx_ring : & po -> rx_ring ; rb_queue = tx_ring ? & sk -> sk_write_queue : & sk -> sk_receive_queue ; err = - EBUSY ; if ( ! closing ) { if ( atomic_read ( & po -> mapped ) ) goto out ; if ( packet_read_pending ( rb ) ) goto out ; } if ( req -> tp_block_nr ) { err = - EBUSY ; if ( unlikely ( rb -> pg_vec ) ) goto out ; switch ( po -> tp_version ) { case TPACKET_V1 : po -> tp_hdrlen = TPACKET_HDRLEN ; break ; case TPACKET_V2 : po -> tp_hdrlen = TPACKET2_HDRLEN ; break ; case TPACKET_V3 : po -> tp_hdrlen = TPACKET3_HDRLEN ; break ; } err = - EINVAL ; if ( unlikely ( ( int ) req -> tp_block_size <= 0 ) ) goto out ; if ( unlikely ( ! PAGE_ALIGNED ( req -> tp_block_size ) ) ) goto out ; if ( po -> tp_version >= TPACKET_V3 && ( int ) ( req -> tp_block_size - BLK_PLUS_PRIV ( req_u -> req3 . tp_sizeof_priv ) ) <= 0 ) goto out ; if ( unlikely ( req -> tp_frame_size < po -> tp_hdrlen + po -> tp_reserve ) ) goto out ; if ( unlikely ( req -> tp_frame_size & ( TPACKET_ALIGNMENT - 1 ) ) ) goto out ; rb -> frames_per_block = req -> tp_block_size / req -> tp_frame_size ; if ( unlikely ( rb -> frames_per_block == 0 ) ) goto out ; if ( unlikely ( ( rb -> frames_per_block * req -> tp_block_nr ) != req -> tp_frame_nr ) ) goto out ; err = - ENOMEM ; order = get_order ( req -> tp_block_size ) ; pg_vec = alloc_pg_vec ( req , order ) ; if ( unlikely ( ! pg_vec ) ) goto out ; switch ( po -> tp_version ) { case TPACKET_V3 : if ( ! tx_ring ) init_prb_bdqc ( po , rb , pg_vec , req_u ) ; break ; default : break ; } } else { err = - EINVAL ; if ( unlikely ( req -> tp_frame_nr ) ) goto out ; } lock_sock ( sk ) ; spin_lock ( & po -> bind_lock ) ; was_running = po -> running ; num = po -> num ; if ( was_running ) { po -> num = 0 ; __unregister_prot_hook ( sk , false ) ; } spin_unlock ( & po -> bind_lock ) ; synchronize_net ( ) ; err = - EBUSY ; mutex_lock ( & po -> pg_vec_lock ) ; if ( closing || atomic_read ( & po -> mapped ) == 0 ) { err = 0 ; spin_lock_bh ( & rb_queue -> lock ) ; swap ( rb -> pg_vec , pg_vec ) ; rb -> frame_max = ( req -> tp_frame_nr - 1 ) ; rb -> head = 0 ; rb -> frame_size = req -> tp_frame_size ; spin_unlock_bh ( & rb_queue -> lock ) ; swap ( rb -> pg_vec_order , order ) ; swap ( rb -> pg_vec_len , req -> tp_block_nr ) ; rb -> pg_vec_pages = req -> tp_block_size / PAGE_SIZE ; po -> prot_hook . func = ( po -> rx_ring . pg_vec ) ? tpacket_rcv : packet_rcv ; skb_queue_purge ( rb_queue ) ; if ( atomic_read ( & po -> mapped ) ) pr_err ( \"packet_mmap:vmaisbusy:%d\\\\n\" , atomic_read ( & po -> mapped ) ) ; } mutex_unlock ( & po -> pg_vec_lock ) ; spin_lock ( & po -> bind_lock ) ; if ( was_running ) { po -> num = num ; register_prot_hook ( sk ) ; } spin_unlock ( & po -> bind_lock ) ; if ( closing && ( po -> tp_version > TPACKET_V2 ) ) { if ( ! tx_ring ) prb_shutdown_retire_blk_timer ( po , rb_queue ) ; } release_sock ( sk ) ; if ( pg_vec ) free_pg_vec ( pg_vec , order , req -> tp_block_nr ) ; out : return err ; }\n", "\n", "1: CWE-362 static int packet_set_ring ( struct sock * sk , union tpacket_req_u * req_u , int closing , int tx_ring ) { struct pgv * pg_vec = NULL ; struct packet_sock * po = pkt_sk ( sk ) ; int was_running , order = 0 ; struct packet_ring_buffer * rb ; struct sk_buff_head * rb_queue ; __be16 num ; int err = - EINVAL ; struct tpacket_req * req = & req_u -> req ; if ( ! closing && tx_ring && ( po -> tp_version > TPACKET_V2 ) ) { net_warn_ratelimited ( \"Tx-ringisnotsupported.\\\\n\" ) ; goto out ; } rb = tx_ring ? & po -> tx_ring : & po -> rx_ring ; rb_queue = tx_ring ? & sk -> sk_write_queue : & sk -> sk_receive_queue ; err = - EBUSY ; if ( ! closing ) { if ( atomic_read ( & po -> mapped ) ) goto out ; if ( packet_read_pending ( rb ) ) goto out ; } if ( req -> tp_block_nr ) { err = - EBUSY ; if ( unlikely ( rb -> pg_vec ) ) goto out ; switch ( po -> tp_version ) { case TPACKET_V1 : po -> tp_hdrlen = TPACKET_HDRLEN ; break ; case TPACKET_V2 : po -> tp_hdrlen = TPACKET2_HDRLEN ; break ; case TPACKET_V3 : po -> tp_hdrlen = TPACKET3_HDRLEN ; break ; } err = - EINVAL ; if ( unlikely ( ( int ) req -> tp_block_size <= 0 ) ) goto out ; if ( unlikely ( ! PAGE_ALIGNED ( req -> tp_block_size ) ) ) goto out ; if ( po -> tp_version >= TPACKET_V3 && ( int ) ( req -> tp_block_size - BLK_PLUS_PRIV ( req_u -> req3 . tp_sizeof_priv ) ) <= 0 ) goto out ; if ( unlikely ( req -> tp_frame_size < po -> tp_hdrlen + po -> tp_reserve ) ) goto out ; if ( unlikely ( req -> tp_frame_size & ( TPACKET_ALIGNMENT - 1 ) ) ) goto out ; rb -> frames_per_block = req -> tp_block_size / req -> tp_frame_size ; if ( unlikely ( rb -> frames_per_block == 0 ) ) goto out ; if ( unlikely ( ( rb -> frames_per_block * req -> tp_block_nr ) != req -> tp_frame_nr ) ) goto out ; err = - ENOMEM ; order = get_order ( req -> tp_block_size ) ; pg_vec = alloc_pg_vec ( req , order ) ; if ( unlikely ( ! pg_vec ) ) goto out ; switch ( po -> tp_version ) { case TPACKET_V3 : if ( ! tx_ring ) init_prb_bdqc ( po , rb , pg_vec , req_u ) ; break ; default : break ; } } else { err = - EINVAL ; if ( unlikely ( req -> tp_frame_nr ) ) goto out ; } lock_sock ( sk ) ; spin_lock ( & po -> bind_lock ) ; was_running = po -> running ; num = po -> num ; if ( was_running ) { po -> num = 0 ; __unregister_prot_hook ( sk , false ) ; } spin_unlock ( & po -> bind_lock ) ; synchronize_net ( ) ; err = - EBUSY ; mutex_lock ( & po -> pg_vec_lock ) ; if ( closing || atomic_read ( & po -> mapped ) == 0 ) { err = 0 ; spin_lock_bh ( & rb_queue -> lock ) ; swap ( rb -> pg_vec , pg_vec ) ; rb -> frame_max = ( req -> tp_frame_nr - 1 ) ; rb -> head = 0 ; rb -> frame_size = req -> tp_frame_size ; spin_unlock_bh ( & rb_queue -> lock ) ; swap ( rb -> pg_vec_order , order ) ; swap ( rb -> pg_vec_len , req -> tp_block_nr ) ; rb -> pg_vec_pages = req -> tp_block_size / PAGE_SIZE ; po -> prot_hook . func = ( po -> rx_ring . pg_vec ) ? tpacket_rcv : packet_rcv ; skb_queue_purge ( rb_queue ) ; if ( atomic_read ( & po -> mapped ) ) pr_err ( \"packet_mmap:vmaisbusy:%d\\\\n\" , atomic_read ( & po -> mapped ) ) ; } mutex_unlock ( & po -> pg_vec_lock ) ; spin_lock ( & po -> bind_lock ) ; if ( was_running ) { po -> num = num ; register_prot_hook ( sk ) ; } spin_unlock ( & po -> bind_lock ) ; if ( closing && ( po -> tp_version > TPACKET_V2 ) ) { if ( ! tx_ring ) prb_shutdown_retire_blk_timer ( po , rb_queue ) ; } release_sock ( sk ) ; if ( pg_vec ) free_pg_vec ( pg_vec , order , req -> tp_block_nr ) ; out : return err ; }\n", "\n", "\n", "Target: Resub * out , int depth scratch ; int result ; int Rune c ; if ( depth > MAXREC ) return - 1 ; I_END : return 0 ; case I_JUMP * out ; result = match ( pc , & scratch , depth + 1 ) ; if ( result == - 1 ) return - 1 ; if ( result == 0 ) { * scratch ; return 0 ; } pc case I_PLA : result = match ( pc flags , out , depth + 1 ) ; if ( result == - 1 ) return - 1 ; if ( result == 1 ) return 1 ; pc = * out ; result = match ( pc , & scratch , depth + 1 ) ; if ( result == - 1 ) return - 1 ; if ( result == 0 ) return 1 ; pc = 0 ) return 1 ; pc = 0 ) return 1 ; if ( ) ) return 1 ; pc = 0 ) return 1 ; if ( c ) return 1 ; pc = 0 ) return 1 ; if ( ) ) return 1 ; } else ) ) return 1 ; } pc 0 ) return 1 ; if ( ) ) return 1 ; } else ) ) return 1 ; } pc ) ) return 1 ; } else ) ) return 1 ; } if } } return 1 ; case I_EOL } } return 1 ; case I_WORD i ) return 1 ; pc = i ) return 1 ; pc = default : return 1 ; } }\n", "\n", "Sources:\n", "0: CWE-674 static int match ( Reinst * pc , const char * sp , const char * bol , int flags , Resub * out ) { Resub scratch ; int i ; Rune c ; for ( ; ; ) { switch ( pc -> opcode ) { case I_END : return 1 ; case I_JUMP : pc = pc -> x ; break ; case I_SPLIT : scratch = * out ; if ( match ( pc -> x , sp , bol , flags , & scratch ) ) { * out = scratch ; return 1 ; } pc = pc -> y ; break ; case I_PLA : if ( ! match ( pc -> x , sp , bol , flags , out ) ) return 0 ; pc = pc -> y ; break ; case I_NLA : scratch = * out ; if ( match ( pc -> x , sp , bol , flags , & scratch ) ) return 0 ; pc = pc -> y ; break ; case I_ANYNL : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; pc = pc + 1 ; break ; case I_ANY : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( isnewline ( c ) ) return 0 ; pc = pc + 1 ; break ; case I_CHAR : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) c = canon ( c ) ; if ( c != pc -> c ) return 0 ; pc = pc + 1 ; break ; case I_CCLASS : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) { if ( ! incclasscanon ( pc -> cc , canon ( c ) ) ) return 0 ; } else { if ( ! incclass ( pc -> cc , c ) ) return 0 ; } pc = pc + 1 ; break ; case I_NCCLASS : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) { if ( incclasscanon ( pc -> cc , canon ( c ) ) ) return 0 ; } else { if ( incclass ( pc -> cc , c ) ) return 0 ; } pc = pc + 1 ; break ; case I_REF : i = out -> sub [ pc -> n ] . ep - out -> sub [ pc -> n ] . sp ; if ( flags & REG_ICASE ) { if ( strncmpcanon ( sp , out -> sub [ pc -> n ] . sp , i ) ) return 0 ; } else { if ( strncmp ( sp , out -> sub [ pc -> n ] . sp , i ) ) return 0 ; } if ( i > 0 ) sp += i ; pc = pc + 1 ; break ; case I_BOL : if ( sp == bol && ! ( flags & REG_NOTBOL ) ) { pc = pc + 1 ; break ; } if ( flags & REG_NEWLINE ) { if ( sp > bol && isnewline ( sp [ - 1 ] ) ) { pc = pc + 1 ; break ; } } return 0 ; case I_EOL : if ( * sp == 0 ) { pc = pc + 1 ; break ; } if ( flags & REG_NEWLINE ) { if ( isnewline ( * sp ) ) { pc = pc + 1 ; break ; } } return 0 ; case I_WORD : i = sp > bol && iswordchar ( sp [ - 1 ] ) ; i ^= iswordchar ( sp [ 0 ] ) ; if ( ! i ) return 0 ; pc = pc + 1 ; break ; case I_NWORD : i = sp > bol && iswordchar ( sp [ - 1 ] ) ; i ^= iswordchar ( sp [ 0 ] ) ; if ( i ) return 0 ; pc = pc + 1 ; break ; case I_LPAR : out -> sub [ pc -> n ] . sp = sp ; pc = pc + 1 ; break ; case I_RPAR : out -> sub [ pc -> n ] . ep = sp ; pc = pc + 1 ; break ; default : return 0 ; } } }\n", "\n", "1: CWE-400 static int match ( Reinst * pc , const char * sp , const char * bol , int flags , Resub * out ) { Resub scratch ; int i ; Rune c ; for ( ; ; ) { switch ( pc -> opcode ) { case I_END : return 1 ; case I_JUMP : pc = pc -> x ; break ; case I_SPLIT : scratch = * out ; if ( match ( pc -> x , sp , bol , flags , & scratch ) ) { * out = scratch ; return 1 ; } pc = pc -> y ; break ; case I_PLA : if ( ! match ( pc -> x , sp , bol , flags , out ) ) return 0 ; pc = pc -> y ; break ; case I_NLA : scratch = * out ; if ( match ( pc -> x , sp , bol , flags , & scratch ) ) return 0 ; pc = pc -> y ; break ; case I_ANYNL : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; pc = pc + 1 ; break ; case I_ANY : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( isnewline ( c ) ) return 0 ; pc = pc + 1 ; break ; case I_CHAR : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) c = canon ( c ) ; if ( c != pc -> c ) return 0 ; pc = pc + 1 ; break ; case I_CCLASS : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) { if ( ! incclasscanon ( pc -> cc , canon ( c ) ) ) return 0 ; } else { if ( ! incclass ( pc -> cc , c ) ) return 0 ; } pc = pc + 1 ; break ; case I_NCCLASS : sp += chartorune ( & c , sp ) ; if ( c == 0 ) return 0 ; if ( flags & REG_ICASE ) { if ( incclasscanon ( pc -> cc , canon ( c ) ) ) return 0 ; } else { if ( incclass ( pc -> cc , c ) ) return 0 ; } pc = pc + 1 ; break ; case I_REF : i = out -> sub [ pc -> n ] . ep - out -> sub [ pc -> n ] . sp ; if ( flags & REG_ICASE ) { if ( strncmpcanon ( sp , out -> sub [ pc -> n ] . sp , i ) ) return 0 ; } else { if ( strncmp ( sp , out -> sub [ pc -> n ] . sp , i ) ) return 0 ; } if ( i > 0 ) sp += i ; pc = pc + 1 ; break ; case I_BOL : if ( sp == bol && ! ( flags & REG_NOTBOL ) ) { pc = pc + 1 ; break ; } if ( flags & REG_NEWLINE ) { if ( sp > bol && isnewline ( sp [ - 1 ] ) ) { pc = pc + 1 ; break ; } } return 0 ; case I_EOL : if ( * sp == 0 ) { pc = pc + 1 ; break ; } if ( flags & REG_NEWLINE ) { if ( isnewline ( * sp ) ) { pc = pc + 1 ; break ; } } return 0 ; case I_WORD : i = sp > bol && iswordchar ( sp [ - 1 ] ) ; i ^= iswordchar ( sp [ 0 ] ) ; if ( ! i ) return 0 ; pc = pc + 1 ; break ; case I_NWORD : i = sp > bol && iswordchar ( sp [ - 1 ] ) ; i ^= iswordchar ( sp [ 0 ] ) ; if ( i ) return 0 ; pc = pc + 1 ; break ; case I_LPAR : out -> sub [ pc -> n ] . sp = sp ; pc = pc + 1 ; break ; case I_RPAR : out -> sub [ pc -> n ] . ep = sp ; pc = pc + 1 ; break ; default : return 0 ; } } }\n", "\n", "\n", "Target: uint8 * tmp ; if ( 0 ; } tmp = ( uint8 * ) _TIFFmalloc ( cc ) ;\n", "\n", "Sources:\n", "0: CWE-119 static int fpDiff ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; uint32 bps = tif -> tif_dir . td_bitspersample / 8 ; tmsize_t wc = cc / bps ; tmsize_t count ; uint8 * cp = ( uint8 * ) cp0 ; uint8 * tmp = ( uint8 * ) _TIFFmalloc ( cc ) ; if ( ( cc % ( bps * stride ) ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , \"fpDiff\" , \"%s\" , \"(cc%(bps*stride))!=0\" ) ; return 0 ; } if ( ! tmp ) return 0 ; _TIFFmemcpy ( tmp , cp0 , cc ) ; for ( count = 0 ; count < wc ; count ++ ) { uint32 byte ; for ( byte = 0 ; byte < bps ; byte ++ ) { # if WORDS_BIGENDIAN cp [ byte * wc + count ] = tmp [ bps * count + byte ] ; # else cp [ ( bps - byte - 1 ) * wc + count ] = tmp [ bps * count + byte ] ; # endif } } _TIFFfree ( tmp ) ; cp = ( uint8 * ) cp0 ; cp += cc - stride - 1 ; for ( count = cc ; count > stride ; count -= stride ) REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] - cp [ 0 ] ) & 0xff ) ; cp -- ) return 1 ; }\n", "\n", "1: CWE-119 static int fpAcc ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; uint32 bps = tif -> tif_dir . td_bitspersample / 8 ; tmsize_t wc = cc / bps ; tmsize_t count = cc ; uint8 * cp = ( uint8 * ) cp0 ; uint8 * tmp = ( uint8 * ) _TIFFmalloc ( cc ) ; if ( cc % ( bps * stride ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , \"fpAcc\" , \"%s\" , \"cc%(bps*stride))!=0\" ) ; return 0 ; } if ( ! tmp ) return 0 ; while ( count > stride ) { REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] + cp [ 0 ] ) & 0xff ) ; cp ++ ) count -= stride ; } _TIFFmemcpy ( tmp , cp0 , cc ) ; cp = ( uint8 * ) cp0 ; for ( count = 0 ; count < wc ; count ++ ) { uint32 byte ; for ( byte = 0 ; byte < bps ; byte ++ ) { # if WORDS_BIGENDIAN cp [ bps * count + byte ] = tmp [ byte * wc + count ] ; # else cp [ bps * count + byte ] = tmp [ ( bps - byte - 1 ) * wc + count ] ; # endif } } _TIFFfree ( tmp ) ; return 1 ; }\n", "\n", "\n", "Target: 0 , \"MessagePackpackneedsinput.\" ) ; if ( ! lua_checkstack ( L , nargs ) ) return luaL_argerror ( L , 0 , \"ToomanyargumentsforMessagePackpack.\"\n", "\n", "Sources:\n", "0: CWE-119 int mp_pack ( lua_State * L ) { int nargs = lua_gettop ( L ) ; int i ; mp_buf * buf ; if ( nargs == 0 ) return luaL_argerror ( L , 0 , \"MessagePackpackneedsinput.\" ) ; buf = mp_buf_new ( L ) ; for ( i = 1 ; i <= nargs ; i ++ ) { lua_pushvalue ( L , i ) ; mp_encode_lua_type ( L , buf , 0 ) ; lua_pushlstring ( L , ( char * ) buf -> b , buf -> len ) ; buf -> free += buf -> len ; buf -> len = 0 ; } mp_buf_free ( L , buf ) ; lua_concat ( L , nargs ) ; return 1 ; }\n", "\n", "1: CWE-787 int mp_pack ( lua_State * L ) { int nargs = lua_gettop ( L ) ; int i ; mp_buf * buf ; if ( nargs == 0 ) return luaL_argerror ( L , 0 , \"MessagePackpackneedsinput.\" ) ; buf = mp_buf_new ( L ) ; for ( i = 1 ; i <= nargs ; i ++ ) { lua_pushvalue ( L , i ) ; mp_encode_lua_type ( L , buf , 0 ) ; lua_pushlstring ( L , ( char * ) buf -> b , buf -> len ) ; buf -> free += buf -> len ; buf -> len = 0 ; } mp_buf_free ( L , buf ) ; lua_concat ( L , nargs ) ; return 1 ; }\n", "\n", "\n", "Target: return res ; size_t alloc_size = 0 ; if ( MUL_OVERFLOW ( sizeof ( TEE_Attribute ) , num_params , & alloc_size ) ) return TEE_ERROR_OVERFLOW ; = malloc ( alloc_size ) ; if\n", "\n", "Sources:\n", "0: CWE-119 TEE_Result syscall_asymm_verify ( unsigned long state , const struct utee_attribute * usr_params , size_t num_params , const void * data , size_t data_len , const void * sig , size_t sig_len ) { TEE_Result res ; struct tee_cryp_state * cs ; struct tee_ta_session * sess ; struct tee_obj * o ; size_t hash_size ; int salt_len = 0 ; TEE_Attribute * params = NULL ; uint32_t hash_algo ; struct user_ta_ctx * utc ; res = tee_ta_get_current_session ( & sess ) ; if ( res != TEE_SUCCESS ) return res ; utc = to_user_ta_ctx ( sess -> ctx ) ; res = tee_svc_cryp_get_state ( sess , tee_svc_uref_to_vaddr ( state ) , & cs ) ; if ( res != TEE_SUCCESS ) return res ; if ( cs -> mode != TEE_MODE_VERIFY ) return TEE_ERROR_BAD_PARAMETERS ; res = tee_mmu_check_access_rights ( utc , TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_ANY_OWNER , ( uaddr_t ) data , data_len ) ; if ( res != TEE_SUCCESS ) return res ; res = tee_mmu_check_access_rights ( utc , TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_ANY_OWNER , ( uaddr_t ) sig , sig_len ) ; if ( res != TEE_SUCCESS ) return res ; params = malloc ( sizeof ( TEE_Attribute ) * num_params ) ; if ( ! params ) return TEE_ERROR_OUT_OF_MEMORY ; res = copy_in_attrs ( utc , usr_params , num_params , params ) ; if ( res != TEE_SUCCESS ) goto out ; res = tee_obj_get ( utc , cs -> key1 , & o ) ; if ( res != TEE_SUCCESS ) goto out ; if ( ( o -> info . handleFlags & TEE_HANDLE_FLAG_INITIALIZED ) == 0 ) { res = TEE_ERROR_BAD_PARAMETERS ; goto out ; } switch ( TEE_ALG_GET_MAIN_ALG ( cs -> algo ) ) { case TEE_MAIN_ALGO_RSA : if ( cs -> algo != TEE_ALG_RSASSA_PKCS1_V1_5 ) { hash_algo = TEE_DIGEST_HASH_TO_ALGO ( cs -> algo ) ; res = tee_hash_get_digest_size ( hash_algo , & hash_size ) ; if ( res != TEE_SUCCESS ) break ; if ( data_len != hash_size ) { res = TEE_ERROR_BAD_PARAMETERS ; break ; } salt_len = pkcs1_get_salt_len ( params , num_params , hash_size ) ; } res = crypto_acipher_rsassa_verify ( cs -> algo , o -> attr , salt_len , data , data_len , sig , sig_len ) ; break ; case TEE_MAIN_ALGO_DSA : hash_algo = TEE_DIGEST_HASH_TO_ALGO ( cs -> algo ) ; res = tee_hash_get_digest_size ( hash_algo , & hash_size ) ; if ( res != TEE_SUCCESS ) break ; if ( data_len > hash_size ) { res = TEE_ERROR_BAD_PARAMETERS ; break ; } res = crypto_acipher_dsa_verify ( cs -> algo , o -> attr , data , data_len , sig , sig_len ) ; break ; case TEE_MAIN_ALGO_ECDSA : res = crypto_acipher_ecc_verify ( cs -> algo , o -> attr , data , data_len , sig , sig_len ) ; break ; default : res = TEE_ERROR_NOT_SUPPORTED ; } out : free ( params ) ; return res ; }\n", "\n", "1: CWE-119 TEE_Result syscall_asymm_operate ( unsigned long state , const struct utee_attribute * usr_params , size_t num_params , const void * src_data , size_t src_len , void * dst_data , uint64_t * dst_len ) { TEE_Result res ; struct tee_cryp_state * cs ; struct tee_ta_session * sess ; uint64_t dlen64 ; size_t dlen ; struct tee_obj * o ; void * label = NULL ; size_t label_len = 0 ; size_t n ; int salt_len ; TEE_Attribute * params = NULL ; struct user_ta_ctx * utc ; res = tee_ta_get_current_session ( & sess ) ; if ( res != TEE_SUCCESS ) return res ; utc = to_user_ta_ctx ( sess -> ctx ) ; res = tee_svc_cryp_get_state ( sess , tee_svc_uref_to_vaddr ( state ) , & cs ) ; if ( res != TEE_SUCCESS ) return res ; res = tee_mmu_check_access_rights ( utc , TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_ANY_OWNER , ( uaddr_t ) src_data , src_len ) ; if ( res != TEE_SUCCESS ) return res ; res = tee_svc_copy_from_user ( & dlen64 , dst_len , sizeof ( dlen64 ) ) ; if ( res != TEE_SUCCESS ) return res ; dlen = dlen64 ; res = tee_mmu_check_access_rights ( utc , TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE | TEE_MEMORY_ACCESS_ANY_OWNER , ( uaddr_t ) dst_data , dlen ) ; if ( res != TEE_SUCCESS ) return res ; params = malloc ( sizeof ( TEE_Attribute ) * num_params ) ; if ( ! params ) return TEE_ERROR_OUT_OF_MEMORY ; res = copy_in_attrs ( utc , usr_params , num_params , params ) ; if ( res != TEE_SUCCESS ) goto out ; res = tee_obj_get ( utc , cs -> key1 , & o ) ; if ( res != TEE_SUCCESS ) goto out ; if ( ( o -> info . handleFlags & TEE_HANDLE_FLAG_INITIALIZED ) == 0 ) { res = TEE_ERROR_GENERIC ; goto out ; } switch ( cs -> algo ) { case TEE_ALG_RSA_NOPAD : if ( cs -> mode == TEE_MODE_ENCRYPT ) { res = crypto_acipher_rsanopad_encrypt ( o -> attr , src_data , src_len , dst_data , & dlen ) ; } else if ( cs -> mode == TEE_MODE_DECRYPT ) { res = crypto_acipher_rsanopad_decrypt ( o -> attr , src_data , src_len , dst_data , & dlen ) ; } else { res = TEE_ERROR_GENERIC ; } break ; case TEE_ALG_RSAES_PKCS1_V1_5 : case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1 : case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 : case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 : case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 : case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 : for ( n = 0 ; n < num_params ; n ++ ) { if ( params [ n ] . attributeID == TEE_ATTR_RSA_OAEP_LABEL ) { label = params [ n ] . content . ref . buffer ; label_len = params [ n ] . content . ref . length ; break ; } } if ( cs -> mode == TEE_MODE_ENCRYPT ) { res = crypto_acipher_rsaes_encrypt ( cs -> algo , o -> attr , label , label_len , src_data , src_len , dst_data , & dlen ) ; } else if ( cs -> mode == TEE_MODE_DECRYPT ) { res = crypto_acipher_rsaes_decrypt ( cs -> algo , o -> attr , label , label_len , src_data , src_len , dst_data , & dlen ) ; } else { res = TEE_ERROR_BAD_PARAMETERS ; } break ; # if defined ( CFG_CRYPTO_RSASSA_NA1 ) case TEE_ALG_RSASSA_PKCS1_V1_5 : # endif case TEE_ALG_RSASSA_PKCS1_V1_5_MD5 : case TEE_ALG_RSASSA_PKCS1_V1_5_SHA1 : case TEE_ALG_RSASSA_PKCS1_V1_5_SHA224 : case TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 : case TEE_ALG_RSASSA_PKCS1_V1_5_SHA384 : case TEE_ALG_RSASSA_PKCS1_V1_5_SHA512 : case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1 : case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224 : case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 : case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384 : case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512 : if ( cs -> mode != TEE_MODE_SIGN ) { res = TEE_ERROR_BAD_PARAMETERS ; break ; } salt_len = pkcs1_get_salt_len ( params , num_params , src_len ) ; res = crypto_acipher_rsassa_sign ( cs -> algo , o -> attr , salt_len , src_data , src_len , dst_data , & dlen ) ; break ; case TEE_ALG_DSA_SHA1 : case TEE_ALG_DSA_SHA224 : case TEE_ALG_DSA_SHA256 : res = crypto_acipher_dsa_sign ( cs -> algo , o -> attr , src_data , src_len , dst_data , & dlen ) ; break ; case TEE_ALG_ECDSA_P192 : case TEE_ALG_ECDSA_P224 : case TEE_ALG_ECDSA_P256 : case TEE_ALG_ECDSA_P384 : case TEE_ALG_ECDSA_P521 : res = crypto_acipher_ecc_sign ( cs -> algo , o -> attr , src_data , src_len , dst_data , & dlen ) ; break ; default : res = TEE_ERROR_BAD_PARAMETERS ; break ; } out : free ( params ) ; if ( res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER ) { TEE_Result res2 ; dlen64 = dlen ; res2 = tee_svc_copy_to_user ( dst_len , & dlen64 , sizeof ( * dst_len ) ) ; if ( res2 != TEE_SUCCESS ) return res2 ; } return res ; }\n", "\n", "\n", "Target: char buf [ L_BUFSIZE ] ; char ( buf , L_BUFSIZE , \"gnuplot%s\" , ( buf , L_BUFSIZE , \"wgnuplot%s\" ,\n", "\n", "Sources:\n", "0: CWE-119 l_int32 gplotMakeOutput ( GPLOT * gplot ) { char buf [ L_BUF_SIZE ] ; char * cmdname ; l_int32 ignore ; PROCNAME ( \"gplotMakeOutput\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; gplotGenCommandFile ( gplot ) ; gplotGenDataFiles ( gplot ) ; cmdname = genPathname ( gplot -> cmdname , NULL ) ; # ifndef _WIN32 snprintf ( buf , L_BUF_SIZE , \"gnuplot%s\" , cmdname ) ; # else snprintf ( buf , L_BUF_SIZE , \"wgnuplot%s\" , cmdname ) ; # endif # ifndef OS_IOS ignore = system ( buf ) ; # endif LEPT_FREE ( cmdname ) ; return 0 ; }\n", "\n", "1: CWE-787 l_int32 gplotMakeOutput ( GPLOT * gplot ) { char buf [ L_BUF_SIZE ] ; char * cmdname ; l_int32 ignore ; PROCNAME ( \"gplotMakeOutput\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; gplotGenCommandFile ( gplot ) ; gplotGenDataFiles ( gplot ) ; cmdname = genPathname ( gplot -> cmdname , NULL ) ; # ifndef _WIN32 snprintf ( buf , L_BUF_SIZE , \"gnuplot%s\" , cmdname ) ; # else snprintf ( buf , L_BUF_SIZE , \"wgnuplot%s\" , cmdname ) ; # endif # ifndef OS_IOS ignore = system ( buf ) ; # endif LEPT_FREE ( cmdname ) ; return 0 ; }\n", "\n", "\n", "Target: ; bufsize = MIN ( file -> size , sizeof buf )\n", "\n", "Sources:\n", "0: CWE-119 static int read_private_key ( RSA * rsa ) { int r ; sc_path_t path ; sc_file_t * file ; const sc_acl_entry_t * e ; u8 buf [ 2048 ] , * p = buf ; size_t bufsize , keysize ; r = select_app_df ( ) ; if ( r ) return 1 ; sc_format_path ( \"I0012\" , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r ) { fprintf ( stderr , \"Unabletoselectprivatekeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } e = sc_file_get_acl_entry ( file , SC_AC_OP_READ ) ; if ( e == NULL || e -> method == SC_AC_NEVER ) return 10 ; bufsize = file -> size ; sc_file_free ( file ) ; r = sc_read_binary ( card , 0 , buf , bufsize , 0 ) ; if ( r < 0 ) { fprintf ( stderr , \"Unabletoreadprivatekeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = r ; do { if ( bufsize < 4 ) return 3 ; keysize = ( p [ 0 ] << 8 ) | p [ 1 ] ; if ( keysize == 0 ) break ; if ( keysize < 3 ) return 3 ; if ( p [ 2 ] == opt_key_num ) break ; p += keysize ; bufsize -= keysize ; } while ( 1 ) ; if ( keysize == 0 ) { printf ( \"Keynumber%dnotfound.\\\\n\" , opt_key_num ) ; return 2 ; } return parse_private_key ( p , keysize , rsa ) ; }\n", "\n", "1: CWE-415 static int read_private_key ( RSA * rsa ) { int r ; sc_path_t path ; sc_file_t * file ; const sc_acl_entry_t * e ; u8 buf [ 2048 ] , * p = buf ; size_t bufsize , keysize ; r = select_app_df ( ) ; if ( r ) return 1 ; sc_format_path ( \"I0012\" , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r ) { fprintf ( stderr , \"Unabletoselectprivatekeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } e = sc_file_get_acl_entry ( file , SC_AC_OP_READ ) ; if ( e == NULL || e -> method == SC_AC_NEVER ) return 10 ; bufsize = file -> size ; sc_file_free ( file ) ; r = sc_read_binary ( card , 0 , buf , bufsize , 0 ) ; if ( r < 0 ) { fprintf ( stderr , \"Unabletoreadprivatekeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = r ; do { if ( bufsize < 4 ) return 3 ; keysize = ( p [ 0 ] << 8 ) | p [ 1 ] ; if ( keysize == 0 ) break ; if ( keysize < 3 ) return 3 ; if ( p [ 2 ] == opt_key_num ) break ; p += keysize ; bufsize -= keysize ; } while ( 1 ) ; if ( keysize == 0 ) { printf ( \"Keynumber%dnotfound.\\\\n\" , opt_key_num ) ; return 2 ; } return parse_private_key ( p , keysize , rsa ) ; }\n", "\n", "\n", "Target: PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , regs ,\n", "\n", "Sources:\n", "0: CWE-399 asmlinkage void do_ade ( struct pt_regs * regs ) { unsigned int __user * pc ; mm_segment_t seg ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , regs -> cp0_badvaddr ) ; if ( ( regs -> cp0_badvaddr == regs -> cp0_epc ) || ( regs -> cp0_epc & 0x1 ) ) goto sigbus ; pc = ( unsigned int __user * ) exception_epc ( regs ) ; if ( user_mode ( regs ) && ! test_thread_flag ( TIF_FIXADE ) ) goto sigbus ; if ( unaligned_action == UNALIGNED_ACTION_SIGNAL ) goto sigbus ; else if ( unaligned_action == UNALIGNED_ACTION_SHOW ) show_registers ( regs ) ; seg = get_fs ( ) ; if ( ! user_mode ( regs ) ) set_fs ( KERNEL_DS ) ; emulate_load_store_insn ( regs , ( void __user * ) regs -> cp0_badvaddr , pc ) ; set_fs ( seg ) ; return ; sigbus : die_if_kernel ( \"Kernelunalignedinstructionaccess\" , regs ) ; force_sig ( SIGBUS , current ) ; }\n", "\n", "1: CWE-400 void handle_lddfmna ( struct pt_regs * regs , unsigned long sfar , unsigned long sfsr ) { unsigned long pc = regs -> tpc ; unsigned long tstate = regs -> tstate ; u32 insn ; u64 value ; u8 freg ; int flag ; struct fpustate * f = FPUSTATE ; if ( tstate & TSTATE_PRIV ) die_if_kernel ( \"lddfmnafromkernel\" , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , sfar ) ; if ( test_thread_flag ( TIF_32BIT ) ) pc = ( u32 ) pc ; if ( get_user ( insn , ( u32 __user * ) pc ) != - EFAULT ) { int asi = decode_asi ( insn , regs ) ; u32 first , second ; int err ; if ( ( asi > ASI_SNFL ) || ( asi < ASI_P ) ) goto daex ; first = second = 0 ; err = get_user ( first , ( u32 __user * ) sfar ) ; if ( ! err ) err = get_user ( second , ( u32 __user * ) ( sfar + 4 ) ) ; if ( err ) { if ( ! ( asi & 0x2 ) ) goto daex ; first = second = 0 ; } save_and_clear_fpu ( ) ; freg = ( ( insn >> 25 ) & 0x1e ) | ( ( insn >> 20 ) & 0x20 ) ; value = ( ( ( u64 ) first ) << 32 ) | second ; if ( asi & 0x8 ) value = __swab64p ( & value ) ; flag = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & FPRS_FEF ) ) { current_thread_info ( ) -> fpsaved [ 0 ] = FPRS_FEF ; current_thread_info ( ) -> gsr [ 0 ] = 0 ; } if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & flag ) ) { if ( freg < 32 ) memset ( f -> regs , 0 , 32 * sizeof ( u32 ) ) ; else memset ( f -> regs + 32 , 0 , 32 * sizeof ( u32 ) ) ; } * ( u64 * ) ( f -> regs + freg ) = value ; current_thread_info ( ) -> fpsaved [ 0 ] |= flag ; } else { daex : if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , sfar , sfsr ) ; else spitfire_data_access_exception ( regs , sfsr , sfar ) ; return ; } advance ( regs ) ; }\n", "\n", "2: CWE-400 asmlinkage void do_ade ( struct pt_regs * regs ) { unsigned int __user * pc ; mm_segment_t seg ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , regs -> cp0_badvaddr ) ; if ( ( regs -> cp0_badvaddr == regs -> cp0_epc ) || ( regs -> cp0_epc & 0x1 ) ) goto sigbus ; pc = ( unsigned int __user * ) exception_epc ( regs ) ; if ( user_mode ( regs ) && ! test_thread_flag ( TIF_FIXADE ) ) goto sigbus ; if ( unaligned_action == UNALIGNED_ACTION_SIGNAL ) goto sigbus ; else if ( unaligned_action == UNALIGNED_ACTION_SHOW ) show_registers ( regs ) ; seg = get_fs ( ) ; if ( ! user_mode ( regs ) ) set_fs ( KERNEL_DS ) ; emulate_load_store_insn ( regs , ( void __user * ) regs -> cp0_badvaddr , pc ) ; set_fs ( seg ) ; return ; sigbus : die_if_kernel ( \"Kernelunalignedinstructionaccess\" , regs ) ; force_sig ( SIGBUS , current ) ; }\n", "\n", "3: CWE-400 void handle_stdfmna ( struct pt_regs * regs , unsigned long sfar , unsigned long sfsr ) { unsigned long pc = regs -> tpc ; unsigned long tstate = regs -> tstate ; u32 insn ; u64 value ; u8 freg ; int flag ; struct fpustate * f = FPUSTATE ; if ( tstate & TSTATE_PRIV ) die_if_kernel ( \"stdfmnafromkernel\" , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , sfar ) ; if ( test_thread_flag ( TIF_32BIT ) ) pc = ( u32 ) pc ; if ( get_user ( insn , ( u32 __user * ) pc ) != - EFAULT ) { int asi = decode_asi ( insn , regs ) ; freg = ( ( insn >> 25 ) & 0x1e ) | ( ( insn >> 20 ) & 0x20 ) ; value = 0 ; flag = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ( asi > ASI_SNFL ) || ( asi < ASI_P ) ) goto daex ; save_and_clear_fpu ( ) ; if ( current_thread_info ( ) -> fpsaved [ 0 ] & flag ) value = * ( u64 * ) & f -> regs [ freg ] ; switch ( asi ) { case ASI_P : case ASI_S : break ; case ASI_PL : case ASI_SL : value = __swab64p ( & value ) ; break ; default : goto daex ; } if ( put_user ( value >> 32 , ( u32 __user * ) sfar ) || __put_user ( ( u32 ) value , ( u32 __user * ) ( sfar + 4 ) ) ) goto daex ; } else { daex : if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , sfar , sfsr ) ; else spitfire_data_access_exception ( regs , sfsr , sfar ) ; return ; } advance ( regs ) ; }\n", "\n", "\n", "Target: + 30 ; if ( rsrc . map_offset + 28 > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badmapoffset.\\\\n\" ) ; goto parse_rsrc_fork_cleanup ; } ; ++ ) { if ( rsrc . type_offset k * 8 > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badrsrcmarker.\\\\n\" ) ; goto parse_rsrc_fork_cleanup ; } ; marker = read_rsrc_marker ( & rsrc , rsrc . type_offset + k * 8\n", "\n", "Sources:\n", "0: CWE-000 static int sd2_parse_rsrc_fork ( SF_PRIVATE * psf ) { SD2_RSRC rsrc ; int k , marker , error = 0 ; psf_use_rsrc ( psf , SF_TRUE ) ; memset ( & rsrc , 0 , sizeof ( rsrc ) ) ; rsrc . rsrc_len = psf_get_filelen ( psf ) ; psf_log_printf ( psf , \"Resourcelength:%d(0x%04X)\\\\n\" , rsrc . rsrc_len , rsrc . rsrc_len ) ; if ( rsrc . rsrc_len > SIGNED_SIZEOF ( psf -> header ) ) { rsrc . rsrc_data = calloc ( 1 , rsrc . rsrc_len ) ; rsrc . need_to_free_rsrc_data = SF_TRUE ; } else { rsrc . rsrc_data = psf -> header ; rsrc . need_to_free_rsrc_data = SF_FALSE ; } ; psf_fread ( rsrc . rsrc_data , rsrc . rsrc_len , 1 , psf ) ; psf -> headindex = psf -> headend = rsrc . rsrc_len ; rsrc . data_offset = read_rsrc_int ( & rsrc , 0 ) ; rsrc . map_offset = read_rsrc_int ( & rsrc , 4 ) ; rsrc . data_length = read_rsrc_int ( & rsrc , 8 ) ; rsrc . map_length = read_rsrc_int ( & rsrc , 12 ) ; if ( rsrc . data_offset == 0x51607 && rsrc . map_offset == 0x20000 ) { psf_log_printf ( psf , \"Tryingoffsetof0x52bytes.\\\\n\" ) ; rsrc . data_offset = read_rsrc_int ( & rsrc , 0x52 + 0 ) + 0x52 ; rsrc . map_offset = read_rsrc_int ( & rsrc , 0x52 + 4 ) + 0x52 ; rsrc . data_length = read_rsrc_int ( & rsrc , 0x52 + 8 ) ; rsrc . map_length = read_rsrc_int ( & rsrc , 0x52 + 12 ) ; } ; psf_log_printf ( psf , \"dataoffset:0x%04X\\\\nmapoffset:0x%04X\\\\n\" \"datalength:0x%04X\\\\nmaplength:0x%04X\\\\n\" , rsrc . data_offset , rsrc . map_offset , rsrc . data_length , rsrc . map_length ) ; if ( rsrc . data_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.data_offset(%d,0x%x)>len\\\\n\" , rsrc . data_offset , rsrc . data_offset ) ; error = SFE_SD2_BAD_DATA_OFFSET ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.map_offset>len\\\\n\" ) ; error = SFE_SD2_BAD_MAP_OFFSET ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . data_length > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.data_length>len\\\\n\" ) ; error = SFE_SD2_BAD_DATA_LENGTH ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_length > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.map_length>len\\\\n\" ) ; error = SFE_SD2_BAD_MAP_LENGTH ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . data_offset + rsrc . data_length != rsrc . map_offset || rsrc . map_offset + rsrc . map_length != rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:ThisdoesnotlooklikeaMacOSXresourcefork.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_offset + 28 >= rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badmapoffset(%d+28>%d).\\\\n\" , rsrc . map_offset , rsrc . rsrc_len ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . string_offset = rsrc . map_offset + read_rsrc_short ( & rsrc , rsrc . map_offset + 26 ) ; if ( rsrc . string_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badstringoffset(%d).\\\\n\" , rsrc . string_offset ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . type_offset = rsrc . map_offset + 30 ; rsrc . type_count = read_rsrc_short ( & rsrc , rsrc . map_offset + 28 ) + 1 ; if ( rsrc . type_count < 1 ) { psf_log_printf ( psf , \"Badtypecount.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . item_offset = rsrc . type_offset + rsrc . type_count * 8 ; if ( rsrc . item_offset < 0 || rsrc . item_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Baditemoffset(%d).\\\\n\" , rsrc . item_offset ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . str_index = - 1 ; for ( k = 0 ; k < rsrc . type_count ; k ++ ) { marker = read_rsrc_marker ( & rsrc , rsrc . type_offset + k * 8 ) ; if ( marker == STR_MARKER ) { rsrc . str_index = k ; rsrc . str_count = read_rsrc_short ( & rsrc , rsrc . type_offset + k * 8 + 4 ) + 1 ; error = parse_str_rsrc ( psf , & rsrc ) ; goto parse_rsrc_fork_cleanup ; } ; } ; psf_log_printf ( psf , \"No\\'STR\\'resource.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; parse_rsrc_fork_cleanup : psf_use_rsrc ( psf , SF_FALSE ) ; if ( rsrc . need_to_free_rsrc_data ) free ( rsrc . rsrc_data ) ; return error ; }\n", "\n", "1: CWE-119 static int sd2_parse_rsrc_fork ( SF_PRIVATE * psf ) { SD2_RSRC rsrc ; int k , marker , error = 0 ; psf_use_rsrc ( psf , SF_TRUE ) ; memset ( & rsrc , 0 , sizeof ( rsrc ) ) ; rsrc . rsrc_len = psf_get_filelen ( psf ) ; psf_log_printf ( psf , \"Resourcelength:%d(0x%04X)\\\\n\" , rsrc . rsrc_len , rsrc . rsrc_len ) ; if ( rsrc . rsrc_len > SIGNED_SIZEOF ( psf -> header ) ) { rsrc . rsrc_data = calloc ( 1 , rsrc . rsrc_len ) ; rsrc . need_to_free_rsrc_data = SF_TRUE ; } else { rsrc . rsrc_data = psf -> header ; rsrc . need_to_free_rsrc_data = SF_FALSE ; } ; psf_fread ( rsrc . rsrc_data , rsrc . rsrc_len , 1 , psf ) ; psf -> headindex = psf -> headend = rsrc . rsrc_len ; rsrc . data_offset = read_rsrc_int ( & rsrc , 0 ) ; rsrc . map_offset = read_rsrc_int ( & rsrc , 4 ) ; rsrc . data_length = read_rsrc_int ( & rsrc , 8 ) ; rsrc . map_length = read_rsrc_int ( & rsrc , 12 ) ; if ( rsrc . data_offset == 0x51607 && rsrc . map_offset == 0x20000 ) { psf_log_printf ( psf , \"Tryingoffsetof0x52bytes.\\\\n\" ) ; rsrc . data_offset = read_rsrc_int ( & rsrc , 0x52 + 0 ) + 0x52 ; rsrc . map_offset = read_rsrc_int ( & rsrc , 0x52 + 4 ) + 0x52 ; rsrc . data_length = read_rsrc_int ( & rsrc , 0x52 + 8 ) ; rsrc . map_length = read_rsrc_int ( & rsrc , 0x52 + 12 ) ; } ; psf_log_printf ( psf , \"dataoffset:0x%04X\\\\nmapoffset:0x%04X\\\\n\" \"datalength:0x%04X\\\\nmaplength:0x%04X\\\\n\" , rsrc . data_offset , rsrc . map_offset , rsrc . data_length , rsrc . map_length ) ; if ( rsrc . data_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.data_offset(%d,0x%x)>len\\\\n\" , rsrc . data_offset , rsrc . data_offset ) ; error = SFE_SD2_BAD_DATA_OFFSET ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.map_offset>len\\\\n\" ) ; error = SFE_SD2_BAD_MAP_OFFSET ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . data_length > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.data_length>len\\\\n\" ) ; error = SFE_SD2_BAD_DATA_LENGTH ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_length > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:rsrc.map_length>len\\\\n\" ) ; error = SFE_SD2_BAD_MAP_LENGTH ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . data_offset + rsrc . data_length != rsrc . map_offset || rsrc . map_offset + rsrc . map_length != rsrc . rsrc_len ) { psf_log_printf ( psf , \"Error:ThisdoesnotlooklikeaMacOSXresourcefork.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; if ( rsrc . map_offset + 28 >= rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badmapoffset(%d+28>%d).\\\\n\" , rsrc . map_offset , rsrc . rsrc_len ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . string_offset = rsrc . map_offset + read_rsrc_short ( & rsrc , rsrc . map_offset + 26 ) ; if ( rsrc . string_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Badstringoffset(%d).\\\\n\" , rsrc . string_offset ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . type_offset = rsrc . map_offset + 30 ; rsrc . type_count = read_rsrc_short ( & rsrc , rsrc . map_offset + 28 ) + 1 ; if ( rsrc . type_count < 1 ) { psf_log_printf ( psf , \"Badtypecount.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . item_offset = rsrc . type_offset + rsrc . type_count * 8 ; if ( rsrc . item_offset < 0 || rsrc . item_offset > rsrc . rsrc_len ) { psf_log_printf ( psf , \"Baditemoffset(%d).\\\\n\" , rsrc . item_offset ) ; error = SFE_SD2_BAD_RSRC ; goto parse_rsrc_fork_cleanup ; } ; rsrc . str_index = - 1 ; for ( k = 0 ; k < rsrc . type_count ; k ++ ) { marker = read_rsrc_marker ( & rsrc , rsrc . type_offset + k * 8 ) ; if ( marker == STR_MARKER ) { rsrc . str_index = k ; rsrc . str_count = read_rsrc_short ( & rsrc , rsrc . type_offset + k * 8 + 4 ) + 1 ; error = parse_str_rsrc ( psf , & rsrc ) ; goto parse_rsrc_fork_cleanup ; } ; } ; psf_log_printf ( psf , \"No\\'STR\\'resource.\\\\n\" ) ; error = SFE_SD2_BAD_RSRC ; parse_rsrc_fork_cleanup : psf_use_rsrc ( psf , SF_FALSE ) ; if ( rsrc . need_to_free_rsrc_data ) free ( rsrc . rsrc_data ) ; return error ; }\n", "\n", "\n", "Target: * st ; int ret ; val ) ; ret = ] ) ; if ( ret != 4 ) return AVERROR_INVALIDDATA ;\n", "\n", "Sources:\n", "0: CWE-908 static int aa_read_header ( AVFormatContext * s ) { int i , j , idx , largest_idx = - 1 ; uint32_t nkey , nval , toc_size , npairs , header_seed = 0 , start ; char key [ 128 ] , val [ 128 ] , codec_name [ 64 ] = { 0 } ; uint8_t output [ 24 ] , dst [ 8 ] , src [ 8 ] ; int64_t largest_size = - 1 , current_size = - 1 , chapter_pos ; struct toc_entry { uint32_t offset ; uint32_t size ; } TOC [ MAX_TOC_ENTRIES ] ; uint32_t header_key_part [ 4 ] ; uint8_t header_key [ 16 ] = { 0 } ; AADemuxContext * c = s -> priv_data ; AVIOContext * pb = s -> pb ; AVStream * st ; avio_skip ( pb , 4 ) ; avio_skip ( pb , 4 ) ; toc_size = avio_rb32 ( pb ) ; avio_skip ( pb , 4 ) ; if ( toc_size > MAX_TOC_ENTRIES ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < toc_size ; i ++ ) { avio_skip ( pb , 4 ) ; TOC [ i ] . offset = avio_rb32 ( pb ) ; TOC [ i ] . size = avio_rb32 ( pb ) ; } avio_skip ( pb , 24 ) ; npairs = avio_rb32 ( pb ) ; if ( npairs > MAX_DICTIONARY_ENTRIES ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < npairs ; i ++ ) { memset ( val , 0 , sizeof ( val ) ) ; memset ( key , 0 , sizeof ( key ) ) ; avio_skip ( pb , 1 ) ; nkey = avio_rb32 ( pb ) ; nval = avio_rb32 ( pb ) ; avio_get_str ( pb , nkey , key , sizeof ( key ) ) ; avio_get_str ( pb , nval , val , sizeof ( val ) ) ; if ( ! strcmp ( key , \"codec\" ) ) { av_log ( s , AV_LOG_DEBUG , \"Codecis<%s>\\\\n\" , val ) ; strncpy ( codec_name , val , sizeof ( codec_name ) - 1 ) ; } else if ( ! strcmp ( key , \"HeaderSeed\" ) ) { av_log ( s , AV_LOG_DEBUG , \"HeaderSeedis<%s>\\\\n\" , val ) ; header_seed = atoi ( val ) ; } else if ( ! strcmp ( key , \"HeaderKey\" ) ) { av_log ( s , AV_LOG_DEBUG , \"HeaderKeyis<%s>\\\\n\" , val ) ; sscanf ( val , \"%\" SCNu32 \"%\" SCNu32 \"%\" SCNu32 \"%\" SCNu32 , & header_key_part [ 0 ] , & header_key_part [ 1 ] , & header_key_part [ 2 ] , & header_key_part [ 3 ] ) ; for ( idx = 0 ; idx < 4 ; idx ++ ) { AV_WB32 ( & header_key [ idx * 4 ] , header_key_part [ idx ] ) ; } av_log ( s , AV_LOG_DEBUG , \"ProcessedHeaderKeyis\" ) ; for ( i = 0 ; i < 16 ; i ++ ) av_log ( s , AV_LOG_DEBUG , \"%02x\" , header_key [ i ] ) ; av_log ( s , AV_LOG_DEBUG , \"\\\\n\" ) ; } else { av_dict_set ( & s -> metadata , key , val , 0 ) ; } } if ( c -> aa_fixed_key_len != 16 ) { av_log ( s , AV_LOG_ERROR , \"aa_fixed_keyvalueneedstobe16bytes!\\\\n\" ) ; return AVERROR ( EINVAL ) ; } if ( ( c -> codec_second_size = get_second_size ( codec_name ) ) == - 1 ) { av_log ( s , AV_LOG_ERROR , \"unknowncodec<%s>!\\\\n\" , codec_name ) ; return AVERROR ( EINVAL ) ; } c -> tea_ctx = av_tea_alloc ( ) ; if ( ! c -> tea_ctx ) return AVERROR ( ENOMEM ) ; av_tea_init ( c -> tea_ctx , c -> aa_fixed_key , 16 ) ; output [ 0 ] = output [ 1 ] = 0 ; memcpy ( output + 2 , header_key , 16 ) ; idx = 0 ; for ( i = 0 ; i < 3 ; i ++ ) { AV_WB32 ( src , header_seed ) ; AV_WB32 ( src + 4 , header_seed + 1 ) ; header_seed += 2 ; av_tea_crypt ( c -> tea_ctx , dst , src , 1 , NULL , 0 ) ; for ( j = 0 ; j < TEA_BLOCK_SIZE && idx < 18 ; j += 1 , idx += 1 ) { output [ idx ] = output [ idx ] ^ dst [ j ] ; } } memcpy ( c -> file_key , output + 2 , 16 ) ; av_log ( s , AV_LOG_DEBUG , \"Filekeyis\" ) ; for ( i = 0 ; i < 16 ; i ++ ) av_log ( s , AV_LOG_DEBUG , \"%02x\" , c -> file_key [ i ] ) ; av_log ( s , AV_LOG_DEBUG , \"\\\\n\" ) ; st = avformat_new_stream ( s , NULL ) ; if ( ! st ) { av_freep ( & c -> tea_ctx ) ; return AVERROR ( ENOMEM ) ; } st -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; if ( ! strcmp ( codec_name , \"mp332\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_MP3 ; st -> codecpar -> sample_rate = 22050 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 32000 * TIMEPREC ) ; } else if ( ! strcmp ( codec_name , \"acelp85\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_SIPR ; st -> codecpar -> block_align = 19 ; st -> codecpar -> channels = 1 ; st -> codecpar -> sample_rate = 8500 ; st -> codecpar -> bit_rate = 8500 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 8500 * TIMEPREC ) ; } else if ( ! strcmp ( codec_name , \"acelp16\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_SIPR ; st -> codecpar -> block_align = 20 ; st -> codecpar -> channels = 1 ; st -> codecpar -> sample_rate = 16000 ; st -> codecpar -> bit_rate = 16000 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 16000 * TIMEPREC ) ; } for ( i = 1 ; i < toc_size ; i ++ ) { current_size = TOC [ i ] . size ; if ( current_size > largest_size ) { largest_idx = i ; largest_size = current_size ; } } start = TOC [ largest_idx ] . offset ; avio_seek ( pb , start , SEEK_SET ) ; st -> start_time = 0 ; c -> content_start = start ; c -> content_end = start + largest_size ; while ( ( chapter_pos = avio_tell ( pb ) ) >= 0 && chapter_pos < c -> content_end ) { int chapter_idx = s -> nb_chapters ; uint32_t chapter_size = avio_rb32 ( pb ) ; if ( chapter_size == 0 ) break ; chapter_pos -= start + CHAPTER_HEADER_SIZE * chapter_idx ; avio_skip ( pb , 4 + chapter_size ) ; if ( ! avpriv_new_chapter ( s , chapter_idx , st -> time_base , chapter_pos * TIMEPREC , ( chapter_pos + chapter_size ) * TIMEPREC , NULL ) ) return AVERROR ( ENOMEM ) ; } st -> duration = ( largest_size - CHAPTER_HEADER_SIZE * s -> nb_chapters ) * TIMEPREC ; ff_update_cur_dts ( s , st , 0 ) ; avio_seek ( pb , start , SEEK_SET ) ; c -> current_chapter_size = 0 ; c -> seek_offset = 0 ; return 0 ; }\n", "\n", "1: CWE-665 static int aa_read_header ( AVFormatContext * s ) { int i , j , idx , largest_idx = - 1 ; uint32_t nkey , nval , toc_size , npairs , header_seed = 0 , start ; char key [ 128 ] , val [ 128 ] , codec_name [ 64 ] = { 0 } ; uint8_t output [ 24 ] , dst [ 8 ] , src [ 8 ] ; int64_t largest_size = - 1 , current_size = - 1 , chapter_pos ; struct toc_entry { uint32_t offset ; uint32_t size ; } TOC [ MAX_TOC_ENTRIES ] ; uint32_t header_key_part [ 4 ] ; uint8_t header_key [ 16 ] = { 0 } ; AADemuxContext * c = s -> priv_data ; AVIOContext * pb = s -> pb ; AVStream * st ; avio_skip ( pb , 4 ) ; avio_skip ( pb , 4 ) ; toc_size = avio_rb32 ( pb ) ; avio_skip ( pb , 4 ) ; if ( toc_size > MAX_TOC_ENTRIES ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < toc_size ; i ++ ) { avio_skip ( pb , 4 ) ; TOC [ i ] . offset = avio_rb32 ( pb ) ; TOC [ i ] . size = avio_rb32 ( pb ) ; } avio_skip ( pb , 24 ) ; npairs = avio_rb32 ( pb ) ; if ( npairs > MAX_DICTIONARY_ENTRIES ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < npairs ; i ++ ) { memset ( val , 0 , sizeof ( val ) ) ; memset ( key , 0 , sizeof ( key ) ) ; avio_skip ( pb , 1 ) ; nkey = avio_rb32 ( pb ) ; nval = avio_rb32 ( pb ) ; avio_get_str ( pb , nkey , key , sizeof ( key ) ) ; avio_get_str ( pb , nval , val , sizeof ( val ) ) ; if ( ! strcmp ( key , \"codec\" ) ) { av_log ( s , AV_LOG_DEBUG , \"Codecis<%s>\\\\n\" , val ) ; strncpy ( codec_name , val , sizeof ( codec_name ) - 1 ) ; } else if ( ! strcmp ( key , \"HeaderSeed\" ) ) { av_log ( s , AV_LOG_DEBUG , \"HeaderSeedis<%s>\\\\n\" , val ) ; header_seed = atoi ( val ) ; } else if ( ! strcmp ( key , \"HeaderKey\" ) ) { av_log ( s , AV_LOG_DEBUG , \"HeaderKeyis<%s>\\\\n\" , val ) ; sscanf ( val , \"%\" SCNu32 \"%\" SCNu32 \"%\" SCNu32 \"%\" SCNu32 , & header_key_part [ 0 ] , & header_key_part [ 1 ] , & header_key_part [ 2 ] , & header_key_part [ 3 ] ) ; for ( idx = 0 ; idx < 4 ; idx ++ ) { AV_WB32 ( & header_key [ idx * 4 ] , header_key_part [ idx ] ) ; } av_log ( s , AV_LOG_DEBUG , \"ProcessedHeaderKeyis\" ) ; for ( i = 0 ; i < 16 ; i ++ ) av_log ( s , AV_LOG_DEBUG , \"%02x\" , header_key [ i ] ) ; av_log ( s , AV_LOG_DEBUG , \"\\\\n\" ) ; } else { av_dict_set ( & s -> metadata , key , val , 0 ) ; } } if ( c -> aa_fixed_key_len != 16 ) { av_log ( s , AV_LOG_ERROR , \"aa_fixed_keyvalueneedstobe16bytes!\\\\n\" ) ; return AVERROR ( EINVAL ) ; } if ( ( c -> codec_second_size = get_second_size ( codec_name ) ) == - 1 ) { av_log ( s , AV_LOG_ERROR , \"unknowncodec<%s>!\\\\n\" , codec_name ) ; return AVERROR ( EINVAL ) ; } c -> tea_ctx = av_tea_alloc ( ) ; if ( ! c -> tea_ctx ) return AVERROR ( ENOMEM ) ; av_tea_init ( c -> tea_ctx , c -> aa_fixed_key , 16 ) ; output [ 0 ] = output [ 1 ] = 0 ; memcpy ( output + 2 , header_key , 16 ) ; idx = 0 ; for ( i = 0 ; i < 3 ; i ++ ) { AV_WB32 ( src , header_seed ) ; AV_WB32 ( src + 4 , header_seed + 1 ) ; header_seed += 2 ; av_tea_crypt ( c -> tea_ctx , dst , src , 1 , NULL , 0 ) ; for ( j = 0 ; j < TEA_BLOCK_SIZE && idx < 18 ; j += 1 , idx += 1 ) { output [ idx ] = output [ idx ] ^ dst [ j ] ; } } memcpy ( c -> file_key , output + 2 , 16 ) ; av_log ( s , AV_LOG_DEBUG , \"Filekeyis\" ) ; for ( i = 0 ; i < 16 ; i ++ ) av_log ( s , AV_LOG_DEBUG , \"%02x\" , c -> file_key [ i ] ) ; av_log ( s , AV_LOG_DEBUG , \"\\\\n\" ) ; st = avformat_new_stream ( s , NULL ) ; if ( ! st ) { av_freep ( & c -> tea_ctx ) ; return AVERROR ( ENOMEM ) ; } st -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; if ( ! strcmp ( codec_name , \"mp332\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_MP3 ; st -> codecpar -> sample_rate = 22050 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 32000 * TIMEPREC ) ; } else if ( ! strcmp ( codec_name , \"acelp85\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_SIPR ; st -> codecpar -> block_align = 19 ; st -> codecpar -> channels = 1 ; st -> codecpar -> sample_rate = 8500 ; st -> codecpar -> bit_rate = 8500 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 8500 * TIMEPREC ) ; } else if ( ! strcmp ( codec_name , \"acelp16\" ) ) { st -> codecpar -> codec_id = AV_CODEC_ID_SIPR ; st -> codecpar -> block_align = 20 ; st -> codecpar -> channels = 1 ; st -> codecpar -> sample_rate = 16000 ; st -> codecpar -> bit_rate = 16000 ; st -> need_parsing = AVSTREAM_PARSE_FULL_RAW ; avpriv_set_pts_info ( st , 64 , 8 , 16000 * TIMEPREC ) ; } for ( i = 1 ; i < toc_size ; i ++ ) { current_size = TOC [ i ] . size ; if ( current_size > largest_size ) { largest_idx = i ; largest_size = current_size ; } } start = TOC [ largest_idx ] . offset ; avio_seek ( pb , start , SEEK_SET ) ; st -> start_time = 0 ; c -> content_start = start ; c -> content_end = start + largest_size ; while ( ( chapter_pos = avio_tell ( pb ) ) >= 0 && chapter_pos < c -> content_end ) { int chapter_idx = s -> nb_chapters ; uint32_t chapter_size = avio_rb32 ( pb ) ; if ( chapter_size == 0 ) break ; chapter_pos -= start + CHAPTER_HEADER_SIZE * chapter_idx ; avio_skip ( pb , 4 + chapter_size ) ; if ( ! avpriv_new_chapter ( s , chapter_idx , st -> time_base , chapter_pos * TIMEPREC , ( chapter_pos + chapter_size ) * TIMEPREC , NULL ) ) return AVERROR ( ENOMEM ) ; } st -> duration = ( largest_size - CHAPTER_HEADER_SIZE * s -> nb_chapters ) * TIMEPREC ; ff_update_cur_dts ( s , st , 0 ) ; avio_seek ( pb , start , SEEK_SET ) ; c -> current_chapter_size = 0 ; c -> seek_offset = 0 ; return 0 ; }\n", "\n", "\n", "Target: buf + 2 , sizeof ( obuf )\n", "\n", "Sources:\n", "0: CWE-120 enum ImapAuthRes imap_auth_cram_md5 ( struct ImapData * idata , const char * method ) { char ibuf [ LONG_STRING * 2 ] , obuf [ LONG_STRING ] ; unsigned char hmac_response [ MD5_DIGEST_LEN ] ; int len ; int rc ; if ( ! mutt_bit_isset ( idata -> capabilities , ACRAM_MD5 ) ) return IMAP_AUTH_UNAVAIL ; mutt_message ( _ ( \"Authenticating(CRAM-MD5)...\" ) ) ; if ( mutt_account_getlogin ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; if ( mutt_account_getpass ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; imap_cmd_start ( idata , \"AUTHENTICATECRAM-MD5\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"Invalidresponsefromserver:%s\\\\n\" , ibuf ) ; goto bail ; } len = mutt_b64_decode ( obuf , idata -> buf + 2 ) ; if ( len == - 1 ) { mutt_debug ( 1 , \"Errordecodingbase64response.\\\\n\" ) ; goto bail ; } obuf [ len ] = '\\\\0' ; mutt_debug ( 2 , \"CRAMchallenge:%s\\\\n\" , obuf ) ; hmac_md5 ( idata -> conn -> account . pass , obuf , hmac_response ) ; int off = snprintf ( obuf , sizeof ( obuf ) , \"%s\" , idata -> conn -> account . user ) ; mutt_md5_toascii ( hmac_response , obuf + off ) ; mutt_debug ( 2 , \"CRAMresponse:%s\\\\n\" , obuf ) ; mutt_b64_encode ( ibuf , obuf , strlen ( obuf ) , sizeof ( ibuf ) - 2 ) ; mutt_str_strcat ( ibuf , sizeof ( ibuf ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , ibuf ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_OK ) { mutt_debug ( 1 , \"Errorreceivingserverresponse.\\\\n\" ) ; goto bail ; } if ( imap_code ( idata -> buf ) ) return IMAP_AUTH_SUCCESS ; bail : mutt_error ( _ ( \"CRAM-MD5authenticationfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "1: CWE-119 enum ImapAuthRes imap_auth_cram_md5 ( struct ImapData * idata , const char * method ) { char ibuf [ LONG_STRING * 2 ] , obuf [ LONG_STRING ] ; unsigned char hmac_response [ MD5_DIGEST_LEN ] ; int len ; int rc ; if ( ! mutt_bit_isset ( idata -> capabilities , ACRAM_MD5 ) ) return IMAP_AUTH_UNAVAIL ; mutt_message ( _ ( \"Authenticating(CRAM-MD5)...\" ) ) ; if ( mutt_account_getlogin ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; if ( mutt_account_getpass ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; imap_cmd_start ( idata , \"AUTHENTICATECRAM-MD5\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"Invalidresponsefromserver:%s\\\\n\" , ibuf ) ; goto bail ; } len = mutt_b64_decode ( obuf , idata -> buf + 2 ) ; if ( len == - 1 ) { mutt_debug ( 1 , \"Errordecodingbase64response.\\\\n\" ) ; goto bail ; } obuf [ len ] = '\\\\0' ; mutt_debug ( 2 , \"CRAMchallenge:%s\\\\n\" , obuf ) ; hmac_md5 ( idata -> conn -> account . pass , obuf , hmac_response ) ; int off = snprintf ( obuf , sizeof ( obuf ) , \"%s\" , idata -> conn -> account . user ) ; mutt_md5_toascii ( hmac_response , obuf + off ) ; mutt_debug ( 2 , \"CRAMresponse:%s\\\\n\" , obuf ) ; mutt_b64_encode ( ibuf , obuf , strlen ( obuf ) , sizeof ( ibuf ) - 2 ) ; mutt_str_strcat ( ibuf , sizeof ( ibuf ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , ibuf ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_OK ) { mutt_debug ( 1 , \"Errorreceivingserverresponse.\\\\n\" ) ; goto bail ; } if ( imap_code ( idata -> buf ) ) return IMAP_AUTH_SUCCESS ; bail : mutt_error ( _ ( \"CRAM-MD5authenticationfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "\n", "Target: char buf [ L_BUFSIZE ] ; l_int32 ( buf , L_BUFSIZE , \"%s.cmd\" , ( buf , L_BUFSIZE , \"%s.png\" , ( buf , L_BUFSIZE , \"%s.ps\" , ( buf , L_BUFSIZE , \"%s.eps\" , ( buf , L_BUFSIZE , \"%s.tex\" ,\n", "\n", "Sources:\n", "0: CWE-119 GPLOT * gplotCreate ( const char * rootname , l_int32 outformat , const char * title , const char * xlabel , const char * ylabel ) { char * newroot ; char buf [ L_BUF_SIZE ] ; l_int32 badchar ; GPLOT * gplot ; PROCNAME ( \"gplotCreate\" ) ; if ( ! rootname ) return ( GPLOT * ) ERROR_PTR ( \"rootnamenotdefined\" , procName , NULL ) ; if ( outformat != GPLOT_PNG && outformat != GPLOT_PS && outformat != GPLOT_EPS && outformat != GPLOT_LATEX ) return ( GPLOT * ) ERROR_PTR ( \"outformatinvalid\" , procName , NULL ) ; stringCheckForChars ( rootname , \"`;&|><\\\\\"?*\" , & badchar ) ; if ( badchar ) return ( GPLOT * ) ERROR_PTR ( \"invalidrootname\" , procName , NULL ) ; if ( ( gplot = ( GPLOT * ) LEPT_CALLOC ( 1 , sizeof ( GPLOT ) ) ) == NULL ) return ( GPLOT * ) ERROR_PTR ( \"gplotnotmade\" , procName , NULL ) ; gplot -> cmddata = sarrayCreate ( 0 ) ; gplot -> datanames = sarrayCreate ( 0 ) ; gplot -> plotdata = sarrayCreate ( 0 ) ; gplot -> plottitles = sarrayCreate ( 0 ) ; gplot -> plotstyles = numaCreate ( 0 ) ; newroot = genPathname ( rootname , NULL ) ; gplot -> rootname = newroot ; gplot -> outformat = outformat ; snprintf ( buf , L_BUF_SIZE , \"%s.cmd\" , rootname ) ; gplot -> cmdname = stringNew ( buf ) ; if ( outformat == GPLOT_PNG ) snprintf ( buf , L_BUF_SIZE , \"%s.png\" , newroot ) ; else if ( outformat == GPLOT_PS ) snprintf ( buf , L_BUF_SIZE , \"%s.ps\" , newroot ) ; else if ( outformat == GPLOT_EPS ) snprintf ( buf , L_BUF_SIZE , \"%s.eps\" , newroot ) ; else if ( outformat == GPLOT_LATEX ) snprintf ( buf , L_BUF_SIZE , \"%s.tex\" , newroot ) ; gplot -> outname = stringNew ( buf ) ; if ( title ) gplot -> title = stringNew ( title ) ; if ( xlabel ) gplot -> xlabel = stringNew ( xlabel ) ; if ( ylabel ) gplot -> ylabel = stringNew ( ylabel ) ; return gplot ; }\n", "\n", "1: CWE-787 GPLOT * gplotCreate ( const char * rootname , l_int32 outformat , const char * title , const char * xlabel , const char * ylabel ) { char * newroot ; char buf [ L_BUF_SIZE ] ; l_int32 badchar ; GPLOT * gplot ; PROCNAME ( \"gplotCreate\" ) ; if ( ! rootname ) return ( GPLOT * ) ERROR_PTR ( \"rootnamenotdefined\" , procName , NULL ) ; if ( outformat != GPLOT_PNG && outformat != GPLOT_PS && outformat != GPLOT_EPS && outformat != GPLOT_LATEX ) return ( GPLOT * ) ERROR_PTR ( \"outformatinvalid\" , procName , NULL ) ; stringCheckForChars ( rootname , \"`;&|><\\\\\"?*\" , & badchar ) ; if ( badchar ) return ( GPLOT * ) ERROR_PTR ( \"invalidrootname\" , procName , NULL ) ; if ( ( gplot = ( GPLOT * ) LEPT_CALLOC ( 1 , sizeof ( GPLOT ) ) ) == NULL ) return ( GPLOT * ) ERROR_PTR ( \"gplotnotmade\" , procName , NULL ) ; gplot -> cmddata = sarrayCreate ( 0 ) ; gplot -> datanames = sarrayCreate ( 0 ) ; gplot -> plotdata = sarrayCreate ( 0 ) ; gplot -> plottitles = sarrayCreate ( 0 ) ; gplot -> plotstyles = numaCreate ( 0 ) ; newroot = genPathname ( rootname , NULL ) ; gplot -> rootname = newroot ; gplot -> outformat = outformat ; snprintf ( buf , L_BUF_SIZE , \"%s.cmd\" , rootname ) ; gplot -> cmdname = stringNew ( buf ) ; if ( outformat == GPLOT_PNG ) snprintf ( buf , L_BUF_SIZE , \"%s.png\" , newroot ) ; else if ( outformat == GPLOT_PS ) snprintf ( buf , L_BUF_SIZE , \"%s.ps\" , newroot ) ; else if ( outformat == GPLOT_EPS ) snprintf ( buf , L_BUF_SIZE , \"%s.eps\" , newroot ) ; else if ( outformat == GPLOT_LATEX ) snprintf ( buf , L_BUF_SIZE , \"%s.tex\" , newroot ) ; gplot -> outname = stringNew ( buf ) ; if ( title ) gplot -> title = stringNew ( title ) ; if ( xlabel ) gplot -> xlabel = stringNew ( xlabel ) ; if ( ylabel ) gplot -> ylabel = stringNew ( ylabel ) ; return gplot ; }\n", "\n", "\n", "Target: ) length ) { quantum_info = DestroyQuantumInfo ( quantum_info ) ; \"UnableToReadImageData\" ) ; }\n", "\n", "Sources:\n", "0: CWE-772 static Image * ReadARTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { const unsigned char * pixels ; Image * image ; QuantumInfo * quantum_info ; QuantumType quantum_type ; MagickBooleanType status ; size_t length ; ssize_t count , y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 1 ; image -> endian = MSBEndian ; ( void ) ReadBlobLSBShort ( image ) ; image -> columns = ( size_t ) ReadBlobLSBShort ( image ) ; ( void ) ReadBlobLSBShort ( image ) ; image -> rows = ( size_t ) ReadBlobLSBShort ( image ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( AcquireImageColormap ( image , 2 ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } SetImageColorspace ( image , GRAYColorspace ) ; quantum_type = IndexQuantum ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; length = GetQuantumExtent ( image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register PixelPacket * magick_restrict q ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; ( void ) ReadBlobStream ( image , ( size_t ) ( - ( ssize_t ) length ) & 0x01 , GetQuantumPixels ( quantum_info ) , & count ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } SetQuantumImageType ( image , quantum_type ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-772 static Image * ReadARTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { const unsigned char * pixels ; Image * image ; QuantumInfo * quantum_info ; MagickBooleanType status ; size_t length ; ssize_t count , y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 1 ; image -> endian = MSBEndian ; ( void ) ReadBlobLSBShort ( image ) ; image -> columns = ( size_t ) ReadBlobLSBShort ( image ) ; ( void ) ReadBlobLSBShort ( image ) ; image -> rows = ( size_t ) ReadBlobLSBShort ( image ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; SetImageColorspace ( image , GRAYColorspace , exception ) ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; length = GetQuantumExtent ( image , quantum_info , GrayQuantum ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register Quantum * magick_restrict q ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , GrayQuantum , pixels , exception ) ; pixels = ( const unsigned char * ) ReadBlobStream ( image , ( size_t ) ( - ( ssize_t ) length ) & 0x01 , GetQuantumPixels ( quantum_info ) , & count ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( SetImageProgress ( image , LoadImageTag , y , image -> rows ) == MagickFalse ) break ; } SetQuantumImageType ( image , GrayQuantum ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ) { return NULL ; } while\n", "\n", "Sources:\n", "0: CWE-119 char * _multi_string_alloc_and_copy ( LPCWSTR in ) { char * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { len ++ ; } chr = malloc ( len + 2 ) ; len = 0 ; while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { chr [ len ] = 0xFF & in [ len ] ; len ++ ; } chr [ len ++ ] = '\\\\0' ; chr [ len ++ ] = '\\\\0' ; return chr ; }\n", "\n", "1: CWE-119 char * _single_string_alloc_and_copy ( LPCWSTR in ) { char * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 ) { len ++ ; } chr = malloc ( len + 1 ) ; len = 0 ; while ( in [ len ] != 0 ) { chr [ len ] = 0xFF & in [ len ] ; len ++ ; } chr [ len ++ ] = '\\\\0' ; return chr ; }\n", "\n", "2: CWE-119 SQLWCHAR * _multi_string_alloc_and_expand ( LPCSTR in ) { SQLWCHAR * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { len ++ ; } chr = malloc ( sizeof ( SQLWCHAR ) * ( len + 2 ) ) ; len = 0 ; while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { chr [ len ] = in [ len ] ; len ++ ; } chr [ len ++ ] = 0 ; chr [ len ++ ] = 0 ; return chr ; }\n", "\n", "3: CWE-119 SQLWCHAR * _single_string_alloc_and_expand ( LPCSTR in ) { SQLWCHAR * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 ) { len ++ ; } chr = malloc ( sizeof ( SQLWCHAR ) * ( len + 1 ) ) ; len = 0 ; while ( in [ len ] != 0 ) { chr [ len ] = in [ len ] ; len ++ ; } chr [ len ++ ] = 0 ; return chr ; }\n", "\n", "\n", "Target: setpwnam ( pw , \".chsh\"\n", "\n", "Sources:\n", "0: CWE-264 int main ( int argc , char * * argv ) { char * oldshell ; int nullshell = 0 ; const uid_t uid = getuid ( ) ; struct sinfo info = { 0 } ; struct passwd * pw ; sanitize_env ( ) ; setlocale ( LC_ALL , \"\" ) ; bindtextdomain ( PACKAGE , LOCALEDIR ) ; textdomain ( PACKAGE ) ; atexit ( close_stdout ) ; parse_argv ( argc , argv , & info ) ; if ( ! info . username ) { pw = getpwuid ( uid ) ; if ( ! pw ) errx ( EXIT_FAILURE , _ ( \"you(user%d)don\\'texist.\" ) , uid ) ; } else { pw = getpwnam ( info . username ) ; if ( ! pw ) errx ( EXIT_FAILURE , _ ( \"user\\\\\"%s\\\\\"doesnotexist.\" ) , info . username ) ; } # ifndef HAVE_LIBUSER if ( ! ( is_local ( pw -> pw_name ) ) ) errx ( EXIT_FAILURE , _ ( \"canonlychangelocalentries\" ) ) ; # endif # ifdef HAVE_LIBSELINUX if ( is_selinux_enabled ( ) > 0 ) { if ( uid == 0 ) { if ( checkAccess ( pw -> pw_name , PASSWD__CHSH ) != 0 ) { security_context_t user_context ; if ( getprevcon ( & user_context ) < 0 ) user_context = ( security_context_t ) NULL ; errx ( EXIT_FAILURE , _ ( \"%sisnotauthorizedtochangetheshellof%s\" ) , user_context ? : _ ( \"Unknownusercontext\" ) , pw -> pw_name ) ; } } if ( setupDefaultContext ( _PATH_PASSWD ) != 0 ) errx ( EXIT_FAILURE , _ ( \"can\\'tsetdefaultcontextfor%s\" ) , _PATH_PASSWD ) ; } # endif oldshell = pw -> pw_shell ; if ( oldshell == NULL || * oldshell == '\\\\0' ) { oldshell = _PATH_BSHELL ; nullshell = 1 ; } # ifdef HAVE_LIBUSER if ( geteuid ( ) != getuid ( ) && uid != pw -> pw_uid ) { # else if ( uid != 0 && uid != pw -> pw_uid ) { # endif errno = EACCES ; err ( EXIT_FAILURE , _ ( \"runningUIDdoesn\\'tmatchUIDofuserwe\\'re\" \"altering,shellchangedenied\" ) ) ; } if ( uid != 0 && ! get_shell_list ( oldshell ) ) { errno = EACCES ; err ( EXIT_FAILURE , _ ( \"yourshellisnotin%s,\" \"shellchangedenied\" ) , _PATH_SHELLS ) ; } printf ( _ ( \"Changingshellfor%s.\\\\n\" ) , pw -> pw_name ) ; # if ! defined ( HAVE_LIBUSER ) && defined ( CHFN_CHSH_PASSWORD ) if ( ! auth_pam ( \"chsh\" , uid , pw -> pw_name ) ) { return EXIT_FAILURE ; } # endif if ( ! info . shell ) { info . shell = ask_new_shell ( _ ( \"Newshell\" ) , oldshell ) ; if ( ! info . shell ) return EXIT_SUCCESS ; } check_shell ( info . shell ) ; if ( ! nullshell && strcmp ( oldshell , info . shell ) == 0 ) errx ( EXIT_SUCCESS , _ ( \"Shellnotchanged.\" ) ) ; # ifdef HAVE_LIBUSER if ( set_value_libuser ( \"chsh\" , pw -> pw_name , uid , LU_LOGINSHELL , info . shell ) < 0 ) errx ( EXIT_FAILURE , _ ( \"Shell*NOT*changed.Tryagainlater.\" ) ) ; # else pw -> pw_shell = info . shell ; if ( setpwnam ( pw ) < 0 ) err ( EXIT_FAILURE , _ ( \"setpwnamfailed\\\\n\" \"Shell*NOT*changed.Tryagainlater.\" ) ) ; # endif printf ( _ ( \"Shellchanged.\\\\n\" ) ) ; return EXIT_SUCCESS ; }\n", "\n", "1: CWE-000 int main ( int argc , char * * argv ) { char * oldshell ; int nullshell = 0 ; const uid_t uid = getuid ( ) ; struct sinfo info = { 0 } ; struct passwd * pw ; sanitize_env ( ) ; setlocale ( LC_ALL , \"\" ) ; bindtextdomain ( PACKAGE , LOCALEDIR ) ; textdomain ( PACKAGE ) ; atexit ( close_stdout ) ; parse_argv ( argc , argv , & info ) ; if ( ! info . username ) { pw = getpwuid ( uid ) ; if ( ! pw ) errx ( EXIT_FAILURE , _ ( \"you(user%d)don\\'texist.\" ) , uid ) ; } else { pw = getpwnam ( info . username ) ; if ( ! pw ) errx ( EXIT_FAILURE , _ ( \"user\\\\\"%s\\\\\"doesnotexist.\" ) , info . username ) ; } # ifndef HAVE_LIBUSER if ( ! ( is_local ( pw -> pw_name ) ) ) errx ( EXIT_FAILURE , _ ( \"canonlychangelocalentries\" ) ) ; # endif # ifdef HAVE_LIBSELINUX if ( is_selinux_enabled ( ) > 0 ) { if ( uid == 0 ) { if ( checkAccess ( pw -> pw_name , PASSWD__CHSH ) != 0 ) { security_context_t user_context ; if ( getprevcon ( & user_context ) < 0 ) user_context = ( security_context_t ) NULL ; errx ( EXIT_FAILURE , _ ( \"%sisnotauthorizedtochangetheshellof%s\" ) , user_context ? : _ ( \"Unknownusercontext\" ) , pw -> pw_name ) ; } } if ( setupDefaultContext ( _PATH_PASSWD ) != 0 ) errx ( EXIT_FAILURE , _ ( \"can\\'tsetdefaultcontextfor%s\" ) , _PATH_PASSWD ) ; } # endif oldshell = pw -> pw_shell ; if ( oldshell == NULL || * oldshell == '\\\\0' ) { oldshell = _PATH_BSHELL ; nullshell = 1 ; } # ifdef HAVE_LIBUSER if ( geteuid ( ) != getuid ( ) && uid != pw -> pw_uid ) { # else if ( uid != 0 && uid != pw -> pw_uid ) { # endif errno = EACCES ; err ( EXIT_FAILURE , _ ( \"runningUIDdoesn\\'tmatchUIDofuserwe\\'re\" \"altering,shellchangedenied\" ) ) ; } if ( uid != 0 && ! get_shell_list ( oldshell ) ) { errno = EACCES ; err ( EXIT_FAILURE , _ ( \"yourshellisnotin%s,\" \"shellchangedenied\" ) , _PATH_SHELLS ) ; } printf ( _ ( \"Changingshellfor%s.\\\\n\" ) , pw -> pw_name ) ; # if ! defined ( HAVE_LIBUSER ) && defined ( CHFN_CHSH_PASSWORD ) if ( ! auth_pam ( \"chsh\" , uid , pw -> pw_name ) ) { return EXIT_FAILURE ; } # endif if ( ! info . shell ) { info . shell = ask_new_shell ( _ ( \"Newshell\" ) , oldshell ) ; if ( ! info . shell ) return EXIT_SUCCESS ; } check_shell ( info . shell ) ; if ( ! nullshell && strcmp ( oldshell , info . shell ) == 0 ) errx ( EXIT_SUCCESS , _ ( \"Shellnotchanged.\" ) ) ; # ifdef HAVE_LIBUSER if ( set_value_libuser ( \"chsh\" , pw -> pw_name , uid , LU_LOGINSHELL , info . shell ) < 0 ) errx ( EXIT_FAILURE , _ ( \"Shell*NOT*changed.Tryagainlater.\" ) ) ; # else pw -> pw_shell = info . shell ; if ( setpwnam ( pw ) < 0 ) err ( EXIT_FAILURE , _ ( \"setpwnamfailed\\\\n\" \"Shell*NOT*changed.Tryagainlater.\" ) ) ; # endif printf ( _ ( \"Shellchanged.\\\\n\" ) ) ; return EXIT_SUCCESS ; }\n", "\n", "\n", "Target: vpx_codec_alg_priv_t * ctx , va_list args\n", "\n", "Sources:\n", "0: CWE-119 static vpx_codec_err_t vp8e_set_roi_map ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_roi_map_t * data = va_arg ( args , vpx_roi_map_t * ) ; if ( data ) { vpx_roi_map_t * roi = ( vpx_roi_map_t * ) data ; if ( ! vp8_set_roimap ( ctx -> cpi , roi -> roi_map , roi -> rows , roi -> cols , roi -> delta_q , roi -> delta_lf , roi -> static_threshold ) ) return VPX_CODEC_OK ; else return VPX_CODEC_INVALID_PARAM ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "1: CWE-119 static vpx_codec_err_t vp8e_get_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * data = va_arg ( args , vpx_ref_frame_t * ) ; if ( data ) { vpx_ref_frame_t * frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; vp8_get_reference ( ctx -> cpi , frame -> frame_type , & sd ) ; return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "2: CWE-119 static vpx_codec_err_t vp8e_update_entropy ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { int update = va_arg ( args , int ) ; vp8_update_entropy ( ctx -> cpi , update ) ; return VPX_CODEC_OK ; }\n", "\n", "3: CWE-119 static vpx_codec_err_t vp8_get_last_ref_frame ( vpx_codec_alg_priv_t * ctx , int ctrl_id , va_list args ) { int * ref_info = va_arg ( args , int * ) ; if ( ref_info && ! ctx -> yv12_frame_buffers . use_frame_threads ) { VP8D_COMP * pbi = ( VP8D_COMP * ) ctx -> yv12_frame_buffers . pbi [ 0 ] ; VP8_COMMON * oci = & pbi -> common ; * ref_info = ( vp8dx_references_buffer ( oci , ALTREF_FRAME ) ? VP8_ALTR_FRAME : 0 ) | ( vp8dx_references_buffer ( oci , GOLDEN_FRAME ) ? VP8_GOLD_FRAME : 0 ) | ( vp8dx_references_buffer ( oci , LAST_FRAME ) ? VP8_LAST_FRAME : 0 ) ; return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "4: CWE-119 static vpx_codec_err_t vp8e_set_activemap ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_active_map_t * data = va_arg ( args , vpx_active_map_t * ) ; if ( data ) { vpx_active_map_t * map = ( vpx_active_map_t * ) data ; if ( ! vp8_set_active_map ( ctx -> cpi , map -> active_map , map -> rows , map -> cols ) ) return VPX_CODEC_OK ; else return VPX_CODEC_INVALID_PARAM ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "5: CWE-119 static vpx_codec_err_t vp8e_set_scalemode ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_scaling_mode_t * data = va_arg ( args , vpx_scaling_mode_t * ) ; if ( data ) { int res ; vpx_scaling_mode_t scalemode = * ( vpx_scaling_mode_t * ) data ; res = vp8_set_internal_size ( ctx -> cpi , ( VPX_SCALING ) scalemode . h_scaling_mode , ( VPX_SCALING ) scalemode . v_scaling_mode ) ; if ( ! res ) { ctx -> next_frame_flag |= FRAMEFLAGS_KEY ; return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "6: CWE-119 static vpx_codec_err_t vp8e_use_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { int reference_flag = va_arg ( args , int ) ; vp8_use_as_reference ( ctx -> cpi , reference_flag ) ; return VPX_CODEC_OK ; }\n", "\n", "7: CWE-119 static vpx_codec_err_t vp8e_update_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { int update = va_arg ( args , int ) ; vp8_update_reference ( ctx -> cpi , update ) ; return VPX_CODEC_OK ; }\n", "\n", "8: CWE-119 static vpx_codec_err_t vp8_get_last_ref_updates ( vpx_codec_alg_priv_t * ctx , int ctrl_id , va_list args ) { int * update_info = va_arg ( args , int * ) ; if ( update_info && ! ctx -> yv12_frame_buffers . use_frame_threads ) { VP8D_COMP * pbi = ( VP8D_COMP * ) ctx -> yv12_frame_buffers . pbi [ 0 ] ; * update_info = pbi -> common . refresh_alt_ref_frame * ( int ) VP8_ALTR_FRAME + pbi -> common . refresh_golden_frame * ( int ) VP8_GOLD_FRAME + pbi -> common . refresh_last_frame * ( int ) VP8_LAST_FRAME ; return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "9: CWE-119 static vpx_codec_err_t ctrl_set_svc_layer_id ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_svc_layer_id_t * const data = va_arg ( args , vpx_svc_layer_id_t * ) ; VP9_COMP * const cpi = ( VP9_COMP * ) ctx -> cpi ; SVC * const svc = & cpi -> svc ; svc -> spatial_layer_id = data -> spatial_layer_id ; svc -> temporal_layer_id = data -> temporal_layer_id ; if ( svc -> temporal_layer_id < 0 || svc -> temporal_layer_id >= ( int ) ctx -> cfg . ts_number_layers ) { return VPX_CODEC_INVALID_PARAM ; } if ( svc -> spatial_layer_id < 0 || svc -> spatial_layer_id >= ( int ) ctx -> cfg . ss_number_layers ) { return VPX_CODEC_INVALID_PARAM ; } return VPX_CODEC_OK ; }\n", "\n", "10: CWE-119 static vpx_codec_err_t vp8e_set_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * data = va_arg ( args , vpx_ref_frame_t * ) ; if ( data ) { vpx_ref_frame_t * frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; vp8_set_reference ( ctx -> cpi , frame -> frame_type , & sd ) ; return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "11: CWE-119 static vpx_codec_err_t vp8_set_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * data = va_arg ( args , vpx_ref_frame_t * ) ; if ( data && ! ctx -> yv12_frame_buffers . use_frame_threads ) { vpx_ref_frame_t * frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; return vp8dx_set_reference ( ctx -> yv12_frame_buffers . pbi [ 0 ] , frame -> frame_type , & sd ) ; } else return VPX_CODEC_INVALID_PARAM ; }\n", "\n", "\n", "Target: NULL ) { status = MagickFalse ; break ; } image\n", "\n", "Sources:\n", "0: CWE-399 static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo { unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ; char comment [ 512 ] ; unsigned int rows , columns , subrows ; int x_offset , y_offset ; float x_bits_per_pixel , y_bits_per_pixel ; unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ; } ViffInfo ; double min_value , scale_factor , value ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_pixel , max_packets , quantum ; ssize_t count , y ; unsigned char * pixels ; unsigned long lsb_first ; ViffInfo viff_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & viff_info . identifier ) ; do { if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , \"NotAVIFFImage\" ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ; count = ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ; if ( count != 512 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_info . comment [ 511 ] = '\\\\0' ; if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , \"comment\" , viff_info . comment , exception ) ; if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ; else image -> endian = MSBEndian ; viff_info . rows = ReadBlobLong ( image ) ; viff_info . columns = ReadBlobLong ( image ) ; viff_info . subrows = ReadBlobLong ( image ) ; viff_info . x_offset = ReadBlobSignedLong ( image ) ; viff_info . y_offset = ReadBlobSignedLong ( image ) ; viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . location_type = ReadBlobLong ( image ) ; viff_info . location_dimension = ReadBlobLong ( image ) ; viff_info . number_of_images = ReadBlobLong ( image ) ; viff_info . number_data_bands = ReadBlobLong ( image ) ; viff_info . data_storage_type = ReadBlobLong ( image ) ; viff_info . data_encode_scheme = ReadBlobLong ( image ) ; viff_info . map_scheme = ReadBlobLong ( image ) ; viff_info . map_storage_type = ReadBlobLong ( image ) ; viff_info . map_rows = ReadBlobLong ( image ) ; viff_info . map_columns = ReadBlobLong ( image ) ; viff_info . map_subrows = ReadBlobLong ( image ) ; viff_info . map_enable = ReadBlobLong ( image ) ; viff_info . maps_per_cycle = ReadBlobLong ( image ) ; viff_info . color_space_model = ReadBlobLong ( image ) ; for ( i = 0 ; i < 420 ; i ++ ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ; if ( number_pixels > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( number_pixels == 0 ) ThrowReaderException ( CoderError , \"ImageColumnOrRowSizeIsNotSupported\" ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ; image -> alpha_trait = viff_info . number_data_bands == 4 ? BlendPixelTrait : UndefinedPixelTrait ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; ( void ) SetImageBackgroundColor ( image , exception ) ; if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"DataStorageTypeIsNotSupported\" ) ; if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"MapStorageTypeIsNotSupported\" ) ; if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , \"ColorspaceModelIsNotSupported\" ) ; if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , \"LocationTypeIsNotSupported\" ) ; if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , \"NumberOfImagesIsNotSupported\" ) ; if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ; switch ( ( int ) viff_info . map_scheme ) { case VFF_MS_NONE : { if ( viff_info . number_data_bands < 3 ) { if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ; else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ; else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ; status = AcquireImageColormap ( image , image -> colors , exception ) ; if ( status == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : { unsigned char * viff_colormap ; switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ; break ; case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } image -> colors = viff_info . map_columns ; if ( ( MagickSizeType ) ( viff_info . map_rows * image -> colors ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( MagickSizeType ) viff_info . map_rows > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ( MagickSizeType ) viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ; if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : { MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : { MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } default : break ; } for ( i = 0 ; i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ; i ++ ) { switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ; break ; default : value = 1.0 * viff_colormap [ i ] ; break ; } if ( i < ( ssize_t ) image -> colors ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; } else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; } viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ; break ; } default : ThrowReaderException ( CoderError , \"ColormapTypeNotSupported\" ) ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { image -> colors = 2 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; image -> colorspace = GRAYColorspace ; } switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_TYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } if ( viff_info . data_storage_type == VFF_TYP_BIT ) { if ( HeapOverflowSanityCheck ( ( image -> columns + 7UL ) >> 3UL , image -> rows ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ; } else { if ( HeapOverflowSanityCheck ( ( size_t ) number_pixels , viff_info . number_data_bands ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ; } if ( ( MagickSizeType ) ( bytes_per_pixel * max_packets ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( number_pixels , max_packets ) , bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( pixels , 0 , MagickMax ( number_pixels , max_packets ) * bytes_per_pixel * sizeof ( * pixels ) ) ; count = ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : { MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ; break ; } case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : { MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ; break ; } default : break ; } min_value = 0.0 ; scale_factor = 1.0 ; if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) { double max_value ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ; break ; default : value = 1.0 * pixels [ 0 ] ; break ; } max_value = value ; min_value = value ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( value > max_value ) max_value = value ; else if ( value < min_value ) min_value = value ; } if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ; else if ( min_value == max_value ) { scale_factor = ( double ) QuantumRange / min_value ; min_value = 0 ; } else scale_factor = ( double ) QuantumRange / ( max_value - min_value ) ; } p = ( unsigned char * ) pixels ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( viff_info . map_scheme == VFF_MS_NONE ) { value = ( value - min_value ) * scale_factor ; if ( value > QuantumRange ) value = QuantumRange ; else if ( value < 0 ) value = 0 ; } * p = ( unsigned char ) ( ( Quantum ) value ) ; p ++ ; } p = ( unsigned char * ) pixels ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( int ) ( image -> columns % 8 ) ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else if ( image -> storage_class == PseudoClass ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else { number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * ( p + number_pixels ) ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) , q ) ; if ( image -> colors != 0 ) { ssize_t index ; index = ( ssize_t ) GetPixelRed ( image , q ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . red ) , q ) ; index = ( ssize_t ) GetPixelGreen ( image , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . green ) , q ) ; index = ( ssize_t ) GetPixelBlue ( image , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . blue ) , q ) ; } SetPixelAlpha ( image , image -> alpha_trait != UndefinedPixelTrait ? ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueAlpha , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; count = ReadBlob ( image , 1 , & viff_info . identifier ) ; if ( ( count == 1 ) && ( viff_info . identifier == 0xab ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-401 static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo { unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ; char comment [ 512 ] ; unsigned int rows , columns , subrows ; int x_offset , y_offset ; float x_bits_per_pixel , y_bits_per_pixel ; unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ; } ViffInfo ; double min_value , scale_factor , value ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_pixel , max_packets , quantum ; ssize_t count , y ; unsigned char * pixels ; unsigned long lsb_first ; ViffInfo viff_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & viff_info . identifier ) ; do { if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , \"NotAVIFFImage\" ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ; count = ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ; if ( count != 512 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_info . comment [ 511 ] = '\\\\0' ; if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , \"comment\" , viff_info . comment , exception ) ; if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ; else image -> endian = MSBEndian ; viff_info . rows = ReadBlobLong ( image ) ; viff_info . columns = ReadBlobLong ( image ) ; viff_info . subrows = ReadBlobLong ( image ) ; viff_info . x_offset = ReadBlobSignedLong ( image ) ; viff_info . y_offset = ReadBlobSignedLong ( image ) ; viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . location_type = ReadBlobLong ( image ) ; viff_info . location_dimension = ReadBlobLong ( image ) ; viff_info . number_of_images = ReadBlobLong ( image ) ; viff_info . number_data_bands = ReadBlobLong ( image ) ; viff_info . data_storage_type = ReadBlobLong ( image ) ; viff_info . data_encode_scheme = ReadBlobLong ( image ) ; viff_info . map_scheme = ReadBlobLong ( image ) ; viff_info . map_storage_type = ReadBlobLong ( image ) ; viff_info . map_rows = ReadBlobLong ( image ) ; viff_info . map_columns = ReadBlobLong ( image ) ; viff_info . map_subrows = ReadBlobLong ( image ) ; viff_info . map_enable = ReadBlobLong ( image ) ; viff_info . maps_per_cycle = ReadBlobLong ( image ) ; viff_info . color_space_model = ReadBlobLong ( image ) ; for ( i = 0 ; i < 420 ; i ++ ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ; if ( number_pixels > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( number_pixels == 0 ) ThrowReaderException ( CoderError , \"ImageColumnOrRowSizeIsNotSupported\" ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ; image -> alpha_trait = viff_info . number_data_bands == 4 ? BlendPixelTrait : UndefinedPixelTrait ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; ( void ) SetImageBackgroundColor ( image , exception ) ; if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"DataStorageTypeIsNotSupported\" ) ; if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , \"DataEncodingSchemeIsNotSupported\" ) ; if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , \"MapStorageTypeIsNotSupported\" ) ; if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , \"ColorspaceModelIsNotSupported\" ) ; if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , \"LocationTypeIsNotSupported\" ) ; if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , \"NumberOfImagesIsNotSupported\" ) ; if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ; switch ( ( int ) viff_info . map_scheme ) { case VFF_MS_NONE : { if ( viff_info . number_data_bands < 3 ) { if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ; else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ; else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ; status = AcquireImageColormap ( image , image -> colors , exception ) ; if ( status == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : { unsigned char * viff_colormap ; switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ; break ; case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } image -> colors = viff_info . map_columns ; if ( ( MagickSizeType ) ( viff_info . map_rows * image -> colors ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( MagickSizeType ) viff_info . map_rows > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ( MagickSizeType ) viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ; if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : { MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : { MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } default : break ; } for ( i = 0 ; i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ; i ++ ) { switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ; break ; default : value = 1.0 * viff_colormap [ i ] ; break ; } if ( i < ( ssize_t ) image -> colors ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; } else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) value ) ; } viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ; break ; } default : ThrowReaderException ( CoderError , \"ColormapTypeNotSupported\" ) ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { image -> colors = 2 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; image -> colorspace = GRAYColorspace ; } switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_TYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } if ( viff_info . data_storage_type == VFF_TYP_BIT ) { if ( HeapOverflowSanityCheck ( ( image -> columns + 7UL ) >> 3UL , image -> rows ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ; } else { if ( HeapOverflowSanityCheck ( ( size_t ) number_pixels , viff_info . number_data_bands ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ; } if ( ( MagickSizeType ) ( bytes_per_pixel * max_packets ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( number_pixels , max_packets ) , bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( pixels , 0 , MagickMax ( number_pixels , max_packets ) * bytes_per_pixel * sizeof ( * pixels ) ) ; count = ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : { MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ; break ; } case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : { MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ; break ; } default : break ; } min_value = 0.0 ; scale_factor = 1.0 ; if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) { double max_value ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ; break ; default : value = 1.0 * pixels [ 0 ] ; break ; } max_value = value ; min_value = value ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( value > max_value ) max_value = value ; else if ( value < min_value ) min_value = value ; } if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ; else if ( min_value == max_value ) { scale_factor = ( double ) QuantumRange / min_value ; min_value = 0 ; } else scale_factor = ( double ) QuantumRange / ( max_value - min_value ) ; } p = ( unsigned char * ) pixels ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( viff_info . map_scheme == VFF_MS_NONE ) { value = ( value - min_value ) * scale_factor ; if ( value > QuantumRange ) value = QuantumRange ; else if ( value < 0 ) value = 0 ; } * p = ( unsigned char ) ( ( Quantum ) value ) ; p ++ ; } p = ( unsigned char * ) pixels ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( int ) ( image -> columns % 8 ) ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else if ( image -> storage_class == PseudoClass ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else { number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * ( p + number_pixels ) ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) , q ) ; if ( image -> colors != 0 ) { ssize_t index ; index = ( ssize_t ) GetPixelRed ( image , q ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . red ) , q ) ; index = ( ssize_t ) GetPixelGreen ( image , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . green ) , q ) ; index = ( ssize_t ) GetPixelBlue ( image , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . blue ) , q ) ; } SetPixelAlpha ( image , image -> alpha_trait != UndefinedPixelTrait ? ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueAlpha , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; count = ReadBlob ( image , 1 , & viff_info . identifier ) ; if ( ( count == 1 ) && ( viff_info . identifier == 0xab ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: buf [ MAX_PKT_SIZE + 1 ( buf ) - 1 0 ) { if ( sa\n", "\n", "Sources:\n", "0: CWE-787 static void ssdp_recv ( int sd ) { ssize_t len ; struct sockaddr sa ; socklen_t salen ; char buf [ MAX_PKT_SIZE ] ; memset ( buf , 0 , sizeof ( buf ) ) ; len = recvfrom ( sd , buf , sizeof ( buf ) , MSG_DONTWAIT , & sa , & salen ) ; if ( len > 0 ) { buf [ len ] = 0 ; if ( sa . sa_family != AF_INET ) return ; if ( strstr ( buf , \"M-SEARCH*\" ) ) { size_t i ; char * ptr , * type ; struct ifsock * ifs ; struct sockaddr_in * sin = ( struct sockaddr_in * ) & sa ; ifs = find_outbound ( & sa ) ; if ( ! ifs ) { logit ( LOG_DEBUG , \"Nomatchingsocketforclient%s\" , inet_ntoa ( sin -> sin_addr ) ) ; return ; } logit ( LOG_DEBUG , \"Matchingsocketforclient%s\" , inet_ntoa ( sin -> sin_addr ) ) ; type = strcasestr ( buf , \"\\\\r\\\\nST:\" ) ; if ( ! type ) { logit ( LOG_DEBUG , \"NoSearchType(ST:)foundinM-SEARCH*,assuming\" SSDP_ST_ALL ) ; type = SSDP_ST_ALL ; send_message ( ifs , type , & sa ) ; return ; } type = strchr ( type , ':' ) ; if ( ! type ) return ; type ++ ; while ( isspace ( * type ) ) type ++ ; ptr = strstr ( type , \"\\\\r\\\\n\" ) ; if ( ! ptr ) return ; * ptr = 0 ; for ( i = 0 ; supported_types [ i ] ; i ++ ) { if ( ! strcmp ( supported_types [ i ] , type ) ) { logit ( LOG_DEBUG , \"M-SEARCH*ST:%sfrom%sport%d\" , type , inet_ntoa ( sin -> sin_addr ) , ntohs ( sin -> sin_port ) ) ; send_message ( ifs , type , & sa ) ; return ; } } logit ( LOG_DEBUG , \"M-SEARCH*forunsupportedST:%sfrom%s\" , type , inet_ntoa ( sin -> sin_addr ) ) ; } } }\n", "\n", "1: CWE-119 static void ssdp_recv ( int sd ) { ssize_t len ; struct sockaddr sa ; socklen_t salen ; char buf [ MAX_PKT_SIZE ] ; memset ( buf , 0 , sizeof ( buf ) ) ; len = recvfrom ( sd , buf , sizeof ( buf ) , MSG_DONTWAIT , & sa , & salen ) ; if ( len > 0 ) { buf [ len ] = 0 ; if ( sa . sa_family != AF_INET ) return ; if ( strstr ( buf , \"M-SEARCH*\" ) ) { size_t i ; char * ptr , * type ; struct ifsock * ifs ; struct sockaddr_in * sin = ( struct sockaddr_in * ) & sa ; ifs = find_outbound ( & sa ) ; if ( ! ifs ) { logit ( LOG_DEBUG , \"Nomatchingsocketforclient%s\" , inet_ntoa ( sin -> sin_addr ) ) ; return ; } logit ( LOG_DEBUG , \"Matchingsocketforclient%s\" , inet_ntoa ( sin -> sin_addr ) ) ; type = strcasestr ( buf , \"\\\\r\\\\nST:\" ) ; if ( ! type ) { logit ( LOG_DEBUG , \"NoSearchType(ST:)foundinM-SEARCH*,assuming\" SSDP_ST_ALL ) ; type = SSDP_ST_ALL ; send_message ( ifs , type , & sa ) ; return ; } type = strchr ( type , ':' ) ; if ( ! type ) return ; type ++ ; while ( isspace ( * type ) ) type ++ ; ptr = strstr ( type , \"\\\\r\\\\n\" ) ; if ( ! ptr ) return ; * ptr = 0 ; for ( i = 0 ; supported_types [ i ] ; i ++ ) { if ( ! strcmp ( supported_types [ i ] , type ) ) { logit ( LOG_DEBUG , \"M-SEARCH*ST:%sfrom%sport%d\" , type , inet_ntoa ( sin -> sin_addr ) , ntohs ( sin -> sin_port ) ) ; send_message ( ifs , type , & sa ) ; return ; } } logit ( LOG_DEBUG , \"M-SEARCH*forunsupportedST:%sfrom%s\" , type , inet_ntoa ( sin -> sin_addr ) ) ; } } }\n", "\n", "\n", "Target: , unsigned long npages ) { gfn_t = gfn + npages ; gfn +=\n", "\n", "Sources:\n", "0: CWE-119 static pfn_t kvm_pin_pages ( struct kvm_memory_slot * slot , gfn_t gfn , unsigned long size ) { gfn_t end_gfn ; pfn_t pfn ; pfn = gfn_to_pfn_memslot ( slot , gfn ) ; end_gfn = gfn + ( size >> PAGE_SHIFT ) ; gfn += 1 ; if ( is_error_noslot_pfn ( pfn ) ) return pfn ; while ( gfn < end_gfn ) gfn_to_pfn_memslot ( slot , gfn ++ ) ; return pfn ; }\n", "\n", "1: CWE-189 static pfn_t kvm_pin_pages ( struct kvm_memory_slot * slot , gfn_t gfn , unsigned long size ) { gfn_t end_gfn ; pfn_t pfn ; pfn = gfn_to_pfn_memslot ( slot , gfn ) ; end_gfn = gfn + ( size >> PAGE_SHIFT ) ; gfn += 1 ; if ( is_error_noslot_pfn ( pfn ) ) return pfn ; while ( gfn < end_gfn ) gfn_to_pfn_memslot ( slot , gfn ++ ) ; return pfn ; }\n", "\n", "\n", "Target: ; if ( key_is_positive ( key )\n", "\n", "Sources:\n", "0: CWE-20 void big_key_revoke ( struct key * key ) { struct path * path = ( struct path * ) & key -> payload . data [ big_key_path ] ; key_payload_reserve ( key , 0 ) ; if ( key_is_instantiated ( key ) && ( size_t ) key -> payload . data [ big_key_len ] > BIG_KEY_FILE_THRESHOLD ) vfs_truncate ( path , 0 ) ; }\n", "\n", "1: CWE-20 static void request_key_auth_describe ( const struct key * key , struct seq_file * m ) { struct request_key_auth * rka = key -> payload . data [ 0 ] ; seq_puts ( m , \"key:\" ) ; seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) seq_printf ( m , \"pid:%dci:%zu\" , rka -> pid , rka -> callout_len ) ; }\n", "\n", "2: CWE-20 void big_key_describe ( const struct key * key , struct seq_file * m ) { size_t datalen = ( size_t ) key -> payload . data [ big_key_len ] ; seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) seq_printf ( m , \":%zu[%s]\" , datalen , datalen > BIG_KEY_FILE_THRESHOLD ? \"file\" : \"buff\" ) ; }\n", "\n", "3: CWE-20 static void dns_resolver_describe ( const struct key * key , struct seq_file * m ) { seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) { int err = PTR_ERR ( key -> payload . data [ dns_key_error ] ) ; if ( err ) seq_printf ( m , \":%d\" , err ) ; else seq_printf ( m , \":%u\" , key -> datalen ) ; } }\n", "\n", "\n", "Target: int res , i , indexes , index_bytes ; unsigned int ids ; long long bytes ; long long id_table ) ; ids = id_table . xattr_ids ; xattr_table_start = id_table . . xattr_table_start ; index_bytes = SQUASHFS_XATTR_BLOCK_BYTES ( ( long long ) ids ) ; indexes = SQUASHFS_XATTR_BLOCKS ( ( long long ) ids ) ; if ( index_bytes != ( sBlk -> bytes_used - ( sBlk -> xattr_id_table_start ( id_table ) ) ) ) { ERROR ( \"read_xattrs_from_disk:Badxattr_idscountinsuperblock\\\\n\" ) ; return 0 ; } if ( table_start != NULL ) * table_start = id_table . xattr_table_start ; if ( flag ) return id_table . xattr_ids ; index = malloc ( index_bytes ) ; if ( index == NULL ) MEM_ERROR ( ) ; res = read_fs_bytes ( fd , sBlk -> xattr_id_table_start + sizeof ( id_table ) = SQUASHFS_XATTR_BYTES ( ( long long ) ) + ( ( long long )\n", "\n", "Sources:\n", "0: CWE-190 int read_xattrs_from_disk ( int fd , struct squashfs_super_block * sBlk , int flag , long long * table_start ) { int res , bytes , i , indexes , index_bytes , ids ; long long * index , start , end ; struct squashfs_xattr_table id_table ; TRACE ( \"read_xattrs_from_disk\\\\n\" ) ; if ( sBlk -> xattr_id_table_start == SQUASHFS_INVALID_BLK ) return SQUASHFS_INVALID_BLK ; res = read_fs_bytes ( fd , sBlk -> xattr_id_table_start , sizeof ( id_table ) , & id_table ) ; if ( res == 0 ) return 0 ; SQUASHFS_INSWAP_XATTR_TABLE ( & id_table ) ; if ( flag ) { * table_start = id_table . xattr_table_start ; return id_table . xattr_ids ; } ids = id_table . xattr_ids ; xattr_table_start = id_table . xattr_table_start ; index_bytes = SQUASHFS_XATTR_BLOCK_BYTES ( ids ) ; indexes = SQUASHFS_XATTR_BLOCKS ( ids ) ; index = malloc ( index_bytes ) ; if ( index == NULL ) MEM_ERROR ( ) ; res = read_fs_bytes ( fd , sBlk -> xattr_id_table_start + sizeof ( id_table ) , index_bytes , index ) ; if ( res == 0 ) goto failed1 ; SQUASHFS_INSWAP_LONG_LONGS ( index , indexes ) ; bytes = SQUASHFS_XATTR_BYTES ( ids ) ; xattr_ids = malloc ( bytes ) ; if ( xattr_ids == NULL ) MEM_ERROR ( ) ; for ( i = 0 ; i < indexes ; i ++ ) { int expected = ( i + 1 ) != indexes ? SQUASHFS_METADATA_SIZE : bytes & ( SQUASHFS_METADATA_SIZE - 1 ) ; int length = read_block ( fd , index [ i ] , NULL , expected , ( ( unsigned char * ) xattr_ids ) + ( i * SQUASHFS_METADATA_SIZE ) ) ; TRACE ( \"Readxattridtableblock%d,from0x%llx,length\" \"%d\\\\n\" , i , index [ i ] , length ) ; if ( length == 0 ) { ERROR ( \"Failedtoreadxattridtableblock%d,\" \"from0x%llx,length%d\\\\n\" , i , index [ i ] , length ) ; goto failed2 ; } } start = xattr_table_start ; end = index [ 0 ] ; for ( i = 0 ; start < end ; i ++ ) { int length ; xattrs = realloc ( xattrs , ( i + 1 ) * SQUASHFS_METADATA_SIZE ) ; if ( xattrs == NULL ) MEM_ERROR ( ) ; save_xattr_block ( start , i * SQUASHFS_METADATA_SIZE ) ; length = read_block ( fd , start , & start , 0 , ( ( unsigned char * ) xattrs ) + ( i * SQUASHFS_METADATA_SIZE ) ) ; TRACE ( \"Readxattrblock%d,length%d\\\\n\" , i , length ) ; if ( length == 0 ) { ERROR ( \"Failedtoreadxattrblock%d\\\\n\" , i ) ; goto failed3 ; } if ( start != end && length != SQUASHFS_METADATA_SIZE ) { ERROR ( \"Xattrblock%dshouldbe%dbytesinlength,\" \"itis%dbytes\\\\n\" , i , SQUASHFS_METADATA_SIZE , length ) ; goto failed3 ; } } for ( i = 0 ; i < ids ; i ++ ) SQUASHFS_INSWAP_XATTR_ID ( & xattr_ids [ i ] ) ; free ( index ) ; return ids ; failed3 : free ( xattrs ) ; failed2 : free ( xattr_ids ) ; failed1 : free ( index ) ; return 0 ; }\n", "\n", "1: CWE-20 int read_xattrs_from_disk ( int fd , struct squashfs_super_block * sBlk , int flag , long long * table_start ) { int res , bytes , i , indexes , index_bytes , ids ; long long * index , start , end ; struct squashfs_xattr_table id_table ; TRACE ( \"read_xattrs_from_disk\\\\n\" ) ; if ( sBlk -> xattr_id_table_start == SQUASHFS_INVALID_BLK ) return SQUASHFS_INVALID_BLK ; res = read_fs_bytes ( fd , sBlk -> xattr_id_table_start , sizeof ( id_table ) , & id_table ) ; if ( res == 0 ) return 0 ; SQUASHFS_INSWAP_XATTR_TABLE ( & id_table ) ; if ( flag ) { * table_start = id_table . xattr_table_start ; return id_table . xattr_ids ; } ids = id_table . xattr_ids ; xattr_table_start = id_table . xattr_table_start ; index_bytes = SQUASHFS_XATTR_BLOCK_BYTES ( ids ) ; indexes = SQUASHFS_XATTR_BLOCKS ( ids ) ; index = malloc ( index_bytes ) ; if ( index == NULL ) MEM_ERROR ( ) ; res = read_fs_bytes ( fd , sBlk -> xattr_id_table_start + sizeof ( id_table ) , index_bytes , index ) ; if ( res == 0 ) goto failed1 ; SQUASHFS_INSWAP_LONG_LONGS ( index , indexes ) ; bytes = SQUASHFS_XATTR_BYTES ( ids ) ; xattr_ids = malloc ( bytes ) ; if ( xattr_ids == NULL ) MEM_ERROR ( ) ; for ( i = 0 ; i < indexes ; i ++ ) { int expected = ( i + 1 ) != indexes ? SQUASHFS_METADATA_SIZE : bytes & ( SQUASHFS_METADATA_SIZE - 1 ) ; int length = read_block ( fd , index [ i ] , NULL , expected , ( ( unsigned char * ) xattr_ids ) + ( i * SQUASHFS_METADATA_SIZE ) ) ; TRACE ( \"Readxattridtableblock%d,from0x%llx,length\" \"%d\\\\n\" , i , index [ i ] , length ) ; if ( length == 0 ) { ERROR ( \"Failedtoreadxattridtableblock%d,\" \"from0x%llx,length%d\\\\n\" , i , index [ i ] , length ) ; goto failed2 ; } } start = xattr_table_start ; end = index [ 0 ] ; for ( i = 0 ; start < end ; i ++ ) { int length ; xattrs = realloc ( xattrs , ( i + 1 ) * SQUASHFS_METADATA_SIZE ) ; if ( xattrs == NULL ) MEM_ERROR ( ) ; save_xattr_block ( start , i * SQUASHFS_METADATA_SIZE ) ; length = read_block ( fd , start , & start , 0 , ( ( unsigned char * ) xattrs ) + ( i * SQUASHFS_METADATA_SIZE ) ) ; TRACE ( \"Readxattrblock%d,length%d\\\\n\" , i , length ) ; if ( length == 0 ) { ERROR ( \"Failedtoreadxattrblock%d\\\\n\" , i ) ; goto failed3 ; } if ( start != end && length != SQUASHFS_METADATA_SIZE ) { ERROR ( \"Xattrblock%dshouldbe%dbytesinlength,\" \"itis%dbytes\\\\n\" , i , SQUASHFS_METADATA_SIZE , length ) ; goto failed3 ; } } for ( i = 0 ; i < ids ; i ++ ) SQUASHFS_INSWAP_XATTR_ID ( & xattr_ids [ i ] ) ; free ( index ) ; return ids ; failed3 : free ( xattrs ) ; failed2 : free ( xattr_ids ) ; failed1 : free ( index ) ; return 0 ; }\n", "\n", "\n", "Target: ! unconditional ( e ) ) return\n", "\n", "Sources:\n", "0: CWE-119 static bool check_underflow ( const struct ip6t_entry * e ) { const struct xt_entry_target * t ; unsigned int verdict ; if ( ! unconditional ( & e -> ipv6 ) ) return false ; t = ip6t_get_target_c ( e ) ; if ( strcmp ( t -> u . user . name , XT_STANDARD_TARGET ) != 0 ) return false ; verdict = ( ( struct xt_standard_target * ) t ) -> verdict ; verdict = - verdict - 1 ; return verdict == NF_DROP || verdict == NF_ACCEPT ; }\n", "\n", "1: CWE-119 static bool check_underflow ( const struct ipt_entry * e ) { const struct xt_entry_target * t ; unsigned int verdict ; if ( ! unconditional ( & e -> ip ) ) return false ; t = ipt_get_target_c ( e ) ; if ( strcmp ( t -> u . user . name , XT_STANDARD_TARGET ) != 0 ) return false ; verdict = ( ( struct xt_standard_target * ) t ) -> verdict ; verdict = - verdict - 1 ; return verdict == NF_DROP || verdict == NF_ACCEPT ; }\n", "\n", "2: CWE-119 static bool check_underflow ( const struct arpt_entry * e ) { const struct xt_entry_target * t ; unsigned int verdict ; if ( ! unconditional ( & e -> arp ) ) return false ; t = arpt_get_target_c ( e ) ; if ( strcmp ( t -> u . user . name , XT_STANDARD_TARGET ) != 0 ) return false ; verdict = ( ( struct xt_standard_target * ) t ) -> verdict ; verdict = - verdict - 1 ; return verdict == NF_DROP || verdict == NF_ACCEPT ; }\n", "\n", "\n", "Target: string ) ) i ++ , c = c -> next ; if ( c\n", "\n", "Sources:\n", "0: CWE-119 cJSON * cJSON_DetachItemFromObject ( cJSON * object , const char * string ) { int i = 0 ; cJSON * c = object -> child ; while ( c && cJSON_strcasecmp ( c -> string , string ) ) { ++ i ; c = c -> next ; } if ( c ) return cJSON_DetachItemFromArray ( object , i ) ; return 0 ; }\n", "\n", "1: CWE-119 void cJSON_ReplaceItemInObject ( cJSON * object , const char * string , cJSON * newitem ) { int i = 0 ; cJSON * c = object -> child ; while ( c && cJSON_strcasecmp ( c -> string , string ) ) { ++ i ; c = c -> next ; } if ( c ) { newitem -> string = cJSON_strdup ( string ) ; cJSON_ReplaceItemInArray ( object , i , newitem ) ; } }\n", "\n", "\n", "Target: 0 ; } h . h2 -> tp_padding = 0 ;\n", "\n", "Sources:\n", "0: CWE-200 static int tpacket_rcv ( struct sk_buff * skb , struct net_device * dev , struct packet_type * pt , struct net_device * orig_dev ) { struct sock * sk ; struct packet_sock * po ; struct sockaddr_ll * sll ; union { struct tpacket_hdr * h1 ; struct tpacket2_hdr * h2 ; void * raw ; } h ; u8 * skb_head = skb -> data ; int skb_len = skb -> len ; unsigned int snaplen , res ; unsigned long status = TP_STATUS_LOSING | TP_STATUS_USER ; unsigned short macoff , netoff , hdrlen ; struct sk_buff * copy_skb = NULL ; struct timeval tv ; struct timespec ts ; struct skb_shared_hwtstamps * shhwtstamps = skb_hwtstamps ( skb ) ; if ( skb -> pkt_type == PACKET_LOOPBACK ) goto drop ; sk = pt -> af_packet_priv ; po = pkt_sk ( sk ) ; if ( ! net_eq ( dev_net ( dev ) , sock_net ( sk ) ) ) goto drop ; if ( dev -> header_ops ) { if ( sk -> sk_type != SOCK_DGRAM ) skb_push ( skb , skb -> data - skb_mac_header ( skb ) ) ; else if ( skb -> pkt_type == PACKET_OUTGOING ) { skb_pull ( skb , skb_network_offset ( skb ) ) ; } } if ( skb -> ip_summed == CHECKSUM_PARTIAL ) status |= TP_STATUS_CSUMNOTREADY ; snaplen = skb -> len ; res = run_filter ( skb , sk , snaplen ) ; if ( ! res ) goto drop_n_restore ; if ( snaplen > res ) snaplen = res ; if ( sk -> sk_type == SOCK_DGRAM ) { macoff = netoff = TPACKET_ALIGN ( po -> tp_hdrlen ) + 16 + po -> tp_reserve ; } else { unsigned maclen = skb_network_offset ( skb ) ; netoff = TPACKET_ALIGN ( po -> tp_hdrlen + ( maclen < 16 ? 16 : maclen ) ) + po -> tp_reserve ; macoff = netoff - maclen ; } if ( macoff + snaplen > po -> rx_ring . frame_size ) { if ( po -> copy_thresh && atomic_read ( & sk -> sk_rmem_alloc ) + skb -> truesize < ( unsigned ) sk -> sk_rcvbuf ) { if ( skb_shared ( skb ) ) { copy_skb = skb_clone ( skb , GFP_ATOMIC ) ; } else { copy_skb = skb_get ( skb ) ; skb_head = skb -> data ; } if ( copy_skb ) skb_set_owner_r ( copy_skb , sk ) ; } snaplen = po -> rx_ring . frame_size - macoff ; if ( ( int ) snaplen < 0 ) snaplen = 0 ; } spin_lock ( & sk -> sk_receive_queue . lock ) ; h . raw = packet_current_frame ( po , & po -> rx_ring , TP_STATUS_KERNEL ) ; if ( ! h . raw ) goto ring_is_full ; packet_increment_head ( & po -> rx_ring ) ; po -> stats . tp_packets ++ ; if ( copy_skb ) { status |= TP_STATUS_COPY ; __skb_queue_tail ( & sk -> sk_receive_queue , copy_skb ) ; } if ( ! po -> stats . tp_drops ) status &= ~ TP_STATUS_LOSING ; spin_unlock ( & sk -> sk_receive_queue . lock ) ; skb_copy_bits ( skb , 0 , h . raw + macoff , snaplen ) ; switch ( po -> tp_version ) { case TPACKET_V1 : h . h1 -> tp_len = skb -> len ; h . h1 -> tp_snaplen = snaplen ; h . h1 -> tp_mac = macoff ; h . h1 -> tp_net = netoff ; if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_SYS_HARDWARE ) && shhwtstamps -> syststamp . tv64 ) tv = ktime_to_timeval ( shhwtstamps -> syststamp ) ; else if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_RAW_HARDWARE ) && shhwtstamps -> hwtstamp . tv64 ) tv = ktime_to_timeval ( shhwtstamps -> hwtstamp ) ; else if ( skb -> tstamp . tv64 ) tv = ktime_to_timeval ( skb -> tstamp ) ; else do_gettimeofday ( & tv ) ; h . h1 -> tp_sec = tv . tv_sec ; h . h1 -> tp_usec = tv . tv_usec ; hdrlen = sizeof ( * h . h1 ) ; break ; case TPACKET_V2 : h . h2 -> tp_len = skb -> len ; h . h2 -> tp_snaplen = snaplen ; h . h2 -> tp_mac = macoff ; h . h2 -> tp_net = netoff ; if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_SYS_HARDWARE ) && shhwtstamps -> syststamp . tv64 ) ts = ktime_to_timespec ( shhwtstamps -> syststamp ) ; else if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_RAW_HARDWARE ) && shhwtstamps -> hwtstamp . tv64 ) ts = ktime_to_timespec ( shhwtstamps -> hwtstamp ) ; else if ( skb -> tstamp . tv64 ) ts = ktime_to_timespec ( skb -> tstamp ) ; else getnstimeofday ( & ts ) ; h . h2 -> tp_sec = ts . tv_sec ; h . h2 -> tp_nsec = ts . tv_nsec ; if ( vlan_tx_tag_present ( skb ) ) { h . h2 -> tp_vlan_tci = vlan_tx_tag_get ( skb ) ; status |= TP_STATUS_VLAN_VALID ; } else { h . h2 -> tp_vlan_tci = 0 ; } hdrlen = sizeof ( * h . h2 ) ; break ; default : BUG ( ) ; } sll = h . raw + TPACKET_ALIGN ( hdrlen ) ; sll -> sll_halen = dev_parse_header ( skb , sll -> sll_addr ) ; sll -> sll_family = AF_PACKET ; sll -> sll_hatype = dev -> type ; sll -> sll_protocol = skb -> protocol ; sll -> sll_pkttype = skb -> pkt_type ; if ( unlikely ( po -> origdev ) ) sll -> sll_ifindex = orig_dev -> ifindex ; else sll -> sll_ifindex = dev -> ifindex ; __packet_set_status ( po , h . raw , status ) ; smp_mb ( ) ; # if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 { u8 * start , * end ; end = ( u8 * ) PAGE_ALIGN ( ( unsigned long ) h . raw + macoff + snaplen ) ; for ( start = h . raw ; start < end ; start += PAGE_SIZE ) flush_dcache_page ( pgv_to_page ( start ) ) ; } # endif sk -> sk_data_ready ( sk , 0 ) ; drop_n_restore : if ( skb_head != skb -> data && skb_shared ( skb ) ) { skb -> data = skb_head ; skb -> len = skb_len ; } drop : kfree_skb ( skb ) ; return 0 ; ring_is_full : po -> stats . tp_drops ++ ; spin_unlock ( & sk -> sk_receive_queue . lock ) ; sk -> sk_data_ready ( sk , 0 ) ; kfree_skb ( copy_skb ) ; goto drop_n_restore ; }\n", "\n", "1: CWE-264 static int tpacket_rcv ( struct sk_buff * skb , struct net_device * dev , struct packet_type * pt , struct net_device * orig_dev ) { struct sock * sk ; struct packet_sock * po ; struct sockaddr_ll * sll ; union { struct tpacket_hdr * h1 ; struct tpacket2_hdr * h2 ; void * raw ; } h ; u8 * skb_head = skb -> data ; int skb_len = skb -> len ; unsigned int snaplen , res ; unsigned long status = TP_STATUS_LOSING | TP_STATUS_USER ; unsigned short macoff , netoff , hdrlen ; struct sk_buff * copy_skb = NULL ; struct timeval tv ; struct timespec ts ; struct skb_shared_hwtstamps * shhwtstamps = skb_hwtstamps ( skb ) ; if ( skb -> pkt_type == PACKET_LOOPBACK ) goto drop ; sk = pt -> af_packet_priv ; po = pkt_sk ( sk ) ; if ( ! net_eq ( dev_net ( dev ) , sock_net ( sk ) ) ) goto drop ; if ( dev -> header_ops ) { if ( sk -> sk_type != SOCK_DGRAM ) skb_push ( skb , skb -> data - skb_mac_header ( skb ) ) ; else if ( skb -> pkt_type == PACKET_OUTGOING ) { skb_pull ( skb , skb_network_offset ( skb ) ) ; } } if ( skb -> ip_summed == CHECKSUM_PARTIAL ) status |= TP_STATUS_CSUMNOTREADY ; snaplen = skb -> len ; res = run_filter ( skb , sk , snaplen ) ; if ( ! res ) goto drop_n_restore ; if ( snaplen > res ) snaplen = res ; if ( sk -> sk_type == SOCK_DGRAM ) { macoff = netoff = TPACKET_ALIGN ( po -> tp_hdrlen ) + 16 + po -> tp_reserve ; } else { unsigned maclen = skb_network_offset ( skb ) ; netoff = TPACKET_ALIGN ( po -> tp_hdrlen + ( maclen < 16 ? 16 : maclen ) ) + po -> tp_reserve ; macoff = netoff - maclen ; } if ( macoff + snaplen > po -> rx_ring . frame_size ) { if ( po -> copy_thresh && atomic_read ( & sk -> sk_rmem_alloc ) + skb -> truesize < ( unsigned ) sk -> sk_rcvbuf ) { if ( skb_shared ( skb ) ) { copy_skb = skb_clone ( skb , GFP_ATOMIC ) ; } else { copy_skb = skb_get ( skb ) ; skb_head = skb -> data ; } if ( copy_skb ) skb_set_owner_r ( copy_skb , sk ) ; } snaplen = po -> rx_ring . frame_size - macoff ; if ( ( int ) snaplen < 0 ) snaplen = 0 ; } spin_lock ( & sk -> sk_receive_queue . lock ) ; h . raw = packet_current_frame ( po , & po -> rx_ring , TP_STATUS_KERNEL ) ; if ( ! h . raw ) goto ring_is_full ; packet_increment_head ( & po -> rx_ring ) ; po -> stats . tp_packets ++ ; if ( copy_skb ) { status |= TP_STATUS_COPY ; __skb_queue_tail ( & sk -> sk_receive_queue , copy_skb ) ; } if ( ! po -> stats . tp_drops ) status &= ~ TP_STATUS_LOSING ; spin_unlock ( & sk -> sk_receive_queue . lock ) ; skb_copy_bits ( skb , 0 , h . raw + macoff , snaplen ) ; switch ( po -> tp_version ) { case TPACKET_V1 : h . h1 -> tp_len = skb -> len ; h . h1 -> tp_snaplen = snaplen ; h . h1 -> tp_mac = macoff ; h . h1 -> tp_net = netoff ; if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_SYS_HARDWARE ) && shhwtstamps -> syststamp . tv64 ) tv = ktime_to_timeval ( shhwtstamps -> syststamp ) ; else if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_RAW_HARDWARE ) && shhwtstamps -> hwtstamp . tv64 ) tv = ktime_to_timeval ( shhwtstamps -> hwtstamp ) ; else if ( skb -> tstamp . tv64 ) tv = ktime_to_timeval ( skb -> tstamp ) ; else do_gettimeofday ( & tv ) ; h . h1 -> tp_sec = tv . tv_sec ; h . h1 -> tp_usec = tv . tv_usec ; hdrlen = sizeof ( * h . h1 ) ; break ; case TPACKET_V2 : h . h2 -> tp_len = skb -> len ; h . h2 -> tp_snaplen = snaplen ; h . h2 -> tp_mac = macoff ; h . h2 -> tp_net = netoff ; if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_SYS_HARDWARE ) && shhwtstamps -> syststamp . tv64 ) ts = ktime_to_timespec ( shhwtstamps -> syststamp ) ; else if ( ( po -> tp_tstamp & SOF_TIMESTAMPING_RAW_HARDWARE ) && shhwtstamps -> hwtstamp . tv64 ) ts = ktime_to_timespec ( shhwtstamps -> hwtstamp ) ; else if ( skb -> tstamp . tv64 ) ts = ktime_to_timespec ( skb -> tstamp ) ; else getnstimeofday ( & ts ) ; h . h2 -> tp_sec = ts . tv_sec ; h . h2 -> tp_nsec = ts . tv_nsec ; if ( vlan_tx_tag_present ( skb ) ) { h . h2 -> tp_vlan_tci = vlan_tx_tag_get ( skb ) ; status |= TP_STATUS_VLAN_VALID ; } else { h . h2 -> tp_vlan_tci = 0 ; } hdrlen = sizeof ( * h . h2 ) ; break ; default : BUG ( ) ; } sll = h . raw + TPACKET_ALIGN ( hdrlen ) ; sll -> sll_halen = dev_parse_header ( skb , sll -> sll_addr ) ; sll -> sll_family = AF_PACKET ; sll -> sll_hatype = dev -> type ; sll -> sll_protocol = skb -> protocol ; sll -> sll_pkttype = skb -> pkt_type ; if ( unlikely ( po -> origdev ) ) sll -> sll_ifindex = orig_dev -> ifindex ; else sll -> sll_ifindex = dev -> ifindex ; __packet_set_status ( po , h . raw , status ) ; smp_mb ( ) ; # if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 { u8 * start , * end ; end = ( u8 * ) PAGE_ALIGN ( ( unsigned long ) h . raw + macoff + snaplen ) ; for ( start = h . raw ; start < end ; start += PAGE_SIZE ) flush_dcache_page ( pgv_to_page ( start ) ) ; } # endif sk -> sk_data_ready ( sk , 0 ) ; drop_n_restore : if ( skb_head != skb -> data && skb_shared ( skb ) ) { skb -> data = skb_head ; skb -> len = skb_len ; } drop : kfree_skb ( skb ) ; return 0 ; ring_is_full : po -> stats . tp_drops ++ ; spin_unlock ( & sk -> sk_receive_queue . lock ) ; sk -> sk_data_ready ( sk , 0 ) ; kfree_skb ( copy_skb ) ; goto drop_n_restore ; }\n", "\n", "\n", "Target: stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS\n", "\n", "Sources:\n", "0: CWE-119 static int hns_gmac_get_sset_count ( int stringset ) { if ( stringset == ETH_SS_STATS ) return ARRAY_SIZE ( g_gmac_stats_string ) ; return 0 ; }\n", "\n", "1: CWE-119 static int hns_xgmac_get_sset_count ( int stringset ) { if ( stringset == ETH_SS_STATS ) return ARRAY_SIZE ( g_xgmac_stats_string ) ; return 0 ; }\n", "\n", "\n", "Target: += 8 ; break ; case += 8 ; break ; case += 4 ; break ; case ; break ; } while ( context -> pass > 0 && context -> pass < 4 && context -> curY >= p -> height ) { switch ( ++ context -> pass ) { case 2 : context -> curY = i -> posY + 4 ; break ; case 3 : context -> curY = i -> posY + 2 ; break ; case 4 : context -> curY = i -> posY + 1 ; break ; }\n", "\n", "Sources:\n", "0: CWE-787 static void WritePixels ( struct ngiflib_img * i , struct ngiflib_decode_context * context , const u8 * pixels , u16 n ) { u16 tocopy ; struct ngiflib_gif * p = i -> parent ; while ( n > 0 ) { tocopy = ( context -> Xtogo < n ) ? context -> Xtogo : n ; if ( ! i -> gce . transparent_flag ) { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif ngiflib_memcpy ( context -> frbuff_p . p8 , pixels , tocopy ) ; pixels += tocopy ; context -> frbuff_p . p8 += tocopy ; # ifndef NGIFLIB_INDEXED_ONLY } else { int j ; for ( j = ( int ) tocopy ; j > 0 ; j -- ) { * ( context -> frbuff_p . p32 ++ ) = GifIndexToTrueColor ( i -> palette , * pixels ++ ) ; } } # endif } else { int j ; # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif for ( j = ( int ) tocopy ; j > 0 ; j -- ) { if ( * pixels != i -> gce . transparent_color ) * context -> frbuff_p . p8 = * pixels ; pixels ++ ; context -> frbuff_p . p8 ++ ; } # ifndef NGIFLIB_INDEXED_ONLY } else { for ( j = ( int ) tocopy ; j > 0 ; j -- ) { if ( * pixels != i -> gce . transparent_color ) { * context -> frbuff_p . p32 = GifIndexToTrueColor ( i -> palette , * pixels ) ; } pixels ++ ; context -> frbuff_p . p32 ++ ; } } # endif } context -> Xtogo -= tocopy ; if ( context -> Xtogo == 0 ) { # ifdef NGIFLIB_ENABLE_CALLBACKS if ( p -> line_cb ) p -> line_cb ( p , context -> line_p , context -> curY ) ; # endif context -> Xtogo = i -> width ; switch ( context -> pass ) { case 0 : context -> curY ++ ; break ; case 1 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 4 ; } break ; case 2 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 2 ; } break ; case 3 : context -> curY += 4 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 1 ; } break ; case 4 : context -> curY += 2 ; break ; } # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p8 = context -> line_p . p8 + i -> posX ; # else context -> frbuff_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif # ifndef NGIFLIB_INDEXED_ONLY } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p32 = context -> line_p . p32 + i -> posX ; # else context -> frbuff_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif } # endif } n -= tocopy ; } }\n", "\n", "1: CWE-119 static void WritePixels ( struct ngiflib_img * i , struct ngiflib_decode_context * context , const u8 * pixels , u16 n ) { u16 tocopy ; struct ngiflib_gif * p = i -> parent ; while ( n > 0 ) { tocopy = ( context -> Xtogo < n ) ? context -> Xtogo : n ; if ( ! i -> gce . transparent_flag ) { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif ngiflib_memcpy ( context -> frbuff_p . p8 , pixels , tocopy ) ; pixels += tocopy ; context -> frbuff_p . p8 += tocopy ; # ifndef NGIFLIB_INDEXED_ONLY } else { int j ; for ( j = ( int ) tocopy ; j > 0 ; j -- ) { * ( context -> frbuff_p . p32 ++ ) = GifIndexToTrueColor ( i -> palette , * pixels ++ ) ; } } # endif } else { int j ; # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif for ( j = ( int ) tocopy ; j > 0 ; j -- ) { if ( * pixels != i -> gce . transparent_color ) * context -> frbuff_p . p8 = * pixels ; pixels ++ ; context -> frbuff_p . p8 ++ ; } # ifndef NGIFLIB_INDEXED_ONLY } else { for ( j = ( int ) tocopy ; j > 0 ; j -- ) { if ( * pixels != i -> gce . transparent_color ) { * context -> frbuff_p . p32 = GifIndexToTrueColor ( i -> palette , * pixels ) ; } pixels ++ ; context -> frbuff_p . p32 ++ ; } } # endif } context -> Xtogo -= tocopy ; if ( context -> Xtogo == 0 ) { # ifdef NGIFLIB_ENABLE_CALLBACKS if ( p -> line_cb ) p -> line_cb ( p , context -> line_p , context -> curY ) ; # endif context -> Xtogo = i -> width ; switch ( context -> pass ) { case 0 : context -> curY ++ ; break ; case 1 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 4 ; } break ; case 2 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 2 ; } break ; case 3 : context -> curY += 4 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 1 ; } break ; case 4 : context -> curY += 2 ; break ; } # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p8 = context -> line_p . p8 + i -> posX ; # else context -> frbuff_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif # ifndef NGIFLIB_INDEXED_ONLY } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p32 = context -> line_p . p32 + i -> posX ; # else context -> frbuff_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif } # endif } n -= tocopy ; } }\n", "\n", "2: CWE-119 static void WritePixel ( struct ngiflib_img * i , struct ngiflib_decode_context * context , u8 v ) { struct ngiflib_gif * p = i -> parent ; if ( v != i -> gce . transparent_color || ! i -> gce . transparent_flag ) { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif * context -> frbuff_p . p8 = v ; # ifndef NGIFLIB_INDEXED_ONLY } else * context -> frbuff_p . p32 = GifIndexToTrueColor ( i -> palette , v ) ; # endif } if ( -- ( context -> Xtogo ) <= 0 ) { # ifdef NGIFLIB_ENABLE_CALLBACKS if ( p -> line_cb ) p -> line_cb ( p , context -> line_p , context -> curY ) ; # endif context -> Xtogo = i -> width ; switch ( context -> pass ) { case 0 : context -> curY ++ ; break ; case 1 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 4 ; } break ; case 2 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 2 ; } break ; case 3 : context -> curY += 4 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 1 ; } break ; case 4 : context -> curY += 2 ; break ; } # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p8 = context -> line_p . p8 + i -> posX ; # else context -> frbuff_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif # ifndef NGIFLIB_INDEXED_ONLY } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p32 = context -> line_p . p32 + i -> posX ; # else context -> frbuff_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif } # endif } else { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif context -> frbuff_p . p8 ++ ; # ifndef NGIFLIB_INDEXED_ONLY } else { context -> frbuff_p . p32 ++ ; } # endif } }\n", "\n", "\n", "Target: slen ; else { if ( slen > VARBITMAXLEN / 4 ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( \"bitstringlengthexceedsthemaximumallowed(%d)\" , VARBITMAXLEN ) ) ) ; * 4 ; }\n", "\n", "Sources:\n", "0: CWE-189 Datum bit_in ( PG_FUNCTION_ARGS ) { char * input_string = PG_GETARG_CSTRING ( 0 ) ; # ifdef NOT_USED Oid typelem = PG_GETARG_OID ( 1 ) ; # endif int32 atttypmod = PG_GETARG_INT32 ( 2 ) ; VarBit * result ; char * sp ; bits8 * r ; int len , bitlen , slen ; bool bit_not_hex ; int bc ; bits8 x = 0 ; if ( input_string [ 0 ] == 'b' || input_string [ 0 ] == 'B' ) { bit_not_hex = true ; sp = input_string + 1 ; } else if ( input_string [ 0 ] == 'x' || input_string [ 0 ] == 'X' ) { bit_not_hex = false ; sp = input_string + 1 ; } else { bit_not_hex = true ; sp = input_string ; } slen = strlen ( sp ) ; if ( bit_not_hex ) bitlen = slen ; else bitlen = slen * 4 ; if ( atttypmod <= 0 ) atttypmod = bitlen ; else if ( bitlen != atttypmod ) ereport ( ERROR , ( errcode ( ERRCODE_STRING_DATA_LENGTH_MISMATCH ) , errmsg ( \"bitstringlength%ddoesnotmatchtypebit(%d)\" , bitlen , atttypmod ) ) ) ; len = VARBITTOTALLEN ( atttypmod ) ; result = ( VarBit * ) palloc0 ( len ) ; SET_VARSIZE ( result , len ) ; VARBITLEN ( result ) = atttypmod ; r = VARBITS ( result ) ; if ( bit_not_hex ) { x = HIGHBIT ; for ( ; * sp ; sp ++ ) { if ( * sp == '1' ) * r |= x ; else if ( * sp != '0' ) ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( \"\\\\\"%c\\\\\"isnotavalidbinarydigit\" , * sp ) ) ) ; x >>= 1 ; if ( x == 0 ) { x = HIGHBIT ; r ++ ; } } } else { for ( bc = 0 ; * sp ; sp ++ ) { if ( * sp >= '0' && * sp <= '9' ) x = ( bits8 ) ( * sp - '0' ) ; else if ( * sp >= 'A' && * sp <= 'F' ) x = ( bits8 ) ( * sp - 'A' ) + 10 ; else if ( * sp >= 'a' && * sp <= 'f' ) x = ( bits8 ) ( * sp - 'a' ) + 10 ; else ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( \"\\\\\"%c\\\\\"isnotavalidhexadecimaldigit\" , * sp ) ) ) ; if ( bc ) { * r ++ |= x ; bc = 0 ; } else { * r = x << 4 ; bc = 1 ; } } } PG_RETURN_VARBIT_P ( result ) ; }\n", "\n", "1: CWE-189 Datum varbit_in ( PG_FUNCTION_ARGS ) { char * input_string = PG_GETARG_CSTRING ( 0 ) ; # ifdef NOT_USED Oid typelem = PG_GETARG_OID ( 1 ) ; # endif int32 atttypmod = PG_GETARG_INT32 ( 2 ) ; VarBit * result ; char * sp ; bits8 * r ; int len , bitlen , slen ; bool bit_not_hex ; int bc ; bits8 x = 0 ; if ( input_string [ 0 ] == 'b' || input_string [ 0 ] == 'B' ) { bit_not_hex = true ; sp = input_string + 1 ; } else if ( input_string [ 0 ] == 'x' || input_string [ 0 ] == 'X' ) { bit_not_hex = false ; sp = input_string + 1 ; } else { bit_not_hex = true ; sp = input_string ; } slen = strlen ( sp ) ; if ( bit_not_hex ) bitlen = slen ; else bitlen = slen * 4 ; if ( atttypmod <= 0 ) atttypmod = bitlen ; else if ( bitlen > atttypmod ) ereport ( ERROR , ( errcode ( ERRCODE_STRING_DATA_RIGHT_TRUNCATION ) , errmsg ( \"bitstringtoolongfortypebitvarying(%d)\" , atttypmod ) ) ) ; len = VARBITTOTALLEN ( bitlen ) ; result = ( VarBit * ) palloc0 ( len ) ; SET_VARSIZE ( result , len ) ; VARBITLEN ( result ) = Min ( bitlen , atttypmod ) ; r = VARBITS ( result ) ; if ( bit_not_hex ) { x = HIGHBIT ; for ( ; * sp ; sp ++ ) { if ( * sp == '1' ) * r |= x ; else if ( * sp != '0' ) ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( \"\\\\\"%c\\\\\"isnotavalidbinarydigit\" , * sp ) ) ) ; x >>= 1 ; if ( x == 0 ) { x = HIGHBIT ; r ++ ; } } } else { for ( bc = 0 ; * sp ; sp ++ ) { if ( * sp >= '0' && * sp <= '9' ) x = ( bits8 ) ( * sp - '0' ) ; else if ( * sp >= 'A' && * sp <= 'F' ) x = ( bits8 ) ( * sp - 'A' ) + 10 ; else if ( * sp >= 'a' && * sp <= 'f' ) x = ( bits8 ) ( * sp - 'a' ) + 10 ; else ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( \"\\\\\"%c\\\\\"isnotavalidhexadecimaldigit\" , * sp ) ) ) ; if ( bc ) { * r ++ |= x ; bc = 0 ; } else { * r = x << 4 ; bc = 1 ; } } } PG_RETURN_VARBIT_P ( result ) ; }\n", "\n", "\n", "Target: netbk , pending_idx , XEN_NETIF_RSP_OKAY\n", "\n", "Sources:\n", "0: CWE-399 static void xen_netbk_tx_submit ( struct xen_netbk * netbk ) { struct gnttab_copy * gop = netbk -> tx_copy_ops ; struct sk_buff * skb ; while ( ( skb = __skb_dequeue ( & netbk -> tx_queue ) ) != NULL ) { struct xen_netif_tx_request * txp ; struct xenvif * vif ; u16 pending_idx ; unsigned data_len ; pending_idx = * ( ( u16 * ) skb -> data ) ; vif = netbk -> pending_tx_info [ pending_idx ] . vif ; txp = & netbk -> pending_tx_info [ pending_idx ] . req ; if ( unlikely ( xen_netbk_tx_check_gop ( netbk , skb , & gop ) ) ) { netdev_dbg ( vif -> dev , \"netbackgrantfailed.\\\\n\" ) ; skb_shinfo ( skb ) -> nr_frags = 0 ; kfree_skb ( skb ) ; continue ; } data_len = skb -> len ; memcpy ( skb -> data , ( void * ) ( idx_to_kaddr ( netbk , pending_idx ) | txp -> offset ) , data_len ) ; if ( data_len < txp -> size ) { txp -> offset += data_len ; txp -> size -= data_len ; } else { xen_netbk_idx_release ( netbk , pending_idx ) ; } if ( txp -> flags & XEN_NETTXF_csum_blank ) skb -> ip_summed = CHECKSUM_PARTIAL ; else if ( txp -> flags & XEN_NETTXF_data_validated ) skb -> ip_summed = CHECKSUM_UNNECESSARY ; xen_netbk_fill_frags ( netbk , skb ) ; if ( skb_headlen ( skb ) < PKT_PROT_LEN && skb_is_nonlinear ( skb ) ) { int target = min_t ( int , skb -> len , PKT_PROT_LEN ) ; __pskb_pull_tail ( skb , target - skb_headlen ( skb ) ) ; } skb -> dev = vif -> dev ; skb -> protocol = eth_type_trans ( skb , skb -> dev ) ; if ( checksum_setup ( vif , skb ) ) { netdev_dbg ( vif -> dev , \"Can\\'tsetupchecksuminnet_tx_action\\\\n\" ) ; kfree_skb ( skb ) ; continue ; } vif -> dev -> stats . rx_bytes += skb -> len ; vif -> dev -> stats . rx_packets ++ ; xenvif_receive_skb ( vif , skb ) ; } }\n", "\n", "1: CWE-399 static void xen_netbk_fill_frags ( struct xen_netbk * netbk , struct sk_buff * skb ) { struct skb_shared_info * shinfo = skb_shinfo ( skb ) ; int nr_frags = shinfo -> nr_frags ; int i ; for ( i = 0 ; i < nr_frags ; i ++ ) { skb_frag_t * frag = shinfo -> frags + i ; struct xen_netif_tx_request * txp ; struct page * page ; u16 pending_idx ; pending_idx = frag_get_pending_idx ( frag ) ; txp = & netbk -> pending_tx_info [ pending_idx ] . req ; page = virt_to_page ( idx_to_kaddr ( netbk , pending_idx ) ) ; __skb_fill_page_desc ( skb , i , page , txp -> offset , txp -> size ) ; skb -> len += txp -> size ; skb -> data_len += txp -> size ; skb -> truesize += txp -> size ; get_page ( netbk -> mmap_pages [ pending_idx ] ) ; xen_netbk_idx_release ( netbk , pending_idx ) ; } }\n", "\n", "\n", "Target: ( attrs , PAGE_KERNEL ) ; void\n", "\n", "Sources:\n", "0: CWE-264 static void * arm_coherent_dma_alloc ( struct device * dev , size_t size , dma_addr_t * handle , gfp_t gfp , struct dma_attrs * attrs ) { pgprot_t prot = __get_dma_pgprot ( attrs , pgprot_kernel ) ; void * memory ; if ( dma_alloc_from_coherent ( dev , size , handle , & memory ) ) return memory ; return __dma_alloc ( dev , size , handle , gfp , prot , true , __builtin_return_address ( 0 ) ) ; }\n", "\n", "1: CWE-264 void * arm_dma_alloc ( struct device * dev , size_t size , dma_addr_t * handle , gfp_t gfp , struct dma_attrs * attrs ) { pgprot_t prot = __get_dma_pgprot ( attrs , pgprot_kernel ) ; void * memory ; if ( dma_alloc_from_coherent ( dev , size , handle , & memory ) ) return memory ; return __dma_alloc ( dev , size , handle , gfp , prot , false , __builtin_return_address ( 0 ) ) ; }\n", "\n", "\n", "Target: PERF_COUNT_SW_EMULATION_FAULTS , 1 , xcp ,\n", "\n", "Sources:\n", "0: CWE-399 static int cop1Emulate ( struct pt_regs * xcp , struct mips_fpu_struct * ctx , void * __user * fault_addr ) { mips_instruction ir ; unsigned long emulpc , contpc ; unsigned int cond ; if ( ! access_ok ( VERIFY_READ , xcp -> cp0_epc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) xcp -> cp0_epc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGSEGV ; } if ( ( xcp -> cp0_cause & CAUSEF_BD ) && ! isBranchInstr ( & ir ) ) xcp -> cp0_cause &= ~ CAUSEF_BD ; if ( xcp -> cp0_cause & CAUSEF_BD ) { emulpc = xcp -> cp0_epc + 4 ; if ( __compute_return_epc ( xcp ) ) { # ifdef CP1DBG printk ( \"failedtoemulatebranchat%p\\\\n\" , ( void * ) ( xcp -> cp0_epc ) ) ; # endif return SIGILL ; } if ( ! access_ok ( VERIFY_READ , emulpc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) emulpc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) emulpc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) emulpc ; return SIGSEGV ; } contpc = xcp -> cp0_epc ; xcp -> cp0_epc = emulpc - 4 ; } else { emulpc = xcp -> cp0_epc ; contpc = xcp -> cp0_epc + 4 ; } emul : perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , xcp , 0 ) ; MIPS_FPU_EMU_INC_STATS ( emulated ) ; switch ( MIPSInst_OPCODE ( ir ) ) { case ldc1_op : { u64 __user * va = ( u64 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u64 val ; MIPS_FPU_EMU_INC_STATS ( loads ) ; if ( ! access_ok ( VERIFY_READ , va , sizeof ( u64 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __get_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } DITOREG ( val , MIPSInst_RT ( ir ) ) ; break ; } case sdc1_op : { u64 __user * va = ( u64 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u64 val ; MIPS_FPU_EMU_INC_STATS ( stores ) ; DIFROMREG ( val , MIPSInst_RT ( ir ) ) ; if ( ! access_ok ( VERIFY_WRITE , va , sizeof ( u64 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __put_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } break ; } case lwc1_op : { u32 __user * va = ( u32 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u32 val ; MIPS_FPU_EMU_INC_STATS ( loads ) ; if ( ! access_ok ( VERIFY_READ , va , sizeof ( u32 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __get_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } SITOREG ( val , MIPSInst_RT ( ir ) ) ; break ; } case swc1_op : { u32 __user * va = ( u32 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u32 val ; MIPS_FPU_EMU_INC_STATS ( stores ) ; SIFROMREG ( val , MIPSInst_RT ( ir ) ) ; if ( ! access_ok ( VERIFY_WRITE , va , sizeof ( u32 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __put_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } break ; } case cop1_op : switch ( MIPSInst_RS ( ir ) ) { # if defined ( __mips64 ) case dmfc_op : if ( MIPSInst_RT ( ir ) != 0 ) { DIFROMREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; } break ; case dmtc_op : DITOREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; break ; # endif case mfc_op : if ( MIPSInst_RT ( ir ) != 0 ) { SIFROMREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; } break ; case mtc_op : SITOREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; break ; case cfc_op : { u32 value ; if ( MIPSInst_RD ( ir ) == FPCREG_CSR ) { value = ctx -> fcr31 ; value = ( value & ~ FPU_CSR_RM ) | mips_rm [ modeindex ( value ) ] ; # ifdef CSRTRACE printk ( \"%pgpr[%d]<-csr=%08x\\\\n\" , ( void * ) ( xcp -> cp0_epc ) , MIPSInst_RT ( ir ) , value ) ; # endif } else if ( MIPSInst_RD ( ir ) == FPCREG_RID ) value = 0 ; else value = 0 ; if ( MIPSInst_RT ( ir ) ) xcp -> regs [ MIPSInst_RT ( ir ) ] = value ; break ; } case ctc_op : { u32 value ; if ( MIPSInst_RT ( ir ) == 0 ) value = 0 ; else value = xcp -> regs [ MIPSInst_RT ( ir ) ] ; if ( MIPSInst_RD ( ir ) == FPCREG_CSR ) { # ifdef CSRTRACE printk ( \"%pgpr[%d]->csr=%08x\\\\n\" , ( void * ) ( xcp -> cp0_epc ) , MIPSInst_RT ( ir ) , value ) ; # endif ctx -> fcr31 = ( value & ~ ( FPU_CSR_RSVD | FPU_CSR_RM ) ) | ieee_rm [ modeindex ( value ) ] ; } if ( ( ctx -> fcr31 >> 5 ) & ctx -> fcr31 & FPU_CSR_ALL_E ) { return SIGFPE ; } break ; } case bc_op : { int likely = 0 ; if ( xcp -> cp0_cause & CAUSEF_BD ) return SIGILL ; # if __mips >= 4 cond = ctx -> fcr31 & fpucondbit [ MIPSInst_RT ( ir ) >> 2 ] ; # else cond = ctx -> fcr31 & FPU_CSR_COND ; # endif switch ( MIPSInst_RT ( ir ) & 3 ) { case bcfl_op : likely = 1 ; case bcf_op : cond = ! cond ; break ; case bctl_op : likely = 1 ; case bct_op : break ; default : return SIGILL ; } xcp -> cp0_cause |= CAUSEF_BD ; if ( cond ) { xcp -> cp0_epc += 4 ; contpc = ( xcp -> cp0_epc + ( MIPSInst_SIMM ( ir ) << 2 ) ) ; if ( ! access_ok ( VERIFY_READ , xcp -> cp0_epc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) xcp -> cp0_epc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGSEGV ; } switch ( MIPSInst_OPCODE ( ir ) ) { case lwc1_op : case swc1_op : # if ( __mips >= 2 || defined ( __mips64 ) ) case ldc1_op : case sdc1_op : # endif case cop1_op : # if __mips >= 4 && __mips != 32 case cop1x_op : # endif goto emul ; # if __mips >= 4 case spec_op : if ( MIPSInst_FUNC ( ir ) == movc_op ) goto emul ; break ; # endif } return mips_dsemul ( xcp , ir , contpc ) ; } else { if ( likely ) { xcp -> cp0_epc += 4 ; contpc += 4 ; } } break ; } default : if ( ! ( MIPSInst_RS ( ir ) & 0x10 ) ) return SIGILL ; { int sig ; if ( ( sig = fpu_emu ( xcp , ctx , ir ) ) ) return sig ; } } break ; # if __mips >= 4 && __mips != 32 case cop1x_op : { int sig = fpux_emu ( xcp , ctx , ir , fault_addr ) ; if ( sig ) return sig ; break ; } # endif # if __mips >= 4 case spec_op : if ( MIPSInst_FUNC ( ir ) != movc_op ) return SIGILL ; cond = fpucondbit [ MIPSInst_RT ( ir ) >> 2 ] ; if ( ( ( ctx -> fcr31 & cond ) != 0 ) == ( ( MIPSInst_RT ( ir ) & 1 ) != 0 ) ) xcp -> regs [ MIPSInst_RD ( ir ) ] = xcp -> regs [ MIPSInst_RS ( ir ) ] ; break ; # endif default : return SIGILL ; } xcp -> cp0_epc = contpc ; xcp -> cp0_cause &= ~ CAUSEF_BD ; return 0 ; }\n", "\n", "1: CWE-400 static int cop1Emulate ( struct pt_regs * xcp , struct mips_fpu_struct * ctx , void * __user * fault_addr ) { mips_instruction ir ; unsigned long emulpc , contpc ; unsigned int cond ; if ( ! access_ok ( VERIFY_READ , xcp -> cp0_epc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) xcp -> cp0_epc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGSEGV ; } if ( ( xcp -> cp0_cause & CAUSEF_BD ) && ! isBranchInstr ( & ir ) ) xcp -> cp0_cause &= ~ CAUSEF_BD ; if ( xcp -> cp0_cause & CAUSEF_BD ) { emulpc = xcp -> cp0_epc + 4 ; if ( __compute_return_epc ( xcp ) ) { # ifdef CP1DBG printk ( \"failedtoemulatebranchat%p\\\\n\" , ( void * ) ( xcp -> cp0_epc ) ) ; # endif return SIGILL ; } if ( ! access_ok ( VERIFY_READ , emulpc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) emulpc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) emulpc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) emulpc ; return SIGSEGV ; } contpc = xcp -> cp0_epc ; xcp -> cp0_epc = emulpc - 4 ; } else { emulpc = xcp -> cp0_epc ; contpc = xcp -> cp0_epc + 4 ; } emul : perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , xcp , 0 ) ; MIPS_FPU_EMU_INC_STATS ( emulated ) ; switch ( MIPSInst_OPCODE ( ir ) ) { case ldc1_op : { u64 __user * va = ( u64 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u64 val ; MIPS_FPU_EMU_INC_STATS ( loads ) ; if ( ! access_ok ( VERIFY_READ , va , sizeof ( u64 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __get_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } DITOREG ( val , MIPSInst_RT ( ir ) ) ; break ; } case sdc1_op : { u64 __user * va = ( u64 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u64 val ; MIPS_FPU_EMU_INC_STATS ( stores ) ; DIFROMREG ( val , MIPSInst_RT ( ir ) ) ; if ( ! access_ok ( VERIFY_WRITE , va , sizeof ( u64 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __put_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } break ; } case lwc1_op : { u32 __user * va = ( u32 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u32 val ; MIPS_FPU_EMU_INC_STATS ( loads ) ; if ( ! access_ok ( VERIFY_READ , va , sizeof ( u32 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __get_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } SITOREG ( val , MIPSInst_RT ( ir ) ) ; break ; } case swc1_op : { u32 __user * va = ( u32 __user * ) ( xcp -> regs [ MIPSInst_RS ( ir ) ] + MIPSInst_SIMM ( ir ) ) ; u32 val ; MIPS_FPU_EMU_INC_STATS ( stores ) ; SIFROMREG ( val , MIPSInst_RT ( ir ) ) ; if ( ! access_ok ( VERIFY_WRITE , va , sizeof ( u32 ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGBUS ; } if ( __put_user ( val , va ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = va ; return SIGSEGV ; } break ; } case cop1_op : switch ( MIPSInst_RS ( ir ) ) { # if defined ( __mips64 ) case dmfc_op : if ( MIPSInst_RT ( ir ) != 0 ) { DIFROMREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; } break ; case dmtc_op : DITOREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; break ; # endif case mfc_op : if ( MIPSInst_RT ( ir ) != 0 ) { SIFROMREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; } break ; case mtc_op : SITOREG ( xcp -> regs [ MIPSInst_RT ( ir ) ] , MIPSInst_RD ( ir ) ) ; break ; case cfc_op : { u32 value ; if ( MIPSInst_RD ( ir ) == FPCREG_CSR ) { value = ctx -> fcr31 ; value = ( value & ~ FPU_CSR_RM ) | mips_rm [ modeindex ( value ) ] ; # ifdef CSRTRACE printk ( \"%pgpr[%d]<-csr=%08x\\\\n\" , ( void * ) ( xcp -> cp0_epc ) , MIPSInst_RT ( ir ) , value ) ; # endif } else if ( MIPSInst_RD ( ir ) == FPCREG_RID ) value = 0 ; else value = 0 ; if ( MIPSInst_RT ( ir ) ) xcp -> regs [ MIPSInst_RT ( ir ) ] = value ; break ; } case ctc_op : { u32 value ; if ( MIPSInst_RT ( ir ) == 0 ) value = 0 ; else value = xcp -> regs [ MIPSInst_RT ( ir ) ] ; if ( MIPSInst_RD ( ir ) == FPCREG_CSR ) { # ifdef CSRTRACE printk ( \"%pgpr[%d]->csr=%08x\\\\n\" , ( void * ) ( xcp -> cp0_epc ) , MIPSInst_RT ( ir ) , value ) ; # endif ctx -> fcr31 = ( value & ~ ( FPU_CSR_RSVD | FPU_CSR_RM ) ) | ieee_rm [ modeindex ( value ) ] ; } if ( ( ctx -> fcr31 >> 5 ) & ctx -> fcr31 & FPU_CSR_ALL_E ) { return SIGFPE ; } break ; } case bc_op : { int likely = 0 ; if ( xcp -> cp0_cause & CAUSEF_BD ) return SIGILL ; # if __mips >= 4 cond = ctx -> fcr31 & fpucondbit [ MIPSInst_RT ( ir ) >> 2 ] ; # else cond = ctx -> fcr31 & FPU_CSR_COND ; # endif switch ( MIPSInst_RT ( ir ) & 3 ) { case bcfl_op : likely = 1 ; case bcf_op : cond = ! cond ; break ; case bctl_op : likely = 1 ; case bct_op : break ; default : return SIGILL ; } xcp -> cp0_cause |= CAUSEF_BD ; if ( cond ) { xcp -> cp0_epc += 4 ; contpc = ( xcp -> cp0_epc + ( MIPSInst_SIMM ( ir ) << 2 ) ) ; if ( ! access_ok ( VERIFY_READ , xcp -> cp0_epc , sizeof ( mips_instruction ) ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGBUS ; } if ( __get_user ( ir , ( mips_instruction __user * ) xcp -> cp0_epc ) ) { MIPS_FPU_EMU_INC_STATS ( errors ) ; * fault_addr = ( mips_instruction __user * ) xcp -> cp0_epc ; return SIGSEGV ; } switch ( MIPSInst_OPCODE ( ir ) ) { case lwc1_op : case swc1_op : # if ( __mips >= 2 || defined ( __mips64 ) ) case ldc1_op : case sdc1_op : # endif case cop1_op : # if __mips >= 4 && __mips != 32 case cop1x_op : # endif goto emul ; # if __mips >= 4 case spec_op : if ( MIPSInst_FUNC ( ir ) == movc_op ) goto emul ; break ; # endif } return mips_dsemul ( xcp , ir , contpc ) ; } else { if ( likely ) { xcp -> cp0_epc += 4 ; contpc += 4 ; } } break ; } default : if ( ! ( MIPSInst_RS ( ir ) & 0x10 ) ) return SIGILL ; { int sig ; if ( ( sig = fpu_emu ( xcp , ctx , ir ) ) ) return sig ; } } break ; # if __mips >= 4 && __mips != 32 case cop1x_op : { int sig = fpux_emu ( xcp , ctx , ir , fault_addr ) ; if ( sig ) return sig ; break ; } # endif # if __mips >= 4 case spec_op : if ( MIPSInst_FUNC ( ir ) != movc_op ) return SIGILL ; cond = fpucondbit [ MIPSInst_RT ( ir ) >> 2 ] ; if ( ( ( ctx -> fcr31 & cond ) != 0 ) == ( ( MIPSInst_RT ( ir ) & 1 ) != 0 ) ) xcp -> regs [ MIPSInst_RD ( ir ) ] = xcp -> regs [ MIPSInst_RS ( ir ) ] ; break ; # endif default : return SIGILL ; } xcp -> cp0_epc = contpc ; xcp -> cp0_cause &= ~ CAUSEF_BD ; return 0 ; }\n", "\n", "\n", "Target: output ) { const int16_t *\n", "\n", "Sources:\n", "0: CWE-119 static void down2_symodd ( const uint8_t * const input , int length , uint8_t * output ) { static const int16_t * filter = vp9_down2_symodd_half_filter ; const int filter_len_half = sizeof ( vp9_down2_symodd_half_filter ) / 2 ; int i , j ; uint8_t * optr = output ; int l1 = filter_len_half - 1 ; int l2 = ( length - filter_len_half + 1 ) ; l1 += ( l1 & 1 ) ; l2 += ( l2 & 1 ) ; if ( l1 > l2 ) { for ( i = 0 ; i < length ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) + input [ i ] * filter [ 0 ] ; for ( j = 1 ; j < filter_len_half ; ++ j ) { sum += ( input [ ( i - j < 0 ? 0 : i - j ) ] + input [ ( i + j >= length ? length - 1 : i + j ) ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } } else { for ( i = 0 ; i < l1 ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) + input [ i ] * filter [ 0 ] ; for ( j = 1 ; j < filter_len_half ; ++ j ) { sum += ( input [ ( i - j < 0 ? 0 : i - j ) ] + input [ i + j ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } for ( ; i < l2 ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) + input [ i ] * filter [ 0 ] ; for ( j = 1 ; j < filter_len_half ; ++ j ) { sum += ( input [ i - j ] + input [ i + j ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } for ( ; i < length ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) + input [ i ] * filter [ 0 ] ; for ( j = 1 ; j < filter_len_half ; ++ j ) { sum += ( input [ i - j ] + input [ ( i + j >= length ? length - 1 : i + j ) ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } } }\n", "\n", "1: CWE-119 static void down2_symeven ( const uint8_t * const input , int length , uint8_t * output ) { static const int16_t * filter = vp9_down2_symeven_half_filter ; const int filter_len_half = sizeof ( vp9_down2_symeven_half_filter ) / 2 ; int i , j ; uint8_t * optr = output ; int l1 = filter_len_half ; int l2 = ( length - filter_len_half ) ; l1 += ( l1 & 1 ) ; l2 += ( l2 & 1 ) ; if ( l1 > l2 ) { for ( i = 0 ; i < length ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) ; for ( j = 0 ; j < filter_len_half ; ++ j ) { sum += ( input [ ( i - j < 0 ? 0 : i - j ) ] + input [ ( i + 1 + j >= length ? length - 1 : i + 1 + j ) ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } } else { for ( i = 0 ; i < l1 ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) ; for ( j = 0 ; j < filter_len_half ; ++ j ) { sum += ( input [ ( i - j < 0 ? 0 : i - j ) ] + input [ i + 1 + j ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } for ( ; i < l2 ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) ; for ( j = 0 ; j < filter_len_half ; ++ j ) { sum += ( input [ i - j ] + input [ i + 1 + j ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } for ( ; i < length ; i += 2 ) { int sum = ( 1 << ( FILTER_BITS - 1 ) ) ; for ( j = 0 ; j < filter_len_half ; ++ j ) { sum += ( input [ i - j ] + input [ ( i + 1 + j >= length ? length - 1 : i + 1 + j ) ] ) * filter [ j ] ; } sum >>= FILTER_BITS ; * optr ++ = clip_pixel ( sum ) ; } } }\n", "\n", "\n", "Target: * dllhandle ; if ( COM_CompareExtension ( name , \".pk3\" ) ) { Com_Printf ( \"RejectingDLLnamed\\\\\"%s\\\\\"\" , name ) ; return NULL ; }\n", "\n", "Sources:\n", "0: CWE-269 void * Sys_LoadDll ( const char * name , qboolean useSystemLib ) { void * dllhandle ; if ( useSystemLib ) Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"...\\\\n\" , name ) ; if ( ! useSystemLib || ! ( dllhandle = Sys_LoadLibrary ( name ) ) ) { const char * topDir ; char libPath [ MAX_OSPATH ] ; topDir = Sys_BinaryPath ( ) ; if ( ! * topDir ) topDir = \".\" ; Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"from\\\\\"%s\\\\\"...\\\\n\" , name , topDir ) ; Com_sprintf ( libPath , sizeof ( libPath ) , \"%s%c%s\" , topDir , PATH_SEP , name ) ; if ( ! ( dllhandle = Sys_LoadLibrary ( libPath ) ) ) { const char * basePath = Cvar_VariableString ( \"fs_basepath\" ) ; if ( ! basePath || ! * basePath ) basePath = \".\" ; if ( FS_FilenameCompare ( topDir , basePath ) ) { Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"from\\\\\"%s\\\\\"...\\\\n\" , name , basePath ) ; Com_sprintf ( libPath , sizeof ( libPath ) , \"%s%c%s\" , basePath , PATH_SEP , name ) ; dllhandle = Sys_LoadLibrary ( libPath ) ; } if ( ! dllhandle ) Com_Printf ( \"Loading\\\\\"%s\\\\\"failed\\\\n\" , name ) ; } } return dllhandle ; }\n", "\n", "1: CWE-000 void * Sys_LoadDll ( const char * name , qboolean useSystemLib ) { void * dllhandle ; if ( useSystemLib ) Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"...\\\\n\" , name ) ; if ( ! useSystemLib || ! ( dllhandle = Sys_LoadLibrary ( name ) ) ) { const char * topDir ; char libPath [ MAX_OSPATH ] ; topDir = Sys_BinaryPath ( ) ; if ( ! * topDir ) topDir = \".\" ; Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"from\\\\\"%s\\\\\"...\\\\n\" , name , topDir ) ; Com_sprintf ( libPath , sizeof ( libPath ) , \"%s%c%s\" , topDir , PATH_SEP , name ) ; if ( ! ( dllhandle = Sys_LoadLibrary ( libPath ) ) ) { const char * basePath = Cvar_VariableString ( \"fs_basepath\" ) ; if ( ! basePath || ! * basePath ) basePath = \".\" ; if ( FS_FilenameCompare ( topDir , basePath ) ) { Com_Printf ( \"Tryingtoload\\\\\"%s\\\\\"from\\\\\"%s\\\\\"...\\\\n\" , name , basePath ) ; Com_sprintf ( libPath , sizeof ( libPath ) , \"%s%c%s\" , basePath , PATH_SEP , name ) ; dllhandle = Sys_LoadLibrary ( libPath ) ; } if ( ! dllhandle ) Com_Printf ( \"Loading\\\\\"%s\\\\\"failed\\\\n\" , name ) ; } } return dllhandle ; }\n", "\n", "\n", "Target: = vdup_n_u8 ( bifilter4_coeff [ xoffset = vdup_n_u8 ( bifilter4_coeff [ xoffset\n", "\n", "Sources:\n", "0: CWE-119 void vp8_bilinear_predict8x4_neon ( unsigned char * src_ptr , int src_pixels_per_line , int xoffset , int yoffset , unsigned char * dst_ptr , int dst_pitch ) { uint8x8_t d0u8 , d1u8 , d2u8 , d3u8 , d4u8 , d5u8 ; uint8x8_t d7u8 , d9u8 , d11u8 , d22u8 , d23u8 , d24u8 , d25u8 , d26u8 ; uint8x16_t q1u8 , q2u8 , q3u8 , q4u8 , q5u8 ; uint16x8_t q1u16 , q2u16 , q3u16 , q4u16 ; uint16x8_t q6u16 , q7u16 , q8u16 , q9u16 , q10u16 ; if ( xoffset == 0 ) { d22u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d23u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d24u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d25u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d26u8 = vld1_u8 ( src_ptr ) ; } else { q1u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q2u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q3u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q4u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q5u8 = vld1q_u8 ( src_ptr ) ; d0u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 1 ] ) ; q6u16 = vmull_u8 ( vget_low_u8 ( q1u8 ) , d0u8 ) ; q7u16 = vmull_u8 ( vget_low_u8 ( q2u8 ) , d0u8 ) ; q8u16 = vmull_u8 ( vget_low_u8 ( q3u8 ) , d0u8 ) ; q9u16 = vmull_u8 ( vget_low_u8 ( q4u8 ) , d0u8 ) ; q10u16 = vmull_u8 ( vget_low_u8 ( q5u8 ) , d0u8 ) ; d3u8 = vext_u8 ( vget_low_u8 ( q1u8 ) , vget_high_u8 ( q1u8 ) , 1 ) ; d5u8 = vext_u8 ( vget_low_u8 ( q2u8 ) , vget_high_u8 ( q2u8 ) , 1 ) ; d7u8 = vext_u8 ( vget_low_u8 ( q3u8 ) , vget_high_u8 ( q3u8 ) , 1 ) ; d9u8 = vext_u8 ( vget_low_u8 ( q4u8 ) , vget_high_u8 ( q4u8 ) , 1 ) ; d11u8 = vext_u8 ( vget_low_u8 ( q5u8 ) , vget_high_u8 ( q5u8 ) , 1 ) ; q6u16 = vmlal_u8 ( q6u16 , d3u8 , d1u8 ) ; q7u16 = vmlal_u8 ( q7u16 , d5u8 , d1u8 ) ; q8u16 = vmlal_u8 ( q8u16 , d7u8 , d1u8 ) ; q9u16 = vmlal_u8 ( q9u16 , d9u8 , d1u8 ) ; q10u16 = vmlal_u8 ( q10u16 , d11u8 , d1u8 ) ; d22u8 = vqrshrn_n_u16 ( q6u16 , 7 ) ; d23u8 = vqrshrn_n_u16 ( q7u16 , 7 ) ; d24u8 = vqrshrn_n_u16 ( q8u16 , 7 ) ; d25u8 = vqrshrn_n_u16 ( q9u16 , 7 ) ; d26u8 = vqrshrn_n_u16 ( q10u16 , 7 ) ; } if ( yoffset == 0 ) { vst1_u8 ( ( uint8_t * ) dst_ptr , d22u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d23u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d24u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d25u8 ) ; } else { d0u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 1 ] ) ; q1u16 = vmull_u8 ( d22u8 , d0u8 ) ; q2u16 = vmull_u8 ( d23u8 , d0u8 ) ; q3u16 = vmull_u8 ( d24u8 , d0u8 ) ; q4u16 = vmull_u8 ( d25u8 , d0u8 ) ; q1u16 = vmlal_u8 ( q1u16 , d23u8 , d1u8 ) ; q2u16 = vmlal_u8 ( q2u16 , d24u8 , d1u8 ) ; q3u16 = vmlal_u8 ( q3u16 , d25u8 , d1u8 ) ; q4u16 = vmlal_u8 ( q4u16 , d26u8 , d1u8 ) ; d2u8 = vqrshrn_n_u16 ( q1u16 , 7 ) ; d3u8 = vqrshrn_n_u16 ( q2u16 , 7 ) ; d4u8 = vqrshrn_n_u16 ( q3u16 , 7 ) ; d5u8 = vqrshrn_n_u16 ( q4u16 , 7 ) ; vst1_u8 ( ( uint8_t * ) dst_ptr , d2u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d3u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d4u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d5u8 ) ; } return ; }\n", "\n", "1: CWE-119 void vp8_bilinear_predict8x8_neon ( unsigned char * src_ptr , int src_pixels_per_line , int xoffset , int yoffset , unsigned char * dst_ptr , int dst_pitch ) { uint8x8_t d0u8 , d1u8 , d2u8 , d3u8 , d4u8 , d5u8 , d6u8 , d7u8 , d8u8 , d9u8 , d11u8 ; uint8x8_t d22u8 , d23u8 , d24u8 , d25u8 , d26u8 , d27u8 , d28u8 , d29u8 , d30u8 ; uint8x16_t q1u8 , q2u8 , q3u8 , q4u8 , q5u8 ; uint16x8_t q1u16 , q2u16 , q3u16 , q4u16 , q5u16 ; uint16x8_t q6u16 , q7u16 , q8u16 , q9u16 , q10u16 ; if ( xoffset == 0 ) { d22u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d23u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d24u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d25u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d26u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d27u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d28u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d29u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d30u8 = vld1_u8 ( src_ptr ) ; } else { q1u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q2u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q3u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q4u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d0u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 1 ] ) ; q6u16 = vmull_u8 ( vget_low_u8 ( q1u8 ) , d0u8 ) ; q7u16 = vmull_u8 ( vget_low_u8 ( q2u8 ) , d0u8 ) ; q8u16 = vmull_u8 ( vget_low_u8 ( q3u8 ) , d0u8 ) ; q9u16 = vmull_u8 ( vget_low_u8 ( q4u8 ) , d0u8 ) ; d3u8 = vext_u8 ( vget_low_u8 ( q1u8 ) , vget_high_u8 ( q1u8 ) , 1 ) ; d5u8 = vext_u8 ( vget_low_u8 ( q2u8 ) , vget_high_u8 ( q2u8 ) , 1 ) ; d7u8 = vext_u8 ( vget_low_u8 ( q3u8 ) , vget_high_u8 ( q3u8 ) , 1 ) ; d9u8 = vext_u8 ( vget_low_u8 ( q4u8 ) , vget_high_u8 ( q4u8 ) , 1 ) ; q6u16 = vmlal_u8 ( q6u16 , d3u8 , d1u8 ) ; q7u16 = vmlal_u8 ( q7u16 , d5u8 , d1u8 ) ; q8u16 = vmlal_u8 ( q8u16 , d7u8 , d1u8 ) ; q9u16 = vmlal_u8 ( q9u16 , d9u8 , d1u8 ) ; d22u8 = vqrshrn_n_u16 ( q6u16 , 7 ) ; d23u8 = vqrshrn_n_u16 ( q7u16 , 7 ) ; d24u8 = vqrshrn_n_u16 ( q8u16 , 7 ) ; d25u8 = vqrshrn_n_u16 ( q9u16 , 7 ) ; q1u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q2u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q3u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q4u8 = vld1q_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; q5u8 = vld1q_u8 ( src_ptr ) ; q6u16 = vmull_u8 ( vget_low_u8 ( q1u8 ) , d0u8 ) ; q7u16 = vmull_u8 ( vget_low_u8 ( q2u8 ) , d0u8 ) ; q8u16 = vmull_u8 ( vget_low_u8 ( q3u8 ) , d0u8 ) ; q9u16 = vmull_u8 ( vget_low_u8 ( q4u8 ) , d0u8 ) ; q10u16 = vmull_u8 ( vget_low_u8 ( q5u8 ) , d0u8 ) ; d3u8 = vext_u8 ( vget_low_u8 ( q1u8 ) , vget_high_u8 ( q1u8 ) , 1 ) ; d5u8 = vext_u8 ( vget_low_u8 ( q2u8 ) , vget_high_u8 ( q2u8 ) , 1 ) ; d7u8 = vext_u8 ( vget_low_u8 ( q3u8 ) , vget_high_u8 ( q3u8 ) , 1 ) ; d9u8 = vext_u8 ( vget_low_u8 ( q4u8 ) , vget_high_u8 ( q4u8 ) , 1 ) ; d11u8 = vext_u8 ( vget_low_u8 ( q5u8 ) , vget_high_u8 ( q5u8 ) , 1 ) ; q6u16 = vmlal_u8 ( q6u16 , d3u8 , d1u8 ) ; q7u16 = vmlal_u8 ( q7u16 , d5u8 , d1u8 ) ; q8u16 = vmlal_u8 ( q8u16 , d7u8 , d1u8 ) ; q9u16 = vmlal_u8 ( q9u16 , d9u8 , d1u8 ) ; q10u16 = vmlal_u8 ( q10u16 , d11u8 , d1u8 ) ; d26u8 = vqrshrn_n_u16 ( q6u16 , 7 ) ; d27u8 = vqrshrn_n_u16 ( q7u16 , 7 ) ; d28u8 = vqrshrn_n_u16 ( q8u16 , 7 ) ; d29u8 = vqrshrn_n_u16 ( q9u16 , 7 ) ; d30u8 = vqrshrn_n_u16 ( q10u16 , 7 ) ; } if ( yoffset == 0 ) { vst1_u8 ( ( uint8_t * ) dst_ptr , d22u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d23u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d24u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d25u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d26u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d27u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d28u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d29u8 ) ; } else { d0u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 1 ] ) ; q1u16 = vmull_u8 ( d22u8 , d0u8 ) ; q2u16 = vmull_u8 ( d23u8 , d0u8 ) ; q3u16 = vmull_u8 ( d24u8 , d0u8 ) ; q4u16 = vmull_u8 ( d25u8 , d0u8 ) ; q5u16 = vmull_u8 ( d26u8 , d0u8 ) ; q6u16 = vmull_u8 ( d27u8 , d0u8 ) ; q7u16 = vmull_u8 ( d28u8 , d0u8 ) ; q8u16 = vmull_u8 ( d29u8 , d0u8 ) ; q1u16 = vmlal_u8 ( q1u16 , d23u8 , d1u8 ) ; q2u16 = vmlal_u8 ( q2u16 , d24u8 , d1u8 ) ; q3u16 = vmlal_u8 ( q3u16 , d25u8 , d1u8 ) ; q4u16 = vmlal_u8 ( q4u16 , d26u8 , d1u8 ) ; q5u16 = vmlal_u8 ( q5u16 , d27u8 , d1u8 ) ; q6u16 = vmlal_u8 ( q6u16 , d28u8 , d1u8 ) ; q7u16 = vmlal_u8 ( q7u16 , d29u8 , d1u8 ) ; q8u16 = vmlal_u8 ( q8u16 , d30u8 , d1u8 ) ; d2u8 = vqrshrn_n_u16 ( q1u16 , 7 ) ; d3u8 = vqrshrn_n_u16 ( q2u16 , 7 ) ; d4u8 = vqrshrn_n_u16 ( q3u16 , 7 ) ; d5u8 = vqrshrn_n_u16 ( q4u16 , 7 ) ; d6u8 = vqrshrn_n_u16 ( q5u16 , 7 ) ; d7u8 = vqrshrn_n_u16 ( q6u16 , 7 ) ; d8u8 = vqrshrn_n_u16 ( q7u16 , 7 ) ; d9u8 = vqrshrn_n_u16 ( q8u16 , 7 ) ; vst1_u8 ( ( uint8_t * ) dst_ptr , d2u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d3u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d4u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d5u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d6u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d7u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d8u8 ) ; dst_ptr += dst_pitch ; vst1_u8 ( ( uint8_t * ) dst_ptr , d9u8 ) ; } return ; }\n", "\n", "\n", "Target: * fc , vpx_reader * r )\n", "\n", "Sources:\n", "0: CWE-119 static void read_inter_mode_probs ( FRAME_CONTEXT * fc , vp9_reader * r ) { int i , j ; for ( i = 0 ; i < INTER_MODE_CONTEXTS ; ++ i ) for ( j = 0 ; j < INTER_MODES - 1 ; ++ j ) vp9_diff_update_prob ( r , & fc -> inter_mode_probs [ i ] [ j ] ) ; }\n", "\n", "1: CWE-119 static void read_switchable_interp_probs ( FRAME_CONTEXT * fc , vp9_reader * r ) { int i , j ; for ( j = 0 ; j < SWITCHABLE_FILTER_CONTEXTS ; ++ j ) for ( i = 0 ; i < SWITCHABLE_FILTERS - 1 ; ++ i ) vp9_diff_update_prob ( r , & fc -> switchable_interp_prob [ j ] [ i ] ) ; }\n", "\n", "\n", "Target: , p_data , p_total_data_size , , p_data , p_total_data_size ,\n", "\n", "Sources:\n", "0: CWE-119 static OPJ_BOOL opj_j2k_write_all_tile_parts ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , opj_stream_private_t * p_stream , struct opj_event_mgr * p_manager ) { OPJ_UINT32 tilepartno = 0 ; OPJ_UINT32 l_nb_bytes_written = 0 ; OPJ_UINT32 l_current_nb_bytes_written ; OPJ_UINT32 l_part_tile_size ; OPJ_UINT32 tot_num_tp ; OPJ_UINT32 pino ; OPJ_BYTE * l_begin_data ; opj_tcp_t * l_tcp = 00 ; opj_tcd_t * l_tcd = 00 ; opj_cp_t * l_cp = 00 ; l_tcd = p_j2k -> m_tcd ; l_cp = & ( p_j2k -> m_cp ) ; l_tcp = l_cp -> tcps + p_j2k -> m_current_tile_number ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , 0 , p_j2k -> m_current_tile_number ) ; ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; for ( tilepartno = 1 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } p_data += l_current_nb_bytes_written ; l_nb_bytes_written += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } for ( pino = 1 ; pino <= l_tcp -> numpocs ; ++ pino ) { l_tcd -> cur_pino = pino ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , pino , p_j2k -> m_current_tile_number ) ; for ( tilepartno = 0 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } } * p_data_written = l_nb_bytes_written ; return OPJ_TRUE ; }\n", "\n", "1: CWE-787 static OPJ_BOOL opj_j2k_write_all_tile_parts ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , opj_stream_private_t * p_stream , struct opj_event_mgr * p_manager ) { OPJ_UINT32 tilepartno = 0 ; OPJ_UINT32 l_nb_bytes_written = 0 ; OPJ_UINT32 l_current_nb_bytes_written ; OPJ_UINT32 l_part_tile_size ; OPJ_UINT32 tot_num_tp ; OPJ_UINT32 pino ; OPJ_BYTE * l_begin_data ; opj_tcp_t * l_tcp = 00 ; opj_tcd_t * l_tcd = 00 ; opj_cp_t * l_cp = 00 ; l_tcd = p_j2k -> m_tcd ; l_cp = & ( p_j2k -> m_cp ) ; l_tcp = l_cp -> tcps + p_j2k -> m_current_tile_number ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , 0 , p_j2k -> m_current_tile_number ) ; ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; for ( tilepartno = 1 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } p_data += l_current_nb_bytes_written ; l_nb_bytes_written += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } for ( pino = 1 ; pino <= l_tcp -> numpocs ; ++ pino ) { l_tcd -> cur_pino = pino ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , pino , p_j2k -> m_current_tile_number ) ; for ( tilepartno = 0 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } } * p_data_written = l_nb_bytes_written ; return OPJ_TRUE ; }\n", "\n", "\n", "Target: -> mmap_sem ) ; if ( ! mmget_still_valid ( mm ) ) goto skip_mm umap_lock ) ; skip_mm :\n", "\n", "Sources:\n", "0: CWE-362 void uverbs_user_mmap_disassociate ( struct ib_uverbs_file * ufile ) { struct rdma_umap_priv * priv , * next_priv ; lockdep_assert_held ( & ufile -> hw_destroy_rwsem ) ; while ( 1 ) { struct mm_struct * mm = NULL ; mutex_lock ( & ufile -> umap_lock ) ; while ( ! list_empty ( & ufile -> umaps ) ) { int ret ; priv = list_first_entry ( & ufile -> umaps , struct rdma_umap_priv , list ) ; mm = priv -> vma -> vm_mm ; ret = mmget_not_zero ( mm ) ; if ( ! ret ) { list_del_init ( & priv -> list ) ; mm = NULL ; continue ; } break ; } mutex_unlock ( & ufile -> umap_lock ) ; if ( ! mm ) return ; down_write ( & mm -> mmap_sem ) ; mutex_lock ( & ufile -> umap_lock ) ; list_for_each_entry_safe ( priv , next_priv , & ufile -> umaps , list ) { struct vm_area_struct * vma = priv -> vma ; if ( vma -> vm_mm != mm ) continue ; list_del_init ( & priv -> list ) ; zap_vma_ptes ( vma , vma -> vm_start , vma -> vm_end - vma -> vm_start ) ; vma -> vm_flags &= ~ ( VM_SHARED | VM_MAYSHARE ) ; } mutex_unlock ( & ufile -> umap_lock ) ; up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; } }\n", "\n", "1: CWE-667 void uverbs_user_mmap_disassociate ( struct ib_uverbs_file * ufile ) { struct rdma_umap_priv * priv , * next_priv ; lockdep_assert_held ( & ufile -> hw_destroy_rwsem ) ; while ( 1 ) { struct mm_struct * mm = NULL ; mutex_lock ( & ufile -> umap_lock ) ; while ( ! list_empty ( & ufile -> umaps ) ) { int ret ; priv = list_first_entry ( & ufile -> umaps , struct rdma_umap_priv , list ) ; mm = priv -> vma -> vm_mm ; ret = mmget_not_zero ( mm ) ; if ( ! ret ) { list_del_init ( & priv -> list ) ; mm = NULL ; continue ; } break ; } mutex_unlock ( & ufile -> umap_lock ) ; if ( ! mm ) return ; down_write ( & mm -> mmap_sem ) ; mutex_lock ( & ufile -> umap_lock ) ; list_for_each_entry_safe ( priv , next_priv , & ufile -> umaps , list ) { struct vm_area_struct * vma = priv -> vma ; if ( vma -> vm_mm != mm ) continue ; list_del_init ( & priv -> list ) ; zap_vma_ptes ( vma , vma -> vm_start , vma -> vm_end - vma -> vm_start ) ; vma -> vm_flags &= ~ ( VM_SHARED | VM_MAYSHARE ) ; } mutex_unlock ( & ufile -> umap_lock ) ; up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; } }\n", "\n", "\n", "Target: -> mglist && mp -> timer_armed &&\n", "\n", "Sources:\n", "0: CWE-20 static int __br_mdb_del ( struct net_bridge * br , struct br_mdb_entry * entry ) { struct net_bridge_mdb_htable * mdb ; struct net_bridge_mdb_entry * mp ; struct net_bridge_port_group * p ; struct net_bridge_port_group __rcu * * pp ; struct br_ip ip ; int err = - EINVAL ; if ( ! netif_running ( br -> dev ) || br -> multicast_disabled ) return - EINVAL ; if ( timer_pending ( & br -> multicast_querier_timer ) ) return - EBUSY ; ip . proto = entry -> addr . proto ; if ( ip . proto == htons ( ETH_P_IP ) ) ip . u . ip4 = entry -> addr . u . ip4 ; # if IS_ENABLED ( CONFIG_IPV6 ) else ip . u . ip6 = entry -> addr . u . ip6 ; # endif spin_lock_bh ( & br -> multicast_lock ) ; mdb = mlock_dereference ( br -> mdb , br ) ; mp = br_mdb_ip_get ( mdb , & ip ) ; if ( ! mp ) goto unlock ; for ( pp = & mp -> ports ; ( p = mlock_dereference ( * pp , br ) ) != NULL ; pp = & p -> next ) { if ( ! p -> port || p -> port -> dev -> ifindex != entry -> ifindex ) continue ; if ( p -> port -> state == BR_STATE_DISABLED ) goto unlock ; rcu_assign_pointer ( * pp , p -> next ) ; hlist_del_init ( & p -> mglist ) ; del_timer ( & p -> timer ) ; call_rcu_bh ( & p -> rcu , br_multicast_free_pg ) ; err = 0 ; if ( ! mp -> ports && ! mp -> mglist && netif_running ( br -> dev ) ) mod_timer ( & mp -> timer , jiffies ) ; break ; } unlock : spin_unlock_bh ( & br -> multicast_lock ) ; return err ; }\n", "\n", "1: CWE-20 static void br_multicast_del_pg ( struct net_bridge * br , struct net_bridge_port_group * pg ) { struct net_bridge_mdb_htable * mdb ; struct net_bridge_mdb_entry * mp ; struct net_bridge_port_group * p ; struct net_bridge_port_group __rcu * * pp ; mdb = mlock_dereference ( br -> mdb , br ) ; mp = br_mdb_ip_get ( mdb , & pg -> addr ) ; if ( WARN_ON ( ! mp ) ) return ; for ( pp = & mp -> ports ; ( p = mlock_dereference ( * pp , br ) ) != NULL ; pp = & p -> next ) { if ( p != pg ) continue ; rcu_assign_pointer ( * pp , p -> next ) ; hlist_del_init ( & p -> mglist ) ; del_timer ( & p -> timer ) ; call_rcu_bh ( & p -> rcu , br_multicast_free_pg ) ; if ( ! mp -> ports && ! mp -> mglist && netif_running ( br -> dev ) ) mod_timer ( & mp -> timer , jiffies ) ; return ; } WARN_ON ( 1 ) ; }\n", "\n", "\n", "Target: \"auth_tag_len\" ) ; id_key_set = rb_intern_const ( \"key_set\" ) ;\n", "\n", "Sources:\n", "0: CWE-326 void Init_ossl_cipher ( void ) { # if 0 mOSSL = rb_define_module ( \"OpenSSL\" ) ; eOSSLError = rb_define_class_under ( mOSSL , \"OpenSSLError\" , rb_eStandardError ) ; # endif cCipher = rb_define_class_under ( mOSSL , \"Cipher\" , rb_cObject ) ; eCipherError = rb_define_class_under ( cCipher , \"CipherError\" , eOSSLError ) ; rb_define_alloc_func ( cCipher , ossl_cipher_alloc ) ; rb_define_copy_func ( cCipher , ossl_cipher_copy ) ; rb_define_module_function ( cCipher , \"ciphers\" , ossl_s_ciphers , 0 ) ; rb_define_method ( cCipher , \"initialize\" , ossl_cipher_initialize , 1 ) ; rb_define_method ( cCipher , \"reset\" , ossl_cipher_reset , 0 ) ; rb_define_method ( cCipher , \"encrypt\" , ossl_cipher_encrypt , - 1 ) ; rb_define_method ( cCipher , \"decrypt\" , ossl_cipher_decrypt , - 1 ) ; rb_define_method ( cCipher , \"pkcs5_keyivgen\" , ossl_cipher_pkcs5_keyivgen , - 1 ) ; rb_define_method ( cCipher , \"update\" , ossl_cipher_update , - 1 ) ; rb_define_method ( cCipher , \"final\" , ossl_cipher_final , 0 ) ; rb_define_method ( cCipher , \"name\" , ossl_cipher_name , 0 ) ; rb_define_method ( cCipher , \"key=\" , ossl_cipher_set_key , 1 ) ; rb_define_method ( cCipher , \"auth_data=\" , ossl_cipher_set_auth_data , 1 ) ; rb_define_method ( cCipher , \"auth_tag=\" , ossl_cipher_set_auth_tag , 1 ) ; rb_define_method ( cCipher , \"auth_tag\" , ossl_cipher_get_auth_tag , - 1 ) ; rb_define_method ( cCipher , \"auth_tag_len=\" , ossl_cipher_set_auth_tag_len , 1 ) ; rb_define_method ( cCipher , \"authenticated?\" , ossl_cipher_is_authenticated , 0 ) ; rb_define_method ( cCipher , \"key_len=\" , ossl_cipher_set_key_length , 1 ) ; rb_define_method ( cCipher , \"key_len\" , ossl_cipher_key_length , 0 ) ; rb_define_method ( cCipher , \"iv=\" , ossl_cipher_set_iv , 1 ) ; rb_define_method ( cCipher , \"iv_len=\" , ossl_cipher_set_iv_length , 1 ) ; rb_define_method ( cCipher , \"iv_len\" , ossl_cipher_iv_length , 0 ) ; rb_define_method ( cCipher , \"block_size\" , ossl_cipher_block_size , 0 ) ; rb_define_method ( cCipher , \"padding=\" , ossl_cipher_set_padding , 1 ) ; id_auth_tag_len = rb_intern_const ( \"auth_tag_len\" ) ; } \n", "\n", "1: CWE-310 void Init_ossl_cipher ( void ) { # if 0 mOSSL = rb_define_module ( \"OpenSSL\" ) ; eOSSLError = rb_define_class_under ( mOSSL , \"OpenSSLError\" , rb_eStandardError ) ; # endif cCipher = rb_define_class_under ( mOSSL , \"Cipher\" , rb_cObject ) ; eCipherError = rb_define_class_under ( cCipher , \"CipherError\" , eOSSLError ) ; rb_define_alloc_func ( cCipher , ossl_cipher_alloc ) ; rb_define_copy_func ( cCipher , ossl_cipher_copy ) ; rb_define_module_function ( cCipher , \"ciphers\" , ossl_s_ciphers , 0 ) ; rb_define_method ( cCipher , \"initialize\" , ossl_cipher_initialize , 1 ) ; rb_define_method ( cCipher , \"reset\" , ossl_cipher_reset , 0 ) ; rb_define_method ( cCipher , \"encrypt\" , ossl_cipher_encrypt , - 1 ) ; rb_define_method ( cCipher , \"decrypt\" , ossl_cipher_decrypt , - 1 ) ; rb_define_method ( cCipher , \"pkcs5_keyivgen\" , ossl_cipher_pkcs5_keyivgen , - 1 ) ; rb_define_method ( cCipher , \"update\" , ossl_cipher_update , - 1 ) ; rb_define_method ( cCipher , \"final\" , ossl_cipher_final , 0 ) ; rb_define_method ( cCipher , \"name\" , ossl_cipher_name , 0 ) ; rb_define_method ( cCipher , \"key=\" , ossl_cipher_set_key , 1 ) ; rb_define_method ( cCipher , \"auth_data=\" , ossl_cipher_set_auth_data , 1 ) ; rb_define_method ( cCipher , \"auth_tag=\" , ossl_cipher_set_auth_tag , 1 ) ; rb_define_method ( cCipher , \"auth_tag\" , ossl_cipher_get_auth_tag , - 1 ) ; rb_define_method ( cCipher , \"auth_tag_len=\" , ossl_cipher_set_auth_tag_len , 1 ) ; rb_define_method ( cCipher , \"authenticated?\" , ossl_cipher_is_authenticated , 0 ) ; rb_define_method ( cCipher , \"key_len=\" , ossl_cipher_set_key_length , 1 ) ; rb_define_method ( cCipher , \"key_len\" , ossl_cipher_key_length , 0 ) ; rb_define_method ( cCipher , \"iv=\" , ossl_cipher_set_iv , 1 ) ; rb_define_method ( cCipher , \"iv_len=\" , ossl_cipher_set_iv_length , 1 ) ; rb_define_method ( cCipher , \"iv_len\" , ossl_cipher_iv_length , 0 ) ; rb_define_method ( cCipher , \"block_size\" , ossl_cipher_block_size , 0 ) ; rb_define_method ( cCipher , \"padding=\" , ossl_cipher_set_padding , 1 ) ; id_auth_tag_len = rb_intern_const ( \"auth_tag_len\" ) ; } \n", "\n", "\n", "Target: ++ ] ; IRDA_ASSERT ( name_len < IAS_MAX_CLASSNAME + 1 , return ; ) ; n ++ ] ; IRDA_ASSERT ( attr_len < IAS_MAX_ATTRIBNAME + 1 , return ; )\n", "\n", "Sources:\n", "0: CWE-119 static void iriap_getvaluebyclass_indication ( struct iriap_cb * self , struct sk_buff * skb ) { struct ias_object * obj ; struct ias_attrib * attrib ; int name_len ; int attr_len ; char name [ IAS_MAX_CLASSNAME + 1 ] ; char attr [ IAS_MAX_ATTRIBNAME + 1 ] ; __u8 * fp ; int n ; IRDA_DEBUG ( 4 , \"%s()\\\\n\" , __func__ ) ; IRDA_ASSERT ( self != NULL , return ; ) ; IRDA_ASSERT ( self -> magic == IAS_MAGIC , return ; ) ; IRDA_ASSERT ( skb != NULL , return ; ) ; fp = skb -> data ; n = 1 ; name_len = fp [ n ++ ] ; memcpy ( name , fp + n , name_len ) ; n += name_len ; name [ name_len ] = '\\\\0' ; attr_len = fp [ n ++ ] ; memcpy ( attr , fp + n , attr_len ) ; n += attr_len ; attr [ attr_len ] = '\\\\0' ; IRDA_DEBUG ( 4 , \"LM-IAS:Lookingup%s:%s\\\\n\" , name , attr ) ; obj = irias_find_object ( name ) ; if ( obj == NULL ) { IRDA_DEBUG ( 2 , \"LM-IAS:Object%snotfound\\\\n\" , name ) ; iriap_getvaluebyclass_response ( self , 0x1235 , IAS_CLASS_UNKNOWN , & irias_missing ) ; return ; } IRDA_DEBUG ( 4 , \"LM-IAS:found%s,id=%d\\\\n\" , obj -> name , obj -> id ) ; attrib = irias_find_attrib ( obj , attr ) ; if ( attrib == NULL ) { IRDA_DEBUG ( 2 , \"LM-IAS:Attribute%snotfound\\\\n\" , attr ) ; iriap_getvaluebyclass_response ( self , obj -> id , IAS_ATTRIB_UNKNOWN , & irias_missing ) ; return ; } iriap_getvaluebyclass_response ( self , obj -> id , IAS_SUCCESS , attrib -> value ) ; }\n", "\n", "1: CWE-787 static void iriap_getvaluebyclass_indication ( struct iriap_cb * self , struct sk_buff * skb ) { struct ias_object * obj ; struct ias_attrib * attrib ; int name_len ; int attr_len ; char name [ IAS_MAX_CLASSNAME + 1 ] ; char attr [ IAS_MAX_ATTRIBNAME + 1 ] ; __u8 * fp ; int n ; IRDA_DEBUG ( 4 , \"%s()\\\\n\" , __func__ ) ; IRDA_ASSERT ( self != NULL , return ; ) ; IRDA_ASSERT ( self -> magic == IAS_MAGIC , return ; ) ; IRDA_ASSERT ( skb != NULL , return ; ) ; fp = skb -> data ; n = 1 ; name_len = fp [ n ++ ] ; memcpy ( name , fp + n , name_len ) ; n += name_len ; name [ name_len ] = '\\\\0' ; attr_len = fp [ n ++ ] ; memcpy ( attr , fp + n , attr_len ) ; n += attr_len ; attr [ attr_len ] = '\\\\0' ; IRDA_DEBUG ( 4 , \"LM-IAS:Lookingup%s:%s\\\\n\" , name , attr ) ; obj = irias_find_object ( name ) ; if ( obj == NULL ) { IRDA_DEBUG ( 2 , \"LM-IAS:Object%snotfound\\\\n\" , name ) ; iriap_getvaluebyclass_response ( self , 0x1235 , IAS_CLASS_UNKNOWN , & irias_missing ) ; return ; } IRDA_DEBUG ( 4 , \"LM-IAS:found%s,id=%d\\\\n\" , obj -> name , obj -> id ) ; attrib = irias_find_attrib ( obj , attr ) ; if ( attrib == NULL ) { IRDA_DEBUG ( 2 , \"LM-IAS:Attribute%snotfound\\\\n\" , attr ) ; iriap_getvaluebyclass_response ( self , obj -> id , IAS_ATTRIB_UNKNOWN , & irias_missing ) ; return ; } iriap_getvaluebyclass_response ( self , obj -> id , IAS_SUCCESS , attrib -> value ) ; }\n", "\n", "\n", "Target: , read_memory , - , from_document , -\n", "\n", "Sources:\n", "0: CWE-611 void init_xml_relax_ng ( ) { VALUE nokogiri = rb_define_module ( \"Nokogiri\" ) ; VALUE xml = rb_define_module_under ( nokogiri , \"XML\" ) ; VALUE klass = rb_define_class_under ( xml , \"RelaxNG\" , cNokogiriXmlSchema ) ; cNokogiriXmlRelaxNG = klass ; rb_define_singleton_method ( klass , \"read_memory\" , read_memory , 1 ) ; rb_define_singleton_method ( klass , \"from_document\" , from_document , 1 ) ; rb_define_private_method ( klass , \"validate_document\" , validate_document , 1 ) ; }\n", "\n", "1: CWE-611 void init_xml_schema ( ) { VALUE nokogiri = rb_define_module ( \"Nokogiri\" ) ; VALUE xml = rb_define_module_under ( nokogiri , \"XML\" ) ; VALUE klass = rb_define_class_under ( xml , \"Schema\" , rb_cObject ) ; cNokogiriXmlSchema = klass ; rb_define_singleton_method ( klass , \"read_memory\" , read_memory , 1 ) ; rb_define_singleton_method ( klass , \"from_document\" , from_document , 1 ) ; rb_define_private_method ( klass , \"validate_document\" , validate_document , 1 ) ; rb_define_private_method ( klass , \"validate_file\" , validate_file , 1 ) ; }\n", "\n", "\n", "Target: ( sk ) ; bool checksum_valid = false partial_cov ) { checksum_valid = ! udp_lib_checksum_complete ( skb ( skb ) ; if ( ! checksum_valid } if ( checksum_valid ||\n", "\n", "Sources:\n", "0: CWE-358 int udp_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; DECLARE_SOCKADDR ( struct sockaddr_in * , sin , msg -> msg_name ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ip_recv_error ( sk , msg , len , addr_len ) ; try_again : skb = __skb_recv_datagram ( sk , flags | ( noblock ? MSG_DONTWAIT : 0 ) , & peeked , & off , & err ) ; if ( ! skb ) goto out ; ulen = skb -> len - sizeof ( struct udphdr ) ; copied = len ; if ( copied > ulen ) copied = ulen ; else if ( copied < ulen ) msg -> msg_flags |= MSG_TRUNC ; if ( copied < ulen || UDP_SKB_CB ( skb ) -> partial_cov ) { if ( udp_lib_checksum_complete ( skb ) ) goto csum_copy_err ; } if ( skb_csum_unnecessary ( skb ) ) err = skb_copy_datagram_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udp_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( sin ) { sin -> sin_family = AF_INET ; sin -> sin_port = udp_hdr ( skb ) -> source ; sin -> sin_addr . s_addr = ip_hdr ( skb ) -> saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; * addr_len = sizeof ( * sin ) ; } if ( inet -> cmsg_flags ) ip_cmsg_recv_offset ( msg , skb , sizeof ( struct udphdr ) ) ; err = copied ; if ( flags & MSG_TRUNC ) err = ulen ; out_free : skb_free_datagram_locked ( sk , skb ) ; out : return err ; csum_copy_err : slow = lock_sock_fast ( sk ) ; if ( ! skb_kill_datagram ( sk , skb , flags ) ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } unlock_sock_fast ( sk , slow ) ; cond_resched ( ) ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; }\n", "\n", "1: CWE-358 int udpv6_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; int is_udp4 ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ipv6_recv_error ( sk , msg , len , addr_len ) ; if ( np -> rxpmtu && np -> rxopt . bits . rxpmtu ) return ipv6_recv_rxpmtu ( sk , msg , len , addr_len ) ; try_again : skb = __skb_recv_datagram ( sk , flags | ( noblock ? MSG_DONTWAIT : 0 ) , & peeked , & off , & err ) ; if ( ! skb ) goto out ; ulen = skb -> len - sizeof ( struct udphdr ) ; copied = len ; if ( copied > ulen ) copied = ulen ; else if ( copied < ulen ) msg -> msg_flags |= MSG_TRUNC ; is_udp4 = ( skb -> protocol == htons ( ETH_P_IP ) ) ; if ( copied < ulen || UDP_SKB_CB ( skb ) -> partial_cov ) { if ( udp_lib_checksum_complete ( skb ) ) goto csum_copy_err ; } if ( skb_csum_unnecessary ( skb ) ) err = skb_copy_datagram_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udpv6_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) { if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; } sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) { DECLARE_SOCKADDR ( struct sockaddr_in6 * , sin6 , msg -> msg_name ) ; sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = udp_hdr ( skb ) -> source ; sin6 -> sin6_flowinfo = 0 ; if ( is_udp4 ) { ipv6_addr_set_v4mapped ( ip_hdr ( skb ) -> saddr , & sin6 -> sin6_addr ) ; sin6 -> sin6_scope_id = 0 ; } else { sin6 -> sin6_addr = ipv6_hdr ( skb ) -> saddr ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , inet6_iif ( skb ) ) ; } * addr_len = sizeof ( * sin6 ) ; } if ( np -> rxopt . all ) ip6_datagram_recv_common_ctl ( sk , msg , skb ) ; if ( is_udp4 ) { if ( inet -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; } else { if ( np -> rxopt . all ) ip6_datagram_recv_specific_ctl ( sk , msg , skb ) ; } err = copied ; if ( flags & MSG_TRUNC ) err = ulen ; out_free : skb_free_datagram_locked ( sk , skb ) ; out : return err ; csum_copy_err : slow = lock_sock_fast ( sk ) ; if ( ! skb_kill_datagram ( sk , skb , flags ) ) { if ( is_udp4 ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } else { UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } } unlock_sock_fast ( sk , slow ) ; cond_resched ( ) ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; }\n", "\n", "\n", "Target: , plane ) * ( ( img -> fmt & VPX_IMG_FMT_HIGHBITDEPTH ) ? 2 : 1 )\n", "\n", "Sources:\n", "0: CWE-119 void vpx_img_write ( const vpx_image_t * img , FILE * file ) { int plane ; for ( plane = 0 ; plane < 3 ; ++ plane ) { const unsigned char * buf = img -> planes [ plane ] ; const int stride = img -> stride [ plane ] ; const int w = vpx_img_plane_width ( img , plane ) ; const int h = vpx_img_plane_height ( img , plane ) ; int y ; for ( y = 0 ; y < h ; ++ y ) { fwrite ( buf , 1 , w , file ) ; buf += stride ; } } }\n", "\n", "1: CWE-119 static void update_image_md5 ( const vpx_image_t * img , const int planes [ 3 ] , MD5Context * md5 ) { int i , y ; for ( i = 0 ; i < 3 ; ++ i ) { const int plane = planes [ i ] ; const unsigned char * buf = img -> planes [ plane ] ; const int stride = img -> stride [ plane ] ; const int w = vpx_img_plane_width ( img , plane ) ; const int h = vpx_img_plane_height ( img , plane ) ; for ( y = 0 ; y < h ; ++ y ) { MD5Update ( md5 , buf , w ) ; buf += stride ; } } }\n", "\n", "\n", "Target: , 1 , regs , 0\n", "\n", "Sources:\n", "0: CWE-400 int vis_emul ( struct pt_regs * regs , unsigned int insn ) { unsigned long pc = regs -> tpc ; unsigned int opf ; BUG_ON ( regs -> tstate & TSTATE_PRIV ) ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; if ( test_thread_flag ( TIF_32BIT ) ) pc = ( u32 ) pc ; if ( get_user ( insn , ( u32 __user * ) pc ) ) return - EFAULT ; save_and_clear_fpu ( ) ; opf = ( insn & VIS_OPF_MASK ) >> VIS_OPF_SHIFT ; switch ( opf ) { default : return - EINVAL ; case FPACK16_OPF : case FPACK32_OPF : case FPACKFIX_OPF : case FEXPAND_OPF : case FPMERGE_OPF : pformat ( regs , insn , opf ) ; break ; case FMUL8x16_OPF : case FMUL8x16AU_OPF : case FMUL8x16AL_OPF : case FMUL8SUx16_OPF : case FMUL8ULx16_OPF : case FMULD8SUx16_OPF : case FMULD8ULx16_OPF : pmul ( regs , insn , opf ) ; break ; case FCMPGT16_OPF : case FCMPGT32_OPF : case FCMPLE16_OPF : case FCMPLE32_OPF : case FCMPNE16_OPF : case FCMPNE32_OPF : case FCMPEQ16_OPF : case FCMPEQ32_OPF : pcmp ( regs , insn , opf ) ; break ; case EDGE8_OPF : case EDGE8N_OPF : case EDGE8L_OPF : case EDGE8LN_OPF : case EDGE16_OPF : case EDGE16N_OPF : case EDGE16L_OPF : case EDGE16LN_OPF : case EDGE32_OPF : case EDGE32N_OPF : case EDGE32L_OPF : case EDGE32LN_OPF : edge ( regs , insn , opf ) ; break ; case PDIST_OPF : pdist ( regs , insn ) ; break ; case ARRAY8_OPF : case ARRAY16_OPF : case ARRAY32_OPF : array ( regs , insn , opf ) ; break ; case BMASK_OPF : bmask ( regs , insn ) ; break ; case BSHUFFLE_OPF : bshuffle ( regs , insn ) ; break ; } regs -> tpc = regs -> tnpc ; regs -> tnpc += 4 ; return 0 ; }\n", "\n", "1: CWE-400 int handle_ldf_stq ( u32 insn , struct pt_regs * regs ) { unsigned long addr = compute_effective_address ( regs , insn , 0 ) ; int freg = ( ( insn >> 25 ) & 0x1e ) | ( ( insn >> 20 ) & 0x20 ) ; struct fpustate * f = FPUSTATE ; int asi = decode_asi ( insn , regs ) ; int flag = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; save_and_clear_fpu ( ) ; current_thread_info ( ) -> xfsr [ 0 ] &= ~ 0x1c000 ; if ( freg & 3 ) { current_thread_info ( ) -> xfsr [ 0 ] |= ( 6 << 14 ) ; do_fpother ( regs ) ; return 0 ; } if ( insn & 0x200000 ) { u64 first = 0 , second = 0 ; if ( current_thread_info ( ) -> fpsaved [ 0 ] & flag ) { first = * ( u64 * ) & f -> regs [ freg ] ; second = * ( u64 * ) & f -> regs [ freg + 2 ] ; } if ( asi < 0x80 ) { do_privact ( regs ) ; return 1 ; } switch ( asi ) { case ASI_P : case ASI_S : break ; case ASI_PL : case ASI_SL : { u64 tmp = __swab64p ( & first ) ; first = __swab64p ( & second ) ; second = tmp ; break ; } default : if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , addr , 0 ) ; else spitfire_data_access_exception ( regs , 0 , addr ) ; return 1 ; } if ( put_user ( first >> 32 , ( u32 __user * ) addr ) || __put_user ( ( u32 ) first , ( u32 __user * ) ( addr + 4 ) ) || __put_user ( second >> 32 , ( u32 __user * ) ( addr + 8 ) ) || __put_user ( ( u32 ) second , ( u32 __user * ) ( addr + 12 ) ) ) { if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , addr , 0 ) ; else spitfire_data_access_exception ( regs , 0 , addr ) ; return 1 ; } } else { u32 data [ 4 ] __attribute__ ( ( aligned ( 8 ) ) ) ; int size , i ; int err ; if ( asi < 0x80 ) { do_privact ( regs ) ; return 1 ; } else if ( asi > ASI_SNFL ) { if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , addr , 0 ) ; else spitfire_data_access_exception ( regs , 0 , addr ) ; return 1 ; } switch ( insn & 0x180000 ) { case 0x000000 : size = 1 ; break ; case 0x100000 : size = 4 ; break ; default : size = 2 ; break ; } for ( i = 0 ; i < size ; i ++ ) data [ i ] = 0 ; err = get_user ( data [ 0 ] , ( u32 __user * ) addr ) ; if ( ! err ) { for ( i = 1 ; i < size ; i ++ ) err |= __get_user ( data [ i ] , ( u32 __user * ) ( addr + 4 * i ) ) ; } if ( err && ! ( asi & 0x2 ) ) { if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , addr , 0 ) ; else spitfire_data_access_exception ( regs , 0 , addr ) ; return 1 ; } if ( asi & 0x8 ) { u64 tmp ; switch ( size ) { case 1 : data [ 0 ] = le32_to_cpup ( data + 0 ) ; break ; default : * ( u64 * ) ( data + 0 ) = le64_to_cpup ( ( u64 * ) ( data + 0 ) ) ; break ; case 4 : tmp = le64_to_cpup ( ( u64 * ) ( data + 0 ) ) ; * ( u64 * ) ( data + 0 ) = le64_to_cpup ( ( u64 * ) ( data + 2 ) ) ; * ( u64 * ) ( data + 2 ) = tmp ; break ; } } if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & FPRS_FEF ) ) { current_thread_info ( ) -> fpsaved [ 0 ] = FPRS_FEF ; current_thread_info ( ) -> gsr [ 0 ] = 0 ; } if ( ! ( current_thread_info ( ) -> fpsaved [ 0 ] & flag ) ) { if ( freg < 32 ) memset ( f -> regs , 0 , 32 * sizeof ( u32 ) ) ; else memset ( f -> regs + 32 , 0 , 32 * sizeof ( u32 ) ) ; } memcpy ( f -> regs + freg , data , size * 4 ) ; current_thread_info ( ) -> fpsaved [ 0 ] |= flag ; } advance ( regs ) ; return 1 ; }\n", "\n", "2: CWE-399 static int simulate_sync ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == SPEC0 && ( opcode & FUNC ) == SYNC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return 0 ; } return - 1 ; }\n", "\n", "3: CWE-400 static int simulate_rdhwr ( struct pt_regs * regs , unsigned int opcode ) { struct thread_info * ti = task_thread_info ( current ) ; if ( ( opcode & OPCODE ) == SPEC3 && ( opcode & FUNC ) == RDHWR ) { int rd = ( opcode & RD ) >> 11 ; int rt = ( opcode & RT ) >> 16 ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; switch ( rd ) { case 0 : regs -> regs [ rt ] = smp_processor_id ( ) ; return 0 ; case 1 : regs -> regs [ rt ] = min ( current_cpu_data . dcache . linesz , current_cpu_data . icache . linesz ) ; return 0 ; case 2 : regs -> regs [ rt ] = read_c0_count ( ) ; return 0 ; case 3 : switch ( current_cpu_data . cputype ) { case CPU_20KC : case CPU_25KF : regs -> regs [ rt ] = 1 ; break ; default : regs -> regs [ rt ] = 2 ; } return 0 ; case 29 : regs -> regs [ rt ] = ti -> tp_value ; return 0 ; default : return - 1 ; } } return - 1 ; }\n", "\n", "4: CWE-400 static int simulate_sync ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == SPEC0 && ( opcode & FUNC ) == SYNC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return 0 ; } return - 1 ; }\n", "\n", "5: CWE-400 void handle_ld_nf ( u32 insn , struct pt_regs * regs ) { int rd = ( ( insn >> 25 ) & 0x1f ) ; int from_kernel = ( regs -> tstate & TSTATE_PRIV ) != 0 ; unsigned long * reg ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; maybe_flush_windows ( 0 , 0 , rd , from_kernel ) ; reg = fetch_reg_addr ( rd , regs ) ; if ( from_kernel || rd < 16 ) { reg [ 0 ] = 0 ; if ( ( insn & 0x780000 ) == 0x180000 ) reg [ 1 ] = 0 ; } else if ( test_thread_flag ( TIF_32BIT ) ) { put_user ( 0 , ( int __user * ) reg ) ; if ( ( insn & 0x780000 ) == 0x180000 ) put_user ( 0 , ( ( int __user * ) reg ) + 1 ) ; } else { put_user ( 0 , ( unsigned long __user * ) reg ) ; if ( ( insn & 0x780000 ) == 0x180000 ) put_user ( 0 , ( unsigned long __user * ) reg + 1 ) ; } advance ( regs ) ; }\n", "\n", "\n", "Target: cpl , false , NULL\n", "\n", "Sources:\n", "0: CWE-264 static int load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg ) { u8 cpl = ctxt -> ops -> cpl ( ctxt ) ; return __load_segment_descriptor ( ctxt , selector , seg , cpl , false ) ; }\n", "\n", "1: CWE-000 static int load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg ) { u8 cpl = ctxt -> ops -> cpl ( ctxt ) ; return __load_segment_descriptor ( ctxt , selector , seg , cpl , false ) ; }\n", "\n", "\n", "Target: ENCBASE64 ) { const int olen = 3 * len 4 + 1 ; char * out = mutt_mem_malloc ( olen out , it , olen\n", "\n", "Sources:\n", "0: CWE-119 static char * rfc2047_decode_word ( const char * s , size_t len , enum ContentEncoding enc ) { const char * it = s ; const char * end = s + len ; if ( enc == ENCQUOTEDPRINTABLE ) { struct Buffer buf = { 0 } ; for ( ; it < end ; ++ it ) { if ( * it == '_' ) { mutt_buffer_addch ( & buf , '' ) ; } else if ( ( * it == '=' ) && ( ! ( it [ 1 ] & ~ 127 ) && hexval ( it [ 1 ] ) != - 1 ) && ( ! ( it [ 2 ] & ~ 127 ) && hexval ( it [ 2 ] ) != - 1 ) ) { mutt_buffer_addch ( & buf , ( hexval ( it [ 1 ] ) << 4 ) | hexval ( it [ 2 ] ) ) ; it += 2 ; } else { mutt_buffer_addch ( & buf , * it ) ; } } mutt_buffer_addch ( & buf , '\\\\0' ) ; return buf . data ; } else if ( enc == ENCBASE64 ) { char * out = mutt_mem_malloc ( 3 * len / 4 + 1 ) ; int dlen = mutt_b64_decode ( out , it ) ; if ( dlen == - 1 ) { FREE ( & out ) ; return NULL ; } out [ dlen ] = '\\\\0' ; return out ; } assert ( 0 ) ; return NULL ; }\n", "\n", "1: CWE-120 static char * rfc2047_decode_word ( const char * s , size_t len , enum ContentEncoding enc ) { const char * it = s ; const char * end = s + len ; if ( enc == ENCQUOTEDPRINTABLE ) { struct Buffer buf = { 0 } ; for ( ; it < end ; ++ it ) { if ( * it == '_' ) { mutt_buffer_addch ( & buf , '' ) ; } else if ( ( * it == '=' ) && ( ! ( it [ 1 ] & ~ 127 ) && hexval ( it [ 1 ] ) != - 1 ) && ( ! ( it [ 2 ] & ~ 127 ) && hexval ( it [ 2 ] ) != - 1 ) ) { mutt_buffer_addch ( & buf , ( hexval ( it [ 1 ] ) << 4 ) | hexval ( it [ 2 ] ) ) ; it += 2 ; } else { mutt_buffer_addch ( & buf , * it ) ; } } mutt_buffer_addch ( & buf , '\\\\0' ) ; return buf . data ; } else if ( enc == ENCBASE64 ) { char * out = mutt_mem_malloc ( 3 * len / 4 + 1 ) ; int dlen = mutt_b64_decode ( out , it ) ; if ( dlen == - 1 ) { FREE ( & out ) ; return NULL ; } out [ dlen ] = '\\\\0' ; return out ; } assert ( 0 ) ; return NULL ; }\n", "\n", "\n", "Target: best_address , in_what_stride ) + mvsad_err_cost check_here , in_what_stride ) ; if\n", "\n", "Sources:\n", "0: CWE-119 int vp8_refining_search_sadx4 ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int error_per_bit , int search_range , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { MV neighbors [ 4 ] = { { - 1 , 0 } , { 0 , - 1 } , { 0 , 1 } , { 1 , 0 } } ; int i , j ; short this_row_offset , this_col_offset ; int what_stride = b -> src_stride ; int pre_stride = x -> e_mbd . pre . y_stride ; unsigned char * base_pre = x -> e_mbd . pre . y_buffer ; int in_what_stride = pre_stride ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; unsigned char * best_address = ( unsigned char * ) ( base_pre + d -> offset + ( ref_mv -> as_mv . row * pre_stride ) + ref_mv -> as_mv . col ) ; unsigned char * check_here ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int * mvsadcost [ 2 ] ; int_mv fcenter_mv ; mvsadcost [ 0 ] = x -> mvsadcost [ 0 ] ; mvsadcost [ 1 ] = x -> mvsadcost [ 1 ] ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; bestsad = fn_ptr -> sdf ( what , what_stride , best_address , in_what_stride , UINT_MAX ) + mvsad_err_cost ( ref_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; for ( i = 0 ; i < search_range ; i ++ ) { int best_site = - 1 ; int all_in = 1 ; all_in &= ( ( ref_mv -> as_mv . row - 1 ) > x -> mv_row_min ) ; all_in &= ( ( ref_mv -> as_mv . row + 1 ) < x -> mv_row_max ) ; all_in &= ( ( ref_mv -> as_mv . col - 1 ) > x -> mv_col_min ) ; all_in &= ( ( ref_mv -> as_mv . col + 1 ) < x -> mv_col_max ) ; if ( all_in ) { unsigned int sad_array [ 4 ] ; const unsigned char * block_offset [ 4 ] ; block_offset [ 0 ] = best_address - in_what_stride ; block_offset [ 1 ] = best_address - 1 ; block_offset [ 2 ] = best_address + 1 ; block_offset [ 3 ] = best_address + in_what_stride ; fn_ptr -> sdx4df ( what , what_stride , block_offset , in_what_stride , sad_array ) ; for ( j = 0 ; j < 4 ; j ++ ) { if ( sad_array [ j ] < bestsad ) { this_mv . as_mv . row = ref_mv -> as_mv . row + neighbors [ j ] . row ; this_mv . as_mv . col = ref_mv -> as_mv . col + neighbors [ j ] . col ; sad_array [ j ] += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; if ( sad_array [ j ] < bestsad ) { bestsad = sad_array [ j ] ; best_site = j ; } } } } else { for ( j = 0 ; j < 4 ; j ++ ) { this_row_offset = ref_mv -> as_mv . row + neighbors [ j ] . row ; this_col_offset = ref_mv -> as_mv . col + neighbors [ j ] . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ( neighbors [ j ] . row ) * in_what_stride + neighbors [ j ] . col + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = j ; } } } } } if ( best_site == - 1 ) break ; else { ref_mv -> as_mv . row += neighbors [ best_site ] . row ; ref_mv -> as_mv . col += neighbors [ best_site ] . col ; best_address += ( neighbors [ best_site ] . row ) * in_what_stride + neighbors [ best_site ] . col ; } } this_mv . as_mv . row = ref_mv -> as_mv . row * 8 ; this_mv . as_mv . col = ref_mv -> as_mv . col * 8 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; }\n", "\n", "1: CWE-119 int vp8_refining_search_sad_c ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int error_per_bit , int search_range , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { MV neighbors [ 4 ] = { { - 1 , 0 } , { 0 , - 1 } , { 0 , 1 } , { 1 , 0 } } ; int i , j ; short this_row_offset , this_col_offset ; int what_stride = b -> src_stride ; int pre_stride = x -> e_mbd . pre . y_stride ; unsigned char * base_pre = x -> e_mbd . pre . y_buffer ; int in_what_stride = pre_stride ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; unsigned char * best_address = ( unsigned char * ) ( base_pre + d -> offset + ( ref_mv -> as_mv . row * pre_stride ) + ref_mv -> as_mv . col ) ; unsigned char * check_here ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int * mvsadcost [ 2 ] ; int_mv fcenter_mv ; mvsadcost [ 0 ] = x -> mvsadcost [ 0 ] ; mvsadcost [ 1 ] = x -> mvsadcost [ 1 ] ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; bestsad = fn_ptr -> sdf ( what , what_stride , best_address , in_what_stride , UINT_MAX ) + mvsad_err_cost ( ref_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; for ( i = 0 ; i < search_range ; i ++ ) { int best_site = - 1 ; for ( j = 0 ; j < 4 ; j ++ ) { this_row_offset = ref_mv -> as_mv . row + neighbors [ j ] . row ; this_col_offset = ref_mv -> as_mv . col + neighbors [ j ] . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ( neighbors [ j ] . row ) * in_what_stride + neighbors [ j ] . col + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = j ; } } } } if ( best_site == - 1 ) break ; else { ref_mv -> as_mv . row += neighbors [ best_site ] . row ; ref_mv -> as_mv . col += neighbors [ best_site ] . col ; best_address += ( neighbors [ best_site ] . row ) * in_what_stride + neighbors [ best_site ] . col ; } } this_mv . as_mv . row = ref_mv -> as_mv . row << 3 ; this_mv . as_mv . col = ref_mv -> as_mv . col << 3 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; }\n", "\n", "\n", "Target: , e -> elems , e ->\n", "\n", "Sources:\n", "0: CWE-264 static int check_entry_size_and_hooks ( struct ipt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ipt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ipt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ipt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } if ( ! ip_checkentry ( & e -> ip ) ) return - EINVAL ; err = xt_check_entry_offsets ( e , e -> target_offset , e -> next_offset ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_debug ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "1: CWE-264 static inline int check_entry_size_and_hooks ( struct arpt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct arpt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct arpt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct arpt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } if ( ! arp_checkentry ( & e -> arp ) ) return - EINVAL ; err = xt_check_entry_offsets ( e , e -> target_offset , e -> next_offset ) ; if ( err ) return err ; for ( h = 0 ; h < NF_ARP_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_debug ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "2: CWE-264 static int check_entry_size_and_hooks ( struct ip6t_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ip6t_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ip6t_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( \"Badoffset%p\\\\n\" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ip6t_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( \"checking:element%psize%u\\\\n\" , e , e -> next_offset ) ; return - EINVAL ; } if ( ! ip6_checkentry ( & e -> ipv6 ) ) return - EINVAL ; err = xt_check_entry_offsets ( e , e -> target_offset , e -> next_offset ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_debug ( \"Underflowsmustbeunconditionaland\" \"usetheSTANDARDtargetwith\" \"ACCEPT/DROP\\\\n\" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; }\n", "\n", "\n", "Target: * hdr ; __u32 serial ; if ( serial ) ; if ( ! ( asoc , chunk , true , & err_param )\n", "\n", "Sources:\n", "0: CWE-20 sctp_disposition_t sctp_sf_do_asconf ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * chunk = arg ; struct sctp_chunk * asconf_ack = NULL ; struct sctp_paramhdr * err_param = NULL ; sctp_addiphdr_t * hdr ; union sctp_addr_param * addr_param ; __u32 serial ; int length ; if ( ! sctp_vtag_verify ( chunk , asoc ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_REPORT_BAD_TAG , SCTP_NULL ( ) ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } if ( ! net -> sctp . addip_noauth && ! chunk -> auth ) return sctp_sf_discard_chunk ( net , ep , asoc , type , arg , commands ) ; if ( ! sctp_chunk_length_valid ( chunk , sizeof ( sctp_addip_chunk_t ) ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , arg , commands ) ; hdr = ( sctp_addiphdr_t * ) chunk -> skb -> data ; serial = ntohl ( hdr -> serial ) ; addr_param = ( union sctp_addr_param * ) hdr -> params ; length = ntohs ( addr_param -> p . length ) ; if ( length < sizeof ( sctp_paramhdr_t ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) addr_param , commands ) ; if ( ! sctp_verify_asconf ( asoc , ( sctp_paramhdr_t * ) ( ( void * ) addr_param + length ) , ( void * ) chunk -> chunk_end , & err_param ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) err_param , commands ) ; if ( serial == asoc -> peer . addip_serial + 1 ) { if ( ! chunk -> has_asconf ) sctp_assoc_clean_asconf_ack_cache ( asoc ) ; asconf_ack = sctp_process_asconf ( ( struct sctp_association * ) asoc , chunk ) ; if ( ! asconf_ack ) return SCTP_DISPOSITION_NOMEM ; } else if ( serial < asoc -> peer . addip_serial + 1 ) { asconf_ack = sctp_assoc_lookup_asconf_ack ( asoc , hdr -> serial ) ; if ( ! asconf_ack ) return SCTP_DISPOSITION_DISCARD ; asconf_ack -> transport = NULL ; } else { return SCTP_DISPOSITION_DISCARD ; } asconf_ack -> dest = chunk -> source ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( asconf_ack ) ) ; if ( asoc -> new_transport ) { sctp_sf_heartbeat ( ep , asoc , type , asoc -> new_transport , commands ) ; ( ( struct sctp_association * ) asoc ) -> new_transport = NULL ; } return SCTP_DISPOSITION_CONSUME ; }\n", "\n", "1: CWE-399 sctp_disposition_t sctp_sf_do_asconf ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * chunk = arg ; struct sctp_chunk * asconf_ack = NULL ; struct sctp_paramhdr * err_param = NULL ; sctp_addiphdr_t * hdr ; union sctp_addr_param * addr_param ; __u32 serial ; int length ; if ( ! sctp_vtag_verify ( chunk , asoc ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_REPORT_BAD_TAG , SCTP_NULL ( ) ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } if ( ! net -> sctp . addip_noauth && ! chunk -> auth ) return sctp_sf_discard_chunk ( net , ep , asoc , type , arg , commands ) ; if ( ! sctp_chunk_length_valid ( chunk , sizeof ( sctp_addip_chunk_t ) ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , arg , commands ) ; hdr = ( sctp_addiphdr_t * ) chunk -> skb -> data ; serial = ntohl ( hdr -> serial ) ; addr_param = ( union sctp_addr_param * ) hdr -> params ; length = ntohs ( addr_param -> p . length ) ; if ( length < sizeof ( sctp_paramhdr_t ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) addr_param , commands ) ; if ( ! sctp_verify_asconf ( asoc , ( sctp_paramhdr_t * ) ( ( void * ) addr_param + length ) , ( void * ) chunk -> chunk_end , & err_param ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) err_param , commands ) ; if ( serial == asoc -> peer . addip_serial + 1 ) { if ( ! chunk -> has_asconf ) sctp_assoc_clean_asconf_ack_cache ( asoc ) ; asconf_ack = sctp_process_asconf ( ( struct sctp_association * ) asoc , chunk ) ; if ( ! asconf_ack ) return SCTP_DISPOSITION_NOMEM ; } else if ( serial < asoc -> peer . addip_serial + 1 ) { asconf_ack = sctp_assoc_lookup_asconf_ack ( asoc , hdr -> serial ) ; if ( ! asconf_ack ) return SCTP_DISPOSITION_DISCARD ; asconf_ack -> transport = NULL ; } else { return SCTP_DISPOSITION_DISCARD ; } asconf_ack -> dest = chunk -> source ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( asconf_ack ) ) ; if ( asoc -> new_transport ) { sctp_sf_heartbeat ( ep , asoc , type , asoc -> new_transport , commands ) ; ( ( struct sctp_association * ) asoc ) -> new_transport = NULL ; } return SCTP_DISPOSITION_CONSUME ; }\n", "\n", "\n", "Target: ctxt ) { int rc = X86EMUL_CONTINUE ; == 0 ) rc = ) ; return rc ; } \n", "\n", "Sources:\n", "0: CWE-000 static int em_jcxz ( struct x86_emulate_ctxt * ctxt ) { if ( address_mask ( ctxt , reg_read ( ctxt , VCPU_REGS_RCX ) ) == 0 ) jmp_rel ( ctxt , ctxt -> src . val ) ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-264 static int em_jcxz ( struct x86_emulate_ctxt * ctxt ) { if ( address_mask ( ctxt , reg_read ( ctxt , VCPU_REGS_RCX ) ) == 0 ) jmp_rel ( ctxt , ctxt -> src . val ) ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: pos ) { check_stack_depth ( ) ;\n", "\n", "Sources:\n", "0: CWE-189 static void findoprnd ( ITEM * ptr , int32 * pos ) { # ifdef BS_DEBUG elog ( DEBUG3 , ( ptr [ * pos ] . type == OPR ) ? \"%d%c\" : \"%d%d\" , * pos , ptr [ * pos ] . val ) ; # endif if ( ptr [ * pos ] . type == VAL ) { ptr [ * pos ] . left = 0 ; ( * pos ) -- ; } else if ( ptr [ * pos ] . val == ( int32 ) '!' ) { ptr [ * pos ] . left = - 1 ; ( * pos ) -- ; findoprnd ( ptr , pos ) ; } else { ITEM * curitem = & ptr [ * pos ] ; int32 tmp = * pos ; ( * pos ) -- ; findoprnd ( ptr , pos ) ; curitem -> left = * pos - tmp ; findoprnd ( ptr , pos ) ; } }\n", "\n", "1: CWE-189 static void findoprnd ( ITEM * ptr , int32 * pos ) { if ( ptr [ * pos ] . type == VAL || ptr [ * pos ] . type == VALTRUE ) { ptr [ * pos ] . left = 0 ; ( * pos ) ++ ; } else if ( ptr [ * pos ] . val == ( int32 ) '!' ) { ptr [ * pos ] . left = 1 ; ( * pos ) ++ ; findoprnd ( ptr , pos ) ; } else { ITEM * curitem = & ptr [ * pos ] ; int32 tmp = * pos ; ( * pos ) ++ ; findoprnd ( ptr , pos ) ; curitem -> left = * pos - tmp ; findoprnd ( ptr , pos ) ; } }\n", "\n", "\n", "Target: ; int openasuser = 0 should_free_authpending_file = 0 ; PAM_MODUTIL_DEF_PRIVS ( privs ) done ; } openasuser = geteuid ( ) == 0 ? 1 : 0 ; DEFAULT_AUTHFILE ) ; if ( ! openasuser ) { DBG ( \"WARNING:notdroppingprivilegeswhenreading%s,please\" \"considersettingopenasuser=1inthemoduleconfiguration\" , buf ) buf ) ; } } DBG ( \"Usingauthenticationfile%s\" , buf ) ; ) ; } if ( ! openasuser ) { openasuser = geteuid ( -> openasuser ; } openasuser ) { DBG ( \"Droppingprivileges\" ) ; if ( pam_modutil_drop_priv ( pamh , & privs , pw ) ) { ( \"Unabletoswitchusertouid%i\" , pw -> pw_uid ) ; ( \"Switchedtouid%i\" , pw -> pw_uid ) ; { if ( pam_modutil_regain_priv ( pamh , & privs ) ) { DBG ( \"couldnotrestoreprivileges\" ) ; retval } DBG ( \"Restoredprivileges\" ) ; }\n", "\n", "Sources:\n", "0: CWE-200 int pam_sm_authenticate ( pam_handle_t * pamh , int flags , int argc , const char * * argv ) { struct passwd * pw = NULL , pw_s ; const char * user = NULL ; cfg_t cfg_st ; cfg_t * cfg = & cfg_st ; char buffer [ BUFSIZE ] ; char * buf = NULL ; char * authfile_dir ; size_t authfile_dir_len ; int pgu_ret , gpn_ret ; int retval = PAM_IGNORE ; device_t * devices = NULL ; unsigned n_devices = 0 ; int openasuser ; int should_free_origin = 0 ; int should_free_appid = 0 ; int should_free_auth_file = 0 ; int should_free_authpending_file = 0 ; parse_cfg ( flags , argc , argv , cfg ) ; if ( ! cfg -> origin ) { strcpy ( buffer , DEFAULT_ORIGIN_PREFIX ) ; if ( gethostname ( buffer + strlen ( DEFAULT_ORIGIN_PREFIX ) , BUFSIZE - strlen ( DEFAULT_ORIGIN_PREFIX ) ) == - 1 ) { DBG ( \"Unabletogethostname\" ) ; goto done ; } DBG ( \"Originnotspecified,using\\\\\"%s\\\\\"\" , buffer ) ; cfg -> origin = strdup ( buffer ) ; if ( ! cfg -> origin ) { DBG ( \"Unabletoallocatememory\" ) ; goto done ; } else { should_free_origin = 1 ; } } if ( ! cfg -> appid ) { DBG ( \"Appidnotspecified,usingthesamevalueoforigin(%s)\" , cfg -> origin ) ; cfg -> appid = strdup ( cfg -> origin ) ; if ( ! cfg -> appid ) { DBG ( \"Unabletoallocatememory\" ) goto done ; } else { should_free_appid = 1 ; } } if ( cfg -> max_devs == 0 ) { DBG ( \"Maximumdevicesnumbernotset.Usingdefault(%d)\" , MAX_DEVS ) ; cfg -> max_devs = MAX_DEVS ; } devices = malloc ( sizeof ( device_t ) * cfg -> max_devs ) ; if ( ! devices ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } pgu_ret = pam_get_user ( pamh , & user , NULL ) ; if ( pgu_ret != PAM_SUCCESS || user == NULL ) { DBG ( \"Unabletoaccessuser%s\" , user ) ; retval = PAM_CONV_ERR ; goto done ; } DBG ( \"Requestingauthenticationforuser%s\" , user ) ; gpn_ret = getpwnam_r ( user , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpn_ret != 0 || pw == NULL || pw -> pw_dir == NULL || pw -> pw_dir [ 0 ] != '/' ) { DBG ( \"Unabletoretrievecredentialsforuser%s,(%s)\" , user , strerror ( errno ) ) ; retval = PAM_USER_UNKNOWN ; goto done ; } DBG ( \"Founduser%s\" , user ) ; DBG ( \"Homedirectoryfor%sis%s\" , user , pw -> pw_dir ) ; if ( ! cfg -> auth_file ) { buf = NULL ; authfile_dir = secure_getenv ( DEFAULT_AUTHFILE_DIR_VAR ) ; if ( ! authfile_dir ) { DBG ( \"Variable%sisnotset.Usingdefaultvalue($HOME/.config/)\" , DEFAULT_AUTHFILE_DIR_VAR ) ; authfile_dir_len = strlen ( pw -> pw_dir ) + strlen ( \"/.config\" ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s/.config%s\" , pw -> pw_dir , DEFAULT_AUTHFILE ) ; } else { DBG ( \"Variable%ssetto%s\" , DEFAULT_AUTHFILE_DIR_VAR , authfile_dir ) ; authfile_dir_len = strlen ( authfile_dir ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s%s\" , authfile_dir , DEFAULT_AUTHFILE ) ; } DBG ( \"Usingdefaultauthenticationfile%s\" , buf ) ; cfg -> auth_file = buf ; should_free_auth_file = 1 ; buf = NULL ; } else { DBG ( \"Usingauthenticationfile%s\" , cfg -> auth_file ) ; } openasuser = geteuid ( ) == 0 && cfg -> openasuser ; if ( openasuser ) { if ( seteuid ( pw_s . pw_uid ) ) { DBG ( \"Unabletoswitchusertouid%i\" , pw_s . pw_uid ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedtouid%i\" , pw_s . pw_uid ) ; } retval = get_devices_from_authfile ( cfg -> auth_file , user , cfg -> max_devs , cfg -> debug , cfg -> debug_file , devices , & n_devices ) ; if ( openasuser ) { if ( seteuid ( 0 ) ) { DBG ( \"Unabletoswitchbacktouid0\" ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedbacktouid0\" ) ; } if ( retval != 1 ) { n_devices = 0 ; } if ( n_devices == 0 ) { if ( cfg -> nouserok ) { DBG ( \"Foundnodevicesbutnouserokspecified.Skippingauthentication\" ) ; retval = PAM_SUCCESS ; goto done ; } else if ( retval != 1 ) { DBG ( \"Unabletogetdevicesfromfile%s\" , cfg -> auth_file ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } else { DBG ( \"Foundnodevices.Aborting.\" ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } } if ( ! cfg -> authpending_file ) { int actual_size = snprintf ( buffer , BUFSIZE , DEFAULT_AUTHPENDING_FILE_PATH , getuid ( ) ) ; if ( actual_size >= 0 && actual_size < BUFSIZE ) { cfg -> authpending_file = strdup ( buffer ) ; } if ( ! cfg -> authpending_file ) { DBG ( \"Unabletoallocatememoryfortheauthpending_file,touchrequestnotificationswillnotbeemitted\" ) ; } else { should_free_authpending_file = 1 ; } } else { if ( strlen ( cfg -> authpending_file ) == 0 ) { DBG ( \"authpending_fileissettoanemptyvalue,touchrequestnotificationswillbedisabled\" ) ; cfg -> authpending_file = NULL ; } } int authpending_file_descriptor = - 1 ; if ( cfg -> authpending_file ) { DBG ( \"Usingfile\\'%s\\'foremittingtouchrequestnotifications\" , cfg -> authpending_file ) ; authpending_file_descriptor = open ( cfg -> authpending_file , O_RDONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY , 0664 ) ; if ( authpending_file_descriptor < 0 ) { DBG ( \"Unabletoemit\\'authenticationstarted\\'notificationbyopeningthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( cfg -> manual == 0 ) { if ( cfg -> interactive ) { converse ( pamh , PAM_PROMPT_ECHO_ON , cfg -> prompt != NULL ? cfg -> prompt : DEFAULT_PROMPT ) ; } retval = do_authentication ( cfg , devices , n_devices , pamh ) ; } else { retval = do_manual_authentication ( cfg , devices , n_devices , pamh ) ; } if ( authpending_file_descriptor >= 0 ) { if ( close ( authpending_file_descriptor ) < 0 ) { DBG ( \"Unabletoemit\\'authenticationstopped\\'notificationbyclosingthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( retval != 1 ) { DBG ( \"do_authenticationreturned%d\" , retval ) ; retval = PAM_AUTH_ERR ; goto done ; } retval = PAM_SUCCESS ; done : free_devices ( devices , n_devices ) ; if ( buf ) { free ( buf ) ; buf = NULL ; } if ( should_free_origin ) { free ( ( char * ) cfg -> origin ) ; cfg -> origin = NULL ; } if ( should_free_appid ) { free ( ( char * ) cfg -> appid ) ; cfg -> appid = NULL ; } if ( should_free_auth_file ) { free ( ( char * ) cfg -> auth_file ) ; cfg -> auth_file = NULL ; } if ( should_free_authpending_file ) { free ( ( char * ) cfg -> authpending_file ) ; cfg -> authpending_file = NULL ; } if ( cfg -> alwaysok && retval != PAM_SUCCESS ) { DBG ( \"alwaysokneeded(otherwisereturnwith%d)\" , retval ) ; retval = PAM_SUCCESS ; } DBG ( \"done.[%s]\" , pam_strerror ( pamh , retval ) ) ; if ( cfg -> is_custom_debug_file ) { fclose ( cfg -> debug_file ) ; } return retval ; }\n", "\n", "1: CWE-59 int pam_sm_authenticate ( pam_handle_t * pamh , int flags , int argc , const char * * argv ) { struct passwd * pw = NULL , pw_s ; const char * user = NULL ; cfg_t cfg_st ; cfg_t * cfg = & cfg_st ; char buffer [ BUFSIZE ] ; char * buf = NULL ; char * authfile_dir ; size_t authfile_dir_len ; int pgu_ret , gpn_ret ; int retval = PAM_IGNORE ; device_t * devices = NULL ; unsigned n_devices = 0 ; int openasuser ; int should_free_origin = 0 ; int should_free_appid = 0 ; int should_free_auth_file = 0 ; int should_free_authpending_file = 0 ; parse_cfg ( flags , argc , argv , cfg ) ; if ( ! cfg -> origin ) { strcpy ( buffer , DEFAULT_ORIGIN_PREFIX ) ; if ( gethostname ( buffer + strlen ( DEFAULT_ORIGIN_PREFIX ) , BUFSIZE - strlen ( DEFAULT_ORIGIN_PREFIX ) ) == - 1 ) { DBG ( \"Unabletogethostname\" ) ; goto done ; } DBG ( \"Originnotspecified,using\\\\\"%s\\\\\"\" , buffer ) ; cfg -> origin = strdup ( buffer ) ; if ( ! cfg -> origin ) { DBG ( \"Unabletoallocatememory\" ) ; goto done ; } else { should_free_origin = 1 ; } } if ( ! cfg -> appid ) { DBG ( \"Appidnotspecified,usingthesamevalueoforigin(%s)\" , cfg -> origin ) ; cfg -> appid = strdup ( cfg -> origin ) ; if ( ! cfg -> appid ) { DBG ( \"Unabletoallocatememory\" ) goto done ; } else { should_free_appid = 1 ; } } if ( cfg -> max_devs == 0 ) { DBG ( \"Maximumdevicesnumbernotset.Usingdefault(%d)\" , MAX_DEVS ) ; cfg -> max_devs = MAX_DEVS ; } devices = malloc ( sizeof ( device_t ) * cfg -> max_devs ) ; if ( ! devices ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } pgu_ret = pam_get_user ( pamh , & user , NULL ) ; if ( pgu_ret != PAM_SUCCESS || user == NULL ) { DBG ( \"Unabletoaccessuser%s\" , user ) ; retval = PAM_CONV_ERR ; goto done ; } DBG ( \"Requestingauthenticationforuser%s\" , user ) ; gpn_ret = getpwnam_r ( user , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpn_ret != 0 || pw == NULL || pw -> pw_dir == NULL || pw -> pw_dir [ 0 ] != '/' ) { DBG ( \"Unabletoretrievecredentialsforuser%s,(%s)\" , user , strerror ( errno ) ) ; retval = PAM_USER_UNKNOWN ; goto done ; } DBG ( \"Founduser%s\" , user ) ; DBG ( \"Homedirectoryfor%sis%s\" , user , pw -> pw_dir ) ; if ( ! cfg -> auth_file ) { buf = NULL ; authfile_dir = secure_getenv ( DEFAULT_AUTHFILE_DIR_VAR ) ; if ( ! authfile_dir ) { DBG ( \"Variable%sisnotset.Usingdefaultvalue($HOME/.config/)\" , DEFAULT_AUTHFILE_DIR_VAR ) ; authfile_dir_len = strlen ( pw -> pw_dir ) + strlen ( \"/.config\" ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s/.config%s\" , pw -> pw_dir , DEFAULT_AUTHFILE ) ; } else { DBG ( \"Variable%ssetto%s\" , DEFAULT_AUTHFILE_DIR_VAR , authfile_dir ) ; authfile_dir_len = strlen ( authfile_dir ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s%s\" , authfile_dir , DEFAULT_AUTHFILE ) ; } DBG ( \"Usingdefaultauthenticationfile%s\" , buf ) ; cfg -> auth_file = buf ; should_free_auth_file = 1 ; buf = NULL ; } else { DBG ( \"Usingauthenticationfile%s\" , cfg -> auth_file ) ; } openasuser = geteuid ( ) == 0 && cfg -> openasuser ; if ( openasuser ) { if ( seteuid ( pw_s . pw_uid ) ) { DBG ( \"Unabletoswitchusertouid%i\" , pw_s . pw_uid ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedtouid%i\" , pw_s . pw_uid ) ; } retval = get_devices_from_authfile ( cfg -> auth_file , user , cfg -> max_devs , cfg -> debug , cfg -> debug_file , devices , & n_devices ) ; if ( openasuser ) { if ( seteuid ( 0 ) ) { DBG ( \"Unabletoswitchbacktouid0\" ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedbacktouid0\" ) ; } if ( retval != 1 ) { n_devices = 0 ; } if ( n_devices == 0 ) { if ( cfg -> nouserok ) { DBG ( \"Foundnodevicesbutnouserokspecified.Skippingauthentication\" ) ; retval = PAM_SUCCESS ; goto done ; } else if ( retval != 1 ) { DBG ( \"Unabletogetdevicesfromfile%s\" , cfg -> auth_file ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } else { DBG ( \"Foundnodevices.Aborting.\" ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } } if ( ! cfg -> authpending_file ) { int actual_size = snprintf ( buffer , BUFSIZE , DEFAULT_AUTHPENDING_FILE_PATH , getuid ( ) ) ; if ( actual_size >= 0 && actual_size < BUFSIZE ) { cfg -> authpending_file = strdup ( buffer ) ; } if ( ! cfg -> authpending_file ) { DBG ( \"Unabletoallocatememoryfortheauthpending_file,touchrequestnotificationswillnotbeemitted\" ) ; } else { should_free_authpending_file = 1 ; } } else { if ( strlen ( cfg -> authpending_file ) == 0 ) { DBG ( \"authpending_fileissettoanemptyvalue,touchrequestnotificationswillbedisabled\" ) ; cfg -> authpending_file = NULL ; } } int authpending_file_descriptor = - 1 ; if ( cfg -> authpending_file ) { DBG ( \"Usingfile\\'%s\\'foremittingtouchrequestnotifications\" , cfg -> authpending_file ) ; authpending_file_descriptor = open ( cfg -> authpending_file , O_RDONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY , 0664 ) ; if ( authpending_file_descriptor < 0 ) { DBG ( \"Unabletoemit\\'authenticationstarted\\'notificationbyopeningthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( cfg -> manual == 0 ) { if ( cfg -> interactive ) { converse ( pamh , PAM_PROMPT_ECHO_ON , cfg -> prompt != NULL ? cfg -> prompt : DEFAULT_PROMPT ) ; } retval = do_authentication ( cfg , devices , n_devices , pamh ) ; } else { retval = do_manual_authentication ( cfg , devices , n_devices , pamh ) ; } if ( authpending_file_descriptor >= 0 ) { if ( close ( authpending_file_descriptor ) < 0 ) { DBG ( \"Unabletoemit\\'authenticationstopped\\'notificationbyclosingthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( retval != 1 ) { DBG ( \"do_authenticationreturned%d\" , retval ) ; retval = PAM_AUTH_ERR ; goto done ; } retval = PAM_SUCCESS ; done : free_devices ( devices , n_devices ) ; if ( buf ) { free ( buf ) ; buf = NULL ; } if ( should_free_origin ) { free ( ( char * ) cfg -> origin ) ; cfg -> origin = NULL ; } if ( should_free_appid ) { free ( ( char * ) cfg -> appid ) ; cfg -> appid = NULL ; } if ( should_free_auth_file ) { free ( ( char * ) cfg -> auth_file ) ; cfg -> auth_file = NULL ; } if ( should_free_authpending_file ) { free ( ( char * ) cfg -> authpending_file ) ; cfg -> authpending_file = NULL ; } if ( cfg -> alwaysok && retval != PAM_SUCCESS ) { DBG ( \"alwaysokneeded(otherwisereturnwith%d)\" , retval ) ; retval = PAM_SUCCESS ; } DBG ( \"done.[%s]\" , pam_strerror ( pamh , retval ) ) ; if ( cfg -> is_custom_debug_file ) { fclose ( cfg -> debug_file ) ; } return retval ; }\n", "\n", "\n", "Target: x , y , written = y = written = pix = c1 ; written ++ = c1 ; written ++ ; } } } if ( written != width * height ) { fprintf ( stderr , \"warning,image\\'sactualsizedoesnotmatchadvertizedone\\\\n\" ) ; return OPJ_FALSE ; }\n", "\n", "Sources:\n", "0: CWE-400 static OPJ_BOOL bmp_read_rle8_data ( FILE * IN , OPJ_UINT8 * pData , OPJ_UINT32 stride , OPJ_UINT32 width , OPJ_UINT32 height ) { OPJ_UINT32 x , y ; OPJ_UINT8 * pix ; const OPJ_UINT8 * beyond ; beyond = pData + stride * height ; pix = pData ; x = y = 0U ; while ( y < height ) { int c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } if ( c ) { int j , c1_int ; OPJ_UINT8 c1 ; c1_int = getc ( IN ) ; if ( c1_int == EOF ) { return OPJ_FALSE ; } c1 = ( OPJ_UINT8 ) c1_int ; for ( j = 0 ; ( j < c ) && ( x < width ) && ( ( OPJ_SIZE_T ) pix < ( OPJ_SIZE_T ) beyond ) ; j ++ , x ++ , pix ++ ) { * pix = c1 ; } } else { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } if ( c == 0x00 ) { x = 0 ; ++ y ; pix = pData + y * stride + x ; } else if ( c == 0x01 ) { break ; } else if ( c == 0x02 ) { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } x += ( OPJ_UINT32 ) c ; c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } y += ( OPJ_UINT32 ) c ; pix = pData + y * stride + x ; } else { int j ; for ( j = 0 ; ( j < c ) && ( x < width ) && ( ( OPJ_SIZE_T ) pix < ( OPJ_SIZE_T ) beyond ) ; j ++ , x ++ , pix ++ ) { int c1_int ; OPJ_UINT8 c1 ; c1_int = getc ( IN ) ; if ( c1_int == EOF ) { return OPJ_FALSE ; } c1 = ( OPJ_UINT8 ) c1_int ; * pix = c1 ; } if ( ( OPJ_UINT32 ) c & 1U ) { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } } } } } return OPJ_TRUE ; }\n", "\n", "1: CWE-834 static OPJ_BOOL bmp_read_rle8_data ( FILE * IN , OPJ_UINT8 * pData , OPJ_UINT32 stride , OPJ_UINT32 width , OPJ_UINT32 height ) { OPJ_UINT32 x , y ; OPJ_UINT8 * pix ; const OPJ_UINT8 * beyond ; beyond = pData + stride * height ; pix = pData ; x = y = 0U ; while ( y < height ) { int c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } if ( c ) { int j , c1_int ; OPJ_UINT8 c1 ; c1_int = getc ( IN ) ; if ( c1_int == EOF ) { return OPJ_FALSE ; } c1 = ( OPJ_UINT8 ) c1_int ; for ( j = 0 ; ( j < c ) && ( x < width ) && ( ( OPJ_SIZE_T ) pix < ( OPJ_SIZE_T ) beyond ) ; j ++ , x ++ , pix ++ ) { * pix = c1 ; } } else { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } if ( c == 0x00 ) { x = 0 ; ++ y ; pix = pData + y * stride + x ; } else if ( c == 0x01 ) { break ; } else if ( c == 0x02 ) { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } x += ( OPJ_UINT32 ) c ; c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } y += ( OPJ_UINT32 ) c ; pix = pData + y * stride + x ; } else { int j ; for ( j = 0 ; ( j < c ) && ( x < width ) && ( ( OPJ_SIZE_T ) pix < ( OPJ_SIZE_T ) beyond ) ; j ++ , x ++ , pix ++ ) { int c1_int ; OPJ_UINT8 c1 ; c1_int = getc ( IN ) ; if ( c1_int == EOF ) { return OPJ_FALSE ; } c1 = ( OPJ_UINT8 ) c1_int ; * pix = c1 ; } if ( ( OPJ_UINT32 ) c & 1U ) { c = getc ( IN ) ; if ( c == EOF ) { return OPJ_FALSE ; } } } } } return OPJ_TRUE ; }\n", "\n", "\n", "Target: ( psf = psf_allocate ( ) ) ==\n", "\n", "Sources:\n", "0: CWE-119 SNDFILE * sf_open_virtual ( SF_VIRTUAL_IO * sfvirtual , int mode , SF_INFO * sfinfo , void * user_data ) { SF_PRIVATE * psf ; if ( sfvirtual -> get_filelen == NULL || sfvirtual -> seek == NULL || sfvirtual -> tell == NULL ) { sf_errno = SFE_BAD_VIRTUAL_IO ; snprintf ( sf_parselog , sizeof ( sf_parselog ) , \"Badvio_get_filelen/vio_seek/vio_tellinSF_VIRTUAL_IOstruct.\\\\n\" ) ; return NULL ; } ; if ( ( mode == SFM_READ || mode == SFM_RDWR ) && sfvirtual -> read == NULL ) { sf_errno = SFE_BAD_VIRTUAL_IO ; snprintf ( sf_parselog , sizeof ( sf_parselog ) , \"Badvio_readinSF_VIRTUAL_IOstruct.\\\\n\" ) ; return NULL ; } ; if ( ( mode == SFM_WRITE || mode == SFM_RDWR ) && sfvirtual -> write == NULL ) { sf_errno = SFE_BAD_VIRTUAL_IO ; snprintf ( sf_parselog , sizeof ( sf_parselog ) , \"Badvio_writeinSF_VIRTUAL_IOstruct.\\\\n\" ) ; return NULL ; } ; if ( ( psf = calloc ( 1 , sizeof ( SF_PRIVATE ) ) ) == NULL ) { sf_errno = SFE_MALLOC_FAILED ; return NULL ; } ; psf_init_files ( psf ) ; psf -> virtual_io = SF_TRUE ; psf -> vio = * sfvirtual ; psf -> vio_user_data = user_data ; psf -> file . mode = mode ; return psf_open_file ( psf , sfinfo ) ; }\n", "\n", "1: CWE-119 SNDFILE * sf_open_fd ( int fd , int mode , SF_INFO * sfinfo , int close_desc ) { SF_PRIVATE * psf ; if ( ( SF_CONTAINER ( sfinfo -> format ) ) == SF_FORMAT_SD2 ) { sf_errno = SFE_SD2_FD_DISALLOWED ; return NULL ; } ; if ( ( psf = calloc ( 1 , sizeof ( SF_PRIVATE ) ) ) == NULL ) { sf_errno = SFE_MALLOC_FAILED ; return NULL ; } ; psf_init_files ( psf ) ; copy_filename ( psf , \"\" ) ; psf -> file . mode = mode ; psf_set_file ( psf , fd ) ; psf -> is_pipe = psf_is_pipe ( psf ) ; psf -> fileoffset = psf_ftell ( psf ) ; if ( ! close_desc ) psf -> file . do_not_close_descriptor = SF_TRUE ; return psf_open_file ( psf , sfinfo ) ; }\n", "\n", "\n", "Target: ; dentry -> d_flags |= DCACHE_RCUACCESS ; dentry ->\n", "\n", "Sources:\n", "0: CWE-362 static void * __ns_get_path ( struct path * path , struct ns_common * ns ) { struct vfsmount * mnt = nsfs_mnt ; struct qstr qname = { . name = \"\" , } ; struct dentry * dentry ; struct inode * inode ; unsigned long d ; rcu_read_lock ( ) ; d = atomic_long_read ( & ns -> stashed ) ; if ( ! d ) goto slow ; dentry = ( struct dentry * ) d ; if ( ! lockref_get_not_dead ( & dentry -> d_lockref ) ) goto slow ; rcu_read_unlock ( ) ; ns -> ops -> put ( ns ) ; got_it : path -> mnt = mntget ( mnt ) ; path -> dentry = dentry ; return NULL ; slow : rcu_read_unlock ( ) ; inode = new_inode_pseudo ( mnt -> mnt_sb ) ; if ( ! inode ) { ns -> ops -> put ( ns ) ; return ERR_PTR ( - ENOMEM ) ; } inode -> i_ino = ns -> inum ; inode -> i_mtime = inode -> i_atime = inode -> i_ctime = current_time ( inode ) ; inode -> i_flags |= S_IMMUTABLE ; inode -> i_mode = S_IFREG | S_IRUGO ; inode -> i_fop = & ns_file_operations ; inode -> i_private = ns ; dentry = d_alloc_pseudo ( mnt -> mnt_sb , & qname ) ; if ( ! dentry ) { iput ( inode ) ; return ERR_PTR ( - ENOMEM ) ; } d_instantiate ( dentry , inode ) ; dentry -> d_fsdata = ( void * ) ns -> ops ; d = atomic_long_cmpxchg ( & ns -> stashed , 0 , ( unsigned long ) dentry ) ; if ( d ) { d_delete ( dentry ) ; dput ( dentry ) ; cpu_relax ( ) ; return ERR_PTR ( - EAGAIN ) ; } goto got_it ; }\n", "\n", "1: CWE-416 static void * __ns_get_path ( struct path * path , struct ns_common * ns ) { struct vfsmount * mnt = nsfs_mnt ; struct qstr qname = { . name = \"\" , } ; struct dentry * dentry ; struct inode * inode ; unsigned long d ; rcu_read_lock ( ) ; d = atomic_long_read ( & ns -> stashed ) ; if ( ! d ) goto slow ; dentry = ( struct dentry * ) d ; if ( ! lockref_get_not_dead ( & dentry -> d_lockref ) ) goto slow ; rcu_read_unlock ( ) ; ns -> ops -> put ( ns ) ; got_it : path -> mnt = mntget ( mnt ) ; path -> dentry = dentry ; return NULL ; slow : rcu_read_unlock ( ) ; inode = new_inode_pseudo ( mnt -> mnt_sb ) ; if ( ! inode ) { ns -> ops -> put ( ns ) ; return ERR_PTR ( - ENOMEM ) ; } inode -> i_ino = ns -> inum ; inode -> i_mtime = inode -> i_atime = inode -> i_ctime = current_time ( inode ) ; inode -> i_flags |= S_IMMUTABLE ; inode -> i_mode = S_IFREG | S_IRUGO ; inode -> i_fop = & ns_file_operations ; inode -> i_private = ns ; dentry = d_alloc_pseudo ( mnt -> mnt_sb , & qname ) ; if ( ! dentry ) { iput ( inode ) ; return ERR_PTR ( - ENOMEM ) ; } d_instantiate ( dentry , inode ) ; dentry -> d_fsdata = ( void * ) ns -> ops ; d = atomic_long_cmpxchg ( & ns -> stashed , 0 , ( unsigned long ) dentry ) ; if ( d ) { d_delete ( dentry ) ; dput ( dentry ) ; cpu_relax ( ) ; return ERR_PTR ( - EAGAIN ) ; } goto got_it ; }\n", "\n", "\n", "Target: ) ) ; ptr -> next = NULL ; ptr -> buffer_length = 0 ; ptr -> kernel_data = NULL ; return - EFAULT ; param += = 0 ; if ( ptr\n", "\n", "Sources:\n", "0: CWE-754 static int raw_cmd_copyin ( int cmd , void __user * param , struct floppy_raw_cmd * * rcmd ) { struct floppy_raw_cmd * ptr ; int ret ; int i ; * rcmd = NULL ; loop : ptr = kmalloc ( sizeof ( struct floppy_raw_cmd ) , GFP_USER ) ; if ( ! ptr ) return - ENOMEM ; * rcmd = ptr ; ret = copy_from_user ( ptr , param , sizeof ( * ptr ) ) ; if ( ret ) return - EFAULT ; ptr -> next = NULL ; ptr -> buffer_length = 0 ; param += sizeof ( struct floppy_raw_cmd ) ; if ( ptr -> cmd_count > 33 ) return - EINVAL ; for ( i = 0 ; i < 16 ; i ++ ) ptr -> reply [ i ] = 0 ; ptr -> resultcode = 0 ; ptr -> kernel_data = NULL ; if ( ptr -> flags & ( FD_RAW_READ | FD_RAW_WRITE ) ) { if ( ptr -> length <= 0 ) return - EINVAL ; ptr -> kernel_data = ( char * ) fd_dma_mem_alloc ( ptr -> length ) ; fallback_on_nodma_alloc ( & ptr -> kernel_data , ptr -> length ) ; if ( ! ptr -> kernel_data ) return - ENOMEM ; ptr -> buffer_length = ptr -> length ; } if ( ptr -> flags & FD_RAW_WRITE ) { ret = fd_copyin ( ptr -> data , ptr -> kernel_data , ptr -> length ) ; if ( ret ) return ret ; } if ( ptr -> flags & FD_RAW_MORE ) { rcmd = & ( ptr -> next ) ; ptr -> rate &= 0x43 ; goto loop ; } return 0 ; }\n", "\n", "1: CWE-264 static int raw_cmd_copyin ( int cmd , void __user * param , struct floppy_raw_cmd * * rcmd ) { struct floppy_raw_cmd * ptr ; int ret ; int i ; * rcmd = NULL ; loop : ptr = kmalloc ( sizeof ( struct floppy_raw_cmd ) , GFP_USER ) ; if ( ! ptr ) return - ENOMEM ; * rcmd = ptr ; ret = copy_from_user ( ptr , param , sizeof ( * ptr ) ) ; if ( ret ) return - EFAULT ; ptr -> next = NULL ; ptr -> buffer_length = 0 ; param += sizeof ( struct floppy_raw_cmd ) ; if ( ptr -> cmd_count > 33 ) return - EINVAL ; for ( i = 0 ; i < 16 ; i ++ ) ptr -> reply [ i ] = 0 ; ptr -> resultcode = 0 ; ptr -> kernel_data = NULL ; if ( ptr -> flags & ( FD_RAW_READ | FD_RAW_WRITE ) ) { if ( ptr -> length <= 0 ) return - EINVAL ; ptr -> kernel_data = ( char * ) fd_dma_mem_alloc ( ptr -> length ) ; fallback_on_nodma_alloc ( & ptr -> kernel_data , ptr -> length ) ; if ( ! ptr -> kernel_data ) return - ENOMEM ; ptr -> buffer_length = ptr -> length ; } if ( ptr -> flags & FD_RAW_WRITE ) { ret = fd_copyin ( ptr -> data , ptr -> kernel_data , ptr -> length ) ; if ( ret ) return ret ; } if ( ptr -> flags & FD_RAW_MORE ) { rcmd = & ( ptr -> next ) ; ptr -> rate &= 0x43 ; goto loop ; } return 0 ; }\n", "\n", "\n", "Target: mmap_sem ) ; if ( ! mmget_still_valid ( mm ) ) goto skip_mm ; NULL_VM_UFFD_CTX ; } skip_mm :\n", "\n", "Sources:\n", "0: CWE-362 static int userfaultfd_release ( struct inode * inode , struct file * file ) { struct userfaultfd_ctx * ctx = file -> private_data ; struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev ; struct userfaultfd_wake_range range = { . len = 0 , } ; unsigned long new_flags ; WRITE_ONCE ( ctx -> released , true ) ; if ( ! mmget_not_zero ( mm ) ) goto wakeup ; down_write ( & mm -> mmap_sem ) ; prev = NULL ; for ( vma = mm -> mmap ; vma ; vma = vma -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! vma -> vm_userfaultfd_ctx . ctx ^ ! ! ( vma -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; if ( vma -> vm_userfaultfd_ctx . ctx != ctx ) { prev = vma ; continue ; } new_flags = vma -> vm_flags & ~ ( VM_UFFD_MISSING | VM_UFFD_WP ) ; prev = vma_merge ( mm , prev , vma -> vm_start , vma -> vm_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , NULL_VM_UFFD_CTX ) ; if ( prev ) vma = prev ; else prev = vma ; vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; } up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; wakeup : spin_lock ( & ctx -> fault_pending_wqh . lock ) ; __wake_up_locked_key ( & ctx -> fault_pending_wqh , TASK_NORMAL , & range ) ; __wake_up ( & ctx -> fault_wqh , TASK_NORMAL , 1 , & range ) ; spin_unlock ( & ctx -> fault_pending_wqh . lock ) ; wake_up_all ( & ctx -> event_wqh ) ; wake_up_poll ( & ctx -> fd_wqh , EPOLLHUP ) ; userfaultfd_ctx_put ( ctx ) ; return 0 ; }\n", "\n", "1: CWE-667 static int userfaultfd_release ( struct inode * inode , struct file * file ) { struct userfaultfd_ctx * ctx = file -> private_data ; struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev ; struct userfaultfd_wake_range range = { . len = 0 , } ; unsigned long new_flags ; WRITE_ONCE ( ctx -> released , true ) ; if ( ! mmget_not_zero ( mm ) ) goto wakeup ; down_write ( & mm -> mmap_sem ) ; prev = NULL ; for ( vma = mm -> mmap ; vma ; vma = vma -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! vma -> vm_userfaultfd_ctx . ctx ^ ! ! ( vma -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; if ( vma -> vm_userfaultfd_ctx . ctx != ctx ) { prev = vma ; continue ; } new_flags = vma -> vm_flags & ~ ( VM_UFFD_MISSING | VM_UFFD_WP ) ; prev = vma_merge ( mm , prev , vma -> vm_start , vma -> vm_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , NULL_VM_UFFD_CTX ) ; if ( prev ) vma = prev ; else prev = vma ; vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; } up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; wakeup : spin_lock ( & ctx -> fault_pending_wqh . lock ) ; __wake_up_locked_key ( & ctx -> fault_pending_wqh , TASK_NORMAL , & range ) ; __wake_up ( & ctx -> fault_wqh , TASK_NORMAL , 1 , & range ) ; spin_unlock ( & ctx -> fault_pending_wqh . lock ) ; wake_up_all ( & ctx -> event_wqh ) ; wake_up_poll ( & ctx -> fd_wqh , EPOLLHUP ) ; userfaultfd_ctx_put ( ctx ) ; return 0 ; }\n", "\n", "\n", "Target: ; size_t buf_size = 0 ; size_t data_size , & buf_size , & data_size OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( data_size > OE_SSIZE_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( ret > ( ssize_t ) data_size ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; }\n", "\n", "Sources:\n", "0: CWE-552 static ssize_t _hostsock_writev ( oe_fd_t * desc , const struct oe_iovec * iov , int iovcnt ) { ssize_t ret = - 1 ; sock_t * sock = _cast_sock ( desc ) ; void * buf = NULL ; size_t buf_size = 0 ; if ( ! sock || ! iov || iovcnt < 0 || iovcnt > OE_IOV_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_iov_pack ( iov , iovcnt , & buf , & buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( oe_syscall_sendv_ocall ( & ret , sock -> host_fd , buf , iovcnt , buf_size ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : if ( buf ) oe_free ( buf ) ; return ret ; }\n", "\n", "1: CWE-552 static ssize_t _hostsock_sendmsg ( oe_fd_t * sock_ , const struct oe_msghdr * msg , int flags ) { ssize_t ret = - 1 ; sock_t * sock = _cast_sock ( sock_ ) ; void * buf = NULL ; size_t buf_size = 0 ; oe_errno = 0 ; if ( ! sock || ! msg || ( msg -> msg_iovlen && ! msg -> msg_iov ) ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_iov_pack ( msg -> msg_iov , ( int ) msg -> msg_iovlen , & buf , & buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( oe_syscall_sendmsg_ocall ( & ret , sock -> host_fd , msg -> msg_name , msg -> msg_namelen , buf , msg -> msg_iovlen , buf_size , msg -> msg_control , msg -> msg_controllen , flags ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : if ( buf ) oe_free ( buf ) ; return ret ; }\n", "\n", "\n", "Target: ctxt ) { int rc ; -> _eip ; rc = , rel ) ; if ( rc != X86EMUL_CONTINUE ) return rc\n", "\n", "Sources:\n", "0: CWE-000 static int em_call ( struct x86_emulate_ctxt * ctxt ) { long rel = ctxt -> src . val ; ctxt -> src . val = ( unsigned long ) ctxt -> _eip ; jmp_rel ( ctxt , rel ) ; return em_push ( ctxt ) ; }\n", "\n", "1: CWE-264 static int em_call ( struct x86_emulate_ctxt * ctxt ) { long rel = ctxt -> src . val ; ctxt -> src . val = ( unsigned long ) ctxt -> _eip ; jmp_rel ( ctxt , rel ) ; return em_push ( ctxt ) ; }\n", "\n", "\n", "Target: eflags ) ) rc = case 0xeb : rc = eflags ) ) rc =\n", "\n", "Sources:\n", "0: CWE-000 int x86_emulate_insn ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; int rc = X86EMUL_CONTINUE ; int saved_dst_type = ctxt -> dst . type ; ctxt -> mem_read . pos = 0 ; if ( ctxt -> lock_prefix && ( ! ( ctxt -> d & Lock ) || ctxt -> dst . type != OP_MEM ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ctxt -> d & SrcMask ) == SrcMemFAddr && ctxt -> src . type != OP_MEM ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( unlikely ( ctxt -> d & ( No64 | Undefined | Sse | Mmx | Intercept | CheckPerm | Priv | Prot | String ) ) ) { if ( ( ctxt -> mode == X86EMUL_MODE_PROT64 && ( ctxt -> d & No64 ) ) || ( ctxt -> d & Undefined ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ( ctxt -> d & ( Sse | Mmx ) ) && ( ( ops -> get_cr ( ctxt , 0 ) & X86_CR0_EM ) ) ) || ( ( ctxt -> d & Sse ) && ! ( ops -> get_cr ( ctxt , 4 ) & X86_CR4_OSFXSR ) ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ctxt -> d & ( Sse | Mmx ) ) && ( ops -> get_cr ( ctxt , 0 ) & X86_CR0_TS ) ) { rc = emulate_nm ( ctxt ) ; goto done ; } if ( ctxt -> d & Mmx ) { rc = flush_pending_x87_faults ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; fetch_possible_mmx_operand ( ctxt , & ctxt -> src ) ; fetch_possible_mmx_operand ( ctxt , & ctxt -> src2 ) ; if ( ! ( ctxt -> d & Mov ) ) fetch_possible_mmx_operand ( ctxt , & ctxt -> dst ) ; } if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_PRE_EXCEPT ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ( ctxt -> d & Priv ) && ops -> cpl ( ctxt ) ) { if ( ctxt -> d & PrivUD ) rc = emulate_ud ( ctxt ) ; else rc = emulate_gp ( ctxt , 0 ) ; goto done ; } if ( ( ctxt -> d & Prot ) && ctxt -> mode < X86EMUL_MODE_PROT16 ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ctxt -> d & CheckPerm ) { rc = ctxt -> check_perm ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_POST_EXCEPT ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) { if ( address_mask ( ctxt , reg_read ( ctxt , VCPU_REGS_RCX ) ) == 0 ) { ctxt -> eip = ctxt -> _eip ; ctxt -> eflags &= ~ EFLG_RF ; goto done ; } } } if ( ( ctxt -> src . type == OP_MEM ) && ! ( ctxt -> d & NoAccess ) ) { rc = segmented_read ( ctxt , ctxt -> src . addr . mem , ctxt -> src . valptr , ctxt -> src . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; ctxt -> src . orig_val64 = ctxt -> src . val64 ; } if ( ctxt -> src2 . type == OP_MEM ) { rc = segmented_read ( ctxt , ctxt -> src2 . addr . mem , & ctxt -> src2 . val , ctxt -> src2 . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ( ctxt -> d & DstMask ) == ImplicitOps ) goto special_insn ; if ( ( ctxt -> dst . type == OP_MEM ) && ! ( ctxt -> d & Mov ) ) { rc = segmented_read ( ctxt , ctxt -> dst . addr . mem , & ctxt -> dst . val , ctxt -> dst . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } ctxt -> dst . orig_val = ctxt -> dst . val ; special_insn : if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_POST_MEMACCESS ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) ctxt -> eflags |= EFLG_RF ; else ctxt -> eflags &= ~ EFLG_RF ; if ( ctxt -> execute ) { if ( ctxt -> d & Fastop ) { void ( * fop ) ( struct fastop * ) = ( void * ) ctxt -> execute ; rc = fastop ( ctxt , fop ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; } rc = ctxt -> execute ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; } if ( ctxt -> opcode_len == 2 ) goto twobyte_insn ; else if ( ctxt -> opcode_len == 3 ) goto threebyte_insn ; switch ( ctxt -> b ) { case 0x63 : if ( ctxt -> mode != X86EMUL_MODE_PROT64 ) goto cannot_emulate ; ctxt -> dst . val = ( s32 ) ctxt -> src . val ; break ; case 0x70 ... 0x7f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) jmp_rel ( ctxt , ctxt -> src . val ) ; break ; case 0x8d : ctxt -> dst . val = ctxt -> src . addr . mem . ea ; break ; case 0x90 ... 0x97 : if ( ctxt -> dst . addr . reg == reg_rmw ( ctxt , VCPU_REGS_RAX ) ) ctxt -> dst . type = OP_NONE ; else rc = em_xchg ( ctxt ) ; break ; case 0x98 : switch ( ctxt -> op_bytes ) { case 2 : ctxt -> dst . val = ( s8 ) ctxt -> dst . val ; break ; case 4 : ctxt -> dst . val = ( s16 ) ctxt -> dst . val ; break ; case 8 : ctxt -> dst . val = ( s32 ) ctxt -> dst . val ; break ; } break ; case 0xcc : rc = emulate_int ( ctxt , 3 ) ; break ; case 0xcd : rc = emulate_int ( ctxt , ctxt -> src . val ) ; break ; case 0xce : if ( ctxt -> eflags & EFLG_OF ) rc = emulate_int ( ctxt , 4 ) ; break ; case 0xe9 : case 0xeb : jmp_rel ( ctxt , ctxt -> src . val ) ; ctxt -> dst . type = OP_NONE ; break ; case 0xf4 : ctxt -> ops -> halt ( ctxt ) ; break ; case 0xf5 : ctxt -> eflags ^= EFLG_CF ; break ; case 0xf8 : ctxt -> eflags &= ~ EFLG_CF ; break ; case 0xf9 : ctxt -> eflags |= EFLG_CF ; break ; case 0xfc : ctxt -> eflags &= ~ EFLG_DF ; break ; case 0xfd : ctxt -> eflags |= EFLG_DF ; break ; default : goto cannot_emulate ; } if ( rc != X86EMUL_CONTINUE ) goto done ; writeback : if ( ctxt -> d & SrcWrite ) { BUG_ON ( ctxt -> src . type == OP_MEM || ctxt -> src . type == OP_MEM_STR ) ; rc = writeback ( ctxt , & ctxt -> src ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ! ( ctxt -> d & NoWrite ) ) { rc = writeback ( ctxt , & ctxt -> dst ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } ctxt -> dst . type = saved_dst_type ; if ( ( ctxt -> d & SrcMask ) == SrcSI ) string_addr_inc ( ctxt , VCPU_REGS_RSI , & ctxt -> src ) ; if ( ( ctxt -> d & DstMask ) == DstDI ) string_addr_inc ( ctxt , VCPU_REGS_RDI , & ctxt -> dst ) ; if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) { unsigned int count ; struct read_cache * r = & ctxt -> io_read ; if ( ( ctxt -> d & SrcMask ) == SrcSI ) count = ctxt -> src . count ; else count = ctxt -> dst . count ; register_address_increment ( ctxt , reg_rmw ( ctxt , VCPU_REGS_RCX ) , - count ) ; if ( ! string_insn_completed ( ctxt ) ) { if ( ( r -> end != 0 || reg_read ( ctxt , VCPU_REGS_RCX ) & 0x3ff ) && ( r -> end == 0 || r -> end != r -> pos ) ) { ctxt -> mem_read . end = 0 ; writeback_registers ( ctxt ) ; return EMULATION_RESTART ; } goto done ; } ctxt -> eflags &= ~ EFLG_RF ; } ctxt -> eip = ctxt -> _eip ; done : if ( rc == X86EMUL_PROPAGATE_FAULT ) { WARN_ON ( ctxt -> exception . vector > 0x1f ) ; ctxt -> have_exception = true ; } if ( rc == X86EMUL_INTERCEPTED ) return EMULATION_INTERCEPTED ; if ( rc == X86EMUL_CONTINUE ) writeback_registers ( ctxt ) ; return ( rc == X86EMUL_UNHANDLEABLE ) ? EMULATION_FAILED : EMULATION_OK ; twobyte_insn : switch ( ctxt -> b ) { case 0x09 : ( ctxt -> ops -> wbinvd ) ( ctxt ) ; break ; case 0x08 : case 0x0d : case 0x18 : case 0x1f : break ; case 0x20 : ctxt -> dst . val = ops -> get_cr ( ctxt , ctxt -> modrm_reg ) ; break ; case 0x21 : ops -> get_dr ( ctxt , ctxt -> modrm_reg , & ctxt -> dst . val ) ; break ; case 0x40 ... 0x4f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) ctxt -> dst . val = ctxt -> src . val ; else if ( ctxt -> mode != X86EMUL_MODE_PROT64 || ctxt -> op_bytes != 4 ) ctxt -> dst . type = OP_NONE ; break ; case 0x80 ... 0x8f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) jmp_rel ( ctxt , ctxt -> src . val ) ; break ; case 0x90 ... 0x9f : ctxt -> dst . val = test_cc ( ctxt -> b , ctxt -> eflags ) ; break ; case 0xae : break ; case 0xb6 ... 0xb7 : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> src . bytes == 1 ) ? ( u8 ) ctxt -> src . val : ( u16 ) ctxt -> src . val ; break ; case 0xbe ... 0xbf : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> src . bytes == 1 ) ? ( s8 ) ctxt -> src . val : ( s16 ) ctxt -> src . val ; break ; case 0xc3 : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> op_bytes == 8 ) ? ( u64 ) ctxt -> src . val : ( u32 ) ctxt -> src . val ; break ; default : goto cannot_emulate ; } threebyte_insn : if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; cannot_emulate : return EMULATION_FAILED ; }\n", "\n", "1: CWE-264 int x86_emulate_insn ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; int rc = X86EMUL_CONTINUE ; int saved_dst_type = ctxt -> dst . type ; ctxt -> mem_read . pos = 0 ; if ( ctxt -> lock_prefix && ( ! ( ctxt -> d & Lock ) || ctxt -> dst . type != OP_MEM ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ctxt -> d & SrcMask ) == SrcMemFAddr && ctxt -> src . type != OP_MEM ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( unlikely ( ctxt -> d & ( No64 | Undefined | Sse | Mmx | Intercept | CheckPerm | Priv | Prot | String ) ) ) { if ( ( ctxt -> mode == X86EMUL_MODE_PROT64 && ( ctxt -> d & No64 ) ) || ( ctxt -> d & Undefined ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ( ctxt -> d & ( Sse | Mmx ) ) && ( ( ops -> get_cr ( ctxt , 0 ) & X86_CR0_EM ) ) ) || ( ( ctxt -> d & Sse ) && ! ( ops -> get_cr ( ctxt , 4 ) & X86_CR4_OSFXSR ) ) ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ( ctxt -> d & ( Sse | Mmx ) ) && ( ops -> get_cr ( ctxt , 0 ) & X86_CR0_TS ) ) { rc = emulate_nm ( ctxt ) ; goto done ; } if ( ctxt -> d & Mmx ) { rc = flush_pending_x87_faults ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; fetch_possible_mmx_operand ( ctxt , & ctxt -> src ) ; fetch_possible_mmx_operand ( ctxt , & ctxt -> src2 ) ; if ( ! ( ctxt -> d & Mov ) ) fetch_possible_mmx_operand ( ctxt , & ctxt -> dst ) ; } if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_PRE_EXCEPT ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ( ctxt -> d & Priv ) && ops -> cpl ( ctxt ) ) { if ( ctxt -> d & PrivUD ) rc = emulate_ud ( ctxt ) ; else rc = emulate_gp ( ctxt , 0 ) ; goto done ; } if ( ( ctxt -> d & Prot ) && ctxt -> mode < X86EMUL_MODE_PROT16 ) { rc = emulate_ud ( ctxt ) ; goto done ; } if ( ctxt -> d & CheckPerm ) { rc = ctxt -> check_perm ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_POST_EXCEPT ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) { if ( address_mask ( ctxt , reg_read ( ctxt , VCPU_REGS_RCX ) ) == 0 ) { ctxt -> eip = ctxt -> _eip ; ctxt -> eflags &= ~ EFLG_RF ; goto done ; } } } if ( ( ctxt -> src . type == OP_MEM ) && ! ( ctxt -> d & NoAccess ) ) { rc = segmented_read ( ctxt , ctxt -> src . addr . mem , ctxt -> src . valptr , ctxt -> src . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; ctxt -> src . orig_val64 = ctxt -> src . val64 ; } if ( ctxt -> src2 . type == OP_MEM ) { rc = segmented_read ( ctxt , ctxt -> src2 . addr . mem , & ctxt -> src2 . val , ctxt -> src2 . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ( ctxt -> d & DstMask ) == ImplicitOps ) goto special_insn ; if ( ( ctxt -> dst . type == OP_MEM ) && ! ( ctxt -> d & Mov ) ) { rc = segmented_read ( ctxt , ctxt -> dst . addr . mem , & ctxt -> dst . val , ctxt -> dst . bytes ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } ctxt -> dst . orig_val = ctxt -> dst . val ; special_insn : if ( unlikely ( ctxt -> guest_mode ) && ( ctxt -> d & Intercept ) ) { rc = emulator_check_intercept ( ctxt , ctxt -> intercept , X86_ICPT_POST_MEMACCESS ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) ctxt -> eflags |= EFLG_RF ; else ctxt -> eflags &= ~ EFLG_RF ; if ( ctxt -> execute ) { if ( ctxt -> d & Fastop ) { void ( * fop ) ( struct fastop * ) = ( void * ) ctxt -> execute ; rc = fastop ( ctxt , fop ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; } rc = ctxt -> execute ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; } if ( ctxt -> opcode_len == 2 ) goto twobyte_insn ; else if ( ctxt -> opcode_len == 3 ) goto threebyte_insn ; switch ( ctxt -> b ) { case 0x63 : if ( ctxt -> mode != X86EMUL_MODE_PROT64 ) goto cannot_emulate ; ctxt -> dst . val = ( s32 ) ctxt -> src . val ; break ; case 0x70 ... 0x7f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) jmp_rel ( ctxt , ctxt -> src . val ) ; break ; case 0x8d : ctxt -> dst . val = ctxt -> src . addr . mem . ea ; break ; case 0x90 ... 0x97 : if ( ctxt -> dst . addr . reg == reg_rmw ( ctxt , VCPU_REGS_RAX ) ) ctxt -> dst . type = OP_NONE ; else rc = em_xchg ( ctxt ) ; break ; case 0x98 : switch ( ctxt -> op_bytes ) { case 2 : ctxt -> dst . val = ( s8 ) ctxt -> dst . val ; break ; case 4 : ctxt -> dst . val = ( s16 ) ctxt -> dst . val ; break ; case 8 : ctxt -> dst . val = ( s32 ) ctxt -> dst . val ; break ; } break ; case 0xcc : rc = emulate_int ( ctxt , 3 ) ; break ; case 0xcd : rc = emulate_int ( ctxt , ctxt -> src . val ) ; break ; case 0xce : if ( ctxt -> eflags & EFLG_OF ) rc = emulate_int ( ctxt , 4 ) ; break ; case 0xe9 : case 0xeb : jmp_rel ( ctxt , ctxt -> src . val ) ; ctxt -> dst . type = OP_NONE ; break ; case 0xf4 : ctxt -> ops -> halt ( ctxt ) ; break ; case 0xf5 : ctxt -> eflags ^= EFLG_CF ; break ; case 0xf8 : ctxt -> eflags &= ~ EFLG_CF ; break ; case 0xf9 : ctxt -> eflags |= EFLG_CF ; break ; case 0xfc : ctxt -> eflags &= ~ EFLG_DF ; break ; case 0xfd : ctxt -> eflags |= EFLG_DF ; break ; default : goto cannot_emulate ; } if ( rc != X86EMUL_CONTINUE ) goto done ; writeback : if ( ctxt -> d & SrcWrite ) { BUG_ON ( ctxt -> src . type == OP_MEM || ctxt -> src . type == OP_MEM_STR ) ; rc = writeback ( ctxt , & ctxt -> src ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } if ( ! ( ctxt -> d & NoWrite ) ) { rc = writeback ( ctxt , & ctxt -> dst ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; } ctxt -> dst . type = saved_dst_type ; if ( ( ctxt -> d & SrcMask ) == SrcSI ) string_addr_inc ( ctxt , VCPU_REGS_RSI , & ctxt -> src ) ; if ( ( ctxt -> d & DstMask ) == DstDI ) string_addr_inc ( ctxt , VCPU_REGS_RDI , & ctxt -> dst ) ; if ( ctxt -> rep_prefix && ( ctxt -> d & String ) ) { unsigned int count ; struct read_cache * r = & ctxt -> io_read ; if ( ( ctxt -> d & SrcMask ) == SrcSI ) count = ctxt -> src . count ; else count = ctxt -> dst . count ; register_address_increment ( ctxt , reg_rmw ( ctxt , VCPU_REGS_RCX ) , - count ) ; if ( ! string_insn_completed ( ctxt ) ) { if ( ( r -> end != 0 || reg_read ( ctxt , VCPU_REGS_RCX ) & 0x3ff ) && ( r -> end == 0 || r -> end != r -> pos ) ) { ctxt -> mem_read . end = 0 ; writeback_registers ( ctxt ) ; return EMULATION_RESTART ; } goto done ; } ctxt -> eflags &= ~ EFLG_RF ; } ctxt -> eip = ctxt -> _eip ; done : if ( rc == X86EMUL_PROPAGATE_FAULT ) { WARN_ON ( ctxt -> exception . vector > 0x1f ) ; ctxt -> have_exception = true ; } if ( rc == X86EMUL_INTERCEPTED ) return EMULATION_INTERCEPTED ; if ( rc == X86EMUL_CONTINUE ) writeback_registers ( ctxt ) ; return ( rc == X86EMUL_UNHANDLEABLE ) ? EMULATION_FAILED : EMULATION_OK ; twobyte_insn : switch ( ctxt -> b ) { case 0x09 : ( ctxt -> ops -> wbinvd ) ( ctxt ) ; break ; case 0x08 : case 0x0d : case 0x18 : case 0x1f : break ; case 0x20 : ctxt -> dst . val = ops -> get_cr ( ctxt , ctxt -> modrm_reg ) ; break ; case 0x21 : ops -> get_dr ( ctxt , ctxt -> modrm_reg , & ctxt -> dst . val ) ; break ; case 0x40 ... 0x4f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) ctxt -> dst . val = ctxt -> src . val ; else if ( ctxt -> mode != X86EMUL_MODE_PROT64 || ctxt -> op_bytes != 4 ) ctxt -> dst . type = OP_NONE ; break ; case 0x80 ... 0x8f : if ( test_cc ( ctxt -> b , ctxt -> eflags ) ) jmp_rel ( ctxt , ctxt -> src . val ) ; break ; case 0x90 ... 0x9f : ctxt -> dst . val = test_cc ( ctxt -> b , ctxt -> eflags ) ; break ; case 0xae : break ; case 0xb6 ... 0xb7 : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> src . bytes == 1 ) ? ( u8 ) ctxt -> src . val : ( u16 ) ctxt -> src . val ; break ; case 0xbe ... 0xbf : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> src . bytes == 1 ) ? ( s8 ) ctxt -> src . val : ( s16 ) ctxt -> src . val ; break ; case 0xc3 : ctxt -> dst . bytes = ctxt -> op_bytes ; ctxt -> dst . val = ( ctxt -> op_bytes == 8 ) ? ( u64 ) ctxt -> src . val : ( u32 ) ctxt -> src . val ; break ; default : goto cannot_emulate ; } threebyte_insn : if ( rc != X86EMUL_CONTINUE ) goto done ; goto writeback ; cannot_emulate : return EMULATION_FAILED ; }\n", "\n", "\n", "Target: if ( index >= MAX_SUPPORTED_TV_TIMING ) return if ( index >= MAX_SUPPORTED_TV_TIMING_V1_2 ) return\n", "\n", "Sources:\n", "0: CWE-193 bool radeon_atom_get_tv_timings ( struct radeon_device * rdev , int index , struct drm_display_mode * mode ) { struct radeon_mode_info * mode_info = & rdev -> mode_info ; ATOM_ANALOG_TV_INFO * tv_info ; ATOM_ANALOG_TV_INFO_V1_2 * tv_info_v1_2 ; ATOM_DTD_FORMAT * dtd_timings ; int data_index = GetIndexIntoMasterTable ( DATA , AnalogTV_Info ) ; u8 frev , crev ; u16 data_offset , misc ; if ( ! atom_parse_data_header ( mode_info -> atom_context , data_index , NULL , & frev , & crev , & data_offset ) ) return false ; switch ( crev ) { case 1 : tv_info = ( ATOM_ANALOG_TV_INFO * ) ( mode_info -> atom_context -> bios + data_offset ) ; if ( index > MAX_SUPPORTED_TV_TIMING ) return false ; mode -> crtc_htotal = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_Total ) ; mode -> crtc_hdisplay = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_Disp ) ; mode -> crtc_hsync_start = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncStart ) ; mode -> crtc_hsync_end = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncStart ) + le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncWidth ) ; mode -> crtc_vtotal = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_Total ) ; mode -> crtc_vdisplay = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_Disp ) ; mode -> crtc_vsync_start = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncStart ) ; mode -> crtc_vsync_end = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncStart ) + le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncWidth ) ; mode -> flags = 0 ; misc = le16_to_cpu ( tv_info -> aModeTimings [ index ] . susModeMiscInfo . usAccess ) ; if ( misc & ATOM_VSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NVSYNC ; if ( misc & ATOM_HSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NHSYNC ; if ( misc & ATOM_COMPOSITESYNC ) mode -> flags |= DRM_MODE_FLAG_CSYNC ; if ( misc & ATOM_INTERLACE ) mode -> flags |= DRM_MODE_FLAG_INTERLACE ; if ( misc & ATOM_DOUBLE_CLOCK_MODE ) mode -> flags |= DRM_MODE_FLAG_DBLSCAN ; mode -> clock = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usPixelClock ) * 10 ; if ( index == 1 ) { mode -> crtc_htotal -= 1 ; mode -> crtc_vtotal -= 1 ; } break ; case 2 : tv_info_v1_2 = ( ATOM_ANALOG_TV_INFO_V1_2 * ) ( mode_info -> atom_context -> bios + data_offset ) ; if ( index > MAX_SUPPORTED_TV_TIMING_V1_2 ) return false ; dtd_timings = & tv_info_v1_2 -> aModeTimings [ index ] ; mode -> crtc_htotal = le16_to_cpu ( dtd_timings -> usHActive ) + le16_to_cpu ( dtd_timings -> usHBlanking_Time ) ; mode -> crtc_hdisplay = le16_to_cpu ( dtd_timings -> usHActive ) ; mode -> crtc_hsync_start = le16_to_cpu ( dtd_timings -> usHActive ) + le16_to_cpu ( dtd_timings -> usHSyncOffset ) ; mode -> crtc_hsync_end = mode -> crtc_hsync_start + le16_to_cpu ( dtd_timings -> usHSyncWidth ) ; mode -> crtc_vtotal = le16_to_cpu ( dtd_timings -> usVActive ) + le16_to_cpu ( dtd_timings -> usVBlanking_Time ) ; mode -> crtc_vdisplay = le16_to_cpu ( dtd_timings -> usVActive ) ; mode -> crtc_vsync_start = le16_to_cpu ( dtd_timings -> usVActive ) + le16_to_cpu ( dtd_timings -> usVSyncOffset ) ; mode -> crtc_vsync_end = mode -> crtc_vsync_start + le16_to_cpu ( dtd_timings -> usVSyncWidth ) ; mode -> flags = 0 ; misc = le16_to_cpu ( dtd_timings -> susModeMiscInfo . usAccess ) ; if ( misc & ATOM_VSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NVSYNC ; if ( misc & ATOM_HSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NHSYNC ; if ( misc & ATOM_COMPOSITESYNC ) mode -> flags |= DRM_MODE_FLAG_CSYNC ; if ( misc & ATOM_INTERLACE ) mode -> flags |= DRM_MODE_FLAG_INTERLACE ; if ( misc & ATOM_DOUBLE_CLOCK_MODE ) mode -> flags |= DRM_MODE_FLAG_DBLSCAN ; mode -> clock = le16_to_cpu ( dtd_timings -> usPixClk ) * 10 ; break ; } return true ; }\n", "\n", "1: CWE-119 bool radeon_atom_get_tv_timings ( struct radeon_device * rdev , int index , struct drm_display_mode * mode ) { struct radeon_mode_info * mode_info = & rdev -> mode_info ; ATOM_ANALOG_TV_INFO * tv_info ; ATOM_ANALOG_TV_INFO_V1_2 * tv_info_v1_2 ; ATOM_DTD_FORMAT * dtd_timings ; int data_index = GetIndexIntoMasterTable ( DATA , AnalogTV_Info ) ; u8 frev , crev ; u16 data_offset , misc ; if ( ! atom_parse_data_header ( mode_info -> atom_context , data_index , NULL , & frev , & crev , & data_offset ) ) return false ; switch ( crev ) { case 1 : tv_info = ( ATOM_ANALOG_TV_INFO * ) ( mode_info -> atom_context -> bios + data_offset ) ; if ( index > MAX_SUPPORTED_TV_TIMING ) return false ; mode -> crtc_htotal = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_Total ) ; mode -> crtc_hdisplay = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_Disp ) ; mode -> crtc_hsync_start = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncStart ) ; mode -> crtc_hsync_end = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncStart ) + le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_H_SyncWidth ) ; mode -> crtc_vtotal = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_Total ) ; mode -> crtc_vdisplay = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_Disp ) ; mode -> crtc_vsync_start = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncStart ) ; mode -> crtc_vsync_end = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncStart ) + le16_to_cpu ( tv_info -> aModeTimings [ index ] . usCRTC_V_SyncWidth ) ; mode -> flags = 0 ; misc = le16_to_cpu ( tv_info -> aModeTimings [ index ] . susModeMiscInfo . usAccess ) ; if ( misc & ATOM_VSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NVSYNC ; if ( misc & ATOM_HSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NHSYNC ; if ( misc & ATOM_COMPOSITESYNC ) mode -> flags |= DRM_MODE_FLAG_CSYNC ; if ( misc & ATOM_INTERLACE ) mode -> flags |= DRM_MODE_FLAG_INTERLACE ; if ( misc & ATOM_DOUBLE_CLOCK_MODE ) mode -> flags |= DRM_MODE_FLAG_DBLSCAN ; mode -> clock = le16_to_cpu ( tv_info -> aModeTimings [ index ] . usPixelClock ) * 10 ; if ( index == 1 ) { mode -> crtc_htotal -= 1 ; mode -> crtc_vtotal -= 1 ; } break ; case 2 : tv_info_v1_2 = ( ATOM_ANALOG_TV_INFO_V1_2 * ) ( mode_info -> atom_context -> bios + data_offset ) ; if ( index > MAX_SUPPORTED_TV_TIMING_V1_2 ) return false ; dtd_timings = & tv_info_v1_2 -> aModeTimings [ index ] ; mode -> crtc_htotal = le16_to_cpu ( dtd_timings -> usHActive ) + le16_to_cpu ( dtd_timings -> usHBlanking_Time ) ; mode -> crtc_hdisplay = le16_to_cpu ( dtd_timings -> usHActive ) ; mode -> crtc_hsync_start = le16_to_cpu ( dtd_timings -> usHActive ) + le16_to_cpu ( dtd_timings -> usHSyncOffset ) ; mode -> crtc_hsync_end = mode -> crtc_hsync_start + le16_to_cpu ( dtd_timings -> usHSyncWidth ) ; mode -> crtc_vtotal = le16_to_cpu ( dtd_timings -> usVActive ) + le16_to_cpu ( dtd_timings -> usVBlanking_Time ) ; mode -> crtc_vdisplay = le16_to_cpu ( dtd_timings -> usVActive ) ; mode -> crtc_vsync_start = le16_to_cpu ( dtd_timings -> usVActive ) + le16_to_cpu ( dtd_timings -> usVSyncOffset ) ; mode -> crtc_vsync_end = mode -> crtc_vsync_start + le16_to_cpu ( dtd_timings -> usVSyncWidth ) ; mode -> flags = 0 ; misc = le16_to_cpu ( dtd_timings -> susModeMiscInfo . usAccess ) ; if ( misc & ATOM_VSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NVSYNC ; if ( misc & ATOM_HSYNC_POLARITY ) mode -> flags |= DRM_MODE_FLAG_NHSYNC ; if ( misc & ATOM_COMPOSITESYNC ) mode -> flags |= DRM_MODE_FLAG_CSYNC ; if ( misc & ATOM_INTERLACE ) mode -> flags |= DRM_MODE_FLAG_INTERLACE ; if ( misc & ATOM_DOUBLE_CLOCK_MODE ) mode -> flags |= DRM_MODE_FLAG_DBLSCAN ; mode -> clock = le16_to_cpu ( dtd_timings -> usPixClk ) * 10 ; break ; } return true ; }\n", "\n", "\n", "Target: pt_regs * regs ) { u64 ( event , & data ,\n", "\n", "Sources:\n", "0: CWE-400 static void record_and_restart ( struct perf_event * event , unsigned long val , struct pt_regs * regs , int nmi ) { u64 period = event -> hw . sample_period ; s64 prev , delta , left ; int record = 0 ; if ( event -> hw . state & PERF_HES_STOPPED ) { write_pmc ( event -> hw . idx , 0 ) ; return ; } prev = local64_read ( & event -> hw . prev_count ) ; delta = ( val - prev ) & 0xfffffffful ; local64_add ( delta , & event -> count ) ; val = 0 ; left = local64_read ( & event -> hw . period_left ) - delta ; if ( period ) { if ( left <= 0 ) { left += period ; if ( left <= 0 ) left = period ; record = 1 ; event -> hw . last_period = event -> hw . sample_period ; } if ( left < 0x80000000LL ) val = 0x80000000LL - left ; } write_pmc ( event -> hw . idx , val ) ; local64_set ( & event -> hw . prev_count , val ) ; local64_set ( & event -> hw . period_left , left ) ; perf_event_update_userpage ( event ) ; if ( record ) { struct perf_sample_data data ; perf_sample_data_init ( & data , 0 ) ; data . period = event -> hw . last_period ; if ( perf_event_overflow ( event , nmi , & data , regs ) ) fsl_emb_pmu_stop ( event , 0 ) ; } }\n", "\n", "1: CWE-399 static void record_and_restart ( struct perf_event * event , unsigned long val , struct pt_regs * regs , int nmi ) { u64 period = event -> hw . sample_period ; s64 prev , delta , left ; int record = 0 ; if ( event -> hw . state & PERF_HES_STOPPED ) { write_pmc ( event -> hw . idx , 0 ) ; return ; } prev = local64_read ( & event -> hw . prev_count ) ; delta = ( val - prev ) & 0xfffffffful ; local64_add ( delta , & event -> count ) ; val = 0 ; left = local64_read ( & event -> hw . period_left ) - delta ; if ( period ) { if ( left <= 0 ) { left += period ; if ( left <= 0 ) left = period ; record = 1 ; event -> hw . last_period = event -> hw . sample_period ; } if ( left < 0x80000000LL ) val = 0x80000000LL - left ; } write_pmc ( event -> hw . idx , val ) ; local64_set ( & event -> hw . prev_count , val ) ; local64_set ( & event -> hw . period_left , left ) ; perf_event_update_userpage ( event ) ; if ( record ) { struct perf_sample_data data ; perf_sample_data_init ( & data , 0 ) ; data . period = event -> hw . last_period ; if ( perf_event_overflow ( event , nmi , & data , regs ) ) fsl_emb_pmu_stop ( event , 0 ) ; } }\n", "\n", "2: CWE-400 static void record_and_restart ( struct perf_event * event , unsigned long val , struct pt_regs * regs , int nmi ) { u64 period = event -> hw . sample_period ; s64 prev , delta , left ; int record = 0 ; if ( event -> hw . state & PERF_HES_STOPPED ) { write_pmc ( event -> hw . idx , 0 ) ; return ; } prev = local64_read ( & event -> hw . prev_count ) ; delta = check_and_compute_delta ( prev , val ) ; local64_add ( delta , & event -> count ) ; val = 0 ; left = local64_read ( & event -> hw . period_left ) - delta ; if ( period ) { if ( left <= 0 ) { left += period ; if ( left <= 0 ) left = period ; record = 1 ; event -> hw . last_period = event -> hw . sample_period ; } if ( left < 0x80000000LL ) val = 0x80000000LL - left ; } write_pmc ( event -> hw . idx , val ) ; local64_set ( & event -> hw . prev_count , val ) ; local64_set ( & event -> hw . period_left , left ) ; perf_event_update_userpage ( event ) ; if ( record ) { struct perf_sample_data data ; perf_sample_data_init ( & data , ~ 0ULL ) ; data . period = event -> hw . last_period ; if ( event -> attr . sample_type & PERF_SAMPLE_ADDR ) perf_get_data_addr ( regs , & data . addr ) ; if ( perf_event_overflow ( event , nmi , & data , regs ) ) power_pmu_stop ( event , 0 ) ; } }\n", "\n", "\n", "Target: ) ) { if ( unlikely ( stackidx >= private -> stacksize ) ) { verdict = NF_DROP ; break ; }\n", "\n", "Sources:\n", "0: CWE-476 unsigned int ip6t_do_table ( struct sk_buff * skb , const struct nf_hook_state * state , struct xt_table * table ) { unsigned int hook = state -> hook ; static const char nulldevname [ IFNAMSIZ ] __attribute__ ( ( aligned ( sizeof ( long ) ) ) ) ; unsigned int verdict = NF_DROP ; const char * indev , * outdev ; const void * table_base ; struct ip6t_entry * e , * * jumpstack ; unsigned int stackidx , cpu ; const struct xt_table_info * private ; struct xt_action_param acpar ; unsigned int addend ; stackidx = 0 ; indev = state -> in ? state -> in -> name : nulldevname ; outdev = state -> out ? state -> out -> name : nulldevname ; acpar . hotdrop = false ; acpar . state = state ; WARN_ON ( ! ( table -> valid_hooks & ( 1 << hook ) ) ) ; local_bh_disable ( ) ; addend = xt_write_recseq_begin ( ) ; private = READ_ONCE ( table -> private ) ; cpu = smp_processor_id ( ) ; table_base = private -> entries ; jumpstack = ( struct ip6t_entry * * ) private -> jumpstack [ cpu ] ; if ( static_key_false ( & xt_tee_enabled ) ) jumpstack += private -> stacksize * __this_cpu_read ( nf_skb_duplicated ) ; e = get_entry ( table_base , private -> hook_entry [ hook ] ) ; do { const struct xt_entry_target * t ; const struct xt_entry_match * ematch ; struct xt_counters * counter ; WARN_ON ( ! e ) ; acpar . thoff = 0 ; if ( ! ip6_packet_match ( skb , indev , outdev , & e -> ipv6 , & acpar . thoff , & acpar . fragoff , & acpar . hotdrop ) ) { no_match : e = ip6t_next_entry ( e ) ; continue ; } xt_ematch_foreach ( ematch , e ) { acpar . match = ematch -> u . kernel . match ; acpar . matchinfo = ematch -> data ; if ( ! acpar . match -> match ( skb , & acpar ) ) goto no_match ; } counter = xt_get_this_cpu_counter ( & e -> counters ) ; ADD_COUNTER ( * counter , skb -> len , 1 ) ; t = ip6t_get_target_c ( e ) ; WARN_ON ( ! t -> u . kernel . target ) ; # if IS_ENABLED ( CONFIG_NETFILTER_XT_TARGET_TRACE ) if ( unlikely ( skb -> nf_trace ) ) trace_packet ( state -> net , skb , hook , state -> in , state -> out , table -> name , private , e ) ; # endif if ( ! t -> u . kernel . target -> target ) { int v ; v = ( ( struct xt_standard_target * ) t ) -> verdict ; if ( v < 0 ) { if ( v != XT_RETURN ) { verdict = ( unsigned int ) ( - v ) - 1 ; break ; } if ( stackidx == 0 ) e = get_entry ( table_base , private -> underflow [ hook ] ) ; else e = ip6t_next_entry ( jumpstack [ -- stackidx ] ) ; continue ; } if ( table_base + v != ip6t_next_entry ( e ) && ! ( e -> ipv6 . flags & IP6T_F_GOTO ) ) { jumpstack [ stackidx ++ ] = e ; } e = get_entry ( table_base , v ) ; continue ; } acpar . target = t -> u . kernel . target ; acpar . targinfo = t -> data ; verdict = t -> u . kernel . target -> target ( skb , & acpar ) ; if ( verdict == XT_CONTINUE ) e = ip6t_next_entry ( e ) ; else break ; } while ( ! acpar . hotdrop ) ; xt_write_recseq_end ( addend ) ; local_bh_enable ( ) ; if ( acpar . hotdrop ) return NF_DROP ; else return verdict ; }\n", "\n", "1: CWE-476 unsigned int arpt_do_table ( struct sk_buff * skb , const struct nf_hook_state * state , struct xt_table * table ) { unsigned int hook = state -> hook ; static const char nulldevname [ IFNAMSIZ ] __attribute__ ( ( aligned ( sizeof ( long ) ) ) ) ; unsigned int verdict = NF_DROP ; const struct arphdr * arp ; struct arpt_entry * e , * * jumpstack ; const char * indev , * outdev ; const void * table_base ; unsigned int cpu , stackidx = 0 ; const struct xt_table_info * private ; struct xt_action_param acpar ; unsigned int addend ; if ( ! pskb_may_pull ( skb , arp_hdr_len ( skb -> dev ) ) ) return NF_DROP ; indev = state -> in ? state -> in -> name : nulldevname ; outdev = state -> out ? state -> out -> name : nulldevname ; local_bh_disable ( ) ; addend = xt_write_recseq_begin ( ) ; private = READ_ONCE ( table -> private ) ; cpu = smp_processor_id ( ) ; table_base = private -> entries ; jumpstack = ( struct arpt_entry * * ) private -> jumpstack [ cpu ] ; e = get_entry ( table_base , private -> hook_entry [ hook ] ) ; acpar . state = state ; acpar . hotdrop = false ; arp = arp_hdr ( skb ) ; do { const struct xt_entry_target * t ; struct xt_counters * counter ; if ( ! arp_packet_match ( arp , skb -> dev , indev , outdev , & e -> arp ) ) { e = arpt_next_entry ( e ) ; continue ; } counter = xt_get_this_cpu_counter ( & e -> counters ) ; ADD_COUNTER ( * counter , arp_hdr_len ( skb -> dev ) , 1 ) ; t = arpt_get_target_c ( e ) ; if ( ! t -> u . kernel . target -> target ) { int v ; v = ( ( struct xt_standard_target * ) t ) -> verdict ; if ( v < 0 ) { if ( v != XT_RETURN ) { verdict = ( unsigned int ) ( - v ) - 1 ; break ; } if ( stackidx == 0 ) { e = get_entry ( table_base , private -> underflow [ hook ] ) ; } else { e = jumpstack [ -- stackidx ] ; e = arpt_next_entry ( e ) ; } continue ; } if ( table_base + v != arpt_next_entry ( e ) ) { jumpstack [ stackidx ++ ] = e ; } e = get_entry ( table_base , v ) ; continue ; } acpar . target = t -> u . kernel . target ; acpar . targinfo = t -> data ; verdict = t -> u . kernel . target -> target ( skb , & acpar ) ; if ( verdict == XT_CONTINUE ) { arp = arp_hdr ( skb ) ; e = arpt_next_entry ( e ) ; } else { break ; } } while ( ! acpar . hotdrop ) ; xt_write_recseq_end ( addend ) ; local_bh_enable ( ) ; if ( acpar . hotdrop ) return NF_DROP ; else return verdict ; }\n", "\n", "\n", "Target: -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( \"b/26366256\" ) ; return ; }\n", "\n", "Sources:\n", "0: CWE-119 void WT_NoiseGenerator ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 nInterpolatedSample ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; pOutputBuffer = pWTIntFrame -> pAudioBuffer ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; tmp0 = ( EAS_I32 ) ( pWTVoice -> phaseAccum ) >> 18 ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; while ( numSamples -- ) { nInterpolatedSample = MULT_AUDIO_COEF ( tmp0 , ( PHASE_ONE - pWTVoice -> phaseFrac ) ) ; nInterpolatedSample += MULT_AUDIO_COEF ( tmp1 , pWTVoice -> phaseFrac ) ; * pOutputBuffer ++ = ( EAS_PCM ) nInterpolatedSample ; pWTVoice -> phaseFrac += ( EAS_U32 ) phaseInc ; if ( GET_PHASE_INT_PART ( pWTVoice -> phaseFrac ) ) { tmp0 = tmp1 ; pWTVoice -> phaseAccum = pWTVoice -> loopEnd ; pWTVoice -> loopEnd = ( 5 * pWTVoice -> loopEnd + 1 ) ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; pWTVoice -> phaseFrac = GET_PHASE_FRAC_PART ( pWTVoice -> phaseFrac ) ; } } }\n", "\n", "1: CWE-119 void WT_VoiceGain ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_I32 * pMixBuffer ; EAS_PCM * pInputBuffer ; EAS_I32 gain ; EAS_I32 gainIncrement ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 tmp2 ; EAS_I32 numSamples ; # if ( NUM_OUTPUT_CHANNELS == 2 ) EAS_I32 gainLeft , gainRight ; # endif numSamples = pWTIntFrame -> numSamples ; pMixBuffer = pWTIntFrame -> pMixBuffer ; pInputBuffer = pWTIntFrame -> pAudioBuffer ; gainIncrement = ( pWTIntFrame -> frame . gainTarget - pWTIntFrame -> prevGain ) << ( 16 - SYNTH_UPDATE_PERIOD_IN_BITS ) ; if ( gainIncrement < 0 ) gainIncrement ++ ; gain = pWTIntFrame -> prevGain << 16 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) gainLeft = pWTVoice -> gainLeft ; gainRight = pWTVoice -> gainRight ; # endif while ( numSamples -- ) { tmp0 = * pInputBuffer ++ ; gain += gainIncrement ; tmp2 = gain >> 16 ; tmp2 *= tmp0 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) tmp2 = tmp2 >> 14 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainLeft ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainRight ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; # else tmp1 = * pMixBuffer ; tmp2 = tmp2 >> ( NUM_MIXER_GUARD_BITS - 1 ) ; tmp1 += tmp2 ; * pMixBuffer ++ = tmp1 ; # endif } }\n", "\n", "2: CWE-119 void WT_InterpolateNoLoop ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 phaseFrac ; EAS_I32 acc0 ; const EAS_SAMPLE * pSamples ; EAS_I32 samp1 ; EAS_I32 samp2 ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; pOutputBuffer = pWTIntFrame -> pAudioBuffer ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; pSamples = ( const EAS_SAMPLE * ) pWTVoice -> phaseAccum ; phaseFrac = ( EAS_I32 ) pWTVoice -> phaseFrac ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif while ( numSamples -- ) { acc0 = samp2 - samp1 ; acc0 = acc0 * phaseFrac ; acc0 = samp1 + ( acc0 >> NUM_PHASE_FRAC_BITS ) ; * pOutputBuffer ++ = ( EAS_I16 ) ( acc0 >> 2 ) ; phaseFrac += phaseInc ; acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS ; if ( acc0 > 0 ) { pSamples += acc0 ; phaseFrac = ( EAS_I32 ) ( ( EAS_U32 ) phaseFrac & PHASE_FRAC_MASK ) ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif } } pWTVoice -> phaseAccum = ( EAS_U32 ) pSamples ; pWTVoice -> phaseFrac = ( EAS_U32 ) phaseFrac ; }\n", "\n", "3: CWE-119 void WT_Interpolate ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 phaseFrac ; EAS_I32 acc0 ; const EAS_SAMPLE * pSamples ; const EAS_SAMPLE * loopEnd ; EAS_I32 samp1 ; EAS_I32 samp2 ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; pOutputBuffer = pWTIntFrame -> pAudioBuffer ; loopEnd = ( const EAS_SAMPLE * ) pWTVoice -> loopEnd + 1 ; pSamples = ( const EAS_SAMPLE * ) pWTVoice -> phaseAccum ; phaseFrac = pWTVoice -> phaseFrac ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif while ( numSamples -- ) { acc0 = samp2 - samp1 ; acc0 = acc0 * phaseFrac ; acc0 = samp1 + ( acc0 >> NUM_PHASE_FRAC_BITS ) ; * pOutputBuffer ++ = ( EAS_I16 ) ( acc0 >> 2 ) ; phaseFrac += phaseInc ; acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS ; if ( acc0 > 0 ) { pSamples += acc0 ; phaseFrac = ( EAS_I32 ) ( ( EAS_U32 ) phaseFrac & PHASE_FRAC_MASK ) ; acc0 = ( EAS_I32 ) ( pSamples - loopEnd ) ; if ( acc0 >= 0 ) pSamples = ( const EAS_SAMPLE * ) pWTVoice -> loopStart + acc0 ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif } } pWTVoice -> phaseAccum = ( EAS_U32 ) pSamples ; pWTVoice -> phaseFrac = ( EAS_U32 ) phaseFrac ; }\n", "\n", "\n", "Target: * f ; mutex_lock ( & fanout_mutex ) ; ; if ( f ) { po -> fanout ) ; } if ( po ) ; } mutex_unlock ( & fanout_mutex ) ; }\n", "\n", "Sources:\n", "0: CWE-416 static void fanout_release ( struct sock * sk ) { struct packet_sock * po = pkt_sk ( sk ) ; struct packet_fanout * f ; f = po -> fanout ; if ( ! f ) return ; mutex_lock ( & fanout_mutex ) ; po -> fanout = NULL ; if ( atomic_dec_and_test ( & f -> sk_ref ) ) { list_del ( & f -> list ) ; dev_remove_pack ( & f -> prot_hook ) ; fanout_release_data ( f ) ; kfree ( f ) ; } mutex_unlock ( & fanout_mutex ) ; if ( po -> rollover ) kfree_rcu ( po -> rollover , rcu ) ; } \n", "\n", "1: CWE-362 static void fanout_release ( struct sock * sk ) { struct packet_sock * po = pkt_sk ( sk ) ; struct packet_fanout * f ; f = po -> fanout ; if ( ! f ) return ; mutex_lock ( & fanout_mutex ) ; po -> fanout = NULL ; if ( atomic_dec_and_test ( & f -> sk_ref ) ) { list_del ( & f -> list ) ; dev_remove_pack ( & f -> prot_hook ) ; fanout_release_data ( f ) ; kfree ( f ) ; } mutex_unlock ( & fanout_mutex ) ; if ( po -> rollover ) kfree_rcu ( po -> rollover , rcu ) ; } \n", "\n", "\n", "Target: ; gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; OM_uint32 minor_stat ) ; } exit_func : gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; free_server_handle ( handle\n", "\n", "Sources:\n", "0: CWE-772 generic_ret * create_policy_2_svc ( cpol_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> rec . policy ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_ADD , NULL , NULL ) ) { ret . code = KADM5_AUTH_ADD ; log_unauth ( \"kadm5_create_policy\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_create_policy ( ( void * ) handle , & arg -> rec , arg -> mask ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_create_policy\" , ( ( prime_arg == NULL ) ? \"(null)\" : prime_arg ) , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "1: CWE-772 gpol_ret * get_policy_2_svc ( gpol_arg * arg , struct svc_req * rqstp ) { static gpol_ret ret ; kadm5_ret_t ret2 ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_principal_ent_rec caller_ent ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gpol_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; funcname = \"kadm5_get_policy\" ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> name ; ret . code = KADM5_AUTH_GET ; if ( ! CHANGEPW_SERVICE ( rqstp ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_INQUIRE , NULL , NULL ) ) ret . code = KADM5_OK ; else { ret . code = kadm5_get_principal ( handle -> lhandle , handle -> current_caller , & caller_ent , KADM5_PRINCIPAL_NORMAL_MASK ) ; if ( ret . code == KADM5_OK ) { if ( caller_ent . aux_attributes & KADM5_POLICY && strcmp ( caller_ent . policy , arg -> name ) == 0 ) { ret . code = KADM5_OK ; } else ret . code = KADM5_AUTH_GET ; ret2 = kadm5_free_principal_ent ( handle -> lhandle , & caller_ent ) ; ret . code = ret . code ? ret . code : ret2 ; } } if ( ret . code == KADM5_OK ) { ret . code = kadm5_get_policy ( handle , arg -> name , & ret . rec ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , ( ( prime_arg == NULL ) ? \"(null)\" : prime_arg ) , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } else { log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "2: CWE-772 generic_ret * modify_policy_2_svc ( mpol_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> rec . policy ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_MODIFY , NULL , NULL ) ) { log_unauth ( \"kadm5_modify_policy\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_MODIFY ; } else { ret . code = kadm5_modify_policy ( ( void * ) handle , & arg -> rec , arg -> mask ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_modify_policy\" , ( ( prime_arg == NULL ) ? \"(null)\" : prime_arg ) , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "3: CWE-772 gpols_ret * get_pols_2_svc ( gpols_arg * arg , struct svc_req * rqstp ) { static gpols_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gpols_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> exp ; if ( prime_arg == NULL ) prime_arg = \"*\" ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_LIST , NULL , NULL ) ) { ret . code = KADM5_AUTH_LIST ; log_unauth ( \"kadm5_get_policies\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_get_policies ( ( void * ) handle , arg -> exp , & ret . pols , & ret . count ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_get_policies\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "4: CWE-772 gprincs_ret * get_princs_2_svc ( gprincs_arg * arg , struct svc_req * rqstp ) { static gprincs_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gprincs_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> exp ; if ( prime_arg == NULL ) prime_arg = \"*\" ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_LIST , NULL , NULL ) ) { ret . code = KADM5_AUTH_LIST ; log_unauth ( \"kadm5_get_principals\" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_get_principals ( ( void * ) handle , arg -> exp , & ret . princs , & ret . count ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_get_principals\" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "5: CWE-772 generic_ret * delete_policy_2_svc ( dpol_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } prime_arg = arg -> name ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_DELETE , NULL , NULL ) ) { log_unauth ( \"kadm5_delete_policy\" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_DELETE ; } else { ret . code = kadm5_delete_policy ( ( void * ) handle , arg -> name ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( \"kadm5_delete_policy\" , ( ( prime_arg == NULL ) ? \"(null)\" : prime_arg ) , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; }\n", "\n", "\n", "Target: ; if ( validate_core_offset ( reg ) ) return - EINVAL ; if (\n", "\n", "Sources:\n", "0: CWE-20 static int get_core_reg ( struct kvm_vcpu * vcpu , const struct kvm_one_reg * reg ) { __u32 __user * uaddr = ( __u32 __user * ) ( unsigned long ) reg -> addr ; struct kvm_regs * regs = vcpu_gp_regs ( vcpu ) ; int nr_regs = sizeof ( * regs ) / sizeof ( __u32 ) ; u32 off ; off = core_reg_offset_from_id ( reg -> id ) ; if ( off >= nr_regs || ( off + ( KVM_REG_SIZE ( reg -> id ) / sizeof ( __u32 ) ) ) >= nr_regs ) return - ENOENT ; if ( copy_to_user ( uaddr , ( ( u32 * ) regs ) + off , KVM_REG_SIZE ( reg -> id ) ) ) return - EFAULT ; return 0 ; }\n", "\n", "1: CWE-20 static int set_core_reg ( struct kvm_vcpu * vcpu , const struct kvm_one_reg * reg ) { __u32 __user * uaddr = ( __u32 __user * ) ( unsigned long ) reg -> addr ; struct kvm_regs * regs = vcpu_gp_regs ( vcpu ) ; int nr_regs = sizeof ( * regs ) / sizeof ( __u32 ) ; __uint128_t tmp ; void * valp = & tmp ; u64 off ; int err = 0 ; off = core_reg_offset_from_id ( reg -> id ) ; if ( off >= nr_regs || ( off + ( KVM_REG_SIZE ( reg -> id ) / sizeof ( __u32 ) ) ) >= nr_regs ) return - ENOENT ; if ( KVM_REG_SIZE ( reg -> id ) > sizeof ( tmp ) ) return - EINVAL ; if ( copy_from_user ( valp , uaddr , KVM_REG_SIZE ( reg -> id ) ) ) { err = - EFAULT ; goto out ; } if ( off == KVM_REG_ARM_CORE_REG ( regs . pstate ) ) { u32 mode = ( * ( u32 * ) valp ) & PSR_AA32_MODE_MASK ; switch ( mode ) { case PSR_AA32_MODE_USR : case PSR_AA32_MODE_FIQ : case PSR_AA32_MODE_IRQ : case PSR_AA32_MODE_SVC : case PSR_AA32_MODE_ABT : case PSR_AA32_MODE_UND : case PSR_MODE_EL0t : case PSR_MODE_EL1t : case PSR_MODE_EL1h : break ; default : err = - EINVAL ; goto out ; } } memcpy ( ( u32 * ) regs + off , valp , KVM_REG_SIZE ( reg -> id ) ) ; out : return err ; }\n", "\n", "\n", "Target: char buf [ L_BUFSIZE ] ; char ( buf , L_BUFSIZE , \"%s.data.%d\" , ( buf , L_BUFSIZE , \"%f%f\\\\n\" ,\n", "\n", "Sources:\n", "0: CWE-119 l_int32 gplotAddPlot ( GPLOT * gplot , NUMA * nax , NUMA * nay , l_int32 plotstyle , const char * plottitle ) { char buf [ L_BUF_SIZE ] ; char emptystring [ ] = \"\" ; char * datastr , * title ; l_int32 n , i ; l_float32 valx , valy , startx , delx ; SARRAY * sa ; PROCNAME ( \"gplotAddPlot\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; if ( ! nay ) return ERROR_INT ( \"naynotdefined\" , procName , 1 ) ; if ( plotstyle < 0 || plotstyle >= NUM_GPLOT_STYLES ) return ERROR_INT ( \"invalidplotstyle\" , procName , 1 ) ; if ( ( n = numaGetCount ( nay ) ) == 0 ) return ERROR_INT ( \"nopointstoplot\" , procName , 1 ) ; if ( nax && ( n != numaGetCount ( nax ) ) ) return ERROR_INT ( \"naxandnaysizesdiffer\" , procName , 1 ) ; if ( n == 1 && plotstyle == GPLOT_LINES ) { L_INFO ( \"only1pt;changingstyletopoints\\\\n\" , procName ) ; plotstyle = GPLOT_POINTS ; } numaGetParameters ( nay , & startx , & delx ) ; numaAddNumber ( gplot -> plotstyles , plotstyle ) ; if ( plottitle ) { title = stringNew ( plottitle ) ; sarrayAddString ( gplot -> plottitles , title , L_INSERT ) ; } else { sarrayAddString ( gplot -> plottitles , emptystring , L_COPY ) ; } gplot -> nplots ++ ; snprintf ( buf , L_BUF_SIZE , \"%s.data.%d\" , gplot -> rootname , gplot -> nplots ) ; sarrayAddString ( gplot -> datanames , buf , L_COPY ) ; sa = sarrayCreate ( n ) ; for ( i = 0 ; i < n ; i ++ ) { if ( nax ) numaGetFValue ( nax , i , & valx ) ; else valx = startx + i * delx ; numaGetFValue ( nay , i , & valy ) ; snprintf ( buf , L_BUF_SIZE , \"%f%f\\\\n\" , valx , valy ) ; sarrayAddString ( sa , buf , L_COPY ) ; } datastr = sarrayToString ( sa , 0 ) ; sarrayAddString ( gplot -> plotdata , datastr , L_INSERT ) ; sarrayDestroy ( & sa ) ; return 0 ; }\n", "\n", "1: CWE-787 l_int32 gplotAddPlot ( GPLOT * gplot , NUMA * nax , NUMA * nay , l_int32 plotstyle , const char * plottitle ) { char buf [ L_BUF_SIZE ] ; char emptystring [ ] = \"\" ; char * datastr , * title ; l_int32 n , i ; l_float32 valx , valy , startx , delx ; SARRAY * sa ; PROCNAME ( \"gplotAddPlot\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; if ( ! nay ) return ERROR_INT ( \"naynotdefined\" , procName , 1 ) ; if ( plotstyle < 0 || plotstyle >= NUM_GPLOT_STYLES ) return ERROR_INT ( \"invalidplotstyle\" , procName , 1 ) ; if ( ( n = numaGetCount ( nay ) ) == 0 ) return ERROR_INT ( \"nopointstoplot\" , procName , 1 ) ; if ( nax && ( n != numaGetCount ( nax ) ) ) return ERROR_INT ( \"naxandnaysizesdiffer\" , procName , 1 ) ; if ( n == 1 && plotstyle == GPLOT_LINES ) { L_INFO ( \"only1pt;changingstyletopoints\\\\n\" , procName ) ; plotstyle = GPLOT_POINTS ; } numaGetParameters ( nay , & startx , & delx ) ; numaAddNumber ( gplot -> plotstyles , plotstyle ) ; if ( plottitle ) { title = stringNew ( plottitle ) ; sarrayAddString ( gplot -> plottitles , title , L_INSERT ) ; } else { sarrayAddString ( gplot -> plottitles , emptystring , L_COPY ) ; } gplot -> nplots ++ ; snprintf ( buf , L_BUF_SIZE , \"%s.data.%d\" , gplot -> rootname , gplot -> nplots ) ; sarrayAddString ( gplot -> datanames , buf , L_COPY ) ; sa = sarrayCreate ( n ) ; for ( i = 0 ; i < n ; i ++ ) { if ( nax ) numaGetFValue ( nax , i , & valx ) ; else valx = startx + i * delx ; numaGetFValue ( nay , i , & valy ) ; snprintf ( buf , L_BUF_SIZE , \"%f%f\\\\n\" , valx , valy ) ; sarrayAddString ( sa , buf , L_COPY ) ; } datastr = sarrayToString ( sa , 0 ) ; sarrayAddString ( gplot -> plotdata , datastr , L_INSERT ) ; sarrayDestroy ( & sa ) ; return 0 ; }\n", "\n", "\n", "Target: rd_dev ) { struct rd_dev_sg_table * sg_table ; u32 sg_tables , total_sg_needed ) ) ; int rc ; if ( = sg_tables ; rc = rd_allocate_sgl_table ( rd_dev , sg_table , total_sg_needed , 0x00 ) ; if ( rc ) return rc ; pr_debug ( \"CORE_RD[%u]-BuiltRamdiskDeviceID:%uspaceof\"\n", "\n", "Sources:\n", "0: CWE-264 static int rd_build_device_space ( struct rd_dev * rd_dev ) { u32 i = 0 , j , page_offset = 0 , sg_per_table , sg_tables , total_sg_needed ; u32 max_sg_per_table = ( RD_MAX_ALLOCATION_SIZE / sizeof ( struct scatterlist ) ) ; struct rd_dev_sg_table * sg_table ; struct page * pg ; struct scatterlist * sg ; if ( rd_dev -> rd_page_count <= 0 ) { pr_err ( \"Illegalpagecount:%uforRamdiskdevice\\\\n\" , rd_dev -> rd_page_count ) ; return - EINVAL ; } if ( rd_dev -> rd_flags & RDF_NULLIO ) return 0 ; total_sg_needed = rd_dev -> rd_page_count ; sg_tables = ( total_sg_needed / max_sg_per_table ) + 1 ; sg_table = kzalloc ( sg_tables * sizeof ( struct rd_dev_sg_table ) , GFP_KERNEL ) ; if ( ! sg_table ) { pr_err ( \"UnabletoallocatememoryforRamdisk\" \"scatterlisttables\\\\n\" ) ; return - ENOMEM ; } rd_dev -> sg_table_array = sg_table ; rd_dev -> sg_table_count = sg_tables ; while ( total_sg_needed ) { sg_per_table = ( total_sg_needed > max_sg_per_table ) ? max_sg_per_table : total_sg_needed ; sg = kzalloc ( sg_per_table * sizeof ( struct scatterlist ) , GFP_KERNEL ) ; if ( ! sg ) { pr_err ( \"Unabletoallocatescatterlistarray\" \"forstructrd_dev\\\\n\" ) ; return - ENOMEM ; } sg_init_table ( sg , sg_per_table ) ; sg_table [ i ] . sg_table = sg ; sg_table [ i ] . rd_sg_count = sg_per_table ; sg_table [ i ] . page_start_offset = page_offset ; sg_table [ i ++ ] . page_end_offset = ( page_offset + sg_per_table ) - 1 ; for ( j = 0 ; j < sg_per_table ; j ++ ) { pg = alloc_pages ( GFP_KERNEL , 0 ) ; if ( ! pg ) { pr_err ( \"Unabletoallocatescatterlist\" \"pagesforstructrd_dev_sg_table\\\\n\" ) ; return - ENOMEM ; } sg_assign_page ( & sg [ j ] , pg ) ; sg [ j ] . length = PAGE_SIZE ; } page_offset += sg_per_table ; total_sg_needed -= sg_per_table ; } pr_debug ( \"CORE_RD[%u]-BuiltRamdiskDeviceID:%uspaceof\" \"%upagesin%utables\\\\n\" , rd_dev -> rd_host -> rd_host_id , rd_dev -> rd_dev_id , rd_dev -> rd_page_count , rd_dev -> sg_table_count ) ; return 0 ; }\n", "\n", "1: CWE-200 static int rd_build_device_space ( struct rd_dev * rd_dev ) { u32 i = 0 , j , page_offset = 0 , sg_per_table , sg_tables , total_sg_needed ; u32 max_sg_per_table = ( RD_MAX_ALLOCATION_SIZE / sizeof ( struct scatterlist ) ) ; struct rd_dev_sg_table * sg_table ; struct page * pg ; struct scatterlist * sg ; if ( rd_dev -> rd_page_count <= 0 ) { pr_err ( \"Illegalpagecount:%uforRamdiskdevice\\\\n\" , rd_dev -> rd_page_count ) ; return - EINVAL ; } if ( rd_dev -> rd_flags & RDF_NULLIO ) return 0 ; total_sg_needed = rd_dev -> rd_page_count ; sg_tables = ( total_sg_needed / max_sg_per_table ) + 1 ; sg_table = kzalloc ( sg_tables * sizeof ( struct rd_dev_sg_table ) , GFP_KERNEL ) ; if ( ! sg_table ) { pr_err ( \"UnabletoallocatememoryforRamdisk\" \"scatterlisttables\\\\n\" ) ; return - ENOMEM ; } rd_dev -> sg_table_array = sg_table ; rd_dev -> sg_table_count = sg_tables ; while ( total_sg_needed ) { sg_per_table = ( total_sg_needed > max_sg_per_table ) ? max_sg_per_table : total_sg_needed ; sg = kzalloc ( sg_per_table * sizeof ( struct scatterlist ) , GFP_KERNEL ) ; if ( ! sg ) { pr_err ( \"Unabletoallocatescatterlistarray\" \"forstructrd_dev\\\\n\" ) ; return - ENOMEM ; } sg_init_table ( sg , sg_per_table ) ; sg_table [ i ] . sg_table = sg ; sg_table [ i ] . rd_sg_count = sg_per_table ; sg_table [ i ] . page_start_offset = page_offset ; sg_table [ i ++ ] . page_end_offset = ( page_offset + sg_per_table ) - 1 ; for ( j = 0 ; j < sg_per_table ; j ++ ) { pg = alloc_pages ( GFP_KERNEL , 0 ) ; if ( ! pg ) { pr_err ( \"Unabletoallocatescatterlist\" \"pagesforstructrd_dev_sg_table\\\\n\" ) ; return - ENOMEM ; } sg_assign_page ( & sg [ j ] , pg ) ; sg [ j ] . length = PAGE_SIZE ; } page_offset += sg_per_table ; total_sg_needed -= sg_per_table ; } pr_debug ( \"CORE_RD[%u]-BuiltRamdiskDeviceID:%uspaceof\" \"%upagesin%utables\\\\n\" , rd_dev -> rd_host -> rd_host_id , rd_dev -> rd_dev_id , rd_dev -> rd_page_count , rd_dev -> sg_table_count ) ; return 0 ; }\n", "\n", "\n", "Target: char buf [ L_BUFSIZE ] ; char ( buf , L_BUFSIZE , \"settitle\\'%s\\'\" , ( buf , L_BUFSIZE , \"setxlabel\\'%s\\'\" , ( buf , L_BUFSIZE , \"setylabel\\'%s\\'\" , ( buf , L_BUFSIZE , \"setterminalpng;setoutput\\'%s\\'\" , ( buf , L_BUFSIZE , \"setterminalpostscript;setoutput\\'%s\\'\" , ( buf , L_BUFSIZE , \"setterminalpostscripteps;setoutput\\'%s\\'\" , ( buf , L_BUFSIZE , \"setterminallatex;setoutput\\'%s\\'\" , ( buf , L_BUFSIZE , \"setlogscalex\" ) ( buf , L_BUFSIZE , \"setlogscaley\" ) ( buf , L_BUFSIZE , \"plot\\'%s\\'title\\'%s\\'%s\" , ( buf , L_BUFSIZE , \"plot\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , ( buf , L_BUFSIZE , \"\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , ( buf , L_BUFSIZE , \"\\'%s\\'title\\'%s\\'%s\" ,\n", "\n", "Sources:\n", "0: CWE-119 l_int32 gplotGenCommandFile ( GPLOT * gplot ) { char buf [ L_BUF_SIZE ] ; char * cmdstr , * plottitle , * dataname ; l_int32 i , plotstyle , nplots ; FILE * fp ; PROCNAME ( \"gplotGenCommandFile\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; sarrayClear ( gplot -> cmddata ) ; if ( gplot -> title ) { snprintf ( buf , L_BUF_SIZE , \"settitle\\'%s\\'\" , gplot -> title ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> xlabel ) { snprintf ( buf , L_BUF_SIZE , \"setxlabel\\'%s\\'\" , gplot -> xlabel ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> ylabel ) { snprintf ( buf , L_BUF_SIZE , \"setylabel\\'%s\\'\" , gplot -> ylabel ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> outformat == GPLOT_PNG ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpng;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_PS ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpostscript;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_EPS ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpostscripteps;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_LATEX ) { snprintf ( buf , L_BUF_SIZE , \"setterminallatex;setoutput\\'%s\\'\" , gplot -> outname ) ; } sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; if ( gplot -> scaling == GPLOT_LOG_SCALE_X || gplot -> scaling == GPLOT_LOG_SCALE_X_Y ) { snprintf ( buf , L_BUF_SIZE , \"setlogscalex\" ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> scaling == GPLOT_LOG_SCALE_Y || gplot -> scaling == GPLOT_LOG_SCALE_X_Y ) { snprintf ( buf , L_BUF_SIZE , \"setlogscaley\" ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } nplots = sarrayGetCount ( gplot -> datanames ) ; for ( i = 0 ; i < nplots ; i ++ ) { plottitle = sarrayGetString ( gplot -> plottitles , i , L_NOCOPY ) ; dataname = sarrayGetString ( gplot -> datanames , i , L_NOCOPY ) ; numaGetIValue ( gplot -> plotstyles , i , & plotstyle ) ; if ( nplots == 1 ) { snprintf ( buf , L_BUF_SIZE , \"plot\\'%s\\'title\\'%s\\'%s\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; } else { if ( i == 0 ) snprintf ( buf , L_BUF_SIZE , \"plot\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; else if ( i < nplots - 1 ) snprintf ( buf , L_BUF_SIZE , \"\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; else snprintf ( buf , L_BUF_SIZE , \"\\'%s\\'title\\'%s\\'%s\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; } sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } cmdstr = sarrayToString ( gplot -> cmddata , 1 ) ; if ( ( fp = fopenWriteStream ( gplot -> cmdname , \"w\" ) ) == NULL ) { LEPT_FREE ( cmdstr ) ; return ERROR_INT ( \"cmdstreamnotopened\" , procName , 1 ) ; } fwrite ( cmdstr , 1 , strlen ( cmdstr ) , fp ) ; fclose ( fp ) ; LEPT_FREE ( cmdstr ) ; return 0 ; }\n", "\n", "1: CWE-787 l_int32 gplotGenCommandFile ( GPLOT * gplot ) { char buf [ L_BUF_SIZE ] ; char * cmdstr , * plottitle , * dataname ; l_int32 i , plotstyle , nplots ; FILE * fp ; PROCNAME ( \"gplotGenCommandFile\" ) ; if ( ! gplot ) return ERROR_INT ( \"gplotnotdefined\" , procName , 1 ) ; sarrayClear ( gplot -> cmddata ) ; if ( gplot -> title ) { snprintf ( buf , L_BUF_SIZE , \"settitle\\'%s\\'\" , gplot -> title ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> xlabel ) { snprintf ( buf , L_BUF_SIZE , \"setxlabel\\'%s\\'\" , gplot -> xlabel ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> ylabel ) { snprintf ( buf , L_BUF_SIZE , \"setylabel\\'%s\\'\" , gplot -> ylabel ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> outformat == GPLOT_PNG ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpng;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_PS ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpostscript;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_EPS ) { snprintf ( buf , L_BUF_SIZE , \"setterminalpostscripteps;setoutput\\'%s\\'\" , gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_LATEX ) { snprintf ( buf , L_BUF_SIZE , \"setterminallatex;setoutput\\'%s\\'\" , gplot -> outname ) ; } sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; if ( gplot -> scaling == GPLOT_LOG_SCALE_X || gplot -> scaling == GPLOT_LOG_SCALE_X_Y ) { snprintf ( buf , L_BUF_SIZE , \"setlogscalex\" ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } if ( gplot -> scaling == GPLOT_LOG_SCALE_Y || gplot -> scaling == GPLOT_LOG_SCALE_X_Y ) { snprintf ( buf , L_BUF_SIZE , \"setlogscaley\" ) ; sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } nplots = sarrayGetCount ( gplot -> datanames ) ; for ( i = 0 ; i < nplots ; i ++ ) { plottitle = sarrayGetString ( gplot -> plottitles , i , L_NOCOPY ) ; dataname = sarrayGetString ( gplot -> datanames , i , L_NOCOPY ) ; numaGetIValue ( gplot -> plotstyles , i , & plotstyle ) ; if ( nplots == 1 ) { snprintf ( buf , L_BUF_SIZE , \"plot\\'%s\\'title\\'%s\\'%s\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; } else { if ( i == 0 ) snprintf ( buf , L_BUF_SIZE , \"plot\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; else if ( i < nplots - 1 ) snprintf ( buf , L_BUF_SIZE , \"\\'%s\\'title\\'%s\\'%s,\\\\\\\\\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; else snprintf ( buf , L_BUF_SIZE , \"\\'%s\\'title\\'%s\\'%s\" , dataname , plottitle , gplotstylenames [ plotstyle ] ) ; } sarrayAddString ( gplot -> cmddata , buf , L_COPY ) ; } cmdstr = sarrayToString ( gplot -> cmddata , 1 ) ; if ( ( fp = fopenWriteStream ( gplot -> cmdname , \"w\" ) ) == NULL ) { LEPT_FREE ( cmdstr ) ; return ERROR_INT ( \"cmdstreamnotopened\" , procName , 1 ) ; } fwrite ( cmdstr , 1 , strlen ( cmdstr ) , fp ) ; fclose ( fp ) ; LEPT_FREE ( cmdstr ) ; return 0 ; }\n", "\n", "\n", "Target: , p_data , p_total_data_size ,\n", "\n", "Sources:\n", "0: CWE-119 static OPJ_BOOL opj_j2k_write_first_tile_part ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , opj_stream_private_t * p_stream , struct opj_event_mgr * p_manager ) { OPJ_UINT32 l_nb_bytes_written = 0 ; OPJ_UINT32 l_current_nb_bytes_written ; OPJ_BYTE * l_begin_data = 00 ; opj_tcd_t * l_tcd = 00 ; opj_cp_t * l_cp = 00 ; l_tcd = p_j2k -> m_tcd ; l_cp = & ( p_j2k -> m_cp ) ; l_tcd -> cur_pino = 0 ; p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = 0 ; l_current_nb_bytes_written = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; if ( ! OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { # if 0 for ( compno = 1 ; compno < p_j2k -> m_private_image -> numcomps ; compno ++ ) { l_current_nb_bytes_written = 0 ; opj_j2k_write_coc_in_memory ( p_j2k , compno , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; opj_j2k_write_qcc_in_memory ( p_j2k , compno , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; } # endif if ( l_cp -> tcps [ p_j2k -> m_current_tile_number ] . numpocs ) { l_current_nb_bytes_written = 0 ; opj_j2k_write_poc_in_memory ( p_j2k , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; } } l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; * p_data_written = l_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_nb_bytes_written , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_nb_bytes_written ) ; } return OPJ_TRUE ; }\n", "\n", "1: CWE-787 static OPJ_BOOL opj_j2k_write_first_tile_part ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , opj_stream_private_t * p_stream , struct opj_event_mgr * p_manager ) { OPJ_UINT32 l_nb_bytes_written = 0 ; OPJ_UINT32 l_current_nb_bytes_written ; OPJ_BYTE * l_begin_data = 00 ; opj_tcd_t * l_tcd = 00 ; opj_cp_t * l_cp = 00 ; l_tcd = p_j2k -> m_tcd ; l_cp = & ( p_j2k -> m_cp ) ; l_tcd -> cur_pino = 0 ; p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = 0 ; l_current_nb_bytes_written = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; if ( ! OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { # if 0 for ( compno = 1 ; compno < p_j2k -> m_private_image -> numcomps ; compno ++ ) { l_current_nb_bytes_written = 0 ; opj_j2k_write_coc_in_memory ( p_j2k , compno , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; opj_j2k_write_qcc_in_memory ( p_j2k , compno , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; } # endif if ( l_cp -> tcps [ p_j2k -> m_current_tile_number ] . numpocs ) { l_current_nb_bytes_written = 0 ; opj_j2k_write_poc_in_memory ( p_j2k , p_data , & l_current_nb_bytes_written , p_manager ) ; l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; } } l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; * p_data_written = l_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_nb_bytes_written , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_nb_bytes_written ) ; } return OPJ_TRUE ; }\n", "\n", "\n", "Target: char buf [ 50 ] , *\n", "\n", "Sources:\n", "0: CWE-119 static void numtostr ( js_State * J , const char * fmt , int w , double n ) { char buf [ 32 ] , * e ; sprintf ( buf , fmt , w , n ) ; e = strchr ( buf , 'e' ) ; if ( e ) { int exp = atoi ( e + 1 ) ; sprintf ( e , \"e%+d\" , exp ) ; } js_pushstring ( J , buf ) ; }\n", "\n", "1: CWE-787 static void numtostr ( js_State * J , const char * fmt , int w , double n ) { char buf [ 32 ] , * e ; sprintf ( buf , fmt , w , n ) ; e = strchr ( buf , 'e' ) ; if ( e ) { int exp = atoi ( e + 1 ) ; sprintf ( e , \"e%+d\" , exp ) ; } js_pushstring ( J , buf ) ; }\n", "\n", "\n", "Target: ; cmd = kzalloc ( sizeof (\n", "\n", "Sources:\n", "0: CWE-908 static int kvaser_usb_leaf_set_opt_mode ( const struct kvaser_usb_net_priv * priv ) { struct kvaser_cmd * cmd ; int rc ; cmd = kmalloc ( sizeof ( * cmd ) , GFP_KERNEL ) ; if ( ! cmd ) return - ENOMEM ; cmd -> id = CMD_SET_CTRL_MODE ; cmd -> len = CMD_HEADER_LEN + sizeof ( struct kvaser_cmd_ctrl_mode ) ; cmd -> u . ctrl_mode . tid = 0xff ; cmd -> u . ctrl_mode . channel = priv -> channel ; if ( priv -> can . ctrlmode & CAN_CTRLMODE_LISTENONLY ) cmd -> u . ctrl_mode . ctrl_mode = KVASER_CTRL_MODE_SILENT ; else cmd -> u . ctrl_mode . ctrl_mode = KVASER_CTRL_MODE_NORMAL ; rc = kvaser_usb_send_cmd ( priv -> dev , cmd , cmd -> len ) ; kfree ( cmd ) ; return rc ; }\n", "\n", "1: CWE-908 static int kvaser_usb_leaf_simple_cmd_async ( struct kvaser_usb_net_priv * priv , u8 cmd_id ) { struct kvaser_cmd * cmd ; int err ; cmd = kmalloc ( sizeof ( * cmd ) , GFP_ATOMIC ) ; if ( ! cmd ) return - ENOMEM ; cmd -> len = CMD_HEADER_LEN + sizeof ( struct kvaser_cmd_simple ) ; cmd -> id = cmd_id ; cmd -> u . simple . channel = priv -> channel ; err = kvaser_usb_send_cmd_async ( priv , cmd , cmd -> len ) ; if ( err ) kfree ( cmd ) ; return err ; }\n", "\n", "2: CWE-908 static int kvaser_usb_leaf_flush_queue ( struct kvaser_usb_net_priv * priv ) { struct kvaser_cmd * cmd ; int rc ; cmd = kmalloc ( sizeof ( * cmd ) , GFP_KERNEL ) ; if ( ! cmd ) return - ENOMEM ; cmd -> id = CMD_FLUSH_QUEUE ; cmd -> len = CMD_HEADER_LEN + sizeof ( struct kvaser_cmd_flush_queue ) ; cmd -> u . flush_queue . channel = priv -> channel ; cmd -> u . flush_queue . flags = 0x00 ; rc = kvaser_usb_send_cmd ( priv -> dev , cmd , cmd -> len ) ; kfree ( cmd ) ; return rc ; }\n", "\n", "\n", "Target: , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if\n", "\n", "Sources:\n", "0: CWE-000 static int load_state_from_tss16 ( struct x86_emulate_ctxt * ctxt , struct tss_segment_16 * tss ) { int ret ; u8 cpl ; ctxt -> _eip = tss -> ip ; ctxt -> eflags = tss -> flag | 2 ; * reg_write ( ctxt , VCPU_REGS_RAX ) = tss -> ax ; * reg_write ( ctxt , VCPU_REGS_RCX ) = tss -> cx ; * reg_write ( ctxt , VCPU_REGS_RDX ) = tss -> dx ; * reg_write ( ctxt , VCPU_REGS_RBX ) = tss -> bx ; * reg_write ( ctxt , VCPU_REGS_RSP ) = tss -> sp ; * reg_write ( ctxt , VCPU_REGS_RBP ) = tss -> bp ; * reg_write ( ctxt , VCPU_REGS_RSI ) = tss -> si ; * reg_write ( ctxt , VCPU_REGS_RDI ) = tss -> di ; set_segment_selector ( ctxt , tss -> ldt , VCPU_SREG_LDTR ) ; set_segment_selector ( ctxt , tss -> es , VCPU_SREG_ES ) ; set_segment_selector ( ctxt , tss -> cs , VCPU_SREG_CS ) ; set_segment_selector ( ctxt , tss -> ss , VCPU_SREG_SS ) ; set_segment_selector ( ctxt , tss -> ds , VCPU_SREG_DS ) ; cpl = tss -> cs & 3 ; ret = __load_segment_descriptor ( ctxt , tss -> ldt , VCPU_SREG_LDTR , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> es , VCPU_SREG_ES , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> cs , VCPU_SREG_CS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ss , VCPU_SREG_SS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ds , VCPU_SREG_DS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-264 static int load_state_from_tss16 ( struct x86_emulate_ctxt * ctxt , struct tss_segment_16 * tss ) { int ret ; u8 cpl ; ctxt -> _eip = tss -> ip ; ctxt -> eflags = tss -> flag | 2 ; * reg_write ( ctxt , VCPU_REGS_RAX ) = tss -> ax ; * reg_write ( ctxt , VCPU_REGS_RCX ) = tss -> cx ; * reg_write ( ctxt , VCPU_REGS_RDX ) = tss -> dx ; * reg_write ( ctxt , VCPU_REGS_RBX ) = tss -> bx ; * reg_write ( ctxt , VCPU_REGS_RSP ) = tss -> sp ; * reg_write ( ctxt , VCPU_REGS_RBP ) = tss -> bp ; * reg_write ( ctxt , VCPU_REGS_RSI ) = tss -> si ; * reg_write ( ctxt , VCPU_REGS_RDI ) = tss -> di ; set_segment_selector ( ctxt , tss -> ldt , VCPU_SREG_LDTR ) ; set_segment_selector ( ctxt , tss -> es , VCPU_SREG_ES ) ; set_segment_selector ( ctxt , tss -> cs , VCPU_SREG_CS ) ; set_segment_selector ( ctxt , tss -> ss , VCPU_SREG_SS ) ; set_segment_selector ( ctxt , tss -> ds , VCPU_SREG_DS ) ; cpl = tss -> cs & 3 ; ret = __load_segment_descriptor ( ctxt , tss -> ldt , VCPU_SREG_LDTR , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> es , VCPU_SREG_ES , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> cs , VCPU_SREG_CS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ss , VCPU_SREG_SS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ds , VCPU_SREG_DS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: = MagickFalse ; break ; } image\n", "\n", "Sources:\n", "0: CWE-401 static Image * ReadBMPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { BMPInfo bmp_info ; Image * image ; MagickBooleanType status ; MagickOffsetType offset , profile_data , profile_size , start_position ; MemoryInfo * pixel_info ; Quantum index ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bit , bytes_per_line , length ; ssize_t count , y ; unsigned char magick [ 12 ] , * pixels ; unsigned int blue , green , offset_bits , red ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( & bmp_info , 0 , sizeof ( bmp_info ) ) ; bmp_info . ba_offset = 0 ; start_position = 0 ; offset_bits = 0 ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { PixelInfo quantum_bits ; PixelPacket shift ; start_position = TellBlob ( image ) - 2 ; bmp_info . ba_offset = 0 ; while ( LocaleNCompare ( ( char * ) magick , \"BA\" , 2 ) == 0 ) { bmp_info . file_size = ReadBlobLSBLong ( image ) ; bmp_info . ba_offset = ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) break ; } if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Magick:%c%c\" , magick [ 0 ] , magick [ 1 ] ) ; if ( ( count != 2 ) || ( ( LocaleNCompare ( ( char * ) magick , \"BM\" , 2 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , \"CI\" , 2 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; bmp_info . file_size = ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; bmp_info . size = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"BMPsize:%u\" , bmp_info . size ) ; profile_data = 0 ; profile_size = 0 ; if ( bmp_info . size == 12 ) { ( void ) CopyMagickString ( image -> magick , \"BMP2\" , MagickPathExtent ) ; bmp_info . width = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . x_pixels = 0 ; bmp_info . y_pixels = 0 ; bmp_info . number_colors = 0 ; bmp_info . compression = BI_RGB ; bmp_info . image_size = 0 ; bmp_info . alpha_mask = 0 ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:OS/2Bitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; } } else { if ( bmp_info . size < 40 ) ThrowReaderException ( CorruptImageError , \"NonOS2HeaderSizeError\" ) ; bmp_info . width = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . height = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . compression = ReadBlobLSBLong ( image ) ; bmp_info . image_size = ReadBlobLSBLong ( image ) ; bmp_info . x_pixels = ReadBlobLSBLong ( image ) ; bmp_info . y_pixels = ReadBlobLSBLong ( image ) ; bmp_info . number_colors = ReadBlobLSBLong ( image ) ; if ( ( MagickSizeType ) bmp_info . number_colors > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; bmp_info . colors_important = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:MSWindowsbitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Bitsperpixel:%.20g\" , ( double ) bmp_info . bits_per_pixel ) ; switch ( bmp_info . compression ) { case BI_RGB : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RGB\" ) ; break ; } case BI_RLE4 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE4\" ) ; break ; } case BI_RLE8 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE8\" ) ; break ; } case BI_BITFIELDS : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_BITFIELDS\" ) ; break ; } case BI_PNG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_PNG\" ) ; break ; } case BI_JPEG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_JPEG\" ) ; break ; } default : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:UNKNOWN(%u)\" , bmp_info . compression ) ; } } ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Numberofcolors:%u\" , bmp_info . number_colors ) ; } bmp_info . red_mask = ReadBlobLSBLong ( image ) ; bmp_info . green_mask = ReadBlobLSBLong ( image ) ; bmp_info . blue_mask = ReadBlobLSBLong ( image ) ; if ( bmp_info . size > 40 ) { double gamma ; bmp_info . alpha_mask = ReadBlobLSBLong ( image ) ; bmp_info . colorspace = ReadBlobLSBSignedLong ( image ) ; # define BMP_DENOM ( ( double ) 0x40000000 ) bmp_info . red_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; gamma = bmp_info . red_primary . x + bmp_info . red_primary . y + bmp_info . red_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . red_primary . x *= gamma ; bmp_info . red_primary . y *= gamma ; image -> chromaticity . red_primary . x = bmp_info . red_primary . x ; image -> chromaticity . red_primary . y = bmp_info . red_primary . y ; gamma = bmp_info . green_primary . x + bmp_info . green_primary . y + bmp_info . green_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . green_primary . x *= gamma ; bmp_info . green_primary . y *= gamma ; image -> chromaticity . green_primary . x = bmp_info . green_primary . x ; image -> chromaticity . green_primary . y = bmp_info . green_primary . y ; gamma = bmp_info . blue_primary . x + bmp_info . blue_primary . y + bmp_info . blue_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . blue_primary . x *= gamma ; bmp_info . blue_primary . y *= gamma ; image -> chromaticity . blue_primary . x = bmp_info . blue_primary . x ; image -> chromaticity . blue_primary . y = bmp_info . blue_primary . y ; bmp_info . gamma_scale . x = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . y = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . z = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; image -> gamma = ( bmp_info . gamma_scale . x + bmp_info . gamma_scale . y + bmp_info . gamma_scale . z ) / 3.0 ; } else ( void ) CopyMagickString ( image -> magick , \"BMP3\" , MagickPathExtent ) ; if ( bmp_info . size > 108 ) { size_t intent ; intent = ReadBlobLSBLong ( image ) ; switch ( ( int ) intent ) { case LCS_GM_BUSINESS : { image -> rendering_intent = SaturationIntent ; break ; } case LCS_GM_GRAPHICS : { image -> rendering_intent = RelativeIntent ; break ; } case LCS_GM_IMAGES : { image -> rendering_intent = PerceptualIntent ; break ; } case LCS_GM_ABS_COLORIMETRIC : { image -> rendering_intent = AbsoluteIntent ; break ; } } profile_data = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; profile_size = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; } } if ( ( MagickSizeType ) bmp_info . file_size > GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; else if ( ( MagickSizeType ) bmp_info . file_size < GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageWarning , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; if ( bmp_info . width <= 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . height == 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . planes != 1 ) ThrowReaderException ( CorruptImageError , \"StaticPlanesValueNotEqualToOne\" ) ; if ( ( bmp_info . bits_per_pixel != 1 ) && ( bmp_info . bits_per_pixel != 4 ) && ( bmp_info . bits_per_pixel != 8 ) && ( bmp_info . bits_per_pixel != 16 ) && ( bmp_info . bits_per_pixel != 24 ) && ( bmp_info . bits_per_pixel != 32 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( bmp_info . bits_per_pixel < 16 && bmp_info . number_colors > ( 1U << bmp_info . bits_per_pixel ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedNumberOfColors\" ) ; if ( ( bmp_info . compression == 1 ) && ( bmp_info . bits_per_pixel != 8 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 2 ) && ( bmp_info . bits_per_pixel != 4 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 3 ) && ( bmp_info . bits_per_pixel < 16 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; switch ( bmp_info . compression ) { case BI_RGB : image -> compression = NoCompression ; break ; case BI_RLE8 : case BI_RLE4 : image -> compression = RLECompression ; break ; case BI_BITFIELDS : break ; case BI_JPEG : ThrowReaderException ( CoderError , \"JPEGCompressNotSupported\" ) ; case BI_PNG : ThrowReaderException ( CoderError , \"PNGCompressNotSupported\" ) ; default : ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } image -> columns = ( size_t ) MagickAbsoluteValue ( bmp_info . width ) ; image -> rows = ( size_t ) MagickAbsoluteValue ( bmp_info . height ) ; image -> depth = bmp_info . bits_per_pixel <= 8 ? bmp_info . bits_per_pixel : 8 ; image -> alpha_trait = ( ( bmp_info . alpha_mask != 0 ) && ( bmp_info . compression == BI_BITFIELDS ) ) ? BlendPixelTrait : UndefinedPixelTrait ; if ( bmp_info . bits_per_pixel < 16 ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = bmp_info . number_colors ; one = 1 ; if ( image -> colors == 0 ) image -> colors = one << bmp_info . bits_per_pixel ; } image -> resolution . x = ( double ) bmp_info . x_pixels / 100.0 ; image -> resolution . y = ( double ) bmp_info . y_pixels / 100.0 ; image -> units = PixelsPerCentimeterResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> storage_class == PseudoClass ) { unsigned char * bmp_colormap ; size_t packet_size ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingcolormapof%.20gcolors\" , ( double ) image -> colors ) ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; bmp_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) image -> colors , 4 * sizeof ( * bmp_colormap ) ) ; if ( bmp_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( bmp_info . size == 12 ) || ( bmp_info . size == 64 ) ) packet_size = 3 ; else packet_size = 4 ; offset = SeekBlob ( image , start_position + 14 + bmp_info . size , SEEK_SET ) ; if ( offset < 0 ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } count = ReadBlob ( image , packet_size * image -> colors , bmp_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } p = bmp_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; } if ( bmp_info . offset_bits == offset_bits ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; offset_bits = bmp_info . offset_bits ; offset = SeekBlob ( image , start_position + bmp_info . offset_bits , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( bmp_info . compression == BI_RLE4 ) bmp_info . bits_per_pixel <<= 1 ; bytes_per_line = 4 * ( ( image -> columns * bmp_info . bits_per_pixel + 31 ) / 32 ) ; length = ( size_t ) bytes_per_line * image -> rows ; if ( ( MagickSizeType ) ( length / 256 ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ( bmp_info . compression == BI_RGB ) || ( bmp_info . compression == BI_BITFIELDS ) ) { pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingpixels(%.20gbytes)\" , ( double ) length ) ; count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } } else { pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; status = DecodeImage ( image , bmp_info . compression , pixels , image -> columns * image -> rows ) ; if ( status == MagickFalse ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToRunlengthDecodeImage\" ) ; } } if ( bmp_info . compression == BI_RGB ) { if ( ( image -> alpha_trait == UndefinedPixelTrait ) && ( bmp_info . size == 40 ) && ( bmp_info . bits_per_pixel == 32 ) ) { bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( * ( p + 3 ) != 0 ) { image -> alpha_trait = BlendPixelTrait ; y = - 1 ; break ; } p += 4 ; } } } bmp_info . alpha_mask = image -> alpha_trait != UndefinedPixelTrait ? 0xff000000U : 0U ; bmp_info . red_mask = 0x00ff0000U ; bmp_info . green_mask = 0x0000ff00U ; bmp_info . blue_mask = 0x000000ffU ; if ( bmp_info . bits_per_pixel == 16 ) { bmp_info . red_mask = 0x00007c00U ; bmp_info . green_mask = 0x000003e0U ; bmp_info . blue_mask = 0x0000001fU ; } } ( void ) memset ( & shift , 0 , sizeof ( shift ) ) ; ( void ) memset ( & quantum_bits , 0 , sizeof ( quantum_bits ) ) ; if ( ( bmp_info . bits_per_pixel == 16 ) || ( bmp_info . bits_per_pixel == 32 ) ) { register unsigned int sample ; if ( bmp_info . red_mask != 0 ) while ( ( ( bmp_info . red_mask << shift . red ) & 0x80000000UL ) == 0 ) { shift . red ++ ; if ( shift . red >= 32U ) break ; } if ( bmp_info . green_mask != 0 ) while ( ( ( bmp_info . green_mask << shift . green ) & 0x80000000UL ) == 0 ) { shift . green ++ ; if ( shift . green >= 32U ) break ; } if ( bmp_info . blue_mask != 0 ) while ( ( ( bmp_info . blue_mask << shift . blue ) & 0x80000000UL ) == 0 ) { shift . blue ++ ; if ( shift . blue >= 32U ) break ; } if ( bmp_info . alpha_mask != 0 ) while ( ( ( bmp_info . alpha_mask << shift . alpha ) & 0x80000000UL ) == 0 ) { shift . alpha ++ ; if ( shift . alpha >= 32U ) break ; } sample = shift . red ; while ( ( ( bmp_info . red_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . red = ( MagickRealType ) ( sample - shift . red ) ; sample = shift . green ; while ( ( ( bmp_info . green_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . green = ( MagickRealType ) ( sample - shift . green ) ; sample = shift . blue ; while ( ( ( bmp_info . blue_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . blue = ( MagickRealType ) ( sample - shift . blue ) ; sample = shift . alpha ; while ( ( ( bmp_info . alpha_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . alpha = ( MagickRealType ) ( sample - shift . alpha ) ; } switch ( bmp_info . bits_per_pixel ) { case 1 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 4 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; ValidateColormapValue ( image , ( ssize_t ) ( * p & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0xf ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; x ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 8 : { if ( ( bmp_info . compression == BI_RLE8 ) || ( bmp_info . compression == BI_RLE4 ) ) bytes_per_line = image -> columns ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = ( ssize_t ) image -> columns ; x != 0 ; -- x ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 16 : { unsigned int alpha , pixel ; if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 2 * ( image -> columns + image -> columns % 2 ) ; image -> storage_class = DirectClass ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( * p ++ ) << 8 ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 5 ) red |= ( ( red & 0xe000 ) >> 5 ) ; if ( quantum_bits . red <= 8 ) red |= ( ( red & 0xff00 ) >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 5 ) green |= ( ( green & 0xe000 ) >> 5 ) ; if ( quantum_bits . green == 6 ) green |= ( ( green & 0xc000 ) >> 6 ) ; if ( quantum_bits . green <= 8 ) green |= ( ( green & 0xff00 ) >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 5 ) blue |= ( ( blue & 0xe000 ) >> 5 ) ; if ( quantum_bits . blue <= 8 ) blue |= ( ( blue & 0xff00 ) >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha <= 8 ) alpha |= ( ( alpha & 0xff00 ) >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 24 : { bytes_per_line = 4 * ( ( image -> columns * 24 + 31 ) / 32 ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 32 : { if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { unsigned int alpha , pixel ; p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( ( unsigned int ) * p ++ << 8 ) ; pixel |= ( ( unsigned int ) * p ++ << 16 ) ; pixel |= ( ( unsigned int ) * p ++ << 24 ) ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 8 ) red |= ( red >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 8 ) green |= ( green >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 8 ) blue |= ( blue >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha == 8 ) alpha |= ( alpha >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } default : { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( y > 0 ) break ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( bmp_info . height < 0 ) { Image * flipped_image ; flipped_image = FlipImage ( image , exception ) ; if ( flipped_image != ( Image * ) NULL ) { DuplicateBlob ( flipped_image , image ) ; ReplaceImageInList ( & image , flipped_image ) ; image = flipped_image ; } } if ( ( bmp_info . colorspace == 0x4D424544L ) && ( profile_data > 0 ) && ( profile_size > 0 ) ) { StringInfo * profile ; unsigned char * datum ; offset = start_position + 14 + profile_data ; if ( ( offset < TellBlob ( image ) ) || ( SeekBlob ( image , offset , SEEK_SET ) != offset ) || ( GetBlobSize ( image ) < ( MagickSizeType ) ( offset + profile_size ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; profile = AcquireStringInfo ( ( size_t ) profile_size ) ; if ( profile == ( StringInfo * ) NULL ) ThrowReaderException ( CorruptImageError , \"MemoryAllocationFailed\" ) ; datum = GetStringInfoDatum ( profile ) ; if ( ReadBlob ( image , ( size_t ) profile_size , datum ) == ( ssize_t ) profile_size ) { MagickOffsetType profile_size_orig ; profile_size_orig = ( MagickOffsetType ) datum [ 0 ] << 24 ; profile_size_orig |= ( MagickOffsetType ) datum [ 1 ] << 16 ; profile_size_orig |= ( MagickOffsetType ) datum [ 2 ] << 8 ; profile_size_orig |= ( MagickOffsetType ) datum [ 3 ] ; if ( profile_size_orig < profile_size ) SetStringInfoLength ( profile , ( size_t ) profile_size_orig ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Profile:ICC,%ubytes\" , ( unsigned int ) profile_size_orig ) ; ( void ) SetImageProfile ( image , \"icc\" , profile , exception ) ; } profile = DestroyStringInfo ( profile ) ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; offset = ( MagickOffsetType ) bmp_info . ba_offset ; if ( offset != 0 ) if ( ( offset < TellBlob ( image ) ) || ( SeekBlob ( image , offset , SEEK_SET ) != offset ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; * magick = '\\\\0' ; count = ReadBlob ( image , 2 , magick ) ; if ( ( count == 2 ) && ( IsBMP ( magick , 2 ) != MagickFalse ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( IsBMP ( magick , 2 ) != MagickFalse ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-399 static Image * ReadBMPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { BMPInfo bmp_info ; Image * image ; MagickBooleanType status ; MagickOffsetType offset , profile_data , profile_size , start_position ; MemoryInfo * pixel_info ; Quantum index ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bit , bytes_per_line , length ; ssize_t count , y ; unsigned char magick [ 12 ] , * pixels ; unsigned int blue , green , offset_bits , red ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( & bmp_info , 0 , sizeof ( bmp_info ) ) ; bmp_info . ba_offset = 0 ; start_position = 0 ; offset_bits = 0 ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { PixelInfo quantum_bits ; PixelPacket shift ; start_position = TellBlob ( image ) - 2 ; bmp_info . ba_offset = 0 ; while ( LocaleNCompare ( ( char * ) magick , \"BA\" , 2 ) == 0 ) { bmp_info . file_size = ReadBlobLSBLong ( image ) ; bmp_info . ba_offset = ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) break ; } if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Magick:%c%c\" , magick [ 0 ] , magick [ 1 ] ) ; if ( ( count != 2 ) || ( ( LocaleNCompare ( ( char * ) magick , \"BM\" , 2 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , \"CI\" , 2 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; bmp_info . file_size = ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; bmp_info . size = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"BMPsize:%u\" , bmp_info . size ) ; profile_data = 0 ; profile_size = 0 ; if ( bmp_info . size == 12 ) { ( void ) CopyMagickString ( image -> magick , \"BMP2\" , MagickPathExtent ) ; bmp_info . width = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . x_pixels = 0 ; bmp_info . y_pixels = 0 ; bmp_info . number_colors = 0 ; bmp_info . compression = BI_RGB ; bmp_info . image_size = 0 ; bmp_info . alpha_mask = 0 ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:OS/2Bitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; } } else { if ( bmp_info . size < 40 ) ThrowReaderException ( CorruptImageError , \"NonOS2HeaderSizeError\" ) ; bmp_info . width = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . height = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . compression = ReadBlobLSBLong ( image ) ; bmp_info . image_size = ReadBlobLSBLong ( image ) ; bmp_info . x_pixels = ReadBlobLSBLong ( image ) ; bmp_info . y_pixels = ReadBlobLSBLong ( image ) ; bmp_info . number_colors = ReadBlobLSBLong ( image ) ; if ( ( MagickSizeType ) bmp_info . number_colors > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; bmp_info . colors_important = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Format:MSWindowsbitmap\" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Geometry:%.20gx%.20g\" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Bitsperpixel:%.20g\" , ( double ) bmp_info . bits_per_pixel ) ; switch ( bmp_info . compression ) { case BI_RGB : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RGB\" ) ; break ; } case BI_RLE4 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE4\" ) ; break ; } case BI_RLE8 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_RLE8\" ) ; break ; } case BI_BITFIELDS : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_BITFIELDS\" ) ; break ; } case BI_PNG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_PNG\" ) ; break ; } case BI_JPEG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:BI_JPEG\" ) ; break ; } default : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Compression:UNKNOWN(%u)\" , bmp_info . compression ) ; } } ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Numberofcolors:%u\" , bmp_info . number_colors ) ; } bmp_info . red_mask = ReadBlobLSBLong ( image ) ; bmp_info . green_mask = ReadBlobLSBLong ( image ) ; bmp_info . blue_mask = ReadBlobLSBLong ( image ) ; if ( bmp_info . size > 40 ) { double gamma ; bmp_info . alpha_mask = ReadBlobLSBLong ( image ) ; bmp_info . colorspace = ReadBlobLSBSignedLong ( image ) ; # define BMP_DENOM ( ( double ) 0x40000000 ) bmp_info . red_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; gamma = bmp_info . red_primary . x + bmp_info . red_primary . y + bmp_info . red_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . red_primary . x *= gamma ; bmp_info . red_primary . y *= gamma ; image -> chromaticity . red_primary . x = bmp_info . red_primary . x ; image -> chromaticity . red_primary . y = bmp_info . red_primary . y ; gamma = bmp_info . green_primary . x + bmp_info . green_primary . y + bmp_info . green_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . green_primary . x *= gamma ; bmp_info . green_primary . y *= gamma ; image -> chromaticity . green_primary . x = bmp_info . green_primary . x ; image -> chromaticity . green_primary . y = bmp_info . green_primary . y ; gamma = bmp_info . blue_primary . x + bmp_info . blue_primary . y + bmp_info . blue_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . blue_primary . x *= gamma ; bmp_info . blue_primary . y *= gamma ; image -> chromaticity . blue_primary . x = bmp_info . blue_primary . x ; image -> chromaticity . blue_primary . y = bmp_info . blue_primary . y ; bmp_info . gamma_scale . x = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . y = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . z = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; image -> gamma = ( bmp_info . gamma_scale . x + bmp_info . gamma_scale . y + bmp_info . gamma_scale . z ) / 3.0 ; } else ( void ) CopyMagickString ( image -> magick , \"BMP3\" , MagickPathExtent ) ; if ( bmp_info . size > 108 ) { size_t intent ; intent = ReadBlobLSBLong ( image ) ; switch ( ( int ) intent ) { case LCS_GM_BUSINESS : { image -> rendering_intent = SaturationIntent ; break ; } case LCS_GM_GRAPHICS : { image -> rendering_intent = RelativeIntent ; break ; } case LCS_GM_IMAGES : { image -> rendering_intent = PerceptualIntent ; break ; } case LCS_GM_ABS_COLORIMETRIC : { image -> rendering_intent = AbsoluteIntent ; break ; } } profile_data = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; profile_size = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; } } if ( ( MagickSizeType ) bmp_info . file_size > GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; else if ( ( MagickSizeType ) bmp_info . file_size < GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageWarning , \"LengthAndFilesizeDoNotMatch\" , \"`%s\\'\" , image -> filename ) ; if ( bmp_info . width <= 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . height == 0 ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; if ( bmp_info . planes != 1 ) ThrowReaderException ( CorruptImageError , \"StaticPlanesValueNotEqualToOne\" ) ; if ( ( bmp_info . bits_per_pixel != 1 ) && ( bmp_info . bits_per_pixel != 4 ) && ( bmp_info . bits_per_pixel != 8 ) && ( bmp_info . bits_per_pixel != 16 ) && ( bmp_info . bits_per_pixel != 24 ) && ( bmp_info . bits_per_pixel != 32 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( bmp_info . bits_per_pixel < 16 && bmp_info . number_colors > ( 1U << bmp_info . bits_per_pixel ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedNumberOfColors\" ) ; if ( ( bmp_info . compression == 1 ) && ( bmp_info . bits_per_pixel != 8 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 2 ) && ( bmp_info . bits_per_pixel != 4 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; if ( ( bmp_info . compression == 3 ) && ( bmp_info . bits_per_pixel < 16 ) ) ThrowReaderException ( CorruptImageError , \"UnsupportedBitsPerPixel\" ) ; switch ( bmp_info . compression ) { case BI_RGB : image -> compression = NoCompression ; break ; case BI_RLE8 : case BI_RLE4 : image -> compression = RLECompression ; break ; case BI_BITFIELDS : break ; case BI_JPEG : ThrowReaderException ( CoderError , \"JPEGCompressNotSupported\" ) ; case BI_PNG : ThrowReaderException ( CoderError , \"PNGCompressNotSupported\" ) ; default : ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } image -> columns = ( size_t ) MagickAbsoluteValue ( bmp_info . width ) ; image -> rows = ( size_t ) MagickAbsoluteValue ( bmp_info . height ) ; image -> depth = bmp_info . bits_per_pixel <= 8 ? bmp_info . bits_per_pixel : 8 ; image -> alpha_trait = ( ( bmp_info . alpha_mask != 0 ) && ( bmp_info . compression == BI_BITFIELDS ) ) ? BlendPixelTrait : UndefinedPixelTrait ; if ( bmp_info . bits_per_pixel < 16 ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = bmp_info . number_colors ; one = 1 ; if ( image -> colors == 0 ) image -> colors = one << bmp_info . bits_per_pixel ; } image -> resolution . x = ( double ) bmp_info . x_pixels / 100.0 ; image -> resolution . y = ( double ) bmp_info . y_pixels / 100.0 ; image -> units = PixelsPerCentimeterResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> storage_class == PseudoClass ) { unsigned char * bmp_colormap ; size_t packet_size ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingcolormapof%.20gcolors\" , ( double ) image -> colors ) ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; bmp_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) image -> colors , 4 * sizeof ( * bmp_colormap ) ) ; if ( bmp_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( bmp_info . size == 12 ) || ( bmp_info . size == 64 ) ) packet_size = 3 ; else packet_size = 4 ; offset = SeekBlob ( image , start_position + 14 + bmp_info . size , SEEK_SET ) ; if ( offset < 0 ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } count = ReadBlob ( image , packet_size * image -> colors , bmp_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } p = bmp_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; } if ( bmp_info . offset_bits == offset_bits ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; offset_bits = bmp_info . offset_bits ; offset = SeekBlob ( image , start_position + bmp_info . offset_bits , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( bmp_info . compression == BI_RLE4 ) bmp_info . bits_per_pixel <<= 1 ; bytes_per_line = 4 * ( ( image -> columns * bmp_info . bits_per_pixel + 31 ) / 32 ) ; length = ( size_t ) bytes_per_line * image -> rows ; if ( ( MagickSizeType ) ( length / 256 ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ( bmp_info . compression == BI_RGB ) || ( bmp_info . compression == BI_BITFIELDS ) ) { pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Readingpixels(%.20gbytes)\" , ( double ) length ) ; count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } } else { pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; status = DecodeImage ( image , bmp_info . compression , pixels , image -> columns * image -> rows ) ; if ( status == MagickFalse ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToRunlengthDecodeImage\" ) ; } } if ( bmp_info . compression == BI_RGB ) { if ( ( image -> alpha_trait == UndefinedPixelTrait ) && ( bmp_info . size == 40 ) && ( bmp_info . bits_per_pixel == 32 ) ) { bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( * ( p + 3 ) != 0 ) { image -> alpha_trait = BlendPixelTrait ; y = - 1 ; break ; } p += 4 ; } } } bmp_info . alpha_mask = image -> alpha_trait != UndefinedPixelTrait ? 0xff000000U : 0U ; bmp_info . red_mask = 0x00ff0000U ; bmp_info . green_mask = 0x0000ff00U ; bmp_info . blue_mask = 0x000000ffU ; if ( bmp_info . bits_per_pixel == 16 ) { bmp_info . red_mask = 0x00007c00U ; bmp_info . green_mask = 0x000003e0U ; bmp_info . blue_mask = 0x0000001fU ; } } ( void ) memset ( & shift , 0 , sizeof ( shift ) ) ; ( void ) memset ( & quantum_bits , 0 , sizeof ( quantum_bits ) ) ; if ( ( bmp_info . bits_per_pixel == 16 ) || ( bmp_info . bits_per_pixel == 32 ) ) { register unsigned int sample ; if ( bmp_info . red_mask != 0 ) while ( ( ( bmp_info . red_mask << shift . red ) & 0x80000000UL ) == 0 ) { shift . red ++ ; if ( shift . red >= 32U ) break ; } if ( bmp_info . green_mask != 0 ) while ( ( ( bmp_info . green_mask << shift . green ) & 0x80000000UL ) == 0 ) { shift . green ++ ; if ( shift . green >= 32U ) break ; } if ( bmp_info . blue_mask != 0 ) while ( ( ( bmp_info . blue_mask << shift . blue ) & 0x80000000UL ) == 0 ) { shift . blue ++ ; if ( shift . blue >= 32U ) break ; } if ( bmp_info . alpha_mask != 0 ) while ( ( ( bmp_info . alpha_mask << shift . alpha ) & 0x80000000UL ) == 0 ) { shift . alpha ++ ; if ( shift . alpha >= 32U ) break ; } sample = shift . red ; while ( ( ( bmp_info . red_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . red = ( MagickRealType ) ( sample - shift . red ) ; sample = shift . green ; while ( ( ( bmp_info . green_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . green = ( MagickRealType ) ( sample - shift . green ) ; sample = shift . blue ; while ( ( ( bmp_info . blue_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . blue = ( MagickRealType ) ( sample - shift . blue ) ; sample = shift . alpha ; while ( ( ( bmp_info . alpha_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . alpha = ( MagickRealType ) ( sample - shift . alpha ) ; } switch ( bmp_info . bits_per_pixel ) { case 1 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 4 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; ValidateColormapValue ( image , ( ssize_t ) ( * p & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0xf ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; x ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 8 : { if ( ( bmp_info . compression == BI_RLE8 ) || ( bmp_info . compression == BI_RLE4 ) ) bytes_per_line = image -> columns ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = ( ssize_t ) image -> columns ; x != 0 ; -- x ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 16 : { unsigned int alpha , pixel ; if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 2 * ( image -> columns + image -> columns % 2 ) ; image -> storage_class = DirectClass ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( * p ++ ) << 8 ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 5 ) red |= ( ( red & 0xe000 ) >> 5 ) ; if ( quantum_bits . red <= 8 ) red |= ( ( red & 0xff00 ) >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 5 ) green |= ( ( green & 0xe000 ) >> 5 ) ; if ( quantum_bits . green == 6 ) green |= ( ( green & 0xc000 ) >> 6 ) ; if ( quantum_bits . green <= 8 ) green |= ( ( green & 0xff00 ) >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 5 ) blue |= ( ( blue & 0xe000 ) >> 5 ) ; if ( quantum_bits . blue <= 8 ) blue |= ( ( blue & 0xff00 ) >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha <= 8 ) alpha |= ( ( alpha & 0xff00 ) >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 24 : { bytes_per_line = 4 * ( ( image -> columns * 24 + 31 ) / 32 ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 32 : { if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; } bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { unsigned int alpha , pixel ; p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( ( unsigned int ) * p ++ << 8 ) ; pixel |= ( ( unsigned int ) * p ++ << 16 ) ; pixel |= ( ( unsigned int ) * p ++ << 24 ) ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 8 ) red |= ( red >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 8 ) green |= ( green >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 8 ) blue |= ( blue >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha == 8 ) alpha |= ( alpha >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } default : { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( y > 0 ) break ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( bmp_info . height < 0 ) { Image * flipped_image ; flipped_image = FlipImage ( image , exception ) ; if ( flipped_image != ( Image * ) NULL ) { DuplicateBlob ( flipped_image , image ) ; ReplaceImageInList ( & image , flipped_image ) ; image = flipped_image ; } } if ( ( bmp_info . colorspace == 0x4D424544L ) && ( profile_data > 0 ) && ( profile_size > 0 ) ) { StringInfo * profile ; unsigned char * datum ; offset = start_position + 14 + profile_data ; if ( ( offset < TellBlob ( image ) ) || ( SeekBlob ( image , offset , SEEK_SET ) != offset ) || ( GetBlobSize ( image ) < ( MagickSizeType ) ( offset + profile_size ) ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; profile = AcquireStringInfo ( ( size_t ) profile_size ) ; if ( profile == ( StringInfo * ) NULL ) ThrowReaderException ( CorruptImageError , \"MemoryAllocationFailed\" ) ; datum = GetStringInfoDatum ( profile ) ; if ( ReadBlob ( image , ( size_t ) profile_size , datum ) == ( ssize_t ) profile_size ) { MagickOffsetType profile_size_orig ; profile_size_orig = ( MagickOffsetType ) datum [ 0 ] << 24 ; profile_size_orig |= ( MagickOffsetType ) datum [ 1 ] << 16 ; profile_size_orig |= ( MagickOffsetType ) datum [ 2 ] << 8 ; profile_size_orig |= ( MagickOffsetType ) datum [ 3 ] ; if ( profile_size_orig < profile_size ) SetStringInfoLength ( profile , ( size_t ) profile_size_orig ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"Profile:ICC,%ubytes\" , ( unsigned int ) profile_size_orig ) ; ( void ) SetImageProfile ( image , \"icc\" , profile , exception ) ; } profile = DestroyStringInfo ( profile ) ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; offset = ( MagickOffsetType ) bmp_info . ba_offset ; if ( offset != 0 ) if ( ( offset < TellBlob ( image ) ) || ( SeekBlob ( image , offset , SEEK_SET ) != offset ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; * magick = '\\\\0' ; count = ReadBlob ( image , 2 , magick ) ; if ( ( count == 2 ) && ( IsBMP ( magick , 2 ) != MagickFalse ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( IsBMP ( magick , 2 ) != MagickFalse ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: * key ; } * pair\n", "\n", "Sources:\n", "0: CWE-416 void comps_rtree_unite ( COMPS_RTree * rt1 , COMPS_RTree * rt2 ) { COMPS_HSList * tmplist , * tmp_subnodes ; COMPS_HSListItem * it ; struct Pair { COMPS_HSList * subnodes ; char * key ; char added ; } * pair , * parent_pair ; pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = rt2 -> subnodes ; pair -> key = NULL ; tmplist = comps_hslist_create ( ) ; comps_hslist_init ( tmplist , NULL , NULL , & free ) ; comps_hslist_append ( tmplist , pair , 0 ) ; while ( tmplist -> first != NULL ) { it = tmplist -> first ; comps_hslist_remove ( tmplist , tmplist -> first ) ; tmp_subnodes = ( ( struct Pair * ) it -> data ) -> subnodes ; parent_pair = ( struct Pair * ) it -> data ; free ( it ) ; for ( it = tmp_subnodes -> first ; it != NULL ; it = it -> next ) { pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = ( ( COMPS_RTreeData * ) it -> data ) -> subnodes ; if ( parent_pair -> key != NULL ) { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_RTreeData * ) it -> data ) -> key ) + strlen ( parent_pair -> key ) + 1 ) ) ; memcpy ( pair -> key , parent_pair -> key , sizeof ( char ) * strlen ( parent_pair -> key ) ) ; memcpy ( pair -> key + strlen ( parent_pair -> key ) , ( ( COMPS_RTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_RTreeData * ) it -> data ) -> key ) + 1 ) ) ; } else { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_RTreeData * ) it -> data ) -> key ) + 1 ) ) ; memcpy ( pair -> key , ( ( COMPS_RTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_RTreeData * ) it -> data ) -> key ) + 1 ) ) ; } if ( ( ( COMPS_RTreeData * ) it -> data ) -> data != NULL ) { comps_rtree_set ( rt1 , pair -> key , rt2 -> data_cloner ( ( ( COMPS_RTreeData * ) it -> data ) -> data ) ) ; } if ( ( ( COMPS_RTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } free ( parent_pair -> key ) ; free ( parent_pair ) ; } comps_hslist_destroy ( & tmplist ) ; }\n", "\n", "1: CWE-416 void comps_objrtree_unite ( COMPS_ObjRTree * rt1 , COMPS_ObjRTree * rt2 ) { COMPS_HSList * tmplist , * tmp_subnodes ; COMPS_HSListItem * it ; struct Pair { COMPS_HSList * subnodes ; char * key ; char added ; } * pair , * parent_pair ; pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = rt2 -> subnodes ; pair -> key = NULL ; tmplist = comps_hslist_create ( ) ; comps_hslist_init ( tmplist , NULL , NULL , & free ) ; comps_hslist_append ( tmplist , pair , 0 ) ; while ( tmplist -> first != NULL ) { it = tmplist -> first ; comps_hslist_remove ( tmplist , tmplist -> first ) ; tmp_subnodes = ( ( struct Pair * ) it -> data ) -> subnodes ; parent_pair = ( struct Pair * ) it -> data ; free ( it ) ; for ( it = tmp_subnodes -> first ; it != NULL ; it = it -> next ) { pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = ( ( COMPS_ObjRTreeData * ) it -> data ) -> subnodes ; if ( parent_pair -> key != NULL ) { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> key ) + strlen ( parent_pair -> key ) + 1 ) ) ; memcpy ( pair -> key , parent_pair -> key , sizeof ( char ) * strlen ( parent_pair -> key ) ) ; memcpy ( pair -> key + strlen ( parent_pair -> key ) , ( ( COMPS_ObjRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } else { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> key ) + 1 ) ) ; memcpy ( pair -> key , ( ( COMPS_ObjRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } if ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> data != NULL ) { comps_objrtree_set ( rt1 , pair -> key , ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> data ) ) ; } if ( ( ( COMPS_ObjRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } free ( parent_pair -> key ) ; free ( parent_pair ) ; } comps_hslist_destroy ( & tmplist ) ; }\n", "\n", "\n", "Target: s ) { if ( s == 0 ) return ( ( void * ) NULL ) ;\n", "\n", "Sources:\n", "0: CWE-369 void * _TIFFmalloc ( tmsize_t s ) { return ( malloc ( ( size_t ) s ) ) ; }\n", "\n", "1: CWE-369 tdata_t _TIFFmalloc ( tsize_t s ) { return ( malloc ( ( size_t ) s ) ) ; }\n", "\n", "\n", "Target: ( ndo , \"%s\" , rpl_tstr ) ) ;\n", "\n", "Sources:\n", "0: CWE-125 static void rpl_print ( netdissect_options * ndo , const struct icmp6_hdr * hdr , const u_char * bp , u_int length ) { int secured = hdr -> icmp6_code & 0x80 ; int basecode = hdr -> icmp6_code & 0x7f ; if ( secured ) { ND_PRINT ( ( ndo , \",(SEC)[worktodo]\" ) ) ; return ; } else { ND_PRINT ( ( ndo , \",(CLR)\" ) ) ; } switch ( basecode ) { case ND_RPL_DAG_IS : ND_PRINT ( ( ndo , \"DODAGInformationSolicitation\" ) ) ; if ( ndo -> ndo_vflag ) { } break ; case ND_RPL_DAG_IO : ND_PRINT ( ( ndo , \"DODAGInformationObject\" ) ) ; if ( ndo -> ndo_vflag ) { rpl_dio_print ( ndo , bp , length ) ; } break ; case ND_RPL_DAO : ND_PRINT ( ( ndo , \"DestinationAdvertisementObject\" ) ) ; if ( ndo -> ndo_vflag ) { rpl_dao_print ( ndo , bp , length ) ; } break ; case ND_RPL_DAO_ACK : ND_PRINT ( ( ndo , \"DestinationAdvertisementObjectAck\" ) ) ; if ( ndo -> ndo_vflag ) { rpl_daoack_print ( ndo , bp , length ) ; } break ; default : ND_PRINT ( ( ndo , \"RPLmessage,unknowncode%u\" , hdr -> icmp6_code ) ) ; break ; } return ; # if 0 trunc : ND_PRINT ( ( ndo , \"[|truncated]\" ) ) ; return ; # endif }\n", "\n", "1: CWE-125 static void rpl_dao_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const struct nd_rpl_dao * dao = ( const struct nd_rpl_dao * ) bp ; const char * dagid_str = \"\" ; ND_TCHECK ( * dao ) ; if ( length < ND_RPL_DAO_MIN_LEN ) goto tooshort ; bp += ND_RPL_DAO_MIN_LEN ; length -= ND_RPL_DAO_MIN_LEN ; if ( RPL_DAO_D ( dao -> rpl_flags ) ) { ND_TCHECK2 ( dao -> rpl_dagid , DAGID_LEN ) ; if ( length < DAGID_LEN ) goto tooshort ; dagid_str = ip6addr_string ( ndo , dao -> rpl_dagid ) ; bp += DAGID_LEN ; length -= DAGID_LEN ; } ND_PRINT ( ( ndo , \"[dagid:%s,seq:%u,instance:%u%s%s,%02x]\" , dagid_str , dao -> rpl_daoseq , dao -> rpl_instanceid , RPL_DAO_K ( dao -> rpl_flags ) ? \",acK\" : \"\" , RPL_DAO_D ( dao -> rpl_flags ) ? \",Dagid\" : \"\" , dao -> rpl_flags ) ) ; if ( ndo -> ndo_vflag > 1 ) { const struct rpl_dio_genoption * opt = ( const struct rpl_dio_genoption * ) bp ; rpl_dio_printopt ( ndo , opt , length ) ; } return ; trunc : ND_PRINT ( ( ndo , \"[|truncated]\" ) ) ; return ; tooshort : ND_PRINT ( ( ndo , \"[|lengthtooshort]\" ) ) ; return ; }\n", "\n", "\n", "Target: snd_kcontrol * kctl ; if ( card -> last_numid >= UINT_MAX - count ) card -> last_numid = 0\n", "\n", "Sources:\n", "0: CWE-189 static bool snd_ctl_remove_numid_conflict ( struct snd_card * card , unsigned int count ) { struct snd_kcontrol * kctl ; 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 + 1 ) { card -> last_numid = kctl -> id . numid + kctl -> count - 1 ; return true ; } } return false ; }\n", "\n", "1: CWE-190 static bool snd_ctl_remove_numid_conflict ( struct snd_card * card , unsigned int count ) { struct snd_kcontrol * kctl ; 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 + 1 ) { card -> last_numid = kctl -> id . numid + kctl -> count - 1 ; return true ; } } return false ; }\n", "\n", "\n", "Target: ; if ( key_is_negative ( key ) ) return\n", "\n", "Sources:\n", "0: CWE-20 static int encrypted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct encrypted_key_payload * epayload = key -> payload . data [ 0 ] ; struct encrypted_key_payload * new_epayload ; char * buf ; char * new_master_desc = NULL ; const char * format = NULL ; size_t datalen = prep -> datalen ; int ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; buf = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; buf [ datalen ] = 0 ; memcpy ( buf , prep -> data , datalen ) ; ret = datablob_parse ( buf , & format , & new_master_desc , NULL , NULL ) ; if ( ret < 0 ) goto out ; ret = valid_master_desc ( new_master_desc , epayload -> master_desc ) ; if ( ret < 0 ) goto out ; new_epayload = encrypted_key_alloc ( key , epayload -> format , new_master_desc , epayload -> datalen ) ; if ( IS_ERR ( new_epayload ) ) { ret = PTR_ERR ( new_epayload ) ; goto out ; } __ekey_init ( new_epayload , epayload -> format , new_master_desc , epayload -> datalen ) ; memcpy ( new_epayload -> iv , epayload -> iv , ivsize ) ; memcpy ( new_epayload -> payload_data , epayload -> payload_data , epayload -> payload_datalen ) ; rcu_assign_keypointer ( key , new_epayload ) ; call_rcu ( & epayload -> rcu , encrypted_rcu_free ) ; out : kzfree ( buf ) ; return ret ; }\n", "\n", "1: CWE-20 static int trusted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct trusted_key_payload * p ; struct trusted_key_payload * new_p ; struct trusted_key_options * new_o ; size_t datalen = prep -> datalen ; char * datablob ; int ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ; p = key -> payload . data [ 0 ] ; if ( ! p -> migratable ) return - EPERM ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; datablob = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! datablob ) return - ENOMEM ; new_o = trusted_options_alloc ( ) ; if ( ! new_o ) { ret = - ENOMEM ; goto out ; } new_p = trusted_payload_alloc ( key ) ; if ( ! new_p ) { ret = - ENOMEM ; goto out ; } memcpy ( datablob , prep -> data , datalen ) ; datablob [ datalen ] = '\\\\0' ; ret = datablob_parse ( datablob , new_p , new_o ) ; if ( ret != Opt_update ) { ret = - EINVAL ; kzfree ( new_p ) ; goto out ; } if ( ! new_o -> keyhandle ) { ret = - EINVAL ; kzfree ( new_p ) ; goto out ; } new_p -> migratable = p -> migratable ; new_p -> key_len = p -> key_len ; memcpy ( new_p -> key , p -> key , p -> key_len ) ; dump_payload ( p ) ; dump_payload ( new_p ) ; ret = key_seal ( new_p , new_o ) ; if ( ret < 0 ) { pr_info ( \"trusted_key:key_sealfailed(%d)\\\\n\" , ret ) ; kzfree ( new_p ) ; goto out ; } if ( new_o -> pcrlock ) { ret = pcrlock ( new_o -> pcrlock ) ; if ( ret < 0 ) { pr_info ( \"trusted_key:pcrlockfailed(%d)\\\\n\" , ret ) ; kzfree ( new_p ) ; goto out ; } } rcu_assign_keypointer ( key , new_p ) ; call_rcu ( & p -> rcu , trusted_rcu_free ) ; out : kzfree ( datablob ) ; kzfree ( new_o ) ; return ret ; }\n", "\n", "\n", "Target: size_t columns , rows ; rows = MagickMax ( GetImageListLength ( images ) , ( size_t ) ( ThreadResource ) ) ) AcquireQuantumMemory ( rows , sizeof ( * NULL ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) rows ; i ++\n", "\n", "Sources:\n", "0: CWE-787 static MagickPixelPacket * * AcquirePixelThreadSet ( const Image * images ) { const Image * next ; MagickPixelPacket * * pixels ; register ssize_t i , j ; size_t columns , number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( MagickPixelPacket * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( MagickPixelPacket * * ) NULL ) return ( ( MagickPixelPacket * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { pixels [ i ] = ( MagickPixelPacket * ) AcquireQuantumMemory ( columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( MagickPixelPacket * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) columns ; j ++ ) GetMagickPixelPacket ( images , & pixels [ i ] [ j ] ) ; } return ( pixels ) ; }\n", "\n", "1: CWE-119 static MagickPixelPacket * * AcquirePixelThreadSet ( const Image * images ) { const Image * next ; MagickPixelPacket * * pixels ; register ssize_t i , j ; size_t columns , number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( MagickPixelPacket * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( MagickPixelPacket * * ) NULL ) return ( ( MagickPixelPacket * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { pixels [ i ] = ( MagickPixelPacket * ) AcquireQuantumMemory ( columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( MagickPixelPacket * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) columns ; j ++ ) GetMagickPixelPacket ( images , & pixels [ i ] [ j ] ) ; } return ( pixels ) ; }\n", "\n", "\n", "Target: NULL ; } else { matvar -> name [ tmp - 1 ] = '\\\\0' ; }\n", "\n", "Sources:\n", "0: CWE-000 matvar_t * Mat_VarReadNextInfo4 ( mat_t * mat ) { int M , O , data_type , class_type ; mat_int32_t tmp ; long nBytes ; size_t readresult ; matvar_t * matvar = NULL ; union { mat_uint32_t u ; mat_uint8_t c [ 4 ] ; } endian ; if ( mat == NULL || mat -> fp == NULL ) return NULL ; else if ( NULL == ( matvar = Mat_VarCalloc ( ) ) ) return NULL ; readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } endian . u = 0x01020304 ; if ( tmp < 0 || tmp > 4052 ) { if ( Mat_int32Swap ( & tmp ) > 4052 ) { Mat_VarFree ( matvar ) ; return NULL ; } } M = ( int ) floor ( tmp / 1000.0 ) ; switch ( M ) { case 0 : mat -> byteswap = endian . c [ 0 ] != 4 ; break ; case 1 : mat -> byteswap = endian . c [ 0 ] != 1 ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } tmp -= M * 1000 ; O = ( int ) floor ( tmp / 100.0 ) ; if ( 0 != O ) { Mat_VarFree ( matvar ) ; return NULL ; } tmp -= O * 100 ; data_type = ( int ) floor ( tmp / 10.0 ) ; switch ( data_type ) { case 0 : matvar -> data_type = MAT_T_DOUBLE ; break ; case 1 : matvar -> data_type = MAT_T_SINGLE ; break ; case 2 : matvar -> data_type = MAT_T_INT32 ; break ; case 3 : matvar -> data_type = MAT_T_INT16 ; break ; case 4 : matvar -> data_type = MAT_T_UINT16 ; break ; case 5 : matvar -> data_type = MAT_T_UINT8 ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } tmp -= data_type * 10 ; class_type = ( int ) floor ( tmp / 1.0 ) ; switch ( class_type ) { case 0 : matvar -> class_type = MAT_C_DOUBLE ; break ; case 1 : matvar -> class_type = MAT_C_CHAR ; break ; case 2 : matvar -> class_type = MAT_C_SPARSE ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } matvar -> rank = 2 ; matvar -> dims = ( size_t * ) calloc ( 2 , sizeof ( * matvar -> dims ) ) ; if ( NULL == matvar -> dims ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; matvar -> dims [ 0 ] = tmp ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; matvar -> dims [ 1 ] = tmp ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & ( matvar -> isComplex ) , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } if ( matvar -> isComplex && MAT_C_CHAR == matvar -> class_type ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; if ( tmp < 1 ) { Mat_VarFree ( matvar ) ; return NULL ; } matvar -> name = ( char * ) malloc ( tmp ) ; if ( NULL == matvar -> name ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( matvar -> name , 1 , tmp , ( FILE * ) mat -> fp ) ; if ( tmp != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } matvar -> internal -> datapos = ftell ( ( FILE * ) mat -> fp ) ; if ( matvar -> internal -> datapos == - 1L ) { Mat_VarFree ( matvar ) ; Mat_Critical ( \"Couldn\\'tdeterminefileposition\" ) ; return NULL ; } { int err ; size_t tmp2 = Mat_SizeOf ( matvar -> data_type ) ; if ( matvar -> isComplex ) tmp2 *= 2 ; err = SafeMulDims ( matvar , & tmp2 ) ; if ( err ) { Mat_VarFree ( matvar ) ; Mat_Critical ( \"Integermultiplicationoverflow\" ) ; return NULL ; } nBytes = ( long ) tmp2 ; } ( void ) fseek ( ( FILE * ) mat -> fp , nBytes , SEEK_CUR ) ; return matvar ; }\n", "\n", "1: CWE-125 matvar_t * Mat_VarReadNextInfo4 ( mat_t * mat ) { int M , O , data_type , class_type ; mat_int32_t tmp ; long nBytes ; size_t readresult ; matvar_t * matvar = NULL ; union { mat_uint32_t u ; mat_uint8_t c [ 4 ] ; } endian ; if ( mat == NULL || mat -> fp == NULL ) return NULL ; else if ( NULL == ( matvar = Mat_VarCalloc ( ) ) ) return NULL ; readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } endian . u = 0x01020304 ; if ( tmp < 0 || tmp > 4052 ) { if ( Mat_int32Swap ( & tmp ) > 4052 ) { Mat_VarFree ( matvar ) ; return NULL ; } } M = ( int ) floor ( tmp / 1000.0 ) ; switch ( M ) { case 0 : mat -> byteswap = endian . c [ 0 ] != 4 ; break ; case 1 : mat -> byteswap = endian . c [ 0 ] != 1 ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } tmp -= M * 1000 ; O = ( int ) floor ( tmp / 100.0 ) ; if ( 0 != O ) { Mat_VarFree ( matvar ) ; return NULL ; } tmp -= O * 100 ; data_type = ( int ) floor ( tmp / 10.0 ) ; switch ( data_type ) { case 0 : matvar -> data_type = MAT_T_DOUBLE ; break ; case 1 : matvar -> data_type = MAT_T_SINGLE ; break ; case 2 : matvar -> data_type = MAT_T_INT32 ; break ; case 3 : matvar -> data_type = MAT_T_INT16 ; break ; case 4 : matvar -> data_type = MAT_T_UINT16 ; break ; case 5 : matvar -> data_type = MAT_T_UINT8 ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } tmp -= data_type * 10 ; class_type = ( int ) floor ( tmp / 1.0 ) ; switch ( class_type ) { case 0 : matvar -> class_type = MAT_C_DOUBLE ; break ; case 1 : matvar -> class_type = MAT_C_CHAR ; break ; case 2 : matvar -> class_type = MAT_C_SPARSE ; break ; default : Mat_VarFree ( matvar ) ; return NULL ; } matvar -> rank = 2 ; matvar -> dims = ( size_t * ) calloc ( 2 , sizeof ( * matvar -> dims ) ) ; if ( NULL == matvar -> dims ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; matvar -> dims [ 0 ] = tmp ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; matvar -> dims [ 1 ] = tmp ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & ( matvar -> isComplex ) , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } if ( matvar -> isComplex && MAT_C_CHAR == matvar -> class_type ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( & tmp , sizeof ( int ) , 1 , ( FILE * ) mat -> fp ) ; if ( 1 != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } if ( mat -> byteswap ) Mat_int32Swap ( & tmp ) ; if ( tmp < 1 ) { Mat_VarFree ( matvar ) ; return NULL ; } matvar -> name = ( char * ) malloc ( tmp ) ; if ( NULL == matvar -> name ) { Mat_VarFree ( matvar ) ; return NULL ; } readresult = fread ( matvar -> name , 1 , tmp , ( FILE * ) mat -> fp ) ; if ( tmp != readresult ) { Mat_VarFree ( matvar ) ; return NULL ; } matvar -> internal -> datapos = ftell ( ( FILE * ) mat -> fp ) ; if ( matvar -> internal -> datapos == - 1L ) { Mat_VarFree ( matvar ) ; Mat_Critical ( \"Couldn\\'tdeterminefileposition\" ) ; return NULL ; } { int err ; size_t tmp2 = Mat_SizeOf ( matvar -> data_type ) ; if ( matvar -> isComplex ) tmp2 *= 2 ; err = SafeMulDims ( matvar , & tmp2 ) ; if ( err ) { Mat_VarFree ( matvar ) ; Mat_Critical ( \"Integermultiplicationoverflow\" ) ; return NULL ; } nBytes = ( long ) tmp2 ; } ( void ) fseek ( ( FILE * ) mat -> fp , nBytes , SEEK_CUR ) ; return matvar ; }\n", "\n", "\n", "Target: ) { BN_ULONG c1 , c2\n", "\n", "Sources:\n", "0: CWE-310 void bn_sqr_comba4 ( BN_ULONG * r , const BN_ULONG * a ) { BN_ULONG t1 , t2 ; BN_ULONG c1 , c2 , c3 ; c1 = 0 ; c2 = 0 ; c3 = 0 ; sqr_add_c ( a , 0 , c1 , c2 , c3 ) ; r [ 0 ] = c1 ; c1 = 0 ; sqr_add_c2 ( a , 1 , 0 , c2 , c3 , c1 ) ; r [ 1 ] = c2 ; c2 = 0 ; sqr_add_c ( a , 1 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 2 , 0 , c3 , c1 , c2 ) ; r [ 2 ] = c3 ; c3 = 0 ; sqr_add_c2 ( a , 3 , 0 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 2 , 1 , c1 , c2 , c3 ) ; r [ 3 ] = c1 ; c1 = 0 ; sqr_add_c ( a , 2 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 3 , 1 , c2 , c3 , c1 ) ; r [ 4 ] = c2 ; c2 = 0 ; sqr_add_c2 ( a , 3 , 2 , c3 , c1 , c2 ) ; r [ 5 ] = c3 ; c3 = 0 ; sqr_add_c ( a , 3 , c1 , c2 , c3 ) ; r [ 6 ] = c1 ; r [ 7 ] = c2 ; }\n", "\n", "1: CWE-310 void bn_mul_comba8 ( BN_ULONG * r , BN_ULONG * a , BN_ULONG * b ) { BN_ULONG t1 , t2 ; BN_ULONG c1 , c2 , c3 ; c1 = 0 ; c2 = 0 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 0 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 0 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 0 ] , c2 , c3 , c1 ) ; r [ 1 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 2 ] , b [ 0 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 1 ] , b [ 1 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 0 ] , b [ 2 ] , c3 , c1 , c2 ) ; r [ 2 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 3 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 1 ] , b [ 2 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 2 ] , b [ 1 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 3 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 3 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 4 ] , b [ 0 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 3 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 2 ] , b [ 2 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 3 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 0 ] , b [ 4 ] , c2 , c3 , c1 ) ; r [ 4 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 0 ] , b [ 5 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 1 ] , b [ 4 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 2 ] , b [ 3 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 3 ] , b [ 2 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 4 ] , b [ 1 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 5 ] , b [ 0 ] , c3 , c1 , c2 ) ; r [ 5 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 6 ] , b [ 0 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 5 ] , b [ 1 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 4 ] , b [ 2 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 3 ] , b [ 3 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 2 ] , b [ 4 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 1 ] , b [ 5 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 0 ] , b [ 6 ] , c1 , c2 , c3 ) ; r [ 6 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 0 ] , b [ 7 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 6 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 2 ] , b [ 5 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 3 ] , b [ 4 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 4 ] , b [ 3 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 5 ] , b [ 2 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 6 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 7 ] , b [ 0 ] , c2 , c3 , c1 ) ; r [ 7 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 7 ] , b [ 1 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 6 ] , b [ 2 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 5 ] , b [ 3 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 4 ] , b [ 4 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 3 ] , b [ 5 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 2 ] , b [ 6 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 1 ] , b [ 7 ] , c3 , c1 , c2 ) ; r [ 8 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 2 ] , b [ 7 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 3 ] , b [ 6 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 4 ] , b [ 5 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 5 ] , b [ 4 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 6 ] , b [ 3 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 7 ] , b [ 2 ] , c1 , c2 , c3 ) ; r [ 9 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 7 ] , b [ 3 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 6 ] , b [ 4 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 5 ] , b [ 5 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 4 ] , b [ 6 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 3 ] , b [ 7 ] , c2 , c3 , c1 ) ; r [ 10 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 4 ] , b [ 7 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 5 ] , b [ 6 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 6 ] , b [ 5 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 7 ] , b [ 4 ] , c3 , c1 , c2 ) ; r [ 11 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 7 ] , b [ 5 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 6 ] , b [ 6 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 5 ] , b [ 7 ] , c1 , c2 , c3 ) ; r [ 12 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 6 ] , b [ 7 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 7 ] , b [ 6 ] , c2 , c3 , c1 ) ; r [ 13 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 7 ] , b [ 7 ] , c3 , c1 , c2 ) ; r [ 14 ] = c3 ; r [ 15 ] = c1 ; }\n", "\n", "2: CWE-310 void bn_mul_comba4 ( BN_ULONG * r , BN_ULONG * a , BN_ULONG * b ) { BN_ULONG t1 , t2 ; BN_ULONG c1 , c2 , c3 ; c1 = 0 ; c2 = 0 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 0 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 0 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 0 ] , c2 , c3 , c1 ) ; r [ 1 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 2 ] , b [ 0 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 1 ] , b [ 1 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 0 ] , b [ 2 ] , c3 , c1 , c2 ) ; r [ 2 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 3 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 1 ] , b [ 2 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 2 ] , b [ 1 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 3 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 3 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 3 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 2 ] , b [ 2 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 3 ] , c2 , c3 , c1 ) ; r [ 4 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 2 ] , b [ 3 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 3 ] , b [ 2 ] , c3 , c1 , c2 ) ; r [ 5 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 3 ] , b [ 3 ] , c1 , c2 , c3 ) ; r [ 6 ] = c1 ; r [ 7 ] = c2 ; }\n", "\n", "\n", "Target: { option = ssplit ( option ,\n", "\n", "Sources:\n", "0: CWE-000 static int traceLogDirective ( MaState * state , cchar * key , cchar * value ) { HttpRoute * route ; char * format , * option , * ovalue , * tok , * path , * formatter ; ssize size ; int flags , backup , level ; route = state -> route ; size = MAXINT ; backup = 0 ; flags = 0 ; path = 0 ; format = ME_HTTP_LOG_FORMAT ; formatter = \"detail\" ; level = 0 ; if ( route -> trace -> flags & MPR_LOG_CMDLINE ) { mprLog ( \"infoappwebconfig\" , 4 , \"Alreadytracing.IgnoringTraceLogdirective\" ) ; return 0 ; } for ( option = maGetNextArg ( sclone ( value ) , & tok ) ; option ; option = maGetNextArg ( tok , & tok ) ) { if ( ! path ) { path = sclone ( option ) ; } else { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( smatch ( option , \"anew\" ) ) { flags |= MPR_LOG_ANEW ; } else if ( smatch ( option , \"backup\" ) ) { backup = atoi ( ovalue ) ; } else if ( smatch ( option , \"format\" ) ) { format = ovalue ; } else if ( smatch ( option , \"level\" ) ) { level = ( int ) stoi ( ovalue ) ; } else if ( smatch ( option , \"size\" ) ) { size = ( ssize ) getnum ( ovalue ) ; } else if ( smatch ( option , \"formatter\" ) ) { formatter = ovalue ; } else { mprLog ( \"errorappwebconfig\" , 0 , \"UnknownTraceLogoption%s\" , option ) ; } } } if ( size < HTTP_TRACE_MIN_LOG_SIZE ) { size = HTTP_TRACE_MIN_LOG_SIZE ; } if ( path == 0 ) { mprLog ( \"errorappwebconfig\" , 0 , \"MissingTraceLogfilename\" ) ; return MPR_ERR_BAD_SYNTAX ; } if ( formatter ) { httpSetTraceFormatterName ( route -> trace , formatter ) ; } if ( ! smatch ( path , \"stdout\" ) && ! smatch ( path , \"stderr\" ) ) { path = httpMakePath ( route , state -> configDir , path ) ; } route -> trace = httpCreateTrace ( route -> trace ) ; if ( httpSetTraceLogFile ( route -> trace , path , size , backup , format , flags ) < 0 ) { return MPR_ERR_CANT_OPEN ; } httpSetTraceLevel ( level ) ; return 0 ; }\n", "\n", "1: CWE-000 static int requireDirective ( MaState * state , cchar * key , cchar * value ) { char * age , * type , * rest , * option , * ovalue , * tok ; int domains ; if ( ! maTokenize ( state , value , \"%S?*\" , & type , & rest ) ) { return MPR_ERR_BAD_SYNTAX ; } if ( scaselesscmp ( type , \"ability\" ) == 0 ) { httpSetAuthRequiredAbilities ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , \"group\" ) == 0 || scaselesscmp ( type , \"role\" ) == 0 ) { httpSetAuthRequiredAbilities ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , \"secure\" ) == 0 ) { domains = 0 ; age = 0 ; for ( option = stok ( sclone ( rest ) , \"\\\\t\" , & tok ) ; option ; option = stok ( 0 , \"\\\\t\" , & tok ) ) { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( smatch ( option , \"age\" ) ) { age = sfmt ( \"%lld\" , ( int64 ) httpGetTicks ( ovalue ) ) ; } else if ( smatch ( option , \"domains\" ) ) { domains = 1 ; } } if ( age ) { if ( domains ) { age = sjoin ( \"-1\" , age , NULL ) ; } } addCondition ( state , \"secure\" , age , HTTP_ROUTE_STRICT_TLS ) ; } else if ( scaselesscmp ( type , \"user\" ) == 0 ) { httpSetAuthPermittedUsers ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , \"valid-user\" ) == 0 ) { httpSetAuthAnyValidUser ( state -> auth ) ; } else { return configError ( state , key ) ; } return 0 ; }\n", "\n", "2: CWE-000 static int crossOriginDirective ( MaState * state , cchar * key , cchar * value ) { HttpRoute * route ; char * option , * ovalue , * tok ; route = state -> route ; tok = sclone ( value ) ; while ( ( option = maGetNextArg ( tok , & tok ) ) != 0 ) { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( scaselessmatch ( option , \"origin\" ) ) { route -> corsOrigin = sclone ( ovalue ) ; } else if ( scaselessmatch ( option , \"credentials\" ) ) { route -> corsCredentials = httpGetBoolToken ( ovalue ) ; } else if ( scaselessmatch ( option , \"headers\" ) ) { route -> corsHeaders = sclone ( ovalue ) ; } else if ( scaselessmatch ( option , \"age\" ) ) { route -> corsAge = atoi ( ovalue ) ; } else { mprLog ( \"errorappwebconfig\" , 0 , \"UnknownCrossOriginoption%s\" , option ) ; return MPR_ERR_BAD_SYNTAX ; } } # if KEEP if ( smatch ( route -> corsOrigin , \"*\" ) && route -> corsCredentials ) { mprLog ( \"errorappwebconfig\" , 0 , \"CrossOrigin:CannotusewildcardOriginifallowingcredentials\" ) ; return MPR_ERR_BAD_STATE ; } # endif httpAddRouteMethods ( route , \"OPTIONS\" ) ; route -> flags |= HTTP_ROUTE_CORS ; return 0 ; }\n", "\n", "\n", "Target: struct snd_ctl_elem_id id ; unsigned int count -> count ; count = kcontrol -> count ; ; idx < count ; idx\n", "\n", "Sources:\n", "0: CWE-000 int snd_ctl_replace ( struct snd_card * card , struct snd_kcontrol * kcontrol , bool add_on_replace ) { struct snd_ctl_elem_id id ; unsigned int idx ; struct snd_kcontrol * old ; int ret ; if ( ! kcontrol ) return - EINVAL ; if ( snd_BUG_ON ( ! card || ! kcontrol -> info ) ) { ret = - EINVAL ; goto error ; } id = kcontrol -> id ; down_write ( & card -> controls_rwsem ) ; old = snd_ctl_find_id ( card , & id ) ; if ( ! old ) { if ( add_on_replace ) goto add ; up_write ( & card -> controls_rwsem ) ; ret = - EINVAL ; goto error ; } ret = snd_ctl_remove ( card , old ) ; if ( ret < 0 ) { up_write ( & card -> controls_rwsem ) ; goto error ; } add : if ( snd_ctl_find_hole ( card , kcontrol -> count ) < 0 ) { up_write ( & card -> controls_rwsem ) ; ret = - ENOMEM ; goto error ; } list_add_tail ( & kcontrol -> list , & card -> controls ) ; card -> controls_count += kcontrol -> count ; kcontrol -> id . numid = card -> last_numid + 1 ; card -> last_numid += kcontrol -> count ; up_write ( & card -> controls_rwsem ) ; for ( idx = 0 ; idx < kcontrol -> count ; idx ++ , id . index ++ , id . numid ++ ) snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_ADD , & id ) ; return 0 ; error : snd_ctl_free_one ( kcontrol ) ; return ret ; }\n", "\n", "1: CWE-416 int snd_ctl_replace ( struct snd_card * card , struct snd_kcontrol * kcontrol , bool add_on_replace ) { struct snd_ctl_elem_id id ; unsigned int idx ; struct snd_kcontrol * old ; int ret ; if ( ! kcontrol ) return - EINVAL ; if ( snd_BUG_ON ( ! card || ! kcontrol -> info ) ) { ret = - EINVAL ; goto error ; } id = kcontrol -> id ; down_write ( & card -> controls_rwsem ) ; old = snd_ctl_find_id ( card , & id ) ; if ( ! old ) { if ( add_on_replace ) goto add ; up_write ( & card -> controls_rwsem ) ; ret = - EINVAL ; goto error ; } ret = snd_ctl_remove ( card , old ) ; if ( ret < 0 ) { up_write ( & card -> controls_rwsem ) ; goto error ; } add : if ( snd_ctl_find_hole ( card , kcontrol -> count ) < 0 ) { up_write ( & card -> controls_rwsem ) ; ret = - ENOMEM ; goto error ; } list_add_tail ( & kcontrol -> list , & card -> controls ) ; card -> controls_count += kcontrol -> count ; kcontrol -> id . numid = card -> last_numid + 1 ; card -> last_numid += kcontrol -> count ; up_write ( & card -> controls_rwsem ) ; for ( idx = 0 ; idx < kcontrol -> count ; idx ++ , id . index ++ , id . numid ++ ) snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_ADD , & id ) ; return 0 ; error : snd_ctl_free_one ( kcontrol ) ; return ret ; }\n", "\n", "\n", "Target: num < 0 || num >= 256\n", "\n", "Sources:\n", "0: CWE-787 static int fetch_token_in_cc ( OnigToken * tok , UChar * * src , UChar * end , ScanEnv * env ) { int num ; OnigCodePoint c , c2 ; OnigSyntaxType * syn = env -> syntax ; OnigEncoding enc = env -> enc ; UChar * prev ; UChar * p = * src ; PFETCH_READY ; if ( PEND ) { tok -> type = TK_EOT ; return tok -> type ; } PFETCH ( c ) ; tok -> type = TK_CHAR ; tok -> base = 0 ; tok -> u . c = c ; tok -> escaped = 0 ; if ( c == ']' ) { tok -> type = TK_CC_CLOSE ; } else if ( c == '-' ) { tok -> type = TK_CC_RANGE ; } else if ( c == MC_ESC ( syn ) ) { if ( ! IS_SYNTAX_BV ( syn , ONIG_SYN_BACKSLASH_ESCAPE_IN_CC ) ) goto end ; if ( PEND ) return ONIGERR_END_PATTERN_AT_ESCAPE ; PFETCH ( c ) ; tok -> escaped = 1 ; tok -> u . c = c ; switch ( c ) { case 'w' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 0 ; break ; case 'W' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 1 ; break ; case 'd' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 0 ; break ; case 'D' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 1 ; break ; case 's' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 0 ; break ; case 'S' : tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 1 ; break ; case 'h' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 0 ; break ; case 'H' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 1 ; break ; case 'p' : case 'P' : if ( PEND ) break ; c2 = PPEEK ; if ( c2 == '{' && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY ) ) { PINC ; tok -> type = TK_CHAR_PROPERTY ; tok -> u . prop . not = ( c == 'P' ? 1 : 0 ) ; if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT ) ) { PFETCH ( c2 ) ; if ( c2 == '^' ) { tok -> u . prop . not = ( tok -> u . prop . not == 0 ? 1 : 0 ) ; } else PUNFETCH ; } } break ; case 'x' : if ( PEND ) break ; prev = p ; if ( PPEEK_IS ( '{' ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_BRACE_HEX8 ) ) { PINC ; num = scan_unsigned_hexadecimal_number ( & p , end , 8 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE ; if ( ! PEND ) { c2 = PPEEK ; if ( ONIGENC_IS_CODE_XDIGIT ( enc , c2 ) ) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE ; } if ( p > prev + enclen ( enc , prev ) && ! PEND && ( PPEEK_IS ( '}' ) ) ) { PINC ; tok -> type = TK_CODE_POINT ; tok -> base = 16 ; tok -> u . code = ( OnigCodePoint ) num ; } else { p = prev ; } } else if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_HEX2 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 2 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 16 ; tok -> u . c = num ; } break ; case 'u' : if ( PEND ) break ; prev = p ; if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_U_HEX4 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 4 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_CODE_POINT ; tok -> base = 16 ; tok -> u . code = ( OnigCodePoint ) num ; } break ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_OCTAL3 ) ) { PUNFETCH ; prev = p ; num = scan_unsigned_octal_number ( & p , end , 3 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 8 ; tok -> u . c = num ; } break ; default : PUNFETCH ; num = fetch_escaped_value ( & p , end , env , & c2 ) ; if ( num < 0 ) return num ; if ( tok -> u . c != c2 ) { tok -> u . code = c2 ; tok -> type = TK_CODE_POINT ; } break ; } } else if ( c == '[' ) { if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_POSIX_BRACKET ) && ( PPEEK_IS ( ':' ) ) ) { OnigCodePoint send [ ] = { ( OnigCodePoint ) ':' , ( OnigCodePoint ) ']' } ; tok -> backp = p ; PINC ; if ( str_exist_check_with_esc ( send , 2 , p , end , ( OnigCodePoint ) ']' , enc , syn ) ) { tok -> type = TK_POSIX_BRACKET_OPEN ; } else { PUNFETCH ; goto cc_in_cc ; } } else { cc_in_cc : if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_CCLASS_SET_OP ) ) { tok -> type = TK_CC_CC_OPEN ; } else { CC_ESC_WARN ( env , ( UChar * ) \"[\" ) ; } } } else if ( c == '&' ) { if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_CCLASS_SET_OP ) && ! PEND && ( PPEEK_IS ( '&' ) ) ) { PINC ; tok -> type = TK_CC_AND ; } } end : * src = p ; return tok -> type ; }\n", "\n", "1: CWE-787 static int fetch_token ( OnigToken * tok , UChar * * src , UChar * end , ScanEnv * env ) { int r , num ; OnigCodePoint c ; OnigEncoding enc = env -> enc ; OnigSyntaxType * syn = env -> syntax ; UChar * prev ; UChar * p = * src ; PFETCH_READY ; start : if ( PEND ) { tok -> type = TK_EOT ; return tok -> type ; } tok -> type = TK_STRING ; tok -> base = 0 ; tok -> backp = p ; PFETCH ( c ) ; if ( IS_MC_ESC_CODE ( c , syn ) ) { if ( PEND ) return ONIGERR_END_PATTERN_AT_ESCAPE ; tok -> backp = p ; PFETCH ( c ) ; tok -> u . c = c ; tok -> escaped = 1 ; switch ( c ) { case '*' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '+' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_PLUS_ONE_INF ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 1 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '?' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_QMARK_ZERO_ONE ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = 1 ; greedy_check : if ( ! PEND && PPEEK_IS ( '?' ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_QMARK_NON_GREEDY ) ) { PFETCH ( c ) ; tok -> u . repeat . greedy = 0 ; tok -> u . repeat . possessive = 0 ; } else { possessive_check : if ( ! PEND && PPEEK_IS ( '+' ) && ( ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT ) && tok -> type != TK_INTERVAL ) || ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL ) && tok -> type == TK_INTERVAL ) ) ) { PFETCH ( c ) ; tok -> u . repeat . greedy = 1 ; tok -> u . repeat . possessive = 1 ; } else { tok -> u . repeat . greedy = 1 ; tok -> u . repeat . possessive = 0 ; } } break ; case '{' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_BRACE_INTERVAL ) ) break ; r = fetch_range_quantifier ( & p , end , tok , env ) ; if ( r < 0 ) return r ; if ( r == 0 ) goto greedy_check ; else if ( r == 2 ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY ) ) goto possessive_check ; goto greedy_check ; } break ; case '|' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_VBAR_ALT ) ) break ; tok -> type = TK_ALT ; break ; case '(' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_OPEN ; break ; case ')' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_CLOSE ; break ; case 'w' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_W_WORD ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 0 ; break ; case 'W' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_W_WORD ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 1 ; break ; case 'b' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_B_WORD_BOUND ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_BOUND ; break ; case 'B' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_B_WORD_BOUND ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_NOT_WORD_BOUND ; break ; # ifdef USE_WORD_BEGIN_END case '<' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_BEGIN ; break ; case '>' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_END ; break ; # endif case 's' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_S_WHITE_SPACE ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 0 ; break ; case 'S' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_S_WHITE_SPACE ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 1 ; break ; case 'd' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_D_DIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 0 ; break ; case 'D' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_D_DIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 1 ; break ; case 'h' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 0 ; break ; case 'H' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 1 ; break ; case 'A' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; begin_buf : tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_BEGIN_BUF ; break ; case 'Z' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_SEMI_END_BUF ; break ; case 'z' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; end_buf : tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_END_BUF ; break ; case 'G' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_BEGIN_POSITION ; break ; case '`' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR ) ) break ; goto begin_buf ; break ; case '\\\\'' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR ) ) break ; goto end_buf ; break ; case 'x' : if ( PEND ) break ; prev = p ; if ( PPEEK_IS ( '{' ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_BRACE_HEX8 ) ) { PINC ; num = scan_unsigned_hexadecimal_number ( & p , end , 8 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE ; if ( ! PEND ) { if ( ONIGENC_IS_CODE_XDIGIT ( enc , PPEEK ) ) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE ; } if ( ( p > prev + enclen ( enc , prev ) ) && ! PEND && PPEEK_IS ( '}' ) ) { PINC ; tok -> type = TK_CODE_POINT ; tok -> u . code = ( OnigCodePoint ) num ; } else { p = prev ; } } else if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_HEX2 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 2 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 16 ; tok -> u . c = num ; } break ; case 'u' : if ( PEND ) break ; prev = p ; if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_U_HEX4 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 4 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_CODE_POINT ; tok -> base = 16 ; tok -> u . code = ( OnigCodePoint ) num ; } break ; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : PUNFETCH ; prev = p ; num = onig_scan_unsigned_number ( & p , end , enc ) ; if ( num < 0 || num > ONIG_MAX_BACKREF_NUM ) { goto skip_backref ; } if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_DECIMAL_BACKREF ) && ( num <= env -> num_mem || num <= 9 ) ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { if ( num > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ num ] ) ) return ONIGERR_INVALID_BACKREF ; } tok -> type = TK_BACKREF ; tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = num ; tok -> u . backref . by_name = 0 ; # ifdef USE_BACKREF_WITH_LEVEL tok -> u . backref . exist_level = 0 ; # endif break ; } skip_backref : if ( c == '8' || c == '9' ) { p = prev ; PINC ; break ; } p = prev ; case '0' : if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_OCTAL3 ) ) { prev = p ; num = scan_unsigned_octal_number ( & p , end , ( c == '0' ? 2 : 3 ) , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 8 ; tok -> u . c = num ; } else if ( c != '0' ) { PINC ; } break ; # ifdef USE_NAMED_GROUP case 'k' : if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_K_NAMED_BACKREF ) ) { PFETCH ( c ) ; if ( c == '<' || c == '\\\\'' ) { UChar * name_end ; int * backs ; int back_num ; prev = p ; # ifdef USE_BACKREF_WITH_LEVEL name_end = NULL_UCHARP ; r = fetch_name_with_level ( ( OnigCodePoint ) c , & p , end , & name_end , env , & back_num , & tok -> u . backref . level ) ; if ( r == 1 ) tok -> u . backref . exist_level = 1 ; else tok -> u . backref . exist_level = 0 ; # else r = fetch_name ( & p , end , & name_end , env , & back_num , 1 ) ; # endif if ( r < 0 ) return r ; if ( back_num != 0 ) { if ( back_num < 0 ) { back_num = BACKREF_REL_TO_ABS ( back_num , env ) ; if ( back_num <= 0 ) return ONIGERR_INVALID_BACKREF ; } if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { if ( back_num > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ back_num ] ) ) return ONIGERR_INVALID_BACKREF ; } tok -> type = TK_BACKREF ; tok -> u . backref . by_name = 0 ; tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = back_num ; } else { num = onig_name_to_group_numbers ( env -> reg , prev , name_end , & backs ) ; if ( num <= 0 ) { onig_scan_env_set_error_string ( env , ONIGERR_UNDEFINED_NAME_REFERENCE , prev , name_end ) ; return ONIGERR_UNDEFINED_NAME_REFERENCE ; } if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { int i ; for ( i = 0 ; i < num ; i ++ ) { if ( backs [ i ] > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ backs [ i ] ] ) ) return ONIGERR_INVALID_BACKREF ; } } tok -> type = TK_BACKREF ; tok -> u . backref . by_name = 1 ; if ( num == 1 ) { tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = backs [ 0 ] ; } else { tok -> u . backref . num = num ; tok -> u . backref . refs = backs ; } } } else PUNFETCH ; } break ; # endif # ifdef USE_SUBEXP_CALL case 'g' : if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_G_SUBEXP_CALL ) ) { PFETCH ( c ) ; if ( c == '<' || c == '\\\\'' ) { int gnum ; UChar * name_end ; prev = p ; r = fetch_name ( ( OnigCodePoint ) c , & p , end , & name_end , env , & gnum , 1 ) ; if ( r < 0 ) return r ; tok -> type = TK_CALL ; tok -> u . call . name = prev ; tok -> u . call . name_end = name_end ; tok -> u . call . gnum = gnum ; } else PUNFETCH ; } break ; # endif case 'Q' : if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE ) ) { tok -> type = TK_QUOTE_OPEN ; } break ; case 'p' : case 'P' : if ( ! PEND && PPEEK_IS ( '{' ) && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY ) ) { PINC ; tok -> type = TK_CHAR_PROPERTY ; tok -> u . prop . not = ( c == 'P' ? 1 : 0 ) ; if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT ) ) { PFETCH ( c ) ; if ( c == '^' ) { tok -> u . prop . not = ( tok -> u . prop . not == 0 ? 1 : 0 ) ; } else PUNFETCH ; } } break ; default : { OnigCodePoint c2 ; PUNFETCH ; num = fetch_escaped_value ( & p , end , env , & c2 ) ; if ( num < 0 ) return num ; if ( tok -> u . c != c2 ) { tok -> type = TK_CODE_POINT ; tok -> u . code = c2 ; } else { p = tok -> backp + enclen ( enc , tok -> backp ) ; } } break ; } } else { tok -> u . c = c ; tok -> escaped = 0 ; # ifdef USE_VARIABLE_META_CHARS if ( ( c != ONIG_INEFFECTIVE_META_CHAR ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_VARIABLE_META_CHARACTERS ) ) { if ( c == MC_ANYCHAR ( syn ) ) goto any_char ; else if ( c == MC_ANYTIME ( syn ) ) goto anytime ; else if ( c == MC_ZERO_OR_ONE_TIME ( syn ) ) goto zero_or_one_time ; else if ( c == MC_ONE_OR_MORE_TIME ( syn ) ) goto one_or_more_time ; else if ( c == MC_ANYCHAR_ANYTIME ( syn ) ) { tok -> type = TK_ANYCHAR_ANYTIME ; goto out ; } } # endif switch ( c ) { case '.' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_DOT_ANYCHAR ) ) break ; # ifdef USE_VARIABLE_META_CHARS any_char : # endif tok -> type = TK_ANYCHAR ; break ; case '*' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ASTERISK_ZERO_INF ) ) break ; # ifdef USE_VARIABLE_META_CHARS anytime : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '+' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_PLUS_ONE_INF ) ) break ; # ifdef USE_VARIABLE_META_CHARS one_or_more_time : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 1 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '?' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_QMARK_ZERO_ONE ) ) break ; # ifdef USE_VARIABLE_META_CHARS zero_or_one_time : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = 1 ; goto greedy_check ; break ; case '{' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_BRACE_INTERVAL ) ) break ; r = fetch_range_quantifier ( & p , end , tok , env ) ; if ( r < 0 ) return r ; if ( r == 0 ) goto greedy_check ; else if ( r == 2 ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY ) ) goto possessive_check ; goto greedy_check ; } break ; case '|' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_VBAR_ALT ) ) break ; tok -> type = TK_ALT ; break ; case '(' : if ( ! PEND && PPEEK_IS ( '?' ) && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_QMARK_GROUP_EFFECT ) ) { PINC ; if ( ! PEND && PPEEK_IS ( '#' ) ) { PFETCH ( c ) ; while ( 1 ) { if ( PEND ) return ONIGERR_END_PATTERN_IN_GROUP ; PFETCH ( c ) ; if ( c == MC_ESC ( syn ) ) { if ( ! PEND ) PFETCH ( c ) ; } else { if ( c == ')' ) break ; } } goto start ; } PUNFETCH ; } if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_OPEN ; break ; case ')' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_CLOSE ; break ; case '^' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LINE_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ( IS_SINGLELINE ( env -> option ) ? ANCHOR_BEGIN_BUF : ANCHOR_BEGIN_LINE ) ; break ; case '$' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LINE_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ( IS_SINGLELINE ( env -> option ) ? ANCHOR_SEMI_END_BUF : ANCHOR_END_LINE ) ; break ; case '[' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_BRACKET_CC ) ) break ; tok -> type = TK_CC_OPEN ; break ; case ']' : if ( * src > env -> pattern ) CLOSE_BRACKET_WITHOUT_ESC_WARN ( env , ( UChar * ) \"]\" ) ; break ; case '#' : if ( IS_EXTEND ( env -> option ) ) { while ( ! PEND ) { PFETCH ( c ) ; if ( ONIGENC_IS_CODE_NEWLINE ( enc , c ) ) break ; } goto start ; break ; } break ; case '' : case '\\\\t' : case '\\\\n' : case '\\\\r' : case '\\\\f' : if ( IS_EXTEND ( env -> option ) ) goto start ; break ; default : break ; } } # ifdef USE_VARIABLE_META_CHARS out : # endif * src = p ; return tok -> type ; }\n", "\n", "\n", "Target: = line_end ; error = add_push_report_pkt\n", "\n", "Sources:\n", "0: CWE-476 static int add_push_report_sideband_pkt ( git_push * push , git_pkt_data * data_pkt , git_buf * data_pkt_buf ) { git_pkt * pkt ; const char * line , * line_end ; size_t line_len ; int error ; int reading_from_buf = data_pkt_buf -> size > 0 ; if ( reading_from_buf ) { git_buf_put ( data_pkt_buf , data_pkt -> data , data_pkt -> len ) ; line = data_pkt_buf -> ptr ; line_len = data_pkt_buf -> size ; } else { line = data_pkt -> data ; line_len = data_pkt -> len ; } while ( line_len > 0 ) { error = git_pkt_parse_line ( & pkt , line , & line_end , line_len ) ; if ( error == GIT_EBUFS ) { if ( ! reading_from_buf ) git_buf_put ( data_pkt_buf , line , line_len ) ; error = 0 ; goto done ; } else if ( error < 0 ) goto done ; line_len -= ( line_end - line ) ; line = line_end ; if ( pkt == NULL ) continue ; error = add_push_report_pkt ( push , pkt ) ; git_pkt_free ( pkt ) ; if ( error < 0 && error != GIT_ITEROVER ) goto done ; } error = 0 ; done : if ( reading_from_buf ) git_buf_consume ( data_pkt_buf , line_end ) ; return error ; }\n", "\n", "1: CWE-476 static int add_push_report_sideband_pkt ( git_push * push , git_pkt_data * data_pkt , git_buf * data_pkt_buf ) { git_pkt * pkt ; const char * line , * line_end = NULL ; size_t line_len ; int error ; int reading_from_buf = data_pkt_buf -> size > 0 ; if ( reading_from_buf ) { git_buf_put ( data_pkt_buf , data_pkt -> data , data_pkt -> len ) ; line = data_pkt_buf -> ptr ; line_len = data_pkt_buf -> size ; } else { line = data_pkt -> data ; line_len = data_pkt -> len ; } while ( line_len > 0 ) { error = git_pkt_parse_line ( & pkt , line , & line_end , line_len ) ; if ( error == GIT_EBUFS ) { if ( ! reading_from_buf ) git_buf_put ( data_pkt_buf , line , line_len ) ; error = 0 ; goto done ; } else if ( error < 0 ) goto done ; line_len -= ( line_end - line ) ; line = line_end ; if ( pkt == NULL ) continue ; error = add_push_report_pkt ( push , pkt ) ; git_pkt_free ( pkt ) ; if ( error < 0 && error != GIT_ITEROVER ) goto done ; } error = 0 ; done : if ( reading_from_buf ) git_buf_consume ( data_pkt_buf , line_end ) ; return error ; }\n", "\n", "\n", "Target: RAPTOR_OPTION_NO_FILE : case RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES : case\n", "\n", "Sources:\n", "0: CWE-200 int raptor_turtle_writer_get_option ( raptor_turtle_writer * turtle_writer , raptor_option option ) { int result = - 1 ; switch ( option ) { case RAPTOR_OPTION_WRITER_AUTO_INDENT : result = TURTLE_WRITER_AUTO_INDENT ( turtle_writer ) ; break ; case RAPTOR_OPTION_WRITER_INDENT_WIDTH : result = turtle_writer -> indent ; break ; case RAPTOR_OPTION_WRITER_AUTO_EMPTY : case RAPTOR_OPTION_WRITER_XML_VERSION : case RAPTOR_OPTION_WRITER_XML_DECLARATION : case RAPTOR_OPTION_SCANNING : case RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES : case RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES : case RAPTOR_OPTION_ALLOW_BAGID : case RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST : case RAPTOR_OPTION_NORMALIZE_LANGUAGE : case RAPTOR_OPTION_NON_NFC_FATAL : case RAPTOR_OPTION_WARN_OTHER_PARSETYPES : case RAPTOR_OPTION_CHECK_RDF_ID : case RAPTOR_OPTION_HTML_TAG_SOUP : case RAPTOR_OPTION_MICROFORMATS : case RAPTOR_OPTION_HTML_LINK : case RAPTOR_OPTION_WWW_TIMEOUT : case RAPTOR_OPTION_STRICT : case RAPTOR_OPTION_NO_NET : case RAPTOR_OPTION_NO_FILE : case RAPTOR_OPTION_RELATIVE_URIS : case RAPTOR_OPTION_RESOURCE_BORDER : case RAPTOR_OPTION_LITERAL_BORDER : case RAPTOR_OPTION_BNODE_BORDER : case RAPTOR_OPTION_RESOURCE_FILL : case RAPTOR_OPTION_LITERAL_FILL : case RAPTOR_OPTION_BNODE_FILL : case RAPTOR_OPTION_JSON_CALLBACK : case RAPTOR_OPTION_JSON_EXTRA_DATA : case RAPTOR_OPTION_RSS_TRIPLES : case RAPTOR_OPTION_ATOM_ENTRY_URI : case RAPTOR_OPTION_PREFIX_ELEMENTS : case RAPTOR_OPTION_WRITE_BASE_URI : case RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL : case RAPTOR_OPTION_WWW_HTTP_USER_AGENT : case RAPTOR_OPTION_WWW_CERT_FILENAME : case RAPTOR_OPTION_WWW_CERT_TYPE : case RAPTOR_OPTION_WWW_CERT_PASSPHRASE : case RAPTOR_OPTION_WWW_SSL_VERIFY_PEER : case RAPTOR_OPTION_WWW_SSL_VERIFY_HOST : default : break ; } return result ; }\n", "\n", "1: CWE-200 int raptor_turtle_writer_set_option ( raptor_turtle_writer * turtle_writer , raptor_option option , int value ) { if ( value < 0 || ! raptor_option_is_valid_for_area ( option , RAPTOR_OPTION_AREA_TURTLE_WRITER ) ) return 1 ; switch ( option ) { case RAPTOR_OPTION_WRITER_AUTO_INDENT : if ( value ) turtle_writer -> flags |= TURTLE_WRITER_AUTO_INDENT ; else turtle_writer -> flags &= ~ TURTLE_WRITER_AUTO_INDENT ; break ; case RAPTOR_OPTION_WRITER_INDENT_WIDTH : turtle_writer -> indent = value ; break ; case RAPTOR_OPTION_WRITER_AUTO_EMPTY : case RAPTOR_OPTION_WRITER_XML_VERSION : case RAPTOR_OPTION_WRITER_XML_DECLARATION : break ; case RAPTOR_OPTION_SCANNING : case RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES : case RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES : case RAPTOR_OPTION_ALLOW_BAGID : case RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST : case RAPTOR_OPTION_NORMALIZE_LANGUAGE : case RAPTOR_OPTION_NON_NFC_FATAL : case RAPTOR_OPTION_WARN_OTHER_PARSETYPES : case RAPTOR_OPTION_CHECK_RDF_ID : case RAPTOR_OPTION_HTML_TAG_SOUP : case RAPTOR_OPTION_MICROFORMATS : case RAPTOR_OPTION_HTML_LINK : case RAPTOR_OPTION_WWW_TIMEOUT : case RAPTOR_OPTION_STRICT : case RAPTOR_OPTION_NO_NET : case RAPTOR_OPTION_NO_FILE : case RAPTOR_OPTION_RELATIVE_URIS : case RAPTOR_OPTION_RESOURCE_BORDER : case RAPTOR_OPTION_LITERAL_BORDER : case RAPTOR_OPTION_BNODE_BORDER : case RAPTOR_OPTION_RESOURCE_FILL : case RAPTOR_OPTION_LITERAL_FILL : case RAPTOR_OPTION_BNODE_FILL : case RAPTOR_OPTION_JSON_CALLBACK : case RAPTOR_OPTION_JSON_EXTRA_DATA : case RAPTOR_OPTION_RSS_TRIPLES : case RAPTOR_OPTION_ATOM_ENTRY_URI : case RAPTOR_OPTION_PREFIX_ELEMENTS : case RAPTOR_OPTION_WRITE_BASE_URI : case RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL : case RAPTOR_OPTION_WWW_HTTP_USER_AGENT : case RAPTOR_OPTION_WWW_CERT_FILENAME : case RAPTOR_OPTION_WWW_CERT_TYPE : case RAPTOR_OPTION_WWW_CERT_PASSPHRASE : case RAPTOR_OPTION_WWW_SSL_VERIFY_PEER : case RAPTOR_OPTION_WWW_SSL_VERIFY_HOST : default : return - 1 ; break ; } return 0 ; }\n", "\n", "\n", "Target: const Image * images ) { const Image * next ; PixelChannels * * i ; size_t columns , ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; ) AcquireQuantumMemory ( columns , sizeof ( * ( ssize_t ) columns ; j\n", "\n", "Sources:\n", "0: CWE-119 static PixelChannels * * AcquirePixelThreadSet ( const Image * image ) { PixelChannels * * pixels ; register ssize_t i ; size_t number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( PixelChannels * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( PixelChannels * * ) NULL ) return ( ( PixelChannels * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { register ssize_t j ; pixels [ i ] = ( PixelChannels * ) AcquireQuantumMemory ( image -> columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( PixelChannels * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { register ssize_t k ; for ( k = 0 ; k < MaxPixelChannels ; k ++ ) pixels [ i ] [ j ] . channel [ k ] = 0.0 ; } } return ( pixels ) ; }\n", "\n", "1: CWE-787 static PixelChannels * * AcquirePixelThreadSet ( const Image * image ) { PixelChannels * * pixels ; register ssize_t i ; size_t number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( PixelChannels * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( PixelChannels * * ) NULL ) return ( ( PixelChannels * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { register ssize_t j ; pixels [ i ] = ( PixelChannels * ) AcquireQuantumMemory ( image -> columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( PixelChannels * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { register ssize_t k ; for ( k = 0 ; k < MaxPixelChannels ; k ++ ) pixels [ i ] [ j ] . channel [ k ] = 0.0 ; } } return ( pixels ) ; }\n", "\n", "\n", "Target: char * name ; name = , NULL , NULL , NULL ,\n", "\n", "Sources:\n", "0: CWE-326 static VALUE ossl_cipher_initialize ( VALUE self , VALUE str ) { EVP_CIPHER_CTX * ctx ; const EVP_CIPHER * cipher ; char * name ; unsigned char dummy_key [ EVP_MAX_KEY_LENGTH ] = { 0 } ; name = StringValueCStr ( str ) ; GetCipherInit ( self , ctx ) ; if ( ctx ) { ossl_raise ( rb_eRuntimeError , \"Cipheralreadyinititalized!\" ) ; } AllocCipher ( self , ctx ) ; if ( ! ( cipher = EVP_get_cipherbyname ( name ) ) ) { ossl_raise ( rb_eRuntimeError , \"unsupportedcipheralgorithm(%\" PRIsVALUE \")\" , str ) ; } if ( EVP_CipherInit_ex ( ctx , cipher , NULL , dummy_key , NULL , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; return self ; }\n", "\n", "1: CWE-310 static VALUE ossl_cipher_initialize ( VALUE self , VALUE str ) { EVP_CIPHER_CTX * ctx ; const EVP_CIPHER * cipher ; char * name ; unsigned char dummy_key [ EVP_MAX_KEY_LENGTH ] = { 0 } ; name = StringValueCStr ( str ) ; GetCipherInit ( self , ctx ) ; if ( ctx ) { ossl_raise ( rb_eRuntimeError , \"Cipheralreadyinititalized!\" ) ; } AllocCipher ( self , ctx ) ; if ( ! ( cipher = EVP_get_cipherbyname ( name ) ) ) { ossl_raise ( rb_eRuntimeError , \"unsupportedcipheralgorithm(%\" PRIsVALUE \")\" , str ) ; } if ( EVP_CipherInit_ex ( ctx , cipher , NULL , dummy_key , NULL , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; return self ; }\n", "\n", "\n", "Target: ; queueItem -> interface = interface ; queueItem ->\n", "\n", "Sources:\n", "0: CWE-20 void rawSocketProcessEthPacket ( NetInterface * interface , EthHeader * header , const uint8_t * data , size_t length , NetRxAncillary * ancillary ) { uint_t i ; Socket * socket ; SocketQueueItem * queueItem ; NetBuffer * p ; for ( i = 0 ; i < SOCKET_MAX_COUNT ; i ++ ) { socket = socketTable + i ; if ( socket -> type != SOCKET_TYPE_RAW_ETH ) continue ; if ( socket -> interface && socket -> interface != interface ) continue ; if ( socket -> protocol == SOCKET_ETH_PROTO_ALL ) { } else if ( socket -> protocol == SOCKET_ETH_PROTO_LLC ) { if ( ntohs ( header -> type ) > ETH_MTU ) continue ; } else { if ( ntohs ( header -> type ) != socket -> protocol ) continue ; } break ; } if ( i >= SOCKET_MAX_COUNT ) return ; if ( socket -> receiveQueue == NULL ) { p = netBufferAlloc ( sizeof ( SocketQueueItem ) + sizeof ( EthHeader ) + length ) ; if ( p != NULL ) { queueItem = netBufferAt ( p , 0 ) ; queueItem -> buffer = p ; socket -> receiveQueue = queueItem ; } else { queueItem = NULL ; } } else { queueItem = socket -> receiveQueue ; for ( i = 1 ; queueItem -> next ; i ++ ) { queueItem = queueItem -> next ; } if ( i >= RAW_SOCKET_RX_QUEUE_SIZE ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ; } p = netBufferAlloc ( sizeof ( SocketQueueItem ) + sizeof ( EthHeader ) + length ) ; if ( p != NULL ) { queueItem -> next = netBufferAt ( p , 0 ) ; queueItem = queueItem -> next ; queueItem -> buffer = p ; } else { queueItem = NULL ; } } if ( queueItem == NULL ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ; } queueItem -> next = NULL ; queueItem -> srcPort = 0 ; queueItem -> srcIpAddr = IP_ADDR_ANY ; queueItem -> destIpAddr = IP_ADDR_ANY ; queueItem -> offset = sizeof ( SocketQueueItem ) ; netBufferWrite ( queueItem -> buffer , queueItem -> offset , header , sizeof ( EthHeader ) ) ; netBufferWrite ( queueItem -> buffer , queueItem -> offset + sizeof ( EthHeader ) , data , length ) ; queueItem -> ancillary = * ancillary ; rawSocketUpdateEvents ( socket ) ; }\n", "\n", "1: CWE-20 error_t rawSocketProcessIpPacket ( NetInterface * interface , IpPseudoHeader * pseudoHeader , const NetBuffer * buffer , size_t offset , NetRxAncillary * ancillary ) { uint_t i ; size_t length ; Socket * socket ; SocketQueueItem * queueItem ; NetBuffer * p ; length = netBufferGetLength ( buffer ) - offset ; for ( i = 0 ; i < SOCKET_MAX_COUNT ; i ++ ) { socket = socketTable + i ; if ( socket -> type != SOCKET_TYPE_RAW_IP ) continue ; if ( socket -> interface && socket -> interface != interface ) continue ; # if ( IPV4_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv4PseudoHeader ) ) { if ( socket -> protocol != pseudoHeader -> ipv4Data . protocol ) continue ; if ( socket -> localIpAddr . length != 0 ) { if ( socket -> localIpAddr . length != sizeof ( Ipv4Addr ) ) continue ; if ( socket -> localIpAddr . ipv4Addr != pseudoHeader -> ipv4Data . destAddr ) continue ; } if ( socket -> remoteIpAddr . length != 0 ) { if ( socket -> remoteIpAddr . length != sizeof ( Ipv4Addr ) ) continue ; if ( socket -> remoteIpAddr . ipv4Addr != pseudoHeader -> ipv4Data . srcAddr ) continue ; } } else # endif # if ( IPV6_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { if ( socket -> protocol != pseudoHeader -> ipv6Data . nextHeader ) continue ; if ( socket -> localIpAddr . length != 0 ) { if ( socket -> localIpAddr . length != sizeof ( Ipv6Addr ) ) continue ; if ( ! ipv6CompAddr ( & socket -> localIpAddr . ipv6Addr , & pseudoHeader -> ipv6Data . destAddr ) ) continue ; } if ( socket -> remoteIpAddr . length != 0 ) { if ( socket -> remoteIpAddr . length != sizeof ( Ipv6Addr ) ) continue ; if ( ! ipv6CompAddr ( & socket -> remoteIpAddr . ipv6Addr , & pseudoHeader -> ipv6Data . srcAddr ) ) continue ; } } else # endif { continue ; } break ; } if ( i >= SOCKET_MAX_COUNT ) return ERROR_PROTOCOL_UNREACHABLE ; if ( socket -> receiveQueue == NULL ) { p = netBufferAlloc ( sizeof ( SocketQueueItem ) + length ) ; if ( p != NULL ) { queueItem = netBufferAt ( p , 0 ) ; queueItem -> buffer = p ; socket -> receiveQueue = queueItem ; } else { queueItem = NULL ; } } else { queueItem = socket -> receiveQueue ; for ( i = 1 ; queueItem -> next ; i ++ ) { queueItem = queueItem -> next ; } if ( i >= RAW_SOCKET_RX_QUEUE_SIZE ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ERROR_RECEIVE_QUEUE_FULL ; } p = netBufferAlloc ( sizeof ( SocketQueueItem ) + length ) ; if ( p != NULL ) { queueItem -> next = netBufferAt ( p , 0 ) ; queueItem = queueItem -> next ; queueItem -> buffer = p ; } else { queueItem = NULL ; } } if ( queueItem == NULL ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ERROR_OUT_OF_MEMORY ; } queueItem -> next = NULL ; queueItem -> srcPort = 0 ; # if ( IPV4_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv4PseudoHeader ) ) { queueItem -> srcIpAddr . length = sizeof ( Ipv4Addr ) ; queueItem -> srcIpAddr . ipv4Addr = pseudoHeader -> ipv4Data . srcAddr ; queueItem -> destIpAddr . length = sizeof ( Ipv4Addr ) ; queueItem -> destIpAddr . ipv4Addr = pseudoHeader -> ipv4Data . destAddr ; } # endif # if ( IPV6_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { queueItem -> srcIpAddr . length = sizeof ( Ipv6Addr ) ; queueItem -> srcIpAddr . ipv6Addr = pseudoHeader -> ipv6Data . srcAddr ; queueItem -> destIpAddr . length = sizeof ( Ipv6Addr ) ; queueItem -> destIpAddr . ipv6Addr = pseudoHeader -> ipv6Data . destAddr ; } # endif queueItem -> offset = sizeof ( SocketQueueItem ) ; netBufferCopy ( queueItem -> buffer , queueItem -> offset , buffer , offset , length ) ; queueItem -> ancillary = * ancillary ; rawSocketUpdateEvents ( socket ) ; return NO_ERROR ; }\n", "\n", "2: CWE-20 error_t udpProcessDatagram ( NetInterface * interface , IpPseudoHeader * pseudoHeader , const NetBuffer * buffer , size_t offset , NetRxAncillary * ancillary ) { error_t error ; uint_t i ; size_t length ; UdpHeader * header ; Socket * socket ; SocketQueueItem * queueItem ; NetBuffer * p ; length = netBufferGetLength ( buffer ) - offset ; if ( length < sizeof ( UdpHeader ) ) { MIB2_INC_COUNTER32 ( udpGroup . udpInErrors , 1 ) ; UDP_MIB_INC_COUNTER32 ( udpInErrors , 1 ) ; return ERROR_INVALID_HEADER ; } header = netBufferAt ( buffer , offset ) ; if ( header == NULL ) return ERROR_FAILURE ; TRACE_INFO ( \"UDPdatagramreceived(%\" PRIuSIZE \"bytes)...\\\\r\\\\n\" , length ) ; udpDumpHeader ( header ) ; if ( header -> checksum != 0x0000 || pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { if ( ipCalcUpperLayerChecksumEx ( pseudoHeader -> data , pseudoHeader -> length , buffer , offset , length ) != 0x0000 ) { TRACE_WARNING ( \"WrongUDPheaderchecksum!\\\\r\\\\n\" ) ; MIB2_INC_COUNTER32 ( udpGroup . udpInErrors , 1 ) ; UDP_MIB_INC_COUNTER32 ( udpInErrors , 1 ) ; return ERROR_WRONG_CHECKSUM ; } } for ( i = 0 ; i < SOCKET_MAX_COUNT ; i ++ ) { socket = socketTable + i ; if ( socket -> type != SOCKET_TYPE_DGRAM ) continue ; if ( socket -> interface && socket -> interface != interface ) continue ; if ( socket -> localPort == 0 || socket -> localPort != ntohs ( header -> destPort ) ) continue ; if ( socket -> remotePort != 0 && socket -> remotePort != ntohs ( header -> srcPort ) ) continue ; # if ( IPV4_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv4PseudoHeader ) ) { if ( socket -> localIpAddr . length != 0 ) { if ( socket -> localIpAddr . length != sizeof ( Ipv4Addr ) ) continue ; if ( socket -> localIpAddr . ipv4Addr != pseudoHeader -> ipv4Data . destAddr ) continue ; } if ( socket -> remoteIpAddr . length != 0 ) { if ( socket -> remoteIpAddr . length != sizeof ( Ipv4Addr ) ) continue ; if ( socket -> remoteIpAddr . ipv4Addr != pseudoHeader -> ipv4Data . srcAddr ) continue ; } } else # endif # if ( IPV6_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { if ( socket -> localIpAddr . length != 0 ) { if ( socket -> localIpAddr . length != sizeof ( Ipv6Addr ) ) continue ; if ( ! ipv6CompAddr ( & socket -> localIpAddr . ipv6Addr , & pseudoHeader -> ipv6Data . destAddr ) ) continue ; } if ( socket -> remoteIpAddr . length != 0 ) { if ( socket -> remoteIpAddr . length != sizeof ( Ipv6Addr ) ) continue ; if ( ! ipv6CompAddr ( & socket -> remoteIpAddr . ipv6Addr , & pseudoHeader -> ipv6Data . srcAddr ) ) continue ; } } else # endif { continue ; } break ; } offset += sizeof ( UdpHeader ) ; length -= sizeof ( UdpHeader ) ; if ( i >= SOCKET_MAX_COUNT ) { error = udpInvokeRxCallback ( interface , pseudoHeader , header , buffer , offset , ancillary ) ; return error ; } if ( socket -> receiveQueue == NULL ) { p = netBufferAlloc ( sizeof ( SocketQueueItem ) + length ) ; if ( p != NULL ) { queueItem = netBufferAt ( p , 0 ) ; queueItem -> buffer = p ; socket -> receiveQueue = queueItem ; } else { queueItem = NULL ; } } else { queueItem = socket -> receiveQueue ; for ( i = 1 ; queueItem -> next ; i ++ ) { queueItem = queueItem -> next ; } if ( i >= UDP_RX_QUEUE_SIZE ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ERROR_RECEIVE_QUEUE_FULL ; } p = netBufferAlloc ( sizeof ( SocketQueueItem ) + length ) ; if ( p != NULL ) { queueItem -> next = netBufferAt ( p , 0 ) ; queueItem = queueItem -> next ; queueItem -> buffer = p ; } else { queueItem = NULL ; } } if ( queueItem == NULL ) { MIB2_INC_COUNTER32 ( ifGroup . ifTable [ interface -> index ] . ifInDiscards , 1 ) ; IF_MIB_INC_COUNTER32 ( ifTable [ interface -> index ] . ifInDiscards , 1 ) ; return ERROR_OUT_OF_MEMORY ; } queueItem -> next = NULL ; queueItem -> srcPort = ntohs ( header -> srcPort ) ; # if ( IPV4_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv4PseudoHeader ) ) { queueItem -> srcIpAddr . length = sizeof ( Ipv4Addr ) ; queueItem -> srcIpAddr . ipv4Addr = pseudoHeader -> ipv4Data . srcAddr ; queueItem -> destIpAddr . length = sizeof ( Ipv4Addr ) ; queueItem -> destIpAddr . ipv4Addr = pseudoHeader -> ipv4Data . destAddr ; } # endif # if ( IPV6_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { queueItem -> srcIpAddr . length = sizeof ( Ipv6Addr ) ; queueItem -> srcIpAddr . ipv6Addr = pseudoHeader -> ipv6Data . srcAddr ; queueItem -> destIpAddr . length = sizeof ( Ipv6Addr ) ; queueItem -> destIpAddr . ipv6Addr = pseudoHeader -> ipv6Data . destAddr ; } # endif queueItem -> offset = sizeof ( SocketQueueItem ) ; netBufferCopy ( queueItem -> buffer , queueItem -> offset , buffer , offset , length ) ; queueItem -> ancillary = * ancillary ; udpUpdateEvents ( socket ) ; MIB2_INC_COUNTER32 ( udpGroup . udpInDatagrams , 1 ) ; UDP_MIB_INC_COUNTER32 ( udpInDatagrams , 1 ) ; UDP_MIB_INC_COUNTER64 ( udpHCInDatagrams , 1 ) ; return NO_ERROR ; }\n", "\n", "\n", "Target: o ) { Py_RETURN_NONE ; } switch\n", "\n", "Sources:\n", "0: CWE-125 PyObject * ast2obj_type_ignore ( void * _o ) { type_ignore_ty o = ( type_ignore_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case TypeIgnore_kind : result = PyType_GenericNew ( TypeIgnore_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_int ( o -> v . TypeIgnore . lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "1: CWE-125 PyObject * ast2obj_stmt ( void * _o ) { stmt_ty o = ( stmt_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case FunctionDef_kind : result = PyType_GenericNew ( FunctionDef_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . FunctionDef . name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_arguments ( o -> v . FunctionDef . args ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . FunctionDef . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . FunctionDef . decorator_list , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_decorator_list , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . FunctionDef . returns ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_returns , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . FunctionDef . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case AsyncFunctionDef_kind : result = PyType_GenericNew ( AsyncFunctionDef_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . AsyncFunctionDef . name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_arguments ( o -> v . AsyncFunctionDef . args ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . AsyncFunctionDef . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . AsyncFunctionDef . decorator_list , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_decorator_list , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . AsyncFunctionDef . returns ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_returns , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . AsyncFunctionDef . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ClassDef_kind : result = PyType_GenericNew ( ClassDef_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . ClassDef . name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ClassDef . bases , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_bases , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ClassDef . keywords , ast2obj_keyword ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_keywords , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ClassDef . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ClassDef . decorator_list , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_decorator_list , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Return_kind : result = PyType_GenericNew ( Return_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Return . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Delete_kind : result = PyType_GenericNew ( Delete_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Delete . targets , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_targets , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Assign_kind : result = PyType_GenericNew ( Assign_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Assign . targets , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_targets , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Assign . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . Assign . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case AugAssign_kind : result = PyType_GenericNew ( AugAssign_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . AugAssign . target ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_target , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_operator ( o -> v . AugAssign . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . AugAssign . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case AnnAssign_kind : result = PyType_GenericNew ( AnnAssign_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . AnnAssign . target ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_target , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . AnnAssign . annotation ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_annotation , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . AnnAssign . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> v . AnnAssign . simple ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_simple , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case For_kind : result = PyType_GenericNew ( For_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . For . target ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_target , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . For . iter ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_iter , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . For . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . For . orelse , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . For . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case AsyncFor_kind : result = PyType_GenericNew ( AsyncFor_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . AsyncFor . target ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_target , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . AsyncFor . iter ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_iter , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . AsyncFor . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . AsyncFor . orelse , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . AsyncFor . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case While_kind : result = PyType_GenericNew ( While_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . While . test ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_test , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . While . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . While . orelse , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case If_kind : result = PyType_GenericNew ( If_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . If . test ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_test , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . If . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . If . orelse , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case With_kind : result = PyType_GenericNew ( With_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . With . items , ast2obj_withitem ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_items , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . With . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . With . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case AsyncWith_kind : result = PyType_GenericNew ( AsyncWith_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . AsyncWith . items , ast2obj_withitem ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_items , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . AsyncWith . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . AsyncWith . type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Raise_kind : result = PyType_GenericNew ( Raise_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Raise . exc ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_exc , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Raise . cause ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_cause , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Try_kind : result = PyType_GenericNew ( Try_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Try . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Try . handlers , ast2obj_excepthandler ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_handlers , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Try . orelse , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Try . finalbody , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_finalbody , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Assert_kind : result = PyType_GenericNew ( Assert_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Assert . test ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_test , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Assert . msg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_msg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Import_kind : result = PyType_GenericNew ( Import_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Import . names , ast2obj_alias ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_names , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ImportFrom_kind : result = PyType_GenericNew ( ImportFrom_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . ImportFrom . module ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_module , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ImportFrom . names , ast2obj_alias ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_names , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> v . ImportFrom . level ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_level , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Global_kind : result = PyType_GenericNew ( Global_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Global . names , ast2obj_identifier ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_names , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Nonlocal_kind : result = PyType_GenericNew ( Nonlocal_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Nonlocal . names , ast2obj_identifier ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_names , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Expr_kind : result = PyType_GenericNew ( Expr_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Expr . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Pass_kind : result = PyType_GenericNew ( Pass_type , NULL , NULL ) ; if ( ! result ) goto failed ; break ; case Break_kind : result = PyType_GenericNew ( Break_type , NULL , NULL ) ; if ( ! result ) goto failed ; break ; case Continue_kind : result = PyType_GenericNew ( Continue_type , NULL , NULL ) ; if ( ! result ) goto failed ; break ; } value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "2: CWE-125 PyObject * ast2obj_slice ( void * _o ) { slice_ty o = ( slice_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case Slice_kind : result = PyType_GenericNew ( Slice_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Slice . lower ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lower , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Slice . upper ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_upper , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Slice . step ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_step , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ExtSlice_kind : result = PyType_GenericNew ( ExtSlice_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . ExtSlice . dims , ast2obj_slice ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_dims , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Index_kind : result = PyType_GenericNew ( Index_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Index . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "3: CWE-125 PyObject * ast2obj_expr ( void * _o ) { expr_ty o = ( expr_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case BoolOp_kind : result = PyType_GenericNew ( BoolOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_boolop ( o -> v . BoolOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . BoolOp . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case BinOp_kind : result = PyType_GenericNew ( BinOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . BinOp . left ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_left , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_operator ( o -> v . BinOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . BinOp . right ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_right , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case UnaryOp_kind : result = PyType_GenericNew ( UnaryOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_unaryop ( o -> v . UnaryOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . UnaryOp . operand ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_operand , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Lambda_kind : result = PyType_GenericNew ( Lambda_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_arguments ( o -> v . Lambda . args ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Lambda . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case IfExp_kind : result = PyType_GenericNew ( IfExp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . IfExp . test ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_test , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . IfExp . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . IfExp . orelse ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Dict_kind : result = PyType_GenericNew ( Dict_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Dict . keys , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_keys , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Dict . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Set_kind : result = PyType_GenericNew ( Set_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Set . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ListComp_kind : result = PyType_GenericNew ( ListComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . ListComp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ListComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case SetComp_kind : result = PyType_GenericNew ( SetComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . SetComp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . SetComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case DictComp_kind : result = PyType_GenericNew ( DictComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . DictComp . key ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_key , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . DictComp . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . DictComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case GeneratorExp_kind : result = PyType_GenericNew ( GeneratorExp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . GeneratorExp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . GeneratorExp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Await_kind : result = PyType_GenericNew ( Await_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Await . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Yield_kind : result = PyType_GenericNew ( Yield_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Yield . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case YieldFrom_kind : result = PyType_GenericNew ( YieldFrom_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . YieldFrom . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Compare_kind : result = PyType_GenericNew ( Compare_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Compare . left ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_left , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; { Py_ssize_t i , n = asdl_seq_LEN ( o -> v . Compare . ops ) ; value = PyList_New ( n ) ; if ( ! value ) goto failed ; for ( i = 0 ; i < n ; i ++ ) PyList_SET_ITEM ( value , i , ast2obj_cmpop ( ( cmpop_ty ) asdl_seq_GET ( o -> v . Compare . ops , i ) ) ) ; } if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ops , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Compare . comparators , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_comparators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Call_kind : result = PyType_GenericNew ( Call_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Call . func ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_func , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Call . args , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Call . keywords , ast2obj_keyword ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_keywords , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Num_kind : result = PyType_GenericNew ( Num_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_object ( o -> v . Num . n ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_n , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Str_kind : result = PyType_GenericNew ( Str_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_string ( o -> v . Str . s ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_s , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . Str . kind ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_kind , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case FormattedValue_kind : result = PyType_GenericNew ( FormattedValue_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . FormattedValue . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> v . FormattedValue . conversion ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_conversion , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . FormattedValue . format_spec ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_format_spec , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case JoinedStr_kind : result = PyType_GenericNew ( JoinedStr_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . JoinedStr . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Bytes_kind : result = PyType_GenericNew ( Bytes_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_bytes ( o -> v . Bytes . s ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_s , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case NameConstant_kind : result = PyType_GenericNew ( NameConstant_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_singleton ( o -> v . NameConstant . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Ellipsis_kind : result = PyType_GenericNew ( Ellipsis_type , NULL , NULL ) ; if ( ! result ) goto failed ; break ; case Constant_kind : result = PyType_GenericNew ( Constant_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_constant ( o -> v . Constant . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Attribute_kind : result = PyType_GenericNew ( Attribute_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Attribute . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_identifier ( o -> v . Attribute . attr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_attr , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Attribute . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Subscript_kind : result = PyType_GenericNew ( Subscript_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Subscript . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_slice ( o -> v . Subscript . slice ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_slice , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Subscript . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Starred_kind : result = PyType_GenericNew ( Starred_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Starred . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Starred . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Name_kind : result = PyType_GenericNew ( Name_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . Name . id ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_id , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Name . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case List_kind : result = PyType_GenericNew ( List_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . List . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . List . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Tuple_kind : result = PyType_GenericNew ( Tuple_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Tuple . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Tuple . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "\n", "Target: ) ] ; struct nf_conn * ct = exp -> master ; union nf_inet_addr newaddr ; unsigned int ret ; newaddr = ct -> tuplehash [ IP_CT_DIR_REPLY ] . tuple . dst . u3 ( skb , ct , \"allportsinuse\" ) NF_DROP ; } snprintf ( buffer , sizeof ( buffer ) , \"%u%u\" , ntohl ( newaddr . ip ) , port ) ; pr_debug ( \"nf_nat_irc:inserting\\'%s\\'==%pI4,port%u\\\\n\" , buffer , & newaddr . ip , port ) ; ( skb , ct , ctinfo , ( skb , ct , \"cannotmanglepacket\" )\n", "\n", "Sources:\n", "0: CWE-200 static unsigned int help ( struct sk_buff * skb , enum ip_conntrack_info ctinfo , unsigned int protoff , unsigned int matchoff , unsigned int matchlen , struct nf_conntrack_expect * exp ) { char buffer [ sizeof ( \"429496729665635\" ) ] ; u_int16_t port ; unsigned int ret ; exp -> saved_proto . tcp . port = exp -> tuple . dst . u . tcp . port ; exp -> dir = IP_CT_DIR_REPLY ; exp -> expectfn = nf_nat_follow_master ; for ( port = ntohs ( exp -> saved_proto . tcp . port ) ; port != 0 ; port ++ ) { int ret ; exp -> tuple . dst . u . tcp . port = htons ( port ) ; ret = nf_ct_expect_related ( exp ) ; if ( ret == 0 ) break ; else if ( ret != - EBUSY ) { port = 0 ; break ; } } if ( port == 0 ) { nf_ct_helper_log ( skb , exp -> master , \"allportsinuse\" ) ; return NF_DROP ; } ret = nf_nat_mangle_tcp_packet ( skb , exp -> master , ctinfo , protoff , matchoff , matchlen , buffer , strlen ( buffer ) ) ; if ( ret != NF_ACCEPT ) { nf_ct_helper_log ( skb , exp -> master , \"cannotmanglepacket\" ) ; nf_ct_unexpect_related ( exp ) ; } return ret ; }\n", "\n", "1: CWE-119 static unsigned int help ( struct sk_buff * skb , enum ip_conntrack_info ctinfo , unsigned int protoff , unsigned int matchoff , unsigned int matchlen , struct nf_conntrack_expect * exp ) { char buffer [ sizeof ( \"429496729665635\" ) ] ; u_int16_t port ; unsigned int ret ; exp -> saved_proto . tcp . port = exp -> tuple . dst . u . tcp . port ; exp -> dir = IP_CT_DIR_REPLY ; exp -> expectfn = nf_nat_follow_master ; for ( port = ntohs ( exp -> saved_proto . tcp . port ) ; port != 0 ; port ++ ) { int ret ; exp -> tuple . dst . u . tcp . port = htons ( port ) ; ret = nf_ct_expect_related ( exp ) ; if ( ret == 0 ) break ; else if ( ret != - EBUSY ) { port = 0 ; break ; } } if ( port == 0 ) { nf_ct_helper_log ( skb , exp -> master , \"allportsinuse\" ) ; return NF_DROP ; } ret = nf_nat_mangle_tcp_packet ( skb , exp -> master , ctinfo , protoff , matchoff , matchlen , buffer , strlen ( buffer ) ) ; if ( ret != NF_ACCEPT ) { nf_ct_helper_log ( skb , exp -> master , \"cannotmanglepacket\" ) ; nf_ct_unexpect_related ( exp ) ; } return ret ; }\n", "\n", "\n", "Target: val , regs ) ; }\n", "\n", "Sources:\n", "0: CWE-399 static void perf_event_interrupt ( struct pt_regs * regs ) { int i ; struct cpu_hw_events * cpuhw = & __get_cpu_var ( cpu_hw_events ) ; struct perf_event * event ; unsigned long val ; int found = 0 ; int nmi ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { event = cpuhw -> event [ i ] ; val = read_pmc ( i ) ; if ( ( int ) val < 0 ) { if ( event ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } else { write_pmc ( i , 0 ) ; } } } mtmsr ( mfmsr ( ) | MSR_PMM ) ; mtpmr ( PMRN_PMGC0 , PMGC0_PMIE | PMGC0_FCECE ) ; isync ( ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; }\n", "\n", "1: CWE-399 static void perf_event_interrupt ( struct pt_regs * regs ) { int i ; struct cpu_hw_events * cpuhw = & __get_cpu_var ( cpu_hw_events ) ; struct perf_event * event ; unsigned long val ; int found = 0 ; int nmi ; if ( cpuhw -> n_limited ) freeze_limited_counters ( cpuhw , mfspr ( SPRN_PMC5 ) , mfspr ( SPRN_PMC6 ) ) ; perf_read_regs ( regs ) ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < cpuhw -> n_events ; ++ i ) { event = cpuhw -> event [ i ] ; if ( ! event -> hw . idx || is_limited_pmc ( event -> hw . idx ) ) continue ; val = read_pmc ( event -> hw . idx ) ; if ( ( int ) val < 0 ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } } if ( ! found ) { for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { if ( is_limited_pmc ( i + 1 ) ) continue ; val = read_pmc ( i + 1 ) ; if ( pmc_overflow ( val ) ) write_pmc ( i + 1 , 0 ) ; } } write_mmcr0 ( cpuhw , cpuhw -> mmcr [ 0 ] ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; }\n", "\n", "2: CWE-400 static void perf_event_interrupt ( struct pt_regs * regs ) { int i ; struct cpu_hw_events * cpuhw = & __get_cpu_var ( cpu_hw_events ) ; struct perf_event * event ; unsigned long val ; int found = 0 ; int nmi ; if ( cpuhw -> n_limited ) freeze_limited_counters ( cpuhw , mfspr ( SPRN_PMC5 ) , mfspr ( SPRN_PMC6 ) ) ; perf_read_regs ( regs ) ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < cpuhw -> n_events ; ++ i ) { event = cpuhw -> event [ i ] ; if ( ! event -> hw . idx || is_limited_pmc ( event -> hw . idx ) ) continue ; val = read_pmc ( event -> hw . idx ) ; if ( ( int ) val < 0 ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } } if ( ! found ) { for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { if ( is_limited_pmc ( i + 1 ) ) continue ; val = read_pmc ( i + 1 ) ; if ( pmc_overflow ( val ) ) write_pmc ( i + 1 , 0 ) ; } } write_mmcr0 ( cpuhw , cpuhw -> mmcr [ 0 ] ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; }\n", "\n", "3: CWE-400 static void perf_event_interrupt ( struct pt_regs * regs ) { int i ; struct cpu_hw_events * cpuhw = & __get_cpu_var ( cpu_hw_events ) ; struct perf_event * event ; unsigned long val ; int found = 0 ; int nmi ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { event = cpuhw -> event [ i ] ; val = read_pmc ( i ) ; if ( ( int ) val < 0 ) { if ( event ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } else { write_pmc ( i , 0 ) ; } } } mtmsr ( mfmsr ( ) | MSR_PMM ) ; mtpmr ( PMRN_PMGC0 , PMGC0_PMIE | PMGC0_FCECE ) ; isync ( ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; }\n", "\n", "\n", "Target: } if ( rq -> curr -> se . on_rq &&\n", "\n", "Sources:\n", "0: CWE-000 static void check_preempt_curr ( struct rq * rq , struct task_struct * p , int flags ) { const struct sched_class * class ; if ( p -> sched_class == rq -> curr -> sched_class ) { rq -> curr -> sched_class -> check_preempt_curr ( rq , p , flags ) ; } else { for_each_class ( class ) { if ( class == rq -> curr -> sched_class ) break ; if ( class == p -> sched_class ) { resched_task ( rq -> curr ) ; break ; } } } if ( test_tsk_need_resched ( rq -> curr ) ) rq -> skip_clock_update = 1 ; }\n", "\n", "1: CWE-835 static void check_preempt_curr ( struct rq * rq , struct task_struct * p , int flags ) { const struct sched_class * class ; if ( p -> sched_class == rq -> curr -> sched_class ) { rq -> curr -> sched_class -> check_preempt_curr ( rq , p , flags ) ; } else { for_each_class ( class ) { if ( class == rq -> curr -> sched_class ) break ; if ( class == p -> sched_class ) { resched_task ( rq -> curr ) ; break ; } } } if ( test_tsk_need_resched ( rq -> curr ) ) rq -> skip_clock_update = 1 ; }\n", "\n", "\n", "Target: im ) ; return NULL ;\n", "\n", "Sources:\n", "0: CWE-134 rrd_info_t * rrd_graph_v ( int argc , char * * argv ) { image_desc_t im ; rrd_info_t * grinfo ; char * old_locale ; rrd_graph_init ( & im ) ; old_locale = setlocale ( LC_NUMERIC , \"C\" ) ; rrd_graph_options ( argc , argv , & im ) ; if ( rrd_test_error ( ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( optind >= argc ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; rrd_set_error ( \"missingfilename\" ) ; return NULL ; } if ( strlen ( argv [ optind ] ) >= MAXPATH ) { rrd_set_error ( \"filename(includingpath)toolong\" ) ; rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } strncpy ( im . graphfile , argv [ optind ] , MAXPATH - 1 ) ; im . graphfile [ MAXPATH - 1 ] = '\\\\0' ; if ( strcmp ( im . graphfile , \"-\" ) == 0 ) { im . graphfile [ 0 ] = '\\\\0' ; } rrd_graph_script ( argc , argv , & im , 1 ) ; setlocale ( LC_NUMERIC , old_locale ) ; if ( rrd_test_error ( ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( graph_paint ( & im ) == - 1 ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( im . imginfo ) { rrd_infoval_t info ; char * path ; char * filename ; if ( bad_format_imginfo ( im . imginfo ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; rrd_set_error ( \"badformatforimginfo\" ) ; return NULL ; } path = strdup ( im . graphfile ) ; filename = basename ( path ) ; info . u_str = sprintf_alloc ( im . imginfo , filename , ( long ) ( im . zoom * im . ximg ) , ( long ) ( im . zoom * im . yimg ) ) ; grinfo_push ( & im , sprintf_alloc ( \"image_info\" ) , RD_I_STR , info ) ; free ( info . u_str ) ; free ( path ) ; } if ( im . rendered_image ) { rrd_infoval_t img ; img . u_blo . size = im . rendered_image_size ; img . u_blo . ptr = im . rendered_image ; grinfo_push ( & im , sprintf_alloc ( \"image\" ) , RD_I_BLO , img ) ; } grinfo = im . grinfo ; im_free ( & im ) ; return grinfo ; }\n", "\n", "1: CWE-134 rrd_info_t * rrd_graph_v ( int argc , char * * argv ) { image_desc_t im ; rrd_info_t * grinfo ; rrd_graph_init ( & im ) ; rrd_graph_options ( argc , argv , & im ) ; if ( rrd_test_error ( ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( optind >= argc ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; rrd_set_error ( \"missingfilename\" ) ; return NULL ; } if ( strlen ( argv [ optind ] ) >= MAXPATH ) { rrd_set_error ( \"filename(includingpath)toolong\" ) ; rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } strncpy ( im . graphfile , argv [ optind ] , MAXPATH - 1 ) ; im . graphfile [ MAXPATH - 1 ] = '\\\\0' ; if ( strcmp ( im . graphfile , \"-\" ) == 0 ) { im . graphfile [ 0 ] = '\\\\0' ; } rrd_graph_script ( argc , argv , & im , 1 ) ; if ( rrd_test_error ( ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( graph_paint ( & im ) == - 1 ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; return NULL ; } if ( im . imginfo && * im . imginfo ) { rrd_infoval_t info ; char * path ; char * filename ; if ( bad_format_imginfo ( im . imginfo ) ) { rrd_info_free ( im . grinfo ) ; im_free ( & im ) ; rrd_set_error ( \"badformatforimginfo\" ) ; return NULL ; } path = strdup ( im . graphfile ) ; filename = basename ( path ) ; info . u_str = sprintf_alloc ( im . imginfo , filename , ( long ) ( im . zoom * im . ximg ) , ( long ) ( im . zoom * im . yimg ) ) ; grinfo_push ( & im , sprintf_alloc ( \"image_info\" ) , RD_I_STR , info ) ; free ( info . u_str ) ; free ( path ) ; } if ( im . rendered_image ) { rrd_infoval_t img ; img . u_blo . size = im . rendered_image_size ; img . u_blo . ptr = im . rendered_image ; grinfo_push ( & im , sprintf_alloc ( \"image\" ) , RD_I_BLO , img ) ; } grinfo = im . grinfo ; im_free ( & im ) ; return grinfo ; }\n", "\n", "\n", "Target: int rc ; unsigned long eip ; rc = ctxt , & eip , ctxt -> ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; rc = assign_eip_near ( ctxt , eip\n", "\n", "Sources:\n", "0: CWE-264 static int em_ret_near_imm ( struct x86_emulate_ctxt * ctxt ) { int rc ; ctxt -> dst . type = OP_REG ; ctxt -> dst . addr . reg = & ctxt -> _eip ; ctxt -> dst . bytes = ctxt -> op_bytes ; rc = emulate_pop ( ctxt , & ctxt -> dst . val , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; rsp_increment ( ctxt , ctxt -> src . val ) ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-000 static int em_ret_near_imm ( struct x86_emulate_ctxt * ctxt ) { int rc ; ctxt -> dst . type = OP_REG ; ctxt -> dst . addr . reg = & ctxt -> _eip ; ctxt -> dst . bytes = ctxt -> op_bytes ; rc = emulate_pop ( ctxt , & ctxt -> dst . val , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; rsp_increment ( ctxt , ctxt -> src . val ) ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: U2FH_OK ) { int offs = sizeof ( nonce ) ; if ( if ( resplen < 17 ) { return U2FH_SIZE_ERROR ; } if ( memcmp ( nonce , resp , sizeof ( nonce ) ) != 0 ) { return U2FH_TRANSPORT_ERROR ; } dev -> cid -> cid = resp [ offs ] << 24 | resp [ offs + 1 ] << 16 | resp [ offs + 2 ] << 8 | resp [ offs + 3 ] ; offs += 4 ; dev -> -> versionInterface = resp [ offs ++ ] ; dev -> -> versionMajor = resp [ offs ++ ] ; dev -> -> versionMinor = resp [ offs ++ ] ; dev -> versionBuild = resp [ offs ++ ] ; dev -> -> capFlags = resp [ offs ++ ] ; } else\n", "\n", "Sources:\n", "0: CWE-119 static int init_device ( u2fh_devs * devs , struct u2fdevice * dev ) { unsigned char resp [ 1024 ] ; unsigned char nonce [ 8 ] ; if ( obtain_nonce ( nonce ) != 0 ) { return U2FH_TRANSPORT_ERROR ; } size_t resplen = sizeof ( resp ) ; dev -> cid = CID_BROADCAST ; if ( u2fh_sendrecv ( devs , dev -> id , U2FHID_INIT , nonce , sizeof ( nonce ) , resp , & resplen ) == U2FH_OK ) { U2FHID_INIT_RESP initresp ; if ( resplen > sizeof ( initresp ) ) { return U2FH_MEMORY_ERROR ; } memcpy ( & initresp , resp , resplen ) ; dev -> cid = initresp . cid ; dev -> versionInterface = initresp . versionInterface ; dev -> versionMajor = initresp . versionMajor ; dev -> versionMinor = initresp . versionMinor ; dev -> capFlags = initresp . capFlags ; } else { return U2FH_TRANSPORT_ERROR ; } return U2FH_OK ; }\n", "\n", "1: CWE-908 static int init_device ( u2fh_devs * devs , struct u2fdevice * dev ) { unsigned char resp [ 1024 ] ; unsigned char nonce [ 8 ] ; if ( obtain_nonce ( nonce ) != 0 ) { return U2FH_TRANSPORT_ERROR ; } size_t resplen = sizeof ( resp ) ; dev -> cid = CID_BROADCAST ; if ( u2fh_sendrecv ( devs , dev -> id , U2FHID_INIT , nonce , sizeof ( nonce ) , resp , & resplen ) == U2FH_OK ) { U2FHID_INIT_RESP initresp ; if ( resplen > sizeof ( initresp ) ) { return U2FH_MEMORY_ERROR ; } memcpy ( & initresp , resp , resplen ) ; dev -> cid = initresp . cid ; dev -> versionInterface = initresp . versionInterface ; dev -> versionMajor = initresp . versionMajor ; dev -> versionMinor = initresp . versionMinor ; dev -> capFlags = initresp . capFlags ; } else { return U2FH_TRANSPORT_ERROR ; } return U2FH_OK ; }\n", "\n", "\n", "Target: ) ; return TEMP_FAILURE_RETRY ( , MSG_DONTWAIT ) )\n", "\n", "Sources:\n", "0: CWE-284 ssize_t socket_read ( const socket_t * socket , void * buf , size_t count ) { assert ( socket != NULL ) ; assert ( buf != NULL ) ; return recv ( socket -> fd , buf , count , MSG_DONTWAIT ) ; }\n", "\n", "1: CWE-284 ssize_t socket_write ( const socket_t * socket , const void * buf , size_t count ) { assert ( socket != NULL ) ; assert ( buf != NULL ) ; return send ( socket -> fd , buf , count , MSG_DONTWAIT ) ; }\n", "\n", "\n", "Target: ALOGE ( \"b/26366256\" ) ; android_errorWriteLog ( 0x534e4554 , \"26366256\"\n", "\n", "Sources:\n", "0: CWE-119 void WT_NoiseGenerator ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 nInterpolatedSample ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( \"b/26366256\" ) ; return ; } pOutputBuffer = pWTIntFrame -> pAudioBuffer ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; tmp0 = ( EAS_I32 ) ( pWTVoice -> phaseAccum ) >> 18 ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; while ( numSamples -- ) { nInterpolatedSample = MULT_AUDIO_COEF ( tmp0 , ( PHASE_ONE - pWTVoice -> phaseFrac ) ) ; nInterpolatedSample += MULT_AUDIO_COEF ( tmp1 , pWTVoice -> phaseFrac ) ; * pOutputBuffer ++ = ( EAS_PCM ) nInterpolatedSample ; pWTVoice -> phaseFrac += ( EAS_U32 ) phaseInc ; if ( GET_PHASE_INT_PART ( pWTVoice -> phaseFrac ) ) { tmp0 = tmp1 ; pWTVoice -> phaseAccum = pWTVoice -> loopEnd ; pWTVoice -> loopEnd = ( 5 * pWTVoice -> loopEnd + 1 ) ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; pWTVoice -> phaseFrac = GET_PHASE_FRAC_PART ( pWTVoice -> phaseFrac ) ; } } }\n", "\n", "1: CWE-119 void WT_InterpolateNoLoop ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 phaseFrac ; EAS_I32 acc0 ; const EAS_SAMPLE * pSamples ; EAS_I32 samp1 ; EAS_I32 samp2 ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( \"b/26366256\" ) ; return ; } pOutputBuffer = pWTIntFrame -> pAudioBuffer ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; pSamples = ( const EAS_SAMPLE * ) pWTVoice -> phaseAccum ; phaseFrac = ( EAS_I32 ) pWTVoice -> phaseFrac ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif while ( numSamples -- ) { acc0 = samp2 - samp1 ; acc0 = acc0 * phaseFrac ; acc0 = samp1 + ( acc0 >> NUM_PHASE_FRAC_BITS ) ; * pOutputBuffer ++ = ( EAS_I16 ) ( acc0 >> 2 ) ; phaseFrac += phaseInc ; acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS ; if ( acc0 > 0 ) { pSamples += acc0 ; phaseFrac = ( EAS_I32 ) ( ( EAS_U32 ) phaseFrac & PHASE_FRAC_MASK ) ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif } } pWTVoice -> phaseAccum = ( EAS_U32 ) pSamples ; pWTVoice -> phaseFrac = ( EAS_U32 ) phaseFrac ; }\n", "\n", "2: CWE-119 void WT_Interpolate ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 phaseFrac ; EAS_I32 acc0 ; const EAS_SAMPLE * pSamples ; const EAS_SAMPLE * loopEnd ; EAS_I32 samp1 ; EAS_I32 samp2 ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( \"b/26366256\" ) ; return ; } pOutputBuffer = pWTIntFrame -> pAudioBuffer ; loopEnd = ( const EAS_SAMPLE * ) pWTVoice -> loopEnd + 1 ; pSamples = ( const EAS_SAMPLE * ) pWTVoice -> phaseAccum ; phaseFrac = pWTVoice -> phaseFrac ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif while ( numSamples -- ) { acc0 = samp2 - samp1 ; acc0 = acc0 * phaseFrac ; acc0 = samp1 + ( acc0 >> NUM_PHASE_FRAC_BITS ) ; * pOutputBuffer ++ = ( EAS_I16 ) ( acc0 >> 2 ) ; phaseFrac += phaseInc ; acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS ; if ( acc0 > 0 ) { pSamples += acc0 ; phaseFrac = ( EAS_I32 ) ( ( EAS_U32 ) phaseFrac & PHASE_FRAC_MASK ) ; acc0 = ( EAS_I32 ) ( pSamples - loopEnd ) ; if ( acc0 >= 0 ) pSamples = ( const EAS_SAMPLE * ) pWTVoice -> loopStart + acc0 ; # if defined ( _8_BIT_SAMPLES ) samp1 = pSamples [ 0 ] << 8 ; samp2 = pSamples [ 1 ] << 8 ; # else samp1 = pSamples [ 0 ] ; samp2 = pSamples [ 1 ] ; # endif } } pWTVoice -> phaseAccum = ( EAS_U32 ) pSamples ; pWTVoice -> phaseFrac = ( EAS_U32 ) phaseFrac ; }\n", "\n", "3: CWE-119 void WT_VoiceGain ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_I32 * pMixBuffer ; EAS_PCM * pInputBuffer ; EAS_I32 gain ; EAS_I32 gainIncrement ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 tmp2 ; EAS_I32 numSamples ; # if ( NUM_OUTPUT_CHANNELS == 2 ) EAS_I32 gainLeft , gainRight ; # endif numSamples = pWTIntFrame -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( \"b/26366256\" ) ; return ; } pMixBuffer = pWTIntFrame -> pMixBuffer ; pInputBuffer = pWTIntFrame -> pAudioBuffer ; gainIncrement = ( pWTIntFrame -> frame . gainTarget - pWTIntFrame -> prevGain ) << ( 16 - SYNTH_UPDATE_PERIOD_IN_BITS ) ; if ( gainIncrement < 0 ) gainIncrement ++ ; gain = pWTIntFrame -> prevGain << 16 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) gainLeft = pWTVoice -> gainLeft ; gainRight = pWTVoice -> gainRight ; # endif while ( numSamples -- ) { tmp0 = * pInputBuffer ++ ; gain += gainIncrement ; tmp2 = gain >> 16 ; tmp2 *= tmp0 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) tmp2 = tmp2 >> 14 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainLeft ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainRight ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; # else tmp1 = * pMixBuffer ; tmp2 = tmp2 >> ( NUM_MIXER_GUARD_BITS - 1 ) ; tmp1 += tmp2 ; * pMixBuffer ++ = tmp1 ; # endif } }\n", "\n", "\n", "Target: NullS ) ; SSL_SET_OPTIONS ( & mysql_connection ) ; if ( opt_protocol\n", "\n", "Sources:\n", "0: CWE-284 static int connect_to_db ( char * host , char * user , char * passwd ) { char buff [ 20 + FN_REFLEN ] ; DBUG_ENTER ( \"connect_to_db\" ) ; verbose_msg ( \"--Connectingto%s...\\\\n\" , host ? host : \"localhost\" ) ; mysql_init ( & mysql_connection ) ; if ( opt_compress ) mysql_options ( & mysql_connection , MYSQL_OPT_COMPRESS , NullS ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( & mysql_connection , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } mysql_options ( & mysql_connection , MYSQL_OPT_SSL_VERIFY_SERVER_CERT , ( char * ) & opt_ssl_verify_server_cert ) ; # endif if ( opt_protocol ) mysql_options ( & mysql_connection , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; if ( opt_bind_addr ) mysql_options ( & mysql_connection , MYSQL_OPT_BIND , opt_bind_addr ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( & mysql_connection , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif mysql_options ( & mysql_connection , MYSQL_SET_CHARSET_NAME , default_charset ) ; if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( & mysql_connection , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( & mysql_connection , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_ADD , \"program_name\" , \"mysqldump\" ) ; if ( ! ( mysql = mysql_real_connect ( & mysql_connection , host , user , passwd , NULL , opt_mysql_port , opt_mysql_unix_port , 0 ) ) ) { DB_error ( & mysql_connection , \"whentryingtoconnect\" ) ; DBUG_RETURN ( 1 ) ; } if ( ( mysql_get_server_version ( & mysql_connection ) < 40100 ) || ( opt_compatible_mode & 3 ) ) { opt_set_charset = 0 ; server_supports_switching_charsets = FALSE ; } mysql -> reconnect = 0 ; my_snprintf ( buff , sizeof ( buff ) , \"/*!40100SET@@SQL_MODE=\\'%s\\'*/\" , compatible_mode_normal_str ) ; if ( mysql_query_with_error_report ( mysql , 0 , buff ) ) DBUG_RETURN ( 1 ) ; if ( opt_tz_utc ) { my_snprintf ( buff , sizeof ( buff ) , \"/*!40103SETTIME_ZONE=\\'+00:00\\'*/\" ) ; if ( mysql_query_with_error_report ( mysql , 0 , buff ) ) DBUG_RETURN ( 1 ) ; } DBUG_RETURN ( 0 ) ; }\n", "\n", "1: CWE-284 static int dbConnect ( char * host , char * user , char * passwd ) { DBUG_ENTER ( \"dbConnect\" ) ; if ( verbose ) { fprintf ( stderr , \"#Connectingto%s...\\\\n\" , host ? host : \"localhost\" ) ; } mysql_init ( & mysql_connection ) ; if ( opt_compress ) mysql_options ( & mysql_connection , MYSQL_OPT_COMPRESS , NullS ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( & mysql_connection , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } # endif if ( opt_protocol ) mysql_options ( & mysql_connection , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; if ( opt_bind_addr ) mysql_options ( & mysql_connection , MYSQL_OPT_BIND , opt_bind_addr ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( & mysql_connection , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( & mysql_connection , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( & mysql_connection , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( & mysql_connection , MYSQL_SET_CHARSET_NAME , default_charset ) ; mysql_options ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_ADD , \"program_name\" , \"mysqlcheck\" ) ; if ( ! ( sock = mysql_real_connect ( & mysql_connection , host , user , passwd , NULL , opt_mysql_port , opt_mysql_unix_port , 0 ) ) ) { DBerror ( & mysql_connection , \"whentryingtoconnect\" ) ; DBUG_RETURN ( 1 ) ; } mysql_connection . reconnect = 1 ; DBUG_RETURN ( 0 ) ; }\n", "\n", "\n", "Target: exit ; } m -> msg_namelen = 0 ;\n", "\n", "Sources:\n", "0: CWE-200 static int recv_stream ( struct kiocb * iocb , struct socket * sock , struct msghdr * m , size_t buf_len , int flags ) { struct sock * sk = sock -> sk ; struct tipc_port * tport = tipc_sk_port ( sk ) ; struct sk_buff * buf ; struct tipc_msg * msg ; long timeout ; unsigned int sz ; int sz_to_copy , target , needed ; int sz_copied = 0 ; u32 err ; int res = 0 ; if ( unlikely ( ! buf_len ) ) return - EINVAL ; lock_sock ( sk ) ; if ( unlikely ( ( sock -> state == SS_UNCONNECTED ) || ( sock -> state == SS_CONNECTING ) ) ) { res = - ENOTCONN ; goto exit ; } target = sock_rcvlowat ( sk , flags & MSG_WAITALL , buf_len ) ; timeout = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; restart : while ( skb_queue_empty ( & sk -> sk_receive_queue ) ) { if ( sock -> state == SS_DISCONNECTING ) { res = - ENOTCONN ; goto exit ; } if ( timeout <= 0L ) { res = timeout ? timeout : - EWOULDBLOCK ; goto exit ; } release_sock ( sk ) ; timeout = wait_event_interruptible_timeout ( * sk_sleep ( sk ) , tipc_rx_ready ( sock ) , timeout ) ; lock_sock ( sk ) ; } buf = skb_peek ( & sk -> sk_receive_queue ) ; msg = buf_msg ( buf ) ; sz = msg_data_sz ( msg ) ; err = msg_errcode ( msg ) ; if ( ( ! sz ) && ( ! err ) ) { advance_rx_queue ( sk ) ; goto restart ; } if ( sz_copied == 0 ) { set_orig_addr ( m , msg ) ; res = anc_data_recv ( m , msg , tport ) ; if ( res ) goto exit ; } if ( ! err ) { u32 offset = ( u32 ) ( unsigned long ) ( TIPC_SKB_CB ( buf ) -> handle ) ; sz -= offset ; needed = ( buf_len - sz_copied ) ; sz_to_copy = ( sz <= needed ) ? sz : needed ; res = skb_copy_datagram_iovec ( buf , msg_hdr_sz ( msg ) + offset , m -> msg_iov , sz_to_copy ) ; if ( res ) goto exit ; sz_copied += sz_to_copy ; if ( sz_to_copy < sz ) { if ( ! ( flags & MSG_PEEK ) ) TIPC_SKB_CB ( buf ) -> handle = ( void * ) ( unsigned long ) ( offset + sz_to_copy ) ; goto exit ; } } else { if ( sz_copied != 0 ) goto exit ; if ( ( err == TIPC_CONN_SHUTDOWN ) || m -> msg_control ) res = 0 ; else res = - ECONNRESET ; } if ( likely ( ! ( flags & MSG_PEEK ) ) ) { if ( unlikely ( ++ tport -> conn_unacked >= TIPC_FLOW_CONTROL_WIN ) ) tipc_acknowledge ( tport -> ref , tport -> conn_unacked ) ; advance_rx_queue ( sk ) ; } if ( ( sz_copied < buf_len ) && ( ! skb_queue_empty ( & sk -> sk_receive_queue ) || ( sz_copied < target ) ) && ( ! ( flags & MSG_PEEK ) ) && ( ! err ) ) goto restart ; exit : release_sock ( sk ) ; return sz_copied ? sz_copied : res ; }\n", "\n", "1: CWE-200 static int recv_msg ( struct kiocb * iocb , struct socket * sock , struct msghdr * m , size_t buf_len , int flags ) { struct sock * sk = sock -> sk ; struct tipc_port * tport = tipc_sk_port ( sk ) ; struct sk_buff * buf ; struct tipc_msg * msg ; long timeout ; unsigned int sz ; u32 err ; int res ; if ( unlikely ( ! buf_len ) ) return - EINVAL ; lock_sock ( sk ) ; if ( unlikely ( sock -> state == SS_UNCONNECTED ) ) { res = - ENOTCONN ; goto exit ; } timeout = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; restart : while ( skb_queue_empty ( & sk -> sk_receive_queue ) ) { if ( sock -> state == SS_DISCONNECTING ) { res = - ENOTCONN ; goto exit ; } if ( timeout <= 0L ) { res = timeout ? timeout : - EWOULDBLOCK ; goto exit ; } release_sock ( sk ) ; timeout = wait_event_interruptible_timeout ( * sk_sleep ( sk ) , tipc_rx_ready ( sock ) , timeout ) ; lock_sock ( sk ) ; } buf = skb_peek ( & sk -> sk_receive_queue ) ; msg = buf_msg ( buf ) ; sz = msg_data_sz ( msg ) ; err = msg_errcode ( msg ) ; if ( ( ! sz ) && ( ! err ) ) { advance_rx_queue ( sk ) ; goto restart ; } set_orig_addr ( m , msg ) ; res = anc_data_recv ( m , msg , tport ) ; if ( res ) goto exit ; if ( ! err ) { if ( unlikely ( buf_len < sz ) ) { sz = buf_len ; m -> msg_flags |= MSG_TRUNC ; } res = skb_copy_datagram_iovec ( buf , msg_hdr_sz ( msg ) , m -> msg_iov , sz ) ; if ( res ) goto exit ; res = sz ; } else { if ( ( sock -> state == SS_READY ) || ( ( err == TIPC_CONN_SHUTDOWN ) || m -> msg_control ) ) res = 0 ; else res = - ECONNRESET ; } if ( likely ( ! ( flags & MSG_PEEK ) ) ) { if ( ( sock -> state != SS_READY ) && ( ++ tport -> conn_unacked >= TIPC_FLOW_CONTROL_WIN ) ) tipc_acknowledge ( tport -> ref , tport -> conn_unacked ) ; advance_rx_queue ( sk ) ; } exit : release_sock ( sk ) ; return res ; }\n", "\n", "\n", "Target: , message ) \\\\\\n{ if ( data ) ) ; \\\\\\n} char explicit_vr [ image ) ) ThrowDCMException ( CorruptImageError ,\n", "\n", "Sources:\n", "0: CWE-772 static Image * ReadDCMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowDCMException ( exception , message ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( stream_info != ( DCMStreamInfo * ) NULL ) stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char explicit_vr [ MagickPathExtent ] , implicit_vr [ MagickPathExtent ] , magick [ MagickPathExtent ] , photometric [ MagickPathExtent ] ; DCMInfo info ; DCMStreamInfo * stream_info ; Image * image ; int * bluemap , datum , * greenmap , * graymap , * redmap ; MagickBooleanType explicit_file , explicit_retry , sequence , use_explicit ; MagickOffsetType offset ; register unsigned char * p ; register ssize_t i ; size_t colors , height , length , number_scenes , quantum , status , width ; ssize_t count , scene ; unsigned char * data ; unsigned short group , element ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 8UL ; image -> endian = LSBEndian ; data = ( unsigned char * ) NULL ; stream_info = ( DCMStreamInfo * ) AcquireMagickMemory ( sizeof ( * stream_info ) ) ; if ( stream_info == ( DCMStreamInfo * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ResetMagickMemory ( stream_info , 0 , sizeof ( * stream_info ) ) ; count = ReadBlob ( image , 128 , ( unsigned char * ) magick ) ; if ( count != 128 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; if ( ( count != 4 ) || ( LocaleNCompare ( magick , \"DICM\" , 4 ) != 0 ) ) { offset = SeekBlob ( image , 0L , SEEK_SET ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } ( void ) CopyMagickString ( photometric , \"MONOCHROME1\" , MagickPathExtent ) ; info . polarity = MagickFalse ; info . scale = ( Quantum * ) NULL ; info . bits_allocated = 8 ; info . bytes_per_pixel = 1 ; info . depth = 8 ; info . mask = 0xffff ; info . max_value = 255UL ; info . samples_per_pixel = 1 ; info . signed_data = ( ~ 0UL ) ; info . significant_bits = 0 ; info . rescale = MagickFalse ; info . rescale_intercept = 0.0 ; info . rescale_slope = 1.0 ; info . window_center = 0.0 ; info . window_width = 0.0 ; data = ( unsigned char * ) NULL ; element = 0 ; explicit_vr [ 2 ] = '\\\\0' ; explicit_file = MagickFalse ; colors = 0 ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; graymap = ( int * ) NULL ; height = 0 ; number_scenes = 1 ; sequence = MagickFalse ; use_explicit = MagickFalse ; explicit_retry = MagickFalse ; width = 0 ; for ( group = 0 ; ( group != 0x7FE0 ) || ( element != 0x0010 ) || ( sequence != MagickFalse ) ; ) { image -> offset = ( ssize_t ) TellBlob ( image ) ; group = ReadBlobLSBShort ( image ) ; element = ReadBlobLSBShort ( image ) ; if ( ( group != 0x0002 ) && ( image -> endian == MSBEndian ) ) { group = ( unsigned short ) ( ( group << 8 ) | ( ( group >> 8 ) & 0xFF ) ) ; element = ( unsigned short ) ( ( element << 8 ) | ( ( element >> 8 ) & 0xFF ) ) ; } quantum = 0 ; for ( i = 0 ; dicom_info [ i ] . group < 0xffff ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) CopyMagickString ( implicit_vr , dicom_info [ i ] . vr , MagickPathExtent ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) explicit_vr ) ; if ( count != 2 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( explicit_file == MagickFalse ) && ( group != 0x0002 ) ) explicit_file = ( isupper ( ( unsigned char ) * explicit_vr ) != MagickFalse ) && ( isupper ( ( unsigned char ) * ( explicit_vr + 1 ) ) != MagickFalse ) ? MagickTrue : MagickFalse ; use_explicit = ( ( group == 0x0002 ) && ( explicit_retry == MagickFalse ) ) || ( explicit_file != MagickFalse ) ? MagickTrue : MagickFalse ; if ( ( use_explicit != MagickFalse ) && ( strncmp ( implicit_vr , \"xs\" , 2 ) == 0 ) ) ( void ) CopyMagickString ( implicit_vr , explicit_vr , MagickPathExtent ) ; if ( ( use_explicit == MagickFalse ) || ( strncmp ( implicit_vr , \"!!\" , 2 ) == 0 ) ) { offset = SeekBlob ( image , ( MagickOffsetType ) - 2 , SEEK_CUR ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; quantum = 4 ; } else { quantum = 2 ; if ( ( strncmp ( explicit_vr , \"OB\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"UN\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"SQ\" , 2 ) == 0 ) ) { ( void ) ReadBlobLSBShort ( image ) ; quantum = 4 ; } } datum = 0 ; if ( quantum == 4 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( quantum == 2 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } quantum = 0 ; length = 1 ; if ( datum != 0 ) { if ( ( strncmp ( implicit_vr , \"SS\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"US\" , 2 ) == 0 ) ) quantum = 2 ; else if ( ( strncmp ( implicit_vr , \"UL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"FL\" , 2 ) == 0 ) ) quantum = 4 ; else if ( strncmp ( implicit_vr , \"FD\" , 2 ) != 0 ) quantum = 1 ; else quantum = 8 ; if ( datum != ~ 0 ) length = ( size_t ) datum / quantum ; else { quantum = 0 ; length = 0 ; } } if ( image_info -> verbose != MagickFalse ) { if ( use_explicit == MagickFalse ) explicit_vr [ 0 ] = '\\\\0' ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) FormatLocaleFile ( stdout , \"0x%04lX%4ld%s-%s(0x%04lx,0x%04lx)\" , ( unsigned long ) image -> offset , ( long ) length , implicit_vr , explicit_vr , ( unsigned long ) group , ( unsigned long ) element ) ; if ( dicom_info [ i ] . description != ( char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%s\" , dicom_info [ i ] . description ) ; ( void ) FormatLocaleFile ( stdout , \":\" ) ; } if ( ( sequence == MagickFalse ) && ( group == 0x7FE0 ) && ( element == 0x0010 ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; break ; } data = ( unsigned char * ) NULL ; if ( ( length == 1 ) && ( quantum == 1 ) ) datum = ReadBlobByte ( image ) ; else if ( ( length == 1 ) && ( quantum == 2 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } else if ( ( length == 1 ) && ( quantum == 4 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( ( quantum != 0 ) && ( length != 0 ) ) { if ( length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ~ length >= 1 ) data = ( unsigned char * ) AcquireQuantumMemory ( length + 1 , quantum * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , ( size_t ) quantum * length , data ) ; if ( count != ( ssize_t ) ( quantum * length ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"count=%dquantum=%d\" \"length=%dgroup=%d\\\\n\" , ( int ) count , ( int ) quantum , ( int ) length , ( int ) group ) ; ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } data [ length * quantum ] = '\\\\0' ; } else if ( ( unsigned int ) datum == 0xFFFFFFFFU ) { sequence = MagickTrue ; continue ; } if ( ( unsigned int ) ( ( group << 16 ) | element ) == 0xFFFEE0DD ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; sequence = MagickFalse ; continue ; } if ( sequence != MagickFalse ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; continue ; } switch ( group ) { case 0x0002 : { switch ( element ) { case 0x0010 : { char transfer_syntax [ MagickPathExtent ] ; if ( ( datum == 0 ) && ( explicit_retry == MagickFalse ) ) { explicit_retry = MagickTrue ; ( void ) SeekBlob ( image , ( MagickOffsetType ) 0 , SEEK_SET ) ; group = 0 ; element = 0 ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"Corruptedimage-tryingexplicitformat\\\\n\" ) ; break ; } * transfer_syntax = '\\\\0' ; if ( data != ( unsigned char * ) NULL ) ( void ) CopyMagickString ( transfer_syntax , ( char * ) data , MagickPathExtent ) ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"transfer_syntax=%s\\\\n\" , ( const char * ) transfer_syntax ) ; if ( strncmp ( transfer_syntax , \"1.2.840.10008.1.2\" , 17 ) == 0 ) { int subtype , type ; type = 1 ; subtype = 0 ; if ( strlen ( transfer_syntax ) > 17 ) { count = ( ssize_t ) sscanf ( transfer_syntax + 17 , \".%d.%d\" , & type , & subtype ) ; if ( count < 1 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } switch ( type ) { case 1 : { image -> endian = LSBEndian ; break ; } case 2 : { image -> endian = MSBEndian ; break ; } case 4 : { if ( ( subtype >= 80 ) && ( subtype <= 81 ) ) image -> compression = JPEGCompression ; else if ( ( subtype >= 90 ) && ( subtype <= 93 ) ) image -> compression = JPEG2000Compression ; else image -> compression = JPEGCompression ; break ; } case 5 : { image -> compression = RLECompression ; break ; } } } break ; } default : break ; } break ; } case 0x0028 : { switch ( element ) { case 0x0002 : { info . samples_per_pixel = ( size_t ) datum ; break ; } case 0x0004 : { if ( data == ( unsigned char * ) NULL ) break ; for ( i = 0 ; i < ( ssize_t ) MagickMin ( length , MagickPathExtent - 1 ) ; i ++ ) photometric [ i ] = ( char ) data [ i ] ; photometric [ i ] = '\\\\0' ; info . polarity = LocaleCompare ( photometric , \"MONOCHROME1\" ) == 0 ? MagickTrue : MagickFalse ; break ; } case 0x0006 : { if ( datum == 1 ) image -> interlace = PlaneInterlace ; break ; } case 0x0008 : { if ( data == ( unsigned char * ) NULL ) break ; number_scenes = StringToUnsignedLong ( ( char * ) data ) ; break ; } case 0x0010 : { height = ( size_t ) datum ; break ; } case 0x0011 : { width = ( size_t ) datum ; break ; } case 0x0100 : { info . bits_allocated = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( datum > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . bits_allocated ; if ( info . depth > 32 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . bits_allocated ) - 1 ; image -> depth = info . depth ; break ; } case 0x0101 : { info . significant_bits = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( info . significant_bits > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . significant_bits ; if ( info . depth > 32 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . significant_bits ) - 1 ; info . mask = ( size_t ) GetQuantumRange ( info . significant_bits ) ; image -> depth = info . depth ; break ; } case 0x0102 : { break ; } case 0x0103 : { info . signed_data = ( size_t ) datum ; break ; } case 0x1050 : { if ( data != ( unsigned char * ) NULL ) info . window_center = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1051 : { if ( data != ( unsigned char * ) NULL ) info . window_width = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1052 : { if ( data != ( unsigned char * ) NULL ) info . rescale_intercept = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1053 : { if ( data != ( unsigned char * ) NULL ) info . rescale_slope = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1200 : case 0x3006 : { if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / info . bytes_per_pixel ) ; datum = ( int ) colors ; graymap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * graymap ) ) ; if ( graymap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) if ( info . bytes_per_pixel == 1 ) graymap [ i ] = ( int ) data [ i ] ; else graymap [ i ] = ( int ) ( ( short * ) data ) [ i ] ; break ; } case 0x1201 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; redmap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * redmap ) ) ; if ( redmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; redmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1202 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; greenmap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * greenmap ) ) ; if ( greenmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; greenmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1203 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; bluemap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * bluemap ) ) ; if ( bluemap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; bluemap [ i ] = ( int ) index ; p += 2 ; } break ; } default : break ; } break ; } case 0x2050 : { switch ( element ) { case 0x0020 : { if ( ( data != ( unsigned char * ) NULL ) && ( strncmp ( ( char * ) data , \"INVERSE\" , 7 ) == 0 ) ) info . polarity = MagickTrue ; break ; } default : break ; } break ; } default : break ; } if ( data != ( unsigned char * ) NULL ) { char * attribute ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; if ( dicom_info [ i ] . description != ( char * ) NULL ) { attribute = AcquireString ( \"dcm:\" ) ; ( void ) ConcatenateString ( & attribute , dicom_info [ i ] . description ) ; for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i == ( ssize_t ) length ) || ( length > 4 ) ) { ( void ) SubstituteString ( & attribute , \"\" , \"\" ) ; ( void ) SetImageProperty ( image , attribute , ( char * ) data , exception ) ; } attribute = DestroyString ( attribute ) ; } } if ( image_info -> verbose != MagickFalse ) { if ( data == ( unsigned char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%d\\\\n\" , datum ) ; else { for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i != ( ssize_t ) length ) && ( length <= 4 ) ) { ssize_t j ; datum = 0 ; for ( j = ( ssize_t ) length - 1 ; j >= 0 ; j -- ) datum = ( 256 * datum + data [ j ] ) ; ( void ) FormatLocaleFile ( stdout , \"%d\" , datum ) ; } else for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( isprint ( ( int ) data [ i ] ) != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"%c\" , data [ i ] ) ; else ( void ) FormatLocaleFile ( stdout , \"%c\" , '.' ) ; ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; } } if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } } if ( ( width == 0 ) || ( height == 0 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; if ( info . signed_data == 0xffff ) info . signed_data = ( size_t ) ( info . significant_bits == 16 ? 1 : 0 ) ; if ( ( image -> compression == JPEGCompression ) || ( image -> compression == JPEG2000Compression ) ) { Image * images ; ImageInfo * read_info ; int c ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; ( void ) ( ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; images = NewImageList ( ) ; for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { char filename [ MagickPathExtent ] ; const char * property ; FILE * file ; Image * jpeg_image ; int unique_file ; unsigned int tag ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( tag == 0xFFFEE0DD ) break ; if ( tag != 0xFFFEE000 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( file == ( FILE * ) NULL ) { ( void ) RelinquishUniqueFileResource ( filename ) ; ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , filename ) ; break ; } for ( ; length != 0 ; length -- ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"jpeg:%s\" , filename ) ; if ( image -> compression == JPEG2000Compression ) ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"j2k:%s\" , filename ) ; jpeg_image = ReadImage ( read_info , exception ) ; if ( jpeg_image != ( Image * ) NULL ) { ResetImagePropertyIterator ( image ) ; property = GetNextImageProperty ( image ) ; while ( property != ( const char * ) NULL ) { ( void ) SetImageProperty ( jpeg_image , property , GetImageProperty ( image , property , exception ) , exception ) ; property = GetNextImageProperty ( image ) ; } AppendImageToList ( & images , jpeg_image ) ; } ( void ) RelinquishUniqueFileResource ( filename ) ; } read_info = DestroyImageInfo ( read_info ) ; image = DestroyImage ( image ) ; return ( GetFirstImageInList ( images ) ) ; } if ( info . depth != ( 1UL * MAGICKCORE_QUANTUM_DEPTH ) ) { QuantumAny range ; length = ( size_t ) ( GetQuantumRange ( info . depth ) + 1 ) ; info . scale = ( Quantum * ) AcquireQuantumMemory ( length , sizeof ( * info . scale ) ) ; if ( info . scale == ( Quantum * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; range = GetQuantumRange ( info . depth ) ; for ( i = 0 ; i <= ( ssize_t ) GetQuantumRange ( info . depth ) ; i ++ ) info . scale [ i ] = ScaleAnyToQuantum ( ( size_t ) i , range ) ; } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) + 8 ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } } for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { if ( image_info -> ping != MagickFalse ) break ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; image -> depth = info . depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; image -> colorspace = RGBColorspace ; if ( ( image -> colormap == ( PixelInfo * ) NULL ) && ( info . samples_per_pixel == 1 ) ) { int index ; size_t one ; one = 1 ; if ( colors == 0 ) colors = one << info . depth ; if ( AcquireImageColormap ( image , colors , exception ) == MagickFalse ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( redmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = redmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; } if ( greenmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = greenmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . green = ( MagickRealType ) index ; } if ( bluemap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = bluemap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } if ( graymap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = graymap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; image -> colormap [ i ] . green = ( MagickRealType ) index ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; stream_info -> remaining = ( size_t ) ReadBlobLSBLong ( image ) ; if ( ( tag != 0xFFFEE000 ) || ( stream_info -> remaining <= 64 ) || ( EOFBlob ( image ) != MagickFalse ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; stream_info -> count = 0 ; stream_info -> segment_count = ReadBlobLSBLong ( image ) ; for ( i = 0 ; i < 15 ; i ++ ) stream_info -> segments [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; stream_info -> remaining -= 64 ; if ( stream_info -> segment_count > 1 ) { info . bytes_per_pixel = 1 ; info . depth = 8 ; if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 0 ] , SEEK_SET ) ; } } if ( ( info . samples_per_pixel > 1 ) && ( image -> interlace == PlaneInterlace ) ) { register ssize_t x ; register Quantum * q ; ssize_t y ; for ( i = 0 ; i < ( ssize_t ) info . samples_per_pixel ; i ++ ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( ( int ) i ) { case 0 : { SetPixelRed ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 1 : { SetPixelGreen ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 2 : { SetPixelBlue ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 3 : { SetPixelAlpha ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } default : break ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } } else { const char * option ; option = GetImageOption ( image_info , \"dcm:display-range\" ) ; if ( option != ( const char * ) NULL ) { if ( LocaleCompare ( option , \"reset\" ) == 0 ) info . window_width = 0 ; } option = GetImageOption ( image_info , \"dcm:window\" ) ; if ( option != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( option , & geometry_info ) ; if ( flags & RhoValue ) info . window_center = geometry_info . rho ; if ( flags & SigmaValue ) info . window_width = geometry_info . sigma ; info . rescale = MagickTrue ; } option = GetImageOption ( image_info , \"dcm:rescale\" ) ; if ( option != ( char * ) NULL ) info . rescale = IsStringTrue ( option ) ; if ( ( info . window_center != 0 ) && ( info . window_width == 0 ) ) info . window_width = info . window_center ; status = ReadDCMPixels ( image , & info , stream_info , MagickTrue , exception ) ; if ( ( status != MagickFalse ) && ( stream_info -> segment_count > 1 ) ) { if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 1 ] , SEEK_SET ) ; ( void ) ReadDCMPixels ( image , & info , stream_info , MagickFalse , exception ) ; } } if ( SetImageGray ( image , exception ) != MagickFalse ) ( void ) SetImageColorspace ( image , GRAYColorspace , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( number_scenes - 1 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-772 static Image * ReadDCMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowDCMException ( exception , message ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( stream_info != ( DCMStreamInfo * ) NULL ) stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char explicit_vr [ MaxTextExtent ] , implicit_vr [ MaxTextExtent ] , magick [ MaxTextExtent ] , photometric [ MaxTextExtent ] ; DCMInfo info ; DCMStreamInfo * stream_info ; Image * image ; int * bluemap , datum , * greenmap , * graymap , * redmap ; MagickBooleanType explicit_file , explicit_retry , sequence , use_explicit ; MagickOffsetType offset ; register unsigned char * p ; register ssize_t i ; size_t colors , height , length , number_scenes , quantum , status , width ; ssize_t count , scene ; unsigned char * data ; unsigned short group , element ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 8UL ; image -> endian = LSBEndian ; data = ( unsigned char * ) NULL ; stream_info = ( DCMStreamInfo * ) AcquireMagickMemory ( sizeof ( * stream_info ) ) ; if ( stream_info == ( DCMStreamInfo * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ResetMagickMemory ( stream_info , 0 , sizeof ( * stream_info ) ) ; count = ReadBlob ( image , 128 , ( unsigned char * ) magick ) ; if ( count != 128 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; if ( ( count != 4 ) || ( LocaleNCompare ( magick , \"DICM\" , 4 ) != 0 ) ) { offset = SeekBlob ( image , 0L , SEEK_SET ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } ( void ) CopyMagickString ( photometric , \"MONOCHROME1\" , MaxTextExtent ) ; info . polarity = MagickFalse ; info . scale = ( Quantum * ) NULL ; info . bits_allocated = 8 ; info . bytes_per_pixel = 1 ; info . depth = 8 ; info . mask = 0xffff ; info . max_value = 255UL ; info . samples_per_pixel = 1 ; info . signed_data = ( ~ 0UL ) ; info . significant_bits = 0 ; info . rescale = MagickFalse ; info . rescale_intercept = 0.0 ; info . rescale_slope = 1.0 ; info . window_center = 0.0 ; info . window_width = 0.0 ; data = ( unsigned char * ) NULL ; element = 0 ; explicit_vr [ 2 ] = '\\\\0' ; explicit_file = MagickFalse ; colors = 0 ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; graymap = ( int * ) NULL ; height = 0 ; number_scenes = 1 ; sequence = MagickFalse ; use_explicit = MagickFalse ; explicit_retry = MagickFalse ; width = 0 ; for ( group = 0 ; ( group != 0x7FE0 ) || ( element != 0x0010 ) || ( sequence != MagickFalse ) ; ) { image -> offset = ( ssize_t ) TellBlob ( image ) ; group = ReadBlobLSBShort ( image ) ; element = ReadBlobLSBShort ( image ) ; if ( ( group != 0x0002 ) && ( image -> endian == MSBEndian ) ) { group = ( unsigned short ) ( ( group << 8 ) | ( ( group >> 8 ) & 0xFF ) ) ; element = ( unsigned short ) ( ( element << 8 ) | ( ( element >> 8 ) & 0xFF ) ) ; } quantum = 0 ; for ( i = 0 ; dicom_info [ i ] . group < 0xffff ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) CopyMagickString ( implicit_vr , dicom_info [ i ] . vr , MaxTextExtent ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) explicit_vr ) ; if ( count != 2 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( explicit_file == MagickFalse ) && ( group != 0x0002 ) ) explicit_file = ( isupper ( ( unsigned char ) * explicit_vr ) != MagickFalse ) && ( isupper ( ( unsigned char ) * ( explicit_vr + 1 ) ) != MagickFalse ) ? MagickTrue : MagickFalse ; use_explicit = ( ( group == 0x0002 ) && ( explicit_retry == MagickFalse ) ) || ( explicit_file != MagickFalse ) ? MagickTrue : MagickFalse ; if ( ( use_explicit != MagickFalse ) && ( strncmp ( implicit_vr , \"xs\" , 2 ) == 0 ) ) ( void ) CopyMagickString ( implicit_vr , explicit_vr , MaxTextExtent ) ; if ( ( use_explicit == MagickFalse ) || ( strncmp ( implicit_vr , \"!!\" , 2 ) == 0 ) ) { offset = SeekBlob ( image , ( MagickOffsetType ) - 2 , SEEK_CUR ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; quantum = 4 ; } else { quantum = 2 ; if ( ( strncmp ( explicit_vr , \"OB\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"UN\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"SQ\" , 2 ) == 0 ) ) { ( void ) ReadBlobLSBShort ( image ) ; quantum = 4 ; } } datum = 0 ; if ( quantum == 4 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( quantum == 2 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } quantum = 0 ; length = 1 ; if ( datum != 0 ) { if ( ( strncmp ( implicit_vr , \"SS\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"US\" , 2 ) == 0 ) ) quantum = 2 ; else if ( ( strncmp ( implicit_vr , \"UL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"FL\" , 2 ) == 0 ) ) quantum = 4 ; else if ( strncmp ( implicit_vr , \"FD\" , 2 ) != 0 ) quantum = 1 ; else quantum = 8 ; if ( datum != ~ 0 ) length = ( size_t ) datum / quantum ; else { quantum = 0 ; length = 0 ; } } if ( image_info -> verbose != MagickFalse ) { if ( use_explicit == MagickFalse ) explicit_vr [ 0 ] = '\\\\0' ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) FormatLocaleFile ( stdout , \"0x%04lX%4ld%s-%s(0x%04lx,0x%04lx)\" , ( unsigned long ) image -> offset , ( long ) length , implicit_vr , explicit_vr , ( unsigned long ) group , ( unsigned long ) element ) ; if ( dicom_info [ i ] . description != ( char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%s\" , dicom_info [ i ] . description ) ; ( void ) FormatLocaleFile ( stdout , \":\" ) ; } if ( ( sequence == MagickFalse ) && ( group == 0x7FE0 ) && ( element == 0x0010 ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; break ; } data = ( unsigned char * ) NULL ; if ( ( length == 1 ) && ( quantum == 1 ) ) datum = ReadBlobByte ( image ) ; else if ( ( length == 1 ) && ( quantum == 2 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } else if ( ( length == 1 ) && ( quantum == 4 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( ( quantum != 0 ) && ( length != 0 ) ) { if ( length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ~ length >= 1 ) data = ( unsigned char * ) AcquireQuantumMemory ( length + 1 , quantum * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , ( size_t ) quantum * length , data ) ; if ( count != ( ssize_t ) ( quantum * length ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"count=%dquantum=%d\" \"length=%dgroup=%d\\\\n\" , ( int ) count , ( int ) quantum , ( int ) length , ( int ) group ) ; ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } data [ length * quantum ] = '\\\\0' ; } else if ( ( unsigned int ) datum == 0xFFFFFFFFU ) { sequence = MagickTrue ; continue ; } if ( ( unsigned int ) ( ( group << 16 ) | element ) == 0xFFFEE0DD ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; sequence = MagickFalse ; continue ; } if ( sequence != MagickFalse ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; continue ; } switch ( group ) { case 0x0002 : { switch ( element ) { case 0x0010 : { char transfer_syntax [ MaxTextExtent ] ; if ( ( datum == 0 ) && ( explicit_retry == MagickFalse ) ) { explicit_retry = MagickTrue ; ( void ) SeekBlob ( image , ( MagickOffsetType ) 0 , SEEK_SET ) ; group = 0 ; element = 0 ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"Corruptedimage-tryingexplicitformat\\\\n\" ) ; break ; } * transfer_syntax = '\\\\0' ; if ( data != ( unsigned char * ) NULL ) ( void ) CopyMagickString ( transfer_syntax , ( char * ) data , MaxTextExtent ) ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"transfer_syntax=%s\\\\n\" , ( const char * ) transfer_syntax ) ; if ( strncmp ( transfer_syntax , \"1.2.840.10008.1.2\" , 17 ) == 0 ) { int count , subtype , type ; type = 1 ; subtype = 0 ; if ( strlen ( transfer_syntax ) > 17 ) { count = sscanf ( transfer_syntax + 17 , \".%d.%d\" , & type , & subtype ) ; if ( count < 1 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } switch ( type ) { case 1 : { image -> endian = LSBEndian ; break ; } case 2 : { image -> endian = MSBEndian ; break ; } case 4 : { if ( ( subtype >= 80 ) && ( subtype <= 81 ) ) image -> compression = JPEGCompression ; else if ( ( subtype >= 90 ) && ( subtype <= 93 ) ) image -> compression = JPEG2000Compression ; else image -> compression = JPEGCompression ; break ; } case 5 : { image -> compression = RLECompression ; break ; } } } break ; } default : break ; } break ; } case 0x0028 : { switch ( element ) { case 0x0002 : { info . samples_per_pixel = ( size_t ) datum ; break ; } case 0x0004 : { if ( data == ( unsigned char * ) NULL ) break ; for ( i = 0 ; i < ( ssize_t ) MagickMin ( length , MaxTextExtent - 1 ) ; i ++ ) photometric [ i ] = ( char ) data [ i ] ; photometric [ i ] = '\\\\0' ; info . polarity = LocaleCompare ( photometric , \"MONOCHROME1\" ) == 0 ? MagickTrue : MagickFalse ; break ; } case 0x0006 : { if ( datum == 1 ) image -> interlace = PlaneInterlace ; break ; } case 0x0008 : { if ( data == ( unsigned char * ) NULL ) break ; number_scenes = StringToUnsignedLong ( ( char * ) data ) ; break ; } case 0x0010 : { height = ( size_t ) datum ; break ; } case 0x0011 : { width = ( size_t ) datum ; break ; } case 0x0100 : { info . bits_allocated = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( datum > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . bits_allocated ; if ( info . depth > 32 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . bits_allocated ) - 1 ; image -> depth = info . depth ; break ; } case 0x0101 : { info . significant_bits = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( info . significant_bits > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . significant_bits ; if ( info . depth > 32 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . significant_bits ) - 1 ; info . mask = ( size_t ) GetQuantumRange ( info . significant_bits ) ; image -> depth = info . depth ; break ; } case 0x0102 : { break ; } case 0x0103 : { info . signed_data = ( size_t ) datum ; break ; } case 0x1050 : { if ( data != ( unsigned char * ) NULL ) info . window_center = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1051 : { if ( data != ( unsigned char * ) NULL ) info . window_width = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1052 : { if ( data != ( unsigned char * ) NULL ) info . rescale_intercept = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1053 : { if ( data != ( unsigned char * ) NULL ) info . rescale_slope = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1200 : case 0x3006 : { if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / info . bytes_per_pixel ) ; datum = ( int ) colors ; graymap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * graymap ) ) ; if ( graymap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) if ( info . bytes_per_pixel == 1 ) graymap [ i ] = ( int ) data [ i ] ; else graymap [ i ] = ( int ) ( ( short * ) data ) [ i ] ; break ; } case 0x1201 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; redmap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * redmap ) ) ; if ( redmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; redmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1202 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; greenmap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * greenmap ) ) ; if ( greenmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; greenmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1203 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; bluemap = ( int * ) AcquireQuantumMemory ( ( size_t ) colors , sizeof ( * bluemap ) ) ; if ( bluemap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; bluemap [ i ] = ( int ) index ; p += 2 ; } break ; } default : break ; } break ; } case 0x2050 : { switch ( element ) { case 0x0020 : { if ( ( data != ( unsigned char * ) NULL ) && ( strncmp ( ( char * ) data , \"INVERSE\" , 7 ) == 0 ) ) info . polarity = MagickTrue ; break ; } default : break ; } break ; } default : break ; } if ( data != ( unsigned char * ) NULL ) { char * attribute ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; if ( dicom_info [ i ] . description != ( char * ) NULL ) { attribute = AcquireString ( \"dcm:\" ) ; ( void ) ConcatenateString ( & attribute , dicom_info [ i ] . description ) ; for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i == ( ssize_t ) length ) || ( length > 4 ) ) { ( void ) SubstituteString ( & attribute , \"\" , \"\" ) ; ( void ) SetImageProperty ( image , attribute , ( char * ) data ) ; } attribute = DestroyString ( attribute ) ; } } if ( image_info -> verbose != MagickFalse ) { if ( data == ( unsigned char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%d\\\\n\" , datum ) ; else { for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i != ( ssize_t ) length ) && ( length <= 4 ) ) { ssize_t j ; datum = 0 ; for ( j = ( ssize_t ) length - 1 ; j >= 0 ; j -- ) datum = ( 256 * datum + data [ j ] ) ; ( void ) FormatLocaleFile ( stdout , \"%d\" , datum ) ; } else for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( isprint ( ( int ) data [ i ] ) != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"%c\" , data [ i ] ) ; else ( void ) FormatLocaleFile ( stdout , \"%c\" , '.' ) ; ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; } } if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } } if ( ( width == 0 ) || ( height == 0 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; if ( info . signed_data == 0xffff ) info . signed_data = ( size_t ) ( info . significant_bits == 16 ? 1 : 0 ) ; if ( ( image -> compression == JPEGCompression ) || ( image -> compression == JPEG2000Compression ) ) { Image * images ; ImageInfo * read_info ; int c ; size_t length ; unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { MagickOffsetType offset ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; images = NewImageList ( ) ; for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { char filename [ MaxTextExtent ] ; const char * property ; FILE * file ; Image * jpeg_image ; int unique_file ; unsigned int tag ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( tag == 0xFFFEE0DD ) break ; if ( tag != 0xFFFEE000 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( file == ( FILE * ) NULL ) { ( void ) RelinquishUniqueFileResource ( filename ) ; ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , filename ) ; break ; } for ( ; length != 0 ; length -- ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; ( void ) FormatLocaleString ( read_info -> filename , MaxTextExtent , \"jpeg:%s\" , filename ) ; if ( image -> compression == JPEG2000Compression ) ( void ) FormatLocaleString ( read_info -> filename , MaxTextExtent , \"j2k:%s\" , filename ) ; jpeg_image = ReadImage ( read_info , exception ) ; if ( jpeg_image != ( Image * ) NULL ) { ResetImagePropertyIterator ( image ) ; property = GetNextImageProperty ( image ) ; while ( property != ( const char * ) NULL ) { ( void ) SetImageProperty ( jpeg_image , property , GetImageProperty ( image , property ) ) ; property = GetNextImageProperty ( image ) ; } AppendImageToList ( & images , jpeg_image ) ; } ( void ) RelinquishUniqueFileResource ( filename ) ; } read_info = DestroyImageInfo ( read_info ) ; image = DestroyImage ( image ) ; return ( GetFirstImageInList ( images ) ) ; } if ( info . depth != ( 1UL * MAGICKCORE_QUANTUM_DEPTH ) ) { QuantumAny range ; size_t length ; length = ( size_t ) ( GetQuantumRange ( info . depth ) + 1 ) ; info . scale = ( Quantum * ) AcquireQuantumMemory ( length , sizeof ( * info . scale ) ) ; if ( info . scale == ( Quantum * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; range = GetQuantumRange ( info . depth ) ; for ( i = 0 ; i <= ( ssize_t ) GetQuantumRange ( info . depth ) ; i ++ ) info . scale [ i ] = ScaleAnyToQuantum ( ( size_t ) i , range ) ; } if ( image -> compression == RLECompression ) { size_t length ; unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { MagickOffsetType offset ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) + 8 ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } } for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { if ( image_info -> ping != MagickFalse ) break ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; image -> depth = info . depth ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; break ; } image -> colorspace = RGBColorspace ; if ( ( image -> colormap == ( PixelPacket * ) NULL ) && ( info . samples_per_pixel == 1 ) ) { int index ; size_t one ; one = 1 ; if ( colors == 0 ) colors = one << info . depth ; if ( AcquireImageColormap ( image , colors ) == MagickFalse ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( redmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = redmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( Quantum ) index ; } if ( greenmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = greenmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . green = ( Quantum ) index ; } if ( bluemap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = bluemap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . blue = ( Quantum ) index ; } if ( graymap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = graymap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( Quantum ) index ; image -> colormap [ i ] . green = ( Quantum ) index ; image -> colormap [ i ] . blue = ( Quantum ) index ; } } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) ( void ) ReadBlobByte ( image ) ; tag = ( ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; stream_info -> remaining = ( size_t ) ReadBlobLSBLong ( image ) ; if ( ( tag != 0xFFFEE000 ) || ( stream_info -> remaining <= 64 ) || ( EOFBlob ( image ) != MagickFalse ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; stream_info -> count = 0 ; stream_info -> segment_count = ReadBlobLSBLong ( image ) ; for ( i = 0 ; i < 15 ; i ++ ) stream_info -> segments [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; stream_info -> remaining -= 64 ; if ( stream_info -> segment_count > 1 ) { info . bytes_per_pixel = 1 ; info . depth = 8 ; if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , stream_info -> offsets [ 0 ] + stream_info -> segments [ 0 ] , SEEK_SET ) ; } } if ( ( info . samples_per_pixel > 1 ) && ( image -> interlace == PlaneInterlace ) ) { register ssize_t x ; register PixelPacket * q ; ssize_t y ; for ( i = 0 ; i < ( ssize_t ) info . samples_per_pixel ; i ++ ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( ( int ) i ) { case 0 : { SetPixelRed ( q , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) ) ; break ; } case 1 : { SetPixelGreen ( q , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) ) ; break ; } case 2 : { SetPixelBlue ( q , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) ) ; break ; } case 3 : { SetPixelAlpha ( q , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) ) ; break ; } default : break ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } } else { const char * option ; option = GetImageOption ( image_info , \"dcm:display-range\" ) ; if ( option != ( const char * ) NULL ) { if ( LocaleCompare ( option , \"reset\" ) == 0 ) info . window_width = 0 ; } option = GetImageOption ( image_info , \"dcm:window\" ) ; if ( option != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( option , & geometry_info ) ; if ( flags & RhoValue ) info . window_center = geometry_info . rho ; if ( flags & SigmaValue ) info . window_width = geometry_info . sigma ; info . rescale = MagickTrue ; } option = GetImageOption ( image_info , \"dcm:rescale\" ) ; if ( option != ( char * ) NULL ) info . rescale = IsStringTrue ( option ) ; if ( ( info . window_center != 0 ) && ( info . window_width == 0 ) ) info . window_width = info . window_center ; status = ReadDCMPixels ( image , & info , stream_info , MagickTrue , exception ) ; if ( ( status != MagickFalse ) && ( stream_info -> segment_count > 1 ) ) { if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , stream_info -> offsets [ 0 ] + stream_info -> segments [ 1 ] , SEEK_SET ) ; ( void ) ReadDCMPixels ( image , & info , stream_info , MagickFalse , exception ) ; } } if ( SetImageGray ( image , exception ) != MagickFalse ) ( void ) SetImageColorspace ( image , GRAYColorspace ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( number_scenes - 1 ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: crypto_report_comp rcomp ; strncpy ( rcomp .\n", "\n", "Sources:\n", "0: CWE-000 static int crypto_report_comp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_comp rcomp ; strlcpy ( rcomp . type , \"compression\" , sizeof ( rcomp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_COMPRESS , sizeof ( struct crypto_report_comp ) , & rcomp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "1: CWE-200 static int crypto_report_comp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_comp rcomp ; strlcpy ( rcomp . type , \"compression\" , sizeof ( rcomp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_COMPRESS , sizeof ( struct crypto_report_comp ) , & rcomp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "\n", "Target: ; int err ; if ( protocol < 0 || protocol >= IPPROTO_MAX ) return - EINVAL\n", "\n", "Sources:\n", "0: CWE-000 static int inet6_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct inet_sock * inet ; struct ipv6_pinfo * np ; struct sock * sk ; struct inet_protosw * answer ; struct proto * answer_prot ; unsigned char answer_flags ; int try_loading_module = 0 ; int err ; lookup_protocol : err = - ESOCKTNOSUPPORT ; rcu_read_lock ( ) ; list_for_each_entry_rcu ( answer , & inetsw6 [ sock -> type ] , list ) { err = 0 ; if ( protocol == answer -> protocol ) { if ( protocol != IPPROTO_IP ) break ; } else { if ( IPPROTO_IP == protocol ) { protocol = answer -> protocol ; break ; } if ( IPPROTO_IP == answer -> protocol ) break ; } err = - EPROTONOSUPPORT ; } if ( err ) { if ( try_loading_module < 2 ) { rcu_read_unlock ( ) ; if ( ++ try_loading_module == 1 ) request_module ( \"net-pf-%d-proto-%d-type-%d\" , PF_INET6 , protocol , sock -> type ) ; else request_module ( \"net-pf-%d-proto-%d\" , PF_INET6 , protocol ) ; goto lookup_protocol ; } else goto out_rcu_unlock ; } err = - EPERM ; if ( sock -> type == SOCK_RAW && ! kern && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) goto out_rcu_unlock ; sock -> ops = answer -> ops ; answer_prot = answer -> prot ; answer_flags = answer -> flags ; rcu_read_unlock ( ) ; WARN_ON ( ! answer_prot -> slab ) ; err = - ENOBUFS ; sk = sk_alloc ( net , PF_INET6 , GFP_KERNEL , answer_prot , kern ) ; if ( ! sk ) goto out ; sock_init_data ( sock , sk ) ; err = 0 ; if ( INET_PROTOSW_REUSE & answer_flags ) sk -> sk_reuse = SK_CAN_REUSE ; inet = inet_sk ( sk ) ; inet -> is_icsk = ( INET_PROTOSW_ICSK & answer_flags ) != 0 ; if ( SOCK_RAW == sock -> type ) { inet -> inet_num = protocol ; if ( IPPROTO_RAW == protocol ) inet -> hdrincl = 1 ; } sk -> sk_destruct = inet_sock_destruct ; sk -> sk_family = PF_INET6 ; sk -> sk_protocol = protocol ; sk -> sk_backlog_rcv = answer -> prot -> backlog_rcv ; inet_sk ( sk ) -> pinet6 = np = inet6_sk_generic ( sk ) ; np -> hop_limit = - 1 ; np -> mcast_hops = IPV6_DEFAULT_MCASTHOPS ; np -> mc_loop = 1 ; np -> pmtudisc = IPV6_PMTUDISC_WANT ; np -> autoflowlabel = ip6_default_np_autolabel ( sock_net ( sk ) ) ; sk -> sk_ipv6only = net -> ipv6 . sysctl . bindv6only ; inet -> uc_ttl = - 1 ; inet -> mc_loop = 1 ; inet -> mc_ttl = 1 ; inet -> mc_index = 0 ; inet -> mc_list = NULL ; inet -> rcv_tos = 0 ; if ( net -> ipv4 . sysctl_ip_no_pmtu_disc ) inet -> pmtudisc = IP_PMTUDISC_DONT ; else inet -> pmtudisc = IP_PMTUDISC_WANT ; sk_refcnt_debug_inc ( sk ) ; if ( inet -> inet_num ) { inet -> inet_sport = htons ( inet -> inet_num ) ; sk -> sk_prot -> hash ( sk ) ; } if ( sk -> sk_prot -> init ) { err = sk -> sk_prot -> init ( sk ) ; if ( err ) { sk_common_release ( sk ) ; goto out ; } } out : return err ; out_rcu_unlock : rcu_read_unlock ( ) ; goto out ; }\n", "\n", "1: CWE-000 static int inet_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct sock * sk ; struct inet_protosw * answer ; struct inet_sock * inet ; struct proto * answer_prot ; unsigned char answer_flags ; int try_loading_module = 0 ; int err ; sock -> state = SS_UNCONNECTED ; lookup_protocol : err = - ESOCKTNOSUPPORT ; rcu_read_lock ( ) ; list_for_each_entry_rcu ( answer , & inetsw [ sock -> type ] , list ) { err = 0 ; if ( protocol == answer -> protocol ) { if ( protocol != IPPROTO_IP ) break ; } else { if ( IPPROTO_IP == protocol ) { protocol = answer -> protocol ; break ; } if ( IPPROTO_IP == answer -> protocol ) break ; } err = - EPROTONOSUPPORT ; } if ( unlikely ( err ) ) { if ( try_loading_module < 2 ) { rcu_read_unlock ( ) ; if ( ++ try_loading_module == 1 ) request_module ( \"net-pf-%d-proto-%d-type-%d\" , PF_INET , protocol , sock -> type ) ; else request_module ( \"net-pf-%d-proto-%d\" , PF_INET , protocol ) ; goto lookup_protocol ; } else goto out_rcu_unlock ; } err = - EPERM ; if ( sock -> type == SOCK_RAW && ! kern && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) goto out_rcu_unlock ; sock -> ops = answer -> ops ; answer_prot = answer -> prot ; answer_flags = answer -> flags ; rcu_read_unlock ( ) ; WARN_ON ( ! answer_prot -> slab ) ; err = - ENOBUFS ; sk = sk_alloc ( net , PF_INET , GFP_KERNEL , answer_prot , kern ) ; if ( ! sk ) goto out ; err = 0 ; if ( INET_PROTOSW_REUSE & answer_flags ) sk -> sk_reuse = SK_CAN_REUSE ; inet = inet_sk ( sk ) ; inet -> is_icsk = ( INET_PROTOSW_ICSK & answer_flags ) != 0 ; inet -> nodefrag = 0 ; if ( SOCK_RAW == sock -> type ) { inet -> inet_num = protocol ; if ( IPPROTO_RAW == protocol ) inet -> hdrincl = 1 ; } if ( net -> ipv4 . sysctl_ip_no_pmtu_disc ) inet -> pmtudisc = IP_PMTUDISC_DONT ; else inet -> pmtudisc = IP_PMTUDISC_WANT ; inet -> inet_id = 0 ; sock_init_data ( sock , sk ) ; sk -> sk_destruct = inet_sock_destruct ; sk -> sk_protocol = protocol ; sk -> sk_backlog_rcv = sk -> sk_prot -> backlog_rcv ; inet -> uc_ttl = - 1 ; inet -> mc_loop = 1 ; inet -> mc_ttl = 1 ; inet -> mc_all = 1 ; inet -> mc_index = 0 ; inet -> mc_list = NULL ; inet -> rcv_tos = 0 ; sk_refcnt_debug_inc ( sk ) ; if ( inet -> inet_num ) { inet -> inet_sport = htons ( inet -> inet_num ) ; sk -> sk_prot -> hash ( sk ) ; } if ( sk -> sk_prot -> init ) { err = sk -> sk_prot -> init ( sk ) ; if ( err ) sk_common_release ( sk ) ; } out : return err ; out_rcu_unlock : rcu_read_unlock ( ) ; goto out ; }\n", "\n", "\n", "Target: error ; struct mb2_cache * ext4_mb_cache =\n", "\n", "Sources:\n", "0: CWE-19 static int ext4_xattr_block_get ( struct inode * inode , int name_index , const char * name , void * buffer , size_t buffer_size ) { struct buffer_head * bh = NULL ; struct ext4_xattr_entry * entry ; size_t size ; int error ; struct mb_cache * ext4_mb_cache = EXT4_GET_MB_CACHE ( inode ) ; ea_idebug ( inode , \"name=%d.%s,buffer=%p,buffer_size=%ld\" , name_index , name , buffer , ( long ) buffer_size ) ; error = - ENODATA ; if ( ! EXT4_I ( inode ) -> i_file_acl ) goto cleanup ; ea_idebug ( inode , \"readingblock%llu\" , ( unsigned long long ) EXT4_I ( inode ) -> i_file_acl ) ; bh = sb_bread ( inode -> i_sb , EXT4_I ( inode ) -> i_file_acl ) ; if ( ! bh ) goto cleanup ; ea_bdebug ( bh , \"b_count=%d,refcount=%d\" , atomic_read ( & ( bh -> b_count ) ) , le32_to_cpu ( BHDR ( bh ) -> h_refcount ) ) ; if ( ext4_xattr_check_block ( inode , bh ) ) { bad_block : EXT4_ERROR_INODE ( inode , \"badblock%llu\" , EXT4_I ( inode ) -> i_file_acl ) ; error = - EFSCORRUPTED ; goto cleanup ; } ext4_xattr_cache_insert ( ext4_mb_cache , bh ) ; entry = BFIRST ( bh ) ; error = ext4_xattr_find_entry ( & entry , name_index , name , bh -> b_size , 1 ) ; if ( error == - EFSCORRUPTED ) goto bad_block ; if ( error ) goto cleanup ; size = le32_to_cpu ( entry -> e_value_size ) ; if ( buffer ) { error = - ERANGE ; if ( size > buffer_size ) goto cleanup ; memcpy ( buffer , bh -> b_data + le16_to_cpu ( entry -> e_value_offs ) , size ) ; } error = size ; cleanup : brelse ( bh ) ; return error ; }\n", "\n", "1: CWE-19 static int ext4_xattr_block_list ( struct dentry * dentry , char * buffer , size_t buffer_size ) { struct inode * inode = d_inode ( dentry ) ; struct buffer_head * bh = NULL ; int error ; struct mb_cache * ext4_mb_cache = EXT4_GET_MB_CACHE ( inode ) ; ea_idebug ( inode , \"buffer=%p,buffer_size=%ld\" , buffer , ( long ) buffer_size ) ; error = 0 ; if ( ! EXT4_I ( inode ) -> i_file_acl ) goto cleanup ; ea_idebug ( inode , \"readingblock%llu\" , ( unsigned long long ) EXT4_I ( inode ) -> i_file_acl ) ; bh = sb_bread ( inode -> i_sb , EXT4_I ( inode ) -> i_file_acl ) ; error = - EIO ; if ( ! bh ) goto cleanup ; ea_bdebug ( bh , \"b_count=%d,refcount=%d\" , atomic_read ( & ( bh -> b_count ) ) , le32_to_cpu ( BHDR ( bh ) -> h_refcount ) ) ; if ( ext4_xattr_check_block ( inode , bh ) ) { EXT4_ERROR_INODE ( inode , \"badblock%llu\" , EXT4_I ( inode ) -> i_file_acl ) ; error = - EFSCORRUPTED ; goto cleanup ; } ext4_xattr_cache_insert ( ext4_mb_cache , bh ) ; error = ext4_xattr_list_entries ( dentry , BFIRST ( bh ) , buffer , buffer_size ) ; cleanup : brelse ( bh ) ; return error ; }\n", "\n", "\n", "Target: char linebuf [ L_BUFSIZE ] ; l_int32 ( linebuf , L_BUFSIZE , fp ) ( linebuf , \"------%200s------\" , selname )\n", "\n", "Sources:\n", "0: CWE-119 SEL * selReadStream ( FILE * fp ) { char * selname ; char linebuf [ L_BUF_SIZE ] ; l_int32 sy , sx , cy , cx , i , j , version , ignore ; SEL * sel ; PROCNAME ( \"selReadStream\" ) ; if ( ! fp ) return ( SEL * ) ERROR_PTR ( \"streamnotdefined\" , procName , NULL ) ; if ( fscanf ( fp , \"SelVersion%d\\\\n\" , & version ) != 1 ) return ( SEL * ) ERROR_PTR ( \"notaselfile\" , procName , NULL ) ; if ( version != SEL_VERSION_NUMBER ) return ( SEL * ) ERROR_PTR ( \"invalidselversion\" , procName , NULL ) ; if ( fgets ( linebuf , L_BUF_SIZE , fp ) == NULL ) return ( SEL * ) ERROR_PTR ( \"errorreadingintolinebuf\" , procName , NULL ) ; selname = stringNew ( linebuf ) ; sscanf ( linebuf , \"------%s------\" , selname ) ; if ( fscanf ( fp , \"sy=%d,sx=%d,cy=%d,cx=%d\\\\n\" , & sy , & sx , & cy , & cx ) != 4 ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( \"dimensionsnotread\" , procName , NULL ) ; } if ( ( sel = selCreate ( sy , sx , selname ) ) == NULL ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( \"selnotmade\" , procName , NULL ) ; } selSetOrigin ( sel , cy , cx ) ; for ( i = 0 ; i < sy ; i ++ ) { ignore = fscanf ( fp , \"\" ) ; for ( j = 0 ; j < sx ; j ++ ) ignore = fscanf ( fp , \"%1d\" , & sel -> data [ i ] [ j ] ) ; ignore = fscanf ( fp , \"\\\\n\" ) ; } ignore = fscanf ( fp , \"\\\\n\" ) ; LEPT_FREE ( selname ) ; return sel ; }\n", "\n", "1: CWE-787 SEL * selReadStream ( FILE * fp ) { char * selname ; char linebuf [ L_BUF_SIZE ] ; l_int32 sy , sx , cy , cx , i , j , version , ignore ; SEL * sel ; PROCNAME ( \"selReadStream\" ) ; if ( ! fp ) return ( SEL * ) ERROR_PTR ( \"streamnotdefined\" , procName , NULL ) ; if ( fscanf ( fp , \"SelVersion%d\\\\n\" , & version ) != 1 ) return ( SEL * ) ERROR_PTR ( \"notaselfile\" , procName , NULL ) ; if ( version != SEL_VERSION_NUMBER ) return ( SEL * ) ERROR_PTR ( \"invalidselversion\" , procName , NULL ) ; if ( fgets ( linebuf , L_BUF_SIZE , fp ) == NULL ) return ( SEL * ) ERROR_PTR ( \"errorreadingintolinebuf\" , procName , NULL ) ; selname = stringNew ( linebuf ) ; sscanf ( linebuf , \"------%s------\" , selname ) ; if ( fscanf ( fp , \"sy=%d,sx=%d,cy=%d,cx=%d\\\\n\" , & sy , & sx , & cy , & cx ) != 4 ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( \"dimensionsnotread\" , procName , NULL ) ; } if ( ( sel = selCreate ( sy , sx , selname ) ) == NULL ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( \"selnotmade\" , procName , NULL ) ; } selSetOrigin ( sel , cy , cx ) ; for ( i = 0 ; i < sy ; i ++ ) { ignore = fscanf ( fp , \"\" ) ; for ( j = 0 ; j < sx ; j ++ ) ignore = fscanf ( fp , \"%1d\" , & sel -> data [ i ] [ j ] ) ; ignore = fscanf ( fp , \"\\\\n\" ) ; } ignore = fscanf ( fp , \"\\\\n\" ) ; LEPT_FREE ( selname ) ; return sel ; }\n", "\n", "\n", "Target: ( isspace ( ( unsigned char )\n", "\n", "Sources:\n", "0: CWE-119 static int translate_hex_string ( char * s , char * saved_orphan ) { int c1 = * saved_orphan ; char * start = s ; char * t = s ; for ( ; * s ; s ++ ) { if ( isspace ( * s ) ) continue ; if ( c1 ) { * t ++ = ( hexval ( c1 ) << 4 ) + hexval ( * s ) ; c1 = 0 ; } else c1 = * s ; } * saved_orphan = c1 ; return t - start ; }\n", "\n", "1: CWE-119 static int check_line_charstring ( void ) { char * p = line ; while ( isspace ( * p ) ) p ++ ; return ( * p == '/' || ( p [ 0 ] == 'd' && p [ 1 ] == 'u' && p [ 2 ] == 'p' ) ) ; }\n", "\n", "\n", "Target: ; if ( WARN_ON_ONCE ( ! ib_safe_file_access ( fp ) ) ) return - EACCES ; if (\n", "\n", "Sources:\n", "0: CWE-264 static ssize_t hfi1_file_write ( struct file * fp , const char __user * data , size_t count , loff_t * offset ) { const struct hfi1_cmd __user * ucmd ; struct hfi1_filedata * fd = fp -> private_data ; struct hfi1_ctxtdata * uctxt = fd -> uctxt ; struct hfi1_cmd cmd ; struct hfi1_user_info uinfo ; struct hfi1_tid_info tinfo ; unsigned long addr ; ssize_t consumed = 0 , copy = 0 , ret = 0 ; void * dest = NULL ; __u64 user_val = 0 ; int uctxt_required = 1 ; int must_be_root = 0 ; if ( count < sizeof ( cmd ) ) { ret = - EINVAL ; goto bail ; } ucmd = ( const struct hfi1_cmd __user * ) data ; if ( copy_from_user ( & cmd , ucmd , sizeof ( cmd ) ) ) { ret = - EFAULT ; goto bail ; } consumed = sizeof ( cmd ) ; switch ( cmd . type ) { case HFI1_CMD_ASSIGN_CTXT : uctxt_required = 0 ; copy = sizeof ( uinfo ) ; dest = & uinfo ; break ; case HFI1_CMD_SDMA_STATUS_UPD : case HFI1_CMD_CREDIT_UPD : copy = 0 ; break ; case HFI1_CMD_TID_UPDATE : case HFI1_CMD_TID_FREE : case HFI1_CMD_TID_INVAL_READ : copy = sizeof ( tinfo ) ; dest = & tinfo ; break ; case HFI1_CMD_USER_INFO : case HFI1_CMD_RECV_CTRL : case HFI1_CMD_POLL_TYPE : case HFI1_CMD_ACK_EVENT : case HFI1_CMD_CTXT_INFO : case HFI1_CMD_SET_PKEY : case HFI1_CMD_CTXT_RESET : copy = 0 ; user_val = cmd . addr ; break ; case HFI1_CMD_EP_INFO : case HFI1_CMD_EP_ERASE_CHIP : case HFI1_CMD_EP_ERASE_RANGE : case HFI1_CMD_EP_READ_RANGE : case HFI1_CMD_EP_WRITE_RANGE : uctxt_required = 0 ; must_be_root = 1 ; copy = 0 ; break ; default : ret = - EINVAL ; goto bail ; } if ( copy ) { if ( copy_from_user ( dest , ( void __user * ) cmd . addr , copy ) ) { ret = - EFAULT ; goto bail ; } consumed += copy ; } if ( uctxt_required && ! uctxt ) { ret = - EINVAL ; goto bail ; } if ( must_be_root && ! capable ( CAP_SYS_ADMIN ) ) { ret = - EPERM ; goto bail ; } switch ( cmd . type ) { case HFI1_CMD_ASSIGN_CTXT : ret = assign_ctxt ( fp , & uinfo ) ; if ( ret < 0 ) goto bail ; ret = setup_ctxt ( fp ) ; if ( ret ) goto bail ; ret = user_init ( fp ) ; break ; case HFI1_CMD_CTXT_INFO : ret = get_ctxt_info ( fp , ( void __user * ) ( unsigned long ) user_val , cmd . len ) ; break ; case HFI1_CMD_USER_INFO : ret = get_base_info ( fp , ( void __user * ) ( unsigned long ) user_val , cmd . len ) ; break ; case HFI1_CMD_SDMA_STATUS_UPD : break ; case HFI1_CMD_CREDIT_UPD : if ( uctxt && uctxt -> sc ) sc_return_credits ( uctxt -> sc ) ; break ; case HFI1_CMD_TID_UPDATE : ret = hfi1_user_exp_rcv_setup ( fp , & tinfo ) ; if ( ! ret ) { addr = ( unsigned long ) cmd . addr + offsetof ( struct hfi1_tid_info , tidcnt ) ; if ( copy_to_user ( ( void __user * ) addr , & tinfo . tidcnt , sizeof ( tinfo . tidcnt ) + sizeof ( tinfo . length ) ) ) ret = - EFAULT ; } break ; case HFI1_CMD_TID_INVAL_READ : ret = hfi1_user_exp_rcv_invalid ( fp , & tinfo ) ; if ( ret ) break ; addr = ( unsigned long ) cmd . addr + offsetof ( struct hfi1_tid_info , tidcnt ) ; if ( copy_to_user ( ( void __user * ) addr , & tinfo . tidcnt , sizeof ( tinfo . tidcnt ) ) ) ret = - EFAULT ; break ; case HFI1_CMD_TID_FREE : ret = hfi1_user_exp_rcv_clear ( fp , & tinfo ) ; if ( ret ) break ; addr = ( unsigned long ) cmd . addr + offsetof ( struct hfi1_tid_info , tidcnt ) ; if ( copy_to_user ( ( void __user * ) addr , & tinfo . tidcnt , sizeof ( tinfo . tidcnt ) ) ) ret = - EFAULT ; break ; case HFI1_CMD_RECV_CTRL : ret = manage_rcvq ( uctxt , fd -> subctxt , ( int ) user_val ) ; break ; case HFI1_CMD_POLL_TYPE : uctxt -> poll_type = ( typeof ( uctxt -> poll_type ) ) user_val ; break ; case HFI1_CMD_ACK_EVENT : ret = user_event_ack ( uctxt , fd -> subctxt , user_val ) ; break ; case HFI1_CMD_SET_PKEY : if ( HFI1_CAP_IS_USET ( PKEY_CHECK ) ) ret = set_ctxt_pkey ( uctxt , fd -> subctxt , user_val ) ; else ret = - EPERM ; break ; case HFI1_CMD_CTXT_RESET : { struct send_context * sc ; struct hfi1_devdata * dd ; if ( ! uctxt || ! uctxt -> dd || ! uctxt -> sc ) { ret = - EINVAL ; break ; } dd = uctxt -> dd ; sc = uctxt -> sc ; wait_event_interruptible_timeout ( sc -> halt_wait , ( sc -> flags & SCF_HALTED ) , msecs_to_jiffies ( SEND_CTXT_HALT_TIMEOUT ) ) ; if ( ! ( sc -> flags & SCF_HALTED ) ) { ret = - ENOLCK ; break ; } if ( sc -> flags & SCF_FROZEN ) { wait_event_interruptible_timeout ( dd -> event_queue , ! ( ACCESS_ONCE ( dd -> flags ) & HFI1_FROZEN ) , msecs_to_jiffies ( SEND_CTXT_HALT_TIMEOUT ) ) ; if ( dd -> flags & HFI1_FROZEN ) { ret = - ENOLCK ; break ; } if ( dd -> flags & HFI1_FORCED_FREEZE ) { ret = - ENODEV ; break ; } sc_disable ( sc ) ; ret = sc_enable ( sc ) ; hfi1_rcvctrl ( dd , HFI1_RCVCTRL_CTXT_ENB , uctxt -> ctxt ) ; } else { ret = sc_restart ( sc ) ; } if ( ! ret ) sc_return_credits ( sc ) ; break ; } case HFI1_CMD_EP_INFO : case HFI1_CMD_EP_ERASE_CHIP : case HFI1_CMD_EP_ERASE_RANGE : case HFI1_CMD_EP_READ_RANGE : case HFI1_CMD_EP_WRITE_RANGE : ret = handle_eprom_command ( fp , & cmd ) ; break ; } if ( ret >= 0 ) ret = consumed ; bail : return ret ; }\n", "\n", "1: CWE-264 static ssize_t qib_write ( struct file * fp , const char __user * data , size_t count , loff_t * off ) { const struct qib_cmd __user * ucmd ; struct qib_ctxtdata * rcd ; const void __user * src ; size_t consumed , copy = 0 ; struct qib_cmd cmd ; ssize_t ret = 0 ; void * dest ; if ( count < sizeof ( cmd . type ) ) { ret = - EINVAL ; goto bail ; } ucmd = ( const struct qib_cmd __user * ) data ; if ( copy_from_user ( & cmd . type , & ucmd -> type , sizeof ( cmd . type ) ) ) { ret = - EFAULT ; goto bail ; } consumed = sizeof ( cmd . type ) ; switch ( cmd . type ) { case QIB_CMD_ASSIGN_CTXT : case QIB_CMD_USER_INIT : copy = sizeof ( cmd . cmd . user_info ) ; dest = & cmd . cmd . user_info ; src = & ucmd -> cmd . user_info ; break ; case QIB_CMD_RECV_CTRL : copy = sizeof ( cmd . cmd . recv_ctrl ) ; dest = & cmd . cmd . recv_ctrl ; src = & ucmd -> cmd . recv_ctrl ; break ; case QIB_CMD_CTXT_INFO : copy = sizeof ( cmd . cmd . ctxt_info ) ; dest = & cmd . cmd . ctxt_info ; src = & ucmd -> cmd . ctxt_info ; break ; case QIB_CMD_TID_UPDATE : case QIB_CMD_TID_FREE : copy = sizeof ( cmd . cmd . tid_info ) ; dest = & cmd . cmd . tid_info ; src = & ucmd -> cmd . tid_info ; break ; case QIB_CMD_SET_PART_KEY : copy = sizeof ( cmd . cmd . part_key ) ; dest = & cmd . cmd . part_key ; src = & ucmd -> cmd . part_key ; break ; case QIB_CMD_DISARM_BUFS : case QIB_CMD_PIOAVAILUPD : copy = 0 ; src = NULL ; dest = NULL ; break ; case QIB_CMD_POLL_TYPE : copy = sizeof ( cmd . cmd . poll_type ) ; dest = & cmd . cmd . poll_type ; src = & ucmd -> cmd . poll_type ; break ; case QIB_CMD_ARMLAUNCH_CTRL : copy = sizeof ( cmd . cmd . armlaunch_ctrl ) ; dest = & cmd . cmd . armlaunch_ctrl ; src = & ucmd -> cmd . armlaunch_ctrl ; break ; case QIB_CMD_SDMA_INFLIGHT : copy = sizeof ( cmd . cmd . sdma_inflight ) ; dest = & cmd . cmd . sdma_inflight ; src = & ucmd -> cmd . sdma_inflight ; break ; case QIB_CMD_SDMA_COMPLETE : copy = sizeof ( cmd . cmd . sdma_complete ) ; dest = & cmd . cmd . sdma_complete ; src = & ucmd -> cmd . sdma_complete ; break ; case QIB_CMD_ACK_EVENT : copy = sizeof ( cmd . cmd . event_mask ) ; dest = & cmd . cmd . event_mask ; src = & ucmd -> cmd . event_mask ; break ; default : ret = - EINVAL ; goto bail ; } if ( copy ) { if ( ( count - consumed ) < copy ) { ret = - EINVAL ; goto bail ; } if ( copy_from_user ( dest , src , copy ) ) { ret = - EFAULT ; goto bail ; } consumed += copy ; } rcd = ctxt_fp ( fp ) ; if ( ! rcd && cmd . type != QIB_CMD_ASSIGN_CTXT ) { ret = - EINVAL ; goto bail ; } switch ( cmd . type ) { case QIB_CMD_ASSIGN_CTXT : ret = qib_assign_ctxt ( fp , & cmd . cmd . user_info ) ; if ( ret ) goto bail ; break ; case QIB_CMD_USER_INIT : ret = qib_do_user_init ( fp , & cmd . cmd . user_info ) ; if ( ret ) goto bail ; ret = qib_get_base_info ( fp , ( void __user * ) ( unsigned long ) cmd . cmd . user_info . spu_base_info , cmd . cmd . user_info . spu_base_info_size ) ; break ; case QIB_CMD_RECV_CTRL : ret = qib_manage_rcvq ( rcd , subctxt_fp ( fp ) , cmd . cmd . recv_ctrl ) ; break ; case QIB_CMD_CTXT_INFO : ret = qib_ctxt_info ( fp , ( struct qib_ctxt_info __user * ) ( unsigned long ) cmd . cmd . ctxt_info ) ; break ; case QIB_CMD_TID_UPDATE : ret = qib_tid_update ( rcd , fp , & cmd . cmd . tid_info ) ; break ; case QIB_CMD_TID_FREE : ret = qib_tid_free ( rcd , subctxt_fp ( fp ) , & cmd . cmd . tid_info ) ; break ; case QIB_CMD_SET_PART_KEY : ret = qib_set_part_key ( rcd , cmd . cmd . part_key ) ; break ; case QIB_CMD_DISARM_BUFS : ( void ) qib_disarm_piobufs_ifneeded ( rcd ) ; ret = disarm_req_delay ( rcd ) ; break ; case QIB_CMD_PIOAVAILUPD : qib_force_pio_avail_update ( rcd -> dd ) ; break ; case QIB_CMD_POLL_TYPE : rcd -> poll_type = cmd . cmd . poll_type ; break ; case QIB_CMD_ARMLAUNCH_CTRL : rcd -> dd -> f_set_armlaunch ( rcd -> dd , cmd . cmd . armlaunch_ctrl ) ; break ; case QIB_CMD_SDMA_INFLIGHT : ret = qib_sdma_get_inflight ( user_sdma_queue_fp ( fp ) , ( u32 __user * ) ( unsigned long ) cmd . cmd . sdma_inflight ) ; break ; case QIB_CMD_SDMA_COMPLETE : ret = qib_sdma_get_complete ( rcd -> ppd , user_sdma_queue_fp ( fp ) , ( u32 __user * ) ( unsigned long ) cmd . cmd . sdma_complete ) ; break ; case QIB_CMD_ACK_EVENT : ret = qib_user_event_ack ( rcd , subctxt_fp ( fp ) , cmd . cmd . event_mask ) ; break ; } if ( ret >= 0 ) ret = consumed ; bail : return ret ; }\n", "\n", "\n", "Target: char fstr [ 7 ] ; int i ; cp ++ ; for ( i = 0 ; i < 6 ; i ++ ) fstr [ i ] = * cp != '\\\\0' ? * cp ++ : '0' ; fstr [ i ] = '\\\\0' ;\n", "\n", "Sources:\n", "0: CWE-119 static int DecodeNumberField ( int len , char * str , int fmask , int * tmask , struct tm * tm , fsec_t * fsec , int * is2digits ) { char * cp ; if ( ( cp = strchr ( str , '.' ) ) != NULL ) { # ifdef HAVE_INT64_TIMESTAMP char fstr [ MAXDATELEN + 1 ] ; strcpy ( fstr , ( cp + 1 ) ) ; strcpy ( fstr + strlen ( fstr ) , \"000000\" ) ; * ( fstr + 6 ) = '\\\\0' ; * fsec = strtol ( fstr , NULL , 10 ) ; # else * fsec = strtod ( cp , NULL ) ; # endif * cp = '\\\\0' ; len = strlen ( str ) ; } else if ( ( fmask & DTK_DATE_M ) != DTK_DATE_M ) { if ( len == 8 ) { * tmask = DTK_DATE_M ; tm -> tm_mday = atoi ( str + 6 ) ; * ( str + 6 ) = '\\\\0' ; tm -> tm_mon = atoi ( str + 4 ) ; * ( str + 4 ) = '\\\\0' ; tm -> tm_year = atoi ( str + 0 ) ; return DTK_DATE ; } else if ( len == 6 ) { * tmask = DTK_DATE_M ; tm -> tm_mday = atoi ( str + 4 ) ; * ( str + 4 ) = '\\\\0' ; tm -> tm_mon = atoi ( str + 2 ) ; * ( str + 2 ) = '\\\\0' ; tm -> tm_year = atoi ( str + 0 ) ; * is2digits = TRUE ; return DTK_DATE ; } else if ( len == 5 ) { * tmask = DTK_DATE_M ; tm -> tm_mday = atoi ( str + 2 ) ; * ( str + 2 ) = '\\\\0' ; tm -> tm_mon = 1 ; tm -> tm_year = atoi ( str + 0 ) ; * is2digits = TRUE ; return DTK_DATE ; } } if ( ( fmask & DTK_TIME_M ) != DTK_TIME_M ) { if ( len == 6 ) { * tmask = DTK_TIME_M ; tm -> tm_sec = atoi ( str + 4 ) ; * ( str + 4 ) = '\\\\0' ; tm -> tm_min = atoi ( str + 2 ) ; * ( str + 2 ) = '\\\\0' ; tm -> tm_hour = atoi ( str + 0 ) ; return DTK_TIME ; } else if ( len == 4 ) { * tmask = DTK_TIME_M ; tm -> tm_sec = 0 ; tm -> tm_min = atoi ( str + 2 ) ; * ( str + 2 ) = '\\\\0' ; tm -> tm_hour = atoi ( str + 0 ) ; return DTK_TIME ; } } return - 1 ; }\n", "\n", "1: CWE-119 int DecodeTime ( char * str , int * tmask , struct tm * tm , fsec_t * fsec ) { char * cp ; * tmask = DTK_TIME_M ; tm -> tm_hour = strtol ( str , & cp , 10 ) ; if ( * cp != ':' ) return - 1 ; str = cp + 1 ; tm -> tm_min = strtol ( str , & cp , 10 ) ; if ( * cp == '\\\\0' ) { tm -> tm_sec = 0 ; * fsec = 0 ; } else if ( * cp != ':' ) return - 1 ; else { str = cp + 1 ; tm -> tm_sec = strtol ( str , & cp , 10 ) ; if ( * cp == '\\\\0' ) * fsec = 0 ; else if ( * cp == '.' ) { # ifdef HAVE_INT64_TIMESTAMP char fstr [ MAXDATELEN + 1 ] ; strncpy ( fstr , ( cp + 1 ) , 7 ) ; strcpy ( fstr + strlen ( fstr ) , \"000000\" ) ; * ( fstr + 6 ) = '\\\\0' ; * fsec = strtol ( fstr , & cp , 10 ) ; # else str = cp ; * fsec = strtod ( str , & cp ) ; # endif if ( * cp != '\\\\0' ) return - 1 ; } else return - 1 ; } # ifdef HAVE_INT64_TIMESTAMP if ( tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 || tm -> tm_sec < 0 || tm -> tm_sec > 59 || * fsec >= USECS_PER_SEC ) return - 1 ; # else if ( tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 || tm -> tm_sec < 0 || tm -> tm_sec > 59 || * fsec >= 1 ) return - 1 ; # endif return 0 ; }\n", "\n", "\n", "Target: > 0 ) c = c c -> next , which -- ; if ( !\n", "\n", "Sources:\n", "0: CWE-119 void cJSON_ReplaceItemInArray ( cJSON * array , int which , cJSON * newitem ) { cJSON * c = array -> child ; while ( c && which > 0 ) { c = c -> next ; -- which ; } if ( ! c ) return ; newitem -> next = c -> next ; newitem -> prev = c -> prev ; if ( newitem -> next ) newitem -> next -> prev = newitem ; if ( c == array -> child ) array -> child = newitem ; else newitem -> prev -> next = newitem ; c -> next = c -> prev = 0 ; cJSON_Delete ( c ) ; }\n", "\n", "1: CWE-119 cJSON * cJSON_DetachItemFromArray ( cJSON * array , int which ) { cJSON * c = array -> child ; while ( c && which > 0 ) { c = c -> next ; -- which ; } if ( ! c ) return 0 ; if ( c -> prev ) c -> prev -> next = c -> next ; if ( c -> next ) c -> next -> prev = c -> prev ; if ( c == array -> child ) array -> child = c -> next ; c -> prev = c -> next = 0 ; return c ; }\n", "\n", "\n", "Target: -> msg , \"\\\\n\\\\t\\\\tEntry:\\\\\\n\\\\n\\\\t\\\\t\\\\tDescriptor=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tRecNumber=%d\\\\\\n\\\\n\\\\t\\\\t\\\\tFieldIdent=%s\\\\\\n\\\\n\\\\t\\\\t\\\\tValue=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tBufferLength=%d\" , descriptor , SQL_DESC_COUNT && ( intptr_t ) value < == SQL_DESC_PARAMETER_TYPE && ( intptr_t ) != SQL_PARAM_INPUT && ( intptr_t ) != SQL_PARAM_OUTPUT && ( intptr_t ) != SQL_PARAM_INPUT_OUTPUT && ( intptr_t ) != SQL_PARAM_INPUT_OUTPUT_STREAM && ( intptr_t )\n", "\n", "Sources:\n", "0: CWE-119 SQLRETURN SQLSetDescField ( SQLHDESC descriptor_handle , SQLSMALLINT rec_number , SQLSMALLINT field_identifier , SQLPOINTER value , SQLINTEGER buffer_length ) { DMHDESC descriptor = ( DMHDESC ) descriptor_handle ; SQLRETURN ret ; SQLCHAR s1 [ 100 + LOG_MESSAGE_LEN ] ; int isStrField = 0 ; if ( ! __validate_desc ( descriptor ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:SQL_INVALID_HANDLE\" ) ; return SQL_INVALID_HANDLE ; } function_entry ( descriptor ) ; if ( log_info . log_flag ) { sprintf ( descriptor -> msg , \"\\\\n\\\\t\\\\tEntry:\\\\\\n\\\\n\\\\t\\\\t\\\\tDescriptor=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tRecNumber=%d\\\\\\n\\\\n\\\\t\\\\t\\\\tFieldIdent=%s\\\\\\n\\\\n\\\\t\\\\t\\\\tValue=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tBufferLength=%d\" , descriptor , rec_number , __desc_attr_as_string ( s1 , field_identifier ) , value , ( int ) buffer_length ) ; dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , descriptor -> msg ) ; } thread_protect ( SQL_HANDLE_DESC , descriptor ) ; if ( descriptor -> connection -> state < STATE_C4 ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:HY010\" ) ; __post_internal_error ( & descriptor -> error , ERROR_HY010 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( __check_stmt_from_desc ( descriptor , STATE_S8 ) || __check_stmt_from_desc ( descriptor , STATE_S9 ) || __check_stmt_from_desc ( descriptor , STATE_S10 ) || __check_stmt_from_desc ( descriptor , STATE_S11 ) || __check_stmt_from_desc ( descriptor , STATE_S12 ) || __check_stmt_from_desc ( descriptor , STATE_S13 ) || __check_stmt_from_desc ( descriptor , STATE_S14 ) || __check_stmt_from_desc ( descriptor , STATE_S15 ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:HY010\" ) ; __post_internal_error ( & descriptor -> error , ERROR_HY010 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( rec_number < 0 ) { __post_internal_error ( & descriptor -> error , ERROR_07009 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } switch ( field_identifier ) { case SQL_DESC_ALLOC_TYPE : case SQL_DESC_ARRAY_SIZE : case SQL_DESC_ARRAY_STATUS_PTR : case SQL_DESC_BIND_OFFSET_PTR : case SQL_DESC_BIND_TYPE : case SQL_DESC_COUNT : case SQL_DESC_ROWS_PROCESSED_PTR : case SQL_DESC_AUTO_UNIQUE_VALUE : case SQL_DESC_CASE_SENSITIVE : case SQL_DESC_CONCISE_TYPE : case SQL_DESC_DATA_PTR : case SQL_DESC_DATETIME_INTERVAL_CODE : case SQL_DESC_DATETIME_INTERVAL_PRECISION : case SQL_DESC_DISPLAY_SIZE : case SQL_DESC_FIXED_PREC_SCALE : case SQL_DESC_INDICATOR_PTR : case SQL_DESC_LENGTH : case SQL_DESC_NULLABLE : case SQL_DESC_NUM_PREC_RADIX : case SQL_DESC_OCTET_LENGTH : case SQL_DESC_OCTET_LENGTH_PTR : case SQL_DESC_PARAMETER_TYPE : case SQL_DESC_PRECISION : case SQL_DESC_ROWVER : case SQL_DESC_SCALE : case SQL_DESC_SEARCHABLE : case SQL_DESC_TYPE : case SQL_DESC_UNNAMED : case SQL_DESC_UNSIGNED : case SQL_DESC_UPDATABLE : isStrField = 0 ; break ; case SQL_DESC_BASE_COLUMN_NAME : case SQL_DESC_BASE_TABLE_NAME : case SQL_DESC_CATALOG_NAME : case SQL_DESC_LABEL : case SQL_DESC_LITERAL_PREFIX : case SQL_DESC_LITERAL_SUFFIX : case SQL_DESC_LOCAL_TYPE_NAME : case SQL_DESC_NAME : case SQL_DESC_SCHEMA_NAME : case SQL_DESC_TABLE_NAME : case SQL_DESC_TYPE_NAME : isStrField = 1 ; break ; default : isStrField = buffer_length != SQL_IS_POINTER && buffer_length != SQL_IS_INTEGER && buffer_length != SQL_IS_UINTEGER && buffer_length != SQL_IS_SMALLINT && buffer_length != SQL_IS_USMALLINT ; } if ( isStrField && buffer_length < 0 && buffer_length != SQL_NTS ) { __post_internal_error ( & descriptor -> error , ERROR_HY090 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( field_identifier == SQL_DESC_COUNT && ( SQLINTEGER ) value < 0 ) { __post_internal_error ( & descriptor -> error , ERROR_07009 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM ) { __post_internal_error ( & descriptor -> error , ERROR_HY105 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( CHECK_SQLSETDESCFIELD ( descriptor -> connection ) ) { ret = SQLSETDESCFIELD ( descriptor -> connection , descriptor -> driver_desc , rec_number , field_identifier , value , buffer_length ) ; } else if ( CHECK_SQLSETDESCFIELDW ( descriptor -> connection ) ) { SQLWCHAR * s1 = NULL ; if ( isStrField ) { s1 = ansi_to_unicode_alloc ( value , buffer_length , descriptor -> connection , NULL ) ; if ( SQL_NTS != buffer_length ) { buffer_length *= sizeof ( SQLWCHAR ) ; } } else { s1 = value ; } ret = SQLSETDESCFIELDW ( descriptor -> connection , descriptor -> driver_desc , rec_number , field_identifier , s1 , buffer_length ) ; if ( isStrField ) { if ( s1 ) free ( s1 ) ; } } else { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:IM001\" ) ; __post_internal_error ( & descriptor -> error , ERROR_IM001 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( log_info . log_flag ) { sprintf ( descriptor -> msg , \"\\\\n\\\\t\\\\tExit:[%s]\" , __get_return_status ( ret , s1 ) ) ; dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , descriptor -> msg ) ; } return function_return ( SQL_HANDLE_DESC , descriptor , ret ) ; }\n", "\n", "1: CWE-119 SQLRETURN SQLSetDescFieldW ( SQLHDESC descriptor_handle , SQLSMALLINT rec_number , SQLSMALLINT field_identifier , SQLPOINTER value , SQLINTEGER buffer_length ) { DMHDESC descriptor = ( DMHDESC ) descriptor_handle ; SQLRETURN ret ; SQLCHAR s1 [ 100 + LOG_MESSAGE_LEN ] ; int isStrField = 0 ; if ( ! __validate_desc ( descriptor ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:SQL_INVALID_HANDLE\" ) ; # ifdef WITH_HANDLE_REDIRECT { DMHDESC parent_desc ; parent_desc = find_parent_handle ( descriptor , SQL_HANDLE_DESC ) ; if ( parent_desc ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Info:foundparenthandle\" ) ; if ( CHECK_SQLSETDESCFIELDW ( parent_desc -> connection ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Info:callingredirecteddriverfunction\" ) ; return SQLSETDESCFIELDW ( parent_desc -> connection , descriptor , rec_number , field_identifier , value , buffer_length ) ; } } } # endif return SQL_INVALID_HANDLE ; } function_entry ( descriptor ) ; if ( log_info . log_flag ) { sprintf ( descriptor -> msg , \"\\\\n\\\\t\\\\tEntry:\\\\\\n\\\\n\\\\t\\\\t\\\\tDescriptor=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tRecNumber=%d\\\\\\n\\\\n\\\\t\\\\t\\\\tFieldIdent=%s\\\\\\n\\\\n\\\\t\\\\t\\\\tValue=%p\\\\\\n\\\\n\\\\t\\\\t\\\\tBufferLength=%d\" , descriptor , rec_number , __desc_attr_as_string ( s1 , field_identifier ) , value , ( int ) buffer_length ) ; dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , descriptor -> msg ) ; } thread_protect ( SQL_HANDLE_DESC , descriptor ) ; if ( descriptor -> connection -> state < STATE_C4 ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:HY010\" ) ; __post_internal_error ( & descriptor -> error , ERROR_HY010 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( __check_stmt_from_desc ( descriptor , STATE_S8 ) || __check_stmt_from_desc ( descriptor , STATE_S9 ) || __check_stmt_from_desc ( descriptor , STATE_S10 ) || __check_stmt_from_desc ( descriptor , STATE_S11 ) || __check_stmt_from_desc ( descriptor , STATE_S12 ) || __check_stmt_from_desc ( descriptor , STATE_S13 ) || __check_stmt_from_desc ( descriptor , STATE_S14 ) || __check_stmt_from_desc ( descriptor , STATE_S15 ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:HY010\" ) ; __post_internal_error ( & descriptor -> error , ERROR_HY010 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( rec_number < 0 ) { __post_internal_error ( & descriptor -> error , ERROR_07009 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } switch ( field_identifier ) { case SQL_DESC_ALLOC_TYPE : case SQL_DESC_ARRAY_SIZE : case SQL_DESC_ARRAY_STATUS_PTR : case SQL_DESC_BIND_OFFSET_PTR : case SQL_DESC_BIND_TYPE : case SQL_DESC_COUNT : case SQL_DESC_ROWS_PROCESSED_PTR : case SQL_DESC_AUTO_UNIQUE_VALUE : case SQL_DESC_CASE_SENSITIVE : case SQL_DESC_CONCISE_TYPE : case SQL_DESC_DATA_PTR : case SQL_DESC_DATETIME_INTERVAL_CODE : case SQL_DESC_DATETIME_INTERVAL_PRECISION : case SQL_DESC_DISPLAY_SIZE : case SQL_DESC_FIXED_PREC_SCALE : case SQL_DESC_INDICATOR_PTR : case SQL_DESC_LENGTH : case SQL_DESC_NULLABLE : case SQL_DESC_NUM_PREC_RADIX : case SQL_DESC_OCTET_LENGTH : case SQL_DESC_OCTET_LENGTH_PTR : case SQL_DESC_PARAMETER_TYPE : case SQL_DESC_PRECISION : case SQL_DESC_ROWVER : case SQL_DESC_SCALE : case SQL_DESC_SEARCHABLE : case SQL_DESC_TYPE : case SQL_DESC_UNNAMED : case SQL_DESC_UNSIGNED : case SQL_DESC_UPDATABLE : isStrField = 0 ; break ; case SQL_DESC_BASE_COLUMN_NAME : case SQL_DESC_BASE_TABLE_NAME : case SQL_DESC_CATALOG_NAME : case SQL_DESC_LABEL : case SQL_DESC_LITERAL_PREFIX : case SQL_DESC_LITERAL_SUFFIX : case SQL_DESC_LOCAL_TYPE_NAME : case SQL_DESC_NAME : case SQL_DESC_SCHEMA_NAME : case SQL_DESC_TABLE_NAME : case SQL_DESC_TYPE_NAME : isStrField = 1 ; break ; default : isStrField = buffer_length != SQL_IS_POINTER && buffer_length != SQL_IS_INTEGER && buffer_length != SQL_IS_UINTEGER && buffer_length != SQL_IS_SMALLINT && buffer_length != SQL_IS_USMALLINT ; } if ( isStrField && buffer_length < 0 && buffer_length != SQL_NTS ) { __post_internal_error ( & descriptor -> error , ERROR_HY090 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( field_identifier == SQL_DESC_COUNT && ( SQLINTEGER ) value < 0 ) { __post_internal_error ( & descriptor -> error , ERROR_07009 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM ) { __post_internal_error ( & descriptor -> error , ERROR_HY105 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } if ( descriptor -> connection -> unicode_driver || CHECK_SQLSETDESCFIELDW ( descriptor -> connection ) ) { if ( ! CHECK_SQLSETDESCFIELDW ( descriptor -> connection ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:IM001\" ) ; __post_internal_error ( & descriptor -> error , ERROR_IM001 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } ret = SQLSETDESCFIELDW ( descriptor -> connection , descriptor -> driver_desc , rec_number , field_identifier , value , buffer_length ) ; if ( log_info . log_flag ) { sprintf ( descriptor -> msg , \"\\\\n\\\\t\\\\tExit:[%s]\" , __get_return_status ( ret , s1 ) ) ; dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , descriptor -> msg ) ; } } else { SQLCHAR * ascii_str = NULL ; if ( ! CHECK_SQLSETDESCFIELD ( descriptor -> connection ) ) { dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , \"Error:IM001\" ) ; __post_internal_error ( & descriptor -> error , ERROR_IM001 , NULL , descriptor -> connection -> environment -> requested_version ) ; return function_return_nodrv ( SQL_HANDLE_DESC , descriptor , SQL_ERROR ) ; } switch ( field_identifier ) { case SQL_DESC_NAME : ascii_str = ( SQLCHAR * ) unicode_to_ansi_alloc ( value , buffer_length , descriptor -> connection , NULL ) ; value = ascii_str ; buffer_length = strlen ( ( char * ) ascii_str ) ; break ; default : break ; } ret = SQLSETDESCFIELD ( descriptor -> connection , descriptor -> driver_desc , rec_number , field_identifier , value , buffer_length ) ; if ( log_info . log_flag ) { sprintf ( descriptor -> msg , \"\\\\n\\\\t\\\\tExit:[%s]\" , __get_return_status ( ret , s1 ) ) ; dm_log_write ( __FILE__ , __LINE__ , LOG_INFO , LOG_INFO , descriptor -> msg ) ; } if ( ascii_str ) { free ( ascii_str ) ; } } return function_return ( SQL_HANDLE_DESC , descriptor , ret ) ; }\n", "\n", "\n", "Target: = xchg ( ( __force struct ipv6_txoptions * * ) ( opt ) { atomic_sub ( opt -> tot_len , & sk -> sk_omem_alloc ) ; txopt_put ( opt ) ; } pktopt = xchg ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; opt = ( sk , opt , optname ( opt ) { atomic_sub ( opt -> tot_len , & sk -> sk_omem_alloc ) ; txopt_put ( opt ) ; } break ; } ) ) ; atomic_set ( & opt -> refcnt , 1 ) ; ( opt ) { atomic_sub ( opt -> tot_len , & sk -> sk_omem_alloc ) ; txopt_put ( opt ) ; } break ; }\n", "\n", "Sources:\n", "0: CWE-416 static int do_ipv6_setsockopt ( struct sock * sk , int level , int optname , char __user * optval , unsigned int optlen ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct net * net = sock_net ( sk ) ; int val , valbool ; int retv = - ENOPROTOOPT ; bool needs_rtnl = setsockopt_needs_rtnl ( optname ) ; if ( ! optval ) val = 0 ; else { if ( optlen >= sizeof ( int ) ) { if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; } else val = 0 ; } valbool = ( val != 0 ) ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_setsockopt ( sk , optname , optval , optlen ) ; if ( needs_rtnl ) rtnl_lock ( ) ; lock_sock ( sk ) ; switch ( optname ) { case IPV6_ADDRFORM : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val == PF_INET ) { struct ipv6_txoptions * opt ; struct sk_buff * pktopt ; if ( sk -> sk_type == SOCK_RAW ) break ; if ( sk -> sk_protocol == IPPROTO_UDP || sk -> sk_protocol == IPPROTO_UDPLITE ) { struct udp_sock * up = udp_sk ( sk ) ; if ( up -> pending == AF_INET6 ) { retv = - EBUSY ; break ; } } else if ( sk -> sk_protocol != IPPROTO_TCP ) break ; if ( sk -> sk_state != TCP_ESTABLISHED ) { retv = - ENOTCONN ; break ; } if ( ipv6_only_sock ( sk ) || ! ipv6_addr_v4mapped ( & sk -> sk_v6_daddr ) ) { retv = - EADDRNOTAVAIL ; break ; } fl6_free_socklist ( sk ) ; ipv6_sock_mc_close ( sk ) ; sk_refcnt_debug_dec ( sk ) ; if ( sk -> sk_protocol == IPPROTO_TCP ) { struct inet_connection_sock * icsk = inet_csk ( sk ) ; local_bh_disable ( ) ; sock_prot_inuse_add ( net , sk -> sk_prot , - 1 ) ; sock_prot_inuse_add ( net , & tcp_prot , 1 ) ; local_bh_enable ( ) ; sk -> sk_prot = & tcp_prot ; icsk -> icsk_af_ops = & ipv4_specific ; sk -> sk_socket -> ops = & inet_stream_ops ; sk -> sk_family = PF_INET ; tcp_sync_mss ( sk , icsk -> icsk_pmtu_cookie ) ; } else { struct proto * prot = & udp_prot ; if ( sk -> sk_protocol == IPPROTO_UDPLITE ) prot = & udplite_prot ; local_bh_disable ( ) ; sock_prot_inuse_add ( net , sk -> sk_prot , - 1 ) ; sock_prot_inuse_add ( net , prot , 1 ) ; local_bh_enable ( ) ; sk -> sk_prot = prot ; sk -> sk_socket -> ops = & inet_dgram_ops ; sk -> sk_family = PF_INET ; } opt = xchg ( & np -> opt , NULL ) ; if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; pktopt = xchg ( & np -> pktoptions , NULL ) ; kfree_skb ( pktopt ) ; sk -> sk_destruct = inet_sock_destruct ; sk_refcnt_debug_inc ( sk ) ; module_put ( THIS_MODULE ) ; retv = 0 ; break ; } goto e_inval ; case IPV6_V6ONLY : if ( optlen < sizeof ( int ) || inet_sk ( sk ) -> inet_num ) goto e_inval ; sk -> sk_ipv6only = valbool ; retv = 0 ; break ; case IPV6_RECVPKTINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxinfo = valbool ; retv = 0 ; break ; case IPV6_2292PKTINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxoinfo = valbool ; retv = 0 ; break ; case IPV6_RECVHOPLIMIT : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxhlim = valbool ; retv = 0 ; break ; case IPV6_2292HOPLIMIT : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxohlim = valbool ; retv = 0 ; break ; case IPV6_RECVRTHDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . srcrt = valbool ; retv = 0 ; break ; case IPV6_2292RTHDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . osrcrt = valbool ; retv = 0 ; break ; case IPV6_RECVHOPOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . hopopts = valbool ; retv = 0 ; break ; case IPV6_2292HOPOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . ohopopts = valbool ; retv = 0 ; break ; case IPV6_RECVDSTOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . dstopts = valbool ; retv = 0 ; break ; case IPV6_2292DSTOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . odstopts = valbool ; retv = 0 ; break ; case IPV6_TCLASS : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < - 1 || val > 0xff ) goto e_inval ; if ( val == - 1 ) val = 0 ; np -> tclass = val ; retv = 0 ; break ; case IPV6_RECVTCLASS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxtclass = valbool ; retv = 0 ; break ; case IPV6_FLOWINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxflow = valbool ; retv = 0 ; break ; case IPV6_RECVPATHMTU : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxpmtu = valbool ; retv = 0 ; break ; case IPV6_TRANSPARENT : if ( valbool && ! ns_capable ( net -> user_ns , CAP_NET_ADMIN ) && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) { retv = - EPERM ; break ; } if ( optlen < sizeof ( int ) ) goto e_inval ; inet_sk ( sk ) -> transparent = valbool ; retv = 0 ; break ; case IPV6_RECVORIGDSTADDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxorigdstaddr = valbool ; retv = 0 ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { struct ipv6_txoptions * opt ; if ( optlen == 0 ) optval = NULL ; else if ( ! optval ) goto e_inval ; else if ( optlen < sizeof ( struct ipv6_opt_hdr ) || optlen & 0x7 || optlen > 8 * 255 ) goto e_inval ; retv = - EPERM ; if ( optname != IPV6_RTHDR && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) break ; opt = ipv6_renew_options ( sk , np -> opt , optname , ( struct ipv6_opt_hdr __user * ) optval , optlen ) ; if ( IS_ERR ( opt ) ) { retv = PTR_ERR ( opt ) ; break ; } retv = - EINVAL ; if ( optname == IPV6_RTHDR && opt && opt -> srcrt ) { struct ipv6_rt_hdr * rthdr = opt -> srcrt ; switch ( rthdr -> type ) { # if IS_ENABLED ( CONFIG_IPV6_MIP6 ) case IPV6_SRCRT_TYPE_2 : if ( rthdr -> hdrlen != 2 || rthdr -> segments_left != 1 ) goto sticky_done ; break ; # endif default : goto sticky_done ; } } retv = 0 ; opt = ipv6_update_options ( sk , opt ) ; sticky_done : if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; break ; } case IPV6_PKTINFO : { struct in6_pktinfo pkt ; if ( optlen == 0 ) goto e_inval ; else if ( optlen < sizeof ( struct in6_pktinfo ) || ! optval ) goto e_inval ; if ( copy_from_user ( & pkt , optval , sizeof ( struct in6_pktinfo ) ) ) { retv = - EFAULT ; break ; } if ( sk -> sk_bound_dev_if && pkt . ipi6_ifindex != sk -> sk_bound_dev_if ) goto e_inval ; np -> sticky_pktinfo . ipi6_ifindex = pkt . ipi6_ifindex ; np -> sticky_pktinfo . ipi6_addr = pkt . ipi6_addr ; retv = 0 ; break ; } case IPV6_2292PKTOPTIONS : { struct ipv6_txoptions * opt = NULL ; struct msghdr msg ; struct flowi6 fl6 ; int junk ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = sk -> sk_mark ; if ( optlen == 0 ) goto update ; retv = - EINVAL ; if ( optlen > 64 * 1024 ) break ; opt = sock_kmalloc ( sk , sizeof ( * opt ) + optlen , GFP_KERNEL ) ; retv = - ENOBUFS ; if ( ! opt ) break ; memset ( opt , 0 , sizeof ( * opt ) ) ; opt -> tot_len = sizeof ( * opt ) + optlen ; retv = - EFAULT ; if ( copy_from_user ( opt + 1 , optval , optlen ) ) goto done ; msg . msg_controllen = optlen ; msg . msg_control = ( void * ) ( opt + 1 ) ; retv = ip6_datagram_send_ctl ( net , sk , & msg , & fl6 , opt , & junk , & junk , & junk ) ; if ( retv ) goto done ; update : retv = 0 ; opt = ipv6_update_options ( sk , opt ) ; done : if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; break ; } case IPV6_UNICAST_HOPS : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val > 255 || val < - 1 ) goto e_inval ; np -> hop_limit = val ; retv = 0 ; break ; case IPV6_MULTICAST_HOPS : if ( sk -> sk_type == SOCK_STREAM ) break ; if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val > 255 || val < - 1 ) goto e_inval ; np -> mcast_hops = ( val == - 1 ? IPV6_DEFAULT_MCASTHOPS : val ) ; retv = 0 ; break ; case IPV6_MULTICAST_LOOP : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val != valbool ) goto e_inval ; np -> mc_loop = valbool ; retv = 0 ; break ; case IPV6_UNICAST_IF : { struct net_device * dev = NULL ; int ifindex ; if ( optlen != sizeof ( int ) ) goto e_inval ; ifindex = ( __force int ) ntohl ( ( __force __be32 ) val ) ; if ( ifindex == 0 ) { np -> ucast_oif = 0 ; retv = 0 ; break ; } dev = dev_get_by_index ( net , ifindex ) ; retv = - EADDRNOTAVAIL ; if ( ! dev ) break ; dev_put ( dev ) ; retv = - EINVAL ; if ( sk -> sk_bound_dev_if ) break ; np -> ucast_oif = ifindex ; retv = 0 ; break ; } case IPV6_MULTICAST_IF : if ( sk -> sk_type == SOCK_STREAM ) break ; if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val ) { struct net_device * dev ; if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != val ) goto e_inval ; dev = dev_get_by_index ( net , val ) ; if ( ! dev ) { retv = - ENODEV ; break ; } dev_put ( dev ) ; } np -> mcast_oif = val ; retv = 0 ; break ; case IPV6_ADD_MEMBERSHIP : case IPV6_DROP_MEMBERSHIP : { struct ipv6_mreq mreq ; if ( optlen < sizeof ( struct ipv6_mreq ) ) goto e_inval ; retv = - EPROTO ; if ( inet_sk ( sk ) -> is_icsk ) break ; retv = - EFAULT ; if ( copy_from_user ( & mreq , optval , sizeof ( struct ipv6_mreq ) ) ) break ; if ( optname == IPV6_ADD_MEMBERSHIP ) retv = ipv6_sock_mc_join ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_multiaddr ) ; else retv = ipv6_sock_mc_drop ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_multiaddr ) ; break ; } case IPV6_JOIN_ANYCAST : case IPV6_LEAVE_ANYCAST : { struct ipv6_mreq mreq ; if ( optlen < sizeof ( struct ipv6_mreq ) ) goto e_inval ; retv = - EFAULT ; if ( copy_from_user ( & mreq , optval , sizeof ( struct ipv6_mreq ) ) ) break ; if ( optname == IPV6_JOIN_ANYCAST ) retv = ipv6_sock_ac_join ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_acaddr ) ; else retv = ipv6_sock_ac_drop ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_acaddr ) ; break ; } case MCAST_JOIN_GROUP : case MCAST_LEAVE_GROUP : { struct group_req greq ; struct sockaddr_in6 * psin6 ; if ( optlen < sizeof ( struct group_req ) ) goto e_inval ; retv = - EFAULT ; if ( copy_from_user ( & greq , optval , sizeof ( struct group_req ) ) ) break ; if ( greq . gr_group . ss_family != AF_INET6 ) { retv = - EADDRNOTAVAIL ; break ; } psin6 = ( struct sockaddr_in6 * ) & greq . gr_group ; if ( optname == MCAST_JOIN_GROUP ) retv = ipv6_sock_mc_join ( sk , greq . gr_interface , & psin6 -> sin6_addr ) ; else retv = ipv6_sock_mc_drop ( sk , greq . gr_interface , & psin6 -> sin6_addr ) ; break ; } case MCAST_JOIN_SOURCE_GROUP : case MCAST_LEAVE_SOURCE_GROUP : case MCAST_BLOCK_SOURCE : case MCAST_UNBLOCK_SOURCE : { struct group_source_req greqs ; int omode , add ; if ( optlen < sizeof ( struct group_source_req ) ) goto e_inval ; if ( copy_from_user ( & greqs , optval , sizeof ( greqs ) ) ) { retv = - EFAULT ; break ; } if ( greqs . gsr_group . ss_family != AF_INET6 || greqs . gsr_source . ss_family != AF_INET6 ) { retv = - EADDRNOTAVAIL ; break ; } if ( optname == MCAST_BLOCK_SOURCE ) { omode = MCAST_EXCLUDE ; add = 1 ; } else if ( optname == MCAST_UNBLOCK_SOURCE ) { omode = MCAST_EXCLUDE ; add = 0 ; } else if ( optname == MCAST_JOIN_SOURCE_GROUP ) { struct sockaddr_in6 * psin6 ; psin6 = ( struct sockaddr_in6 * ) & greqs . gsr_group ; retv = ipv6_sock_mc_join ( sk , greqs . gsr_interface , & psin6 -> sin6_addr ) ; if ( retv && retv != - EADDRINUSE ) break ; omode = MCAST_INCLUDE ; add = 1 ; } else { omode = MCAST_INCLUDE ; add = 0 ; } retv = ip6_mc_source ( add , omode , sk , & greqs ) ; break ; } case MCAST_MSFILTER : { struct group_filter * gsf ; if ( optlen < GROUP_FILTER_SIZE ( 0 ) ) goto e_inval ; if ( optlen > sysctl_optmem_max ) { retv = - ENOBUFS ; break ; } gsf = kmalloc ( optlen , GFP_KERNEL ) ; if ( ! gsf ) { retv = - ENOBUFS ; break ; } retv = - EFAULT ; if ( copy_from_user ( gsf , optval , optlen ) ) { kfree ( gsf ) ; break ; } if ( gsf -> gf_numsrc >= 0x1ffffffU || gsf -> gf_numsrc > sysctl_mld_max_msf ) { kfree ( gsf ) ; retv = - ENOBUFS ; break ; } if ( GROUP_FILTER_SIZE ( gsf -> gf_numsrc ) > optlen ) { kfree ( gsf ) ; retv = - EINVAL ; break ; } retv = ip6_mc_msfilter ( sk , gsf ) ; kfree ( gsf ) ; break ; } case IPV6_ROUTER_ALERT : if ( optlen < sizeof ( int ) ) goto e_inval ; retv = ip6_ra_control ( sk , val ) ; break ; case IPV6_MTU_DISCOVER : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < IPV6_PMTUDISC_DONT || val > IPV6_PMTUDISC_OMIT ) goto e_inval ; np -> pmtudisc = val ; retv = 0 ; break ; case IPV6_MTU : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val && val < IPV6_MIN_MTU ) goto e_inval ; np -> frag_size = val ; retv = 0 ; break ; case IPV6_RECVERR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> recverr = valbool ; if ( ! val ) skb_queue_purge ( & sk -> sk_error_queue ) ; retv = 0 ; break ; case IPV6_FLOWINFO_SEND : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> sndflow = valbool ; retv = 0 ; break ; case IPV6_FLOWLABEL_MGR : retv = ipv6_flowlabel_opt ( sk , optval , optlen ) ; break ; case IPV6_IPSEC_POLICY : case IPV6_XFRM_POLICY : retv = - EPERM ; if ( ! ns_capable ( net -> user_ns , CAP_NET_ADMIN ) ) break ; retv = xfrm_user_policy ( sk , optname , optval , optlen ) ; break ; case IPV6_ADDR_PREFERENCES : { unsigned int pref = 0 ; unsigned int prefmask = ~ 0 ; if ( optlen < sizeof ( int ) ) goto e_inval ; retv = - EINVAL ; switch ( val & ( IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP | IPV6_PREFER_SRC_PUBTMP_DEFAULT ) ) { case IPV6_PREFER_SRC_PUBLIC : pref |= IPV6_PREFER_SRC_PUBLIC ; break ; case IPV6_PREFER_SRC_TMP : pref |= IPV6_PREFER_SRC_TMP ; break ; case IPV6_PREFER_SRC_PUBTMP_DEFAULT : break ; case 0 : goto pref_skip_pubtmp ; default : goto e_inval ; } prefmask &= ~ ( IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP ) ; pref_skip_pubtmp : switch ( val & ( IPV6_PREFER_SRC_HOME | IPV6_PREFER_SRC_COA ) ) { case IPV6_PREFER_SRC_HOME : break ; case IPV6_PREFER_SRC_COA : pref |= IPV6_PREFER_SRC_COA ; case 0 : goto pref_skip_coa ; default : goto e_inval ; } prefmask &= ~ IPV6_PREFER_SRC_COA ; pref_skip_coa : switch ( val & ( IPV6_PREFER_SRC_CGA | IPV6_PREFER_SRC_NONCGA ) ) { case IPV6_PREFER_SRC_CGA : case IPV6_PREFER_SRC_NONCGA : case 0 : break ; default : goto e_inval ; } np -> srcprefs = ( np -> srcprefs & prefmask ) | pref ; retv = 0 ; break ; } case IPV6_MINHOPCOUNT : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < 0 || val > 255 ) goto e_inval ; np -> min_hopcount = val ; retv = 0 ; break ; case IPV6_DONTFRAG : np -> dontfrag = valbool ; retv = 0 ; break ; case IPV6_AUTOFLOWLABEL : np -> autoflowlabel = valbool ; retv = 0 ; break ; } release_sock ( sk ) ; if ( needs_rtnl ) rtnl_unlock ( ) ; return retv ; e_inval : release_sock ( sk ) ; if ( needs_rtnl ) rtnl_unlock ( ) ; return - EINVAL ; }\n", "\n", "1: CWE-264 static int do_ipv6_setsockopt ( struct sock * sk , int level , int optname , char __user * optval , unsigned int optlen ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct net * net = sock_net ( sk ) ; int val , valbool ; int retv = - ENOPROTOOPT ; bool needs_rtnl = setsockopt_needs_rtnl ( optname ) ; if ( ! optval ) val = 0 ; else { if ( optlen >= sizeof ( int ) ) { if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; } else val = 0 ; } valbool = ( val != 0 ) ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_setsockopt ( sk , optname , optval , optlen ) ; if ( needs_rtnl ) rtnl_lock ( ) ; lock_sock ( sk ) ; switch ( optname ) { case IPV6_ADDRFORM : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val == PF_INET ) { struct ipv6_txoptions * opt ; struct sk_buff * pktopt ; if ( sk -> sk_type == SOCK_RAW ) break ; if ( sk -> sk_protocol == IPPROTO_UDP || sk -> sk_protocol == IPPROTO_UDPLITE ) { struct udp_sock * up = udp_sk ( sk ) ; if ( up -> pending == AF_INET6 ) { retv = - EBUSY ; break ; } } else if ( sk -> sk_protocol != IPPROTO_TCP ) break ; if ( sk -> sk_state != TCP_ESTABLISHED ) { retv = - ENOTCONN ; break ; } if ( ipv6_only_sock ( sk ) || ! ipv6_addr_v4mapped ( & sk -> sk_v6_daddr ) ) { retv = - EADDRNOTAVAIL ; break ; } fl6_free_socklist ( sk ) ; ipv6_sock_mc_close ( sk ) ; sk_refcnt_debug_dec ( sk ) ; if ( sk -> sk_protocol == IPPROTO_TCP ) { struct inet_connection_sock * icsk = inet_csk ( sk ) ; local_bh_disable ( ) ; sock_prot_inuse_add ( net , sk -> sk_prot , - 1 ) ; sock_prot_inuse_add ( net , & tcp_prot , 1 ) ; local_bh_enable ( ) ; sk -> sk_prot = & tcp_prot ; icsk -> icsk_af_ops = & ipv4_specific ; sk -> sk_socket -> ops = & inet_stream_ops ; sk -> sk_family = PF_INET ; tcp_sync_mss ( sk , icsk -> icsk_pmtu_cookie ) ; } else { struct proto * prot = & udp_prot ; if ( sk -> sk_protocol == IPPROTO_UDPLITE ) prot = & udplite_prot ; local_bh_disable ( ) ; sock_prot_inuse_add ( net , sk -> sk_prot , - 1 ) ; sock_prot_inuse_add ( net , prot , 1 ) ; local_bh_enable ( ) ; sk -> sk_prot = prot ; sk -> sk_socket -> ops = & inet_dgram_ops ; sk -> sk_family = PF_INET ; } opt = xchg ( & np -> opt , NULL ) ; if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; pktopt = xchg ( & np -> pktoptions , NULL ) ; kfree_skb ( pktopt ) ; sk -> sk_destruct = inet_sock_destruct ; sk_refcnt_debug_inc ( sk ) ; module_put ( THIS_MODULE ) ; retv = 0 ; break ; } goto e_inval ; case IPV6_V6ONLY : if ( optlen < sizeof ( int ) || inet_sk ( sk ) -> inet_num ) goto e_inval ; sk -> sk_ipv6only = valbool ; retv = 0 ; break ; case IPV6_RECVPKTINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxinfo = valbool ; retv = 0 ; break ; case IPV6_2292PKTINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxoinfo = valbool ; retv = 0 ; break ; case IPV6_RECVHOPLIMIT : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxhlim = valbool ; retv = 0 ; break ; case IPV6_2292HOPLIMIT : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxohlim = valbool ; retv = 0 ; break ; case IPV6_RECVRTHDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . srcrt = valbool ; retv = 0 ; break ; case IPV6_2292RTHDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . osrcrt = valbool ; retv = 0 ; break ; case IPV6_RECVHOPOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . hopopts = valbool ; retv = 0 ; break ; case IPV6_2292HOPOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . ohopopts = valbool ; retv = 0 ; break ; case IPV6_RECVDSTOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . dstopts = valbool ; retv = 0 ; break ; case IPV6_2292DSTOPTS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . odstopts = valbool ; retv = 0 ; break ; case IPV6_TCLASS : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < - 1 || val > 0xff ) goto e_inval ; if ( val == - 1 ) val = 0 ; np -> tclass = val ; retv = 0 ; break ; case IPV6_RECVTCLASS : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxtclass = valbool ; retv = 0 ; break ; case IPV6_FLOWINFO : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxflow = valbool ; retv = 0 ; break ; case IPV6_RECVPATHMTU : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxpmtu = valbool ; retv = 0 ; break ; case IPV6_TRANSPARENT : if ( valbool && ! ns_capable ( net -> user_ns , CAP_NET_ADMIN ) && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) { retv = - EPERM ; break ; } if ( optlen < sizeof ( int ) ) goto e_inval ; inet_sk ( sk ) -> transparent = valbool ; retv = 0 ; break ; case IPV6_RECVORIGDSTADDR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> rxopt . bits . rxorigdstaddr = valbool ; retv = 0 ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { struct ipv6_txoptions * opt ; if ( optlen == 0 ) optval = NULL ; else if ( ! optval ) goto e_inval ; else if ( optlen < sizeof ( struct ipv6_opt_hdr ) || optlen & 0x7 || optlen > 8 * 255 ) goto e_inval ; retv = - EPERM ; if ( optname != IPV6_RTHDR && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) break ; opt = ipv6_renew_options ( sk , np -> opt , optname , ( struct ipv6_opt_hdr __user * ) optval , optlen ) ; if ( IS_ERR ( opt ) ) { retv = PTR_ERR ( opt ) ; break ; } retv = - EINVAL ; if ( optname == IPV6_RTHDR && opt && opt -> srcrt ) { struct ipv6_rt_hdr * rthdr = opt -> srcrt ; switch ( rthdr -> type ) { # if IS_ENABLED ( CONFIG_IPV6_MIP6 ) case IPV6_SRCRT_TYPE_2 : if ( rthdr -> hdrlen != 2 || rthdr -> segments_left != 1 ) goto sticky_done ; break ; # endif default : goto sticky_done ; } } retv = 0 ; opt = ipv6_update_options ( sk , opt ) ; sticky_done : if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; break ; } case IPV6_PKTINFO : { struct in6_pktinfo pkt ; if ( optlen == 0 ) goto e_inval ; else if ( optlen < sizeof ( struct in6_pktinfo ) || ! optval ) goto e_inval ; if ( copy_from_user ( & pkt , optval , sizeof ( struct in6_pktinfo ) ) ) { retv = - EFAULT ; break ; } if ( sk -> sk_bound_dev_if && pkt . ipi6_ifindex != sk -> sk_bound_dev_if ) goto e_inval ; np -> sticky_pktinfo . ipi6_ifindex = pkt . ipi6_ifindex ; np -> sticky_pktinfo . ipi6_addr = pkt . ipi6_addr ; retv = 0 ; break ; } case IPV6_2292PKTOPTIONS : { struct ipv6_txoptions * opt = NULL ; struct msghdr msg ; struct flowi6 fl6 ; int junk ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = sk -> sk_mark ; if ( optlen == 0 ) goto update ; retv = - EINVAL ; if ( optlen > 64 * 1024 ) break ; opt = sock_kmalloc ( sk , sizeof ( * opt ) + optlen , GFP_KERNEL ) ; retv = - ENOBUFS ; if ( ! opt ) break ; memset ( opt , 0 , sizeof ( * opt ) ) ; opt -> tot_len = sizeof ( * opt ) + optlen ; retv = - EFAULT ; if ( copy_from_user ( opt + 1 , optval , optlen ) ) goto done ; msg . msg_controllen = optlen ; msg . msg_control = ( void * ) ( opt + 1 ) ; retv = ip6_datagram_send_ctl ( net , sk , & msg , & fl6 , opt , & junk , & junk , & junk ) ; if ( retv ) goto done ; update : retv = 0 ; opt = ipv6_update_options ( sk , opt ) ; done : if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; break ; } case IPV6_UNICAST_HOPS : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val > 255 || val < - 1 ) goto e_inval ; np -> hop_limit = val ; retv = 0 ; break ; case IPV6_MULTICAST_HOPS : if ( sk -> sk_type == SOCK_STREAM ) break ; if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val > 255 || val < - 1 ) goto e_inval ; np -> mcast_hops = ( val == - 1 ? IPV6_DEFAULT_MCASTHOPS : val ) ; retv = 0 ; break ; case IPV6_MULTICAST_LOOP : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val != valbool ) goto e_inval ; np -> mc_loop = valbool ; retv = 0 ; break ; case IPV6_UNICAST_IF : { struct net_device * dev = NULL ; int ifindex ; if ( optlen != sizeof ( int ) ) goto e_inval ; ifindex = ( __force int ) ntohl ( ( __force __be32 ) val ) ; if ( ifindex == 0 ) { np -> ucast_oif = 0 ; retv = 0 ; break ; } dev = dev_get_by_index ( net , ifindex ) ; retv = - EADDRNOTAVAIL ; if ( ! dev ) break ; dev_put ( dev ) ; retv = - EINVAL ; if ( sk -> sk_bound_dev_if ) break ; np -> ucast_oif = ifindex ; retv = 0 ; break ; } case IPV6_MULTICAST_IF : if ( sk -> sk_type == SOCK_STREAM ) break ; if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val ) { struct net_device * dev ; if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != val ) goto e_inval ; dev = dev_get_by_index ( net , val ) ; if ( ! dev ) { retv = - ENODEV ; break ; } dev_put ( dev ) ; } np -> mcast_oif = val ; retv = 0 ; break ; case IPV6_ADD_MEMBERSHIP : case IPV6_DROP_MEMBERSHIP : { struct ipv6_mreq mreq ; if ( optlen < sizeof ( struct ipv6_mreq ) ) goto e_inval ; retv = - EPROTO ; if ( inet_sk ( sk ) -> is_icsk ) break ; retv = - EFAULT ; if ( copy_from_user ( & mreq , optval , sizeof ( struct ipv6_mreq ) ) ) break ; if ( optname == IPV6_ADD_MEMBERSHIP ) retv = ipv6_sock_mc_join ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_multiaddr ) ; else retv = ipv6_sock_mc_drop ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_multiaddr ) ; break ; } case IPV6_JOIN_ANYCAST : case IPV6_LEAVE_ANYCAST : { struct ipv6_mreq mreq ; if ( optlen < sizeof ( struct ipv6_mreq ) ) goto e_inval ; retv = - EFAULT ; if ( copy_from_user ( & mreq , optval , sizeof ( struct ipv6_mreq ) ) ) break ; if ( optname == IPV6_JOIN_ANYCAST ) retv = ipv6_sock_ac_join ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_acaddr ) ; else retv = ipv6_sock_ac_drop ( sk , mreq . ipv6mr_ifindex , & mreq . ipv6mr_acaddr ) ; break ; } case MCAST_JOIN_GROUP : case MCAST_LEAVE_GROUP : { struct group_req greq ; struct sockaddr_in6 * psin6 ; if ( optlen < sizeof ( struct group_req ) ) goto e_inval ; retv = - EFAULT ; if ( copy_from_user ( & greq , optval , sizeof ( struct group_req ) ) ) break ; if ( greq . gr_group . ss_family != AF_INET6 ) { retv = - EADDRNOTAVAIL ; break ; } psin6 = ( struct sockaddr_in6 * ) & greq . gr_group ; if ( optname == MCAST_JOIN_GROUP ) retv = ipv6_sock_mc_join ( sk , greq . gr_interface , & psin6 -> sin6_addr ) ; else retv = ipv6_sock_mc_drop ( sk , greq . gr_interface , & psin6 -> sin6_addr ) ; break ; } case MCAST_JOIN_SOURCE_GROUP : case MCAST_LEAVE_SOURCE_GROUP : case MCAST_BLOCK_SOURCE : case MCAST_UNBLOCK_SOURCE : { struct group_source_req greqs ; int omode , add ; if ( optlen < sizeof ( struct group_source_req ) ) goto e_inval ; if ( copy_from_user ( & greqs , optval , sizeof ( greqs ) ) ) { retv = - EFAULT ; break ; } if ( greqs . gsr_group . ss_family != AF_INET6 || greqs . gsr_source . ss_family != AF_INET6 ) { retv = - EADDRNOTAVAIL ; break ; } if ( optname == MCAST_BLOCK_SOURCE ) { omode = MCAST_EXCLUDE ; add = 1 ; } else if ( optname == MCAST_UNBLOCK_SOURCE ) { omode = MCAST_EXCLUDE ; add = 0 ; } else if ( optname == MCAST_JOIN_SOURCE_GROUP ) { struct sockaddr_in6 * psin6 ; psin6 = ( struct sockaddr_in6 * ) & greqs . gsr_group ; retv = ipv6_sock_mc_join ( sk , greqs . gsr_interface , & psin6 -> sin6_addr ) ; if ( retv && retv != - EADDRINUSE ) break ; omode = MCAST_INCLUDE ; add = 1 ; } else { omode = MCAST_INCLUDE ; add = 0 ; } retv = ip6_mc_source ( add , omode , sk , & greqs ) ; break ; } case MCAST_MSFILTER : { struct group_filter * gsf ; if ( optlen < GROUP_FILTER_SIZE ( 0 ) ) goto e_inval ; if ( optlen > sysctl_optmem_max ) { retv = - ENOBUFS ; break ; } gsf = kmalloc ( optlen , GFP_KERNEL ) ; if ( ! gsf ) { retv = - ENOBUFS ; break ; } retv = - EFAULT ; if ( copy_from_user ( gsf , optval , optlen ) ) { kfree ( gsf ) ; break ; } if ( gsf -> gf_numsrc >= 0x1ffffffU || gsf -> gf_numsrc > sysctl_mld_max_msf ) { kfree ( gsf ) ; retv = - ENOBUFS ; break ; } if ( GROUP_FILTER_SIZE ( gsf -> gf_numsrc ) > optlen ) { kfree ( gsf ) ; retv = - EINVAL ; break ; } retv = ip6_mc_msfilter ( sk , gsf ) ; kfree ( gsf ) ; break ; } case IPV6_ROUTER_ALERT : if ( optlen < sizeof ( int ) ) goto e_inval ; retv = ip6_ra_control ( sk , val ) ; break ; case IPV6_MTU_DISCOVER : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < IPV6_PMTUDISC_DONT || val > IPV6_PMTUDISC_OMIT ) goto e_inval ; np -> pmtudisc = val ; retv = 0 ; break ; case IPV6_MTU : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val && val < IPV6_MIN_MTU ) goto e_inval ; np -> frag_size = val ; retv = 0 ; break ; case IPV6_RECVERR : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> recverr = valbool ; if ( ! val ) skb_queue_purge ( & sk -> sk_error_queue ) ; retv = 0 ; break ; case IPV6_FLOWINFO_SEND : if ( optlen < sizeof ( int ) ) goto e_inval ; np -> sndflow = valbool ; retv = 0 ; break ; case IPV6_FLOWLABEL_MGR : retv = ipv6_flowlabel_opt ( sk , optval , optlen ) ; break ; case IPV6_IPSEC_POLICY : case IPV6_XFRM_POLICY : retv = - EPERM ; if ( ! ns_capable ( net -> user_ns , CAP_NET_ADMIN ) ) break ; retv = xfrm_user_policy ( sk , optname , optval , optlen ) ; break ; case IPV6_ADDR_PREFERENCES : { unsigned int pref = 0 ; unsigned int prefmask = ~ 0 ; if ( optlen < sizeof ( int ) ) goto e_inval ; retv = - EINVAL ; switch ( val & ( IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP | IPV6_PREFER_SRC_PUBTMP_DEFAULT ) ) { case IPV6_PREFER_SRC_PUBLIC : pref |= IPV6_PREFER_SRC_PUBLIC ; break ; case IPV6_PREFER_SRC_TMP : pref |= IPV6_PREFER_SRC_TMP ; break ; case IPV6_PREFER_SRC_PUBTMP_DEFAULT : break ; case 0 : goto pref_skip_pubtmp ; default : goto e_inval ; } prefmask &= ~ ( IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP ) ; pref_skip_pubtmp : switch ( val & ( IPV6_PREFER_SRC_HOME | IPV6_PREFER_SRC_COA ) ) { case IPV6_PREFER_SRC_HOME : break ; case IPV6_PREFER_SRC_COA : pref |= IPV6_PREFER_SRC_COA ; case 0 : goto pref_skip_coa ; default : goto e_inval ; } prefmask &= ~ IPV6_PREFER_SRC_COA ; pref_skip_coa : switch ( val & ( IPV6_PREFER_SRC_CGA | IPV6_PREFER_SRC_NONCGA ) ) { case IPV6_PREFER_SRC_CGA : case IPV6_PREFER_SRC_NONCGA : case 0 : break ; default : goto e_inval ; } np -> srcprefs = ( np -> srcprefs & prefmask ) | pref ; retv = 0 ; break ; } case IPV6_MINHOPCOUNT : if ( optlen < sizeof ( int ) ) goto e_inval ; if ( val < 0 || val > 255 ) goto e_inval ; np -> min_hopcount = val ; retv = 0 ; break ; case IPV6_DONTFRAG : np -> dontfrag = valbool ; retv = 0 ; break ; case IPV6_AUTOFLOWLABEL : np -> autoflowlabel = valbool ; retv = 0 ; break ; } release_sock ( sk ) ; if ( needs_rtnl ) rtnl_unlock ( ) ; return retv ; e_inval : release_sock ( sk ) ; if ( needs_rtnl ) rtnl_unlock ( ) ; return - EINVAL ; }\n", "\n", "\n", "Target: us_delay ) ; TEMP_FAILURE_RETRY ( usleep ( us_delay )\n", "\n", "Sources:\n", "0: CWE-284 static ssize_t in_read ( struct audio_stream_in * stream , void * buffer , size_t bytes ) { struct a2dp_stream_in * in = ( struct a2dp_stream_in * ) stream ; int read ; DEBUG ( \"read%zubytes,state:%d\" , bytes , in -> common . state ) ; if ( in -> common . state == AUDIO_A2DP_STATE_SUSPENDED ) { DEBUG ( \"streamsuspended\" ) ; return - 1 ; } if ( ( in -> common . state == AUDIO_A2DP_STATE_STOPPED ) || ( in -> common . state == AUDIO_A2DP_STATE_STANDBY ) ) { pthread_mutex_lock ( & in -> common . lock ) ; if ( start_audio_datapath ( & in -> common ) < 0 ) { int us_delay = calc_audiotime ( in -> common . cfg , bytes ) ; DEBUG ( \"emulatea2dpreaddelay(%dus)\" , us_delay ) ; usleep ( us_delay ) ; pthread_mutex_unlock ( & in -> common . lock ) ; return - 1 ; } pthread_mutex_unlock ( & in -> common . lock ) ; } else if ( in -> common . state != AUDIO_A2DP_STATE_STARTED ) { ERROR ( \"streamnotinstoppedorstandby\" ) ; return - 1 ; } read = skt_read ( in -> common . audio_fd , buffer , bytes ) ; if ( read == - 1 ) { skt_disconnect ( in -> common . audio_fd ) ; in -> common . audio_fd = AUDIO_SKT_DISCONNECTED ; in -> common . state = AUDIO_A2DP_STATE_STOPPED ; } else if ( read == 0 ) { DEBUG ( \"readtimeout-returnzeros\" ) ; memset ( buffer , 0 , bytes ) ; read = bytes ; } DEBUG ( \"read%dbytesoutof%zubytes\" , read , bytes ) ; return read ; }\n", "\n", "1: CWE-284 static ssize_t out_write ( struct audio_stream_out * stream , const void * buffer , size_t bytes ) { struct a2dp_stream_out * out = ( struct a2dp_stream_out * ) stream ; int sent ; DEBUG ( \"write%zubytes(fd%d)\" , bytes , out -> common . audio_fd ) ; pthread_mutex_lock ( & out -> common . lock ) ; if ( out -> common . state == AUDIO_A2DP_STATE_SUSPENDED ) { DEBUG ( \"streamsuspended\" ) ; pthread_mutex_unlock ( & out -> common . lock ) ; return - 1 ; } if ( ( out -> common . state == AUDIO_A2DP_STATE_STOPPED ) || ( out -> common . state == AUDIO_A2DP_STATE_STANDBY ) ) { if ( start_audio_datapath ( & out -> common ) < 0 ) { int us_delay = calc_audiotime ( out -> common . cfg , bytes ) ; DEBUG ( \"emulatea2dpwritedelay(%dus)\" , us_delay ) ; usleep ( us_delay ) ; pthread_mutex_unlock ( & out -> common . lock ) ; return - 1 ; } } else if ( out -> common . state != AUDIO_A2DP_STATE_STARTED ) { ERROR ( \"streamnotinstoppedorstandby\" ) ; pthread_mutex_unlock ( & out -> common . lock ) ; return - 1 ; } pthread_mutex_unlock ( & out -> common . lock ) ; sent = skt_write ( out -> common . audio_fd , buffer , bytes ) ; if ( sent == - 1 ) { skt_disconnect ( out -> common . audio_fd ) ; out -> common . audio_fd = AUDIO_SKT_DISCONNECTED ; if ( out -> common . state != AUDIO_A2DP_STATE_SUSPENDED ) out -> common . state = AUDIO_A2DP_STATE_STOPPED ; else ERROR ( \"writefailed:streamsuspended,avoidresettingstate\" ) ; } else { const size_t frames = bytes / audio_stream_out_frame_size ( stream ) ; out -> frames_rendered += frames ; out -> frames_presented += frames ; } DEBUG ( \"wrote%dbytesoutof%zubytes\" , sent , bytes ) ; return sent ; }\n", "\n", "\n", "Target: ; if ( ctx -> terminated ||\n", "\n", "Sources:\n", "0: CWE-000 OM_uint32 kg_seal_iov ( OM_uint32 * minor_status , gss_ctx_id_t context_handle , int conf_req_flag , gss_qop_t qop_req , int * conf_state , gss_iov_buffer_desc * iov , int iov_count , int toktype ) { krb5_gss_ctx_id_rec * ctx ; krb5_error_code code ; krb5_context context ; if ( qop_req != 0 ) { * minor_status = ( OM_uint32 ) G_UNKNOWN_QOP ; return GSS_S_FAILURE ; } ctx = ( krb5_gss_ctx_id_rec * ) context_handle ; if ( ! ctx -> established ) { * minor_status = KG_CTX_INCOMPLETE ; return GSS_S_NO_CONTEXT ; } if ( conf_req_flag && kg_integ_only_iov ( iov , iov_count ) ) { conf_req_flag = FALSE ; } context = ctx -> k5_context ; switch ( ctx -> proto ) { case 0 : code = make_seal_token_v1_iov ( context , ctx , conf_req_flag , conf_state , iov , iov_count , toktype ) ; break ; case 1 : code = gss_krb5int_make_seal_token_v3_iov ( context , ctx , conf_req_flag , conf_state , iov , iov_count , toktype ) ; break ; default : code = G_UNKNOWN_QOP ; break ; } if ( code != 0 ) { * minor_status = code ; save_error_info ( * minor_status , context ) ; return GSS_S_FAILURE ; } * minor_status = 0 ; return GSS_S_COMPLETE ; }\n", "\n", "1: CWE-000 OM_uint32 kg_unseal_iov ( OM_uint32 * minor_status , gss_ctx_id_t context_handle , int * conf_state , gss_qop_t * qop_state , gss_iov_buffer_desc * iov , int iov_count , int toktype ) { krb5_gss_ctx_id_rec * ctx ; OM_uint32 code ; ctx = ( krb5_gss_ctx_id_rec * ) context_handle ; if ( ! ctx -> established ) { * minor_status = KG_CTX_INCOMPLETE ; return GSS_S_NO_CONTEXT ; } if ( kg_locate_iov ( iov , iov_count , GSS_IOV_BUFFER_TYPE_STREAM ) != NULL ) { code = kg_unseal_stream_iov ( minor_status , ctx , conf_state , qop_state , iov , iov_count , toktype ) ; } else { code = kg_unseal_iov_token ( minor_status , ctx , conf_state , qop_state , iov , iov_count , toktype ) ; } return code ; }\n", "\n", "\n", "Target: = create_spnego_ctx ( 0\n", "\n", "Sources:\n", "0: CWE-763 static OM_uint32 acc_ctx_new ( OM_uint32 * minor_status , gss_buffer_t buf , gss_ctx_id_t * ctx , spnego_gss_cred_id_t spcred , gss_buffer_t * mechToken , gss_buffer_t * mechListMIC , OM_uint32 * negState , send_token_flag * return_token ) { OM_uint32 tmpmin , ret , req_flags ; gss_OID_set supported_mechSet , mechTypes ; gss_buffer_desc der_mechTypes ; gss_OID mech_wanted ; spnego_gss_ctx_id_t sc = NULL ; ret = GSS_S_DEFECTIVE_TOKEN ; der_mechTypes . length = 0 ; der_mechTypes . value = NULL ; * mechToken = * mechListMIC = GSS_C_NO_BUFFER ; supported_mechSet = mechTypes = GSS_C_NO_OID_SET ; * return_token = ERROR_TOKEN_SEND ; * negState = REJECT ; * minor_status = 0 ; ret = get_negTokenInit ( minor_status , buf , & der_mechTypes , & mechTypes , & req_flags , mechToken , mechListMIC ) ; if ( ret != GSS_S_COMPLETE ) { goto cleanup ; } ret = get_negotiable_mechs ( minor_status , spcred , GSS_C_ACCEPT , & supported_mechSet ) ; if ( ret != GSS_S_COMPLETE ) { * return_token = NO_TOKEN_SEND ; goto cleanup ; } mech_wanted = negotiate_mech ( supported_mechSet , mechTypes , negState ) ; if ( * negState == REJECT ) { ret = GSS_S_BAD_MECH ; goto cleanup ; } sc = ( spnego_gss_ctx_id_t ) * ctx ; if ( sc != NULL ) { gss_release_buffer ( & tmpmin , & sc -> DER_mechTypes ) ; assert ( mech_wanted != GSS_C_NO_OID ) ; } else sc = create_spnego_ctx ( ) ; if ( sc == NULL ) { ret = GSS_S_FAILURE ; * return_token = NO_TOKEN_SEND ; goto cleanup ; } sc -> mech_set = mechTypes ; mechTypes = GSS_C_NO_OID_SET ; sc -> internal_mech = mech_wanted ; sc -> DER_mechTypes = der_mechTypes ; der_mechTypes . length = 0 ; der_mechTypes . value = NULL ; if ( * negState == REQUEST_MIC ) sc -> mic_reqd = 1 ; * return_token = INIT_TOKEN_SEND ; sc -> firstpass = 1 ; * ctx = ( gss_ctx_id_t ) sc ; ret = GSS_S_COMPLETE ; cleanup : gss_release_oid_set ( & tmpmin , & mechTypes ) ; gss_release_oid_set ( & tmpmin , & supported_mechSet ) ; if ( der_mechTypes . length != 0 ) gss_release_buffer ( & tmpmin , & der_mechTypes ) ; return ret ; }\n", "\n", "1: CWE-763 static OM_uint32 acc_ctx_hints ( OM_uint32 * minor_status , gss_ctx_id_t * ctx , spnego_gss_cred_id_t spcred , gss_buffer_t * mechListMIC , OM_uint32 * negState , send_token_flag * return_token ) { OM_uint32 tmpmin , ret ; gss_OID_set supported_mechSet ; spnego_gss_ctx_id_t sc = NULL ; * mechListMIC = GSS_C_NO_BUFFER ; supported_mechSet = GSS_C_NO_OID_SET ; * return_token = NO_TOKEN_SEND ; * negState = REJECT ; * minor_status = 0 ; if ( * ctx != GSS_C_NO_CONTEXT ) return GSS_S_DEFECTIVE_TOKEN ; ret = get_negotiable_mechs ( minor_status , spcred , GSS_C_ACCEPT , & supported_mechSet ) ; if ( ret != GSS_S_COMPLETE ) goto cleanup ; ret = make_NegHints ( minor_status , mechListMIC ) ; if ( ret != GSS_S_COMPLETE ) goto cleanup ; sc = create_spnego_ctx ( ) ; if ( sc == NULL ) { ret = GSS_S_FAILURE ; goto cleanup ; } if ( put_mech_set ( supported_mechSet , & sc -> DER_mechTypes ) < 0 ) { ret = GSS_S_FAILURE ; goto cleanup ; } sc -> internal_mech = GSS_C_NO_OID ; * negState = ACCEPT_INCOMPLETE ; * return_token = INIT_TOKEN_SEND ; sc -> firstpass = 1 ; * ctx = ( gss_ctx_id_t ) sc ; sc = NULL ; ret = GSS_S_COMPLETE ; cleanup : release_spnego_ctx ( & sc ) ; gss_release_oid_set ( & tmpmin , & supported_mechSet ) ; return ret ; }\n", "\n", "\n", "Target: len , group ; Node * * * tp ; unsigned int parse_depth ; group = 0 ) goto end_of_token ; parse_depth = env -> parse_depth return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID ; parse_depth ++ ; if ( parse_depth > ParseDepthLimit ) return ONIGERR_PARSE_DEPTH_LIMIT_OVER ;\n", "\n", "Sources:\n", "0: CWE-400 static int parse_exp ( Node * * np , PToken * tok , int term , UChar * * src , UChar * end , ScanEnv * env , int group_head ) { int r , len , group = 0 ; Node * qn ; Node * * tp ; * np = NULL ; if ( tok -> type == ( enum TokenSyms ) term ) goto end_of_token ; switch ( tok -> type ) { case TK_ALT : case TK_EOT : end_of_token : * np = node_new_empty ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; return tok -> type ; break ; case TK_SUBEXP_OPEN : r = parse_bag ( np , tok , TK_SUBEXP_CLOSE , src , end , env ) ; if ( r < 0 ) return r ; if ( r == 1 ) { if ( group_head == 0 ) group = 1 ; else { Node * target = * np ; * np = node_new_group ( target ) ; if ( IS_NULL ( * np ) ) { onig_node_free ( target ) ; return ONIGERR_MEMORY ; } group = 2 ; } } else if ( r == 2 ) { Node * target ; OnigOptionType prev = env -> options ; env -> options = BAG_ ( * np ) -> o . options ; r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; r = parse_subexp ( & target , tok , term , src , end , env , 0 ) ; env -> options = prev ; if ( r < 0 ) { onig_node_free ( target ) ; return r ; } NODE_BODY ( * np ) = target ; return tok -> type ; } break ; case TK_SUBEXP_CLOSE : if ( ! IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP ) ) return ONIGERR_UNMATCHED_CLOSE_PARENTHESIS ; if ( tok -> escaped ) goto tk_raw_byte ; else goto tk_byte ; break ; case TK_STRING : tk_byte : { * np = node_new_str ( tok -> backp , * src ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; while ( 1 ) { r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; if ( r != TK_STRING ) break ; r = onig_node_str_cat ( * np , tok -> backp , * src ) ; if ( r < 0 ) return r ; } string_end : tp = np ; goto repeat ; } break ; case TK_RAW_BYTE : tk_raw_byte : { * np = node_new_str_raw_char ( ( UChar ) tok -> u . c ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; len = 1 ; while ( 1 ) { if ( len >= ONIGENC_MBC_MINLEN ( env -> enc ) ) { if ( len == enclen ( env -> enc , STR_ ( * np ) -> s ) ) { r = fetch_token ( tok , src , end , env ) ; goto tk_raw_byte_end ; } } r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; if ( r != TK_RAW_BYTE ) return ONIGERR_TOO_SHORT_MULTI_BYTE_STRING ; r = node_str_cat_char ( * np , ( UChar ) tok -> u . c ) ; if ( r < 0 ) return r ; len ++ ; } tk_raw_byte_end : if ( ! ONIGENC_IS_VALID_MBC_STRING ( env -> enc , STR_ ( * np ) -> s , STR_ ( * np ) -> end ) ) return ONIGERR_INVALID_WIDE_CHAR_VALUE ; NODE_STRING_CLEAR_RAW ( * np ) ; goto string_end ; } break ; case TK_CODE_POINT : { UChar buf [ ONIGENC_CODE_TO_MBC_MAXLEN ] ; len = ONIGENC_CODE_TO_MBC ( env -> enc , tok -> u . code , buf ) ; if ( len < 0 ) return len ; # ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG * np = node_new_str_raw ( buf , buf + len ) ; # else * np = node_new_str ( buf , buf + len ) ; # endif CHECK_NULL_RETURN_MEMERR ( * np ) ; } break ; case TK_QUOTE_OPEN : { OnigCodePoint end_op [ 2 ] ; UChar * qstart , * qend , * nextp ; end_op [ 0 ] = ( OnigCodePoint ) MC_ESC ( env -> syntax ) ; end_op [ 1 ] = ( OnigCodePoint ) 'E' ; qstart = * src ; qend = find_str_position ( end_op , 2 , qstart , end , & nextp , env -> enc ) ; if ( IS_NULL ( qend ) ) { nextp = qend = end ; } * np = node_new_str ( qstart , qend ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; * src = nextp ; } break ; case TK_CHAR_TYPE : { switch ( tok -> u . prop . ctype ) { case ONIGENC_CTYPE_WORD : * np = node_new_ctype ( tok -> u . prop . ctype , tok -> u . prop . not , env -> options ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; case ONIGENC_CTYPE_SPACE : case ONIGENC_CTYPE_DIGIT : case ONIGENC_CTYPE_XDIGIT : { CClassNode * cc ; * np = node_new_cclass ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; cc = CCLASS_ ( * np ) ; add_ctype_to_cc ( cc , tok -> u . prop . ctype , 0 , env ) ; if ( tok -> u . prop . not != 0 ) NCCLASS_SET_NOT ( cc ) ; } break ; default : return ONIGERR_PARSER_BUG ; break ; } } break ; case TK_CHAR_PROPERTY : r = parse_char_property ( np , tok , src , end , env ) ; if ( r != 0 ) return r ; break ; case TK_CC_OPEN : { CClassNode * cc ; r = parse_char_class ( np , tok , src , end , env ) ; if ( r != 0 ) return r ; cc = CCLASS_ ( * np ) ; if ( IS_IGNORECASE ( env -> options ) ) { IApplyCaseFoldArg iarg ; iarg . env = env ; iarg . cc = cc ; iarg . alt_root = NULL_NODE ; iarg . ptail = & ( iarg . alt_root ) ; r = ONIGENC_APPLY_ALL_CASE_FOLD ( env -> enc , env -> case_fold_flag , i_apply_case_fold , & iarg ) ; if ( r != 0 ) { onig_node_free ( iarg . alt_root ) ; return r ; } if ( IS_NOT_NULL ( iarg . alt_root ) ) { Node * work = onig_node_new_alt ( * np , iarg . alt_root ) ; if ( IS_NULL ( work ) ) { onig_node_free ( iarg . alt_root ) ; return ONIGERR_MEMORY ; } * np = work ; } } } break ; case TK_ANYCHAR : * np = node_new_anychar ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; case TK_ANYCHAR_ANYTIME : * np = node_new_anychar ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; qn = node_new_quantifier ( 0 , INFINITE_REPEAT , 0 ) ; CHECK_NULL_RETURN_MEMERR ( qn ) ; NODE_BODY ( qn ) = * np ; * np = qn ; break ; case TK_BACKREF : len = tok -> u . backref . num ; * np = node_new_backref ( len , ( len > 1 ? tok -> u . backref . refs : & ( tok -> u . backref . ref1 ) ) , tok -> u . backref . by_name , # ifdef USE_BACKREF_WITH_LEVEL tok -> u . backref . exist_level , tok -> u . backref . level , # endif env ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; # ifdef USE_CALL case TK_CALL : { int gnum = tok -> u . call . gnum ; * np = node_new_call ( tok -> u . call . name , tok -> u . call . name_end , gnum , tok -> u . call . by_number ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; env -> num_call ++ ; if ( tok -> u . call . by_number != 0 && gnum == 0 ) { env -> has_call_zero = 1 ; } } break ; # endif case TK_ANCHOR : { int ascii_mode = IS_WORD_ASCII ( env -> options ) && IS_WORD_ANCHOR_TYPE ( tok -> u . anchor ) ? 1 : 0 ; * np = onig_node_new_anchor ( tok -> u . anchor , ascii_mode ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; } break ; case TK_REPEAT : case TK_INTERVAL : if ( IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS ) ) { if ( IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS ) ) return ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED ; else { * np = node_new_empty ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; } } else { goto tk_byte ; } break ; case TK_KEEP : r = node_new_keep ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_GENERAL_NEWLINE : r = node_new_general_newline ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_NO_NEWLINE : r = node_new_no_newline ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_TRUE_ANYCHAR : r = node_new_true_anychar ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_TEXT_SEGMENT : r = make_text_segment ( np , env ) ; if ( r < 0 ) return r ; break ; default : return ONIGERR_PARSER_BUG ; break ; } { tp = np ; re_entry : r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; repeat : if ( r == TK_REPEAT || r == TK_INTERVAL ) { Node * target ; if ( is_invalid_quantifier_target ( * tp ) ) return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID ; qn = node_new_quantifier ( tok -> u . repeat . lower , tok -> u . repeat . upper , r == TK_INTERVAL ) ; CHECK_NULL_RETURN_MEMERR ( qn ) ; QUANT_ ( qn ) -> greedy = tok -> u . repeat . greedy ; if ( group == 2 ) { target = node_drop_group ( * tp ) ; * tp = NULL_NODE ; } else { target = * tp ; } r = set_quantifier ( qn , target , group , env ) ; if ( r < 0 ) { onig_node_free ( qn ) ; return r ; } if ( tok -> u . repeat . possessive != 0 ) { Node * en ; en = node_new_bag ( BAG_STOP_BACKTRACK ) ; if ( IS_NULL ( en ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } NODE_BODY ( en ) = qn ; qn = en ; } if ( r == 0 ) { * tp = qn ; } else if ( r == 1 ) { onig_node_free ( qn ) ; * tp = target ; } else if ( r == 2 ) { Node * tmp ; * tp = node_new_list ( * tp , NULL ) ; if ( IS_NULL ( * tp ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } tmp = NODE_CDR ( * tp ) = node_new_list ( qn , NULL ) ; if ( IS_NULL ( tmp ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } tp = & ( NODE_CAR ( tmp ) ) ; } group = 0 ; goto re_entry ; } } return r ; }\n", "\n", "1: CWE-674 static int parse_exp ( Node * * np , PToken * tok , int term , UChar * * src , UChar * end , ScanEnv * env , int group_head ) { int r , len , group = 0 ; Node * qn ; Node * * tp ; * np = NULL ; if ( tok -> type == ( enum TokenSyms ) term ) goto end_of_token ; switch ( tok -> type ) { case TK_ALT : case TK_EOT : end_of_token : * np = node_new_empty ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; return tok -> type ; break ; case TK_SUBEXP_OPEN : r = parse_bag ( np , tok , TK_SUBEXP_CLOSE , src , end , env ) ; if ( r < 0 ) return r ; if ( r == 1 ) { if ( group_head == 0 ) group = 1 ; else { Node * target = * np ; * np = node_new_group ( target ) ; if ( IS_NULL ( * np ) ) { onig_node_free ( target ) ; return ONIGERR_MEMORY ; } group = 2 ; } } else if ( r == 2 ) { Node * target ; OnigOptionType prev = env -> options ; env -> options = BAG_ ( * np ) -> o . options ; r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; r = parse_subexp ( & target , tok , term , src , end , env , 0 ) ; env -> options = prev ; if ( r < 0 ) { onig_node_free ( target ) ; return r ; } NODE_BODY ( * np ) = target ; return tok -> type ; } break ; case TK_SUBEXP_CLOSE : if ( ! IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP ) ) return ONIGERR_UNMATCHED_CLOSE_PARENTHESIS ; if ( tok -> escaped ) goto tk_raw_byte ; else goto tk_byte ; break ; case TK_STRING : tk_byte : { * np = node_new_str ( tok -> backp , * src ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; while ( 1 ) { r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; if ( r != TK_STRING ) break ; r = onig_node_str_cat ( * np , tok -> backp , * src ) ; if ( r < 0 ) return r ; } string_end : tp = np ; goto repeat ; } break ; case TK_RAW_BYTE : tk_raw_byte : { * np = node_new_str_raw_char ( ( UChar ) tok -> u . c ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; len = 1 ; while ( 1 ) { if ( len >= ONIGENC_MBC_MINLEN ( env -> enc ) ) { if ( len == enclen ( env -> enc , STR_ ( * np ) -> s ) ) { r = fetch_token ( tok , src , end , env ) ; goto tk_raw_byte_end ; } } r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; if ( r != TK_RAW_BYTE ) return ONIGERR_TOO_SHORT_MULTI_BYTE_STRING ; r = node_str_cat_char ( * np , ( UChar ) tok -> u . c ) ; if ( r < 0 ) return r ; len ++ ; } tk_raw_byte_end : if ( ! ONIGENC_IS_VALID_MBC_STRING ( env -> enc , STR_ ( * np ) -> s , STR_ ( * np ) -> end ) ) return ONIGERR_INVALID_WIDE_CHAR_VALUE ; NODE_STRING_CLEAR_RAW ( * np ) ; goto string_end ; } break ; case TK_CODE_POINT : { UChar buf [ ONIGENC_CODE_TO_MBC_MAXLEN ] ; len = ONIGENC_CODE_TO_MBC ( env -> enc , tok -> u . code , buf ) ; if ( len < 0 ) return len ; # ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG * np = node_new_str_raw ( buf , buf + len ) ; # else * np = node_new_str ( buf , buf + len ) ; # endif CHECK_NULL_RETURN_MEMERR ( * np ) ; } break ; case TK_QUOTE_OPEN : { OnigCodePoint end_op [ 2 ] ; UChar * qstart , * qend , * nextp ; end_op [ 0 ] = ( OnigCodePoint ) MC_ESC ( env -> syntax ) ; end_op [ 1 ] = ( OnigCodePoint ) 'E' ; qstart = * src ; qend = find_str_position ( end_op , 2 , qstart , end , & nextp , env -> enc ) ; if ( IS_NULL ( qend ) ) { nextp = qend = end ; } * np = node_new_str ( qstart , qend ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; * src = nextp ; } break ; case TK_CHAR_TYPE : { switch ( tok -> u . prop . ctype ) { case ONIGENC_CTYPE_WORD : * np = node_new_ctype ( tok -> u . prop . ctype , tok -> u . prop . not , env -> options ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; case ONIGENC_CTYPE_SPACE : case ONIGENC_CTYPE_DIGIT : case ONIGENC_CTYPE_XDIGIT : { CClassNode * cc ; * np = node_new_cclass ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; cc = CCLASS_ ( * np ) ; add_ctype_to_cc ( cc , tok -> u . prop . ctype , 0 , env ) ; if ( tok -> u . prop . not != 0 ) NCCLASS_SET_NOT ( cc ) ; } break ; default : return ONIGERR_PARSER_BUG ; break ; } } break ; case TK_CHAR_PROPERTY : r = parse_char_property ( np , tok , src , end , env ) ; if ( r != 0 ) return r ; break ; case TK_CC_OPEN : { CClassNode * cc ; r = parse_char_class ( np , tok , src , end , env ) ; if ( r != 0 ) return r ; cc = CCLASS_ ( * np ) ; if ( IS_IGNORECASE ( env -> options ) ) { IApplyCaseFoldArg iarg ; iarg . env = env ; iarg . cc = cc ; iarg . alt_root = NULL_NODE ; iarg . ptail = & ( iarg . alt_root ) ; r = ONIGENC_APPLY_ALL_CASE_FOLD ( env -> enc , env -> case_fold_flag , i_apply_case_fold , & iarg ) ; if ( r != 0 ) { onig_node_free ( iarg . alt_root ) ; return r ; } if ( IS_NOT_NULL ( iarg . alt_root ) ) { Node * work = onig_node_new_alt ( * np , iarg . alt_root ) ; if ( IS_NULL ( work ) ) { onig_node_free ( iarg . alt_root ) ; return ONIGERR_MEMORY ; } * np = work ; } } } break ; case TK_ANYCHAR : * np = node_new_anychar ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; case TK_ANYCHAR_ANYTIME : * np = node_new_anychar ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; qn = node_new_quantifier ( 0 , INFINITE_REPEAT , 0 ) ; CHECK_NULL_RETURN_MEMERR ( qn ) ; NODE_BODY ( qn ) = * np ; * np = qn ; break ; case TK_BACKREF : len = tok -> u . backref . num ; * np = node_new_backref ( len , ( len > 1 ? tok -> u . backref . refs : & ( tok -> u . backref . ref1 ) ) , tok -> u . backref . by_name , # ifdef USE_BACKREF_WITH_LEVEL tok -> u . backref . exist_level , tok -> u . backref . level , # endif env ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; break ; # ifdef USE_CALL case TK_CALL : { int gnum = tok -> u . call . gnum ; * np = node_new_call ( tok -> u . call . name , tok -> u . call . name_end , gnum , tok -> u . call . by_number ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; env -> num_call ++ ; if ( tok -> u . call . by_number != 0 && gnum == 0 ) { env -> has_call_zero = 1 ; } } break ; # endif case TK_ANCHOR : { int ascii_mode = IS_WORD_ASCII ( env -> options ) && IS_WORD_ANCHOR_TYPE ( tok -> u . anchor ) ? 1 : 0 ; * np = onig_node_new_anchor ( tok -> u . anchor , ascii_mode ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; } break ; case TK_REPEAT : case TK_INTERVAL : if ( IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS ) ) { if ( IS_SYNTAX_BV ( env -> syntax , ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS ) ) return ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED ; else { * np = node_new_empty ( ) ; CHECK_NULL_RETURN_MEMERR ( * np ) ; } } else { goto tk_byte ; } break ; case TK_KEEP : r = node_new_keep ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_GENERAL_NEWLINE : r = node_new_general_newline ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_NO_NEWLINE : r = node_new_no_newline ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_TRUE_ANYCHAR : r = node_new_true_anychar ( np , env ) ; if ( r < 0 ) return r ; break ; case TK_TEXT_SEGMENT : r = make_text_segment ( np , env ) ; if ( r < 0 ) return r ; break ; default : return ONIGERR_PARSER_BUG ; break ; } { tp = np ; re_entry : r = fetch_token ( tok , src , end , env ) ; if ( r < 0 ) return r ; repeat : if ( r == TK_REPEAT || r == TK_INTERVAL ) { Node * target ; if ( is_invalid_quantifier_target ( * tp ) ) return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID ; qn = node_new_quantifier ( tok -> u . repeat . lower , tok -> u . repeat . upper , r == TK_INTERVAL ) ; CHECK_NULL_RETURN_MEMERR ( qn ) ; QUANT_ ( qn ) -> greedy = tok -> u . repeat . greedy ; if ( group == 2 ) { target = node_drop_group ( * tp ) ; * tp = NULL_NODE ; } else { target = * tp ; } r = set_quantifier ( qn , target , group , env ) ; if ( r < 0 ) { onig_node_free ( qn ) ; return r ; } if ( tok -> u . repeat . possessive != 0 ) { Node * en ; en = node_new_bag ( BAG_STOP_BACKTRACK ) ; if ( IS_NULL ( en ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } NODE_BODY ( en ) = qn ; qn = en ; } if ( r == 0 ) { * tp = qn ; } else if ( r == 1 ) { onig_node_free ( qn ) ; * tp = target ; } else if ( r == 2 ) { Node * tmp ; * tp = node_new_list ( * tp , NULL ) ; if ( IS_NULL ( * tp ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } tmp = NODE_CDR ( * tp ) = node_new_list ( qn , NULL ) ; if ( IS_NULL ( tmp ) ) { onig_node_free ( qn ) ; return ONIGERR_MEMORY ; } tp = & ( NODE_CAR ( tmp ) ) ; } group = 0 ; goto re_entry ; } } return r ; }\n", "\n", "\n", "Target: o ) { Py_RETURN_NONE ; } result\n", "\n", "Sources:\n", "0: CWE-125 PyObject * ast2obj_keyword ( void * _o ) { keyword_ty o = ( keyword_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( keyword_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_identifier ( o -> arg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_arg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "1: CWE-125 PyObject * ast2obj_comprehension ( void * _o ) { comprehension_ty o = ( comprehension_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( comprehension_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_expr ( o -> target ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_target , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> iter ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_iter , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> ifs , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ifs , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> is_async ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_is_async , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "2: CWE-125 PyObject * ast2obj_arguments ( void * _o ) { arguments_ty o = ( arguments_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( arguments_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_list ( o -> args , ast2obj_arg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_arg ( o -> vararg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_vararg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> kwonlyargs , ast2obj_arg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_kwonlyargs , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> kw_defaults , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_kw_defaults , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_arg ( o -> kwarg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_kwarg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> defaults , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_defaults , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "3: CWE-125 PyObject * ast2obj_arg ( void * _o ) { arg_ty o = ( arg_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( arg_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_identifier ( o -> arg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_arg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> annotation ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_annotation , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "4: CWE-125 PyObject * ast2obj_withitem ( void * _o ) { withitem_ty o = ( withitem_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( withitem_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_expr ( o -> context_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_context_expr , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> optional_vars ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_optional_vars , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "\n", "Target: , y , MagickMin ( 4 , x ) , MagickMin ( 4 , ; } } return ( dds_info , 16 , exception ) ) ; } \n", "\n", "Sources:\n", "0: CWE-20 static MagickBooleanType ReadDXT3 ( Image * image , DDSInfo * dds_info , ExceptionInfo * exception ) { DDSColors colors ; ssize_t j , y ; PixelPacket * q ; register ssize_t i , x ; unsigned char alpha ; size_t a0 , a1 , bits , code ; unsigned short c0 , c1 ; for ( y = 0 ; y < ( ssize_t ) dds_info -> height ; y += 4 ) { for ( x = 0 ; x < ( ssize_t ) dds_info -> width ; x += 4 ) { q = QueueAuthenticPixels ( image , x , y , Min ( 4 , dds_info -> width - x ) , Min ( 4 , dds_info -> height - y ) , exception ) ; if ( q == ( PixelPacket * ) NULL ) return MagickFalse ; a0 = ReadBlobLSBLong ( image ) ; a1 = ReadBlobLSBLong ( image ) ; c0 = ReadBlobLSBShort ( image ) ; c1 = ReadBlobLSBShort ( image ) ; bits = ReadBlobLSBLong ( image ) ; CalculateColors ( c0 , c1 , & colors , MagickTrue ) ; for ( j = 0 ; j < 4 ; j ++ ) { for ( i = 0 ; i < 4 ; i ++ ) { if ( ( x + i ) < ( ssize_t ) dds_info -> width && ( y + j ) < ( ssize_t ) dds_info -> height ) { code = ( bits >> ( ( 4 * j + i ) * 2 ) ) & 0x3 ; SetPixelRed ( q , ScaleCharToQuantum ( colors . r [ code ] ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( colors . g [ code ] ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( colors . b [ code ] ) ) ; if ( j < 2 ) alpha = 17U * ( unsigned char ) ( ( a0 >> ( 4 * ( 4 * j + i ) ) ) & 0xf ) ; else alpha = 17U * ( unsigned char ) ( ( a1 >> ( 4 * ( 4 * ( j - 2 ) + i ) ) ) & 0xf ) ; SetPixelAlpha ( q , ScaleCharToQuantum ( ( unsigned char ) alpha ) ) ; q ++ ; } } } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) return MagickFalse ; } } SkipDXTMipmaps ( image , dds_info , 16 ) ; return MagickTrue ; }\n", "\n", "1: CWE-20 static MagickBooleanType ReadDXT5 ( Image * image , DDSInfo * dds_info , ExceptionInfo * exception ) { DDSColors colors ; ssize_t j , y ; MagickSizeType alpha_bits ; PixelPacket * q ; register ssize_t i , x ; unsigned char a0 , a1 ; size_t alpha , bits , code , alpha_code ; unsigned short c0 , c1 ; for ( y = 0 ; y < ( ssize_t ) dds_info -> height ; y += 4 ) { for ( x = 0 ; x < ( ssize_t ) dds_info -> width ; x += 4 ) { q = QueueAuthenticPixels ( image , x , y , Min ( 4 , dds_info -> width - x ) , Min ( 4 , dds_info -> height - y ) , exception ) ; if ( q == ( PixelPacket * ) NULL ) return MagickFalse ; a0 = ( unsigned char ) ReadBlobByte ( image ) ; a1 = ( unsigned char ) ReadBlobByte ( image ) ; alpha_bits = ( MagickSizeType ) ReadBlobLSBLong ( image ) ; alpha_bits = alpha_bits | ( ( MagickSizeType ) ReadBlobLSBShort ( image ) << 32 ) ; c0 = ReadBlobLSBShort ( image ) ; c1 = ReadBlobLSBShort ( image ) ; bits = ReadBlobLSBLong ( image ) ; CalculateColors ( c0 , c1 , & colors , MagickTrue ) ; for ( j = 0 ; j < 4 ; j ++ ) { for ( i = 0 ; i < 4 ; i ++ ) { if ( ( x + i ) < ( ssize_t ) dds_info -> width && ( y + j ) < ( ssize_t ) dds_info -> height ) { code = ( bits >> ( ( 4 * j + i ) * 2 ) ) & 0x3 ; SetPixelRed ( q , ScaleCharToQuantum ( colors . r [ code ] ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( colors . g [ code ] ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( colors . b [ code ] ) ) ; alpha_code = ( size_t ) ( alpha_bits >> ( 3 * ( 4 * j + i ) ) ) & 0x7 ; if ( alpha_code == 0 ) alpha = a0 ; else if ( alpha_code == 1 ) alpha = a1 ; else if ( a0 > a1 ) alpha = ( ( 8 - alpha_code ) * a0 + ( alpha_code - 1 ) * a1 ) / 7 ; else if ( alpha_code == 6 ) alpha = 0 ; else if ( alpha_code == 7 ) alpha = 255 ; else alpha = ( ( ( 6 - alpha_code ) * a0 + ( alpha_code - 1 ) * a1 ) / 5 ) ; SetPixelAlpha ( q , ScaleCharToQuantum ( ( unsigned char ) alpha ) ) ; q ++ ; } } } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) return MagickFalse ; } } SkipDXTMipmaps ( image , dds_info , 16 ) ; return MagickTrue ; }\n", "\n", "\n", "Target: len = file && file -> size > 0\n", "\n", "Sources:\n", "0: CWE-119 int read_file ( struct sc_card * card , char * str_path , unsigned char * * data , size_t * data_len ) { struct sc_path path ; struct sc_file * file ; unsigned char * p ; int ok = 0 ; int r ; size_t len ; sc_format_path ( str_path , & path ) ; if ( SC_SUCCESS != sc_select_file ( card , & path , & file ) ) { goto err ; } len = file ? file -> size : 4096 ; p = realloc ( * data , len ) ; if ( ! p ) { goto err ; } * data = p ; * data_len = len ; r = sc_read_binary ( card , 0 , p , len , 0 ) ; if ( r < 0 ) goto err ; * data_len = r ; ok = 1 ; err : sc_file_free ( file ) ; return ok ; }\n", "\n", "1: CWE-415 int read_file ( struct sc_card * card , char * str_path , unsigned char * * data , size_t * data_len ) { struct sc_path path ; struct sc_file * file ; unsigned char * p ; int ok = 0 ; int r ; size_t len ; sc_format_path ( str_path , & path ) ; if ( SC_SUCCESS != sc_select_file ( card , & path , & file ) ) { goto err ; } len = file ? file -> size : 4096 ; p = realloc ( * data , len ) ; if ( ! p ) { goto err ; } * data = p ; * data_len = len ; r = sc_read_binary ( card , 0 , p , len , 0 ) ; if ( r < 0 ) goto err ; * data_len = r ; ok = 1 ; err : sc_file_free ( file ) ; return ok ; }\n", "\n", "\n", "Target: ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; dev ->\n", "\n", "Sources:\n", "0: CWE-000 void bnep_net_setup ( struct net_device * dev ) { memset ( dev -> broadcast , 0xff , ETH_ALEN ) ; dev -> addr_len = ETH_ALEN ; ether_setup ( dev ) ; dev -> netdev_ops = & bnep_netdev_ops ; dev -> watchdog_timeo = HZ * 2 ; }\n", "\n", "1: CWE-000 static void l2tp_eth_dev_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & l2tp_eth_netdev_ops ; dev -> destructor = free_netdev ; }\n", "\n", "2: CWE-264 static void ieee80211_if_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & ieee80211_dataif_ops ; dev -> destructor = free_netdev ; }\n", "\n", "3: CWE-264 void bnep_net_setup ( struct net_device * dev ) { memset ( dev -> broadcast , 0xff , ETH_ALEN ) ; dev -> addr_len = ETH_ALEN ; ether_setup ( dev ) ; dev -> netdev_ops = & bnep_netdev_ops ; dev -> watchdog_timeo = HZ * 2 ; }\n", "\n", "4: CWE-264 static void _isdn_setup ( struct net_device * dev ) { isdn_net_local * lp = netdev_priv ( dev ) ; ether_setup ( dev ) ; dev -> flags = IFF_NOARP | IFF_POINTOPOINT ; dev -> header_ops = NULL ; dev -> netdev_ops = & isdn_netdev_ops ; dev -> tx_queue_len = 30 ; lp -> p_encap = ISDN_NET_ENCAP_RAWIP ; lp -> magic = ISDN_NET_MAGIC ; lp -> last = lp ; lp -> next = lp ; lp -> isdn_device = - 1 ; lp -> isdn_channel = - 1 ; lp -> pre_device = - 1 ; lp -> pre_channel = - 1 ; lp -> exclusive = - 1 ; lp -> ppp_slot = - 1 ; lp -> pppbind = - 1 ; skb_queue_head_init ( & lp -> super_tx_queue ) ; lp -> l2_proto = ISDN_PROTO_L2_X75I ; lp -> l3_proto = ISDN_PROTO_L3_TRANS ; lp -> triggercps = 6000 ; lp -> slavedelay = 10 * HZ ; lp -> hupflags = ISDN_INHUP ; lp -> onhtime = 10 ; lp -> dialmax = 1 ; lp -> flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL ; lp -> cbdelay = 25 ; lp -> dialtimeout = - 1 ; lp -> dialwait = 5 * HZ ; lp -> dialstarted = 0 ; lp -> dialwait_timer = 0 ; }\n", "\n", "\n", "Target: -> gdi ; UINT32 size = DstWidth * DstHeight ; -> dstFormat ; if ( ( GetBytesPerPixel ( bitmap -> format ) == 0 ) || ( DstWidth == 0 ) || ( DstHeight == 0 ) || ( DstWidth > UINT32_MAX / DstHeight ) || ( size > ( UINT32_MAX / GetBytesPerPixel ( bitmap -> format ) ) ) ) return FALSE ; size *= GetBytesPerPixel ( bitmap -> format ) ; -> length = size ; bitmap ->\n", "\n", "Sources:\n", "0: CWE-190 static BOOL gdi_Bitmap_Decompress ( rdpContext * context , rdpBitmap * bitmap , const BYTE * pSrcData , UINT32 DstWidth , UINT32 DstHeight , UINT32 bpp , UINT32 length , BOOL compressed , UINT32 codecId ) { UINT32 SrcSize = length ; rdpGdi * gdi = context -> gdi ; bitmap -> compressed = FALSE ; bitmap -> format = gdi -> dstFormat ; bitmap -> length = DstWidth * DstHeight * GetBytesPerPixel ( bitmap -> format ) ; bitmap -> data = ( BYTE * ) _aligned_malloc ( bitmap -> length , 16 ) ; if ( ! bitmap -> data ) return FALSE ; if ( compressed ) { if ( bpp < 32 ) { if ( ! interleaved_decompress ( context -> codecs -> interleaved , pSrcData , SrcSize , DstWidth , DstHeight , bpp , bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , & gdi -> palette ) ) return FALSE ; } else { if ( ! planar_decompress ( context -> codecs -> planar , pSrcData , SrcSize , DstWidth , DstHeight , bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , TRUE ) ) return FALSE ; } } else { const UINT32 SrcFormat = gdi_get_pixel_format ( bpp ) ; const size_t sbpp = GetBytesPerPixel ( SrcFormat ) ; const size_t dbpp = GetBytesPerPixel ( bitmap -> format ) ; if ( ( sbpp == 0 ) || ( dbpp == 0 ) ) return FALSE ; else { const size_t dstSize = SrcSize * dbpp / sbpp ; if ( dstSize < bitmap -> length ) return FALSE ; } if ( ! freerdp_image_copy ( bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , pSrcData , SrcFormat , 0 , 0 , 0 , & gdi -> palette , FREERDP_FLIP_VERTICAL ) ) return FALSE ; } return TRUE ; }\n", "\n", "1: CWE-787 static BOOL gdi_Bitmap_Decompress ( rdpContext * context , rdpBitmap * bitmap , const BYTE * pSrcData , UINT32 DstWidth , UINT32 DstHeight , UINT32 bpp , UINT32 length , BOOL compressed , UINT32 codecId ) { UINT32 SrcSize = length ; rdpGdi * gdi = context -> gdi ; bitmap -> compressed = FALSE ; bitmap -> format = gdi -> dstFormat ; bitmap -> length = DstWidth * DstHeight * GetBytesPerPixel ( bitmap -> format ) ; bitmap -> data = ( BYTE * ) _aligned_malloc ( bitmap -> length , 16 ) ; if ( ! bitmap -> data ) return FALSE ; if ( compressed ) { if ( bpp < 32 ) { if ( ! interleaved_decompress ( context -> codecs -> interleaved , pSrcData , SrcSize , DstWidth , DstHeight , bpp , bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , & gdi -> palette ) ) return FALSE ; } else { if ( ! planar_decompress ( context -> codecs -> planar , pSrcData , SrcSize , DstWidth , DstHeight , bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , TRUE ) ) return FALSE ; } } else { const UINT32 SrcFormat = gdi_get_pixel_format ( bpp ) ; const size_t sbpp = GetBytesPerPixel ( SrcFormat ) ; const size_t dbpp = GetBytesPerPixel ( bitmap -> format ) ; if ( ( sbpp == 0 ) || ( dbpp == 0 ) ) return FALSE ; else { const size_t dstSize = SrcSize * dbpp / sbpp ; if ( dstSize < bitmap -> length ) return FALSE ; } if ( ! freerdp_image_copy ( bitmap -> data , bitmap -> format , 0 , 0 , 0 , DstWidth , DstHeight , pSrcData , SrcFormat , 0 , 0 , 0 , & gdi -> palette , FREERDP_FLIP_VERTICAL ) ) return FALSE ; } return TRUE ; }\n", "\n", "\n", "Target: value ) { if ( voice < 0 || voice >= devc -> nr_voice ) return ;\n", "\n", "Sources:\n", "0: CWE-264 static void opl3_panning ( int dev , int voice , int value ) { devc -> voc [ voice ] . panning = value ; }\n", "\n", "1: CWE-119 static void opl3_panning ( int dev , int voice , int value ) { devc -> voc [ voice ] . panning = value ; }\n", "\n", "\n", "Target: text ; int result ; int ; } } result = js_regexec ( re , opts ) ; if ( result < 0 ) js_error ( J , \"regexecfailed\" ) ; if ( result == 0\n", "\n", "Sources:\n", "0: CWE-674 static void Rp_test ( js_State * J ) { js_Regexp * re ; const char * text ; int opts ; Resub m ; re = js_toregexp ( J , 0 ) ; text = js_tostring ( J , 1 ) ; opts = 0 ; if ( re -> flags & JS_REGEXP_G ) { if ( re -> last > strlen ( text ) ) { re -> last = 0 ; js_pushboolean ( J , 0 ) ; return ; } if ( re -> last > 0 ) { text += re -> last ; opts |= REG_NOTBOL ; } } if ( ! js_regexec ( re -> prog , text , & m , opts ) ) { if ( re -> flags & JS_REGEXP_G ) re -> last = re -> last + ( m . sub [ 0 ] . ep - text ) ; js_pushboolean ( J , 1 ) ; return ; } if ( re -> flags & JS_REGEXP_G ) re -> last = 0 ; js_pushboolean ( J , 0 ) ; }\n", "\n", "1: CWE-400 static void Rp_test ( js_State * J ) { js_Regexp * re ; const char * text ; int opts ; Resub m ; re = js_toregexp ( J , 0 ) ; text = js_tostring ( J , 1 ) ; opts = 0 ; if ( re -> flags & JS_REGEXP_G ) { if ( re -> last > strlen ( text ) ) { re -> last = 0 ; js_pushboolean ( J , 0 ) ; return ; } if ( re -> last > 0 ) { text += re -> last ; opts |= REG_NOTBOL ; } } if ( ! js_regexec ( re -> prog , text , & m , opts ) ) { if ( re -> flags & JS_REGEXP_G ) re -> last = re -> last + ( m . sub [ 0 ] . ep - text ) ; js_pushboolean ( J , 1 ) ; return ; } if ( re -> flags & JS_REGEXP_G ) re -> last = 0 ; js_pushboolean ( J , 0 ) ; }\n", "\n", "\n", "Target: ( void ) strncpy ( clone_info ->\n", "\n", "Sources:\n", "0: CWE-125 static Image * ExtractPostscript ( Image * image , const ImageInfo * image_info , MagickOffsetType PS_Offset , ssize_t PS_Size , ExceptionInfo * exception ) { char postscript_file [ MagickPathExtent ] ; const MagicInfo * magic_info ; FILE * ps_file ; ImageInfo * clone_info ; Image * image2 ; unsigned char magick [ 2 * MagickPathExtent ] ; if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) return ( image ) ; clone_info -> blob = ( void * ) NULL ; clone_info -> length = 0 ; ( void ) AcquireUniqueFilename ( postscript_file ) ; ps_file = fopen_utf8 ( postscript_file , \"wb\" ) ; if ( ps_file == ( FILE * ) NULL ) goto FINISH ; ( void ) SeekBlob ( image , PS_Offset , SEEK_SET ) ; ( void ) ReadBlob ( image , 2 * MagickPathExtent , magick ) ; ( void ) SeekBlob ( image , PS_Offset , SEEK_SET ) ; while ( PS_Size -- > 0 ) { ( void ) fputc ( ReadBlobByte ( image ) , ps_file ) ; } ( void ) fclose ( ps_file ) ; magic_info = GetMagicInfo ( magick , 2 * MagickPathExtent , exception ) ; if ( magic_info == ( const MagicInfo * ) NULL ) goto FINISH_UNL ; if ( exception -> severity != UndefinedException ) goto FINISH_UNL ; if ( magic_info -> name == ( char * ) NULL ) goto FINISH_UNL ; ( void ) CopyMagickMemory ( clone_info -> magick , magic_info -> name , MagickPathExtent ) ; FormatLocaleString ( clone_info -> filename , MagickPathExtent , \"%s\" , postscript_file ) ; image2 = ReadImage ( clone_info , exception ) ; if ( ! image2 ) goto FINISH_UNL ; ( void ) CopyMagickMemory ( image2 -> filename , image -> filename , MagickPathExtent ) ; ( void ) CopyMagickMemory ( image2 -> magick_filename , image -> magick_filename , MagickPathExtent ) ; ( void ) CopyMagickMemory ( image2 -> magick , image -> magick , MagickPathExtent ) ; image2 -> depth = image -> depth ; DestroyBlob ( image2 ) ; image2 -> blob = ReferenceBlob ( image -> blob ) ; if ( ( image -> rows == 0 ) || ( image -> columns == 0 ) ) DeleteImageFromList ( & image ) ; AppendImageToList ( & image , image2 ) ; FINISH_UNL : ( void ) RelinquishUniqueFileResource ( postscript_file ) ; FINISH : DestroyImageInfo ( clone_info ) ; return ( image ) ; }\n", "\n", "1: CWE-125 static Image * ExtractPostscript ( Image * image , const ImageInfo * image_info , MagickOffsetType PS_Offset , ssize_t PS_Size , ExceptionInfo * exception ) { char postscript_file [ MaxTextExtent ] ; const MagicInfo * magic_info ; FILE * ps_file ; ImageInfo * clone_info ; Image * image2 ; unsigned char magick [ 2 * MaxTextExtent ] ; if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) return ( image ) ; clone_info -> blob = ( void * ) NULL ; clone_info -> length = 0 ; ( void ) AcquireUniqueFilename ( postscript_file ) ; ps_file = fopen_utf8 ( postscript_file , \"wb\" ) ; if ( ps_file == ( FILE * ) NULL ) goto FINISH ; ( void ) SeekBlob ( image , PS_Offset , SEEK_SET ) ; ( void ) ReadBlob ( image , 2 * MaxTextExtent , magick ) ; ( void ) SeekBlob ( image , PS_Offset , SEEK_SET ) ; while ( PS_Size -- > 0 ) { ( void ) fputc ( ReadBlobByte ( image ) , ps_file ) ; } ( void ) fclose ( ps_file ) ; magic_info = GetMagicInfo ( magick , 2 * MaxTextExtent , exception ) ; if ( magic_info == ( const MagicInfo * ) NULL ) goto FINISH_UNL ; if ( exception -> severity != UndefinedException ) goto FINISH_UNL ; if ( magic_info -> name == ( char * ) NULL ) goto FINISH_UNL ; ( void ) CopyMagickMemory ( clone_info -> magick , magic_info -> name , MaxTextExtent ) ; FormatLocaleString ( clone_info -> filename , MaxTextExtent , \"%s\" , postscript_file ) ; image2 = ReadImage ( clone_info , exception ) ; if ( ! image2 ) goto FINISH_UNL ; ( void ) CopyMagickMemory ( image2 -> filename , image -> filename , MaxTextExtent ) ; ( void ) CopyMagickMemory ( image2 -> magick_filename , image -> magick_filename , MaxTextExtent ) ; ( void ) CopyMagickMemory ( image2 -> magick , image -> magick , MaxTextExtent ) ; image2 -> depth = image -> depth ; DestroyBlob ( image2 ) ; image2 -> blob = ReferenceBlob ( image -> blob ) ; if ( ( image -> rows == 0 ) || ( image -> columns == 0 ) ) DeleteImageFromList ( & image ) ; AppendImageToList ( & image , image2 ) ; FINISH_UNL : ( void ) RelinquishUniqueFileResource ( postscript_file ) ; FINISH : DestroyImageInfo ( clone_info ) ; return ( image ) ; }\n", "\n", "\n", "Target: ( ) ; } \n", "\n", "Sources:\n", "0: CWE-20 static void ikev2_parent_outI1_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct ke_continuation * ke = ( struct ke_continuation * ) pcrc ; struct msg_digest * md = ke -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( \"ikev2parentoutI1:calculatedke+nonce,sendingI1\" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , \"%s:Requestwasdisconnectedfromstate\" , __FUNCTION__ ) ; if ( ke -> md ) release_md ( ke -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == ke -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_outI1_tail ( pcrc , r ) ; if ( ke -> md != NULL ) { complete_v2_state_transition ( & ke -> md , e ) ; if ( ke -> md ) release_md ( ke -> md ) ; } reset_cur_state ( ) ; reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; }\n", "\n", "1: CWE-20 static void ikev2_parent_inI1outR1_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct ke_continuation * ke = ( struct ke_continuation * ) pcrc ; struct msg_digest * md = ke -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( \"ikev2parentinI1outR1:calculatedke+nonce,sendingR1\" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , \"%s:Requestwasdisconnectedfromstate\" , __FUNCTION__ ) ; if ( ke -> md ) release_md ( ke -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == ke -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inI1outR1_tail ( pcrc , r ) ; if ( ke -> md != NULL ) { complete_v2_state_transition ( & ke -> md , e ) ; if ( ke -> md ) release_md ( ke -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; }\n", "\n", "2: CWE-20 static void ikev2_parent_inR1outI2_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct dh_continuation * dh = ( struct dh_continuation * ) pcrc ; struct msg_digest * md = dh -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( \"ikev2parentinR1outI2:calculatingg^{xy},sendingI2\" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , \"%s:Requestwasdisconnectedfromstate\" , __FUNCTION__ ) ; if ( dh -> md ) release_md ( dh -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == dh -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inR1outI2_tail ( pcrc , r ) ; if ( dh -> md != NULL ) { complete_v2_state_transition ( & dh -> md , e ) ; if ( dh -> md ) release_md ( dh -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; }\n", "\n", "3: CWE-20 static void ikev2_parent_inI2outR2_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct dh_continuation * dh = ( struct dh_continuation * ) pcrc ; struct msg_digest * md = dh -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( \"ikev2parentinI2outR2:calculatingg^{xy},sendingR2\" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , \"%s:Requestwasdisconnectedfromstate\" , __FUNCTION__ ) ; if ( dh -> md ) release_md ( dh -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == dh -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inI2outR2_tail ( pcrc , r ) ; if ( e > STF_FAIL ) { int v2_notify_num = e - STF_FAIL ; DBG_log ( \"ikev2_parent_inI2outR2_tailreturnedSTF_FAILwith%s\" , enum_name ( & ikev2_notify_names , v2_notify_num ) ) ; } else if ( e != STF_OK ) { DBG_log ( \"ikev2_parent_inI2outR2_tailreturned%s\" , enum_name ( & stfstatus_name , e ) ) ; } if ( dh -> md != NULL ) { complete_v2_state_transition ( & dh -> md , e ) ; if ( dh -> md ) release_md ( dh -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; }\n", "\n", "\n", "Target: \".txt\" ) ; if ( ! COM_CompareExtension ( filename , \".txt\" ) ) { Com_Printf ( \"Con_Dump_f:Onlythe\\\\\".txt\\\\\"extensionissupportedbythiscommand!\\\\n\" ) ; return ; }\n", "\n", "Sources:\n", "0: CWE-000 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"usage:condump\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".txt\" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( \"ERROR:couldn\\'topen%s.\\\\n\" , filename ) ; return ; } Com_Printf ( \"Dumpedconsoletextto%s.\\\\n\" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) { break ; } if ( x != con . linewidth ) { break ; } } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) { buffer [ x ] = 0 ; } else { break ; } } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , \"\\\\r\\\\n\" ) ; # else Q_strcat ( buffer , bufferlen , \"\\\\n\" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; }\n", "\n", "1: CWE-269 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"usage:condump\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".txt\" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( \"ERROR:couldn\\'topen%s.\\\\n\" , filename ) ; return ; } Com_Printf ( \"Dumpedconsoletextto%s.\\\\n\" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) break ; if ( x != con . linewidth ) break ; } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) buffer [ x ] = 0 ; else break ; } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , \"\\\\r\\\\n\" ) ; # else Q_strcat ( buffer , bufferlen , \"\\\\n\" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; }\n", "\n", "2: CWE-000 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"usage:condump\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".txt\" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( \"ERROR:couldn\\'topen%s.\\\\n\" , filename ) ; return ; } Com_Printf ( \"Dumpedconsoletextto%s.\\\\n\" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) break ; if ( x != con . linewidth ) break ; } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) buffer [ x ] = 0 ; else break ; } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , \"\\\\r\\\\n\" ) ; # else Q_strcat ( buffer , bufferlen , \"\\\\n\" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; }\n", "\n", "3: CWE-269 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( \"usage:condump\\\\n\" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , \".txt\" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( \"ERROR:couldn\\'topen%s.\\\\n\" , filename ) ; return ; } Com_Printf ( \"Dumpedconsoletextto%s.\\\\n\" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) { break ; } if ( x != con . linewidth ) { break ; } } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) { buffer [ x ] = 0 ; } else { break ; } } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , \"\\\\r\\\\n\" ) ; # else Q_strcat ( buffer , bufferlen , \"\\\\n\" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; }\n", "\n", "\n", "Target: ; separator = osStrchr ( connection ->\n", "\n", "Sources:\n", "0: CWE-20 error_t httpReadRequestHeader ( HttpConnection * connection ) { error_t error ; size_t length ; error = socketSetTimeout ( connection -> socket , HTTP_SERVER_IDLE_TIMEOUT ) ; if ( error ) return error ; error = httpReceive ( connection , connection -> buffer , HTTP_SERVER_BUFFER_SIZE - 1 , & length , SOCKET_FLAG_BREAK_CRLF ) ; if ( error ) return error ; error = socketSetTimeout ( connection -> socket , HTTP_SERVER_TIMEOUT ) ; if ( error ) return error ; connection -> buffer [ length ] = '\\\\0' ; TRACE_INFO ( \"%s\" , connection -> buffer ) ; error = httpParseRequestLine ( connection , connection -> buffer ) ; if ( error ) return error ; connection -> request . chunkedEncoding = FALSE ; connection -> request . contentLength = 0 ; # if ( HTTP_SERVER_WEB_SOCKET_SUPPORT == ENABLED ) connection -> request . upgradeWebSocket = FALSE ; connection -> request . connectionUpgrade = FALSE ; osStrcpy ( connection -> request . clientKey , \"\" ) ; # endif if ( connection -> request . version >= HTTP_VERSION_1_0 ) { char_t firstChar ; char_t * separator ; char_t * name ; char_t * value ; firstChar = '\\\\0' ; while ( 1 ) { error = httpReadHeaderField ( connection , connection -> buffer , HTTP_SERVER_BUFFER_SIZE , & firstChar ) ; if ( error ) return error ; TRACE_DEBUG ( \"%s\" , connection -> buffer ) ; if ( ! osStrcmp ( connection -> buffer , \"\\\\r\\\\n\" ) ) break ; separator = strchr ( connection -> buffer , ':' ) ; if ( separator != NULL ) { * separator = '\\\\0' ; name = strTrimWhitespace ( connection -> buffer ) ; value = strTrimWhitespace ( separator + 1 ) ; httpParseHeaderField ( connection , name , value ) ; } } } if ( connection -> request . chunkedEncoding ) { connection -> request . byteCount = 0 ; connection -> request . firstChunk = TRUE ; connection -> request . lastChunk = FALSE ; } else { connection -> request . byteCount = connection -> request . contentLength ; } return NO_ERROR ; }\n", "\n", "1: CWE-20 error_t ssiProcessEchoCommand ( HttpConnection * connection , const char_t * tag , size_t length ) { error_t error ; char_t * separator ; char_t * attribute ; char_t * value ; if ( length < 4 || length >= HTTP_SERVER_BUFFER_SIZE ) return ERROR_INVALID_TAG ; osMemcpy ( connection -> buffer , tag + 4 , length - 4 ) ; connection -> buffer [ length - 4 ] = '\\\\0' ; separator = strchr ( connection -> buffer , '=' ) ; if ( ! separator ) return ERROR_INVALID_TAG ; * separator = '\\\\0' ; attribute = strTrimWhitespace ( connection -> buffer ) ; value = strTrimWhitespace ( separator + 1 ) ; if ( value [ 0 ] == '\\\\'' || value [ 0 ] == \\'\\\\\"\\' ) value ++ ; length = osStrlen ( value ) ; if ( length > 0 ) { if ( value [ length - 1 ] == '\\\\'' || value [ length - 1 ] == \\'\\\\\"\\' ) value [ length - 1 ] = '\\\\0' ; } if ( osStrcasecmp ( attribute , \"var\" ) ) return ERROR_INVALID_TAG ; if ( ! osStrcasecmp ( value , \"REMOTE_ADDR\" ) ) { ipAddrToString ( & connection -> socket -> remoteIpAddr , connection -> buffer ) ; } else if ( ! osStrcasecmp ( value , \"REMOTE_PORT\" ) ) { osSprintf ( connection -> buffer , \"%\" PRIu16 , connection -> socket -> remotePort ) ; } else if ( ! osStrcasecmp ( value , \"SERVER_ADDR\" ) ) { ipAddrToString ( & connection -> socket -> localIpAddr , connection -> buffer ) ; } else if ( ! osStrcasecmp ( value , \"SERVER_PORT\" ) ) { osSprintf ( connection -> buffer , \"%\" PRIu16 , connection -> socket -> localPort ) ; } else if ( ! osStrcasecmp ( value , \"REQUEST_METHOD\" ) ) { osStrcpy ( connection -> buffer , connection -> request . method ) ; } else if ( ! osStrcasecmp ( value , \"DOCUMENT_ROOT\" ) ) { osStrcpy ( connection -> buffer , connection -> settings -> rootDirectory ) ; } else if ( ! osStrcasecmp ( value , \"DOCUMENT_URI\" ) ) { osStrcpy ( connection -> buffer , connection -> request . uri ) ; } else if ( ! osStrcasecmp ( value , \"DOCUMENT_NAME\" ) ) { httpGetAbsolutePath ( connection , connection -> request . uri , connection -> buffer , HTTP_SERVER_BUFFER_SIZE ) ; } else if ( ! osStrcasecmp ( value , \"QUERY_STRING\" ) ) { osStrcpy ( connection -> buffer , connection -> request . queryString ) ; } else if ( ! osStrcasecmp ( value , \"AUTH_USER\" ) ) { # if ( HTTP_SERVER_BASIC_AUTH_SUPPORT == ENABLED || HTTP_SERVER_DIGEST_AUTH_SUPPORT == ENABLED ) osStrcpy ( connection -> buffer , connection -> request . auth . user ) ; # else connection -> buffer [ 0 ] = '\\\\0' ; # endif } else if ( ! osStrcasecmp ( value , \"DATE_GMT\" ) ) { connection -> buffer [ 0 ] = '\\\\0' ; } else if ( ! osStrcasecmp ( value , \"DATE_LOCAL\" ) ) { connection -> buffer [ 0 ] = '\\\\0' ; } else { return ERROR_INVALID_TAG ; } length = osStrlen ( connection -> buffer ) ; error = httpWriteStream ( connection , connection -> buffer , length ) ; if ( error ) return error ; return NO_ERROR ; }\n", "\n", "2: CWE-20 error_t ssiProcessIncludeCommand ( HttpConnection * connection , const char_t * tag , size_t length , const char_t * uri , uint_t level ) { error_t error ; char_t * separator ; char_t * attribute ; char_t * value ; char_t * path ; char_t * p ; if ( length < 7 || length >= HTTP_SERVER_BUFFER_SIZE ) return ERROR_INVALID_TAG ; osMemcpy ( connection -> buffer , tag + 7 , length - 7 ) ; connection -> buffer [ length - 7 ] = '\\\\0' ; separator = strchr ( connection -> buffer , '=' ) ; if ( ! separator ) return ERROR_INVALID_TAG ; * separator = '\\\\0' ; attribute = strTrimWhitespace ( connection -> buffer ) ; value = strTrimWhitespace ( separator + 1 ) ; if ( value [ 0 ] == '\\\\'' || value [ 0 ] == \\'\\\\\"\\' ) value ++ ; length = osStrlen ( value ) ; if ( length > 0 ) { if ( value [ length - 1 ] == '\\\\'' || value [ length - 1 ] == \\'\\\\\"\\' ) value [ length - 1 ] = '\\\\0' ; } if ( osStrlen ( value ) > HTTP_SERVER_URI_MAX_LEN ) return ERROR_INVALID_TAG ; if ( ! osStrcasecmp ( attribute , \"file\" ) ) { path = osAllocMem ( osStrlen ( uri ) + osStrlen ( value ) + 1 ) ; if ( path == NULL ) return ERROR_OUT_OF_MEMORY ; osStrcpy ( path , uri ) ; p = strrchr ( path , '/' ) ; if ( p ) osStrcpy ( p + 1 , value ) ; else osStrcpy ( path , value ) ; } else if ( ! osStrcasecmp ( attribute , \"virtual\" ) ) { path = strDuplicate ( value ) ; if ( path == NULL ) return ERROR_OUT_OF_MEMORY ; } else { return ERROR_INVALID_TAG ; } if ( httpCompExtension ( value , \".stm\" ) || httpCompExtension ( value , \".shtm\" ) || httpCompExtension ( value , \".shtml\" ) ) { error = ssiExecuteScript ( connection , path , level + 1 ) ; } else { # if ( HTTP_SERVER_FS_SUPPORT == ENABLED ) FsFile * file ; httpGetAbsolutePath ( connection , path , connection -> buffer , HTTP_SERVER_BUFFER_SIZE ) ; file = fsOpenFile ( connection -> buffer , FS_FILE_MODE_READ ) ; if ( file ) { while ( 1 ) { error = fsReadFile ( file , connection -> buffer , HTTP_SERVER_BUFFER_SIZE , & length ) ; if ( error ) break ; error = httpWriteStream ( connection , connection -> buffer , length ) ; if ( error ) break ; } fsCloseFile ( file ) ; if ( error == ERROR_END_OF_FILE ) error = NO_ERROR ; } else { error = ERROR_NOT_FOUND ; } # else const uint8_t * data ; httpGetAbsolutePath ( connection , path , connection -> buffer , HTTP_SERVER_BUFFER_SIZE ) ; error = resGetData ( connection -> buffer , & data , & length ) ; if ( ! error ) error = httpWriteStream ( connection , data , length ) ; # endif } if ( error == ERROR_NOT_FOUND ) error = ERROR_INVALID_TAG ; osFreeMem ( path ) ; return error ; }\n", "\n", "3: CWE-20 error_t ssiProcessExecCommand ( HttpConnection * connection , const char_t * tag , size_t length ) { char_t * separator ; char_t * attribute ; char_t * value ; if ( connection -> settings -> cgiCallback == NULL ) return ERROR_INVALID_TAG ; if ( length < 4 || length >= HTTP_SERVER_BUFFER_SIZE ) return ERROR_INVALID_TAG ; osMemcpy ( connection -> buffer , tag + 4 , length - 4 ) ; connection -> buffer [ length - 4 ] = '\\\\0' ; separator = strchr ( connection -> buffer , '=' ) ; if ( ! separator ) return ERROR_INVALID_TAG ; * separator = '\\\\0' ; attribute = strTrimWhitespace ( connection -> buffer ) ; value = strTrimWhitespace ( separator + 1 ) ; if ( value [ 0 ] == '\\\\'' || value [ 0 ] == \\'\\\\\"\\' ) value ++ ; length = osStrlen ( value ) ; if ( length > 0 ) { if ( value [ length - 1 ] == '\\\\'' || value [ length - 1 ] == \\'\\\\\"\\' ) value [ length - 1 ] = '\\\\0' ; } if ( osStrcasecmp ( attribute , \"cgi\" ) && osStrcasecmp ( attribute , \"cmd\" ) && osStrcasecmp ( attribute , \"cmd_argument\" ) ) return ERROR_INVALID_TAG ; if ( osStrlen ( value ) > HTTP_SERVER_CGI_PARAM_MAX_LEN ) return ERROR_INVALID_TAG ; osStrcpy ( connection -> cgiParam , value ) ; return connection -> settings -> cgiCallback ( connection , connection -> cgiParam ) ; }\n", "\n", "\n", "Target: ; p = osStrchr ( context ->\n", "\n", "Sources:\n", "0: CWE-20 error_t ftpClientParsePwdReply ( FtpClientContext * context , char_t * path , size_t maxLen ) { size_t length ; char_t * p ; p = strrchr ( context -> buffer , \\'\\\\\"\\' ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; * p = '\\\\0' ; p = strchr ( context -> buffer , \\'\\\\\"\\' ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; length = osStrlen ( p + 1 ) ; length = MIN ( length , maxLen ) ; osStrncpy ( path , p + 1 , length ) ; path [ length ] = '\\\\0' ; return NO_ERROR ; }\n", "\n", "1: CWE-20 error_t httpClientSetUri ( HttpClientContext * context , const char_t * uri ) { size_t m ; size_t n ; char_t * p ; char_t * q ; if ( context == NULL || uri == NULL ) return ERROR_INVALID_PARAMETER ; if ( uri [ 0 ] == '\\\\0' ) return ERROR_INVALID_PARAMETER ; if ( context -> requestState != HTTP_REQ_STATE_FORMAT_HEADER ) return ERROR_WRONG_STATE ; if ( context -> bufferLen > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_INVALID_SYNTAX ; context -> buffer [ context -> bufferLen ] = '\\\\0' ; p = strchr ( context -> buffer , '' ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; p ++ ; q = strpbrk ( p , \"?\" ) ; if ( q == NULL ) return ERROR_INVALID_SYNTAX ; m = q - p ; n = osStrlen ( uri ) ; if ( ( context -> bufferLen + n - m ) > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_BUFFER_OVERFLOW ; osMemmove ( p + n , q , context -> buffer + context -> bufferLen + 1 - q ) ; osStrncpy ( p , uri , n ) ; context -> bufferLen = context -> bufferLen + n - m ; return NO_ERROR ; }\n", "\n", "2: CWE-20 error_t httpClientSetMethod ( HttpClientContext * context , const char_t * method ) { size_t m ; size_t n ; char_t * p ; if ( context == NULL || method == NULL ) return ERROR_INVALID_PARAMETER ; n = osStrlen ( method ) ; if ( n == 0 || n > HTTP_CLIENT_MAX_METHOD_LEN ) return ERROR_INVALID_LENGTH ; if ( context -> bufferLen > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_INVALID_SYNTAX ; context -> buffer [ context -> bufferLen ] = '\\\\0' ; p = strchr ( context -> buffer , '' ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; m = p - context -> buffer ; if ( ( context -> bufferLen + n - m ) > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_BUFFER_OVERFLOW ; osMemmove ( context -> buffer + n , p , context -> bufferLen + 1 - m ) ; osStrncpy ( context -> buffer , method , n ) ; context -> bufferLen = context -> bufferLen + n - m ; osStrcpy ( context -> method , method ) ; return NO_ERROR ; }\n", "\n", "\n", "Target: * s && ( s != \\'\\\\\"\\' ) && ( ptmp != ( tmp + sizeof ( tmp ) - 1 ) ) ) * s ) && ( ptmp != ( tmp + sizeof ( tmp ) - 1 )\n", "\n", "Sources:\n", "0: CWE-787 static int msg_parse_fetch ( struct ImapHeader * h , char * s ) { char tmp [ SHORT_STRING ] ; char * ptmp = NULL ; if ( ! s ) return - 1 ; while ( * s ) { SKIPWS ( s ) ; if ( mutt_str_strncasecmp ( \"FLAGS\" , s , 5 ) == 0 ) { s = msg_parse_flags ( h , s ) ; if ( ! s ) return - 1 ; } else if ( mutt_str_strncasecmp ( \"UID\" , s , 3 ) == 0 ) { s += 3 ; SKIPWS ( s ) ; if ( mutt_str_atoui ( s , & h -> data -> uid ) < 0 ) return - 1 ; s = imap_next_word ( s ) ; } else if ( mutt_str_strncasecmp ( \"INTERNALDATE\" , s , 12 ) == 0 ) { s += 12 ; SKIPWS ( s ) ; if ( * s != \\'\\\\\"\\' ) { mutt_debug ( 1 , \"bogusINTERNALDATEentry:%s\\\\n\" , s ) ; return - 1 ; } s ++ ; ptmp = tmp ; while ( * s && * s != \\'\\\\\"\\' ) * ptmp ++ = * s ++ ; if ( * s != \\'\\\\\"\\' ) return - 1 ; s ++ ; * ptmp = '\\\\0' ; h -> received = mutt_date_parse_imap ( tmp ) ; } else if ( mutt_str_strncasecmp ( \"RFC822.SIZE\" , s , 11 ) == 0 ) { s += 11 ; SKIPWS ( s ) ; ptmp = tmp ; while ( isdigit ( ( unsigned char ) * s ) ) * ptmp ++ = * s ++ ; * ptmp = '\\\\0' ; if ( mutt_str_atol ( tmp , & h -> content_length ) < 0 ) return - 1 ; } else if ( ( mutt_str_strncasecmp ( \"BODY\" , s , 4 ) == 0 ) || ( mutt_str_strncasecmp ( \"RFC822.HEADER\" , s , 13 ) == 0 ) ) { return - 2 ; } else if ( * s == ')' ) s ++ ; else if ( * s ) { imap_error ( \"msg_parse_fetch\" , s ) ; return - 1 ; } } return 0 ; }\n", "\n", "1: CWE-119 static int msg_parse_fetch ( struct ImapHeader * h , char * s ) { char tmp [ SHORT_STRING ] ; char * ptmp = NULL ; if ( ! s ) return - 1 ; while ( * s ) { SKIPWS ( s ) ; if ( mutt_str_strncasecmp ( \"FLAGS\" , s , 5 ) == 0 ) { s = msg_parse_flags ( h , s ) ; if ( ! s ) return - 1 ; } else if ( mutt_str_strncasecmp ( \"UID\" , s , 3 ) == 0 ) { s += 3 ; SKIPWS ( s ) ; if ( mutt_str_atoui ( s , & h -> data -> uid ) < 0 ) return - 1 ; s = imap_next_word ( s ) ; } else if ( mutt_str_strncasecmp ( \"INTERNALDATE\" , s , 12 ) == 0 ) { s += 12 ; SKIPWS ( s ) ; if ( * s != \\'\\\\\"\\' ) { mutt_debug ( 1 , \"bogusINTERNALDATEentry:%s\\\\n\" , s ) ; return - 1 ; } s ++ ; ptmp = tmp ; while ( * s && * s != \\'\\\\\"\\' ) * ptmp ++ = * s ++ ; if ( * s != \\'\\\\\"\\' ) return - 1 ; s ++ ; * ptmp = '\\\\0' ; h -> received = mutt_date_parse_imap ( tmp ) ; } else if ( mutt_str_strncasecmp ( \"RFC822.SIZE\" , s , 11 ) == 0 ) { s += 11 ; SKIPWS ( s ) ; ptmp = tmp ; while ( isdigit ( ( unsigned char ) * s ) ) * ptmp ++ = * s ++ ; * ptmp = '\\\\0' ; if ( mutt_str_atol ( tmp , & h -> content_length ) < 0 ) return - 1 ; } else if ( ( mutt_str_strncasecmp ( \"BODY\" , s , 4 ) == 0 ) || ( mutt_str_strncasecmp ( \"RFC822.HEADER\" , s , 13 ) == 0 ) ) { return - 2 ; } else if ( * s == ')' ) s ++ ; else if ( * s ) { imap_error ( \"msg_parse_fetch\" , s ) ; return - 1 ; } } return 0 ; }\n", "\n", "\n", "Target: ( ndo , \"%s\" , tstr ) ) ;\n", "\n", "Sources:\n", "0: CWE-20 void lmp_print ( netdissect_options * ndo , register const u_char * pptr , register u_int len ) { const struct lmp_common_header * lmp_com_header ; const struct lmp_object_header * lmp_obj_header ; const u_char * tptr , * obj_tptr ; u_int tlen , lmp_obj_len , lmp_obj_ctype , obj_tlen ; int hexdump , ret ; u_int offset ; u_int link_type ; union { float f ; uint32_t i ; } bw ; tptr = pptr ; lmp_com_header = ( const struct lmp_common_header * ) pptr ; ND_TCHECK ( * lmp_com_header ) ; if ( LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) != LMP_VERSION ) { ND_PRINT ( ( ndo , \"LMPversion%upacketnotsupported\" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) ) ) ; return ; } if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , \"LMPv%u%sMessage,length:%u\" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) , tok2str ( lmp_msg_type_values , \"unknown(%u)\" , lmp_com_header -> msg_type ) , len ) ) ; return ; } tlen = EXTRACT_16BITS ( lmp_com_header -> length ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLMPv%u,msg-type:%s,Flags:[%s],length:%u\" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) , tok2str ( lmp_msg_type_values , \"unknown,type:%u\" , lmp_com_header -> msg_type ) , bittok2str ( lmp_header_flag_values , \"none\" , lmp_com_header -> flags ) , tlen ) ) ; if ( tlen < sizeof ( const struct lmp_common_header ) ) { ND_PRINT ( ( ndo , \"(tooshort)\" ) ) ; return ; } if ( tlen > len ) { ND_PRINT ( ( ndo , \"(toolong)\" ) ) ; tlen = len ; } tptr += sizeof ( const struct lmp_common_header ) ; tlen -= sizeof ( const struct lmp_common_header ) ; while ( tlen > 0 ) { ND_TCHECK2 ( * tptr , sizeof ( struct lmp_object_header ) ) ; lmp_obj_header = ( const struct lmp_object_header * ) tptr ; lmp_obj_len = EXTRACT_16BITS ( lmp_obj_header -> length ) ; lmp_obj_ctype = ( lmp_obj_header -> ctype ) & 0x7f ; ND_PRINT ( ( ndo , \"\\\\n\\\\t%sObject(%u),Class-Type:%s(%u)Flags:[%snegotiable],length:%u\" , tok2str ( lmp_obj_values , \"Unknown\" , lmp_obj_header -> class_num ) , lmp_obj_header -> class_num , tok2str ( lmp_ctype_values , \"Unknown\" , ( ( lmp_obj_header -> class_num ) << 8 ) + lmp_obj_ctype ) , lmp_obj_ctype , ( lmp_obj_header -> ctype ) & 0x80 ? \"\" : \"non-\" , lmp_obj_len ) ) ; if ( lmp_obj_len < 4 ) { ND_PRINT ( ( ndo , \"(tooshort)\" ) ) ; return ; } if ( ( lmp_obj_len % 4 ) != 0 ) { ND_PRINT ( ( ndo , \"(notamultipleof4)\" ) ) ; return ; } obj_tptr = tptr + sizeof ( struct lmp_object_header ) ; obj_tlen = lmp_obj_len - sizeof ( struct lmp_object_header ) ; ND_TCHECK2 ( * tptr , lmp_obj_len ) ; hexdump = FALSE ; switch ( lmp_obj_header -> class_num ) { case LMP_OBJ_CC_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_LOC : case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tControlChannelID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_LINK_ID : case LMP_OBJ_INTERFACE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4_LOC : case LMP_CTYPE_IPV4_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tIPv4LinkID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_IPV6_LOC : case LMP_CTYPE_IPV6_RMT : if ( obj_tlen != 16 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tIPv6LinkID:%s(0x%08x)\" , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_UNMD_LOC : case LMP_CTYPE_UNMD_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tLinkID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_MESSAGE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tMessageID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_2 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tMessageIDAck:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_NODE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_LOC : case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tNodeID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CONFIG : switch ( lmp_obj_ctype ) { case LMP_CTYPE_HELLO_CONFIG : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tHelloInterval:%u\\\\n\\\\tHelloDeadInterval:%u\" , EXTRACT_16BITS ( obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_HELLO : switch ( lmp_obj_ctype ) { case LMP_CTYPE_HELLO : if ( obj_tlen != 8 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tTxSeq:%u,RxSeq:%u\" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_TE_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen != 12 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_te_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalLink-ID:%s(0x%08x)\" \"\\\\n\\\\tRemoteLink-ID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; break ; case LMP_CTYPE_IPV6 : if ( obj_tlen != 36 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_te_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalLink-ID:%s(0x%08x)\" \"\\\\n\\\\tRemoteLink-ID:%s(0x%08x)\" , ip6addr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_32BITS ( obj_tptr + 20 ) ) ) ; break ; case LMP_CTYPE_UNMD : if ( obj_tlen != 12 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_te_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalLink-ID:%u(0x%08x)\" \"\\\\n\\\\tRemoteLink-ID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_DATA_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen < 12 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_data_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalInterfaceID:%s(0x%08x)\" \"\\\\n\\\\tRemoteInterfaceID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; ret = lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 12 , 12 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ) hexdump = TRUE ; break ; case LMP_CTYPE_IPV6 : if ( obj_tlen < 36 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_data_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalInterfaceID:%s(0x%08x)\" \"\\\\n\\\\tRemoteInterfaceID:%s(0x%08x)\" , ip6addr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_32BITS ( obj_tptr + 20 ) ) ) ; ret = lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 36 , 36 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ) hexdump = TRUE ; break ; case LMP_CTYPE_UNMD : if ( obj_tlen < 12 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:[%s]\" , bittok2str ( lmp_obj_data_link_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalInterfaceID:%u(0x%08x)\" \"\\\\n\\\\tRemoteInterfaceID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; ret = lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 12 , 12 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ) hexdump = TRUE ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_BEGIN : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 20 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:%s\" , bittok2str ( lmp_obj_begin_verify_flag_values , \"none\" , EXTRACT_16BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tVerifyInterval:%u\" , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tDatalinks:%u\" , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tEncodingtype:%s\" , tok2str ( gmpls_encoding_values , \"Unknown\" , * ( obj_tptr + 8 ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tVerifyTransportMechanism:%u(0x%x)%s\" , EXTRACT_16BITS ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr + 10 ) & 8000 ? \"(Payloadtestmessagescapable)\" : \"\" ) ) ; bw . i = EXTRACT_32BITS ( obj_tptr + 12 ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tTransmissionRate:%.3fMbps\" , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tWavelength:%u\" , EXTRACT_32BITS ( obj_tptr + 16 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_BEGIN_ACK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tVerifyDeadInterval:%u\" \"\\\\n\\\\tVerifyTransportResponse:%u\" , EXTRACT_16BITS ( obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tVerifyID:%u\" , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CHANNEL_STATUS : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : offset = 0 ; while ( offset + 8 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tActive:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ? \"Allocated\" : \"Non-allocated\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tDirection:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ? \"Transmit\" : \"Receive\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tChannelStatus:%s(%u)\" , tok2str ( lmp_obj_channel_status_values , \"Unknown\" , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) ) ; offset += 8 ; } break ; case LMP_CTYPE_IPV6 : offset = 0 ; while ( offset + 20 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%s(0x%08x)\" , ip6addr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tActive:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 31 ) ? \"Allocated\" : \"Non-allocated\" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tDirection:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 30 ) & 0x1 ? \"Transmit\" : \"Receive\" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tChannelStatus:%s(%u)\" , tok2str ( lmp_obj_channel_status_values , \"Unknown\" , EXTRACT_32BITS ( obj_tptr + offset + 16 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 16 ) & 0x3FFFFFF ) ) ; offset += 20 ; } break ; case LMP_CTYPE_UNMD : offset = 0 ; while ( offset + 8 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tActive:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ? \"Allocated\" : \"Non-allocated\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tDirection:%s(%u)\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ? \"Transmit\" : \"Receive\" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tChannelStatus:%s(%u)\" , tok2str ( lmp_obj_channel_status_values , \"Unknown\" , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) ) ; offset += 8 ; } break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CHANNEL_STATUS_REQ : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : offset = 0 ; while ( offset + 4 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 4 ; } break ; case LMP_CTYPE_IPV6 : offset = 0 ; while ( offset + 16 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%s(0x%08x)\" , ip6addr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 16 ; } break ; case LMP_CTYPE_UNMD : offset = 0 ; while ( offset + 4 <= obj_tlen ) { ND_PRINT ( ( ndo , \"\\\\n\\\\tInterfaceID:%u(0x%08x)\" , EXTRACT_32BITS ( obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 4 ; } break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_ERROR_CODE : switch ( lmp_obj_ctype ) { case LMP_CTYPE_BEGIN_VERIFY_ERROR : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tErrorCode:%s\" , bittok2str ( lmp_obj_begin_verify_error_values , \"none\" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; break ; case LMP_CTYPE_LINK_SUMMARY_ERROR : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tErrorCode:%s\" , bittok2str ( lmp_obj_link_summary_error_values , \"none\" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_SERVICE_CONFIG : switch ( lmp_obj_ctype ) { case LMP_CTYPE_SERVICE_CONFIG_SP : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tFlags:%s\" , bittok2str ( lmp_obj_service_config_sp_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tUNIVersion:%u\" , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_CPSA : if ( obj_tlen != 16 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } link_type = EXTRACT_8BITS ( obj_tptr ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLinkType:%s(%u)\" , tok2str ( lmp_sd_service_config_cpsa_link_type_values , \"Unknown\" , link_type ) , link_type ) ) ; switch ( link_type ) { case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH : ND_PRINT ( ( ndo , \"\\\\n\\\\tSignalType:%s(%u)\" , tok2str ( lmp_sd_service_config_cpsa_signal_type_sdh_values , \"Unknown\" , EXTRACT_8BITS ( obj_tptr + 1 ) ) , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET : ND_PRINT ( ( ndo , \"\\\\n\\\\tSignalType:%s(%u)\" , tok2str ( lmp_sd_service_config_cpsa_signal_type_sonet_values , \"Unknown\" , EXTRACT_8BITS ( obj_tptr + 1 ) ) , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tTransparency:%s\" , bittok2str ( lmp_obj_service_config_cpsa_tp_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr + 2 ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tContiguousConcatenationTypes:%s\" , bittok2str ( lmp_obj_service_config_cpsa_cct_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr + 3 ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tMinimumNCC:%u\" , EXTRACT_16BITS ( obj_tptr + 4 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tMaximumNCC:%u\" , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tMinimumNVC:%u\" , EXTRACT_16BITS ( obj_tptr + 8 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tMaximumNVC:%u\" , EXTRACT_16BITS ( obj_tptr + 10 ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tLocalInterfaceID:%s(0x%08x)\" , ipaddr_string ( ndo , obj_tptr + 12 ) , EXTRACT_32BITS ( obj_tptr + 12 ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM : if ( obj_tlen != 8 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tTransparencyFlags:%s\" , bittok2str ( lmp_obj_service_config_nsa_transparency_flag_values , \"none\" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , \"\\\\n\\\\tTCMMonitoringFlags:%s\" , bittok2str ( lmp_obj_service_config_nsa_tcm_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr + 7 ) ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , \"(notcorrectforobject)\" ) ) ; break ; } ND_PRINT ( ( ndo , \"\\\\n\\\\tDiversity:Flags:%s\" , bittok2str ( lmp_obj_service_config_nsa_network_diversity_flag_values , \"none\" , EXTRACT_8BITS ( obj_tptr + 3 ) ) ) ) ; break ; default : hexdump = TRUE ; } break ; default : if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , obj_tptr , \"\\\\n\\\\t\" , obj_tlen ) ; break ; } if ( ndo -> ndo_vflag > 1 || hexdump == TRUE ) print_unknown_data ( ndo , tptr + sizeof ( struct lmp_object_header ) , \"\\\\n\\\\t\" , lmp_obj_len - sizeof ( struct lmp_object_header ) ) ; tptr += lmp_obj_len ; tlen -= lmp_obj_len ; } return ; trunc : ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tpacketexceededsnapshot\" ) ) ; }\n", "\n", "1: CWE-125 static u_int ldp_pdu_print ( netdissect_options * ndo , register const u_char * pptr ) { const struct ldp_common_header * ldp_com_header ; const struct ldp_msg_header * ldp_msg_header ; const u_char * tptr , * msg_tptr ; u_short tlen ; u_short pdu_len , msg_len , msg_type , msg_tlen ; int hexdump , processed ; ldp_com_header = ( const struct ldp_common_header * ) pptr ; ND_TCHECK ( * ldp_com_header ) ; if ( EXTRACT_16BITS ( & ldp_com_header -> version ) != LDP_VERSION ) { ND_PRINT ( ( ndo , \"%sLDPversion%upacketnotsupported\" , ( ndo -> ndo_vflag < 1 ) ? \"\" : \"\\\\n\\\\t\" , EXTRACT_16BITS ( & ldp_com_header -> version ) ) ) ; return 0 ; } pdu_len = EXTRACT_16BITS ( & ldp_com_header -> pdu_length ) ; if ( pdu_len < sizeof ( const struct ldp_common_header ) - 4 ) { ND_PRINT ( ( ndo , \"%sLDP,pdu-length:%u(tooshort,<%u)\" , ( ndo -> ndo_vflag < 1 ) ? \"\" : \"\\\\n\\\\t\" , pdu_len , ( u_int ) ( sizeof ( const struct ldp_common_header ) - 4 ) ) ) ; return 0 ; } ND_PRINT ( ( ndo , \"%sLDP,Label-Space-ID:%s:%u,pdu-length:%u\" , ( ndo -> ndo_vflag < 1 ) ? \"\" : \"\\\\n\\\\t\" , ipaddr_string ( ndo , & ldp_com_header -> lsr_id ) , EXTRACT_16BITS ( & ldp_com_header -> label_space ) , pdu_len ) ) ; if ( ndo -> ndo_vflag < 1 ) return 0 ; tptr = pptr + sizeof ( const struct ldp_common_header ) ; tlen = pdu_len - ( sizeof ( const struct ldp_common_header ) - 4 ) ; while ( tlen > 0 ) { ND_TCHECK2 ( * tptr , sizeof ( struct ldp_msg_header ) ) ; ldp_msg_header = ( const struct ldp_msg_header * ) tptr ; msg_len = EXTRACT_16BITS ( ldp_msg_header -> length ) ; msg_type = LDP_MASK_MSG_TYPE ( EXTRACT_16BITS ( ldp_msg_header -> type ) ) ; if ( msg_len < sizeof ( struct ldp_msg_header ) - 4 ) { ND_PRINT ( ( ndo , \"\\\\n\\\\t%sMessage(0x%04x),length:%u(tooshort,<%u)\" , tok2str ( ldp_msg_values , \"Unknown\" , msg_type ) , msg_type , msg_len , ( u_int ) ( sizeof ( struct ldp_msg_header ) - 4 ) ) ) ; return 0 ; } ND_PRINT ( ( ndo , \"\\\\n\\\\t%sMessage(0x%04x),length:%u,MessageID:0x%08x,Flags:[%sifunknown]\" , tok2str ( ldp_msg_values , \"Unknown\" , msg_type ) , msg_type , msg_len , EXTRACT_32BITS ( & ldp_msg_header -> id ) , LDP_MASK_U_BIT ( EXTRACT_16BITS ( & ldp_msg_header -> type ) ) ? \"continueprocessing\" : \"ignore\" ) ) ; msg_tptr = tptr + sizeof ( struct ldp_msg_header ) ; msg_tlen = msg_len - ( sizeof ( struct ldp_msg_header ) - 4 ) ; ND_TCHECK2 ( * tptr , msg_len ) ; hexdump = FALSE ; switch ( msg_type ) { case LDP_MSG_NOTIF : case LDP_MSG_HELLO : case LDP_MSG_INIT : case LDP_MSG_KEEPALIVE : case LDP_MSG_ADDRESS : case LDP_MSG_LABEL_MAPPING : case LDP_MSG_ADDRESS_WITHDRAW : case LDP_MSG_LABEL_WITHDRAW : while ( msg_tlen >= 4 ) { processed = ldp_tlv_print ( ndo , msg_tptr , msg_tlen ) ; if ( processed == 0 ) break ; msg_tlen -= processed ; msg_tptr += processed ; } break ; case LDP_MSG_LABEL_REQUEST : case LDP_MSG_LABEL_RELEASE : case LDP_MSG_LABEL_ABORT_REQUEST : default : if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , msg_tptr , \"\\\\n\\\\t\" , msg_tlen ) ; break ; } if ( ndo -> ndo_vflag > 1 || hexdump == TRUE ) print_unknown_data ( ndo , tptr + sizeof ( struct ldp_msg_header ) , \"\\\\n\\\\t\" , msg_len ) ; tptr += msg_len + 4 ; tlen -= msg_len + 4 ; } return pdu_len + 4 ; trunc : ND_PRINT ( ( ndo , \"\\\\n\\\\t\\\\tpacketexceededsnapshot\" ) ) ; return 0 ; }\n", "\n", "\n", "Target: saddr ) { u32 id ; id = __ipv6_select_ident ( net , daddr ,\n", "\n", "Sources:\n", "0: CWE-326 __be32 ipv6_select_ident ( struct net * net , const struct in6_addr * daddr , const struct in6_addr * saddr ) { static u32 ip6_idents_hashrnd __read_mostly ; u32 id ; net_get_random_once ( & ip6_idents_hashrnd , sizeof ( ip6_idents_hashrnd ) ) ; id = __ipv6_select_ident ( net , ip6_idents_hashrnd , daddr , saddr ) ; return htonl ( id ) ; }\n", "\n", "1: CWE-200 __be32 ipv6_select_ident ( struct net * net , const struct in6_addr * daddr , const struct in6_addr * saddr ) { static u32 ip6_idents_hashrnd __read_mostly ; u32 id ; net_get_random_once ( & ip6_idents_hashrnd , sizeof ( ip6_idents_hashrnd ) ) ; id = __ipv6_select_ident ( net , ip6_idents_hashrnd , daddr , saddr ) ; return htonl ( id ) ; }\n", "\n", "\n", "Target: EIO ; } if ( alt -> desc . bNumEndpoints < 1 ) return - ENODEV ;\n", "\n", "Sources:\n", "0: CWE-476 static int cit_get_packet_size ( struct gspca_dev * gspca_dev ) { struct usb_host_interface * alt ; struct usb_interface * intf ; intf = usb_ifnum_to_if ( gspca_dev -> dev , gspca_dev -> iface ) ; alt = usb_altnum_to_altsetting ( intf , gspca_dev -> alt ) ; if ( ! alt ) { pr_err ( \"Couldn\\'tgetaltsetting\\\\n\" ) ; return - EIO ; } return le16_to_cpu ( alt -> endpoint [ 0 ] . desc . wMaxPacketSize ) ; }\n", "\n", "1: CWE-476 static int stv06xx_start ( struct gspca_dev * gspca_dev ) { struct sd * sd = ( struct sd * ) gspca_dev ; struct usb_host_interface * alt ; struct usb_interface * intf ; int err , packet_size ; intf = usb_ifnum_to_if ( sd -> gspca_dev . dev , sd -> gspca_dev . iface ) ; alt = usb_altnum_to_altsetting ( intf , sd -> gspca_dev . alt ) ; if ( ! alt ) { gspca_err ( gspca_dev , \"Couldn\\'tgetaltsetting\\\\n\" ) ; return - EIO ; } packet_size = le16_to_cpu ( alt -> endpoint [ 0 ] . desc . wMaxPacketSize ) ; err = stv06xx_write_bridge ( sd , STV_ISO_SIZE_L , packet_size ) ; if ( err < 0 ) return err ; err = sd -> sensor -> start ( sd ) ; if ( err < 0 ) goto out ; err = stv06xx_write_bridge ( sd , STV_ISO_ENABLE , 1 ) ; out : if ( err < 0 ) gspca_dbg ( gspca_dev , D_STREAM , \"Startingstreamfailed\\\\n\" ) ; else gspca_dbg ( gspca_dev , D_STREAM , \"Startedstreaming\\\\n\" ) ; return ( err < 0 ) ? err : 0 ; }\n", "\n", "\n", "Target: ; if ( ! nfs_write_pageuptodate ( page , inode ) ) return 0 ; if ( ; if ( inode -> i_flock F_RDLCK ) ) return 1 ;\n", "\n", "Sources:\n", "0: CWE-200 static int nfs_can_extend_write ( struct file * file , struct page * page , struct inode * inode ) { if ( file -> f_flags & O_DSYNC ) return 0 ; if ( NFS_PROTO ( inode ) -> have_delegation ( inode , FMODE_WRITE ) ) return 1 ; if ( nfs_write_pageuptodate ( page , inode ) && ( inode -> i_flock == NULL || ( inode -> i_flock -> fl_start == 0 && inode -> i_flock -> fl_end == OFFSET_MAX && inode -> i_flock -> fl_type != F_RDLCK ) ) ) return 1 ; return 0 ; }\n", "\n", "1: CWE-20 static int nfs_can_extend_write ( struct file * file , struct page * page , struct inode * inode ) { if ( file -> f_flags & O_DSYNC ) return 0 ; if ( NFS_PROTO ( inode ) -> have_delegation ( inode , FMODE_WRITE ) ) return 1 ; if ( nfs_write_pageuptodate ( page , inode ) && ( inode -> i_flock == NULL || ( inode -> i_flock -> fl_start == 0 && inode -> i_flock -> fl_end == OFFSET_MAX && inode -> i_flock -> fl_type != F_RDLCK ) ) ) return 1 ; return 0 ; }\n", "\n", "\n", "Target: inverse_db_table [ y & 255 inverse_db_table [ y & 255\n", "\n", "Sources:\n", "0: CWE-617 static __forceinline void draw_line ( float * output , int x0 , int y0 , int x1 , int y1 , int n ) { int dy = y1 - y0 ; int adx = x1 - x0 ; int ady = abs ( dy ) ; int base ; int x = x0 , y = y0 ; int err = 0 ; int sy ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( adx < DIVTAB_DENOM && ady < DIVTAB_NUMER ) { if ( dy < 0 ) { base = - integer_divide_table [ ady ] [ adx ] ; sy = base - 1 ; } else { base = integer_divide_table [ ady ] [ adx ] ; sy = base + 1 ; } } else { base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; } # else base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; # endif ady -= abs ( base ) * adx ; if ( x1 > n ) x1 = n ; if ( x < x1 ) { LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; for ( ++ x ; x < x1 ; ++ x ) { err += ady ; if ( err >= adx ) { err -= adx ; y += sy ; } else y += base ; LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; } } }\n", "\n", "1: CWE-119 static __forceinline void draw_line ( float * output , int x0 , int y0 , int x1 , int y1 , int n ) { int dy = y1 - y0 ; int adx = x1 - x0 ; int ady = abs ( dy ) ; int base ; int x = x0 , y = y0 ; int err = 0 ; int sy ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( adx < DIVTAB_DENOM && ady < DIVTAB_NUMER ) { if ( dy < 0 ) { base = - integer_divide_table [ ady ] [ adx ] ; sy = base - 1 ; } else { base = integer_divide_table [ ady ] [ adx ] ; sy = base + 1 ; } } else { base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; } # else base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; # endif ady -= abs ( base ) * adx ; if ( x1 > n ) x1 = n ; if ( x < x1 ) { LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; for ( ++ x ; x < x1 ; ++ x ) { err += ady ; if ( err >= adx ) { err -= adx ; y += sy ; } else y += base ; LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; } } }\n", "\n", "\n", "Target: { error = posix_acl_update_mode ( inode , & inode inode -> i_mode , & acl ) ; if ( error ) return error ; inode -> i_ctime inode ) ; } break ;\n", "\n", "Sources:\n", "0: CWE-285 int ext2_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) { int name_index ; void * value = NULL ; size_t size = 0 ; int error ; switch ( type ) { case ACL_TYPE_ACCESS : name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS ; if ( acl ) { error = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( error < 0 ) return error ; else { inode -> i_ctime = CURRENT_TIME_SEC ; mark_inode_dirty ( inode ) ; if ( error == 0 ) acl = NULL ; } } break ; case ACL_TYPE_DEFAULT : name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT ; if ( ! S_ISDIR ( inode -> i_mode ) ) return acl ? - EACCES : 0 ; break ; default : return - EINVAL ; } if ( acl ) { value = ext2_acl_to_disk ( acl , & size ) ; if ( IS_ERR ( value ) ) return ( int ) PTR_ERR ( value ) ; } error = ext2_xattr_set ( inode , name_index , \"\" , value , size , 0 ) ; kfree ( value ) ; if ( ! error ) set_cached_acl ( inode , type , acl ) ; return error ; }\n", "\n", "1: CWE-285 static int __ext4_set_acl ( handle_t * handle , struct inode * inode , int type , struct posix_acl * acl ) { int name_index ; void * value = NULL ; size_t size = 0 ; int error ; switch ( type ) { case ACL_TYPE_ACCESS : name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS ; if ( acl ) { error = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( error < 0 ) return error ; else { inode -> i_ctime = ext4_current_time ( inode ) ; ext4_mark_inode_dirty ( handle , inode ) ; if ( error == 0 ) acl = NULL ; } } break ; case ACL_TYPE_DEFAULT : name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT ; if ( ! S_ISDIR ( inode -> i_mode ) ) return acl ? - EACCES : 0 ; break ; default : return - EINVAL ; } if ( acl ) { value = ext4_acl_to_disk ( acl , & size ) ; if ( IS_ERR ( value ) ) return ( int ) PTR_ERR ( value ) ; } error = ext4_xattr_set_handle ( handle , inode , name_index , \"\" , value , size , 0 ) ; kfree ( value ) ; if ( ! error ) set_cached_acl ( inode , type , acl ) ; return error ; }\n", "\n", "\n", "Target: ) ) { return - 1\n", "\n", "Sources:\n", "0: CWE-415 zip_int64_t _zip_dirent_read ( zip_dirent_t * zde , zip_source_t * src , zip_buffer_t * buffer , bool local , zip_error_t * error ) { zip_uint8_t buf [ CDENTRYSIZE ] ; zip_uint16_t dostime , dosdate ; zip_uint32_t size , variable_size ; zip_uint16_t filename_len , comment_len , ef_len ; bool from_buffer = ( buffer != NULL ) ; size = local ? LENTRYSIZE : CDENTRYSIZE ; if ( buffer ) { if ( _zip_buffer_left ( buffer ) < size ) { zip_error_set ( error , ZIP_ER_NOZIP , 0 ) ; return - 1 ; } } else { if ( ( buffer = _zip_buffer_new_from_source ( src , size , buf , error ) ) == NULL ) { return - 1 ; } } if ( memcmp ( _zip_buffer_get ( buffer , 4 ) , ( local ? LOCAL_MAGIC : CENTRAL_MAGIC ) , 4 ) != 0 ) { zip_error_set ( error , ZIP_ER_NOZIP , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } _zip_dirent_init ( zde ) ; if ( ! local ) zde -> version_madeby = _zip_buffer_get_16 ( buffer ) ; else zde -> version_madeby = 0 ; zde -> version_needed = _zip_buffer_get_16 ( buffer ) ; zde -> bitflags = _zip_buffer_get_16 ( buffer ) ; zde -> comp_method = _zip_buffer_get_16 ( buffer ) ; dostime = _zip_buffer_get_16 ( buffer ) ; dosdate = _zip_buffer_get_16 ( buffer ) ; zde -> last_mod = _zip_d2u_time ( dostime , dosdate ) ; zde -> crc = _zip_buffer_get_32 ( buffer ) ; zde -> comp_size = _zip_buffer_get_32 ( buffer ) ; zde -> uncomp_size = _zip_buffer_get_32 ( buffer ) ; filename_len = _zip_buffer_get_16 ( buffer ) ; ef_len = _zip_buffer_get_16 ( buffer ) ; if ( local ) { comment_len = 0 ; zde -> disk_number = 0 ; zde -> int_attrib = 0 ; zde -> ext_attrib = 0 ; zde -> offset = 0 ; } else { comment_len = _zip_buffer_get_16 ( buffer ) ; zde -> disk_number = _zip_buffer_get_16 ( buffer ) ; zde -> int_attrib = _zip_buffer_get_16 ( buffer ) ; zde -> ext_attrib = _zip_buffer_get_32 ( buffer ) ; zde -> offset = _zip_buffer_get_32 ( buffer ) ; } if ( ! _zip_buffer_ok ( buffer ) ) { zip_error_set ( error , ZIP_ER_INTERNAL , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCRYPTED ) { if ( zde -> bitflags & ZIP_GPBF_STRONG_ENCRYPTION ) { zde -> encryption_method = ZIP_EM_UNKNOWN ; } else { zde -> encryption_method = ZIP_EM_TRAD_PKWARE ; } } else { zde -> encryption_method = ZIP_EM_NONE ; } zde -> filename = NULL ; zde -> extra_fields = NULL ; zde -> comment = NULL ; variable_size = ( zip_uint32_t ) filename_len + ( zip_uint32_t ) ef_len + ( zip_uint32_t ) comment_len ; if ( from_buffer ) { if ( _zip_buffer_left ( buffer ) < variable_size ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; return - 1 ; } } else { _zip_buffer_free ( buffer ) ; if ( ( buffer = _zip_buffer_new_from_source ( src , variable_size , NULL , error ) ) == NULL ) { return - 1 ; } } if ( filename_len ) { zde -> filename = _zip_read_string ( buffer , src , filename_len , 1 , error ) ; if ( ! zde -> filename ) { if ( zip_error_code_zip ( error ) == ZIP_ER_EOF ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; } if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCODING_UTF_8 ) { if ( _zip_guess_encoding ( zde -> filename , ZIP_ENCODING_UTF8_KNOWN ) == ZIP_ENCODING_ERROR ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } } } if ( ef_len ) { zip_uint8_t * ef = _zip_read_data ( buffer , src , ef_len , 0 , error ) ; if ( ef == NULL ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ! _zip_ef_parse ( ef , ef_len , local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL , & zde -> extra_fields , error ) ) { free ( ef ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } free ( ef ) ; if ( local ) zde -> local_extra_fields_read = 1 ; } if ( comment_len ) { zde -> comment = _zip_read_string ( buffer , src , comment_len , 0 , error ) ; if ( ! zde -> comment ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCODING_UTF_8 ) { if ( _zip_guess_encoding ( zde -> comment , ZIP_ENCODING_UTF8_KNOWN ) == ZIP_ENCODING_ERROR ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } } } zde -> filename = _zip_dirent_process_ef_utf_8 ( zde , ZIP_EF_UTF_8_NAME , zde -> filename ) ; zde -> comment = _zip_dirent_process_ef_utf_8 ( zde , ZIP_EF_UTF_8_COMMENT , zde -> comment ) ; if ( zde -> uncomp_size == ZIP_UINT32_MAX || zde -> comp_size == ZIP_UINT32_MAX || zde -> offset == ZIP_UINT32_MAX ) { zip_uint16_t got_len ; zip_buffer_t * ef_buffer ; const zip_uint8_t * ef = _zip_ef_get_by_id ( zde -> extra_fields , & got_len , ZIP_EF_ZIP64 , 0 , local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL , error ) ; if ( ef == NULL ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ( ef_buffer = _zip_buffer_new ( ( zip_uint8_t * ) ef , got_len ) ) == NULL ) { zip_error_set ( error , ZIP_ER_MEMORY , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> uncomp_size == ZIP_UINT32_MAX ) zde -> uncomp_size = _zip_buffer_get_64 ( ef_buffer ) ; else if ( local ) { ( void ) _zip_buffer_skip ( ef_buffer , 8 ) ; } if ( zde -> comp_size == ZIP_UINT32_MAX ) zde -> comp_size = _zip_buffer_get_64 ( ef_buffer ) ; if ( ! local ) { if ( zde -> offset == ZIP_UINT32_MAX ) zde -> offset = _zip_buffer_get_64 ( ef_buffer ) ; if ( zde -> disk_number == ZIP_UINT16_MAX ) zde -> disk_number = _zip_buffer_get_32 ( buffer ) ; } if ( ! _zip_buffer_eof ( ef_buffer ) ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; _zip_buffer_free ( ef_buffer ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } _zip_buffer_free ( ef_buffer ) ; } if ( ! _zip_buffer_ok ( buffer ) ) { zip_error_set ( error , ZIP_ER_INTERNAL , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } if ( zde -> offset > ZIP_INT64_MAX ) { zip_error_set ( error , ZIP_ER_SEEK , EFBIG ) ; return - 1 ; } if ( ! _zip_dirent_process_winzip_aes ( zde , error ) ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } zde -> extra_fields = _zip_ef_remove_internal ( zde -> extra_fields ) ; return ( zip_int64_t ) ( size + variable_size ) ; }\n", "\n", "1: CWE-416 zip_int64_t _zip_dirent_read ( zip_dirent_t * zde , zip_source_t * src , zip_buffer_t * buffer , bool local , zip_error_t * error ) { zip_uint8_t buf [ CDENTRYSIZE ] ; zip_uint16_t dostime , dosdate ; zip_uint32_t size , variable_size ; zip_uint16_t filename_len , comment_len , ef_len ; bool from_buffer = ( buffer != NULL ) ; size = local ? LENTRYSIZE : CDENTRYSIZE ; if ( buffer ) { if ( _zip_buffer_left ( buffer ) < size ) { zip_error_set ( error , ZIP_ER_NOZIP , 0 ) ; return - 1 ; } } else { if ( ( buffer = _zip_buffer_new_from_source ( src , size , buf , error ) ) == NULL ) { return - 1 ; } } if ( memcmp ( _zip_buffer_get ( buffer , 4 ) , ( local ? LOCAL_MAGIC : CENTRAL_MAGIC ) , 4 ) != 0 ) { zip_error_set ( error , ZIP_ER_NOZIP , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } _zip_dirent_init ( zde ) ; if ( ! local ) zde -> version_madeby = _zip_buffer_get_16 ( buffer ) ; else zde -> version_madeby = 0 ; zde -> version_needed = _zip_buffer_get_16 ( buffer ) ; zde -> bitflags = _zip_buffer_get_16 ( buffer ) ; zde -> comp_method = _zip_buffer_get_16 ( buffer ) ; dostime = _zip_buffer_get_16 ( buffer ) ; dosdate = _zip_buffer_get_16 ( buffer ) ; zde -> last_mod = _zip_d2u_time ( dostime , dosdate ) ; zde -> crc = _zip_buffer_get_32 ( buffer ) ; zde -> comp_size = _zip_buffer_get_32 ( buffer ) ; zde -> uncomp_size = _zip_buffer_get_32 ( buffer ) ; filename_len = _zip_buffer_get_16 ( buffer ) ; ef_len = _zip_buffer_get_16 ( buffer ) ; if ( local ) { comment_len = 0 ; zde -> disk_number = 0 ; zde -> int_attrib = 0 ; zde -> ext_attrib = 0 ; zde -> offset = 0 ; } else { comment_len = _zip_buffer_get_16 ( buffer ) ; zde -> disk_number = _zip_buffer_get_16 ( buffer ) ; zde -> int_attrib = _zip_buffer_get_16 ( buffer ) ; zde -> ext_attrib = _zip_buffer_get_32 ( buffer ) ; zde -> offset = _zip_buffer_get_32 ( buffer ) ; } if ( ! _zip_buffer_ok ( buffer ) ) { zip_error_set ( error , ZIP_ER_INTERNAL , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCRYPTED ) { if ( zde -> bitflags & ZIP_GPBF_STRONG_ENCRYPTION ) { zde -> encryption_method = ZIP_EM_UNKNOWN ; } else { zde -> encryption_method = ZIP_EM_TRAD_PKWARE ; } } else { zde -> encryption_method = ZIP_EM_NONE ; } zde -> filename = NULL ; zde -> extra_fields = NULL ; zde -> comment = NULL ; variable_size = ( zip_uint32_t ) filename_len + ( zip_uint32_t ) ef_len + ( zip_uint32_t ) comment_len ; if ( from_buffer ) { if ( _zip_buffer_left ( buffer ) < variable_size ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; return - 1 ; } } else { _zip_buffer_free ( buffer ) ; if ( ( buffer = _zip_buffer_new_from_source ( src , variable_size , NULL , error ) ) == NULL ) { return - 1 ; } } if ( filename_len ) { zde -> filename = _zip_read_string ( buffer , src , filename_len , 1 , error ) ; if ( ! zde -> filename ) { if ( zip_error_code_zip ( error ) == ZIP_ER_EOF ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; } if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCODING_UTF_8 ) { if ( _zip_guess_encoding ( zde -> filename , ZIP_ENCODING_UTF8_KNOWN ) == ZIP_ENCODING_ERROR ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } } } if ( ef_len ) { zip_uint8_t * ef = _zip_read_data ( buffer , src , ef_len , 0 , error ) ; if ( ef == NULL ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ! _zip_ef_parse ( ef , ef_len , local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL , & zde -> extra_fields , error ) ) { free ( ef ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } free ( ef ) ; if ( local ) zde -> local_extra_fields_read = 1 ; } if ( comment_len ) { zde -> comment = _zip_read_string ( buffer , src , comment_len , 0 , error ) ; if ( ! zde -> comment ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> bitflags & ZIP_GPBF_ENCODING_UTF_8 ) { if ( _zip_guess_encoding ( zde -> comment , ZIP_ENCODING_UTF8_KNOWN ) == ZIP_ENCODING_ERROR ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } } } zde -> filename = _zip_dirent_process_ef_utf_8 ( zde , ZIP_EF_UTF_8_NAME , zde -> filename ) ; zde -> comment = _zip_dirent_process_ef_utf_8 ( zde , ZIP_EF_UTF_8_COMMENT , zde -> comment ) ; if ( zde -> uncomp_size == ZIP_UINT32_MAX || zde -> comp_size == ZIP_UINT32_MAX || zde -> offset == ZIP_UINT32_MAX ) { zip_uint16_t got_len ; zip_buffer_t * ef_buffer ; const zip_uint8_t * ef = _zip_ef_get_by_id ( zde -> extra_fields , & got_len , ZIP_EF_ZIP64 , 0 , local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL , error ) ; if ( ef == NULL ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ( ef_buffer = _zip_buffer_new ( ( zip_uint8_t * ) ef , got_len ) ) == NULL ) { zip_error_set ( error , ZIP_ER_MEMORY , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( zde -> uncomp_size == ZIP_UINT32_MAX ) zde -> uncomp_size = _zip_buffer_get_64 ( ef_buffer ) ; else if ( local ) { ( void ) _zip_buffer_skip ( ef_buffer , 8 ) ; } if ( zde -> comp_size == ZIP_UINT32_MAX ) zde -> comp_size = _zip_buffer_get_64 ( ef_buffer ) ; if ( ! local ) { if ( zde -> offset == ZIP_UINT32_MAX ) zde -> offset = _zip_buffer_get_64 ( ef_buffer ) ; if ( zde -> disk_number == ZIP_UINT16_MAX ) zde -> disk_number = _zip_buffer_get_32 ( buffer ) ; } if ( ! _zip_buffer_eof ( ef_buffer ) ) { zip_error_set ( error , ZIP_ER_INCONS , 0 ) ; _zip_buffer_free ( ef_buffer ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } _zip_buffer_free ( ef_buffer ) ; } if ( ! _zip_buffer_ok ( buffer ) ) { zip_error_set ( error , ZIP_ER_INTERNAL , 0 ) ; if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } if ( zde -> offset > ZIP_INT64_MAX ) { zip_error_set ( error , ZIP_ER_SEEK , EFBIG ) ; return - 1 ; } if ( ! _zip_dirent_process_winzip_aes ( zde , error ) ) { if ( ! from_buffer ) { _zip_buffer_free ( buffer ) ; } return - 1 ; } zde -> extra_fields = _zip_ef_remove_internal ( zde -> extra_fields ) ; return ( zip_int64_t ) ( size + variable_size ) ; }\n", "\n", "\n", "Target: -> u1_dpb_commands_read ) { i_temp = ih264d_read_mmco_commands ( ps_dec ) ; if ( i_temp < 0 ) { return ERROR_DBP_MANAGER_T ; } -> u4_bitoffset = i_temp ; } else ps_bitstrm ->\n", "\n", "Sources:\n", "0: CWE-119 WORD32 ih264d_parse_pslice ( dec_struct_t * ps_dec , UWORD16 u2_first_mb_in_slice ) { dec_pic_params_t * ps_pps = ps_dec -> ps_cur_pps ; dec_slice_params_t * ps_cur_slice = ps_dec -> ps_cur_slice ; dec_bit_stream_t * ps_bitstrm = ps_dec -> ps_bitstrm ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; UWORD8 u1_mbaff = ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ; UWORD8 u1_field_pic_flag = ps_cur_slice -> u1_field_pic_flag ; UWORD32 u4_temp ; WORD32 i_temp ; WORD32 ret ; { WORD8 * pi1_buf ; WORD16 * pi2_mv = ps_dec -> s_default_mv_pred . i2_mv ; WORD32 * pi4_mv = ( WORD32 * ) pi2_mv ; WORD16 * pi16_refFrame ; pi1_buf = ps_dec -> s_default_mv_pred . i1_ref_frame ; pi16_refFrame = ( WORD16 * ) pi1_buf ; * pi4_mv = 0 ; * ( pi4_mv + 1 ) = 0 ; * pi16_refFrame = OUT_OF_RANGE_REF ; ps_dec -> s_default_mv_pred . u1_col_ref_pic_idx = ( UWORD8 ) - 1 ; ps_dec -> s_default_mv_pred . u1_pic_type = ( UWORD8 ) - 1 ; } ps_cur_slice -> u1_num_ref_idx_active_override_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( \"SH:num_ref_idx_override_flag\" , ps_cur_slice -> u1_num_ref_idx_active_override_flag ) ; u4_temp = ps_dec -> ps_cur_pps -> u1_num_ref_idx_lx_active [ 0 ] ; if ( ps_cur_slice -> u1_num_ref_idx_active_override_flag ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) + 1 ; } { UWORD8 u1_max_ref_idx = MAX_FRAMES << u1_field_pic_flag ; if ( u4_temp > u1_max_ref_idx ) { return ERROR_NUM_REF ; } ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] = u4_temp ; COPYTHECONTEXT ( \"SH:num_ref_idx_l0_active_minus1\" , ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] - 1 ) ; } { UWORD8 uc_refIdxReFlagL0 = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( \"SH:ref_pic_list_reordering_flag_l0\" , uc_refIdxReFlagL0 ) ; { UWORD8 init_idx_flg = ( ps_dec -> u1_pr_sl_type != ps_dec -> ps_cur_slice -> u1_slice_type ) ; if ( ps_dec -> u1_first_pb_nal_in_pic || ( init_idx_flg & ! ps_dec -> u1_sl_typ_5_9 ) || ps_dec -> u1_num_ref_idx_lx_active_prev != ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ) { ih264d_init_ref_idx_lx_p ( ps_dec ) ; } if ( ps_dec -> u1_first_pb_nal_in_pic & ps_dec -> u1_sl_typ_5_9 ) ps_dec -> u1_first_pb_nal_in_pic = 0 ; } ps_dec -> u1_num_ref_idx_lx_active_prev = ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; if ( uc_refIdxReFlagL0 ) { WORD8 ret ; ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_mod_dpb [ 0 ] ; ret = ih264d_ref_idx_reordering ( ps_dec , 0 ) ; if ( ret == - 1 ) return ERROR_REFIDX_ORDER_T ; ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_mod_dpb [ 0 ] ; } else ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 0 ] ; } { void * * pui_map_ref_idx_to_poc_lx0 , * * pui_map_ref_idx_to_poc_lx1 ; WORD8 idx ; struct pic_buffer_t * ps_pic ; pui_map_ref_idx_to_poc_lx0 = ps_dec -> ppv_map_ref_idx_to_poc + FRM_LIST_L0 ; pui_map_ref_idx_to_poc_lx0 [ 0 ] = 0 ; pui_map_ref_idx_to_poc_lx0 ++ ; for ( idx = 0 ; idx < ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; idx ++ ) { ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ idx ] ; pui_map_ref_idx_to_poc_lx0 [ idx ] = ( ps_pic -> pu1_buf1 ) ; } pui_map_ref_idx_to_poc_lx1 = ps_dec -> ppv_map_ref_idx_to_poc + FRM_LIST_L1 ; pui_map_ref_idx_to_poc_lx1 [ 0 ] = 0 ; if ( u1_mbaff ) { void * * ppv_map_ref_idx_to_poc_lx_t , * * ppv_map_ref_idx_to_poc_lx_b ; void * * ppv_map_ref_idx_to_poc_lx_t1 , * * ppv_map_ref_idx_to_poc_lx_b1 ; ppv_map_ref_idx_to_poc_lx_t = ps_dec -> ppv_map_ref_idx_to_poc + TOP_LIST_FLD_L0 ; ppv_map_ref_idx_to_poc_lx_b = ps_dec -> ppv_map_ref_idx_to_poc + BOT_LIST_FLD_L0 ; ppv_map_ref_idx_to_poc_lx_t [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_t ++ ; ppv_map_ref_idx_to_poc_lx_b [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_b ++ ; idx = 0 ; for ( idx = 0 ; idx < ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; idx ++ ) { ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ idx ] ; ppv_map_ref_idx_to_poc_lx_t [ 0 ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ 1 ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ 0 ] = ( ps_pic -> pu1_buf1 ) + 1 ; ppv_map_ref_idx_to_poc_lx_t [ 1 ] = ( ps_pic -> pu1_buf1 ) + 1 ; ppv_map_ref_idx_to_poc_lx_t += 2 ; ppv_map_ref_idx_to_poc_lx_b += 2 ; } ppv_map_ref_idx_to_poc_lx_t1 = ps_dec -> ppv_map_ref_idx_to_poc + TOP_LIST_FLD_L1 ; ppv_map_ref_idx_to_poc_lx_t1 [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_b1 = ps_dec -> ppv_map_ref_idx_to_poc + BOT_LIST_FLD_L1 ; ppv_map_ref_idx_to_poc_lx_b1 [ 0 ] = 0 ; } if ( ps_dec -> u4_num_cores >= 3 ) { WORD32 num_entries ; WORD32 size ; num_entries = MIN ( MAX_FRAMES , ps_dec -> u4_num_ref_frames_at_init ) ; num_entries = 2 * ( ( 2 * num_entries ) + 1 ) ; size = num_entries * sizeof ( void * ) ; size += PAD_MAP_IDX_POC * sizeof ( void * ) ; memcpy ( ( void * ) ps_dec -> ps_parse_cur_slice -> ppv_map_ref_idx_to_poc , ps_dec -> ppv_map_ref_idx_to_poc , size ) ; } } if ( ps_pps -> u1_wted_pred_flag ) { ret = ih264d_parse_pred_weight_table ( ps_cur_slice , ps_bitstrm ) ; if ( ret != OK ) return ret ; ih264d_form_pred_weight_matrix ( ps_dec ) ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; } else { ps_dec -> ps_cur_slice -> u2_log2Y_crwd = 0 ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; } ps_dec -> ps_parse_cur_slice -> u2_log2Y_crwd = ps_dec -> ps_cur_slice -> u2_log2Y_crwd ; if ( u1_mbaff && ( u1_field_pic_flag == 0 ) ) { ih264d_convert_frm_mbaff_list ( ps_dec ) ; } if ( ps_cur_slice -> u1_nal_ref_idc != 0 ) { if ( ! ps_dec -> ps_dpb_cmds -> u1_dpb_commands_read ) ps_dec -> u4_bitoffset = ih264d_read_mmco_commands ( ps_dec ) ; else ps_bitstrm -> u4_ofst += ps_dec -> u4_bitoffset ; } if ( ps_pps -> u1_entropy_coding_mode == CABAC ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_CABAC_INIT_IDC ) { return ERROR_INV_SLICE_HDR_T ; } ps_cur_slice -> u1_cabac_init_idc = u4_temp ; COPYTHECONTEXT ( \"SH:cabac_init_idc\" , ps_cur_slice -> u1_cabac_init_idc ) ; } i_temp = ps_pps -> u1_pic_init_qp + ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ( i_temp < 0 ) || ( i_temp > 51 ) ) { return ERROR_INV_RANGE_QP_T ; } ps_cur_slice -> u1_slice_qp = i_temp ; COPYTHECONTEXT ( \"SH:slice_qp_delta\" , ( WORD8 ) ( ps_cur_slice -> u1_slice_qp - ps_pps -> u1_pic_init_qp ) ) ; if ( ps_pps -> u1_deblocking_filter_parameters_present_flag == 1 ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > SLICE_BOUNDARY_DBLK_DISABLED ) { return ERROR_INV_SLICE_HDR_T ; } COPYTHECONTEXT ( \"SH:disable_deblocking_filter_idc\" , u4_temp ) ; ps_cur_slice -> u1_disable_dblk_filter_idc = u4_temp ; if ( u4_temp != 1 ) { i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_cur_slice -> i1_slice_alpha_c0_offset = i_temp ; COPYTHECONTEXT ( \"SH:slice_alpha_c0_offset_div2\" , ps_cur_slice -> i1_slice_alpha_c0_offset >> 1 ) ; i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_cur_slice -> i1_slice_beta_offset = i_temp ; COPYTHECONTEXT ( \"SH:slice_beta_offset_div2\" , ps_cur_slice -> i1_slice_beta_offset >> 1 ) ; } else { ps_cur_slice -> i1_slice_alpha_c0_offset = 0 ; ps_cur_slice -> i1_slice_beta_offset = 0 ; } } else { ps_cur_slice -> u1_disable_dblk_filter_idc = 0 ; ps_cur_slice -> i1_slice_alpha_c0_offset = 0 ; ps_cur_slice -> i1_slice_beta_offset = 0 ; } ps_dec -> u1_slice_header_done = 2 ; if ( ps_pps -> u1_entropy_coding_mode ) { SWITCHOFFTRACE ; SWITCHONTRACECABAC ; ps_dec -> pf_parse_inter_slice = ih264d_parse_inter_slice_data_cabac ; ps_dec -> pf_parse_inter_mb = ih264d_parse_pmb_cabac ; ih264d_init_cabac_contexts ( P_SLICE , ps_dec ) ; if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_mbaff ; else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_nonmbaff ; } else { SWITCHONTRACE ; SWITCHOFFTRACECABAC ; ps_dec -> pf_parse_inter_slice = ih264d_parse_inter_slice_data_cavlc ; ps_dec -> pf_parse_inter_mb = ih264d_parse_pmb_cavlc ; if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) { ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_mbaff ; } else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_nonmbaff ; } ps_dec -> u1_B = 0 ; ps_dec -> pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb ; ret = ps_dec -> pf_parse_inter_slice ( ps_dec , ps_cur_slice , u2_first_mb_in_slice ) ; if ( ret != OK ) return ret ; return OK ; }\n", "\n", "1: CWE-119 WORD32 ih264d_parse_bslice ( dec_struct_t * ps_dec , UWORD16 u2_first_mb_in_slice ) { dec_pic_params_t * ps_pps = ps_dec -> ps_cur_pps ; dec_slice_params_t * ps_slice = ps_dec -> ps_cur_slice ; dec_bit_stream_t * ps_bitstrm = ps_dec -> ps_bitstrm ; UWORD8 u1_ref_idx_re_flag_lx ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; UWORD32 u4_temp , ui_temp1 ; WORD32 i_temp ; WORD32 ret ; { WORD8 * pi1_buf ; WORD16 * pi2_mv = ps_dec -> s_default_mv_pred . i2_mv ; WORD32 * pi4_mv = ( WORD32 * ) pi2_mv ; WORD16 * pi16_refFrame ; pi1_buf = ps_dec -> s_default_mv_pred . i1_ref_frame ; pi16_refFrame = ( WORD16 * ) pi1_buf ; * pi4_mv = 0 ; * ( pi4_mv + 1 ) = 0 ; * pi16_refFrame = OUT_OF_RANGE_REF ; ps_dec -> s_default_mv_pred . u1_col_ref_pic_idx = ( UWORD8 ) - 1 ; ps_dec -> s_default_mv_pred . u1_pic_type = ( UWORD8 ) - 1 ; } ps_slice -> u1_num_ref_idx_active_override_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( \"SH:num_ref_idx_override_flag\" , ps_slice -> u1_num_ref_idx_active_override_flag ) ; u4_temp = ps_dec -> ps_cur_pps -> u1_num_ref_idx_lx_active [ 0 ] ; ui_temp1 = ps_dec -> ps_cur_pps -> u1_num_ref_idx_lx_active [ 1 ] ; if ( ps_slice -> u1_num_ref_idx_active_override_flag ) { u4_temp = 1 + ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( \"SH:num_ref_idx_l0_active_minus1\" , u4_temp - 1 ) ; ui_temp1 = 1 + ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( \"SH:num_ref_idx_l1_active_minus1\" , ui_temp1 - 1 ) ; } { UWORD8 u1_max_ref_idx = MAX_FRAMES ; if ( ps_slice -> u1_field_pic_flag ) { u1_max_ref_idx = MAX_FRAMES << 1 ; } if ( ( u4_temp > u1_max_ref_idx ) || ( ui_temp1 > u1_max_ref_idx ) ) { return ERROR_NUM_REF ; } ps_slice -> u1_num_ref_idx_lx_active [ 0 ] = u4_temp ; ps_slice -> u1_num_ref_idx_lx_active [ 1 ] = ui_temp1 ; } { UWORD8 init_idx_flg = ( ps_dec -> u1_pr_sl_type != ps_dec -> ps_cur_slice -> u1_slice_type ) ; if ( ps_dec -> u1_first_pb_nal_in_pic || ( init_idx_flg & ! ps_dec -> u1_sl_typ_5_9 ) || ps_dec -> u1_num_ref_idx_lx_active_prev != ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ) ih264d_init_ref_idx_lx_b ( ps_dec ) ; if ( ps_dec -> u1_first_pb_nal_in_pic & ps_dec -> u1_sl_typ_5_9 ) ps_dec -> u1_first_pb_nal_in_pic = 0 ; } ps_dec -> u1_num_ref_idx_lx_active_prev = ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; u1_ref_idx_re_flag_lx = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( \"SH:ref_pic_list_reordering_flag_l0\" , u1_ref_idx_re_flag_lx ) ; if ( u1_ref_idx_re_flag_lx ) { WORD8 ret ; ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_mod_dpb [ 0 ] ; ret = ih264d_ref_idx_reordering ( ps_dec , 0 ) ; if ( ret == - 1 ) return ERROR_REFIDX_ORDER_T ; } else ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 0 ] ; u1_ref_idx_re_flag_lx = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( \"SH:ref_pic_list_reordering_flag_l1\" , u1_ref_idx_re_flag_lx ) ; if ( u1_ref_idx_re_flag_lx ) { WORD8 ret ; ps_dec -> ps_ref_pic_buf_lx [ 1 ] = ps_dec -> ps_dpb_mgr -> ps_mod_dpb [ 1 ] ; ret = ih264d_ref_idx_reordering ( ps_dec , 1 ) ; if ( ret == - 1 ) return ERROR_REFIDX_ORDER_T ; } else ps_dec -> ps_ref_pic_buf_lx [ 1 ] = ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 1 ] ; { void * * ppv_map_ref_idx_to_poc_lx ; WORD8 idx ; struct pic_buffer_t * ps_pic ; ppv_map_ref_idx_to_poc_lx = ps_dec -> ppv_map_ref_idx_to_poc + FRM_LIST_L0 ; ppv_map_ref_idx_to_poc_lx [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx ++ ; for ( idx = 0 ; idx < ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; idx ++ ) { ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ idx ] ; ppv_map_ref_idx_to_poc_lx [ idx ] = ( ps_pic -> pu1_buf1 ) ; } ppv_map_ref_idx_to_poc_lx = ps_dec -> ppv_map_ref_idx_to_poc + FRM_LIST_L1 ; ppv_map_ref_idx_to_poc_lx [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx ++ ; for ( idx = 0 ; idx < ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 1 ] ; idx ++ ) { ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 1 ] [ idx ] ; ppv_map_ref_idx_to_poc_lx [ idx ] = ( ps_pic -> pu1_buf1 ) ; } if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) { void * * ppv_map_ref_idx_to_poc_lx_t , * * ppv_map_ref_idx_to_poc_lx_b ; ppv_map_ref_idx_to_poc_lx_t = ps_dec -> ppv_map_ref_idx_to_poc + TOP_LIST_FLD_L0 ; ppv_map_ref_idx_to_poc_lx_b = ps_dec -> ppv_map_ref_idx_to_poc + BOT_LIST_FLD_L0 ; ppv_map_ref_idx_to_poc_lx_t [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_t ++ ; ppv_map_ref_idx_to_poc_lx_b [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_b ++ ; for ( idx = 0 ; idx < ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 0 ] ; idx ++ ) { ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ idx ] ; ppv_map_ref_idx_to_poc_lx_t [ 0 ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ 1 ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ 0 ] = ( ps_pic -> pu1_buf1 ) + 1 ; ppv_map_ref_idx_to_poc_lx_t [ 1 ] = ( ps_pic -> pu1_buf1 ) + 1 ; ppv_map_ref_idx_to_poc_lx_t += 2 ; ppv_map_ref_idx_to_poc_lx_b += 2 ; } ppv_map_ref_idx_to_poc_lx_t = ps_dec -> ppv_map_ref_idx_to_poc + TOP_LIST_FLD_L1 ; ppv_map_ref_idx_to_poc_lx_b = ps_dec -> ppv_map_ref_idx_to_poc + BOT_LIST_FLD_L1 ; ppv_map_ref_idx_to_poc_lx_t [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_t ++ ; ppv_map_ref_idx_to_poc_lx_b [ 0 ] = 0 ; ppv_map_ref_idx_to_poc_lx_b ++ ; for ( idx = 0 ; idx < ps_dec -> ps_cur_slice -> u1_num_ref_idx_lx_active [ 1 ] ; idx ++ ) { UWORD8 u1_tmp_idx = idx << 1 ; ps_pic = ps_dec -> ps_ref_pic_buf_lx [ 1 ] [ idx ] ; ppv_map_ref_idx_to_poc_lx_t [ u1_tmp_idx ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ u1_tmp_idx + 1 ] = ( ps_pic -> pu1_buf1 ) ; ppv_map_ref_idx_to_poc_lx_b [ u1_tmp_idx ] = ( ps_pic -> pu1_buf1 ) + 1 ; ppv_map_ref_idx_to_poc_lx_t [ u1_tmp_idx + 1 ] = ( ps_pic -> pu1_buf1 ) + 1 ; } } if ( ps_dec -> u4_num_cores >= 3 ) { WORD32 num_entries ; WORD32 size ; num_entries = MIN ( MAX_FRAMES , ps_dec -> u4_num_ref_frames_at_init ) ; num_entries = 2 * ( ( 2 * num_entries ) + 1 ) ; size = num_entries * sizeof ( void * ) ; size += PAD_MAP_IDX_POC * sizeof ( void * ) ; memcpy ( ( void * ) ps_dec -> ps_parse_cur_slice -> ppv_map_ref_idx_to_poc , ps_dec -> ppv_map_ref_idx_to_poc , size ) ; } } if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag && ( ps_dec -> ps_cur_slice -> u1_field_pic_flag == 0 ) ) { ih264d_convert_frm_mbaff_list ( ps_dec ) ; } if ( ps_pps -> u1_wted_bipred_idc == 1 ) { ret = ih264d_parse_pred_weight_table ( ps_slice , ps_bitstrm ) ; if ( ret != OK ) return ret ; ih264d_form_pred_weight_matrix ( ps_dec ) ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; } else if ( ps_pps -> u1_wted_bipred_idc == 2 ) { ps_slice -> u2_log2Y_crwd = 0x0505 ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; ih264d_get_implicit_weights ( ps_dec ) ; } else ps_dec -> ps_cur_slice -> u2_log2Y_crwd = 0 ; ps_dec -> ps_parse_cur_slice -> u2_log2Y_crwd = ps_dec -> ps_cur_slice -> u2_log2Y_crwd ; if ( ps_slice -> u1_nal_ref_idc != 0 ) { if ( ! ps_dec -> ps_dpb_cmds -> u1_dpb_commands_read ) ps_dec -> u4_bitoffset = ih264d_read_mmco_commands ( ps_dec ) ; else ps_bitstrm -> u4_ofst += ps_dec -> u4_bitoffset ; } if ( ps_pps -> u1_entropy_coding_mode == CABAC ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_CABAC_INIT_IDC ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> u1_cabac_init_idc = u4_temp ; COPYTHECONTEXT ( \"SH:cabac_init_idc\" , ps_slice -> u1_cabac_init_idc ) ; } i_temp = ps_pps -> u1_pic_init_qp + ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ( i_temp < 0 ) || ( i_temp > 51 ) ) { return ERROR_INV_RANGE_QP_T ; } ps_slice -> u1_slice_qp = i_temp ; COPYTHECONTEXT ( \"SH:slice_qp_delta\" , ( WORD8 ) ( ps_slice -> u1_slice_qp - ps_pps -> u1_pic_init_qp ) ) ; if ( ps_pps -> u1_deblocking_filter_parameters_present_flag == 1 ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > SLICE_BOUNDARY_DBLK_DISABLED ) { return ERROR_INV_SLICE_HDR_T ; } COPYTHECONTEXT ( \"SH:disable_deblocking_filter_idc\" , u4_temp ) ; ps_slice -> u1_disable_dblk_filter_idc = u4_temp ; if ( u4_temp != 1 ) { i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> i1_slice_alpha_c0_offset = i_temp ; COPYTHECONTEXT ( \"SH:slice_alpha_c0_offset_div2\" , ps_slice -> i1_slice_alpha_c0_offset >> 1 ) ; i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> i1_slice_beta_offset = i_temp ; COPYTHECONTEXT ( \"SH:slice_beta_offset_div2\" , ps_slice -> i1_slice_beta_offset >> 1 ) ; } else { ps_slice -> i1_slice_alpha_c0_offset = 0 ; ps_slice -> i1_slice_beta_offset = 0 ; } } else { ps_slice -> u1_disable_dblk_filter_idc = 0 ; ps_slice -> i1_slice_alpha_c0_offset = 0 ; ps_slice -> i1_slice_beta_offset = 0 ; } ps_dec -> u1_slice_header_done = 2 ; if ( ps_pps -> u1_entropy_coding_mode ) { SWITCHOFFTRACE ; SWITCHONTRACECABAC ; ps_dec -> pf_parse_inter_slice = ih264d_parse_inter_slice_data_cabac ; ps_dec -> pf_parse_inter_mb = ih264d_parse_bmb_cabac ; ih264d_init_cabac_contexts ( B_SLICE , ps_dec ) ; if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_mbaff ; else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_nonmbaff ; } else { SWITCHONTRACE ; SWITCHOFFTRACECABAC ; ps_dec -> pf_parse_inter_slice = ih264d_parse_inter_slice_data_cavlc ; ps_dec -> pf_parse_inter_mb = ih264d_parse_bmb_cavlc ; if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_mbaff ; else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_nonmbaff ; } ret = ih264d_cal_col_pic ( ps_dec ) ; if ( ret != OK ) return ret ; ps_dec -> u1_B = 1 ; ps_dec -> pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_bmb ; ret = ps_dec -> pf_parse_inter_slice ( ps_dec , ps_slice , u2_first_mb_in_slice ) ; if ( ret != OK ) return ret ; return OK ; }\n", "\n", "\n", "Target: id ; goto errout_free ; } err id ) ; errout_free :\n", "\n", "Sources:\n", "0: CWE-399 int genl_register_family ( struct genl_family * family ) { int err , i ; int start = GENL_START_ALLOC , end = GENL_MAX_ID ; err = genl_validate_ops ( family ) ; if ( err ) return err ; genl_lock_all ( ) ; if ( genl_family_find_byname ( family -> name ) ) { err = - EEXIST ; goto errout_locked ; } if ( family == & genl_ctrl ) { start = end = GENL_ID_CTRL ; } else if ( strcmp ( family -> name , \"pmcraid\" ) == 0 ) { start = end = GENL_ID_PMCRAID ; } else if ( strcmp ( family -> name , \"VFS_DQUOT\" ) == 0 ) { start = end = GENL_ID_VFS_DQUOT ; } if ( family -> maxattr && ! family -> parallel_ops ) { family -> attrbuf = kmalloc_array ( family -> maxattr + 1 , sizeof ( struct nlattr * ) , GFP_KERNEL ) ; if ( family -> attrbuf == NULL ) { err = - ENOMEM ; goto errout_locked ; } } else family -> attrbuf = NULL ; family -> id = idr_alloc ( & genl_fam_idr , family , start , end + 1 , GFP_KERNEL ) ; if ( family -> id < 0 ) { err = family -> id ; goto errout_locked ; } err = genl_validate_assign_mc_groups ( family ) ; if ( err ) goto errout_remove ; genl_unlock_all ( ) ; genl_ctrl_event ( CTRL_CMD_NEWFAMILY , family , NULL , 0 ) ; for ( i = 0 ; i < family -> n_mcgrps ; i ++ ) genl_ctrl_event ( CTRL_CMD_NEWMCAST_GRP , family , & family -> mcgrps [ i ] , family -> mcgrp_offset + i ) ; return 0 ; errout_remove : idr_remove ( & genl_fam_idr , family -> id ) ; kfree ( family -> attrbuf ) ; errout_locked : genl_unlock_all ( ) ; return err ; }\n", "\n", "1: CWE-401 int genl_register_family ( struct genl_family * family ) { int err , i ; int start = GENL_START_ALLOC , end = GENL_MAX_ID ; err = genl_validate_ops ( family ) ; if ( err ) return err ; genl_lock_all ( ) ; if ( genl_family_find_byname ( family -> name ) ) { err = - EEXIST ; goto errout_locked ; } if ( family == & genl_ctrl ) { start = end = GENL_ID_CTRL ; } else if ( strcmp ( family -> name , \"pmcraid\" ) == 0 ) { start = end = GENL_ID_PMCRAID ; } else if ( strcmp ( family -> name , \"VFS_DQUOT\" ) == 0 ) { start = end = GENL_ID_VFS_DQUOT ; } if ( family -> maxattr && ! family -> parallel_ops ) { family -> attrbuf = kmalloc_array ( family -> maxattr + 1 , sizeof ( struct nlattr * ) , GFP_KERNEL ) ; if ( family -> attrbuf == NULL ) { err = - ENOMEM ; goto errout_locked ; } } else family -> attrbuf = NULL ; family -> id = idr_alloc ( & genl_fam_idr , family , start , end + 1 , GFP_KERNEL ) ; if ( family -> id < 0 ) { err = family -> id ; goto errout_locked ; } err = genl_validate_assign_mc_groups ( family ) ; if ( err ) goto errout_remove ; genl_unlock_all ( ) ; genl_ctrl_event ( CTRL_CMD_NEWFAMILY , family , NULL , 0 ) ; for ( i = 0 ; i < family -> n_mcgrps ; i ++ ) genl_ctrl_event ( CTRL_CMD_NEWMCAST_GRP , family , & family -> mcgrps [ i ] , family -> mcgrp_offset + i ) ; return 0 ; errout_remove : idr_remove ( & genl_fam_idr , family -> id ) ; kfree ( family -> attrbuf ) ; errout_locked : genl_unlock_all ( ) ; return err ; }\n", "\n", "\n", "Target: = vendor_ie ; if ( * ( wmm_ie + 1 ) > sizeof ( struct mwifiex_types_wmm_info ) ) return ; memcpy ( & bss_cfg -> wmm_info , wmm_ie + sizeof ( struct ieee_types_header ) , * ( wmm_ie + 1 )\n", "\n", "Sources:\n", "0: CWE-120 void mwifiex_set_wmm_params ( struct mwifiex_private * priv , struct mwifiex_uap_bss_param * bss_cfg , struct cfg80211_ap_settings * params ) { const u8 * vendor_ie ; const u8 * wmm_ie ; u8 wmm_oui [ ] = { 0x00 , 0x50 , 0xf2 , 0x02 } ; vendor_ie = cfg80211_find_vendor_ie ( WLAN_OUI_MICROSOFT , WLAN_OUI_TYPE_MICROSOFT_WMM , params -> beacon . tail , params -> beacon . tail_len ) ; if ( vendor_ie ) { wmm_ie = vendor_ie ; memcpy ( & bss_cfg -> wmm_info , wmm_ie + sizeof ( struct ieee_types_header ) , * ( wmm_ie + 1 ) ) ; priv -> wmm_enabled = 1 ; } else { memset ( & bss_cfg -> wmm_info , 0 , sizeof ( bss_cfg -> wmm_info ) ) ; memcpy ( & bss_cfg -> wmm_info . oui , wmm_oui , sizeof ( wmm_oui ) ) ; bss_cfg -> wmm_info . subtype = MWIFIEX_WMM_SUBTYPE ; bss_cfg -> wmm_info . version = MWIFIEX_WMM_VERSION ; priv -> wmm_enabled = 0 ; } bss_cfg -> qos_info = 0x00 ; return ; }\n", "\n", "1: CWE-787 void mwifiex_set_wmm_params ( struct mwifiex_private * priv , struct mwifiex_uap_bss_param * bss_cfg , struct cfg80211_ap_settings * params ) { const u8 * vendor_ie ; const u8 * wmm_ie ; u8 wmm_oui [ ] = { 0x00 , 0x50 , 0xf2 , 0x02 } ; vendor_ie = cfg80211_find_vendor_ie ( WLAN_OUI_MICROSOFT , WLAN_OUI_TYPE_MICROSOFT_WMM , params -> beacon . tail , params -> beacon . tail_len ) ; if ( vendor_ie ) { wmm_ie = vendor_ie ; memcpy ( & bss_cfg -> wmm_info , wmm_ie + sizeof ( struct ieee_types_header ) , * ( wmm_ie + 1 ) ) ; priv -> wmm_enabled = 1 ; } else { memset ( & bss_cfg -> wmm_info , 0 , sizeof ( bss_cfg -> wmm_info ) ) ; memcpy ( & bss_cfg -> wmm_info . oui , wmm_oui , sizeof ( wmm_oui ) ) ; bss_cfg -> wmm_info . subtype = MWIFIEX_WMM_SUBTYPE ; bss_cfg -> wmm_info . version = MWIFIEX_WMM_VERSION ; priv -> wmm_enabled = 0 ; } bss_cfg -> qos_info = 0x00 ; return ; }\n", "\n", "\n", "Target: insertpos ) = _x2c ( & buf\n", "\n", "Sources:\n", "0: CWE-125 int Util_handle0Escapes ( char * buf ) { int editpos ; int insertpos ; ASSERT ( buf ) ; for ( editpos = insertpos = 0 ; * ( buf + editpos ) != '\\\\0' ; editpos ++ , insertpos ++ ) { if ( * ( buf + editpos ) == '\\\\\\\\' ) { switch ( * ( buf + editpos + 1 ) ) { case '0' : if ( * ( buf + editpos + 2 ) == 'x' ) { * ( buf + insertpos ) = x2c ( & buf [ editpos + 3 ] ) ; editpos += 4 ; } break ; default : * ( buf + insertpos ) = * ( buf + editpos ) ; } } else { * ( buf + insertpos ) = * ( buf + editpos ) ; } } * ( buf + insertpos ) = '\\\\0' ; return insertpos ; }\n", "\n", "1: CWE-125 void Util_handleEscapes ( char * buf ) { int editpos ; int insertpos ; ASSERT ( buf ) ; for ( editpos = insertpos = 0 ; * ( buf + editpos ) != '\\\\0' ; editpos ++ , insertpos ++ ) { if ( * ( buf + editpos ) == '\\\\\\\\' ) { switch ( * ( buf + editpos + 1 ) ) { case 'n' : * ( buf + insertpos ) = '\\\\n' ; editpos ++ ; break ; case 't' : * ( buf + insertpos ) = '\\\\t' ; editpos ++ ; break ; case 'r' : * ( buf + insertpos ) = '\\\\r' ; editpos ++ ; break ; case '' : * ( buf + insertpos ) = '' ; editpos ++ ; break ; case '0' : if ( * ( buf + editpos + 2 ) == 'x' ) { if ( ( * ( buf + editpos + 3 ) == '0' && * ( buf + editpos + 4 ) == '0' ) ) { * ( buf + insertpos ) = * ( buf + editpos ) ; } else { * ( buf + insertpos ) = x2c ( & buf [ editpos + 3 ] ) ; editpos += 4 ; } } break ; case '\\\\\\\\' : * ( buf + insertpos ) = '\\\\\\\\' ; editpos ++ ; break ; default : * ( buf + insertpos ) = * ( buf + editpos ) ; } } else { * ( buf + insertpos ) = * ( buf + editpos ) ; } } * ( buf + insertpos ) = '\\\\0' ; }\n", "\n", "\n", "Target: 1 ) ; get_random_bytes ( & net -> hash_mix , sizeof ( u32 ) ) ;\n", "\n", "Sources:\n", "0: CWE-326 static __net_init int setup_net ( struct net * net , struct user_namespace * user_ns ) { const struct pernet_operations * ops , * saved_ops ; int error = 0 ; LIST_HEAD ( net_exit_list ) ; refcount_set ( & net -> count , 1 ) ; refcount_set ( & net -> passive , 1 ) ; net -> dev_base_seq = 1 ; net -> user_ns = user_ns ; idr_init ( & net -> netns_ids ) ; spin_lock_init ( & net -> nsid_lock ) ; mutex_init ( & net -> ipv4 . ra_mutex ) ; list_for_each_entry ( ops , & pernet_list , list ) { error = ops_init ( ops , net ) ; if ( error < 0 ) goto out_undo ; } down_write ( & net_rwsem ) ; list_add_tail_rcu ( & net -> list , & net_namespace_list ) ; up_write ( & net_rwsem ) ; out : return error ; out_undo : list_add ( & net -> exit_list , & net_exit_list ) ; saved_ops = ops ; list_for_each_entry_continue_reverse ( ops , & pernet_list , list ) ops_exit_list ( ops , & net_exit_list ) ; ops = saved_ops ; list_for_each_entry_continue_reverse ( ops , & pernet_list , list ) ops_free_list ( ops , & net_exit_list ) ; rcu_barrier ( ) ; goto out ; }\n", "\n", "1: CWE-200 static __net_init int setup_net ( struct net * net , struct user_namespace * user_ns ) { const struct pernet_operations * ops , * saved_ops ; int error = 0 ; LIST_HEAD ( net_exit_list ) ; refcount_set ( & net -> count , 1 ) ; refcount_set ( & net -> passive , 1 ) ; net -> dev_base_seq = 1 ; net -> user_ns = user_ns ; idr_init ( & net -> netns_ids ) ; spin_lock_init ( & net -> nsid_lock ) ; mutex_init ( & net -> ipv4 . ra_mutex ) ; list_for_each_entry ( ops , & pernet_list , list ) { error = ops_init ( ops , net ) ; if ( error < 0 ) goto out_undo ; } down_write ( & net_rwsem ) ; list_add_tail_rcu ( & net -> list , & net_namespace_list ) ; up_write ( & net_rwsem ) ; out : return error ; out_undo : list_add ( & net -> exit_list , & net_exit_list ) ; saved_ops = ops ; list_for_each_entry_continue_reverse ( ops , & pernet_list , list ) ops_exit_list ( ops , & net_exit_list ) ; ops = saved_ops ; list_for_each_entry_continue_reverse ( ops , & pernet_list , list ) ops_free_list ( ops , & net_exit_list ) ; rcu_barrier ( ) ; goto out ; }\n", "\n", "\n", "Target: skb ) { strncpy ( ualg -> ) ) ; strncpy ( ualg -> ) ) ; strncpy ( ualg -> crypto_report_larval rl ; strncpy ( rl .\n", "\n", "Sources:\n", "0: CWE-200 static int crypto_report_one ( struct crypto_alg * alg , struct crypto_user_alg * ualg , struct sk_buff * skb ) { strlcpy ( ualg -> cru_name , alg -> cra_name , sizeof ( ualg -> cru_name ) ) ; strlcpy ( ualg -> cru_driver_name , alg -> cra_driver_name , sizeof ( ualg -> cru_driver_name ) ) ; strlcpy ( ualg -> cru_module_name , module_name ( alg -> cra_module ) , sizeof ( ualg -> cru_module_name ) ) ; ualg -> cru_type = 0 ; ualg -> cru_mask = 0 ; ualg -> cru_flags = alg -> cra_flags ; ualg -> cru_refcnt = refcount_read ( & alg -> cra_refcnt ) ; if ( nla_put_u32 ( skb , CRYPTOCFGA_PRIORITY_VAL , alg -> cra_priority ) ) goto nla_put_failure ; if ( alg -> cra_flags & CRYPTO_ALG_LARVAL ) { struct crypto_report_larval rl ; strlcpy ( rl . type , \"larval\" , sizeof ( rl . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_LARVAL , sizeof ( struct crypto_report_larval ) , & rl ) ) goto nla_put_failure ; goto out ; } if ( alg -> cra_type && alg -> cra_type -> report ) { if ( alg -> cra_type -> report ( skb , alg ) ) goto nla_put_failure ; goto out ; } switch ( alg -> cra_flags & ( CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL ) ) { case CRYPTO_ALG_TYPE_CIPHER : if ( crypto_report_cipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_COMPRESS : if ( crypto_report_comp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_ACOMPRESS : if ( crypto_report_acomp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_AKCIPHER : if ( crypto_report_akcipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_KPP : if ( crypto_report_kpp ( skb , alg ) ) goto nla_put_failure ; break ; } out : return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "1: CWE-000 static int crypto_report_one ( struct crypto_alg * alg , struct crypto_user_alg * ualg , struct sk_buff * skb ) { strlcpy ( ualg -> cru_name , alg -> cra_name , sizeof ( ualg -> cru_name ) ) ; strlcpy ( ualg -> cru_driver_name , alg -> cra_driver_name , sizeof ( ualg -> cru_driver_name ) ) ; strlcpy ( ualg -> cru_module_name , module_name ( alg -> cra_module ) , sizeof ( ualg -> cru_module_name ) ) ; ualg -> cru_type = 0 ; ualg -> cru_mask = 0 ; ualg -> cru_flags = alg -> cra_flags ; ualg -> cru_refcnt = refcount_read ( & alg -> cra_refcnt ) ; if ( nla_put_u32 ( skb , CRYPTOCFGA_PRIORITY_VAL , alg -> cra_priority ) ) goto nla_put_failure ; if ( alg -> cra_flags & CRYPTO_ALG_LARVAL ) { struct crypto_report_larval rl ; strlcpy ( rl . type , \"larval\" , sizeof ( rl . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_LARVAL , sizeof ( struct crypto_report_larval ) , & rl ) ) goto nla_put_failure ; goto out ; } if ( alg -> cra_type && alg -> cra_type -> report ) { if ( alg -> cra_type -> report ( skb , alg ) ) goto nla_put_failure ; goto out ; } switch ( alg -> cra_flags & ( CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL ) ) { case CRYPTO_ALG_TYPE_CIPHER : if ( crypto_report_cipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_COMPRESS : if ( crypto_report_comp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_ACOMPRESS : if ( crypto_report_acomp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_AKCIPHER : if ( crypto_report_akcipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_KPP : if ( crypto_report_kpp ( skb , alg ) ) goto nla_put_failure ; break ; } out : return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "\n", "Target: . mnt_flags & ~ MNT_USER_SETTABLE_MASK ; mnt ->\n", "\n", "Sources:\n", "0: CWE-264 static int do_remount ( struct path * path , int flags , int mnt_flags , void * data ) { int err ; struct super_block * sb = path -> mnt -> mnt_sb ; struct mount * mnt = real_mount ( path -> mnt ) ; if ( ! check_mnt ( mnt ) ) return - EINVAL ; if ( path -> dentry != path -> mnt -> mnt_root ) return - EINVAL ; err = security_sb_remount ( sb , data ) ; if ( err ) return err ; down_write ( & sb -> s_umount ) ; if ( flags & MS_BIND ) err = change_mount_flags ( path -> mnt , flags ) ; else if ( ! capable ( CAP_SYS_ADMIN ) ) err = - EPERM ; else err = do_remount_sb ( sb , flags , data , 0 ) ; if ( ! err ) { lock_mount_hash ( ) ; mnt_flags |= mnt -> mnt . mnt_flags & MNT_PROPAGATION_MASK ; mnt -> mnt . mnt_flags = mnt_flags ; touch_mnt_namespace ( mnt -> mnt_ns ) ; unlock_mount_hash ( ) ; } up_write ( & sb -> s_umount ) ; return err ; }\n", "\n", "1: CWE-269 static int do_remount ( struct path * path , int flags , int mnt_flags , void * data ) { int err ; struct super_block * sb = path -> mnt -> mnt_sb ; struct mount * mnt = real_mount ( path -> mnt ) ; if ( ! check_mnt ( mnt ) ) return - EINVAL ; if ( path -> dentry != path -> mnt -> mnt_root ) return - EINVAL ; err = security_sb_remount ( sb , data ) ; if ( err ) return err ; down_write ( & sb -> s_umount ) ; if ( flags & MS_BIND ) err = change_mount_flags ( path -> mnt , flags ) ; else if ( ! capable ( CAP_SYS_ADMIN ) ) err = - EPERM ; else err = do_remount_sb ( sb , flags , data , 0 ) ; if ( ! err ) { lock_mount_hash ( ) ; mnt_flags |= mnt -> mnt . mnt_flags & MNT_PROPAGATION_MASK ; mnt -> mnt . mnt_flags = mnt_flags ; touch_mnt_namespace ( mnt -> mnt_ns ) ; unlock_mount_hash ( ) ; } up_write ( & sb -> s_umount ) ; return err ; }\n", "\n", "\n", "Target: endif _end : kill_fasync ( & POLL_IN ) ; snd_pcm_stream_unlock_irqrestore ( substream , flags ) ;\n", "\n", "Sources:\n", "0: CWE-416 void snd_pcm_period_elapsed ( struct snd_pcm_substream * substream ) { struct snd_pcm_runtime * runtime ; unsigned long flags ; if ( PCM_RUNTIME_CHECK ( substream ) ) return ; runtime = substream -> runtime ; snd_pcm_stream_lock_irqsave ( substream , flags ) ; if ( ! snd_pcm_running ( substream ) || snd_pcm_update_hw_ptr0 ( substream , 1 ) < 0 ) goto _end ; # ifdef CONFIG_SND_PCM_TIMER if ( substream -> timer_running ) snd_timer_interrupt ( substream -> timer , 1 ) ; # endif _end : snd_pcm_stream_unlock_irqrestore ( substream , flags ) ; kill_fasync ( & runtime -> fasync , SIGIO , POLL_IN ) ; } \n", "\n", "1: CWE-362 void snd_pcm_period_elapsed ( struct snd_pcm_substream * substream ) { struct snd_pcm_runtime * runtime ; unsigned long flags ; if ( PCM_RUNTIME_CHECK ( substream ) ) return ; runtime = substream -> runtime ; snd_pcm_stream_lock_irqsave ( substream , flags ) ; if ( ! snd_pcm_running ( substream ) || snd_pcm_update_hw_ptr0 ( substream , 1 ) < 0 ) goto _end ; # ifdef CONFIG_SND_PCM_TIMER if ( substream -> timer_running ) snd_timer_interrupt ( substream -> timer , 1 ) ; # endif _end : snd_pcm_stream_unlock_irqrestore ( substream , flags ) ; kill_fasync ( & runtime -> fasync , SIGIO , POLL_IN ) ; } \n", "\n", "\n", "Target: handle ) { BUG_ON ( client lock ) ; ion_free_nolock ( client , client , handle ) ; mutex_unlock lock ) ; } \n", "\n", "Sources:\n", "0: CWE-416 void ion_free ( struct ion_client * client , struct ion_handle * handle ) { bool valid_handle ; BUG_ON ( client != handle -> client ) ; mutex_lock ( & client -> lock ) ; valid_handle = ion_handle_validate ( client , handle ) ; if ( ! valid_handle ) { WARN ( 1 , \"%s:invalidhandlepassedtofree.\\\\n\" , __func__ ) ; mutex_unlock ( & client -> lock ) ; return ; } mutex_unlock ( & client -> lock ) ; ion_handle_put ( handle ) ; }\n", "\n", "1: CWE-264 void ion_free ( struct ion_client * client , struct ion_handle * handle ) { bool valid_handle ; BUG_ON ( client != handle -> client ) ; mutex_lock ( & client -> lock ) ; valid_handle = ion_handle_validate ( client , handle ) ; if ( ! valid_handle ) { WARN ( 1 , \"%s:invalidhandlepassedtofree.\\\\n\" , __func__ ) ; mutex_unlock ( & client -> lock ) ; return ; } mutex_unlock ( & client -> lock ) ; ion_handle_put ( handle ) ; }\n", "\n", "\n", "Target: 16 ; WORD16 ai2_level_arr [ 19 ] ; WORD16 * i2_level_arr = & ai2_level_arr [ 3 ] ; tu_sblk4x4_coeff_data_t\n", "\n", "Sources:\n", "0: CWE-119 WORD32 ih264d_cavlc_4x4res_block_totalcoeff_2to10 ( UWORD32 u4_isdc , UWORD32 u4_total_coeff_trail_one , dec_bit_stream_t * ps_bitstrm ) { UWORD32 u4_total_zeroes ; WORD32 i ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 u4_bitstream_offset = ps_bitstrm -> u4_ofst ; UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF ; UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16 ; WORD16 i2_level_arr [ 16 ] ; tu_sblk4x4_coeff_data_t * ps_tu_4x4 ; WORD16 * pi2_coeff_data ; dec_struct_t * ps_dec = ( dec_struct_t * ) ps_bitstrm -> pv_codec_handle ; ps_tu_4x4 = ( tu_sblk4x4_coeff_data_t * ) ps_dec -> pv_parse_tu_coeff_data ; ps_tu_4x4 -> u2_sig_coeff_map = 0 ; pi2_coeff_data = & ps_tu_4x4 -> ai2_level [ 0 ] ; i = u4_total_coeff - 1 ; if ( u4_trailing_ones ) { UWORD32 u4_signs , u4_cnt = u4_trailing_ones ; WORD16 ( * ppi2_trlone_lkup ) [ 3 ] = ( WORD16 ( * ) [ 3 ] ) gai2_ih264d_trailing_one_level ; WORD16 * pi2_trlone_lkup ; GETBITS ( u4_signs , u4_bitstream_offset , pu4_bitstrm_buf , u4_cnt ) ; pi2_trlone_lkup = ppi2_trlone_lkup [ ( 1 << u4_cnt ) - 2 + u4_signs ] ; while ( u4_cnt -- ) i2_level_arr [ i -- ] = * pi2_trlone_lkup ++ ; } if ( i >= 0 ) { UWORD32 u4_lev_suffix , u4_suffix_len , u4_lev_suffix_size ; WORD32 u2_lev_code , u2_abs_value ; UWORD32 u4_lev_prefix ; FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u2_lev_code = MIN ( 15 , u4_lev_prefix ) ; u2_lev_code += ( 3 == u4_trailing_ones ) ? 0 : 2 ; if ( 14 == u4_lev_prefix ) u4_lev_suffix_size = 4 ; else if ( 15 <= u4_lev_prefix ) { u2_lev_code += 15 ; u4_lev_suffix_size = u4_lev_prefix - 3 ; } else u4_lev_suffix_size = 0 ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } if ( u4_lev_suffix_size ) { GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code += u4_lev_suffix ; } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len = ( u2_abs_value > 3 ) ? 2 : 1 ; while ( i >= 0 ) { FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_lev_suffix_size = ( 15 <= u4_lev_prefix ) ? ( u4_lev_prefix - 3 ) : u4_suffix_len ; GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code = ( MIN ( 15 , u4_lev_prefix ) << u4_suffix_len ) + u4_lev_suffix ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len += ( u4_suffix_len < 6 ) ? ( u2_abs_value > ( 3 << ( u4_suffix_len - 1 ) ) ) : 0 ; } } { UWORD32 u4_index ; const UWORD8 ( * ppu1_total_zero_lkup ) [ 64 ] = ( const UWORD8 ( * ) [ 64 ] ) gau1_ih264d_table_total_zero_2to10 ; NEXTBITS ( u4_index , u4_bitstream_offset , pu4_bitstrm_buf , 6 ) ; u4_total_zeroes = ppu1_total_zero_lkup [ u4_total_coeff - 2 ] [ u4_index ] ; FLUSHBITS ( u4_bitstream_offset , ( u4_total_zeroes >> 4 ) ) ; u4_total_zeroes &= 0xf ; } { const UWORD8 * pu1_table_runbefore ; UWORD32 u4_run ; WORD32 k ; UWORD32 u4_scan_pos = u4_total_coeff + u4_total_zeroes - 1 + u4_isdc ; WORD32 u4_zeroes_left = u4_total_zeroes ; k = u4_total_coeff - 1 ; while ( ( u4_zeroes_left > 6 ) && k ) { UWORD32 u4_code ; NEXTBITS ( u4_code , u4_bitstream_offset , pu4_bitstrm_buf , 3 ) ; if ( u4_code != 0 ) { FLUSHBITS ( u4_bitstream_offset , 3 ) ; u4_run = ( 7 - u4_code ) ; } else { FIND_ONE_IN_STREAM_LEN ( u4_code , u4_bitstream_offset , pu4_bitstrm_buf , 11 ) ; u4_run = ( 4 + u4_code ) ; } SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ k -- ] ; u4_zeroes_left -= u4_run ; u4_scan_pos -= ( u4_run + 1 ) ; } pu1_table_runbefore = ( UWORD8 * ) gau1_ih264d_table_run_before ; while ( ( u4_zeroes_left > 0 ) && k ) { UWORD32 u4_code ; NEXTBITS ( u4_code , u4_bitstream_offset , pu4_bitstrm_buf , 3 ) ; u4_code = pu1_table_runbefore [ u4_code + ( u4_zeroes_left << 3 ) ] ; u4_run = u4_code >> 2 ; FLUSHBITS ( u4_bitstream_offset , ( u4_code & 0x03 ) ) ; SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ k -- ] ; u4_zeroes_left -= u4_run ; u4_scan_pos -= ( u4_run + 1 ) ; } if ( u4_zeroes_left < 0 ) return - 1 ; while ( k >= 0 ) { SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ k -- ] ; u4_scan_pos -- ; } } { WORD32 offset ; offset = ( UWORD8 * ) pi2_coeff_data - ( UWORD8 * ) ps_tu_4x4 ; offset = ALIGN4 ( offset ) ; ps_dec -> pv_parse_tu_coeff_data = ( void * ) ( ( UWORD8 * ) ps_dec -> pv_parse_tu_coeff_data + offset ) ; } ps_bitstrm -> u4_ofst = u4_bitstream_offset ; return 0 ; }\n", "\n", "1: CWE-119 WORD32 ih264d_cavlc_4x4res_block_totalcoeff_11to16 ( UWORD32 u4_isdc , UWORD32 u4_total_coeff_trail_one , dec_bit_stream_t * ps_bitstrm ) { UWORD32 u4_total_zeroes ; WORD32 i ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 u4_bitstream_offset = ps_bitstrm -> u4_ofst ; UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF ; UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16 ; WORD16 i2_level_arr [ 16 ] ; tu_sblk4x4_coeff_data_t * ps_tu_4x4 ; WORD16 * pi2_coeff_data ; dec_struct_t * ps_dec = ( dec_struct_t * ) ps_bitstrm -> pv_codec_handle ; ps_tu_4x4 = ( tu_sblk4x4_coeff_data_t * ) ps_dec -> pv_parse_tu_coeff_data ; ps_tu_4x4 -> u2_sig_coeff_map = 0 ; pi2_coeff_data = & ps_tu_4x4 -> ai2_level [ 0 ] ; i = u4_total_coeff - 1 ; if ( u4_trailing_ones ) { UWORD32 u4_signs , u4_cnt = u4_trailing_ones ; WORD16 ( * ppi2_trlone_lkup ) [ 3 ] = ( WORD16 ( * ) [ 3 ] ) gai2_ih264d_trailing_one_level ; WORD16 * pi2_trlone_lkup ; GETBITS ( u4_signs , u4_bitstream_offset , pu4_bitstrm_buf , u4_cnt ) ; pi2_trlone_lkup = ppi2_trlone_lkup [ ( 1 << u4_cnt ) - 2 + u4_signs ] ; while ( u4_cnt -- ) i2_level_arr [ i -- ] = * pi2_trlone_lkup ++ ; } if ( i >= 0 ) { UWORD32 u4_lev_suffix , u4_suffix_len , u4_lev_suffix_size ; UWORD16 u2_lev_code , u2_abs_value ; UWORD32 u4_lev_prefix ; if ( u4_trailing_ones < 3 ) { FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_lev_suffix_size = ( 15 <= u4_lev_prefix ) ? ( u4_lev_prefix - 3 ) : 1 ; GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code = 2 + ( MIN ( u4_lev_prefix , 15 ) << 1 ) + u4_lev_suffix ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } } else { FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u2_lev_code = MIN ( 15 , u4_lev_prefix ) ; u2_lev_code += ( 3 == u4_trailing_ones ) ? 0 : ( 2 ) ; if ( 14 == u4_lev_prefix ) u4_lev_suffix_size = 4 ; else if ( 15 <= u4_lev_prefix ) { u2_lev_code += 15 ; u4_lev_suffix_size = ( u4_lev_prefix - 3 ) ; } else u4_lev_suffix_size = 0 ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } if ( u4_lev_suffix_size ) { GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code += u4_lev_suffix ; } } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len = ( u2_abs_value > 3 ) ? 2 : 1 ; while ( i >= 0 ) { FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_lev_suffix_size = ( 15 <= u4_lev_prefix ) ? ( u4_lev_prefix - 3 ) : u4_suffix_len ; GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code = ( MIN ( 15 , u4_lev_prefix ) << u4_suffix_len ) + u4_lev_suffix ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len += ( u4_suffix_len < 6 ) ? ( u2_abs_value > ( 3 << ( u4_suffix_len - 1 ) ) ) : 0 ; } } if ( u4_total_coeff < ( 16 - u4_isdc ) ) { UWORD32 u4_index ; const UWORD8 ( * ppu1_total_zero_lkup ) [ 16 ] = ( const UWORD8 ( * ) [ 16 ] ) gau1_ih264d_table_total_zero_11to15 ; NEXTBITS ( u4_index , u4_bitstream_offset , pu4_bitstrm_buf , 4 ) ; u4_total_zeroes = ppu1_total_zero_lkup [ u4_total_coeff - 11 ] [ u4_index ] ; FLUSHBITS ( u4_bitstream_offset , ( u4_total_zeroes >> 4 ) ) ; u4_total_zeroes &= 0xf ; } else u4_total_zeroes = 0 ; { const UWORD8 * pu1_table_runbefore ; UWORD32 u4_run ; WORD32 k ; UWORD32 u4_scan_pos = u4_total_coeff + u4_total_zeroes - 1 + u4_isdc ; WORD32 u4_zeroes_left = u4_total_zeroes ; k = u4_total_coeff - 1 ; pu1_table_runbefore = ( UWORD8 * ) gau1_ih264d_table_run_before ; while ( ( u4_zeroes_left > 0 ) && k ) { UWORD32 u4_code ; NEXTBITS ( u4_code , u4_bitstream_offset , pu4_bitstrm_buf , 3 ) ; u4_code = pu1_table_runbefore [ u4_code + ( u4_zeroes_left << 3 ) ] ; u4_run = u4_code >> 2 ; FLUSHBITS ( u4_bitstream_offset , ( u4_code & 0x03 ) ) ; SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ k -- ] ; u4_zeroes_left -= u4_run ; u4_scan_pos -= ( u4_run + 1 ) ; } if ( u4_zeroes_left < 0 ) return - 1 ; while ( k >= 0 ) { SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ k -- ] ; u4_scan_pos -- ; } } { WORD32 offset ; offset = ( UWORD8 * ) pi2_coeff_data - ( UWORD8 * ) ps_tu_4x4 ; offset = ALIGN4 ( offset ) ; ps_dec -> pv_parse_tu_coeff_data = ( void * ) ( ( UWORD8 * ) ps_dec -> pv_parse_tu_coeff_data + offset ) ; } ps_bitstrm -> u4_ofst = u4_bitstream_offset ; return 0 ; }\n", "\n", "\n", "Target: { if ( uaddr1 == uaddr2 ) return - EINVAL ; if ( goto out_put_key1 ; if ( requeue_pi && match_futex ( & key1 , & key2 ) ) { ret = - EINVAL ; goto out_put_keys ; }\n", "\n", "Sources:\n", "0: CWE-264 static int futex_requeue ( u32 __user * uaddr1 , unsigned int flags , u32 __user * uaddr2 , int nr_wake , int nr_requeue , u32 * cmpval , int requeue_pi ) { union futex_key key1 = FUTEX_KEY_INIT , key2 = FUTEX_KEY_INIT ; int drop_count = 0 , task_count = 0 , ret ; struct futex_pi_state * pi_state = NULL ; struct futex_hash_bucket * hb1 , * hb2 ; struct futex_q * this , * next ; if ( requeue_pi ) { if ( refill_pi_state_cache ( ) ) return - ENOMEM ; if ( nr_wake != 1 ) return - EINVAL ; } retry : if ( pi_state != NULL ) { free_pi_state ( pi_state ) ; pi_state = NULL ; } ret = get_futex_key ( uaddr1 , flags & FLAGS_SHARED , & key1 , VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , requeue_pi ? VERIFY_WRITE : VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out_put_key1 ; hb1 = hash_futex ( & key1 ) ; hb2 = hash_futex ( & key2 ) ; retry_private : hb_waiters_inc ( hb2 ) ; double_lock_hb ( hb1 , hb2 ) ; if ( likely ( cmpval != NULL ) ) { u32 curval ; ret = get_futex_value_locked ( & curval , uaddr1 ) ; if ( unlikely ( ret ) ) { double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; ret = get_user ( curval , uaddr1 ) ; if ( ret ) goto out_put_keys ; if ( ! ( flags & FLAGS_SHARED ) ) goto retry_private ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; goto retry ; } if ( curval != * cmpval ) { ret = - EAGAIN ; goto out_unlock ; } } if ( requeue_pi && ( task_count - nr_wake < nr_requeue ) ) { ret = futex_proxy_trylock_atomic ( uaddr2 , hb1 , hb2 , & key1 , & key2 , & pi_state , nr_requeue ) ; if ( ret > 0 ) { WARN_ON ( pi_state ) ; drop_count ++ ; task_count ++ ; ret = lookup_pi_state ( ret , hb2 , & key2 , & pi_state , NULL ) ; } switch ( ret ) { case 0 : break ; case - EFAULT : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; ret = fault_in_user_writeable ( uaddr2 ) ; if ( ! ret ) goto retry ; goto out ; case - EAGAIN : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; cond_resched ( ) ; goto retry ; default : goto out_unlock ; } } plist_for_each_entry_safe ( this , next , & hb1 -> chain , list ) { if ( task_count - nr_wake >= nr_requeue ) break ; if ( ! match_futex ( & this -> key , & key1 ) ) continue ; if ( ( requeue_pi && ! this -> rt_waiter ) || ( ! requeue_pi && this -> rt_waiter ) || this -> pi_state ) { ret = - EINVAL ; break ; } if ( ++ task_count <= nr_wake && ! requeue_pi ) { wake_futex ( this ) ; continue ; } if ( requeue_pi && ! match_futex ( this -> requeue_pi_key , & key2 ) ) { ret = - EINVAL ; break ; } if ( requeue_pi ) { atomic_inc ( & pi_state -> refcount ) ; this -> pi_state = pi_state ; ret = rt_mutex_start_proxy_lock ( & pi_state -> pi_mutex , this -> rt_waiter , this -> task , 1 ) ; if ( ret == 1 ) { requeue_pi_wake_futex ( this , & key2 , hb2 ) ; drop_count ++ ; continue ; } else if ( ret ) { this -> pi_state = NULL ; free_pi_state ( pi_state ) ; goto out_unlock ; } } requeue_futex ( this , hb1 , hb2 , & key2 ) ; drop_count ++ ; } out_unlock : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; while ( -- drop_count >= 0 ) drop_futex_key_refs ( & key1 ) ; out_put_keys : put_futex_key ( & key2 ) ; out_put_key1 : put_futex_key ( & key1 ) ; out : if ( pi_state != NULL ) free_pi_state ( pi_state ) ; return ret ? ret : task_count ; }\n", "\n", "1: CWE-269 static int futex_requeue ( u32 __user * uaddr1 , unsigned int flags , u32 __user * uaddr2 , int nr_wake , int nr_requeue , u32 * cmpval , int requeue_pi ) { union futex_key key1 = FUTEX_KEY_INIT , key2 = FUTEX_KEY_INIT ; int drop_count = 0 , task_count = 0 , ret ; struct futex_pi_state * pi_state = NULL ; struct futex_hash_bucket * hb1 , * hb2 ; struct futex_q * this , * next ; if ( requeue_pi ) { if ( refill_pi_state_cache ( ) ) return - ENOMEM ; if ( nr_wake != 1 ) return - EINVAL ; } retry : if ( pi_state != NULL ) { free_pi_state ( pi_state ) ; pi_state = NULL ; } ret = get_futex_key ( uaddr1 , flags & FLAGS_SHARED , & key1 , VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , requeue_pi ? VERIFY_WRITE : VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out_put_key1 ; hb1 = hash_futex ( & key1 ) ; hb2 = hash_futex ( & key2 ) ; retry_private : hb_waiters_inc ( hb2 ) ; double_lock_hb ( hb1 , hb2 ) ; if ( likely ( cmpval != NULL ) ) { u32 curval ; ret = get_futex_value_locked ( & curval , uaddr1 ) ; if ( unlikely ( ret ) ) { double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; ret = get_user ( curval , uaddr1 ) ; if ( ret ) goto out_put_keys ; if ( ! ( flags & FLAGS_SHARED ) ) goto retry_private ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; goto retry ; } if ( curval != * cmpval ) { ret = - EAGAIN ; goto out_unlock ; } } if ( requeue_pi && ( task_count - nr_wake < nr_requeue ) ) { ret = futex_proxy_trylock_atomic ( uaddr2 , hb1 , hb2 , & key1 , & key2 , & pi_state , nr_requeue ) ; if ( ret > 0 ) { WARN_ON ( pi_state ) ; drop_count ++ ; task_count ++ ; ret = lookup_pi_state ( ret , hb2 , & key2 , & pi_state , NULL ) ; } switch ( ret ) { case 0 : break ; case - EFAULT : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; ret = fault_in_user_writeable ( uaddr2 ) ; if ( ! ret ) goto retry ; goto out ; case - EAGAIN : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; cond_resched ( ) ; goto retry ; default : goto out_unlock ; } } plist_for_each_entry_safe ( this , next , & hb1 -> chain , list ) { if ( task_count - nr_wake >= nr_requeue ) break ; if ( ! match_futex ( & this -> key , & key1 ) ) continue ; if ( ( requeue_pi && ! this -> rt_waiter ) || ( ! requeue_pi && this -> rt_waiter ) || this -> pi_state ) { ret = - EINVAL ; break ; } if ( ++ task_count <= nr_wake && ! requeue_pi ) { wake_futex ( this ) ; continue ; } if ( requeue_pi && ! match_futex ( this -> requeue_pi_key , & key2 ) ) { ret = - EINVAL ; break ; } if ( requeue_pi ) { atomic_inc ( & pi_state -> refcount ) ; this -> pi_state = pi_state ; ret = rt_mutex_start_proxy_lock ( & pi_state -> pi_mutex , this -> rt_waiter , this -> task , 1 ) ; if ( ret == 1 ) { requeue_pi_wake_futex ( this , & key2 , hb2 ) ; drop_count ++ ; continue ; } else if ( ret ) { this -> pi_state = NULL ; free_pi_state ( pi_state ) ; goto out_unlock ; } } requeue_futex ( this , hb1 , hb2 , & key2 ) ; drop_count ++ ; } out_unlock : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; while ( -- drop_count >= 0 ) drop_futex_key_refs ( & key1 ) ; out_put_keys : put_futex_key ( & key2 ) ; out_put_key1 : put_futex_key ( & key1 ) ; out : if ( pi_state != NULL ) free_pi_state ( pi_state ) ; return ret ? ret : task_count ; }\n", "\n", "\n", "Target: ) ) { memset ( vec , 1 , nr ) ; goto pte ) ) * vec = 0 ; else if pte ) ; * vec = ! ! non_swap_entry ( entry ( entry ) ; } vec ++\n", "\n", "Sources:\n", "0: CWE-319 static int mincore_pte_range ( pmd_t * pmd , unsigned long addr , unsigned long end , struct mm_walk * walk ) { spinlock_t * ptl ; struct vm_area_struct * vma = walk -> vma ; pte_t * ptep ; unsigned char * vec = walk -> private ; int nr = ( end - addr ) >> PAGE_SHIFT ; ptl = pmd_trans_huge_lock ( pmd , vma ) ; if ( ptl ) { memset ( vec , 1 , nr ) ; spin_unlock ( ptl ) ; goto out ; } if ( pmd_trans_unstable ( pmd ) ) { __mincore_unmapped_range ( addr , end , vma , vec ) ; goto out ; } ptep = pte_offset_map_lock ( walk -> mm , pmd , addr , & ptl ) ; for ( ; addr != end ; ptep ++ , addr += PAGE_SIZE ) { pte_t pte = * ptep ; if ( pte_none ( pte ) ) __mincore_unmapped_range ( addr , addr + PAGE_SIZE , vma , vec ) ; else if ( pte_present ( pte ) ) * vec = 1 ; else { swp_entry_t entry = pte_to_swp_entry ( pte ) ; if ( non_swap_entry ( entry ) ) { * vec = 1 ; } else { # ifdef CONFIG_SWAP * vec = mincore_page ( swap_address_space ( entry ) , swp_offset ( entry ) ) ; # else WARN_ON ( 1 ) ; * vec = 1 ; # endif } } vec ++ ; } pte_unmap_unlock ( ptep - 1 , ptl ) ; out : walk -> private += nr ; cond_resched ( ) ; return 0 ; }\n", "\n", "1: CWE-200 static int mincore_pte_range ( pmd_t * pmd , unsigned long addr , unsigned long end , struct mm_walk * walk ) { spinlock_t * ptl ; struct vm_area_struct * vma = walk -> vma ; pte_t * ptep ; unsigned char * vec = walk -> private ; int nr = ( end - addr ) >> PAGE_SHIFT ; ptl = pmd_trans_huge_lock ( pmd , vma ) ; if ( ptl ) { memset ( vec , 1 , nr ) ; spin_unlock ( ptl ) ; goto out ; } if ( pmd_trans_unstable ( pmd ) ) { __mincore_unmapped_range ( addr , end , vma , vec ) ; goto out ; } ptep = pte_offset_map_lock ( walk -> mm , pmd , addr , & ptl ) ; for ( ; addr != end ; ptep ++ , addr += PAGE_SIZE ) { pte_t pte = * ptep ; if ( pte_none ( pte ) ) __mincore_unmapped_range ( addr , addr + PAGE_SIZE , vma , vec ) ; else if ( pte_present ( pte ) ) * vec = 1 ; else { swp_entry_t entry = pte_to_swp_entry ( pte ) ; if ( non_swap_entry ( entry ) ) { * vec = 1 ; } else { # ifdef CONFIG_SWAP * vec = mincore_page ( swap_address_space ( entry ) , swp_offset ( entry ) ) ; # else WARN_ON ( 1 ) ; * vec = 1 ; # endif } } vec ++ ; } pte_unmap_unlock ( ptep - 1 , ptl ) ; out : walk -> private += nr ; cond_resched ( ) ; return 0 ; }\n", "\n", "\n", "Target: len ) ; luaL_checkstack ( L , 1 , \"infunctionmp_encode_lua_table_as_array\" ) ;\n", "\n", "Sources:\n", "0: CWE-119 void mp_encode_lua_table_as_array ( lua_State * L , mp_buf * buf , int level ) { # if LUA_VERSION_NUM < 502 size_t len = lua_objlen ( L , - 1 ) , j ; # else size_t len = lua_rawlen ( L , - 1 ) , j ; # endif mp_encode_array ( L , buf , len ) ; for ( j = 1 ; j <= len ; j ++ ) { lua_pushnumber ( L , j ) ; lua_gettable ( L , - 2 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; } }\n", "\n", "1: CWE-787 void mp_encode_lua_table_as_array ( lua_State * L , mp_buf * buf , int level ) { # if LUA_VERSION_NUM < 502 size_t len = lua_objlen ( L , - 1 ) , j ; # else size_t len = lua_rawlen ( L , - 1 ) , j ; # endif mp_encode_array ( L , buf , len ) ; for ( j = 1 ; j <= len ; j ++ ) { lua_pushnumber ( L , j ) ; lua_gettable ( L , - 2 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; } }\n", "\n", "\n", "Target: ++ ) { luaL_checkstack ( L , 1 , \"infunctionmp_check\" ) ;\n", "\n", "Sources:\n", "0: CWE-119 int mp_pack ( lua_State * L ) { int nargs = lua_gettop ( L ) ; int i ; mp_buf * buf ; if ( nargs == 0 ) return luaL_argerror ( L , 0 , \"MessagePackpackneedsinput.\" ) ; if ( ! lua_checkstack ( L , nargs ) ) return luaL_argerror ( L , 0 , \"ToomanyargumentsforMessagePackpack.\" ) ; buf = mp_buf_new ( L ) ; for ( i = 1 ; i <= nargs ; i ++ ) { lua_pushvalue ( L , i ) ; mp_encode_lua_type ( L , buf , 0 ) ; lua_pushlstring ( L , ( char * ) buf -> b , buf -> len ) ; buf -> free += buf -> len ; buf -> len = 0 ; } mp_buf_free ( L , buf ) ; lua_concat ( L , nargs ) ; return 1 ; }\n", "\n", "1: CWE-787 int mp_pack ( lua_State * L ) { int nargs = lua_gettop ( L ) ; int i ; mp_buf * buf ; if ( nargs == 0 ) return luaL_argerror ( L , 0 , \"MessagePackpackneedsinput.\" ) ; if ( ! lua_checkstack ( L , nargs ) ) return luaL_argerror ( L , 0 , \"ToomanyargumentsforMessagePackpack.\" ) ; buf = mp_buf_new ( L ) ; for ( i = 1 ; i <= nargs ; i ++ ) { lua_pushvalue ( L , i ) ; mp_encode_lua_type ( L , buf , 0 ) ; lua_pushlstring ( L , ( char * ) buf -> b , buf -> len ) ; buf -> free += buf -> len ; buf -> len = 0 ; } mp_buf_free ( L , buf ) ; lua_concat ( L , nargs ) ; return 1 ; }\n", "\n", "\n", "Target: , nameptr , lfi , fname , UDF_NAME_LEN ) ; if\n", "\n", "Sources:\n", "0: CWE-17 static struct fileIdentDesc * udf_find_entry ( struct inode * dir , const struct qstr * child , struct udf_fileident_bh * fibh , struct fileIdentDesc * cfi ) { struct fileIdentDesc * fi = NULL ; loff_t f_pos ; int block , flen ; unsigned char * fname = NULL ; unsigned char * nameptr ; uint8_t lfi ; uint16_t liu ; loff_t size ; struct kernel_lb_addr eloc ; uint32_t elen ; sector_t offset ; struct extent_position epos = { } ; struct udf_inode_info * dinfo = UDF_I ( dir ) ; int isdotdot = child -> len == 2 && child -> name [ 0 ] == '.' && child -> name [ 1 ] == '.' ; size = udf_ext0_offset ( dir ) + dir -> i_size ; f_pos = udf_ext0_offset ( dir ) ; fibh -> sbh = fibh -> ebh = NULL ; fibh -> soffset = fibh -> eoffset = f_pos & ( dir -> i_sb -> s_blocksize - 1 ) ; if ( dinfo -> i_alloc_type != ICBTAG_FLAG_AD_IN_ICB ) { if ( inode_bmap ( dir , f_pos >> dir -> i_sb -> s_blocksize_bits , & epos , & eloc , & elen , & offset ) != ( EXT_RECORDED_ALLOCATED >> 30 ) ) goto out_err ; block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset ) ; if ( ( ++ offset << dir -> i_sb -> s_blocksize_bits ) < elen ) { if ( dinfo -> i_alloc_type == ICBTAG_FLAG_AD_SHORT ) epos . offset -= sizeof ( struct short_ad ) ; else if ( dinfo -> i_alloc_type == ICBTAG_FLAG_AD_LONG ) epos . offset -= sizeof ( struct long_ad ) ; } else offset = 0 ; fibh -> sbh = fibh -> ebh = udf_tread ( dir -> i_sb , block ) ; if ( ! fibh -> sbh ) goto out_err ; } fname = kmalloc ( UDF_NAME_LEN , GFP_NOFS ) ; if ( ! fname ) goto out_err ; while ( f_pos < size ) { fi = udf_fileident_read ( dir , & f_pos , fibh , cfi , & epos , & eloc , & elen , & offset ) ; if ( ! fi ) goto out_err ; liu = le16_to_cpu ( cfi -> lengthOfImpUse ) ; lfi = cfi -> lengthFileIdent ; if ( fibh -> sbh == fibh -> ebh ) { nameptr = fi -> fileIdent + liu ; } else { int poffset ; poffset = fibh -> soffset + sizeof ( struct fileIdentDesc ) + liu + lfi ; if ( poffset >= lfi ) nameptr = ( uint8_t * ) ( fibh -> ebh -> b_data + poffset - lfi ) ; else { nameptr = fname ; memcpy ( nameptr , fi -> fileIdent + liu , lfi - poffset ) ; memcpy ( nameptr + lfi - poffset , fibh -> ebh -> b_data , poffset ) ; } } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_DELETED ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNDELETE ) ) continue ; } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_HIDDEN ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNHIDE ) ) continue ; } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_PARENT ) && isdotdot ) goto out_ok ; if ( ! lfi ) continue ; flen = udf_get_filename ( dir -> i_sb , nameptr , fname , lfi ) ; if ( flen && udf_match ( flen , fname , child -> len , child -> name ) ) goto out_ok ; } out_err : fi = NULL ; if ( fibh -> sbh != fibh -> ebh ) brelse ( fibh -> ebh ) ; brelse ( fibh -> sbh ) ; out_ok : brelse ( epos . bh ) ; kfree ( fname ) ; return fi ; }\n", "\n", "1: CWE-17 static int udf_readdir ( struct file * file , struct dir_context * ctx ) { struct inode * dir = file_inode ( file ) ; struct udf_inode_info * iinfo = UDF_I ( dir ) ; struct udf_fileident_bh fibh = { . sbh = NULL , . ebh = NULL } ; struct fileIdentDesc * fi = NULL ; struct fileIdentDesc cfi ; int block , iblock ; loff_t nf_pos ; int flen ; unsigned char * fname = NULL ; unsigned char * nameptr ; uint16_t liu ; uint8_t lfi ; loff_t size = udf_ext0_offset ( dir ) + dir -> i_size ; struct buffer_head * tmp , * bha [ 16 ] ; struct kernel_lb_addr eloc ; uint32_t elen ; sector_t offset ; int i , num , ret = 0 ; struct extent_position epos = { NULL , 0 , { 0 , 0 } } ; if ( ctx -> pos == 0 ) { if ( ! dir_emit_dot ( file , ctx ) ) return 0 ; ctx -> pos = 1 ; } nf_pos = ( ctx -> pos - 1 ) << 2 ; if ( nf_pos >= size ) goto out ; fname = kmalloc ( UDF_NAME_LEN , GFP_NOFS ) ; if ( ! fname ) { ret = - ENOMEM ; goto out ; } if ( nf_pos == 0 ) nf_pos = udf_ext0_offset ( dir ) ; fibh . soffset = fibh . eoffset = nf_pos & ( dir -> i_sb -> s_blocksize - 1 ) ; if ( iinfo -> i_alloc_type != ICBTAG_FLAG_AD_IN_ICB ) { if ( inode_bmap ( dir , nf_pos >> dir -> i_sb -> s_blocksize_bits , & epos , & eloc , & elen , & offset ) != ( EXT_RECORDED_ALLOCATED >> 30 ) ) { ret = - ENOENT ; goto out ; } block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset ) ; if ( ( ++ offset << dir -> i_sb -> s_blocksize_bits ) < elen ) { if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_SHORT ) epos . offset -= sizeof ( struct short_ad ) ; else if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_LONG ) epos . offset -= sizeof ( struct long_ad ) ; } else { offset = 0 ; } if ( ! ( fibh . sbh = fibh . ebh = udf_tread ( dir -> i_sb , block ) ) ) { ret = - EIO ; goto out ; } if ( ! ( offset & ( ( 16 >> ( dir -> i_sb -> s_blocksize_bits - 9 ) ) - 1 ) ) ) { i = 16 >> ( dir -> i_sb -> s_blocksize_bits - 9 ) ; if ( i + offset > ( elen >> dir -> i_sb -> s_blocksize_bits ) ) i = ( elen >> dir -> i_sb -> s_blocksize_bits ) - offset ; for ( num = 0 ; i > 0 ; i -- ) { block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset + i ) ; tmp = udf_tgetblk ( dir -> i_sb , block ) ; if ( tmp && ! buffer_uptodate ( tmp ) && ! buffer_locked ( tmp ) ) bha [ num ++ ] = tmp ; else brelse ( tmp ) ; } if ( num ) { ll_rw_block ( READA , num , bha ) ; for ( i = 0 ; i < num ; i ++ ) brelse ( bha [ i ] ) ; } } } while ( nf_pos < size ) { struct kernel_lb_addr tloc ; ctx -> pos = ( nf_pos >> 2 ) + 1 ; fi = udf_fileident_read ( dir , & nf_pos , & fibh , & cfi , & epos , & eloc , & elen , & offset ) ; if ( ! fi ) goto out ; liu = le16_to_cpu ( cfi . lengthOfImpUse ) ; lfi = cfi . lengthFileIdent ; if ( fibh . sbh == fibh . ebh ) { nameptr = fi -> fileIdent + liu ; } else { int poffset ; poffset = fibh . soffset + sizeof ( struct fileIdentDesc ) + liu + lfi ; if ( poffset >= lfi ) { nameptr = ( char * ) ( fibh . ebh -> b_data + poffset - lfi ) ; } else { nameptr = fname ; memcpy ( nameptr , fi -> fileIdent + liu , lfi - poffset ) ; memcpy ( nameptr + lfi - poffset , fibh . ebh -> b_data , poffset ) ; } } if ( ( cfi . fileCharacteristics & FID_FILE_CHAR_DELETED ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNDELETE ) ) continue ; } if ( ( cfi . fileCharacteristics & FID_FILE_CHAR_HIDDEN ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNHIDE ) ) continue ; } if ( cfi . fileCharacteristics & FID_FILE_CHAR_PARENT ) { if ( ! dir_emit_dotdot ( file , ctx ) ) goto out ; continue ; } flen = udf_get_filename ( dir -> i_sb , nameptr , fname , lfi ) ; if ( ! flen ) continue ; tloc = lelb_to_cpu ( cfi . icb . extLocation ) ; iblock = udf_get_lb_pblock ( dir -> i_sb , & tloc , 0 ) ; if ( ! dir_emit ( ctx , fname , flen , iblock , DT_UNKNOWN ) ) goto out ; } ctx -> pos = ( nf_pos >> 2 ) + 1 ; out : if ( fibh . sbh != fibh . ebh ) brelse ( fibh . ebh ) ; brelse ( fibh . sbh ) ; brelse ( epos . bh ) ; kfree ( fname ) ; return ret ; }\n", "\n", "\n", "Target: ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; }\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadHDRImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char format [ MaxTextExtent ] , keyword [ MaxTextExtent ] , tag [ MaxTextExtent ] , value [ MaxTextExtent ] ; double gamma ; Image * image ; int c ; MagickBooleanType status , value_expected ; register PixelPacket * q ; register unsigned char * p ; register ssize_t i , x ; ssize_t count , y ; unsigned char * end , pixel [ 4 ] , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> columns = 0 ; image -> rows = 0 ; * format = '\\\\0' ; c = ReadBlobByte ( image ) ; if ( c == EOF ) { image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } while ( isgraph ( c ) && ( image -> columns == 0 ) && ( image -> rows == 0 ) ) { if ( c == ( int ) '#' ) { char * comment ; register char * p ; size_t length ; length = MaxTextExtent ; comment = AcquireString ( ( char * ) NULL ) ; for ( p = comment ; comment != ( char * ) NULL ; p ++ ) { c = ReadBlobByte ( image ) ; if ( ( c == EOF ) || ( c == ( int ) '\\\\n' ) ) break ; if ( ( size_t ) ( p - comment + 1 ) >= length ) { * p = '\\\\0' ; length <<= 1 ; comment = ( char * ) ResizeQuantumMemory ( comment , length + MaxTextExtent , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) break ; p = comment + strlen ( comment ) ; } * p = ( char ) c ; } if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; * p = '\\\\0' ; ( void ) SetImageProperty ( image , \"comment\" , comment ) ; comment = DestroyString ( comment ) ; c = ReadBlobByte ( image ) ; } else if ( isalnum ( c ) == MagickFalse ) c = ReadBlobByte ( image ) ; else { register char * p ; p = keyword ; do { if ( ( size_t ) ( p - keyword ) < ( MaxTextExtent - 1 ) ) * p ++ = c ; c = ReadBlobByte ( image ) ; } while ( isalnum ( c ) || ( c == '_' ) ) ; * p = '\\\\0' ; value_expected = MagickFalse ; while ( ( isspace ( ( int ) ( ( unsigned char ) c ) ) != 0 ) || ( c == '=' ) ) { if ( c == '=' ) value_expected = MagickTrue ; c = ReadBlobByte ( image ) ; } if ( LocaleCompare ( keyword , \"Y\" ) == 0 ) value_expected = MagickTrue ; if ( value_expected == MagickFalse ) continue ; p = value ; while ( ( c != '\\\\n' ) && ( c != '\\\\0' ) ) { if ( ( size_t ) ( p - value ) < ( MaxTextExtent - 1 ) ) * p ++ = c ; c = ReadBlobByte ( image ) ; } * p = '\\\\0' ; switch ( * keyword ) { case 'F' : case 'f' : { if ( LocaleCompare ( keyword , \"format\" ) == 0 ) { ( void ) CopyMagickString ( format , value , MaxTextExtent ) ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , \"hdr:%s\" , keyword ) ; ( void ) SetImageProperty ( image , tag , value ) ; break ; } case 'G' : case 'g' : { if ( LocaleCompare ( keyword , \"gamma\" ) == 0 ) { image -> gamma = StringToDouble ( value , ( char * * ) NULL ) ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , \"hdr:%s\" , keyword ) ; ( void ) SetImageProperty ( image , tag , value ) ; break ; } case 'P' : case 'p' : { if ( LocaleCompare ( keyword , \"primaries\" ) == 0 ) { float chromaticity [ 6 ] , white_point [ 2 ] ; ( void ) sscanf ( value , \"%g%g%g%g%g%g%g%g\" , & chromaticity [ 0 ] , & chromaticity [ 1 ] , & chromaticity [ 2 ] , & chromaticity [ 3 ] , & chromaticity [ 4 ] , & chromaticity [ 5 ] , & white_point [ 0 ] , & white_point [ 1 ] ) ; image -> chromaticity . red_primary . x = chromaticity [ 0 ] ; image -> chromaticity . red_primary . y = chromaticity [ 1 ] ; image -> chromaticity . green_primary . x = chromaticity [ 2 ] ; image -> chromaticity . green_primary . y = chromaticity [ 3 ] ; image -> chromaticity . blue_primary . x = chromaticity [ 4 ] ; image -> chromaticity . blue_primary . y = chromaticity [ 5 ] ; image -> chromaticity . white_point . x = white_point [ 0 ] , image -> chromaticity . white_point . y = white_point [ 1 ] ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , \"hdr:%s\" , keyword ) ; ( void ) SetImageProperty ( image , tag , value ) ; break ; } case 'Y' : case 'y' : { if ( strcmp ( keyword , \"Y\" ) == 0 ) { int height , width ; ( void ) sscanf ( value , \"%d+X%d\" , & height , & width ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , \"hdr:%s\" , keyword ) ; ( void ) SetImageProperty ( image , tag , value ) ; break ; } default : { ( void ) FormatLocaleString ( tag , MaxTextExtent , \"hdr:%s\" , keyword ) ; ( void ) SetImageProperty ( image , tag , value ) ; break ; } } } if ( ( image -> columns == 0 ) && ( image -> rows == 0 ) ) while ( isspace ( ( int ) ( ( unsigned char ) c ) ) != 0 ) c = ReadBlobByte ( image ) ; } if ( ( LocaleCompare ( format , \"32-bit_rle_rgbe\" ) != 0 ) && ( LocaleCompare ( format , \"32-bit_rle_xyze\" ) != 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; ( void ) SetImageColorspace ( image , RGBColorspace ) ; if ( LocaleCompare ( format , \"32-bit_rle_xyze\" ) == 0 ) ( void ) SetImageColorspace ( image , XYZColorspace ) ; image -> compression = ( image -> columns < 8 ) || ( image -> columns > 0x7ffff ) ? NoCompression : RLECompression ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 4 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { if ( image -> compression != RLECompression ) { count = ReadBlob ( image , 4 * image -> columns * sizeof ( * pixels ) , pixels ) ; if ( count != ( ssize_t ) ( 4 * image -> columns * sizeof ( * pixels ) ) ) break ; } else { count = ReadBlob ( image , 4 * sizeof ( * pixel ) , pixel ) ; if ( count != 4 ) break ; if ( ( size_t ) ( ( ( ( size_t ) pixel [ 2 ] ) << 8 ) | pixel [ 3 ] ) != image -> columns ) { ( void ) memcpy ( pixels , pixel , 4 * sizeof ( * pixel ) ) ; count = ReadBlob ( image , 4 * ( image -> columns - 1 ) * sizeof ( * pixels ) , pixels + 4 ) ; image -> compression = NoCompression ; } else { p = pixels ; for ( i = 0 ; i < 4 ; i ++ ) { end = & pixels [ ( i + 1 ) * image -> columns ] ; while ( p < end ) { count = ReadBlob ( image , 2 * sizeof ( * pixel ) , pixel ) ; if ( count < 1 ) break ; if ( pixel [ 0 ] > 128 ) { count = ( ssize_t ) pixel [ 0 ] - 128 ; if ( ( count == 0 ) || ( count > ( ssize_t ) ( end - p ) ) ) break ; while ( count -- > 0 ) * p ++ = pixel [ 1 ] ; } else { count = ( ssize_t ) pixel [ 0 ] ; if ( ( count == 0 ) || ( count > ( ssize_t ) ( end - p ) ) ) break ; * p ++ = pixel [ 1 ] ; if ( -- count > 0 ) { count = ReadBlob ( image , ( size_t ) count * sizeof ( * p ) , p ) ; if ( count < 1 ) break ; p += count ; } } } } } } q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; i = 0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> compression == RLECompression ) { pixel [ 0 ] = pixels [ x ] ; pixel [ 1 ] = pixels [ x + image -> columns ] ; pixel [ 2 ] = pixels [ x + 2 * image -> columns ] ; pixel [ 3 ] = pixels [ x + 3 * image -> columns ] ; } else { pixel [ 0 ] = pixels [ i ++ ] ; pixel [ 1 ] = pixels [ i ++ ] ; pixel [ 2 ] = pixels [ i ++ ] ; pixel [ 3 ] = pixels [ i ++ ] ; } SetPixelRed ( q , 0 ) ; SetPixelGreen ( q , 0 ) ; SetPixelBlue ( q , 0 ) ; if ( pixel [ 3 ] != 0 ) { gamma = pow ( 2.0 , pixel [ 3 ] - ( 128.0 + 8.0 ) ) ; SetPixelRed ( q , ClampToQuantum ( QuantumRange * gamma * pixel [ 0 ] ) ) ; SetPixelGreen ( q , ClampToQuantum ( QuantumRange * gamma * pixel [ 1 ] ) ) ; SetPixelBlue ( q , ClampToQuantum ( QuantumRange * gamma * pixel [ 2 ] ) ) ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-119 static Image * ReadARTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; QuantumInfo * quantum_info ; QuantumType quantum_type ; MagickBooleanType status ; size_t length ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 1 ; image -> endian = MSBEndian ; ( void ) ReadBlobLSBShort ( image ) ; image -> columns = ( size_t ) ReadBlobLSBShort ( image ) ; ( void ) ReadBlobLSBShort ( image ) ; image -> rows = ( size_t ) ReadBlobLSBShort ( image ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( AcquireImageColormap ( image , 2 ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } SetImageColorspace ( image , GRAYColorspace ) ; quantum_type = IndexQuantum ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = GetQuantumPixels ( quantum_info ) ; length = GetQuantumExtent ( image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register PixelPacket * restrict q ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; count = ReadBlob ( image , ( size_t ) ( - ( ssize_t ) length ) & 0x01 , pixels ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } SetQuantumImageType ( image , quantum_type ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: <= w - ( int )\n", "\n", "Sources:\n", "0: CWE-189 static void add_bytes_c ( uint8_t * dst , uint8_t * src , int w ) { long i ; for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src + i ) ; long b = * ( long * ) ( dst + i ) ; * ( long * ) ( dst + i ) = ( ( a & pb_7f ) + ( b & pb_7f ) ) ^ ( ( a ^ b ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i + 0 ] += src [ i + 0 ] ; }\n", "\n", "1: CWE-189 static void add_bytes_l2_c ( uint8_t * dst , uint8_t * src1 , uint8_t * src2 , int w ) { long i ; for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src1 + i ) ; long b = * ( long * ) ( src2 + i ) ; * ( long * ) ( dst + i ) = ( ( a & pb_7f ) + ( b & pb_7f ) ) ^ ( ( a ^ b ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i ] = src1 [ i ] + src2 [ i ] ; }\n", "\n", "2: CWE-189 static void diff_bytes_c ( uint8_t * dst , const uint8_t * src1 , const uint8_t * src2 , int w ) { long i ; # if ! HAVE_FAST_UNALIGNED if ( ( long ) src2 & ( sizeof ( long ) - 1 ) ) { for ( i = 0 ; i + 7 < w ; i += 8 ) { dst [ i + 0 ] = src1 [ i + 0 ] - src2 [ i + 0 ] ; dst [ i + 1 ] = src1 [ i + 1 ] - src2 [ i + 1 ] ; dst [ i + 2 ] = src1 [ i + 2 ] - src2 [ i + 2 ] ; dst [ i + 3 ] = src1 [ i + 3 ] - src2 [ i + 3 ] ; dst [ i + 4 ] = src1 [ i + 4 ] - src2 [ i + 4 ] ; dst [ i + 5 ] = src1 [ i + 5 ] - src2 [ i + 5 ] ; dst [ i + 6 ] = src1 [ i + 6 ] - src2 [ i + 6 ] ; dst [ i + 7 ] = src1 [ i + 7 ] - src2 [ i + 7 ] ; } } else # endif for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src1 + i ) ; long b = * ( long * ) ( src2 + i ) ; * ( long * ) ( dst + i ) = ( ( a | pb_80 ) - ( b & pb_7f ) ) ^ ( ( a ^ b ^ pb_80 ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i + 0 ] = src1 [ i + 0 ] - src2 [ i + 0 ] ; }\n", "\n", "\n", "Target: ! retval ) r = k5memdup0 ( realm , rlen , & retval ) ; while ( !\n", "\n", "Sources:\n", "0: CWE-125 static krb5_error_code build_principal_va ( krb5_context context , krb5_principal princ , unsigned int rlen , const char * realm , va_list ap ) { krb5_error_code retval = 0 ; char * r = NULL ; krb5_data * data = NULL ; krb5_int32 count = 0 ; krb5_int32 size = 2 ; char * component = NULL ; data = malloc ( size * sizeof ( krb5_data ) ) ; if ( ! data ) { retval = ENOMEM ; } if ( ! retval ) { r = strdup ( realm ) ; if ( ! r ) { retval = ENOMEM ; } } while ( ! retval && ( component = va_arg ( ap , char * ) ) ) { if ( count == size ) { krb5_data * new_data = NULL ; size *= 2 ; new_data = realloc ( data , size * sizeof ( krb5_data ) ) ; if ( new_data ) { data = new_data ; } else { retval = ENOMEM ; } } if ( ! retval ) { data [ count ] . length = strlen ( component ) ; data [ count ] . data = strdup ( component ) ; if ( ! data [ count ] . data ) { retval = ENOMEM ; } count ++ ; } } if ( ! retval ) { princ -> type = KRB5_NT_UNKNOWN ; princ -> magic = KV5M_PRINCIPAL ; princ -> realm = make_data ( r , rlen ) ; princ -> data = data ; princ -> length = count ; r = NULL ; data = NULL ; } if ( data ) { while ( -- count >= 0 ) { free ( data [ count ] . data ) ; } free ( data ) ; } free ( r ) ; return retval ; }\n", "\n", "1: CWE-119 static krb5_error_code build_principal_va ( krb5_context context , krb5_principal princ , unsigned int rlen , const char * realm , va_list ap ) { krb5_error_code retval = 0 ; char * r = NULL ; krb5_data * data = NULL ; krb5_int32 count = 0 ; krb5_int32 size = 2 ; char * component = NULL ; data = malloc ( size * sizeof ( krb5_data ) ) ; if ( ! data ) { retval = ENOMEM ; } if ( ! retval ) { r = strdup ( realm ) ; if ( ! r ) { retval = ENOMEM ; } } while ( ! retval && ( component = va_arg ( ap , char * ) ) ) { if ( count == size ) { krb5_data * new_data = NULL ; size *= 2 ; new_data = realloc ( data , size * sizeof ( krb5_data ) ) ; if ( new_data ) { data = new_data ; } else { retval = ENOMEM ; } } if ( ! retval ) { data [ count ] . length = strlen ( component ) ; data [ count ] . data = strdup ( component ) ; if ( ! data [ count ] . data ) { retval = ENOMEM ; } count ++ ; } } if ( ! retval ) { princ -> type = KRB5_NT_UNKNOWN ; princ -> magic = KV5M_PRINCIPAL ; princ -> realm = make_data ( r , rlen ) ; princ -> data = data ; princ -> length = count ; r = NULL ; data = NULL ; } if ( data ) { while ( -- count >= 0 ) { free ( data [ count ] . data ) ; } free ( data ) ; } free ( r ) ; return retval ; }\n", "\n", "\n", "Target: != MagickTrue ) ThrowReaderException ( CorruptImageError \"ImproperImageHeader\" ) ; if ( dds_info . depth ; if ( num_images < 1 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ;\n", "\n", "Sources:\n", "0: CWE-20 static Image * ReadDDSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status , cubemap = MagickFalse , volume = MagickFalse ; CompressionType compression ; DDSInfo dds_info ; DDSDecoder * decoder ; PixelTrait alpha_trait ; size_t n , num_images ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( ReadDDSInfo ( image , & dds_info ) != MagickTrue ) { ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP ) cubemap = MagickTrue ; if ( dds_info . ddscaps2 & DDSCAPS2_VOLUME && dds_info . depth > 0 ) volume = MagickTrue ; ( void ) SeekBlob ( image , 128 , SEEK_SET ) ; if ( dds_info . pixelformat . flags & DDPF_RGB ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { alpha_trait = BlendPixelTrait ; decoder = ReadUncompressedRGBA ; } else { alpha_trait = UndefinedPixelTrait ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_LUMINANCE ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } else { alpha_trait = UndefinedPixelTrait ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_FOURCC ) { switch ( dds_info . pixelformat . fourcc ) { case FOURCC_DXT1 : { alpha_trait = UndefinedPixelTrait ; compression = DXT1Compression ; decoder = ReadDXT1 ; break ; } case FOURCC_DXT3 : { alpha_trait = BlendPixelTrait ; compression = DXT3Compression ; decoder = ReadDXT3 ; break ; } case FOURCC_DXT5 : { alpha_trait = BlendPixelTrait ; compression = DXT5Compression ; decoder = ReadDXT5 ; break ; } default : { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } } } else { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } num_images = 1 ; if ( cubemap ) { num_images = 0 ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) num_images ++ ; } if ( volume ) num_images = dds_info . depth ; for ( n = 0 ; n < num_images ; n ++ ) { if ( n != 0 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) return ( DestroyImageList ( image ) ) ; image = SyncNextImageInList ( image ) ; } image -> alpha_trait = alpha_trait ; image -> compression = compression ; image -> columns = dds_info . width ; image -> rows = dds_info . height ; image -> storage_class = DirectClass ; image -> endian = LSBEndian ; image -> depth = 8 ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( decoder ) ( image , & dds_info , exception ) != MagickTrue ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-20 static Image * ReadDDSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status , cubemap = MagickFalse , volume = MagickFalse , matte ; CompressionType compression ; DDSInfo dds_info ; DDSDecoder * decoder ; size_t n , num_images ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( ReadDDSInfo ( image , & dds_info ) != MagickTrue ) { ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP ) cubemap = MagickTrue ; if ( dds_info . ddscaps2 & DDSCAPS2_VOLUME && dds_info . depth > 0 ) volume = MagickTrue ; ( void ) SeekBlob ( image , 128 , SEEK_SET ) ; if ( dds_info . pixelformat . flags & DDPF_RGB ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { matte = MagickTrue ; decoder = ReadUncompressedRGBA ; } else { matte = MagickTrue ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_LUMINANCE ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } else { matte = MagickFalse ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_FOURCC ) { switch ( dds_info . pixelformat . fourcc ) { case FOURCC_DXT1 : { matte = MagickFalse ; compression = DXT1Compression ; decoder = ReadDXT1 ; break ; } case FOURCC_DXT3 : { matte = MagickTrue ; compression = DXT3Compression ; decoder = ReadDXT3 ; break ; } case FOURCC_DXT5 : { matte = MagickTrue ; compression = DXT5Compression ; decoder = ReadDXT5 ; break ; } default : { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } } } else { ThrowReaderException ( CorruptImageError , \"ImageTypeNotSupported\" ) ; } num_images = 1 ; if ( cubemap ) { num_images = 0 ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) num_images ++ ; } if ( volume ) num_images = dds_info . depth ; for ( n = 0 ; n < num_images ; n ++ ) { if ( n != 0 ) { if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) return ( DestroyImageList ( image ) ) ; image = SyncNextImageInList ( image ) ; } image -> matte = matte ; image -> compression = compression ; image -> columns = dds_info . width ; image -> rows = dds_info . height ; image -> storage_class = DirectClass ; image -> endian = LSBEndian ; image -> depth = 8 ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( ( decoder ) ( image , & dds_info , exception ) != MagickTrue ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: n ) { jas_matind_t i ; jas_matind_t j ; jas_seqent_t * rowstart ; jas_matind_t rowstep ; jas_seqent_t\n", "\n", "Sources:\n", "0: CWE-190 void jas_matrix_asl ( jas_matrix_t * matrix , int n ) { int i ; int j ; jas_seqent_t * rowstart ; int rowstep ; jas_seqent_t * data ; if ( jas_matrix_numrows ( matrix ) > 0 && jas_matrix_numcols ( matrix ) > 0 ) { assert ( matrix -> rows_ ) ; rowstep = jas_matrix_rowstep ( matrix ) ; for ( i = matrix -> numrows_ , rowstart = matrix -> rows_ [ 0 ] ; i > 0 ; -- i , rowstart += rowstep ) { for ( j = matrix -> numcols_ , data = rowstart ; j > 0 ; -- j , ++ data ) { * data = jas_seqent_asl ( * data , n ) ; } } } }\n", "\n", "1: CWE-190 void jas_matrix_divpow2 ( jas_matrix_t * matrix , int n ) { int i ; int j ; jas_seqent_t * rowstart ; int rowstep ; jas_seqent_t * data ; if ( jas_matrix_numrows ( matrix ) > 0 && jas_matrix_numcols ( matrix ) > 0 ) { assert ( matrix -> rows_ ) ; rowstep = jas_matrix_rowstep ( matrix ) ; for ( i = matrix -> numrows_ , rowstart = matrix -> rows_ [ 0 ] ; i > 0 ; -- i , rowstart += rowstep ) { for ( j = matrix -> numcols_ , data = rowstart ; j > 0 ; -- j , ++ data ) { * data = ( * data >= 0 ) ? ( ( * data ) >> n ) : ( - ( ( - ( * data ) ) >> n ) ) ; } } } }\n", "\n", "\n", "Target: * next_order ; struct stream packet = * s ; type ) ; if ( ! s_check_rem ( s , length + 7 ) ) { rdp_protocol_error ( \"process_secondary_order(),nextorderpointerwouldoverrunstream\" , & packet ) ; }\n", "\n", "Sources:\n", "0: CWE-787 static void process_secondary_order ( STREAM s ) { uint16 length ; uint16 flags ; uint8 type ; uint8 * next_order ; in_uint16_le ( s , length ) ; in_uint16_le ( s , flags ) ; in_uint8 ( s , type ) ; next_order = s -> p + ( sint16 ) length + 7 ; switch ( type ) { case RDP_ORDER_RAW_BMPCACHE : process_raw_bmpcache ( s ) ; break ; case RDP_ORDER_COLCACHE : process_colcache ( s ) ; break ; case RDP_ORDER_BMPCACHE : process_bmpcache ( s ) ; break ; case RDP_ORDER_FONTCACHE : process_fontcache ( s ) ; break ; case RDP_ORDER_RAW_BMPCACHE2 : process_bmpcache2 ( s , flags , False ) ; break ; case RDP_ORDER_BMPCACHE2 : process_bmpcache2 ( s , flags , True ) ; break ; case RDP_ORDER_BRUSHCACHE : process_brushcache ( s , flags ) ; break ; default : logger ( Graphics , Warning , \"process_secondary_order(),unhandledsecondaryorder%d\" , type ) ; } s -> p = next_order ; }\n", "\n", "1: CWE-119 static void process_secondary_order ( STREAM s ) { uint16 length ; uint16 flags ; uint8 type ; uint8 * next_order ; in_uint16_le ( s , length ) ; in_uint16_le ( s , flags ) ; in_uint8 ( s , type ) ; next_order = s -> p + ( sint16 ) length + 7 ; switch ( type ) { case RDP_ORDER_RAW_BMPCACHE : process_raw_bmpcache ( s ) ; break ; case RDP_ORDER_COLCACHE : process_colcache ( s ) ; break ; case RDP_ORDER_BMPCACHE : process_bmpcache ( s ) ; break ; case RDP_ORDER_FONTCACHE : process_fontcache ( s ) ; break ; case RDP_ORDER_RAW_BMPCACHE2 : process_bmpcache2 ( s , flags , False ) ; break ; case RDP_ORDER_BMPCACHE2 : process_bmpcache2 ( s , flags , True ) ; break ; case RDP_ORDER_BRUSHCACHE : process_brushcache ( s , flags ) ; break ; default : logger ( Graphics , Warning , \"process_secondary_order(),unhandledsecondaryorder%d\" , type ) ; } s -> p = next_order ; }\n", "\n", "\n", "Target: char buf [ 100 ] ; js_Object = \"0123456789abcdefghijklmnopqrstuvwxyz\" ; double number =\n", "\n", "Sources:\n", "0: CWE-119 static void Np_toString ( js_State * J ) { char buf [ 32 ] ; js_Object * self = js_toobject ( J , 0 ) ; int radix = js_isundefined ( J , 1 ) ? 10 : js_tointeger ( J , 1 ) ; if ( self -> type != JS_CNUMBER ) js_typeerror ( J , \"notanumber\" ) ; if ( radix == 10 ) { js_pushstring ( J , jsV_numbertostring ( J , buf , self -> u . number ) ) ; return ; } if ( radix < 2 || radix > 36 ) js_rangeerror ( J , \"invalidradix\" ) ; { static const char digits [ ] = \"0123456789abcdefghijklmnopqrstuvwxyz\" ; char buf [ 100 ] ; double number = self -> u . number ; int sign = self -> u . number < 0 ; js_Buffer * sb = NULL ; uint64_t u , limit = ( ( uint64_t ) 1 << 52 ) ; int ndigits , exp , point ; if ( number == 0 ) { js_pushstring ( J , \"0\" ) ; return ; } if ( isnan ( number ) ) { js_pushstring ( J , \"NaN\" ) ; return ; } if ( isinf ( number ) ) { js_pushstring ( J , sign ? \"-Infinity\" : \"Infinity\" ) ; return ; } if ( sign ) number = - number ; exp = 0 ; while ( number * pow ( radix , exp ) > limit ) -- exp ; while ( number * pow ( radix , exp + 1 ) < limit ) ++ exp ; u = number * pow ( radix , exp ) + 0.5 ; while ( u > 0 && ( u % radix ) == 0 ) { u /= radix ; -- exp ; } ndigits = 0 ; while ( u > 0 ) { buf [ ndigits ++ ] = digits [ u % radix ] ; u /= radix ; } point = ndigits - exp ; if ( js_try ( J ) ) { js_free ( J , sb ) ; js_throw ( J ) ; } if ( sign ) js_putc ( J , & sb , '-' ) ; if ( point <= 0 ) { js_putc ( J , & sb , '0' ) ; js_putc ( J , & sb , '.' ) ; while ( point ++ < 0 ) js_putc ( J , & sb , '0' ) ; while ( ndigits -- > 0 ) js_putc ( J , & sb , buf [ ndigits ] ) ; } else { while ( ndigits -- > 0 ) { js_putc ( J , & sb , buf [ ndigits ] ) ; if ( -- point == 0 && ndigits > 0 ) js_putc ( J , & sb , '.' ) ; } while ( point -- > 0 ) js_putc ( J , & sb , '0' ) ; } js_putc ( J , & sb , 0 ) ; js_pushstring ( J , sb -> s ) ; js_endtry ( J ) ; js_free ( J , sb ) ; } }\n", "\n", "1: CWE-787 static void Np_toString ( js_State * J ) { char buf [ 32 ] ; js_Object * self = js_toobject ( J , 0 ) ; int radix = js_isundefined ( J , 1 ) ? 10 : js_tointeger ( J , 1 ) ; if ( self -> type != JS_CNUMBER ) js_typeerror ( J , \"notanumber\" ) ; if ( radix == 10 ) { js_pushstring ( J , jsV_numbertostring ( J , buf , self -> u . number ) ) ; return ; } if ( radix < 2 || radix > 36 ) js_rangeerror ( J , \"invalidradix\" ) ; { static const char digits [ ] = \"0123456789abcdefghijklmnopqrstuvwxyz\" ; char buf [ 100 ] ; double number = self -> u . number ; int sign = self -> u . number < 0 ; js_Buffer * sb = NULL ; uint64_t u , limit = ( ( uint64_t ) 1 << 52 ) ; int ndigits , exp , point ; if ( number == 0 ) { js_pushstring ( J , \"0\" ) ; return ; } if ( isnan ( number ) ) { js_pushstring ( J , \"NaN\" ) ; return ; } if ( isinf ( number ) ) { js_pushstring ( J , sign ? \"-Infinity\" : \"Infinity\" ) ; return ; } if ( sign ) number = - number ; exp = 0 ; while ( number * pow ( radix , exp ) > limit ) -- exp ; while ( number * pow ( radix , exp + 1 ) < limit ) ++ exp ; u = number * pow ( radix , exp ) + 0.5 ; while ( u > 0 && ( u % radix ) == 0 ) { u /= radix ; -- exp ; } ndigits = 0 ; while ( u > 0 ) { buf [ ndigits ++ ] = digits [ u % radix ] ; u /= radix ; } point = ndigits - exp ; if ( js_try ( J ) ) { js_free ( J , sb ) ; js_throw ( J ) ; } if ( sign ) js_putc ( J , & sb , '-' ) ; if ( point <= 0 ) { js_putc ( J , & sb , '0' ) ; js_putc ( J , & sb , '.' ) ; while ( point ++ < 0 ) js_putc ( J , & sb , '0' ) ; while ( ndigits -- > 0 ) js_putc ( J , & sb , buf [ ndigits ] ) ; } else { while ( ndigits -- > 0 ) { js_putc ( J , & sb , buf [ ndigits ] ) ; if ( -- point == 0 && ndigits > 0 ) js_putc ( J , & sb , '.' ) ; } while ( point -- > 0 ) js_putc ( J , & sb , '0' ) ; } js_putc ( J , & sb , 0 ) ; js_pushstring ( J , sb -> s ) ; js_endtry ( J ) ; js_free ( J , sb ) ; } }\n", "\n", "\n", "Target: ) ) { if ( tp -> snd_numholes >= TCP_SACKHOLE_LIMIT ) goto done ; ) ) { if ( tp -> snd_numholes >= TCP_SACKHOLE_LIMIT ) goto done ;\n", "\n", "Sources:\n", "0: CWE-20 void tcp_sack_option ( struct tcpcb * tp , struct tcphdr * th , u_char * cp , int optlen ) { int tmp_olen ; u_char * tmp_cp ; struct sackhole * cur , * p , * temp ; if ( ! tp -> sack_enable ) return ; if ( ( th -> th_flags & TH_ACK ) == 0 ) return ; if ( SEQ_LT ( th -> th_ack , tp -> snd_una ) || SEQ_GT ( th -> th_ack , tp -> snd_max ) ) return ; if ( optlen <= 2 || ( optlen - 2 ) % TCPOLEN_SACK != 0 ) return ; tmp_cp = cp + 2 ; tmp_olen = optlen - 2 ; tcpstat_inc ( tcps_sack_rcv_opts ) ; if ( tp -> snd_numholes < 0 ) tp -> snd_numholes = 0 ; if ( tp -> t_maxseg == 0 ) panic ( \"tcp_sack_option\" ) ; while ( tmp_olen > 0 ) { struct sackblk sack ; memcpy ( & sack . start , tmp_cp , sizeof ( tcp_seq ) ) ; sack . start = ntohl ( sack . start ) ; memcpy ( & sack . end , tmp_cp + sizeof ( tcp_seq ) , sizeof ( tcp_seq ) ) ; sack . end = ntohl ( sack . end ) ; tmp_olen -= TCPOLEN_SACK ; tmp_cp += TCPOLEN_SACK ; if ( SEQ_LEQ ( sack . end , sack . start ) ) continue ; if ( SEQ_LEQ ( sack . end , tp -> snd_una ) ) continue ; if ( SEQ_GT ( th -> th_ack , tp -> snd_una ) ) { if ( SEQ_LT ( sack . start , th -> th_ack ) ) continue ; } if ( SEQ_GT ( sack . end , tp -> snd_max ) ) continue ; if ( tp -> snd_holes == NULL ) { tp -> snd_holes = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( tp -> snd_holes == NULL ) { goto done ; } cur = tp -> snd_holes ; cur -> start = th -> th_ack ; cur -> end = sack . start ; cur -> rxmit = cur -> start ; cur -> next = NULL ; tp -> snd_numholes = 1 ; tp -> rcv_lastsack = sack . end ; cur -> dups = min ( tcprexmtthresh , ( ( sack . end - cur -> end ) / tp -> t_maxseg ) ) ; if ( cur -> dups < 1 ) cur -> dups = 1 ; continue ; } p = cur = tp -> snd_holes ; while ( cur ) { if ( SEQ_LEQ ( sack . end , cur -> start ) ) break ; if ( SEQ_GEQ ( sack . start , cur -> end ) ) { cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_LEQ ( sack . start , cur -> start ) ) { if ( SEQ_GEQ ( sack . end , cur -> end ) ) { if ( p != cur ) { p -> next = cur -> next ; pool_put ( & sackhl_pool , cur ) ; cur = p -> next ; } else { cur = cur -> next ; pool_put ( & sackhl_pool , p ) ; p = cur ; tp -> snd_holes = p ; } tp -> snd_numholes -- ; continue ; } cur -> start = sack . end ; cur -> rxmit = SEQ_MAX ( cur -> rxmit , cur -> start ) ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_GEQ ( sack . end , cur -> end ) ) { cur -> end = sack . start ; cur -> rxmit = SEQ_MIN ( cur -> rxmit , cur -> end ) ; cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_LT ( cur -> start , sack . start ) && SEQ_GT ( cur -> end , sack . end ) ) { temp = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( temp == NULL ) goto done ; temp -> next = cur -> next ; temp -> start = sack . end ; temp -> end = cur -> end ; temp -> dups = cur -> dups ; temp -> rxmit = SEQ_MAX ( cur -> rxmit , temp -> start ) ; cur -> end = sack . start ; cur -> rxmit = SEQ_MIN ( cur -> rxmit , cur -> end ) ; cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; cur -> next = temp ; p = temp ; cur = p -> next ; tp -> snd_numholes ++ ; } } if ( SEQ_LT ( tp -> rcv_lastsack , sack . start ) ) { temp = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( temp == NULL ) goto done ; temp -> start = tp -> rcv_lastsack ; temp -> end = sack . start ; temp -> dups = min ( tcprexmtthresh , ( ( sack . end - sack . start ) / tp -> t_maxseg ) ) ; if ( temp -> dups < 1 ) temp -> dups = 1 ; temp -> rxmit = temp -> start ; temp -> next = 0 ; p -> next = temp ; tp -> rcv_lastsack = sack . end ; tp -> snd_numholes ++ ; } } done : return ; }\n", "\n", "1: CWE-000 void tcp_sack_option ( struct tcpcb * tp , struct tcphdr * th , u_char * cp , int optlen ) { int tmp_olen ; u_char * tmp_cp ; struct sackhole * cur , * p , * temp ; if ( ! tp -> sack_enable ) return ; if ( ( th -> th_flags & TH_ACK ) == 0 ) return ; if ( SEQ_LT ( th -> th_ack , tp -> snd_una ) || SEQ_GT ( th -> th_ack , tp -> snd_max ) ) return ; if ( optlen <= 2 || ( optlen - 2 ) % TCPOLEN_SACK != 0 ) return ; tmp_cp = cp + 2 ; tmp_olen = optlen - 2 ; tcpstat_inc ( tcps_sack_rcv_opts ) ; if ( tp -> snd_numholes < 0 ) tp -> snd_numholes = 0 ; if ( tp -> t_maxseg == 0 ) panic ( \"tcp_sack_option\" ) ; while ( tmp_olen > 0 ) { struct sackblk sack ; memcpy ( & sack . start , tmp_cp , sizeof ( tcp_seq ) ) ; sack . start = ntohl ( sack . start ) ; memcpy ( & sack . end , tmp_cp + sizeof ( tcp_seq ) , sizeof ( tcp_seq ) ) ; sack . end = ntohl ( sack . end ) ; tmp_olen -= TCPOLEN_SACK ; tmp_cp += TCPOLEN_SACK ; if ( SEQ_LEQ ( sack . end , sack . start ) ) continue ; if ( SEQ_LEQ ( sack . end , tp -> snd_una ) ) continue ; if ( SEQ_GT ( th -> th_ack , tp -> snd_una ) ) { if ( SEQ_LT ( sack . start , th -> th_ack ) ) continue ; } if ( SEQ_GT ( sack . end , tp -> snd_max ) ) continue ; if ( tp -> snd_holes == NULL ) { tp -> snd_holes = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( tp -> snd_holes == NULL ) { goto done ; } cur = tp -> snd_holes ; cur -> start = th -> th_ack ; cur -> end = sack . start ; cur -> rxmit = cur -> start ; cur -> next = NULL ; tp -> snd_numholes = 1 ; tp -> rcv_lastsack = sack . end ; cur -> dups = min ( tcprexmtthresh , ( ( sack . end - cur -> end ) / tp -> t_maxseg ) ) ; if ( cur -> dups < 1 ) cur -> dups = 1 ; continue ; } p = cur = tp -> snd_holes ; while ( cur ) { if ( SEQ_LEQ ( sack . end , cur -> start ) ) break ; if ( SEQ_GEQ ( sack . start , cur -> end ) ) { cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_LEQ ( sack . start , cur -> start ) ) { if ( SEQ_GEQ ( sack . end , cur -> end ) ) { if ( p != cur ) { p -> next = cur -> next ; pool_put ( & sackhl_pool , cur ) ; cur = p -> next ; } else { cur = cur -> next ; pool_put ( & sackhl_pool , p ) ; p = cur ; tp -> snd_holes = p ; } tp -> snd_numholes -- ; continue ; } cur -> start = sack . end ; cur -> rxmit = SEQ_MAX ( cur -> rxmit , cur -> start ) ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_GEQ ( sack . end , cur -> end ) ) { cur -> end = sack . start ; cur -> rxmit = SEQ_MIN ( cur -> rxmit , cur -> end ) ; cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; p = cur ; cur = cur -> next ; continue ; } if ( SEQ_LT ( cur -> start , sack . start ) && SEQ_GT ( cur -> end , sack . end ) ) { temp = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( temp == NULL ) goto done ; temp -> next = cur -> next ; temp -> start = sack . end ; temp -> end = cur -> end ; temp -> dups = cur -> dups ; temp -> rxmit = SEQ_MAX ( cur -> rxmit , temp -> start ) ; cur -> end = sack . start ; cur -> rxmit = SEQ_MIN ( cur -> rxmit , cur -> end ) ; cur -> dups ++ ; if ( ( ( sack . end - cur -> end ) / tp -> t_maxseg ) >= tcprexmtthresh ) cur -> dups = tcprexmtthresh ; cur -> next = temp ; p = temp ; cur = p -> next ; tp -> snd_numholes ++ ; } } if ( SEQ_LT ( tp -> rcv_lastsack , sack . start ) ) { temp = ( struct sackhole * ) pool_get ( & sackhl_pool , PR_NOWAIT ) ; if ( temp == NULL ) goto done ; temp -> start = tp -> rcv_lastsack ; temp -> end = sack . start ; temp -> dups = min ( tcprexmtthresh , ( ( sack . end - sack . start ) / tp -> t_maxseg ) ) ; if ( temp -> dups < 1 ) temp -> dups = 1 ; temp -> rxmit = temp -> start ; temp -> next = 0 ; p -> next = temp ; tp -> rcv_lastsack = sack . end ; tp -> snd_numholes ++ ; } } done : return ; }\n", "\n", "\n", "Target: = 0 ; size_t data_size = 0 ; , & buf_size , & data_size OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( data_size > OE_SSIZE_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( ret > ( ssize_t ) data_size ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; }\n", "\n", "Sources:\n", "0: CWE-552 static ssize_t _consolefs_writev ( oe_fd_t * desc , const struct oe_iovec * iov , int iovcnt ) { ssize_t ret = - 1 ; file_t * file = _cast_file ( desc ) ; void * buf = NULL ; size_t buf_size = 0 ; if ( ! file || ( ! iov && iovcnt ) || iovcnt < 0 || iovcnt > OE_IOV_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_iov_pack ( iov , iovcnt , & buf , & buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( oe_syscall_writev_ocall ( & ret , file -> host_fd , buf , iovcnt , buf_size ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : if ( buf ) oe_free ( buf ) ; return ret ; }\n", "\n", "1: CWE-552 static ssize_t _epoll_writev ( oe_fd_t * desc , const struct oe_iovec * iov , int iovcnt ) { ssize_t ret = - 1 ; epoll_t * file = _cast_epoll ( desc ) ; void * buf = NULL ; size_t buf_size = 0 ; if ( ! file || ( iovcnt && ! iov ) || iovcnt < 0 || iovcnt > OE_IOV_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_iov_pack ( iov , iovcnt , & buf , & buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( oe_syscall_writev_ocall ( & ret , file -> host_fd , buf , iovcnt , buf_size ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : if ( buf ) oe_free ( buf ) ; return ret ; }\n", "\n", "\n", "Target: -> id ; if ( id . index > UINT_MAX - kcontrol -> count ) goto error ;\n", "\n", "Sources:\n", "0: CWE-190 int snd_ctl_add ( struct snd_card * card , struct snd_kcontrol * kcontrol ) { struct snd_ctl_elem_id id ; unsigned int idx ; unsigned int count ; int err = - EINVAL ; if ( ! kcontrol ) return err ; if ( snd_BUG_ON ( ! card || ! kcontrol -> info ) ) goto error ; id = kcontrol -> id ; down_write ( & card -> controls_rwsem ) ; if ( snd_ctl_find_id ( card , & id ) ) { up_write ( & card -> controls_rwsem ) ; dev_err ( card -> dev , \"control%i:%i:%i:%s:%iisalreadypresent\\\\n\" , id . iface , id . device , id . subdevice , id . name , id . index ) ; err = - EBUSY ; goto error ; } if ( snd_ctl_find_hole ( card , kcontrol -> count ) < 0 ) { up_write ( & card -> controls_rwsem ) ; err = - ENOMEM ; goto error ; } list_add_tail ( & kcontrol -> list , & card -> controls ) ; card -> controls_count += kcontrol -> count ; kcontrol -> id . numid = card -> last_numid + 1 ; card -> last_numid += kcontrol -> count ; count = kcontrol -> count ; up_write ( & card -> controls_rwsem ) ; for ( idx = 0 ; idx < count ; idx ++ , id . index ++ , id . numid ++ ) snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_ADD , & id ) ; return 0 ; error : snd_ctl_free_one ( kcontrol ) ; return err ; }\n", "\n", "1: CWE-189 int snd_ctl_add ( struct snd_card * card , struct snd_kcontrol * kcontrol ) { struct snd_ctl_elem_id id ; unsigned int idx ; unsigned int count ; int err = - EINVAL ; if ( ! kcontrol ) return err ; if ( snd_BUG_ON ( ! card || ! kcontrol -> info ) ) goto error ; id = kcontrol -> id ; down_write ( & card -> controls_rwsem ) ; if ( snd_ctl_find_id ( card , & id ) ) { up_write ( & card -> controls_rwsem ) ; dev_err ( card -> dev , \"control%i:%i:%i:%s:%iisalreadypresent\\\\n\" , id . iface , id . device , id . subdevice , id . name , id . index ) ; err = - EBUSY ; goto error ; } if ( snd_ctl_find_hole ( card , kcontrol -> count ) < 0 ) { up_write ( & card -> controls_rwsem ) ; err = - ENOMEM ; goto error ; } list_add_tail ( & kcontrol -> list , & card -> controls ) ; card -> controls_count += kcontrol -> count ; kcontrol -> id . numid = card -> last_numid + 1 ; card -> last_numid += kcontrol -> count ; count = kcontrol -> count ; up_write ( & card -> controls_rwsem ) ; for ( idx = 0 ; idx < count ; idx ++ , id . index ++ , id . numid ++ ) snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_ADD , & id ) ; return 0 ; error : snd_ctl_free_one ( kcontrol ) ; return err ; }\n", "\n", "\n", "Target: ( size_t ) floor ( size_t ) floor ( size_t ) floor ( size_t ) floor ( size_t ) floor\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadLABELImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char geometry [ MaxTextExtent ] , * property ; const char * label ; DrawInfo * draw_info ; Image * image ; MagickBooleanType status ; TypeMetric metrics ; size_t height , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; ( void ) ResetImagePage ( image , \"0x0+0+0\" ) ; property = InterpretImageProperties ( image_info , image , image_info -> filename ) ; ( void ) SetImageProperty ( image , \"label\" , property ) ; property = DestroyString ( property ) ; label = GetImageProperty ( image , \"label\" ) ; draw_info = CloneDrawInfo ( image_info , ( DrawInfo * ) NULL ) ; draw_info -> text = ConstantString ( label ) ; metrics . width = 0 ; metrics . ascent = 0.0 ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; if ( ( image -> columns == 0 ) && ( image -> rows == 0 ) ) { image -> columns = ( size_t ) ( metrics . width + draw_info -> stroke_width + 0.5 ) ; image -> rows = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; } else if ( ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) || ( fabs ( image_info -> pointsize ) < MagickEpsilon ) ) { double high , low ; for ( ; ; draw_info -> pointsize *= 2.0 ) { ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width >= image -> columns ) && ( height >= image -> rows ) ) break ; } else if ( ( ( image -> columns != 0 ) && ( width >= image -> columns ) ) || ( ( image -> rows != 0 ) && ( height >= image -> rows ) ) ) break ; } high = draw_info -> pointsize ; for ( low = 1.0 ; ( high - low ) > 0.5 ; ) { draw_info -> pointsize = ( low + high ) / 2.0 ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width < image -> columns ) && ( height < image -> rows ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } else if ( ( ( image -> columns != 0 ) && ( width < image -> columns ) ) || ( ( image -> rows != 0 ) && ( height < image -> rows ) ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } draw_info -> pointsize = ( low + high ) / 2.0 - 0.5 ; } status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( image -> columns == 0 ) image -> columns = ( size_t ) ( metrics . width + draw_info -> stroke_width + 0.5 ) ; if ( image -> columns == 0 ) image -> columns = ( size_t ) ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) ( metrics . ascent - metrics . descent + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( SetImageBackgroundColor ( image ) == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%+g%+g\" , draw_info -> direction == RightToLeftDirection ? image -> columns - metrics . bounds . x2 : 0.0 , draw_info -> gravity == UndefinedGravity ? metrics . ascent : 0.0 ) ; draw_info -> geometry = AcquireString ( geometry ) ; status = AnnotateImage ( image , draw_info ) ; if ( image_info -> pointsize == 0.0 ) { char pointsize [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pointsize , MaxTextExtent , \"%.20g\" , draw_info -> pointsize ) ; ( void ) SetImageProperty ( image , \"label:pointsize\" , pointsize ) ; } draw_info = DestroyDrawInfo ( draw_info ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-120 static Image * ReadLABELImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char geometry [ MagickPathExtent ] , * property ; const char * label ; DrawInfo * draw_info ; Image * image ; MagickBooleanType status ; TypeMetric metrics ; size_t height , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; ( void ) ResetImagePage ( image , \"0x0+0+0\" ) ; property = InterpretImageProperties ( ( ImageInfo * ) image_info , image , image_info -> filename , exception ) ; ( void ) SetImageProperty ( image , \"label\" , property , exception ) ; property = DestroyString ( property ) ; label = GetImageProperty ( image , \"label\" , exception ) ; draw_info = CloneDrawInfo ( image_info , ( DrawInfo * ) NULL ) ; draw_info -> text = ConstantString ( label ) ; metrics . width = 0 ; metrics . ascent = 0.0 ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics , exception ) ; if ( ( image -> columns == 0 ) && ( image -> rows == 0 ) ) { image -> columns = ( size_t ) ( metrics . width + draw_info -> stroke_width + 0.5 ) ; image -> rows = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; } else if ( ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) || ( fabs ( image_info -> pointsize ) < MagickEpsilon ) ) { double high , low ; for ( ; ; draw_info -> pointsize *= 2.0 ) { ( void ) FormatLocaleString ( geometry , MagickPathExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics , exception ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width >= image -> columns ) && ( height >= image -> rows ) ) break ; } else if ( ( ( image -> columns != 0 ) && ( width >= image -> columns ) ) || ( ( image -> rows != 0 ) && ( height >= image -> rows ) ) ) break ; } high = draw_info -> pointsize ; for ( low = 1.0 ; ( high - low ) > 0.5 ; ) { draw_info -> pointsize = ( low + high ) / 2.0 ; ( void ) FormatLocaleString ( geometry , MagickPathExtent , \"%+g%+g\" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics , exception ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width < image -> columns ) && ( height < image -> rows ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } else if ( ( ( image -> columns != 0 ) && ( width < image -> columns ) ) || ( ( image -> rows != 0 ) && ( height < image -> rows ) ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } draw_info -> pointsize = ( low + high ) / 2.0 - 0.5 ; } status = GetMultilineTypeMetrics ( image , draw_info , & metrics , exception ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( image -> columns == 0 ) image -> columns = ( size_t ) ( metrics . width + draw_info -> stroke_width + 0.5 ) ; if ( image -> columns == 0 ) image -> columns = ( size_t ) ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) ( metrics . ascent - metrics . descent + draw_info -> stroke_width + 0.5 ) ; if ( image -> rows == 0 ) image -> rows = ( size_t ) ( draw_info -> pointsize + draw_info -> stroke_width + 0.5 ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; return ( DestroyImageList ( image ) ) ; } if ( SetImageBackgroundColor ( image , exception ) == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) FormatLocaleString ( geometry , MagickPathExtent , \"%+g%+g\" , draw_info -> direction == RightToLeftDirection ? image -> columns - metrics . bounds . x2 : 0.0 , draw_info -> gravity == UndefinedGravity ? metrics . ascent : 0.0 ) ; draw_info -> geometry = AcquireString ( geometry ) ; status = AnnotateImage ( image , draw_info , exception ) ; if ( image_info -> pointsize == 0.0 ) { char pointsize [ MagickPathExtent ] ; ( void ) FormatLocaleString ( pointsize , MagickPathExtent , \"%.20g\" , draw_info -> pointsize ) ; ( void ) SetImageProperty ( image , \"label:pointsize\" , pointsize , exception ) ; } draw_info = DestroyDrawInfo ( draw_info ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ( dev ) ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING\n", "\n", "Sources:\n", "0: CWE-264 static void veth_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & veth_netdev_ops ; dev -> ethtool_ops = & veth_ethtool_ops ; dev -> features |= NETIF_F_LLTX ; dev -> destructor = veth_dev_free ; dev -> hw_features = NETIF_F_NO_CSUM | NETIF_F_SG | NETIF_F_RXCSUM ; }\n", "\n", "1: CWE-000 void hostap_setup_dev ( struct net_device * dev , local_info_t * local , int type ) { struct hostap_interface * iface ; iface = netdev_priv ( dev ) ; ether_setup ( dev ) ; if ( iface ) { iface -> wireless_data . spy_data = & iface -> spy_data ; dev -> wireless_data = & iface -> wireless_data ; } dev -> wireless_handlers = & hostap_iw_handler_def ; dev -> watchdog_timeo = TX_TIMEOUT ; switch ( type ) { case HOSTAP_INTERFACE_AP : dev -> tx_queue_len = 0 ; dev -> netdev_ops = & hostap_mgmt_netdev_ops ; dev -> type = ARPHRD_IEEE80211 ; dev -> header_ops = & hostap_80211_ops ; break ; case HOSTAP_INTERFACE_MASTER : dev -> netdev_ops = & hostap_master_ops ; break ; default : dev -> tx_queue_len = 0 ; dev -> netdev_ops = & hostap_netdev_ops ; } dev -> mtu = local -> mtu ; SET_ETHTOOL_OPS ( dev , & prism2_ethtool_ops ) ; }\n", "\n", "2: CWE-000 static void veth_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & veth_netdev_ops ; dev -> ethtool_ops = & veth_ethtool_ops ; dev -> features |= NETIF_F_LLTX ; dev -> destructor = veth_dev_free ; dev -> hw_features = NETIF_F_NO_CSUM | NETIF_F_SG | NETIF_F_RXCSUM ; }\n", "\n", "3: CWE-264 void hostap_setup_dev ( struct net_device * dev , local_info_t * local , int type ) { struct hostap_interface * iface ; iface = netdev_priv ( dev ) ; ether_setup ( dev ) ; if ( iface ) { iface -> wireless_data . spy_data = & iface -> spy_data ; dev -> wireless_data = & iface -> wireless_data ; } dev -> wireless_handlers = & hostap_iw_handler_def ; dev -> watchdog_timeo = TX_TIMEOUT ; switch ( type ) { case HOSTAP_INTERFACE_AP : dev -> tx_queue_len = 0 ; dev -> netdev_ops = & hostap_mgmt_netdev_ops ; dev -> type = ARPHRD_IEEE80211 ; dev -> header_ops = & hostap_80211_ops ; break ; case HOSTAP_INTERFACE_MASTER : dev -> netdev_ops = & hostap_master_ops ; break ; default : dev -> tx_queue_len = 0 ; dev -> netdev_ops = & hostap_netdev_ops ; } dev -> mtu = local -> mtu ; SET_ETHTOOL_OPS ( dev , & prism2_ethtool_ops ) ; }\n", "\n", "\n", "Target: ) exit_io_context ( tsk\n", "\n", "Sources:\n", "0: CWE-20 NORET_TYPE void do_exit ( long code ) { struct task_struct * tsk = current ; int group_dead ; profile_task_exit ( tsk ) ; WARN_ON ( atomic_read ( & tsk -> fs_excl ) ) ; if ( unlikely ( in_interrupt ( ) ) ) panic ( \"Aiee,killinginterrupthandler!\" ) ; if ( unlikely ( ! tsk -> pid ) ) panic ( \"Attemptedtokilltheidletask!\" ) ; tracehook_report_exit ( & code ) ; validate_creds_for_do_exit ( tsk ) ; if ( unlikely ( tsk -> flags & PF_EXITING ) ) { printk ( KERN_ALERT \"Fixingrecursivefaultbutrebootisneeded!\\\\n\" ) ; tsk -> flags |= PF_EXITPIDONE ; set_current_state ( TASK_UNINTERRUPTIBLE ) ; schedule ( ) ; } exit_irq_thread ( ) ; exit_signals ( tsk ) ; smp_mb ( ) ; spin_unlock_wait ( & tsk -> pi_lock ) ; if ( unlikely ( in_atomic ( ) ) ) printk ( KERN_INFO \"note:%s[%d]exitedwithpreempt_count%d\\\\n\" , current -> comm , task_pid_nr ( current ) , preempt_count ( ) ) ; acct_update_integrals ( tsk ) ; group_dead = atomic_dec_and_test ( & tsk -> signal -> live ) ; if ( group_dead ) { hrtimer_cancel ( & tsk -> signal -> real_timer ) ; exit_itimers ( tsk -> signal ) ; if ( tsk -> mm ) setmax_mm_hiwater_rss ( & tsk -> signal -> maxrss , tsk -> mm ) ; } acct_collect ( code , group_dead ) ; if ( group_dead ) tty_audit_exit ( ) ; if ( unlikely ( tsk -> audit_context ) ) audit_free ( tsk ) ; tsk -> exit_code = code ; taskstats_exit ( tsk , group_dead ) ; exit_mm ( tsk ) ; if ( group_dead ) acct_process ( ) ; trace_sched_process_exit ( tsk ) ; exit_sem ( tsk ) ; exit_files ( tsk ) ; exit_fs ( tsk ) ; check_stack_usage ( ) ; exit_thread ( ) ; cgroup_exit ( tsk , 1 ) ; if ( group_dead && tsk -> signal -> leader ) disassociate_ctty ( 1 ) ; module_put ( task_thread_info ( tsk ) -> exec_domain -> module ) ; proc_exit_connector ( tsk ) ; perf_event_exit_task ( tsk ) ; exit_notify ( tsk , group_dead ) ; # ifdef CONFIG_NUMA mpol_put ( tsk -> mempolicy ) ; tsk -> mempolicy = NULL ; # endif # ifdef CONFIG_FUTEX if ( unlikely ( current -> pi_state_cache ) ) kfree ( current -> pi_state_cache ) ; # endif debug_check_no_locks_held ( tsk ) ; tsk -> flags |= PF_EXITPIDONE ; if ( tsk -> io_context ) exit_io_context ( ) ; if ( tsk -> splice_pipe ) __free_pipe_info ( tsk -> splice_pipe ) ; validate_creds_for_do_exit ( tsk ) ; preempt_disable ( ) ; exit_rcu ( ) ; tsk -> state = TASK_DEAD ; schedule ( ) ; BUG ( ) ; for ( ; ; ) cpu_relax ( ) ; }\n", "\n", "1: CWE-400 NORET_TYPE void do_exit ( long code ) { struct task_struct * tsk = current ; int group_dead ; profile_task_exit ( tsk ) ; WARN_ON ( atomic_read ( & tsk -> fs_excl ) ) ; if ( unlikely ( in_interrupt ( ) ) ) panic ( \"Aiee,killinginterrupthandler!\" ) ; if ( unlikely ( ! tsk -> pid ) ) panic ( \"Attemptedtokilltheidletask!\" ) ; tracehook_report_exit ( & code ) ; validate_creds_for_do_exit ( tsk ) ; if ( unlikely ( tsk -> flags & PF_EXITING ) ) { printk ( KERN_ALERT \"Fixingrecursivefaultbutrebootisneeded!\\\\n\" ) ; tsk -> flags |= PF_EXITPIDONE ; set_current_state ( TASK_UNINTERRUPTIBLE ) ; schedule ( ) ; } exit_irq_thread ( ) ; exit_signals ( tsk ) ; smp_mb ( ) ; spin_unlock_wait ( & tsk -> pi_lock ) ; if ( unlikely ( in_atomic ( ) ) ) printk ( KERN_INFO \"note:%s[%d]exitedwithpreempt_count%d\\\\n\" , current -> comm , task_pid_nr ( current ) , preempt_count ( ) ) ; acct_update_integrals ( tsk ) ; group_dead = atomic_dec_and_test ( & tsk -> signal -> live ) ; if ( group_dead ) { hrtimer_cancel ( & tsk -> signal -> real_timer ) ; exit_itimers ( tsk -> signal ) ; if ( tsk -> mm ) setmax_mm_hiwater_rss ( & tsk -> signal -> maxrss , tsk -> mm ) ; } acct_collect ( code , group_dead ) ; if ( group_dead ) tty_audit_exit ( ) ; if ( unlikely ( tsk -> audit_context ) ) audit_free ( tsk ) ; tsk -> exit_code = code ; taskstats_exit ( tsk , group_dead ) ; exit_mm ( tsk ) ; if ( group_dead ) acct_process ( ) ; trace_sched_process_exit ( tsk ) ; exit_sem ( tsk ) ; exit_files ( tsk ) ; exit_fs ( tsk ) ; check_stack_usage ( ) ; exit_thread ( ) ; cgroup_exit ( tsk , 1 ) ; if ( group_dead && tsk -> signal -> leader ) disassociate_ctty ( 1 ) ; module_put ( task_thread_info ( tsk ) -> exec_domain -> module ) ; proc_exit_connector ( tsk ) ; perf_event_exit_task ( tsk ) ; exit_notify ( tsk , group_dead ) ; # ifdef CONFIG_NUMA mpol_put ( tsk -> mempolicy ) ; tsk -> mempolicy = NULL ; # endif # ifdef CONFIG_FUTEX if ( unlikely ( current -> pi_state_cache ) ) kfree ( current -> pi_state_cache ) ; # endif debug_check_no_locks_held ( tsk ) ; tsk -> flags |= PF_EXITPIDONE ; if ( tsk -> io_context ) exit_io_context ( ) ; if ( tsk -> splice_pipe ) __free_pipe_info ( tsk -> splice_pipe ) ; validate_creds_for_do_exit ( tsk ) ; preempt_disable ( ) ; exit_rcu ( ) ; tsk -> state = TASK_DEAD ; schedule ( ) ; BUG ( ) ; for ( ; ; ) cpu_relax ( ) ; }\n", "\n", "\n", "Target: char buf [ L_BUFSIZE ] ; char ( fp , \"Rootname:%511s\\\\n\" , buf ) ( buf , L_BUFSIZE , fp ) ( buf , L_BUFSIZE , fp ) ( buf , L_BUFSIZE , fp ) ( fp , \"Commandfilename:%511s\\\\n\" , buf ) ( fp , \"Outputfilename:%511s\\\\n\" , buf )\n", "\n", "Sources:\n", "0: CWE-119 GPLOT * gplotRead ( const char * filename ) { char buf [ L_BUF_SIZE ] ; char * rootname , * title , * xlabel , * ylabel , * ignores ; l_int32 outformat , ret , version , ignore ; FILE * fp ; GPLOT * gplot ; PROCNAME ( \"gplotRead\" ) ; if ( ! filename ) return ( GPLOT * ) ERROR_PTR ( \"filenamenotdefined\" , procName , NULL ) ; if ( ( fp = fopenReadStream ( filename ) ) == NULL ) return ( GPLOT * ) ERROR_PTR ( \"streamnotopened\" , procName , NULL ) ; ret = fscanf ( fp , \"GplotVersion%d\\\\n\" , & version ) ; if ( ret != 1 ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"notagplotfile\" , procName , NULL ) ; } if ( version != GPLOT_VERSION_NUMBER ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"invalidgplotversion\" , procName , NULL ) ; } ignore = fscanf ( fp , \"Rootname:%s\\\\n\" , buf ) ; rootname = stringNew ( buf ) ; ignore = fscanf ( fp , \"Outputformat:%d\\\\n\" , & outformat ) ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; title = stringNew ( buf + 7 ) ; title [ strlen ( title ) - 1 ] = '\\\\0' ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; xlabel = stringNew ( buf + 14 ) ; xlabel [ strlen ( xlabel ) - 1 ] = '\\\\0' ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; ylabel = stringNew ( buf + 14 ) ; ylabel [ strlen ( ylabel ) - 1 ] = '\\\\0' ; gplot = gplotCreate ( rootname , outformat , title , xlabel , ylabel ) ; LEPT_FREE ( rootname ) ; LEPT_FREE ( title ) ; LEPT_FREE ( xlabel ) ; LEPT_FREE ( ylabel ) ; if ( ! gplot ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"gplotnotmade\" , procName , NULL ) ; } sarrayDestroy ( & gplot -> cmddata ) ; sarrayDestroy ( & gplot -> datanames ) ; sarrayDestroy ( & gplot -> plotdata ) ; sarrayDestroy ( & gplot -> plottitles ) ; numaDestroy ( & gplot -> plotstyles ) ; ignore = fscanf ( fp , \"Commandfilename:%s\\\\n\" , buf ) ; stringReplace ( & gplot -> cmdname , buf ) ; ignore = fscanf ( fp , \"\\\\nCommandfiledata:\" ) ; gplot -> cmddata = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nDatafilenames:\" ) ; gplot -> datanames = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlotdata:\" ) ; gplot -> plotdata = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlottitles:\" ) ; gplot -> plottitles = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlotstyles:\" ) ; gplot -> plotstyles = numaReadStream ( fp ) ; ignore = fscanf ( fp , \"Numberofplots:%d\\\\n\" , & gplot -> nplots ) ; ignore = fscanf ( fp , \"Outputfilename:%s\\\\n\" , buf ) ; stringReplace ( & gplot -> outname , buf ) ; ignore = fscanf ( fp , \"Axisscaling:%d\\\\n\" , & gplot -> scaling ) ; fclose ( fp ) ; return gplot ; }\n", "\n", "1: CWE-787 GPLOT * gplotRead ( const char * filename ) { char buf [ L_BUF_SIZE ] ; char * rootname , * title , * xlabel , * ylabel , * ignores ; l_int32 outformat , ret , version , ignore ; FILE * fp ; GPLOT * gplot ; PROCNAME ( \"gplotRead\" ) ; if ( ! filename ) return ( GPLOT * ) ERROR_PTR ( \"filenamenotdefined\" , procName , NULL ) ; if ( ( fp = fopenReadStream ( filename ) ) == NULL ) return ( GPLOT * ) ERROR_PTR ( \"streamnotopened\" , procName , NULL ) ; ret = fscanf ( fp , \"GplotVersion%d\\\\n\" , & version ) ; if ( ret != 1 ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"notagplotfile\" , procName , NULL ) ; } if ( version != GPLOT_VERSION_NUMBER ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"invalidgplotversion\" , procName , NULL ) ; } ignore = fscanf ( fp , \"Rootname:%s\\\\n\" , buf ) ; rootname = stringNew ( buf ) ; ignore = fscanf ( fp , \"Outputformat:%d\\\\n\" , & outformat ) ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; title = stringNew ( buf + 7 ) ; title [ strlen ( title ) - 1 ] = '\\\\0' ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; xlabel = stringNew ( buf + 14 ) ; xlabel [ strlen ( xlabel ) - 1 ] = '\\\\0' ; ignores = fgets ( buf , L_BUF_SIZE , fp ) ; ylabel = stringNew ( buf + 14 ) ; ylabel [ strlen ( ylabel ) - 1 ] = '\\\\0' ; gplot = gplotCreate ( rootname , outformat , title , xlabel , ylabel ) ; LEPT_FREE ( rootname ) ; LEPT_FREE ( title ) ; LEPT_FREE ( xlabel ) ; LEPT_FREE ( ylabel ) ; if ( ! gplot ) { fclose ( fp ) ; return ( GPLOT * ) ERROR_PTR ( \"gplotnotmade\" , procName , NULL ) ; } sarrayDestroy ( & gplot -> cmddata ) ; sarrayDestroy ( & gplot -> datanames ) ; sarrayDestroy ( & gplot -> plotdata ) ; sarrayDestroy ( & gplot -> plottitles ) ; numaDestroy ( & gplot -> plotstyles ) ; ignore = fscanf ( fp , \"Commandfilename:%s\\\\n\" , buf ) ; stringReplace ( & gplot -> cmdname , buf ) ; ignore = fscanf ( fp , \"\\\\nCommandfiledata:\" ) ; gplot -> cmddata = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nDatafilenames:\" ) ; gplot -> datanames = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlotdata:\" ) ; gplot -> plotdata = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlottitles:\" ) ; gplot -> plottitles = sarrayReadStream ( fp ) ; ignore = fscanf ( fp , \"\\\\nPlotstyles:\" ) ; gplot -> plotstyles = numaReadStream ( fp ) ; ignore = fscanf ( fp , \"Numberofplots:%d\\\\n\" , & gplot -> nplots ) ; ignore = fscanf ( fp , \"Outputfilename:%s\\\\n\" , buf ) ; stringReplace ( & gplot -> outname , buf ) ; ignore = fscanf ( fp , \"Axisscaling:%d\\\\n\" , & gplot -> scaling ) ; fclose ( fp ) ; return gplot ; }\n", "\n", "\n", "Target: account . user , false account . pass , false\n", "\n", "Sources:\n", "0: CWE-78 enum ImapAuthRes imap_auth_login ( struct ImapData * idata , const char * method ) { char q_user [ SHORT_STRING ] , q_pass [ SHORT_STRING ] ; char buf [ STRING ] ; int rc ; if ( mutt_bit_isset ( idata -> capabilities , LOGINDISABLED ) ) { mutt_message ( _ ( \"LOGINdisabledonthisserver.\" ) ) ; return IMAP_AUTH_UNAVAIL ; } if ( mutt_account_getuser ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; if ( mutt_account_getpass ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; mutt_message ( _ ( \"Loggingin...\" ) ) ; imap_quote_string ( q_user , sizeof ( q_user ) , idata -> conn -> account . user ) ; imap_quote_string ( q_pass , sizeof ( q_pass ) , idata -> conn -> account . pass ) ; if ( DebugLevel < IMAP_LOG_PASS ) mutt_debug ( 2 , \"SendingLOGINcommandfor%s...\\\\n\" , idata -> conn -> account . user ) ; snprintf ( buf , sizeof ( buf ) , \"LOGIN%s%s\" , q_user , q_pass ) ; rc = imap_exec ( idata , buf , IMAP_CMD_FAIL_OK | IMAP_CMD_PASS ) ; if ( ! rc ) { mutt_clear_error ( ) ; return IMAP_AUTH_SUCCESS ; } mutt_error ( _ ( \"Loginfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "1: CWE-77 enum ImapAuthRes imap_auth_login ( struct ImapData * idata , const char * method ) { char q_user [ SHORT_STRING ] , q_pass [ SHORT_STRING ] ; char buf [ STRING ] ; int rc ; if ( mutt_bit_isset ( idata -> capabilities , LOGINDISABLED ) ) { mutt_message ( _ ( \"LOGINdisabledonthisserver.\" ) ) ; return IMAP_AUTH_UNAVAIL ; } if ( mutt_account_getuser ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; if ( mutt_account_getpass ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; mutt_message ( _ ( \"Loggingin...\" ) ) ; imap_quote_string ( q_user , sizeof ( q_user ) , idata -> conn -> account . user ) ; imap_quote_string ( q_pass , sizeof ( q_pass ) , idata -> conn -> account . pass ) ; if ( DebugLevel < IMAP_LOG_PASS ) mutt_debug ( 2 , \"SendingLOGINcommandfor%s...\\\\n\" , idata -> conn -> account . user ) ; snprintf ( buf , sizeof ( buf ) , \"LOGIN%s%s\" , q_user , q_pass ) ; rc = imap_exec ( idata , buf , IMAP_CMD_FAIL_OK | IMAP_CMD_PASS ) ; if ( ! rc ) { mutt_clear_error ( ) ; return IMAP_AUTH_SUCCESS ; } mutt_error ( _ ( \"Loginfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "\n", "Target: void usage_exit ( void\n", "\n", "Sources:\n", "0: CWE-119 void usage_exit ( ) { fprintf ( stderr , \"Usage:%s\\\\n\" , exec_name ) ; exit ( EXIT_FAILURE ) ; }\n", "\n", "1: CWE-119 void usage_exit ( ) { fprintf ( stderr , \"Usage:%s\\\\n\" , exec_name ) ; exit ( EXIT_FAILURE ) ; }\n", "\n", "2: CWE-119 void usage_exit ( ) { fprintf ( stderr , \"Usage:%s\\\\n\" , exec_name ) ; exit ( EXIT_FAILURE ) ; }\n", "\n", "3: CWE-119 void usage_exit ( ) { fprintf ( stderr , \"Usage:%s\" \"[]\\\\nSeecommentsin\" \"simple_encoder.cformoreinformation.\\\\n\" , exec_name ) ; exit ( EXIT_FAILURE ) ; }\n", "\n", "4: CWE-119 void usage_exit ( ) { fprintf ( stderr , \"Usage:%s\\\\n\" , exec_name ) ; exit ( EXIT_FAILURE ) ; }\n", "\n", "\n", "Target: u_char * dat , u_int length ) dat ; if ( length < 2 ) { ND_PRINT ( ( ndo , \"AVPtooshort\" ) ) ; return ; }\n", "\n", "Sources:\n", "0: CWE-125 static void l2tp_msgtype_print ( netdissect_options * ndo , const u_char * dat ) { const uint16_t * ptr = ( const uint16_t * ) dat ; ND_PRINT ( ( ndo , \"%s\" , tok2str ( l2tp_msgtype2str , \"MSGTYPE-#%u\" , EXTRACT_16BITS ( ptr ) ) ) ) ; }\n", "\n", "1: CWE-125 static void l2tp_proxy_auth_type_print ( netdissect_options * ndo , const u_char * dat ) { const uint16_t * ptr = ( const uint16_t * ) dat ; ND_PRINT ( ( ndo , \"%s\" , tok2str ( l2tp_authentype2str , \"AuthType-#%u\" , EXTRACT_16BITS ( ptr ) ) ) ) ; }\n", "\n", "\n", "Target: 1 ] ; return NULL ;\n", "\n", "Sources:\n", "0: CWE-119 static float * get_window ( vorb * f , int len ) { len <<= 1 ; if ( len == f -> blocksize_0 ) return f -> window [ 0 ] ; if ( len == f -> blocksize_1 ) return f -> window [ 1 ] ; assert ( 0 ) ; return NULL ; }\n", "\n", "1: CWE-617 static float * get_window ( vorb * f , int len ) { len <<= 1 ; if ( len == f -> blocksize_0 ) return f -> window [ 0 ] ; if ( len == f -> blocksize_1 ) return f -> window [ 1 ] ; assert ( 0 ) ; return NULL ; }\n", "\n", "\n", "Target: len = 0 ; luaL_checkstack ( L , 3 , \"infunctionmp_encode_lua_table_as_map\" )\n", "\n", "Sources:\n", "0: CWE-787 void mp_encode_lua_table_as_map ( lua_State * L , mp_buf * buf , int level ) { size_t len = 0 ; lua_pushnil ( L ) ; while ( lua_next ( L , - 2 ) ) { lua_pop ( L , 1 ) ; len ++ ; } mp_encode_map ( L , buf , len ) ; lua_pushnil ( L ) ; while ( lua_next ( L , - 2 ) ) { lua_pushvalue ( L , - 2 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; } }\n", "\n", "1: CWE-119 void mp_encode_lua_table_as_map ( lua_State * L , mp_buf * buf , int level ) { size_t len = 0 ; lua_pushnil ( L ) ; while ( lua_next ( L , - 2 ) ) { lua_pop ( L , 1 ) ; len ++ ; } mp_encode_map ( L , buf , len ) ; lua_pushnil ( L ) ; while ( lua_next ( L , - 2 ) ) { lua_pushvalue ( L , - 2 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; } }\n", "\n", "\n", "Target: * tmpname , const char * dir , const char * prefix * localtmp ; const , rc ; tmpenv = dir tmpenv = dir ? dir : getenv ( \"TMPDIR\" ; if ( ! tmpenv ) tmpenv = _PATH_TMP ; rc = asprintf , tmpenv , prefix ) ; if\n", "\n", "Sources:\n", "0: CWE-000 int xmkstemp ( char * * tmpname , char * dir ) { char * localtmp ; char * tmpenv ; mode_t old_mode ; int fd , rc ; if ( dir != NULL ) tmpenv = dir ; else tmpenv = getenv ( \"TMPDIR\" ) ; if ( tmpenv ) rc = asprintf ( & localtmp , \"%s/%s.XXXXXX\" , tmpenv , program_invocation_short_name ) ; else rc = asprintf ( & localtmp , \"%s/%s.XXXXXX\" , _PATH_TMP , program_invocation_short_name ) ; if ( rc < 0 ) return - 1 ; old_mode = umask ( 077 ) ; fd = mkostemp ( localtmp , O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC ) ; umask ( old_mode ) ; if ( fd == - 1 ) { free ( localtmp ) ; localtmp = NULL ; } * tmpname = localtmp ; return fd ; }\n", "\n", "1: CWE-264 int xmkstemp ( char * * tmpname , char * dir ) { char * localtmp ; char * tmpenv ; mode_t old_mode ; int fd , rc ; if ( dir != NULL ) tmpenv = dir ; else tmpenv = getenv ( \"TMPDIR\" ) ; if ( tmpenv ) rc = asprintf ( & localtmp , \"%s/%s.XXXXXX\" , tmpenv , program_invocation_short_name ) ; else rc = asprintf ( & localtmp , \"%s/%s.XXXXXX\" , _PATH_TMP , program_invocation_short_name ) ; if ( rc < 0 ) return - 1 ; old_mode = umask ( 077 ) ; fd = mkostemp ( localtmp , O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC ) ; umask ( old_mode ) ; if ( fd == - 1 ) { free ( localtmp ) ; localtmp = NULL ; } * tmpname = localtmp ; return fd ; }\n", "\n", "\n", "Target: [ plane ] && frame -> linesize [ plane ]\n", "\n", "Sources:\n", "0: CWE-119 static AVFrame * get_video_buffer ( AVFilterLink * inlink , int w , int h ) { PadContext * s = inlink -> dst -> priv ; AVFrame * frame = ff_get_video_buffer ( inlink -> dst -> outputs [ 0 ] , w + ( s -> w - s -> in_w ) , h + ( s -> h - s -> in_h ) ) ; int plane ; if ( ! frame ) return NULL ; frame -> width = w ; frame -> height = h ; for ( plane = 0 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) { int hsub = s -> draw . hsub [ plane ] ; int vsub = s -> draw . vsub [ plane ] ; frame -> data [ plane ] += ( s -> x >> hsub ) * s -> draw . pixelstep [ plane ] + ( s -> y >> vsub ) * frame -> linesize [ plane ] ; } return frame ; }\n", "\n", "1: CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * frame ) { AVFilterContext * ctx = inlink -> dst ; FieldOrderContext * s = ctx -> priv ; AVFilterLink * outlink = ctx -> outputs [ 0 ] ; int h , plane , line_step , line_size , line ; uint8_t * data ; if ( ! frame -> interlaced_frame || frame -> top_field_first == s -> dst_tff ) return ff_filter_frame ( outlink , frame ) ; av_dlog ( ctx , \"picturewillmove%soneline\\\\n\" , s -> dst_tff ? \"up\" : \"down\" ) ; h = frame -> height ; for ( plane = 0 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) { line_step = frame -> linesize [ plane ] ; line_size = s -> line_size [ plane ] ; data = frame -> data [ plane ] ; if ( s -> dst_tff ) { for ( line = 0 ; line < h ; line ++ ) { if ( 1 + line < frame -> height ) { memcpy ( data , data + line_step , line_size ) ; } else { memcpy ( data , data - line_step - line_step , line_size ) ; } data += line_step ; } } else { data += ( h - 1 ) * line_step ; for ( line = h - 1 ; line >= 0 ; line -- ) { if ( line > 0 ) { memcpy ( data , data - line_step , line_size ) ; } else { memcpy ( data , data + line_step + line_step , line_size ) ; } data -= line_step ; } } } frame -> top_field_first = s -> dst_tff ; return ff_filter_frame ( outlink , frame ) ; }\n", "\n", "\n", "Target: ; if ( current_length >= 32 ) return error ( f , VORBIS_invalid_setup ) ; if ( 1 ) { int values = lookup1_values ( c -> entries , c -> dimensions ) ; if ( values < 0 ) return error ( f , VORBIS_invalid_setup ) ; -> lookup_values = ( uint32 ) values ; } else g -> values - 1 ; ++ j ) if ( p [ j ] . x == p [ j + 1 ] . x ) return error ( f , VORBIS_invalid_setup ) ; for ( j = 0 ; j < g -> values ) + 1 ; if ( m -> coupling_steps > f -> channels ) return error ( f , VORBIS_invalid_setup )\n", "\n", "Sources:\n", "0: CWE-617 static int start_decoder ( vorb * f ) { uint8 header [ 6 ] , x , y ; int len , i , j , k , max_submaps = 0 ; int longest_floorlist = 0 ; if ( ! start_page ( f ) ) return FALSE ; if ( ! ( f -> page_flag & PAGEFLAG_first_page ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_last_page ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_continued_packet ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segment_count != 1 ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segments [ 0 ] != 30 ) { if ( f -> segments [ 0 ] == 64 && getn ( f , header , 6 ) && header [ 0 ] == 'f' && header [ 1 ] == 'i' && header [ 2 ] == 's' && header [ 3 ] == 'h' && header [ 4 ] == 'e' && header [ 5 ] == 'a' && get8 ( f ) == 'd' && get8 ( f ) == '\\\\0' ) return error ( f , VORBIS_ogg_skeleton_not_supported ) ; else return error ( f , VORBIS_invalid_first_page ) ; } if ( get8 ( f ) != VORBIS_packet_id ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! getn ( f , header , 6 ) ) return error ( f , VORBIS_unexpected_eof ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( get32 ( f ) != 0 ) return error ( f , VORBIS_invalid_first_page ) ; f -> channels = get8 ( f ) ; if ( ! f -> channels ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> channels > STB_VORBIS_MAX_CHANNELS ) return error ( f , VORBIS_too_many_channels ) ; f -> sample_rate = get32 ( f ) ; if ( ! f -> sample_rate ) return error ( f , VORBIS_invalid_first_page ) ; get32 ( f ) ; get32 ( f ) ; get32 ( f ) ; x = get8 ( f ) ; { int log0 , log1 ; log0 = x & 15 ; log1 = x >> 4 ; f -> blocksize_0 = 1 << log0 ; f -> blocksize_1 = 1 << log1 ; if ( log0 < 6 || log0 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log1 < 6 || log1 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log0 > log1 ) return error ( f , VORBIS_invalid_setup ) ; } x = get8 ( f ) ; if ( ! ( x & 1 ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! start_page ( f ) ) return FALSE ; if ( ! start_packet ( f ) ) return FALSE ; do { len = next_segment ( f ) ; skip ( f , len ) ; f -> bytes_in_seg = 0 ; } while ( len ) ; if ( ! start_packet ( f ) ) return FALSE ; # ifndef STB_VORBIS_NO_PUSHDATA_API if ( IS_PUSH_MODE ( f ) ) { if ( ! is_whole_packet_present ( f , TRUE ) ) { if ( f -> error == VORBIS_invalid_stream ) f -> error = VORBIS_invalid_setup ; return FALSE ; } } # endif crc32_init ( ) ; if ( get8_packet ( f ) != VORBIS_packet_setup ) return error ( f , VORBIS_invalid_setup ) ; for ( i = 0 ; i < 6 ; ++ i ) header [ i ] = get8_packet ( f ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_setup ) ; f -> codebook_count = get_bits ( f , 8 ) + 1 ; f -> codebooks = ( Codebook * ) setup_malloc ( f , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; if ( f -> codebooks == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> codebooks , 0 , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; for ( i = 0 ; i < f -> codebook_count ; ++ i ) { uint32 * values ; int ordered , sorted_count ; int total = 0 ; uint8 * lengths ; Codebook * c = f -> codebooks + i ; CHECK ( f ) ; x = get_bits ( f , 8 ) ; if ( x != 0x42 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x43 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x56 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; c -> dimensions = ( get_bits ( f , 8 ) << 8 ) + x ; x = get_bits ( f , 8 ) ; y = get_bits ( f , 8 ) ; c -> entries = ( get_bits ( f , 8 ) << 16 ) + ( y << 8 ) + x ; ordered = get_bits ( f , 1 ) ; c -> sparse = ordered ? 0 : get_bits ( f , 1 ) ; if ( c -> dimensions == 0 && c -> entries != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> sparse ) lengths = ( uint8 * ) setup_temp_malloc ( f , c -> entries ) ; else lengths = c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( ! lengths ) return error ( f , VORBIS_outofmem ) ; if ( ordered ) { int current_entry = 0 ; int current_length = get_bits ( f , 5 ) + 1 ; while ( current_entry < c -> entries ) { int limit = c -> entries - current_entry ; int n = get_bits ( f , ilog ( limit ) ) ; if ( current_entry + n > ( int ) c -> entries ) { return error ( f , VORBIS_invalid_setup ) ; } memset ( lengths + current_entry , current_length , n ) ; current_entry += n ; ++ current_length ; } } else { for ( j = 0 ; j < c -> entries ; ++ j ) { int present = c -> sparse ? get_bits ( f , 1 ) : 1 ; if ( present ) { lengths [ j ] = get_bits ( f , 5 ) + 1 ; ++ total ; if ( lengths [ j ] == 32 ) return error ( f , VORBIS_invalid_setup ) ; } else { lengths [ j ] = NO_CODE ; } } } if ( c -> sparse && total >= c -> entries >> 2 ) { if ( c -> entries > ( int ) f -> setup_temp_memory_required ) f -> setup_temp_memory_required = c -> entries ; c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( c -> codeword_lengths == NULL ) return error ( f , VORBIS_outofmem ) ; memcpy ( c -> codeword_lengths , lengths , c -> entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; lengths = c -> codeword_lengths ; c -> sparse = 0 ; } if ( c -> sparse ) { sorted_count = total ; } else { sorted_count = 0 ; # ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for ( j = 0 ; j < c -> entries ; ++ j ) if ( lengths [ j ] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths [ j ] != NO_CODE ) ++ sorted_count ; # endif } c -> sorted_entries = sorted_count ; values = NULL ; CHECK ( f ) ; if ( ! c -> sparse ) { c -> codewords = ( uint32 * ) setup_malloc ( f , sizeof ( c -> codewords [ 0 ] ) * c -> entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; } else { unsigned int size ; if ( c -> sorted_entries ) { c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> sorted_entries ) ; if ( ! c -> codeword_lengths ) return error ( f , VORBIS_outofmem ) ; c -> codewords = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; values = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * values ) * c -> sorted_entries ) ; if ( ! values ) return error ( f , VORBIS_outofmem ) ; } size = c -> entries + ( sizeof ( * c -> codewords ) + sizeof ( * values ) ) * c -> sorted_entries ; if ( size > f -> setup_temp_memory_required ) f -> setup_temp_memory_required = size ; } if ( ! compute_codewords ( c , lengths , c -> entries , values ) ) { if ( c -> sparse ) setup_temp_free ( f , values , 0 ) ; return error ( f , VORBIS_invalid_setup ) ; } if ( c -> sorted_entries ) { c -> sorted_codewords = ( uint32 * ) setup_malloc ( f , sizeof ( * c -> sorted_codewords ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_codewords == NULL ) return error ( f , VORBIS_outofmem ) ; c -> sorted_values = ( int * ) setup_malloc ( f , sizeof ( * c -> sorted_values ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_values == NULL ) return error ( f , VORBIS_outofmem ) ; ++ c -> sorted_values ; c -> sorted_values [ - 1 ] = - 1 ; compute_sorted_huffman ( c , lengths , values ) ; } if ( c -> sparse ) { setup_temp_free ( f , values , sizeof ( * values ) * c -> sorted_entries ) ; setup_temp_free ( f , c -> codewords , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; c -> codewords = NULL ; } compute_accelerated_huffman ( c ) ; CHECK ( f ) ; c -> lookup_type = get_bits ( f , 4 ) ; if ( c -> lookup_type > 2 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> lookup_type > 0 ) { uint16 * mults ; c -> minimum_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> delta_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> value_bits = get_bits ( f , 4 ) + 1 ; c -> sequence_p = get_bits ( f , 1 ) ; if ( c -> lookup_type == 1 ) { c -> lookup_values = lookup1_values ( c -> entries , c -> dimensions ) ; } else { c -> lookup_values = c -> entries * c -> dimensions ; } if ( c -> lookup_values == 0 ) return error ( f , VORBIS_invalid_setup ) ; mults = ( uint16 * ) setup_temp_malloc ( f , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; if ( mults == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { int q = get_bits ( f , c -> value_bits ) ; if ( q == EOP ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } mults [ j ] = q ; } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if ( c -> lookup_type == 1 ) { int len , sparse = c -> sparse ; float last = 0 ; if ( sparse ) { if ( c -> sorted_entries == 0 ) goto skip ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> sorted_entries * c -> dimensions ) ; } else c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> entries * c -> dimensions ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } len = sparse ? c -> sorted_entries : c -> entries ; for ( j = 0 ; j < len ; ++ j ) { unsigned int z = sparse ? c -> sorted_values [ j ] : j ; unsigned int div = 1 ; for ( k = 0 ; k < c -> dimensions ; ++ k ) { int off = ( z / div ) % c -> lookup_values ; float val = mults [ off ] ; val = mults [ off ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j * c -> dimensions + k ] = val ; if ( c -> sequence_p ) last = val ; if ( k + 1 < c -> dimensions ) { if ( div > UINT_MAX / ( unsigned int ) c -> lookup_values ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } div *= c -> lookup_values ; } } } c -> lookup_type = 2 ; } else # endif { float last = 0 ; CHECK ( f ) ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> lookup_values ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { float val = mults [ j ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j ] = val ; if ( c -> sequence_p ) last = val ; } } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip : ; # endif setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; CHECK ( f ) ; } CHECK ( f ) ; } x = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < x ; ++ i ) { uint32 z = get_bits ( f , 16 ) ; if ( z != 0 ) return error ( f , VORBIS_invalid_setup ) ; } f -> floor_count = get_bits ( f , 6 ) + 1 ; f -> floor_config = ( Floor * ) setup_malloc ( f , f -> floor_count * sizeof ( * f -> floor_config ) ) ; if ( f -> floor_config == NULL ) return error ( f , VORBIS_outofmem ) ; for ( i = 0 ; i < f -> floor_count ; ++ i ) { f -> floor_types [ i ] = get_bits ( f , 16 ) ; if ( f -> floor_types [ i ] > 1 ) return error ( f , VORBIS_invalid_setup ) ; if ( f -> floor_types [ i ] == 0 ) { Floor0 * g = & f -> floor_config [ i ] . floor0 ; g -> order = get_bits ( f , 8 ) ; g -> rate = get_bits ( f , 16 ) ; g -> bark_map_size = get_bits ( f , 16 ) ; g -> amplitude_bits = get_bits ( f , 6 ) ; g -> amplitude_offset = get_bits ( f , 8 ) ; g -> number_of_books = get_bits ( f , 4 ) + 1 ; for ( j = 0 ; j < g -> number_of_books ; ++ j ) g -> book_list [ j ] = get_bits ( f , 8 ) ; return error ( f , VORBIS_feature_not_supported ) ; } else { stbv__floor_ordering p [ 31 * 8 + 2 ] ; Floor1 * g = & f -> floor_config [ i ] . floor1 ; int max_class = - 1 ; g -> partitions = get_bits ( f , 5 ) ; for ( j = 0 ; j < g -> partitions ; ++ j ) { g -> partition_class_list [ j ] = get_bits ( f , 4 ) ; if ( g -> partition_class_list [ j ] > max_class ) max_class = g -> partition_class_list [ j ] ; } for ( j = 0 ; j <= max_class ; ++ j ) { g -> class_dimensions [ j ] = get_bits ( f , 3 ) + 1 ; g -> class_subclasses [ j ] = get_bits ( f , 2 ) ; if ( g -> class_subclasses [ j ] ) { g -> class_masterbooks [ j ] = get_bits ( f , 8 ) ; if ( g -> class_masterbooks [ j ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } for ( k = 0 ; k < 1 << g -> class_subclasses [ j ] ; ++ k ) { g -> subclass_books [ j ] [ k ] = get_bits ( f , 8 ) - 1 ; if ( g -> subclass_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } } g -> floor1_multiplier = get_bits ( f , 2 ) + 1 ; g -> rangebits = get_bits ( f , 4 ) ; g -> Xlist [ 0 ] = 0 ; g -> Xlist [ 1 ] = 1 << g -> rangebits ; g -> values = 2 ; for ( j = 0 ; j < g -> partitions ; ++ j ) { int c = g -> partition_class_list [ j ] ; for ( k = 0 ; k < g -> class_dimensions [ c ] ; ++ k ) { g -> Xlist [ g -> values ] = get_bits ( f , g -> rangebits ) ; ++ g -> values ; } } for ( j = 0 ; j < g -> values ; ++ j ) { p [ j ] . x = g -> Xlist [ j ] ; p [ j ] . id = j ; } qsort ( p , g -> values , sizeof ( p [ 0 ] ) , point_compare ) ; for ( j = 0 ; j < g -> values ; ++ j ) g -> sorted_order [ j ] = ( uint8 ) p [ j ] . id ; for ( j = 2 ; j < g -> values ; ++ j ) { int low , hi ; neighbors ( g -> Xlist , j , & low , & hi ) ; g -> neighbors [ j ] [ 0 ] = low ; g -> neighbors [ j ] [ 1 ] = hi ; } if ( g -> values > longest_floorlist ) longest_floorlist = g -> values ; } } f -> residue_count = get_bits ( f , 6 ) + 1 ; f -> residue_config = ( Residue * ) setup_malloc ( f , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; if ( f -> residue_config == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> residue_config , 0 , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { uint8 residue_cascade [ 64 ] ; Residue * r = f -> residue_config + i ; f -> residue_types [ i ] = get_bits ( f , 16 ) ; if ( f -> residue_types [ i ] > 2 ) return error ( f , VORBIS_invalid_setup ) ; r -> begin = get_bits ( f , 24 ) ; r -> end = get_bits ( f , 24 ) ; if ( r -> end < r -> begin ) return error ( f , VORBIS_invalid_setup ) ; r -> part_size = get_bits ( f , 24 ) + 1 ; r -> classifications = get_bits ( f , 6 ) + 1 ; r -> classbook = get_bits ( f , 8 ) ; if ( r -> classbook >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { uint8 high_bits = 0 ; uint8 low_bits = get_bits ( f , 3 ) ; if ( get_bits ( f , 1 ) ) high_bits = get_bits ( f , 5 ) ; residue_cascade [ j ] = high_bits * 8 + low_bits ; } r -> residue_books = ( short ( * ) [ 8 ] ) setup_malloc ( f , sizeof ( r -> residue_books [ 0 ] ) * r -> classifications ) ; if ( r -> residue_books == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { for ( k = 0 ; k < 8 ; ++ k ) { if ( residue_cascade [ j ] & ( 1 << k ) ) { r -> residue_books [ j ] [ k ] = get_bits ( f , 8 ) ; if ( r -> residue_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } else { r -> residue_books [ j ] [ k ] = - 1 ; } } } r -> classdata = ( uint8 * * ) setup_malloc ( f , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; if ( ! r -> classdata ) return error ( f , VORBIS_outofmem ) ; memset ( r -> classdata , 0 , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; for ( j = 0 ; j < f -> codebooks [ r -> classbook ] . entries ; ++ j ) { int classwords = f -> codebooks [ r -> classbook ] . dimensions ; int temp = j ; r -> classdata [ j ] = ( uint8 * ) setup_malloc ( f , sizeof ( r -> classdata [ j ] [ 0 ] ) * classwords ) ; if ( r -> classdata [ j ] == NULL ) return error ( f , VORBIS_outofmem ) ; for ( k = classwords - 1 ; k >= 0 ; -- k ) { r -> classdata [ j ] [ k ] = temp % r -> classifications ; temp /= r -> classifications ; } } } f -> mapping_count = get_bits ( f , 6 ) + 1 ; f -> mapping = ( Mapping * ) setup_malloc ( f , f -> mapping_count * sizeof ( * f -> mapping ) ) ; if ( f -> mapping == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> mapping , 0 , f -> mapping_count * sizeof ( * f -> mapping ) ) ; for ( i = 0 ; i < f -> mapping_count ; ++ i ) { Mapping * m = f -> mapping + i ; int mapping_type = get_bits ( f , 16 ) ; if ( mapping_type != 0 ) return error ( f , VORBIS_invalid_setup ) ; m -> chan = ( MappingChannel * ) setup_malloc ( f , f -> channels * sizeof ( * m -> chan ) ) ; if ( m -> chan == NULL ) return error ( f , VORBIS_outofmem ) ; if ( get_bits ( f , 1 ) ) m -> submaps = get_bits ( f , 4 ) + 1 ; else m -> submaps = 1 ; if ( m -> submaps > max_submaps ) max_submaps = m -> submaps ; if ( get_bits ( f , 1 ) ) { m -> coupling_steps = get_bits ( f , 8 ) + 1 ; for ( k = 0 ; k < m -> coupling_steps ; ++ k ) { m -> chan [ k ] . magnitude = get_bits ( f , ilog ( f -> channels - 1 ) ) ; m -> chan [ k ] . angle = get_bits ( f , ilog ( f -> channels - 1 ) ) ; if ( m -> chan [ k ] . magnitude >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . angle >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . magnitude == m -> chan [ k ] . angle ) return error ( f , VORBIS_invalid_setup ) ; } } else m -> coupling_steps = 0 ; if ( get_bits ( f , 2 ) ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submaps > 1 ) { for ( j = 0 ; j < f -> channels ; ++ j ) { m -> chan [ j ] . mux = get_bits ( f , 4 ) ; if ( m -> chan [ j ] . mux >= m -> submaps ) return error ( f , VORBIS_invalid_setup ) ; } } else for ( j = 0 ; j < f -> channels ; ++ j ) m -> chan [ j ] . mux = 0 ; for ( j = 0 ; j < m -> submaps ; ++ j ) { get_bits ( f , 8 ) ; m -> submap_floor [ j ] = get_bits ( f , 8 ) ; m -> submap_residue [ j ] = get_bits ( f , 8 ) ; if ( m -> submap_floor [ j ] >= f -> floor_count ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submap_residue [ j ] >= f -> residue_count ) return error ( f , VORBIS_invalid_setup ) ; } } f -> mode_count = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < f -> mode_count ; ++ i ) { Mode * m = f -> mode_config + i ; m -> blockflag = get_bits ( f , 1 ) ; m -> windowtype = get_bits ( f , 16 ) ; m -> transformtype = get_bits ( f , 16 ) ; m -> mapping = get_bits ( f , 8 ) ; if ( m -> windowtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> transformtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> mapping >= f -> mapping_count ) return error ( f , VORBIS_invalid_setup ) ; } flush_packet ( f ) ; f -> previous_length = 0 ; for ( i = 0 ; i < f -> channels ; ++ i ) { f -> channel_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 ) ; f -> previous_window [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; f -> finalY [ i ] = ( int16 * ) setup_malloc ( f , sizeof ( int16 ) * longest_floorlist ) ; if ( f -> channel_buffers [ i ] == NULL || f -> previous_window [ i ] == NULL || f -> finalY [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> channel_buffers [ i ] , 0 , sizeof ( float ) * f -> blocksize_1 ) ; # ifdef STB_VORBIS_NO_DEFER_FLOOR f -> floor_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; if ( f -> floor_buffers [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; # endif } if ( ! init_blocksize ( f , 0 , f -> blocksize_0 ) ) return FALSE ; if ( ! init_blocksize ( f , 1 , f -> blocksize_1 ) ) return FALSE ; f -> blocksize [ 0 ] = f -> blocksize_0 ; f -> blocksize [ 1 ] = f -> blocksize_1 ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( integer_divide_table [ 1 ] [ 1 ] == 0 ) for ( i = 0 ; i < DIVTAB_NUMER ; ++ i ) for ( j = 1 ; j < DIVTAB_DENOM ; ++ j ) integer_divide_table [ i ] [ j ] = i / j ; # endif { uint32 imdct_mem = ( f -> blocksize_1 * sizeof ( float ) >> 1 ) ; uint32 classify_mem ; int i , max_part_read = 0 ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { Residue * r = f -> residue_config + i ; unsigned int actual_size = f -> blocksize_1 / 2 ; unsigned int limit_r_begin = r -> begin < actual_size ? r -> begin : actual_size ; unsigned int limit_r_end = r -> end < actual_size ? r -> end : actual_size ; int n_read = limit_r_end - limit_r_begin ; int part_read = n_read / r -> part_size ; if ( part_read > max_part_read ) max_part_read = part_read ; } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( uint8 * ) ) ; # else classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( int * ) ) ; # endif f -> temp_memory_required = classify_mem ; if ( imdct_mem > f -> temp_memory_required ) f -> temp_memory_required = imdct_mem ; } f -> first_decode = TRUE ; if ( f -> alloc . alloc_buffer ) { assert ( f -> temp_offset == f -> alloc . alloc_buffer_length_in_bytes ) ; if ( f -> setup_offset + sizeof ( * f ) + f -> temp_memory_required > ( unsigned ) f -> temp_offset ) return error ( f , VORBIS_outofmem ) ; } f -> first_audio_page_offset = stb_vorbis_get_file_offset ( f ) ; return TRUE ; }\n", "\n", "1: CWE-119 static int start_decoder ( vorb * f ) { uint8 header [ 6 ] , x , y ; int len , i , j , k , max_submaps = 0 ; int longest_floorlist = 0 ; if ( ! start_page ( f ) ) return FALSE ; if ( ! ( f -> page_flag & PAGEFLAG_first_page ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_last_page ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_continued_packet ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segment_count != 1 ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segments [ 0 ] != 30 ) { if ( f -> segments [ 0 ] == 64 && getn ( f , header , 6 ) && header [ 0 ] == 'f' && header [ 1 ] == 'i' && header [ 2 ] == 's' && header [ 3 ] == 'h' && header [ 4 ] == 'e' && header [ 5 ] == 'a' && get8 ( f ) == 'd' && get8 ( f ) == '\\\\0' ) return error ( f , VORBIS_ogg_skeleton_not_supported ) ; else return error ( f , VORBIS_invalid_first_page ) ; } if ( get8 ( f ) != VORBIS_packet_id ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! getn ( f , header , 6 ) ) return error ( f , VORBIS_unexpected_eof ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( get32 ( f ) != 0 ) return error ( f , VORBIS_invalid_first_page ) ; f -> channels = get8 ( f ) ; if ( ! f -> channels ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> channels > STB_VORBIS_MAX_CHANNELS ) return error ( f , VORBIS_too_many_channels ) ; f -> sample_rate = get32 ( f ) ; if ( ! f -> sample_rate ) return error ( f , VORBIS_invalid_first_page ) ; get32 ( f ) ; get32 ( f ) ; get32 ( f ) ; x = get8 ( f ) ; { int log0 , log1 ; log0 = x & 15 ; log1 = x >> 4 ; f -> blocksize_0 = 1 << log0 ; f -> blocksize_1 = 1 << log1 ; if ( log0 < 6 || log0 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log1 < 6 || log1 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log0 > log1 ) return error ( f , VORBIS_invalid_setup ) ; } x = get8 ( f ) ; if ( ! ( x & 1 ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! start_page ( f ) ) return FALSE ; if ( ! start_packet ( f ) ) return FALSE ; do { len = next_segment ( f ) ; skip ( f , len ) ; f -> bytes_in_seg = 0 ; } while ( len ) ; if ( ! start_packet ( f ) ) return FALSE ; # ifndef STB_VORBIS_NO_PUSHDATA_API if ( IS_PUSH_MODE ( f ) ) { if ( ! is_whole_packet_present ( f , TRUE ) ) { if ( f -> error == VORBIS_invalid_stream ) f -> error = VORBIS_invalid_setup ; return FALSE ; } } # endif crc32_init ( ) ; if ( get8_packet ( f ) != VORBIS_packet_setup ) return error ( f , VORBIS_invalid_setup ) ; for ( i = 0 ; i < 6 ; ++ i ) header [ i ] = get8_packet ( f ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_setup ) ; f -> codebook_count = get_bits ( f , 8 ) + 1 ; f -> codebooks = ( Codebook * ) setup_malloc ( f , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; if ( f -> codebooks == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> codebooks , 0 , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; for ( i = 0 ; i < f -> codebook_count ; ++ i ) { uint32 * values ; int ordered , sorted_count ; int total = 0 ; uint8 * lengths ; Codebook * c = f -> codebooks + i ; CHECK ( f ) ; x = get_bits ( f , 8 ) ; if ( x != 0x42 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x43 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x56 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; c -> dimensions = ( get_bits ( f , 8 ) << 8 ) + x ; x = get_bits ( f , 8 ) ; y = get_bits ( f , 8 ) ; c -> entries = ( get_bits ( f , 8 ) << 16 ) + ( y << 8 ) + x ; ordered = get_bits ( f , 1 ) ; c -> sparse = ordered ? 0 : get_bits ( f , 1 ) ; if ( c -> dimensions == 0 && c -> entries != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> sparse ) lengths = ( uint8 * ) setup_temp_malloc ( f , c -> entries ) ; else lengths = c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( ! lengths ) return error ( f , VORBIS_outofmem ) ; if ( ordered ) { int current_entry = 0 ; int current_length = get_bits ( f , 5 ) + 1 ; while ( current_entry < c -> entries ) { int limit = c -> entries - current_entry ; int n = get_bits ( f , ilog ( limit ) ) ; if ( current_entry + n > ( int ) c -> entries ) { return error ( f , VORBIS_invalid_setup ) ; } memset ( lengths + current_entry , current_length , n ) ; current_entry += n ; ++ current_length ; } } else { for ( j = 0 ; j < c -> entries ; ++ j ) { int present = c -> sparse ? get_bits ( f , 1 ) : 1 ; if ( present ) { lengths [ j ] = get_bits ( f , 5 ) + 1 ; ++ total ; if ( lengths [ j ] == 32 ) return error ( f , VORBIS_invalid_setup ) ; } else { lengths [ j ] = NO_CODE ; } } } if ( c -> sparse && total >= c -> entries >> 2 ) { if ( c -> entries > ( int ) f -> setup_temp_memory_required ) f -> setup_temp_memory_required = c -> entries ; c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( c -> codeword_lengths == NULL ) return error ( f , VORBIS_outofmem ) ; memcpy ( c -> codeword_lengths , lengths , c -> entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; lengths = c -> codeword_lengths ; c -> sparse = 0 ; } if ( c -> sparse ) { sorted_count = total ; } else { sorted_count = 0 ; # ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for ( j = 0 ; j < c -> entries ; ++ j ) if ( lengths [ j ] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths [ j ] != NO_CODE ) ++ sorted_count ; # endif } c -> sorted_entries = sorted_count ; values = NULL ; CHECK ( f ) ; if ( ! c -> sparse ) { c -> codewords = ( uint32 * ) setup_malloc ( f , sizeof ( c -> codewords [ 0 ] ) * c -> entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; } else { unsigned int size ; if ( c -> sorted_entries ) { c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> sorted_entries ) ; if ( ! c -> codeword_lengths ) return error ( f , VORBIS_outofmem ) ; c -> codewords = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; values = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * values ) * c -> sorted_entries ) ; if ( ! values ) return error ( f , VORBIS_outofmem ) ; } size = c -> entries + ( sizeof ( * c -> codewords ) + sizeof ( * values ) ) * c -> sorted_entries ; if ( size > f -> setup_temp_memory_required ) f -> setup_temp_memory_required = size ; } if ( ! compute_codewords ( c , lengths , c -> entries , values ) ) { if ( c -> sparse ) setup_temp_free ( f , values , 0 ) ; return error ( f , VORBIS_invalid_setup ) ; } if ( c -> sorted_entries ) { c -> sorted_codewords = ( uint32 * ) setup_malloc ( f , sizeof ( * c -> sorted_codewords ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_codewords == NULL ) return error ( f , VORBIS_outofmem ) ; c -> sorted_values = ( int * ) setup_malloc ( f , sizeof ( * c -> sorted_values ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_values == NULL ) return error ( f , VORBIS_outofmem ) ; ++ c -> sorted_values ; c -> sorted_values [ - 1 ] = - 1 ; compute_sorted_huffman ( c , lengths , values ) ; } if ( c -> sparse ) { setup_temp_free ( f , values , sizeof ( * values ) * c -> sorted_entries ) ; setup_temp_free ( f , c -> codewords , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; c -> codewords = NULL ; } compute_accelerated_huffman ( c ) ; CHECK ( f ) ; c -> lookup_type = get_bits ( f , 4 ) ; if ( c -> lookup_type > 2 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> lookup_type > 0 ) { uint16 * mults ; c -> minimum_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> delta_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> value_bits = get_bits ( f , 4 ) + 1 ; c -> sequence_p = get_bits ( f , 1 ) ; if ( c -> lookup_type == 1 ) { c -> lookup_values = lookup1_values ( c -> entries , c -> dimensions ) ; } else { c -> lookup_values = c -> entries * c -> dimensions ; } if ( c -> lookup_values == 0 ) return error ( f , VORBIS_invalid_setup ) ; mults = ( uint16 * ) setup_temp_malloc ( f , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; if ( mults == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { int q = get_bits ( f , c -> value_bits ) ; if ( q == EOP ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } mults [ j ] = q ; } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if ( c -> lookup_type == 1 ) { int len , sparse = c -> sparse ; float last = 0 ; if ( sparse ) { if ( c -> sorted_entries == 0 ) goto skip ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> sorted_entries * c -> dimensions ) ; } else c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> entries * c -> dimensions ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } len = sparse ? c -> sorted_entries : c -> entries ; for ( j = 0 ; j < len ; ++ j ) { unsigned int z = sparse ? c -> sorted_values [ j ] : j ; unsigned int div = 1 ; for ( k = 0 ; k < c -> dimensions ; ++ k ) { int off = ( z / div ) % c -> lookup_values ; float val = mults [ off ] ; val = mults [ off ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j * c -> dimensions + k ] = val ; if ( c -> sequence_p ) last = val ; if ( k + 1 < c -> dimensions ) { if ( div > UINT_MAX / ( unsigned int ) c -> lookup_values ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } div *= c -> lookup_values ; } } } c -> lookup_type = 2 ; } else # endif { float last = 0 ; CHECK ( f ) ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> lookup_values ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { float val = mults [ j ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j ] = val ; if ( c -> sequence_p ) last = val ; } } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip : ; # endif setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; CHECK ( f ) ; } CHECK ( f ) ; } x = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < x ; ++ i ) { uint32 z = get_bits ( f , 16 ) ; if ( z != 0 ) return error ( f , VORBIS_invalid_setup ) ; } f -> floor_count = get_bits ( f , 6 ) + 1 ; f -> floor_config = ( Floor * ) setup_malloc ( f , f -> floor_count * sizeof ( * f -> floor_config ) ) ; if ( f -> floor_config == NULL ) return error ( f , VORBIS_outofmem ) ; for ( i = 0 ; i < f -> floor_count ; ++ i ) { f -> floor_types [ i ] = get_bits ( f , 16 ) ; if ( f -> floor_types [ i ] > 1 ) return error ( f , VORBIS_invalid_setup ) ; if ( f -> floor_types [ i ] == 0 ) { Floor0 * g = & f -> floor_config [ i ] . floor0 ; g -> order = get_bits ( f , 8 ) ; g -> rate = get_bits ( f , 16 ) ; g -> bark_map_size = get_bits ( f , 16 ) ; g -> amplitude_bits = get_bits ( f , 6 ) ; g -> amplitude_offset = get_bits ( f , 8 ) ; g -> number_of_books = get_bits ( f , 4 ) + 1 ; for ( j = 0 ; j < g -> number_of_books ; ++ j ) g -> book_list [ j ] = get_bits ( f , 8 ) ; return error ( f , VORBIS_feature_not_supported ) ; } else { stbv__floor_ordering p [ 31 * 8 + 2 ] ; Floor1 * g = & f -> floor_config [ i ] . floor1 ; int max_class = - 1 ; g -> partitions = get_bits ( f , 5 ) ; for ( j = 0 ; j < g -> partitions ; ++ j ) { g -> partition_class_list [ j ] = get_bits ( f , 4 ) ; if ( g -> partition_class_list [ j ] > max_class ) max_class = g -> partition_class_list [ j ] ; } for ( j = 0 ; j <= max_class ; ++ j ) { g -> class_dimensions [ j ] = get_bits ( f , 3 ) + 1 ; g -> class_subclasses [ j ] = get_bits ( f , 2 ) ; if ( g -> class_subclasses [ j ] ) { g -> class_masterbooks [ j ] = get_bits ( f , 8 ) ; if ( g -> class_masterbooks [ j ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } for ( k = 0 ; k < 1 << g -> class_subclasses [ j ] ; ++ k ) { g -> subclass_books [ j ] [ k ] = get_bits ( f , 8 ) - 1 ; if ( g -> subclass_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } } g -> floor1_multiplier = get_bits ( f , 2 ) + 1 ; g -> rangebits = get_bits ( f , 4 ) ; g -> Xlist [ 0 ] = 0 ; g -> Xlist [ 1 ] = 1 << g -> rangebits ; g -> values = 2 ; for ( j = 0 ; j < g -> partitions ; ++ j ) { int c = g -> partition_class_list [ j ] ; for ( k = 0 ; k < g -> class_dimensions [ c ] ; ++ k ) { g -> Xlist [ g -> values ] = get_bits ( f , g -> rangebits ) ; ++ g -> values ; } } for ( j = 0 ; j < g -> values ; ++ j ) { p [ j ] . x = g -> Xlist [ j ] ; p [ j ] . id = j ; } qsort ( p , g -> values , sizeof ( p [ 0 ] ) , point_compare ) ; for ( j = 0 ; j < g -> values ; ++ j ) g -> sorted_order [ j ] = ( uint8 ) p [ j ] . id ; for ( j = 2 ; j < g -> values ; ++ j ) { int low , hi ; neighbors ( g -> Xlist , j , & low , & hi ) ; g -> neighbors [ j ] [ 0 ] = low ; g -> neighbors [ j ] [ 1 ] = hi ; } if ( g -> values > longest_floorlist ) longest_floorlist = g -> values ; } } f -> residue_count = get_bits ( f , 6 ) + 1 ; f -> residue_config = ( Residue * ) setup_malloc ( f , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; if ( f -> residue_config == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> residue_config , 0 , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { uint8 residue_cascade [ 64 ] ; Residue * r = f -> residue_config + i ; f -> residue_types [ i ] = get_bits ( f , 16 ) ; if ( f -> residue_types [ i ] > 2 ) return error ( f , VORBIS_invalid_setup ) ; r -> begin = get_bits ( f , 24 ) ; r -> end = get_bits ( f , 24 ) ; if ( r -> end < r -> begin ) return error ( f , VORBIS_invalid_setup ) ; r -> part_size = get_bits ( f , 24 ) + 1 ; r -> classifications = get_bits ( f , 6 ) + 1 ; r -> classbook = get_bits ( f , 8 ) ; if ( r -> classbook >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { uint8 high_bits = 0 ; uint8 low_bits = get_bits ( f , 3 ) ; if ( get_bits ( f , 1 ) ) high_bits = get_bits ( f , 5 ) ; residue_cascade [ j ] = high_bits * 8 + low_bits ; } r -> residue_books = ( short ( * ) [ 8 ] ) setup_malloc ( f , sizeof ( r -> residue_books [ 0 ] ) * r -> classifications ) ; if ( r -> residue_books == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { for ( k = 0 ; k < 8 ; ++ k ) { if ( residue_cascade [ j ] & ( 1 << k ) ) { r -> residue_books [ j ] [ k ] = get_bits ( f , 8 ) ; if ( r -> residue_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } else { r -> residue_books [ j ] [ k ] = - 1 ; } } } r -> classdata = ( uint8 * * ) setup_malloc ( f , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; if ( ! r -> classdata ) return error ( f , VORBIS_outofmem ) ; memset ( r -> classdata , 0 , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; for ( j = 0 ; j < f -> codebooks [ r -> classbook ] . entries ; ++ j ) { int classwords = f -> codebooks [ r -> classbook ] . dimensions ; int temp = j ; r -> classdata [ j ] = ( uint8 * ) setup_malloc ( f , sizeof ( r -> classdata [ j ] [ 0 ] ) * classwords ) ; if ( r -> classdata [ j ] == NULL ) return error ( f , VORBIS_outofmem ) ; for ( k = classwords - 1 ; k >= 0 ; -- k ) { r -> classdata [ j ] [ k ] = temp % r -> classifications ; temp /= r -> classifications ; } } } f -> mapping_count = get_bits ( f , 6 ) + 1 ; f -> mapping = ( Mapping * ) setup_malloc ( f , f -> mapping_count * sizeof ( * f -> mapping ) ) ; if ( f -> mapping == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> mapping , 0 , f -> mapping_count * sizeof ( * f -> mapping ) ) ; for ( i = 0 ; i < f -> mapping_count ; ++ i ) { Mapping * m = f -> mapping + i ; int mapping_type = get_bits ( f , 16 ) ; if ( mapping_type != 0 ) return error ( f , VORBIS_invalid_setup ) ; m -> chan = ( MappingChannel * ) setup_malloc ( f , f -> channels * sizeof ( * m -> chan ) ) ; if ( m -> chan == NULL ) return error ( f , VORBIS_outofmem ) ; if ( get_bits ( f , 1 ) ) m -> submaps = get_bits ( f , 4 ) + 1 ; else m -> submaps = 1 ; if ( m -> submaps > max_submaps ) max_submaps = m -> submaps ; if ( get_bits ( f , 1 ) ) { m -> coupling_steps = get_bits ( f , 8 ) + 1 ; for ( k = 0 ; k < m -> coupling_steps ; ++ k ) { m -> chan [ k ] . magnitude = get_bits ( f , ilog ( f -> channels - 1 ) ) ; m -> chan [ k ] . angle = get_bits ( f , ilog ( f -> channels - 1 ) ) ; if ( m -> chan [ k ] . magnitude >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . angle >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . magnitude == m -> chan [ k ] . angle ) return error ( f , VORBIS_invalid_setup ) ; } } else m -> coupling_steps = 0 ; if ( get_bits ( f , 2 ) ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submaps > 1 ) { for ( j = 0 ; j < f -> channels ; ++ j ) { m -> chan [ j ] . mux = get_bits ( f , 4 ) ; if ( m -> chan [ j ] . mux >= m -> submaps ) return error ( f , VORBIS_invalid_setup ) ; } } else for ( j = 0 ; j < f -> channels ; ++ j ) m -> chan [ j ] . mux = 0 ; for ( j = 0 ; j < m -> submaps ; ++ j ) { get_bits ( f , 8 ) ; m -> submap_floor [ j ] = get_bits ( f , 8 ) ; m -> submap_residue [ j ] = get_bits ( f , 8 ) ; if ( m -> submap_floor [ j ] >= f -> floor_count ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submap_residue [ j ] >= f -> residue_count ) return error ( f , VORBIS_invalid_setup ) ; } } f -> mode_count = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < f -> mode_count ; ++ i ) { Mode * m = f -> mode_config + i ; m -> blockflag = get_bits ( f , 1 ) ; m -> windowtype = get_bits ( f , 16 ) ; m -> transformtype = get_bits ( f , 16 ) ; m -> mapping = get_bits ( f , 8 ) ; if ( m -> windowtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> transformtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> mapping >= f -> mapping_count ) return error ( f , VORBIS_invalid_setup ) ; } flush_packet ( f ) ; f -> previous_length = 0 ; for ( i = 0 ; i < f -> channels ; ++ i ) { f -> channel_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 ) ; f -> previous_window [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; f -> finalY [ i ] = ( int16 * ) setup_malloc ( f , sizeof ( int16 ) * longest_floorlist ) ; if ( f -> channel_buffers [ i ] == NULL || f -> previous_window [ i ] == NULL || f -> finalY [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> channel_buffers [ i ] , 0 , sizeof ( float ) * f -> blocksize_1 ) ; # ifdef STB_VORBIS_NO_DEFER_FLOOR f -> floor_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; if ( f -> floor_buffers [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; # endif } if ( ! init_blocksize ( f , 0 , f -> blocksize_0 ) ) return FALSE ; if ( ! init_blocksize ( f , 1 , f -> blocksize_1 ) ) return FALSE ; f -> blocksize [ 0 ] = f -> blocksize_0 ; f -> blocksize [ 1 ] = f -> blocksize_1 ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( integer_divide_table [ 1 ] [ 1 ] == 0 ) for ( i = 0 ; i < DIVTAB_NUMER ; ++ i ) for ( j = 1 ; j < DIVTAB_DENOM ; ++ j ) integer_divide_table [ i ] [ j ] = i / j ; # endif { uint32 imdct_mem = ( f -> blocksize_1 * sizeof ( float ) >> 1 ) ; uint32 classify_mem ; int i , max_part_read = 0 ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { Residue * r = f -> residue_config + i ; unsigned int actual_size = f -> blocksize_1 / 2 ; unsigned int limit_r_begin = r -> begin < actual_size ? r -> begin : actual_size ; unsigned int limit_r_end = r -> end < actual_size ? r -> end : actual_size ; int n_read = limit_r_end - limit_r_begin ; int part_read = n_read / r -> part_size ; if ( part_read > max_part_read ) max_part_read = part_read ; } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( uint8 * ) ) ; # else classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( int * ) ) ; # endif f -> temp_memory_required = classify_mem ; if ( imdct_mem > f -> temp_memory_required ) f -> temp_memory_required = imdct_mem ; } f -> first_decode = TRUE ; if ( f -> alloc . alloc_buffer ) { assert ( f -> temp_offset == f -> alloc . alloc_buffer_length_in_bytes ) ; if ( f -> setup_offset + sizeof ( * f ) + f -> temp_memory_required > ( unsigned ) f -> temp_offset ) return error ( f , VORBIS_outofmem ) ; } f -> first_audio_page_offset = stb_vorbis_get_file_offset ( f ) ; return TRUE ; }\n", "\n", "\n", "Target: mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV\n", "\n", "Sources:\n", "0: CWE-264 static int do_new_mount ( struct path * path , const char * fstype , int flags , int mnt_flags , const char * name , void * data ) { struct file_system_type * type ; struct user_namespace * user_ns = current -> nsproxy -> mnt_ns -> user_ns ; struct vfsmount * mnt ; int err ; if ( ! fstype ) return - EINVAL ; type = get_fs_type ( fstype ) ; if ( ! type ) return - ENODEV ; if ( user_ns != & init_user_ns ) { if ( ! ( type -> fs_flags & FS_USERNS_MOUNT ) ) { put_filesystem ( type ) ; return - EPERM ; } if ( ! ( type -> fs_flags & FS_USERNS_DEV_MOUNT ) ) { flags |= MS_NODEV ; mnt_flags |= MNT_NODEV ; } } mnt = vfs_kern_mount ( type , flags , name , data ) ; if ( ! IS_ERR ( mnt ) && ( type -> fs_flags & FS_HAS_SUBTYPE ) && ! mnt -> mnt_sb -> s_subtype ) mnt = fs_set_subtype ( mnt , fstype ) ; put_filesystem ( type ) ; if ( IS_ERR ( mnt ) ) return PTR_ERR ( mnt ) ; err = do_add_mount ( real_mount ( mnt ) , path , mnt_flags ) ; if ( err ) mntput ( mnt ) ; return err ; }\n", "\n", "1: CWE-269 static int do_new_mount ( struct path * path , const char * fstype , int flags , int mnt_flags , const char * name , void * data ) { struct file_system_type * type ; struct user_namespace * user_ns = current -> nsproxy -> mnt_ns -> user_ns ; struct vfsmount * mnt ; int err ; if ( ! fstype ) return - EINVAL ; type = get_fs_type ( fstype ) ; if ( ! type ) return - ENODEV ; if ( user_ns != & init_user_ns ) { if ( ! ( type -> fs_flags & FS_USERNS_MOUNT ) ) { put_filesystem ( type ) ; return - EPERM ; } if ( ! ( type -> fs_flags & FS_USERNS_DEV_MOUNT ) ) { flags |= MS_NODEV ; mnt_flags |= MNT_NODEV ; } } mnt = vfs_kern_mount ( type , flags , name , data ) ; if ( ! IS_ERR ( mnt ) && ( type -> fs_flags & FS_HAS_SUBTYPE ) && ! mnt -> mnt_sb -> s_subtype ) mnt = fs_set_subtype ( mnt , fstype ) ; put_filesystem ( type ) ; if ( IS_ERR ( mnt ) ) return PTR_ERR ( mnt ) ; err = do_add_mount ( real_mount ( mnt ) , path , mnt_flags ) ; if ( err ) mntput ( mnt ) ; return err ; }\n", "\n", "\n", "Target: priv_flags &= ~ ( IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING ) ; bond_dev ->\n", "\n", "Sources:\n", "0: CWE-000 static void bond_setup ( struct net_device * bond_dev ) { struct bonding * bond = netdev_priv ( bond_dev ) ; rwlock_init ( & bond -> lock ) ; rwlock_init ( & bond -> curr_slave_lock ) ; bond -> params = bonding_defaults ; bond -> dev = bond_dev ; INIT_LIST_HEAD ( & bond -> vlan_list ) ; ether_setup ( bond_dev ) ; bond_dev -> netdev_ops = & bond_netdev_ops ; bond_dev -> ethtool_ops = & bond_ethtool_ops ; bond_set_mode_ops ( bond , bond -> params . mode ) ; bond_dev -> destructor = bond_destructor ; bond_dev -> tx_queue_len = 0 ; bond_dev -> flags |= IFF_MASTER | IFF_MULTICAST ; bond_dev -> priv_flags |= IFF_BONDING ; bond_dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; bond_dev -> features |= NETIF_F_VLAN_CHALLENGED ; bond_dev -> features |= NETIF_F_LLTX ; bond_dev -> hw_features = BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER ; bond_dev -> hw_features &= ~ ( NETIF_F_ALL_CSUM & ~ NETIF_F_NO_CSUM ) ; bond_dev -> features |= bond_dev -> hw_features ; }\n", "\n", "1: CWE-264 static void bond_setup ( struct net_device * bond_dev ) { struct bonding * bond = netdev_priv ( bond_dev ) ; rwlock_init ( & bond -> lock ) ; rwlock_init ( & bond -> curr_slave_lock ) ; bond -> params = bonding_defaults ; bond -> dev = bond_dev ; INIT_LIST_HEAD ( & bond -> vlan_list ) ; ether_setup ( bond_dev ) ; bond_dev -> netdev_ops = & bond_netdev_ops ; bond_dev -> ethtool_ops = & bond_ethtool_ops ; bond_set_mode_ops ( bond , bond -> params . mode ) ; bond_dev -> destructor = bond_destructor ; bond_dev -> tx_queue_len = 0 ; bond_dev -> flags |= IFF_MASTER | IFF_MULTICAST ; bond_dev -> priv_flags |= IFF_BONDING ; bond_dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; bond_dev -> features |= NETIF_F_VLAN_CHALLENGED ; bond_dev -> features |= NETIF_F_LLTX ; bond_dev -> hw_features = BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER ; bond_dev -> hw_features &= ~ ( NETIF_F_ALL_CSUM & ~ NETIF_F_NO_CSUM ) ; bond_dev -> features |= bond_dev -> hw_features ; }\n", "\n", "\n", "Target: assoc ) { sctp_sock_rfree_frag ( skb ) skb ) ; sctp_skb_set_owner_r_frag ( skb , assoc ) { sctp_sock_rfree_frag ( skb ) skb ) ; sctp_skb_set_owner_r_frag ( skb , sctp_clear_pd ( oldsk ) ; } sctp_skb_for_each ( skb , & assoc -> ulpq . reasm , tmp ) { sctp_sock_rfree_frag ( skb ) ; sctp_skb_set_owner_r_frag ( skb , newsk ) ; } sctp_skb_for_each ( skb , & assoc -> ulpq . lobby , tmp ) { sctp_sock_rfree_frag ( skb ) ; sctp_skb_set_owner_r_frag ( skb , newsk\n", "\n", "Sources:\n", "0: CWE-000 static void sctp_sock_migrate ( struct sock * oldsk , struct sock * newsk , struct sctp_association * assoc , sctp_socket_type_t type ) { struct sctp_sock * oldsp = sctp_sk ( oldsk ) ; struct sctp_sock * newsp = sctp_sk ( newsk ) ; struct sctp_bind_bucket * pp ; struct sctp_endpoint * newep = newsp -> ep ; struct sk_buff * skb , * tmp ; struct sctp_ulpevent * event ; int flags = 0 ; newsk -> sk_sndbuf = oldsk -> sk_sndbuf ; newsk -> sk_rcvbuf = oldsk -> sk_rcvbuf ; inet_sk_copy_descendant ( newsk , oldsk ) ; newsp -> ep = newep ; newsp -> hmac = NULL ; pp = sctp_sk ( oldsk ) -> bind_hash ; sk_add_bind_node ( newsk , & pp -> owner ) ; sctp_sk ( newsk ) -> bind_hash = pp ; inet_sk ( newsk ) -> num = inet_sk ( oldsk ) -> num ; if ( PF_INET6 == assoc -> base . sk -> sk_family ) flags = SCTP_ADDR6_ALLOWED ; if ( assoc -> peer . ipv4_address ) flags |= SCTP_ADDR4_PEERSUPP ; if ( assoc -> peer . ipv6_address ) flags |= SCTP_ADDR6_PEERSUPP ; sctp_bind_addr_copy ( & newsp -> ep -> base . bind_addr , & oldsp -> ep -> base . bind_addr , SCTP_SCOPE_GLOBAL , GFP_KERNEL , flags ) ; sctp_skb_for_each ( skb , & oldsk -> sk_receive_queue , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { sctp_sock_rfree ( skb ) ; __skb_unlink ( skb , & oldsk -> sk_receive_queue ) ; __skb_queue_tail ( & newsk -> sk_receive_queue , skb ) ; sctp_skb_set_owner_r ( skb , newsk ) ; } } skb_queue_head_init ( & newsp -> pd_lobby ) ; sctp_sk ( newsk ) -> pd_mode = assoc -> ulpq . pd_mode ; if ( sctp_sk ( oldsk ) -> pd_mode ) { struct sk_buff_head * queue ; if ( assoc -> ulpq . pd_mode ) { queue = & newsp -> pd_lobby ; } else queue = & newsk -> sk_receive_queue ; sctp_skb_for_each ( skb , & oldsp -> pd_lobby , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { sctp_sock_rfree ( skb ) ; __skb_unlink ( skb , & oldsp -> pd_lobby ) ; __skb_queue_tail ( queue , skb ) ; sctp_skb_set_owner_r ( skb , newsk ) ; } } if ( assoc -> ulpq . pd_mode ) sctp_clear_pd ( oldsk ) ; } newsp -> type = type ; sctp_lock_sock ( newsk ) ; sctp_assoc_migrate ( assoc , newsk ) ; if ( sctp_state ( assoc , CLOSED ) && sctp_style ( newsk , TCP ) ) newsk -> sk_shutdown |= RCV_SHUTDOWN ; newsk -> sk_state = SCTP_SS_ESTABLISHED ; sctp_release_sock ( newsk ) ; }\n", "\n", "1: CWE-476 static void sctp_sock_migrate ( struct sock * oldsk , struct sock * newsk , struct sctp_association * assoc , sctp_socket_type_t type ) { struct sctp_sock * oldsp = sctp_sk ( oldsk ) ; struct sctp_sock * newsp = sctp_sk ( newsk ) ; struct sctp_bind_bucket * pp ; struct sctp_endpoint * newep = newsp -> ep ; struct sk_buff * skb , * tmp ; struct sctp_ulpevent * event ; int flags = 0 ; newsk -> sk_sndbuf = oldsk -> sk_sndbuf ; newsk -> sk_rcvbuf = oldsk -> sk_rcvbuf ; inet_sk_copy_descendant ( newsk , oldsk ) ; newsp -> ep = newep ; newsp -> hmac = NULL ; pp = sctp_sk ( oldsk ) -> bind_hash ; sk_add_bind_node ( newsk , & pp -> owner ) ; sctp_sk ( newsk ) -> bind_hash = pp ; inet_sk ( newsk ) -> num = inet_sk ( oldsk ) -> num ; if ( PF_INET6 == assoc -> base . sk -> sk_family ) flags = SCTP_ADDR6_ALLOWED ; if ( assoc -> peer . ipv4_address ) flags |= SCTP_ADDR4_PEERSUPP ; if ( assoc -> peer . ipv6_address ) flags |= SCTP_ADDR6_PEERSUPP ; sctp_bind_addr_copy ( & newsp -> ep -> base . bind_addr , & oldsp -> ep -> base . bind_addr , SCTP_SCOPE_GLOBAL , GFP_KERNEL , flags ) ; sctp_skb_for_each ( skb , & oldsk -> sk_receive_queue , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { sctp_sock_rfree ( skb ) ; __skb_unlink ( skb , & oldsk -> sk_receive_queue ) ; __skb_queue_tail ( & newsk -> sk_receive_queue , skb ) ; sctp_skb_set_owner_r ( skb , newsk ) ; } } skb_queue_head_init ( & newsp -> pd_lobby ) ; sctp_sk ( newsk ) -> pd_mode = assoc -> ulpq . pd_mode ; if ( sctp_sk ( oldsk ) -> pd_mode ) { struct sk_buff_head * queue ; if ( assoc -> ulpq . pd_mode ) { queue = & newsp -> pd_lobby ; } else queue = & newsk -> sk_receive_queue ; sctp_skb_for_each ( skb , & oldsp -> pd_lobby , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { sctp_sock_rfree ( skb ) ; __skb_unlink ( skb , & oldsp -> pd_lobby ) ; __skb_queue_tail ( queue , skb ) ; sctp_skb_set_owner_r ( skb , newsk ) ; } } if ( assoc -> ulpq . pd_mode ) sctp_clear_pd ( oldsk ) ; } newsp -> type = type ; sctp_lock_sock ( newsk ) ; sctp_assoc_migrate ( assoc , newsk ) ; if ( sctp_state ( assoc , CLOSED ) && sctp_style ( newsk , TCP ) ) newsk -> sk_shutdown |= RCV_SHUTDOWN ; newsk -> sk_state = SCTP_SS_ESTABLISHED ; sctp_release_sock ( newsk ) ; }\n", "\n", "\n", "Target: * ace ; unsigned\n", "\n", "Sources:\n", "0: CWE-190 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; }\n", "\n", "1: CWE-189 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; }\n", "\n", "\n", "Target: return res ; return 0 ;\n", "\n", "Sources:\n", "0: CWE-000 int sas_discover_end_dev ( struct domain_device * dev ) { int res ; res = sas_notify_lldd_dev_found ( dev ) ; if ( res ) return res ; sas_discover_event ( dev -> port , DISCE_PROBE ) ; return 0 ; }\n", "\n", "1: CWE-000 int sas_discover_sata ( struct domain_device * dev ) { int res ; if ( dev -> dev_type == SAS_SATA_PM ) return - ENODEV ; dev -> sata_dev . class = sas_get_ata_command_set ( dev ) ; sas_fill_in_rphy ( dev , dev -> rphy ) ; res = sas_notify_lldd_dev_found ( dev ) ; if ( res ) return res ; sas_discover_event ( dev -> port , DISCE_PROBE ) ; return 0 ; }\n", "\n", "\n", "Target: ( event , & data ,\n", "\n", "Sources:\n", "0: CWE-400 static void alpha_perf_event_irq_handler ( unsigned long la_ptr , struct pt_regs * regs ) { struct cpu_hw_events * cpuc ; struct perf_sample_data data ; struct perf_event * event ; struct hw_perf_event * hwc ; int idx , j ; __get_cpu_var ( irq_pmi_count ) ++ ; cpuc = & __get_cpu_var ( cpu_hw_events ) ; wrperfmon ( PERFMON_CMD_DISABLE , cpuc -> idx_mask ) ; if ( unlikely ( la_ptr >= alpha_pmu -> num_pmcs ) ) { irq_err_count ++ ; pr_warning ( \"PMI:sillyindex%ld\\\\n\" , la_ptr ) ; wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } idx = la_ptr ; perf_sample_data_init ( & data , 0 ) ; for ( j = 0 ; j < cpuc -> n_events ; j ++ ) { if ( cpuc -> current_idx [ j ] == idx ) break ; } if ( unlikely ( j == cpuc -> n_events ) ) { wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } event = cpuc -> event [ j ] ; if ( unlikely ( ! event ) ) { irq_err_count ++ ; pr_warning ( \"PMI:Noeventatindex%d!\\\\n\" , idx ) ; wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } hwc = & event -> hw ; alpha_perf_event_update ( event , hwc , idx , alpha_pmu -> pmc_max_period [ idx ] + 1 ) ; data . period = event -> hw . last_period ; if ( alpha_perf_event_set_period ( event , hwc , idx ) ) { if ( perf_event_overflow ( event , 1 , & data , regs ) ) { alpha_pmu_stop ( event , 0 ) ; } } wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; }\n", "\n", "1: CWE-400 static enum hrtimer_restart perf_swevent_hrtimer ( struct hrtimer * hrtimer ) { enum hrtimer_restart ret = HRTIMER_RESTART ; struct perf_sample_data data ; struct pt_regs * regs ; struct perf_event * event ; u64 period ; event = container_of ( hrtimer , struct perf_event , hw . hrtimer ) ; if ( event -> state != PERF_EVENT_STATE_ACTIVE ) return HRTIMER_NORESTART ; event -> pmu -> read ( event ) ; perf_sample_data_init ( & data , 0 ) ; data . period = event -> hw . last_period ; regs = get_irq_regs ( ) ; if ( regs && ! perf_exclude_event ( event , regs ) ) { if ( ! ( event -> attr . exclude_idle && current -> pid == 0 ) ) if ( perf_event_overflow ( event , 0 , & data , regs ) ) ret = HRTIMER_NORESTART ; } period = max_t ( u64 , 10000 , event -> hw . sample_period ) ; hrtimer_forward_now ( hrtimer , ns_to_ktime ( period ) ) ; return ret ; }\n", "\n", "2: CWE-400 static int x86_pmu_handle_irq ( struct pt_regs * regs ) { struct perf_sample_data data ; struct cpu_hw_events * cpuc ; struct perf_event * event ; int idx , handled = 0 ; u64 val ; perf_sample_data_init ( & data , 0 ) ; cpuc = & __get_cpu_var ( cpu_hw_events ) ; apic_write ( APIC_LVTPC , APIC_DM_NMI ) ; for ( idx = 0 ; idx < x86_pmu . num_counters ; idx ++ ) { if ( ! test_bit ( idx , cpuc -> active_mask ) ) { if ( __test_and_clear_bit ( idx , cpuc -> running ) ) handled ++ ; continue ; } event = cpuc -> events [ idx ] ; val = x86_perf_event_update ( event ) ; if ( val & ( 1ULL << ( x86_pmu . cntval_bits - 1 ) ) ) continue ; handled ++ ; data . period = event -> hw . last_period ; if ( ! x86_perf_event_set_period ( event ) ) continue ; if ( perf_event_overflow ( event , 1 , & data , regs ) ) x86_pmu_stop ( event , 0 ) ; } if ( handled ) inc_irq_stat ( apic_perf_irqs ) ; return handled ; }\n", "\n", "\n", "Target: siocb -> scm , false\n", "\n", "Sources:\n", "0: CWE-287 static int unix_dgram_sendmsg ( struct kiocb * kiocb , struct socket * sock , struct msghdr * msg , size_t len ) { struct sock_iocb * siocb = kiocb_to_siocb ( kiocb ) ; struct sock * sk = sock -> sk ; struct net * net = sock_net ( sk ) ; struct unix_sock * u = unix_sk ( sk ) ; struct sockaddr_un * sunaddr = msg -> msg_name ; struct sock * other = NULL ; int namelen = 0 ; int err ; unsigned int hash ; struct sk_buff * skb ; long timeo ; struct scm_cookie tmp_scm ; int max_level ; int data_len = 0 ; if ( NULL == siocb -> scm ) siocb -> scm = & tmp_scm ; wait_for_unix_gc ( ) ; err = scm_send ( sock , msg , siocb -> scm ) ; if ( err < 0 ) return err ; err = - EOPNOTSUPP ; if ( msg -> msg_flags & MSG_OOB ) goto out ; if ( msg -> msg_namelen ) { err = unix_mkname ( sunaddr , msg -> msg_namelen , & hash ) ; if ( err < 0 ) goto out ; namelen = err ; } else { sunaddr = NULL ; err = - ENOTCONN ; other = unix_peer_get ( sk ) ; if ( ! other ) goto out ; } if ( test_bit ( SOCK_PASSCRED , & sock -> flags ) && ! u -> addr && ( err = unix_autobind ( sock ) ) != 0 ) goto out ; err = - EMSGSIZE ; if ( len > sk -> sk_sndbuf - 32 ) goto out ; if ( len > SKB_MAX_ALLOC ) data_len = min_t ( size_t , len - SKB_MAX_ALLOC , MAX_SKB_FRAGS * PAGE_SIZE ) ; skb = sock_alloc_send_pskb ( sk , len - data_len , data_len , msg -> msg_flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out ; err = unix_scm_to_skb ( siocb -> scm , skb , true ) ; if ( err < 0 ) goto out_free ; max_level = err + 1 ; unix_get_secdata ( siocb -> scm , skb ) ; skb_put ( skb , len - data_len ) ; skb -> data_len = data_len ; skb -> len = len ; err = skb_copy_datagram_from_iovec ( skb , 0 , msg -> msg_iov , 0 , len ) ; if ( err ) goto out_free ; timeo = sock_sndtimeo ( sk , msg -> msg_flags & MSG_DONTWAIT ) ; restart : if ( ! other ) { err = - ECONNRESET ; if ( sunaddr == NULL ) goto out_free ; other = unix_find_other ( net , sunaddr , namelen , sk -> sk_type , hash , & err ) ; if ( other == NULL ) goto out_free ; } if ( sk_filter ( other , skb ) < 0 ) { err = len ; goto out_free ; } unix_state_lock ( other ) ; err = - EPERM ; if ( ! unix_may_send ( sk , other ) ) goto out_unlock ; if ( sock_flag ( other , SOCK_DEAD ) ) { unix_state_unlock ( other ) ; sock_put ( other ) ; err = 0 ; unix_state_lock ( sk ) ; if ( unix_peer ( sk ) == other ) { unix_peer ( sk ) = NULL ; unix_state_unlock ( sk ) ; unix_dgram_disconnected ( sk , other ) ; sock_put ( other ) ; err = - ECONNREFUSED ; } else { unix_state_unlock ( sk ) ; } other = NULL ; if ( err ) goto out_free ; goto restart ; } err = - EPIPE ; if ( other -> sk_shutdown & RCV_SHUTDOWN ) goto out_unlock ; if ( sk -> sk_type != SOCK_SEQPACKET ) { err = security_unix_may_send ( sk -> sk_socket , other -> sk_socket ) ; if ( err ) goto out_unlock ; } if ( unix_peer ( other ) != sk && unix_recvq_full ( other ) ) { if ( ! timeo ) { err = - EAGAIN ; goto out_unlock ; } timeo = unix_wait_for_peer ( other , timeo ) ; err = sock_intr_errno ( timeo ) ; if ( signal_pending ( current ) ) goto out_free ; goto restart ; } if ( sock_flag ( other , SOCK_RCVTSTAMP ) ) __net_timestamp ( skb ) ; maybe_add_creds ( skb , sock , other ) ; skb_queue_tail ( & other -> sk_receive_queue , skb ) ; if ( max_level > unix_sk ( other ) -> recursion_level ) unix_sk ( other ) -> recursion_level = max_level ; unix_state_unlock ( other ) ; other -> sk_data_ready ( other , len ) ; sock_put ( other ) ; scm_destroy ( siocb -> scm ) ; return len ; out_unlock : unix_state_unlock ( other ) ; out_free : kfree_skb ( skb ) ; out : if ( other ) sock_put ( other ) ; scm_destroy ( siocb -> scm ) ; return err ; }\n", "\n", "1: CWE-287 static int unix_stream_sendmsg ( struct kiocb * kiocb , struct socket * sock , struct msghdr * msg , size_t len ) { struct sock_iocb * siocb = kiocb_to_siocb ( kiocb ) ; struct sock * sk = sock -> sk ; struct sock * other = NULL ; int err , size ; struct sk_buff * skb ; int sent = 0 ; struct scm_cookie tmp_scm ; bool fds_sent = false ; int max_level ; if ( NULL == siocb -> scm ) siocb -> scm = & tmp_scm ; wait_for_unix_gc ( ) ; err = scm_send ( sock , msg , siocb -> scm ) ; if ( err < 0 ) return err ; err = - EOPNOTSUPP ; if ( msg -> msg_flags & MSG_OOB ) goto out_err ; if ( msg -> msg_namelen ) { err = sk -> sk_state == TCP_ESTABLISHED ? - EISCONN : - EOPNOTSUPP ; goto out_err ; } else { err = - ENOTCONN ; other = unix_peer ( sk ) ; if ( ! other ) goto out_err ; } if ( sk -> sk_shutdown & SEND_SHUTDOWN ) goto pipe_err ; while ( sent < len ) { size = len - sent ; if ( size > ( ( sk -> sk_sndbuf >> 1 ) - 64 ) ) size = ( sk -> sk_sndbuf >> 1 ) - 64 ; if ( size > SKB_MAX_ALLOC ) size = SKB_MAX_ALLOC ; skb = sock_alloc_send_skb ( sk , size , msg -> msg_flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out_err ; size = min_t ( int , size , skb_tailroom ( skb ) ) ; err = unix_scm_to_skb ( siocb -> scm , skb , ! fds_sent ) ; if ( err < 0 ) { kfree_skb ( skb ) ; goto out_err ; } max_level = err + 1 ; fds_sent = true ; err = memcpy_fromiovec ( skb_put ( skb , size ) , msg -> msg_iov , size ) ; if ( err ) { kfree_skb ( skb ) ; goto out_err ; } unix_state_lock ( other ) ; if ( sock_flag ( other , SOCK_DEAD ) || ( other -> sk_shutdown & RCV_SHUTDOWN ) ) goto pipe_err_free ; maybe_add_creds ( skb , sock , other ) ; skb_queue_tail ( & other -> sk_receive_queue , skb ) ; if ( max_level > unix_sk ( other ) -> recursion_level ) unix_sk ( other ) -> recursion_level = max_level ; unix_state_unlock ( other ) ; other -> sk_data_ready ( other , size ) ; sent += size ; } scm_destroy ( siocb -> scm ) ; siocb -> scm = NULL ; return sent ; pipe_err_free : unix_state_unlock ( other ) ; kfree_skb ( skb ) ; pipe_err : if ( sent == 0 && ! ( msg -> msg_flags & MSG_NOSIGNAL ) ) send_sig ( SIGPIPE , current , 0 ) ; err = - EPIPE ; out_err : scm_destroy ( siocb -> scm ) ; siocb -> scm = NULL ; return sent ? : err ; }\n", "\n", "\n", "Target: ; bad_fork_cleanup_io : if ( p -> p -> io_context ) exit_io_context ( p\n", "\n", "Sources:\n", "0: CWE-20 static struct task_struct * copy_process ( unsigned long clone_flags , unsigned long stack_start , struct pt_regs * regs , unsigned long stack_size , int __user * child_tidptr , struct pid * pid , int trace ) { int retval ; struct task_struct * p ; int cgroup_callbacks_done = 0 ; if ( ( clone_flags & ( CLONE_NEWNS | CLONE_FS ) ) == ( CLONE_NEWNS | CLONE_FS ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_THREAD ) && ! ( clone_flags & CLONE_SIGHAND ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_SIGHAND ) && ! ( clone_flags & CLONE_VM ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_PARENT ) && current -> signal -> flags & SIGNAL_UNKILLABLE ) return ERR_PTR ( - EINVAL ) ; retval = security_task_create ( clone_flags ) ; if ( retval ) goto fork_out ; retval = - ENOMEM ; p = dup_task_struct ( current ) ; if ( ! p ) goto fork_out ; ftrace_graph_init_task ( p ) ; rt_mutex_init_task ( p ) ; # ifdef CONFIG_PROVE_LOCKING DEBUG_LOCKS_WARN_ON ( ! p -> hardirqs_enabled ) ; DEBUG_LOCKS_WARN_ON ( ! p -> softirqs_enabled ) ; # endif retval = - EAGAIN ; if ( atomic_read ( & p -> real_cred -> user -> processes ) >= p -> signal -> rlim [ RLIMIT_NPROC ] . rlim_cur ) { if ( ! capable ( CAP_SYS_ADMIN ) && ! capable ( CAP_SYS_RESOURCE ) && p -> real_cred -> user != INIT_USER ) goto bad_fork_free ; } retval = copy_creds ( p , clone_flags ) ; if ( retval < 0 ) goto bad_fork_free ; retval = - EAGAIN ; if ( nr_threads >= max_threads ) goto bad_fork_cleanup_count ; if ( ! try_module_get ( task_thread_info ( p ) -> exec_domain -> module ) ) goto bad_fork_cleanup_count ; p -> did_exec = 0 ; delayacct_tsk_init ( p ) ; copy_flags ( clone_flags , p ) ; INIT_LIST_HEAD ( & p -> children ) ; INIT_LIST_HEAD ( & p -> sibling ) ; rcu_copy_process ( p ) ; p -> vfork_done = NULL ; spin_lock_init ( & p -> alloc_lock ) ; init_sigpending ( & p -> pending ) ; p -> utime = cputime_zero ; p -> stime = cputime_zero ; p -> gtime = cputime_zero ; p -> utimescaled = cputime_zero ; p -> stimescaled = cputime_zero ; p -> prev_utime = cputime_zero ; p -> prev_stime = cputime_zero ; p -> default_timer_slack_ns = current -> timer_slack_ns ; task_io_accounting_init ( & p -> ioac ) ; acct_clear_integrals ( p ) ; posix_cpu_timers_init ( p ) ; p -> lock_depth = - 1 ; do_posix_clock_monotonic_gettime ( & p -> start_time ) ; p -> real_start_time = p -> start_time ; monotonic_to_bootbased ( & p -> real_start_time ) ; p -> io_context = NULL ; p -> audit_context = NULL ; cgroup_fork ( p ) ; # ifdef CONFIG_NUMA p -> mempolicy = mpol_dup ( p -> mempolicy ) ; if ( IS_ERR ( p -> mempolicy ) ) { retval = PTR_ERR ( p -> mempolicy ) ; p -> mempolicy = NULL ; goto bad_fork_cleanup_cgroup ; } mpol_fix_fork_child_flag ( p ) ; # endif # ifdef CONFIG_TRACE_IRQFLAGS p -> irq_events = 0 ; # ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW p -> hardirqs_enabled = 1 ; # else p -> hardirqs_enabled = 0 ; # endif p -> hardirq_enable_ip = 0 ; p -> hardirq_enable_event = 0 ; p -> hardirq_disable_ip = _THIS_IP_ ; p -> hardirq_disable_event = 0 ; p -> softirqs_enabled = 1 ; p -> softirq_enable_ip = _THIS_IP_ ; p -> softirq_enable_event = 0 ; p -> softirq_disable_ip = 0 ; p -> softirq_disable_event = 0 ; p -> hardirq_context = 0 ; p -> softirq_context = 0 ; # endif # ifdef CONFIG_LOCKDEP p -> lockdep_depth = 0 ; p -> curr_chain_key = 0 ; p -> lockdep_recursion = 0 ; # endif # ifdef CONFIG_DEBUG_MUTEXES p -> blocked_on = NULL ; # endif p -> bts = NULL ; p -> stack_start = stack_start ; sched_fork ( p , clone_flags ) ; retval = perf_event_init_task ( p ) ; if ( retval ) goto bad_fork_cleanup_policy ; if ( ( retval = audit_alloc ( p ) ) ) goto bad_fork_cleanup_policy ; if ( ( retval = copy_semundo ( clone_flags , p ) ) ) goto bad_fork_cleanup_audit ; if ( ( retval = copy_files ( clone_flags , p ) ) ) goto bad_fork_cleanup_semundo ; if ( ( retval = copy_fs ( clone_flags , p ) ) ) goto bad_fork_cleanup_files ; if ( ( retval = copy_sighand ( clone_flags , p ) ) ) goto bad_fork_cleanup_fs ; if ( ( retval = copy_signal ( clone_flags , p ) ) ) goto bad_fork_cleanup_sighand ; if ( ( retval = copy_mm ( clone_flags , p ) ) ) goto bad_fork_cleanup_signal ; if ( ( retval = copy_namespaces ( clone_flags , p ) ) ) goto bad_fork_cleanup_mm ; if ( ( retval = copy_io ( clone_flags , p ) ) ) goto bad_fork_cleanup_namespaces ; retval = copy_thread ( clone_flags , stack_start , stack_size , p , regs ) ; if ( retval ) goto bad_fork_cleanup_io ; if ( pid != & init_struct_pid ) { retval = - ENOMEM ; pid = alloc_pid ( p -> nsproxy -> pid_ns ) ; if ( ! pid ) goto bad_fork_cleanup_io ; if ( clone_flags & CLONE_NEWPID ) { retval = pid_ns_prepare_proc ( p -> nsproxy -> pid_ns ) ; if ( retval < 0 ) goto bad_fork_free_pid ; } } p -> pid = pid_nr ( pid ) ; p -> tgid = p -> pid ; if ( clone_flags & CLONE_THREAD ) p -> tgid = current -> tgid ; if ( current -> nsproxy != p -> nsproxy ) { retval = ns_cgroup_clone ( p , pid ) ; if ( retval ) goto bad_fork_free_pid ; } p -> set_child_tid = ( clone_flags & CLONE_CHILD_SETTID ) ? child_tidptr : NULL ; p -> clear_child_tid = ( clone_flags & CLONE_CHILD_CLEARTID ) ? child_tidptr : NULL ; # ifdef CONFIG_FUTEX p -> robust_list = NULL ; # ifdef CONFIG_COMPAT p -> compat_robust_list = NULL ; # endif INIT_LIST_HEAD ( & p -> pi_state_list ) ; p -> pi_state_cache = NULL ; # endif if ( ( clone_flags & ( CLONE_VM | CLONE_VFORK ) ) == CLONE_VM ) p -> sas_ss_sp = p -> sas_ss_size = 0 ; clear_tsk_thread_flag ( p , TIF_SYSCALL_TRACE ) ; # ifdef TIF_SYSCALL_EMU clear_tsk_thread_flag ( p , TIF_SYSCALL_EMU ) ; # endif clear_all_latency_tracing ( p ) ; p -> exit_signal = ( clone_flags & CLONE_THREAD ) ? - 1 : ( clone_flags & CSIGNAL ) ; p -> pdeath_signal = 0 ; p -> exit_state = 0 ; p -> group_leader = p ; INIT_LIST_HEAD ( & p -> thread_group ) ; cgroup_fork_callbacks ( p ) ; cgroup_callbacks_done = 1 ; write_lock_irq ( & tasklist_lock ) ; p -> cpus_allowed = current -> cpus_allowed ; p -> rt . nr_cpus_allowed = current -> rt . nr_cpus_allowed ; if ( unlikely ( ! cpu_isset ( task_cpu ( p ) , p -> cpus_allowed ) || ! cpu_online ( task_cpu ( p ) ) ) ) set_task_cpu ( p , smp_processor_id ( ) ) ; if ( clone_flags & ( CLONE_PARENT | CLONE_THREAD ) ) { p -> real_parent = current -> real_parent ; p -> parent_exec_id = current -> parent_exec_id ; } else { p -> real_parent = current ; p -> parent_exec_id = current -> self_exec_id ; } spin_lock ( & current -> sighand -> siglock ) ; recalc_sigpending ( ) ; if ( signal_pending ( current ) ) { spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; retval = - ERESTARTNOINTR ; goto bad_fork_free_pid ; } if ( clone_flags & CLONE_THREAD ) { atomic_inc ( & current -> signal -> count ) ; atomic_inc ( & current -> signal -> live ) ; p -> group_leader = current -> group_leader ; list_add_tail_rcu ( & p -> thread_group , & p -> group_leader -> thread_group ) ; } if ( likely ( p -> pid ) ) { list_add_tail ( & p -> sibling , & p -> real_parent -> children ) ; tracehook_finish_clone ( p , clone_flags , trace ) ; if ( thread_group_leader ( p ) ) { if ( clone_flags & CLONE_NEWPID ) p -> nsproxy -> pid_ns -> child_reaper = p ; p -> signal -> leader_pid = pid ; tty_kref_put ( p -> signal -> tty ) ; p -> signal -> tty = tty_kref_get ( current -> signal -> tty ) ; attach_pid ( p , PIDTYPE_PGID , task_pgrp ( current ) ) ; attach_pid ( p , PIDTYPE_SID , task_session ( current ) ) ; list_add_tail_rcu ( & p -> tasks , & init_task . tasks ) ; __get_cpu_var ( process_counts ) ++ ; } attach_pid ( p , PIDTYPE_PID , pid ) ; nr_threads ++ ; } total_forks ++ ; spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; proc_fork_connector ( p ) ; cgroup_post_fork ( p ) ; perf_event_fork ( p ) ; return p ; bad_fork_free_pid : if ( pid != & init_struct_pid ) free_pid ( pid ) ; bad_fork_cleanup_io : put_io_context ( p -> io_context ) ; bad_fork_cleanup_namespaces : exit_task_namespaces ( p ) ; bad_fork_cleanup_mm : if ( p -> mm ) mmput ( p -> mm ) ; bad_fork_cleanup_signal : if ( ! ( clone_flags & CLONE_THREAD ) ) __cleanup_signal ( p -> signal ) ; bad_fork_cleanup_sighand : __cleanup_sighand ( p -> sighand ) ; bad_fork_cleanup_fs : exit_fs ( p ) ; bad_fork_cleanup_files : exit_files ( p ) ; bad_fork_cleanup_semundo : exit_sem ( p ) ; bad_fork_cleanup_audit : audit_free ( p ) ; bad_fork_cleanup_policy : perf_event_free_task ( p ) ; # ifdef CONFIG_NUMA mpol_put ( p -> mempolicy ) ; bad_fork_cleanup_cgroup : # endif cgroup_exit ( p , cgroup_callbacks_done ) ; delayacct_tsk_free ( p ) ; module_put ( task_thread_info ( p ) -> exec_domain -> module ) ; bad_fork_cleanup_count : atomic_dec ( & p -> cred -> user -> processes ) ; exit_creds ( p ) ; bad_fork_free : free_task ( p ) ; fork_out : return ERR_PTR ( retval ) ; }\n", "\n", "1: CWE-400 static struct task_struct * copy_process ( unsigned long clone_flags , unsigned long stack_start , struct pt_regs * regs , unsigned long stack_size , int __user * child_tidptr , struct pid * pid , int trace ) { int retval ; struct task_struct * p ; int cgroup_callbacks_done = 0 ; if ( ( clone_flags & ( CLONE_NEWNS | CLONE_FS ) ) == ( CLONE_NEWNS | CLONE_FS ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_THREAD ) && ! ( clone_flags & CLONE_SIGHAND ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_SIGHAND ) && ! ( clone_flags & CLONE_VM ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_PARENT ) && current -> signal -> flags & SIGNAL_UNKILLABLE ) return ERR_PTR ( - EINVAL ) ; retval = security_task_create ( clone_flags ) ; if ( retval ) goto fork_out ; retval = - ENOMEM ; p = dup_task_struct ( current ) ; if ( ! p ) goto fork_out ; ftrace_graph_init_task ( p ) ; rt_mutex_init_task ( p ) ; # ifdef CONFIG_PROVE_LOCKING DEBUG_LOCKS_WARN_ON ( ! p -> hardirqs_enabled ) ; DEBUG_LOCKS_WARN_ON ( ! p -> softirqs_enabled ) ; # endif retval = - EAGAIN ; if ( atomic_read ( & p -> real_cred -> user -> processes ) >= p -> signal -> rlim [ RLIMIT_NPROC ] . rlim_cur ) { if ( ! capable ( CAP_SYS_ADMIN ) && ! capable ( CAP_SYS_RESOURCE ) && p -> real_cred -> user != INIT_USER ) goto bad_fork_free ; } retval = copy_creds ( p , clone_flags ) ; if ( retval < 0 ) goto bad_fork_free ; retval = - EAGAIN ; if ( nr_threads >= max_threads ) goto bad_fork_cleanup_count ; if ( ! try_module_get ( task_thread_info ( p ) -> exec_domain -> module ) ) goto bad_fork_cleanup_count ; p -> did_exec = 0 ; delayacct_tsk_init ( p ) ; copy_flags ( clone_flags , p ) ; INIT_LIST_HEAD ( & p -> children ) ; INIT_LIST_HEAD ( & p -> sibling ) ; rcu_copy_process ( p ) ; p -> vfork_done = NULL ; spin_lock_init ( & p -> alloc_lock ) ; init_sigpending ( & p -> pending ) ; p -> utime = cputime_zero ; p -> stime = cputime_zero ; p -> gtime = cputime_zero ; p -> utimescaled = cputime_zero ; p -> stimescaled = cputime_zero ; p -> prev_utime = cputime_zero ; p -> prev_stime = cputime_zero ; p -> default_timer_slack_ns = current -> timer_slack_ns ; task_io_accounting_init ( & p -> ioac ) ; acct_clear_integrals ( p ) ; posix_cpu_timers_init ( p ) ; p -> lock_depth = - 1 ; do_posix_clock_monotonic_gettime ( & p -> start_time ) ; p -> real_start_time = p -> start_time ; monotonic_to_bootbased ( & p -> real_start_time ) ; p -> io_context = NULL ; p -> audit_context = NULL ; cgroup_fork ( p ) ; # ifdef CONFIG_NUMA p -> mempolicy = mpol_dup ( p -> mempolicy ) ; if ( IS_ERR ( p -> mempolicy ) ) { retval = PTR_ERR ( p -> mempolicy ) ; p -> mempolicy = NULL ; goto bad_fork_cleanup_cgroup ; } mpol_fix_fork_child_flag ( p ) ; # endif # ifdef CONFIG_TRACE_IRQFLAGS p -> irq_events = 0 ; # ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW p -> hardirqs_enabled = 1 ; # else p -> hardirqs_enabled = 0 ; # endif p -> hardirq_enable_ip = 0 ; p -> hardirq_enable_event = 0 ; p -> hardirq_disable_ip = _THIS_IP_ ; p -> hardirq_disable_event = 0 ; p -> softirqs_enabled = 1 ; p -> softirq_enable_ip = _THIS_IP_ ; p -> softirq_enable_event = 0 ; p -> softirq_disable_ip = 0 ; p -> softirq_disable_event = 0 ; p -> hardirq_context = 0 ; p -> softirq_context = 0 ; # endif # ifdef CONFIG_LOCKDEP p -> lockdep_depth = 0 ; p -> curr_chain_key = 0 ; p -> lockdep_recursion = 0 ; # endif # ifdef CONFIG_DEBUG_MUTEXES p -> blocked_on = NULL ; # endif p -> bts = NULL ; p -> stack_start = stack_start ; sched_fork ( p , clone_flags ) ; retval = perf_event_init_task ( p ) ; if ( retval ) goto bad_fork_cleanup_policy ; if ( ( retval = audit_alloc ( p ) ) ) goto bad_fork_cleanup_policy ; if ( ( retval = copy_semundo ( clone_flags , p ) ) ) goto bad_fork_cleanup_audit ; if ( ( retval = copy_files ( clone_flags , p ) ) ) goto bad_fork_cleanup_semundo ; if ( ( retval = copy_fs ( clone_flags , p ) ) ) goto bad_fork_cleanup_files ; if ( ( retval = copy_sighand ( clone_flags , p ) ) ) goto bad_fork_cleanup_fs ; if ( ( retval = copy_signal ( clone_flags , p ) ) ) goto bad_fork_cleanup_sighand ; if ( ( retval = copy_mm ( clone_flags , p ) ) ) goto bad_fork_cleanup_signal ; if ( ( retval = copy_namespaces ( clone_flags , p ) ) ) goto bad_fork_cleanup_mm ; if ( ( retval = copy_io ( clone_flags , p ) ) ) goto bad_fork_cleanup_namespaces ; retval = copy_thread ( clone_flags , stack_start , stack_size , p , regs ) ; if ( retval ) goto bad_fork_cleanup_io ; if ( pid != & init_struct_pid ) { retval = - ENOMEM ; pid = alloc_pid ( p -> nsproxy -> pid_ns ) ; if ( ! pid ) goto bad_fork_cleanup_io ; if ( clone_flags & CLONE_NEWPID ) { retval = pid_ns_prepare_proc ( p -> nsproxy -> pid_ns ) ; if ( retval < 0 ) goto bad_fork_free_pid ; } } p -> pid = pid_nr ( pid ) ; p -> tgid = p -> pid ; if ( clone_flags & CLONE_THREAD ) p -> tgid = current -> tgid ; if ( current -> nsproxy != p -> nsproxy ) { retval = ns_cgroup_clone ( p , pid ) ; if ( retval ) goto bad_fork_free_pid ; } p -> set_child_tid = ( clone_flags & CLONE_CHILD_SETTID ) ? child_tidptr : NULL ; p -> clear_child_tid = ( clone_flags & CLONE_CHILD_CLEARTID ) ? child_tidptr : NULL ; # ifdef CONFIG_FUTEX p -> robust_list = NULL ; # ifdef CONFIG_COMPAT p -> compat_robust_list = NULL ; # endif INIT_LIST_HEAD ( & p -> pi_state_list ) ; p -> pi_state_cache = NULL ; # endif if ( ( clone_flags & ( CLONE_VM | CLONE_VFORK ) ) == CLONE_VM ) p -> sas_ss_sp = p -> sas_ss_size = 0 ; clear_tsk_thread_flag ( p , TIF_SYSCALL_TRACE ) ; # ifdef TIF_SYSCALL_EMU clear_tsk_thread_flag ( p , TIF_SYSCALL_EMU ) ; # endif clear_all_latency_tracing ( p ) ; p -> exit_signal = ( clone_flags & CLONE_THREAD ) ? - 1 : ( clone_flags & CSIGNAL ) ; p -> pdeath_signal = 0 ; p -> exit_state = 0 ; p -> group_leader = p ; INIT_LIST_HEAD ( & p -> thread_group ) ; cgroup_fork_callbacks ( p ) ; cgroup_callbacks_done = 1 ; write_lock_irq ( & tasklist_lock ) ; p -> cpus_allowed = current -> cpus_allowed ; p -> rt . nr_cpus_allowed = current -> rt . nr_cpus_allowed ; if ( unlikely ( ! cpu_isset ( task_cpu ( p ) , p -> cpus_allowed ) || ! cpu_online ( task_cpu ( p ) ) ) ) set_task_cpu ( p , smp_processor_id ( ) ) ; if ( clone_flags & ( CLONE_PARENT | CLONE_THREAD ) ) { p -> real_parent = current -> real_parent ; p -> parent_exec_id = current -> parent_exec_id ; } else { p -> real_parent = current ; p -> parent_exec_id = current -> self_exec_id ; } spin_lock ( & current -> sighand -> siglock ) ; recalc_sigpending ( ) ; if ( signal_pending ( current ) ) { spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; retval = - ERESTARTNOINTR ; goto bad_fork_free_pid ; } if ( clone_flags & CLONE_THREAD ) { atomic_inc ( & current -> signal -> count ) ; atomic_inc ( & current -> signal -> live ) ; p -> group_leader = current -> group_leader ; list_add_tail_rcu ( & p -> thread_group , & p -> group_leader -> thread_group ) ; } if ( likely ( p -> pid ) ) { list_add_tail ( & p -> sibling , & p -> real_parent -> children ) ; tracehook_finish_clone ( p , clone_flags , trace ) ; if ( thread_group_leader ( p ) ) { if ( clone_flags & CLONE_NEWPID ) p -> nsproxy -> pid_ns -> child_reaper = p ; p -> signal -> leader_pid = pid ; tty_kref_put ( p -> signal -> tty ) ; p -> signal -> tty = tty_kref_get ( current -> signal -> tty ) ; attach_pid ( p , PIDTYPE_PGID , task_pgrp ( current ) ) ; attach_pid ( p , PIDTYPE_SID , task_session ( current ) ) ; list_add_tail_rcu ( & p -> tasks , & init_task . tasks ) ; __get_cpu_var ( process_counts ) ++ ; } attach_pid ( p , PIDTYPE_PID , pid ) ; nr_threads ++ ; } total_forks ++ ; spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; proc_fork_connector ( p ) ; cgroup_post_fork ( p ) ; perf_event_fork ( p ) ; return p ; bad_fork_free_pid : if ( pid != & init_struct_pid ) free_pid ( pid ) ; bad_fork_cleanup_io : put_io_context ( p -> io_context ) ; bad_fork_cleanup_namespaces : exit_task_namespaces ( p ) ; bad_fork_cleanup_mm : if ( p -> mm ) mmput ( p -> mm ) ; bad_fork_cleanup_signal : if ( ! ( clone_flags & CLONE_THREAD ) ) __cleanup_signal ( p -> signal ) ; bad_fork_cleanup_sighand : __cleanup_sighand ( p -> sighand ) ; bad_fork_cleanup_fs : exit_fs ( p ) ; bad_fork_cleanup_files : exit_files ( p ) ; bad_fork_cleanup_semundo : exit_sem ( p ) ; bad_fork_cleanup_audit : audit_free ( p ) ; bad_fork_cleanup_policy : perf_event_free_task ( p ) ; # ifdef CONFIG_NUMA mpol_put ( p -> mempolicy ) ; bad_fork_cleanup_cgroup : # endif cgroup_exit ( p , cgroup_callbacks_done ) ; delayacct_tsk_free ( p ) ; module_put ( task_thread_info ( p ) -> exec_domain -> module ) ; bad_fork_cleanup_count : atomic_dec ( & p -> cred -> user -> processes ) ; exit_creds ( p ) ; bad_fork_free : free_task ( p ) ; fork_out : return ERR_PTR ( retval ) ; }\n", "\n", "\n", "Target: , GID_INVALID , MODE_INVALID ) ; }\n", "\n", "Sources:\n", "0: CWE-264 static int timer_start ( Unit * u ) { Timer * t = TIMER ( u ) ; TimerValue * v ; assert ( t ) ; assert ( t -> state == TIMER_DEAD || t -> state == TIMER_FAILED ) ; if ( UNIT_TRIGGER ( u ) -> load_state != UNIT_LOADED ) return - ENOENT ; t -> last_trigger = DUAL_TIMESTAMP_NULL ; LIST_FOREACH ( value , v , t -> values ) if ( v -> base == TIMER_ACTIVE ) v -> disabled = false ; if ( t -> stamp_path ) { struct stat st ; if ( stat ( t -> stamp_path , & st ) >= 0 ) t -> last_trigger . realtime = timespec_load ( & st . st_atim ) ; else if ( errno == ENOENT ) touch_file ( t -> stamp_path , true , USEC_INFINITY , UID_INVALID , GID_INVALID , 0 ) ; } t -> result = TIMER_SUCCESS ; timer_enter_waiting ( t , true ) ; return 1 ; }\n", "\n", "1: CWE-264 int touch ( const char * path ) { return touch_file ( path , false , USEC_INFINITY , UID_INVALID , GID_INVALID , 0 ) ; }\n", "\n", "\n", "Target: break ; } if ( task -> tk_rebind_retry == 0 ) break ; task -> tk_rebind_retry -- ;\n", "\n", "Sources:\n", "0: CWE-400 static void call_bind_status ( struct rpc_task * task ) { int status = - EIO ; if ( task -> tk_status >= 0 ) { dprint_status ( task ) ; task -> tk_status = 0 ; task -> tk_action = call_connect ; return ; } switch ( task -> tk_status ) { case - ENOMEM : dprintk ( \"RPC:%5urpcbindoutofmemory\\\\n\" , task -> tk_pid ) ; rpc_delay ( task , HZ >> 2 ) ; goto retry_timeout ; case - EACCES : dprintk ( \"RPC:%5uremoterpcbind:RPCprogram/version\" \"unavailable\\\\n\" , task -> tk_pid ) ; if ( task -> tk_msg . rpc_proc -> p_proc == 0 ) { status = - EOPNOTSUPP ; break ; } rpc_delay ( task , 3 * HZ ) ; goto retry_timeout ; case - ETIMEDOUT : dprintk ( \"RPC:%5urpcbindrequesttimedout\\\\n\" , task -> tk_pid ) ; goto retry_timeout ; case - EPFNOSUPPORT : dprintk ( \"RPC:%5uunrecognizedremoterpcbindservice\\\\n\" , task -> tk_pid ) ; break ; case - EPROTONOSUPPORT : dprintk ( \"RPC:%5uremoterpcbindversionunavailable,retrying\\\\n\" , task -> tk_pid ) ; task -> tk_status = 0 ; task -> tk_action = call_bind ; return ; case - ECONNREFUSED : case - ECONNRESET : case - ENOTCONN : case - EHOSTDOWN : case - EHOSTUNREACH : case - ENETUNREACH : case - EPIPE : dprintk ( \"RPC:%5uremoterpcbindunreachable:%d\\\\n\" , task -> tk_pid , task -> tk_status ) ; if ( ! RPC_IS_SOFTCONN ( task ) ) { rpc_delay ( task , 5 * HZ ) ; goto retry_timeout ; } status = task -> tk_status ; break ; default : dprintk ( \"RPC:%5uunrecognizedrpcbinderror(%d)\\\\n\" , task -> tk_pid , - task -> tk_status ) ; } rpc_exit ( task , status ) ; return ; retry_timeout : task -> tk_action = call_timeout ; }\n", "\n", "1: CWE-399 static void call_bind_status ( struct rpc_task * task ) { int status = - EIO ; if ( task -> tk_status >= 0 ) { dprint_status ( task ) ; task -> tk_status = 0 ; task -> tk_action = call_connect ; return ; } switch ( task -> tk_status ) { case - ENOMEM : dprintk ( \"RPC:%5urpcbindoutofmemory\\\\n\" , task -> tk_pid ) ; rpc_delay ( task , HZ >> 2 ) ; goto retry_timeout ; case - EACCES : dprintk ( \"RPC:%5uremoterpcbind:RPCprogram/version\" \"unavailable\\\\n\" , task -> tk_pid ) ; if ( task -> tk_msg . rpc_proc -> p_proc == 0 ) { status = - EOPNOTSUPP ; break ; } rpc_delay ( task , 3 * HZ ) ; goto retry_timeout ; case - ETIMEDOUT : dprintk ( \"RPC:%5urpcbindrequesttimedout\\\\n\" , task -> tk_pid ) ; goto retry_timeout ; case - EPFNOSUPPORT : dprintk ( \"RPC:%5uunrecognizedremoterpcbindservice\\\\n\" , task -> tk_pid ) ; break ; case - EPROTONOSUPPORT : dprintk ( \"RPC:%5uremoterpcbindversionunavailable,retrying\\\\n\" , task -> tk_pid ) ; task -> tk_status = 0 ; task -> tk_action = call_bind ; return ; case - ECONNREFUSED : case - ECONNRESET : case - ENOTCONN : case - EHOSTDOWN : case - EHOSTUNREACH : case - ENETUNREACH : case - EPIPE : dprintk ( \"RPC:%5uremoterpcbindunreachable:%d\\\\n\" , task -> tk_pid , task -> tk_status ) ; if ( ! RPC_IS_SOFTCONN ( task ) ) { rpc_delay ( task , 5 * HZ ) ; goto retry_timeout ; } status = task -> tk_status ; break ; default : dprintk ( \"RPC:%5uunrecognizedrpcbinderror(%d)\\\\n\" , task -> tk_pid , - task -> tk_status ) ; } rpc_exit ( task , status ) ; return ; retry_timeout : task -> tk_action = call_timeout ; }\n", "\n", "\n", "Target: * dev ; int no_module ; ( ) ; no_module = ! dev ; if ( no_module && capable ( CAP_NET_ADMIN ) ) no_module = request_module ( \"netdev-%s\" , name ) ; if ( no_module && capable ( CAP_SYS_MODULE ) ) { if ( ! , name ) ) pr_err ( \"Loadingkernelmoduleforanetworkdevice\" \"withCAP_SYS_MODULE(deprecated).UseCAP_NET_ADMINandaliasnetdev-%s\" \"instead\\\\n\" , name ) ; } } \n", "\n", "Sources:\n", "0: CWE-000 void dev_load ( struct net * net , const char * name ) { struct net_device * dev ; rcu_read_lock ( ) ; dev = dev_get_by_name_rcu ( net , name ) ; rcu_read_unlock ( ) ; if ( ! dev && capable ( CAP_NET_ADMIN ) ) request_module ( \"%s\" , name ) ; }\n", "\n", "1: CWE-264 void dev_load ( struct net * net , const char * name ) { struct net_device * dev ; rcu_read_lock ( ) ; dev = dev_get_by_name_rcu ( net , name ) ; rcu_read_unlock ( ) ; if ( ! dev && capable ( CAP_NET_ADMIN ) ) request_module ( \"%s\" , name ) ; }\n", "\n", "\n", "Target: str ) ; if ( ! RTEST ( rb_attr_get ( self , id_key_set ) ) ) ossl_raise ( eCipherError , \"keynotset\" ) ;\n", "\n", "Sources:\n", "0: CWE-326 static VALUE ossl_cipher_update ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; unsigned char * in ; long in_len , out_len ; VALUE data , str ; rb_scan_args ( argc , argv , \"11\" , & data , & str ) ; StringValue ( data ) ; in = ( unsigned char * ) RSTRING_PTR ( data ) ; if ( ( in_len = RSTRING_LEN ( data ) ) == 0 ) ossl_raise ( rb_eArgError , \"datamustnotbeempty\" ) ; GetCipher ( self , ctx ) ; out_len = in_len + EVP_CIPHER_CTX_block_size ( ctx ) ; if ( out_len <= 0 ) { ossl_raise ( rb_eRangeError , \"datatoobigtomakeoutputbuffer:%ldbytes\" , in_len ) ; } if ( NIL_P ( str ) ) { str = rb_str_new ( 0 , out_len ) ; } else { StringValue ( str ) ; rb_str_resize ( str , out_len ) ; } if ( ! ossl_cipher_update_long ( ctx , ( unsigned char * ) RSTRING_PTR ( str ) , & out_len , in , in_len ) ) ossl_raise ( eCipherError , NULL ) ; assert ( out_len < RSTRING_LEN ( str ) ) ; rb_str_set_len ( str , out_len ) ; return str ; }\n", "\n", "1: CWE-310 static VALUE ossl_cipher_update ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; unsigned char * in ; long in_len , out_len ; VALUE data , str ; rb_scan_args ( argc , argv , \"11\" , & data , & str ) ; StringValue ( data ) ; in = ( unsigned char * ) RSTRING_PTR ( data ) ; if ( ( in_len = RSTRING_LEN ( data ) ) == 0 ) ossl_raise ( rb_eArgError , \"datamustnotbeempty\" ) ; GetCipher ( self , ctx ) ; out_len = in_len + EVP_CIPHER_CTX_block_size ( ctx ) ; if ( out_len <= 0 ) { ossl_raise ( rb_eRangeError , \"datatoobigtomakeoutputbuffer:%ldbytes\" , in_len ) ; } if ( NIL_P ( str ) ) { str = rb_str_new ( 0 , out_len ) ; } else { StringValue ( str ) ; rb_str_resize ( str , out_len ) ; } if ( ! ossl_cipher_update_long ( ctx , ( unsigned char * ) RSTRING_PTR ( str ) , & out_len , in , in_len ) ) ossl_raise ( eCipherError , NULL ) ; assert ( out_len < RSTRING_LEN ( str ) ) ; rb_str_set_len ( str , out_len ) ; return str ; }\n", "\n", "\n", "Target: keyring_key ) ; down_read ( & keyring_key -> sem ) ; out ; } ukp = user_key_payload ( keyring_key ) ; if ( ukp -> datalen != sizeof ( struct fscrypt_key ) ) { res = - EINVAL ; goto out ; } master_key = ( struct fscrypt_key * ) ukp -> data ; BUILD_BUG_ON ( FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE ) ; if ( master_key -> size != FS_AES_256_XTS_KEY_SIZE ) { printk_once ( KERN_WARNING \"%s:keysizeincorrect:%d\\\\n\" , __func__ , master_key -> size ) ; res = - ENOKEY ; goto out ; } res = derive_key_aes ( ctx -> nonce , master_key -> raw , raw_key ) ; out : up_read ( & keyring_key sem ) ; key_put ( keyring_key ) ; return res ; }\n", "\n", "Sources:\n", "0: CWE-476 static int validate_user_key ( struct fscrypt_info * crypt_info , struct fscrypt_context * ctx , u8 * raw_key , const char * prefix ) { char * description ; struct key * keyring_key ; struct fscrypt_key * master_key ; const struct user_key_payload * ukp ; int res ; description = kasprintf ( GFP_NOFS , \"%s%*phN\" , prefix , FS_KEY_DESCRIPTOR_SIZE , ctx -> master_key_descriptor ) ; if ( ! description ) return - ENOMEM ; keyring_key = request_key ( & key_type_logon , description , NULL ) ; kfree ( description ) ; if ( IS_ERR ( keyring_key ) ) return PTR_ERR ( keyring_key ) ; if ( keyring_key -> type != & key_type_logon ) { printk_once ( KERN_WARNING \"%s:keytypemustbelogon\\\\n\" , __func__ ) ; res = - ENOKEY ; goto out ; } down_read ( & keyring_key -> sem ) ; ukp = user_key_payload ( keyring_key ) ; if ( ukp -> datalen != sizeof ( struct fscrypt_key ) ) { res = - EINVAL ; up_read ( & keyring_key -> sem ) ; goto out ; } master_key = ( struct fscrypt_key * ) ukp -> data ; BUILD_BUG_ON ( FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE ) ; if ( master_key -> size != FS_AES_256_XTS_KEY_SIZE ) { printk_once ( KERN_WARNING \"%s:keysizeincorrect:%d\\\\n\" , __func__ , master_key -> size ) ; res = - ENOKEY ; up_read ( & keyring_key -> sem ) ; goto out ; } res = derive_key_aes ( ctx -> nonce , master_key -> raw , raw_key ) ; up_read ( & keyring_key -> sem ) ; if ( res ) goto out ; crypt_info -> ci_keyring_key = keyring_key ; return 0 ; out : key_put ( keyring_key ) ; return res ; }\n", "\n", "1: CWE-416 static int validate_user_key ( struct fscrypt_info * crypt_info , struct fscrypt_context * ctx , u8 * raw_key , const char * prefix ) { char * description ; struct key * keyring_key ; struct fscrypt_key * master_key ; const struct user_key_payload * ukp ; int res ; description = kasprintf ( GFP_NOFS , \"%s%*phN\" , prefix , FS_KEY_DESCRIPTOR_SIZE , ctx -> master_key_descriptor ) ; if ( ! description ) return - ENOMEM ; keyring_key = request_key ( & key_type_logon , description , NULL ) ; kfree ( description ) ; if ( IS_ERR ( keyring_key ) ) return PTR_ERR ( keyring_key ) ; if ( keyring_key -> type != & key_type_logon ) { printk_once ( KERN_WARNING \"%s:keytypemustbelogon\\\\n\" , __func__ ) ; res = - ENOKEY ; goto out ; } down_read ( & keyring_key -> sem ) ; ukp = user_key_payload ( keyring_key ) ; if ( ukp -> datalen != sizeof ( struct fscrypt_key ) ) { res = - EINVAL ; up_read ( & keyring_key -> sem ) ; goto out ; } master_key = ( struct fscrypt_key * ) ukp -> data ; BUILD_BUG_ON ( FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE ) ; if ( master_key -> size != FS_AES_256_XTS_KEY_SIZE ) { printk_once ( KERN_WARNING \"%s:keysizeincorrect:%d\\\\n\" , __func__ , master_key -> size ) ; res = - ENOKEY ; up_read ( & keyring_key -> sem ) ; goto out ; } res = derive_key_aes ( ctx -> nonce , master_key -> raw , raw_key ) ; up_read ( & keyring_key -> sem ) ; if ( res ) goto out ; crypt_info -> ci_keyring_key = keyring_key ; return 0 ; out : key_put ( keyring_key ) ; return res ; }\n", "\n", "\n", "Target: mode ) { mutex_lock ( & loop_index_mutex ) ; __lo_release ( disk -> private_data disk -> private_data ) ; mutex_unlock ( & mutex_unlock ( & loop_index_mutex ) ; }\n", "\n", "Sources:\n", "0: CWE-362 static void lo_release ( struct gendisk * disk , fmode_t mode ) { struct loop_device * lo = disk -> private_data ; int err ; if ( atomic_dec_return ( & lo -> lo_refcnt ) ) return ; mutex_lock ( & lo -> lo_ctl_mutex ) ; if ( lo -> lo_flags & LO_FLAGS_AUTOCLEAR ) { err = loop_clr_fd ( lo ) ; if ( ! err ) return ; } else if ( lo -> lo_state == Lo_bound ) { blk_mq_freeze_queue ( lo -> lo_queue ) ; blk_mq_unfreeze_queue ( lo -> lo_queue ) ; } mutex_unlock ( & lo -> lo_ctl_mutex ) ; }\n", "\n", "1: CWE-416 static void lo_release ( struct gendisk * disk , fmode_t mode ) { struct loop_device * lo = disk -> private_data ; int err ; if ( atomic_dec_return ( & lo -> lo_refcnt ) ) return ; mutex_lock ( & lo -> lo_ctl_mutex ) ; if ( lo -> lo_flags & LO_FLAGS_AUTOCLEAR ) { err = loop_clr_fd ( lo ) ; if ( ! err ) return ; } else if ( lo -> lo_state == Lo_bound ) { blk_mq_freeze_queue ( lo -> lo_queue ) ; blk_mq_unfreeze_queue ( lo -> lo_queue ) ; } mutex_unlock ( & lo -> lo_ctl_mutex ) ; }\n", "\n", "\n", "Target: ; if ( ( len > 12 ) && else if ( ( len > 9 ) &&\n", "\n", "Sources:\n", "0: CWE-125 static void send_ssi_file ( struct mg_connection * conn , const char * path , struct mg_file * filep , int include_level ) { char buf [ MG_BUF_LEN ] ; int ch , offset , len , in_tag , in_ssi_tag ; if ( include_level > 10 ) { mg_cry_internal ( conn , \"SSI#includelevelistoodeep(%s)\" , path ) ; return ; } in_tag = in_ssi_tag = len = offset = 0 ; while ( ( ch = mg_fgetc ( filep , offset ++ ) ) != EOF ) { if ( in_tag ) { if ( ch == '>' ) { buf [ len ++ ] = '>' ; if ( in_ssi_tag ) { buf [ len ] = 0 ; if ( ! memcmp ( buf + 5 , \"include\" , 7 ) ) { do_ssi_include ( conn , path , buf + 12 , include_level + 1 ) ; # if ! defined ( NO_POPEN ) } else if ( ! memcmp ( buf + 5 , \"exec\" , 4 ) ) { do_ssi_exec ( conn , buf + 9 ) ; # endif } else { mg_cry_internal ( conn , \"%s:unknownSSI\" \"command:\\\\\"%s\\\\\"\" , path , buf ) ; } len = 0 ; in_ssi_tag = in_tag = 0 ; } else { ( void ) mg_write ( conn , buf , ( size_t ) len ) ; len = 0 ; in_tag = 0 ; } } else { buf [ len ++ ] = ( char ) ( ch & 0xff ) ; if ( ( len == 5 ) && ! memcmp ( buf , \"%d\" , i + 1 , descriptions [ i ] . mChannelLabel ) ; } for ( label = 1 ; label <= 18 ; ++ label ) for ( i = 0 ; i < num_descriptions ; ++ i ) if ( descriptions [ i ] . mChannelLabel == label ) { config -> channel_mask |= 1 << ( label - 1 ) ; channel_reorder [ i ] = cindex ++ ; break ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] == ( unsigned char ) - 1 ) { uint32_t clabel = descriptions [ i ] . mChannelLabel ; if ( clabel == 0 || clabel == 0xffffffff || clabel == 100 ) channel_identities [ idents ++ ] = 0xff ; else if ( ( clabel >= 33 && clabel <= 44 ) || ( clabel >= 200 && clabel <= 207 ) || ( clabel >= 301 && clabel <= 305 ) ) channel_identities [ idents ++ ] = clabel >= 301 ? clabel - 80 : clabel ; else { error_line ( \"warning:unknownchanneldescriptionslabel:%d\" , clabel ) ; channel_identities [ idents ++ ] = 0xff ; } channel_reorder [ i ] = cindex ++ ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] != i ) break ; if ( i == num_descriptions ) { free ( channel_reorder ) ; channel_reorder = NULL ; } else { config -> qmode |= QMODE_REORDERED_CHANS ; channel_layout = num_descriptions ; } if ( ! idents ) { free ( channel_identities ) ; channel_identities = NULL ; } else channel_identities [ idents ] = 0 ; if ( debug_logging_mode ) { error_line ( \"layout_tag=0x%08x,sogeneratedbitmapof0x%08xfrom%ddescriptions,%dnon-MS\" , caf_channel_layout -> mChannelLayoutTag , config -> channel_mask , caf_channel_layout -> mNumberChannelDescriptions , idents ) ; if ( channel_reorder && num_descriptions <= 8 ) { char reorder_string [ ] = \"12345678\" ; for ( i = 0 ; i < num_descriptions ; ++ i ) reorder_string [ i ] = channel_reorder [ i ] + '1' ; reorder_string [ i ] = 0 ; error_line ( \"reorderingstring=\\\\\"%s\\\\\"\\\\n\" , reorder_string ) ; } } } break ; case kCAFChannelLayoutTag_UseChannelBitmap : config -> channel_mask = caf_channel_layout -> mChannelBitmap ; if ( debug_logging_mode ) error_line ( \"layout_tag=0x%08x,sousingsuppliedbitmapof0x%08x\" , caf_channel_layout -> mChannelLayoutTag , caf_channel_layout -> mChannelBitmap ) ; break ; default : for ( i = 0 ; i < NUM_LAYOUTS ; ++ i ) if ( caf_channel_layout -> mChannelLayoutTag == layouts [ i ] . mChannelLayoutTag ) { config -> channel_mask = layouts [ i ] . mChannelBitmap ; channel_layout = layouts [ i ] . mChannelLayoutTag ; if ( layouts [ i ] . mChannelReorder ) { channel_reorder = ( unsigned char * ) strdup ( layouts [ i ] . mChannelReorder ) ; config -> qmode |= QMODE_REORDERED_CHANS ; } if ( layouts [ i ] . mChannelIdentities ) channel_identities = ( unsigned char * ) strdup ( layouts [ i ] . mChannelIdentities ) ; if ( debug_logging_mode ) error_line ( \"layout_tag0x%08xfoundintable,bitmap=0x%08x,reorder=%s,identities=%s\" , channel_layout , config -> channel_mask , channel_reorder ? \"yes\" : \"no\" , channel_identities ? \"yes\" : \"no\" ) ; break ; } if ( i == NUM_LAYOUTS && debug_logging_mode ) error_line ( \"layout_tag0x%08xnotfoundintable...allchannelsunassigned\" , caf_channel_layout -> mChannelLayoutTag ) ; break ; } free ( caf_channel_layout ) ; } else if ( ! strncmp ( caf_chunk_header . mChunkType , \"data\" , 4 ) ) { uint32_t mEditCount ; if ( ! DoReadFile ( infile , & mEditCount , sizeof ( mEditCount ) , & bcount ) || bcount != sizeof ( mEditCount ) ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & mEditCount , sizeof ( mEditCount ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( ( config -> qmode & QMODE_IGNORE_LENGTH ) || caf_chunk_header . mChunkSize == - 1 ) { config -> qmode |= QMODE_IGNORE_LENGTH ; if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / caf_audio_format . mBytesPerPacket ; else total_samples = - 1 ; } else { if ( infilesize && infilesize - caf_chunk_header . mChunkSize > 16777216 ) { error_line ( \".CAFfile%shasover16MBofextraCAFFdata,probablyiscorrupt!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ( caf_chunk_header . mChunkSize - 4 ) % caf_audio_format . mBytesPerPacket ) { error_line ( \".CAFfile%shasaninvaliddatachunksize,probablyiscorrupt!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } total_samples = ( caf_chunk_header . mChunkSize - 4 ) / caf_audio_format . mBytesPerPacket ; if ( ! total_samples ) { error_line ( \"this.CAFfilehasnoaudiosamples,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( \"%shastoomanysamplesforWavPack!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } break ; } else { uint32_t bytes_to_copy = ( uint32_t ) caf_chunk_header . mChunkSize ; char * buff ; if ( caf_chunk_header . mChunkSize < 0 || caf_chunk_header . mChunkSize > 1048576 ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( \"extraunknownchunk\\\\\"%c%c%c%c\\\\\"of%dbytes\" , caf_chunk_header . mChunkType [ 0 ] , caf_chunk_header . mChunkType [ 1 ] , caf_chunk_header . mChunkType [ 2 ] , caf_chunk_header . mChunkType [ 3 ] , caf_chunk_header . mChunkSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! chan_chunk && ! config -> channel_mask && config -> num_channels <= 2 && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) config -> channel_mask = 0x5 - config -> num_channels ; if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , channel_identities ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_identities ) free ( channel_identities ) ; if ( channel_layout || channel_reorder ) { if ( ! WavpackSetChannelLayout ( wpc , channel_layout , channel_reorder ) ) { error_line ( \"problemwithsettingchannellayout(shouldnothappen)\" ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_reorder ) free ( channel_reorder ) ; } return WAVPACK_NO_ERROR ; }\n", "\n", "1: CWE-665 int ParseCaffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { uint32_t chan_chunk = 0 , channel_layout = 0 , bcount ; unsigned char * channel_identities = NULL ; unsigned char * channel_reorder = NULL ; int64_t total_samples = 0 , infilesize ; CAFFileHeader caf_file_header ; CAFChunkHeader caf_chunk_header ; CAFAudioFormat caf_audio_format ; int i ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & caf_file_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & caf_file_header ) + 4 , sizeof ( CAFFileHeader ) - 4 , & bcount ) || bcount != sizeof ( CAFFileHeader ) - 4 ) ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_file_header , sizeof ( CAFFileHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_file_header , CAFFileHeaderFormat ) ; if ( caf_file_header . mFileVersion != 1 ) { error_line ( \"%s:can\\'thandleversion%d.CAFfiles!\" , infilename , caf_file_header . mFileVersion ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if ( ! DoReadFile ( infile , & caf_chunk_header , sizeof ( CAFChunkHeader ) , & bcount ) || bcount != sizeof ( CAFChunkHeader ) ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_chunk_header , sizeof ( CAFChunkHeader ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_chunk_header , CAFChunkHeaderFormat ) ; if ( ! strncmp ( caf_chunk_header . mChunkType , \"desc\" , 4 ) ) { int supported = TRUE ; if ( caf_chunk_header . mChunkSize != sizeof ( CAFAudioFormat ) || ! DoReadFile ( infile , & caf_audio_format , ( uint32_t ) caf_chunk_header . mChunkSize , & bcount ) || bcount != caf_chunk_header . mChunkSize ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_audio_format , ( uint32_t ) caf_chunk_header . mChunkSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_audio_format , CAFAudioFormatFormat ) ; if ( debug_logging_mode ) { char formatstr [ 5 ] ; memcpy ( formatstr , caf_audio_format . mFormatID , 4 ) ; formatstr [ 4 ] = 0 ; error_line ( \"format=%s,flags=%x,samplingrate=%g\" , formatstr , caf_audio_format . mFormatFlags , caf_audio_format . mSampleRate ) ; error_line ( \"packet=%dbytesand%dframes\" , caf_audio_format . mBytesPerPacket , caf_audio_format . mFramesPerPacket ) ; error_line ( \"channelsperframe=%d,bitsperchannel=%d\" , caf_audio_format . mChannelsPerFrame , caf_audio_format . mBitsPerChannel ) ; } if ( strncmp ( caf_audio_format . mFormatID , \"lpcm\" , 4 ) || ( caf_audio_format . mFormatFlags & ~ 3 ) ) supported = FALSE ; else if ( caf_audio_format . mSampleRate < 1.0 || caf_audio_format . mSampleRate > 16777215.0 || caf_audio_format . mSampleRate != floor ( caf_audio_format . mSampleRate ) ) supported = FALSE ; else if ( ! caf_audio_format . mChannelsPerFrame || caf_audio_format . mChannelsPerFrame > 256 ) supported = FALSE ; else if ( caf_audio_format . mBitsPerChannel < 1 || caf_audio_format . mBitsPerChannel > 32 || ( ( caf_audio_format . mFormatFlags & CAF_FORMAT_FLOAT ) && caf_audio_format . mBitsPerChannel != 32 ) ) supported = FALSE ; else if ( caf_audio_format . mFramesPerPacket != 1 || caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame < ( caf_audio_format . mBitsPerChannel + 7 ) / 8 || caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame > 4 || caf_audio_format . mBytesPerPacket % caf_audio_format . mChannelsPerFrame ) supported = FALSE ; if ( ! supported ) { error_line ( \"%sisanunsupported.CAFformat!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } config -> bytes_per_sample = caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame ; config -> float_norm_exp = ( caf_audio_format . mFormatFlags & CAF_FORMAT_FLOAT ) ? 127 : 0 ; config -> bits_per_sample = caf_audio_format . mBitsPerChannel ; config -> num_channels = caf_audio_format . mChannelsPerFrame ; config -> sample_rate = ( int ) caf_audio_format . mSampleRate ; if ( ! ( caf_audio_format . mFormatFlags & CAF_FORMAT_LITTLE_ENDIAN ) && config -> bytes_per_sample > 1 ) config -> qmode |= QMODE_BIG_ENDIAN ; if ( config -> bytes_per_sample == 1 ) config -> qmode |= QMODE_SIGNED_BYTES ; if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( \"dataformat:32-bit%s-endianfloatingpoint\" , ( config -> qmode & QMODE_BIG_ENDIAN ) ? \"big\" : \"little\" ) ; else error_line ( \"dataformat:%d-bit%s-endianintegersstoredin%dbyte(s)\" , config -> bits_per_sample , ( config -> qmode & QMODE_BIG_ENDIAN ) ? \"big\" : \"little\" , config -> bytes_per_sample ) ; } } else if ( ! strncmp ( caf_chunk_header . mChunkType , \"chan\" , 4 ) ) { CAFChannelLayout * caf_channel_layout ; if ( caf_chunk_header . mChunkSize < 0 || caf_chunk_header . mChunkSize > 1024 || caf_chunk_header . mChunkSize < sizeof ( CAFChannelLayout ) ) { error_line ( \"this.CAFfilehasaninvalid\\'chan\\'chunk!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( \"\\'chan\\'chunkis%dbytes\" , ( int ) caf_chunk_header . mChunkSize ) ; caf_channel_layout = malloc ( ( size_t ) caf_chunk_header . mChunkSize ) ; if ( ! DoReadFile ( infile , caf_channel_layout , ( uint32_t ) caf_chunk_header . mChunkSize , & bcount ) || bcount != caf_chunk_header . mChunkSize ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , caf_channel_layout , ( uint32_t ) caf_chunk_header . mChunkSize ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( caf_channel_layout , CAFChannelLayoutFormat ) ; chan_chunk = 1 ; if ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { error_line ( \"thisCAFfilealreadyhaschannelorderinformation!\" ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } switch ( caf_channel_layout -> mChannelLayoutTag ) { case kCAFChannelLayoutTag_UseChannelDescriptions : { CAFChannelDescription * descriptions = ( CAFChannelDescription * ) ( caf_channel_layout + 1 ) ; int num_descriptions = caf_channel_layout -> mNumberChannelDescriptions ; int label , cindex = 0 , idents = 0 ; if ( caf_chunk_header . mChunkSize != sizeof ( CAFChannelLayout ) + sizeof ( CAFChannelDescription ) * num_descriptions || num_descriptions != config -> num_channels ) { error_line ( \"channeldescriptionsin\\'chan\\'chunkarethewrongsize!\" ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } if ( num_descriptions >= 256 ) { error_line ( \"%dchanneldescriptionsismorethanwecanhandle...ignoring!\" ) ; break ; } channel_reorder = malloc ( num_descriptions ) ; memset ( channel_reorder , - 1 , num_descriptions ) ; channel_identities = malloc ( num_descriptions + 1 ) ; for ( i = 0 ; i < num_descriptions ; ++ i ) { WavpackBigEndianToNative ( descriptions + i , CAFChannelDescriptionFormat ) ; if ( debug_logging_mode ) error_line ( \"chan%d-->%d\" , i + 1 , descriptions [ i ] . mChannelLabel ) ; } for ( label = 1 ; label <= 18 ; ++ label ) for ( i = 0 ; i < num_descriptions ; ++ i ) if ( descriptions [ i ] . mChannelLabel == label ) { config -> channel_mask |= 1 << ( label - 1 ) ; channel_reorder [ i ] = cindex ++ ; break ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] == ( unsigned char ) - 1 ) { uint32_t clabel = descriptions [ i ] . mChannelLabel ; if ( clabel == 0 || clabel == 0xffffffff || clabel == 100 ) channel_identities [ idents ++ ] = 0xff ; else if ( ( clabel >= 33 && clabel <= 44 ) || ( clabel >= 200 && clabel <= 207 ) || ( clabel >= 301 && clabel <= 305 ) ) channel_identities [ idents ++ ] = clabel >= 301 ? clabel - 80 : clabel ; else { error_line ( \"warning:unknownchanneldescriptionslabel:%d\" , clabel ) ; channel_identities [ idents ++ ] = 0xff ; } channel_reorder [ i ] = cindex ++ ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] != i ) break ; if ( i == num_descriptions ) { free ( channel_reorder ) ; channel_reorder = NULL ; } else { config -> qmode |= QMODE_REORDERED_CHANS ; channel_layout = num_descriptions ; } if ( ! idents ) { free ( channel_identities ) ; channel_identities = NULL ; } else channel_identities [ idents ] = 0 ; if ( debug_logging_mode ) { error_line ( \"layout_tag=0x%08x,sogeneratedbitmapof0x%08xfrom%ddescriptions,%dnon-MS\" , caf_channel_layout -> mChannelLayoutTag , config -> channel_mask , caf_channel_layout -> mNumberChannelDescriptions , idents ) ; if ( channel_reorder && num_descriptions <= 8 ) { char reorder_string [ ] = \"12345678\" ; for ( i = 0 ; i < num_descriptions ; ++ i ) reorder_string [ i ] = channel_reorder [ i ] + '1' ; reorder_string [ i ] = 0 ; error_line ( \"reorderingstring=\\\\\"%s\\\\\"\\\\n\" , reorder_string ) ; } } } break ; case kCAFChannelLayoutTag_UseChannelBitmap : config -> channel_mask = caf_channel_layout -> mChannelBitmap ; if ( debug_logging_mode ) error_line ( \"layout_tag=0x%08x,sousingsuppliedbitmapof0x%08x\" , caf_channel_layout -> mChannelLayoutTag , caf_channel_layout -> mChannelBitmap ) ; break ; default : for ( i = 0 ; i < NUM_LAYOUTS ; ++ i ) if ( caf_channel_layout -> mChannelLayoutTag == layouts [ i ] . mChannelLayoutTag ) { config -> channel_mask = layouts [ i ] . mChannelBitmap ; channel_layout = layouts [ i ] . mChannelLayoutTag ; if ( layouts [ i ] . mChannelReorder ) { channel_reorder = ( unsigned char * ) strdup ( layouts [ i ] . mChannelReorder ) ; config -> qmode |= QMODE_REORDERED_CHANS ; } if ( layouts [ i ] . mChannelIdentities ) channel_identities = ( unsigned char * ) strdup ( layouts [ i ] . mChannelIdentities ) ; if ( debug_logging_mode ) error_line ( \"layout_tag0x%08xfoundintable,bitmap=0x%08x,reorder=%s,identities=%s\" , channel_layout , config -> channel_mask , channel_reorder ? \"yes\" : \"no\" , channel_identities ? \"yes\" : \"no\" ) ; break ; } if ( i == NUM_LAYOUTS && debug_logging_mode ) error_line ( \"layout_tag0x%08xnotfoundintable...allchannelsunassigned\" , caf_channel_layout -> mChannelLayoutTag ) ; break ; } free ( caf_channel_layout ) ; } else if ( ! strncmp ( caf_chunk_header . mChunkType , \"data\" , 4 ) ) { uint32_t mEditCount ; if ( ! DoReadFile ( infile , & mEditCount , sizeof ( mEditCount ) , & bcount ) || bcount != sizeof ( mEditCount ) ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & mEditCount , sizeof ( mEditCount ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( ( config -> qmode & QMODE_IGNORE_LENGTH ) || caf_chunk_header . mChunkSize == - 1 ) { config -> qmode |= QMODE_IGNORE_LENGTH ; if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / caf_audio_format . mBytesPerPacket ; else total_samples = - 1 ; } else { if ( infilesize && infilesize - caf_chunk_header . mChunkSize > 16777216 ) { error_line ( \".CAFfile%shasover16MBofextraCAFFdata,probablyiscorrupt!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ( caf_chunk_header . mChunkSize - 4 ) % caf_audio_format . mBytesPerPacket ) { error_line ( \".CAFfile%shasaninvaliddatachunksize,probablyiscorrupt!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } total_samples = ( caf_chunk_header . mChunkSize - 4 ) / caf_audio_format . mBytesPerPacket ; if ( ! total_samples ) { error_line ( \"this.CAFfilehasnoaudiosamples,probablyiscorrupt!\" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( \"%shastoomanysamplesforWavPack!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } break ; } else { uint32_t bytes_to_copy = ( uint32_t ) caf_chunk_header . mChunkSize ; char * buff ; if ( caf_chunk_header . mChunkSize < 0 || caf_chunk_header . mChunkSize > 1048576 ) { error_line ( \"%sisnotavalid.CAFfile!\" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( \"extraunknownchunk\\\\\"%c%c%c%c\\\\\"of%dbytes\" , caf_chunk_header . mChunkType [ 0 ] , caf_chunk_header . mChunkType [ 1 ] , caf_chunk_header . mChunkType [ 2 ] , caf_chunk_header . mChunkType [ 3 ] , caf_chunk_header . mChunkSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! chan_chunk && ! config -> channel_mask && config -> num_channels <= 2 && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) config -> channel_mask = 0x5 - config -> num_channels ; if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , channel_identities ) ) { error_line ( \"%s\" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_identities ) free ( channel_identities ) ; if ( channel_layout || channel_reorder ) { if ( ! WavpackSetChannelLayout ( wpc , channel_layout , channel_reorder ) ) { error_line ( \"problemwithsettingchannellayout(shouldnothappen)\" ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_reorder ) free ( channel_reorder ) ; } return WAVPACK_NO_ERROR ; }\n", "\n", "\n", "Target: -> buffer ) { kfree ( adis -> xfer ) ; adis -> xfer = NULL ; - ENOMEM ; }\n", "\n", "Sources:\n", "0: CWE-401 static int adis_update_scan_mode_burst ( struct iio_dev * indio_dev , const unsigned long * scan_mask ) { struct adis * adis = iio_device_get_drvdata ( indio_dev ) ; unsigned int burst_length ; u8 * tx ; burst_length = ( indio_dev -> num_channels - 1 ) * sizeof ( u16 ) ; burst_length += adis -> burst -> extra_len ; adis -> xfer = kcalloc ( 2 , sizeof ( * adis -> xfer ) , GFP_KERNEL ) ; if ( ! adis -> xfer ) return - ENOMEM ; adis -> buffer = kzalloc ( burst_length + sizeof ( u16 ) , GFP_KERNEL ) ; if ( ! adis -> buffer ) return - ENOMEM ; tx = adis -> buffer + burst_length ; tx [ 0 ] = ADIS_READ_REG ( adis -> burst -> reg_cmd ) ; tx [ 1 ] = 0 ; adis -> xfer [ 0 ] . tx_buf = tx ; adis -> xfer [ 0 ] . bits_per_word = 8 ; adis -> xfer [ 0 ] . len = 2 ; adis -> xfer [ 1 ] . rx_buf = adis -> buffer ; adis -> xfer [ 1 ] . bits_per_word = 8 ; adis -> xfer [ 1 ] . len = burst_length ; spi_message_init ( & adis -> msg ) ; spi_message_add_tail ( & adis -> xfer [ 0 ] , & adis -> msg ) ; spi_message_add_tail ( & adis -> xfer [ 1 ] , & adis -> msg ) ; return 0 ; }\n", "\n", "1: CWE-401 int adis_update_scan_mode ( struct iio_dev * indio_dev , const unsigned long * scan_mask ) { struct adis * adis = iio_device_get_drvdata ( indio_dev ) ; const struct iio_chan_spec * chan ; unsigned int scan_count ; unsigned int i , j ; __be16 * tx , * rx ; kfree ( adis -> xfer ) ; kfree ( adis -> buffer ) ; if ( adis -> burst && adis -> burst -> en ) return adis_update_scan_mode_burst ( indio_dev , scan_mask ) ; scan_count = indio_dev -> scan_bytes / 2 ; adis -> xfer = kcalloc ( scan_count + 1 , sizeof ( * adis -> xfer ) , GFP_KERNEL ) ; if ( ! adis -> xfer ) return - ENOMEM ; adis -> buffer = kcalloc ( indio_dev -> scan_bytes , 2 , GFP_KERNEL ) ; if ( ! adis -> buffer ) return - ENOMEM ; rx = adis -> buffer ; tx = rx + scan_count ; spi_message_init ( & adis -> msg ) ; for ( j = 0 ; j <= scan_count ; j ++ ) { adis -> xfer [ j ] . bits_per_word = 8 ; if ( j != scan_count ) adis -> xfer [ j ] . cs_change = 1 ; adis -> xfer [ j ] . len = 2 ; adis -> xfer [ j ] . delay_usecs = adis -> data -> read_delay ; if ( j < scan_count ) adis -> xfer [ j ] . tx_buf = & tx [ j ] ; if ( j >= 1 ) adis -> xfer [ j ] . rx_buf = & rx [ j - 1 ] ; spi_message_add_tail ( & adis -> xfer [ j ] , & adis -> msg ) ; } chan = indio_dev -> channels ; for ( i = 0 ; i < indio_dev -> num_channels ; i ++ , chan ++ ) { if ( ! test_bit ( chan -> scan_index , scan_mask ) ) continue ; if ( chan -> scan_type . storagebits == 32 ) * tx ++ = cpu_to_be16 ( ( chan -> address + 2 ) << 8 ) ; * tx ++ = cpu_to_be16 ( chan -> address << 8 ) ; } return 0 ; }\n", "\n", "\n", "Target: err ; } ca . name [ sizeof ( ca . name ) - 1 ] = 0 ;\n", "\n", "Sources:\n", "0: CWE-77 static int do_hidp_sock_ioctl ( struct socket * sock , unsigned int cmd , void __user * argp ) { struct hidp_connadd_req ca ; struct hidp_conndel_req cd ; struct hidp_connlist_req cl ; struct hidp_conninfo ci ; struct socket * csock ; struct socket * isock ; int err ; BT_DBG ( \"cmd%xarg%p\" , cmd , argp ) ; switch ( cmd ) { case HIDPCONNADD : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & ca , argp , sizeof ( ca ) ) ) return - EFAULT ; csock = sockfd_lookup ( ca . ctrl_sock , & err ) ; if ( ! csock ) return err ; isock = sockfd_lookup ( ca . intr_sock , & err ) ; if ( ! isock ) { sockfd_put ( csock ) ; return err ; } err = hidp_connection_add ( & ca , csock , isock ) ; if ( ! err && copy_to_user ( argp , & ca , sizeof ( ca ) ) ) err = - EFAULT ; sockfd_put ( csock ) ; sockfd_put ( isock ) ; return err ; case HIDPCONNDEL : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & cd , argp , sizeof ( cd ) ) ) return - EFAULT ; return hidp_connection_del ( & cd ) ; case HIDPGETCONNLIST : if ( copy_from_user ( & cl , argp , sizeof ( cl ) ) ) return - EFAULT ; if ( cl . cnum <= 0 ) return - EINVAL ; err = hidp_get_connlist ( & cl ) ; if ( ! err && copy_to_user ( argp , & cl , sizeof ( cl ) ) ) return - EFAULT ; return err ; case HIDPGETCONNINFO : if ( copy_from_user ( & ci , argp , sizeof ( ci ) ) ) return - EFAULT ; err = hidp_get_conninfo ( & ci ) ; if ( ! err && copy_to_user ( argp , & ci , sizeof ( ci ) ) ) return - EFAULT ; return err ; } return - EINVAL ; }\n", "\n", "1: CWE-000 static int do_hidp_sock_ioctl ( struct socket * sock , unsigned int cmd , void __user * argp ) { struct hidp_connadd_req ca ; struct hidp_conndel_req cd ; struct hidp_connlist_req cl ; struct hidp_conninfo ci ; struct socket * csock ; struct socket * isock ; int err ; BT_DBG ( \"cmd%xarg%p\" , cmd , argp ) ; switch ( cmd ) { case HIDPCONNADD : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & ca , argp , sizeof ( ca ) ) ) return - EFAULT ; csock = sockfd_lookup ( ca . ctrl_sock , & err ) ; if ( ! csock ) return err ; isock = sockfd_lookup ( ca . intr_sock , & err ) ; if ( ! isock ) { sockfd_put ( csock ) ; return err ; } err = hidp_connection_add ( & ca , csock , isock ) ; if ( ! err && copy_to_user ( argp , & ca , sizeof ( ca ) ) ) err = - EFAULT ; sockfd_put ( csock ) ; sockfd_put ( isock ) ; return err ; case HIDPCONNDEL : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & cd , argp , sizeof ( cd ) ) ) return - EFAULT ; return hidp_connection_del ( & cd ) ; case HIDPGETCONNLIST : if ( copy_from_user ( & cl , argp , sizeof ( cl ) ) ) return - EFAULT ; if ( cl . cnum <= 0 ) return - EINVAL ; err = hidp_get_connlist ( & cl ) ; if ( ! err && copy_to_user ( argp , & cl , sizeof ( cl ) ) ) return - EFAULT ; return err ; case HIDPGETCONNINFO : if ( copy_from_user ( & ci , argp , sizeof ( ci ) ) ) return - EFAULT ; err = hidp_get_conninfo ( & ci ) ; if ( ! err && copy_to_user ( argp , & ci , sizeof ( ci ) ) ) return - EFAULT ; return err ; } return - EINVAL ; }\n", "\n", "\n", "Target: 0 ) { struct snd_ctl_elem_id id = control -> id ; , SNDRV_CTL_EVENT_MASK_VALUE , & id ) ;\n", "\n", "Sources:\n", "0: CWE-000 static int snd_ctl_elem_write ( struct snd_card * card , struct snd_ctl_file * file , struct snd_ctl_elem_value * control ) { struct snd_kcontrol * kctl ; struct snd_kcontrol_volatile * vd ; unsigned int index_offset ; int result ; down_read ( & card -> controls_rwsem ) ; kctl = snd_ctl_find_id ( card , & control -> id ) ; if ( kctl == NULL ) { result = - ENOENT ; } else { index_offset = snd_ctl_get_ioff ( kctl , & control -> id ) ; vd = & kctl -> vd [ index_offset ] ; if ( ! ( vd -> access & SNDRV_CTL_ELEM_ACCESS_WRITE ) || kctl -> put == NULL || ( file && vd -> owner && vd -> owner != file ) ) { result = - EPERM ; } else { snd_ctl_build_ioff ( & control -> id , kctl , index_offset ) ; result = kctl -> put ( kctl , control ) ; } if ( result > 0 ) { up_read ( & card -> controls_rwsem ) ; snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_VALUE , & control -> id ) ; return 0 ; } } up_read ( & card -> controls_rwsem ) ; return result ; }\n", "\n", "1: CWE-416 static int snd_ctl_elem_write ( struct snd_card * card , struct snd_ctl_file * file , struct snd_ctl_elem_value * control ) { struct snd_kcontrol * kctl ; struct snd_kcontrol_volatile * vd ; unsigned int index_offset ; int result ; down_read ( & card -> controls_rwsem ) ; kctl = snd_ctl_find_id ( card , & control -> id ) ; if ( kctl == NULL ) { result = - ENOENT ; } else { index_offset = snd_ctl_get_ioff ( kctl , & control -> id ) ; vd = & kctl -> vd [ index_offset ] ; if ( ! ( vd -> access & SNDRV_CTL_ELEM_ACCESS_WRITE ) || kctl -> put == NULL || ( file && vd -> owner && vd -> owner != file ) ) { result = - EPERM ; } else { snd_ctl_build_ioff ( & control -> id , kctl , index_offset ) ; result = kctl -> put ( kctl , control ) ; } if ( result > 0 ) { up_read ( & card -> controls_rwsem ) ; snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_VALUE , & control -> id ) ; return 0 ; } } up_read ( & card -> controls_rwsem ) ; return result ; }\n", "\n", "\n", "Target: , 1 , regs , regs\n", "\n", "Sources:\n", "0: CWE-400 static int swp_handler ( struct pt_regs * regs , unsigned int instr ) { unsigned int address , destreg , data , type ; unsigned int res = 0 ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , regs -> ARM_pc ) ; if ( current -> pid != previous_pid ) { pr_debug ( \"\\\\\"%s\\\\\"(%ld)usesdeprecatedSWP{B}instruction\\\\n\" , current -> comm , ( unsigned long ) current -> pid ) ; previous_pid = current -> pid ; } address = regs -> uregs [ EXTRACT_REG_NUM ( instr , RN_OFFSET ) ] ; data = regs -> uregs [ EXTRACT_REG_NUM ( instr , RT2_OFFSET ) ] ; destreg = EXTRACT_REG_NUM ( instr , RT_OFFSET ) ; type = instr & TYPE_SWPB ; pr_debug ( \"addrinr%d->0x%08x,destisr%d,sourceinr%d->0x%08x)\\\\n\" , EXTRACT_REG_NUM ( instr , RN_OFFSET ) , address , destreg , EXTRACT_REG_NUM ( instr , RT2_OFFSET ) , data ) ; if ( ! access_ok ( VERIFY_WRITE , ( address & ~ 3 ) , 4 ) ) { pr_debug ( \"SWP{B}emulation:accessto%pnotallowed!\\\\n\" , ( void * ) address ) ; res = - EFAULT ; } else { res = emulate_swpX ( address , & data , type ) ; } if ( res == 0 ) { regs -> ARM_pc += 4 ; regs -> uregs [ destreg ] = data ; } else if ( res == - EFAULT ) { set_segfault ( regs , address ) ; } return 0 ; }\n", "\n", "1: CWE-399 static int swp_handler ( struct pt_regs * regs , unsigned int instr ) { unsigned int address , destreg , data , type ; unsigned int res = 0 ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , regs -> ARM_pc ) ; if ( current -> pid != previous_pid ) { pr_debug ( \"\\\\\"%s\\\\\"(%ld)usesdeprecatedSWP{B}instruction\\\\n\" , current -> comm , ( unsigned long ) current -> pid ) ; previous_pid = current -> pid ; } address = regs -> uregs [ EXTRACT_REG_NUM ( instr , RN_OFFSET ) ] ; data = regs -> uregs [ EXTRACT_REG_NUM ( instr , RT2_OFFSET ) ] ; destreg = EXTRACT_REG_NUM ( instr , RT_OFFSET ) ; type = instr & TYPE_SWPB ; pr_debug ( \"addrinr%d->0x%08x,destisr%d,sourceinr%d->0x%08x)\\\\n\" , EXTRACT_REG_NUM ( instr , RN_OFFSET ) , address , destreg , EXTRACT_REG_NUM ( instr , RT2_OFFSET ) , data ) ; if ( ! access_ok ( VERIFY_WRITE , ( address & ~ 3 ) , 4 ) ) { pr_debug ( \"SWP{B}emulation:accessto%pnotallowed!\\\\n\" , ( void * ) address ) ; res = - EFAULT ; } else { res = emulate_swpX ( address , & data , type ) ; } if ( res == 0 ) { regs -> ARM_pc += 4 ; regs -> uregs [ destreg ] = data ; } else if ( res == - EFAULT ) { set_segfault ( regs , address ) ; } return 0 ; }\n", "\n", "\n", "Target: val ) { jas_ulonglong tmp ; if\n", "\n", "Sources:\n", "0: CWE-190 static int jas_iccgetuint16 ( jas_stream_t * in , jas_iccuint16_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 2 , & tmp ) ) return - 1 ; * val = tmp ; return 0 ; }\n", "\n", "1: CWE-190 static int jas_iccgetuint64 ( jas_stream_t * in , jas_iccuint64_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 8 , & tmp ) ) return - 1 ; * val = tmp ; return 0 ; }\n", "\n", "2: CWE-190 static int jas_iccgetuint32 ( jas_stream_t * in , jas_iccuint32_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 4 , & tmp ) ) return - 1 ; * val = tmp ; return 0 ; }\n", "\n", "\n", "Target: SAS_TASK_STATE_DONE ) ) { task_state_flags |= SAS_TASK_STATE_ABORTED ; complete ( ) ; } spin_unlock_irqrestore ( & task -> task_state_lock , flags ) ; }\n", "\n", "Sources:\n", "0: CWE-416 static void smp_task_timedout ( struct timer_list * t ) { struct sas_task_slow * slow = from_timer ( slow , t , timer ) ; struct sas_task * task = slow -> task ; unsigned long flags ; spin_lock_irqsave ( & task -> task_state_lock , flags ) ; if ( ! ( task -> task_state_flags & SAS_TASK_STATE_DONE ) ) task -> task_state_flags |= SAS_TASK_STATE_ABORTED ; spin_unlock_irqrestore ( & task -> task_state_lock , flags ) ; complete ( & task -> slow_task -> completion ) ; } \n", "\n", "1: CWE-362 static void smp_task_timedout ( struct timer_list * t ) { struct sas_task_slow * slow = from_timer ( slow , t , timer ) ; struct sas_task * task = slow -> task ; unsigned long flags ; spin_lock_irqsave ( & task -> task_state_lock , flags ) ; if ( ! ( task -> task_state_flags & SAS_TASK_STATE_DONE ) ) task -> task_state_flags |= SAS_TASK_STATE_ABORTED ; spin_unlock_irqrestore ( & task -> task_state_lock , flags ) ; complete ( & task -> slow_task -> completion ) ; } \n", "\n", "\n", "Target: & fl6 , rcu_dereference ( np -> opt )\n", "\n", "Sources:\n", "0: CWE-416 int inet6_csk_xmit ( struct sock * sk , struct sk_buff * skb , struct flowi * fl_unused ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 fl6 ; struct dst_entry * dst ; int res ; dst = inet6_csk_route_socket ( sk , & fl6 ) ; if ( IS_ERR ( dst ) ) { sk -> sk_err_soft = - PTR_ERR ( dst ) ; sk -> sk_route_caps = 0 ; kfree_skb ( skb ) ; return PTR_ERR ( dst ) ; } rcu_read_lock ( ) ; skb_dst_set_noref ( skb , dst ) ; fl6 . daddr = sk -> sk_v6_daddr ; res = ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; rcu_read_unlock ( ) ; return res ; }\n", "\n", "1: CWE-264 struct sock * cookie_v6_check ( struct sock * sk , struct sk_buff * skb ) { struct tcp_options_received tcp_opt ; struct inet_request_sock * ireq ; struct tcp_request_sock * treq ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct tcp_sock * tp = tcp_sk ( sk ) ; const struct tcphdr * th = tcp_hdr ( skb ) ; __u32 cookie = ntohl ( th -> ack_seq ) - 1 ; struct sock * ret = sk ; struct request_sock * req ; int mss ; struct dst_entry * dst ; __u8 rcv_wscale ; if ( ! sysctl_tcp_syncookies || ! th -> ack || th -> rst ) goto out ; if ( tcp_synq_no_recent_overflow ( sk ) ) goto out ; mss = __cookie_v6_check ( ipv6_hdr ( skb ) , th , cookie ) ; if ( mss == 0 ) { NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESFAILED ) ; goto out ; } NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESRECV ) ; memset ( & tcp_opt , 0 , sizeof ( tcp_opt ) ) ; tcp_parse_options ( skb , & tcp_opt , 0 , NULL ) ; if ( ! cookie_timestamp_decode ( & tcp_opt ) ) goto out ; ret = NULL ; req = inet_reqsk_alloc ( & tcp6_request_sock_ops , sk , false ) ; if ( ! req ) goto out ; ireq = inet_rsk ( req ) ; treq = tcp_rsk ( req ) ; treq -> tfo_listener = false ; if ( security_inet_conn_request ( sk , skb , req ) ) goto out_free ; req -> mss = mss ; ireq -> ir_rmt_port = th -> source ; ireq -> ir_num = ntohs ( th -> dest ) ; ireq -> ir_v6_rmt_addr = ipv6_hdr ( skb ) -> saddr ; ireq -> ir_v6_loc_addr = ipv6_hdr ( skb ) -> daddr ; if ( ipv6_opt_accepted ( sk , skb , & TCP_SKB_CB ( skb ) -> header . h6 ) || np -> rxopt . bits . rxinfo || np -> rxopt . bits . rxoinfo || np -> rxopt . bits . rxhlim || np -> rxopt . bits . rxohlim ) { atomic_inc ( & skb -> users ) ; ireq -> pktopts = skb ; } ireq -> ir_iif = sk -> sk_bound_dev_if ; if ( ! sk -> sk_bound_dev_if && ipv6_addr_type ( & ireq -> ir_v6_rmt_addr ) & IPV6_ADDR_LINKLOCAL ) ireq -> ir_iif = tcp_v6_iif ( skb ) ; ireq -> ir_mark = inet_request_mark ( sk , skb ) ; req -> num_retrans = 0 ; ireq -> snd_wscale = tcp_opt . snd_wscale ; ireq -> sack_ok = tcp_opt . sack_ok ; ireq -> wscale_ok = tcp_opt . wscale_ok ; ireq -> tstamp_ok = tcp_opt . saw_tstamp ; req -> ts_recent = tcp_opt . saw_tstamp ? tcp_opt . rcv_tsval : 0 ; treq -> snt_synack . v64 = 0 ; treq -> rcv_isn = ntohl ( th -> seq ) - 1 ; treq -> snt_isn = cookie ; { struct in6_addr * final_p , final ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_TCP ; fl6 . daddr = ireq -> ir_v6_rmt_addr ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; fl6 . saddr = ireq -> ir_v6_loc_addr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = ireq -> ir_mark ; fl6 . fl6_dport = ireq -> ir_rmt_port ; fl6 . fl6_sport = inet_sk ( sk ) -> inet_sport ; security_req_classify_flow ( req , flowi6_to_flowi ( & fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) goto out_free ; } req -> rsk_window_clamp = tp -> window_clamp ? : dst_metric ( dst , RTAX_WINDOW ) ; tcp_select_initial_window ( tcp_full_space ( sk ) , req -> mss , & req -> rsk_rcv_wnd , & req -> rsk_window_clamp , ireq -> wscale_ok , & rcv_wscale , dst_metric ( dst , RTAX_INITRWND ) ) ; ireq -> rcv_wscale = rcv_wscale ; ireq -> ecn_ok = cookie_ecn_ok ( & tcp_opt , sock_net ( sk ) , dst ) ; ret = tcp_get_cookie_sock ( sk , skb , req , dst ) ; out : return ret ; out_free : reqsk_free ( req ) ; return NULL ; }\n", "\n", "2: CWE-264 int inet6_csk_xmit ( struct sock * sk , struct sk_buff * skb , struct flowi * fl_unused ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 fl6 ; struct dst_entry * dst ; int res ; dst = inet6_csk_route_socket ( sk , & fl6 ) ; if ( IS_ERR ( dst ) ) { sk -> sk_err_soft = - PTR_ERR ( dst ) ; sk -> sk_route_caps = 0 ; kfree_skb ( skb ) ; return PTR_ERR ( dst ) ; } rcu_read_lock ( ) ; skb_dst_set_noref ( skb , dst ) ; fl6 . daddr = sk -> sk_v6_daddr ; res = ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; rcu_read_unlock ( ) ; return res ; }\n", "\n", "3: CWE-416 struct sock * cookie_v6_check ( struct sock * sk , struct sk_buff * skb ) { struct tcp_options_received tcp_opt ; struct inet_request_sock * ireq ; struct tcp_request_sock * treq ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct tcp_sock * tp = tcp_sk ( sk ) ; const struct tcphdr * th = tcp_hdr ( skb ) ; __u32 cookie = ntohl ( th -> ack_seq ) - 1 ; struct sock * ret = sk ; struct request_sock * req ; int mss ; struct dst_entry * dst ; __u8 rcv_wscale ; if ( ! sysctl_tcp_syncookies || ! th -> ack || th -> rst ) goto out ; if ( tcp_synq_no_recent_overflow ( sk ) ) goto out ; mss = __cookie_v6_check ( ipv6_hdr ( skb ) , th , cookie ) ; if ( mss == 0 ) { NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESFAILED ) ; goto out ; } NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESRECV ) ; memset ( & tcp_opt , 0 , sizeof ( tcp_opt ) ) ; tcp_parse_options ( skb , & tcp_opt , 0 , NULL ) ; if ( ! cookie_timestamp_decode ( & tcp_opt ) ) goto out ; ret = NULL ; req = inet_reqsk_alloc ( & tcp6_request_sock_ops , sk , false ) ; if ( ! req ) goto out ; ireq = inet_rsk ( req ) ; treq = tcp_rsk ( req ) ; treq -> tfo_listener = false ; if ( security_inet_conn_request ( sk , skb , req ) ) goto out_free ; req -> mss = mss ; ireq -> ir_rmt_port = th -> source ; ireq -> ir_num = ntohs ( th -> dest ) ; ireq -> ir_v6_rmt_addr = ipv6_hdr ( skb ) -> saddr ; ireq -> ir_v6_loc_addr = ipv6_hdr ( skb ) -> daddr ; if ( ipv6_opt_accepted ( sk , skb , & TCP_SKB_CB ( skb ) -> header . h6 ) || np -> rxopt . bits . rxinfo || np -> rxopt . bits . rxoinfo || np -> rxopt . bits . rxhlim || np -> rxopt . bits . rxohlim ) { atomic_inc ( & skb -> users ) ; ireq -> pktopts = skb ; } ireq -> ir_iif = sk -> sk_bound_dev_if ; if ( ! sk -> sk_bound_dev_if && ipv6_addr_type ( & ireq -> ir_v6_rmt_addr ) & IPV6_ADDR_LINKLOCAL ) ireq -> ir_iif = tcp_v6_iif ( skb ) ; ireq -> ir_mark = inet_request_mark ( sk , skb ) ; req -> num_retrans = 0 ; ireq -> snd_wscale = tcp_opt . snd_wscale ; ireq -> sack_ok = tcp_opt . sack_ok ; ireq -> wscale_ok = tcp_opt . wscale_ok ; ireq -> tstamp_ok = tcp_opt . saw_tstamp ; req -> ts_recent = tcp_opt . saw_tstamp ? tcp_opt . rcv_tsval : 0 ; treq -> snt_synack . v64 = 0 ; treq -> rcv_isn = ntohl ( th -> seq ) - 1 ; treq -> snt_isn = cookie ; { struct in6_addr * final_p , final ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_TCP ; fl6 . daddr = ireq -> ir_v6_rmt_addr ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; fl6 . saddr = ireq -> ir_v6_loc_addr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = ireq -> ir_mark ; fl6 . fl6_dport = ireq -> ir_rmt_port ; fl6 . fl6_sport = inet_sk ( sk ) -> inet_sport ; security_req_classify_flow ( req , flowi6_to_flowi ( & fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) goto out_free ; } req -> rsk_window_clamp = tp -> window_clamp ? : dst_metric ( dst , RTAX_WINDOW ) ; tcp_select_initial_window ( tcp_full_space ( sk ) , req -> mss , & req -> rsk_rcv_wnd , & req -> rsk_window_clamp , ireq -> wscale_ok , & rcv_wscale , dst_metric ( dst , RTAX_INITRWND ) ) ; ireq -> rcv_wscale = rcv_wscale ; ireq -> ecn_ok = cookie_ecn_ok ( & tcp_opt , sock_net ( sk ) , dst ) ; ret = tcp_get_cookie_sock ( sk , skb , req , dst ) ; out : return ret ; out_free : reqsk_free ( req ) ; return NULL ; }\n", "\n", "\n", "Target: net * net , const struct src ) { const struct { struct in6_addr dst ; struct in6_addr src ; } __aligned ( SIPHASH_ALIGNMENT ) combined = { . dst = * dst , . src = * src , } ; , id ; if ( unlikely ( siphash_key_is_zero ( & net -> ipv4 . ip_id_key ) ) ) get_random_bytes ( & net -> ipv4 . ip_id_key , sizeof ( net -> ipv4 . ip_id_key ) ) ; hash ; hash = siphash ( & combined , sizeof ( combined ) , & net -> ipv4 . ip_id_key ) ; id\n", "\n", "Sources:\n", "0: CWE-200 static u32 __ipv6_select_ident ( struct net * net , u32 hashrnd , const struct in6_addr * dst , const struct in6_addr * src ) { u32 hash , id ; hash = __ipv6_addr_jhash ( dst , hashrnd ) ; hash = __ipv6_addr_jhash ( src , hash ) ; hash ^= net_hash_mix ( net ) ; id = ip_idents_reserve ( hash , 1 ) ; if ( unlikely ( ! id ) ) id = 1 << 31 ; return id ; }\n", "\n", "1: CWE-326 static u32 __ipv6_select_ident ( struct net * net , u32 hashrnd , const struct in6_addr * dst , const struct in6_addr * src ) { u32 hash , id ; hash = __ipv6_addr_jhash ( dst , hashrnd ) ; hash = __ipv6_addr_jhash ( src , hash ) ; hash ^= net_hash_mix ( net ) ; id = ip_idents_reserve ( hash , 1 ) ; if ( unlikely ( ! id ) ) id = 1 << 31 ; return id ; }\n", "\n", "\n", "Target: ( ! handle || ! SecIsValidHandle ( handle )\n", "\n", "Sources:\n", "0: CWE-476 void * sspi_SecureHandleGetLowerPointer ( SecHandle * handle ) { void * pointer ; if ( ! handle ) return NULL ; pointer = ( void * ) ~ ( ( size_t ) handle -> dwLower ) ; return pointer ; }\n", "\n", "1: CWE-476 void * sspi_SecureHandleGetUpperPointer ( SecHandle * handle ) { void * pointer ; if ( ! handle ) return NULL ; pointer = ( void * ) ~ ( ( size_t ) handle -> dwUpper ) ; return pointer ; }\n", "\n", "\n", "Target: ( asoc , asconf_ack , false , & err_param )\n", "\n", "Sources:\n", "0: CWE-399 sctp_disposition_t sctp_sf_do_asconf_ack ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * asconf_ack = arg ; struct sctp_chunk * last_asconf = asoc -> addip_last_asconf ; struct sctp_chunk * abort ; struct sctp_paramhdr * err_param = NULL ; sctp_addiphdr_t * addip_hdr ; __u32 sent_serial , rcvd_serial ; if ( ! sctp_vtag_verify ( asconf_ack , asoc ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_REPORT_BAD_TAG , SCTP_NULL ( ) ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } if ( ! net -> sctp . addip_noauth && ! asconf_ack -> auth ) return sctp_sf_discard_chunk ( net , ep , asoc , type , arg , commands ) ; if ( ! sctp_chunk_length_valid ( asconf_ack , sizeof ( sctp_addip_chunk_t ) ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , arg , commands ) ; addip_hdr = ( sctp_addiphdr_t * ) asconf_ack -> skb -> data ; rcvd_serial = ntohl ( addip_hdr -> serial ) ; if ( ! sctp_verify_asconf ( asoc , ( sctp_paramhdr_t * ) addip_hdr -> params , ( void * ) asconf_ack -> chunk_end , & err_param ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) err_param , commands ) ; if ( last_asconf ) { addip_hdr = ( sctp_addiphdr_t * ) last_asconf -> subh . addip_hdr ; sent_serial = ntohl ( addip_hdr -> serial ) ; } else { sent_serial = asoc -> addip_serial - 1 ; } if ( ADDIP_SERIAL_gte ( rcvd_serial , sent_serial + 1 ) && ! ( asoc -> addip_last_asconf ) ) { abort = sctp_make_abort ( asoc , asconf_ack , sizeof ( sctp_errhdr_t ) ) ; if ( abort ) { sctp_init_cause ( abort , SCTP_ERROR_ASCONF_ACK , 0 ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( abort ) ) ; } sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_STOP , SCTP_TO ( SCTP_EVENT_TIMEOUT_T4_RTO ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_DISCARD_PACKET , SCTP_NULL ( ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_SET_SK_ERR , SCTP_ERROR ( ECONNABORTED ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_ASSOC_FAILED , SCTP_PERR ( SCTP_ERROR_ASCONF_ACK ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_ABORTEDS ) ; SCTP_DEC_STATS ( net , SCTP_MIB_CURRESTAB ) ; return SCTP_DISPOSITION_ABORT ; } if ( ( rcvd_serial == sent_serial ) && asoc -> addip_last_asconf ) { sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_STOP , SCTP_TO ( SCTP_EVENT_TIMEOUT_T4_RTO ) ) ; if ( ! sctp_process_asconf_ack ( ( struct sctp_association * ) asoc , asconf_ack ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_SEND_NEXT_ASCONF , SCTP_NULL ( ) ) ; return SCTP_DISPOSITION_CONSUME ; } abort = sctp_make_abort ( asoc , asconf_ack , sizeof ( sctp_errhdr_t ) ) ; if ( abort ) { sctp_init_cause ( abort , SCTP_ERROR_RSRC_LOW , 0 ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( abort ) ) ; } sctp_add_cmd_sf ( commands , SCTP_CMD_DISCARD_PACKET , SCTP_NULL ( ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_SET_SK_ERR , SCTP_ERROR ( ECONNABORTED ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_ASSOC_FAILED , SCTP_PERR ( SCTP_ERROR_ASCONF_ACK ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_ABORTEDS ) ; SCTP_DEC_STATS ( net , SCTP_MIB_CURRESTAB ) ; return SCTP_DISPOSITION_ABORT ; } return SCTP_DISPOSITION_DISCARD ; }\n", "\n", "1: CWE-20 sctp_disposition_t sctp_sf_do_asconf_ack ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * asconf_ack = arg ; struct sctp_chunk * last_asconf = asoc -> addip_last_asconf ; struct sctp_chunk * abort ; struct sctp_paramhdr * err_param = NULL ; sctp_addiphdr_t * addip_hdr ; __u32 sent_serial , rcvd_serial ; if ( ! sctp_vtag_verify ( asconf_ack , asoc ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_REPORT_BAD_TAG , SCTP_NULL ( ) ) ; return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; } if ( ! net -> sctp . addip_noauth && ! asconf_ack -> auth ) return sctp_sf_discard_chunk ( net , ep , asoc , type , arg , commands ) ; if ( ! sctp_chunk_length_valid ( asconf_ack , sizeof ( sctp_addip_chunk_t ) ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , arg , commands ) ; addip_hdr = ( sctp_addiphdr_t * ) asconf_ack -> skb -> data ; rcvd_serial = ntohl ( addip_hdr -> serial ) ; if ( ! sctp_verify_asconf ( asoc , ( sctp_paramhdr_t * ) addip_hdr -> params , ( void * ) asconf_ack -> chunk_end , & err_param ) ) return sctp_sf_violation_paramlen ( net , ep , asoc , type , arg , ( void * ) err_param , commands ) ; if ( last_asconf ) { addip_hdr = ( sctp_addiphdr_t * ) last_asconf -> subh . addip_hdr ; sent_serial = ntohl ( addip_hdr -> serial ) ; } else { sent_serial = asoc -> addip_serial - 1 ; } if ( ADDIP_SERIAL_gte ( rcvd_serial , sent_serial + 1 ) && ! ( asoc -> addip_last_asconf ) ) { abort = sctp_make_abort ( asoc , asconf_ack , sizeof ( sctp_errhdr_t ) ) ; if ( abort ) { sctp_init_cause ( abort , SCTP_ERROR_ASCONF_ACK , 0 ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( abort ) ) ; } sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_STOP , SCTP_TO ( SCTP_EVENT_TIMEOUT_T4_RTO ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_DISCARD_PACKET , SCTP_NULL ( ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_SET_SK_ERR , SCTP_ERROR ( ECONNABORTED ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_ASSOC_FAILED , SCTP_PERR ( SCTP_ERROR_ASCONF_ACK ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_ABORTEDS ) ; SCTP_DEC_STATS ( net , SCTP_MIB_CURRESTAB ) ; return SCTP_DISPOSITION_ABORT ; } if ( ( rcvd_serial == sent_serial ) && asoc -> addip_last_asconf ) { sctp_add_cmd_sf ( commands , SCTP_CMD_TIMER_STOP , SCTP_TO ( SCTP_EVENT_TIMEOUT_T4_RTO ) ) ; if ( ! sctp_process_asconf_ack ( ( struct sctp_association * ) asoc , asconf_ack ) ) { sctp_add_cmd_sf ( commands , SCTP_CMD_SEND_NEXT_ASCONF , SCTP_NULL ( ) ) ; return SCTP_DISPOSITION_CONSUME ; } abort = sctp_make_abort ( asoc , asconf_ack , sizeof ( sctp_errhdr_t ) ) ; if ( abort ) { sctp_init_cause ( abort , SCTP_ERROR_RSRC_LOW , 0 ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_REPLY , SCTP_CHUNK ( abort ) ) ; } sctp_add_cmd_sf ( commands , SCTP_CMD_DISCARD_PACKET , SCTP_NULL ( ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_SET_SK_ERR , SCTP_ERROR ( ECONNABORTED ) ) ; sctp_add_cmd_sf ( commands , SCTP_CMD_ASSOC_FAILED , SCTP_PERR ( SCTP_ERROR_ASCONF_ACK ) ) ; SCTP_INC_STATS ( net , SCTP_MIB_ABORTEDS ) ; SCTP_DEC_STATS ( net , SCTP_MIB_CURRESTAB ) ; return SCTP_DISPOSITION_ABORT ; } return SCTP_DISPOSITION_DISCARD ; }\n", "\n", "\n", "Target: { if ( js_doregexec ( J , re -> prog\n", "\n", "Sources:\n", "0: CWE-400 static void Sp_match ( js_State * J ) { js_Regexp * re ; const char * text ; int len ; const char * a , * b , * c , * e ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , \"\" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! ( re -> flags & JS_REGEXP_G ) ) { js_RegExp_prototype_exec ( J , re , text ) ; return ; } re -> last = 0 ; js_newarray ( J ) ; len = 0 ; a = text ; e = text + strlen ( text ) ; while ( a <= e ) { if ( js_regexec ( re -> prog , a , & m , a > text ? REG_NOTBOL : 0 ) ) break ; b = m . sub [ 0 ] . sp ; c = m . sub [ 0 ] . ep ; js_pushlstring ( J , b , c - b ) ; js_setindex ( J , - 2 , len ++ ) ; a = c ; if ( c - b == 0 ) ++ a ; } if ( len == 0 ) { js_pop ( J , 1 ) ; js_pushnull ( J ) ; } }\n", "\n", "1: CWE-674 static void Sp_match ( js_State * J ) { js_Regexp * re ; const char * text ; int len ; const char * a , * b , * c , * e ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , \"\" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! ( re -> flags & JS_REGEXP_G ) ) { js_RegExp_prototype_exec ( J , re , text ) ; return ; } re -> last = 0 ; js_newarray ( J ) ; len = 0 ; a = text ; e = text + strlen ( text ) ; while ( a <= e ) { if ( js_regexec ( re -> prog , a , & m , a > text ? REG_NOTBOL : 0 ) ) break ; b = m . sub [ 0 ] . sp ; c = m . sub [ 0 ] . ep ; js_pushlstring ( J , b , c - b ) ; js_setindex ( J , - 2 , len ++ ) ; a = c ; if ( c - b == 0 ) ++ a ; } if ( len == 0 ) { js_pop ( J , 1 ) ; js_pushnull ( J ) ; } }\n", "\n", "\n", "Target: ; return error < 0 ? error : 0\n", "\n", "Sources:\n", "0: CWE-000 int iwch_cxgb3_ofld_send ( struct t3cdev * tdev , struct sk_buff * skb ) { int error = 0 ; struct cxio_rdev * rdev ; rdev = ( struct cxio_rdev * ) tdev -> ulp ; if ( cxio_fatal_error ( rdev ) ) { kfree_skb ( skb ) ; return - EIO ; } error = cxgb3_ofld_send ( tdev , skb ) ; if ( error < 0 ) kfree_skb ( skb ) ; return error ; }\n", "\n", "1: CWE-000 static int iwch_l2t_send ( struct t3cdev * tdev , struct sk_buff * skb , struct l2t_entry * l2e ) { int error = 0 ; struct cxio_rdev * rdev ; rdev = ( struct cxio_rdev * ) tdev -> ulp ; if ( cxio_fatal_error ( rdev ) ) { kfree_skb ( skb ) ; return - EIO ; } error = l2t_send ( tdev , skb , l2e ) ; if ( error < 0 ) kfree_skb ( skb ) ; return error ; }\n", "\n", "\n", "Target: ( err ) { kfree_skb ( skb ) ; return err ; } return nlmsg_unicast (\n", "\n", "Sources:\n", "0: CWE-401 static int crypto_report ( struct sk_buff * in_skb , struct nlmsghdr * in_nlh , struct nlattr * * attrs ) { struct net * net = sock_net ( in_skb -> sk ) ; struct crypto_user_alg * p = nlmsg_data ( in_nlh ) ; struct crypto_alg * alg ; struct sk_buff * skb ; struct crypto_dump_info info ; int err ; if ( ! null_terminated ( p -> cru_name ) || ! null_terminated ( p -> cru_driver_name ) ) return - EINVAL ; alg = crypto_alg_match ( p , 0 ) ; if ( ! alg ) return - ENOENT ; err = - ENOMEM ; skb = nlmsg_new ( NLMSG_DEFAULT_SIZE , GFP_KERNEL ) ; if ( ! skb ) goto drop_alg ; info . in_skb = in_skb ; info . out_skb = skb ; info . nlmsg_seq = in_nlh -> nlmsg_seq ; info . nlmsg_flags = 0 ; err = crypto_report_alg ( alg , & info ) ; drop_alg : crypto_mod_put ( alg ) ; if ( err ) return err ; return nlmsg_unicast ( net -> crypto_nlsk , skb , NETLINK_CB ( in_skb ) . portid ) ; }\n", "\n", "1: CWE-401 int crypto_reportstat ( struct sk_buff * in_skb , struct nlmsghdr * in_nlh , struct nlattr * * attrs ) { struct net * net = sock_net ( in_skb -> sk ) ; struct crypto_user_alg * p = nlmsg_data ( in_nlh ) ; struct crypto_alg * alg ; struct sk_buff * skb ; struct crypto_dump_info info ; int err ; if ( ! null_terminated ( p -> cru_name ) || ! null_terminated ( p -> cru_driver_name ) ) return - EINVAL ; alg = crypto_alg_match ( p , 0 ) ; if ( ! alg ) return - ENOENT ; err = - ENOMEM ; skb = nlmsg_new ( NLMSG_DEFAULT_SIZE , GFP_ATOMIC ) ; if ( ! skb ) goto drop_alg ; info . in_skb = in_skb ; info . out_skb = skb ; info . nlmsg_seq = in_nlh -> nlmsg_seq ; info . nlmsg_flags = 0 ; err = crypto_reportstat_alg ( alg , & info ) ; drop_alg : crypto_mod_put ( alg ) ; if ( err ) return err ; return nlmsg_unicast ( net -> crypto_nlsk , skb , NETLINK_CB ( in_skb ) . portid ) ; }\n", "\n", "\n", "Target: if ( ( unconditional ( e ) && ( verdict < 0 ) || visited\n", "\n", "Sources:\n", "0: CWE-119 static int mark_source_chains ( const struct xt_table_info * newinfo , unsigned int valid_hooks , void * entry0 ) { unsigned int hook ; for ( hook = 0 ; hook < NF_INET_NUMHOOKS ; hook ++ ) { unsigned int pos = newinfo -> hook_entry [ hook ] ; struct ipt_entry * e = ( struct ipt_entry * ) ( entry0 + pos ) ; if ( ! ( valid_hooks & ( 1 << hook ) ) ) continue ; e -> counters . pcnt = pos ; for ( ; ; ) { const struct xt_standard_target * t = ( void * ) ipt_get_target_c ( e ) ; int visited = e -> comefrom & ( 1 << hook ) ; if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { pr_err ( \"iptables:loophook%upos%u%08X.\\\\n\" , hook , pos , e -> comefrom ) ; return 0 ; } e -> comefrom |= ( ( 1 << hook ) | ( 1 << NF_INET_NUMHOOKS ) ) ; if ( ( e -> target_offset == sizeof ( struct ipt_entry ) && ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < 0 && unconditional ( & e -> ip ) ) || visited ) { unsigned int oldpos , size ; if ( ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < - NF_MAX_VERDICT - 1 ) { duprintf ( \"mark_source_chains:bad\" \"negativeverdict(%i)\\\\n\" , t -> verdict ) ; return 0 ; } do { e -> comefrom ^= ( 1 << NF_INET_NUMHOOKS ) ; # ifdef DEBUG_IP_FIREWALL_USER if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { duprintf ( \"Backunset\" \"onhook%u\" \"rule%u\\\\n\" , hook , pos ) ; } # endif oldpos = pos ; pos = e -> counters . pcnt ; e -> counters . pcnt = 0 ; if ( pos == oldpos ) goto next ; e = ( struct ipt_entry * ) ( entry0 + pos ) ; } while ( oldpos == pos + e -> next_offset ) ; size = e -> next_offset ; e = ( struct ipt_entry * ) ( entry0 + pos + size ) ; e -> counters . pcnt = pos ; pos += size ; } else { int newpos = t -> verdict ; if ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 && newpos >= 0 ) { if ( newpos > newinfo -> size - sizeof ( struct ipt_entry ) ) { duprintf ( \"mark_source_chains:\" \"badverdict(%i)\\\\n\" , newpos ) ; return 0 ; } duprintf ( \"Jumprule%u->%u\\\\n\" , pos , newpos ) ; } else { newpos = pos + e -> next_offset ; } e = ( struct ipt_entry * ) ( entry0 + newpos ) ; e -> counters . pcnt = pos ; pos = newpos ; } } next : duprintf ( \"Finishedchain%u\\\\n\" , hook ) ; } return 1 ; }\n", "\n", "1: CWE-119 static int mark_source_chains ( const struct xt_table_info * newinfo , unsigned int valid_hooks , void * entry0 ) { unsigned int hook ; for ( hook = 0 ; hook < NF_INET_NUMHOOKS ; hook ++ ) { unsigned int pos = newinfo -> hook_entry [ hook ] ; struct ip6t_entry * e = ( struct ip6t_entry * ) ( entry0 + pos ) ; if ( ! ( valid_hooks & ( 1 << hook ) ) ) continue ; e -> counters . pcnt = pos ; for ( ; ; ) { const struct xt_standard_target * t = ( void * ) ip6t_get_target_c ( e ) ; int visited = e -> comefrom & ( 1 << hook ) ; if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { pr_err ( \"iptables:loophook%upos%u%08X.\\\\n\" , hook , pos , e -> comefrom ) ; return 0 ; } e -> comefrom |= ( ( 1 << hook ) | ( 1 << NF_INET_NUMHOOKS ) ) ; if ( ( e -> target_offset == sizeof ( struct ip6t_entry ) && ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < 0 && unconditional ( & e -> ipv6 ) ) || visited ) { unsigned int oldpos , size ; if ( ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < - NF_MAX_VERDICT - 1 ) { duprintf ( \"mark_source_chains:bad\" \"negativeverdict(%i)\\\\n\" , t -> verdict ) ; return 0 ; } do { e -> comefrom ^= ( 1 << NF_INET_NUMHOOKS ) ; # ifdef DEBUG_IP_FIREWALL_USER if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { duprintf ( \"Backunset\" \"onhook%u\" \"rule%u\\\\n\" , hook , pos ) ; } # endif oldpos = pos ; pos = e -> counters . pcnt ; e -> counters . pcnt = 0 ; if ( pos == oldpos ) goto next ; e = ( struct ip6t_entry * ) ( entry0 + pos ) ; } while ( oldpos == pos + e -> next_offset ) ; size = e -> next_offset ; e = ( struct ip6t_entry * ) ( entry0 + pos + size ) ; e -> counters . pcnt = pos ; pos += size ; } else { int newpos = t -> verdict ; if ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 && newpos >= 0 ) { if ( newpos > newinfo -> size - sizeof ( struct ip6t_entry ) ) { duprintf ( \"mark_source_chains:\" \"badverdict(%i)\\\\n\" , newpos ) ; return 0 ; } duprintf ( \"Jumprule%u->%u\\\\n\" , pos , newpos ) ; } else { newpos = pos + e -> next_offset ; } e = ( struct ip6t_entry * ) ( entry0 + newpos ) ; e -> counters . pcnt = pos ; pos = newpos ; } } next : duprintf ( \"Finishedchain%u\\\\n\" , hook ) ; } return 1 ; }\n", "\n", "2: CWE-119 static int mark_source_chains ( const struct xt_table_info * newinfo , unsigned int valid_hooks , void * entry0 ) { unsigned int hook ; for ( hook = 0 ; hook < NF_ARP_NUMHOOKS ; hook ++ ) { unsigned int pos = newinfo -> hook_entry [ hook ] ; struct arpt_entry * e = ( struct arpt_entry * ) ( entry0 + pos ) ; if ( ! ( valid_hooks & ( 1 << hook ) ) ) continue ; e -> counters . pcnt = pos ; for ( ; ; ) { const struct xt_standard_target * t = ( void * ) arpt_get_target_c ( e ) ; int visited = e -> comefrom & ( 1 << hook ) ; if ( e -> comefrom & ( 1 << NF_ARP_NUMHOOKS ) ) { pr_notice ( \"arptables:loophook%upos%u%08X.\\\\n\" , hook , pos , e -> comefrom ) ; return 0 ; } e -> comefrom |= ( ( 1 << hook ) | ( 1 << NF_ARP_NUMHOOKS ) ) ; if ( ( e -> target_offset == sizeof ( struct arpt_entry ) && ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < 0 && unconditional ( & e -> arp ) ) || visited ) { unsigned int oldpos , size ; if ( ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < - NF_MAX_VERDICT - 1 ) { duprintf ( \"mark_source_chains:bad\" \"negativeverdict(%i)\\\\n\" , t -> verdict ) ; return 0 ; } do { e -> comefrom ^= ( 1 << NF_ARP_NUMHOOKS ) ; oldpos = pos ; pos = e -> counters . pcnt ; e -> counters . pcnt = 0 ; if ( pos == oldpos ) goto next ; e = ( struct arpt_entry * ) ( entry0 + pos ) ; } while ( oldpos == pos + e -> next_offset ) ; size = e -> next_offset ; e = ( struct arpt_entry * ) ( entry0 + pos + size ) ; e -> counters . pcnt = pos ; pos += size ; } else { int newpos = t -> verdict ; if ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 && newpos >= 0 ) { if ( newpos > newinfo -> size - sizeof ( struct arpt_entry ) ) { duprintf ( \"mark_source_chains:\" \"badverdict(%i)\\\\n\" , newpos ) ; return 0 ; } duprintf ( \"Jumprule%u->%u\\\\n\" , pos , newpos ) ; } else { newpos = pos + e -> next_offset ; } e = ( struct arpt_entry * ) ( entry0 + newpos ) ; e -> counters . pcnt = pos ; pos = newpos ; } } next : duprintf ( \"Finishedchain%u\\\\n\" , hook ) ; } return 1 ; }\n", "\n", "\n", "Target: [ LONG_STRING ] = \"\" ( line , \"%1023s\" ANUM \"\" ANUM ANUM \"\" ANUM \"%c%8191[^\\\\n]\" , group , < 4 ) { mutt_debug ( 4 , \"Cannotparseserverline:%s\\\\n\" , line ) ; return 0 ; }\n", "\n", "Sources:\n", "0: CWE-119 int nntp_add_group ( char * line , void * data ) { struct NntpServer * nserv = data ; struct NntpData * nntp_data = NULL ; char group [ LONG_STRING ] ; char desc [ HUGE_STRING ] = \"\" ; char mod ; anum_t first , last ; if ( ! nserv || ! line ) return 0 ; if ( sscanf ( line , \"%s\" ANUM \"\" ANUM \"%c%[^\\\\n]\" , group , & last , & first , & mod , desc ) < 4 ) return 0 ; nntp_data = nntp_data_find ( nserv , group ) ; nntp_data -> deleted = false ; nntp_data -> first_message = first ; nntp_data -> last_message = last ; nntp_data -> allowed = ( mod == 'y' ) || ( mod == 'm' ) ; mutt_str_replace ( & nntp_data -> desc , desc ) ; if ( nntp_data -> newsrc_ent || nntp_data -> last_cached ) nntp_group_unread_stat ( nntp_data ) ; else if ( nntp_data -> last_message && nntp_data -> first_message <= nntp_data -> last_message ) nntp_data -> unread = nntp_data -> last_message - nntp_data -> first_message + 1 ; else nntp_data -> unread = 0 ; return 0 ; }\n", "\n", "1: CWE-787 int nntp_add_group ( char * line , void * data ) { struct NntpServer * nserv = data ; struct NntpData * nntp_data = NULL ; char group [ LONG_STRING ] ; char desc [ HUGE_STRING ] = \"\" ; char mod ; anum_t first , last ; if ( ! nserv || ! line ) return 0 ; if ( sscanf ( line , \"%s\" ANUM \"\" ANUM \"%c%[^\\\\n]\" , group , & last , & first , & mod , desc ) < 4 ) return 0 ; nntp_data = nntp_data_find ( nserv , group ) ; nntp_data -> deleted = false ; nntp_data -> first_message = first ; nntp_data -> last_message = last ; nntp_data -> allowed = ( mod == 'y' ) || ( mod == 'm' ) ; mutt_str_replace ( & nntp_data -> desc , desc ) ; if ( nntp_data -> newsrc_ent || nntp_data -> last_cached ) nntp_group_unread_stat ( nntp_data ) ; else if ( nntp_data -> last_message && nntp_data -> first_message <= nntp_data -> last_message ) nntp_data -> unread = nntp_data -> last_message - nntp_data -> first_message + 1 ; else nntp_data -> unread = 0 ; return 0 ; }\n", "\n", "\n", "Target: in ) ; int64 iskew = ( int64 ) imagew - ( int64 ) tilew ; uint8 if ( colb > iskew ) { uint32\n", "\n", "Sources:\n", "0: CWE-119 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth && colb < imagew ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , \"Error,can\\'treadtileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; }\n", "\n", "1: CWE-190 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth && colb < imagew ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , \"Error,can\\'treadtileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; }\n", "\n", "\n", "Target: 0 ; i < SERDES_MAX ; i\n", "\n", "Sources:\n", "0: CWE-125 static struct phy * serdes_simple_xlate ( struct device * dev , struct of_phandle_args * args ) { struct serdes_ctrl * ctrl = dev_get_drvdata ( dev ) ; unsigned int port , idx , i ; if ( args -> args_count != 2 ) return ERR_PTR ( - EINVAL ) ; port = args -> args [ 0 ] ; idx = args -> args [ 1 ] ; for ( i = 0 ; i <= SERDES_MAX ; i ++ ) { struct serdes_macro * macro = phy_get_drvdata ( ctrl -> phys [ i ] ) ; if ( idx != macro -> idx ) continue ; if ( idx != SERDES6G ( 0 ) && macro -> port >= 0 ) return ERR_PTR ( - EBUSY ) ; macro -> port = port ; return ctrl -> phys [ i ] ; } return ERR_PTR ( - ENODEV ) ; }\n", "\n", "1: CWE-125 static int serdes_probe ( struct platform_device * pdev ) { struct phy_provider * provider ; struct serdes_ctrl * ctrl ; unsigned int i ; int ret ; ctrl = devm_kzalloc ( & pdev -> dev , sizeof ( * ctrl ) , GFP_KERNEL ) ; if ( ! ctrl ) return - ENOMEM ; ctrl -> dev = & pdev -> dev ; ctrl -> regs = syscon_node_to_regmap ( pdev -> dev . parent -> of_node ) ; if ( IS_ERR ( ctrl -> regs ) ) return PTR_ERR ( ctrl -> regs ) ; for ( i = 0 ; i <= SERDES_MAX ; i ++ ) { ret = serdes_phy_create ( ctrl , i , & ctrl -> phys [ i ] ) ; if ( ret ) return ret ; } dev_set_drvdata ( & pdev -> dev , ctrl ) ; provider = devm_of_phy_provider_register ( ctrl -> dev , serdes_simple_xlate ) ; return PTR_ERR_OR_ZERO ( provider ) ; }\n", "\n", "\n", "Target: ( code ) \\\\\\n{ if ( bits ) ; } \\\\\\n} Quantum index ; ++ ) { next_pixel = MagickFalse ; displacement = 1 ; -= MaxHashTable ; if ( k < 0 ) continue ; if (\n", "\n", "Sources:\n", "0: CWE-787 static MagickBooleanType EncodeImage ( const ImageInfo * image_info , Image * image , const size_t data_size , ExceptionInfo * exception ) { # define MaxCode ( number_bits ) ( ( one << ( number_bits ) ) - 1 ) # define MaxHashTable 5003 # define MaxGIFBits 12UL # define MaxGIFTable ( 1UL << MaxGIFBits ) # define GIFOutputCode ( code ) { if ( bits > 0 ) datum |= ( size_t ) ( code ) << bits ; else datum = ( size_t ) ( code ) ; bits += number_bits ; while ( bits >= 8 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } datum >>= 8 ; bits -= 8 ; } if ( free_code > max_code ) { number_bits ++ ; if ( number_bits == MaxGIFBits ) max_code = MaxGIFTable ; else max_code = MaxCode ( number_bits ) ; } } Quantum index ; short * hash_code , * hash_prefix , waiting_code ; size_t bits , clear_code , datum , end_of_information_code , free_code , length , max_code , next_pixel , number_bits , one , pass ; ssize_t displacement , offset , k , y ; unsigned char * packet , * hash_suffix ; assert ( image != ( Image * ) NULL ) ; one = 1 ; packet = ( unsigned char * ) AcquireQuantumMemory ( 256 , sizeof ( * packet ) ) ; hash_code = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_code ) ) ; hash_prefix = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_prefix ) ) ; hash_suffix = ( unsigned char * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_suffix ) ) ; if ( ( packet == ( unsigned char * ) NULL ) || ( hash_code == ( short * ) NULL ) || ( hash_prefix == ( short * ) NULL ) || ( hash_suffix == ( unsigned char * ) NULL ) ) { if ( packet != ( unsigned char * ) NULL ) packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; if ( hash_code != ( short * ) NULL ) hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; if ( hash_prefix != ( short * ) NULL ) hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; if ( hash_suffix != ( unsigned char * ) NULL ) hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; return ( MagickFalse ) ; } ( void ) memset ( packet , 0 , 256 * sizeof ( * packet ) ) ; ( void ) memset ( hash_code , 0 , MaxHashTable * sizeof ( * hash_code ) ) ; ( void ) memset ( hash_prefix , 0 , MaxHashTable * sizeof ( * hash_prefix ) ) ; ( void ) memset ( hash_suffix , 0 , MaxHashTable * sizeof ( * hash_suffix ) ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; clear_code = ( ( short ) one << ( data_size - 1 ) ) ; end_of_information_code = clear_code + 1 ; free_code = clear_code + 2 ; length = 0 ; datum = 0 ; bits = 0 ; GIFOutputCode ( clear_code ) ; offset = 0 ; pass = 0 ; waiting_code = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register const Quantum * magick_restrict p ; register ssize_t x ; p = GetVirtualPixels ( image , 0 , offset , image -> columns , 1 , exception ) ; if ( p == ( const Quantum * ) NULL ) break ; if ( y == 0 ) { waiting_code = ( short ) GetPixelIndex ( image , p ) ; p += GetPixelChannels ( image ) ; } for ( x = ( ssize_t ) ( y == 0 ? 1 : 0 ) ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ( Quantum ) ( ( size_t ) GetPixelIndex ( image , p ) & 0xff ) ; p += GetPixelChannels ( image ) ; k = ( ssize_t ) ( ( ( size_t ) index << ( MaxGIFBits - 8 ) ) + waiting_code ) ; if ( k >= MaxHashTable ) k -= MaxHashTable ; next_pixel = MagickFalse ; displacement = 1 ; if ( hash_code [ k ] > 0 ) { if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; continue ; } if ( k != 0 ) displacement = MaxHashTable - k ; for ( ; ; ) { k -= displacement ; if ( k < 0 ) k += MaxHashTable ; if ( hash_code [ k ] == 0 ) break ; if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; next_pixel = MagickTrue ; break ; } } if ( next_pixel != MagickFalse ) continue ; } GIFOutputCode ( waiting_code ) ; if ( free_code < MaxGIFTable ) { hash_code [ k ] = ( short ) free_code ++ ; hash_prefix [ k ] = waiting_code ; hash_suffix [ k ] = ( unsigned char ) index ; } else { for ( k = 0 ; k < MaxHashTable ; k ++ ) hash_code [ k ] = 0 ; free_code = clear_code + 2 ; GIFOutputCode ( clear_code ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; } waiting_code = ( short ) index ; } if ( image_info -> interlace == NoInterlace ) offset ++ ; else switch ( pass ) { case 0 : default : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 4 ; } break ; } case 1 : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 2 ; } break ; } case 2 : { offset += 4 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 1 ; } break ; } case 3 : { offset += 2 ; break ; } } } GIFOutputCode ( waiting_code ) ; GIFOutputCode ( end_of_information_code ) ; if ( bits > 0 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } } if ( length > 0 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; } hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; return ( MagickTrue ) ; }\n", "\n", "1: CWE-119 static MagickBooleanType EncodeImage ( const ImageInfo * image_info , Image * image , const size_t data_size , ExceptionInfo * exception ) { # define MaxCode ( number_bits ) ( ( one << ( number_bits ) ) - 1 ) # define MaxHashTable 5003 # define MaxGIFBits 12UL # define MaxGIFTable ( 1UL << MaxGIFBits ) # define GIFOutputCode ( code ) { if ( bits > 0 ) datum |= ( size_t ) ( code ) << bits ; else datum = ( size_t ) ( code ) ; bits += number_bits ; while ( bits >= 8 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } datum >>= 8 ; bits -= 8 ; } if ( free_code > max_code ) { number_bits ++ ; if ( number_bits == MaxGIFBits ) max_code = MaxGIFTable ; else max_code = MaxCode ( number_bits ) ; } } Quantum index ; short * hash_code , * hash_prefix , waiting_code ; size_t bits , clear_code , datum , end_of_information_code , free_code , length , max_code , next_pixel , number_bits , one , pass ; ssize_t displacement , offset , k , y ; unsigned char * packet , * hash_suffix ; assert ( image != ( Image * ) NULL ) ; one = 1 ; packet = ( unsigned char * ) AcquireQuantumMemory ( 256 , sizeof ( * packet ) ) ; hash_code = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_code ) ) ; hash_prefix = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_prefix ) ) ; hash_suffix = ( unsigned char * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_suffix ) ) ; if ( ( packet == ( unsigned char * ) NULL ) || ( hash_code == ( short * ) NULL ) || ( hash_prefix == ( short * ) NULL ) || ( hash_suffix == ( unsigned char * ) NULL ) ) { if ( packet != ( unsigned char * ) NULL ) packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; if ( hash_code != ( short * ) NULL ) hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; if ( hash_prefix != ( short * ) NULL ) hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; if ( hash_suffix != ( unsigned char * ) NULL ) hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; return ( MagickFalse ) ; } ( void ) memset ( packet , 0 , 256 * sizeof ( * packet ) ) ; ( void ) memset ( hash_code , 0 , MaxHashTable * sizeof ( * hash_code ) ) ; ( void ) memset ( hash_prefix , 0 , MaxHashTable * sizeof ( * hash_prefix ) ) ; ( void ) memset ( hash_suffix , 0 , MaxHashTable * sizeof ( * hash_suffix ) ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; clear_code = ( ( short ) one << ( data_size - 1 ) ) ; end_of_information_code = clear_code + 1 ; free_code = clear_code + 2 ; length = 0 ; datum = 0 ; bits = 0 ; GIFOutputCode ( clear_code ) ; offset = 0 ; pass = 0 ; waiting_code = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register const Quantum * magick_restrict p ; register ssize_t x ; p = GetVirtualPixels ( image , 0 , offset , image -> columns , 1 , exception ) ; if ( p == ( const Quantum * ) NULL ) break ; if ( y == 0 ) { waiting_code = ( short ) GetPixelIndex ( image , p ) ; p += GetPixelChannels ( image ) ; } for ( x = ( ssize_t ) ( y == 0 ? 1 : 0 ) ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ( Quantum ) ( ( size_t ) GetPixelIndex ( image , p ) & 0xff ) ; p += GetPixelChannels ( image ) ; k = ( ssize_t ) ( ( ( size_t ) index << ( MaxGIFBits - 8 ) ) + waiting_code ) ; if ( k >= MaxHashTable ) k -= MaxHashTable ; next_pixel = MagickFalse ; displacement = 1 ; if ( hash_code [ k ] > 0 ) { if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; continue ; } if ( k != 0 ) displacement = MaxHashTable - k ; for ( ; ; ) { k -= displacement ; if ( k < 0 ) k += MaxHashTable ; if ( hash_code [ k ] == 0 ) break ; if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; next_pixel = MagickTrue ; break ; } } if ( next_pixel != MagickFalse ) continue ; } GIFOutputCode ( waiting_code ) ; if ( free_code < MaxGIFTable ) { hash_code [ k ] = ( short ) free_code ++ ; hash_prefix [ k ] = waiting_code ; hash_suffix [ k ] = ( unsigned char ) index ; } else { for ( k = 0 ; k < MaxHashTable ; k ++ ) hash_code [ k ] = 0 ; free_code = clear_code + 2 ; GIFOutputCode ( clear_code ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; } waiting_code = ( short ) index ; } if ( image_info -> interlace == NoInterlace ) offset ++ ; else switch ( pass ) { case 0 : default : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 4 ; } break ; } case 1 : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 2 ; } break ; } case 2 : { offset += 4 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 1 ; } break ; } case 3 : { offset += 2 ; break ; } } } GIFOutputCode ( waiting_code ) ; GIFOutputCode ( end_of_information_code ) ; if ( bits > 0 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } } if ( length > 0 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; } hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; return ( MagickTrue ) ; }\n", "\n", "\n", "Target: ) { return nf_generic_should_process ( nf_ct_protonum ( ct ) ) ; } \n", "\n", "Sources:\n", "0: CWE-20 static bool generic_new ( struct nf_conn * ct , const struct sk_buff * skb , unsigned int dataoff , unsigned int * timeouts ) { return true ; }\n", "\n", "1: CWE-254 static bool generic_new ( struct nf_conn * ct , const struct sk_buff * skb , unsigned int dataoff , unsigned int * timeouts ) { return true ; }\n", "\n", "\n", "Target: O_RDONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY ) ) ; if ( cfg -> is_custom_debug_file ) { fclose ( cfg -> debug_file ) ; }\n", "\n", "Sources:\n", "0: CWE-000 int pam_sm_authenticate ( pam_handle_t * pamh , int flags , int argc , const char * * argv ) { struct passwd * pw = NULL , pw_s ; const char * user = NULL ; cfg_t cfg_st ; cfg_t * cfg = & cfg_st ; char buffer [ BUFSIZE ] ; char * buf = NULL ; char * authfile_dir ; size_t authfile_dir_len ; int pgu_ret , gpn_ret ; int retval = PAM_IGNORE ; device_t * devices = NULL ; unsigned n_devices = 0 ; int openasuser ; int should_free_origin = 0 ; int should_free_appid = 0 ; int should_free_auth_file = 0 ; int should_free_authpending_file = 0 ; parse_cfg ( flags , argc , argv , cfg ) ; if ( ! cfg -> origin ) { strcpy ( buffer , DEFAULT_ORIGIN_PREFIX ) ; if ( gethostname ( buffer + strlen ( DEFAULT_ORIGIN_PREFIX ) , BUFSIZE - strlen ( DEFAULT_ORIGIN_PREFIX ) ) == - 1 ) { DBG ( \"Unabletogethostname\" ) ; goto done ; } DBG ( \"Originnotspecified,using\\\\\"%s\\\\\"\" , buffer ) ; cfg -> origin = strdup ( buffer ) ; if ( ! cfg -> origin ) { DBG ( \"Unabletoallocatememory\" ) ; goto done ; } else { should_free_origin = 1 ; } } if ( ! cfg -> appid ) { DBG ( \"Appidnotspecified,usingthesamevalueoforigin(%s)\" , cfg -> origin ) ; cfg -> appid = strdup ( cfg -> origin ) ; if ( ! cfg -> appid ) { DBG ( \"Unabletoallocatememory\" ) goto done ; } else { should_free_appid = 1 ; } } if ( cfg -> max_devs == 0 ) { DBG ( \"Maximumdevicesnumbernotset.Usingdefault(%d)\" , MAX_DEVS ) ; cfg -> max_devs = MAX_DEVS ; } devices = malloc ( sizeof ( device_t ) * cfg -> max_devs ) ; if ( ! devices ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } pgu_ret = pam_get_user ( pamh , & user , NULL ) ; if ( pgu_ret != PAM_SUCCESS || user == NULL ) { DBG ( \"Unabletoaccessuser%s\" , user ) ; retval = PAM_CONV_ERR ; goto done ; } DBG ( \"Requestingauthenticationforuser%s\" , user ) ; gpn_ret = getpwnam_r ( user , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpn_ret != 0 || pw == NULL || pw -> pw_dir == NULL || pw -> pw_dir [ 0 ] != '/' ) { DBG ( \"Unabletoretrievecredentialsforuser%s,(%s)\" , user , strerror ( errno ) ) ; retval = PAM_USER_UNKNOWN ; goto done ; } DBG ( \"Founduser%s\" , user ) ; DBG ( \"Homedirectoryfor%sis%s\" , user , pw -> pw_dir ) ; if ( ! cfg -> auth_file ) { buf = NULL ; authfile_dir = secure_getenv ( DEFAULT_AUTHFILE_DIR_VAR ) ; if ( ! authfile_dir ) { DBG ( \"Variable%sisnotset.Usingdefaultvalue($HOME/.config/)\" , DEFAULT_AUTHFILE_DIR_VAR ) ; authfile_dir_len = strlen ( pw -> pw_dir ) + strlen ( \"/.config\" ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s/.config%s\" , pw -> pw_dir , DEFAULT_AUTHFILE ) ; } else { DBG ( \"Variable%ssetto%s\" , DEFAULT_AUTHFILE_DIR_VAR , authfile_dir ) ; authfile_dir_len = strlen ( authfile_dir ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s%s\" , authfile_dir , DEFAULT_AUTHFILE ) ; } DBG ( \"Usingdefaultauthenticationfile%s\" , buf ) ; cfg -> auth_file = buf ; should_free_auth_file = 1 ; buf = NULL ; } else { DBG ( \"Usingauthenticationfile%s\" , cfg -> auth_file ) ; } openasuser = geteuid ( ) == 0 && cfg -> openasuser ; if ( openasuser ) { if ( seteuid ( pw_s . pw_uid ) ) { DBG ( \"Unabletoswitchusertouid%i\" , pw_s . pw_uid ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedtouid%i\" , pw_s . pw_uid ) ; } retval = get_devices_from_authfile ( cfg -> auth_file , user , cfg -> max_devs , cfg -> debug , cfg -> debug_file , devices , & n_devices ) ; if ( openasuser ) { if ( seteuid ( 0 ) ) { DBG ( \"Unabletoswitchbacktouid0\" ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedbacktouid0\" ) ; } if ( retval != 1 ) { n_devices = 0 ; } if ( n_devices == 0 ) { if ( cfg -> nouserok ) { DBG ( \"Foundnodevicesbutnouserokspecified.Skippingauthentication\" ) ; retval = PAM_SUCCESS ; goto done ; } else if ( retval != 1 ) { DBG ( \"Unabletogetdevicesfromfile%s\" , cfg -> auth_file ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } else { DBG ( \"Foundnodevices.Aborting.\" ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } } if ( ! cfg -> authpending_file ) { int actual_size = snprintf ( buffer , BUFSIZE , DEFAULT_AUTHPENDING_FILE_PATH , getuid ( ) ) ; if ( actual_size >= 0 && actual_size < BUFSIZE ) { cfg -> authpending_file = strdup ( buffer ) ; } if ( ! cfg -> authpending_file ) { DBG ( \"Unabletoallocatememoryfortheauthpending_file,touchrequestnotificationswillnotbeemitted\" ) ; } else { should_free_authpending_file = 1 ; } } else { if ( strlen ( cfg -> authpending_file ) == 0 ) { DBG ( \"authpending_fileissettoanemptyvalue,touchrequestnotificationswillbedisabled\" ) ; cfg -> authpending_file = NULL ; } } int authpending_file_descriptor = - 1 ; if ( cfg -> authpending_file ) { DBG ( \"Usingfile\\'%s\\'foremittingtouchrequestnotifications\" , cfg -> authpending_file ) ; authpending_file_descriptor = open ( cfg -> authpending_file , O_RDONLY | O_CREAT , 0664 ) ; if ( authpending_file_descriptor < 0 ) { DBG ( \"Unabletoemit\\'authenticationstarted\\'notificationbyopeningthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( cfg -> manual == 0 ) { if ( cfg -> interactive ) { converse ( pamh , PAM_PROMPT_ECHO_ON , cfg -> prompt != NULL ? cfg -> prompt : DEFAULT_PROMPT ) ; } retval = do_authentication ( cfg , devices , n_devices , pamh ) ; } else { retval = do_manual_authentication ( cfg , devices , n_devices , pamh ) ; } if ( authpending_file_descriptor >= 0 ) { if ( close ( authpending_file_descriptor ) < 0 ) { DBG ( \"Unabletoemit\\'authenticationstopped\\'notificationbyclosingthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( retval != 1 ) { DBG ( \"do_authenticationreturned%d\" , retval ) ; retval = PAM_AUTH_ERR ; goto done ; } retval = PAM_SUCCESS ; done : free_devices ( devices , n_devices ) ; if ( buf ) { free ( buf ) ; buf = NULL ; } if ( should_free_origin ) { free ( ( char * ) cfg -> origin ) ; cfg -> origin = NULL ; } if ( should_free_appid ) { free ( ( char * ) cfg -> appid ) ; cfg -> appid = NULL ; } if ( should_free_auth_file ) { free ( ( char * ) cfg -> auth_file ) ; cfg -> auth_file = NULL ; } if ( should_free_authpending_file ) { free ( ( char * ) cfg -> authpending_file ) ; cfg -> authpending_file = NULL ; } if ( cfg -> alwaysok && retval != PAM_SUCCESS ) { DBG ( \"alwaysokneeded(otherwisereturnwith%d)\" , retval ) ; retval = PAM_SUCCESS ; } DBG ( \"done.[%s]\" , pam_strerror ( pamh , retval ) ) ; return retval ; }\n", "\n", "1: CWE-200 int pam_sm_authenticate ( pam_handle_t * pamh , int flags , int argc , const char * * argv ) { struct passwd * pw = NULL , pw_s ; const char * user = NULL ; cfg_t cfg_st ; cfg_t * cfg = & cfg_st ; char buffer [ BUFSIZE ] ; char * buf = NULL ; char * authfile_dir ; size_t authfile_dir_len ; int pgu_ret , gpn_ret ; int retval = PAM_IGNORE ; device_t * devices = NULL ; unsigned n_devices = 0 ; int openasuser ; int should_free_origin = 0 ; int should_free_appid = 0 ; int should_free_auth_file = 0 ; int should_free_authpending_file = 0 ; parse_cfg ( flags , argc , argv , cfg ) ; if ( ! cfg -> origin ) { strcpy ( buffer , DEFAULT_ORIGIN_PREFIX ) ; if ( gethostname ( buffer + strlen ( DEFAULT_ORIGIN_PREFIX ) , BUFSIZE - strlen ( DEFAULT_ORIGIN_PREFIX ) ) == - 1 ) { DBG ( \"Unabletogethostname\" ) ; goto done ; } DBG ( \"Originnotspecified,using\\\\\"%s\\\\\"\" , buffer ) ; cfg -> origin = strdup ( buffer ) ; if ( ! cfg -> origin ) { DBG ( \"Unabletoallocatememory\" ) ; goto done ; } else { should_free_origin = 1 ; } } if ( ! cfg -> appid ) { DBG ( \"Appidnotspecified,usingthesamevalueoforigin(%s)\" , cfg -> origin ) ; cfg -> appid = strdup ( cfg -> origin ) ; if ( ! cfg -> appid ) { DBG ( \"Unabletoallocatememory\" ) goto done ; } else { should_free_appid = 1 ; } } if ( cfg -> max_devs == 0 ) { DBG ( \"Maximumdevicesnumbernotset.Usingdefault(%d)\" , MAX_DEVS ) ; cfg -> max_devs = MAX_DEVS ; } devices = malloc ( sizeof ( device_t ) * cfg -> max_devs ) ; if ( ! devices ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } pgu_ret = pam_get_user ( pamh , & user , NULL ) ; if ( pgu_ret != PAM_SUCCESS || user == NULL ) { DBG ( \"Unabletoaccessuser%s\" , user ) ; retval = PAM_CONV_ERR ; goto done ; } DBG ( \"Requestingauthenticationforuser%s\" , user ) ; gpn_ret = getpwnam_r ( user , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpn_ret != 0 || pw == NULL || pw -> pw_dir == NULL || pw -> pw_dir [ 0 ] != '/' ) { DBG ( \"Unabletoretrievecredentialsforuser%s,(%s)\" , user , strerror ( errno ) ) ; retval = PAM_USER_UNKNOWN ; goto done ; } DBG ( \"Founduser%s\" , user ) ; DBG ( \"Homedirectoryfor%sis%s\" , user , pw -> pw_dir ) ; if ( ! cfg -> auth_file ) { buf = NULL ; authfile_dir = secure_getenv ( DEFAULT_AUTHFILE_DIR_VAR ) ; if ( ! authfile_dir ) { DBG ( \"Variable%sisnotset.Usingdefaultvalue($HOME/.config/)\" , DEFAULT_AUTHFILE_DIR_VAR ) ; authfile_dir_len = strlen ( pw -> pw_dir ) + strlen ( \"/.config\" ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s/.config%s\" , pw -> pw_dir , DEFAULT_AUTHFILE ) ; } else { DBG ( \"Variable%ssetto%s\" , DEFAULT_AUTHFILE_DIR_VAR , authfile_dir ) ; authfile_dir_len = strlen ( authfile_dir ) + strlen ( DEFAULT_AUTHFILE ) + 1 ; buf = malloc ( sizeof ( char ) * ( authfile_dir_len ) ) ; if ( ! buf ) { DBG ( \"Unabletoallocatememory\" ) ; retval = PAM_IGNORE ; goto done ; } snprintf ( buf , authfile_dir_len , \"%s%s\" , authfile_dir , DEFAULT_AUTHFILE ) ; } DBG ( \"Usingdefaultauthenticationfile%s\" , buf ) ; cfg -> auth_file = buf ; should_free_auth_file = 1 ; buf = NULL ; } else { DBG ( \"Usingauthenticationfile%s\" , cfg -> auth_file ) ; } openasuser = geteuid ( ) == 0 && cfg -> openasuser ; if ( openasuser ) { if ( seteuid ( pw_s . pw_uid ) ) { DBG ( \"Unabletoswitchusertouid%i\" , pw_s . pw_uid ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedtouid%i\" , pw_s . pw_uid ) ; } retval = get_devices_from_authfile ( cfg -> auth_file , user , cfg -> max_devs , cfg -> debug , cfg -> debug_file , devices , & n_devices ) ; if ( openasuser ) { if ( seteuid ( 0 ) ) { DBG ( \"Unabletoswitchbacktouid0\" ) ; retval = PAM_IGNORE ; goto done ; } DBG ( \"Switchedbacktouid0\" ) ; } if ( retval != 1 ) { n_devices = 0 ; } if ( n_devices == 0 ) { if ( cfg -> nouserok ) { DBG ( \"Foundnodevicesbutnouserokspecified.Skippingauthentication\" ) ; retval = PAM_SUCCESS ; goto done ; } else if ( retval != 1 ) { DBG ( \"Unabletogetdevicesfromfile%s\" , cfg -> auth_file ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } else { DBG ( \"Foundnodevices.Aborting.\" ) ; retval = PAM_AUTHINFO_UNAVAIL ; goto done ; } } if ( ! cfg -> authpending_file ) { int actual_size = snprintf ( buffer , BUFSIZE , DEFAULT_AUTHPENDING_FILE_PATH , getuid ( ) ) ; if ( actual_size >= 0 && actual_size < BUFSIZE ) { cfg -> authpending_file = strdup ( buffer ) ; } if ( ! cfg -> authpending_file ) { DBG ( \"Unabletoallocatememoryfortheauthpending_file,touchrequestnotificationswillnotbeemitted\" ) ; } else { should_free_authpending_file = 1 ; } } else { if ( strlen ( cfg -> authpending_file ) == 0 ) { DBG ( \"authpending_fileissettoanemptyvalue,touchrequestnotificationswillbedisabled\" ) ; cfg -> authpending_file = NULL ; } } int authpending_file_descriptor = - 1 ; if ( cfg -> authpending_file ) { DBG ( \"Usingfile\\'%s\\'foremittingtouchrequestnotifications\" , cfg -> authpending_file ) ; authpending_file_descriptor = open ( cfg -> authpending_file , O_RDONLY | O_CREAT , 0664 ) ; if ( authpending_file_descriptor < 0 ) { DBG ( \"Unabletoemit\\'authenticationstarted\\'notificationbyopeningthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( cfg -> manual == 0 ) { if ( cfg -> interactive ) { converse ( pamh , PAM_PROMPT_ECHO_ON , cfg -> prompt != NULL ? cfg -> prompt : DEFAULT_PROMPT ) ; } retval = do_authentication ( cfg , devices , n_devices , pamh ) ; } else { retval = do_manual_authentication ( cfg , devices , n_devices , pamh ) ; } if ( authpending_file_descriptor >= 0 ) { if ( close ( authpending_file_descriptor ) < 0 ) { DBG ( \"Unabletoemit\\'authenticationstopped\\'notificationbyclosingthefile\\'%s\\',(%s)\" , cfg -> authpending_file , strerror ( errno ) ) ; } } if ( retval != 1 ) { DBG ( \"do_authenticationreturned%d\" , retval ) ; retval = PAM_AUTH_ERR ; goto done ; } retval = PAM_SUCCESS ; done : free_devices ( devices , n_devices ) ; if ( buf ) { free ( buf ) ; buf = NULL ; } if ( should_free_origin ) { free ( ( char * ) cfg -> origin ) ; cfg -> origin = NULL ; } if ( should_free_appid ) { free ( ( char * ) cfg -> appid ) ; cfg -> appid = NULL ; } if ( should_free_auth_file ) { free ( ( char * ) cfg -> auth_file ) ; cfg -> auth_file = NULL ; } if ( should_free_authpending_file ) { free ( ( char * ) cfg -> authpending_file ) ; cfg -> authpending_file = NULL ; } if ( cfg -> alwaysok && retval != PAM_SUCCESS ) { DBG ( \"alwaysokneeded(otherwisereturnwith%d)\" , retval ) ; retval = PAM_SUCCESS ; } DBG ( \"done.[%s]\" , pam_strerror ( pamh , retval ) ) ; return retval ; }\n", "\n", "\n", "Target: , 1 , regs , address\n", "\n", "Sources:\n", "0: CWE-399 static int misaligned_store ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift ) { int error ; int srcreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; srcreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; if ( ! access_ok ( VERIFY_WRITE , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } switch ( width_shift ) { case 1 : * ( __u16 * ) & buffer = ( __u16 ) regs -> regs [ srcreg ] ; break ; case 2 : * ( __u32 * ) & buffer = ( __u32 ) regs -> regs [ srcreg ] ; break ; case 3 : buffer = regs -> regs [ srcreg ] ; break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_store,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } if ( __copy_user ( ( void * ) ( int ) address , & buffer , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } } else { __u64 val = regs -> regs [ srcreg ] ; switch ( width_shift ) { case 1 : misaligned_kernel_word_store ( address , val ) ; break ; case 2 : asm ( \"stlo.l%1,0,%0\" : : \"r\" ( val ) , \"r\" ( address ) ) ; asm ( \"sthi.l%1,3,%0\" : : \"r\" ( val ) , \"r\" ( address ) ) ; break ; case 3 : asm ( \"stlo.q%1,0,%0\" : : \"r\" ( val ) , \"r\" ( address ) ) ; asm ( \"sthi.q%1,7,%0\" : : \"r\" ( val ) , \"r\" ( address ) ) ; break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_store,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } return 0 ; }\n", "\n", "1: CWE-400 static int misaligned_fpu_load ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_paired_load ) { int error ; int destreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , address ) ; destreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; __u32 buflo , bufhi ; if ( ! access_ok ( VERIFY_READ , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( __copy_user ( & buffer , ( const void * ) ( int ) address , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } if ( last_task_used_math == current ) { enable_fpu ( ) ; save_fpu ( current ) ; disable_fpu ( ) ; last_task_used_math = NULL ; regs -> sr |= SR_FD ; } buflo = * ( __u32 * ) & buffer ; bufhi = * ( 1 + ( __u32 * ) & buffer ) ; switch ( width_shift ) { case 2 : current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; break ; case 3 : if ( do_paired_load ) { current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = bufhi ; } else { # if defined ( CONFIG_CPU_LITTLE_ENDIAN ) current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = bufhi ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = buflo ; # else current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = bufhi ; # endif } break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_fpu_load,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } return 0 ; } else { die ( \"MisalignedFPUloadinsidekernel\" , regs , 0 ) ; return - 1 ; } }\n", "\n", "2: CWE-400 static int misaligned_load ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_sign_extend ) { int error ; int destreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; destreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; if ( ! access_ok ( VERIFY_READ , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( __copy_user ( & buffer , ( const void * ) ( int ) address , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } switch ( width_shift ) { case 1 : if ( do_sign_extend ) { regs -> regs [ destreg ] = ( __u64 ) ( __s64 ) * ( __s16 * ) & buffer ; } else { regs -> regs [ destreg ] = ( __u64 ) * ( __u16 * ) & buffer ; } break ; case 2 : regs -> regs [ destreg ] = ( __u64 ) ( __s64 ) * ( __s32 * ) & buffer ; break ; case 3 : regs -> regs [ destreg ] = buffer ; break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_load,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } else { __u64 lo , hi ; switch ( width_shift ) { case 1 : misaligned_kernel_word_load ( address , do_sign_extend , & regs -> regs [ destreg ] ) ; break ; case 2 : asm ( \"ldlo.l%1,0,%0\" : \"=r\" ( lo ) : \"r\" ( address ) ) ; asm ( \"ldhi.l%1,3,%0\" : \"=r\" ( hi ) : \"r\" ( address ) ) ; regs -> regs [ destreg ] = lo | hi ; break ; case 3 : asm ( \"ldlo.q%1,0,%0\" : \"=r\" ( lo ) : \"r\" ( address ) ) ; asm ( \"ldhi.q%1,7,%0\" : \"=r\" ( hi ) : \"r\" ( address ) ) ; regs -> regs [ destreg ] = lo | hi ; break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_load,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } return 0 ; }\n", "\n", "3: CWE-400 static int misaligned_fpu_store ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_paired_load ) { int error ; int srcreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , address ) ; srcreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; __u32 buflo = 0xffffffffUL , bufhi = 0xffffffffUL ; if ( ! access_ok ( VERIFY_WRITE , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( last_task_used_math == current ) { enable_fpu ( ) ; save_fpu ( current ) ; disable_fpu ( ) ; last_task_used_math = NULL ; regs -> sr |= SR_FD ; } switch ( width_shift ) { case 2 : buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; break ; case 3 : if ( do_paired_load ) { buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; } else { # if defined ( CONFIG_CPU_LITTLE_ENDIAN ) bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; # else buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; # endif } break ; default : printk ( \"Unexpectedwidth_shift%dinmisaligned_fpu_store,PC=%08lx\\\\n\" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } * ( __u32 * ) & buffer = buflo ; * ( 1 + ( __u32 * ) & buffer ) = bufhi ; if ( __copy_user ( ( void * ) ( int ) address , & buffer , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } return 0 ; } else { die ( \"MisalignedFPUloadinsidekernel\" , regs , 0 ) ; return - 1 ; } }\n", "\n", "\n", "Target: mmap_sem ) ; VM_WARN_ON ( ! mmget_still_valid ( mm ) ) ;\n", "\n", "Sources:\n", "0: CWE-362 static void userfaultfd_event_wait_completion ( struct userfaultfd_ctx * ctx , struct userfaultfd_wait_queue * ewq ) { struct userfaultfd_ctx * release_new_ctx ; if ( WARN_ON_ONCE ( current -> flags & PF_EXITING ) ) goto out ; ewq -> ctx = ctx ; init_waitqueue_entry ( & ewq -> wq , current ) ; release_new_ctx = NULL ; spin_lock ( & ctx -> event_wqh . lock ) ; __add_wait_queue ( & ctx -> event_wqh , & ewq -> wq ) ; for ( ; ; ) { set_current_state ( TASK_KILLABLE ) ; if ( ewq -> msg . event == 0 ) break ; if ( READ_ONCE ( ctx -> released ) || fatal_signal_pending ( current ) ) { __remove_wait_queue ( & ctx -> event_wqh , & ewq -> wq ) ; if ( ewq -> msg . event == UFFD_EVENT_FORK ) { struct userfaultfd_ctx * new ; new = ( struct userfaultfd_ctx * ) ( unsigned long ) ewq -> msg . arg . reserved . reserved1 ; release_new_ctx = new ; } break ; } spin_unlock ( & ctx -> event_wqh . lock ) ; wake_up_poll ( & ctx -> fd_wqh , EPOLLIN ) ; schedule ( ) ; spin_lock ( & ctx -> event_wqh . lock ) ; } __set_current_state ( TASK_RUNNING ) ; spin_unlock ( & ctx -> event_wqh . lock ) ; if ( release_new_ctx ) { struct vm_area_struct * vma ; struct mm_struct * mm = release_new_ctx -> mm ; down_write ( & mm -> mmap_sem ) ; for ( vma = mm -> mmap ; vma ; vma = vma -> vm_next ) if ( vma -> vm_userfaultfd_ctx . ctx == release_new_ctx ) { vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; vma -> vm_flags &= ~ ( VM_UFFD_WP | VM_UFFD_MISSING ) ; } up_write ( & mm -> mmap_sem ) ; userfaultfd_ctx_put ( release_new_ctx ) ; } out : WRITE_ONCE ( ctx -> mmap_changing , false ) ; userfaultfd_ctx_put ( ctx ) ; }\n", "\n", "1: CWE-667 static void userfaultfd_event_wait_completion ( struct userfaultfd_ctx * ctx , struct userfaultfd_wait_queue * ewq ) { struct userfaultfd_ctx * release_new_ctx ; if ( WARN_ON_ONCE ( current -> flags & PF_EXITING ) ) goto out ; ewq -> ctx = ctx ; init_waitqueue_entry ( & ewq -> wq , current ) ; release_new_ctx = NULL ; spin_lock ( & ctx -> event_wqh . lock ) ; __add_wait_queue ( & ctx -> event_wqh , & ewq -> wq ) ; for ( ; ; ) { set_current_state ( TASK_KILLABLE ) ; if ( ewq -> msg . event == 0 ) break ; if ( READ_ONCE ( ctx -> released ) || fatal_signal_pending ( current ) ) { __remove_wait_queue ( & ctx -> event_wqh , & ewq -> wq ) ; if ( ewq -> msg . event == UFFD_EVENT_FORK ) { struct userfaultfd_ctx * new ; new = ( struct userfaultfd_ctx * ) ( unsigned long ) ewq -> msg . arg . reserved . reserved1 ; release_new_ctx = new ; } break ; } spin_unlock ( & ctx -> event_wqh . lock ) ; wake_up_poll ( & ctx -> fd_wqh , EPOLLIN ) ; schedule ( ) ; spin_lock ( & ctx -> event_wqh . lock ) ; } __set_current_state ( TASK_RUNNING ) ; spin_unlock ( & ctx -> event_wqh . lock ) ; if ( release_new_ctx ) { struct vm_area_struct * vma ; struct mm_struct * mm = release_new_ctx -> mm ; down_write ( & mm -> mmap_sem ) ; for ( vma = mm -> mmap ; vma ; vma = vma -> vm_next ) if ( vma -> vm_userfaultfd_ctx . ctx == release_new_ctx ) { vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; vma -> vm_flags &= ~ ( VM_UFFD_WP | VM_UFFD_MISSING ) ; } up_write ( & mm -> mmap_sem ) ; userfaultfd_ctx_put ( release_new_ctx ) ; } out : WRITE_ONCE ( ctx -> mmap_changing , false ) ; userfaultfd_ctx_put ( ctx ) ; }\n", "\n", "\n", "Target: long flags ; spin_lock_irqsave ( & flags ) ; ucounts -> count -= 1 ; if ( ! ucounts -> count ) -> node ) ; else ucounts = NULL ) ; } \n", "\n", "Sources:\n", "0: CWE-416 static void put_ucounts ( struct ucounts * ucounts ) { unsigned long flags ; if ( atomic_dec_and_test ( & ucounts -> count ) ) { spin_lock_irqsave ( & ucounts_lock , flags ) ; hlist_del_init ( & ucounts -> node ) ; spin_unlock_irqrestore ( & ucounts_lock , flags ) ; kfree ( ucounts ) ; } } \n", "\n", "1: CWE-362 static void put_ucounts ( struct ucounts * ucounts ) { unsigned long flags ; if ( atomic_dec_and_test ( & ucounts -> count ) ) { spin_lock_irqsave ( & ucounts_lock , flags ) ; hlist_del_init ( & ucounts -> node ) ; spin_unlock_irqrestore ( & ucounts_lock , flags ) ; kfree ( ucounts ) ; } } \n", "\n", "\n", "Target: in_what , in_what_stride ) + mvsad_err_cost check_here , in_what_stride ) ; if\n", "\n", "Sources:\n", "0: CWE-119 int vp8_diamond_search_sad_c ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int_mv * best_mv , int search_param , int sad_per_bit , int * num00 , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { int i , j , step ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; int what_stride = b -> src_stride ; unsigned char * in_what ; int pre_stride = x -> e_mbd . pre . y_stride ; unsigned char * base_pre = x -> e_mbd . pre . y_buffer ; int in_what_stride = pre_stride ; unsigned char * best_address ; int tot_steps ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int best_site = 0 ; int last_site = 0 ; int ref_row ; int ref_col ; int this_row_offset ; int this_col_offset ; search_site * ss ; unsigned char * check_here ; int * mvsadcost [ 2 ] ; int_mv fcenter_mv ; mvsadcost [ 0 ] = x -> mvsadcost [ 0 ] ; mvsadcost [ 1 ] = x -> mvsadcost [ 1 ] ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; vp8_clamp_mv ( ref_mv , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ; ref_row = ref_mv -> as_mv . row ; ref_col = ref_mv -> as_mv . col ; * num00 = 0 ; best_mv -> as_mv . row = ref_row ; best_mv -> as_mv . col = ref_col ; in_what = ( unsigned char * ) ( base_pre + d -> offset + ( ref_row * pre_stride ) + ref_col ) ; best_address = in_what ; bestsad = fn_ptr -> sdf ( what , what_stride , in_what , in_what_stride , UINT_MAX ) + mvsad_err_cost ( best_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; ss = & x -> ss [ search_param * x -> searches_per_step ] ; tot_steps = ( x -> ss_count / x -> searches_per_step ) - search_param ; i = 1 ; for ( step = 0 ; step < tot_steps ; step ++ ) { for ( j = 0 ; j < x -> searches_per_step ; j ++ ) { this_row_offset = best_mv -> as_mv . row + ss [ i ] . mv . row ; this_col_offset = best_mv -> as_mv . col + ss [ i ] . mv . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ss [ i ] . offset + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = i ; } } } i ++ ; } if ( best_site != last_site ) { best_mv -> as_mv . row += ss [ best_site ] . mv . row ; best_mv -> as_mv . col += ss [ best_site ] . mv . col ; best_address += ss [ best_site ] . offset ; last_site = best_site ; } else if ( best_address == in_what ) ( * num00 ) ++ ; } this_mv . as_mv . row = best_mv -> as_mv . row << 3 ; this_mv . as_mv . col = best_mv -> as_mv . col << 3 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; }\n", "\n", "1: CWE-119 int vp8_diamond_search_sadx4 ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int_mv * best_mv , int search_param , int sad_per_bit , int * num00 , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { int i , j , step ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; int what_stride = b -> src_stride ; unsigned char * in_what ; int pre_stride = x -> e_mbd . pre . y_stride ; unsigned char * base_pre = x -> e_mbd . pre . y_buffer ; int in_what_stride = pre_stride ; unsigned char * best_address ; int tot_steps ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int best_site = 0 ; int last_site = 0 ; int ref_row ; int ref_col ; int this_row_offset ; int this_col_offset ; search_site * ss ; unsigned char * check_here ; int * mvsadcost [ 2 ] ; int_mv fcenter_mv ; mvsadcost [ 0 ] = x -> mvsadcost [ 0 ] ; mvsadcost [ 1 ] = x -> mvsadcost [ 1 ] ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; vp8_clamp_mv ( ref_mv , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ; ref_row = ref_mv -> as_mv . row ; ref_col = ref_mv -> as_mv . col ; * num00 = 0 ; best_mv -> as_mv . row = ref_row ; best_mv -> as_mv . col = ref_col ; in_what = ( unsigned char * ) ( base_pre + d -> offset + ( ref_row * pre_stride ) + ref_col ) ; best_address = in_what ; bestsad = fn_ptr -> sdf ( what , what_stride , in_what , in_what_stride , UINT_MAX ) + mvsad_err_cost ( best_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; ss = & x -> ss [ search_param * x -> searches_per_step ] ; tot_steps = ( x -> ss_count / x -> searches_per_step ) - search_param ; i = 1 ; for ( step = 0 ; step < tot_steps ; step ++ ) { int all_in = 1 , t ; all_in &= ( ( best_mv -> as_mv . row + ss [ i ] . mv . row ) > x -> mv_row_min ) ; all_in &= ( ( best_mv -> as_mv . row + ss [ i + 1 ] . mv . row ) < x -> mv_row_max ) ; all_in &= ( ( best_mv -> as_mv . col + ss [ i + 2 ] . mv . col ) > x -> mv_col_min ) ; all_in &= ( ( best_mv -> as_mv . col + ss [ i + 3 ] . mv . col ) < x -> mv_col_max ) ; if ( all_in ) { unsigned int sad_array [ 4 ] ; for ( j = 0 ; j < x -> searches_per_step ; j += 4 ) { const unsigned char * block_offset [ 4 ] ; for ( t = 0 ; t < 4 ; t ++ ) block_offset [ t ] = ss [ i + t ] . offset + best_address ; fn_ptr -> sdx4df ( what , what_stride , block_offset , in_what_stride , sad_array ) ; for ( t = 0 ; t < 4 ; t ++ , i ++ ) { if ( sad_array [ t ] < bestsad ) { this_mv . as_mv . row = best_mv -> as_mv . row + ss [ i ] . mv . row ; this_mv . as_mv . col = best_mv -> as_mv . col + ss [ i ] . mv . col ; sad_array [ t ] += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( sad_array [ t ] < bestsad ) { bestsad = sad_array [ t ] ; best_site = i ; } } } } } else { for ( j = 0 ; j < x -> searches_per_step ; j ++ ) { this_row_offset = best_mv -> as_mv . row + ss [ i ] . mv . row ; this_col_offset = best_mv -> as_mv . col + ss [ i ] . mv . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ss [ i ] . offset + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = i ; } } } i ++ ; } } if ( best_site != last_site ) { best_mv -> as_mv . row += ss [ best_site ] . mv . row ; best_mv -> as_mv . col += ss [ best_site ] . mv . col ; best_address += ss [ best_site ] . offset ; last_site = best_site ; } else if ( best_address == in_what ) ( * num00 ) ++ ; } this_mv . as_mv . row = best_mv -> as_mv . row * 8 ; this_mv . as_mv . col = best_mv -> as_mv . col * 8 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; }\n", "\n", "\n", "Target: [ plane ] && in -> linesize [ plane ]\n", "\n", "Sources:\n", "0: CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { AVFilterContext * ctx = inlink -> dst ; LutContext * s = ctx -> priv ; AVFilterLink * outlink = ctx -> outputs [ 0 ] ; AVFrame * out ; uint8_t * inrow , * outrow , * inrow0 , * outrow0 ; int i , j , plane , direct = 0 ; if ( av_frame_is_writable ( in ) ) { direct = 1 ; out = in ; } else { out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; } if ( s -> is_rgb ) { inrow0 = in -> data [ 0 ] ; outrow0 = out -> data [ 0 ] ; for ( i = 0 ; i < in -> height ; i ++ ) { int w = inlink -> w ; const uint8_t ( * tab ) [ 256 ] = ( const uint8_t ( * ) [ 256 ] ) s -> lut ; inrow = inrow0 ; outrow = outrow0 ; for ( j = 0 ; j < w ; j ++ ) { switch ( s -> step ) { case 4 : outrow [ 3 ] = tab [ 3 ] [ inrow [ 3 ] ] ; case 3 : outrow [ 2 ] = tab [ 2 ] [ inrow [ 2 ] ] ; case 2 : outrow [ 1 ] = tab [ 1 ] [ inrow [ 1 ] ] ; default : outrow [ 0 ] = tab [ 0 ] [ inrow [ 0 ] ] ; } outrow += s -> step ; inrow += s -> step ; } inrow0 += in -> linesize [ 0 ] ; outrow0 += out -> linesize [ 0 ] ; } } else { for ( plane = 0 ; plane < 4 && in -> data [ plane ] ; plane ++ ) { int vsub = plane == 1 || plane == 2 ? s -> vsub : 0 ; int hsub = plane == 1 || plane == 2 ? s -> hsub : 0 ; int h = FF_CEIL_RSHIFT ( inlink -> h , vsub ) ; int w = FF_CEIL_RSHIFT ( inlink -> w , hsub ) ; inrow = in -> data [ plane ] ; outrow = out -> data [ plane ] ; for ( i = 0 ; i < h ; i ++ ) { const uint8_t * tab = s -> lut [ plane ] ; for ( j = 0 ; j < w ; j ++ ) outrow [ j ] = tab [ inrow [ j ] ] ; inrow += in -> linesize [ plane ] ; outrow += out -> linesize [ plane ] ; } } } if ( ! direct ) av_frame_free ( & in ) ; return ff_filter_frame ( outlink , out ) ; }\n", "\n", "1: CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { AVFilterContext * ctx = inlink -> dst ; FlipContext * s = ctx -> priv ; AVFilterLink * outlink = ctx -> outputs [ 0 ] ; AVFrame * out ; uint8_t * inrow , * outrow ; int i , j , plane , step ; out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; if ( av_pix_fmt_desc_get ( inlink -> format ) -> flags & AV_PIX_FMT_FLAG_PAL ) memcpy ( out -> data [ 1 ] , in -> data [ 1 ] , AVPALETTE_SIZE ) ; for ( plane = 0 ; plane < 4 && in -> data [ plane ] ; plane ++ ) { const int width = ( plane == 1 || plane == 2 ) ? FF_CEIL_RSHIFT ( inlink -> w , s -> hsub ) : inlink -> w ; const int height = ( plane == 1 || plane == 2 ) ? FF_CEIL_RSHIFT ( inlink -> h , s -> vsub ) : inlink -> h ; step = s -> max_step [ plane ] ; outrow = out -> data [ plane ] ; inrow = in -> data [ plane ] + ( width - 1 ) * step ; for ( i = 0 ; i < height ; i ++ ) { switch ( step ) { case 1 : for ( j = 0 ; j < width ; j ++ ) outrow [ j ] = inrow [ - j ] ; break ; case 2 : { uint16_t * outrow16 = ( uint16_t * ) outrow ; uint16_t * inrow16 = ( uint16_t * ) inrow ; for ( j = 0 ; j < width ; j ++ ) outrow16 [ j ] = inrow16 [ - j ] ; } break ; case 3 : { uint8_t * in = inrow ; uint8_t * out = outrow ; for ( j = 0 ; j < width ; j ++ , out += 3 , in -= 3 ) { int32_t v = AV_RB24 ( in ) ; AV_WB24 ( out , v ) ; } } break ; case 4 : { uint32_t * outrow32 = ( uint32_t * ) outrow ; uint32_t * inrow32 = ( uint32_t * ) inrow ; for ( j = 0 ; j < width ; j ++ ) outrow32 [ j ] = inrow32 [ - j ] ; } break ; default : for ( j = 0 ; j < width ; j ++ ) memcpy ( outrow + j * step , inrow - j * step , step ) ; } inrow += in -> linesize [ plane ] ; outrow += out -> linesize [ plane ] ; } } av_frame_free ( & in ) ; return ff_filter_frame ( outlink , out ) ; }\n", "\n", "\n", "Target: final_p , final ; struct ipv6_txoptions * opt ) ) ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; & fl6 , opt , & ; if ( opt ) icsk -> -> icsk_ext_hdr_len = opt -> opt_flen -> opt_flen + opt -> opt_nflen opt -> opt_nflen ; inet ->\n", "\n", "Sources:\n", "0: CWE-264 static int dccp_v6_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_connection_sock * icsk = inet_csk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct dccp_sock * dp = dccp_sk ( sk ) ; struct in6_addr * saddr = NULL , * final_p , final ; struct flowi6 fl6 ; struct dst_entry * dst ; int addr_type ; int err ; dp -> dccps_role = DCCP_ROLE_CLIENT ; if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; IP6_ECN_flow_init ( fl6 . flowlabel ) ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { struct ip6_flowlabel * flowlabel ; flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( flowlabel == NULL ) return - EINVAL ; fl6_sock_release ( flowlabel ) ; } } if ( ipv6_addr_any ( & usin -> sin6_addr ) ) usin -> sin6_addr . s6_addr [ 15 ] = 1 ; addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type & IPV6_ADDR_MULTICAST ) return - ENETUNREACH ; if ( addr_type & IPV6_ADDR_LINKLOCAL ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) return - EINVAL ; sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if ) return - EINVAL ; } sk -> sk_v6_daddr = usin -> sin6_addr ; np -> flow_label = fl6 . flowlabel ; if ( addr_type == IPV6_ADDR_MAPPED ) { u32 exthdrlen = icsk -> icsk_ext_hdr_len ; struct sockaddr_in sin ; SOCK_DEBUG ( sk , \"connect:ipv4mapped\\\\n\" ) ; if ( __ipv6_only_sock ( sk ) ) return - ENETUNREACH ; sin . sin_family = AF_INET ; sin . sin_port = usin -> sin6_port ; sin . sin_addr . s_addr = usin -> sin6_addr . s6_addr32 [ 3 ] ; icsk -> icsk_af_ops = & dccp_ipv6_mapped ; sk -> sk_backlog_rcv = dccp_v4_do_rcv ; err = dccp_v4_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; if ( err ) { icsk -> icsk_ext_hdr_len = exthdrlen ; icsk -> icsk_af_ops = & dccp_ipv6_af_ops ; sk -> sk_backlog_rcv = dccp_v6_do_rcv ; goto failure ; } np -> saddr = sk -> sk_v6_rcv_saddr ; return err ; } if ( ! ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) saddr = & sk -> sk_v6_rcv_saddr ; fl6 . flowi6_proto = IPPROTO_DCCP ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = saddr ? * saddr : np -> saddr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . fl6_dport = usin -> sin6_port ; fl6 . fl6_sport = inet -> inet_sport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto failure ; } if ( saddr == NULL ) { saddr = & fl6 . saddr ; sk -> sk_v6_rcv_saddr = * saddr ; } np -> saddr = * saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; __ip6_dst_store ( sk , dst , NULL , NULL ) ; icsk -> icsk_ext_hdr_len = 0 ; if ( np -> opt != NULL ) icsk -> icsk_ext_hdr_len = ( np -> opt -> opt_flen + np -> opt -> opt_nflen ) ; inet -> inet_dport = usin -> sin6_port ; dccp_set_state ( sk , DCCP_REQUESTING ) ; err = inet6_hash_connect ( & dccp_death_row , sk ) ; if ( err ) goto late_failure ; dp -> dccps_iss = secure_dccpv6_sequence_number ( np -> saddr . s6_addr32 , sk -> sk_v6_daddr . s6_addr32 , inet -> inet_sport , inet -> inet_dport ) ; err = dccp_connect ( sk ) ; if ( err ) goto late_failure ; return 0 ; late_failure : dccp_set_state ( sk , DCCP_CLOSED ) ; __sk_dst_reset ( sk ) ; failure : inet -> inet_dport = 0 ; sk -> sk_route_caps = 0 ; return err ; }\n", "\n", "1: CWE-416 static int dccp_v6_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_connection_sock * icsk = inet_csk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct dccp_sock * dp = dccp_sk ( sk ) ; struct in6_addr * saddr = NULL , * final_p , final ; struct flowi6 fl6 ; struct dst_entry * dst ; int addr_type ; int err ; dp -> dccps_role = DCCP_ROLE_CLIENT ; if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; IP6_ECN_flow_init ( fl6 . flowlabel ) ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { struct ip6_flowlabel * flowlabel ; flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( flowlabel == NULL ) return - EINVAL ; fl6_sock_release ( flowlabel ) ; } } if ( ipv6_addr_any ( & usin -> sin6_addr ) ) usin -> sin6_addr . s6_addr [ 15 ] = 1 ; addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type & IPV6_ADDR_MULTICAST ) return - ENETUNREACH ; if ( addr_type & IPV6_ADDR_LINKLOCAL ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) return - EINVAL ; sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if ) return - EINVAL ; } sk -> sk_v6_daddr = usin -> sin6_addr ; np -> flow_label = fl6 . flowlabel ; if ( addr_type == IPV6_ADDR_MAPPED ) { u32 exthdrlen = icsk -> icsk_ext_hdr_len ; struct sockaddr_in sin ; SOCK_DEBUG ( sk , \"connect:ipv4mapped\\\\n\" ) ; if ( __ipv6_only_sock ( sk ) ) return - ENETUNREACH ; sin . sin_family = AF_INET ; sin . sin_port = usin -> sin6_port ; sin . sin_addr . s_addr = usin -> sin6_addr . s6_addr32 [ 3 ] ; icsk -> icsk_af_ops = & dccp_ipv6_mapped ; sk -> sk_backlog_rcv = dccp_v4_do_rcv ; err = dccp_v4_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; if ( err ) { icsk -> icsk_ext_hdr_len = exthdrlen ; icsk -> icsk_af_ops = & dccp_ipv6_af_ops ; sk -> sk_backlog_rcv = dccp_v6_do_rcv ; goto failure ; } np -> saddr = sk -> sk_v6_rcv_saddr ; return err ; } if ( ! ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) saddr = & sk -> sk_v6_rcv_saddr ; fl6 . flowi6_proto = IPPROTO_DCCP ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = saddr ? * saddr : np -> saddr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . fl6_dport = usin -> sin6_port ; fl6 . fl6_sport = inet -> inet_sport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto failure ; } if ( saddr == NULL ) { saddr = & fl6 . saddr ; sk -> sk_v6_rcv_saddr = * saddr ; } np -> saddr = * saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; __ip6_dst_store ( sk , dst , NULL , NULL ) ; icsk -> icsk_ext_hdr_len = 0 ; if ( np -> opt != NULL ) icsk -> icsk_ext_hdr_len = ( np -> opt -> opt_flen + np -> opt -> opt_nflen ) ; inet -> inet_dport = usin -> sin6_port ; dccp_set_state ( sk , DCCP_REQUESTING ) ; err = inet6_hash_connect ( & dccp_death_row , sk ) ; if ( err ) goto late_failure ; dp -> dccps_iss = secure_dccpv6_sequence_number ( np -> saddr . s6_addr32 , sk -> sk_v6_daddr . s6_addr32 , inet -> inet_sport , inet -> inet_dport ) ; err = dccp_connect ( sk ) ; if ( err ) goto late_failure ; return 0 ; late_failure : dccp_set_state ( sk , DCCP_CLOSED ) ; __sk_dst_reset ( sk ) ; failure : inet -> inet_dport = 0 ; sk -> sk_route_caps = 0 ; return err ; }\n", "\n", "\n", "Target: tx_type , const tran_low_t * input ,\n", "\n", "Sources:\n", "0: CWE-119 void vp9_iht16x16_add ( TX_TYPE tx_type , const int16_t * input , uint8_t * dest , int stride , int eob ) { if ( tx_type == DCT_DCT ) { vp9_idct16x16_add ( input , dest , stride , eob ) ; } else { vp9_iht16x16_256_add ( input , dest , stride , tx_type ) ; } }\n", "\n", "1: CWE-119 void vp9_iht4x4_add ( TX_TYPE tx_type , const int16_t * input , uint8_t * dest , int stride , int eob ) { if ( tx_type == DCT_DCT ) vp9_idct4x4_add ( input , dest , stride , eob ) ; else vp9_iht4x4_16_add ( input , dest , stride , tx_type ) ; }\n", "\n", "\n", "Target: ; # if ENABLE_BGP_VNC_ATTR case BGP_ATTR_VNC :\n", "\n", "Sources:\n", "0: CWE-436 static void bgp_packet_mpattr_tea ( struct bgp * bgp , struct peer * peer , struct stream * s , struct attr * attr , uint8_t attrtype ) { unsigned int attrlenfield = 0 ; unsigned int attrhdrlen = 0 ; struct bgp_attr_encap_subtlv * subtlvs ; struct bgp_attr_encap_subtlv * st ; const char * attrname ; if ( ! attr || ( attrtype == BGP_ATTR_ENCAP && ( ! attr -> encap_tunneltype || attr -> encap_tunneltype == BGP_ENCAP_TYPE_MPLS ) ) ) return ; switch ( attrtype ) { case BGP_ATTR_ENCAP : attrname = \"TunnelEncap\" ; subtlvs = attr -> encap_subtlvs ; if ( subtlvs == NULL ) return ; attrlenfield = 2 + 2 ; attrhdrlen = 1 + 1 ; break ; # if ENABLE_BGP_VNC case BGP_ATTR_VNC : attrname = \"VNC\" ; subtlvs = attr -> vnc_subtlvs ; if ( subtlvs == NULL ) return ; attrlenfield = 0 ; attrhdrlen = 2 + 2 ; break ; # endif default : assert ( 0 ) ; } for ( st = subtlvs ; st ; st = st -> next ) { attrlenfield += ( attrhdrlen + st -> length ) ; } if ( attrlenfield > 0xffff ) { zlog_info ( \"%sattributeistoolong(length=%d),can\\'tsendit\" , attrname , attrlenfield ) ; return ; } if ( attrlenfield > 0xff ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , attrtype ) ; stream_putw ( s , attrlenfield & 0xffff ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , attrtype ) ; stream_putc ( s , attrlenfield & 0xff ) ; } if ( attrtype == BGP_ATTR_ENCAP ) { stream_putw ( s , attr -> encap_tunneltype ) ; stream_putw ( s , attrlenfield - 4 ) ; } for ( st = subtlvs ; st ; st = st -> next ) { if ( attrtype == BGP_ATTR_ENCAP ) { stream_putc ( s , st -> type ) ; stream_putc ( s , st -> length ) ; # if ENABLE_BGP_VNC } else { stream_putw ( s , st -> type ) ; stream_putw ( s , st -> length ) ; # endif } stream_put ( s , st -> value , st -> length ) ; } }\n", "\n", "1: CWE-000 bgp_attr_parse_ret_t bgp_attr_parse ( struct peer * peer , struct attr * attr , bgp_size_t size , struct bgp_nlri * mp_update , struct bgp_nlri * mp_withdraw ) { bgp_attr_parse_ret_t ret ; uint8_t flag = 0 ; uint8_t type = 0 ; bgp_size_t length ; uint8_t * startp , * endp ; uint8_t * attr_endp ; uint8_t seen [ BGP_ATTR_BITMAP_SIZE ] ; struct aspath * as4_path = NULL ; as_t as4_aggregator = 0 ; struct in_addr as4_aggregator_addr = { . s_addr = 0 } ; memset ( seen , 0 , BGP_ATTR_BITMAP_SIZE ) ; endp = BGP_INPUT_PNT ( peer ) + size ; while ( BGP_INPUT_PNT ( peer ) < endp ) { if ( endp - BGP_INPUT_PNT ( peer ) < BGP_ATTR_MIN_LEN ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_SMALL , \"%s:errorBGPattributelength%luissmallerthanminlen\" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } startp = BGP_INPUT_PNT ( peer ) ; flag = 0xF0 & stream_getc ( BGP_INPUT ( peer ) ) ; type = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) && ( ( endp - startp ) < ( BGP_ATTR_MIN_LEN + 1 ) ) ) { flog_warn ( EC_BGP_EXT_ATTRIBUTE_TOO_SMALL , \"%s:Extendedlengthset,butjust%lubytesofattrheader\" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ) length = stream_getw ( BGP_INPUT ( peer ) ) ; else length = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_BITMAP ( seen , type ) ) { flog_warn ( EC_BGP_ATTRIBUTE_REPEATED , \"%s:errorBGPattributetype%dappearstwiceinamessage\" , peer -> host , type ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; return BGP_ATTR_PARSE_ERROR ; } SET_BITMAP ( seen , type ) ; attr_endp = BGP_INPUT_PNT ( peer ) + length ; if ( attr_endp > endp ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_LARGE , \"%s:BGPtype%dlength%distoolarge,attributetotallengthis%d.attr_endpis%p.endpis%p\" , peer -> host , type , length , size , attr_endp , endp ) ; unsigned char ndata [ BGP_MAX_PACKET_SIZE ] ; memset ( ndata , 0x00 , sizeof ( ndata ) ) ; size_t lfl = CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ? 2 : 1 ; stream_forward_getp ( BGP_INPUT ( peer ) , - ( 1 + lfl ) ) ; stream_get ( & ndata [ 0 ] , BGP_INPUT ( peer ) , 1 ) ; stream_get ( & ndata [ 1 ] , BGP_INPUT ( peer ) , lfl ) ; size_t atl = attr_endp - startp ; size_t ndl = MIN ( atl , STREAM_READABLE ( BGP_INPUT ( peer ) ) ) ; stream_get ( & ndata [ lfl + 1 ] , BGP_INPUT ( peer ) , ndl ) ; bgp_notify_send_with_data ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR , ndata , ndl + lfl + 1 ) ; return BGP_ATTR_PARSE_ERROR ; } struct bgp_attr_parser_args attr_args = { . peer = peer , . length = length , . attr = attr , . type = type , . flags = flag , . startp = startp , . total = attr_endp - startp , } ; if ( bgp_attr_flag_invalid ( & attr_args ) ) { ret = bgp_attr_malformed ( & attr_args , BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR , attr_args . total ) ; if ( ret == BGP_ATTR_PARSE_PROCEED ) continue ; return ret ; } switch ( type ) { case BGP_ATTR_ORIGIN : ret = bgp_attr_origin ( & attr_args ) ; break ; case BGP_ATTR_AS_PATH : ret = bgp_attr_aspath ( & attr_args ) ; break ; case BGP_ATTR_AS4_PATH : ret = bgp_attr_as4_path ( & attr_args , & as4_path ) ; break ; case BGP_ATTR_NEXT_HOP : ret = bgp_attr_nexthop ( & attr_args ) ; break ; case BGP_ATTR_MULTI_EXIT_DISC : ret = bgp_attr_med ( & attr_args ) ; break ; case BGP_ATTR_LOCAL_PREF : ret = bgp_attr_local_pref ( & attr_args ) ; break ; case BGP_ATTR_ATOMIC_AGGREGATE : ret = bgp_attr_atomic ( & attr_args ) ; break ; case BGP_ATTR_AGGREGATOR : ret = bgp_attr_aggregator ( & attr_args ) ; break ; case BGP_ATTR_AS4_AGGREGATOR : ret = bgp_attr_as4_aggregator ( & attr_args , & as4_aggregator , & as4_aggregator_addr ) ; break ; case BGP_ATTR_COMMUNITIES : ret = bgp_attr_community ( & attr_args ) ; break ; case BGP_ATTR_LARGE_COMMUNITIES : ret = bgp_attr_large_community ( & attr_args ) ; break ; case BGP_ATTR_ORIGINATOR_ID : ret = bgp_attr_originator_id ( & attr_args ) ; break ; case BGP_ATTR_CLUSTER_LIST : ret = bgp_attr_cluster_list ( & attr_args ) ; break ; case BGP_ATTR_MP_REACH_NLRI : ret = bgp_mp_reach_parse ( & attr_args , mp_update ) ; break ; case BGP_ATTR_MP_UNREACH_NLRI : ret = bgp_mp_unreach_parse ( & attr_args , mp_withdraw ) ; break ; case BGP_ATTR_EXT_COMMUNITIES : ret = bgp_attr_ext_communities ( & attr_args ) ; break ; # if ENABLE_BGP_VNC case BGP_ATTR_VNC : # endif case BGP_ATTR_ENCAP : ret = bgp_attr_encap ( type , peer , length , attr , flag , startp ) ; break ; case BGP_ATTR_PREFIX_SID : ret = bgp_attr_prefix_sid ( length , & attr_args , mp_update ) ; break ; case BGP_ATTR_PMSI_TUNNEL : ret = bgp_attr_pmsi_tunnel ( & attr_args ) ; break ; default : ret = bgp_attr_unknown ( & attr_args ) ; break ; } if ( ret == BGP_ATTR_PARSE_ERROR_NOTIFYPLS ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; ret = BGP_ATTR_PARSE_ERROR ; } if ( ret == BGP_ATTR_PARSE_EOR ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_ERROR ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_ERROR , \"%s:Attribute%s,parseerror\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_WITHDRAW ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_WITHDRAW , \"%s:Attribute%s,parseerror-treatingaswithdrawal\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( BGP_INPUT_PNT ( peer ) != attr_endp ) { flog_warn ( EC_BGP_ATTRIBUTE_FETCH_ERROR , \"%s:BGPattribute%s,fetcherror\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } } if ( BGP_INPUT_PNT ( peer ) != endp ) { flog_warn ( EC_BGP_ATTRIBUTES_MISMATCH , \"%s:BGPattribute%s,lengthmismatch\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( ( ret = bgp_attr_check ( peer , attr ) ) < 0 ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( CHECK_FLAG ( attr -> flag , ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) && bgp_attr_munge_as4_attrs ( peer , attr , as4_path , as4_aggregator , & as4_aggregator_addr ) ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( as4_path ) { aspath_unintern ( & as4_path ) ; } if ( attr -> flag & ( ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) ) { ret = bgp_attr_aspath_check ( peer , attr ) ; if ( ret != BGP_ATTR_PARSE_PROCEED ) return ret ; } if ( attr -> transit ) attr -> transit = transit_intern ( attr -> transit ) ; if ( attr -> encap_subtlvs ) attr -> encap_subtlvs = encap_intern ( attr -> encap_subtlvs , ENCAP_SUBTLV_TYPE ) ; # if ENABLE_BGP_VNC if ( attr -> vnc_subtlvs ) attr -> vnc_subtlvs = encap_intern ( attr -> vnc_subtlvs , VNC_SUBTLV_TYPE ) ; # endif return BGP_ATTR_PARSE_PROCEED ; }\n", "\n", "2: CWE-000 static void bgp_packet_mpattr_tea ( struct bgp * bgp , struct peer * peer , struct stream * s , struct attr * attr , uint8_t attrtype ) { unsigned int attrlenfield = 0 ; unsigned int attrhdrlen = 0 ; struct bgp_attr_encap_subtlv * subtlvs ; struct bgp_attr_encap_subtlv * st ; const char * attrname ; if ( ! attr || ( attrtype == BGP_ATTR_ENCAP && ( ! attr -> encap_tunneltype || attr -> encap_tunneltype == BGP_ENCAP_TYPE_MPLS ) ) ) return ; switch ( attrtype ) { case BGP_ATTR_ENCAP : attrname = \"TunnelEncap\" ; subtlvs = attr -> encap_subtlvs ; if ( subtlvs == NULL ) return ; attrlenfield = 2 + 2 ; attrhdrlen = 1 + 1 ; break ; # if ENABLE_BGP_VNC case BGP_ATTR_VNC : attrname = \"VNC\" ; subtlvs = attr -> vnc_subtlvs ; if ( subtlvs == NULL ) return ; attrlenfield = 0 ; attrhdrlen = 2 + 2 ; break ; # endif default : assert ( 0 ) ; } for ( st = subtlvs ; st ; st = st -> next ) { attrlenfield += ( attrhdrlen + st -> length ) ; } if ( attrlenfield > 0xffff ) { zlog_info ( \"%sattributeistoolong(length=%d),can\\'tsendit\" , attrname , attrlenfield ) ; return ; } if ( attrlenfield > 0xff ) { stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_EXTLEN ) ; stream_putc ( s , attrtype ) ; stream_putw ( s , attrlenfield & 0xffff ) ; } else { stream_putc ( s , BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL ) ; stream_putc ( s , attrtype ) ; stream_putc ( s , attrlenfield & 0xff ) ; } if ( attrtype == BGP_ATTR_ENCAP ) { stream_putw ( s , attr -> encap_tunneltype ) ; stream_putw ( s , attrlenfield - 4 ) ; } for ( st = subtlvs ; st ; st = st -> next ) { if ( attrtype == BGP_ATTR_ENCAP ) { stream_putc ( s , st -> type ) ; stream_putc ( s , st -> length ) ; # if ENABLE_BGP_VNC } else { stream_putw ( s , st -> type ) ; stream_putw ( s , st -> length ) ; # endif } stream_put ( s , st -> value , st -> length ) ; } }\n", "\n", "3: CWE-436 bgp_attr_parse_ret_t bgp_attr_parse ( struct peer * peer , struct attr * attr , bgp_size_t size , struct bgp_nlri * mp_update , struct bgp_nlri * mp_withdraw ) { bgp_attr_parse_ret_t ret ; uint8_t flag = 0 ; uint8_t type = 0 ; bgp_size_t length ; uint8_t * startp , * endp ; uint8_t * attr_endp ; uint8_t seen [ BGP_ATTR_BITMAP_SIZE ] ; struct aspath * as4_path = NULL ; as_t as4_aggregator = 0 ; struct in_addr as4_aggregator_addr = { . s_addr = 0 } ; memset ( seen , 0 , BGP_ATTR_BITMAP_SIZE ) ; endp = BGP_INPUT_PNT ( peer ) + size ; while ( BGP_INPUT_PNT ( peer ) < endp ) { if ( endp - BGP_INPUT_PNT ( peer ) < BGP_ATTR_MIN_LEN ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_SMALL , \"%s:errorBGPattributelength%luissmallerthanminlen\" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } startp = BGP_INPUT_PNT ( peer ) ; flag = 0xF0 & stream_getc ( BGP_INPUT ( peer ) ) ; type = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) && ( ( endp - startp ) < ( BGP_ATTR_MIN_LEN + 1 ) ) ) { flog_warn ( EC_BGP_EXT_ATTRIBUTE_TOO_SMALL , \"%s:Extendedlengthset,butjust%lubytesofattrheader\" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ) length = stream_getw ( BGP_INPUT ( peer ) ) ; else length = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_BITMAP ( seen , type ) ) { flog_warn ( EC_BGP_ATTRIBUTE_REPEATED , \"%s:errorBGPattributetype%dappearstwiceinamessage\" , peer -> host , type ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; return BGP_ATTR_PARSE_ERROR ; } SET_BITMAP ( seen , type ) ; attr_endp = BGP_INPUT_PNT ( peer ) + length ; if ( attr_endp > endp ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_LARGE , \"%s:BGPtype%dlength%distoolarge,attributetotallengthis%d.attr_endpis%p.endpis%p\" , peer -> host , type , length , size , attr_endp , endp ) ; unsigned char ndata [ BGP_MAX_PACKET_SIZE ] ; memset ( ndata , 0x00 , sizeof ( ndata ) ) ; size_t lfl = CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ? 2 : 1 ; stream_forward_getp ( BGP_INPUT ( peer ) , - ( 1 + lfl ) ) ; stream_get ( & ndata [ 0 ] , BGP_INPUT ( peer ) , 1 ) ; stream_get ( & ndata [ 1 ] , BGP_INPUT ( peer ) , lfl ) ; size_t atl = attr_endp - startp ; size_t ndl = MIN ( atl , STREAM_READABLE ( BGP_INPUT ( peer ) ) ) ; stream_get ( & ndata [ lfl + 1 ] , BGP_INPUT ( peer ) , ndl ) ; bgp_notify_send_with_data ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR , ndata , ndl + lfl + 1 ) ; return BGP_ATTR_PARSE_ERROR ; } struct bgp_attr_parser_args attr_args = { . peer = peer , . length = length , . attr = attr , . type = type , . flags = flag , . startp = startp , . total = attr_endp - startp , } ; if ( bgp_attr_flag_invalid ( & attr_args ) ) { ret = bgp_attr_malformed ( & attr_args , BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR , attr_args . total ) ; if ( ret == BGP_ATTR_PARSE_PROCEED ) continue ; return ret ; } switch ( type ) { case BGP_ATTR_ORIGIN : ret = bgp_attr_origin ( & attr_args ) ; break ; case BGP_ATTR_AS_PATH : ret = bgp_attr_aspath ( & attr_args ) ; break ; case BGP_ATTR_AS4_PATH : ret = bgp_attr_as4_path ( & attr_args , & as4_path ) ; break ; case BGP_ATTR_NEXT_HOP : ret = bgp_attr_nexthop ( & attr_args ) ; break ; case BGP_ATTR_MULTI_EXIT_DISC : ret = bgp_attr_med ( & attr_args ) ; break ; case BGP_ATTR_LOCAL_PREF : ret = bgp_attr_local_pref ( & attr_args ) ; break ; case BGP_ATTR_ATOMIC_AGGREGATE : ret = bgp_attr_atomic ( & attr_args ) ; break ; case BGP_ATTR_AGGREGATOR : ret = bgp_attr_aggregator ( & attr_args ) ; break ; case BGP_ATTR_AS4_AGGREGATOR : ret = bgp_attr_as4_aggregator ( & attr_args , & as4_aggregator , & as4_aggregator_addr ) ; break ; case BGP_ATTR_COMMUNITIES : ret = bgp_attr_community ( & attr_args ) ; break ; case BGP_ATTR_LARGE_COMMUNITIES : ret = bgp_attr_large_community ( & attr_args ) ; break ; case BGP_ATTR_ORIGINATOR_ID : ret = bgp_attr_originator_id ( & attr_args ) ; break ; case BGP_ATTR_CLUSTER_LIST : ret = bgp_attr_cluster_list ( & attr_args ) ; break ; case BGP_ATTR_MP_REACH_NLRI : ret = bgp_mp_reach_parse ( & attr_args , mp_update ) ; break ; case BGP_ATTR_MP_UNREACH_NLRI : ret = bgp_mp_unreach_parse ( & attr_args , mp_withdraw ) ; break ; case BGP_ATTR_EXT_COMMUNITIES : ret = bgp_attr_ext_communities ( & attr_args ) ; break ; # if ENABLE_BGP_VNC case BGP_ATTR_VNC : # endif case BGP_ATTR_ENCAP : ret = bgp_attr_encap ( type , peer , length , attr , flag , startp ) ; break ; case BGP_ATTR_PREFIX_SID : ret = bgp_attr_prefix_sid ( length , & attr_args , mp_update ) ; break ; case BGP_ATTR_PMSI_TUNNEL : ret = bgp_attr_pmsi_tunnel ( & attr_args ) ; break ; default : ret = bgp_attr_unknown ( & attr_args ) ; break ; } if ( ret == BGP_ATTR_PARSE_ERROR_NOTIFYPLS ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; ret = BGP_ATTR_PARSE_ERROR ; } if ( ret == BGP_ATTR_PARSE_EOR ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_ERROR ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_ERROR , \"%s:Attribute%s,parseerror\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_WITHDRAW ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_WITHDRAW , \"%s:Attribute%s,parseerror-treatingaswithdrawal\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( BGP_INPUT_PNT ( peer ) != attr_endp ) { flog_warn ( EC_BGP_ATTRIBUTE_FETCH_ERROR , \"%s:BGPattribute%s,fetcherror\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } } if ( BGP_INPUT_PNT ( peer ) != endp ) { flog_warn ( EC_BGP_ATTRIBUTES_MISMATCH , \"%s:BGPattribute%s,lengthmismatch\" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( ( ret = bgp_attr_check ( peer , attr ) ) < 0 ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( CHECK_FLAG ( attr -> flag , ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) && bgp_attr_munge_as4_attrs ( peer , attr , as4_path , as4_aggregator , & as4_aggregator_addr ) ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( as4_path ) { aspath_unintern ( & as4_path ) ; } if ( attr -> flag & ( ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) ) { ret = bgp_attr_aspath_check ( peer , attr ) ; if ( ret != BGP_ATTR_PARSE_PROCEED ) return ret ; } if ( attr -> transit ) attr -> transit = transit_intern ( attr -> transit ) ; if ( attr -> encap_subtlvs ) attr -> encap_subtlvs = encap_intern ( attr -> encap_subtlvs , ENCAP_SUBTLV_TYPE ) ; # if ENABLE_BGP_VNC if ( attr -> vnc_subtlvs ) attr -> vnc_subtlvs = encap_intern ( attr -> vnc_subtlvs , VNC_SUBTLV_TYPE ) ; # endif return BGP_ATTR_PARSE_PROCEED ; }\n", "\n", "\n", "Target: 1 ] ; size_t pathlen ; '\\\\0' ; } res = is_symlink_path ( p , path , pathlen ) ; if 0 ) { if ( errno == EPERM ) { pr_log_pri ( PR_LOG_WARNING ( PR_LOG_WARNING , \"error:DefaultRoot%sisasymlink\" \"(deniedbyAllowChrootSymlinksconfig)\" , path ) ; } errno = EPERM\n", "\n", "Sources:\n", "0: CWE-59 static int get_default_root ( pool * p , int allow_symlinks , char * * root ) { config_rec * c = NULL ; char * dir = NULL ; int res ; c = find_config ( main_server -> conf , CONF_PARAM , \"DefaultRoot\" , FALSE ) ; while ( c ) { pr_signals_handle ( ) ; if ( c -> argc < 2 ) { dir = c -> argv [ 0 ] ; break ; } res = pr_expr_eval_group_and ( ( ( char * * ) c -> argv ) + 1 ) ; if ( res ) { dir = c -> argv [ 0 ] ; break ; } c = find_config_next ( c , c -> next , CONF_PARAM , \"DefaultRoot\" , FALSE ) ; } if ( dir ) { char * new_dir ; new_dir = path_subst_uservar ( p , & dir ) ; if ( new_dir != NULL ) { dir = new_dir ; } if ( strncmp ( dir , \"/\" , 2 ) == 0 ) { dir = NULL ; } else { char * realdir ; int xerrno = 0 ; if ( allow_symlinks == FALSE ) { char * path , target_path [ PR_TUNABLE_PATH_MAX + 1 ] ; struct stat st ; size_t pathlen ; path = dir ; if ( * path != '/' ) { if ( * path == '~' ) { if ( pr_fs_interpolate ( dir , target_path , sizeof ( target_path ) - 1 ) < 0 ) { return - 1 ; } path = target_path ; } } pathlen = strlen ( path ) ; if ( pathlen > 1 && path [ pathlen - 1 ] == '/' ) { path [ pathlen - 1 ] = '\\\\0' ; } pr_fs_clear_cache ( ) ; res = pr_fsio_lstat ( path , & st ) ; if ( res < 0 ) { xerrno = errno ; pr_log_pri ( PR_LOG_WARNING , \"error:unabletocheck%s:%s\" , path , strerror ( xerrno ) ) ; errno = xerrno ; return - 1 ; } if ( S_ISLNK ( st . st_mode ) ) { pr_log_pri ( PR_LOG_WARNING , \"error:DefaultRoot%sisasymlink(deniedbyAllowChrootSymlinks\" \"config)\" , path ) ; errno = EPERM ; return - 1 ; } } PRIVS_USER realdir = dir_realpath ( p , dir ) ; xerrno = errno ; PRIVS_RELINQUISH if ( realdir ) { dir = realdir ; } else { char interp_dir [ PR_TUNABLE_PATH_MAX + 1 ] ; memset ( interp_dir , '\\\\0' , sizeof ( interp_dir ) ) ; ( void ) pr_fs_interpolate ( dir , interp_dir , sizeof ( interp_dir ) - 1 ) ; pr_log_pri ( PR_LOG_NOTICE , \"notice:unabletouseDefaultRoot\\'%s\\'[resolvedto\\'%s\\']:%s\" , dir , interp_dir , strerror ( xerrno ) ) ; errno = xerrno ; } } } * root = dir ; return 0 ; }\n", "\n", "1: CWE-59 static int get_default_root ( pool * p , int allow_symlinks , const char * * root ) { config_rec * c = NULL ; const char * dir = NULL ; int res ; c = find_config ( main_server -> conf , CONF_PARAM , \"DefaultRoot\" , FALSE ) ; while ( c != NULL ) { pr_signals_handle ( ) ; if ( c -> argc < 2 ) { dir = c -> argv [ 0 ] ; break ; } res = pr_expr_eval_group_and ( ( ( char * * ) c -> argv ) + 1 ) ; if ( res ) { dir = c -> argv [ 0 ] ; break ; } c = find_config_next ( c , c -> next , CONF_PARAM , \"DefaultRoot\" , FALSE ) ; } if ( dir != NULL ) { const char * new_dir ; new_dir = path_subst_uservar ( p , & dir ) ; if ( new_dir != NULL ) { dir = new_dir ; } if ( strncmp ( dir , \"/\" , 2 ) == 0 ) { dir = NULL ; } else { char * realdir ; int xerrno = 0 ; if ( allow_symlinks == FALSE ) { char * path , target_path [ PR_TUNABLE_PATH_MAX + 1 ] ; struct stat st ; size_t pathlen ; path = pstrdup ( p , dir ) ; if ( * path != '/' ) { if ( * path == '~' ) { if ( pr_fs_interpolate ( dir , target_path , sizeof ( target_path ) - 1 ) < 0 ) { return - 1 ; } path = target_path ; } } pathlen = strlen ( path ) ; if ( pathlen > 1 && path [ pathlen - 1 ] == '/' ) { path [ pathlen - 1 ] = '\\\\0' ; } pr_fs_clear_cache2 ( path ) ; res = pr_fsio_lstat ( path , & st ) ; if ( res < 0 ) { xerrno = errno ; pr_log_pri ( PR_LOG_WARNING , \"error:unabletocheck%s:%s\" , path , strerror ( xerrno ) ) ; errno = xerrno ; return - 1 ; } if ( S_ISLNK ( st . st_mode ) ) { pr_log_pri ( PR_LOG_WARNING , \"error:DefaultRoot%sisasymlink(deniedbyAllowChrootSymlinks\" \"config)\" , path ) ; errno = EPERM ; return - 1 ; } } pr_fs_clear_cache2 ( dir ) ; PRIVS_USER realdir = dir_realpath ( p , dir ) ; xerrno = errno ; PRIVS_RELINQUISH if ( realdir ) { dir = realdir ; } else { char interp_dir [ PR_TUNABLE_PATH_MAX + 1 ] ; memset ( interp_dir , '\\\\0' , sizeof ( interp_dir ) ) ; ( void ) pr_fs_interpolate ( dir , interp_dir , sizeof ( interp_dir ) - 1 ) ; pr_log_pri ( PR_LOG_NOTICE , \"notice:unabletouseDefaultRoot\\'%s\\'[resolvedto\\'%s\\']:%s\" , dir , interp_dir , strerror ( xerrno ) ) ; errno = xerrno ; } } } * root = dir ; return 0 ; }\n", "\n", "\n", "Target: perf_event * bp , struct perf_sample_data\n", "\n", "Sources:\n", "0: CWE-400 void ptrace_triggered ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event_attr attr ; attr = bp -> attr ; attr . disabled = true ; modify_user_hw_breakpoint ( bp , & attr ) ; }\n", "\n", "1: CWE-400 static void ptrace_triggered ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { int i ; struct thread_struct * thread = & ( current -> thread ) ; for ( i = 0 ; i < HBP_NUM ; i ++ ) { if ( thread -> ptrace_bps [ i ] == bp ) break ; } thread -> debugreg6 |= ( DR_TRAP0 << i ) ; }\n", "\n", "2: CWE-399 void ptrace_triggered ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event_attr attr ; attr = bp -> attr ; attr . disabled = true ; modify_user_hw_breakpoint ( bp , & attr ) ; }\n", "\n", "3: CWE-400 static void sample_hbp_handler ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { printk ( KERN_INFO \"%svalueischanged\\\\n\" , ksym_name ) ; dump_stack ( ) ; printk ( KERN_INFO \"Dumpstackfromsample_hbp_handler\\\\n\" ) ; }\n", "\n", "\n", "Target: { if ( sctp_chunk_pending ( ack ) ) continue ; if (\n", "\n", "Sources:\n", "0: CWE-399 struct sctp_chunk * sctp_assoc_lookup_asconf_ack ( const struct sctp_association * asoc , __be32 serial ) { struct sctp_chunk * ack ; list_for_each_entry ( ack , & asoc -> asconf_ack_list , transmitted_list ) { if ( ack -> subh . addip_hdr -> serial == serial ) { sctp_chunk_hold ( ack ) ; return ack ; } } return NULL ; }\n", "\n", "1: CWE-400 struct sctp_chunk * sctp_assoc_lookup_asconf_ack ( const struct sctp_association * asoc , __be32 serial ) { struct sctp_chunk * ack ; list_for_each_entry ( ack , & asoc -> asconf_ack_list , transmitted_list ) { if ( ack -> subh . addip_hdr -> serial == serial ) { sctp_chunk_hold ( ack ) ; return ack ; } } return NULL ; }\n", "\n", "\n", "Target: sh_size < 1 || shdr -> sh_size > SIZE_MAX\n", "\n", "Sources:\n", "0: CWE-119 static Sdb * store_versioninfo_gnu_verneed ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { ut8 * end , * need = NULL ; const char * section_name = \"\" ; Elf_ ( Shdr ) * link_shdr = NULL ; const char * link_section_name = \"\" ; Sdb * sdb_vernaux = NULL ; Sdb * sdb_version = NULL ; Sdb * sdb = NULL ; int i , cnt ; if ( ! bin || ! bin -> dynstr ) { return NULL ; } if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return NULL ; } if ( shdr -> sh_size < 1 ) { return NULL ; } sdb = sdb_new0 ( ) ; if ( ! sdb ) { return NULL ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! ( need = ( ut8 * ) calloc ( R_MAX ( 1 , shdr -> sh_size ) , sizeof ( ut8 ) ) ) ) { bprintf ( \"Warning:CannotallocatememoryforElf_(Verneed)\\\\n\" ) ; goto beach ; } end = need + shdr -> sh_size ; sdb_set ( sdb , \"section_name\" , section_name , 0 ) ; sdb_num_set ( sdb , \"num_entries\" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , \"addr\" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , \"offset\" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , \"link\" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , \"link_section_name\" , link_section_name , 0 ) ; if ( shdr -> sh_offset > bin -> size || shdr -> sh_offset + shdr -> sh_size > bin -> size ) { goto beach ; } if ( shdr -> sh_offset + shdr -> sh_size < shdr -> sh_size ) { goto beach ; } i = r_buf_read_at ( bin -> b , shdr -> sh_offset , need , shdr -> sh_size ) ; if ( i < 0 ) goto beach ; for ( i = 0 , cnt = 0 ; cnt < shdr -> sh_info ; ++ cnt ) { int j , isum ; ut8 * vstart = need + i ; Elf_ ( Verneed ) vvn = { 0 } ; if ( vstart + sizeof ( Elf_ ( Verneed ) ) > end ) { goto beach ; } Elf_ ( Verneed ) * entry = & vvn ; char key [ 32 ] = { 0 } ; sdb_version = sdb_new0 ( ) ; if ( ! sdb_version ) { goto beach ; } j = 0 ; vvn . vn_version = READ16 ( vstart , j ) vvn . vn_cnt = READ16 ( vstart , j ) vvn . vn_file = READ32 ( vstart , j ) vvn . vn_aux = READ32 ( vstart , j ) vvn . vn_next = READ32 ( vstart , j ) sdb_num_set ( sdb_version , \"vn_version\" , entry -> vn_version , 0 ) ; sdb_num_set ( sdb_version , \"idx\" , i , 0 ) ; if ( entry -> vn_file > bin -> dynstr_size ) { goto beach ; } { char * s = r_str_ndup ( & bin -> dynstr [ entry -> vn_file ] , 16 ) ; sdb_set ( sdb_version , \"file_name\" , s , 0 ) ; free ( s ) ; } sdb_num_set ( sdb_version , \"cnt\" , entry -> vn_cnt , 0 ) ; st32 vnaux = entry -> vn_aux ; if ( vnaux < 1 ) { goto beach ; } vstart += vnaux ; for ( j = 0 , isum = i + entry -> vn_aux ; j < entry -> vn_cnt && vstart + sizeof ( Elf_ ( Vernaux ) ) <= end ; ++ j ) { int k ; Elf_ ( Vernaux ) * aux = NULL ; Elf_ ( Vernaux ) vaux = { 0 } ; sdb_vernaux = sdb_new0 ( ) ; if ( ! sdb_vernaux ) { goto beach ; } aux = ( Elf_ ( Vernaux ) * ) & vaux ; k = 0 ; vaux . vna_hash = READ32 ( vstart , k ) vaux . vna_flags = READ16 ( vstart , k ) vaux . vna_other = READ16 ( vstart , k ) vaux . vna_name = READ32 ( vstart , k ) vaux . vna_next = READ32 ( vstart , k ) if ( aux -> vna_name > bin -> dynstr_size ) { goto beach ; } sdb_num_set ( sdb_vernaux , \"idx\" , isum , 0 ) ; if ( aux -> vna_name > 0 && aux -> vna_name + 8 < bin -> dynstr_size ) { char name [ 16 ] ; strncpy ( name , & bin -> dynstr [ aux -> vna_name ] , sizeof ( name ) - 1 ) ; name [ sizeof ( name ) - 1 ] = 0 ; sdb_set ( sdb_vernaux , \"name\" , name , 0 ) ; } sdb_set ( sdb_vernaux , \"flags\" , get_ver_flags ( aux -> vna_flags ) , 0 ) ; sdb_num_set ( sdb_vernaux , \"version\" , aux -> vna_other , 0 ) ; isum += aux -> vna_next ; vstart += aux -> vna_next ; snprintf ( key , sizeof ( key ) , \"vernaux%d\" , j ) ; sdb_ns_set ( sdb_version , key , sdb_vernaux ) ; } if ( ( int ) entry -> vn_next < 0 ) { bprintf ( \"Invalidvn_next\\\\n\" ) ; break ; } i += entry -> vn_next ; snprintf ( key , sizeof ( key ) , \"version%d\" , cnt ) ; sdb_ns_set ( sdb , key , sdb_version ) ; if ( ! entry -> vn_next ) { break ; } } free ( need ) ; return sdb ; beach : free ( need ) ; sdb_free ( sdb_vernaux ) ; sdb_free ( sdb_version ) ; sdb_free ( sdb ) ; return NULL ; }\n", "\n", "1: CWE-119 static Sdb * store_versioninfo_gnu_verdef ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { const char * section_name = \"\" ; const char * link_section_name = \"\" ; char * end = NULL ; Elf_ ( Shdr ) * link_shdr = NULL ; ut8 dfs [ sizeof ( Elf_ ( Verdef ) ) ] = { 0 } ; Sdb * sdb ; int cnt , i ; if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return false ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( shdr -> sh_size < 1 ) { return false ; } Elf_ ( Verdef ) * defs = calloc ( shdr -> sh_size , sizeof ( char ) ) ; if ( ! defs ) { return false ; } if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( link_shdr && bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! defs ) { bprintf ( \"Warning:Cannotallocatememory(CheckElf_(Verdef))\\\\n\" ) ; return NULL ; } sdb = sdb_new0 ( ) ; end = ( char * ) defs + shdr -> sh_size ; sdb_set ( sdb , \"section_name\" , section_name , 0 ) ; sdb_num_set ( sdb , \"entries\" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , \"addr\" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , \"offset\" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , \"link\" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , \"link_section_name\" , link_section_name , 0 ) ; for ( cnt = 0 , i = 0 ; i >= 0 && cnt < shdr -> sh_info && ( ( char * ) defs + i < end ) ; ++ cnt ) { Sdb * sdb_verdef = sdb_new0 ( ) ; char * vstart = ( ( char * ) defs ) + i ; char key [ 32 ] = { 0 } ; Elf_ ( Verdef ) * verdef = ( Elf_ ( Verdef ) * ) vstart ; Elf_ ( Verdaux ) aux = { 0 } ; int j = 0 ; int isum = 0 ; r_buf_read_at ( bin -> b , shdr -> sh_offset + i , dfs , sizeof ( Elf_ ( Verdef ) ) ) ; verdef -> vd_version = READ16 ( dfs , j ) verdef -> vd_flags = READ16 ( dfs , j ) verdef -> vd_ndx = READ16 ( dfs , j ) verdef -> vd_cnt = READ16 ( dfs , j ) verdef -> vd_hash = READ32 ( dfs , j ) verdef -> vd_aux = READ32 ( dfs , j ) verdef -> vd_next = READ32 ( dfs , j ) int vdaux = verdef -> vd_aux ; if ( vdaux < 1 ) { sdb_free ( sdb_verdef ) ; goto out_error ; } vstart += vdaux ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; goto out_error ; } j = 0 ; aux . vda_name = READ32 ( vstart , j ) aux . vda_next = READ32 ( vstart , j ) isum = i + verdef -> vd_aux ; if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; goto out_error ; } sdb_num_set ( sdb_verdef , \"idx\" , i , 0 ) ; sdb_num_set ( sdb_verdef , \"vd_version\" , verdef -> vd_version , 0 ) ; sdb_num_set ( sdb_verdef , \"vd_ndx\" , verdef -> vd_ndx , 0 ) ; sdb_num_set ( sdb_verdef , \"vd_cnt\" , verdef -> vd_cnt , 0 ) ; sdb_set ( sdb_verdef , \"vda_name\" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; sdb_set ( sdb_verdef , \"flags\" , get_ver_flags ( verdef -> vd_flags ) , 0 ) ; for ( j = 1 ; j < verdef -> vd_cnt ; ++ j ) { int k ; Sdb * sdb_parent = sdb_new0 ( ) ; isum += aux . vda_next ; vstart += aux . vda_next ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } k = 0 ; aux . vda_name = READ32 ( vstart , k ) aux . vda_next = READ32 ( vstart , k ) if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } sdb_num_set ( sdb_parent , \"idx\" , isum , 0 ) ; sdb_num_set ( sdb_parent , \"parent\" , j , 0 ) ; sdb_set ( sdb_parent , \"vda_name\" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; snprintf ( key , sizeof ( key ) , \"parent%d\" , j - 1 ) ; sdb_ns_set ( sdb_verdef , key , sdb_parent ) ; } snprintf ( key , sizeof ( key ) , \"verdef%d\" , cnt ) ; sdb_ns_set ( sdb , key , sdb_verdef ) ; if ( ! verdef -> vd_next ) { sdb_free ( sdb_verdef ) ; goto out_error ; } if ( ( st32 ) verdef -> vd_next < 1 ) { eprintf ( \"Warning:Invalidvd_nextintheELFversion\\\\n\" ) ; break ; } i += verdef -> vd_next ; } free ( defs ) ; return sdb ; out_error : free ( defs ) ; sdb_free ( sdb ) ; return NULL ; }\n", "\n", "\n", "Target: msr ) { switch ( msr -> index ) { case MSR_FS_BASE : case MSR_GS_BASE : case MSR_KERNEL_GS_BASE : case MSR_CSTAR : case MSR_LSTAR : if ( is_noncanonical_address ( msr -> data ) ) return 1 ; break ; case MSR_IA32_SYSENTER_EIP : case MSR_IA32_SYSENTER_ESP : msr -> data = get_canonical ( msr -> data ) ; }\n", "\n", "Sources:\n", "0: CWE-000 int kvm_set_msr ( struct kvm_vcpu * vcpu , struct msr_data * msr ) { return kvm_x86_ops -> set_msr ( vcpu , msr ) ; }\n", "\n", "1: CWE-264 int kvm_set_msr ( struct kvm_vcpu * vcpu , struct msr_data * msr ) { return kvm_x86_ops -> set_msr ( vcpu , msr ) ; }\n", "\n", "\n", "Target: ) break ; if ( fputc ( c , file ) != c ) break\n", "\n", "Sources:\n", "0: CWE-20 static Image * ReadPWPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char filename [ MagickPathExtent ] ; FILE * file ; Image * image , * next_image , * pwp_image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register Image * p ; register ssize_t i ; size_t filesize , length ; ssize_t count ; unsigned char magick [ MagickPathExtent ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } pwp_image = image ; memset ( magick , 0 , sizeof ( magick ) ) ; count = ReadBlob ( pwp_image , 5 , magick ) ; if ( ( count != 5 ) || ( LocaleNCompare ( ( char * ) magick , \"SFW95\" , 5 ) != 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; read_info = CloneImageInfo ( image_info ) ; ( void ) SetImageInfoProgressMonitor ( read_info , ( MagickProgressMonitor ) NULL , ( void * ) NULL ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; unique_file = AcquireUniqueFileResource ( filename ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"sfw:%s\" , filename ) ; for ( ; ; ) { ( void ) memset ( magick , 0 , sizeof ( magick ) ) ; for ( c = ReadBlobByte ( pwp_image ) ; c != EOF ; c = ReadBlobByte ( pwp_image ) ) { for ( i = 0 ; i < 17 ; i ++ ) magick [ i ] = magick [ i + 1 ] ; magick [ 17 ] = ( unsigned char ) c ; if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , \"SFW94A\" , 6 ) == 0 ) break ; } if ( c == EOF ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , \"SFW94A\" , 6 ) != 0 ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } file = ( FILE * ) NULL ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowFileException ( exception , FileOpenError , \"UnableToWriteFile\" , image -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = fwrite ( \"SFW94A\" , 1 , 6 , file ) ; ( void ) length ; filesize = 65535UL * magick [ 2 ] + 256L * magick [ 1 ] + magick [ 0 ] ; for ( i = 0 ; i < ( ssize_t ) filesize ; i ++ ) { c = ReadBlobByte ( pwp_image ) ; if ( c == EOF ) break ; ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; if ( c == EOF ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } next_image = ReadImage ( read_info , exception ) ; if ( next_image == ( Image * ) NULL ) break ; ( void ) FormatLocaleString ( next_image -> filename , MagickPathExtent , \"slide_%02ld.sfw\" , ( long ) next_image -> scene ) ; if ( image == ( Image * ) NULL ) image = next_image ; else { for ( p = image ; p -> next != ( Image * ) NULL ; p = GetNextImageInList ( p ) ) ; next_image -> previous = p ; next_image -> scene = p -> scene + 1 ; p -> next = next_image ; } if ( image_info -> number_scenes != 0 ) if ( next_image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( pwp_image ) , GetBlobSize ( pwp_image ) ) ; if ( status == MagickFalse ) break ; } if ( unique_file != - 1 ) ( void ) close ( unique_file ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( image != ( Image * ) NULL ) { if ( EOFBlob ( image ) != MagickFalse ) { char * message ; message = GetExceptionMessage ( errno ) ; ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"UnexpectedEndOfFile\" , \"`%s\\':%s\" , image -> filename , message ) ; message = DestroyString ( message ) ; } ( void ) CloseBlob ( image ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-252 static Image * ReadPWPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char filename [ MagickPathExtent ] ; FILE * file ; Image * image , * next_image , * pwp_image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register Image * p ; register ssize_t i ; size_t filesize , length ; ssize_t count ; unsigned char magick [ MagickPathExtent ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } pwp_image = image ; memset ( magick , 0 , sizeof ( magick ) ) ; count = ReadBlob ( pwp_image , 5 , magick ) ; if ( ( count != 5 ) || ( LocaleNCompare ( ( char * ) magick , \"SFW95\" , 5 ) != 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; read_info = CloneImageInfo ( image_info ) ; ( void ) SetImageInfoProgressMonitor ( read_info , ( MagickProgressMonitor ) NULL , ( void * ) NULL ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; unique_file = AcquireUniqueFileResource ( filename ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"sfw:%s\" , filename ) ; for ( ; ; ) { ( void ) memset ( magick , 0 , sizeof ( magick ) ) ; for ( c = ReadBlobByte ( pwp_image ) ; c != EOF ; c = ReadBlobByte ( pwp_image ) ) { for ( i = 0 ; i < 17 ; i ++ ) magick [ i ] = magick [ i + 1 ] ; magick [ 17 ] = ( unsigned char ) c ; if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , \"SFW94A\" , 6 ) == 0 ) break ; } if ( c == EOF ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , \"SFW94A\" , 6 ) != 0 ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; } file = ( FILE * ) NULL ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowFileException ( exception , FileOpenError , \"UnableToWriteFile\" , image -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = fwrite ( \"SFW94A\" , 1 , 6 , file ) ; ( void ) length ; filesize = 65535UL * magick [ 2 ] + 256L * magick [ 1 ] + magick [ 0 ] ; for ( i = 0 ; i < ( ssize_t ) filesize ; i ++ ) { c = ReadBlobByte ( pwp_image ) ; if ( c == EOF ) break ; ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; if ( c == EOF ) { ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( CorruptImageError , \"UnexpectedEndOfFile\" ) ; } next_image = ReadImage ( read_info , exception ) ; if ( next_image == ( Image * ) NULL ) break ; ( void ) FormatLocaleString ( next_image -> filename , MagickPathExtent , \"slide_%02ld.sfw\" , ( long ) next_image -> scene ) ; if ( image == ( Image * ) NULL ) image = next_image ; else { for ( p = image ; p -> next != ( Image * ) NULL ; p = GetNextImageInList ( p ) ) ; next_image -> previous = p ; next_image -> scene = p -> scene + 1 ; p -> next = next_image ; } if ( image_info -> number_scenes != 0 ) if ( next_image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( pwp_image ) , GetBlobSize ( pwp_image ) ) ; if ( status == MagickFalse ) break ; } if ( unique_file != - 1 ) ( void ) close ( unique_file ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( image != ( Image * ) NULL ) { if ( EOFBlob ( image ) != MagickFalse ) { char * message ; message = GetExceptionMessage ( errno ) ; ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"UnexpectedEndOfFile\" , \"`%s\\':%s\" , image -> filename , message ) ; message = DestroyString ( message ) ; } ( void ) CloseBlob ( image ) ; } return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: dev ) { if ( dev -> lintr . pin <= 0 ) { pr_warn ( \"%s:Invalidintrpinondev[%s]\\\\n\" , __func__ , dev -> name ) ; return ; } pthread_mutex_lock ( &\n", "\n", "Sources:\n", "0: CWE-617 void pci_lintr_assert ( struct pci_vdev * dev ) { assert ( dev -> lintr . pin > 0 ) ; pthread_mutex_lock ( & dev -> lintr . lock ) ; if ( dev -> lintr . state == IDLE ) { if ( pci_lintr_permitted ( dev ) ) { dev -> lintr . state = ASSERTED ; pci_irq_assert ( dev ) ; } else dev -> lintr . state = PENDING ; } pthread_mutex_unlock ( & dev -> lintr . lock ) ; }\n", "\n", "1: CWE-617 void pci_lintr_deassert ( struct pci_vdev * dev ) { assert ( dev -> lintr . pin > 0 ) ; pthread_mutex_lock ( & dev -> lintr . lock ) ; if ( dev -> lintr . state == ASSERTED ) { dev -> lintr . state = IDLE ; pci_irq_deassert ( dev ) ; } else if ( dev -> lintr . state == PENDING ) dev -> lintr . state = IDLE ; pthread_mutex_unlock ( & dev -> lintr . lock ) ; }\n", "\n", "\n", "Target: \"`%s\\'\" , option ) ; geometry = DestroyString ( geometry\n", "\n", "Sources:\n", "0: CWE-399 static Image * ReadPSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define BoundingBox \"BoundingBox:\" # define BeginDocument \"BeginDocument:\" # define BeginXMPPacket \"begin=\" # define EndXMPPacket \"end=\" # define ICCProfile \"BeginICCProfile:\" # define CMYKCustomColor \"CMYKCustomColor:\" # define CMYKProcessColor \"CMYKProcessColor:\" # define DocumentMedia \"DocumentMedia:\" # define DocumentCustomColors \"DocumentCustomColors:\" # define DocumentProcessColors \"DocumentProcessColors:\" # define EndDocument \"EndDocument:\" # define HiResBoundingBox \"HiResBoundingBox:\" # define ImageData \"ImageData:\" # define PageBoundingBox \"PageBoundingBox:\" # define LanguageLevel \"LanguageLevel:\" # define PageMedia \"PageMedia:\" # define Pages \"Pages:\" # define PhotoshopProfile \"BeginPhotoshop:\" # define PostscriptLevel \"!PS-\" # define RenderPostscriptText \"RenderingPostscript...\" # define SpotColor \"+\" char command [ MaxTextExtent ] , * density , filename [ MaxTextExtent ] , geometry [ MaxTextExtent ] , input_filename [ MaxTextExtent ] , message [ MaxTextExtent ] , * options , postscript_filename [ MaxTextExtent ] ; const char * option ; const DelegateInfo * delegate_info ; GeometryInfo geometry_info ; Image * image , * next , * postscript_image ; ImageInfo * read_info ; int c , file ; MagickBooleanType cmyk , fitPage , skip , status ; MagickStatusType flags ; PointInfo delta , resolution ; RectangleInfo page ; register char * p ; register ssize_t i ; SegmentInfo bounds , hires_bounds ; short int hex_digits [ 256 ] ; size_t length , priority ; ssize_t count ; StringInfo * profile ; unsigned long columns , extent , language_level , pages , rows , scene , spotcolor ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } status = AcquireUniqueSymbolicLink ( image_info -> filename , input_filename ) ; if ( status == MagickFalse ) { ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( hex_digits , 0 , sizeof ( hex_digits ) ) ; hex_digits [ ( int ) '0' ] = 0 ; hex_digits [ ( int ) '1' ] = 1 ; hex_digits [ ( int ) '2' ] = 2 ; hex_digits [ ( int ) '3' ] = 3 ; hex_digits [ ( int ) '4' ] = 4 ; hex_digits [ ( int ) '5' ] = 5 ; hex_digits [ ( int ) '6' ] = 6 ; hex_digits [ ( int ) '7' ] = 7 ; hex_digits [ ( int ) '8' ] = 8 ; hex_digits [ ( int ) '9' ] = 9 ; hex_digits [ ( int ) 'a' ] = 10 ; hex_digits [ ( int ) 'b' ] = 11 ; hex_digits [ ( int ) 'c' ] = 12 ; hex_digits [ ( int ) 'd' ] = 13 ; hex_digits [ ( int ) 'e' ] = 14 ; hex_digits [ ( int ) 'f' ] = 15 ; hex_digits [ ( int ) 'A' ] = 10 ; hex_digits [ ( int ) 'B' ] = 11 ; hex_digits [ ( int ) 'C' ] = 12 ; hex_digits [ ( int ) 'D' ] = 13 ; hex_digits [ ( int ) 'E' ] = 14 ; hex_digits [ ( int ) 'F' ] = 15 ; delta . x = DefaultResolution ; delta . y = DefaultResolution ; if ( ( image -> x_resolution == 0.0 ) || ( image -> y_resolution == 0.0 ) ) { flags = ParseGeometry ( PSDensityGeometry , & geometry_info ) ; image -> x_resolution = geometry_info . rho ; image -> y_resolution = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> y_resolution = image -> x_resolution ; } if ( image_info -> density != ( char * ) NULL ) { flags = ParseGeometry ( image_info -> density , & geometry_info ) ; image -> x_resolution = geometry_info . rho ; image -> y_resolution = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> y_resolution = image -> x_resolution ; } ( void ) ParseAbsoluteGeometry ( PSPageGeometry , & page ) ; if ( image_info -> page != ( char * ) NULL ) ( void ) ParseAbsoluteGeometry ( image_info -> page , & page ) ; resolution . x = image -> x_resolution ; resolution . y = image -> y_resolution ; page . width = ( size_t ) ceil ( ( double ) ( page . width * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * resolution . y / delta . y ) - 0.5 ) ; ( void ) memset ( & bounds , 0 , sizeof ( bounds ) ) ; ( void ) memset ( command , 0 , sizeof ( command ) ) ; cmyk = image_info -> colorspace == CMYKColorspace ? MagickTrue : MagickFalse ; ( void ) memset ( & hires_bounds , 0 , sizeof ( hires_bounds ) ) ; priority = 0 ; columns = 0 ; rows = 0 ; extent = 0 ; spotcolor = 0 ; language_level = 1 ; skip = MagickFalse ; pages = ( ~ 0UL ) ; p = command ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( PostscriptLevel , command , strlen ( PostscriptLevel ) ) == 0 ) { ( void ) SetImageProperty ( image , \"ps:Level\" , command + 4 ) ; if ( GlobExpression ( command , \"*EPSF-*\" , MagickTrue ) != MagickFalse ) pages = 1 ; } if ( LocaleNCompare ( LanguageLevel , command , strlen ( LanguageLevel ) ) == 0 ) ( void ) sscanf ( command , LanguageLevel \"%lu\" , & language_level ) ; if ( LocaleNCompare ( Pages , command , strlen ( Pages ) ) == 0 ) ( void ) sscanf ( command , Pages \"%lu\" , & pages ) ; if ( LocaleNCompare ( ImageData , command , strlen ( ImageData ) ) == 0 ) ( void ) sscanf ( command , ImageData \"%lu%lu\" , & columns , & rows ) ; length = strlen ( DocumentProcessColors ) ; if ( LocaleNCompare ( DocumentProcessColors , command , length ) == 0 ) { if ( ( GlobExpression ( command , \"*Cyan*\" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , \"*Magenta*\" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , \"*Yellow*\" , MagickTrue ) != MagickFalse ) ) cmyk = MagickTrue ; } if ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) cmyk = MagickTrue ; if ( LocaleNCompare ( CMYKProcessColor , command , strlen ( CMYKProcessColor ) ) == 0 ) cmyk = MagickTrue ; length = strlen ( DocumentCustomColors ) ; if ( ( LocaleNCompare ( DocumentCustomColors , command , length ) == 0 ) || ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) || ( LocaleNCompare ( SpotColor , command , strlen ( SpotColor ) ) == 0 ) ) { char property [ MaxTextExtent ] , * value ; register char * p ; ( void ) FormatLocaleString ( property , MaxTextExtent , \"ps:SpotColor-%.20g\" , ( double ) ( spotcolor ++ ) ) ; for ( p = command ; * p != '\\\\0' ; p ++ ) if ( isspace ( ( int ) ( unsigned char ) * p ) != 0 ) break ; value = ConstantString ( p ) ; ( void ) SubstituteString ( & value , \"(\" , \"\" ) ; ( void ) SubstituteString ( & value , \")\" , \"\" ) ; ( void ) StripString ( value ) ; if ( * value != '\\\\0' ) ( void ) SetImageProperty ( image , property , value ) ; value = DestroyString ( value ) ; continue ; } if ( image_info -> page != ( char * ) NULL ) continue ; count = 0 ; i = 0 ; if ( LocaleNCompare ( BoundingBox , command , strlen ( BoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , BoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 2 ; } if ( LocaleNCompare ( DocumentMedia , command , strlen ( DocumentMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , DocumentMedia \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( HiResBoundingBox , command , strlen ( HiResBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , HiResBoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 3 ; } if ( LocaleNCompare ( PageBoundingBox , command , strlen ( PageBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageBoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( PageMedia , command , strlen ( PageMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageMedia \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( ( count != 4 ) || ( i < ( ssize_t ) priority ) ) continue ; if ( ( fabs ( bounds . x2 - bounds . x1 ) <= fabs ( hires_bounds . x2 - hires_bounds . x1 ) ) || ( fabs ( bounds . y2 - bounds . y1 ) <= fabs ( hires_bounds . y2 - hires_bounds . y1 ) ) ) if ( i == ( ssize_t ) priority ) continue ; hires_bounds = bounds ; priority = ( size_t ) i ; } if ( ( fabs ( hires_bounds . x2 - hires_bounds . x1 ) >= MagickEpsilon ) && ( fabs ( hires_bounds . y2 - hires_bounds . y1 ) >= MagickEpsilon ) ) { ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%gx%g%+.15g%+.15g\" , hires_bounds . x2 - hires_bounds . x1 , hires_bounds . y2 - hires_bounds . y1 , hires_bounds . x1 , hires_bounds . y1 ) ; ( void ) SetImageProperty ( image , \"ps:HiResBoundingBox\" , geometry ) ; page . width = ( size_t ) ceil ( ( double ) ( ( hires_bounds . x2 - hires_bounds . x1 ) * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( ( hires_bounds . y2 - hires_bounds . y1 ) * resolution . y / delta . y ) - 0.5 ) ; } fitPage = MagickFalse ; option = GetImageOption ( image_info , \"eps:fit-page\" ) ; if ( option != ( char * ) NULL ) { char * geometry ; MagickStatusType flags ; geometry = GetPageGeometry ( option ) ; flags = ParseMetaGeometry ( geometry , & page . x , & page . y , & page . width , & page . height ) ; if ( flags == NoValue ) { ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , OptionError , \"InvalidGeometry\" , \"`%s\\'\" , option ) ; image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } page . width = ( size_t ) ceil ( ( double ) ( page . width * image -> x_resolution / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * image -> y_resolution / delta . y ) - 0.5 ) ; geometry = DestroyString ( geometry ) ; fitPage = MagickTrue ; } if ( IssRGBCompatibleColorspace ( image_info -> colorspace ) != MagickFalse ) cmyk = MagickFalse ; file = AcquireUniqueFileResource ( postscript_filename ) ; if ( file == - 1 ) { ThrowFileException ( & image -> exception , FileOpenError , \"UnableToOpenFile\" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) CopyMagickString ( command , \"/setpagedevice{pop}bind1indexwhere{\" \"dupwcheck{31rollput}{popdef}ifelse}{def}ifelse\\\\n\" \"<true>>setpagedevice\\\\n\" , MaxTextExtent ) ; count = write ( file , command , ( unsigned int ) strlen ( command ) ) ; if ( image_info -> page == ( char * ) NULL ) { char translate_geometry [ MaxTextExtent ] ; ( void ) FormatLocaleString ( translate_geometry , MaxTextExtent , \"%g%gtranslate\\\\n\" , - hires_bounds . x1 , - hires_bounds . y1 ) ; count = write ( file , translate_geometry , ( unsigned int ) strlen ( translate_geometry ) ) ; } file = close ( file ) - 1 ; if ( image_info -> monochrome != MagickFalse ) delegate_info = GetDelegateInfo ( \"ps:mono\" , ( char * ) NULL , exception ) ; else if ( cmyk != MagickFalse ) delegate_info = GetDelegateInfo ( \"ps:cmyk\" , ( char * ) NULL , exception ) ; else delegate_info = GetDelegateInfo ( \"ps:alpha\" , ( char * ) NULL , exception ) ; if ( delegate_info == ( const DelegateInfo * ) NULL ) { ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } density = AcquireString ( \"\" ) ; options = AcquireString ( \"\" ) ; ( void ) FormatLocaleString ( density , MaxTextExtent , \"%gx%g\" , resolution . x , resolution . y ) ; ( void ) FormatLocaleString ( options , MaxTextExtent , \"-g%.20gx%.20g\" , ( double ) page . width , ( double ) page . height ) ; read_info = CloneImageInfo ( image_info ) ; * read_info -> magick = '\\\\0' ; if ( read_info -> number_scenes != 0 ) { char pages [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pages , MaxTextExtent , \"-dFirstPage=%.20g\" \"-dLastPage=%.20g\" , ( double ) read_info -> scene + 1 , ( double ) ( read_info -> scene + read_info -> number_scenes ) ) ; ( void ) ConcatenateMagickString ( options , pages , MaxTextExtent ) ; read_info -> number_scenes = 0 ; if ( read_info -> scenes != ( char * ) NULL ) * read_info -> scenes = '\\\\0' ; } if ( * image_info -> magick == 'E' ) { option = GetImageOption ( image_info , \"eps:use-cropbox\" ) ; if ( ( option == ( const char * ) NULL ) || ( IsStringTrue ( option ) != MagickFalse ) ) ( void ) ConcatenateMagickString ( options , \"-dEPSCrop\" , MaxTextExtent ) ; if ( fitPage != MagickFalse ) ( void ) ConcatenateMagickString ( options , \"-dEPSFitPage\" , MaxTextExtent ) ; } ( void ) CopyMagickString ( filename , read_info -> filename , MaxTextExtent ) ; ( void ) AcquireUniqueFilename ( filename ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; ( void ) ConcatenateMagickString ( filename , \"%d\" , MaxTextExtent ) ; ( void ) FormatLocaleString ( command , MaxTextExtent , GetDelegateCommands ( delegate_info ) , read_info -> antialias != MagickFalse ? 4 : 1 , read_info -> antialias != MagickFalse ? 4 : 1 , density , options , filename , postscript_filename , input_filename ) ; options = DestroyString ( options ) ; density = DestroyString ( density ) ; * message = '\\\\0' ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; ( void ) InterpretImageFilename ( image_info , image , filename , 1 , read_info -> filename ) ; if ( ( status == MagickFalse ) || ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) ) { ( void ) ConcatenateMagickString ( command , \"-cshowpage\" , MaxTextExtent ) ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; } ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; ( void ) RelinquishUniqueFileResource ( input_filename ) ; postscript_image = ( Image * ) NULL ; if ( status == MagickFalse ) for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; } else for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; read_info -> blob = NULL ; read_info -> length = 0 ; next = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; if ( next == ( Image * ) NULL ) break ; AppendImageToList ( & postscript_image , next ) ; } ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( postscript_image == ( Image * ) NULL ) { if ( * message != '\\\\0' ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , DelegateError , \"PostscriptDelegateFailed\" , \"`%s\\'\" , message ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( LocaleCompare ( postscript_image -> magick , \"BMP\" ) == 0 ) { Image * cmyk_image ; cmyk_image = ConsolidateCMYKImages ( postscript_image , exception ) ; if ( cmyk_image != ( Image * ) NULL ) { postscript_image = DestroyImageList ( postscript_image ) ; postscript_image = cmyk_image ; } } ( void ) SeekBlob ( image , 0 , SEEK_SET ) ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( PostscriptLevel , command , strlen ( PostscriptLevel ) ) == 0 ) { ( void ) SetImageProperty ( image , \"ps:Level\" , command + 4 ) ; if ( GlobExpression ( command , \"*EPSF-*\" , MagickTrue ) != MagickFalse ) pages = 1 ; } if ( LocaleNCompare ( LanguageLevel , command , strlen ( LanguageLevel ) ) == 0 ) ( void ) sscanf ( command , LanguageLevel \"%lu\" , & language_level ) ; if ( LocaleNCompare ( Pages , command , strlen ( Pages ) ) == 0 ) ( void ) sscanf ( command , Pages \"%lu\" , & pages ) ; if ( LocaleNCompare ( ImageData , command , strlen ( ImageData ) ) == 0 ) ( void ) sscanf ( command , ImageData \"%lu%lu\" , & columns , & rows ) ; if ( LocaleNCompare ( ICCProfile , command , strlen ( ICCProfile ) ) == 0 ) { unsigned char * datum ; profile = AcquireStringInfo ( MaxTextExtent ) ; datum = GetStringInfoDatum ( profile ) ; for ( i = 0 ; ( c = ProfileInteger ( image , hex_digits ) ) != EOF ; i ++ ) { if ( i >= ( ssize_t ) GetStringInfoLength ( profile ) ) { SetStringInfoLength ( profile , ( size_t ) i << 1 ) ; datum = GetStringInfoDatum ( profile ) ; } datum [ i ] = ( unsigned char ) c ; } SetStringInfoLength ( profile , ( size_t ) i + 1 ) ; ( void ) SetImageProfile ( image , \"icc\" , profile ) ; profile = DestroyStringInfo ( profile ) ; continue ; } if ( LocaleNCompare ( PhotoshopProfile , command , strlen ( PhotoshopProfile ) ) == 0 ) { unsigned char * p ; count = ( ssize_t ) sscanf ( command , PhotoshopProfile \"%lu\" , & extent ) ; if ( count != 1 ) continue ; length = extent ; if ( ( MagickSizeType ) length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; if ( profile != ( StringInfo * ) NULL ) { p = GetStringInfoDatum ( profile ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) * p ++ = ( unsigned char ) ProfileInteger ( image , hex_digits ) ; ( void ) SetImageProfile ( image , \"8bim\" , profile ) ; profile = DestroyStringInfo ( profile ) ; } continue ; } if ( LocaleNCompare ( BeginXMPPacket , command , strlen ( BeginXMPPacket ) ) == 0 ) { register size_t i ; p = command ; profile = StringToStringInfo ( command ) ; for ( i = GetStringInfoLength ( profile ) - 1 ; c != EOF ; i ++ ) { SetStringInfoLength ( profile , ( size_t ) ( i + 1 ) ) ; c = ReadBlobByte ( image ) ; GetStringInfoDatum ( profile ) [ i ] = ( unsigned char ) c ; * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( EndXMPPacket , command , strlen ( EndXMPPacket ) ) == 0 ) break ; } SetStringInfoLength ( profile , ( size_t ) i ) ; ( void ) SetImageProfile ( image , \"xmp\" , profile ) ; profile = DestroyStringInfo ( profile ) ; continue ; } } ( void ) CloseBlob ( image ) ; if ( image_info -> number_scenes != 0 ) { Image * clone_image ; register ssize_t i ; for ( i = 0 ; i < ( ssize_t ) image_info -> scene ; i ++ ) { clone_image = CloneImage ( postscript_image , 1 , 1 , MagickTrue , exception ) ; if ( clone_image != ( Image * ) NULL ) PrependImageToList ( & postscript_image , clone_image ) ; } } do { ( void ) CopyMagickString ( postscript_image -> filename , filename , MaxTextExtent ) ; ( void ) CopyMagickString ( postscript_image -> magick , image -> magick , MaxTextExtent ) ; if ( columns != 0 ) postscript_image -> magick_columns = columns ; if ( rows != 0 ) postscript_image -> magick_rows = rows ; postscript_image -> page = page ; ( void ) CloneImageProfiles ( postscript_image , image ) ; ( void ) CloneImageProperties ( postscript_image , image ) ; next = SyncNextImageInList ( postscript_image ) ; if ( next != ( Image * ) NULL ) postscript_image = next ; } while ( next != ( Image * ) NULL ) ; image = DestroyImageList ( image ) ; scene = 0 ; for ( next = GetFirstImageInList ( postscript_image ) ; next != ( Image * ) NULL ; ) { next -> scene = scene ++ ; next = GetNextImageInList ( next ) ; } return ( GetFirstImageInList ( postscript_image ) ) ; }\n", "\n", "1: CWE-401 static Image * ReadPSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define BoundingBox \"BoundingBox:\" # define BeginDocument \"BeginDocument:\" # define BeginXMPPacket \"begin=\" # define EndXMPPacket \"end=\" # define ICCProfile \"BeginICCProfile:\" # define CMYKCustomColor \"CMYKCustomColor:\" # define CMYKProcessColor \"CMYKProcessColor:\" # define DocumentMedia \"DocumentMedia:\" # define DocumentCustomColors \"DocumentCustomColors:\" # define DocumentProcessColors \"DocumentProcessColors:\" # define EndDocument \"EndDocument:\" # define HiResBoundingBox \"HiResBoundingBox:\" # define ImageData \"ImageData:\" # define PageBoundingBox \"PageBoundingBox:\" # define LanguageLevel \"LanguageLevel:\" # define PageMedia \"PageMedia:\" # define Pages \"Pages:\" # define PhotoshopProfile \"BeginPhotoshop:\" # define PostscriptLevel \"!PS-\" # define RenderPostscriptText \"RenderingPostscript...\" # define SpotColor \"+\" char command [ MaxTextExtent ] , * density , filename [ MaxTextExtent ] , geometry [ MaxTextExtent ] , input_filename [ MaxTextExtent ] , message [ MaxTextExtent ] , * options , postscript_filename [ MaxTextExtent ] ; const char * option ; const DelegateInfo * delegate_info ; GeometryInfo geometry_info ; Image * image , * next , * postscript_image ; ImageInfo * read_info ; int c , file ; MagickBooleanType cmyk , fitPage , skip , status ; MagickStatusType flags ; PointInfo delta , resolution ; RectangleInfo page ; register char * p ; register ssize_t i ; SegmentInfo bounds , hires_bounds ; short int hex_digits [ 256 ] ; size_t length , priority ; ssize_t count ; StringInfo * profile ; unsigned long columns , extent , language_level , pages , rows , scene , spotcolor ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } status = AcquireUniqueSymbolicLink ( image_info -> filename , input_filename ) ; if ( status == MagickFalse ) { ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( hex_digits , 0 , sizeof ( hex_digits ) ) ; hex_digits [ ( int ) '0' ] = 0 ; hex_digits [ ( int ) '1' ] = 1 ; hex_digits [ ( int ) '2' ] = 2 ; hex_digits [ ( int ) '3' ] = 3 ; hex_digits [ ( int ) '4' ] = 4 ; hex_digits [ ( int ) '5' ] = 5 ; hex_digits [ ( int ) '6' ] = 6 ; hex_digits [ ( int ) '7' ] = 7 ; hex_digits [ ( int ) '8' ] = 8 ; hex_digits [ ( int ) '9' ] = 9 ; hex_digits [ ( int ) 'a' ] = 10 ; hex_digits [ ( int ) 'b' ] = 11 ; hex_digits [ ( int ) 'c' ] = 12 ; hex_digits [ ( int ) 'd' ] = 13 ; hex_digits [ ( int ) 'e' ] = 14 ; hex_digits [ ( int ) 'f' ] = 15 ; hex_digits [ ( int ) 'A' ] = 10 ; hex_digits [ ( int ) 'B' ] = 11 ; hex_digits [ ( int ) 'C' ] = 12 ; hex_digits [ ( int ) 'D' ] = 13 ; hex_digits [ ( int ) 'E' ] = 14 ; hex_digits [ ( int ) 'F' ] = 15 ; delta . x = DefaultResolution ; delta . y = DefaultResolution ; if ( ( image -> x_resolution == 0.0 ) || ( image -> y_resolution == 0.0 ) ) { flags = ParseGeometry ( PSDensityGeometry , & geometry_info ) ; image -> x_resolution = geometry_info . rho ; image -> y_resolution = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> y_resolution = image -> x_resolution ; } if ( image_info -> density != ( char * ) NULL ) { flags = ParseGeometry ( image_info -> density , & geometry_info ) ; image -> x_resolution = geometry_info . rho ; image -> y_resolution = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> y_resolution = image -> x_resolution ; } ( void ) ParseAbsoluteGeometry ( PSPageGeometry , & page ) ; if ( image_info -> page != ( char * ) NULL ) ( void ) ParseAbsoluteGeometry ( image_info -> page , & page ) ; resolution . x = image -> x_resolution ; resolution . y = image -> y_resolution ; page . width = ( size_t ) ceil ( ( double ) ( page . width * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * resolution . y / delta . y ) - 0.5 ) ; ( void ) memset ( & bounds , 0 , sizeof ( bounds ) ) ; ( void ) memset ( command , 0 , sizeof ( command ) ) ; cmyk = image_info -> colorspace == CMYKColorspace ? MagickTrue : MagickFalse ; ( void ) memset ( & hires_bounds , 0 , sizeof ( hires_bounds ) ) ; priority = 0 ; columns = 0 ; rows = 0 ; extent = 0 ; spotcolor = 0 ; language_level = 1 ; skip = MagickFalse ; pages = ( ~ 0UL ) ; p = command ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( PostscriptLevel , command , strlen ( PostscriptLevel ) ) == 0 ) { ( void ) SetImageProperty ( image , \"ps:Level\" , command + 4 ) ; if ( GlobExpression ( command , \"*EPSF-*\" , MagickTrue ) != MagickFalse ) pages = 1 ; } if ( LocaleNCompare ( LanguageLevel , command , strlen ( LanguageLevel ) ) == 0 ) ( void ) sscanf ( command , LanguageLevel \"%lu\" , & language_level ) ; if ( LocaleNCompare ( Pages , command , strlen ( Pages ) ) == 0 ) ( void ) sscanf ( command , Pages \"%lu\" , & pages ) ; if ( LocaleNCompare ( ImageData , command , strlen ( ImageData ) ) == 0 ) ( void ) sscanf ( command , ImageData \"%lu%lu\" , & columns , & rows ) ; length = strlen ( DocumentProcessColors ) ; if ( LocaleNCompare ( DocumentProcessColors , command , length ) == 0 ) { if ( ( GlobExpression ( command , \"*Cyan*\" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , \"*Magenta*\" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , \"*Yellow*\" , MagickTrue ) != MagickFalse ) ) cmyk = MagickTrue ; } if ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) cmyk = MagickTrue ; if ( LocaleNCompare ( CMYKProcessColor , command , strlen ( CMYKProcessColor ) ) == 0 ) cmyk = MagickTrue ; length = strlen ( DocumentCustomColors ) ; if ( ( LocaleNCompare ( DocumentCustomColors , command , length ) == 0 ) || ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) || ( LocaleNCompare ( SpotColor , command , strlen ( SpotColor ) ) == 0 ) ) { char property [ MaxTextExtent ] , * value ; register char * p ; ( void ) FormatLocaleString ( property , MaxTextExtent , \"ps:SpotColor-%.20g\" , ( double ) ( spotcolor ++ ) ) ; for ( p = command ; * p != '\\\\0' ; p ++ ) if ( isspace ( ( int ) ( unsigned char ) * p ) != 0 ) break ; value = ConstantString ( p ) ; ( void ) SubstituteString ( & value , \"(\" , \"\" ) ; ( void ) SubstituteString ( & value , \")\" , \"\" ) ; ( void ) StripString ( value ) ; if ( * value != '\\\\0' ) ( void ) SetImageProperty ( image , property , value ) ; value = DestroyString ( value ) ; continue ; } if ( image_info -> page != ( char * ) NULL ) continue ; count = 0 ; i = 0 ; if ( LocaleNCompare ( BoundingBox , command , strlen ( BoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , BoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 2 ; } if ( LocaleNCompare ( DocumentMedia , command , strlen ( DocumentMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , DocumentMedia \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( HiResBoundingBox , command , strlen ( HiResBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , HiResBoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 3 ; } if ( LocaleNCompare ( PageBoundingBox , command , strlen ( PageBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageBoundingBox \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( PageMedia , command , strlen ( PageMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageMedia \"%lf%lf%lf%lf\" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( ( count != 4 ) || ( i < ( ssize_t ) priority ) ) continue ; if ( ( fabs ( bounds . x2 - bounds . x1 ) <= fabs ( hires_bounds . x2 - hires_bounds . x1 ) ) || ( fabs ( bounds . y2 - bounds . y1 ) <= fabs ( hires_bounds . y2 - hires_bounds . y1 ) ) ) if ( i == ( ssize_t ) priority ) continue ; hires_bounds = bounds ; priority = ( size_t ) i ; } if ( ( fabs ( hires_bounds . x2 - hires_bounds . x1 ) >= MagickEpsilon ) && ( fabs ( hires_bounds . y2 - hires_bounds . y1 ) >= MagickEpsilon ) ) { ( void ) FormatLocaleString ( geometry , MaxTextExtent , \"%gx%g%+.15g%+.15g\" , hires_bounds . x2 - hires_bounds . x1 , hires_bounds . y2 - hires_bounds . y1 , hires_bounds . x1 , hires_bounds . y1 ) ; ( void ) SetImageProperty ( image , \"ps:HiResBoundingBox\" , geometry ) ; page . width = ( size_t ) ceil ( ( double ) ( ( hires_bounds . x2 - hires_bounds . x1 ) * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( ( hires_bounds . y2 - hires_bounds . y1 ) * resolution . y / delta . y ) - 0.5 ) ; } fitPage = MagickFalse ; option = GetImageOption ( image_info , \"eps:fit-page\" ) ; if ( option != ( char * ) NULL ) { char * geometry ; MagickStatusType flags ; geometry = GetPageGeometry ( option ) ; flags = ParseMetaGeometry ( geometry , & page . x , & page . y , & page . width , & page . height ) ; if ( flags == NoValue ) { ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , OptionError , \"InvalidGeometry\" , \"`%s\\'\" , option ) ; image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } page . width = ( size_t ) ceil ( ( double ) ( page . width * image -> x_resolution / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * image -> y_resolution / delta . y ) - 0.5 ) ; geometry = DestroyString ( geometry ) ; fitPage = MagickTrue ; } if ( IssRGBCompatibleColorspace ( image_info -> colorspace ) != MagickFalse ) cmyk = MagickFalse ; file = AcquireUniqueFileResource ( postscript_filename ) ; if ( file == - 1 ) { ThrowFileException ( & image -> exception , FileOpenError , \"UnableToOpenFile\" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) CopyMagickString ( command , \"/setpagedevice{pop}bind1indexwhere{\" \"dupwcheck{31rollput}{popdef}ifelse}{def}ifelse\\\\n\" \"<true>>setpagedevice\\\\n\" , MaxTextExtent ) ; count = write ( file , command , ( unsigned int ) strlen ( command ) ) ; if ( image_info -> page == ( char * ) NULL ) { char translate_geometry [ MaxTextExtent ] ; ( void ) FormatLocaleString ( translate_geometry , MaxTextExtent , \"%g%gtranslate\\\\n\" , - hires_bounds . x1 , - hires_bounds . y1 ) ; count = write ( file , translate_geometry , ( unsigned int ) strlen ( translate_geometry ) ) ; } file = close ( file ) - 1 ; if ( image_info -> monochrome != MagickFalse ) delegate_info = GetDelegateInfo ( \"ps:mono\" , ( char * ) NULL , exception ) ; else if ( cmyk != MagickFalse ) delegate_info = GetDelegateInfo ( \"ps:cmyk\" , ( char * ) NULL , exception ) ; else delegate_info = GetDelegateInfo ( \"ps:alpha\" , ( char * ) NULL , exception ) ; if ( delegate_info == ( const DelegateInfo * ) NULL ) { ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } density = AcquireString ( \"\" ) ; options = AcquireString ( \"\" ) ; ( void ) FormatLocaleString ( density , MaxTextExtent , \"%gx%g\" , resolution . x , resolution . y ) ; ( void ) FormatLocaleString ( options , MaxTextExtent , \"-g%.20gx%.20g\" , ( double ) page . width , ( double ) page . height ) ; read_info = CloneImageInfo ( image_info ) ; * read_info -> magick = '\\\\0' ; if ( read_info -> number_scenes != 0 ) { char pages [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pages , MaxTextExtent , \"-dFirstPage=%.20g\" \"-dLastPage=%.20g\" , ( double ) read_info -> scene + 1 , ( double ) ( read_info -> scene + read_info -> number_scenes ) ) ; ( void ) ConcatenateMagickString ( options , pages , MaxTextExtent ) ; read_info -> number_scenes = 0 ; if ( read_info -> scenes != ( char * ) NULL ) * read_info -> scenes = '\\\\0' ; } if ( * image_info -> magick == 'E' ) { option = GetImageOption ( image_info , \"eps:use-cropbox\" ) ; if ( ( option == ( const char * ) NULL ) || ( IsStringTrue ( option ) != MagickFalse ) ) ( void ) ConcatenateMagickString ( options , \"-dEPSCrop\" , MaxTextExtent ) ; if ( fitPage != MagickFalse ) ( void ) ConcatenateMagickString ( options , \"-dEPSFitPage\" , MaxTextExtent ) ; } ( void ) CopyMagickString ( filename , read_info -> filename , MaxTextExtent ) ; ( void ) AcquireUniqueFilename ( filename ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; ( void ) ConcatenateMagickString ( filename , \"%d\" , MaxTextExtent ) ; ( void ) FormatLocaleString ( command , MaxTextExtent , GetDelegateCommands ( delegate_info ) , read_info -> antialias != MagickFalse ? 4 : 1 , read_info -> antialias != MagickFalse ? 4 : 1 , density , options , filename , postscript_filename , input_filename ) ; options = DestroyString ( options ) ; density = DestroyString ( density ) ; * message = '\\\\0' ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; ( void ) InterpretImageFilename ( image_info , image , filename , 1 , read_info -> filename ) ; if ( ( status == MagickFalse ) || ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) ) { ( void ) ConcatenateMagickString ( command , \"-cshowpage\" , MaxTextExtent ) ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; } ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; ( void ) RelinquishUniqueFileResource ( input_filename ) ; postscript_image = ( Image * ) NULL ; if ( status == MagickFalse ) for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; } else for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; read_info -> blob = NULL ; read_info -> length = 0 ; next = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; if ( next == ( Image * ) NULL ) break ; AppendImageToList ( & postscript_image , next ) ; } ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( postscript_image == ( Image * ) NULL ) { if ( * message != '\\\\0' ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , DelegateError , \"PostscriptDelegateFailed\" , \"`%s\\'\" , message ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( LocaleCompare ( postscript_image -> magick , \"BMP\" ) == 0 ) { Image * cmyk_image ; cmyk_image = ConsolidateCMYKImages ( postscript_image , exception ) ; if ( cmyk_image != ( Image * ) NULL ) { postscript_image = DestroyImageList ( postscript_image ) ; postscript_image = cmyk_image ; } } ( void ) SeekBlob ( image , 0 , SEEK_SET ) ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( PostscriptLevel , command , strlen ( PostscriptLevel ) ) == 0 ) { ( void ) SetImageProperty ( image , \"ps:Level\" , command + 4 ) ; if ( GlobExpression ( command , \"*EPSF-*\" , MagickTrue ) != MagickFalse ) pages = 1 ; } if ( LocaleNCompare ( LanguageLevel , command , strlen ( LanguageLevel ) ) == 0 ) ( void ) sscanf ( command , LanguageLevel \"%lu\" , & language_level ) ; if ( LocaleNCompare ( Pages , command , strlen ( Pages ) ) == 0 ) ( void ) sscanf ( command , Pages \"%lu\" , & pages ) ; if ( LocaleNCompare ( ImageData , command , strlen ( ImageData ) ) == 0 ) ( void ) sscanf ( command , ImageData \"%lu%lu\" , & columns , & rows ) ; if ( LocaleNCompare ( ICCProfile , command , strlen ( ICCProfile ) ) == 0 ) { unsigned char * datum ; profile = AcquireStringInfo ( MaxTextExtent ) ; datum = GetStringInfoDatum ( profile ) ; for ( i = 0 ; ( c = ProfileInteger ( image , hex_digits ) ) != EOF ; i ++ ) { if ( i >= ( ssize_t ) GetStringInfoLength ( profile ) ) { SetStringInfoLength ( profile , ( size_t ) i << 1 ) ; datum = GetStringInfoDatum ( profile ) ; } datum [ i ] = ( unsigned char ) c ; } SetStringInfoLength ( profile , ( size_t ) i + 1 ) ; ( void ) SetImageProfile ( image , \"icc\" , profile ) ; profile = DestroyStringInfo ( profile ) ; continue ; } if ( LocaleNCompare ( PhotoshopProfile , command , strlen ( PhotoshopProfile ) ) == 0 ) { unsigned char * p ; count = ( ssize_t ) sscanf ( command , PhotoshopProfile \"%lu\" , & extent ) ; if ( count != 1 ) continue ; length = extent ; if ( ( MagickSizeType ) length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; if ( profile != ( StringInfo * ) NULL ) { p = GetStringInfoDatum ( profile ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) * p ++ = ( unsigned char ) ProfileInteger ( image , hex_digits ) ; ( void ) SetImageProfile ( image , \"8bim\" , profile ) ; profile = DestroyStringInfo ( profile ) ; } continue ; } if ( LocaleNCompare ( BeginXMPPacket , command , strlen ( BeginXMPPacket ) ) == 0 ) { register size_t i ; p = command ; profile = StringToStringInfo ( command ) ; for ( i = GetStringInfoLength ( profile ) - 1 ; c != EOF ; i ++ ) { SetStringInfoLength ( profile , ( size_t ) ( i + 1 ) ) ; c = ReadBlobByte ( image ) ; GetStringInfoDatum ( profile ) [ i ] = ( unsigned char ) c ; * p ++ = ( char ) c ; if ( ( strchr ( \"\\\\n\\\\r%\" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MaxTextExtent - 1 ) ) ) continue ; * p = '\\\\0' ; p = command ; if ( LocaleNCompare ( EndXMPPacket , command , strlen ( EndXMPPacket ) ) == 0 ) break ; } SetStringInfoLength ( profile , ( size_t ) i ) ; ( void ) SetImageProfile ( image , \"xmp\" , profile ) ; profile = DestroyStringInfo ( profile ) ; continue ; } } ( void ) CloseBlob ( image ) ; if ( image_info -> number_scenes != 0 ) { Image * clone_image ; register ssize_t i ; for ( i = 0 ; i < ( ssize_t ) image_info -> scene ; i ++ ) { clone_image = CloneImage ( postscript_image , 1 , 1 , MagickTrue , exception ) ; if ( clone_image != ( Image * ) NULL ) PrependImageToList ( & postscript_image , clone_image ) ; } } do { ( void ) CopyMagickString ( postscript_image -> filename , filename , MaxTextExtent ) ; ( void ) CopyMagickString ( postscript_image -> magick , image -> magick , MaxTextExtent ) ; if ( columns != 0 ) postscript_image -> magick_columns = columns ; if ( rows != 0 ) postscript_image -> magick_rows = rows ; postscript_image -> page = page ; ( void ) CloneImageProfiles ( postscript_image , image ) ; ( void ) CloneImageProperties ( postscript_image , image ) ; next = SyncNextImageInList ( postscript_image ) ; if ( next != ( Image * ) NULL ) postscript_image = next ; } while ( next != ( Image * ) NULL ) ; image = DestroyImageList ( image ) ; scene = 0 ; for ( next = GetFirstImageInList ( postscript_image ) ; next != ( Image * ) NULL ; ) { next -> scene = scene ++ ; next = GetNextImageInList ( next ) ; } return ( GetFirstImageInList ( postscript_image ) ) ; }\n", "\n", "\n", "Target: 0 ) { mutex_lock ( & kvm -> lock ) ; list_del ( & dev -> vm_node ) ; mutex_unlock ( & kvm -> lock ) ; destroy ( dev ) ; return\n", "\n", "Sources:\n", "0: CWE-264 static int kvm_ioctl_create_device ( struct kvm * kvm , struct kvm_create_device * cd ) { struct kvm_device_ops * ops = NULL ; struct kvm_device * dev ; bool test = cd -> flags & KVM_CREATE_DEVICE_TEST ; int ret ; if ( cd -> type >= ARRAY_SIZE ( kvm_device_ops_table ) ) return - ENODEV ; ops = kvm_device_ops_table [ cd -> type ] ; if ( ops == NULL ) return - ENODEV ; if ( test ) return 0 ; dev = kzalloc ( sizeof ( * dev ) , GFP_KERNEL ) ; if ( ! dev ) return - ENOMEM ; dev -> ops = ops ; dev -> kvm = kvm ; mutex_lock ( & kvm -> lock ) ; ret = ops -> create ( dev , cd -> type ) ; if ( ret < 0 ) { mutex_unlock ( & kvm -> lock ) ; kfree ( dev ) ; return ret ; } list_add ( & dev -> vm_node , & kvm -> devices ) ; mutex_unlock ( & kvm -> lock ) ; if ( ops -> init ) ops -> init ( dev ) ; ret = anon_inode_getfd ( ops -> name , & kvm_device_fops , dev , O_RDWR | O_CLOEXEC ) ; if ( ret < 0 ) { ops -> destroy ( dev ) ; mutex_lock ( & kvm -> lock ) ; list_del ( & dev -> vm_node ) ; mutex_unlock ( & kvm -> lock ) ; return ret ; } kvm_get_kvm ( kvm ) ; cd -> fd = ret ; return 0 ; }\n", "\n", "1: CWE-416 static int kvm_ioctl_create_device ( struct kvm * kvm , struct kvm_create_device * cd ) { struct kvm_device_ops * ops = NULL ; struct kvm_device * dev ; bool test = cd -> flags & KVM_CREATE_DEVICE_TEST ; int ret ; if ( cd -> type >= ARRAY_SIZE ( kvm_device_ops_table ) ) return - ENODEV ; ops = kvm_device_ops_table [ cd -> type ] ; if ( ops == NULL ) return - ENODEV ; if ( test ) return 0 ; dev = kzalloc ( sizeof ( * dev ) , GFP_KERNEL ) ; if ( ! dev ) return - ENOMEM ; dev -> ops = ops ; dev -> kvm = kvm ; mutex_lock ( & kvm -> lock ) ; ret = ops -> create ( dev , cd -> type ) ; if ( ret < 0 ) { mutex_unlock ( & kvm -> lock ) ; kfree ( dev ) ; return ret ; } list_add ( & dev -> vm_node , & kvm -> devices ) ; mutex_unlock ( & kvm -> lock ) ; if ( ops -> init ) ops -> init ( dev ) ; ret = anon_inode_getfd ( ops -> name , & kvm_device_fops , dev , O_RDWR | O_CLOEXEC ) ; if ( ret < 0 ) { ops -> destroy ( dev ) ; mutex_lock ( & kvm -> lock ) ; list_del ( & dev -> vm_node ) ; mutex_unlock ( & kvm -> lock ) ; return ret ; } kvm_get_kvm ( kvm ) ; cd -> fd = ret ; return 0 ; }\n", "\n", "\n", "Target: crypto_report_acomp racomp ; strncpy ( racomp .\n", "\n", "Sources:\n", "0: CWE-200 static int crypto_report_acomp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_acomp racomp ; strlcpy ( racomp . type , \"acomp\" , sizeof ( racomp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_ACOMP , sizeof ( struct crypto_report_acomp ) , & racomp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "1: CWE-000 static int crypto_report_acomp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_acomp racomp ; strlcpy ( racomp . type , \"acomp\" , sizeof ( racomp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_ACOMP , sizeof ( struct crypto_report_acomp ) , & racomp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "\n", "Target: ; if ( rpx >= 31 || ( ( comp -> dx << rpx ) >> rpx ) != comp -> dx || rpy >= 31 || ( ( comp -> dy << rpy ) >> rpy ) != comp -> dy ) { continue ; } if (\n", "\n", "Sources:\n", "0: CWE-369 static OPJ_BOOL opj_pi_next_rpcl ( opj_pi_iterator_t * pi ) { opj_pi_comp_t * comp = NULL ; opj_pi_resolution_t * res = NULL ; OPJ_UINT32 index = 0 ; if ( ! pi -> first ) { goto LABEL_SKIP ; } else { OPJ_UINT32 compno , resno ; pi -> first = 0 ; pi -> dx = 0 ; pi -> dy = 0 ; for ( compno = 0 ; compno < pi -> numcomps ; compno ++ ) { comp = & pi -> comps [ compno ] ; for ( resno = 0 ; resno < comp -> numresolutions ; resno ++ ) { OPJ_UINT32 dx , dy ; res = & comp -> resolutions [ resno ] ; dx = comp -> dx * ( 1u << ( res -> pdx + comp -> numresolutions - 1 - resno ) ) ; dy = comp -> dy * ( 1u << ( res -> pdy + comp -> numresolutions - 1 - resno ) ) ; pi -> dx = ! pi -> dx ? dx : opj_uint_min ( pi -> dx , dx ) ; pi -> dy = ! pi -> dy ? dy : opj_uint_min ( pi -> dy , dy ) ; } } } if ( ! pi -> tp_on ) { pi -> poc . ty0 = pi -> ty0 ; pi -> poc . tx0 = pi -> tx0 ; pi -> poc . ty1 = pi -> ty1 ; pi -> poc . tx1 = pi -> tx1 ; } for ( pi -> resno = pi -> poc . resno0 ; pi -> resno < pi -> poc . resno1 ; pi -> resno ++ ) { for ( pi -> y = pi -> poc . ty0 ; pi -> y < pi -> poc . ty1 ; pi -> y += ( OPJ_INT32 ) ( pi -> dy - ( OPJ_UINT32 ) ( pi -> y % ( OPJ_INT32 ) pi -> dy ) ) ) { for ( pi -> x = pi -> poc . tx0 ; pi -> x < pi -> poc . tx1 ; pi -> x += ( OPJ_INT32 ) ( pi -> dx - ( OPJ_UINT32 ) ( pi -> x % ( OPJ_INT32 ) pi -> dx ) ) ) { for ( pi -> compno = pi -> poc . compno0 ; pi -> compno < pi -> poc . compno1 ; pi -> compno ++ ) { OPJ_UINT32 levelno ; OPJ_INT32 trx0 , try0 ; OPJ_INT32 trx1 , try1 ; OPJ_UINT32 rpx , rpy ; OPJ_INT32 prci , prcj ; comp = & pi -> comps [ pi -> compno ] ; if ( pi -> resno >= comp -> numresolutions ) { continue ; } res = & comp -> resolutions [ pi -> resno ] ; levelno = comp -> numresolutions - 1 - pi -> resno ; trx0 = opj_int_ceildiv ( pi -> tx0 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try0 = opj_int_ceildiv ( pi -> ty0 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; trx1 = opj_int_ceildiv ( pi -> tx1 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try1 = opj_int_ceildiv ( pi -> ty1 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; rpx = res -> pdx + levelno ; rpy = res -> pdy + levelno ; if ( ! ( ( pi -> y % ( OPJ_INT32 ) ( comp -> dy << rpy ) == 0 ) || ( ( pi -> y == pi -> ty0 ) && ( ( try0 << levelno ) % ( 1 << rpy ) ) ) ) ) { continue ; } if ( ! ( ( pi -> x % ( OPJ_INT32 ) ( comp -> dx << rpx ) == 0 ) || ( ( pi -> x == pi -> tx0 ) && ( ( trx0 << levelno ) % ( 1 << rpx ) ) ) ) ) { continue ; } if ( ( res -> pw == 0 ) || ( res -> ph == 0 ) ) { continue ; } if ( ( trx0 == trx1 ) || ( try0 == try1 ) ) { continue ; } prci = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> x , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) , ( OPJ_INT32 ) res -> pdx ) - opj_int_floordivpow2 ( trx0 , ( OPJ_INT32 ) res -> pdx ) ; prcj = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> y , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) , ( OPJ_INT32 ) res -> pdy ) - opj_int_floordivpow2 ( try0 , ( OPJ_INT32 ) res -> pdy ) ; pi -> precno = ( OPJ_UINT32 ) ( prci + prcj * ( OPJ_INT32 ) res -> pw ) ; for ( pi -> layno = pi -> poc . layno0 ; pi -> layno < pi -> poc . layno1 ; pi -> layno ++ ) { index = pi -> layno * pi -> step_l + pi -> resno * pi -> step_r + pi -> compno * pi -> step_c + pi -> precno * pi -> step_p ; if ( ! pi -> include [ index ] ) { pi -> include [ index ] = 1 ; return OPJ_TRUE ; } LABEL_SKIP : ; } } } } } return OPJ_FALSE ; }\n", "\n", "1: CWE-369 static OPJ_BOOL opj_pi_next_cprl ( opj_pi_iterator_t * pi ) { opj_pi_comp_t * comp = NULL ; opj_pi_resolution_t * res = NULL ; OPJ_UINT32 index = 0 ; if ( ! pi -> first ) { comp = & pi -> comps [ pi -> compno ] ; goto LABEL_SKIP ; } else { pi -> first = 0 ; } for ( pi -> compno = pi -> poc . compno0 ; pi -> compno < pi -> poc . compno1 ; pi -> compno ++ ) { OPJ_UINT32 resno ; comp = & pi -> comps [ pi -> compno ] ; pi -> dx = 0 ; pi -> dy = 0 ; for ( resno = 0 ; resno < comp -> numresolutions ; resno ++ ) { OPJ_UINT32 dx , dy ; res = & comp -> resolutions [ resno ] ; dx = comp -> dx * ( 1u << ( res -> pdx + comp -> numresolutions - 1 - resno ) ) ; dy = comp -> dy * ( 1u << ( res -> pdy + comp -> numresolutions - 1 - resno ) ) ; pi -> dx = ! pi -> dx ? dx : opj_uint_min ( pi -> dx , dx ) ; pi -> dy = ! pi -> dy ? dy : opj_uint_min ( pi -> dy , dy ) ; } if ( ! pi -> tp_on ) { pi -> poc . ty0 = pi -> ty0 ; pi -> poc . tx0 = pi -> tx0 ; pi -> poc . ty1 = pi -> ty1 ; pi -> poc . tx1 = pi -> tx1 ; } for ( pi -> y = pi -> poc . ty0 ; pi -> y < pi -> poc . ty1 ; pi -> y += ( OPJ_INT32 ) ( pi -> dy - ( OPJ_UINT32 ) ( pi -> y % ( OPJ_INT32 ) pi -> dy ) ) ) { for ( pi -> x = pi -> poc . tx0 ; pi -> x < pi -> poc . tx1 ; pi -> x += ( OPJ_INT32 ) ( pi -> dx - ( OPJ_UINT32 ) ( pi -> x % ( OPJ_INT32 ) pi -> dx ) ) ) { for ( pi -> resno = pi -> poc . resno0 ; pi -> resno < opj_uint_min ( pi -> poc . resno1 , comp -> numresolutions ) ; pi -> resno ++ ) { OPJ_UINT32 levelno ; OPJ_INT32 trx0 , try0 ; OPJ_INT32 trx1 , try1 ; OPJ_UINT32 rpx , rpy ; OPJ_INT32 prci , prcj ; res = & comp -> resolutions [ pi -> resno ] ; levelno = comp -> numresolutions - 1 - pi -> resno ; trx0 = opj_int_ceildiv ( pi -> tx0 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try0 = opj_int_ceildiv ( pi -> ty0 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; trx1 = opj_int_ceildiv ( pi -> tx1 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try1 = opj_int_ceildiv ( pi -> ty1 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; rpx = res -> pdx + levelno ; rpy = res -> pdy + levelno ; if ( ! ( ( pi -> y % ( OPJ_INT32 ) ( comp -> dy << rpy ) == 0 ) || ( ( pi -> y == pi -> ty0 ) && ( ( try0 << levelno ) % ( 1 << rpy ) ) ) ) ) { continue ; } if ( ! ( ( pi -> x % ( OPJ_INT32 ) ( comp -> dx << rpx ) == 0 ) || ( ( pi -> x == pi -> tx0 ) && ( ( trx0 << levelno ) % ( 1 << rpx ) ) ) ) ) { continue ; } if ( ( res -> pw == 0 ) || ( res -> ph == 0 ) ) { continue ; } if ( ( trx0 == trx1 ) || ( try0 == try1 ) ) { continue ; } prci = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> x , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) , ( OPJ_INT32 ) res -> pdx ) - opj_int_floordivpow2 ( trx0 , ( OPJ_INT32 ) res -> pdx ) ; prcj = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> y , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) , ( OPJ_INT32 ) res -> pdy ) - opj_int_floordivpow2 ( try0 , ( OPJ_INT32 ) res -> pdy ) ; pi -> precno = ( OPJ_UINT32 ) ( prci + prcj * ( OPJ_INT32 ) res -> pw ) ; for ( pi -> layno = pi -> poc . layno0 ; pi -> layno < pi -> poc . layno1 ; pi -> layno ++ ) { index = pi -> layno * pi -> step_l + pi -> resno * pi -> step_r + pi -> compno * pi -> step_c + pi -> precno * pi -> step_p ; if ( ! pi -> include [ index ] ) { pi -> include [ index ] = 1 ; return OPJ_TRUE ; } LABEL_SKIP : ; } } } } } return OPJ_FALSE ; }\n", "\n", "2: CWE-369 static OPJ_BOOL opj_pi_next_pcrl ( opj_pi_iterator_t * pi ) { opj_pi_comp_t * comp = NULL ; opj_pi_resolution_t * res = NULL ; OPJ_UINT32 index = 0 ; if ( ! pi -> first ) { comp = & pi -> comps [ pi -> compno ] ; goto LABEL_SKIP ; } else { OPJ_UINT32 compno , resno ; pi -> first = 0 ; pi -> dx = 0 ; pi -> dy = 0 ; for ( compno = 0 ; compno < pi -> numcomps ; compno ++ ) { comp = & pi -> comps [ compno ] ; for ( resno = 0 ; resno < comp -> numresolutions ; resno ++ ) { OPJ_UINT32 dx , dy ; res = & comp -> resolutions [ resno ] ; dx = comp -> dx * ( 1u << ( res -> pdx + comp -> numresolutions - 1 - resno ) ) ; dy = comp -> dy * ( 1u << ( res -> pdy + comp -> numresolutions - 1 - resno ) ) ; pi -> dx = ! pi -> dx ? dx : opj_uint_min ( pi -> dx , dx ) ; pi -> dy = ! pi -> dy ? dy : opj_uint_min ( pi -> dy , dy ) ; } } } if ( ! pi -> tp_on ) { pi -> poc . ty0 = pi -> ty0 ; pi -> poc . tx0 = pi -> tx0 ; pi -> poc . ty1 = pi -> ty1 ; pi -> poc . tx1 = pi -> tx1 ; } for ( pi -> y = pi -> poc . ty0 ; pi -> y < pi -> poc . ty1 ; pi -> y += ( OPJ_INT32 ) ( pi -> dy - ( OPJ_UINT32 ) ( pi -> y % ( OPJ_INT32 ) pi -> dy ) ) ) { for ( pi -> x = pi -> poc . tx0 ; pi -> x < pi -> poc . tx1 ; pi -> x += ( OPJ_INT32 ) ( pi -> dx - ( OPJ_UINT32 ) ( pi -> x % ( OPJ_INT32 ) pi -> dx ) ) ) { for ( pi -> compno = pi -> poc . compno0 ; pi -> compno < pi -> poc . compno1 ; pi -> compno ++ ) { comp = & pi -> comps [ pi -> compno ] ; for ( pi -> resno = pi -> poc . resno0 ; pi -> resno < opj_uint_min ( pi -> poc . resno1 , comp -> numresolutions ) ; pi -> resno ++ ) { OPJ_UINT32 levelno ; OPJ_INT32 trx0 , try0 ; OPJ_INT32 trx1 , try1 ; OPJ_UINT32 rpx , rpy ; OPJ_INT32 prci , prcj ; res = & comp -> resolutions [ pi -> resno ] ; levelno = comp -> numresolutions - 1 - pi -> resno ; trx0 = opj_int_ceildiv ( pi -> tx0 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try0 = opj_int_ceildiv ( pi -> ty0 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; trx1 = opj_int_ceildiv ( pi -> tx1 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try1 = opj_int_ceildiv ( pi -> ty1 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; rpx = res -> pdx + levelno ; rpy = res -> pdy + levelno ; if ( ! ( ( pi -> y % ( OPJ_INT32 ) ( comp -> dy << rpy ) == 0 ) || ( ( pi -> y == pi -> ty0 ) && ( ( try0 << levelno ) % ( 1 << rpy ) ) ) ) ) { continue ; } if ( ! ( ( pi -> x % ( OPJ_INT32 ) ( comp -> dx << rpx ) == 0 ) || ( ( pi -> x == pi -> tx0 ) && ( ( trx0 << levelno ) % ( 1 << rpx ) ) ) ) ) { continue ; } if ( ( res -> pw == 0 ) || ( res -> ph == 0 ) ) { continue ; } if ( ( trx0 == trx1 ) || ( try0 == try1 ) ) { continue ; } prci = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> x , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) , ( OPJ_INT32 ) res -> pdx ) - opj_int_floordivpow2 ( trx0 , ( OPJ_INT32 ) res -> pdx ) ; prcj = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> y , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) , ( OPJ_INT32 ) res -> pdy ) - opj_int_floordivpow2 ( try0 , ( OPJ_INT32 ) res -> pdy ) ; pi -> precno = ( OPJ_UINT32 ) ( prci + prcj * ( OPJ_INT32 ) res -> pw ) ; for ( pi -> layno = pi -> poc . layno0 ; pi -> layno < pi -> poc . layno1 ; pi -> layno ++ ) { index = pi -> layno * pi -> step_l + pi -> resno * pi -> step_r + pi -> compno * pi -> step_c + pi -> precno * pi -> step_p ; if ( ! pi -> include [ index ] ) { pi -> include [ index ] = 1 ; return OPJ_TRUE ; } LABEL_SKIP : ; } } } } } return OPJ_FALSE ; }\n", "\n", "\n", "Target: 1 ) ; if ( ! , ibuf ) ) { if ( ret == 0 ) ret = - EFAULT ; break ; } obuf = opipe\n", "\n", "Sources:\n", "0: CWE-416 static int link_pipe ( struct pipe_inode_info * ipipe , struct pipe_inode_info * opipe , size_t len , unsigned int flags ) { struct pipe_buffer * ibuf , * obuf ; int ret = 0 , i = 0 , nbuf ; pipe_double_lock ( ipipe , opipe ) ; do { if ( ! opipe -> readers ) { send_sig ( SIGPIPE , current , 0 ) ; if ( ! ret ) ret = - EPIPE ; break ; } if ( i >= ipipe -> nrbufs || opipe -> nrbufs >= opipe -> buffers ) break ; ibuf = ipipe -> bufs + ( ( ipipe -> curbuf + i ) & ( ipipe -> buffers - 1 ) ) ; nbuf = ( opipe -> curbuf + opipe -> nrbufs ) & ( opipe -> buffers - 1 ) ; pipe_buf_get ( ipipe , ibuf ) ; obuf = opipe -> bufs + nbuf ; * obuf = * ibuf ; obuf -> flags &= ~ PIPE_BUF_FLAG_GIFT ; if ( obuf -> len > len ) obuf -> len = len ; opipe -> nrbufs ++ ; ret += obuf -> len ; len -= obuf -> len ; i ++ ; } while ( len ) ; if ( ! ret && ipipe -> waiting_writers && ( flags & SPLICE_F_NONBLOCK ) ) ret = - EAGAIN ; pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; if ( ret > 0 ) wakeup_pipe_readers ( opipe ) ; return ret ; }\n", "\n", "1: CWE-416 static int link_pipe ( struct pipe_inode_info * ipipe , struct pipe_inode_info * opipe , size_t len , unsigned int flags ) { struct pipe_buffer * ibuf , * obuf ; int ret = 0 , i = 0 , nbuf ; pipe_double_lock ( ipipe , opipe ) ; do { if ( ! opipe -> readers ) { send_sig ( SIGPIPE , current , 0 ) ; if ( ! ret ) ret = - EPIPE ; break ; } if ( i >= ipipe -> nrbufs || opipe -> nrbufs >= opipe -> buffers ) break ; ibuf = ipipe -> bufs + ( ( ipipe -> curbuf + i ) & ( ipipe -> buffers - 1 ) ) ; nbuf = ( opipe -> curbuf + opipe -> nrbufs ) & ( opipe -> buffers - 1 ) ; pipe_buf_get ( ipipe , ibuf ) ; obuf = opipe -> bufs + nbuf ; * obuf = * ibuf ; obuf -> flags &= ~ PIPE_BUF_FLAG_GIFT ; pipe_buf_mark_unmergeable ( obuf ) ; if ( obuf -> len > len ) obuf -> len = len ; opipe -> nrbufs ++ ; ret += obuf -> len ; len -= obuf -> len ; i ++ ; } while ( len ) ; if ( ! ret && ipipe -> waiting_writers && ( flags & SPLICE_F_NONBLOCK ) ) ret = - EAGAIN ; pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; if ( ret > 0 ) wakeup_pipe_readers ( opipe ) ; return ret ; }\n", "\n", "\n", "Target: RelinquishMagickMemory ( sixel_buffer ) ; sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels\n", "\n", "Sources:\n", "0: CWE-399 static Image * ReadSIXELImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char * sixel_buffer ; Image * image ; MagickBooleanType status ; register char * p ; register ssize_t x ; register Quantum * q ; size_t length ; ssize_t i , j , y ; unsigned char * sixel_pixels , * sixel_palette ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = MagickPathExtent ; sixel_buffer = ( char * ) AcquireQuantumMemory ( ( size_t ) length + MagickPathExtent , sizeof ( * sixel_buffer ) ) ; p = sixel_buffer ; if ( sixel_buffer != ( char * ) NULL ) while ( ReadBlobString ( image , p ) != ( char * ) NULL ) { if ( ( * p == '#' ) && ( ( p == sixel_buffer ) || ( * ( p - 1 ) == '\\\\n' ) ) ) continue ; if ( ( * p == '}' ) && ( * ( p + 1 ) == ';' ) ) break ; p += strlen ( p ) ; if ( ( size_t ) ( p - sixel_buffer + MagickPathExtent + 1 ) < length ) continue ; length <<= 1 ; sixel_buffer = ( char * ) ResizeQuantumMemory ( sixel_buffer , length + MagickPathExtent + 1 , sizeof ( * sixel_buffer ) ) ; if ( sixel_buffer == ( char * ) NULL ) break ; p = sixel_buffer + strlen ( sixel_buffer ) ; } if ( sixel_buffer == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; sixel_buffer [ length ] = '\\\\0' ; if ( sixel_decode ( image , ( unsigned char * ) sixel_buffer , & sixel_pixels , & image -> columns , & image -> rows , & sixel_palette , & image -> colors , exception ) == MagickFalse ) { sixel_buffer = ( char * ) RelinquishMagickMemory ( sixel_buffer ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } sixel_buffer = ( char * ) RelinquishMagickMemory ( sixel_buffer ) ; image -> depth = 24 ; image -> storage_class = PseudoClass ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; return ( DestroyImageList ( image ) ) ; } if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; ++ i ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( sixel_palette [ i * 4 + 0 ] ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( sixel_palette [ i * 4 + 1 ] ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( sixel_palette [ i * 4 + 2 ] ) ; } j = 0 ; if ( image_info -> ping == MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { j = ( ssize_t ) sixel_pixels [ y * image -> columns + x ] ; SetPixelIndex ( image , j , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( y < ( ssize_t ) image -> rows ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ThrowReaderException ( CorruptImageError , \"NotEnoughPixelData\" ) ; } } sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-401 static Image * ReadSIXELImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char * sixel_buffer ; Image * image ; MagickBooleanType status ; register char * p ; register ssize_t x ; register Quantum * q ; size_t length ; ssize_t i , j , y ; unsigned char * sixel_pixels , * sixel_palette ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = MagickPathExtent ; sixel_buffer = ( char * ) AcquireQuantumMemory ( ( size_t ) length + MagickPathExtent , sizeof ( * sixel_buffer ) ) ; p = sixel_buffer ; if ( sixel_buffer != ( char * ) NULL ) while ( ReadBlobString ( image , p ) != ( char * ) NULL ) { if ( ( * p == '#' ) && ( ( p == sixel_buffer ) || ( * ( p - 1 ) == '\\\\n' ) ) ) continue ; if ( ( * p == '}' ) && ( * ( p + 1 ) == ';' ) ) break ; p += strlen ( p ) ; if ( ( size_t ) ( p - sixel_buffer + MagickPathExtent + 1 ) < length ) continue ; length <<= 1 ; sixel_buffer = ( char * ) ResizeQuantumMemory ( sixel_buffer , length + MagickPathExtent + 1 , sizeof ( * sixel_buffer ) ) ; if ( sixel_buffer == ( char * ) NULL ) break ; p = sixel_buffer + strlen ( sixel_buffer ) ; } if ( sixel_buffer == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; sixel_buffer [ length ] = '\\\\0' ; if ( sixel_decode ( image , ( unsigned char * ) sixel_buffer , & sixel_pixels , & image -> columns , & image -> rows , & sixel_palette , & image -> colors , exception ) == MagickFalse ) { sixel_buffer = ( char * ) RelinquishMagickMemory ( sixel_buffer ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } sixel_buffer = ( char * ) RelinquishMagickMemory ( sixel_buffer ) ; image -> depth = 24 ; image -> storage_class = PseudoClass ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; return ( DestroyImageList ( image ) ) ; } if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } for ( i = 0 ; i < ( ssize_t ) image -> colors ; ++ i ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( sixel_palette [ i * 4 + 0 ] ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( sixel_palette [ i * 4 + 1 ] ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( sixel_palette [ i * 4 + 2 ] ) ; } j = 0 ; if ( image_info -> ping == MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { j = ( ssize_t ) sixel_pixels [ y * image -> columns + x ] ; SetPixelIndex ( image , j , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( y < ( ssize_t ) image -> rows ) { sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ThrowReaderException ( CorruptImageError , \"NotEnoughPixelData\" ) ; } } sixel_pixels = ( unsigned char * ) RelinquishMagickMemory ( sixel_pixels ) ; sixel_palette = ( unsigned char * ) RelinquishMagickMemory ( sixel_palette ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ) ; } if ( p_key ) rb_ivar_set ( self , id_key_set , Qtrue ) ;\n", "\n", "Sources:\n", "0: CWE-326 static VALUE ossl_cipher_init ( int argc , VALUE * argv , VALUE self , int mode ) { EVP_CIPHER_CTX * ctx ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , * p_key = NULL ; unsigned char iv [ EVP_MAX_IV_LENGTH ] , * p_iv = NULL ; VALUE pass , init_v ; if ( rb_scan_args ( argc , argv , \"02\" , & pass , & init_v ) > 0 ) { VALUE cname = rb_class_path ( rb_obj_class ( self ) ) ; rb_warn ( \"argumentsfor%\" PRIsVALUE \"#encryptand%\" PRIsVALUE \"#decryptweredeprecated;\" \"use%\" PRIsVALUE \"#pkcs5_keyivgentoderivekeyandIV\" , cname , cname , cname ) ; StringValue ( pass ) ; GetCipher ( self , ctx ) ; if ( NIL_P ( init_v ) ) memcpy ( iv , \"OpenSSLforRubyrulez!\" , sizeof ( iv ) ) ; else { StringValue ( init_v ) ; if ( EVP_MAX_IV_LENGTH > RSTRING_LEN ( init_v ) ) { memset ( iv , 0 , EVP_MAX_IV_LENGTH ) ; memcpy ( iv , RSTRING_PTR ( init_v ) , RSTRING_LEN ( init_v ) ) ; } else memcpy ( iv , RSTRING_PTR ( init_v ) , sizeof ( iv ) ) ; } EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , EVP_md5 ( ) , iv , ( unsigned char * ) RSTRING_PTR ( pass ) , RSTRING_LENINT ( pass ) , 1 , key , NULL ) ; p_key = key ; p_iv = iv ; } else { GetCipher ( self , ctx ) ; } if ( EVP_CipherInit_ex ( ctx , NULL , NULL , p_key , p_iv , mode ) != 1 ) { ossl_raise ( eCipherError , NULL ) ; } return self ; }\n", "\n", "1: CWE-310 static VALUE ossl_cipher_init ( int argc , VALUE * argv , VALUE self , int mode ) { EVP_CIPHER_CTX * ctx ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , * p_key = NULL ; unsigned char iv [ EVP_MAX_IV_LENGTH ] , * p_iv = NULL ; VALUE pass , init_v ; if ( rb_scan_args ( argc , argv , \"02\" , & pass , & init_v ) > 0 ) { VALUE cname = rb_class_path ( rb_obj_class ( self ) ) ; rb_warn ( \"argumentsfor%\" PRIsVALUE \"#encryptand%\" PRIsVALUE \"#decryptweredeprecated;\" \"use%\" PRIsVALUE \"#pkcs5_keyivgentoderivekeyandIV\" , cname , cname , cname ) ; StringValue ( pass ) ; GetCipher ( self , ctx ) ; if ( NIL_P ( init_v ) ) memcpy ( iv , \"OpenSSLforRubyrulez!\" , sizeof ( iv ) ) ; else { StringValue ( init_v ) ; if ( EVP_MAX_IV_LENGTH > RSTRING_LEN ( init_v ) ) { memset ( iv , 0 , EVP_MAX_IV_LENGTH ) ; memcpy ( iv , RSTRING_PTR ( init_v ) , RSTRING_LEN ( init_v ) ) ; } else memcpy ( iv , RSTRING_PTR ( init_v ) , sizeof ( iv ) ) ; } EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , EVP_md5 ( ) , iv , ( unsigned char * ) RSTRING_PTR ( pass ) , RSTRING_LENINT ( pass ) , 1 , key , NULL ) ; p_key = key ; p_iv = iv ; } else { GetCipher ( self , ctx ) ; } if ( EVP_CipherInit_ex ( ctx , NULL , NULL , p_key , p_iv , mode ) != 1 ) { ossl_raise ( eCipherError , NULL ) ; } return self ; }\n", "\n", "\n", "Target: inet_daddr ; struct dst_entry * dst ; struct * rt ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( ! dst || ! dst -> obsolete || dst -> ops -> check ( dst , 0 ) 0 ) ) { rcu_read_unlock ( ) ; return ; } inet_opt = rcu_dereference sk_bound_dev_if ) ; dst = ! IS_ERR ( ( rt ) ? & rt -> & rt -> dst : NULL ; sk_dst_set ( sk ,\n", "\n", "Sources:\n", "0: CWE-362 void ip4_datagram_release_cb ( struct sock * sk ) { const struct inet_sock * inet = inet_sk ( sk ) ; const struct ip_options_rcu * inet_opt ; __be32 daddr = inet -> inet_daddr ; struct flowi4 fl4 ; struct rtable * rt ; if ( ! __sk_dst_get ( sk ) || __sk_dst_check ( sk , 0 ) ) return ; rcu_read_lock ( ) ; inet_opt = rcu_dereference ( inet -> inet_opt ) ; if ( inet_opt && inet_opt -> opt . srr ) daddr = inet_opt -> opt . faddr ; rt = ip_route_output_ports ( sock_net ( sk ) , & fl4 , sk , daddr , inet -> inet_saddr , inet -> inet_dport , inet -> inet_sport , sk -> sk_protocol , RT_CONN_FLAGS ( sk ) , sk -> sk_bound_dev_if ) ; if ( ! IS_ERR ( rt ) ) __sk_dst_set ( sk , & rt -> dst ) ; rcu_read_unlock ( ) ; }\n", "\n", "1: CWE-416 void ip4_datagram_release_cb ( struct sock * sk ) { const struct inet_sock * inet = inet_sk ( sk ) ; const struct ip_options_rcu * inet_opt ; __be32 daddr = inet -> inet_daddr ; struct flowi4 fl4 ; struct rtable * rt ; if ( ! __sk_dst_get ( sk ) || __sk_dst_check ( sk , 0 ) ) return ; rcu_read_lock ( ) ; inet_opt = rcu_dereference ( inet -> inet_opt ) ; if ( inet_opt && inet_opt -> opt . srr ) daddr = inet_opt -> opt . faddr ; rt = ip_route_output_ports ( sock_net ( sk ) , & fl4 , sk , daddr , inet -> inet_saddr , inet -> inet_dport , inet -> inet_sport , sk -> sk_protocol , RT_CONN_FLAGS ( sk ) , sk -> sk_bound_dev_if ) ; if ( ! IS_ERR ( rt ) ) __sk_dst_set ( sk , & rt -> dst ) ; rcu_read_unlock ( ) ; }\n", "\n", "\n", "Target: dlen , buf , false\n", "\n", "Sources:\n", "0: CWE-78 void imap_munge_mbox_name ( struct ImapData * idata , char * dest , size_t dlen , const char * src ) { char * buf = mutt_str_strdup ( src ) ; imap_utf_encode ( idata , & buf ) ; imap_quote_string ( dest , dlen , buf ) ; FREE ( & buf ) ; }\n", "\n", "1: CWE-77 void imap_munge_mbox_name ( struct ImapData * idata , char * dest , size_t dlen , const char * src ) { char * buf = mutt_str_strdup ( src ) ; imap_utf_encode ( idata , & buf ) ; imap_quote_string ( dest , dlen , buf ) ; FREE ( & buf ) ; }\n", "\n", "\n", "Target: ptr ) { if ( dir_len > PATH_MAX ) { uwsgi_log ( \"invalidpathsize:%d(max%d)\\\\n\" , dir_len , PATH_MAX ) ; return NULL ; } char * src = uwsgi_concat2n ( dir , dir_len dir , dir_len , \"\" , 0 ) ; char * dst ) ; free ( src ) ; NULL ; } free ( src ) ;\n", "\n", "Sources:\n", "0: CWE-119 char * uwsgi_expand_path ( char * dir , int dir_len , char * ptr ) { char src [ PATH_MAX + 1 ] ; memcpy ( src , dir , dir_len ) ; src [ dir_len ] = 0 ; char * dst = ptr ; if ( ! dst ) dst = uwsgi_malloc ( PATH_MAX + 1 ) ; if ( ! realpath ( src , dst ) ) { uwsgi_error_realpath ( src ) ; if ( ! ptr ) free ( dst ) ; return NULL ; } return dst ; }\n", "\n", "1: CWE-787 char * uwsgi_expand_path ( char * dir , int dir_len , char * ptr ) { char src [ PATH_MAX + 1 ] ; memcpy ( src , dir , dir_len ) ; src [ dir_len ] = 0 ; char * dst = ptr ; if ( ! dst ) dst = uwsgi_malloc ( PATH_MAX + 1 ) ; if ( ! realpath ( src , dst ) ) { uwsgi_error_realpath ( src ) ; if ( ! ptr ) free ( dst ) ; return NULL ; } return dst ; }\n", "\n", "\n", "Target: sec_attr == NULL || sec_attr_len\n", "\n", "Sources:\n", "0: CWE-119 int sc_file_set_sec_attr ( sc_file_t * file , const u8 * sec_attr , size_t sec_attr_len ) { u8 * tmp ; if ( ! sc_file_valid ( file ) ) { return SC_ERROR_INVALID_ARGUMENTS ; } if ( sec_attr == NULL ) { if ( file -> sec_attr != NULL ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return 0 ; } tmp = ( u8 * ) realloc ( file -> sec_attr , sec_attr_len ) ; if ( ! tmp ) { if ( file -> sec_attr ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return SC_ERROR_OUT_OF_MEMORY ; } file -> sec_attr = tmp ; memcpy ( file -> sec_attr , sec_attr , sec_attr_len ) ; file -> sec_attr_len = sec_attr_len ; return 0 ; }\n", "\n", "1: CWE-415 int sc_file_set_sec_attr ( sc_file_t * file , const u8 * sec_attr , size_t sec_attr_len ) { u8 * tmp ; if ( ! sc_file_valid ( file ) ) { return SC_ERROR_INVALID_ARGUMENTS ; } if ( sec_attr == NULL ) { if ( file -> sec_attr != NULL ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return 0 ; } tmp = ( u8 * ) realloc ( file -> sec_attr , sec_attr_len ) ; if ( ! tmp ) { if ( file -> sec_attr ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return SC_ERROR_OUT_OF_MEMORY ; } file -> sec_attr = tmp ; memcpy ( file -> sec_attr , sec_attr , sec_attr_len ) ; file -> sec_attr_len = sec_attr_len ; return 0 ; }\n", "\n", "\n", "Target: ctxt ) { int rc ; unsigned long eip ; rc = emulate_pop ( ctxt , & eip , ctxt -> op_bytes ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; return assign_eip_near ( ctxt , eip ) ; }\n", "\n", "Sources:\n", "0: CWE-000 static int em_ret ( struct x86_emulate_ctxt * ctxt ) { ctxt -> dst . type = OP_REG ; ctxt -> dst . addr . reg = & ctxt -> _eip ; ctxt -> dst . bytes = ctxt -> op_bytes ; return em_pop ( ctxt ) ; }\n", "\n", "1: CWE-264 static int em_ret ( struct x86_emulate_ctxt * ctxt ) { ctxt -> dst . type = OP_REG ; ctxt -> dst . addr . reg = & ctxt -> _eip ; ctxt -> dst . bytes = ctxt -> op_bytes ; return em_pop ( ctxt ) ; }\n", "\n", "\n", "Target: == - EEXIST || ret == - EOVERFLOW\n", "\n", "Sources:\n", "0: CWE-310 int btrfs_add_link ( struct btrfs_trans_handle * trans , struct inode * parent_inode , struct inode * inode , const char * name , int name_len , int add_backref , u64 index ) { int ret = 0 ; struct btrfs_key key ; struct btrfs_root * root = BTRFS_I ( parent_inode ) -> root ; u64 ino = btrfs_ino ( inode ) ; u64 parent_ino = btrfs_ino ( parent_inode ) ; if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { memcpy ( & key , & BTRFS_I ( inode ) -> root -> root_key , sizeof ( key ) ) ; } else { key . objectid = ino ; btrfs_set_key_type ( & key , BTRFS_INODE_ITEM_KEY ) ; key . offset = 0 ; } if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { ret = btrfs_add_root_ref ( trans , root -> fs_info -> tree_root , key . objectid , root -> root_key . objectid , parent_ino , index , name , name_len ) ; } else if ( add_backref ) { ret = btrfs_insert_inode_ref ( trans , root , name , name_len , ino , parent_ino , index ) ; } if ( ret ) return ret ; ret = btrfs_insert_dir_item ( trans , root , name , name_len , parent_inode , & key , btrfs_inode_type ( inode ) , index ) ; if ( ret == - EEXIST ) goto fail_dir_item ; else if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; return ret ; } btrfs_i_size_write ( parent_inode , parent_inode -> i_size + name_len * 2 ) ; inode_inc_iversion ( parent_inode ) ; parent_inode -> i_mtime = parent_inode -> i_ctime = CURRENT_TIME ; ret = btrfs_update_inode ( trans , root , parent_inode ) ; if ( ret ) btrfs_abort_transaction ( trans , root , ret ) ; return ret ; fail_dir_item : if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { u64 local_index ; int err ; err = btrfs_del_root_ref ( trans , root -> fs_info -> tree_root , key . objectid , root -> root_key . objectid , parent_ino , & local_index , name , name_len ) ; } else if ( add_backref ) { u64 local_index ; int err ; err = btrfs_del_inode_ref ( trans , root , name , name_len , ino , parent_ino , & local_index ) ; } return ret ; }\n", "\n", "1: CWE-310 static noinline int create_pending_snapshot ( struct btrfs_trans_handle * trans , struct btrfs_fs_info * fs_info , struct btrfs_pending_snapshot * pending ) { struct btrfs_key key ; struct btrfs_root_item * new_root_item ; struct btrfs_root * tree_root = fs_info -> tree_root ; struct btrfs_root * root = pending -> root ; struct btrfs_root * parent_root ; struct btrfs_block_rsv * rsv ; struct inode * parent_inode ; struct btrfs_path * path ; struct btrfs_dir_item * dir_item ; struct dentry * parent ; struct dentry * dentry ; struct extent_buffer * tmp ; struct extent_buffer * old ; struct timespec cur_time = CURRENT_TIME ; int ret ; u64 to_reserve = 0 ; u64 index = 0 ; u64 objectid ; u64 root_flags ; uuid_le new_uuid ; path = btrfs_alloc_path ( ) ; if ( ! path ) { ret = pending -> error = - ENOMEM ; goto path_alloc_fail ; } new_root_item = kmalloc ( sizeof ( * new_root_item ) , GFP_NOFS ) ; if ( ! new_root_item ) { ret = pending -> error = - ENOMEM ; goto root_item_alloc_fail ; } ret = btrfs_find_free_objectid ( tree_root , & objectid ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } btrfs_reloc_pre_snapshot ( trans , pending , & to_reserve ) ; if ( to_reserve > 0 ) { ret = btrfs_block_rsv_add ( root , & pending -> block_rsv , to_reserve , BTRFS_RESERVE_NO_FLUSH ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } } ret = btrfs_qgroup_inherit ( trans , fs_info , root -> root_key . objectid , objectid , pending -> inherit ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } key . objectid = objectid ; key . offset = ( u64 ) - 1 ; key . type = BTRFS_ROOT_ITEM_KEY ; rsv = trans -> block_rsv ; trans -> block_rsv = & pending -> block_rsv ; dentry = pending -> dentry ; parent = dget_parent ( dentry ) ; parent_inode = parent -> d_inode ; parent_root = BTRFS_I ( parent_inode ) -> root ; record_root_in_trans ( trans , parent_root ) ; ret = btrfs_set_inode_index ( parent_inode , & index ) ; BUG_ON ( ret ) ; dir_item = btrfs_lookup_dir_item ( NULL , parent_root , path , btrfs_ino ( parent_inode ) , dentry -> d_name . name , dentry -> d_name . len , 0 ) ; if ( dir_item != NULL && ! IS_ERR ( dir_item ) ) { pending -> error = - EEXIST ; goto fail ; } else if ( IS_ERR ( dir_item ) ) { ret = PTR_ERR ( dir_item ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_release_path ( path ) ; ret = btrfs_run_delayed_items ( trans , root ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } record_root_in_trans ( trans , root ) ; btrfs_set_root_last_snapshot ( & root -> root_item , trans -> transid ) ; memcpy ( new_root_item , & root -> root_item , sizeof ( * new_root_item ) ) ; btrfs_check_and_init_root_item ( new_root_item ) ; root_flags = btrfs_root_flags ( new_root_item ) ; if ( pending -> readonly ) root_flags |= BTRFS_ROOT_SUBVOL_RDONLY ; else root_flags &= ~ BTRFS_ROOT_SUBVOL_RDONLY ; btrfs_set_root_flags ( new_root_item , root_flags ) ; btrfs_set_root_generation_v2 ( new_root_item , trans -> transid ) ; uuid_le_gen ( & new_uuid ) ; memcpy ( new_root_item -> uuid , new_uuid . b , BTRFS_UUID_SIZE ) ; memcpy ( new_root_item -> parent_uuid , root -> root_item . uuid , BTRFS_UUID_SIZE ) ; new_root_item -> otime . sec = cpu_to_le64 ( cur_time . tv_sec ) ; new_root_item -> otime . nsec = cpu_to_le32 ( cur_time . tv_nsec ) ; btrfs_set_root_otransid ( new_root_item , trans -> transid ) ; memset ( & new_root_item -> stime , 0 , sizeof ( new_root_item -> stime ) ) ; memset ( & new_root_item -> rtime , 0 , sizeof ( new_root_item -> rtime ) ) ; btrfs_set_root_stransid ( new_root_item , 0 ) ; btrfs_set_root_rtransid ( new_root_item , 0 ) ; old = btrfs_lock_root_node ( root ) ; ret = btrfs_cow_block ( trans , root , old , NULL , 0 , & old ) ; if ( ret ) { btrfs_tree_unlock ( old ) ; free_extent_buffer ( old ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_set_lock_blocking ( old ) ; ret = btrfs_copy_root ( trans , root , old , & tmp , objectid ) ; btrfs_tree_unlock ( old ) ; free_extent_buffer ( old ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } root -> force_cow = 1 ; smp_wmb ( ) ; btrfs_set_root_node ( new_root_item , tmp ) ; key . offset = trans -> transid ; ret = btrfs_insert_root ( trans , tree_root , & key , new_root_item ) ; btrfs_tree_unlock ( tmp ) ; free_extent_buffer ( tmp ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_add_root_ref ( trans , tree_root , objectid , parent_root -> root_key . objectid , btrfs_ino ( parent_inode ) , index , dentry -> d_name . name , dentry -> d_name . len ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } key . offset = ( u64 ) - 1 ; pending -> snap = btrfs_read_fs_root_no_name ( root -> fs_info , & key ) ; if ( IS_ERR ( pending -> snap ) ) { ret = PTR_ERR ( pending -> snap ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_reloc_post_snapshot ( trans , pending ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_run_delayed_refs ( trans , root , ( unsigned long ) - 1 ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_insert_dir_item ( trans , parent_root , dentry -> d_name . name , dentry -> d_name . len , parent_inode , & key , BTRFS_FT_DIR , index ) ; BUG_ON ( ret == - EEXIST ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_i_size_write ( parent_inode , parent_inode -> i_size + dentry -> d_name . len * 2 ) ; parent_inode -> i_mtime = parent_inode -> i_ctime = CURRENT_TIME ; ret = btrfs_update_inode_fallback ( trans , parent_root , parent_inode ) ; if ( ret ) btrfs_abort_transaction ( trans , root , ret ) ; fail : dput ( parent ) ; trans -> block_rsv = rsv ; no_free_objectid : kfree ( new_root_item ) ; root_item_alloc_fail : btrfs_free_path ( path ) ; path_alloc_fail : btrfs_block_rsv_release ( root , & pending -> block_rsv , ( u64 ) - 1 ) ; return ret ; }\n", "\n", "\n", "Target: x & ( 1U << ( unsigned int ) i ) )\n", "\n", "Sources:\n", "0: CWE-682 static int find_high_bit ( unsigned int x ) { int i ; for ( i = 31 ; i >= 0 ; i -- ) { if ( x & ( 1 << i ) ) return i ; } return 0 ; }\n", "\n", "1: CWE-682 static int find_low_bit ( unsigned int x ) { int i ; for ( i = 0 ; i <= 31 ; i ++ ) { if ( x & ( 1 << i ) ) return i ; } return 0 ; }\n", "\n", "\n", "Target: mq_ops ) { struct blk_mq_hw_ctx * hctx ; first_rq -> tag ; fq -> orig_rq = first_rq ; hctx = q -> mq_ops -> map_queue ( q , first_rq -> mq_ctx -> cpu ) ; blk_mq_tag_set_rq ( hctx , first_rq -> tag , flush_rq )\n", "\n", "Sources:\n", "0: CWE-362 static bool blk_kick_flush ( struct request_queue * q , struct blk_flush_queue * fq ) { struct list_head * pending = & fq -> flush_queue [ fq -> flush_pending_idx ] ; struct request * first_rq = list_first_entry ( pending , struct request , flush . list ) ; struct request * flush_rq = fq -> flush_rq ; if ( fq -> flush_pending_idx != fq -> flush_running_idx || list_empty ( pending ) ) return false ; if ( ! list_empty ( & fq -> flush_data_in_flight ) && time_before ( jiffies , fq -> flush_pending_since + FLUSH_PENDING_TIMEOUT ) ) return false ; fq -> flush_pending_idx ^= 1 ; blk_rq_init ( q , flush_rq ) ; if ( q -> mq_ops ) { flush_rq -> mq_ctx = first_rq -> mq_ctx ; flush_rq -> tag = first_rq -> tag ; } flush_rq -> cmd_type = REQ_TYPE_FS ; flush_rq -> cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ ; flush_rq -> rq_disk = first_rq -> rq_disk ; flush_rq -> end_io = flush_end_io ; return blk_flush_queue_rq ( flush_rq , false ) ; }\n", "\n", "1: CWE-264 static bool blk_kick_flush ( struct request_queue * q , struct blk_flush_queue * fq ) { struct list_head * pending = & fq -> flush_queue [ fq -> flush_pending_idx ] ; struct request * first_rq = list_first_entry ( pending , struct request , flush . list ) ; struct request * flush_rq = fq -> flush_rq ; if ( fq -> flush_pending_idx != fq -> flush_running_idx || list_empty ( pending ) ) return false ; if ( ! list_empty ( & fq -> flush_data_in_flight ) && time_before ( jiffies , fq -> flush_pending_since + FLUSH_PENDING_TIMEOUT ) ) return false ; fq -> flush_pending_idx ^= 1 ; blk_rq_init ( q , flush_rq ) ; if ( q -> mq_ops ) { flush_rq -> mq_ctx = first_rq -> mq_ctx ; flush_rq -> tag = first_rq -> tag ; } flush_rq -> cmd_type = REQ_TYPE_FS ; flush_rq -> cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ ; flush_rq -> rq_disk = first_rq -> rq_disk ; flush_rq -> end_io = flush_end_io ; return blk_flush_queue_rq ( flush_rq , false ) ; }\n", "\n", "\n", "Target: \"SkippingoptionalEF.C_DevAut\" ) ; if ( len > 0 ) { = len ; }\n", "\n", "Sources:\n", "0: CWE-415 static int sc_pkcs15emu_sc_hsm_init ( sc_pkcs15_card_t * p15card ) { sc_card_t * card = p15card -> card ; sc_hsm_private_data_t * priv = ( sc_hsm_private_data_t * ) card -> drv_data ; sc_file_t * file = NULL ; sc_path_t path ; u8 filelist [ MAX_EXT_APDU_LENGTH ] ; int filelistlength ; int r , i ; sc_cvc_t devcert ; struct sc_app_info * appinfo ; struct sc_pkcs15_auth_info pin_info ; struct sc_pkcs15_object pin_obj ; struct sc_pin_cmd_data pindata ; u8 efbin [ 1024 ] ; u8 * ptr ; size_t len ; LOG_FUNC_CALLED ( card -> ctx ) ; appinfo = calloc ( 1 , sizeof ( struct sc_app_info ) ) ; if ( appinfo == NULL ) { LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } appinfo -> aid = sc_hsm_aid ; appinfo -> ddo . aid = sc_hsm_aid ; p15card -> app = appinfo ; sc_path_set ( & path , SC_PATH_TYPE_DF_NAME , sc_hsm_aid . value , sc_hsm_aid . len , 0 , 0 ) ; r = sc_select_file ( card , & path , & file ) ; LOG_TEST_RET ( card -> ctx , r , \"CouldnotselectSmartCard-HSMapplication\" ) ; p15card -> card -> version . hw_major = 24 ; p15card -> card -> version . hw_minor = 13 ; if ( file && file -> prop_attr && file -> prop_attr_len >= 2 ) { p15card -> card -> version . fw_major = file -> prop_attr [ file -> prop_attr_len - 2 ] ; p15card -> card -> version . fw_minor = file -> prop_attr [ file -> prop_attr_len - 1 ] ; } sc_file_free ( file ) ; if ( priv -> EF_C_DevAut && priv -> EF_C_DevAut_len ) { ptr = priv -> EF_C_DevAut ; len = priv -> EF_C_DevAut_len ; } else { len = sizeof efbin ; r = read_file ( p15card , ( u8 * ) \"\\\\x2F\\\\x02\" , efbin , & len , 1 ) ; LOG_TEST_RET ( card -> ctx , r , \"SkippingoptionalEF.C_DevAut\" ) ; ptr = realloc ( priv -> EF_C_DevAut , len ) ; if ( ptr ) { memcpy ( ptr , efbin , len ) ; priv -> EF_C_DevAut = ptr ; priv -> EF_C_DevAut_len = len ; } ptr = efbin ; } memset ( & devcert , 0 , sizeof ( devcert ) ) ; r = sc_pkcs15emu_sc_hsm_decode_cvc ( p15card , ( const u8 * * ) & ptr , & len , & devcert ) ; LOG_TEST_RET ( card -> ctx , r , \"CouldnotdecodeEF.C_DevAut\" ) ; sc_pkcs15emu_sc_hsm_read_tokeninfo ( p15card ) ; if ( p15card -> tokeninfo -> label == NULL ) { if ( p15card -> card -> type == SC_CARD_TYPE_SC_HSM_GOID || p15card -> card -> type == SC_CARD_TYPE_SC_HSM_SOC ) { p15card -> tokeninfo -> label = strdup ( \"GoID\" ) ; } else { p15card -> tokeninfo -> label = strdup ( \"SmartCard-HSM\" ) ; } if ( p15card -> tokeninfo -> label == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } if ( ( p15card -> tokeninfo -> manufacturer_id != NULL ) && ! strcmp ( \"(unknown)\" , p15card -> tokeninfo -> manufacturer_id ) ) { free ( p15card -> tokeninfo -> manufacturer_id ) ; p15card -> tokeninfo -> manufacturer_id = NULL ; } if ( p15card -> tokeninfo -> manufacturer_id == NULL ) { if ( p15card -> card -> type == SC_CARD_TYPE_SC_HSM_GOID || p15card -> card -> type == SC_CARD_TYPE_SC_HSM_SOC ) { p15card -> tokeninfo -> manufacturer_id = strdup ( \"BundesdruckereiGmbH\" ) ; } else { p15card -> tokeninfo -> manufacturer_id = strdup ( \"www.CardContact.de\" ) ; } if ( p15card -> tokeninfo -> manufacturer_id == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } appinfo -> label = strdup ( p15card -> tokeninfo -> label ) ; if ( appinfo -> label == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; len = strnlen ( devcert . chr , sizeof devcert . chr ) ; assert ( len >= 8 ) ; len -= 5 ; p15card -> tokeninfo -> serial_number = calloc ( len + 1 , 1 ) ; if ( p15card -> tokeninfo -> serial_number == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; memcpy ( p15card -> tokeninfo -> serial_number , devcert . chr , len ) ; * ( p15card -> tokeninfo -> serial_number + len ) = 0 ; sc_hsm_set_serialnr ( card , p15card -> tokeninfo -> serial_number ) ; sc_pkcs15emu_sc_hsm_free_cvc ( & devcert ) ; memset ( & pin_info , 0 , sizeof ( pin_info ) ) ; memset ( & pin_obj , 0 , sizeof ( pin_obj ) ) ; pin_info . auth_id . len = 1 ; pin_info . auth_id . value [ 0 ] = 1 ; pin_info . path . aid = sc_hsm_aid ; pin_info . auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN ; pin_info . attrs . pin . reference = 0x81 ; pin_info . attrs . pin . flags = SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA ; pin_info . attrs . pin . type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC ; pin_info . attrs . pin . min_length = 6 ; pin_info . attrs . pin . stored_length = 0 ; pin_info . attrs . pin . max_length = 15 ; pin_info . attrs . pin . pad_char = '\\\\0' ; pin_info . tries_left = 3 ; pin_info . max_tries = 3 ; pin_obj . auth_id . len = 1 ; pin_obj . auth_id . value [ 0 ] = 2 ; strlcpy ( pin_obj . label , \"UserPIN\" , sizeof ( pin_obj . label ) ) ; pin_obj . flags = SC_PKCS15_CO_FLAG_PRIVATE | SC_PKCS15_CO_FLAG_MODIFIABLE ; r = sc_pkcs15emu_add_pin_obj ( p15card , & pin_obj , & pin_info ) ; if ( r < 0 ) LOG_FUNC_RETURN ( card -> ctx , r ) ; memset ( & pin_info , 0 , sizeof ( pin_info ) ) ; memset ( & pin_obj , 0 , sizeof ( pin_obj ) ) ; pin_info . auth_id . len = 1 ; pin_info . auth_id . value [ 0 ] = 2 ; pin_info . path . aid = sc_hsm_aid ; pin_info . auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN ; pin_info . attrs . pin . reference = 0x88 ; pin_info . attrs . pin . flags = SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED | SC_PKCS15_PIN_FLAG_SO_PIN ; pin_info . attrs . pin . type = SC_PKCS15_PIN_TYPE_BCD ; pin_info . attrs . pin . min_length = 16 ; pin_info . attrs . pin . stored_length = 0 ; pin_info . attrs . pin . max_length = 16 ; pin_info . attrs . pin . pad_char = '\\\\0' ; pin_info . tries_left = 15 ; pin_info . max_tries = 15 ; strlcpy ( pin_obj . label , \"SOPIN\" , sizeof ( pin_obj . label ) ) ; pin_obj . flags = SC_PKCS15_CO_FLAG_PRIVATE ; r = sc_pkcs15emu_add_pin_obj ( p15card , & pin_obj , & pin_info ) ; if ( r < 0 ) LOG_FUNC_RETURN ( card -> ctx , r ) ; if ( card -> type == SC_CARD_TYPE_SC_HSM_SOC || card -> type == SC_CARD_TYPE_SC_HSM_GOID ) { r = SC_SUCCESS ; } else { memset ( & pindata , 0 , sizeof ( pindata ) ) ; pindata . cmd = SC_PIN_CMD_GET_INFO ; pindata . pin_type = SC_AC_CHV ; pindata . pin_reference = 0x85 ; r = sc_pin_cmd ( card , & pindata , NULL ) ; } if ( r == SC_ERROR_DATA_OBJECT_NOT_FOUND ) { memset ( & pindata , 0 , sizeof ( pindata ) ) ; pindata . cmd = SC_PIN_CMD_GET_INFO ; pindata . pin_type = SC_AC_CHV ; pindata . pin_reference = 0x86 ; r = sc_pin_cmd ( card , & pindata , NULL ) ; } if ( ( r != SC_ERROR_DATA_OBJECT_NOT_FOUND ) && ( r != SC_ERROR_INCORRECT_PARAMETERS ) ) card -> caps |= SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH ; filelistlength = sc_list_files ( card , filelist , sizeof ( filelist ) ) ; LOG_TEST_RET ( card -> ctx , filelistlength , \"Couldnotenumeratefileandkeyidentifier\" ) ; for ( i = 0 ; i < filelistlength ; i += 2 ) { switch ( filelist [ i ] ) { case KEY_PREFIX : r = sc_pkcs15emu_sc_hsm_add_prkd ( p15card , filelist [ i + 1 ] ) ; break ; case DCOD_PREFIX : r = sc_pkcs15emu_sc_hsm_add_dcod ( p15card , filelist [ i + 1 ] ) ; break ; case CD_PREFIX : r = sc_pkcs15emu_sc_hsm_add_cd ( p15card , filelist [ i + 1 ] ) ; break ; } if ( r != SC_SUCCESS ) { sc_log ( card -> ctx , \"Error%daddingelementstoframework\" , r ) ; } } LOG_FUNC_RETURN ( card -> ctx , SC_SUCCESS ) ; }\n", "\n", "1: CWE-119 static int sc_pkcs15emu_sc_hsm_init ( sc_pkcs15_card_t * p15card ) { sc_card_t * card = p15card -> card ; sc_hsm_private_data_t * priv = ( sc_hsm_private_data_t * ) card -> drv_data ; sc_file_t * file = NULL ; sc_path_t path ; u8 filelist [ MAX_EXT_APDU_LENGTH ] ; int filelistlength ; int r , i ; sc_cvc_t devcert ; struct sc_app_info * appinfo ; struct sc_pkcs15_auth_info pin_info ; struct sc_pkcs15_object pin_obj ; struct sc_pin_cmd_data pindata ; u8 efbin [ 1024 ] ; u8 * ptr ; size_t len ; LOG_FUNC_CALLED ( card -> ctx ) ; appinfo = calloc ( 1 , sizeof ( struct sc_app_info ) ) ; if ( appinfo == NULL ) { LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } appinfo -> aid = sc_hsm_aid ; appinfo -> ddo . aid = sc_hsm_aid ; p15card -> app = appinfo ; sc_path_set ( & path , SC_PATH_TYPE_DF_NAME , sc_hsm_aid . value , sc_hsm_aid . len , 0 , 0 ) ; r = sc_select_file ( card , & path , & file ) ; LOG_TEST_RET ( card -> ctx , r , \"CouldnotselectSmartCard-HSMapplication\" ) ; p15card -> card -> version . hw_major = 24 ; p15card -> card -> version . hw_minor = 13 ; if ( file && file -> prop_attr && file -> prop_attr_len >= 2 ) { p15card -> card -> version . fw_major = file -> prop_attr [ file -> prop_attr_len - 2 ] ; p15card -> card -> version . fw_minor = file -> prop_attr [ file -> prop_attr_len - 1 ] ; } sc_file_free ( file ) ; if ( priv -> EF_C_DevAut && priv -> EF_C_DevAut_len ) { ptr = priv -> EF_C_DevAut ; len = priv -> EF_C_DevAut_len ; } else { len = sizeof efbin ; r = read_file ( p15card , ( u8 * ) \"\\\\x2F\\\\x02\" , efbin , & len , 1 ) ; LOG_TEST_RET ( card -> ctx , r , \"SkippingoptionalEF.C_DevAut\" ) ; ptr = realloc ( priv -> EF_C_DevAut , len ) ; if ( ptr ) { memcpy ( ptr , efbin , len ) ; priv -> EF_C_DevAut = ptr ; priv -> EF_C_DevAut_len = len ; } ptr = efbin ; } memset ( & devcert , 0 , sizeof ( devcert ) ) ; r = sc_pkcs15emu_sc_hsm_decode_cvc ( p15card , ( const u8 * * ) & ptr , & len , & devcert ) ; LOG_TEST_RET ( card -> ctx , r , \"CouldnotdecodeEF.C_DevAut\" ) ; sc_pkcs15emu_sc_hsm_read_tokeninfo ( p15card ) ; if ( p15card -> tokeninfo -> label == NULL ) { if ( p15card -> card -> type == SC_CARD_TYPE_SC_HSM_GOID || p15card -> card -> type == SC_CARD_TYPE_SC_HSM_SOC ) { p15card -> tokeninfo -> label = strdup ( \"GoID\" ) ; } else { p15card -> tokeninfo -> label = strdup ( \"SmartCard-HSM\" ) ; } if ( p15card -> tokeninfo -> label == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } if ( ( p15card -> tokeninfo -> manufacturer_id != NULL ) && ! strcmp ( \"(unknown)\" , p15card -> tokeninfo -> manufacturer_id ) ) { free ( p15card -> tokeninfo -> manufacturer_id ) ; p15card -> tokeninfo -> manufacturer_id = NULL ; } if ( p15card -> tokeninfo -> manufacturer_id == NULL ) { if ( p15card -> card -> type == SC_CARD_TYPE_SC_HSM_GOID || p15card -> card -> type == SC_CARD_TYPE_SC_HSM_SOC ) { p15card -> tokeninfo -> manufacturer_id = strdup ( \"BundesdruckereiGmbH\" ) ; } else { p15card -> tokeninfo -> manufacturer_id = strdup ( \"www.CardContact.de\" ) ; } if ( p15card -> tokeninfo -> manufacturer_id == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; } appinfo -> label = strdup ( p15card -> tokeninfo -> label ) ; if ( appinfo -> label == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; len = strnlen ( devcert . chr , sizeof devcert . chr ) ; assert ( len >= 8 ) ; len -= 5 ; p15card -> tokeninfo -> serial_number = calloc ( len + 1 , 1 ) ; if ( p15card -> tokeninfo -> serial_number == NULL ) LOG_FUNC_RETURN ( card -> ctx , SC_ERROR_OUT_OF_MEMORY ) ; memcpy ( p15card -> tokeninfo -> serial_number , devcert . chr , len ) ; * ( p15card -> tokeninfo -> serial_number + len ) = 0 ; sc_hsm_set_serialnr ( card , p15card -> tokeninfo -> serial_number ) ; sc_pkcs15emu_sc_hsm_free_cvc ( & devcert ) ; memset ( & pin_info , 0 , sizeof ( pin_info ) ) ; memset ( & pin_obj , 0 , sizeof ( pin_obj ) ) ; pin_info . auth_id . len = 1 ; pin_info . auth_id . value [ 0 ] = 1 ; pin_info . path . aid = sc_hsm_aid ; pin_info . auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN ; pin_info . attrs . pin . reference = 0x81 ; pin_info . attrs . pin . flags = SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA ; pin_info . attrs . pin . type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC ; pin_info . attrs . pin . min_length = 6 ; pin_info . attrs . pin . stored_length = 0 ; pin_info . attrs . pin . max_length = 15 ; pin_info . attrs . pin . pad_char = '\\\\0' ; pin_info . tries_left = 3 ; pin_info . max_tries = 3 ; pin_obj . auth_id . len = 1 ; pin_obj . auth_id . value [ 0 ] = 2 ; strlcpy ( pin_obj . label , \"UserPIN\" , sizeof ( pin_obj . label ) ) ; pin_obj . flags = SC_PKCS15_CO_FLAG_PRIVATE | SC_PKCS15_CO_FLAG_MODIFIABLE ; r = sc_pkcs15emu_add_pin_obj ( p15card , & pin_obj , & pin_info ) ; if ( r < 0 ) LOG_FUNC_RETURN ( card -> ctx , r ) ; memset ( & pin_info , 0 , sizeof ( pin_info ) ) ; memset ( & pin_obj , 0 , sizeof ( pin_obj ) ) ; pin_info . auth_id . len = 1 ; pin_info . auth_id . value [ 0 ] = 2 ; pin_info . path . aid = sc_hsm_aid ; pin_info . auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN ; pin_info . attrs . pin . reference = 0x88 ; pin_info . attrs . pin . flags = SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED | SC_PKCS15_PIN_FLAG_SO_PIN ; pin_info . attrs . pin . type = SC_PKCS15_PIN_TYPE_BCD ; pin_info . attrs . pin . min_length = 16 ; pin_info . attrs . pin . stored_length = 0 ; pin_info . attrs . pin . max_length = 16 ; pin_info . attrs . pin . pad_char = '\\\\0' ; pin_info . tries_left = 15 ; pin_info . max_tries = 15 ; strlcpy ( pin_obj . label , \"SOPIN\" , sizeof ( pin_obj . label ) ) ; pin_obj . flags = SC_PKCS15_CO_FLAG_PRIVATE ; r = sc_pkcs15emu_add_pin_obj ( p15card , & pin_obj , & pin_info ) ; if ( r < 0 ) LOG_FUNC_RETURN ( card -> ctx , r ) ; if ( card -> type == SC_CARD_TYPE_SC_HSM_SOC || card -> type == SC_CARD_TYPE_SC_HSM_GOID ) { r = SC_SUCCESS ; } else { memset ( & pindata , 0 , sizeof ( pindata ) ) ; pindata . cmd = SC_PIN_CMD_GET_INFO ; pindata . pin_type = SC_AC_CHV ; pindata . pin_reference = 0x85 ; r = sc_pin_cmd ( card , & pindata , NULL ) ; } if ( r == SC_ERROR_DATA_OBJECT_NOT_FOUND ) { memset ( & pindata , 0 , sizeof ( pindata ) ) ; pindata . cmd = SC_PIN_CMD_GET_INFO ; pindata . pin_type = SC_AC_CHV ; pindata . pin_reference = 0x86 ; r = sc_pin_cmd ( card , & pindata , NULL ) ; } if ( ( r != SC_ERROR_DATA_OBJECT_NOT_FOUND ) && ( r != SC_ERROR_INCORRECT_PARAMETERS ) ) card -> caps |= SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH ; filelistlength = sc_list_files ( card , filelist , sizeof ( filelist ) ) ; LOG_TEST_RET ( card -> ctx , filelistlength , \"Couldnotenumeratefileandkeyidentifier\" ) ; for ( i = 0 ; i < filelistlength ; i += 2 ) { switch ( filelist [ i ] ) { case KEY_PREFIX : r = sc_pkcs15emu_sc_hsm_add_prkd ( p15card , filelist [ i + 1 ] ) ; break ; case DCOD_PREFIX : r = sc_pkcs15emu_sc_hsm_add_dcod ( p15card , filelist [ i + 1 ] ) ; break ; case CD_PREFIX : r = sc_pkcs15emu_sc_hsm_add_cd ( p15card , filelist [ i + 1 ] ) ; break ; } if ( r != SC_SUCCESS ) { sc_log ( card -> ctx , \"Error%daddingelementstoframework\" , r ) ; } } LOG_FUNC_RETURN ( card -> ctx , SC_SUCCESS ) ; }\n", "\n", "\n", "Target: ( ! file || count > OE_SSIZE_MAX OE_EINVAL ) ; if ( ret > ( ssize_t ) count ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; }\n", "\n", "Sources:\n", "0: CWE-552 static ssize_t _consolefs_read ( oe_fd_t * file_ , void * buf , size_t count ) { ssize_t ret = - 1 ; file_t * file = _cast_file ( file_ ) ; if ( ! file ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_syscall_read_ocall ( & ret , file -> host_fd , buf , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; }\n", "\n", "1: CWE-552 static ssize_t _epoll_read ( oe_fd_t * epoll_ , void * buf , size_t count ) { ssize_t ret = - 1 ; epoll_t * file = _cast_epoll ( epoll_ ) ; oe_errno = 0 ; if ( ! file ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_syscall_read_ocall ( & ret , file -> host_fd , buf , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; }\n", "\n", "2: CWE-552 static ssize_t _consolefs_write ( oe_fd_t * file_ , const void * buf , size_t count ) { ssize_t ret = - 1 ; file_t * file = _cast_file ( file_ ) ; if ( ! file ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_syscall_write_ocall ( & ret , file -> host_fd , buf , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; }\n", "\n", "\n", "Target: . security_options . acl_file = config -> default_listener . security_options . acl_file ; config -> listeners [ config -> listener_count - 1 ] . security_options .\n", "\n", "Sources:\n", "0: CWE-732 int config__parse_args ( struct mosquitto_db * db , struct mosquitto__config * config , int argc , char * argv [ ] ) { int i ; int port_tmp ; for ( i = 1 ; i < argc ; i ++ ) { if ( ! strcmp ( argv [ i ] , \"-c\" ) || ! strcmp ( argv [ i ] , \"--config-file\" ) ) { if ( i < argc - 1 ) { db -> config_file = argv [ i + 1 ] ; if ( config__read ( db , config , false ) ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Unabletoopenconfigurationfile.\" ) ; return MOSQ_ERR_INVAL ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:-cargumentgiven,butnoconfigfilespecified.\" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , \"-d\" ) || ! strcmp ( argv [ i ] , \"--daemon\" ) ) { config -> daemon = true ; } else if ( ! strcmp ( argv [ i ] , \"-h\" ) || ! strcmp ( argv [ i ] , \"--help\" ) ) { print_usage ( ) ; return MOSQ_ERR_INVAL ; } else if ( ! strcmp ( argv [ i ] , \"-p\" ) || ! strcmp ( argv [ i ] , \"--port\" ) ) { if ( i < argc - 1 ) { port_tmp = atoi ( argv [ i + 1 ] ) ; if ( port_tmp < 1 || port_tmp > 65535 ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Invalidportspecified(%d).\" , port_tmp ) ; return MOSQ_ERR_INVAL ; } else { if ( config -> default_listener . port ) { log__printf ( NULL , MOSQ_LOG_WARNING , \"Warning:Defaultlistenerportspecifiedmultipletimes.Onlythelatestwillbeused.\" ) ; } config -> default_listener . port = port_tmp ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:-pargumentgiven,butnoportspecified.\" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , \"-v\" ) || ! strcmp ( argv [ i ] , \"--verbose\" ) ) { db -> verbose = true ; } else { fprintf ( stderr , \"Error:Unknownoption\\'%s\\'.\\\\n\" , argv [ i ] ) ; print_usage ( ) ; return MOSQ_ERR_INVAL ; } } if ( config -> listener_count == 0 # ifdef WITH_TLS || config -> default_listener . cafile || config -> default_listener . capath || config -> default_listener . certfile || config -> default_listener . keyfile || config -> default_listener . ciphers || config -> default_listener . psk_hint || config -> default_listener . require_certificate || config -> default_listener . crlfile || config -> default_listener . use_identity_as_username || config -> default_listener . use_subject_as_username # endif || config -> default_listener . use_username_as_clientid || config -> default_listener . host || config -> default_listener . port || config -> default_listener . max_connections != - 1 || config -> default_listener . mount_point || config -> default_listener . protocol != mp_mqtt || config -> default_listener . socket_domain || config -> default_listener . security_options . password_file || config -> default_listener . security_options . psk_file || config -> default_listener . security_options . auth_plugin_config_count || config -> default_listener . security_options . allow_anonymous != - 1 ) { config -> listener_count ++ ; config -> listeners = mosquitto__realloc ( config -> listeners , sizeof ( struct mosquitto__listener ) * config -> listener_count ) ; if ( ! config -> listeners ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Outofmemory.\" ) ; return MOSQ_ERR_NOMEM ; } memset ( & config -> listeners [ config -> listener_count - 1 ] , 0 , sizeof ( struct mosquitto__listener ) ) ; if ( config -> default_listener . port ) { config -> listeners [ config -> listener_count - 1 ] . port = config -> default_listener . port ; } else { config -> listeners [ config -> listener_count - 1 ] . port = 1883 ; } if ( config -> default_listener . host ) { config -> listeners [ config -> listener_count - 1 ] . host = config -> default_listener . host ; } else { config -> listeners [ config -> listener_count - 1 ] . host = NULL ; } if ( config -> default_listener . mount_point ) { config -> listeners [ config -> listener_count - 1 ] . mount_point = config -> default_listener . mount_point ; } else { config -> listeners [ config -> listener_count - 1 ] . mount_point = NULL ; } config -> listeners [ config -> listener_count - 1 ] . max_connections = config -> default_listener . max_connections ; config -> listeners [ config -> listener_count - 1 ] . protocol = config -> default_listener . protocol ; config -> listeners [ config -> listener_count - 1 ] . socket_domain = config -> default_listener . socket_domain ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . socks = NULL ; config -> listeners [ config -> listener_count - 1 ] . sock_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . use_username_as_clientid = config -> default_listener . use_username_as_clientid ; # ifdef WITH_TLS config -> listeners [ config -> listener_count - 1 ] . tls_version = config -> default_listener . tls_version ; config -> listeners [ config -> listener_count - 1 ] . cafile = config -> default_listener . cafile ; config -> listeners [ config -> listener_count - 1 ] . capath = config -> default_listener . capath ; config -> listeners [ config -> listener_count - 1 ] . certfile = config -> default_listener . certfile ; config -> listeners [ config -> listener_count - 1 ] . keyfile = config -> default_listener . keyfile ; config -> listeners [ config -> listener_count - 1 ] . ciphers = config -> default_listener . ciphers ; config -> listeners [ config -> listener_count - 1 ] . psk_hint = config -> default_listener . psk_hint ; config -> listeners [ config -> listener_count - 1 ] . require_certificate = config -> default_listener . require_certificate ; config -> listeners [ config -> listener_count - 1 ] . ssl_ctx = NULL ; config -> listeners [ config -> listener_count - 1 ] . crlfile = config -> default_listener . crlfile ; config -> listeners [ config -> listener_count - 1 ] . use_identity_as_username = config -> default_listener . use_identity_as_username ; config -> listeners [ config -> listener_count - 1 ] . use_subject_as_username = config -> default_listener . use_subject_as_username ; # endif config -> listeners [ config -> listener_count - 1 ] . security_options . password_file = config -> default_listener . security_options . password_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . psk_file = config -> default_listener . security_options . psk_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_configs = config -> default_listener . security_options . auth_plugin_configs ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_config_count = config -> default_listener . security_options . auth_plugin_config_count ; config -> listeners [ config -> listener_count - 1 ] . security_options . allow_anonymous = config -> default_listener . security_options . allow_anonymous ; } if ( ! config -> user ) { config -> user = \"mosquitto\" ; } if ( db -> verbose ) { config -> log_type = INT_MAX ; } return config__check ( config ) ; }\n", "\n", "1: CWE-000 int config__parse_args ( struct mosquitto_db * db , struct mosquitto__config * config , int argc , char * argv [ ] ) { int i ; int port_tmp ; for ( i = 1 ; i < argc ; i ++ ) { if ( ! strcmp ( argv [ i ] , \"-c\" ) || ! strcmp ( argv [ i ] , \"--config-file\" ) ) { if ( i < argc - 1 ) { db -> config_file = argv [ i + 1 ] ; if ( config__read ( db , config , false ) ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Unabletoopenconfigurationfile.\" ) ; return MOSQ_ERR_INVAL ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:-cargumentgiven,butnoconfigfilespecified.\" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , \"-d\" ) || ! strcmp ( argv [ i ] , \"--daemon\" ) ) { config -> daemon = true ; } else if ( ! strcmp ( argv [ i ] , \"-h\" ) || ! strcmp ( argv [ i ] , \"--help\" ) ) { print_usage ( ) ; return MOSQ_ERR_INVAL ; } else if ( ! strcmp ( argv [ i ] , \"-p\" ) || ! strcmp ( argv [ i ] , \"--port\" ) ) { if ( i < argc - 1 ) { port_tmp = atoi ( argv [ i + 1 ] ) ; if ( port_tmp < 1 || port_tmp > 65535 ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Invalidportspecified(%d).\" , port_tmp ) ; return MOSQ_ERR_INVAL ; } else { if ( config -> default_listener . port ) { log__printf ( NULL , MOSQ_LOG_WARNING , \"Warning:Defaultlistenerportspecifiedmultipletimes.Onlythelatestwillbeused.\" ) ; } config -> default_listener . port = port_tmp ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:-pargumentgiven,butnoportspecified.\" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , \"-v\" ) || ! strcmp ( argv [ i ] , \"--verbose\" ) ) { db -> verbose = true ; } else { fprintf ( stderr , \"Error:Unknownoption\\'%s\\'.\\\\n\" , argv [ i ] ) ; print_usage ( ) ; return MOSQ_ERR_INVAL ; } } if ( config -> listener_count == 0 # ifdef WITH_TLS || config -> default_listener . cafile || config -> default_listener . capath || config -> default_listener . certfile || config -> default_listener . keyfile || config -> default_listener . ciphers || config -> default_listener . psk_hint || config -> default_listener . require_certificate || config -> default_listener . crlfile || config -> default_listener . use_identity_as_username || config -> default_listener . use_subject_as_username # endif || config -> default_listener . use_username_as_clientid || config -> default_listener . host || config -> default_listener . port || config -> default_listener . max_connections != - 1 || config -> default_listener . mount_point || config -> default_listener . protocol != mp_mqtt || config -> default_listener . socket_domain || config -> default_listener . security_options . password_file || config -> default_listener . security_options . psk_file || config -> default_listener . security_options . auth_plugin_config_count || config -> default_listener . security_options . allow_anonymous != - 1 ) { config -> listener_count ++ ; config -> listeners = mosquitto__realloc ( config -> listeners , sizeof ( struct mosquitto__listener ) * config -> listener_count ) ; if ( ! config -> listeners ) { log__printf ( NULL , MOSQ_LOG_ERR , \"Error:Outofmemory.\" ) ; return MOSQ_ERR_NOMEM ; } memset ( & config -> listeners [ config -> listener_count - 1 ] , 0 , sizeof ( struct mosquitto__listener ) ) ; if ( config -> default_listener . port ) { config -> listeners [ config -> listener_count - 1 ] . port = config -> default_listener . port ; } else { config -> listeners [ config -> listener_count - 1 ] . port = 1883 ; } if ( config -> default_listener . host ) { config -> listeners [ config -> listener_count - 1 ] . host = config -> default_listener . host ; } else { config -> listeners [ config -> listener_count - 1 ] . host = NULL ; } if ( config -> default_listener . mount_point ) { config -> listeners [ config -> listener_count - 1 ] . mount_point = config -> default_listener . mount_point ; } else { config -> listeners [ config -> listener_count - 1 ] . mount_point = NULL ; } config -> listeners [ config -> listener_count - 1 ] . max_connections = config -> default_listener . max_connections ; config -> listeners [ config -> listener_count - 1 ] . protocol = config -> default_listener . protocol ; config -> listeners [ config -> listener_count - 1 ] . socket_domain = config -> default_listener . socket_domain ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . socks = NULL ; config -> listeners [ config -> listener_count - 1 ] . sock_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . use_username_as_clientid = config -> default_listener . use_username_as_clientid ; # ifdef WITH_TLS config -> listeners [ config -> listener_count - 1 ] . tls_version = config -> default_listener . tls_version ; config -> listeners [ config -> listener_count - 1 ] . cafile = config -> default_listener . cafile ; config -> listeners [ config -> listener_count - 1 ] . capath = config -> default_listener . capath ; config -> listeners [ config -> listener_count - 1 ] . certfile = config -> default_listener . certfile ; config -> listeners [ config -> listener_count - 1 ] . keyfile = config -> default_listener . keyfile ; config -> listeners [ config -> listener_count - 1 ] . ciphers = config -> default_listener . ciphers ; config -> listeners [ config -> listener_count - 1 ] . psk_hint = config -> default_listener . psk_hint ; config -> listeners [ config -> listener_count - 1 ] . require_certificate = config -> default_listener . require_certificate ; config -> listeners [ config -> listener_count - 1 ] . ssl_ctx = NULL ; config -> listeners [ config -> listener_count - 1 ] . crlfile = config -> default_listener . crlfile ; config -> listeners [ config -> listener_count - 1 ] . use_identity_as_username = config -> default_listener . use_identity_as_username ; config -> listeners [ config -> listener_count - 1 ] . use_subject_as_username = config -> default_listener . use_subject_as_username ; # endif config -> listeners [ config -> listener_count - 1 ] . security_options . password_file = config -> default_listener . security_options . password_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . psk_file = config -> default_listener . security_options . psk_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_configs = config -> default_listener . security_options . auth_plugin_configs ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_config_count = config -> default_listener . security_options . auth_plugin_config_count ; config -> listeners [ config -> listener_count - 1 ] . security_options . allow_anonymous = config -> default_listener . security_options . allow_anonymous ; } if ( ! config -> user ) { config -> user = \"mosquitto\" ; } if ( db -> verbose ) { config -> log_type = INT_MAX ; } return config__check ( config ) ; }\n", "\n", "\n", "Target: ] ) { size_t j , len case 0x84 : file -> namelen = MIN ( sizeof file -> name , len ) ; , d , file -> namelen file -> namelen ) ; break ;\n", "\n", "Sources:\n", "0: CWE-119 static int tcos_select_file ( sc_card_t * card , const sc_path_t * in_path , sc_file_t * * file_out ) { sc_context_t * ctx ; sc_apdu_t apdu ; sc_file_t * file = NULL ; u8 buf [ SC_MAX_APDU_BUFFER_SIZE ] , pathbuf [ SC_MAX_PATH_SIZE ] , * path = pathbuf ; unsigned int i ; int r , pathlen ; assert ( card != NULL && in_path != NULL ) ; ctx = card -> ctx ; memcpy ( path , in_path -> value , in_path -> len ) ; pathlen = in_path -> len ; sc_format_apdu ( card , & apdu , SC_APDU_CASE_4_SHORT , 0xA4 , 0 , 0x04 ) ; switch ( in_path -> type ) { case SC_PATH_TYPE_FILE_ID : if ( pathlen != 2 ) return SC_ERROR_INVALID_ARGUMENTS ; case SC_PATH_TYPE_FROM_CURRENT : apdu . p1 = 9 ; break ; case SC_PATH_TYPE_DF_NAME : apdu . p1 = 4 ; break ; case SC_PATH_TYPE_PATH : apdu . p1 = 8 ; if ( pathlen >= 2 && memcmp ( path , \"\\\\x3F\\\\x00\" , 2 ) == 0 ) path += 2 , pathlen -= 2 ; if ( pathlen == 0 ) apdu . p1 = 0 ; break ; case SC_PATH_TYPE_PARENT : apdu . p1 = 3 ; pathlen = 0 ; break ; default : SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_INVALID_ARGUMENTS ) ; } if ( pathlen == 0 ) apdu . cse = SC_APDU_CASE_2_SHORT ; apdu . lc = pathlen ; apdu . data = path ; apdu . datalen = pathlen ; if ( file_out != NULL ) { apdu . resp = buf ; apdu . resplen = sizeof ( buf ) ; apdu . le = 256 ; } else { apdu . resplen = 0 ; apdu . le = 0 ; apdu . p2 = 0x0C ; apdu . cse = ( pathlen == 0 ) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT ; } r = sc_transmit_apdu ( card , & apdu ) ; SC_TEST_RET ( ctx , SC_LOG_DEBUG_NORMAL , r , \"APDUtransmitfailed\" ) ; r = sc_check_sw ( card , apdu . sw1 , apdu . sw2 ) ; if ( r || file_out == NULL ) SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , r ) ; if ( apdu . resplen < 1 || apdu . resp [ 0 ] != 0x62 ) { sc_debug ( ctx , SC_LOG_DEBUG_NORMAL , \"receivedinvalidtemplate%02X\\\\n\" , apdu . resp [ 0 ] ) ; SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_UNKNOWN_DATA_RECEIVED ) ; } file = sc_file_new ( ) ; if ( file == NULL ) SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_NORMAL , SC_ERROR_OUT_OF_MEMORY ) ; * file_out = file ; file -> path = * in_path ; for ( i = 2 ; i + 1 < apdu . resplen && i + 1 + apdu . resp [ i + 1 ] < apdu . resplen ; i += 2 + apdu . resp [ i + 1 ] ) { int j , len = apdu . resp [ i + 1 ] ; unsigned char type = apdu . resp [ i ] , * d = apdu . resp + i + 2 ; switch ( type ) { case 0x80 : case 0x81 : file -> size = 0 ; for ( j = 0 ; j < len ; ++ j ) file -> size = ( file -> size << 8 ) | d [ j ] ; break ; case 0x82 : file -> shareable = ( d [ 0 ] & 0x40 ) ? 1 : 0 ; file -> ef_structure = d [ 0 ] & 7 ; switch ( ( d [ 0 ] >> 3 ) & 7 ) { case 0 : file -> type = SC_FILE_TYPE_WORKING_EF ; break ; case 7 : file -> type = SC_FILE_TYPE_DF ; break ; default : sc_debug ( ctx , SC_LOG_DEBUG_NORMAL , \"invalidfiletype%02Xinfiledescriptor\\\\n\" , d [ 0 ] ) ; SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_UNKNOWN_DATA_RECEIVED ) ; } break ; case 0x83 : file -> id = ( d [ 0 ] << 8 ) | d [ 1 ] ; break ; case 0x84 : memcpy ( file -> name , d , len ) ; file -> namelen = len ; break ; case 0x86 : sc_file_set_sec_attr ( file , d , len ) ; break ; default : if ( len > 0 ) sc_file_set_prop_attr ( file , d , len ) ; } } file -> magic = SC_FILE_MAGIC ; parse_sec_attr ( card , file , file -> sec_attr , file -> sec_attr_len ) ; return 0 ; }\n", "\n", "1: CWE-415 static int tcos_select_file ( sc_card_t * card , const sc_path_t * in_path , sc_file_t * * file_out ) { sc_context_t * ctx ; sc_apdu_t apdu ; sc_file_t * file = NULL ; u8 buf [ SC_MAX_APDU_BUFFER_SIZE ] , pathbuf [ SC_MAX_PATH_SIZE ] , * path = pathbuf ; unsigned int i ; int r , pathlen ; assert ( card != NULL && in_path != NULL ) ; ctx = card -> ctx ; memcpy ( path , in_path -> value , in_path -> len ) ; pathlen = in_path -> len ; sc_format_apdu ( card , & apdu , SC_APDU_CASE_4_SHORT , 0xA4 , 0 , 0x04 ) ; switch ( in_path -> type ) { case SC_PATH_TYPE_FILE_ID : if ( pathlen != 2 ) return SC_ERROR_INVALID_ARGUMENTS ; case SC_PATH_TYPE_FROM_CURRENT : apdu . p1 = 9 ; break ; case SC_PATH_TYPE_DF_NAME : apdu . p1 = 4 ; break ; case SC_PATH_TYPE_PATH : apdu . p1 = 8 ; if ( pathlen >= 2 && memcmp ( path , \"\\\\x3F\\\\x00\" , 2 ) == 0 ) path += 2 , pathlen -= 2 ; if ( pathlen == 0 ) apdu . p1 = 0 ; break ; case SC_PATH_TYPE_PARENT : apdu . p1 = 3 ; pathlen = 0 ; break ; default : SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_INVALID_ARGUMENTS ) ; } if ( pathlen == 0 ) apdu . cse = SC_APDU_CASE_2_SHORT ; apdu . lc = pathlen ; apdu . data = path ; apdu . datalen = pathlen ; if ( file_out != NULL ) { apdu . resp = buf ; apdu . resplen = sizeof ( buf ) ; apdu . le = 256 ; } else { apdu . resplen = 0 ; apdu . le = 0 ; apdu . p2 = 0x0C ; apdu . cse = ( pathlen == 0 ) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT ; } r = sc_transmit_apdu ( card , & apdu ) ; SC_TEST_RET ( ctx , SC_LOG_DEBUG_NORMAL , r , \"APDUtransmitfailed\" ) ; r = sc_check_sw ( card , apdu . sw1 , apdu . sw2 ) ; if ( r || file_out == NULL ) SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , r ) ; if ( apdu . resplen < 1 || apdu . resp [ 0 ] != 0x62 ) { sc_debug ( ctx , SC_LOG_DEBUG_NORMAL , \"receivedinvalidtemplate%02X\\\\n\" , apdu . resp [ 0 ] ) ; SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_UNKNOWN_DATA_RECEIVED ) ; } file = sc_file_new ( ) ; if ( file == NULL ) SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_NORMAL , SC_ERROR_OUT_OF_MEMORY ) ; * file_out = file ; file -> path = * in_path ; for ( i = 2 ; i + 1 < apdu . resplen && i + 1 + apdu . resp [ i + 1 ] < apdu . resplen ; i += 2 + apdu . resp [ i + 1 ] ) { int j , len = apdu . resp [ i + 1 ] ; unsigned char type = apdu . resp [ i ] , * d = apdu . resp + i + 2 ; switch ( type ) { case 0x80 : case 0x81 : file -> size = 0 ; for ( j = 0 ; j < len ; ++ j ) file -> size = ( file -> size << 8 ) | d [ j ] ; break ; case 0x82 : file -> shareable = ( d [ 0 ] & 0x40 ) ? 1 : 0 ; file -> ef_structure = d [ 0 ] & 7 ; switch ( ( d [ 0 ] >> 3 ) & 7 ) { case 0 : file -> type = SC_FILE_TYPE_WORKING_EF ; break ; case 7 : file -> type = SC_FILE_TYPE_DF ; break ; default : sc_debug ( ctx , SC_LOG_DEBUG_NORMAL , \"invalidfiletype%02Xinfiledescriptor\\\\n\" , d [ 0 ] ) ; SC_FUNC_RETURN ( ctx , SC_LOG_DEBUG_VERBOSE , SC_ERROR_UNKNOWN_DATA_RECEIVED ) ; } break ; case 0x83 : file -> id = ( d [ 0 ] << 8 ) | d [ 1 ] ; break ; case 0x84 : memcpy ( file -> name , d , len ) ; file -> namelen = len ; break ; case 0x86 : sc_file_set_sec_attr ( file , d , len ) ; break ; default : if ( len > 0 ) sc_file_set_prop_attr ( file , d , len ) ; } } file -> magic = SC_FILE_MAGIC ; parse_sec_attr ( card , file , file -> sec_attr , file -> sec_attr_len ) ; return 0 ; }\n", "\n", "\n", "Target: fullpixel ) { ( void ) cpi ; ( void ) fullpixel ;\n", "\n", "Sources:\n", "0: CWE-119 static int rd_inter4x4_uv ( VP8_COMP * cpi , MACROBLOCK * x , int * rate , int * distortion , int fullpixel ) { vp8_build_inter4x4_predictors_mbuv ( & x -> e_mbd ) ; vp8_subtract_mbuv ( x -> src_diff , x -> src . u_buffer , x -> src . v_buffer , x -> src . uv_stride , & x -> e_mbd . predictor [ 256 ] , & x -> e_mbd . predictor [ 320 ] , 8 ) ; vp8_transform_mbuv ( x ) ; vp8_quantize_mbuv ( x ) ; * rate = rd_cost_mbuv ( x ) ; * distortion = vp8_mbuverror ( x ) / 4 ; return RDCOST ( x -> rdmult , x -> rddiv , * rate , * distortion ) ; }\n", "\n", "1: CWE-119 static int rd_inter16x16_uv ( VP8_COMP * cpi , MACROBLOCK * x , int * rate , int * distortion , int fullpixel ) { vp8_build_inter16x16_predictors_mbuv ( & x -> e_mbd ) ; vp8_subtract_mbuv ( x -> src_diff , x -> src . u_buffer , x -> src . v_buffer , x -> src . uv_stride , & x -> e_mbd . predictor [ 256 ] , & x -> e_mbd . predictor [ 320 ] , 8 ) ; vp8_transform_mbuv ( x ) ; vp8_quantize_mbuv ( x ) ; * rate = rd_cost_mbuv ( x ) ; * distortion = vp8_mbuverror ( x ) / 4 ; return RDCOST ( x -> rdmult , x -> rddiv , * rate , * distortion ) ; }\n", "\n", "\n", "Target: * buf ; struct stream packet = * s ; if ( ! s_check ( s ) ) { rdp_protocol_error ( \"lspci_process(),streamisinunstablestate\" , & packet ) ; }\n", "\n", "Sources:\n", "0: CWE-787 static void lspci_process ( STREAM s ) { unsigned int pkglen ; static char * rest = NULL ; char * buf ; pkglen = s -> end - s -> p ; buf = xmalloc ( pkglen + 1 ) ; STRNCPY ( buf , ( char * ) s -> p , pkglen + 1 ) ; str_handle_lines ( buf , & rest , lspci_process_line , NULL ) ; xfree ( buf ) ; }\n", "\n", "1: CWE-119 static void lspci_process ( STREAM s ) { unsigned int pkglen ; static char * rest = NULL ; char * buf ; pkglen = s -> end - s -> p ; buf = xmalloc ( pkglen + 1 ) ; STRNCPY ( buf , ( char * ) s -> p , pkglen + 1 ) ; str_handle_lines ( buf , & rest , lspci_process_line , NULL ) ; xfree ( buf ) ; }\n", "\n", "\n", "Target: , bool in_task_switch , struct desc_struct * desc seg ) ; if ( desc ) * desc = seg_desc ;\n", "\n", "Sources:\n", "0: CWE-000 static int __load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg , u8 cpl , bool in_task_switch ) { struct desc_struct seg_desc , old_desc ; u8 dpl , rpl ; unsigned err_vec = GP_VECTOR ; u32 err_code = 0 ; bool null_selector = ! ( selector & ~ 0x3 ) ; ulong desc_addr ; int ret ; u16 dummy ; u32 base3 = 0 ; memset ( & seg_desc , 0 , sizeof seg_desc ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) { ctxt -> ops -> get_segment ( ctxt , & dummy , & seg_desc , NULL , seg ) ; set_desc_base ( & seg_desc , selector << 4 ) ; goto load ; } else if ( seg <= VCPU_SREG_GS && ctxt -> mode == X86EMUL_MODE_VM86 ) { set_desc_base ( & seg_desc , selector << 4 ) ; set_desc_limit ( & seg_desc , 0xffff ) ; seg_desc . type = 3 ; seg_desc . p = 1 ; seg_desc . s = 1 ; seg_desc . dpl = 3 ; goto load ; } rpl = selector & 3 ; if ( ( seg == VCPU_SREG_CS || ( seg == VCPU_SREG_SS && ( ctxt -> mode != X86EMUL_MODE_PROT64 || rpl != cpl ) ) || seg == VCPU_SREG_TR ) && null_selector ) goto exception ; if ( seg == VCPU_SREG_TR && ( selector & ( 1 << 2 ) ) ) goto exception ; if ( null_selector ) goto load ; ret = read_segment_descriptor ( ctxt , selector , & seg_desc , & desc_addr ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; err_code = selector & 0xfffc ; err_vec = in_task_switch ? TS_VECTOR : GP_VECTOR ; if ( seg <= VCPU_SREG_GS && ! seg_desc . s ) goto exception ; if ( ! seg_desc . p ) { err_vec = ( seg == VCPU_SREG_SS ) ? SS_VECTOR : NP_VECTOR ; goto exception ; } dpl = seg_desc . dpl ; switch ( seg ) { case VCPU_SREG_SS : if ( rpl != cpl || ( seg_desc . type & 0xa ) != 0x2 || dpl != cpl ) goto exception ; break ; case VCPU_SREG_CS : if ( ! ( seg_desc . type & 8 ) ) goto exception ; if ( seg_desc . type & 4 ) { if ( dpl > cpl ) goto exception ; } else { if ( rpl > cpl || dpl != cpl ) goto exception ; } if ( seg_desc . d && seg_desc . l ) { u64 efer = 0 ; ctxt -> ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( efer & EFER_LMA ) goto exception ; } selector = ( selector & 0xfffc ) | cpl ; break ; case VCPU_SREG_TR : if ( seg_desc . s || ( seg_desc . type != 1 && seg_desc . type != 9 ) ) goto exception ; old_desc = seg_desc ; seg_desc . type |= 2 ; ret = ctxt -> ops -> cmpxchg_emulated ( ctxt , desc_addr , & old_desc , & seg_desc , sizeof ( seg_desc ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; break ; case VCPU_SREG_LDTR : if ( seg_desc . s || seg_desc . type != 2 ) goto exception ; break ; default : if ( ( seg_desc . type & 0xa ) == 0x8 || ( ( ( seg_desc . type & 0xc ) != 0xc ) && ( rpl > dpl && cpl > dpl ) ) ) goto exception ; break ; } if ( seg_desc . s ) { seg_desc . type |= 1 ; ret = write_segment_descriptor ( ctxt , selector , & seg_desc ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } else if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) { ret = ctxt -> ops -> read_std ( ctxt , desc_addr + 8 , & base3 , sizeof ( base3 ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } load : ctxt -> ops -> set_segment ( ctxt , selector , & seg_desc , base3 , seg ) ; return X86EMUL_CONTINUE ; exception : return emulate_exception ( ctxt , err_vec , err_code , true ) ; }\n", "\n", "1: CWE-264 static int __load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg , u8 cpl , bool in_task_switch ) { struct desc_struct seg_desc , old_desc ; u8 dpl , rpl ; unsigned err_vec = GP_VECTOR ; u32 err_code = 0 ; bool null_selector = ! ( selector & ~ 0x3 ) ; ulong desc_addr ; int ret ; u16 dummy ; u32 base3 = 0 ; memset ( & seg_desc , 0 , sizeof seg_desc ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) { ctxt -> ops -> get_segment ( ctxt , & dummy , & seg_desc , NULL , seg ) ; set_desc_base ( & seg_desc , selector << 4 ) ; goto load ; } else if ( seg <= VCPU_SREG_GS && ctxt -> mode == X86EMUL_MODE_VM86 ) { set_desc_base ( & seg_desc , selector << 4 ) ; set_desc_limit ( & seg_desc , 0xffff ) ; seg_desc . type = 3 ; seg_desc . p = 1 ; seg_desc . s = 1 ; seg_desc . dpl = 3 ; goto load ; } rpl = selector & 3 ; if ( ( seg == VCPU_SREG_CS || ( seg == VCPU_SREG_SS && ( ctxt -> mode != X86EMUL_MODE_PROT64 || rpl != cpl ) ) || seg == VCPU_SREG_TR ) && null_selector ) goto exception ; if ( seg == VCPU_SREG_TR && ( selector & ( 1 << 2 ) ) ) goto exception ; if ( null_selector ) goto load ; ret = read_segment_descriptor ( ctxt , selector , & seg_desc , & desc_addr ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; err_code = selector & 0xfffc ; err_vec = in_task_switch ? TS_VECTOR : GP_VECTOR ; if ( seg <= VCPU_SREG_GS && ! seg_desc . s ) goto exception ; if ( ! seg_desc . p ) { err_vec = ( seg == VCPU_SREG_SS ) ? SS_VECTOR : NP_VECTOR ; goto exception ; } dpl = seg_desc . dpl ; switch ( seg ) { case VCPU_SREG_SS : if ( rpl != cpl || ( seg_desc . type & 0xa ) != 0x2 || dpl != cpl ) goto exception ; break ; case VCPU_SREG_CS : if ( ! ( seg_desc . type & 8 ) ) goto exception ; if ( seg_desc . type & 4 ) { if ( dpl > cpl ) goto exception ; } else { if ( rpl > cpl || dpl != cpl ) goto exception ; } if ( seg_desc . d && seg_desc . l ) { u64 efer = 0 ; ctxt -> ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( efer & EFER_LMA ) goto exception ; } selector = ( selector & 0xfffc ) | cpl ; break ; case VCPU_SREG_TR : if ( seg_desc . s || ( seg_desc . type != 1 && seg_desc . type != 9 ) ) goto exception ; old_desc = seg_desc ; seg_desc . type |= 2 ; ret = ctxt -> ops -> cmpxchg_emulated ( ctxt , desc_addr , & old_desc , & seg_desc , sizeof ( seg_desc ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; break ; case VCPU_SREG_LDTR : if ( seg_desc . s || seg_desc . type != 2 ) goto exception ; break ; default : if ( ( seg_desc . type & 0xa ) == 0x8 || ( ( ( seg_desc . type & 0xc ) != 0xc ) && ( rpl > dpl && cpl > dpl ) ) ) goto exception ; break ; } if ( seg_desc . s ) { seg_desc . type |= 1 ; ret = write_segment_descriptor ( ctxt , selector , & seg_desc ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } else if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) { ret = ctxt -> ops -> read_std ( ctxt , desc_addr + 8 , & base3 , sizeof ( base3 ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } load : ctxt -> ops -> set_segment ( ctxt , selector , & seg_desc , base3 , seg ) ; return X86EMUL_CONTINUE ; exception : return emulate_exception ( ctxt , err_vec , err_code , true ) ; }\n", "\n", "\n", "Target: out_free_buffer ; } } else if ( request_size < 0 ) { rc = - EINVAL ; goto out_free_buffer ;\n", "\n", "Sources:\n", "0: CWE-189 static long pmcraid_ioctl_passthrough ( struct pmcraid_instance * pinstance , unsigned int ioctl_cmd , unsigned int buflen , unsigned long arg ) { struct pmcraid_passthrough_ioctl_buffer * buffer ; struct pmcraid_ioarcb * ioarcb ; struct pmcraid_cmd * cmd ; struct pmcraid_cmd * cancel_cmd ; unsigned long request_buffer ; unsigned long request_offset ; unsigned long lock_flags ; void * ioasa ; u32 ioasc ; int request_size ; int buffer_size ; u8 access , direction ; int rc = 0 ; if ( pinstance -> ioa_reset_in_progress ) { rc = wait_event_interruptible_timeout ( pinstance -> reset_wait_q , ! pinstance -> ioa_reset_in_progress , msecs_to_jiffies ( 10000 ) ) ; if ( ! rc ) return - ETIMEDOUT ; else if ( rc < 0 ) return - ERESTARTSYS ; } if ( pinstance -> ioa_state != IOA_STATE_OPERATIONAL ) { pmcraid_err ( \"IOAisnotoperational\\\\n\" ) ; return - ENOTTY ; } buffer_size = sizeof ( struct pmcraid_passthrough_ioctl_buffer ) ; buffer = kmalloc ( buffer_size , GFP_KERNEL ) ; if ( ! buffer ) { pmcraid_err ( \"nomemoryforpassthroughbuffer\\\\n\" ) ; return - ENOMEM ; } request_offset = offsetof ( struct pmcraid_passthrough_ioctl_buffer , request_buffer ) ; request_buffer = arg + request_offset ; rc = __copy_from_user ( buffer , ( struct pmcraid_passthrough_ioctl_buffer * ) arg , sizeof ( struct pmcraid_passthrough_ioctl_buffer ) ) ; ioasa = ( void * ) ( arg + offsetof ( struct pmcraid_passthrough_ioctl_buffer , ioasa ) ) ; if ( rc ) { pmcraid_err ( \"ioctl:can\\'tcopypassthroughbuffer\\\\n\" ) ; rc = - EFAULT ; goto out_free_buffer ; } request_size = buffer -> ioarcb . data_transfer_length ; if ( buffer -> ioarcb . request_flags0 & TRANSFER_DIR_WRITE ) { access = VERIFY_READ ; direction = DMA_TO_DEVICE ; } else { access = VERIFY_WRITE ; direction = DMA_FROM_DEVICE ; } if ( request_size > 0 ) { rc = access_ok ( access , arg , request_offset + request_size ) ; if ( ! rc ) { rc = - EFAULT ; goto out_free_buffer ; } } else if ( request_size < 0 ) { rc = - EINVAL ; goto out_free_buffer ; } if ( buffer -> ioarcb . add_cmd_param_length > PMCRAID_ADD_CMD_PARAM_LEN ) { rc = - EINVAL ; goto out_free_buffer ; } cmd = pmcraid_get_free_cmd ( pinstance ) ; if ( ! cmd ) { pmcraid_err ( \"freecommandblockisnotavailable\\\\n\" ) ; rc = - ENOMEM ; goto out_free_buffer ; } cmd -> scsi_cmd = NULL ; ioarcb = & ( cmd -> ioa_cb -> ioarcb ) ; ioarcb -> resource_handle = buffer -> ioarcb . resource_handle ; ioarcb -> data_transfer_length = buffer -> ioarcb . data_transfer_length ; ioarcb -> cmd_timeout = buffer -> ioarcb . cmd_timeout ; ioarcb -> request_type = buffer -> ioarcb . request_type ; ioarcb -> request_flags0 = buffer -> ioarcb . request_flags0 ; ioarcb -> request_flags1 = buffer -> ioarcb . request_flags1 ; memcpy ( ioarcb -> cdb , buffer -> ioarcb . cdb , PMCRAID_MAX_CDB_LEN ) ; if ( buffer -> ioarcb . add_cmd_param_length ) { ioarcb -> add_cmd_param_length = buffer -> ioarcb . add_cmd_param_length ; ioarcb -> add_cmd_param_offset = buffer -> ioarcb . add_cmd_param_offset ; memcpy ( ioarcb -> add_data . u . add_cmd_params , buffer -> ioarcb . add_data . u . add_cmd_params , buffer -> ioarcb . add_cmd_param_length ) ; } ioarcb -> hrrq_id = atomic_add_return ( 1 , & ( pinstance -> last_message_id ) ) % pinstance -> num_hrrq ; if ( request_size ) { rc = pmcraid_build_passthrough_ioadls ( cmd , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"couldn\\'tbuildpassthroughioadls\\\\n\" ) ; goto out_free_buffer ; } } if ( direction == DMA_TO_DEVICE && request_size > 0 ) { rc = pmcraid_copy_sglist ( cmd -> sglist , request_buffer , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"failedtocopyuserbuffer\\\\n\" ) ; goto out_free_sglist ; } } cmd -> cmd_done = pmcraid_internal_done ; init_completion ( & cmd -> wait_for_completion ) ; cmd -> completion_req = 1 ; pmcraid_info ( \"command(%d)(CDB[0]=%x)for%x\\\\n\" , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . response_handle ) >> 2 , cmd -> ioa_cb -> ioarcb . cdb [ 0 ] , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . resource_handle ) ) ; spin_lock_irqsave ( pinstance -> host -> host_lock , lock_flags ) ; _pmcraid_fire_command ( cmd ) ; spin_unlock_irqrestore ( pinstance -> host -> host_lock , lock_flags ) ; buffer -> ioarcb . cmd_timeout = 0 ; if ( buffer -> ioarcb . cmd_timeout == 0 ) { wait_for_completion ( & cmd -> wait_for_completion ) ; } else if ( ! wait_for_completion_timeout ( & cmd -> wait_for_completion , msecs_to_jiffies ( buffer -> ioarcb . cmd_timeout * 1000 ) ) ) { pmcraid_info ( \"abortingcmd%d(CDB[0]=%x)duetotimeout\\\\n\" , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . response_handle >> 2 ) , cmd -> ioa_cb -> ioarcb . cdb [ 0 ] ) ; spin_lock_irqsave ( pinstance -> host -> host_lock , lock_flags ) ; cancel_cmd = pmcraid_abort_cmd ( cmd ) ; spin_unlock_irqrestore ( pinstance -> host -> host_lock , lock_flags ) ; if ( cancel_cmd ) { wait_for_completion ( & cancel_cmd -> wait_for_completion ) ; ioasc = cancel_cmd -> ioa_cb -> ioasa . ioasc ; pmcraid_return_cmd ( cancel_cmd ) ; if ( ioasc == PMCRAID_IOASC_IOA_WAS_RESET || PMCRAID_IOASC_SENSE_KEY ( ioasc ) == 0x00 ) { if ( ioasc != PMCRAID_IOASC_GC_IOARCB_NOTFOUND ) rc = - ETIMEDOUT ; goto out_handle_response ; } } if ( ! wait_for_completion_timeout ( & cmd -> wait_for_completion , msecs_to_jiffies ( 150 * 1000 ) ) ) { pmcraid_reset_bringup ( cmd -> drv_inst ) ; rc = - ETIMEDOUT ; } } out_handle_response : if ( copy_to_user ( ioasa , & cmd -> ioa_cb -> ioasa , sizeof ( struct pmcraid_ioasa ) ) ) { pmcraid_err ( \"failedtocopyioasabuffertouser\\\\n\" ) ; rc = - EFAULT ; } else if ( direction == DMA_FROM_DEVICE && request_size > 0 ) { rc = pmcraid_copy_sglist ( cmd -> sglist , request_buffer , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"failedtocopyuserbuffer\\\\n\" ) ; rc = - EFAULT ; } } out_free_sglist : pmcraid_release_passthrough_ioadls ( cmd , request_size , direction ) ; pmcraid_return_cmd ( cmd ) ; out_free_buffer : kfree ( buffer ) ; return rc ; }\n", "\n", "1: CWE-400 static long pmcraid_ioctl_passthrough ( struct pmcraid_instance * pinstance , unsigned int ioctl_cmd , unsigned int buflen , unsigned long arg ) { struct pmcraid_passthrough_ioctl_buffer * buffer ; struct pmcraid_ioarcb * ioarcb ; struct pmcraid_cmd * cmd ; struct pmcraid_cmd * cancel_cmd ; unsigned long request_buffer ; unsigned long request_offset ; unsigned long lock_flags ; void * ioasa ; u32 ioasc ; int request_size ; int buffer_size ; u8 access , direction ; int rc = 0 ; if ( pinstance -> ioa_reset_in_progress ) { rc = wait_event_interruptible_timeout ( pinstance -> reset_wait_q , ! pinstance -> ioa_reset_in_progress , msecs_to_jiffies ( 10000 ) ) ; if ( ! rc ) return - ETIMEDOUT ; else if ( rc < 0 ) return - ERESTARTSYS ; } if ( pinstance -> ioa_state != IOA_STATE_OPERATIONAL ) { pmcraid_err ( \"IOAisnotoperational\\\\n\" ) ; return - ENOTTY ; } buffer_size = sizeof ( struct pmcraid_passthrough_ioctl_buffer ) ; buffer = kmalloc ( buffer_size , GFP_KERNEL ) ; if ( ! buffer ) { pmcraid_err ( \"nomemoryforpassthroughbuffer\\\\n\" ) ; return - ENOMEM ; } request_offset = offsetof ( struct pmcraid_passthrough_ioctl_buffer , request_buffer ) ; request_buffer = arg + request_offset ; rc = __copy_from_user ( buffer , ( struct pmcraid_passthrough_ioctl_buffer * ) arg , sizeof ( struct pmcraid_passthrough_ioctl_buffer ) ) ; ioasa = ( void * ) ( arg + offsetof ( struct pmcraid_passthrough_ioctl_buffer , ioasa ) ) ; if ( rc ) { pmcraid_err ( \"ioctl:can\\'tcopypassthroughbuffer\\\\n\" ) ; rc = - EFAULT ; goto out_free_buffer ; } request_size = buffer -> ioarcb . data_transfer_length ; if ( buffer -> ioarcb . request_flags0 & TRANSFER_DIR_WRITE ) { access = VERIFY_READ ; direction = DMA_TO_DEVICE ; } else { access = VERIFY_WRITE ; direction = DMA_FROM_DEVICE ; } if ( request_size > 0 ) { rc = access_ok ( access , arg , request_offset + request_size ) ; if ( ! rc ) { rc = - EFAULT ; goto out_free_buffer ; } } else if ( request_size < 0 ) { rc = - EINVAL ; goto out_free_buffer ; } if ( buffer -> ioarcb . add_cmd_param_length > PMCRAID_ADD_CMD_PARAM_LEN ) { rc = - EINVAL ; goto out_free_buffer ; } cmd = pmcraid_get_free_cmd ( pinstance ) ; if ( ! cmd ) { pmcraid_err ( \"freecommandblockisnotavailable\\\\n\" ) ; rc = - ENOMEM ; goto out_free_buffer ; } cmd -> scsi_cmd = NULL ; ioarcb = & ( cmd -> ioa_cb -> ioarcb ) ; ioarcb -> resource_handle = buffer -> ioarcb . resource_handle ; ioarcb -> data_transfer_length = buffer -> ioarcb . data_transfer_length ; ioarcb -> cmd_timeout = buffer -> ioarcb . cmd_timeout ; ioarcb -> request_type = buffer -> ioarcb . request_type ; ioarcb -> request_flags0 = buffer -> ioarcb . request_flags0 ; ioarcb -> request_flags1 = buffer -> ioarcb . request_flags1 ; memcpy ( ioarcb -> cdb , buffer -> ioarcb . cdb , PMCRAID_MAX_CDB_LEN ) ; if ( buffer -> ioarcb . add_cmd_param_length ) { ioarcb -> add_cmd_param_length = buffer -> ioarcb . add_cmd_param_length ; ioarcb -> add_cmd_param_offset = buffer -> ioarcb . add_cmd_param_offset ; memcpy ( ioarcb -> add_data . u . add_cmd_params , buffer -> ioarcb . add_data . u . add_cmd_params , buffer -> ioarcb . add_cmd_param_length ) ; } ioarcb -> hrrq_id = atomic_add_return ( 1 , & ( pinstance -> last_message_id ) ) % pinstance -> num_hrrq ; if ( request_size ) { rc = pmcraid_build_passthrough_ioadls ( cmd , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"couldn\\'tbuildpassthroughioadls\\\\n\" ) ; goto out_free_buffer ; } } if ( direction == DMA_TO_DEVICE && request_size > 0 ) { rc = pmcraid_copy_sglist ( cmd -> sglist , request_buffer , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"failedtocopyuserbuffer\\\\n\" ) ; goto out_free_sglist ; } } cmd -> cmd_done = pmcraid_internal_done ; init_completion ( & cmd -> wait_for_completion ) ; cmd -> completion_req = 1 ; pmcraid_info ( \"command(%d)(CDB[0]=%x)for%x\\\\n\" , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . response_handle ) >> 2 , cmd -> ioa_cb -> ioarcb . cdb [ 0 ] , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . resource_handle ) ) ; spin_lock_irqsave ( pinstance -> host -> host_lock , lock_flags ) ; _pmcraid_fire_command ( cmd ) ; spin_unlock_irqrestore ( pinstance -> host -> host_lock , lock_flags ) ; buffer -> ioarcb . cmd_timeout = 0 ; if ( buffer -> ioarcb . cmd_timeout == 0 ) { wait_for_completion ( & cmd -> wait_for_completion ) ; } else if ( ! wait_for_completion_timeout ( & cmd -> wait_for_completion , msecs_to_jiffies ( buffer -> ioarcb . cmd_timeout * 1000 ) ) ) { pmcraid_info ( \"abortingcmd%d(CDB[0]=%x)duetotimeout\\\\n\" , le32_to_cpu ( cmd -> ioa_cb -> ioarcb . response_handle >> 2 ) , cmd -> ioa_cb -> ioarcb . cdb [ 0 ] ) ; spin_lock_irqsave ( pinstance -> host -> host_lock , lock_flags ) ; cancel_cmd = pmcraid_abort_cmd ( cmd ) ; spin_unlock_irqrestore ( pinstance -> host -> host_lock , lock_flags ) ; if ( cancel_cmd ) { wait_for_completion ( & cancel_cmd -> wait_for_completion ) ; ioasc = cancel_cmd -> ioa_cb -> ioasa . ioasc ; pmcraid_return_cmd ( cancel_cmd ) ; if ( ioasc == PMCRAID_IOASC_IOA_WAS_RESET || PMCRAID_IOASC_SENSE_KEY ( ioasc ) == 0x00 ) { if ( ioasc != PMCRAID_IOASC_GC_IOARCB_NOTFOUND ) rc = - ETIMEDOUT ; goto out_handle_response ; } } if ( ! wait_for_completion_timeout ( & cmd -> wait_for_completion , msecs_to_jiffies ( 150 * 1000 ) ) ) { pmcraid_reset_bringup ( cmd -> drv_inst ) ; rc = - ETIMEDOUT ; } } out_handle_response : if ( copy_to_user ( ioasa , & cmd -> ioa_cb -> ioasa , sizeof ( struct pmcraid_ioasa ) ) ) { pmcraid_err ( \"failedtocopyioasabuffertouser\\\\n\" ) ; rc = - EFAULT ; } else if ( direction == DMA_FROM_DEVICE && request_size > 0 ) { rc = pmcraid_copy_sglist ( cmd -> sglist , request_buffer , request_size , direction ) ; if ( rc ) { pmcraid_err ( \"failedtocopyuserbuffer\\\\n\" ) ; rc = - EFAULT ; } } out_free_sglist : pmcraid_release_passthrough_ioadls ( cmd , request_size , direction ) ; pmcraid_return_cmd ( cmd ) ; out_free_buffer : kfree ( buffer ) ; return rc ; }\n", "\n", "\n", "Target: desc_ptr dt ; unsigned long cr4 ; ; vmcs_writel ( HOST_CR3 , read_cr3 ( ) ) ; cr4 = read_cr4 ( ) ; vmcs_writel ( HOST_CR4 , cr4 ) ; vmx -> host_state . vmcs_host_cr4 = cr4 ; vmcs_write16 (\n", "\n", "Sources:\n", "0: CWE-400 static void vmx_set_constant_host_state ( struct vcpu_vmx * vmx ) { u32 low32 , high32 ; unsigned long tmpl ; struct desc_ptr dt ; vmcs_writel ( HOST_CR0 , read_cr0 ( ) & ~ X86_CR0_TS ) ; vmcs_writel ( HOST_CR4 , read_cr4 ( ) ) ; vmcs_writel ( HOST_CR3 , read_cr3 ( ) ) ; vmcs_write16 ( HOST_CS_SELECTOR , __KERNEL_CS ) ; # ifdef CONFIG_X86_64 vmcs_write16 ( HOST_DS_SELECTOR , 0 ) ; vmcs_write16 ( HOST_ES_SELECTOR , 0 ) ; # else vmcs_write16 ( HOST_DS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_ES_SELECTOR , __KERNEL_DS ) ; # endif vmcs_write16 ( HOST_SS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_TR_SELECTOR , GDT_ENTRY_TSS * 8 ) ; native_store_idt ( & dt ) ; vmcs_writel ( HOST_IDTR_BASE , dt . address ) ; vmx -> host_idt_base = dt . address ; vmcs_writel ( HOST_RIP , vmx_return ) ; rdmsr ( MSR_IA32_SYSENTER_CS , low32 , high32 ) ; vmcs_write32 ( HOST_IA32_SYSENTER_CS , low32 ) ; rdmsrl ( MSR_IA32_SYSENTER_EIP , tmpl ) ; vmcs_writel ( HOST_IA32_SYSENTER_EIP , tmpl ) ; if ( vmcs_config . vmexit_ctrl & VM_EXIT_LOAD_IA32_PAT ) { rdmsr ( MSR_IA32_CR_PAT , low32 , high32 ) ; vmcs_write64 ( HOST_IA32_PAT , low32 | ( ( u64 ) high32 << 32 ) ) ; } }\n", "\n", "1: CWE-399 static void vmx_set_constant_host_state ( struct vcpu_vmx * vmx ) { u32 low32 , high32 ; unsigned long tmpl ; struct desc_ptr dt ; vmcs_writel ( HOST_CR0 , read_cr0 ( ) & ~ X86_CR0_TS ) ; vmcs_writel ( HOST_CR4 , read_cr4 ( ) ) ; vmcs_writel ( HOST_CR3 , read_cr3 ( ) ) ; vmcs_write16 ( HOST_CS_SELECTOR , __KERNEL_CS ) ; # ifdef CONFIG_X86_64 vmcs_write16 ( HOST_DS_SELECTOR , 0 ) ; vmcs_write16 ( HOST_ES_SELECTOR , 0 ) ; # else vmcs_write16 ( HOST_DS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_ES_SELECTOR , __KERNEL_DS ) ; # endif vmcs_write16 ( HOST_SS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_TR_SELECTOR , GDT_ENTRY_TSS * 8 ) ; native_store_idt ( & dt ) ; vmcs_writel ( HOST_IDTR_BASE , dt . address ) ; vmx -> host_idt_base = dt . address ; vmcs_writel ( HOST_RIP , vmx_return ) ; rdmsr ( MSR_IA32_SYSENTER_CS , low32 , high32 ) ; vmcs_write32 ( HOST_IA32_SYSENTER_CS , low32 ) ; rdmsrl ( MSR_IA32_SYSENTER_EIP , tmpl ) ; vmcs_writel ( HOST_IA32_SYSENTER_EIP , tmpl ) ; if ( vmcs_config . vmexit_ctrl & VM_EXIT_LOAD_IA32_PAT ) { rdmsr ( MSR_IA32_CR_PAT , low32 , high32 ) ; vmcs_write64 ( HOST_IA32_PAT , low32 | ( ( u64 ) high32 << 32 ) ) ; } }\n", "\n", "\n", "Target: map = { 0 , 0 ,\n", "\n", "Sources:\n", "0: CWE-119 static void set_active_map ( const vpx_codec_enc_cfg_t * cfg , vpx_codec_ctx_t * codec ) { unsigned int i ; vpx_active_map_t map = { 0 } ; map . rows = ( cfg -> g_h + 15 ) / 16 ; map . cols = ( cfg -> g_w + 15 ) / 16 ; map . active_map = ( uint8_t * ) malloc ( map . rows * map . cols ) ; for ( i = 0 ; i < map . rows * map . cols ; ++ i ) map . active_map [ i ] = i % 2 ; if ( vpx_codec_control ( codec , VP8E_SET_ACTIVEMAP , & map ) ) die_codec ( codec , \"Failedtosetactivemap\" ) ; free ( map . active_map ) ; }\n", "\n", "1: CWE-119 static void unset_active_map ( const vpx_codec_enc_cfg_t * cfg , vpx_codec_ctx_t * codec ) { vpx_active_map_t map = { 0 } ; map . rows = ( cfg -> g_h + 15 ) / 16 ; map . cols = ( cfg -> g_w + 15 ) / 16 ; map . active_map = NULL ; if ( vpx_codec_control ( codec , VP8E_SET_ACTIVEMAP , & map ) ) die_codec ( codec , \"Failedtosetactivemap\" ) ; }\n", "\n", "\n", "Target: * key ; } * pair it ) ; for ( it\n", "\n", "Sources:\n", "0: CWE-416 void comps_objmrtree_unite ( COMPS_ObjMRTree * rt1 , COMPS_ObjMRTree * rt2 ) { COMPS_HSList * tmplist , * tmp_subnodes ; COMPS_HSListItem * it ; COMPS_ObjListIt * it2 ; struct Pair { COMPS_HSList * subnodes ; char * key ; char added ; } * pair , * parent_pair ; pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = rt2 -> subnodes ; pair -> key = NULL ; tmplist = comps_hslist_create ( ) ; comps_hslist_init ( tmplist , NULL , NULL , & free ) ; comps_hslist_append ( tmplist , pair , 0 ) ; while ( tmplist -> first != NULL ) { it = tmplist -> first ; comps_hslist_remove ( tmplist , tmplist -> first ) ; tmp_subnodes = ( ( struct Pair * ) it -> data ) -> subnodes ; parent_pair = ( struct Pair * ) it -> data ; free ( it ) ; pair -> added = 0 ; for ( it = tmp_subnodes -> first ; it != NULL ; it = it -> next ) { pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = ( ( COMPS_ObjMRTreeData * ) it -> data ) -> subnodes ; if ( parent_pair -> key != NULL ) { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key ) + strlen ( parent_pair -> key ) + 1 ) ) ; memcpy ( pair -> key , parent_pair -> key , sizeof ( char ) * strlen ( parent_pair -> key ) ) ; memcpy ( pair -> key + strlen ( parent_pair -> key ) , ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } else { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key ) + 1 ) ) ; memcpy ( pair -> key , ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } if ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> data -> first != NULL ) { for ( it2 = ( ( COMPS_ObjMRTreeData * ) it -> data ) -> data -> first ; it2 != NULL ; it2 = it2 -> next ) { comps_objmrtree_set ( rt1 , pair -> key , it2 -> comps_obj ) ; } if ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } else { if ( ( ( COMPS_ObjMRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } } free ( parent_pair -> key ) ; free ( parent_pair ) ; } comps_hslist_destroy ( & tmplist ) ; }\n", "\n", "1: CWE-416 void comps_mrtree_unite ( COMPS_MRTree * rt1 , COMPS_MRTree * rt2 ) { COMPS_HSList * tmplist , * tmp_subnodes ; COMPS_HSListItem * it , * it2 ; struct Pair { COMPS_HSList * subnodes ; char * key ; char added ; } * pair , * parent_pair ; pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = rt2 -> subnodes ; pair -> key = NULL ; tmplist = comps_hslist_create ( ) ; comps_hslist_init ( tmplist , NULL , NULL , & free ) ; comps_hslist_append ( tmplist , pair , 0 ) ; while ( tmplist -> first != NULL ) { it = tmplist -> first ; comps_hslist_remove ( tmplist , tmplist -> first ) ; tmp_subnodes = ( ( struct Pair * ) it -> data ) -> subnodes ; parent_pair = ( struct Pair * ) it -> data ; free ( it ) ; pair -> added = 0 ; for ( it = tmp_subnodes -> first ; it != NULL ; it = it -> next ) { pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes ; if ( parent_pair -> key != NULL ) { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + strlen ( parent_pair -> key ) + 1 ) ) ; memcpy ( pair -> key , parent_pair -> key , sizeof ( char ) * strlen ( parent_pair -> key ) ) ; memcpy ( pair -> key + strlen ( parent_pair -> key ) , ( ( COMPS_MRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } else { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; memcpy ( pair -> key , ( ( COMPS_MRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } if ( ( ( COMPS_MRTreeData * ) it -> data ) -> data -> first != NULL ) { for ( it2 = ( ( COMPS_MRTreeData * ) it -> data ) -> data -> first ; it2 != NULL ; it2 = it2 -> next ) { comps_mrtree_set ( rt1 , pair -> key , it2 -> data ) ; } if ( ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } else { if ( ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } } free ( parent_pair -> key ) ; free ( parent_pair ) ; } comps_hslist_destroy ( & tmplist ) ; }\n", "\n", "\n", "Target: ( ret = ff_set_dimensions ( avctx , s -> width s -> height ) ) <\n", "\n", "Sources:\n", "0: CWE-000 static av_cold int vqa_decode_init ( AVCodecContext * avctx ) { VqaContext * s = avctx -> priv_data ; int i , j , codebook_index , ret ; s -> avctx = avctx ; avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; if ( s -> avctx -> extradata_size != VQA_HEADER_SIZE ) { av_log ( s -> avctx , AV_LOG_ERROR , \"expectedextradatasizeof%d\\\\n\" , VQA_HEADER_SIZE ) ; return AVERROR ( EINVAL ) ; } s -> vqa_version = s -> avctx -> extradata [ 0 ] ; switch ( s -> vqa_version ) { case 1 : case 2 : break ; case 3 : avpriv_report_missing_feature ( avctx , \"VQAVersion%d\" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; default : avpriv_request_sample ( avctx , \"VQAVersion%i\" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; } s -> width = AV_RL16 ( & s -> avctx -> extradata [ 6 ] ) ; s -> height = AV_RL16 ( & s -> avctx -> extradata [ 8 ] ) ; if ( ( ret = av_image_check_size ( s -> width , s -> height , 0 , avctx ) ) < 0 ) { s -> width = s -> height = 0 ; return ret ; } s -> vector_width = s -> avctx -> extradata [ 10 ] ; s -> vector_height = s -> avctx -> extradata [ 11 ] ; s -> partial_count = s -> partial_countdown = s -> avctx -> extradata [ 13 ] ; if ( ( s -> vector_width != 4 ) || ( ( s -> vector_height != 2 ) && ( s -> vector_height != 4 ) ) ) { return AVERROR_INVALIDDATA ; } if ( s -> width % s -> vector_width || s -> height % s -> vector_height ) { av_log ( avctx , AV_LOG_ERROR , \"Imagesizenotmultipleofblocksize\\\\n\" ) ; return AVERROR_INVALIDDATA ; } s -> codebook_size = MAX_CODEBOOK_SIZE ; s -> codebook = av_malloc ( s -> codebook_size ) ; if ( ! s -> codebook ) goto fail ; s -> next_codebook_buffer = av_malloc ( s -> codebook_size ) ; if ( ! s -> next_codebook_buffer ) goto fail ; s -> decode_buffer_size = ( s -> width / s -> vector_width ) * ( s -> height / s -> vector_height ) * 2 ; s -> decode_buffer = av_mallocz ( s -> decode_buffer_size ) ; if ( ! s -> decode_buffer ) goto fail ; if ( s -> vector_height == 4 ) { codebook_index = 0xFF00 * 16 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 16 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } else { codebook_index = 0xF00 * 8 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 8 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } s -> next_codebook_buffer_index = 0 ; return 0 ; fail : av_freep ( & s -> codebook ) ; av_freep ( & s -> next_codebook_buffer ) ; av_freep ( & s -> decode_buffer ) ; return AVERROR ( ENOMEM ) ; }\n", "\n", "1: CWE-129 static av_cold int vqa_decode_init ( AVCodecContext * avctx ) { VqaContext * s = avctx -> priv_data ; int i , j , codebook_index , ret ; s -> avctx = avctx ; avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; if ( s -> avctx -> extradata_size != VQA_HEADER_SIZE ) { av_log ( s -> avctx , AV_LOG_ERROR , \"expectedextradatasizeof%d\\\\n\" , VQA_HEADER_SIZE ) ; return AVERROR ( EINVAL ) ; } s -> vqa_version = s -> avctx -> extradata [ 0 ] ; switch ( s -> vqa_version ) { case 1 : case 2 : break ; case 3 : avpriv_report_missing_feature ( avctx , \"VQAVersion%d\" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; default : avpriv_request_sample ( avctx , \"VQAVersion%i\" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; } s -> width = AV_RL16 ( & s -> avctx -> extradata [ 6 ] ) ; s -> height = AV_RL16 ( & s -> avctx -> extradata [ 8 ] ) ; if ( ( ret = av_image_check_size ( s -> width , s -> height , 0 , avctx ) ) < 0 ) { s -> width = s -> height = 0 ; return ret ; } s -> vector_width = s -> avctx -> extradata [ 10 ] ; s -> vector_height = s -> avctx -> extradata [ 11 ] ; s -> partial_count = s -> partial_countdown = s -> avctx -> extradata [ 13 ] ; if ( ( s -> vector_width != 4 ) || ( ( s -> vector_height != 2 ) && ( s -> vector_height != 4 ) ) ) { return AVERROR_INVALIDDATA ; } if ( s -> width % s -> vector_width || s -> height % s -> vector_height ) { av_log ( avctx , AV_LOG_ERROR , \"Imagesizenotmultipleofblocksize\\\\n\" ) ; return AVERROR_INVALIDDATA ; } s -> codebook_size = MAX_CODEBOOK_SIZE ; s -> codebook = av_malloc ( s -> codebook_size ) ; if ( ! s -> codebook ) goto fail ; s -> next_codebook_buffer = av_malloc ( s -> codebook_size ) ; if ( ! s -> next_codebook_buffer ) goto fail ; s -> decode_buffer_size = ( s -> width / s -> vector_width ) * ( s -> height / s -> vector_height ) * 2 ; s -> decode_buffer = av_mallocz ( s -> decode_buffer_size ) ; if ( ! s -> decode_buffer ) goto fail ; if ( s -> vector_height == 4 ) { codebook_index = 0xFF00 * 16 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 16 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } else { codebook_index = 0xF00 * 8 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 8 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } s -> next_codebook_buffer_index = 0 ; return 0 ; fail : av_freep ( & s -> codebook ) ; av_freep ( & s -> next_codebook_buffer ) ; av_freep ( & s -> decode_buffer ) ; return AVERROR ( ENOMEM ) ; }\n", "\n", "\n", "Target: size_t columns , rows ; rows = MagickMax ( GetImageListLength ( images ) , ( size_t ) ( ThreadResource ) ) ) AcquireQuantumMemory ( rows , sizeof ( * NULL ) ; columns = MaxPixelChannels ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) rows ; i ++\n", "\n", "Sources:\n", "0: CWE-787 static PixelChannels * * AcquirePixelThreadSet ( const Image * images ) { const Image * next ; PixelChannels * * pixels ; register ssize_t i ; size_t columns , number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( PixelChannels * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( PixelChannels * * ) NULL ) return ( ( PixelChannels * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { register ssize_t j ; pixels [ i ] = ( PixelChannels * ) AcquireQuantumMemory ( columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( PixelChannels * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) columns ; j ++ ) { register ssize_t k ; for ( k = 0 ; k < MaxPixelChannels ; k ++ ) pixels [ i ] [ j ] . channel [ k ] = 0.0 ; } } return ( pixels ) ; }\n", "\n", "1: CWE-119 static PixelChannels * * AcquirePixelThreadSet ( const Image * images ) { const Image * next ; PixelChannels * * pixels ; register ssize_t i ; size_t columns , number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( PixelChannels * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( PixelChannels * * ) NULL ) return ( ( PixelChannels * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { register ssize_t j ; pixels [ i ] = ( PixelChannels * ) AcquireQuantumMemory ( columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( PixelChannels * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) columns ; j ++ ) { register ssize_t k ; for ( k = 0 ; k < MaxPixelChannels ; k ++ ) pixels [ i ] [ j ] . channel [ k ] = 0.0 ; } } return ( pixels ) ; }\n", "\n", "\n", "Target: } while ( indexw < width && } while ( indexw < width && } while ( indexw < width && } while ( indexw < width &&\n", "\n", "Sources:\n", "0: CWE-787 static int process_plane ( uint8 * in , int width , int height , uint8 * out , int size ) { UNUSED ( size ) ; int indexw ; int indexh ; int code ; int collen ; int replen ; int color ; int x ; int revcode ; uint8 * last_line ; uint8 * this_line ; uint8 * org_in ; uint8 * org_out ; org_in = in ; org_out = out ; last_line = 0 ; indexh = 0 ; while ( indexh < height ) { out = ( org_out + width * height * 4 ) - ( ( indexh + 1 ) * width * 4 ) ; color = 0 ; this_line = out ; indexw = 0 ; if ( last_line == 0 ) { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { color = CVAL ( in ) ; * out = color ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { * out = color ; out += 4 ; indexw ++ ; replen -- ; } } } else { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { x = CVAL ( in ) ; if ( x & 1 ) { x = x >> 1 ; x = x + 1 ; color = - x ; } else { x = x >> 1 ; color = x ; } x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; replen -- ; } } } indexh ++ ; last_line = this_line ; } return ( int ) ( in - org_in ) ; }\n", "\n", "1: CWE-119 static int process_plane ( uint8 * in , int width , int height , uint8 * out , int size ) { UNUSED ( size ) ; int indexw ; int indexh ; int code ; int collen ; int replen ; int color ; int x ; int revcode ; uint8 * last_line ; uint8 * this_line ; uint8 * org_in ; uint8 * org_out ; org_in = in ; org_out = out ; last_line = 0 ; indexh = 0 ; while ( indexh < height ) { out = ( org_out + width * height * 4 ) - ( ( indexh + 1 ) * width * 4 ) ; color = 0 ; this_line = out ; indexw = 0 ; if ( last_line == 0 ) { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { color = CVAL ( in ) ; * out = color ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { * out = color ; out += 4 ; indexw ++ ; replen -- ; } } } else { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { x = CVAL ( in ) ; if ( x & 1 ) { x = x >> 1 ; x = x + 1 ; color = - x ; } else { x = x >> 1 ; color = x ; } x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; replen -- ; } } } indexh ++ ; last_line = this_line ; } return ( int ) ( in - org_in ) ; }\n", "\n", "\n", "Target: static int encode_frame ( vpx_codec_ctx_t writer ) { int got_pkts = 0 ; NULL ) { got_pkts = 1 ; ; } } return got_pkts ;\n", "\n", "Sources:\n", "0: CWE-119 static void encode_frame ( vpx_codec_ctx_t * codec , vpx_image_t * img , int frame_index , int flags , VpxVideoWriter * writer ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( codec , img , frame_index , 1 , flags , VPX_DL_GOOD_QUALITY ) ; if ( res != VPX_CODEC_OK ) die_codec ( codec , \"Failedtoencodeframe\" ) ; while ( ( pkt = vpx_codec_get_cx_data ( codec , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { const int keyframe = ( pkt -> data . frame . flags & VPX_FRAME_IS_KEY ) != 0 ; if ( ! vpx_video_writer_write_frame ( writer , pkt -> data . frame . buf , pkt -> data . frame . sz , pkt -> data . frame . pts ) ) { die_codec ( codec , \"Failedtowritecompressedframe\" ) ; } printf ( keyframe ? \"K\" : \".\" ) ; fflush ( stdout ) ; } } } \n", "\n", "1: CWE-119 static void encode_frame ( vpx_codec_ctx_t * codec , vpx_image_t * img , int frame_index , VpxVideoWriter * writer ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( codec , img , frame_index , 1 , 0 , VPX_DL_GOOD_QUALITY ) ; if ( res != VPX_CODEC_OK ) die_codec ( codec , \"Failedtoencodeframe\" ) ; while ( ( pkt = vpx_codec_get_cx_data ( codec , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { const int keyframe = ( pkt -> data . frame . flags & VPX_FRAME_IS_KEY ) != 0 ; if ( ! vpx_video_writer_write_frame ( writer , pkt -> data . frame . buf , pkt -> data . frame . sz , pkt -> data . frame . pts ) ) { die_codec ( codec , \"Failedtowritecompressedframe\" ) ; } printf ( keyframe ? \"K\" : \".\" ) ; fflush ( stdout ) ; } } } \n", "\n", "2: CWE-119 static void encode_frame ( vpx_codec_ctx_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned int duration , vpx_enc_frame_flags_t flags , unsigned int deadline , VpxVideoWriter * writer ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( ctx , img , pts , duration , flags , deadline ) ; if ( res != VPX_CODEC_OK ) die_codec ( ctx , \"Failedtoencodeframe.\" ) ; while ( ( pkt = vpx_codec_get_cx_data ( ctx , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { const int keyframe = ( pkt -> data . frame . flags & VPX_FRAME_IS_KEY ) != 0 ; if ( ! vpx_video_writer_write_frame ( writer , pkt -> data . frame . buf , pkt -> data . frame . sz , pkt -> data . frame . pts ) ) die_codec ( ctx , \"Failedtowritecompressedframe.\" ) ; printf ( keyframe ? \"K\" : \".\" ) ; fflush ( stdout ) ; } } } \n", "\n", "\n", "Target: ; unsigned long eip , cs ; u16 old_cs ; int cpl ctxt ) ; struct desc_struct old_desc , new_desc ; const struct x86_emulate_ops * ops = ctxt -> ops ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) ops -> get_segment ( ctxt , & old_cs , & old_desc , NULL , VCPU_SREG_CS ) ; ctxt , & eip , ctxt -> ) return rc ; rc = ; rc = __load_segment_descriptor ( ctxt , cs , VCPU_SREG_CS , 0 , false , & new_desc ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; rc = assign_eip_far ( ctxt , eip , new_desc . l ) ; if ( rc != X86EMUL_CONTINUE ) { WARN_ON ( ! ctxt -> mode != X86EMUL_MODE_PROT64 ) ; ops -> set_segment ( ctxt , old_cs , & old_desc , 0 , VCPU_SREG_CS ) ; } return rc ;\n", "\n", "Sources:\n", "0: CWE-000 static int em_ret_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned long cs ; int cpl = ctxt -> ops -> cpl ( ctxt ) ; rc = emulate_pop ( ctxt , & ctxt -> _eip , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> op_bytes == 4 ) ctxt -> _eip = ( u32 ) ctxt -> _eip ; rc = emulate_pop ( ctxt , & cs , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> mode >= X86EMUL_MODE_PROT16 && ( cs & 3 ) > cpl ) return X86EMUL_UNHANDLEABLE ; rc = load_segment_descriptor ( ctxt , ( u16 ) cs , VCPU_SREG_CS ) ; return rc ; }\n", "\n", "1: CWE-264 static int em_ret_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned long cs ; int cpl = ctxt -> ops -> cpl ( ctxt ) ; rc = emulate_pop ( ctxt , & ctxt -> _eip , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> op_bytes == 4 ) ctxt -> _eip = ( u32 ) ctxt -> _eip ; rc = emulate_pop ( ctxt , & cs , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> mode >= X86EMUL_MODE_PROT16 && ( cs & 3 ) > cpl ) return X86EMUL_UNHANDLEABLE ; rc = load_segment_descriptor ( ctxt , ( u16 ) cs , VCPU_SREG_CS ) ; return rc ; }\n", "\n", "\n", "Target: . id ; if ( bufLen < 2 ) break ; += 2 ; bufLen -= 2 ;\n", "\n", "Sources:\n", "0: CWE-119 static int muscle_list_files ( sc_card_t * card , u8 * buf , size_t bufLen ) { muscle_private_t * priv = MUSCLE_DATA ( card ) ; mscfs_t * fs = priv -> fs ; int x ; int count = 0 ; mscfs_check_cache ( priv -> fs ) ; for ( x = 0 ; x < fs -> cache . size ; x ++ ) { u8 * oid = fs -> cache . array [ x ] . objectId . id ; sc_debug ( card -> ctx , SC_LOG_DEBUG_NORMAL , \"FILE:%02X%02X%02X%02X\\\\n\" , oid [ 0 ] , oid [ 1 ] , oid [ 2 ] , oid [ 3 ] ) ; if ( 0 == memcmp ( fs -> currentPath , oid , 2 ) ) { buf [ 0 ] = oid [ 2 ] ; buf [ 1 ] = oid [ 3 ] ; if ( buf [ 0 ] == 0x00 && buf [ 1 ] == 0x00 ) continue ; buf += 2 ; count += 2 ; } } return count ; }\n", "\n", "1: CWE-415 static int muscle_list_files ( sc_card_t * card , u8 * buf , size_t bufLen ) { muscle_private_t * priv = MUSCLE_DATA ( card ) ; mscfs_t * fs = priv -> fs ; int x ; int count = 0 ; mscfs_check_cache ( priv -> fs ) ; for ( x = 0 ; x < fs -> cache . size ; x ++ ) { u8 * oid = fs -> cache . array [ x ] . objectId . id ; sc_debug ( card -> ctx , SC_LOG_DEBUG_NORMAL , \"FILE:%02X%02X%02X%02X\\\\n\" , oid [ 0 ] , oid [ 1 ] , oid [ 2 ] , oid [ 3 ] ) ; if ( 0 == memcmp ( fs -> currentPath , oid , 2 ) ) { buf [ 0 ] = oid [ 2 ] ; buf [ 1 ] = oid [ 3 ] ; if ( buf [ 0 ] == 0x00 && buf [ 1 ] == 0x00 ) continue ; buf += 2 ; count += 2 ; } } return count ; }\n", "\n", "\n", "Target: ( ) ; save_cpu ( ) rv ; } fs_rdonly ( RUN_SECCOMP_DIR ) ; # endif set_caps ( ) ; FILE * rj\n", "\n", "Sources:\n", "0: CWE-732 int sandbox ( void * sandbox_arg ) { ( void ) sandbox_arg ; pid_t child_pid = getpid ( ) ; if ( arg_debug ) printf ( \"Initializingchildprocess\\\\n\" ) ; close ( parent_to_child_fds [ 1 ] ) ; close ( child_to_parent_fds [ 0 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; if ( arg_debug && child_pid == 1 ) printf ( \"PIDnamespaceinstalled\\\\n\" ) ; if ( cfg . hostname ) { if ( sethostname ( cfg . hostname , strlen ( cfg . hostname ) ) < 0 ) errExit ( \"sethostname\" ) ; } if ( mount ( NULL , \"/\" , NULL , MS_SLAVE | MS_REC , NULL ) < 0 ) { chk_chroot ( ) ; } preproc_mount_mnt_dir ( ) ; if ( mount ( LIBDIR \"/firejail\" , RUN_FIREJAIL_LIB_DIR , \"none\" , MS_BIND , NULL ) < 0 ) errExit ( \"mounting\" RUN_FIREJAIL_LIB_DIR ) ; if ( cfg . name ) fs_logger2 ( \"sandboxname:\" , cfg . name ) ; fs_logger2int ( \"sandboxpid:\" , ( int ) sandbox_pid ) ; if ( cfg . chrootdir ) fs_logger ( \"sandboxfilesystem:chroot\" ) ; else if ( arg_overlay ) fs_logger ( \"sandboxfilesystem:overlay\" ) ; else fs_logger ( \"sandboxfilesystem:local\" ) ; fs_logger ( \"installmountnamespace\" ) ; if ( arg_netfilter && any_bridge_configured ( ) ) { netfilter ( arg_netfilter_file ) ; } if ( arg_netfilter6 && any_bridge_configured ( ) ) { netfilter6 ( arg_netfilter6_file ) ; } int gw_cfg_failed = 0 ; if ( arg_nonetwork ) { net_if_up ( \"lo\" ) ; if ( arg_debug ) printf ( \"Networknamespaceenabled,onlyloopbackinterfaceavailable\\\\n\" ) ; } else if ( arg_netns ) { netns ( arg_netns ) ; if ( arg_debug ) printf ( \"Networknamespace\\'%s\\'activated\\\\n\" , arg_netns ) ; } else if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { net_if_up ( \"lo\" ) ; if ( mac_not_zero ( cfg . bridge0 . macsandbox ) ) net_config_mac ( cfg . bridge0 . devsandbox , cfg . bridge0 . macsandbox ) ; sandbox_if_up ( & cfg . bridge0 ) ; if ( mac_not_zero ( cfg . bridge1 . macsandbox ) ) net_config_mac ( cfg . bridge1 . devsandbox , cfg . bridge1 . macsandbox ) ; sandbox_if_up ( & cfg . bridge1 ) ; if ( mac_not_zero ( cfg . bridge2 . macsandbox ) ) net_config_mac ( cfg . bridge2 . devsandbox , cfg . bridge2 . macsandbox ) ; sandbox_if_up ( & cfg . bridge2 ) ; if ( mac_not_zero ( cfg . bridge3 . macsandbox ) ) net_config_mac ( cfg . bridge3 . devsandbox , cfg . bridge3 . macsandbox ) ; sandbox_if_up ( & cfg . bridge3 ) ; if ( cfg . interface0 . configured && cfg . interface0 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface0 . ip ) , cfg . interface0 . dev ) ; net_config_interface ( cfg . interface0 . dev , cfg . interface0 . ip , cfg . interface0 . mask , cfg . interface0 . mtu ) ; } if ( cfg . interface1 . configured && cfg . interface1 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface1 . ip ) , cfg . interface1 . dev ) ; net_config_interface ( cfg . interface1 . dev , cfg . interface1 . ip , cfg . interface1 . mask , cfg . interface1 . mtu ) ; } if ( cfg . interface2 . configured && cfg . interface2 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface2 . ip ) , cfg . interface2 . dev ) ; net_config_interface ( cfg . interface2 . dev , cfg . interface2 . ip , cfg . interface2 . mask , cfg . interface2 . mtu ) ; } if ( cfg . interface3 . configured && cfg . interface3 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface3 . ip ) , cfg . interface3 . dev ) ; net_config_interface ( cfg . interface3 . dev , cfg . interface3 . ip , cfg . interface3 . mask , cfg . interface3 . mtu ) ; } if ( cfg . defaultgw ) { if ( net_add_route ( 0 , 0 , cfg . defaultgw ) ) { fwarning ( \"cannotconfiguredefaultroute\\\\n\" ) ; gw_cfg_failed = 1 ; } } if ( arg_debug ) printf ( \"Networknamespaceenabled\\\\n\" ) ; } if ( ! arg_quiet ) { if ( any_bridge_configured ( ) || any_interface_configured ( ) || cfg . defaultgw || cfg . dns1 ) { fmessage ( \"\\\\n\" ) ; if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { if ( arg_scan ) sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 3 , PATH_FNET , \"printif\" , \"scan\" ) ; else sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 2 , PATH_FNET , \"printif\" ) ; } if ( cfg . defaultgw != 0 ) { if ( gw_cfg_failed ) fmessage ( \"Defaultgatewayconfigurationfailed\\\\n\" ) ; else fmessage ( \"Defaultgateway%d.%d.%d.%d\\\\n\" , PRINT_IP ( cfg . defaultgw ) ) ; } if ( cfg . dns1 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns1 ) ; if ( cfg . dns2 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns2 ) ; if ( cfg . dns3 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns3 ) ; if ( cfg . dns4 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns4 ) ; fmessage ( \"\\\\n\" ) ; } } if ( arg_nonetwork || any_bridge_configured ( ) || any_interface_configured ( ) ) { } else { EUID_USER ( ) ; env_ibus_load ( ) ; EUID_ROOT ( ) ; } # ifdef HAVE_SECCOMP if ( cfg . protocol ) { if ( arg_debug ) printf ( \"Buildprotocolfilter:%s\\\\n\" , cfg . protocol ) ; int rv = sbox_run ( SBOX_USER | SBOX_CAPS_NONE | SBOX_SECCOMP , 5 , PATH_FSECCOMP , \"protocol\" , \"build\" , cfg . protocol , RUN_SECCOMP_PROTOCOL ) ; if ( rv ) exit ( rv ) ; } if ( arg_seccomp && ( cfg . seccomp_list || cfg . seccomp_list_drop || cfg . seccomp_list_keep ) ) arg_seccomp_postexec = 1 ; # endif bool need_preload = arg_trace || arg_tracelog || arg_seccomp_postexec ; if ( getuid ( ) != 0 && ( arg_appimage || cfg . chrootdir || arg_overlay ) ) { enforce_filters ( ) ; need_preload = arg_trace || arg_tracelog ; } if ( need_preload ) fs_trace_preload ( ) ; if ( cfg . hosts_file ) fs_store_hosts_file ( ) ; # ifdef HAVE_CHROOT if ( cfg . chrootdir ) { fs_chroot ( cfg . chrootdir ) ; if ( need_preload ) fs_trace_preload ( ) ; } else # endif # ifdef HAVE_OVERLAYFS if ( arg_overlay ) fs_overlayfs ( ) ; else # endif fs_basic_fs ( ) ; if ( arg_private ) { if ( cfg . home_private ) { if ( cfg . chrootdir ) fwarning ( \"private=directoryfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private=directoryfeatureisdisabledinoverlay\\\\n\" ) ; else fs_private_homedir ( ) ; } else if ( cfg . home_private_keep ) { if ( cfg . chrootdir ) fwarning ( \"private-home=featureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-home=featureisdisabledinoverlay\\\\n\" ) ; else fs_private_home_list ( ) ; } else fs_private ( ) ; } if ( arg_private_dev ) fs_private_dev ( ) ; if ( arg_private_etc ) { if ( cfg . chrootdir ) fwarning ( \"private-etcfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-etcfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/etc\" , RUN_ETC_DIR , cfg . etc_private_keep ) ; if ( need_preload ) fs_trace_preload ( ) ; } } if ( arg_private_opt ) { if ( cfg . chrootdir ) fwarning ( \"private-optfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-optfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/opt\" , RUN_OPT_DIR , cfg . opt_private_keep ) ; } } if ( arg_private_srv ) { if ( cfg . chrootdir ) fwarning ( \"private-srvfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-srvfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/srv\" , RUN_SRV_DIR , cfg . srv_private_keep ) ; } } if ( arg_private_bin && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( \"private-binfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-binfeatureisdisabledinoverlay\\\\n\" ) ; else { if ( arg_x11_xorg ) { EUID_USER ( ) ; char * tmp ; if ( asprintf ( & tmp , \"%s,xauth\" , cfg . bin_private_keep ) == - 1 ) errExit ( \"asprintf\" ) ; cfg . bin_private_keep = tmp ; EUID_ROOT ( ) ; } fs_private_bin_list ( ) ; } } if ( arg_private_lib && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( \"private-libfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-libfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_lib ( ) ; } } if ( arg_private_cache ) { if ( cfg . chrootdir ) fwarning ( \"private-cachefeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-cachefeatureisdisabledinoverlay\\\\n\" ) ; else fs_private_cache ( ) ; } if ( arg_private_tmp ) { EUID_USER ( ) ; fs_private_tmp ( ) ; EUID_ROOT ( ) ; } if ( arg_nodbus ) dbus_session_disable ( ) ; if ( cfg . hostname ) fs_hostname ( cfg . hostname ) ; if ( cfg . hosts_file ) fs_mount_hosts_file ( ) ; if ( arg_netns ) netns_mounts ( arg_netns ) ; fs_proc_sys_dev_boot ( ) ; if ( checkcfg ( CFG_DISABLE_MNT ) ) fs_mnt ( 1 ) ; else if ( arg_disable_mnt ) fs_mnt ( 0 ) ; fs_whitelist ( ) ; fs_blacklist ( ) ; if ( arg_nosound ) { pulseaudio_disable ( ) ; fs_dev_disable_sound ( ) ; } else if ( ! arg_noautopulse ) pulseaudio_init ( ) ; if ( arg_no3d ) fs_dev_disable_3d ( ) ; if ( arg_notv ) fs_dev_disable_tv ( ) ; if ( arg_nodvd ) fs_dev_disable_dvd ( ) ; if ( arg_nou2f ) fs_dev_disable_u2f ( ) ; if ( arg_novideo ) fs_dev_disable_video ( ) ; if ( need_preload ) fs_trace ( ) ; fs_resolvconf ( ) ; fs_logger_print ( ) ; fs_logger_change_owner ( ) ; EUID_USER ( ) ; int cwd = 0 ; if ( cfg . cwd ) { if ( chdir ( cfg . cwd ) == 0 ) cwd = 1 ; } if ( ! cwd ) { if ( chdir ( \"/\" ) < 0 ) errExit ( \"chdir\" ) ; if ( cfg . homedir ) { struct stat s ; if ( stat ( cfg . homedir , & s ) == 0 ) { if ( chdir ( cfg . homedir ) < 0 ) errExit ( \"chdir\" ) ; } } } if ( arg_debug ) { char * cpath = get_current_dir_name ( ) ; if ( cpath ) { printf ( \"Currentdirectory:%s\\\\n\" , cpath ) ; free ( cpath ) ; } } EUID_ROOT ( ) ; fs_x11 ( ) ; if ( arg_x11_xorg ) x11_xorg ( ) ; save_umask ( ) ; save_nonewprivs ( ) ; set_caps ( ) ; save_cpu ( ) ; save_cgroup ( ) ; # ifdef HAVE_SECCOMP # ifdef SYS_socket if ( cfg . protocol ) { if ( arg_debug ) printf ( \"Installprotocolfilter:%s\\\\n\" , cfg . protocol ) ; seccomp_load ( RUN_SECCOMP_PROTOCOL ) ; protocol_filter_save ( ) ; } else { int rv = unlink ( RUN_SECCOMP_PROTOCOL ) ; ( void ) rv ; } # endif if ( arg_seccomp == 1 ) { if ( cfg . seccomp_list_keep ) seccomp_filter_keep ( ) ; else seccomp_filter_drop ( ) ; } else { int rv = unlink ( RUN_SECCOMP_CFG ) ; rv |= unlink ( RUN_SECCOMP_32 ) ; ( void ) rv ; } if ( arg_memory_deny_write_execute ) { if ( arg_debug ) printf ( \"Installmemorywrite&executefilter\\\\n\" ) ; seccomp_load ( RUN_SECCOMP_MDWX ) ; } else { int rv = unlink ( RUN_SECCOMP_MDWX ) ; ( void ) rv ; } # endif FILE * rj = create_ready_for_join_file ( ) ; save_nogroups ( ) ; if ( arg_noroot ) { int rv = unshare ( CLONE_NEWUSER ) ; if ( rv == - 1 ) { fwarning ( \"cannotcreateanewusernamespace,goingforwardwithoutit...\\\\n\" ) ; arg_noroot = 0 ; } } notify_other ( child_to_parent_fds [ 1 ] ) ; close ( child_to_parent_fds [ 1 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; close ( parent_to_child_fds [ 0 ] ) ; if ( arg_noroot ) { if ( arg_debug ) printf ( \"norootusernamespaceinstalled\\\\n\" ) ; set_caps ( ) ; } if ( arg_nonewprivs ) { prctl ( PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) ; if ( prctl ( PR_GET_NO_NEW_PRIVS , 0 , 0 , 0 , 0 ) != 1 ) { fwarning ( \"cannotsetNO_NEW_PRIVS,itrequiresaLinuxkernelversion3.5ornewer.\\\\n\" ) ; if ( force_nonewprivs ) { fprintf ( stderr , \"Error:NO_NEW_PRIVSrequiredforthissandbox,exiting...\\\\n\" ) ; exit ( 1 ) ; } } else if ( arg_debug ) printf ( \"NO_NEW_PRIVSset\\\\n\" ) ; } drop_privs ( arg_nogroups ) ; prctl ( PR_SET_PDEATHSIG , SIGKILL , 0 , 0 , 0 ) ; if ( cfg . cpus ) set_cpu_affinity ( ) ; pid_t app_pid = fork ( ) ; if ( app_pid == - 1 ) errExit ( \"fork\" ) ; if ( app_pid == 0 ) { # ifdef HAVE_APPARMOR if ( checkcfg ( CFG_APPARMOR ) && arg_apparmor ) { errno = 0 ; if ( aa_change_onexec ( \"firejail-default\" ) ) { fwarning ( \"CannotconfinetheapplicationusingAppArmor.\\\\n\" \"Maybefirejail-defaultAppArmorprofileisnotloadedintothekernel.\\\\n\" \"Asroot,run\\\\\"aa-enforcefirejail-default\\\\\"toloadit.\\\\n\" ) ; } else if ( arg_debug ) printf ( \"AppArmorenabled\\\\n\" ) ; } # endif if ( arg_nice ) set_nice ( cfg . nice ) ; set_rlimits ( ) ; start_application ( 0 , rj ) ; } fclose ( rj ) ; int status = monitor_application ( app_pid ) ; flush_stdin ( ) ; if ( WIFEXITED ( status ) ) { return WEXITSTATUS ( status ) ; } else { return - 1 ; } }\n", "\n", "1: CWE-284 int sandbox ( void * sandbox_arg ) { ( void ) sandbox_arg ; pid_t child_pid = getpid ( ) ; if ( arg_debug ) printf ( \"Initializingchildprocess\\\\n\" ) ; close ( parent_to_child_fds [ 1 ] ) ; close ( child_to_parent_fds [ 0 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; if ( arg_debug && child_pid == 1 ) printf ( \"PIDnamespaceinstalled\\\\n\" ) ; if ( cfg . hostname ) { if ( sethostname ( cfg . hostname , strlen ( cfg . hostname ) ) < 0 ) errExit ( \"sethostname\" ) ; } if ( mount ( NULL , \"/\" , NULL , MS_SLAVE | MS_REC , NULL ) < 0 ) { chk_chroot ( ) ; } preproc_mount_mnt_dir ( ) ; if ( mount ( LIBDIR \"/firejail\" , RUN_FIREJAIL_LIB_DIR , \"none\" , MS_BIND , NULL ) < 0 ) errExit ( \"mounting\" RUN_FIREJAIL_LIB_DIR ) ; if ( cfg . name ) fs_logger2 ( \"sandboxname:\" , cfg . name ) ; fs_logger2int ( \"sandboxpid:\" , ( int ) sandbox_pid ) ; if ( cfg . chrootdir ) fs_logger ( \"sandboxfilesystem:chroot\" ) ; else if ( arg_overlay ) fs_logger ( \"sandboxfilesystem:overlay\" ) ; else fs_logger ( \"sandboxfilesystem:local\" ) ; fs_logger ( \"installmountnamespace\" ) ; if ( arg_netfilter && any_bridge_configured ( ) ) { netfilter ( arg_netfilter_file ) ; } if ( arg_netfilter6 && any_bridge_configured ( ) ) { netfilter6 ( arg_netfilter6_file ) ; } int gw_cfg_failed = 0 ; if ( arg_nonetwork ) { net_if_up ( \"lo\" ) ; if ( arg_debug ) printf ( \"Networknamespaceenabled,onlyloopbackinterfaceavailable\\\\n\" ) ; } else if ( arg_netns ) { netns ( arg_netns ) ; if ( arg_debug ) printf ( \"Networknamespace\\'%s\\'activated\\\\n\" , arg_netns ) ; } else if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { net_if_up ( \"lo\" ) ; if ( mac_not_zero ( cfg . bridge0 . macsandbox ) ) net_config_mac ( cfg . bridge0 . devsandbox , cfg . bridge0 . macsandbox ) ; sandbox_if_up ( & cfg . bridge0 ) ; if ( mac_not_zero ( cfg . bridge1 . macsandbox ) ) net_config_mac ( cfg . bridge1 . devsandbox , cfg . bridge1 . macsandbox ) ; sandbox_if_up ( & cfg . bridge1 ) ; if ( mac_not_zero ( cfg . bridge2 . macsandbox ) ) net_config_mac ( cfg . bridge2 . devsandbox , cfg . bridge2 . macsandbox ) ; sandbox_if_up ( & cfg . bridge2 ) ; if ( mac_not_zero ( cfg . bridge3 . macsandbox ) ) net_config_mac ( cfg . bridge3 . devsandbox , cfg . bridge3 . macsandbox ) ; sandbox_if_up ( & cfg . bridge3 ) ; if ( cfg . interface0 . configured && cfg . interface0 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface0 . ip ) , cfg . interface0 . dev ) ; net_config_interface ( cfg . interface0 . dev , cfg . interface0 . ip , cfg . interface0 . mask , cfg . interface0 . mtu ) ; } if ( cfg . interface1 . configured && cfg . interface1 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface1 . ip ) , cfg . interface1 . dev ) ; net_config_interface ( cfg . interface1 . dev , cfg . interface1 . ip , cfg . interface1 . mask , cfg . interface1 . mtu ) ; } if ( cfg . interface2 . configured && cfg . interface2 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface2 . ip ) , cfg . interface2 . dev ) ; net_config_interface ( cfg . interface2 . dev , cfg . interface2 . ip , cfg . interface2 . mask , cfg . interface2 . mtu ) ; } if ( cfg . interface3 . configured && cfg . interface3 . ip ) { if ( arg_debug ) printf ( \"Configuring%d.%d.%d.%daddressoninterface%s\\\\n\" , PRINT_IP ( cfg . interface3 . ip ) , cfg . interface3 . dev ) ; net_config_interface ( cfg . interface3 . dev , cfg . interface3 . ip , cfg . interface3 . mask , cfg . interface3 . mtu ) ; } if ( cfg . defaultgw ) { if ( net_add_route ( 0 , 0 , cfg . defaultgw ) ) { fwarning ( \"cannotconfiguredefaultroute\\\\n\" ) ; gw_cfg_failed = 1 ; } } if ( arg_debug ) printf ( \"Networknamespaceenabled\\\\n\" ) ; } if ( ! arg_quiet ) { if ( any_bridge_configured ( ) || any_interface_configured ( ) || cfg . defaultgw || cfg . dns1 ) { fmessage ( \"\\\\n\" ) ; if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { if ( arg_scan ) sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 3 , PATH_FNET , \"printif\" , \"scan\" ) ; else sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 2 , PATH_FNET , \"printif\" ) ; } if ( cfg . defaultgw != 0 ) { if ( gw_cfg_failed ) fmessage ( \"Defaultgatewayconfigurationfailed\\\\n\" ) ; else fmessage ( \"Defaultgateway%d.%d.%d.%d\\\\n\" , PRINT_IP ( cfg . defaultgw ) ) ; } if ( cfg . dns1 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns1 ) ; if ( cfg . dns2 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns2 ) ; if ( cfg . dns3 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns3 ) ; if ( cfg . dns4 != NULL ) fmessage ( \"DNSserver%s\\\\n\" , cfg . dns4 ) ; fmessage ( \"\\\\n\" ) ; } } if ( arg_nonetwork || any_bridge_configured ( ) || any_interface_configured ( ) ) { } else { EUID_USER ( ) ; env_ibus_load ( ) ; EUID_ROOT ( ) ; } # ifdef HAVE_SECCOMP if ( cfg . protocol ) { if ( arg_debug ) printf ( \"Buildprotocolfilter:%s\\\\n\" , cfg . protocol ) ; int rv = sbox_run ( SBOX_USER | SBOX_CAPS_NONE | SBOX_SECCOMP , 5 , PATH_FSECCOMP , \"protocol\" , \"build\" , cfg . protocol , RUN_SECCOMP_PROTOCOL ) ; if ( rv ) exit ( rv ) ; } if ( arg_seccomp && ( cfg . seccomp_list || cfg . seccomp_list_drop || cfg . seccomp_list_keep ) ) arg_seccomp_postexec = 1 ; # endif bool need_preload = arg_trace || arg_tracelog || arg_seccomp_postexec ; if ( getuid ( ) != 0 && ( arg_appimage || cfg . chrootdir || arg_overlay ) ) { enforce_filters ( ) ; need_preload = arg_trace || arg_tracelog ; } if ( need_preload ) fs_trace_preload ( ) ; if ( cfg . hosts_file ) fs_store_hosts_file ( ) ; # ifdef HAVE_CHROOT if ( cfg . chrootdir ) { fs_chroot ( cfg . chrootdir ) ; if ( need_preload ) fs_trace_preload ( ) ; } else # endif # ifdef HAVE_OVERLAYFS if ( arg_overlay ) fs_overlayfs ( ) ; else # endif fs_basic_fs ( ) ; if ( arg_private ) { if ( cfg . home_private ) { if ( cfg . chrootdir ) fwarning ( \"private=directoryfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private=directoryfeatureisdisabledinoverlay\\\\n\" ) ; else fs_private_homedir ( ) ; } else if ( cfg . home_private_keep ) { if ( cfg . chrootdir ) fwarning ( \"private-home=featureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-home=featureisdisabledinoverlay\\\\n\" ) ; else fs_private_home_list ( ) ; } else fs_private ( ) ; } if ( arg_private_dev ) fs_private_dev ( ) ; if ( arg_private_etc ) { if ( cfg . chrootdir ) fwarning ( \"private-etcfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-etcfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/etc\" , RUN_ETC_DIR , cfg . etc_private_keep ) ; if ( need_preload ) fs_trace_preload ( ) ; } } if ( arg_private_opt ) { if ( cfg . chrootdir ) fwarning ( \"private-optfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-optfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/opt\" , RUN_OPT_DIR , cfg . opt_private_keep ) ; } } if ( arg_private_srv ) { if ( cfg . chrootdir ) fwarning ( \"private-srvfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-srvfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_dir_list ( \"/srv\" , RUN_SRV_DIR , cfg . srv_private_keep ) ; } } if ( arg_private_bin && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( \"private-binfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-binfeatureisdisabledinoverlay\\\\n\" ) ; else { if ( arg_x11_xorg ) { EUID_USER ( ) ; char * tmp ; if ( asprintf ( & tmp , \"%s,xauth\" , cfg . bin_private_keep ) == - 1 ) errExit ( \"asprintf\" ) ; cfg . bin_private_keep = tmp ; EUID_ROOT ( ) ; } fs_private_bin_list ( ) ; } } if ( arg_private_lib && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( \"private-libfeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-libfeatureisdisabledinoverlay\\\\n\" ) ; else { fs_private_lib ( ) ; } } if ( arg_private_cache ) { if ( cfg . chrootdir ) fwarning ( \"private-cachefeatureisdisabledinchroot\\\\n\" ) ; else if ( arg_overlay ) fwarning ( \"private-cachefeatureisdisabledinoverlay\\\\n\" ) ; else fs_private_cache ( ) ; } if ( arg_private_tmp ) { EUID_USER ( ) ; fs_private_tmp ( ) ; EUID_ROOT ( ) ; } if ( arg_nodbus ) dbus_session_disable ( ) ; if ( cfg . hostname ) fs_hostname ( cfg . hostname ) ; if ( cfg . hosts_file ) fs_mount_hosts_file ( ) ; if ( arg_netns ) netns_mounts ( arg_netns ) ; fs_proc_sys_dev_boot ( ) ; if ( checkcfg ( CFG_DISABLE_MNT ) ) fs_mnt ( 1 ) ; else if ( arg_disable_mnt ) fs_mnt ( 0 ) ; fs_whitelist ( ) ; fs_blacklist ( ) ; if ( arg_nosound ) { pulseaudio_disable ( ) ; fs_dev_disable_sound ( ) ; } else if ( ! arg_noautopulse ) pulseaudio_init ( ) ; if ( arg_no3d ) fs_dev_disable_3d ( ) ; if ( arg_notv ) fs_dev_disable_tv ( ) ; if ( arg_nodvd ) fs_dev_disable_dvd ( ) ; if ( arg_nou2f ) fs_dev_disable_u2f ( ) ; if ( arg_novideo ) fs_dev_disable_video ( ) ; if ( need_preload ) fs_trace ( ) ; fs_resolvconf ( ) ; fs_logger_print ( ) ; fs_logger_change_owner ( ) ; EUID_USER ( ) ; int cwd = 0 ; if ( cfg . cwd ) { if ( chdir ( cfg . cwd ) == 0 ) cwd = 1 ; } if ( ! cwd ) { if ( chdir ( \"/\" ) < 0 ) errExit ( \"chdir\" ) ; if ( cfg . homedir ) { struct stat s ; if ( stat ( cfg . homedir , & s ) == 0 ) { if ( chdir ( cfg . homedir ) < 0 ) errExit ( \"chdir\" ) ; } } } if ( arg_debug ) { char * cpath = get_current_dir_name ( ) ; if ( cpath ) { printf ( \"Currentdirectory:%s\\\\n\" , cpath ) ; free ( cpath ) ; } } EUID_ROOT ( ) ; fs_x11 ( ) ; if ( arg_x11_xorg ) x11_xorg ( ) ; save_umask ( ) ; save_nonewprivs ( ) ; set_caps ( ) ; save_cpu ( ) ; save_cgroup ( ) ; # ifdef HAVE_SECCOMP # ifdef SYS_socket if ( cfg . protocol ) { if ( arg_debug ) printf ( \"Installprotocolfilter:%s\\\\n\" , cfg . protocol ) ; seccomp_load ( RUN_SECCOMP_PROTOCOL ) ; protocol_filter_save ( ) ; } else { int rv = unlink ( RUN_SECCOMP_PROTOCOL ) ; ( void ) rv ; } # endif if ( arg_seccomp == 1 ) { if ( cfg . seccomp_list_keep ) seccomp_filter_keep ( ) ; else seccomp_filter_drop ( ) ; } else { int rv = unlink ( RUN_SECCOMP_CFG ) ; rv |= unlink ( RUN_SECCOMP_32 ) ; ( void ) rv ; } if ( arg_memory_deny_write_execute ) { if ( arg_debug ) printf ( \"Installmemorywrite&executefilter\\\\n\" ) ; seccomp_load ( RUN_SECCOMP_MDWX ) ; } else { int rv = unlink ( RUN_SECCOMP_MDWX ) ; ( void ) rv ; } # endif FILE * rj = create_ready_for_join_file ( ) ; save_nogroups ( ) ; if ( arg_noroot ) { int rv = unshare ( CLONE_NEWUSER ) ; if ( rv == - 1 ) { fwarning ( \"cannotcreateanewusernamespace,goingforwardwithoutit...\\\\n\" ) ; arg_noroot = 0 ; } } notify_other ( child_to_parent_fds [ 1 ] ) ; close ( child_to_parent_fds [ 1 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; close ( parent_to_child_fds [ 0 ] ) ; if ( arg_noroot ) { if ( arg_debug ) printf ( \"norootusernamespaceinstalled\\\\n\" ) ; set_caps ( ) ; } if ( arg_nonewprivs ) { prctl ( PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) ; if ( prctl ( PR_GET_NO_NEW_PRIVS , 0 , 0 , 0 , 0 ) != 1 ) { fwarning ( \"cannotsetNO_NEW_PRIVS,itrequiresaLinuxkernelversion3.5ornewer.\\\\n\" ) ; if ( force_nonewprivs ) { fprintf ( stderr , \"Error:NO_NEW_PRIVSrequiredforthissandbox,exiting...\\\\n\" ) ; exit ( 1 ) ; } } else if ( arg_debug ) printf ( \"NO_NEW_PRIVSset\\\\n\" ) ; } drop_privs ( arg_nogroups ) ; prctl ( PR_SET_PDEATHSIG , SIGKILL , 0 , 0 , 0 ) ; if ( cfg . cpus ) set_cpu_affinity ( ) ; pid_t app_pid = fork ( ) ; if ( app_pid == - 1 ) errExit ( \"fork\" ) ; if ( app_pid == 0 ) { # ifdef HAVE_APPARMOR if ( checkcfg ( CFG_APPARMOR ) && arg_apparmor ) { errno = 0 ; if ( aa_change_onexec ( \"firejail-default\" ) ) { fwarning ( \"CannotconfinetheapplicationusingAppArmor.\\\\n\" \"Maybefirejail-defaultAppArmorprofileisnotloadedintothekernel.\\\\n\" \"Asroot,run\\\\\"aa-enforcefirejail-default\\\\\"toloadit.\\\\n\" ) ; } else if ( arg_debug ) printf ( \"AppArmorenabled\\\\n\" ) ; } # endif if ( arg_nice ) set_nice ( cfg . nice ) ; set_rlimits ( ) ; start_application ( 0 , rj ) ; } fclose ( rj ) ; int status = monitor_application ( app_pid ) ; flush_stdin ( ) ; if ( WIFEXITED ( status ) ) { return WEXITSTATUS ( status ) ; } else { return - 1 ; } }\n", "\n", "\n", "Target: buffer , encoded , sizeof ( buffer )\n", "\n", "Sources:\n", "0: CWE-119 void test_base64_decode ( void ) { char buffer [ 16 ] ; int len = mutt_b64_decode ( buffer , encoded ) ; if ( ! TEST_CHECK ( len == sizeof ( clear ) - 1 ) ) { TEST_MSG ( \"Expected:%zu\" , sizeof ( clear ) - 1 ) ; TEST_MSG ( \"Actual:%zu\" , len ) ; } buffer [ len ] = '\\\\0' ; if ( ! TEST_CHECK ( strcmp ( buffer , clear ) == 0 ) ) { TEST_MSG ( \"Expected:%s\" , clear ) ; TEST_MSG ( \"Actual:%s\" , buffer ) ; } }\n", "\n", "1: CWE-120 void test_base64_decode ( void ) { char buffer [ 16 ] ; int len = mutt_b64_decode ( buffer , encoded ) ; if ( ! TEST_CHECK ( len == sizeof ( clear ) - 1 ) ) { TEST_MSG ( \"Expected:%zu\" , sizeof ( clear ) - 1 ) ; TEST_MSG ( \"Actual:%zu\" , len ) ; } buffer [ len ] = '\\\\0' ; if ( ! TEST_CHECK ( strcmp ( buffer , clear ) == 0 ) ) { TEST_MSG ( \"Expected:%s\" , clear ) ; TEST_MSG ( \"Actual:%s\" , buffer ) ; } }\n", "\n", "\n", "Target: * obj , const char *\n", "\n", "Sources:\n", "0: CWE-119 static void mark_object ( struct object * obj , struct strbuf * path , const char * name , void * data ) { update_progress ( data ) ; }\n", "\n", "1: CWE-119 static void finish_object ( struct object * obj , struct strbuf * path , const char * name , void * cb_data ) { struct rev_list_info * info = cb_data ; if ( obj -> type == OBJ_BLOB && ! has_object_file ( & obj -> oid ) ) die ( \"missingblobobject\\'%s\\'\" , oid_to_hex ( & obj -> oid ) ) ; if ( info -> revs -> verify_objects && ! obj -> parsed && obj -> type != OBJ_COMMIT ) parse_object ( obj -> oid . hash ) ; }\n", "\n", "\n", "Target: ; buf = g_malloc0 ( size )\n", "\n", "Sources:\n", "0: CWE-908 void * vips_malloc ( VipsObject * object , size_t size ) { void * buf ; buf = g_malloc ( size ) ; if ( object ) { g_signal_connect ( object , \"postclose\" , G_CALLBACK ( vips_malloc_cb ) , buf ) ; object -> local_memory += size ; } return ( buf ) ; }\n", "\n", "1: CWE-200 void * vips_malloc ( VipsObject * object , size_t size ) { void * buf ; buf = g_malloc ( size ) ; if ( object ) { g_signal_connect ( object , \"postclose\" , G_CALLBACK ( vips_malloc_cb ) , buf ) ; object -> local_memory += size ; } return ( buf ) ; }\n", "\n", "\n", "Target: ctxt -> mode != X86EMUL_MODE_PROT64 ) && ( msr_data ) ; if ( ( 0 ) ; ctxt -> eflags u16 ) msr_data & ~ SELECTOR_RPL_MASK ; + 8 ; if ( efer & efer & EFER_LMA ) { cs -> _eip = ( efer & EFER_LMA ) ? msr_data : ( u32 ) VCPU_REGS_RSP ) = ( efer & EFER_LMA ) ? msr_data : ( u32 )\n", "\n", "Sources:\n", "0: CWE-362 static int em_sysenter ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; struct desc_struct cs , ss ; u64 msr_data ; u16 cs_sel , ss_sel ; u64 efer = 0 ; ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) return emulate_gp ( ctxt , 0 ) ; if ( ( ctxt -> mode == X86EMUL_MODE_PROT32 ) && ( efer & EFER_LMA ) && ! vendor_intel ( ctxt ) ) return emulate_ud ( ctxt ) ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) return X86EMUL_UNHANDLEABLE ; setup_syscalls_segments ( ctxt , & cs , & ss ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_CS , & msr_data ) ; switch ( ctxt -> mode ) { case X86EMUL_MODE_PROT32 : if ( ( msr_data & 0xfffc ) == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; case X86EMUL_MODE_PROT64 : if ( msr_data == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; default : break ; } ctxt -> eflags &= ~ ( EFLG_VM | EFLG_IF ) ; cs_sel = ( u16 ) msr_data ; cs_sel &= ~ SELECTOR_RPL_MASK ; ss_sel = cs_sel + 8 ; ss_sel &= ~ SELECTOR_RPL_MASK ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 || ( efer & EFER_LMA ) ) { cs . d = 0 ; cs . l = 1 ; } ops -> set_segment ( ctxt , cs_sel , & cs , 0 , VCPU_SREG_CS ) ; ops -> set_segment ( ctxt , ss_sel , & ss , 0 , VCPU_SREG_SS ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_EIP , & msr_data ) ; ctxt -> _eip = msr_data ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_ESP , & msr_data ) ; * reg_write ( ctxt , VCPU_REGS_RSP ) = msr_data ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-269 static int em_sysenter ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; struct desc_struct cs , ss ; u64 msr_data ; u16 cs_sel , ss_sel ; u64 efer = 0 ; ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) return emulate_gp ( ctxt , 0 ) ; if ( ( ctxt -> mode == X86EMUL_MODE_PROT32 ) && ( efer & EFER_LMA ) && ! vendor_intel ( ctxt ) ) return emulate_ud ( ctxt ) ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) return X86EMUL_UNHANDLEABLE ; setup_syscalls_segments ( ctxt , & cs , & ss ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_CS , & msr_data ) ; switch ( ctxt -> mode ) { case X86EMUL_MODE_PROT32 : if ( ( msr_data & 0xfffc ) == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; case X86EMUL_MODE_PROT64 : if ( msr_data == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; default : break ; } ctxt -> eflags &= ~ ( EFLG_VM | EFLG_IF ) ; cs_sel = ( u16 ) msr_data ; cs_sel &= ~ SELECTOR_RPL_MASK ; ss_sel = cs_sel + 8 ; ss_sel &= ~ SELECTOR_RPL_MASK ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 || ( efer & EFER_LMA ) ) { cs . d = 0 ; cs . l = 1 ; } ops -> set_segment ( ctxt , cs_sel , & cs , 0 , VCPU_SREG_CS ) ; ops -> set_segment ( ctxt , ss_sel , & ss , 0 , VCPU_SREG_SS ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_EIP , & msr_data ) ; ctxt -> _eip = msr_data ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_ESP , & msr_data ) ; * reg_write ( ctxt , VCPU_REGS_RSP ) = msr_data ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: ; int bytes_returned ; unsigned int name_len ; __u16\n", "\n", "Sources:\n", "0: CWE-189 int CIFSFindNext ( const int xid , struct cifs_tcon * tcon , __u16 searchHandle , struct cifs_search_info * psrch_inf ) { TRANSACTION2_FNEXT_REQ * pSMB = NULL ; TRANSACTION2_FNEXT_RSP * pSMBr = NULL ; T2_FNEXT_RSP_PARMS * parms ; char * response_data ; int rc = 0 ; int bytes_returned , name_len ; __u16 params , byte_count ; cFYI ( 1 , \"InFindNext\" ) ; if ( psrch_inf -> endOfSearch ) return - ENOENT ; rc = smb_init ( SMB_COM_TRANSACTION2 , 15 , tcon , ( void * * ) & pSMB , ( void * * ) & pSMBr ) ; if ( rc ) return rc ; params = 14 ; byte_count = 0 ; pSMB -> TotalDataCount = 0 ; pSMB -> MaxParameterCount = cpu_to_le16 ( 8 ) ; pSMB -> MaxDataCount = cpu_to_le16 ( ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE ) & 0xFFFFFF00 ) ; pSMB -> MaxSetupCount = 0 ; pSMB -> Reserved = 0 ; pSMB -> Flags = 0 ; pSMB -> Timeout = 0 ; pSMB -> Reserved2 = 0 ; pSMB -> ParameterOffset = cpu_to_le16 ( offsetof ( struct smb_com_transaction2_fnext_req , SearchHandle ) - 4 ) ; pSMB -> DataCount = 0 ; pSMB -> DataOffset = 0 ; pSMB -> SetupCount = 1 ; pSMB -> Reserved3 = 0 ; pSMB -> SubCommand = cpu_to_le16 ( TRANS2_FIND_NEXT ) ; pSMB -> SearchHandle = searchHandle ; pSMB -> SearchCount = cpu_to_le16 ( CIFSMaxBufSize / sizeof ( FILE_UNIX_INFO ) ) ; pSMB -> InformationLevel = cpu_to_le16 ( psrch_inf -> info_level ) ; pSMB -> ResumeKey = psrch_inf -> resume_key ; pSMB -> SearchFlags = cpu_to_le16 ( CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME ) ; name_len = psrch_inf -> resume_name_len ; params += name_len ; if ( name_len < PATH_MAX ) { memcpy ( pSMB -> ResumeFileName , psrch_inf -> presume_name , name_len ) ; byte_count += name_len ; pSMB -> ResumeFileName [ name_len ] = 0 ; pSMB -> ResumeFileName [ name_len + 1 ] = 0 ; } else { rc = - EINVAL ; goto FNext2_err_exit ; } byte_count = params + 1 ; pSMB -> TotalParameterCount = cpu_to_le16 ( params ) ; pSMB -> ParameterCount = pSMB -> TotalParameterCount ; inc_rfc1001_len ( pSMB , byte_count ) ; pSMB -> ByteCount = cpu_to_le16 ( byte_count ) ; rc = SendReceive ( xid , tcon -> ses , ( struct smb_hdr * ) pSMB , ( struct smb_hdr * ) pSMBr , & bytes_returned , 0 ) ; cifs_stats_inc ( & tcon -> num_fnext ) ; if ( rc ) { if ( rc == - EBADF ) { psrch_inf -> endOfSearch = true ; cifs_buf_release ( pSMB ) ; rc = 0 ; } else cFYI ( 1 , \"FindNextreturned=%d\" , rc ) ; } else { rc = validate_t2 ( ( struct smb_t2_rsp * ) pSMBr ) ; if ( rc == 0 ) { unsigned int lnoff ; if ( pSMBr -> hdr . Flags2 & SMBFLG2_UNICODE ) psrch_inf -> unicode = true ; else psrch_inf -> unicode = false ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . ParameterOffset ) ; parms = ( T2_FNEXT_RSP_PARMS * ) response_data ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . DataOffset ) ; if ( psrch_inf -> smallBuf ) cifs_small_buf_release ( psrch_inf -> ntwrk_buf_start ) ; else cifs_buf_release ( psrch_inf -> ntwrk_buf_start ) ; psrch_inf -> srch_entries_start = response_data ; psrch_inf -> ntwrk_buf_start = ( char * ) pSMB ; psrch_inf -> smallBuf = 0 ; if ( parms -> EndofSearch ) psrch_inf -> endOfSearch = true ; else psrch_inf -> endOfSearch = false ; psrch_inf -> entries_in_buffer = le16_to_cpu ( parms -> SearchCount ) ; psrch_inf -> index_of_last_entry += psrch_inf -> entries_in_buffer ; lnoff = le16_to_cpu ( parms -> LastNameOffset ) ; if ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE < lnoff ) { cERROR ( 1 , \"ignoringcorruptresumename\" ) ; psrch_inf -> last_entry = NULL ; return rc ; } else psrch_inf -> last_entry = psrch_inf -> srch_entries_start + lnoff ; } } FNext2_err_exit : if ( rc != 0 ) cifs_buf_release ( pSMB ) ; return rc ; }\n", "\n", "1: CWE-119 int CIFSFindNext ( const int xid , struct cifs_tcon * tcon , __u16 searchHandle , struct cifs_search_info * psrch_inf ) { TRANSACTION2_FNEXT_REQ * pSMB = NULL ; TRANSACTION2_FNEXT_RSP * pSMBr = NULL ; T2_FNEXT_RSP_PARMS * parms ; char * response_data ; int rc = 0 ; int bytes_returned , name_len ; __u16 params , byte_count ; cFYI ( 1 , \"InFindNext\" ) ; if ( psrch_inf -> endOfSearch ) return - ENOENT ; rc = smb_init ( SMB_COM_TRANSACTION2 , 15 , tcon , ( void * * ) & pSMB , ( void * * ) & pSMBr ) ; if ( rc ) return rc ; params = 14 ; byte_count = 0 ; pSMB -> TotalDataCount = 0 ; pSMB -> MaxParameterCount = cpu_to_le16 ( 8 ) ; pSMB -> MaxDataCount = cpu_to_le16 ( ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE ) & 0xFFFFFF00 ) ; pSMB -> MaxSetupCount = 0 ; pSMB -> Reserved = 0 ; pSMB -> Flags = 0 ; pSMB -> Timeout = 0 ; pSMB -> Reserved2 = 0 ; pSMB -> ParameterOffset = cpu_to_le16 ( offsetof ( struct smb_com_transaction2_fnext_req , SearchHandle ) - 4 ) ; pSMB -> DataCount = 0 ; pSMB -> DataOffset = 0 ; pSMB -> SetupCount = 1 ; pSMB -> Reserved3 = 0 ; pSMB -> SubCommand = cpu_to_le16 ( TRANS2_FIND_NEXT ) ; pSMB -> SearchHandle = searchHandle ; pSMB -> SearchCount = cpu_to_le16 ( CIFSMaxBufSize / sizeof ( FILE_UNIX_INFO ) ) ; pSMB -> InformationLevel = cpu_to_le16 ( psrch_inf -> info_level ) ; pSMB -> ResumeKey = psrch_inf -> resume_key ; pSMB -> SearchFlags = cpu_to_le16 ( CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME ) ; name_len = psrch_inf -> resume_name_len ; params += name_len ; if ( name_len < PATH_MAX ) { memcpy ( pSMB -> ResumeFileName , psrch_inf -> presume_name , name_len ) ; byte_count += name_len ; pSMB -> ResumeFileName [ name_len ] = 0 ; pSMB -> ResumeFileName [ name_len + 1 ] = 0 ; } else { rc = - EINVAL ; goto FNext2_err_exit ; } byte_count = params + 1 ; pSMB -> TotalParameterCount = cpu_to_le16 ( params ) ; pSMB -> ParameterCount = pSMB -> TotalParameterCount ; inc_rfc1001_len ( pSMB , byte_count ) ; pSMB -> ByteCount = cpu_to_le16 ( byte_count ) ; rc = SendReceive ( xid , tcon -> ses , ( struct smb_hdr * ) pSMB , ( struct smb_hdr * ) pSMBr , & bytes_returned , 0 ) ; cifs_stats_inc ( & tcon -> num_fnext ) ; if ( rc ) { if ( rc == - EBADF ) { psrch_inf -> endOfSearch = true ; cifs_buf_release ( pSMB ) ; rc = 0 ; } else cFYI ( 1 , \"FindNextreturned=%d\" , rc ) ; } else { rc = validate_t2 ( ( struct smb_t2_rsp * ) pSMBr ) ; if ( rc == 0 ) { unsigned int lnoff ; if ( pSMBr -> hdr . Flags2 & SMBFLG2_UNICODE ) psrch_inf -> unicode = true ; else psrch_inf -> unicode = false ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . ParameterOffset ) ; parms = ( T2_FNEXT_RSP_PARMS * ) response_data ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . DataOffset ) ; if ( psrch_inf -> smallBuf ) cifs_small_buf_release ( psrch_inf -> ntwrk_buf_start ) ; else cifs_buf_release ( psrch_inf -> ntwrk_buf_start ) ; psrch_inf -> srch_entries_start = response_data ; psrch_inf -> ntwrk_buf_start = ( char * ) pSMB ; psrch_inf -> smallBuf = 0 ; if ( parms -> EndofSearch ) psrch_inf -> endOfSearch = true ; else psrch_inf -> endOfSearch = false ; psrch_inf -> entries_in_buffer = le16_to_cpu ( parms -> SearchCount ) ; psrch_inf -> index_of_last_entry += psrch_inf -> entries_in_buffer ; lnoff = le16_to_cpu ( parms -> LastNameOffset ) ; if ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE < lnoff ) { cERROR ( 1 , \"ignoringcorruptresumename\" ) ; psrch_inf -> last_entry = NULL ; return rc ; } else psrch_inf -> last_entry = psrch_inf -> srch_entries_start + lnoff ; } } FNext2_err_exit : if ( rc != 0 ) cifs_buf_release ( pSMB ) ; return rc ; }\n", "\n", "\n", "Target: != EOF ) if ( fputc ( c , file ) != c ) break\n", "\n", "Sources:\n", "0: CWE-252 static Image * ReadCALSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char filename [ MagickPathExtent ] , header [ MagickPathExtent ] , message [ MagickPathExtent ] ; FILE * file ; Image * image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register ssize_t i ; unsigned long density , direction , height , orientation , pel_path , type , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( header , 0 , sizeof ( header ) ) ; density = 0 ; direction = 0 ; orientation = 1 ; pel_path = 0 ; type = 1 ; width = 0 ; height = 0 ; for ( i = 0 ; i < 16 ; i ++ ) { if ( ReadBlob ( image , 128 , ( unsigned char * ) header ) != 128 ) break ; switch ( * header ) { case 'R' : case 'r' : { if ( LocaleNCompare ( header , \"rdensty:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu\" , & density ) ; break ; } if ( LocaleNCompare ( header , \"rpelcnt:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu,%lu\" , & width , & height ) ; break ; } if ( LocaleNCompare ( header , \"rorient:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu,%lu\" , & pel_path , & direction ) ; if ( pel_path == 90 ) orientation = 5 ; else if ( pel_path == 180 ) orientation = 3 ; else if ( pel_path == 270 ) orientation = 7 ; if ( direction == 90 ) orientation ++ ; break ; } if ( LocaleNCompare ( header , \"rtype:\" , 6 ) == 0 ) { ( void ) sscanf ( header + 6 , \"%lu\" , & type ) ; break ; } break ; } } } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) ThrowImageException ( FileOpenError , \"UnableToCreateTemporaryFile\" ) ; while ( ( c = ReadBlobByte ( image ) ) != EOF ) ( void ) fputc ( c , file ) ; ( void ) fclose ( file ) ; ( void ) CloseBlob ( image ) ; image = DestroyImage ( image ) ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"group4:%s\" , filename ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , \"%lux%lu\" , width , height ) ; ( void ) CloneString ( & read_info -> size , message ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , \"%lu\" , density ) ; ( void ) CloneString ( & read_info -> density , message ) ; read_info -> orientation = ( OrientationType ) orientation ; image = ReadImage ( read_info , exception ) ; if ( image != ( Image * ) NULL ) { ( void ) CopyMagickString ( image -> filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick_filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick , \"CALS\" , MagickPathExtent ) ; } read_info = DestroyImageInfo ( read_info ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; return ( image ) ; }\n", "\n", "1: CWE-20 static Image * ReadCALSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char filename [ MagickPathExtent ] , header [ MagickPathExtent ] , message [ MagickPathExtent ] ; FILE * file ; Image * image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register ssize_t i ; unsigned long density , direction , height , orientation , pel_path , type , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( header , 0 , sizeof ( header ) ) ; density = 0 ; direction = 0 ; orientation = 1 ; pel_path = 0 ; type = 1 ; width = 0 ; height = 0 ; for ( i = 0 ; i < 16 ; i ++ ) { if ( ReadBlob ( image , 128 , ( unsigned char * ) header ) != 128 ) break ; switch ( * header ) { case 'R' : case 'r' : { if ( LocaleNCompare ( header , \"rdensty:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu\" , & density ) ; break ; } if ( LocaleNCompare ( header , \"rpelcnt:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu,%lu\" , & width , & height ) ; break ; } if ( LocaleNCompare ( header , \"rorient:\" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , \"%lu,%lu\" , & pel_path , & direction ) ; if ( pel_path == 90 ) orientation = 5 ; else if ( pel_path == 180 ) orientation = 3 ; else if ( pel_path == 270 ) orientation = 7 ; if ( direction == 90 ) orientation ++ ; break ; } if ( LocaleNCompare ( header , \"rtype:\" , 6 ) == 0 ) { ( void ) sscanf ( header + 6 , \"%lu\" , & type ) ; break ; } break ; } } } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) ThrowImageException ( FileOpenError , \"UnableToCreateTemporaryFile\" ) ; while ( ( c = ReadBlobByte ( image ) ) != EOF ) ( void ) fputc ( c , file ) ; ( void ) fclose ( file ) ; ( void ) CloseBlob ( image ) ; image = DestroyImage ( image ) ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"group4:%s\" , filename ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , \"%lux%lu\" , width , height ) ; ( void ) CloneString ( & read_info -> size , message ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , \"%lu\" , density ) ; ( void ) CloneString ( & read_info -> density , message ) ; read_info -> orientation = ( OrientationType ) orientation ; image = ReadImage ( read_info , exception ) ; if ( image != ( Image * ) NULL ) { ( void ) CopyMagickString ( image -> filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick_filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick , \"CALS\" , MagickPathExtent ) ; } read_info = DestroyImageInfo ( read_info ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; return ( image ) ; }\n", "\n", "\n", "Target: lua_newtable ( L ) ; luaL_checkstack ( L , 1 , \"infunctionmp_decode_to_lua_array\"\n", "\n", "Sources:\n", "0: CWE-787 void mp_decode_to_lua_array ( lua_State * L , mp_cur * c , size_t len ) { assert ( len <= UINT_MAX ) ; int index = 1 ; lua_newtable ( L ) ; while ( len -- ) { lua_pushnumber ( L , index ++ ) ; mp_decode_to_lua_type ( L , c ) ; if ( c -> err ) return ; lua_settable ( L , - 3 ) ; } }\n", "\n", "1: CWE-119 void mp_decode_to_lua_array ( lua_State * L , mp_cur * c , size_t len ) { assert ( len <= UINT_MAX ) ; int index = 1 ; lua_newtable ( L ) ; while ( len -- ) { lua_pushnumber ( L , index ++ ) ; mp_decode_to_lua_type ( L , c ) ; if ( c -> err ) return ; lua_settable ( L , - 3 ) ; } }\n", "\n", "\n", "Target: , message ) \\\\\\n{ if ( info ) ) ; \\\\\\n} char explicit_vr [ break ; } if ( fputc ( c , file ) != c ) break\n", "\n", "Sources:\n", "0: CWE-252 static Image * ReadDCMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowDCMException ( exception , message ) { if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; if ( stream_info != ( DCMStreamInfo * ) NULL ) stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char explicit_vr [ MagickPathExtent ] , implicit_vr [ MagickPathExtent ] , magick [ MagickPathExtent ] , photometric [ MagickPathExtent ] ; DCMInfo info ; DCMStreamInfo * stream_info ; Image * image ; int * bluemap , datum , * greenmap , * graymap , * redmap ; MagickBooleanType explicit_file , explicit_retry , use_explicit ; MagickOffsetType offset ; register unsigned char * p ; register ssize_t i ; size_t colors , height , length , number_scenes , quantum , status , width ; ssize_t count , scene ; unsigned char * data ; unsigned short group , element ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 8UL ; image -> endian = LSBEndian ; ( void ) memset ( & info , 0 , sizeof ( info ) ) ; data = ( unsigned char * ) NULL ; graymap = ( int * ) NULL ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; stream_info = ( DCMStreamInfo * ) AcquireMagickMemory ( sizeof ( * stream_info ) ) ; if ( stream_info == ( DCMStreamInfo * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( stream_info , 0 , sizeof ( * stream_info ) ) ; count = ReadBlob ( image , 128 , ( unsigned char * ) magick ) ; if ( count != 128 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; if ( ( count != 4 ) || ( LocaleNCompare ( magick , \"DICM\" , 4 ) != 0 ) ) { offset = SeekBlob ( image , 0L , SEEK_SET ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } ( void ) CopyMagickString ( photometric , \"MONOCHROME1\" , MagickPathExtent ) ; info . bits_allocated = 8 ; info . bytes_per_pixel = 1 ; info . depth = 8 ; info . mask = 0xffff ; info . max_value = 255UL ; info . samples_per_pixel = 1 ; info . signed_data = ( ~ 0UL ) ; info . rescale_slope = 1.0 ; data = ( unsigned char * ) NULL ; element = 0 ; explicit_vr [ 2 ] = '\\\\0' ; explicit_file = MagickFalse ; colors = 0 ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; graymap = ( int * ) NULL ; height = 0 ; number_scenes = 1 ; use_explicit = MagickFalse ; explicit_retry = MagickFalse ; width = 0 ; while ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { for ( group = 0 ; ( group != 0x7FE0 ) || ( element != 0x0010 ) ; ) { image -> offset = ( ssize_t ) TellBlob ( image ) ; group = ReadBlobLSBShort ( image ) ; element = ReadBlobLSBShort ( image ) ; if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) break ; if ( ( group != 0x0002 ) && ( image -> endian == MSBEndian ) ) { group = ( unsigned short ) ( ( group << 8 ) | ( ( group >> 8 ) & 0xFF ) ) ; element = ( unsigned short ) ( ( element << 8 ) | ( ( element >> 8 ) & 0xFF ) ) ; } quantum = 0 ; for ( i = 0 ; dicom_info [ i ] . group < 0xffff ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) CopyMagickString ( implicit_vr , dicom_info [ i ] . vr , MagickPathExtent ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) explicit_vr ) ; if ( count != 2 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( explicit_file == MagickFalse ) && ( group != 0x0002 ) ) explicit_file = ( isupper ( ( unsigned char ) * explicit_vr ) != MagickFalse ) && ( isupper ( ( unsigned char ) * ( explicit_vr + 1 ) ) != MagickFalse ) ? MagickTrue : MagickFalse ; use_explicit = ( ( group == 0x0002 ) && ( explicit_retry == MagickFalse ) ) || ( explicit_file != MagickFalse ) ? MagickTrue : MagickFalse ; if ( ( use_explicit != MagickFalse ) && ( strncmp ( implicit_vr , \"xs\" , 2 ) == 0 ) ) ( void ) CopyMagickString ( implicit_vr , explicit_vr , MagickPathExtent ) ; if ( ( use_explicit == MagickFalse ) || ( strncmp ( implicit_vr , \"!!\" , 2 ) == 0 ) ) { offset = SeekBlob ( image , ( MagickOffsetType ) - 2 , SEEK_CUR ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; quantum = 4 ; } else { quantum = 2 ; if ( ( strncmp ( explicit_vr , \"OB\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"UN\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"SQ\" , 2 ) == 0 ) ) { ( void ) ReadBlobLSBShort ( image ) ; quantum = 4 ; } } datum = 0 ; if ( quantum == 4 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( quantum == 2 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } quantum = 0 ; length = 1 ; if ( datum != 0 ) { if ( ( strncmp ( implicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SS\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"US\" , 2 ) == 0 ) ) quantum = 2 ; else if ( ( strncmp ( implicit_vr , \"FL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"OF\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"UL\" , 2 ) == 0 ) ) quantum = 4 ; else if ( strncmp ( implicit_vr , \"FD\" , 2 ) == 0 ) quantum = 8 ; else quantum = 1 ; if ( datum != ~ 0 ) length = ( size_t ) datum / quantum ; else { quantum = 0 ; length = 0 ; } } if ( image_info -> verbose != MagickFalse ) { if ( use_explicit == MagickFalse ) explicit_vr [ 0 ] = '\\\\0' ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) FormatLocaleFile ( stdout , \"0x%04lX%4ld%s-%s(0x%04lx,0x%04lx)\" , ( unsigned long ) image -> offset , ( long ) length , implicit_vr , explicit_vr , ( unsigned long ) group , ( unsigned long ) element ) ; if ( dicom_info [ i ] . description != ( char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%s\" , dicom_info [ i ] . description ) ; ( void ) FormatLocaleFile ( stdout , \":\" ) ; } if ( ( group == 0x7FE0 ) && ( element == 0x0010 ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; break ; } data = ( unsigned char * ) NULL ; if ( ( length == 1 ) && ( quantum == 1 ) ) datum = ReadBlobByte ( image ) ; else if ( ( length == 1 ) && ( quantum == 2 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } else if ( ( length == 1 ) && ( quantum == 4 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( ( quantum != 0 ) && ( length != 0 ) ) { if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ~ length >= 1 ) data = ( unsigned char * ) AcquireQuantumMemory ( length + 1 , quantum * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , ( size_t ) quantum * length , data ) ; if ( count != ( ssize_t ) ( quantum * length ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"count=%dquantum=%d\" \"length=%dgroup=%d\\\\n\" , ( int ) count , ( int ) quantum , ( int ) length , ( int ) group ) ; ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } data [ length * quantum ] = '\\\\0' ; } if ( ( ( ( unsigned int ) group << 16 ) | element ) == 0xFFFEE0DD ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; continue ; } switch ( group ) { case 0x0002 : { switch ( element ) { case 0x0010 : { char transfer_syntax [ MagickPathExtent ] ; if ( ( datum == 0 ) && ( explicit_retry == MagickFalse ) ) { explicit_retry = MagickTrue ; ( void ) SeekBlob ( image , ( MagickOffsetType ) 0 , SEEK_SET ) ; group = 0 ; element = 0 ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"Corruptedimage-tryingexplicitformat\\\\n\" ) ; break ; } * transfer_syntax = '\\\\0' ; if ( data != ( unsigned char * ) NULL ) ( void ) CopyMagickString ( transfer_syntax , ( char * ) data , MagickPathExtent ) ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"transfer_syntax=%s\\\\n\" , ( const char * ) transfer_syntax ) ; if ( strncmp ( transfer_syntax , \"1.2.840.10008.1.2\" , 17 ) == 0 ) { int subtype , type ; type = 1 ; subtype = 0 ; if ( strlen ( transfer_syntax ) > 17 ) { count = ( ssize_t ) sscanf ( transfer_syntax + 17 , \".%d.%d\" , & type , & subtype ) ; if ( count < 1 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } switch ( type ) { case 1 : { image -> endian = LSBEndian ; break ; } case 2 : { image -> endian = MSBEndian ; break ; } case 4 : { if ( ( subtype >= 80 ) && ( subtype <= 81 ) ) image -> compression = JPEGCompression ; else if ( ( subtype >= 90 ) && ( subtype <= 93 ) ) image -> compression = JPEG2000Compression ; else image -> compression = JPEGCompression ; break ; } case 5 : { image -> compression = RLECompression ; break ; } } } break ; } default : break ; } break ; } case 0x0028 : { switch ( element ) { case 0x0002 : { info . samples_per_pixel = ( size_t ) datum ; if ( ( info . samples_per_pixel == 0 ) || ( info . samples_per_pixel > 4 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; break ; } case 0x0004 : { if ( data == ( unsigned char * ) NULL ) break ; for ( i = 0 ; i < ( ssize_t ) MagickMin ( length , MagickPathExtent - 1 ) ; i ++ ) photometric [ i ] = ( char ) data [ i ] ; photometric [ i ] = '\\\\0' ; info . polarity = LocaleCompare ( photometric , \"MONOCHROME1\" ) == 0 ? MagickTrue : MagickFalse ; break ; } case 0x0006 : { if ( datum == 1 ) image -> interlace = PlaneInterlace ; break ; } case 0x0008 : { if ( data == ( unsigned char * ) NULL ) break ; number_scenes = StringToUnsignedLong ( ( char * ) data ) ; break ; } case 0x0010 : { height = ( size_t ) datum ; break ; } case 0x0011 : { width = ( size_t ) datum ; break ; } case 0x0100 : { info . bits_allocated = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( datum > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . bits_allocated ; if ( ( info . depth == 0 ) || ( info . depth > 32 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . bits_allocated ) - 1 ; image -> depth = info . depth ; break ; } case 0x0101 : { info . significant_bits = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( info . significant_bits > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . significant_bits ; if ( ( info . depth == 0 ) || ( info . depth > 16 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . significant_bits ) - 1 ; info . mask = ( size_t ) GetQuantumRange ( info . significant_bits ) ; image -> depth = info . depth ; break ; } case 0x0102 : { break ; } case 0x0103 : { info . signed_data = ( size_t ) datum ; break ; } case 0x1050 : { if ( data != ( unsigned char * ) NULL ) info . window_center = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1051 : { if ( data != ( unsigned char * ) NULL ) info . window_width = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1052 : { if ( data != ( unsigned char * ) NULL ) info . rescale_intercept = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1053 : { if ( data != ( unsigned char * ) NULL ) info . rescale_slope = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1200 : case 0x3006 : { if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / info . bytes_per_pixel ) ; datum = ( int ) colors ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; graymap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * graymap ) ) ; if ( graymap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( graymap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * graymap ) ) ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) if ( info . bytes_per_pixel == 1 ) graymap [ i ] = ( int ) data [ i ] ; else graymap [ i ] = ( int ) ( ( short * ) data ) [ i ] ; break ; } case 0x1201 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; redmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * redmap ) ) ; if ( redmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( redmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * redmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; redmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1202 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; greenmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * greenmap ) ) ; if ( greenmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( greenmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * greenmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; greenmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1203 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; bluemap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * bluemap ) ) ; if ( bluemap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( bluemap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * bluemap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; bluemap [ i ] = ( int ) index ; p += 2 ; } break ; } default : break ; } break ; } case 0x2050 : { switch ( element ) { case 0x0020 : { if ( ( data != ( unsigned char * ) NULL ) && ( strncmp ( ( char * ) data , \"INVERSE\" , 7 ) == 0 ) ) info . polarity = MagickTrue ; break ; } default : break ; } break ; } default : break ; } if ( data != ( unsigned char * ) NULL ) { char * attribute ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; if ( dicom_info [ i ] . description != ( char * ) NULL ) { attribute = AcquireString ( \"dcm:\" ) ; ( void ) ConcatenateString ( & attribute , dicom_info [ i ] . description ) ; for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i == ( ssize_t ) length ) || ( length > 4 ) ) { ( void ) SubstituteString ( & attribute , \"\" , \"\" ) ; ( void ) SetImageProperty ( image , attribute , ( char * ) data , exception ) ; } attribute = DestroyString ( attribute ) ; } } if ( image_info -> verbose != MagickFalse ) { if ( data == ( unsigned char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%d\\\\n\" , datum ) ; else { for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i != ( ssize_t ) length ) && ( length <= 4 ) ) { ssize_t j ; datum = 0 ; for ( j = ( ssize_t ) length - 1 ; j >= 0 ; j -- ) datum = ( 256 * datum + data [ j ] ) ; ( void ) FormatLocaleFile ( stdout , \"%d\" , datum ) ; } else for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( isprint ( ( int ) data [ i ] ) != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"%c\" , data [ i ] ) ; else ( void ) FormatLocaleFile ( stdout , \"%c\" , '.' ) ; ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; } } if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } } if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) { Image * last ; last = RemoveLastImageFromList ( & image ) ; if ( last != ( Image * ) NULL ) last = DestroyImage ( last ) ; break ; } if ( ( width == 0 ) || ( height == 0 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; if ( info . signed_data == 0xffff ) info . signed_data = ( size_t ) ( info . significant_bits == 16 ? 1 : 0 ) ; if ( ( image -> compression == JPEGCompression ) || ( image -> compression == JPEG2000Compression ) ) { Image * images ; ImageInfo * read_info ; int c ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ( ( ( ssize_t ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; images = NewImageList ( ) ; for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { char filename [ MagickPathExtent ] ; const char * property ; FILE * file ; Image * jpeg_image ; int unique_file ; unsigned int tag ; tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( tag == 0xFFFEE0DD ) break ; if ( tag != 0xFFFEE000 ) { read_info = DestroyImageInfo ( read_info ) ; ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( file == ( FILE * ) NULL ) { ( void ) RelinquishUniqueFileResource ( filename ) ; ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , filename ) ; break ; } for ( c = EOF ; length != 0 ; length -- ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; if ( c == EOF ) break ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"jpeg:%s\" , filename ) ; if ( image -> compression == JPEG2000Compression ) ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"j2k:%s\" , filename ) ; jpeg_image = ReadImage ( read_info , exception ) ; if ( jpeg_image != ( Image * ) NULL ) { ResetImagePropertyIterator ( image ) ; property = GetNextImageProperty ( image ) ; while ( property != ( const char * ) NULL ) { ( void ) SetImageProperty ( jpeg_image , property , GetImageProperty ( image , property , exception ) , exception ) ; property = GetNextImageProperty ( image ) ; } AppendImageToList ( & images , jpeg_image ) ; } ( void ) RelinquishUniqueFileResource ( filename ) ; } read_info = DestroyImageInfo ( read_info ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; image = DestroyImageList ( image ) ; return ( GetFirstImageInList ( images ) ) ; } if ( info . depth != ( 1UL * MAGICKCORE_QUANTUM_DEPTH ) ) { QuantumAny range ; length = ( size_t ) ( GetQuantumRange ( info . depth ) + 1 ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; info . scale = ( Quantum * ) AcquireQuantumMemory ( MagickMax ( length , 256 ) , sizeof ( * info . scale ) ) ; if ( info . scale == ( Quantum * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( info . scale , 0 , MagickMax ( length , 256 ) * sizeof ( * info . scale ) ) ; range = GetQuantumRange ( info . depth ) ; for ( i = 0 ; i <= ( ssize_t ) GetQuantumRange ( info . depth ) ; i ++ ) info . scale [ i ] = ScaleAnyToQuantum ( ( size_t ) i , range ) ; } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) { stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; } offset = TellBlob ( image ) + 8 ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } } for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { if ( image_info -> ping != MagickFalse ) break ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; image -> depth = info . depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; image -> colorspace = RGBColorspace ; ( void ) SetImageBackgroundColor ( image , exception ) ; if ( ( image -> colormap == ( PixelInfo * ) NULL ) && ( info . samples_per_pixel == 1 ) ) { int index ; size_t one ; one = 1 ; if ( colors == 0 ) colors = one << info . depth ; if ( AcquireImageColormap ( image , colors , exception ) == MagickFalse ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( redmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = redmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; } if ( greenmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = greenmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . green = ( MagickRealType ) index ; } if ( bluemap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = bluemap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } if ( graymap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = graymap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; image -> colormap [ i ] . green = ( MagickRealType ) index ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; stream_info -> remaining = ( size_t ) ReadBlobLSBLong ( image ) ; if ( ( tag != 0xFFFEE000 ) || ( stream_info -> remaining <= 64 ) || ( EOFBlob ( image ) != MagickFalse ) ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } stream_info -> count = 0 ; stream_info -> segment_count = ReadBlobLSBLong ( image ) ; for ( i = 0 ; i < 15 ; i ++ ) stream_info -> segments [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; stream_info -> remaining -= 64 ; if ( stream_info -> segment_count > 1 ) { info . bytes_per_pixel = 1 ; info . depth = 8 ; if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 0 ] , SEEK_SET ) ; } } if ( ( info . samples_per_pixel > 1 ) && ( image -> interlace == PlaneInterlace ) ) { register ssize_t x ; register Quantum * q ; ssize_t y ; for ( i = 0 ; i < ( ssize_t ) info . samples_per_pixel ; i ++ ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( ( int ) i ) { case 0 : { SetPixelRed ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 1 : { SetPixelGreen ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 2 : { SetPixelBlue ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 3 : { SetPixelAlpha ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } default : break ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } } else { const char * option ; option = GetImageOption ( image_info , \"dcm:display-range\" ) ; if ( option != ( const char * ) NULL ) { if ( LocaleCompare ( option , \"reset\" ) == 0 ) info . window_width = 0 ; } option = GetImageOption ( image_info , \"dcm:window\" ) ; if ( option != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( option , & geometry_info ) ; if ( flags & RhoValue ) info . window_center = geometry_info . rho ; if ( flags & SigmaValue ) info . window_width = geometry_info . sigma ; info . rescale = MagickTrue ; } option = GetImageOption ( image_info , \"dcm:rescale\" ) ; if ( option != ( char * ) NULL ) info . rescale = IsStringTrue ( option ) ; if ( ( info . window_center != 0 ) && ( info . window_width == 0 ) ) info . window_width = info . window_center ; status = ReadDCMPixels ( image , & info , stream_info , MagickTrue , exception ) ; if ( ( status != MagickFalse ) && ( stream_info -> segment_count > 1 ) ) { if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 1 ] , SEEK_SET ) ; ( void ) ReadDCMPixels ( image , & info , stream_info , MagickFalse , exception ) ; } } if ( SetImageGray ( image , exception ) != MagickFalse ) ( void ) SetImageColorspace ( image , GRAYColorspace , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( number_scenes - 1 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-20 static Image * ReadDCMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowDCMException ( exception , message ) { if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; if ( stream_info != ( DCMStreamInfo * ) NULL ) stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char explicit_vr [ MagickPathExtent ] , implicit_vr [ MagickPathExtent ] , magick [ MagickPathExtent ] , photometric [ MagickPathExtent ] ; DCMInfo info ; DCMStreamInfo * stream_info ; Image * image ; int * bluemap , datum , * greenmap , * graymap , * redmap ; MagickBooleanType explicit_file , explicit_retry , use_explicit ; MagickOffsetType offset ; register unsigned char * p ; register ssize_t i ; size_t colors , height , length , number_scenes , quantum , status , width ; ssize_t count , scene ; unsigned char * data ; unsigned short group , element ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 8UL ; image -> endian = LSBEndian ; ( void ) memset ( & info , 0 , sizeof ( info ) ) ; data = ( unsigned char * ) NULL ; graymap = ( int * ) NULL ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; stream_info = ( DCMStreamInfo * ) AcquireMagickMemory ( sizeof ( * stream_info ) ) ; if ( stream_info == ( DCMStreamInfo * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( stream_info , 0 , sizeof ( * stream_info ) ) ; count = ReadBlob ( image , 128 , ( unsigned char * ) magick ) ; if ( count != 128 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; if ( ( count != 4 ) || ( LocaleNCompare ( magick , \"DICM\" , 4 ) != 0 ) ) { offset = SeekBlob ( image , 0L , SEEK_SET ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } ( void ) CopyMagickString ( photometric , \"MONOCHROME1\" , MagickPathExtent ) ; info . bits_allocated = 8 ; info . bytes_per_pixel = 1 ; info . depth = 8 ; info . mask = 0xffff ; info . max_value = 255UL ; info . samples_per_pixel = 1 ; info . signed_data = ( ~ 0UL ) ; info . rescale_slope = 1.0 ; data = ( unsigned char * ) NULL ; element = 0 ; explicit_vr [ 2 ] = '\\\\0' ; explicit_file = MagickFalse ; colors = 0 ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; graymap = ( int * ) NULL ; height = 0 ; number_scenes = 1 ; use_explicit = MagickFalse ; explicit_retry = MagickFalse ; width = 0 ; while ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { for ( group = 0 ; ( group != 0x7FE0 ) || ( element != 0x0010 ) ; ) { image -> offset = ( ssize_t ) TellBlob ( image ) ; group = ReadBlobLSBShort ( image ) ; element = ReadBlobLSBShort ( image ) ; if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) break ; if ( ( group != 0x0002 ) && ( image -> endian == MSBEndian ) ) { group = ( unsigned short ) ( ( group << 8 ) | ( ( group >> 8 ) & 0xFF ) ) ; element = ( unsigned short ) ( ( element << 8 ) | ( ( element >> 8 ) & 0xFF ) ) ; } quantum = 0 ; for ( i = 0 ; dicom_info [ i ] . group < 0xffff ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) CopyMagickString ( implicit_vr , dicom_info [ i ] . vr , MagickPathExtent ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) explicit_vr ) ; if ( count != 2 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( explicit_file == MagickFalse ) && ( group != 0x0002 ) ) explicit_file = ( isupper ( ( unsigned char ) * explicit_vr ) != MagickFalse ) && ( isupper ( ( unsigned char ) * ( explicit_vr + 1 ) ) != MagickFalse ) ? MagickTrue : MagickFalse ; use_explicit = ( ( group == 0x0002 ) && ( explicit_retry == MagickFalse ) ) || ( explicit_file != MagickFalse ) ? MagickTrue : MagickFalse ; if ( ( use_explicit != MagickFalse ) && ( strncmp ( implicit_vr , \"xs\" , 2 ) == 0 ) ) ( void ) CopyMagickString ( implicit_vr , explicit_vr , MagickPathExtent ) ; if ( ( use_explicit == MagickFalse ) || ( strncmp ( implicit_vr , \"!!\" , 2 ) == 0 ) ) { offset = SeekBlob ( image , ( MagickOffsetType ) - 2 , SEEK_CUR ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; quantum = 4 ; } else { quantum = 2 ; if ( ( strncmp ( explicit_vr , \"OB\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"UN\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( explicit_vr , \"SQ\" , 2 ) == 0 ) ) { ( void ) ReadBlobLSBShort ( image ) ; quantum = 4 ; } } datum = 0 ; if ( quantum == 4 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( quantum == 2 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } quantum = 0 ; length = 1 ; if ( datum != 0 ) { if ( ( strncmp ( implicit_vr , \"OW\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SS\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"US\" , 2 ) == 0 ) ) quantum = 2 ; else if ( ( strncmp ( implicit_vr , \"FL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"OF\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"SL\" , 2 ) == 0 ) || ( strncmp ( implicit_vr , \"UL\" , 2 ) == 0 ) ) quantum = 4 ; else if ( strncmp ( implicit_vr , \"FD\" , 2 ) == 0 ) quantum = 8 ; else quantum = 1 ; if ( datum != ~ 0 ) length = ( size_t ) datum / quantum ; else { quantum = 0 ; length = 0 ; } } if ( image_info -> verbose != MagickFalse ) { if ( use_explicit == MagickFalse ) explicit_vr [ 0 ] = '\\\\0' ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) FormatLocaleFile ( stdout , \"0x%04lX%4ld%s-%s(0x%04lx,0x%04lx)\" , ( unsigned long ) image -> offset , ( long ) length , implicit_vr , explicit_vr , ( unsigned long ) group , ( unsigned long ) element ) ; if ( dicom_info [ i ] . description != ( char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%s\" , dicom_info [ i ] . description ) ; ( void ) FormatLocaleFile ( stdout , \":\" ) ; } if ( ( group == 0x7FE0 ) && ( element == 0x0010 ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; break ; } data = ( unsigned char * ) NULL ; if ( ( length == 1 ) && ( quantum == 1 ) ) datum = ReadBlobByte ( image ) ; else if ( ( length == 1 ) && ( quantum == 2 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } else if ( ( length == 1 ) && ( quantum == 4 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( ( quantum != 0 ) && ( length != 0 ) ) { if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ~ length >= 1 ) data = ( unsigned char * ) AcquireQuantumMemory ( length + 1 , quantum * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , ( size_t ) quantum * length , data ) ; if ( count != ( ssize_t ) ( quantum * length ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"count=%dquantum=%d\" \"length=%dgroup=%d\\\\n\" , ( int ) count , ( int ) quantum , ( int ) length , ( int ) group ) ; ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; } data [ length * quantum ] = '\\\\0' ; } if ( ( ( ( unsigned int ) group << 16 ) | element ) == 0xFFFEE0DD ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; continue ; } switch ( group ) { case 0x0002 : { switch ( element ) { case 0x0010 : { char transfer_syntax [ MagickPathExtent ] ; if ( ( datum == 0 ) && ( explicit_retry == MagickFalse ) ) { explicit_retry = MagickTrue ; ( void ) SeekBlob ( image , ( MagickOffsetType ) 0 , SEEK_SET ) ; group = 0 ; element = 0 ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"Corruptedimage-tryingexplicitformat\\\\n\" ) ; break ; } * transfer_syntax = '\\\\0' ; if ( data != ( unsigned char * ) NULL ) ( void ) CopyMagickString ( transfer_syntax , ( char * ) data , MagickPathExtent ) ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"transfer_syntax=%s\\\\n\" , ( const char * ) transfer_syntax ) ; if ( strncmp ( transfer_syntax , \"1.2.840.10008.1.2\" , 17 ) == 0 ) { int subtype , type ; type = 1 ; subtype = 0 ; if ( strlen ( transfer_syntax ) > 17 ) { count = ( ssize_t ) sscanf ( transfer_syntax + 17 , \".%d.%d\" , & type , & subtype ) ; if ( count < 1 ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } switch ( type ) { case 1 : { image -> endian = LSBEndian ; break ; } case 2 : { image -> endian = MSBEndian ; break ; } case 4 : { if ( ( subtype >= 80 ) && ( subtype <= 81 ) ) image -> compression = JPEGCompression ; else if ( ( subtype >= 90 ) && ( subtype <= 93 ) ) image -> compression = JPEG2000Compression ; else image -> compression = JPEGCompression ; break ; } case 5 : { image -> compression = RLECompression ; break ; } } } break ; } default : break ; } break ; } case 0x0028 : { switch ( element ) { case 0x0002 : { info . samples_per_pixel = ( size_t ) datum ; if ( ( info . samples_per_pixel == 0 ) || ( info . samples_per_pixel > 4 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; break ; } case 0x0004 : { if ( data == ( unsigned char * ) NULL ) break ; for ( i = 0 ; i < ( ssize_t ) MagickMin ( length , MagickPathExtent - 1 ) ; i ++ ) photometric [ i ] = ( char ) data [ i ] ; photometric [ i ] = '\\\\0' ; info . polarity = LocaleCompare ( photometric , \"MONOCHROME1\" ) == 0 ? MagickTrue : MagickFalse ; break ; } case 0x0006 : { if ( datum == 1 ) image -> interlace = PlaneInterlace ; break ; } case 0x0008 : { if ( data == ( unsigned char * ) NULL ) break ; number_scenes = StringToUnsignedLong ( ( char * ) data ) ; break ; } case 0x0010 : { height = ( size_t ) datum ; break ; } case 0x0011 : { width = ( size_t ) datum ; break ; } case 0x0100 : { info . bits_allocated = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( datum > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . bits_allocated ; if ( ( info . depth == 0 ) || ( info . depth > 32 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . bits_allocated ) - 1 ; image -> depth = info . depth ; break ; } case 0x0101 : { info . significant_bits = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( info . significant_bits > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . significant_bits ; if ( ( info . depth == 0 ) || ( info . depth > 16 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; info . max_value = ( 1UL << info . significant_bits ) - 1 ; info . mask = ( size_t ) GetQuantumRange ( info . significant_bits ) ; image -> depth = info . depth ; break ; } case 0x0102 : { break ; } case 0x0103 : { info . signed_data = ( size_t ) datum ; break ; } case 0x1050 : { if ( data != ( unsigned char * ) NULL ) info . window_center = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1051 : { if ( data != ( unsigned char * ) NULL ) info . window_width = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1052 : { if ( data != ( unsigned char * ) NULL ) info . rescale_intercept = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1053 : { if ( data != ( unsigned char * ) NULL ) info . rescale_slope = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1200 : case 0x3006 : { if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / info . bytes_per_pixel ) ; datum = ( int ) colors ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; graymap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * graymap ) ) ; if ( graymap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( graymap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * graymap ) ) ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) if ( info . bytes_per_pixel == 1 ) graymap [ i ] = ( int ) data [ i ] ; else graymap [ i ] = ( int ) ( ( short * ) data ) [ i ] ; break ; } case 0x1201 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; redmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * redmap ) ) ; if ( redmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( redmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * redmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; redmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1202 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; greenmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * greenmap ) ) ; if ( greenmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( greenmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * greenmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; greenmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1203 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; bluemap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * bluemap ) ) ; if ( bluemap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( bluemap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * bluemap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; bluemap [ i ] = ( int ) index ; p += 2 ; } break ; } default : break ; } break ; } case 0x2050 : { switch ( element ) { case 0x0020 : { if ( ( data != ( unsigned char * ) NULL ) && ( strncmp ( ( char * ) data , \"INVERSE\" , 7 ) == 0 ) ) info . polarity = MagickTrue ; break ; } default : break ; } break ; } default : break ; } if ( data != ( unsigned char * ) NULL ) { char * attribute ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; if ( dicom_info [ i ] . description != ( char * ) NULL ) { attribute = AcquireString ( \"dcm:\" ) ; ( void ) ConcatenateString ( & attribute , dicom_info [ i ] . description ) ; for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i == ( ssize_t ) length ) || ( length > 4 ) ) { ( void ) SubstituteString ( & attribute , \"\" , \"\" ) ; ( void ) SetImageProperty ( image , attribute , ( char * ) data , exception ) ; } attribute = DestroyString ( attribute ) ; } } if ( image_info -> verbose != MagickFalse ) { if ( data == ( unsigned char * ) NULL ) ( void ) FormatLocaleFile ( stdout , \"%d\\\\n\" , datum ) ; else { for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i != ( ssize_t ) length ) && ( length <= 4 ) ) { ssize_t j ; datum = 0 ; for ( j = ( ssize_t ) length - 1 ; j >= 0 ; j -- ) datum = ( 256 * datum + data [ j ] ) ; ( void ) FormatLocaleFile ( stdout , \"%d\" , datum ) ; } else for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( isprint ( ( int ) data [ i ] ) != MagickFalse ) ( void ) FormatLocaleFile ( stdout , \"%c\" , data [ i ] ) ; else ( void ) FormatLocaleFile ( stdout , \"%c\" , '.' ) ; ( void ) FormatLocaleFile ( stdout , \"\\\\n\" ) ; } } if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } } if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) { Image * last ; last = RemoveLastImageFromList ( & image ) ; if ( last != ( Image * ) NULL ) last = DestroyImage ( last ) ; break ; } if ( ( width == 0 ) || ( height == 0 ) ) ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; if ( info . signed_data == 0xffff ) info . signed_data = ( size_t ) ( info . significant_bits == 16 ? 1 : 0 ) ; if ( ( image -> compression == JPEGCompression ) || ( image -> compression == JPEG2000Compression ) ) { Image * images ; ImageInfo * read_info ; int c ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ( ( ( ssize_t ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; images = NewImageList ( ) ; for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { char filename [ MagickPathExtent ] ; const char * property ; FILE * file ; Image * jpeg_image ; int unique_file ; unsigned int tag ; tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( tag == 0xFFFEE0DD ) break ; if ( tag != 0xFFFEE000 ) { read_info = DestroyImageInfo ( read_info ) ; ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( file == ( FILE * ) NULL ) { ( void ) RelinquishUniqueFileResource ( filename ) ; ThrowFileException ( exception , FileOpenError , \"UnableToCreateTemporaryFile\" , filename ) ; break ; } for ( c = EOF ; length != 0 ; length -- ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; if ( c == EOF ) break ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"jpeg:%s\" , filename ) ; if ( image -> compression == JPEG2000Compression ) ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , \"j2k:%s\" , filename ) ; jpeg_image = ReadImage ( read_info , exception ) ; if ( jpeg_image != ( Image * ) NULL ) { ResetImagePropertyIterator ( image ) ; property = GetNextImageProperty ( image ) ; while ( property != ( const char * ) NULL ) { ( void ) SetImageProperty ( jpeg_image , property , GetImageProperty ( image , property , exception ) , exception ) ; property = GetNextImageProperty ( image ) ; } AppendImageToList ( & images , jpeg_image ) ; } ( void ) RelinquishUniqueFileResource ( filename ) ; } read_info = DestroyImageInfo ( read_info ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; image = DestroyImageList ( image ) ; return ( GetFirstImageInList ( images ) ) ; } if ( info . depth != ( 1UL * MAGICKCORE_QUANTUM_DEPTH ) ) { QuantumAny range ; length = ( size_t ) ( GetQuantumRange ( info . depth ) + 1 ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; info . scale = ( Quantum * ) AcquireQuantumMemory ( MagickMax ( length , 256 ) , sizeof ( * info . scale ) ) ; if ( info . scale == ( Quantum * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) memset ( info . scale , 0 , MagickMax ( length , 256 ) * sizeof ( * info . scale ) ) ; range = GetQuantumRange ( info . depth ) ; for ( i = 0 ; i <= ( ssize_t ) GetQuantumRange ( info . depth ) ; i ++ ) info . scale [ i ] = ScaleAnyToQuantum ( ( size_t ) i , range ) ; } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) { stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; } offset = TellBlob ( image ) + 8 ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } } for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { if ( image_info -> ping != MagickFalse ) break ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; image -> depth = info . depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; image -> colorspace = RGBColorspace ; ( void ) SetImageBackgroundColor ( image , exception ) ; if ( ( image -> colormap == ( PixelInfo * ) NULL ) && ( info . samples_per_pixel == 1 ) ) { int index ; size_t one ; one = 1 ; if ( colors == 0 ) colors = one << info . depth ; if ( AcquireImageColormap ( image , colors , exception ) == MagickFalse ) ThrowDCMException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( redmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = redmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; } if ( greenmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = greenmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . green = ( MagickRealType ) index ; } if ( bluemap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = bluemap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } if ( graymap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = graymap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; image -> colormap [ i ] . green = ( MagickRealType ) index ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; stream_info -> remaining = ( size_t ) ReadBlobLSBLong ( image ) ; if ( ( tag != 0xFFFEE000 ) || ( stream_info -> remaining <= 64 ) || ( EOFBlob ( image ) != MagickFalse ) ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; ThrowDCMException ( CorruptImageError , \"ImproperImageHeader\" ) ; } stream_info -> count = 0 ; stream_info -> segment_count = ReadBlobLSBLong ( image ) ; for ( i = 0 ; i < 15 ; i ++ ) stream_info -> segments [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; stream_info -> remaining -= 64 ; if ( stream_info -> segment_count > 1 ) { info . bytes_per_pixel = 1 ; info . depth = 8 ; if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 0 ] , SEEK_SET ) ; } } if ( ( info . samples_per_pixel > 1 ) && ( image -> interlace == PlaneInterlace ) ) { register ssize_t x ; register Quantum * q ; ssize_t y ; for ( i = 0 ; i < ( ssize_t ) info . samples_per_pixel ; i ++ ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( ( int ) i ) { case 0 : { SetPixelRed ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 1 : { SetPixelGreen ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 2 : { SetPixelBlue ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 3 : { SetPixelAlpha ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } default : break ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } } else { const char * option ; option = GetImageOption ( image_info , \"dcm:display-range\" ) ; if ( option != ( const char * ) NULL ) { if ( LocaleCompare ( option , \"reset\" ) == 0 ) info . window_width = 0 ; } option = GetImageOption ( image_info , \"dcm:window\" ) ; if ( option != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( option , & geometry_info ) ; if ( flags & RhoValue ) info . window_center = geometry_info . rho ; if ( flags & SigmaValue ) info . window_width = geometry_info . sigma ; info . rescale = MagickTrue ; } option = GetImageOption ( image_info , \"dcm:rescale\" ) ; if ( option != ( char * ) NULL ) info . rescale = IsStringTrue ( option ) ; if ( ( info . window_center != 0 ) && ( info . window_width == 0 ) ) info . window_width = info . window_center ; status = ReadDCMPixels ( image , & info , stream_info , MagickTrue , exception ) ; if ( ( status != MagickFalse ) && ( stream_info -> segment_count > 1 ) ) { if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 1 ] , SEEK_SET ) ; ( void ) ReadDCMPixels ( image , & info , stream_info , MagickFalse , exception ) ; } } if ( SetImageGray ( image , exception ) != MagickFalse ) ( void ) SetImageColorspace ( image , GRAYColorspace , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( number_scenes - 1 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ; dlen -= 3 ; for (\n", "\n", "Sources:\n", "0: CWE-787 void imap_quote_string ( char * dest , size_t dlen , const char * src , bool quote_backtick ) { const char * quote = \"`\\\\\"\\\\\\\\\" ; if ( ! quote_backtick ) quote ++ ; char * pt = dest ; const char * s = src ; * pt ++ = \\'\"\\' ; dlen -= 2 ; for ( ; * s && dlen ; s ++ ) { if ( strchr ( quote , * s ) ) { if ( dlen < 2 ) break ; dlen -= 2 ; * pt ++ = '\\\\\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \\'\"\\' ; * pt = '\\\\0' ; }\n", "\n", "1: CWE-119 void imap_quote_string ( char * dest , size_t dlen , const char * src , bool quote_backtick ) { const char * quote = \"`\\\\\"\\\\\\\\\" ; if ( ! quote_backtick ) quote ++ ; char * pt = dest ; const char * s = src ; * pt ++ = \\'\"\\' ; dlen -= 2 ; for ( ; * s && dlen ; s ++ ) { if ( strchr ( quote , * s ) ) { if ( dlen < 2 ) break ; dlen -= 2 ; * pt ++ = '\\\\\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \\'\"\\' ; * pt = '\\\\0' ; }\n", "\n", "\n", "Target: } bufsize = MIN ( file -> size , sizeof buf )\n", "\n", "Sources:\n", "0: CWE-415 static int read_public_key ( RSA * rsa ) { int r ; sc_path_t path ; sc_file_t * file ; u8 buf [ 2048 ] , * p = buf ; size_t bufsize , keysize ; r = select_app_df ( ) ; if ( r ) return 1 ; sc_format_path ( \"I1012\" , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r ) { fprintf ( stderr , \"Unabletoselectpublickeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = file -> size ; sc_file_free ( file ) ; r = sc_read_binary ( card , 0 , buf , bufsize , 0 ) ; if ( r < 0 ) { fprintf ( stderr , \"Unabletoreadpublickeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = r ; do { if ( bufsize < 4 ) return 3 ; keysize = ( p [ 0 ] << 8 ) | p [ 1 ] ; if ( keysize == 0 ) break ; if ( keysize < 3 ) return 3 ; if ( p [ 2 ] == opt_key_num ) break ; p += keysize ; bufsize -= keysize ; } while ( 1 ) ; if ( keysize == 0 ) { printf ( \"Keynumber%dnotfound.\\\\n\" , opt_key_num ) ; return 2 ; } return parse_public_key ( p , keysize , rsa ) ; }\n", "\n", "1: CWE-119 static int read_public_key ( RSA * rsa ) { int r ; sc_path_t path ; sc_file_t * file ; u8 buf [ 2048 ] , * p = buf ; size_t bufsize , keysize ; r = select_app_df ( ) ; if ( r ) return 1 ; sc_format_path ( \"I1012\" , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r ) { fprintf ( stderr , \"Unabletoselectpublickeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = file -> size ; sc_file_free ( file ) ; r = sc_read_binary ( card , 0 , buf , bufsize , 0 ) ; if ( r < 0 ) { fprintf ( stderr , \"Unabletoreadpublickeyfile:%s\\\\n\" , sc_strerror ( r ) ) ; return 2 ; } bufsize = r ; do { if ( bufsize < 4 ) return 3 ; keysize = ( p [ 0 ] << 8 ) | p [ 1 ] ; if ( keysize == 0 ) break ; if ( keysize < 3 ) return 3 ; if ( p [ 2 ] == opt_key_num ) break ; p += keysize ; bufsize -= keysize ; } while ( 1 ) ; if ( keysize == 0 ) { printf ( \"Keynumber%dnotfound.\\\\n\" , opt_key_num ) ; return 2 ; } return parse_public_key ( p , keysize , rsa ) ; }\n", "\n", "\n", "Target: ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; }\n", "\n", "Sources:\n", "0: CWE-835 static Image * ReadTXTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char colorspace [ MaxTextExtent ] , text [ MaxTextExtent ] ; Image * image ; IndexPacket * indexes ; long x_offset , y_offset ; MagickBooleanType status ; MagickPixelPacket pixel ; QuantumAny range ; register ssize_t i , x ; register PixelPacket * q ; ssize_t count , type , y ; unsigned long depth , height , max_value , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( text , 0 , sizeof ( text ) ) ; ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) != 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { width = 0 ; height = 0 ; max_value = 0 ; * colorspace = '\\\\0' ; count = ( ssize_t ) sscanf ( text + 32 , \"%lu,%lu,%lu,%s\" , & width , & height , & max_value , colorspace ) ; if ( ( count != 4 ) || ( width == 0 ) || ( height == 0 ) || ( max_value == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = width ; image -> rows = height ; for ( depth = 1 ; ( GetQuantumRange ( depth ) + 1 ) < max_value ; depth ++ ) ; image -> depth = depth ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } LocaleLower ( colorspace ) ; i = ( ssize_t ) strlen ( colorspace ) - 1 ; image -> matte = MagickFalse ; if ( ( i > 0 ) && ( colorspace [ i ] == 'a' ) ) { colorspace [ i ] = '\\\\0' ; image -> matte = MagickTrue ; } type = ParseCommandOption ( MagickColorspaceOptions , MagickFalse , colorspace ) ; if ( type < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> colorspace = ( ColorspaceType ) type ; ( void ) ResetMagickMemory ( & pixel , 0 , sizeof ( pixel ) ) ; ( void ) SetImageBackgroundColor ( image ) ; range = GetQuantumRange ( image -> depth ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { double blue , green , index , opacity , red ; red = 0.0 ; green = 0.0 ; blue = 0.0 ; index = 0.0 ; opacity = 0.0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ReadBlobString ( image , text ) == ( char * ) NULL ) break ; switch ( image -> colorspace ) { case GRAYColorspace : { if ( image -> matte != MagickFalse ) { ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & opacity ) ; green = red ; blue = red ; break ; } ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]\" , & x_offset , & y_offset , & red ) ; green = red ; blue = red ; break ; } case CMYKColorspace : { if ( image -> matte != MagickFalse ) { ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & index , & opacity ) ; break ; } ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & index ) ; break ; } default : { if ( image -> matte != MagickFalse ) { ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & opacity ) ; break ; } ( void ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue ) ; break ; } } if ( strchr ( text , '%' ) != ( char * ) NULL ) { red *= 0.01 * range ; green *= 0.01 * range ; blue *= 0.01 * range ; index *= 0.01 * range ; opacity *= 0.01 * range ; } if ( image -> colorspace == LabColorspace ) { green += ( range + 1 ) / 2.0 ; blue += ( range + 1 ) / 2.0 ; } pixel . red = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( red + 0.5 ) , range ) ; pixel . green = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( green + 0.5 ) , range ) ; pixel . blue = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( blue + 0.5 ) , range ) ; pixel . index = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( index + 0.5 ) , range ) ; pixel . opacity = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( opacity + 0.5 ) , range ) ; q = GetAuthenticPixels ( image , ( ssize_t ) x_offset , ( ssize_t ) y_offset , 1 , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) continue ; SetPixelRed ( q , pixel . red ) ; SetPixelGreen ( q , pixel . green ) ; SetPixelBlue ( q , pixel . blue ) ; if ( image -> colorspace == CMYKColorspace ) { indexes = GetAuthenticIndexQueue ( image ) ; SetPixelIndex ( indexes , pixel . index ) ; } if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , pixel . opacity ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } } ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 0 ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 0 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-835 static Image * ReadTXTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char colorspace [ MagickPathExtent ] , text [ MagickPathExtent ] ; Image * image ; long x_offset , y_offset ; PixelInfo pixel ; MagickBooleanType status ; QuantumAny range ; register ssize_t i , x ; register Quantum * q ; ssize_t count , type , y ; unsigned long depth , height , max_value , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( text , 0 , sizeof ( text ) ) ; ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) != 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { width = 0 ; height = 0 ; max_value = 0 ; * colorspace = '\\\\0' ; count = ( ssize_t ) sscanf ( text + 32 , \"%lu,%lu,%lu,%s\" , & width , & height , & max_value , colorspace ) ; if ( ( count != 4 ) || ( width == 0 ) || ( height == 0 ) || ( max_value == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> columns = width ; image -> rows = height ; for ( depth = 1 ; ( GetQuantumRange ( depth ) + 1 ) < max_value ; depth ++ ) ; image -> depth = depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; LocaleLower ( colorspace ) ; i = ( ssize_t ) strlen ( colorspace ) - 1 ; image -> alpha_trait = UndefinedPixelTrait ; if ( ( i > 0 ) && ( colorspace [ i ] == 'a' ) ) { colorspace [ i ] = '\\\\0' ; image -> alpha_trait = BlendPixelTrait ; } type = ParseCommandOption ( MagickColorspaceOptions , MagickFalse , colorspace ) ; if ( type < 0 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; ( void ) SetImageBackgroundColor ( image , exception ) ; ( void ) SetImageColorspace ( image , ( ColorspaceType ) type , exception ) ; GetPixelInfo ( image , & pixel ) ; range = GetQuantumRange ( image -> depth ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { double alpha , black , blue , green , red ; red = 0.0 ; green = 0.0 ; blue = 0.0 ; black = 0.0 ; alpha = 0.0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ReadBlobString ( image , text ) == ( char * ) NULL ) break ; switch ( image -> colorspace ) { case GRAYColorspace : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & alpha ) ; green = red ; blue = red ; break ; } count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]\" , & x_offset , & y_offset , & red ) ; green = red ; blue = red ; break ; } case CMYKColorspace : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & black , & alpha ) ; break ; } count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & black ) ; break ; } default : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue , & alpha ) ; break ; } count = ( ssize_t ) sscanf ( text , \"%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]\" , & x_offset , & y_offset , & red , & green , & blue ) ; break ; } } if ( strchr ( text , '%' ) != ( char * ) NULL ) { red *= 0.01 * range ; green *= 0.01 * range ; blue *= 0.01 * range ; black *= 0.01 * range ; alpha *= 0.01 * range ; } if ( image -> colorspace == LabColorspace ) { green += ( range + 1 ) / 2.0 ; blue += ( range + 1 ) / 2.0 ; } pixel . red = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( red + 0.5 ) , range ) ; pixel . green = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( green + 0.5 ) , range ) ; pixel . blue = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( blue + 0.5 ) , range ) ; pixel . black = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( black + 0.5 ) , range ) ; pixel . alpha = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( alpha + 0.5 ) , range ) ; q = GetAuthenticPixels ( image , ( ssize_t ) x_offset , ( ssize_t ) y_offset , 1 , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) continue ; SetPixelViaPixelInfo ( image , & pixel , q ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } } ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 0 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 0 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: IVD_ERROR_NONE == e_error && ( ps_stream -> u4_offset < ps_stream -> u4_max_offset )\n", "\n", "Sources:\n", "0: CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_pic_ext_data ( dec_state_t * ps_dec ) { stream_t * ps_stream ; UWORD32 u4_start_code ; IMPEG2D_ERROR_CODES_T e_error ; e_error = ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; ps_stream = & ps_dec -> s_bit_stream ; u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; while ( ( u4_start_code == EXTENSION_START_CODE || u4_start_code == USER_DATA_START_CODE ) && ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE == e_error ) { if ( u4_start_code == USER_DATA_START_CODE ) { impeg2d_dec_user_data ( ps_dec ) ; } else { impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , EXT_ID_LEN ) ; switch ( u4_start_code ) { case QUANT_MATRIX_EXT_ID : impeg2d_dec_quant_matrix_ext ( ps_dec ) ; break ; case COPYRIGHT_EXT_ID : impeg2d_dec_copyright_ext ( ps_dec ) ; break ; case PIC_DISPLAY_EXT_ID : impeg2d_dec_pic_disp_ext ( ps_dec ) ; break ; case CAMERA_PARAM_EXT_ID : impeg2d_dec_cam_param_ext ( ps_dec ) ; break ; case ITU_T_EXT_ID : impeg2d_dec_itu_t_ext ( ps_dec ) ; break ; case PIC_SPATIAL_SCALABLE_EXT_ID : case PIC_TEMPORAL_SCALABLE_EXT_ID : e_error = IMPEG2D_SCALABLITY_NOT_SUP ; break ; default : impeg2d_bit_stream_flush ( ps_stream , EXT_ID_LEN ) ; impeg2d_next_start_code ( ps_dec ) ; break ; } } u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; } return e_error ; }\n", "\n", "1: CWE-254 IMPEG2D_ERROR_CODES_T impeg2d_dec_seq_ext_data ( dec_state_t * ps_dec ) { stream_t * ps_stream ; UWORD32 u4_start_code ; IMPEG2D_ERROR_CODES_T e_error ; e_error = ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; ps_stream = & ps_dec -> s_bit_stream ; u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; while ( ( u4_start_code == EXTENSION_START_CODE || u4_start_code == USER_DATA_START_CODE ) && ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE == e_error ) { if ( u4_start_code == USER_DATA_START_CODE ) { impeg2d_dec_user_data ( ps_dec ) ; } else { impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , EXT_ID_LEN ) ; switch ( u4_start_code ) { case SEQ_DISPLAY_EXT_ID : impeg2d_dec_seq_disp_ext ( ps_dec ) ; break ; case SEQ_SCALABLE_EXT_ID : e_error = IMPEG2D_SCALABILITIY_NOT_SUPPORTED ; break ; default : impeg2d_bit_stream_flush ( ps_stream , EXT_ID_LEN ) ; impeg2d_peek_next_start_code ( ps_dec ) ; break ; } } u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; } return e_error ; }\n", "\n", "\n", "Target: p_data , OPJ_UINT32 p_total_data_size , OPJ_UINT32 p_manager ) ; if ( p_total_data_size < 12 ) { opj_event_msg ( p_manager , EVT_ERROR , \"NotenoughbytesinoutputbuffertowriteSOTmarker\\\\n\" ) ; return OPJ_FALSE ; }\n", "\n", "Sources:\n", "0: CWE-119 static OPJ_BOOL opj_j2k_write_sot ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , const opj_stream_private_t * p_stream , opj_event_mgr_t * p_manager ) { assert ( p_j2k != 00 ) ; assert ( p_manager != 00 ) ; assert ( p_stream != 00 ) ; OPJ_UNUSED ( p_stream ) ; OPJ_UNUSED ( p_manager ) ; opj_write_bytes ( p_data , J2K_MS_SOT , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , 10 , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , p_j2k -> m_current_tile_number , 2 ) ; p_data += 2 ; p_data += 4 ; opj_write_bytes ( p_data , p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number , 1 ) ; ++ p_data ; opj_write_bytes ( p_data , p_j2k -> m_cp . tcps [ p_j2k -> m_current_tile_number ] . m_nb_tile_parts , 1 ) ; ++ p_data ; # ifdef USE_JPWL assert ( 0 && \"TODO\" ) ; # endif * p_data_written = 12 ; return OPJ_TRUE ; }\n", "\n", "1: CWE-787 static OPJ_BOOL opj_j2k_write_sot ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , const opj_stream_private_t * p_stream , opj_event_mgr_t * p_manager ) { assert ( p_j2k != 00 ) ; assert ( p_manager != 00 ) ; assert ( p_stream != 00 ) ; OPJ_UNUSED ( p_stream ) ; OPJ_UNUSED ( p_manager ) ; opj_write_bytes ( p_data , J2K_MS_SOT , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , 10 , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , p_j2k -> m_current_tile_number , 2 ) ; p_data += 2 ; p_data += 4 ; opj_write_bytes ( p_data , p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number , 1 ) ; ++ p_data ; opj_write_bytes ( p_data , p_j2k -> m_cp . tcps [ p_j2k -> m_current_tile_number ] . m_nb_tile_parts , 1 ) ; ++ p_data ; # ifdef USE_JPWL assert ( 0 && \"TODO\" ) ; # endif * p_data_written = 12 ; return OPJ_TRUE ; }\n", "\n", "\n", "Target: buf + 2 , sizeof ( buf2 ) buf + 2 , sizeof ( buf2 )\n", "\n", "Sources:\n", "0: CWE-120 enum ImapAuthRes imap_auth_gss ( struct ImapData * idata , const char * method ) { gss_buffer_desc request_buf , send_token ; gss_buffer_t sec_token ; gss_name_t target_name ; gss_ctx_id_t context ; gss_OID mech_name ; char server_conf_flags ; gss_qop_t quality ; int cflags ; OM_uint32 maj_stat , min_stat ; char buf1 [ GSS_BUFSIZE ] , buf2 [ GSS_BUFSIZE ] ; unsigned long buf_size ; int rc ; if ( ! mutt_bit_isset ( idata -> capabilities , AGSSAPI ) ) return IMAP_AUTH_UNAVAIL ; if ( mutt_account_getuser ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; snprintf ( buf1 , sizeof ( buf1 ) , \"imap@%s\" , idata -> conn -> account . host ) ; request_buf . value = buf1 ; request_buf . length = strlen ( buf1 ) ; maj_stat = gss_import_name ( & min_stat , & request_buf , gss_nt_service_name , & target_name ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , \"Couldn\\'tgetservicenamefor[%s]\\\\n\" , buf1 ) ; return IMAP_AUTH_UNAVAIL ; } else if ( DebugLevel >= 2 ) { gss_display_name ( & min_stat , target_name , & request_buf , & mech_name ) ; mutt_debug ( 2 , \"Usingservicename[%s]\\\\n\" , ( char * ) request_buf . value ) ; gss_release_buffer ( & min_stat , & request_buf ) ; } sec_token = GSS_C_NO_BUFFER ; context = GSS_C_NO_CONTEXT ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , \"Erroracquiringcredentials-noTGT?\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; return IMAP_AUTH_UNAVAIL ; } mutt_message ( _ ( \"Authenticating(GSSAPI)...\" ) ) ; imap_cmd_start ( idata , \"AUTHENTICATEGSSAPI\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 2 , \"Invalidresponsefromserver:%s\\\\n\" , buf1 ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } mutt_debug ( 2 , \"Sendingcredentials\\\\n\" ) ; mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; while ( maj_stat == GSS_S_CONTINUE_NEEDED ) { do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"#1Errorreceivingserverresponse.\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; sec_token = & request_buf ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , \"Errorexchangingcredentials\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; } gss_release_name ( & min_stat , & target_name ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"#2Errorreceivingserverresponse.\\\\n\" ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; maj_stat = gss_unwrap ( & min_stat , context , & request_buf , & send_token , & cflags , & quality ) ; if ( maj_stat != GSS_S_COMPLETE ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 2 , \"Couldn\\'tunwrapsecurityleveldata\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } mutt_debug ( 2 , \"Credentialexchangecomplete\\\\n\" ) ; server_conf_flags = ( ( char * ) send_token . value ) [ 0 ] ; if ( ! ( ( ( char * ) send_token . value ) [ 0 ] & GSS_AUTH_P_NONE ) ) { mutt_debug ( 2 , \"Serverrequiresintegrityorprivacy\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } ( ( char * ) send_token . value ) [ 0 ] = '\\\\0' ; buf_size = ntohl ( * ( ( long * ) send_token . value ) ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_debug ( 2 , \"Unwrappedsecuritylevelflags:%c%c%c\\\\n\" , ( server_conf_flags & GSS_AUTH_P_NONE ) ? 'N' : '-' , ( server_conf_flags & GSS_AUTH_P_INTEGRITY ) ? 'I' : '-' , ( server_conf_flags & GSS_AUTH_P_PRIVACY ) ? 'P' : '-' ) ; mutt_debug ( 2 , \"MaximumGSStokensizeis%ld\\\\n\" , buf_size ) ; buf_size = htonl ( buf_size ) ; memcpy ( buf1 , & buf_size , 4 ) ; buf1 [ 0 ] = GSS_AUTH_P_NONE ; strncpy ( buf1 + 4 , idata -> conn -> account . user , sizeof ( buf1 ) - 4 ) ; request_buf . value = buf1 ; request_buf . length = 4 + strlen ( idata -> conn -> account . user ) ; maj_stat = gss_wrap ( & min_stat , context , 0 , GSS_C_QOP_DEFAULT , & request_buf , & cflags , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , \"Errorcreatingloginrequest\\\\n\" ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; mutt_debug ( 2 , \"Requestingauthorisationas%s\\\\n\" , idata -> conn -> account . user ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc == IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"Unexpectedservercontinuationrequest.\\\\n\" ) ; goto err_abort_cmd ; } if ( imap_code ( idata -> buf ) ) { mutt_debug ( 2 , \"ReleasingGSScredentials\\\\n\" ) ; maj_stat = gss_delete_sec_context ( & min_stat , & context , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) mutt_debug ( 1 , \"Errorreleasingcredentials\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; return IMAP_AUTH_SUCCESS ; } else goto bail ; err_abort_cmd : mutt_socket_send ( idata -> conn , \"*\\\\r\\\\n\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; bail : mutt_error ( _ ( \"GSSAPIauthenticationfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "1: CWE-119 enum ImapAuthRes imap_auth_gss ( struct ImapData * idata , const char * method ) { gss_buffer_desc request_buf , send_token ; gss_buffer_t sec_token ; gss_name_t target_name ; gss_ctx_id_t context ; gss_OID mech_name ; char server_conf_flags ; gss_qop_t quality ; int cflags ; OM_uint32 maj_stat , min_stat ; char buf1 [ GSS_BUFSIZE ] , buf2 [ GSS_BUFSIZE ] ; unsigned long buf_size ; int rc ; if ( ! mutt_bit_isset ( idata -> capabilities , AGSSAPI ) ) return IMAP_AUTH_UNAVAIL ; if ( mutt_account_getuser ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; snprintf ( buf1 , sizeof ( buf1 ) , \"imap@%s\" , idata -> conn -> account . host ) ; request_buf . value = buf1 ; request_buf . length = strlen ( buf1 ) ; maj_stat = gss_import_name ( & min_stat , & request_buf , gss_nt_service_name , & target_name ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , \"Couldn\\'tgetservicenamefor[%s]\\\\n\" , buf1 ) ; return IMAP_AUTH_UNAVAIL ; } else if ( DebugLevel >= 2 ) { gss_display_name ( & min_stat , target_name , & request_buf , & mech_name ) ; mutt_debug ( 2 , \"Usingservicename[%s]\\\\n\" , ( char * ) request_buf . value ) ; gss_release_buffer ( & min_stat , & request_buf ) ; } sec_token = GSS_C_NO_BUFFER ; context = GSS_C_NO_CONTEXT ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , \"Erroracquiringcredentials-noTGT?\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; return IMAP_AUTH_UNAVAIL ; } mutt_message ( _ ( \"Authenticating(GSSAPI)...\" ) ) ; imap_cmd_start ( idata , \"AUTHENTICATEGSSAPI\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 2 , \"Invalidresponsefromserver:%s\\\\n\" , buf1 ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } mutt_debug ( 2 , \"Sendingcredentials\\\\n\" ) ; mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; while ( maj_stat == GSS_S_CONTINUE_NEEDED ) { do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"#1Errorreceivingserverresponse.\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; sec_token = & request_buf ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , \"Errorexchangingcredentials\\\\n\" ) ; gss_release_name ( & min_stat , & target_name ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; } gss_release_name ( & min_stat , & target_name ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"#2Errorreceivingserverresponse.\\\\n\" ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; maj_stat = gss_unwrap ( & min_stat , context , & request_buf , & send_token , & cflags , & quality ) ; if ( maj_stat != GSS_S_COMPLETE ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 2 , \"Couldn\\'tunwrapsecurityleveldata\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } mutt_debug ( 2 , \"Credentialexchangecomplete\\\\n\" ) ; server_conf_flags = ( ( char * ) send_token . value ) [ 0 ] ; if ( ! ( ( ( char * ) send_token . value ) [ 0 ] & GSS_AUTH_P_NONE ) ) { mutt_debug ( 2 , \"Serverrequiresintegrityorprivacy\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } ( ( char * ) send_token . value ) [ 0 ] = '\\\\0' ; buf_size = ntohl ( * ( ( long * ) send_token . value ) ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_debug ( 2 , \"Unwrappedsecuritylevelflags:%c%c%c\\\\n\" , ( server_conf_flags & GSS_AUTH_P_NONE ) ? 'N' : '-' , ( server_conf_flags & GSS_AUTH_P_INTEGRITY ) ? 'I' : '-' , ( server_conf_flags & GSS_AUTH_P_PRIVACY ) ? 'P' : '-' ) ; mutt_debug ( 2 , \"MaximumGSStokensizeis%ld\\\\n\" , buf_size ) ; buf_size = htonl ( buf_size ) ; memcpy ( buf1 , & buf_size , 4 ) ; buf1 [ 0 ] = GSS_AUTH_P_NONE ; strncpy ( buf1 + 4 , idata -> conn -> account . user , sizeof ( buf1 ) - 4 ) ; request_buf . value = buf1 ; request_buf . length = 4 + strlen ( idata -> conn -> account . user ) ; maj_stat = gss_wrap ( & min_stat , context , 0 , GSS_C_QOP_DEFAULT , & request_buf , & cflags , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , \"Errorcreatingloginrequest\\\\n\" ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; mutt_debug ( 2 , \"Requestingauthorisationas%s\\\\n\" , idata -> conn -> account . user ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , \"\\\\r\\\\n\" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc == IMAP_CMD_RESPOND ) { mutt_debug ( 1 , \"Unexpectedservercontinuationrequest.\\\\n\" ) ; goto err_abort_cmd ; } if ( imap_code ( idata -> buf ) ) { mutt_debug ( 2 , \"ReleasingGSScredentials\\\\n\" ) ; maj_stat = gss_delete_sec_context ( & min_stat , & context , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) mutt_debug ( 1 , \"Errorreleasingcredentials\\\\n\" ) ; gss_release_buffer ( & min_stat , & send_token ) ; return IMAP_AUTH_SUCCESS ; } else goto bail ; err_abort_cmd : mutt_socket_send ( idata -> conn , \"*\\\\r\\\\n\" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; bail : mutt_error ( _ ( \"GSSAPIauthenticationfailed.\" ) ) ; return IMAP_AUTH_FAILURE ; }\n", "\n", "\n", "Target: ( ( data ^ PSW_USER_BITS ) ~ mask ) return - EINVAL ; if ( ( data & PSW_MASK_ASC ) == PSW_ASC_HOME ) return -\n", "\n", "Sources:\n", "0: CWE-269 static int __poke_user ( struct task_struct * child , addr_t addr , addr_t data ) { struct user * dummy = NULL ; addr_t offset ; if ( addr < ( addr_t ) & dummy -> regs . acrs ) { if ( addr == ( addr_t ) & dummy -> regs . psw . mask ) { unsigned long mask = PSW_MASK_USER ; mask |= is_ri_task ( child ) ? PSW_MASK_RI : 0 ; if ( ( data & ~ mask ) != PSW_USER_BITS ) return - EINVAL ; if ( ( data & PSW_MASK_EA ) && ! ( data & PSW_MASK_BA ) ) return - EINVAL ; } * ( addr_t * ) ( ( addr_t ) & task_pt_regs ( child ) -> psw + addr ) = data ; } else if ( addr < ( addr_t ) ( & dummy -> regs . orig_gpr2 ) ) { offset = addr - ( addr_t ) & dummy -> regs . acrs ; # ifdef CONFIG_64BIT if ( addr == ( addr_t ) & dummy -> regs . acrs [ 15 ] ) child -> thread . acrs [ 15 ] = ( unsigned int ) ( data >> 32 ) ; else # endif * ( addr_t * ) ( ( addr_t ) & child -> thread . acrs + offset ) = data ; } else if ( addr == ( addr_t ) & dummy -> regs . orig_gpr2 ) { task_pt_regs ( child ) -> orig_gpr2 = data ; } else if ( addr < ( addr_t ) & dummy -> regs . fp_regs ) { return 0 ; } else if ( addr < ( addr_t ) ( & dummy -> regs . fp_regs + 1 ) ) { if ( addr == ( addr_t ) & dummy -> regs . fp_regs . fpc ) if ( ( unsigned int ) data != 0 || test_fp_ctl ( data >> ( BITS_PER_LONG - 32 ) ) ) return - EINVAL ; offset = addr - ( addr_t ) & dummy -> regs . fp_regs ; * ( addr_t * ) ( ( addr_t ) & child -> thread . fp_regs + offset ) = data ; } else if ( addr < ( addr_t ) ( & dummy -> regs . per_info + 1 ) ) { addr -= ( addr_t ) & dummy -> regs . per_info ; __poke_user_per ( child , addr , data ) ; } return 0 ; }\n", "\n", "1: CWE-264 static int __poke_user ( struct task_struct * child , addr_t addr , addr_t data ) { struct user * dummy = NULL ; addr_t offset ; if ( addr < ( addr_t ) & dummy -> regs . acrs ) { if ( addr == ( addr_t ) & dummy -> regs . psw . mask ) { unsigned long mask = PSW_MASK_USER ; mask |= is_ri_task ( child ) ? PSW_MASK_RI : 0 ; if ( ( data & ~ mask ) != PSW_USER_BITS ) return - EINVAL ; if ( ( data & PSW_MASK_EA ) && ! ( data & PSW_MASK_BA ) ) return - EINVAL ; } * ( addr_t * ) ( ( addr_t ) & task_pt_regs ( child ) -> psw + addr ) = data ; } else if ( addr < ( addr_t ) ( & dummy -> regs . orig_gpr2 ) ) { offset = addr - ( addr_t ) & dummy -> regs . acrs ; # ifdef CONFIG_64BIT if ( addr == ( addr_t ) & dummy -> regs . acrs [ 15 ] ) child -> thread . acrs [ 15 ] = ( unsigned int ) ( data >> 32 ) ; else # endif * ( addr_t * ) ( ( addr_t ) & child -> thread . acrs + offset ) = data ; } else if ( addr == ( addr_t ) & dummy -> regs . orig_gpr2 ) { task_pt_regs ( child ) -> orig_gpr2 = data ; } else if ( addr < ( addr_t ) & dummy -> regs . fp_regs ) { return 0 ; } else if ( addr < ( addr_t ) ( & dummy -> regs . fp_regs + 1 ) ) { if ( addr == ( addr_t ) & dummy -> regs . fp_regs . fpc ) if ( ( unsigned int ) data != 0 || test_fp_ctl ( data >> ( BITS_PER_LONG - 32 ) ) ) return - EINVAL ; offset = addr - ( addr_t ) & dummy -> regs . fp_regs ; * ( addr_t * ) ( ( addr_t ) & child -> thread . fp_regs + offset ) = data ; } else if ( addr < ( addr_t ) ( & dummy -> regs . per_info + 1 ) ) { addr -= ( addr_t ) & dummy -> regs . per_info ; __poke_user_per ( child , addr , data ) ; } return 0 ; }\n", "\n", "\n", "Target: & O_ACCMODE ) != O_RDONLY || ( flags ( flags & ( O_CREAT | O_TRUNC ) ) != 0 ) ) {\n", "\n", "Sources:\n", "0: CWE-732 static void process_open ( u_int32_t id ) { u_int32_t pflags ; Attrib a ; char * name ; int r , handle , fd , flags , mode , status = SSH2_FX_FAILURE ; if ( ( r = sshbuf_get_cstring ( iqueue , & name , NULL ) ) != 0 || ( r = sshbuf_get_u32 ( iqueue , & pflags ) ) != 0 || ( r = decode_attrib ( iqueue , & a ) ) != 0 ) fatal ( \"%s:buffererror:%s\" , __func__ , ssh_err ( r ) ) ; debug3 ( \"request%u:openflags%d\" , id , pflags ) ; flags = flags_from_portable ( pflags ) ; mode = ( a . flags & SSH2_FILEXFER_ATTR_PERMISSIONS ) ? a . perm : 0666 ; logit ( \"open\\\\\"%s\\\\\"flags%smode0%o\" , name , string_from_portable ( pflags ) , mode ) ; if ( readonly && ( ( flags & O_ACCMODE ) == O_WRONLY || ( flags & O_ACCMODE ) == O_RDWR ) ) { verbose ( \"Refusingopenrequestinread-onlymode\" ) ; status = SSH2_FX_PERMISSION_DENIED ; } else { fd = open ( name , flags , mode ) ; if ( fd < 0 ) { status = errno_to_portable ( errno ) ; } else { handle = handle_new ( HANDLE_FILE , name , fd , flags , NULL ) ; if ( handle < 0 ) { close ( fd ) ; } else { send_handle ( id , handle ) ; status = SSH2_FX_OK ; } } } if ( status != SSH2_FX_OK ) send_status ( id , status ) ; free ( name ) ; }\n", "\n", "1: CWE-269 static void process_open ( u_int32_t id ) { u_int32_t pflags ; Attrib a ; char * name ; int r , handle , fd , flags , mode , status = SSH2_FX_FAILURE ; if ( ( r = sshbuf_get_cstring ( iqueue , & name , NULL ) ) != 0 || ( r = sshbuf_get_u32 ( iqueue , & pflags ) ) != 0 || ( r = decode_attrib ( iqueue , & a ) ) != 0 ) fatal ( \"%s:buffererror:%s\" , __func__ , ssh_err ( r ) ) ; debug3 ( \"request%u:openflags%d\" , id , pflags ) ; flags = flags_from_portable ( pflags ) ; mode = ( a . flags & SSH2_FILEXFER_ATTR_PERMISSIONS ) ? a . perm : 0666 ; logit ( \"open\\\\\"%s\\\\\"flags%smode0%o\" , name , string_from_portable ( pflags ) , mode ) ; if ( readonly && ( ( flags & O_ACCMODE ) == O_WRONLY || ( flags & O_ACCMODE ) == O_RDWR ) ) { verbose ( \"Refusingopenrequestinread-onlymode\" ) ; status = SSH2_FX_PERMISSION_DENIED ; } else { fd = open ( name , flags , mode ) ; if ( fd < 0 ) { status = errno_to_portable ( errno ) ; } else { handle = handle_new ( HANDLE_FILE , name , fd , flags , NULL ) ; if ( handle < 0 ) { close ( fd ) ; } else { send_handle ( id , handle ) ; status = SSH2_FX_OK ; } } } if ( status != SSH2_FX_OK ) send_status ( id , status ) ; free ( name ) ; }\n", "\n", "\n", "Target: break ; } strncat ( line , buf , sizeof line ) ; strncat ( line , line , \"\" , sizeof line } line [ ( sizeof line ) - 1 ] = '\\\\0' ; line [ strlen ( line ) - 1 ] =\n", "\n", "Sources:\n", "0: CWE-119 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 : return \"NONE\" ; case SC_AC_CHV : strcpy ( buf , \"CHV\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"%d\" , e -> key_ref ) ; break ; case SC_AC_TERM : strcpy ( buf , \"TERM\" ) ; break ; case SC_AC_PRO : strcpy ( buf , \"PROT\" ) ; break ; case SC_AC_AUT : strcpy ( buf , \"AUTH\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 4 , \"%d\" , e -> key_ref ) ; break ; case SC_AC_SEN : strcpy ( buf , \"Sec.Env.\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"#%d\" , e -> key_ref ) ; break ; case SC_AC_SCB : strcpy ( buf , \"Sec.ControlByte\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"Ox%X\" , e -> key_ref ) ; break ; case SC_AC_IDA : strcpy ( buf , \"PKCS#15AuthID\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"#%d\" , e -> key_ref ) ; break ; default : strcpy ( buf , \"????\" ) ; break ; } strcat ( line , buf ) ; strcat ( line , \"\" ) ; e = e -> next ; } line [ strlen ( line ) - 1 ] = 0 ; return line ; }\n", "\n", "1: 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 : return \"NONE\" ; case SC_AC_CHV : strcpy ( buf , \"CHV\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"%d\" , e -> key_ref ) ; break ; case SC_AC_TERM : strcpy ( buf , \"TERM\" ) ; break ; case SC_AC_PRO : strcpy ( buf , \"PROT\" ) ; break ; case SC_AC_AUT : strcpy ( buf , \"AUTH\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 4 , \"%d\" , e -> key_ref ) ; break ; case SC_AC_SEN : strcpy ( buf , \"Sec.Env.\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"#%d\" , e -> key_ref ) ; break ; case SC_AC_SCB : strcpy ( buf , \"Sec.ControlByte\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"Ox%X\" , e -> key_ref ) ; break ; case SC_AC_IDA : strcpy ( buf , \"PKCS#15AuthID\" ) ; if ( e -> key_ref != SC_AC_KEY_REF_NONE ) sprintf ( buf + 3 , \"#%d\" , e -> key_ref ) ; break ; default : strcpy ( buf , \"????\" ) ; break ; } strcat ( line , buf ) ; strcat ( line , \"\" ) ; e = e -> next ; } line [ strlen ( line ) - 1 ] = 0 ; return line ; }\n", "\n", "\n", "Target: char combname [ L_BUFSIZE ] ; l_int32 ( combname , L_BUFSIZE , \"sel_comb_%dh\" , ( combname , L_BUFSIZE , \"sel_comb_%dv\" ,\n", "\n", "Sources:\n", "0: CWE-119 char * selaGetCombName ( SELA * sela , l_int32 size , l_int32 direction ) { char * selname ; char combname [ L_BUF_SIZE ] ; l_int32 i , nsels , sx , sy , found ; SEL * sel ; PROCNAME ( \"selaGetCombName\" ) ; if ( ! sela ) return ( char * ) ERROR_PTR ( \"selanotdefined\" , procName , NULL ) ; if ( direction != L_HORIZ && direction != L_VERT ) return ( char * ) ERROR_PTR ( \"invaliddirection\" , procName , NULL ) ; if ( direction == L_HORIZ ) snprintf ( combname , L_BUF_SIZE , \"sel_comb_%dh\" , size ) ; else snprintf ( combname , L_BUF_SIZE , \"sel_comb_%dv\" , size ) ; found = FALSE ; nsels = selaGetCount ( sela ) ; for ( i = 0 ; i < nsels ; i ++ ) { sel = selaGetSel ( sela , i ) ; selGetParameters ( sel , & sy , & sx , NULL , NULL ) ; if ( sy != 1 && sx != 1 ) continue ; selname = selGetName ( sel ) ; if ( ! strcmp ( selname , combname ) ) { found = TRUE ; break ; } } if ( found ) return stringNew ( selname ) ; else return ( char * ) ERROR_PTR ( \"selnotfound\" , procName , NULL ) ; }\n", "\n", "1: CWE-787 char * selaGetCombName ( SELA * sela , l_int32 size , l_int32 direction ) { char * selname ; char combname [ L_BUF_SIZE ] ; l_int32 i , nsels , sx , sy , found ; SEL * sel ; PROCNAME ( \"selaGetCombName\" ) ; if ( ! sela ) return ( char * ) ERROR_PTR ( \"selanotdefined\" , procName , NULL ) ; if ( direction != L_HORIZ && direction != L_VERT ) return ( char * ) ERROR_PTR ( \"invaliddirection\" , procName , NULL ) ; if ( direction == L_HORIZ ) snprintf ( combname , L_BUF_SIZE , \"sel_comb_%dh\" , size ) ; else snprintf ( combname , L_BUF_SIZE , \"sel_comb_%dv\" , size ) ; found = FALSE ; nsels = selaGetCount ( sela ) ; for ( i = 0 ; i < nsels ; i ++ ) { sel = selaGetSel ( sela , i ) ; selGetParameters ( sel , & sy , & sx , NULL , NULL ) ; if ( sy != 1 && sx != 1 ) continue ; selname = selGetName ( sel ) ; if ( ! strcmp ( selname , combname ) ) { found = TRUE ; break ; } } if ( found ) return stringNew ( selname ) ; else return ( char * ) ERROR_PTR ( \"selnotfound\" , procName , NULL ) ; }\n", "\n", "\n", "Target: ( sb , KERN_ERR ,\n", "\n", "Sources:\n", "0: CWE-20 static ext3_fsblk_t get_sb_block ( void * * data , struct super_block * sb ) { ext3_fsblk_t sb_block ; char * options = ( char * ) * data ; if ( ! options || strncmp ( options , \"sb=\" , 3 ) != 0 ) return 1 ; options += 3 ; sb_block = simple_strtoul ( options , & options , 0 ) ; if ( * options && * options != ',' ) { ext3_msg ( sb , \"error:invalidsbspecification:%s\" , ( char * ) * data ) ; return 1 ; } if ( * options == ',' ) options ++ ; * data = ( void * ) options ; return sb_block ; }\n", "\n", "1: CWE-20 static struct block_device * ext3_blkdev_get ( dev_t dev , struct super_block * sb ) { struct block_device * bdev ; char b [ BDEVNAME_SIZE ] ; bdev = blkdev_get_by_dev ( dev , FMODE_READ | FMODE_WRITE | FMODE_EXCL , sb ) ; if ( IS_ERR ( bdev ) ) goto fail ; return bdev ; fail : ext3_msg ( sb , \"error:failedtoopenjournaldevice%s:%ld\" , __bdevname ( dev , b ) , PTR_ERR ( bdev ) ) ; return NULL ; }\n", "\n", "\n", "Target: ! esil ) { return ; } r_anal_esil_to_reil_setup ( esil\n", "\n", "Sources:\n", "0: CWE-908 static void cmd_anal_esil ( RCore * core , const char * input ) { RAnalEsil * esil = core -> anal -> esil ; ut64 addr = core -> offset ; ut64 adr ; char * n , * n1 ; int off ; int stacksize = r_config_get_i ( core -> config , \"esil.stack.depth\" ) ; int iotrap = r_config_get_i ( core -> config , \"esil.iotrap\" ) ; int romem = r_config_get_i ( core -> config , \"esil.romem\" ) ; int stats = r_config_get_i ( core -> config , \"esil.stats\" ) ; int noNULL = r_config_get_i ( core -> config , \"esil.noNULL\" ) ; ut64 until_addr = UT64_MAX ; unsigned int addrsize = r_config_get_i ( core -> config , \"esil.addr.size\" ) ; const char * until_expr = NULL ; RAnalOp * op ; switch ( input [ 0 ] ) { case 'p' : switch ( input [ 1 ] ) { case 'c' : if ( input [ 2 ] == '' ) { r_core_cmdf ( core , \"arPC=%s\" , input + 3 ) ; r_core_cmd0 ( core , \".ar*\" ) ; } else { eprintf ( \"Missingargument\\\\n\" ) ; } break ; case 0 : r_anal_pin_list ( core -> anal ) ; break ; case '-' : if ( input [ 2 ] ) addr = r_num_math ( core -> num , input + 2 ) ; r_anal_pin_unset ( core -> anal , addr ) ; break ; case '' : r_anal_pin ( core -> anal , addr , input + 2 ) ; break ; default : r_core_cmd_help ( core , help_msg_aep ) ; break ; } break ; case 'r' : cmd_anal_reg ( core , input + 1 ) ; break ; case '*' : if ( core -> anal -> esil ) { r_cons_printf ( \"trap:%d\\\\n\" , core -> anal -> esil -> trap ) ; r_cons_printf ( \"trap-code:%d\\\\n\" , core -> anal -> esil -> trap_code ) ; } else { eprintf ( \"esilvmnotinitialized.run`aei`\\\\n\" ) ; } break ; case '' : if ( ! esil ) { if ( ! ( core -> anal -> esil = esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ) ) return ; } r_anal_esil_setup ( esil , core -> anal , romem , stats , noNULL ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; r_anal_esil_parse ( esil , input + 1 ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; break ; case 's' : switch ( input [ 1 ] ) { case '?' : eprintf ( \"See:ae?~aes\\\\n\" ) ; break ; case 'l' : { ut64 pc = r_debug_reg_get ( core -> dbg , \"PC\" ) ; RAnalOp * op = r_core_anal_op ( core , pc ) ; if ( ! op ) { break ; } r_core_esil_step ( core , UT64_MAX , NULL , NULL ) ; r_debug_reg_set ( core -> dbg , \"PC\" , pc + op -> size ) ; r_anal_esil_set_pc ( esil , pc + op -> size ) ; r_core_cmd0 ( core , \".ar*\" ) ; } break ; case 'b' : if ( ! r_core_esil_step_back ( core ) ) { eprintf ( \"cannnotstepback\\\\n\" ) ; } r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'u' : if ( input [ 2 ] == 'e' ) { until_expr = input + 3 ; } else { until_addr = r_num_math ( core -> num , input + 2 ) ; } r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'o' : op = r_core_anal_op ( core , r_reg_getv ( core -> anal -> reg , r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ) ) ; if ( op && op -> type == R_ANAL_OP_TYPE_CALL ) { until_addr = op -> addr + op -> size ; } r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_anal_op_free ( op ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'p' : n = strchr ( input , '' ) ; n1 = n ? strchr ( n + 1 , '' ) : NULL ; if ( ( ! n || ! n1 ) || ( ! ( n + 1 ) || ! ( n1 + 1 ) ) ) { eprintf ( \"aesp[offset][num]\\\\n\" ) ; break ; } adr = r_num_math ( core -> num , n + 1 ) ; off = r_num_math ( core -> num , n1 + 1 ) ; cmd_aespc ( core , adr , off ) ; break ; case '' : n = strchr ( input , '' ) ; if ( ! ( n + 1 ) ) { r_core_esil_step ( core , until_addr , until_expr , NULL ) ; break ; } off = r_num_math ( core -> num , n + 1 ) ; cmd_aespc ( core , - 1 , off ) ; break ; default : r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; } break ; case 'c' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aec ) ; } else if ( input [ 1 ] == 's' ) { const char * pc = r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ; ut64 newaddr ; int ret ; for ( ; ; ) { op = r_core_anal_op ( core , addr ) ; if ( ! op ) { break ; } if ( op -> type == R_ANAL_OP_TYPE_SWI ) { eprintf ( \"syscallat0x%08\" PFMT64x \"\\\\n\" , addr ) ; break ; } if ( op -> type == R_ANAL_OP_TYPE_TRAP ) { eprintf ( \"trapat0x%08\" PFMT64x \"\\\\n\" , addr ) ; break ; } ret = r_core_esil_step ( core , UT64_MAX , NULL , NULL ) ; r_anal_op_free ( op ) ; op = NULL ; if ( core -> anal -> esil -> trap || core -> anal -> esil -> trap_code ) { break ; } if ( ! ret ) break ; r_core_cmd0 ( core , \".ar*\" ) ; newaddr = r_num_get ( core -> num , pc ) ; if ( addr == newaddr ) { addr ++ ; break ; } else { addr = newaddr ; } } if ( op ) { r_anal_op_free ( op ) ; } } else { if ( input [ 1 ] == 'u' && input [ 2 ] == 'e' ) until_expr = input + 3 ; else if ( input [ 1 ] == 'u' ) until_addr = r_num_math ( core -> num , input + 2 ) ; else until_expr = \"0\" ; r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; } break ; case 'i' : switch ( input [ 1 ] ) { case 's' : case 'm' : cmd_esil_mem ( core , input + 2 ) ; break ; case 'p' : r_core_cmd0 ( core , \"arPC=$$\" ) ; break ; case '?' : cmd_esil_mem ( core , \"?\" ) ; break ; case '-' : if ( esil ) { sdb_reset ( esil -> stats ) ; } r_anal_esil_free ( esil ) ; core -> anal -> esil = NULL ; break ; case 0 : r_anal_esil_free ( esil ) ; { const char * pc = r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ; if ( r_reg_getv ( core -> anal -> reg , pc ) == 0LL ) { r_core_cmd0 ( core , \"arPC=$$\" ) ; } } if ( ! ( esil = core -> anal -> esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ) ) { return ; } r_anal_esil_setup ( esil , core -> anal , romem , stats , noNULL ) ; esil -> verbose = ( int ) r_config_get_i ( core -> config , \"esil.verbose\" ) ; { const char * s = r_config_get ( core -> config , \"cmd.esil.intr\" ) ; if ( s ) { char * my = strdup ( s ) ; if ( my ) { r_config_set ( core -> config , \"cmd.esil.intr\" , my ) ; free ( my ) ; } } } break ; } break ; case 'k' : switch ( input [ 1 ] ) { case '\\\\0' : input = \"123*\" ; case '' : if ( esil && esil -> stats ) { char * out = sdb_querys ( esil -> stats , NULL , 0 , input + 2 ) ; if ( out ) { r_cons_println ( out ) ; free ( out ) ; } } else { eprintf ( \"esil.statsisempty.Run\\'aei\\'\\\\n\" ) ; } break ; case '-' : if ( esil ) { sdb_reset ( esil -> stats ) ; } break ; } break ; case 'f' : { RListIter * iter ; RAnalBlock * bb ; RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM ) ; if ( fcn ) { r_list_foreach ( fcn -> bbs , iter , bb ) { ut64 pc = bb -> addr ; ut64 end = bb -> addr + bb -> size ; RAnalOp op ; ut8 * buf ; int ret , bbs = end - pc ; if ( bbs < 1 || bbs > 0xfffff ) { eprintf ( \"Invalidblocksize\\\\n\" ) ; } buf = calloc ( 1 , bbs + 1 ) ; r_io_read_at ( core -> io , pc , buf , bbs ) ; int left ; while ( pc < end ) { left = R_MIN ( end - pc , 32 ) ; r_asm_set_pc ( core -> assembler , pc ) ; ret = r_anal_op ( core -> anal , & op , addr , buf , left , R_ANAL_OP_MASK_ALL ) ; if ( ret ) { r_reg_set_value_by_role ( core -> anal -> reg , R_REG_NAME_PC , pc ) ; r_anal_esil_parse ( esil , R_STRBUF_SAFEGET ( & op . esil ) ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; pc += op . size ; } else { pc += 4 ; } } } } else { eprintf ( \"Cannotfindfunctionat0x%08\" PFMT64x \"\\\\n\" , core -> offset ) ; } } break ; case 't' : switch ( input [ 1 ] ) { case 'r' : { RAnalEsil * esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ; if ( ! esil ) return ; r_anal_esil_to_reil_setup ( esil , core -> anal , romem , stats ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; r_anal_esil_parse ( esil , input + 2 ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_free ( esil ) ; break ; } case 's' : switch ( input [ 2 ] ) { case 0 : r_anal_esil_session_list ( esil ) ; break ; case '+' : r_anal_esil_session_add ( esil ) ; break ; default : r_core_cmd_help ( core , help_msg_aets ) ; break ; } break ; default : eprintf ( \"Unknowncommand.Use`aetr`.\\\\n\" ) ; break ; } break ; case 'A' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ; } else if ( input [ 1 ] == 'r' ) { cmd_aea ( core , 1 + ( 1 << 1 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'w' ) { cmd_aea ( core , 1 + ( 1 << 2 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'n' ) { cmd_aea ( core , 1 + ( 1 << 3 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'j' ) { cmd_aea ( core , 1 + ( 1 << 4 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == '*' ) { cmd_aea ( core , 1 + ( 1 << 5 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'f' ) { RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , - 1 ) ; if ( fcn ) { cmd_aea ( core , 1 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; } } else { cmd_aea ( core , 1 , core -> offset , ( int ) r_num_math ( core -> num , input + 2 ) ) ; } break ; case 'a' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ; } else if ( input [ 1 ] == 'r' ) { cmd_aea ( core , 1 << 1 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'w' ) { cmd_aea ( core , 1 << 2 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'n' ) { cmd_aea ( core , 1 << 3 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'j' ) { cmd_aea ( core , 1 << 4 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == '*' ) { cmd_aea ( core , 1 << 5 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'f' ) { RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , - 1 ) ; if ( fcn ) { switch ( input [ 2 ] ) { case 'j' : cmd_aea ( core , 1 << 4 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; break ; default : cmd_aea ( core , 1 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; break ; } break ; } } else { const char * arg = input [ 1 ] ? input + 2 : \"\" ; ut64 len = r_num_math ( core -> num , arg ) ; cmd_aea ( core , 0 , core -> offset , len ) ; } break ; case 'x' : { char * hex ; int ret , bufsz ; input = r_str_trim_ro ( input + 1 ) ; hex = strdup ( input ) ; if ( ! hex ) { break ; } RAnalOp aop = R_EMPTY ; bufsz = r_hex_str2bin ( hex , ( ut8 * ) hex ) ; ret = r_anal_op ( core -> anal , & aop , core -> offset , ( const ut8 * ) hex , bufsz , R_ANAL_OP_MASK_ALL ) ; if ( ret > 0 ) { const char * str = R_STRBUF_SAFEGET ( & aop . esil ) ; char * str2 = r_str_newf ( \"%s\" , str ) ; cmd_anal_esil ( core , str2 ) ; free ( str2 ) ; } r_anal_op_fini ( & aop ) ; break ; } case '?' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_detail_ae ) ; break ; } default : r_core_cmd_help ( core , help_msg_ae ) ; break ; } }\n", "\n", "1: CWE-416 static void cmd_anal_esil ( RCore * core , const char * input ) { RAnalEsil * esil = core -> anal -> esil ; ut64 addr = core -> offset ; ut64 adr ; char * n , * n1 ; int off ; int stacksize = r_config_get_i ( core -> config , \"esil.stack.depth\" ) ; int iotrap = r_config_get_i ( core -> config , \"esil.iotrap\" ) ; int romem = r_config_get_i ( core -> config , \"esil.romem\" ) ; int stats = r_config_get_i ( core -> config , \"esil.stats\" ) ; int noNULL = r_config_get_i ( core -> config , \"esil.noNULL\" ) ; ut64 until_addr = UT64_MAX ; unsigned int addrsize = r_config_get_i ( core -> config , \"esil.addr.size\" ) ; const char * until_expr = NULL ; RAnalOp * op ; switch ( input [ 0 ] ) { case 'p' : switch ( input [ 1 ] ) { case 'c' : if ( input [ 2 ] == '' ) { r_core_cmdf ( core , \"arPC=%s\" , input + 3 ) ; r_core_cmd0 ( core , \".ar*\" ) ; } else { eprintf ( \"Missingargument\\\\n\" ) ; } break ; case 0 : r_anal_pin_list ( core -> anal ) ; break ; case '-' : if ( input [ 2 ] ) addr = r_num_math ( core -> num , input + 2 ) ; r_anal_pin_unset ( core -> anal , addr ) ; break ; case '' : r_anal_pin ( core -> anal , addr , input + 2 ) ; break ; default : r_core_cmd_help ( core , help_msg_aep ) ; break ; } break ; case 'r' : cmd_anal_reg ( core , input + 1 ) ; break ; case '*' : if ( core -> anal -> esil ) { r_cons_printf ( \"trap:%d\\\\n\" , core -> anal -> esil -> trap ) ; r_cons_printf ( \"trap-code:%d\\\\n\" , core -> anal -> esil -> trap_code ) ; } else { eprintf ( \"esilvmnotinitialized.run`aei`\\\\n\" ) ; } break ; case '' : if ( ! esil ) { if ( ! ( core -> anal -> esil = esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ) ) return ; } r_anal_esil_setup ( esil , core -> anal , romem , stats , noNULL ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; r_anal_esil_parse ( esil , input + 1 ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; break ; case 's' : switch ( input [ 1 ] ) { case '?' : eprintf ( \"See:ae?~aes\\\\n\" ) ; break ; case 'l' : { ut64 pc = r_debug_reg_get ( core -> dbg , \"PC\" ) ; RAnalOp * op = r_core_anal_op ( core , pc ) ; if ( ! op ) { break ; } r_core_esil_step ( core , UT64_MAX , NULL , NULL ) ; r_debug_reg_set ( core -> dbg , \"PC\" , pc + op -> size ) ; r_anal_esil_set_pc ( esil , pc + op -> size ) ; r_core_cmd0 ( core , \".ar*\" ) ; } break ; case 'b' : if ( ! r_core_esil_step_back ( core ) ) { eprintf ( \"cannnotstepback\\\\n\" ) ; } r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'u' : if ( input [ 2 ] == 'e' ) { until_expr = input + 3 ; } else { until_addr = r_num_math ( core -> num , input + 2 ) ; } r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'o' : op = r_core_anal_op ( core , r_reg_getv ( core -> anal -> reg , r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ) ) ; if ( op && op -> type == R_ANAL_OP_TYPE_CALL ) { until_addr = op -> addr + op -> size ; } r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_anal_op_free ( op ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; case 'p' : n = strchr ( input , '' ) ; n1 = n ? strchr ( n + 1 , '' ) : NULL ; if ( ( ! n || ! n1 ) || ( ! ( n + 1 ) || ! ( n1 + 1 ) ) ) { eprintf ( \"aesp[offset][num]\\\\n\" ) ; break ; } adr = r_num_math ( core -> num , n + 1 ) ; off = r_num_math ( core -> num , n1 + 1 ) ; cmd_aespc ( core , adr , off ) ; break ; case '' : n = strchr ( input , '' ) ; if ( ! ( n + 1 ) ) { r_core_esil_step ( core , until_addr , until_expr , NULL ) ; break ; } off = r_num_math ( core -> num , n + 1 ) ; cmd_aespc ( core , - 1 , off ) ; break ; default : r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; break ; } break ; case 'c' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aec ) ; } else if ( input [ 1 ] == 's' ) { const char * pc = r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ; ut64 newaddr ; int ret ; for ( ; ; ) { op = r_core_anal_op ( core , addr ) ; if ( ! op ) { break ; } if ( op -> type == R_ANAL_OP_TYPE_SWI ) { eprintf ( \"syscallat0x%08\" PFMT64x \"\\\\n\" , addr ) ; break ; } if ( op -> type == R_ANAL_OP_TYPE_TRAP ) { eprintf ( \"trapat0x%08\" PFMT64x \"\\\\n\" , addr ) ; break ; } ret = r_core_esil_step ( core , UT64_MAX , NULL , NULL ) ; r_anal_op_free ( op ) ; op = NULL ; if ( core -> anal -> esil -> trap || core -> anal -> esil -> trap_code ) { break ; } if ( ! ret ) break ; r_core_cmd0 ( core , \".ar*\" ) ; newaddr = r_num_get ( core -> num , pc ) ; if ( addr == newaddr ) { addr ++ ; break ; } else { addr = newaddr ; } } if ( op ) { r_anal_op_free ( op ) ; } } else { if ( input [ 1 ] == 'u' && input [ 2 ] == 'e' ) until_expr = input + 3 ; else if ( input [ 1 ] == 'u' ) until_addr = r_num_math ( core -> num , input + 2 ) ; else until_expr = \"0\" ; r_core_esil_step ( core , until_addr , until_expr , NULL ) ; r_core_cmd0 ( core , \".ar*\" ) ; } break ; case 'i' : switch ( input [ 1 ] ) { case 's' : case 'm' : cmd_esil_mem ( core , input + 2 ) ; break ; case 'p' : r_core_cmd0 ( core , \"arPC=$$\" ) ; break ; case '?' : cmd_esil_mem ( core , \"?\" ) ; break ; case '-' : if ( esil ) { sdb_reset ( esil -> stats ) ; } r_anal_esil_free ( esil ) ; core -> anal -> esil = NULL ; break ; case 0 : r_anal_esil_free ( esil ) ; { const char * pc = r_reg_get_name ( core -> anal -> reg , R_REG_NAME_PC ) ; if ( r_reg_getv ( core -> anal -> reg , pc ) == 0LL ) { r_core_cmd0 ( core , \"arPC=$$\" ) ; } } if ( ! ( esil = core -> anal -> esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ) ) { return ; } r_anal_esil_setup ( esil , core -> anal , romem , stats , noNULL ) ; esil -> verbose = ( int ) r_config_get_i ( core -> config , \"esil.verbose\" ) ; { const char * s = r_config_get ( core -> config , \"cmd.esil.intr\" ) ; if ( s ) { char * my = strdup ( s ) ; if ( my ) { r_config_set ( core -> config , \"cmd.esil.intr\" , my ) ; free ( my ) ; } } } break ; } break ; case 'k' : switch ( input [ 1 ] ) { case '\\\\0' : input = \"123*\" ; case '' : if ( esil && esil -> stats ) { char * out = sdb_querys ( esil -> stats , NULL , 0 , input + 2 ) ; if ( out ) { r_cons_println ( out ) ; free ( out ) ; } } else { eprintf ( \"esil.statsisempty.Run\\'aei\\'\\\\n\" ) ; } break ; case '-' : if ( esil ) { sdb_reset ( esil -> stats ) ; } break ; } break ; case 'f' : { RListIter * iter ; RAnalBlock * bb ; RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM ) ; if ( fcn ) { r_list_foreach ( fcn -> bbs , iter , bb ) { ut64 pc = bb -> addr ; ut64 end = bb -> addr + bb -> size ; RAnalOp op ; ut8 * buf ; int ret , bbs = end - pc ; if ( bbs < 1 || bbs > 0xfffff ) { eprintf ( \"Invalidblocksize\\\\n\" ) ; } buf = calloc ( 1 , bbs + 1 ) ; r_io_read_at ( core -> io , pc , buf , bbs ) ; int left ; while ( pc < end ) { left = R_MIN ( end - pc , 32 ) ; r_asm_set_pc ( core -> assembler , pc ) ; ret = r_anal_op ( core -> anal , & op , addr , buf , left , R_ANAL_OP_MASK_ALL ) ; if ( ret ) { r_reg_set_value_by_role ( core -> anal -> reg , R_REG_NAME_PC , pc ) ; r_anal_esil_parse ( esil , R_STRBUF_SAFEGET ( & op . esil ) ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; pc += op . size ; } else { pc += 4 ; } } } } else { eprintf ( \"Cannotfindfunctionat0x%08\" PFMT64x \"\\\\n\" , core -> offset ) ; } } break ; case 't' : switch ( input [ 1 ] ) { case 'r' : { RAnalEsil * esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ; if ( ! esil ) return ; r_anal_esil_to_reil_setup ( esil , core -> anal , romem , stats ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; r_anal_esil_parse ( esil , input + 2 ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_free ( esil ) ; break ; } case 's' : switch ( input [ 2 ] ) { case 0 : r_anal_esil_session_list ( esil ) ; break ; case '+' : r_anal_esil_session_add ( esil ) ; break ; default : r_core_cmd_help ( core , help_msg_aets ) ; break ; } break ; default : eprintf ( \"Unknowncommand.Use`aetr`.\\\\n\" ) ; break ; } break ; case 'A' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ; } else if ( input [ 1 ] == 'r' ) { cmd_aea ( core , 1 + ( 1 << 1 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'w' ) { cmd_aea ( core , 1 + ( 1 << 2 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'n' ) { cmd_aea ( core , 1 + ( 1 << 3 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'j' ) { cmd_aea ( core , 1 + ( 1 << 4 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == '*' ) { cmd_aea ( core , 1 + ( 1 << 5 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'f' ) { RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , - 1 ) ; if ( fcn ) { cmd_aea ( core , 1 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; } } else { cmd_aea ( core , 1 , core -> offset , ( int ) r_num_math ( core -> num , input + 2 ) ) ; } break ; case 'a' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ; } else if ( input [ 1 ] == 'r' ) { cmd_aea ( core , 1 << 1 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'w' ) { cmd_aea ( core , 1 << 2 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'n' ) { cmd_aea ( core , 1 << 3 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'j' ) { cmd_aea ( core , 1 << 4 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == '*' ) { cmd_aea ( core , 1 << 5 , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'f' ) { RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , - 1 ) ; if ( fcn ) { switch ( input [ 2 ] ) { case 'j' : cmd_aea ( core , 1 << 4 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; break ; default : cmd_aea ( core , 1 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; break ; } break ; } } else { const char * arg = input [ 1 ] ? input + 2 : \"\" ; ut64 len = r_num_math ( core -> num , arg ) ; cmd_aea ( core , 0 , core -> offset , len ) ; } break ; case 'x' : { char * hex ; int ret , bufsz ; input = r_str_trim_ro ( input + 1 ) ; hex = strdup ( input ) ; if ( ! hex ) { break ; } RAnalOp aop = R_EMPTY ; bufsz = r_hex_str2bin ( hex , ( ut8 * ) hex ) ; ret = r_anal_op ( core -> anal , & aop , core -> offset , ( const ut8 * ) hex , bufsz , R_ANAL_OP_MASK_ALL ) ; if ( ret > 0 ) { const char * str = R_STRBUF_SAFEGET ( & aop . esil ) ; char * str2 = r_str_newf ( \"%s\" , str ) ; cmd_anal_esil ( core , str2 ) ; free ( str2 ) ; } r_anal_op_fini ( & aop ) ; break ; } case '?' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_detail_ae ) ; break ; } default : r_core_cmd_help ( core , help_msg_ae ) ; break ; } }\n", "\n", "\n", "Target: asoc ; struct sock * sk = asoc -> base . sk ; struct = sock_net ( sk ) ; ; bh_lock_sock ( sk ) ; ( sock_owned_by_user ( sk ) ) ( error ) sk -> sk_err : bh_unlock_sock ( sk ) ;\n", "\n", "Sources:\n", "0: CWE-362 void sctp_generate_t3_rtx_event ( unsigned long peer ) { int error ; struct sctp_transport * transport = ( struct sctp_transport * ) peer ; struct sctp_association * asoc = transport -> asoc ; struct net * net = sock_net ( asoc -> base . sk ) ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( \"%s:sockisbusy\\\\n\" , __func__ ) ; if ( ! mod_timer ( & transport -> T3_rtx_timer , jiffies + ( HZ / 20 ) ) ) sctp_transport_hold ( transport ) ; goto out_unlock ; } if ( transport -> dead ) goto out_unlock ; error = sctp_do_sm ( net , SCTP_EVENT_T_TIMEOUT , SCTP_ST_TIMEOUT ( SCTP_EVENT_TIMEOUT_T3_RTX ) , asoc -> state , asoc -> ep , asoc , transport , GFP_ATOMIC ) ; if ( error ) asoc -> base . sk -> sk_err = - error ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_transport_put ( transport ) ; }\n", "\n", "1: CWE-362 void sctp_generate_heartbeat_event ( unsigned long data ) { int error = 0 ; struct sctp_transport * transport = ( struct sctp_transport * ) data ; struct sctp_association * asoc = transport -> asoc ; struct net * net = sock_net ( asoc -> base . sk ) ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( \"%s:sockisbusy\\\\n\" , __func__ ) ; if ( ! mod_timer ( & transport -> hb_timer , jiffies + ( HZ / 20 ) ) ) sctp_transport_hold ( transport ) ; goto out_unlock ; } if ( transport -> dead ) goto out_unlock ; error = sctp_do_sm ( net , SCTP_EVENT_T_TIMEOUT , SCTP_ST_TIMEOUT ( SCTP_EVENT_TIMEOUT_HEARTBEAT ) , asoc -> state , asoc -> ep , asoc , transport , GFP_ATOMIC ) ; if ( error ) asoc -> base . sk -> sk_err = - error ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_transport_put ( transport ) ; }\n", "\n", "\n", "Target: unsigned char * last_row , * one_row \"MemoryAllocationFailed\" ) ; last_row = ( unsigned PALM_COMPRESSION_SCANLINE ) { last_row = ( unsigned sizeof ( * last_row ) ) ; if ( last_row == ( unsigned bit ] = last_row [ i + ) CopyMagickMemory ( last_row , one_row , == PALM_COMPRESSION_SCANLINE ) last_row = ( unsigned ) RelinquishMagickMemory ( last_row ) ; ThrowReaderException == PALM_COMPRESSION_SCANLINE ) last_row = ( unsigned ) RelinquishMagickMemory ( last_row ) ; ThrowReaderException == PALM_COMPRESSION_SCANLINE ) last_row = ( unsigned ) RelinquishMagickMemory ( last_row ) ; if\n", "\n", "Sources:\n", "0: CWE-772 static Image * ReadPALMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; IndexPacket index ; MagickBooleanType status ; MagickOffsetType totalOffset , seekNextDepth ; MagickPixelPacket transpix ; register IndexPacket * indexes ; register ssize_t i , x ; register PixelPacket * q ; size_t bytes_per_row , flags , bits_per_pixel , version , nextDepthOffset , transparentIndex , compressionType , byte , mask , redbits , greenbits , bluebits , one , pad , size , bit ; ssize_t count , y ; unsigned char * lastrow , * one_row , * ptr ; unsigned short color16 ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ( void ) DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } totalOffset = 0 ; do { image -> columns = ReadBlobMSBShort ( image ) ; image -> rows = ReadBlobMSBShort ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } bytes_per_row = ReadBlobMSBShort ( image ) ; flags = ReadBlobMSBShort ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; if ( ( bits_per_pixel != 1 ) && ( bits_per_pixel != 2 ) && ( bits_per_pixel != 4 ) && ( bits_per_pixel != 8 ) && ( bits_per_pixel != 16 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; version = ( size_t ) ReadBlobByte ( image ) ; if ( ( version != 0 ) && ( version != 1 ) && ( version != 2 ) ) ThrowReaderException ( CorruptImageError , \"FileFormatVersionMismatch\" ) ; nextDepthOffset = ( size_t ) ReadBlobMSBShort ( image ) ; transparentIndex = ( size_t ) ReadBlobByte ( image ) ; compressionType = ( size_t ) ReadBlobByte ( image ) ; if ( ( compressionType != PALM_COMPRESSION_NONE ) && ( compressionType != PALM_COMPRESSION_SCANLINE ) && ( compressionType != PALM_COMPRESSION_RLE ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; pad = ReadBlobMSBShort ( image ) ; ( void ) pad ; one = 1 ; if ( ( bits_per_pixel < 16 ) && ( AcquireImageColormap ( image , one << bits_per_pixel ) == MagickFalse ) ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; GetMagickPixelPacket ( image , & transpix ) ; if ( bits_per_pixel == 16 ) { redbits = ( size_t ) ReadBlobByte ( image ) ; ( void ) redbits ; greenbits = ( size_t ) ReadBlobByte ( image ) ; ( void ) greenbits ; bluebits = ( size_t ) ReadBlobByte ( image ) ; ( void ) bluebits ; ReadBlobByte ( image ) ; ReadBlobByte ( image ) ; transpix . red = ( MagickRealType ) ( QuantumRange * ReadBlobByte ( image ) / 31 ) ; transpix . green = ( MagickRealType ) ( QuantumRange * ReadBlobByte ( image ) / 63 ) ; transpix . blue = ( MagickRealType ) ( QuantumRange * ReadBlobByte ( image ) / 31 ) ; } if ( bits_per_pixel == 8 ) { IndexPacket index ; if ( flags & PALM_HAS_COLORMAP_FLAG ) { count = ( ssize_t ) ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) count ; i ++ ) { ReadBlobByte ( image ) ; index = ConstrainColormapIndex ( image , ( size_t ) ( 255 - i ) ) ; image -> colormap [ ( int ) index ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ ( int ) index ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ ( int ) index ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } } else for ( i = 0 ; i < ( ssize_t ) ( 1L << bits_per_pixel ) ; i ++ ) { index = ConstrainColormapIndex ( image , ( size_t ) ( 255 - i ) ) ; image -> colormap [ ( int ) index ] . red = ScaleCharToQuantum ( PalmPalette [ i ] [ 0 ] ) ; image -> colormap [ ( int ) index ] . green = ScaleCharToQuantum ( PalmPalette [ i ] [ 1 ] ) ; image -> colormap [ ( int ) index ] . blue = ScaleCharToQuantum ( PalmPalette [ i ] [ 2 ] ) ; } } if ( flags & PALM_IS_COMPRESSED_FLAG ) size = ReadBlobMSBShort ( image ) ; ( void ) size ; image -> storage_class = DirectClass ; if ( bits_per_pixel < 16 ) { image -> storage_class = PseudoClass ; image -> depth = 8 ; } if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } one_row = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( bytes_per_row , 2 * image -> columns ) , sizeof ( * one_row ) ) ; if ( one_row == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; lastrow = ( unsigned char * ) NULL ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) { lastrow = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( bytes_per_row , 2 * image -> columns ) , sizeof ( * lastrow ) ) ; if ( lastrow == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } mask = ( size_t ) ( 1U << bits_per_pixel ) - 1 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { if ( ( flags & PALM_IS_COMPRESSED_FLAG ) == 0 ) { image -> compression = NoCompression ; count = ReadBlob ( image , bytes_per_row , one_row ) ; if ( count != ( ssize_t ) bytes_per_row ) break ; } else { if ( compressionType == PALM_COMPRESSION_RLE ) { image -> compression = RLECompression ; for ( i = 0 ; i < ( ssize_t ) bytes_per_row ; ) { count = ( ssize_t ) ReadBlobByte ( image ) ; if ( count < 0 ) break ; count = MagickMin ( count , ( ssize_t ) bytes_per_row - i ) ; byte = ( size_t ) ReadBlobByte ( image ) ; ( void ) ResetMagickMemory ( one_row + i , ( int ) byte , ( size_t ) count ) ; i += count ; } } else if ( compressionType == PALM_COMPRESSION_SCANLINE ) { size_t one ; one = 1 ; image -> compression = FaxCompression ; for ( i = 0 ; i < ( ssize_t ) bytes_per_row ; i += 8 ) { count = ( ssize_t ) ReadBlobByte ( image ) ; if ( count < 0 ) break ; byte = ( size_t ) MagickMin ( ( ssize_t ) bytes_per_row - i , 8 ) ; for ( bit = 0 ; bit < byte ; bit ++ ) { if ( ( y == 0 ) || ( count & ( one << ( 7 - bit ) ) ) ) one_row [ i + bit ] = ( unsigned char ) ReadBlobByte ( image ) ; else one_row [ i + bit ] = lastrow [ i + bit ] ; } } ( void ) CopyMagickMemory ( lastrow , one_row , bytes_per_row ) ; } } ptr = one_row ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; if ( bits_per_pixel == 16 ) { if ( image -> columns > ( 2 * bytes_per_row ) ) { one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { color16 = ( * ptr ++ << 8 ) ; color16 |= ( * ptr ++ ) ; SetPixelRed ( q , ( QuantumRange * ( ( color16 >> 11 ) & 0x1f ) ) / 0x1f ) ; SetPixelGreen ( q , ( QuantumRange * ( ( color16 >> 5 ) & 0x3f ) ) / 0x3f ) ; SetPixelBlue ( q , ( QuantumRange * ( ( color16 >> 0 ) & 0x1f ) ) / 0x1f ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; q ++ ; } } else { bit = 8 - bits_per_pixel ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ( size_t ) ( ptr - one_row ) >= bytes_per_row ) { one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } index = ( IndexPacket ) ( mask - ( ( ( * ptr ) & ( mask << bit ) ) >> bit ) ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; if ( bit ) bit -= bits_per_pixel ; else { ptr ++ ; bit = 8 - bits_per_pixel ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( flags & PALM_HAS_TRANSPARENCY_FLAG ) { IndexPacket index = ConstrainColormapIndex ( image , ( mask - transparentIndex ) ) ; if ( bits_per_pixel != 16 ) SetMagickPixelPacket ( image , image -> colormap + ( ssize_t ) index , ( const IndexPacket * ) NULL , & transpix ) ; ( void ) TransparentPaintImage ( image , & transpix , ( Quantum ) TransparentOpacity , MagickFalse ) ; } one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( nextDepthOffset != 0 ) { totalOffset += ( MagickOffsetType ) ( nextDepthOffset * 4 ) ; if ( totalOffset >= ( MagickOffsetType ) GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) else seekNextDepth = SeekBlob ( image , totalOffset , SEEK_SET ) ; if ( seekNextDepth != totalOffset ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { ( void ) DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( nextDepthOffset != 0 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-772 static Image * ReadPALMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; MagickOffsetType totalOffset , seekNextDepth ; PixelInfo transpix ; Quantum index ; register ssize_t i , x ; register Quantum * q ; size_t bytes_per_row , flags , bits_per_pixel , version , nextDepthOffset , transparentIndex , compressionType , byte , mask , redbits , greenbits , bluebits , one , pad , size , bit ; ssize_t count , y ; unsigned char * lastrow , * one_row , * ptr ; unsigned short color16 ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ( void ) DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } totalOffset = 0 ; do { image -> columns = ReadBlobMSBShort ( image ) ; image -> rows = ReadBlobMSBShort ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , \"NegativeOrZeroImageSize\" ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; bytes_per_row = ReadBlobMSBShort ( image ) ; flags = ReadBlobMSBShort ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; if ( ( bits_per_pixel != 1 ) && ( bits_per_pixel != 2 ) && ( bits_per_pixel != 4 ) && ( bits_per_pixel != 8 ) && ( bits_per_pixel != 16 ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedBitsPerPixel\" ) ; version = ( size_t ) ReadBlobByte ( image ) ; if ( ( version != 0 ) && ( version != 1 ) && ( version != 2 ) ) ThrowReaderException ( CorruptImageError , \"FileFormatVersionMismatch\" ) ; nextDepthOffset = ( size_t ) ReadBlobMSBShort ( image ) ; transparentIndex = ( size_t ) ReadBlobByte ( image ) ; compressionType = ( size_t ) ReadBlobByte ( image ) ; if ( ( compressionType != PALM_COMPRESSION_NONE ) && ( compressionType != PALM_COMPRESSION_SCANLINE ) && ( compressionType != PALM_COMPRESSION_RLE ) ) ThrowReaderException ( CorruptImageError , \"UnrecognizedImageCompression\" ) ; pad = ReadBlobMSBShort ( image ) ; ( void ) pad ; one = 1 ; if ( ( bits_per_pixel < 16 ) && ( AcquireImageColormap ( image , one << bits_per_pixel , exception ) == MagickFalse ) ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; GetPixelInfo ( image , & transpix ) ; if ( bits_per_pixel == 16 ) { redbits = ( size_t ) ReadBlobByte ( image ) ; ( void ) redbits ; greenbits = ( size_t ) ReadBlobByte ( image ) ; ( void ) greenbits ; bluebits = ( size_t ) ReadBlobByte ( image ) ; ( void ) bluebits ; ReadBlobByte ( image ) ; ReadBlobByte ( image ) ; transpix . red = ( double ) ( QuantumRange * ReadBlobByte ( image ) / 31 ) ; transpix . green = ( double ) ( QuantumRange * ReadBlobByte ( image ) / 63 ) ; transpix . blue = ( double ) ( QuantumRange * ReadBlobByte ( image ) / 31 ) ; } if ( bits_per_pixel == 8 ) { ssize_t index ; if ( flags & PALM_HAS_COLORMAP_FLAG ) { count = ( ssize_t ) ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) count ; i ++ ) { ReadBlobByte ( image ) ; index = ConstrainColormapIndex ( image , 255 - i , exception ) ; image -> colormap [ index ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ index ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ index ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } } else for ( i = 0 ; i < ( ssize_t ) ( 1L << bits_per_pixel ) ; i ++ ) { index = ConstrainColormapIndex ( image , 255 - i , exception ) ; image -> colormap [ index ] . red = ( MagickRealType ) ScaleCharToQuantum ( PalmPalette [ i ] [ 0 ] ) ; image -> colormap [ index ] . green = ( MagickRealType ) ScaleCharToQuantum ( PalmPalette [ i ] [ 1 ] ) ; image -> colormap [ index ] . blue = ( MagickRealType ) ScaleCharToQuantum ( PalmPalette [ i ] [ 2 ] ) ; } } if ( flags & PALM_IS_COMPRESSED_FLAG ) size = ReadBlobMSBShort ( image ) ; ( void ) size ; image -> storage_class = DirectClass ; if ( bits_per_pixel < 16 ) { image -> storage_class = PseudoClass ; image -> depth = 8 ; } if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; one_row = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( bytes_per_row , 2 * image -> columns ) , sizeof ( * one_row ) ) ; if ( one_row == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; lastrow = ( unsigned char * ) NULL ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) { lastrow = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( bytes_per_row , 2 * image -> columns ) , sizeof ( * lastrow ) ) ; if ( lastrow == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } mask = ( size_t ) ( 1U << bits_per_pixel ) - 1 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { if ( ( flags & PALM_IS_COMPRESSED_FLAG ) == 0 ) { image -> compression = NoCompression ; count = ReadBlob ( image , bytes_per_row , one_row ) ; if ( count != ( ssize_t ) bytes_per_row ) break ; } else { if ( compressionType == PALM_COMPRESSION_RLE ) { image -> compression = RLECompression ; for ( i = 0 ; i < ( ssize_t ) bytes_per_row ; ) { count = ( ssize_t ) ReadBlobByte ( image ) ; if ( count < 0 ) break ; count = MagickMin ( count , ( ssize_t ) bytes_per_row - i ) ; byte = ( size_t ) ReadBlobByte ( image ) ; ( void ) ResetMagickMemory ( one_row + i , ( int ) byte , ( size_t ) count ) ; i += count ; } } else if ( compressionType == PALM_COMPRESSION_SCANLINE ) { size_t one ; one = 1 ; image -> compression = FaxCompression ; for ( i = 0 ; i < ( ssize_t ) bytes_per_row ; i += 8 ) { count = ( ssize_t ) ReadBlobByte ( image ) ; if ( count < 0 ) break ; byte = ( size_t ) MagickMin ( ( ssize_t ) bytes_per_row - i , 8 ) ; for ( bit = 0 ; bit < byte ; bit ++ ) { if ( ( y == 0 ) || ( count & ( one << ( 7 - bit ) ) ) ) one_row [ i + bit ] = ( unsigned char ) ReadBlobByte ( image ) ; else one_row [ i + bit ] = lastrow [ i + bit ] ; } } ( void ) CopyMagickMemory ( lastrow , one_row , bytes_per_row ) ; } } ptr = one_row ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; if ( bits_per_pixel == 16 ) { if ( image -> columns > ( 2 * bytes_per_row ) ) { one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { color16 = ( * ptr ++ << 8 ) ; color16 |= ( * ptr ++ ) ; SetPixelRed ( image , ( Quantum ) ( ( QuantumRange * ( ( color16 >> 11 ) & 0x1f ) ) / 0x1f ) , q ) ; SetPixelGreen ( image , ( Quantum ) ( ( QuantumRange * ( ( color16 >> 5 ) & 0x3f ) ) / 0x3f ) , q ) ; SetPixelBlue ( image , ( Quantum ) ( ( QuantumRange * ( ( color16 >> 0 ) & 0x1f ) ) / 0x1f ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; q += GetPixelChannels ( image ) ; } } else { bit = 8 - bits_per_pixel ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ( size_t ) ( ptr - one_row ) >= bytes_per_row ) { one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; ThrowReaderException ( CorruptImageError , \"CorruptImage\" ) ; } index = ( Quantum ) ( mask - ( ( ( * ptr ) & ( mask << bit ) ) >> bit ) ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; if ( bit ) bit -= bits_per_pixel ; else { ptr ++ ; bit = 8 - bits_per_pixel ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( flags & PALM_HAS_TRANSPARENCY_FLAG ) { ssize_t index = ConstrainColormapIndex ( image , ( ssize_t ) ( mask - transparentIndex ) , exception ) ; if ( bits_per_pixel != 16 ) transpix = image -> colormap [ index ] ; ( void ) TransparentPaintImage ( image , & transpix , ( Quantum ) TransparentAlpha , MagickFalse , exception ) ; } one_row = ( unsigned char * ) RelinquishMagickMemory ( one_row ) ; if ( compressionType == PALM_COMPRESSION_SCANLINE ) lastrow = ( unsigned char * ) RelinquishMagickMemory ( lastrow ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( nextDepthOffset != 0 ) { totalOffset += ( MagickOffsetType ) ( nextDepthOffset * 4 ) ; if ( totalOffset >= ( MagickOffsetType ) GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) else seekNextDepth = SeekBlob ( image , totalOffset , SEEK_SET ) ; if ( seekNextDepth != totalOffset ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { ( void ) DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( nextDepthOffset != 0 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: ; } } if ( ! xdr_opaque ( xdrs size ) ) return FALSE ; if ( ( * objp ) [ size - 1 ] != '\\\\0' ) return FALSE ; if ( memchr ( * objp , '\\\\0' , size - 1 ) != NULL ) return FALSE ; return TRUE\n", "\n", "Sources:\n", "0: CWE-125 bool_t xdr_nullstring ( XDR * xdrs , char * * objp ) { u_int size ; if ( xdrs -> x_op == XDR_ENCODE ) { if ( * objp == NULL ) size = 0 ; else size = strlen ( * objp ) + 1 ; } if ( ! xdr_u_int ( xdrs , & size ) ) { return FALSE ; } switch ( xdrs -> x_op ) { case XDR_DECODE : if ( size == 0 ) { * objp = NULL ; return TRUE ; } else if ( * objp == NULL ) { * objp = ( char * ) mem_alloc ( size ) ; if ( * objp == NULL ) { errno = ENOMEM ; return FALSE ; } } return ( xdr_opaque ( xdrs , * objp , size ) ) ; case XDR_ENCODE : if ( size != 0 ) return ( xdr_opaque ( xdrs , * objp , size ) ) ; return TRUE ; case XDR_FREE : if ( * objp != NULL ) mem_free ( * objp , size ) ; * objp = NULL ; return TRUE ; } return FALSE ; }\n", "\n", "1: CWE-119 bool_t xdr_nullstring ( XDR * xdrs , char * * objp ) { u_int size ; if ( xdrs -> x_op == XDR_ENCODE ) { if ( * objp == NULL ) size = 0 ; else size = strlen ( * objp ) + 1 ; } if ( ! xdr_u_int ( xdrs , & size ) ) { return FALSE ; } switch ( xdrs -> x_op ) { case XDR_DECODE : if ( size == 0 ) { * objp = NULL ; return TRUE ; } else if ( * objp == NULL ) { * objp = ( char * ) mem_alloc ( size ) ; if ( * objp == NULL ) { errno = ENOMEM ; return FALSE ; } } return ( xdr_opaque ( xdrs , * objp , size ) ) ; case XDR_ENCODE : if ( size != 0 ) return ( xdr_opaque ( xdrs , * objp , size ) ) ; return TRUE ; case XDR_FREE : if ( * objp != NULL ) mem_free ( * objp , size ) ; * objp = NULL ; return TRUE ; } return FALSE ; }\n", "\n", "\n", "Target: jpc_tsfb_band_t bnds [ JPC_MAXBANDS ] ; jpc_pchg_t\n", "\n", "Sources:\n", "0: CWE-119 static int jpc_dec_tileinit ( jpc_dec_t * dec , jpc_dec_tile_t * tile ) { jpc_dec_tcomp_t * tcomp ; int compno ; int rlvlno ; jpc_dec_rlvl_t * rlvl ; jpc_dec_band_t * band ; jpc_dec_prc_t * prc ; int bndno ; jpc_tsfb_band_t * bnd ; int bandno ; jpc_dec_ccp_t * ccp ; int prccnt ; jpc_dec_cblk_t * cblk ; int cblkcnt ; uint_fast32_t tlprcxstart ; uint_fast32_t tlprcystart ; uint_fast32_t brprcxend ; uint_fast32_t brprcyend ; uint_fast32_t tlcbgxstart ; uint_fast32_t tlcbgystart ; uint_fast32_t brcbgxend ; uint_fast32_t brcbgyend ; uint_fast32_t cbgxstart ; uint_fast32_t cbgystart ; uint_fast32_t cbgxend ; uint_fast32_t cbgyend ; uint_fast32_t tlcblkxstart ; uint_fast32_t tlcblkystart ; uint_fast32_t brcblkxend ; uint_fast32_t brcblkyend ; uint_fast32_t cblkxstart ; uint_fast32_t cblkystart ; uint_fast32_t cblkxend ; uint_fast32_t cblkyend ; uint_fast32_t tmpxstart ; uint_fast32_t tmpystart ; uint_fast32_t tmpxend ; uint_fast32_t tmpyend ; jpc_dec_cp_t * cp ; jpc_tsfb_band_t bnds [ 64 ] ; jpc_pchg_t * pchg ; int pchgno ; jpc_dec_cmpt_t * cmpt ; cp = tile -> cp ; tile -> realmode = 0 ; if ( cp -> mctid == JPC_MCT_ICT ) { tile -> realmode = 1 ; } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { ccp = & tile -> cp -> ccps [ compno ] ; if ( ccp -> qmfbid == JPC_COX_INS ) { tile -> realmode = 1 ; } tcomp -> numrlvls = ccp -> numrlvls ; if ( ! ( tcomp -> rlvls = jas_alloc2 ( tcomp -> numrlvls , sizeof ( jpc_dec_rlvl_t ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> data = jas_seq2d_create ( JPC_CEILDIV ( tile -> xstart , cmpt -> hstep ) , JPC_CEILDIV ( tile -> ystart , cmpt -> vstep ) , JPC_CEILDIV ( tile -> xend , cmpt -> hstep ) , JPC_CEILDIV ( tile -> yend , cmpt -> vstep ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> tsfb = jpc_cod_gettsfb ( ccp -> qmfbid , tcomp -> numrlvls - 1 ) ) ) { return - 1 ; } { jpc_tsfb_getbands ( tcomp -> tsfb , jas_seq2d_xstart ( tcomp -> data ) , jas_seq2d_ystart ( tcomp -> data ) , jas_seq2d_xend ( tcomp -> data ) , jas_seq2d_yend ( tcomp -> data ) , bnds ) ; } for ( rlvlno = 0 , rlvl = tcomp -> rlvls ; rlvlno < tcomp -> numrlvls ; ++ rlvlno , ++ rlvl ) { rlvl -> bands = 0 ; rlvl -> xstart = JPC_CEILDIVPOW2 ( tcomp -> xstart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> ystart = JPC_CEILDIVPOW2 ( tcomp -> ystart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> xend = JPC_CEILDIVPOW2 ( tcomp -> xend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> yend = JPC_CEILDIVPOW2 ( tcomp -> yend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> prcwidthexpn = ccp -> prcwidthexpns [ rlvlno ] ; rlvl -> prcheightexpn = ccp -> prcheightexpns [ rlvlno ] ; tlprcxstart = JPC_FLOORDIVPOW2 ( rlvl -> xstart , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; tlprcystart = JPC_FLOORDIVPOW2 ( rlvl -> ystart , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; brprcxend = JPC_CEILDIVPOW2 ( rlvl -> xend , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; brprcyend = JPC_CEILDIVPOW2 ( rlvl -> yend , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; rlvl -> numhprcs = ( brprcxend - tlprcxstart ) >> rlvl -> prcwidthexpn ; rlvl -> numvprcs = ( brprcyend - tlprcystart ) >> rlvl -> prcheightexpn ; rlvl -> numprcs = rlvl -> numhprcs * rlvl -> numvprcs ; if ( rlvl -> xstart >= rlvl -> xend || rlvl -> ystart >= rlvl -> yend ) { rlvl -> bands = 0 ; rlvl -> numprcs = 0 ; rlvl -> numhprcs = 0 ; rlvl -> numvprcs = 0 ; continue ; } if ( ! rlvlno ) { tlcbgxstart = tlprcxstart ; tlcbgystart = tlprcystart ; brcbgxend = brprcxend ; brcbgyend = brprcyend ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn ; } else { tlcbgxstart = JPC_CEILDIVPOW2 ( tlprcxstart , 1 ) ; tlcbgystart = JPC_CEILDIVPOW2 ( tlprcystart , 1 ) ; brcbgxend = JPC_CEILDIVPOW2 ( brprcxend , 1 ) ; brcbgyend = JPC_CEILDIVPOW2 ( brprcyend , 1 ) ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn - 1 ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn - 1 ; } rlvl -> cblkwidthexpn = JAS_MIN ( ccp -> cblkwidthexpn , rlvl -> cbgwidthexpn ) ; rlvl -> cblkheightexpn = JAS_MIN ( ccp -> cblkheightexpn , rlvl -> cbgheightexpn ) ; rlvl -> numbands = ( ! rlvlno ) ? 1 : 3 ; if ( ! ( rlvl -> bands = jas_alloc2 ( rlvl -> numbands , sizeof ( jpc_dec_band_t ) ) ) ) { return - 1 ; } for ( bandno = 0 , band = rlvl -> bands ; bandno < rlvl -> numbands ; ++ bandno , ++ band ) { bndno = ( ! rlvlno ) ? 0 : ( 3 * ( rlvlno - 1 ) + bandno + 1 ) ; bnd = & bnds [ bndno ] ; band -> orient = bnd -> orient ; band -> stepsize = ccp -> stepsizes [ bndno ] ; band -> analgain = JPC_NOMINALGAIN ( ccp -> qmfbid , tcomp -> numrlvls - 1 , rlvlno , band -> orient ) ; band -> absstepsize = jpc_calcabsstepsize ( band -> stepsize , cmpt -> prec + band -> analgain ) ; band -> numbps = ccp -> numguardbits + JPC_QCX_GETEXPN ( band -> stepsize ) - 1 ; band -> roishift = ( ccp -> roishift + band -> numbps >= JPC_PREC ) ? ( JPC_PREC - 1 - band -> numbps ) : ccp -> roishift ; band -> data = 0 ; band -> prcs = 0 ; if ( bnd -> xstart == bnd -> xend || bnd -> ystart == bnd -> yend ) { continue ; } if ( ! ( band -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( band -> data , tcomp -> data , bnd -> locxstart , bnd -> locystart , bnd -> locxend , bnd -> locyend ) ; jas_seq2d_setshift ( band -> data , bnd -> xstart , bnd -> ystart ) ; assert ( rlvl -> numprcs ) ; if ( ! ( band -> prcs = jas_alloc2 ( rlvl -> numprcs , sizeof ( jpc_dec_prc_t ) ) ) ) { return - 1 ; } cbgxstart = tlcbgxstart ; cbgystart = tlcbgystart ; for ( prccnt = rlvl -> numprcs , prc = band -> prcs ; prccnt > 0 ; -- prccnt , ++ prc ) { cbgxend = cbgxstart + ( 1 << rlvl -> cbgwidthexpn ) ; cbgyend = cbgystart + ( 1 << rlvl -> cbgheightexpn ) ; prc -> xstart = JAS_MAX ( cbgxstart , JAS_CAST ( uint_fast32_t , jas_seq2d_xstart ( band -> data ) ) ) ; prc -> ystart = JAS_MAX ( cbgystart , JAS_CAST ( uint_fast32_t , jas_seq2d_ystart ( band -> data ) ) ) ; prc -> xend = JAS_MIN ( cbgxend , JAS_CAST ( uint_fast32_t , jas_seq2d_xend ( band -> data ) ) ) ; prc -> yend = JAS_MIN ( cbgyend , JAS_CAST ( uint_fast32_t , jas_seq2d_yend ( band -> data ) ) ) ; if ( prc -> xend > prc -> xstart && prc -> yend > prc -> ystart ) { tlcblkxstart = JPC_FLOORDIVPOW2 ( prc -> xstart , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; tlcblkystart = JPC_FLOORDIVPOW2 ( prc -> ystart , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; brcblkxend = JPC_CEILDIVPOW2 ( prc -> xend , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; brcblkyend = JPC_CEILDIVPOW2 ( prc -> yend , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; prc -> numhcblks = ( brcblkxend - tlcblkxstart ) >> rlvl -> cblkwidthexpn ; prc -> numvcblks = ( brcblkyend - tlcblkystart ) >> rlvl -> cblkheightexpn ; prc -> numcblks = prc -> numhcblks * prc -> numvcblks ; assert ( prc -> numcblks > 0 ) ; if ( ! ( prc -> incltagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> numimsbstagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> cblks = jas_alloc2 ( prc -> numcblks , sizeof ( jpc_dec_cblk_t ) ) ) ) { return - 1 ; } cblkxstart = cbgxstart ; cblkystart = cbgystart ; for ( cblkcnt = prc -> numcblks , cblk = prc -> cblks ; cblkcnt > 0 ; ) { cblkxend = cblkxstart + ( 1 << rlvl -> cblkwidthexpn ) ; cblkyend = cblkystart + ( 1 << rlvl -> cblkheightexpn ) ; tmpxstart = JAS_MAX ( cblkxstart , prc -> xstart ) ; tmpystart = JAS_MAX ( cblkystart , prc -> ystart ) ; tmpxend = JAS_MIN ( cblkxend , prc -> xend ) ; tmpyend = JAS_MIN ( cblkyend , prc -> yend ) ; if ( tmpxend > tmpxstart && tmpyend > tmpystart ) { cblk -> firstpassno = - 1 ; cblk -> mqdec = 0 ; cblk -> nulldec = 0 ; cblk -> flags = 0 ; cblk -> numpasses = 0 ; cblk -> segs . head = 0 ; cblk -> segs . tail = 0 ; cblk -> curseg = 0 ; cblk -> numimsbs = 0 ; cblk -> numlenbits = 3 ; cblk -> flags = 0 ; if ( ! ( cblk -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( cblk -> data , band -> data , tmpxstart , tmpystart , tmpxend , tmpyend ) ; ++ cblk ; -- cblkcnt ; } cblkxstart += 1 << rlvl -> cblkwidthexpn ; if ( cblkxstart >= cbgxend ) { cblkxstart = cbgxstart ; cblkystart += 1 << rlvl -> cblkheightexpn ; } } } else { prc -> cblks = 0 ; prc -> incltagtree = 0 ; prc -> numimsbstagtree = 0 ; } cbgxstart += 1 << rlvl -> cbgwidthexpn ; if ( cbgxstart >= brcbgxend ) { cbgxstart = tlcbgxstart ; cbgystart += 1 << rlvl -> cbgheightexpn ; } } } } } if ( ! ( tile -> pi = jpc_dec_pi_create ( dec , tile ) ) ) { return - 1 ; } for ( pchgno = 0 ; pchgno < jpc_pchglist_numpchgs ( tile -> cp -> pchglist ) ; ++ pchgno ) { pchg = jpc_pchg_copy ( jpc_pchglist_get ( tile -> cp -> pchglist , pchgno ) ) ; assert ( pchg ) ; jpc_pi_addpchg ( tile -> pi , pchg ) ; } jpc_pi_init ( tile -> pi ) ; return 0 ; }\n", "\n", "1: CWE-787 static int jpc_dec_tileinit ( jpc_dec_t * dec , jpc_dec_tile_t * tile ) { jpc_dec_tcomp_t * tcomp ; int compno ; int rlvlno ; jpc_dec_rlvl_t * rlvl ; jpc_dec_band_t * band ; jpc_dec_prc_t * prc ; int bndno ; jpc_tsfb_band_t * bnd ; int bandno ; jpc_dec_ccp_t * ccp ; int prccnt ; jpc_dec_cblk_t * cblk ; int cblkcnt ; uint_fast32_t tlprcxstart ; uint_fast32_t tlprcystart ; uint_fast32_t brprcxend ; uint_fast32_t brprcyend ; uint_fast32_t tlcbgxstart ; uint_fast32_t tlcbgystart ; uint_fast32_t brcbgxend ; uint_fast32_t brcbgyend ; uint_fast32_t cbgxstart ; uint_fast32_t cbgystart ; uint_fast32_t cbgxend ; uint_fast32_t cbgyend ; uint_fast32_t tlcblkxstart ; uint_fast32_t tlcblkystart ; uint_fast32_t brcblkxend ; uint_fast32_t brcblkyend ; uint_fast32_t cblkxstart ; uint_fast32_t cblkystart ; uint_fast32_t cblkxend ; uint_fast32_t cblkyend ; uint_fast32_t tmpxstart ; uint_fast32_t tmpystart ; uint_fast32_t tmpxend ; uint_fast32_t tmpyend ; jpc_dec_cp_t * cp ; jpc_tsfb_band_t bnds [ 64 ] ; jpc_pchg_t * pchg ; int pchgno ; jpc_dec_cmpt_t * cmpt ; cp = tile -> cp ; tile -> realmode = 0 ; if ( cp -> mctid == JPC_MCT_ICT ) { tile -> realmode = 1 ; } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { ccp = & tile -> cp -> ccps [ compno ] ; if ( ccp -> qmfbid == JPC_COX_INS ) { tile -> realmode = 1 ; } tcomp -> numrlvls = ccp -> numrlvls ; if ( ! ( tcomp -> rlvls = jas_alloc2 ( tcomp -> numrlvls , sizeof ( jpc_dec_rlvl_t ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> data = jas_seq2d_create ( JPC_CEILDIV ( tile -> xstart , cmpt -> hstep ) , JPC_CEILDIV ( tile -> ystart , cmpt -> vstep ) , JPC_CEILDIV ( tile -> xend , cmpt -> hstep ) , JPC_CEILDIV ( tile -> yend , cmpt -> vstep ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> tsfb = jpc_cod_gettsfb ( ccp -> qmfbid , tcomp -> numrlvls - 1 ) ) ) { return - 1 ; } { jpc_tsfb_getbands ( tcomp -> tsfb , jas_seq2d_xstart ( tcomp -> data ) , jas_seq2d_ystart ( tcomp -> data ) , jas_seq2d_xend ( tcomp -> data ) , jas_seq2d_yend ( tcomp -> data ) , bnds ) ; } for ( rlvlno = 0 , rlvl = tcomp -> rlvls ; rlvlno < tcomp -> numrlvls ; ++ rlvlno , ++ rlvl ) { rlvl -> bands = 0 ; rlvl -> xstart = JPC_CEILDIVPOW2 ( tcomp -> xstart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> ystart = JPC_CEILDIVPOW2 ( tcomp -> ystart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> xend = JPC_CEILDIVPOW2 ( tcomp -> xend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> yend = JPC_CEILDIVPOW2 ( tcomp -> yend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> prcwidthexpn = ccp -> prcwidthexpns [ rlvlno ] ; rlvl -> prcheightexpn = ccp -> prcheightexpns [ rlvlno ] ; tlprcxstart = JPC_FLOORDIVPOW2 ( rlvl -> xstart , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; tlprcystart = JPC_FLOORDIVPOW2 ( rlvl -> ystart , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; brprcxend = JPC_CEILDIVPOW2 ( rlvl -> xend , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; brprcyend = JPC_CEILDIVPOW2 ( rlvl -> yend , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; rlvl -> numhprcs = ( brprcxend - tlprcxstart ) >> rlvl -> prcwidthexpn ; rlvl -> numvprcs = ( brprcyend - tlprcystart ) >> rlvl -> prcheightexpn ; rlvl -> numprcs = rlvl -> numhprcs * rlvl -> numvprcs ; if ( rlvl -> xstart >= rlvl -> xend || rlvl -> ystart >= rlvl -> yend ) { rlvl -> bands = 0 ; rlvl -> numprcs = 0 ; rlvl -> numhprcs = 0 ; rlvl -> numvprcs = 0 ; continue ; } if ( ! rlvlno ) { tlcbgxstart = tlprcxstart ; tlcbgystart = tlprcystart ; brcbgxend = brprcxend ; brcbgyend = brprcyend ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn ; } else { tlcbgxstart = JPC_CEILDIVPOW2 ( tlprcxstart , 1 ) ; tlcbgystart = JPC_CEILDIVPOW2 ( tlprcystart , 1 ) ; brcbgxend = JPC_CEILDIVPOW2 ( brprcxend , 1 ) ; brcbgyend = JPC_CEILDIVPOW2 ( brprcyend , 1 ) ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn - 1 ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn - 1 ; } rlvl -> cblkwidthexpn = JAS_MIN ( ccp -> cblkwidthexpn , rlvl -> cbgwidthexpn ) ; rlvl -> cblkheightexpn = JAS_MIN ( ccp -> cblkheightexpn , rlvl -> cbgheightexpn ) ; rlvl -> numbands = ( ! rlvlno ) ? 1 : 3 ; if ( ! ( rlvl -> bands = jas_alloc2 ( rlvl -> numbands , sizeof ( jpc_dec_band_t ) ) ) ) { return - 1 ; } for ( bandno = 0 , band = rlvl -> bands ; bandno < rlvl -> numbands ; ++ bandno , ++ band ) { bndno = ( ! rlvlno ) ? 0 : ( 3 * ( rlvlno - 1 ) + bandno + 1 ) ; bnd = & bnds [ bndno ] ; band -> orient = bnd -> orient ; band -> stepsize = ccp -> stepsizes [ bndno ] ; band -> analgain = JPC_NOMINALGAIN ( ccp -> qmfbid , tcomp -> numrlvls - 1 , rlvlno , band -> orient ) ; band -> absstepsize = jpc_calcabsstepsize ( band -> stepsize , cmpt -> prec + band -> analgain ) ; band -> numbps = ccp -> numguardbits + JPC_QCX_GETEXPN ( band -> stepsize ) - 1 ; band -> roishift = ( ccp -> roishift + band -> numbps >= JPC_PREC ) ? ( JPC_PREC - 1 - band -> numbps ) : ccp -> roishift ; band -> data = 0 ; band -> prcs = 0 ; if ( bnd -> xstart == bnd -> xend || bnd -> ystart == bnd -> yend ) { continue ; } if ( ! ( band -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( band -> data , tcomp -> data , bnd -> locxstart , bnd -> locystart , bnd -> locxend , bnd -> locyend ) ; jas_seq2d_setshift ( band -> data , bnd -> xstart , bnd -> ystart ) ; assert ( rlvl -> numprcs ) ; if ( ! ( band -> prcs = jas_alloc2 ( rlvl -> numprcs , sizeof ( jpc_dec_prc_t ) ) ) ) { return - 1 ; } cbgxstart = tlcbgxstart ; cbgystart = tlcbgystart ; for ( prccnt = rlvl -> numprcs , prc = band -> prcs ; prccnt > 0 ; -- prccnt , ++ prc ) { cbgxend = cbgxstart + ( 1 << rlvl -> cbgwidthexpn ) ; cbgyend = cbgystart + ( 1 << rlvl -> cbgheightexpn ) ; prc -> xstart = JAS_MAX ( cbgxstart , JAS_CAST ( uint_fast32_t , jas_seq2d_xstart ( band -> data ) ) ) ; prc -> ystart = JAS_MAX ( cbgystart , JAS_CAST ( uint_fast32_t , jas_seq2d_ystart ( band -> data ) ) ) ; prc -> xend = JAS_MIN ( cbgxend , JAS_CAST ( uint_fast32_t , jas_seq2d_xend ( band -> data ) ) ) ; prc -> yend = JAS_MIN ( cbgyend , JAS_CAST ( uint_fast32_t , jas_seq2d_yend ( band -> data ) ) ) ; if ( prc -> xend > prc -> xstart && prc -> yend > prc -> ystart ) { tlcblkxstart = JPC_FLOORDIVPOW2 ( prc -> xstart , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; tlcblkystart = JPC_FLOORDIVPOW2 ( prc -> ystart , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; brcblkxend = JPC_CEILDIVPOW2 ( prc -> xend , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; brcblkyend = JPC_CEILDIVPOW2 ( prc -> yend , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; prc -> numhcblks = ( brcblkxend - tlcblkxstart ) >> rlvl -> cblkwidthexpn ; prc -> numvcblks = ( brcblkyend - tlcblkystart ) >> rlvl -> cblkheightexpn ; prc -> numcblks = prc -> numhcblks * prc -> numvcblks ; assert ( prc -> numcblks > 0 ) ; if ( ! ( prc -> incltagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> numimsbstagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> cblks = jas_alloc2 ( prc -> numcblks , sizeof ( jpc_dec_cblk_t ) ) ) ) { return - 1 ; } cblkxstart = cbgxstart ; cblkystart = cbgystart ; for ( cblkcnt = prc -> numcblks , cblk = prc -> cblks ; cblkcnt > 0 ; ) { cblkxend = cblkxstart + ( 1 << rlvl -> cblkwidthexpn ) ; cblkyend = cblkystart + ( 1 << rlvl -> cblkheightexpn ) ; tmpxstart = JAS_MAX ( cblkxstart , prc -> xstart ) ; tmpystart = JAS_MAX ( cblkystart , prc -> ystart ) ; tmpxend = JAS_MIN ( cblkxend , prc -> xend ) ; tmpyend = JAS_MIN ( cblkyend , prc -> yend ) ; if ( tmpxend > tmpxstart && tmpyend > tmpystart ) { cblk -> firstpassno = - 1 ; cblk -> mqdec = 0 ; cblk -> nulldec = 0 ; cblk -> flags = 0 ; cblk -> numpasses = 0 ; cblk -> segs . head = 0 ; cblk -> segs . tail = 0 ; cblk -> curseg = 0 ; cblk -> numimsbs = 0 ; cblk -> numlenbits = 3 ; cblk -> flags = 0 ; if ( ! ( cblk -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( cblk -> data , band -> data , tmpxstart , tmpystart , tmpxend , tmpyend ) ; ++ cblk ; -- cblkcnt ; } cblkxstart += 1 << rlvl -> cblkwidthexpn ; if ( cblkxstart >= cbgxend ) { cblkxstart = cbgxstart ; cblkystart += 1 << rlvl -> cblkheightexpn ; } } } else { prc -> cblks = 0 ; prc -> incltagtree = 0 ; prc -> numimsbstagtree = 0 ; } cbgxstart += 1 << rlvl -> cbgwidthexpn ; if ( cbgxstart >= brcbgxend ) { cbgxstart = tlcbgxstart ; cbgystart += 1 << rlvl -> cbgheightexpn ; } } } } } if ( ! ( tile -> pi = jpc_dec_pi_create ( dec , tile ) ) ) { return - 1 ; } for ( pchgno = 0 ; pchgno < jpc_pchglist_numpchgs ( tile -> cp -> pchglist ) ; ++ pchgno ) { pchg = jpc_pchg_copy ( jpc_pchglist_get ( tile -> cp -> pchglist , pchgno ) ) ; assert ( pchg ) ; jpc_pi_addpchg ( tile -> pi , pchg ) ; } jpc_pi_init ( tile -> pi ) ; return 0 ; }\n", "\n", "\n", "Target: -> mmap_sem ) ; if ( ! mmget_still_valid ( mm ) ) goto out_unlock\n", "\n", "Sources:\n", "0: CWE-362 static int userfaultfd_register ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_register uffdio_register ; struct uffdio_register __user * user_uffdio_register ; unsigned long vm_flags , new_flags ; bool found ; bool basic_ioctls ; unsigned long start , end , vma_end ; user_uffdio_register = ( struct uffdio_register __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_register , user_uffdio_register , sizeof ( uffdio_register ) - sizeof ( __u64 ) ) ) goto out ; ret = - EINVAL ; if ( ! uffdio_register . mode ) goto out ; if ( uffdio_register . mode & ~ ( UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP ) ) goto out ; vm_flags = 0 ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_MISSING ) vm_flags |= VM_UFFD_MISSING ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_WP ) { vm_flags |= VM_UFFD_WP ; ret = - EINVAL ; goto out ; } ret = validate_range ( mm , uffdio_register . range . start , uffdio_register . range . len ) ; if ( ret ) goto out ; start = uffdio_register . range . start ; end = start + uffdio_register . range . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; basic_ioctls = false ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; ret = - EINVAL ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; ret = - EPERM ; if ( unlikely ( ! ( cur -> vm_flags & VM_MAYWRITE ) ) ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) && end <= cur -> vm_end && end > cur -> vm_start ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( cur ) ; ret = - EINVAL ; if ( end & ( vma_hpagesize - 1 ) ) goto out_unlock ; } ret = - EBUSY ; if ( cur -> vm_userfaultfd_ctx . ctx && cur -> vm_userfaultfd_ctx . ctx != ctx ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) ) basic_ioctls = true ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; BUG_ON ( vma -> vm_userfaultfd_ctx . ctx && vma -> vm_userfaultfd_ctx . ctx != ctx ) ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ) ; if ( vma -> vm_userfaultfd_ctx . ctx == ctx && ( vma -> vm_flags & vm_flags ) == vm_flags ) goto skip ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; new_flags = ( vma -> vm_flags & ~ vm_flags ) | vm_flags ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , ( ( struct vm_userfaultfd_ctx ) { ctx } ) ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx . ctx = ctx ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; if ( ! ret ) { if ( put_user ( basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : UFFD_API_RANGE_IOCTLS , & user_uffdio_register -> ioctls ) ) ret = - EFAULT ; } out : return ret ; }\n", "\n", "1: CWE-667 static int userfaultfd_register ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_register uffdio_register ; struct uffdio_register __user * user_uffdio_register ; unsigned long vm_flags , new_flags ; bool found ; bool basic_ioctls ; unsigned long start , end , vma_end ; user_uffdio_register = ( struct uffdio_register __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_register , user_uffdio_register , sizeof ( uffdio_register ) - sizeof ( __u64 ) ) ) goto out ; ret = - EINVAL ; if ( ! uffdio_register . mode ) goto out ; if ( uffdio_register . mode & ~ ( UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP ) ) goto out ; vm_flags = 0 ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_MISSING ) vm_flags |= VM_UFFD_MISSING ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_WP ) { vm_flags |= VM_UFFD_WP ; ret = - EINVAL ; goto out ; } ret = validate_range ( mm , uffdio_register . range . start , uffdio_register . range . len ) ; if ( ret ) goto out ; start = uffdio_register . range . start ; end = start + uffdio_register . range . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; basic_ioctls = false ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; ret = - EINVAL ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; ret = - EPERM ; if ( unlikely ( ! ( cur -> vm_flags & VM_MAYWRITE ) ) ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) && end <= cur -> vm_end && end > cur -> vm_start ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( cur ) ; ret = - EINVAL ; if ( end & ( vma_hpagesize - 1 ) ) goto out_unlock ; } ret = - EBUSY ; if ( cur -> vm_userfaultfd_ctx . ctx && cur -> vm_userfaultfd_ctx . ctx != ctx ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) ) basic_ioctls = true ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; BUG_ON ( vma -> vm_userfaultfd_ctx . ctx && vma -> vm_userfaultfd_ctx . ctx != ctx ) ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ) ; if ( vma -> vm_userfaultfd_ctx . ctx == ctx && ( vma -> vm_flags & vm_flags ) == vm_flags ) goto skip ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; new_flags = ( vma -> vm_flags & ~ vm_flags ) | vm_flags ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , ( ( struct vm_userfaultfd_ctx ) { ctx } ) ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx . ctx = ctx ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; if ( ! ret ) { if ( put_user ( basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : UFFD_API_RANGE_IOCTLS , & user_uffdio_register -> ioctls ) ) ret = - EFAULT ; } out : return ret ; }\n", "\n", "\n", "Target: authfile , O_RDONLY | O_CLOEXEC | O_NOCTTY ) ; if ; goto err ; } else { fd = - 1 opwfile ) ; if ( fd if ( fd != - 1 ) close (\n", "\n", "Sources:\n", "0: CWE-200 int get_devices_from_authfile ( const char * authfile , const char * username , unsigned max_devs , int verbose , FILE * debug_file , device_t * devices , unsigned * n_devs ) { char * buf = NULL ; char * s_user , * s_token ; int retval = 0 ; int fd = - 1 ; struct stat st ; struct passwd * pw = NULL , pw_s ; char buffer [ BUFSIZE ] ; int gpu_ret ; FILE * opwfile = NULL ; unsigned i , j ; * n_devs = 0 ; fd = open ( authfile , O_RDONLY , 0 ) ; if ( fd < 0 ) { if ( verbose ) D ( debug_file , \"Cannotopenfile:%s(%s)\" , authfile , strerror ( errno ) ) ; goto err ; } if ( fstat ( fd , & st ) < 0 ) { if ( verbose ) D ( debug_file , \"Cannotstatfile:%s(%s)\" , authfile , strerror ( errno ) ) ; goto err ; } if ( ! S_ISREG ( st . st_mode ) ) { if ( verbose ) D ( debug_file , \"%sisnotaregularfile\" , authfile ) ; goto err ; } if ( st . st_size == 0 ) { if ( verbose ) D ( debug_file , \"File%sisempty\" , authfile ) ; goto err ; } gpu_ret = getpwuid_r ( st . st_uid , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpu_ret != 0 || pw == NULL ) { D ( debug_file , \"Unabletoretrievecredentialsforuid%u,(%s)\" , st . st_uid , strerror ( errno ) ) ; goto err ; } if ( strcmp ( pw -> pw_name , username ) != 0 && strcmp ( pw -> pw_name , \"root\" ) != 0 ) { if ( strcmp ( username , \"root\" ) != 0 ) { D ( debug_file , \"Theowneroftheauthenticationfileisneither%snorroot\" , username ) ; } else { D ( debug_file , \"Theowneroftheauthenticationfileisnotroot\" ) ; } goto err ; } opwfile = fdopen ( fd , \"r\" ) ; if ( opwfile == NULL ) { if ( verbose ) D ( debug_file , \"fdopen:%s\" , strerror ( errno ) ) ; goto err ; } buf = malloc ( sizeof ( char ) * ( DEVSIZE * max_devs ) ) ; if ( ! buf ) { if ( verbose ) D ( debug_file , \"Unabletoallocatememory\" ) ; goto err ; } retval = - 2 ; while ( fgets ( buf , ( int ) ( DEVSIZE * ( max_devs - 1 ) ) , opwfile ) ) { char * saveptr = NULL ; if ( buf [ strlen ( buf ) - 1 ] == '\\\\n' ) buf [ strlen ( buf ) - 1 ] = '\\\\0' ; if ( verbose ) D ( debug_file , \"Authorizationline:%s\" , buf ) ; s_user = strtok_r ( buf , \":\" , & saveptr ) ; if ( s_user && strcmp ( username , s_user ) == 0 ) { if ( verbose ) D ( debug_file , \"Matcheduser:%s\" , s_user ) ; retval = - 1 ; for ( i = 0 ; i < * n_devs ; i ++ ) { free ( devices [ i ] . keyHandle ) ; free ( devices [ i ] . publicKey ) ; devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; } * n_devs = 0 ; i = 0 ; while ( ( s_token = strtok_r ( NULL , \",\" , & saveptr ) ) ) { devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; if ( ( * n_devs ) ++ > MAX_DEVS - 1 ) { * n_devs = MAX_DEVS ; if ( verbose ) D ( debug_file , \"Foundmorethan%ddevices,ignoringtheremainingones\" , MAX_DEVS ) ; break ; } if ( verbose ) D ( debug_file , \"KeyHandlefordevicenumber%d:%s\" , i + 1 , s_token ) ; devices [ i ] . keyHandle = strdup ( s_token ) ; if ( ! devices [ i ] . keyHandle ) { if ( verbose ) D ( debug_file , \"UnabletoallocatememoryforkeyHandlenumber%d\" , i ) ; goto err ; } s_token = strtok_r ( NULL , \":\" , & saveptr ) ; if ( ! s_token ) { if ( verbose ) D ( debug_file , \"UnabletoretrievepublicKeynumber%d\" , i + 1 ) ; goto err ; } if ( verbose ) D ( debug_file , \"publicKeyfordevicenumber%d:%s\" , i + 1 , s_token ) ; if ( strlen ( s_token ) % 2 != 0 ) { if ( verbose ) D ( debug_file , \"Lengthofkeynumber%dnoteven\" , i + 1 ) ; goto err ; } devices [ i ] . key_len = strlen ( s_token ) / 2 ; if ( verbose ) D ( debug_file , \"Lengthofkeynumber%dis%zu\" , i + 1 , devices [ i ] . key_len ) ; devices [ i ] . publicKey = malloc ( ( sizeof ( unsigned char ) * devices [ i ] . key_len ) ) ; if ( ! devices [ i ] . publicKey ) { if ( verbose ) D ( debug_file , \"UnabletoallocatememoryforpublicKeynumber%d\" , i ) ; goto err ; } for ( j = 0 ; j < devices [ i ] . key_len ; j ++ ) { unsigned int x ; if ( sscanf ( & s_token [ 2 * j ] , \"%2x\" , & x ) != 1 ) { if ( verbose ) D ( debug_file , \"Invalidhexnumberinkey\" ) ; goto err ; } devices [ i ] . publicKey [ j ] = ( unsigned char ) x ; } i ++ ; } } } if ( verbose ) D ( debug_file , \"Found%ddevice(s)foruser%s\" , * n_devs , username ) ; retval = 1 ; goto out ; err : for ( i = 0 ; i < * n_devs ; i ++ ) { free ( devices [ i ] . keyHandle ) ; free ( devices [ i ] . publicKey ) ; devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; } * n_devs = 0 ; out : if ( buf ) { free ( buf ) ; buf = NULL ; } if ( opwfile ) fclose ( opwfile ) ; else if ( fd >= 0 ) close ( fd ) ; return retval ; }\n", "\n", "1: CWE-000 int get_devices_from_authfile ( const char * authfile , const char * username , unsigned max_devs , int verbose , FILE * debug_file , device_t * devices , unsigned * n_devs ) { char * buf = NULL ; char * s_user , * s_token ; int retval = 0 ; int fd = - 1 ; struct stat st ; struct passwd * pw = NULL , pw_s ; char buffer [ BUFSIZE ] ; int gpu_ret ; FILE * opwfile = NULL ; unsigned i , j ; * n_devs = 0 ; fd = open ( authfile , O_RDONLY , 0 ) ; if ( fd < 0 ) { if ( verbose ) D ( debug_file , \"Cannotopenfile:%s(%s)\" , authfile , strerror ( errno ) ) ; goto err ; } if ( fstat ( fd , & st ) < 0 ) { if ( verbose ) D ( debug_file , \"Cannotstatfile:%s(%s)\" , authfile , strerror ( errno ) ) ; goto err ; } if ( ! S_ISREG ( st . st_mode ) ) { if ( verbose ) D ( debug_file , \"%sisnotaregularfile\" , authfile ) ; goto err ; } if ( st . st_size == 0 ) { if ( verbose ) D ( debug_file , \"File%sisempty\" , authfile ) ; goto err ; } gpu_ret = getpwuid_r ( st . st_uid , & pw_s , buffer , sizeof ( buffer ) , & pw ) ; if ( gpu_ret != 0 || pw == NULL ) { D ( debug_file , \"Unabletoretrievecredentialsforuid%u,(%s)\" , st . st_uid , strerror ( errno ) ) ; goto err ; } if ( strcmp ( pw -> pw_name , username ) != 0 && strcmp ( pw -> pw_name , \"root\" ) != 0 ) { if ( strcmp ( username , \"root\" ) != 0 ) { D ( debug_file , \"Theowneroftheauthenticationfileisneither%snorroot\" , username ) ; } else { D ( debug_file , \"Theowneroftheauthenticationfileisnotroot\" ) ; } goto err ; } opwfile = fdopen ( fd , \"r\" ) ; if ( opwfile == NULL ) { if ( verbose ) D ( debug_file , \"fdopen:%s\" , strerror ( errno ) ) ; goto err ; } buf = malloc ( sizeof ( char ) * ( DEVSIZE * max_devs ) ) ; if ( ! buf ) { if ( verbose ) D ( debug_file , \"Unabletoallocatememory\" ) ; goto err ; } retval = - 2 ; while ( fgets ( buf , ( int ) ( DEVSIZE * ( max_devs - 1 ) ) , opwfile ) ) { char * saveptr = NULL ; if ( buf [ strlen ( buf ) - 1 ] == '\\\\n' ) buf [ strlen ( buf ) - 1 ] = '\\\\0' ; if ( verbose ) D ( debug_file , \"Authorizationline:%s\" , buf ) ; s_user = strtok_r ( buf , \":\" , & saveptr ) ; if ( s_user && strcmp ( username , s_user ) == 0 ) { if ( verbose ) D ( debug_file , \"Matcheduser:%s\" , s_user ) ; retval = - 1 ; for ( i = 0 ; i < * n_devs ; i ++ ) { free ( devices [ i ] . keyHandle ) ; free ( devices [ i ] . publicKey ) ; devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; } * n_devs = 0 ; i = 0 ; while ( ( s_token = strtok_r ( NULL , \",\" , & saveptr ) ) ) { devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; if ( ( * n_devs ) ++ > MAX_DEVS - 1 ) { * n_devs = MAX_DEVS ; if ( verbose ) D ( debug_file , \"Foundmorethan%ddevices,ignoringtheremainingones\" , MAX_DEVS ) ; break ; } if ( verbose ) D ( debug_file , \"KeyHandlefordevicenumber%d:%s\" , i + 1 , s_token ) ; devices [ i ] . keyHandle = strdup ( s_token ) ; if ( ! devices [ i ] . keyHandle ) { if ( verbose ) D ( debug_file , \"UnabletoallocatememoryforkeyHandlenumber%d\" , i ) ; goto err ; } s_token = strtok_r ( NULL , \":\" , & saveptr ) ; if ( ! s_token ) { if ( verbose ) D ( debug_file , \"UnabletoretrievepublicKeynumber%d\" , i + 1 ) ; goto err ; } if ( verbose ) D ( debug_file , \"publicKeyfordevicenumber%d:%s\" , i + 1 , s_token ) ; if ( strlen ( s_token ) % 2 != 0 ) { if ( verbose ) D ( debug_file , \"Lengthofkeynumber%dnoteven\" , i + 1 ) ; goto err ; } devices [ i ] . key_len = strlen ( s_token ) / 2 ; if ( verbose ) D ( debug_file , \"Lengthofkeynumber%dis%zu\" , i + 1 , devices [ i ] . key_len ) ; devices [ i ] . publicKey = malloc ( ( sizeof ( unsigned char ) * devices [ i ] . key_len ) ) ; if ( ! devices [ i ] . publicKey ) { if ( verbose ) D ( debug_file , \"UnabletoallocatememoryforpublicKeynumber%d\" , i ) ; goto err ; } for ( j = 0 ; j < devices [ i ] . key_len ; j ++ ) { unsigned int x ; if ( sscanf ( & s_token [ 2 * j ] , \"%2x\" , & x ) != 1 ) { if ( verbose ) D ( debug_file , \"Invalidhexnumberinkey\" ) ; goto err ; } devices [ i ] . publicKey [ j ] = ( unsigned char ) x ; } i ++ ; } } } if ( verbose ) D ( debug_file , \"Found%ddevice(s)foruser%s\" , * n_devs , username ) ; retval = 1 ; goto out ; err : for ( i = 0 ; i < * n_devs ; i ++ ) { free ( devices [ i ] . keyHandle ) ; free ( devices [ i ] . publicKey ) ; devices [ i ] . keyHandle = NULL ; devices [ i ] . publicKey = NULL ; } * n_devs = 0 ; out : if ( buf ) { free ( buf ) ; buf = NULL ; } if ( opwfile ) fclose ( opwfile ) ; else if ( fd >= 0 ) close ( fd ) ; return retval ; }\n", "\n", "\n", "Target: ( ) { once ( setup_rtcd_internal\n", "\n", "Sources:\n", "0: CWE-119 void vp8_rtcd ( ) { vpx_scale_rtcd ( ) ; once ( setup_rtcd_internal ) ; }\n", "\n", "1: CWE-119 void vp9_rtcd ( ) { vpx_scale_rtcd ( ) ; once ( setup_rtcd_internal ) ; }\n", "\n", "\n", "Target: TIOCGETD : return tiocgetd ( tty , p ) ;\n", "\n", "Sources:\n", "0: CWE-362 long tty_ioctl ( struct file * file , unsigned int cmd , unsigned long arg ) { struct tty_struct * tty = file_tty ( file ) ; struct tty_struct * real_tty ; void __user * p = ( void __user * ) arg ; int retval ; struct tty_ldisc * ld ; if ( tty_paranoia_check ( tty , file_inode ( file ) , \"tty_ioctl\" ) ) return - EINVAL ; real_tty = tty_pair_get_tty ( tty ) ; switch ( cmd ) { case TIOCSETD : case TIOCSBRK : case TIOCCBRK : case TCSBRK : case TCSBRKP : retval = tty_check_change ( tty ) ; if ( retval ) return retval ; if ( cmd != TIOCCBRK ) { tty_wait_until_sent ( tty , 0 ) ; if ( signal_pending ( current ) ) return - EINTR ; } break ; } switch ( cmd ) { case TIOCSTI : return tiocsti ( tty , p ) ; case TIOCGWINSZ : return tiocgwinsz ( real_tty , p ) ; case TIOCSWINSZ : return tiocswinsz ( real_tty , p ) ; case TIOCCONS : return real_tty != tty ? - EINVAL : tioccons ( file ) ; case FIONBIO : return fionbio ( file , p ) ; case TIOCEXCL : set_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return 0 ; case TIOCNXCL : clear_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return 0 ; case TIOCGEXCL : { int excl = test_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return put_user ( excl , ( int __user * ) p ) ; } case TIOCNOTTY : if ( current -> signal -> tty != tty ) return - ENOTTY ; no_tty ( ) ; return 0 ; case TIOCSCTTY : return tiocsctty ( real_tty , file , arg ) ; case TIOCGPGRP : return tiocgpgrp ( tty , real_tty , p ) ; case TIOCSPGRP : return tiocspgrp ( tty , real_tty , p ) ; case TIOCGSID : return tiocgsid ( tty , real_tty , p ) ; case TIOCGETD : return put_user ( tty -> ldisc -> ops -> num , ( int __user * ) p ) ; case TIOCSETD : return tiocsetd ( tty , p ) ; case TIOCVHANGUP : if ( ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; tty_vhangup ( tty ) ; return 0 ; case TIOCGDEV : { unsigned int ret = new_encode_dev ( tty_devnum ( real_tty ) ) ; return put_user ( ret , ( unsigned int __user * ) p ) ; } case TIOCSBRK : if ( tty -> ops -> break_ctl ) return tty -> ops -> break_ctl ( tty , - 1 ) ; return 0 ; case TIOCCBRK : if ( tty -> ops -> break_ctl ) return tty -> ops -> break_ctl ( tty , 0 ) ; return 0 ; case TCSBRK : if ( ! arg ) return send_break ( tty , 250 ) ; return 0 ; case TCSBRKP : return send_break ( tty , arg ? arg * 100 : 250 ) ; case TIOCMGET : return tty_tiocmget ( tty , p ) ; case TIOCMSET : case TIOCMBIC : case TIOCMBIS : return tty_tiocmset ( tty , cmd , p ) ; case TIOCGICOUNT : retval = tty_tiocgicount ( tty , p ) ; if ( retval != - EINVAL ) return retval ; break ; case TCFLSH : switch ( arg ) { case TCIFLUSH : case TCIOFLUSH : tty_buffer_flush ( tty , NULL ) ; break ; } break ; case TIOCSSERIAL : tty_warn_deprecated_flags ( p ) ; break ; } if ( tty -> ops -> ioctl ) { retval = tty -> ops -> ioctl ( tty , cmd , arg ) ; if ( retval != - ENOIOCTLCMD ) return retval ; } ld = tty_ldisc_ref_wait ( tty ) ; retval = - EINVAL ; if ( ld -> ops -> ioctl ) { retval = ld -> ops -> ioctl ( tty , file , cmd , arg ) ; if ( retval == - ENOIOCTLCMD ) retval = - ENOTTY ; } tty_ldisc_deref ( ld ) ; return retval ; }\n", "\n", "1: CWE-200 long tty_ioctl ( struct file * file , unsigned int cmd , unsigned long arg ) { struct tty_struct * tty = file_tty ( file ) ; struct tty_struct * real_tty ; void __user * p = ( void __user * ) arg ; int retval ; struct tty_ldisc * ld ; if ( tty_paranoia_check ( tty , file_inode ( file ) , \"tty_ioctl\" ) ) return - EINVAL ; real_tty = tty_pair_get_tty ( tty ) ; switch ( cmd ) { case TIOCSETD : case TIOCSBRK : case TIOCCBRK : case TCSBRK : case TCSBRKP : retval = tty_check_change ( tty ) ; if ( retval ) return retval ; if ( cmd != TIOCCBRK ) { tty_wait_until_sent ( tty , 0 ) ; if ( signal_pending ( current ) ) return - EINTR ; } break ; } switch ( cmd ) { case TIOCSTI : return tiocsti ( tty , p ) ; case TIOCGWINSZ : return tiocgwinsz ( real_tty , p ) ; case TIOCSWINSZ : return tiocswinsz ( real_tty , p ) ; case TIOCCONS : return real_tty != tty ? - EINVAL : tioccons ( file ) ; case FIONBIO : return fionbio ( file , p ) ; case TIOCEXCL : set_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return 0 ; case TIOCNXCL : clear_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return 0 ; case TIOCGEXCL : { int excl = test_bit ( TTY_EXCLUSIVE , & tty -> flags ) ; return put_user ( excl , ( int __user * ) p ) ; } case TIOCNOTTY : if ( current -> signal -> tty != tty ) return - ENOTTY ; no_tty ( ) ; return 0 ; case TIOCSCTTY : return tiocsctty ( real_tty , file , arg ) ; case TIOCGPGRP : return tiocgpgrp ( tty , real_tty , p ) ; case TIOCSPGRP : return tiocspgrp ( tty , real_tty , p ) ; case TIOCGSID : return tiocgsid ( tty , real_tty , p ) ; case TIOCGETD : return put_user ( tty -> ldisc -> ops -> num , ( int __user * ) p ) ; case TIOCSETD : return tiocsetd ( tty , p ) ; case TIOCVHANGUP : if ( ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; tty_vhangup ( tty ) ; return 0 ; case TIOCGDEV : { unsigned int ret = new_encode_dev ( tty_devnum ( real_tty ) ) ; return put_user ( ret , ( unsigned int __user * ) p ) ; } case TIOCSBRK : if ( tty -> ops -> break_ctl ) return tty -> ops -> break_ctl ( tty , - 1 ) ; return 0 ; case TIOCCBRK : if ( tty -> ops -> break_ctl ) return tty -> ops -> break_ctl ( tty , 0 ) ; return 0 ; case TCSBRK : if ( ! arg ) return send_break ( tty , 250 ) ; return 0 ; case TCSBRKP : return send_break ( tty , arg ? arg * 100 : 250 ) ; case TIOCMGET : return tty_tiocmget ( tty , p ) ; case TIOCMSET : case TIOCMBIC : case TIOCMBIS : return tty_tiocmset ( tty , cmd , p ) ; case TIOCGICOUNT : retval = tty_tiocgicount ( tty , p ) ; if ( retval != - EINVAL ) return retval ; break ; case TCFLSH : switch ( arg ) { case TCIFLUSH : case TCIOFLUSH : tty_buffer_flush ( tty , NULL ) ; break ; } break ; case TIOCSSERIAL : tty_warn_deprecated_flags ( p ) ; break ; } if ( tty -> ops -> ioctl ) { retval = tty -> ops -> ioctl ( tty , cmd , arg ) ; if ( retval != - ENOIOCTLCMD ) return retval ; } ld = tty_ldisc_ref_wait ( tty ) ; retval = - EINVAL ; if ( ld -> ops -> ioctl ) { retval = ld -> ops -> ioctl ( tty , file , cmd , arg ) ; if ( retval == - ENOIOCTLCMD ) retval = - ENOTTY ; } tty_ldisc_deref ( ld ) ; return retval ; }\n", "\n", "\n", "Target: return NULL ; if ( ! mmget_still_valid ( mm ) ) return NULL ;\n", "\n", "Sources:\n", "0: CWE-362 struct vm_area_struct * find_extend_vma ( struct mm_struct * mm , unsigned long addr ) { struct vm_area_struct * vma ; unsigned long start ; addr &= PAGE_MASK ; vma = find_vma ( mm , addr ) ; if ( ! vma ) return NULL ; if ( vma -> vm_start <= addr ) return vma ; if ( ! ( vma -> vm_flags & VM_GROWSDOWN ) ) return NULL ; start = vma -> vm_start ; if ( expand_stack ( vma , addr ) ) return NULL ; if ( vma -> vm_flags & VM_LOCKED ) populate_vma_page_range ( vma , addr , start , NULL ) ; return vma ; }\n", "\n", "1: CWE-667 struct vm_area_struct * find_extend_vma ( struct mm_struct * mm , unsigned long addr ) { struct vm_area_struct * vma ; unsigned long start ; addr &= PAGE_MASK ; vma = find_vma ( mm , addr ) ; if ( ! vma ) return NULL ; if ( vma -> vm_start <= addr ) return vma ; if ( ! ( vma -> vm_flags & VM_GROWSDOWN ) ) return NULL ; start = vma -> vm_start ; if ( expand_stack ( vma , addr ) ) return NULL ; if ( vma -> vm_flags & VM_LOCKED ) populate_vma_page_range ( vma , addr , start , NULL ) ; return vma ; }\n", "\n", "\n", "Target: channel_info * info ; if ( voice < 0 || voice >= devc -> nr_voice ) return ; if ( chn < 0 || chn > 15 ) return ; info\n", "\n", "Sources:\n", "0: CWE-264 static void opl3_setup_voice ( int dev , int voice , int chn ) { struct channel_info * info = & synth_devs [ dev ] -> chn_info [ chn ] ; opl3_set_instr ( dev , voice , info -> pgm_num ) ; devc -> voc [ voice ] . bender = 0 ; devc -> voc [ voice ] . bender_range = info -> bender_range ; devc -> voc [ voice ] . volume = info -> controllers [ CTL_MAIN_VOLUME ] ; devc -> voc [ voice ] . panning = ( info -> controllers [ CTL_PAN ] * 2 ) - 128 ; }\n", "\n", "1: CWE-119 static void opl3_setup_voice ( int dev , int voice , int chn ) { struct channel_info * info = & synth_devs [ dev ] -> chn_info [ chn ] ; opl3_set_instr ( dev , voice , info -> pgm_num ) ; devc -> voc [ voice ] . bender = 0 ; devc -> voc [ voice ] . bender_range = info -> bender_range ; devc -> voc [ voice ] . volume = info -> controllers [ CTL_MAIN_VOLUME ] ; devc -> voc [ voice ] . panning = ( info -> controllers [ CTL_PAN ] * 2 ) - 128 ; }\n", "\n", "\n", "Target: tif_rawcc ) ) { tif -> tif_rawcc = 0 ; tif -> tif_rawcp = tif -> tif_rawdata ; 0 ) ; }\n", "\n", "Sources:\n", "0: CWE-119 int TIFFFlushData1 ( TIFF * tif ) { if ( tif -> tif_rawcc > 0 && tif -> tif_flags & TIFF_BUF4WRITE ) { if ( ! isFillOrder ( tif , tif -> tif_dir . td_fillorder ) && ( tif -> tif_flags & TIFF_NOBITREV ) == 0 ) TIFFReverseBits ( ( uint8 * ) tif -> tif_rawdata , tif -> tif_rawcc ) ; if ( ! TIFFAppendToStrip ( tif , isTiled ( tif ) ? tif -> tif_curtile : tif -> tif_curstrip , tif -> tif_rawdata , tif -> tif_rawcc ) ) return ( 0 ) ; tif -> tif_rawcc = 0 ; tif -> tif_rawcp = tif -> tif_rawdata ; } return ( 1 ) ; }\n", "\n", "1: CWE-787 int TIFFFlushData1 ( TIFF * tif ) { if ( tif -> tif_rawcc > 0 && tif -> tif_flags & TIFF_BUF4WRITE ) { if ( ! isFillOrder ( tif , tif -> tif_dir . td_fillorder ) && ( tif -> tif_flags & TIFF_NOBITREV ) == 0 ) TIFFReverseBits ( ( uint8 * ) tif -> tif_rawdata , tif -> tif_rawcc ) ; if ( ! TIFFAppendToStrip ( tif , isTiled ( tif ) ? tif -> tif_curtile : tif -> tif_curstrip , tif -> tif_rawdata , tif -> tif_rawcc ) ) return ( 0 ) ; tif -> tif_rawcc = 0 ; tif -> tif_rawcp = tif -> tif_rawdata ; } return ( 1 ) ; }\n", "\n", "\n", "Target: unsigned short sel , old_sel ; struct desc_struct old_desc , new_desc ; const struct x86_emulate_ops * ops = ctxt -> ops ; u8 cpl = ctxt -> ops -> cpl ( ctxt ) ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) ops -> get_segment ( ctxt , & old_sel , & old_desc , NULL , VCPU_SREG_CS ) ; rc = __load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS , cpl , false , & new_desc return rc ; rc = assign_eip_far ( ctxt , ctxt -> -> src . val , new_desc . l ) ; if ( rc != X86EMUL_CONTINUE ) { WARN_ON ( ! ctxt -> mode != X86EMUL_MODE_PROT64 ) ; ops -> set_segment ( ctxt , old_sel , & old_desc , 0 , VCPU_SREG_CS ) ; return ) ; return rc ; } return rc ; } \n", "\n", "Sources:\n", "0: CWE-000 static int em_jmp_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned short sel ; memcpy ( & sel , ctxt -> src . valptr + ctxt -> op_bytes , 2 ) ; rc = load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; ctxt -> _eip = 0 ; memcpy ( & ctxt -> _eip , ctxt -> src . valptr , ctxt -> op_bytes ) ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-264 static int em_jmp_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned short sel ; memcpy ( & sel , ctxt -> src . valptr + ctxt -> op_bytes , 2 ) ; rc = load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; ctxt -> _eip = 0 ; memcpy ( & ctxt -> _eip , ctxt -> src . valptr , ctxt -> op_bytes ) ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: count ) { UINT32 count = bitmapUpdate * 2 ; BITMAP_DATA *\n", "\n", "Sources:\n", "0: CWE-787 BITMAP_UPDATE * update_read_bitmap_update ( rdpUpdate * update , wStream * s ) { UINT32 i ; BITMAP_UPDATE * bitmapUpdate = calloc ( 1 , sizeof ( BITMAP_UPDATE ) ) ; if ( ! bitmapUpdate ) goto fail ; if ( Stream_GetRemainingLength ( s ) < 2 ) goto fail ; Stream_Read_UINT16 ( s , bitmapUpdate -> number ) ; WLog_Print ( update -> log , WLOG_TRACE , \"BitmapUpdate:%\" PRIu32 \"\" , bitmapUpdate -> number ) ; if ( bitmapUpdate -> number > bitmapUpdate -> count ) { UINT16 count ; BITMAP_DATA * newdata ; count = bitmapUpdate -> number * 2 ; newdata = ( BITMAP_DATA * ) realloc ( bitmapUpdate -> rectangles , sizeof ( BITMAP_DATA ) * count ) ; if ( ! newdata ) goto fail ; bitmapUpdate -> rectangles = newdata ; ZeroMemory ( & bitmapUpdate -> rectangles [ bitmapUpdate -> count ] , sizeof ( BITMAP_DATA ) * ( count - bitmapUpdate -> count ) ) ; bitmapUpdate -> count = count ; } for ( i = 0 ; i < bitmapUpdate -> number ; i ++ ) { if ( ! update_read_bitmap_data ( update , s , & bitmapUpdate -> rectangles [ i ] ) ) goto fail ; } return bitmapUpdate ; fail : free_bitmap_update ( update -> context , bitmapUpdate ) ; return NULL ; }\n", "\n", "1: CWE-119 BITMAP_UPDATE * update_read_bitmap_update ( rdpUpdate * update , wStream * s ) { UINT32 i ; BITMAP_UPDATE * bitmapUpdate = calloc ( 1 , sizeof ( BITMAP_UPDATE ) ) ; if ( ! bitmapUpdate ) goto fail ; if ( Stream_GetRemainingLength ( s ) < 2 ) goto fail ; Stream_Read_UINT16 ( s , bitmapUpdate -> number ) ; WLog_Print ( update -> log , WLOG_TRACE , \"BitmapUpdate:%\" PRIu32 \"\" , bitmapUpdate -> number ) ; if ( bitmapUpdate -> number > bitmapUpdate -> count ) { UINT16 count ; BITMAP_DATA * newdata ; count = bitmapUpdate -> number * 2 ; newdata = ( BITMAP_DATA * ) realloc ( bitmapUpdate -> rectangles , sizeof ( BITMAP_DATA ) * count ) ; if ( ! newdata ) goto fail ; bitmapUpdate -> rectangles = newdata ; ZeroMemory ( & bitmapUpdate -> rectangles [ bitmapUpdate -> count ] , sizeof ( BITMAP_DATA ) * ( count - bitmapUpdate -> count ) ) ; bitmapUpdate -> count = count ; } for ( i = 0 ; i < bitmapUpdate -> number ; i ++ ) { if ( ! update_read_bitmap_data ( update , s , & bitmapUpdate -> rectangles [ i ] ) ) goto fail ; } return bitmapUpdate ; fail : free_bitmap_update ( update -> context , bitmapUpdate ) ; return NULL ; }\n", "\n", "\n", "Target: ; newinet -> inet_opt = NULL ;\n", "\n", "Sources:\n", "0: CWE-362 static struct sock * tcp_v6_syn_recv_sock ( struct sock * sk , struct sk_buff * skb , struct request_sock * req , struct dst_entry * dst ) { struct inet6_request_sock * treq ; struct ipv6_pinfo * newnp , * np = inet6_sk ( sk ) ; struct tcp6_sock * newtcp6sk ; struct inet_sock * newinet ; struct tcp_sock * newtp ; struct sock * newsk ; struct ipv6_txoptions * opt ; # ifdef CONFIG_TCP_MD5SIG struct tcp_md5sig_key * key ; # endif if ( skb -> protocol == htons ( ETH_P_IP ) ) { newsk = tcp_v4_syn_recv_sock ( sk , skb , req , dst ) ; if ( newsk == NULL ) return NULL ; newtcp6sk = ( struct tcp6_sock * ) newsk ; inet_sk ( newsk ) -> pinet6 = & newtcp6sk -> inet6 ; newinet = inet_sk ( newsk ) ; newnp = inet6_sk ( newsk ) ; newtp = tcp_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; ipv6_addr_set_v4mapped ( newinet -> inet_daddr , & newnp -> daddr ) ; ipv6_addr_set_v4mapped ( newinet -> inet_saddr , & newnp -> saddr ) ; ipv6_addr_copy ( & newnp -> rcv_saddr , & newnp -> saddr ) ; inet_csk ( newsk ) -> icsk_af_ops = & ipv6_mapped ; newsk -> sk_backlog_rcv = tcp_v4_do_rcv ; # ifdef CONFIG_TCP_MD5SIG newtp -> af_specific = & tcp_sock_ipv6_mapped_specific ; # endif newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; tcp_sync_mss ( newsk , inet_csk ( newsk ) -> icsk_pmtu_cookie ) ; return newsk ; } treq = inet6_rsk ( req ) ; opt = np -> opt ; if ( sk_acceptq_is_full ( sk ) ) goto out_overflow ; if ( ! dst ) { dst = inet6_csk_route_req ( sk , req ) ; if ( ! dst ) goto out ; } newsk = tcp_create_openreq_child ( sk , req , skb ) ; if ( newsk == NULL ) goto out_nonewsk ; newsk -> sk_gso_type = SKB_GSO_TCPV6 ; __ip6_dst_store ( newsk , dst , NULL , NULL ) ; newtcp6sk = ( struct tcp6_sock * ) newsk ; inet_sk ( newsk ) -> pinet6 = & newtcp6sk -> inet6 ; newtp = tcp_sk ( newsk ) ; newinet = inet_sk ( newsk ) ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; ipv6_addr_copy ( & newnp -> daddr , & treq -> rmt_addr ) ; ipv6_addr_copy ( & newnp -> saddr , & treq -> loc_addr ) ; ipv6_addr_copy ( & newnp -> rcv_saddr , & treq -> loc_addr ) ; newsk -> sk_bound_dev_if = treq -> iif ; newinet -> opt = NULL ; newnp -> ipv6_fl_list = NULL ; newnp -> rxopt . all = np -> rxopt . all ; newnp -> pktoptions = NULL ; if ( treq -> pktopts != NULL ) { newnp -> pktoptions = skb_clone ( treq -> pktopts , GFP_ATOMIC ) ; kfree_skb ( treq -> pktopts ) ; treq -> pktopts = NULL ; if ( newnp -> pktoptions ) skb_set_owner_r ( newnp -> pktoptions , newsk ) ; } newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; if ( opt ) { newnp -> opt = ipv6_dup_options ( newsk , opt ) ; if ( opt != np -> opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; } inet_csk ( newsk ) -> icsk_ext_hdr_len = 0 ; if ( newnp -> opt ) inet_csk ( newsk ) -> icsk_ext_hdr_len = ( newnp -> opt -> opt_nflen + newnp -> opt -> opt_flen ) ; tcp_mtup_init ( newsk ) ; tcp_sync_mss ( newsk , dst_mtu ( dst ) ) ; newtp -> advmss = dst_metric_advmss ( dst ) ; tcp_initialize_rcv_mss ( newsk ) ; newinet -> inet_daddr = newinet -> inet_saddr = LOOPBACK4_IPV6 ; newinet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; # ifdef CONFIG_TCP_MD5SIG if ( ( key = tcp_v6_md5_do_lookup ( sk , & newnp -> daddr ) ) != NULL ) { char * newkey = kmemdup ( key -> key , key -> keylen , GFP_ATOMIC ) ; if ( newkey != NULL ) tcp_v6_md5_do_add ( newsk , & newnp -> daddr , newkey , key -> keylen ) ; } # endif if ( __inet_inherit_port ( sk , newsk ) < 0 ) { sock_put ( newsk ) ; goto out ; } __inet6_hash ( newsk , NULL ) ; return newsk ; out_overflow : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENOVERFLOWS ) ; out_nonewsk : if ( opt && opt != np -> opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; dst_release ( dst ) ; out : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENDROPS ) ; return NULL ; }\n", "\n", "1: CWE-362 static struct sock * dccp_v6_request_recv_sock ( struct sock * sk , struct sk_buff * skb , struct request_sock * req , struct dst_entry * dst ) { struct inet6_request_sock * ireq6 = inet6_rsk ( req ) ; struct ipv6_pinfo * newnp , * np = inet6_sk ( sk ) ; struct inet_sock * newinet ; struct dccp6_sock * newdp6 ; struct sock * newsk ; struct ipv6_txoptions * opt ; if ( skb -> protocol == htons ( ETH_P_IP ) ) { newsk = dccp_v4_request_recv_sock ( sk , skb , req , dst ) ; if ( newsk == NULL ) return NULL ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; ipv6_addr_set_v4mapped ( newinet -> inet_daddr , & newnp -> daddr ) ; ipv6_addr_set_v4mapped ( newinet -> inet_saddr , & newnp -> saddr ) ; ipv6_addr_copy ( & newnp -> rcv_saddr , & newnp -> saddr ) ; inet_csk ( newsk ) -> icsk_af_ops = & dccp_ipv6_mapped ; newsk -> sk_backlog_rcv = dccp_v4_do_rcv ; newnp -> pktoptions = NULL ; newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; dccp_sync_mss ( newsk , inet_csk ( newsk ) -> icsk_pmtu_cookie ) ; return newsk ; } opt = np -> opt ; if ( sk_acceptq_is_full ( sk ) ) goto out_overflow ; if ( dst == NULL ) { struct in6_addr * final_p , final ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_DCCP ; ipv6_addr_copy ( & fl6 . daddr , & ireq6 -> rmt_addr ) ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; ipv6_addr_copy ( & fl6 . saddr , & ireq6 -> loc_addr ) ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . fl6_dport = inet_rsk ( req ) -> rmt_port ; fl6 . fl6_sport = inet_rsk ( req ) -> loc_port ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p , false ) ; if ( IS_ERR ( dst ) ) goto out ; } newsk = dccp_create_openreq_child ( sk , req , skb ) ; if ( newsk == NULL ) goto out_nonewsk ; __ip6_dst_store ( newsk , dst , NULL , NULL ) ; newsk -> sk_route_caps = dst -> dev -> features & ~ ( NETIF_F_IP_CSUM | NETIF_F_TSO ) ; newdp6 = ( struct dccp6_sock * ) newsk ; newinet = inet_sk ( newsk ) ; newinet -> pinet6 = & newdp6 -> inet6 ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; ipv6_addr_copy ( & newnp -> daddr , & ireq6 -> rmt_addr ) ; ipv6_addr_copy ( & newnp -> saddr , & ireq6 -> loc_addr ) ; ipv6_addr_copy ( & newnp -> rcv_saddr , & ireq6 -> loc_addr ) ; newsk -> sk_bound_dev_if = ireq6 -> iif ; newinet -> opt = NULL ; newnp -> rxopt . all = np -> rxopt . all ; newnp -> pktoptions = NULL ; if ( ireq6 -> pktopts != NULL ) { newnp -> pktoptions = skb_clone ( ireq6 -> pktopts , GFP_ATOMIC ) ; kfree_skb ( ireq6 -> pktopts ) ; ireq6 -> pktopts = NULL ; if ( newnp -> pktoptions ) skb_set_owner_r ( newnp -> pktoptions , newsk ) ; } newnp -> opt = NULL ; newnp -> mcast_oif = inet6_iif ( skb ) ; newnp -> mcast_hops = ipv6_hdr ( skb ) -> hop_limit ; if ( opt != NULL ) { newnp -> opt = ipv6_dup_options ( newsk , opt ) ; if ( opt != np -> opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; } inet_csk ( newsk ) -> icsk_ext_hdr_len = 0 ; if ( newnp -> opt != NULL ) inet_csk ( newsk ) -> icsk_ext_hdr_len = ( newnp -> opt -> opt_nflen + newnp -> opt -> opt_flen ) ; dccp_sync_mss ( newsk , dst_mtu ( dst ) ) ; newinet -> inet_daddr = newinet -> inet_saddr = LOOPBACK4_IPV6 ; newinet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( __inet_inherit_port ( sk , newsk ) < 0 ) { sock_put ( newsk ) ; goto out ; } __inet6_hash ( newsk , NULL ) ; return newsk ; out_overflow : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENOVERFLOWS ) ; out_nonewsk : dst_release ( dst ) ; out : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENDROPS ) ; if ( opt != NULL && opt != np -> opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; return NULL ; }\n", "\n", "\n", "Target: return 0 ; if ( ! xdr_argsize_check ( rqstp , p ) ) return 0 ; ) ; return 1 ; } \n", "\n", "Sources:\n", "0: CWE-404 int nfssvc_decode_readlinkargs ( struct svc_rqst * rqstp , __be32 * p , struct nfsd_readlinkargs * args ) { p = decode_fh ( p , & args -> fh ) ; if ( ! p ) return 0 ; args -> buffer = page_address ( * ( rqstp -> rq_next_page ++ ) ) ; return xdr_argsize_check ( rqstp , p ) ; }\n", "\n", "1: CWE-404 int nfs3svc_decode_readlinkargs ( struct svc_rqst * rqstp , __be32 * p , struct nfsd3_readlinkargs * args ) { p = decode_fh ( p , & args -> fh ) ; if ( ! p ) return 0 ; args -> buffer = page_address ( * ( rqstp -> rq_next_page ++ ) ) ; return xdr_argsize_check ( rqstp , p ) ; }\n", "\n", "\n", "Target: ; if ( unlikely ( headcount > UIO_MAXIOV ) ) { msg . msg_iovlen . msg_iovlen = 1 ; err = & msg , 1 , MSG_DONTWAIT | MSG_TRUNC ) ; pr_debug ( \"Discardedrxpacket:len%zd\\\\n\" , sock_len ) ; continue ; } if ( ! headcount ) { if ( unlikely ( vhost_enable_notify ( & net -> dev , vq ) ) ) { vhost_disable_notify ( & net -> dev , vq ) ; continue ; } break ; } if ( unlikely ( ( vhost_hlen ) ) ) move_iovec_hdr ( vq -> iov , nvq -> hdr , vhost_hlen , in ) ; else copy_iovec_hdr ( vq -> iov , nvq -> hdr , sock_hlen , in ) ; msg . msg_iovlen = in ; err = sock -> ops -> recvmsg ( NULL , sock , & msg , sock_len , MSG_DONTWAIT | MSG_TRUNC ) ;\n", "\n", "Sources:\n", "0: CWE-787 static void handle_rx ( struct vhost_net * net ) { struct vhost_net_virtqueue * nvq = & net -> vqs [ VHOST_NET_VQ_RX ] ; struct vhost_virtqueue * vq = & nvq -> vq ; unsigned uninitialized_var ( in ) , log ; struct vhost_log * vq_log ; struct msghdr msg = { . msg_name = NULL , . msg_namelen = 0 , . msg_control = NULL , . msg_controllen = 0 , . msg_iov = vq -> iov , . msg_flags = MSG_DONTWAIT , } ; struct virtio_net_hdr_mrg_rxbuf hdr = { . hdr . flags = 0 , . hdr . gso_type = VIRTIO_NET_HDR_GSO_NONE } ; size_t total_len = 0 ; int err , mergeable ; s16 headcount ; size_t vhost_hlen , sock_hlen ; size_t vhost_len , sock_len ; struct socket * sock ; mutex_lock ( & vq -> mutex ) ; sock = vq -> private_data ; if ( ! sock ) goto out ; vhost_disable_notify ( & net -> dev , vq ) ; vhost_hlen = nvq -> vhost_hlen ; sock_hlen = nvq -> sock_hlen ; vq_log = unlikely ( vhost_has_feature ( & net -> dev , VHOST_F_LOG_ALL ) ) ? vq -> log : NULL ; mergeable = vhost_has_feature ( & net -> dev , VIRTIO_NET_F_MRG_RXBUF ) ; while ( ( sock_len = peek_head_len ( sock -> sk ) ) ) { sock_len += sock_hlen ; vhost_len = sock_len + vhost_hlen ; headcount = get_rx_bufs ( vq , vq -> heads , vhost_len , & in , vq_log , & log , likely ( mergeable ) ? UIO_MAXIOV : 1 ) ; if ( unlikely ( headcount < 0 ) ) break ; if ( ! headcount ) { if ( unlikely ( vhost_enable_notify ( & net -> dev , vq ) ) ) { vhost_disable_notify ( & net -> dev , vq ) ; continue ; } break ; } if ( unlikely ( ( vhost_hlen ) ) ) move_iovec_hdr ( vq -> iov , nvq -> hdr , vhost_hlen , in ) ; else copy_iovec_hdr ( vq -> iov , nvq -> hdr , sock_hlen , in ) ; msg . msg_iovlen = in ; err = sock -> ops -> recvmsg ( NULL , sock , & msg , sock_len , MSG_DONTWAIT | MSG_TRUNC ) ; if ( unlikely ( err != sock_len ) ) { pr_debug ( \"Discardedrxpacket:\" \"len%d,expected%zd\\\\n\" , err , sock_len ) ; vhost_discard_vq_desc ( vq , headcount ) ; continue ; } if ( unlikely ( vhost_hlen ) && memcpy_toiovecend ( nvq -> hdr , ( unsigned char * ) & hdr , 0 , vhost_hlen ) ) { vq_err ( vq , \"Unabletowritevnet_hdrataddr%p\\\\n\" , vq -> iov -> iov_base ) ; break ; } if ( likely ( mergeable ) && memcpy_toiovecend ( nvq -> hdr , ( unsigned char * ) & headcount , offsetof ( typeof ( hdr ) , num_buffers ) , sizeof hdr . num_buffers ) ) { vq_err ( vq , \"Failednum_bufferswrite\" ) ; vhost_discard_vq_desc ( vq , headcount ) ; break ; } vhost_add_used_and_signal_n ( & net -> dev , vq , vq -> heads , headcount ) ; if ( unlikely ( vq_log ) ) vhost_log_write ( vq , vq_log , log , vhost_len ) ; total_len += vhost_len ; if ( unlikely ( total_len >= VHOST_NET_WEIGHT ) ) { vhost_poll_queue ( & vq -> poll ) ; break ; } } out : mutex_unlock ( & vq -> mutex ) ; }\n", "\n", "1: CWE-20 static void handle_rx ( struct vhost_net * net ) { struct vhost_net_virtqueue * nvq = & net -> vqs [ VHOST_NET_VQ_RX ] ; struct vhost_virtqueue * vq = & nvq -> vq ; unsigned uninitialized_var ( in ) , log ; struct vhost_log * vq_log ; struct msghdr msg = { . msg_name = NULL , . msg_namelen = 0 , . msg_control = NULL , . msg_controllen = 0 , . msg_iov = vq -> iov , . msg_flags = MSG_DONTWAIT , } ; struct virtio_net_hdr_mrg_rxbuf hdr = { . hdr . flags = 0 , . hdr . gso_type = VIRTIO_NET_HDR_GSO_NONE } ; size_t total_len = 0 ; int err , mergeable ; s16 headcount ; size_t vhost_hlen , sock_hlen ; size_t vhost_len , sock_len ; struct socket * sock ; mutex_lock ( & vq -> mutex ) ; sock = vq -> private_data ; if ( ! sock ) goto out ; vhost_disable_notify ( & net -> dev , vq ) ; vhost_hlen = nvq -> vhost_hlen ; sock_hlen = nvq -> sock_hlen ; vq_log = unlikely ( vhost_has_feature ( & net -> dev , VHOST_F_LOG_ALL ) ) ? vq -> log : NULL ; mergeable = vhost_has_feature ( & net -> dev , VIRTIO_NET_F_MRG_RXBUF ) ; while ( ( sock_len = peek_head_len ( sock -> sk ) ) ) { sock_len += sock_hlen ; vhost_len = sock_len + vhost_hlen ; headcount = get_rx_bufs ( vq , vq -> heads , vhost_len , & in , vq_log , & log , likely ( mergeable ) ? UIO_MAXIOV : 1 ) ; if ( unlikely ( headcount < 0 ) ) break ; if ( ! headcount ) { if ( unlikely ( vhost_enable_notify ( & net -> dev , vq ) ) ) { vhost_disable_notify ( & net -> dev , vq ) ; continue ; } break ; } if ( unlikely ( ( vhost_hlen ) ) ) move_iovec_hdr ( vq -> iov , nvq -> hdr , vhost_hlen , in ) ; else copy_iovec_hdr ( vq -> iov , nvq -> hdr , sock_hlen , in ) ; msg . msg_iovlen = in ; err = sock -> ops -> recvmsg ( NULL , sock , & msg , sock_len , MSG_DONTWAIT | MSG_TRUNC ) ; if ( unlikely ( err != sock_len ) ) { pr_debug ( \"Discardedrxpacket:\" \"len%d,expected%zd\\\\n\" , err , sock_len ) ; vhost_discard_vq_desc ( vq , headcount ) ; continue ; } if ( unlikely ( vhost_hlen ) && memcpy_toiovecend ( nvq -> hdr , ( unsigned char * ) & hdr , 0 , vhost_hlen ) ) { vq_err ( vq , \"Unabletowritevnet_hdrataddr%p\\\\n\" , vq -> iov -> iov_base ) ; break ; } if ( likely ( mergeable ) && memcpy_toiovecend ( nvq -> hdr , ( unsigned char * ) & headcount , offsetof ( typeof ( hdr ) , num_buffers ) , sizeof hdr . num_buffers ) ) { vq_err ( vq , \"Failednum_bufferswrite\" ) ; vhost_discard_vq_desc ( vq , headcount ) ; break ; } vhost_add_used_and_signal_n ( & net -> dev , vq , vq -> heads , headcount ) ; if ( unlikely ( vq_log ) ) vhost_log_write ( vq , vq_log , log , vhost_len ) ; total_len += vhost_len ; if ( unlikely ( total_len >= VHOST_NET_WEIGHT ) ) { vhost_poll_queue ( & vq -> poll ) ; break ; } } out : mutex_unlock ( & vq -> mutex ) ; }\n", "\n", "\n", "Target: * y ; jas_matind_t i ; jas_matind_t j ; y\n", "\n", "Sources:\n", "0: CWE-190 jas_seq2d_t * jas_seq2d_copy ( jas_seq2d_t * x ) { jas_matrix_t * y ; int i ; int j ; y = jas_seq2d_create ( jas_seq2d_xstart ( x ) , jas_seq2d_ystart ( x ) , jas_seq2d_xend ( x ) , jas_seq2d_yend ( x ) ) ; assert ( y ) ; for ( i = 0 ; i < x -> numrows_ ; ++ i ) { for ( j = 0 ; j < x -> numcols_ ; ++ j ) { * jas_matrix_getref ( y , i , j ) = jas_matrix_get ( x , i , j ) ; } } return y ; }\n", "\n", "1: CWE-190 jas_matrix_t * jas_matrix_copy ( jas_matrix_t * x ) { jas_matrix_t * y ; int i ; int j ; y = jas_matrix_create ( x -> numrows_ , x -> numcols_ ) ; for ( i = 0 ; i < x -> numrows_ ; ++ i ) { for ( j = 0 ; j < x -> numcols_ ; ++ j ) { * jas_matrix_getref ( y , i , j ) = jas_matrix_get ( x , i , j ) ; } } return y ; }\n", "\n", "\n", "Target: ; if ( * cp == '\\\\0' || strchr ( cp ) != NULL || strcmp ( cp ( cp , \".\" ) == 0 || strcmp ( cp , ) == 0 ) { run_err\n", "\n", "Sources:\n", "0: CWE-000 void sink ( int argc , char * * argv ) { static BUF buffer ; struct stat stb ; enum { YES , NO , DISPLAYED } wrerr ; BUF * bp ; off_t i ; size_t j , count ; int amt , exists , first , mask , mode , ofd , omode ; off_t size , statbytes ; int setimes , targisdir , wrerrno = 0 ; char ch , * cp , * np , * targ , * why , * vect [ 1 ] , buf [ 2048 ] ; struct timeval tv [ 2 ] ; # define atime tv [ 0 ] # define mtime tv [ 1 ] # define SCREWUP ( str ) do { why = str ; goto screwup ; } while ( 0 ) setimes = targisdir = 0 ; mask = umask ( 0 ) ; if ( ! pflag ) ( void ) umask ( mask ) ; if ( argc != 1 ) { run_err ( \"ambiguoustarget\" ) ; exit ( 1 ) ; } targ = * argv ; if ( targetshouldbedirectory ) verifydir ( targ ) ; ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; if ( stat ( targ , & stb ) == 0 && S_ISDIR ( stb . st_mode ) ) targisdir = 1 ; for ( first = 1 ; ; first = 0 ) { cp = buf ; if ( atomicio ( read , remin , cp , 1 ) != 1 ) return ; if ( * cp ++ == '\\\\n' ) SCREWUP ( \"unexpected\" ) ; do { if ( atomicio ( read , remin , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) SCREWUP ( \"lostconnection\" ) ; * cp ++ = ch ; } while ( cp < & buf [ sizeof ( buf ) - 1 ] && ch != '\\\\n' ) ; * cp = 0 ; if ( verbose_mode ) fprintf ( stderr , \"Sink:%s\" , buf ) ; if ( buf [ 0 ] == '\\\\01' || buf [ 0 ] == '\\\\02' ) { if ( iamremote == 0 ) ( void ) atomicio ( vwrite , STDERR_FILENO , buf + 1 , strlen ( buf + 1 ) ) ; if ( buf [ 0 ] == '\\\\02' ) exit ( 1 ) ; ++ errs ; continue ; } if ( buf [ 0 ] == 'E' ) { ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; return ; } if ( ch == '\\\\n' ) * -- cp = 0 ; cp = buf ; if ( * cp == 'T' ) { setimes ++ ; cp ++ ; mtime . tv_sec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"mtime.secnotdelimited\" ) ; mtime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"mtime.usecnotdelimited\" ) ; atime . tv_sec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"atime.secnotdelimited\" ) ; atime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '\\\\0' ) SCREWUP ( \"atime.usecnotdelimited\" ) ; ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; continue ; } if ( * cp != 'C' && * cp != 'D' ) { if ( first ) { run_err ( \"%s\" , cp ) ; exit ( 1 ) ; } SCREWUP ( \"expectedcontrolrecord\" ) ; } mode = 0 ; for ( ++ cp ; cp < buf + 5 ; cp ++ ) { if ( * cp < '0' || * cp > '7' ) SCREWUP ( \"badmode\" ) ; mode = ( mode << 3 ) | ( * cp - '0' ) ; } if ( * cp ++ != '' ) SCREWUP ( \"modenotdelimited\" ) ; for ( size = 0 ; isdigit ( * cp ) ; ) size = size * 10 + ( * cp ++ - '0' ) ; if ( * cp ++ != '' ) SCREWUP ( \"sizenotdelimited\" ) ; if ( ( strchr ( cp , '/' ) != NULL ) || ( strcmp ( cp , \"..\" ) == 0 ) ) { run_err ( \"error:unexpectedfilename:%s\" , cp ) ; exit ( 1 ) ; } if ( targisdir ) { static char * namebuf = NULL ; static size_t cursize = 0 ; size_t need ; need = strlen ( targ ) + strlen ( cp ) + 250 ; if ( need > cursize ) { if ( namebuf ) xfree ( namebuf ) ; namebuf = xmalloc ( need ) ; cursize = need ; } ( void ) snprintf ( namebuf , need , \"%s%s%s\" , targ , strcmp ( targ , \"/\" ) ? \"/\" : \"\" , cp ) ; np = namebuf ; } else np = targ ; curfile = cp ; exists = stat ( np , & stb ) == 0 ; if ( buf [ 0 ] == 'D' ) { int mod_flag = pflag ; if ( ! iamrecursive ) SCREWUP ( \"receiveddirectorywithout-r\" ) ; if ( exists ) { if ( ! S_ISDIR ( stb . st_mode ) ) { errno = ENOTDIR ; goto bad ; } if ( pflag ) ( void ) chmod ( np , mode ) ; } else { mod_flag = 1 ; if ( mkdir ( np , mode | S_IRWXU ) < 0 ) goto bad ; } vect [ 0 ] = xstrdup ( np ) ; sink ( 1 , vect ) ; if ( setimes ) { setimes = 0 ; if ( utimes ( vect [ 0 ] , tv ) < 0 ) run_err ( \"%s:settimes:%s\" , vect [ 0 ] , strerror ( errno ) ) ; } if ( mod_flag ) ( void ) chmod ( vect [ 0 ] , mode ) ; if ( vect [ 0 ] ) xfree ( vect [ 0 ] ) ; continue ; } omode = mode ; mode |= S_IWUSR ; if ( ( ofd = open ( np , O_WRONLY | O_CREAT , mode ) ) < 0 ) { bad : run_err ( \"%s:%s\" , np , strerror ( errno ) ) ; continue ; } ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; if ( ( bp = allocbuf ( & buffer , ofd , 4096 ) ) == NULL ) { ( void ) close ( ofd ) ; continue ; } cp = bp -> buf ; wrerr = NO ; statbytes = 0 ; # ifdef PROGRESS_METER if ( showprogress ) start_progress_meter ( curfile , size , & statbytes ) ; # endif for ( count = i = 0 ; i < size ; i += 4096 ) { amt = 4096 ; if ( i + amt > size ) amt = size - i ; count += amt ; do { j = atomicio ( read , remin , cp , amt ) ; if ( j == 0 ) { run_err ( \"%s\" , j ? strerror ( errno ) : \"droppedconnection\" ) ; exit ( 1 ) ; } amt -= j ; cp += j ; statbytes += j ; } while ( amt > 0 ) ; if ( limit_rate ) bwlimit ( 4096 ) ; if ( count == bp -> cnt ) { if ( wrerr == NO ) { if ( atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } } count = 0 ; cp = bp -> buf ; } } # ifdef PROGRESS_METER if ( showprogress ) stop_progress_meter ( ) ; # endif if ( count != 0 && wrerr == NO && atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } if ( wrerr == NO && ftruncate ( ofd , size ) != 0 ) { run_err ( \"%s:truncate:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } if ( pflag ) { if ( exists || omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode ) ) { # else if ( chmod ( np , omode ) ) { # endif run_err ( \"%s:setmode:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } else { if ( ! exists && omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode & ~ mask ) ) { # else if ( chmod ( np , omode & ~ mask ) ) { # endif run_err ( \"%s:setmode:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } if ( close ( ofd ) == - 1 ) { wrerr = YES ; wrerrno = errno ; } ( void ) response ( ) ; if ( setimes && wrerr == NO ) { setimes = 0 ; if ( utimes ( np , tv ) < 0 ) { run_err ( \"%s:settimes:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } switch ( wrerr ) { case YES : run_err ( \"%s:%s\" , np , strerror ( wrerrno ) ) ; break ; case NO : ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; break ; case DISPLAYED : break ; } } screwup : run_err ( \"protocolerror:%s\" , why ) ; exit ( 1 ) ; }\n", "\n", "1: CWE-863 void sink ( int argc , char * * argv ) { static BUF buffer ; struct stat stb ; enum { YES , NO , DISPLAYED } wrerr ; BUF * bp ; off_t i ; size_t j , count ; int amt , exists , first , ofd ; mode_t mode , omode , mask ; off_t size , statbytes ; unsigned long long ull ; int setimes , targisdir , wrerrno = 0 ; char ch , * cp , * np , * targ , * why , * vect [ 1 ] , buf [ 2048 ] , visbuf [ 2048 ] ; struct timeval tv [ 2 ] ; # define atime tv [ 0 ] # define mtime tv [ 1 ] # define SCREWUP ( str ) { why = str ; goto screwup ; } if ( TYPE_OVERFLOW ( time_t , 0 ) || TYPE_OVERFLOW ( off_t , 0 ) ) SCREWUP ( \"Unexpectedoff_t/time_tsize\" ) ; setimes = targisdir = 0 ; mask = umask ( 0 ) ; if ( ! pflag ) ( void ) umask ( mask ) ; if ( argc != 1 ) { run_err ( \"ambiguoustarget\" ) ; exit ( 1 ) ; } targ = * argv ; if ( targetshouldbedirectory ) verifydir ( targ ) ; ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; if ( stat ( targ , & stb ) == 0 && S_ISDIR ( stb . st_mode ) ) targisdir = 1 ; for ( first = 1 ; ; first = 0 ) { cp = buf ; if ( atomicio ( read , remin , cp , 1 ) != 1 ) return ; if ( * cp ++ == '\\\\n' ) SCREWUP ( \"unexpected\" ) ; do { if ( atomicio ( read , remin , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) SCREWUP ( \"lostconnection\" ) ; * cp ++ = ch ; } while ( cp < & buf [ sizeof ( buf ) - 1 ] && ch != '\\\\n' ) ; * cp = 0 ; if ( verbose_mode ) fmprintf ( stderr , \"Sink:%s\" , buf ) ; if ( buf [ 0 ] == '\\\\01' || buf [ 0 ] == '\\\\02' ) { if ( iamremote == 0 ) { ( void ) snmprintf ( visbuf , sizeof ( visbuf ) , NULL , \"%s\" , buf + 1 ) ; ( void ) atomicio ( vwrite , STDERR_FILENO , visbuf , strlen ( visbuf ) ) ; } if ( buf [ 0 ] == '\\\\02' ) exit ( 1 ) ; ++ errs ; continue ; } if ( buf [ 0 ] == 'E' ) { ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; return ; } if ( ch == '\\\\n' ) * -- cp = 0 ; cp = buf ; if ( * cp == 'T' ) { setimes ++ ; cp ++ ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( \"mtime.secnotpresent\" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"mtime.secnotdelimited\" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; mtime . tv_sec = ull ; mtime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' || mtime . tv_usec < 0 || mtime . tv_usec > 999999 ) SCREWUP ( \"mtime.usecnotdelimited\" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( \"atime.secnotpresent\" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"atime.secnotdelimited\" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; atime . tv_sec = ull ; atime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '\\\\0' || atime . tv_usec < 0 || atime . tv_usec > 999999 ) SCREWUP ( \"atime.usecnotdelimited\" ) ; ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; continue ; } if ( * cp != 'C' && * cp != 'D' ) { if ( first ) { run_err ( \"%s\" , cp ) ; exit ( 1 ) ; } SCREWUP ( \"expectedcontrolrecord\" ) ; } mode = 0 ; for ( ++ cp ; cp < buf + 5 ; cp ++ ) { if ( * cp < '0' || * cp > '7' ) SCREWUP ( \"badmode\" ) ; mode = ( mode << 3 ) | ( * cp - '0' ) ; } if ( ! pflag ) mode &= ~ mask ; if ( * cp ++ != '' ) SCREWUP ( \"modenotdelimited\" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( \"sizenotpresent\" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( \"sizenotdelimited\" ) ; if ( TYPE_OVERFLOW ( off_t , ull ) ) SCREWUP ( \"sizeoutofrange\" ) ; size = ( off_t ) ull ; if ( ( strchr ( cp , '/' ) != NULL ) || ( strcmp ( cp , \"..\" ) == 0 ) ) { run_err ( \"error:unexpectedfilename:%s\" , cp ) ; exit ( 1 ) ; } if ( targisdir ) { static char * namebuf ; static size_t cursize ; size_t need ; need = strlen ( targ ) + strlen ( cp ) + 250 ; if ( need > cursize ) { free ( namebuf ) ; namebuf = xmalloc ( need ) ; cursize = need ; } ( void ) snprintf ( namebuf , need , \"%s%s%s\" , targ , strcmp ( targ , \"/\" ) ? \"/\" : \"\" , cp ) ; np = namebuf ; } else np = targ ; curfile = cp ; exists = stat ( np , & stb ) == 0 ; if ( buf [ 0 ] == 'D' ) { int mod_flag = pflag ; if ( ! iamrecursive ) SCREWUP ( \"receiveddirectorywithout-r\" ) ; if ( exists ) { if ( ! S_ISDIR ( stb . st_mode ) ) { errno = ENOTDIR ; goto bad ; } if ( pflag ) ( void ) chmod ( np , mode ) ; } else { mod_flag = 1 ; if ( mkdir ( np , mode | S_IRWXU ) < 0 ) goto bad ; } vect [ 0 ] = xstrdup ( np ) ; sink ( 1 , vect ) ; if ( setimes ) { setimes = 0 ; if ( utimes ( vect [ 0 ] , tv ) < 0 ) run_err ( \"%s:settimes:%s\" , vect [ 0 ] , strerror ( errno ) ) ; } if ( mod_flag ) ( void ) chmod ( vect [ 0 ] , mode ) ; free ( vect [ 0 ] ) ; continue ; } omode = mode ; mode |= S_IWUSR ; if ( ( ofd = open ( np , O_WRONLY | O_CREAT , mode ) ) < 0 ) { bad : run_err ( \"%s:%s\" , np , strerror ( errno ) ) ; continue ; } ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; if ( ( bp = allocbuf ( & buffer , ofd , COPY_BUFLEN ) ) == NULL ) { ( void ) close ( ofd ) ; continue ; } cp = bp -> buf ; wrerr = NO ; statbytes = 0 ; if ( showprogress ) start_progress_meter ( curfile , size , & statbytes ) ; set_nonblock ( remin ) ; for ( count = i = 0 ; i < size ; i += bp -> cnt ) { amt = bp -> cnt ; if ( i + amt > size ) amt = size - i ; count += amt ; do { j = atomicio6 ( read , remin , cp , amt , scpio , & statbytes ) ; if ( j == 0 ) { run_err ( \"%s\" , j != EPIPE ? strerror ( errno ) : \"droppedconnection\" ) ; exit ( 1 ) ; } amt -= j ; cp += j ; } while ( amt > 0 ) ; if ( count == bp -> cnt ) { if ( wrerr == NO ) { if ( atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } } count = 0 ; cp = bp -> buf ; } } unset_nonblock ( remin ) ; if ( count != 0 && wrerr == NO && atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } if ( wrerr == NO && ( ! exists || S_ISREG ( stb . st_mode ) ) && ftruncate ( ofd , size ) != 0 ) { run_err ( \"%s:truncate:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } if ( pflag ) { if ( exists || omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode ) ) { # else if ( chmod ( np , omode ) ) { # endif run_err ( \"%s:setmode:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } else { if ( ! exists && omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode & ~ mask ) ) { # else if ( chmod ( np , omode & ~ mask ) ) { # endif run_err ( \"%s:setmode:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } if ( close ( ofd ) == - 1 ) { wrerr = YES ; wrerrno = errno ; } ( void ) response ( ) ; if ( showprogress ) stop_progress_meter ( ) ; if ( setimes && wrerr == NO ) { setimes = 0 ; if ( utimes ( np , tv ) < 0 ) { run_err ( \"%s:settimes:%s\" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } switch ( wrerr ) { case YES : run_err ( \"%s:%s\" , np , strerror ( wrerrno ) ) ; break ; case NO : ( void ) atomicio ( vwrite , remout , \"\" , 1 ) ; break ; case DISPLAYED : break ; } } screwup : run_err ( \"protocolerror:%s\" , why ) ; exit ( 1 ) ; }\n", "\n", "\n", "Target: ) ) ; rcu_read_lock ( ) ; -> opt : rcu_dereference ( np -> opt ) , & final ) ; rcu_read_unlock (\n", "\n", "Sources:\n", "0: CWE-264 static int __ip6_datagram_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * daddr , * final_p , final ; struct dst_entry * dst ; struct flowi6 fl6 ; struct ip6_flowlabel * flowlabel = NULL ; struct ipv6_txoptions * opt ; int addr_type ; int err ; if ( usin -> sin6_family == AF_INET ) { if ( __ipv6_only_sock ( sk ) ) return - EAFNOSUPPORT ; err = __ip4_datagram_connect ( sk , uaddr , addr_len ) ; goto ipv4_connected ; } if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( ! flowlabel ) return - EINVAL ; } } addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type == IPV6_ADDR_ANY ) { usin -> sin6_addr . s6_addr [ 15 ] = 0x01 ; } daddr = & usin -> sin6_addr ; if ( addr_type == IPV6_ADDR_MAPPED ) { struct sockaddr_in sin ; if ( __ipv6_only_sock ( sk ) ) { err = - ENETUNREACH ; goto out ; } sin . sin_family = AF_INET ; sin . sin_addr . s_addr = daddr -> s6_addr32 [ 3 ] ; sin . sin_port = usin -> sin6_port ; err = __ip4_datagram_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; ipv4_connected : if ( err ) goto out ; ipv6_addr_set_v4mapped ( inet -> inet_daddr , & sk -> sk_v6_daddr ) ; if ( ipv6_addr_any ( & np -> saddr ) || ipv6_mapped_addr_any ( & np -> saddr ) ) ipv6_addr_set_v4mapped ( inet -> inet_saddr , & np -> saddr ) ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) || ipv6_mapped_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { ipv6_addr_set_v4mapped ( inet -> inet_rcv_saddr , & sk -> sk_v6_rcv_saddr ) ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } goto out ; } if ( __ipv6_addr_needs_scope_id ( addr_type ) ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) { err = - EINVAL ; goto out ; } sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if && ( addr_type & IPV6_ADDR_MULTICAST ) ) sk -> sk_bound_dev_if = np -> mcast_oif ; if ( ! sk -> sk_bound_dev_if ) { err = - EINVAL ; goto out ; } } sk -> sk_v6_daddr = * daddr ; np -> flow_label = fl6 . flowlabel ; inet -> inet_dport = usin -> sin6_port ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = np -> saddr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = sk -> sk_mark ; fl6 . fl6_dport = inet -> inet_dport ; fl6 . fl6_sport = inet -> inet_sport ; if ( ! fl6 . flowi6_oif && ( addr_type & IPV6_ADDR_MULTICAST ) ) fl6 . flowi6_oif = np -> mcast_oif ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; opt = flowlabel ? flowlabel -> opt : np -> opt ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; err = 0 ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto out ; } if ( ipv6_addr_any ( & np -> saddr ) ) np -> saddr = fl6 . saddr ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { sk -> sk_v6_rcv_saddr = fl6 . saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } ip6_dst_store ( sk , dst , ipv6_addr_equal ( & fl6 . daddr , & sk -> sk_v6_daddr ) ? & sk -> sk_v6_daddr : NULL , # ifdef CONFIG_IPV6_SUBTREES ipv6_addr_equal ( & fl6 . saddr , & np -> saddr ) ? & np -> saddr : # endif NULL ) ; sk -> sk_state = TCP_ESTABLISHED ; sk_set_txhash ( sk ) ; out : fl6_sock_release ( flowlabel ) ; return err ; }\n", "\n", "1: CWE-416 static int __ip6_datagram_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * daddr , * final_p , final ; struct dst_entry * dst ; struct flowi6 fl6 ; struct ip6_flowlabel * flowlabel = NULL ; struct ipv6_txoptions * opt ; int addr_type ; int err ; if ( usin -> sin6_family == AF_INET ) { if ( __ipv6_only_sock ( sk ) ) return - EAFNOSUPPORT ; err = __ip4_datagram_connect ( sk , uaddr , addr_len ) ; goto ipv4_connected ; } if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( ! flowlabel ) return - EINVAL ; } } addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type == IPV6_ADDR_ANY ) { usin -> sin6_addr . s6_addr [ 15 ] = 0x01 ; } daddr = & usin -> sin6_addr ; if ( addr_type == IPV6_ADDR_MAPPED ) { struct sockaddr_in sin ; if ( __ipv6_only_sock ( sk ) ) { err = - ENETUNREACH ; goto out ; } sin . sin_family = AF_INET ; sin . sin_addr . s_addr = daddr -> s6_addr32 [ 3 ] ; sin . sin_port = usin -> sin6_port ; err = __ip4_datagram_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; ipv4_connected : if ( err ) goto out ; ipv6_addr_set_v4mapped ( inet -> inet_daddr , & sk -> sk_v6_daddr ) ; if ( ipv6_addr_any ( & np -> saddr ) || ipv6_mapped_addr_any ( & np -> saddr ) ) ipv6_addr_set_v4mapped ( inet -> inet_saddr , & np -> saddr ) ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) || ipv6_mapped_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { ipv6_addr_set_v4mapped ( inet -> inet_rcv_saddr , & sk -> sk_v6_rcv_saddr ) ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } goto out ; } if ( __ipv6_addr_needs_scope_id ( addr_type ) ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) { err = - EINVAL ; goto out ; } sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if && ( addr_type & IPV6_ADDR_MULTICAST ) ) sk -> sk_bound_dev_if = np -> mcast_oif ; if ( ! sk -> sk_bound_dev_if ) { err = - EINVAL ; goto out ; } } sk -> sk_v6_daddr = * daddr ; np -> flow_label = fl6 . flowlabel ; inet -> inet_dport = usin -> sin6_port ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = np -> saddr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = sk -> sk_mark ; fl6 . fl6_dport = inet -> inet_dport ; fl6 . fl6_sport = inet -> inet_sport ; if ( ! fl6 . flowi6_oif && ( addr_type & IPV6_ADDR_MULTICAST ) ) fl6 . flowi6_oif = np -> mcast_oif ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; opt = flowlabel ? flowlabel -> opt : np -> opt ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; err = 0 ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto out ; } if ( ipv6_addr_any ( & np -> saddr ) ) np -> saddr = fl6 . saddr ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { sk -> sk_v6_rcv_saddr = fl6 . saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } ip6_dst_store ( sk , dst , ipv6_addr_equal ( & fl6 . daddr , & sk -> sk_v6_daddr ) ? & sk -> sk_v6_daddr : NULL , # ifdef CONFIG_IPV6_SUBTREES ipv6_addr_equal ( & fl6 . saddr , & np -> saddr ) ? & np -> saddr : # endif NULL ) ; sk -> sk_state = TCP_ESTABLISHED ; sk_set_txhash ( sk ) ; out : fl6_sock_release ( flowlabel ) ; return err ; }\n", "\n", "\n", "Target: ImapMbox mx ; size_t len = 0 ; errstr ) ; len = mbox ) , \"%smailboxes\" , subscribe ? \"\" : \"un\" ) ; imap_quote_string ( mbox + len , sizeof ( mbox ) - len , path , true ) ; if\n", "\n", "Sources:\n", "0: CWE-77 int imap_subscribe ( char * path , bool subscribe ) { struct ImapData * idata = NULL ; char buf [ LONG_STRING ] ; char mbox [ LONG_STRING ] ; char errstr [ STRING ] ; struct Buffer err , token ; struct ImapMbox mx ; if ( ! mx_is_imap ( path ) || imap_parse_path ( path , & mx ) || ! mx . mbox ) { mutt_error ( _ ( \"Badmailboxname\" ) ) ; return - 1 ; } idata = imap_conn_find ( & ( mx . account ) , 0 ) ; if ( ! idata ) goto fail ; imap_fix_path ( idata , mx . mbox , buf , sizeof ( buf ) ) ; if ( ! * buf ) mutt_str_strfcpy ( buf , \"INBOX\" , sizeof ( buf ) ) ; if ( ImapCheckSubscribed ) { mutt_buffer_init ( & token ) ; mutt_buffer_init ( & err ) ; err . data = errstr ; err . dsize = sizeof ( errstr ) ; snprintf ( mbox , sizeof ( mbox ) , \"%smailboxes\\\\\"%s\\\\\"\" , subscribe ? \"\" : \"un\" , path ) ; if ( mutt_parse_rc_line ( mbox , & token , & err ) ) mutt_debug ( 1 , \"Erroraddingsubscribedmailbox:%s\\\\n\" , errstr ) ; FREE ( & token . data ) ; } if ( subscribe ) mutt_message ( _ ( \"Subscribingto%s...\" ) , buf ) ; else mutt_message ( _ ( \"Unsubscribingfrom%s...\" ) , buf ) ; imap_munge_mbox_name ( idata , mbox , sizeof ( mbox ) , buf ) ; snprintf ( buf , sizeof ( buf ) , \"%sSUBSCRIBE%s\" , subscribe ? \"\" : \"UN\" , mbox ) ; if ( imap_exec ( idata , buf , 0 ) < 0 ) goto fail ; imap_unmunge_mbox_name ( idata , mx . mbox ) ; if ( subscribe ) mutt_message ( _ ( \"Subscribedto%s\" ) , mx . mbox ) ; else mutt_message ( _ ( \"Unsubscribedfrom%s\" ) , mx . mbox ) ; FREE ( & mx . mbox ) ; return 0 ; fail : FREE ( & mx . mbox ) ; return - 1 ; }\n", "\n", "1: CWE-78 int imap_subscribe ( char * path , bool subscribe ) { struct ImapData * idata = NULL ; char buf [ LONG_STRING ] ; char mbox [ LONG_STRING ] ; char errstr [ STRING ] ; struct Buffer err , token ; struct ImapMbox mx ; if ( ! mx_is_imap ( path ) || imap_parse_path ( path , & mx ) || ! mx . mbox ) { mutt_error ( _ ( \"Badmailboxname\" ) ) ; return - 1 ; } idata = imap_conn_find ( & ( mx . account ) , 0 ) ; if ( ! idata ) goto fail ; imap_fix_path ( idata , mx . mbox , buf , sizeof ( buf ) ) ; if ( ! * buf ) mutt_str_strfcpy ( buf , \"INBOX\" , sizeof ( buf ) ) ; if ( ImapCheckSubscribed ) { mutt_buffer_init ( & token ) ; mutt_buffer_init ( & err ) ; err . data = errstr ; err . dsize = sizeof ( errstr ) ; snprintf ( mbox , sizeof ( mbox ) , \"%smailboxes\\\\\"%s\\\\\"\" , subscribe ? \"\" : \"un\" , path ) ; if ( mutt_parse_rc_line ( mbox , & token , & err ) ) mutt_debug ( 1 , \"Erroraddingsubscribedmailbox:%s\\\\n\" , errstr ) ; FREE ( & token . data ) ; } if ( subscribe ) mutt_message ( _ ( \"Subscribingto%s...\" ) , buf ) ; else mutt_message ( _ ( \"Unsubscribingfrom%s...\" ) , buf ) ; imap_munge_mbox_name ( idata , mbox , sizeof ( mbox ) , buf ) ; snprintf ( buf , sizeof ( buf ) , \"%sSUBSCRIBE%s\" , subscribe ? \"\" : \"UN\" , mbox ) ; if ( imap_exec ( idata , buf , 0 ) < 0 ) goto fail ; imap_unmunge_mbox_name ( idata , mx . mbox ) ; if ( subscribe ) mutt_message ( _ ( \"Subscribedto%s\" ) , mx . mbox ) ; else mutt_message ( _ ( \"Unsubscribedfrom%s\" ) , mx . mbox ) ; FREE ( & mx . mbox ) ; return 0 ; fail : FREE ( & mx . mbox ) ; return - 1 ; }\n", "\n", "\n", "Target: svbranch . len + 1\n", "\n", "Sources:\n", "0: CWE-787 int tmx_check_pretran ( sip_msg_t * msg ) { unsigned int chid ; unsigned int slotid ; int dsize ; struct via_param * vbr ; str scallid ; str scseqmet ; str scseqnum ; str sftag ; str svbranch = { NULL , 0 } ; pretran_t * it ; if ( _tmx_ptran_table == NULL ) { LM_ERR ( \"pretranhashtablenotinitializedyet\\\\n\" ) ; return - 1 ; } if ( get_route_type ( ) != REQUEST_ROUTE ) { LM_ERR ( \"invalidusage-notinrequestroute\\\\n\" ) ; return - 1 ; } if ( msg -> first_line . type != SIP_REQUEST ) { LM_ERR ( \"invalidusage-notasiprequest\\\\n\" ) ; return - 1 ; } if ( parse_headers ( msg , HDR_FROM_F | HDR_VIA1_F | HDR_CALLID_F | HDR_CSEQ_F , 0 ) < 0 ) { LM_ERR ( \"failedtoparserequiredheaders\\\\n\" ) ; return - 1 ; } if ( msg -> cseq == NULL || msg -> cseq -> parsed == NULL ) { LM_ERR ( \"failedtoparsecseqheaders\\\\n\" ) ; return - 1 ; } if ( get_cseq ( msg ) -> method_id == METHOD_ACK || get_cseq ( msg ) -> method_id == METHOD_CANCEL ) { LM_DBG ( \"nopre-transactionmanagementforACKorCANCEL\\\\n\" ) ; return - 1 ; } if ( msg -> via1 == 0 ) { LM_ERR ( \"failedtogetViaheader\\\\n\" ) ; return - 1 ; } if ( parse_from_header ( msg ) < 0 || get_from ( msg ) -> tag_value . len == 0 ) { LM_ERR ( \"failedtogetFromheader\\\\n\" ) ; return - 1 ; } if ( msg -> callid == NULL || msg -> callid -> body . s == NULL ) { LM_ERR ( \"failedtoparsecallidheaders\\\\n\" ) ; return - 1 ; } vbr = msg -> via1 -> branch ; scallid = msg -> callid -> body ; trim ( & scallid ) ; scseqmet = get_cseq ( msg ) -> method ; trim ( & scseqmet ) ; scseqnum = get_cseq ( msg ) -> number ; trim ( & scseqnum ) ; sftag = get_from ( msg ) -> tag_value ; trim ( & sftag ) ; chid = get_hash1_raw ( msg -> callid -> body . s , msg -> callid -> body . len ) ; slotid = chid & ( _tmx_ptran_size - 1 ) ; if ( unlikely ( _tmx_proc_ptran == NULL ) ) { _tmx_proc_ptran = ( pretran_t * ) shm_malloc ( sizeof ( pretran_t ) ) ; if ( _tmx_proc_ptran == NULL ) { LM_ERR ( \"notenoughmemoryforpretranstructure\\\\n\" ) ; return - 1 ; } memset ( _tmx_proc_ptran , 0 , sizeof ( pretran_t ) ) ; _tmx_proc_ptran -> pid = my_pid ( ) ; } dsize = scallid . len + scseqnum . len + scseqmet . len + sftag . len + 4 ; if ( likely ( vbr != NULL ) ) { svbranch = vbr -> value ; trim ( & svbranch ) ; dsize += svbranch . len ; } if ( dsize < 256 ) dsize = 256 ; tmx_pretran_unlink ( ) ; if ( dsize > _tmx_proc_ptran -> dbuf . len ) { if ( _tmx_proc_ptran -> dbuf . s ) shm_free ( _tmx_proc_ptran -> dbuf . s ) ; _tmx_proc_ptran -> dbuf . s = ( char * ) shm_malloc ( dsize ) ; if ( _tmx_proc_ptran -> dbuf . s == NULL ) { LM_ERR ( \"notenoughmemoryforpretrandata\\\\n\" ) ; return - 1 ; } _tmx_proc_ptran -> dbuf . len = dsize ; } _tmx_proc_ptran -> hid = chid ; _tmx_proc_ptran -> cseqmetid = ( get_cseq ( msg ) ) -> method_id ; _tmx_proc_ptran -> callid . s = _tmx_proc_ptran -> dbuf . s ; memcpy ( _tmx_proc_ptran -> callid . s , scallid . s , scallid . len ) ; _tmx_proc_ptran -> callid . len = scallid . len ; _tmx_proc_ptran -> callid . s [ _tmx_proc_ptran -> callid . len ] = '\\\\0' ; _tmx_proc_ptran -> ftag . s = _tmx_proc_ptran -> callid . s + _tmx_proc_ptran -> callid . len + 1 ; memcpy ( _tmx_proc_ptran -> ftag . s , sftag . s , sftag . len ) ; _tmx_proc_ptran -> ftag . len = sftag . len ; _tmx_proc_ptran -> ftag . s [ _tmx_proc_ptran -> ftag . len ] = '\\\\0' ; _tmx_proc_ptran -> cseqnum . s = _tmx_proc_ptran -> ftag . s + _tmx_proc_ptran -> ftag . len + 1 ; memcpy ( _tmx_proc_ptran -> cseqnum . s , scseqnum . s , scseqnum . len ) ; _tmx_proc_ptran -> cseqnum . len = scseqnum . len ; _tmx_proc_ptran -> cseqnum . s [ _tmx_proc_ptran -> cseqnum . len ] = '\\\\0' ; _tmx_proc_ptran -> cseqmet . s = _tmx_proc_ptran -> cseqnum . s + _tmx_proc_ptran -> cseqnum . len + 1 ; memcpy ( _tmx_proc_ptran -> cseqmet . s , scseqmet . s , scseqmet . len ) ; _tmx_proc_ptran -> cseqmet . len = scseqmet . len ; _tmx_proc_ptran -> cseqmet . s [ _tmx_proc_ptran -> cseqmet . len ] = '\\\\0' ; if ( likely ( vbr != NULL ) ) { _tmx_proc_ptran -> vbranch . s = _tmx_proc_ptran -> cseqmet . s + _tmx_proc_ptran -> cseqmet . len + 1 ; memcpy ( _tmx_proc_ptran -> vbranch . s , svbranch . s , svbranch . len ) ; _tmx_proc_ptran -> vbranch . len = svbranch . len ; _tmx_proc_ptran -> vbranch . s [ _tmx_proc_ptran -> vbranch . len ] = '\\\\0' ; } else { _tmx_proc_ptran -> vbranch . s = NULL ; _tmx_proc_ptran -> vbranch . len = 0 ; } lock_get ( & _tmx_ptran_table [ slotid ] . lock ) ; it = _tmx_ptran_table [ slotid ] . plist ; tmx_pretran_link_safe ( slotid ) ; for ( ; it != NULL ; it = it -> next ) { if ( _tmx_proc_ptran -> hid != it -> hid || _tmx_proc_ptran -> cseqmetid != it -> cseqmetid || _tmx_proc_ptran -> callid . len != it -> callid . len || _tmx_proc_ptran -> ftag . len != it -> ftag . len || _tmx_proc_ptran -> cseqmet . len != it -> cseqmet . len || _tmx_proc_ptran -> cseqnum . len != it -> cseqnum . len ) continue ; if ( _tmx_proc_ptran -> vbranch . s != NULL && it -> vbranch . s != NULL ) { if ( _tmx_proc_ptran -> vbranch . len != it -> vbranch . len ) continue ; if ( _tmx_proc_ptran -> vbranch . s [ it -> vbranch . len - 1 ] != it -> vbranch . s [ it -> vbranch . len - 1 ] ) continue ; if ( memcmp ( _tmx_proc_ptran -> vbranch . s , it -> vbranch . s , it -> vbranch . len ) != 0 ) continue ; } if ( memcmp ( _tmx_proc_ptran -> callid . s , it -> callid . s , it -> callid . len ) != 0 || memcmp ( _tmx_proc_ptran -> ftag . s , it -> ftag . s , it -> ftag . len ) != 0 || memcmp ( _tmx_proc_ptran -> cseqnum . s , it -> cseqnum . s , it -> cseqnum . len ) != 0 ) continue ; if ( ( it -> cseqmetid == METHOD_OTHER || it -> cseqmetid == METHOD_UNDEF ) && memcmp ( _tmx_proc_ptran -> cseqmet . s , it -> cseqmet . s , it -> cseqmet . len ) != 0 ) continue ; LM_DBG ( \"matchedanotherpre-transactionbypid%dfor[%.*s]\\\\n\" , it -> pid , it -> callid . len , it -> callid . s ) ; lock_release ( & _tmx_ptran_table [ slotid ] . lock ) ; return 1 ; } lock_release ( & _tmx_ptran_table [ slotid ] . lock ) ; return 0 ; }\n", "\n", "1: CWE-119 int tmx_check_pretran ( sip_msg_t * msg ) { unsigned int chid ; unsigned int slotid ; int dsize ; struct via_param * vbr ; str scallid ; str scseqmet ; str scseqnum ; str sftag ; str svbranch = { NULL , 0 } ; pretran_t * it ; if ( _tmx_ptran_table == NULL ) { LM_ERR ( \"pretranhashtablenotinitializedyet\\\\n\" ) ; return - 1 ; } if ( get_route_type ( ) != REQUEST_ROUTE ) { LM_ERR ( \"invalidusage-notinrequestroute\\\\n\" ) ; return - 1 ; } if ( msg -> first_line . type != SIP_REQUEST ) { LM_ERR ( \"invalidusage-notasiprequest\\\\n\" ) ; return - 1 ; } if ( parse_headers ( msg , HDR_FROM_F | HDR_VIA1_F | HDR_CALLID_F | HDR_CSEQ_F , 0 ) < 0 ) { LM_ERR ( \"failedtoparserequiredheaders\\\\n\" ) ; return - 1 ; } if ( msg -> cseq == NULL || msg -> cseq -> parsed == NULL ) { LM_ERR ( \"failedtoparsecseqheaders\\\\n\" ) ; return - 1 ; } if ( get_cseq ( msg ) -> method_id == METHOD_ACK || get_cseq ( msg ) -> method_id == METHOD_CANCEL ) { LM_DBG ( \"nopre-transactionmanagementforACKorCANCEL\\\\n\" ) ; return - 1 ; } if ( msg -> via1 == 0 ) { LM_ERR ( \"failedtogetViaheader\\\\n\" ) ; return - 1 ; } if ( parse_from_header ( msg ) < 0 || get_from ( msg ) -> tag_value . len == 0 ) { LM_ERR ( \"failedtogetFromheader\\\\n\" ) ; return - 1 ; } if ( msg -> callid == NULL || msg -> callid -> body . s == NULL ) { LM_ERR ( \"failedtoparsecallidheaders\\\\n\" ) ; return - 1 ; } vbr = msg -> via1 -> branch ; scallid = msg -> callid -> body ; trim ( & scallid ) ; scseqmet = get_cseq ( msg ) -> method ; trim ( & scseqmet ) ; scseqnum = get_cseq ( msg ) -> number ; trim ( & scseqnum ) ; sftag = get_from ( msg ) -> tag_value ; trim ( & sftag ) ; chid = get_hash1_raw ( msg -> callid -> body . s , msg -> callid -> body . len ) ; slotid = chid & ( _tmx_ptran_size - 1 ) ; if ( unlikely ( _tmx_proc_ptran == NULL ) ) { _tmx_proc_ptran = ( pretran_t * ) shm_malloc ( sizeof ( pretran_t ) ) ; if ( _tmx_proc_ptran == NULL ) { LM_ERR ( \"notenoughmemoryforpretranstructure\\\\n\" ) ; return - 1 ; } memset ( _tmx_proc_ptran , 0 , sizeof ( pretran_t ) ) ; _tmx_proc_ptran -> pid = my_pid ( ) ; } dsize = scallid . len + scseqnum . len + scseqmet . len + sftag . len + 4 ; if ( likely ( vbr != NULL ) ) { svbranch = vbr -> value ; trim ( & svbranch ) ; dsize += svbranch . len ; } if ( dsize < 256 ) dsize = 256 ; tmx_pretran_unlink ( ) ; if ( dsize > _tmx_proc_ptran -> dbuf . len ) { if ( _tmx_proc_ptran -> dbuf . s ) shm_free ( _tmx_proc_ptran -> dbuf . s ) ; _tmx_proc_ptran -> dbuf . s = ( char * ) shm_malloc ( dsize ) ; if ( _tmx_proc_ptran -> dbuf . s == NULL ) { LM_ERR ( \"notenoughmemoryforpretrandata\\\\n\" ) ; return - 1 ; } _tmx_proc_ptran -> dbuf . len = dsize ; } _tmx_proc_ptran -> hid = chid ; _tmx_proc_ptran -> cseqmetid = ( get_cseq ( msg ) ) -> method_id ; _tmx_proc_ptran -> callid . s = _tmx_proc_ptran -> dbuf . s ; memcpy ( _tmx_proc_ptran -> callid . s , scallid . s , scallid . len ) ; _tmx_proc_ptran -> callid . len = scallid . len ; _tmx_proc_ptran -> callid . s [ _tmx_proc_ptran -> callid . len ] = '\\\\0' ; _tmx_proc_ptran -> ftag . s = _tmx_proc_ptran -> callid . s + _tmx_proc_ptran -> callid . len + 1 ; memcpy ( _tmx_proc_ptran -> ftag . s , sftag . s , sftag . len ) ; _tmx_proc_ptran -> ftag . len = sftag . len ; _tmx_proc_ptran -> ftag . s [ _tmx_proc_ptran -> ftag . len ] = '\\\\0' ; _tmx_proc_ptran -> cseqnum . s = _tmx_proc_ptran -> ftag . s + _tmx_proc_ptran -> ftag . len + 1 ; memcpy ( _tmx_proc_ptran -> cseqnum . s , scseqnum . s , scseqnum . len ) ; _tmx_proc_ptran -> cseqnum . len = scseqnum . len ; _tmx_proc_ptran -> cseqnum . s [ _tmx_proc_ptran -> cseqnum . len ] = '\\\\0' ; _tmx_proc_ptran -> cseqmet . s = _tmx_proc_ptran -> cseqnum . s + _tmx_proc_ptran -> cseqnum . len + 1 ; memcpy ( _tmx_proc_ptran -> cseqmet . s , scseqmet . s , scseqmet . len ) ; _tmx_proc_ptran -> cseqmet . len = scseqmet . len ; _tmx_proc_ptran -> cseqmet . s [ _tmx_proc_ptran -> cseqmet . len ] = '\\\\0' ; if ( likely ( vbr != NULL ) ) { _tmx_proc_ptran -> vbranch . s = _tmx_proc_ptran -> cseqmet . s + _tmx_proc_ptran -> cseqmet . len + 1 ; memcpy ( _tmx_proc_ptran -> vbranch . s , svbranch . s , svbranch . len ) ; _tmx_proc_ptran -> vbranch . len = svbranch . len ; _tmx_proc_ptran -> vbranch . s [ _tmx_proc_ptran -> vbranch . len ] = '\\\\0' ; } else { _tmx_proc_ptran -> vbranch . s = NULL ; _tmx_proc_ptran -> vbranch . len = 0 ; } lock_get ( & _tmx_ptran_table [ slotid ] . lock ) ; it = _tmx_ptran_table [ slotid ] . plist ; tmx_pretran_link_safe ( slotid ) ; for ( ; it != NULL ; it = it -> next ) { if ( _tmx_proc_ptran -> hid != it -> hid || _tmx_proc_ptran -> cseqmetid != it -> cseqmetid || _tmx_proc_ptran -> callid . len != it -> callid . len || _tmx_proc_ptran -> ftag . len != it -> ftag . len || _tmx_proc_ptran -> cseqmet . len != it -> cseqmet . len || _tmx_proc_ptran -> cseqnum . len != it -> cseqnum . len ) continue ; if ( _tmx_proc_ptran -> vbranch . s != NULL && it -> vbranch . s != NULL ) { if ( _tmx_proc_ptran -> vbranch . len != it -> vbranch . len ) continue ; if ( _tmx_proc_ptran -> vbranch . s [ it -> vbranch . len - 1 ] != it -> vbranch . s [ it -> vbranch . len - 1 ] ) continue ; if ( memcmp ( _tmx_proc_ptran -> vbranch . s , it -> vbranch . s , it -> vbranch . len ) != 0 ) continue ; } if ( memcmp ( _tmx_proc_ptran -> callid . s , it -> callid . s , it -> callid . len ) != 0 || memcmp ( _tmx_proc_ptran -> ftag . s , it -> ftag . s , it -> ftag . len ) != 0 || memcmp ( _tmx_proc_ptran -> cseqnum . s , it -> cseqnum . s , it -> cseqnum . len ) != 0 ) continue ; if ( ( it -> cseqmetid == METHOD_OTHER || it -> cseqmetid == METHOD_UNDEF ) && memcmp ( _tmx_proc_ptran -> cseqmet . s , it -> cseqmet . s , it -> cseqmet . len ) != 0 ) continue ; LM_DBG ( \"matchedanotherpre-transactionbypid%dfor[%.*s]\\\\n\" , it -> pid , it -> callid . len , it -> callid . s ) ; lock_release ( & _tmx_ptran_table [ slotid ] . lock ) ; return 1 ; } lock_release ( & _tmx_ptran_table [ slotid ] . lock ) ; return 0 ; }\n", "\n", "\n", "Target: size ) { ASSERT_NO_SIZE_OVERFLOW ( size ) ;\n", "\n", "Sources:\n", "0: CWE-190 void * zmalloc ( size_t size ) { void * ptr = malloc ( size + PREFIX_SIZE ) ; if ( ! ptr ) zmalloc_oom_handler ( size ) ; # ifdef HAVE_MALLOC_SIZE update_zmalloc_stat_alloc ( zmalloc_size ( ptr ) ) ; return ptr ; # else * ( ( size_t * ) ptr ) = size ; update_zmalloc_stat_alloc ( size + PREFIX_SIZE ) ; return ( char * ) ptr + PREFIX_SIZE ; # endif }\n", "\n", "1: CWE-190 void * zrealloc ( void * ptr , size_t size ) { # ifndef HAVE_MALLOC_SIZE void * realptr ; # endif size_t oldsize ; void * newptr ; if ( size == 0 && ptr != NULL ) { zfree ( ptr ) ; return NULL ; } if ( ptr == NULL ) return zmalloc ( size ) ; # ifdef HAVE_MALLOC_SIZE oldsize = zmalloc_size ( ptr ) ; newptr = realloc ( ptr , size ) ; if ( ! newptr ) zmalloc_oom_handler ( size ) ; update_zmalloc_stat_free ( oldsize ) ; update_zmalloc_stat_alloc ( zmalloc_size ( newptr ) ) ; return newptr ; # else realptr = ( char * ) ptr - PREFIX_SIZE ; oldsize = * ( ( size_t * ) realptr ) ; newptr = realloc ( realptr , size + PREFIX_SIZE ) ; if ( ! newptr ) zmalloc_oom_handler ( size ) ; * ( ( size_t * ) newptr ) = size ; update_zmalloc_stat_free ( oldsize + PREFIX_SIZE ) ; update_zmalloc_stat_alloc ( size + PREFIX_SIZE ) ; return ( char * ) newptr + PREFIX_SIZE ; # endif }\n", "\n", "\n", "Target: string , const size_t length ) {\n", "\n", "Sources:\n", "0: CWE-190 int bson_check_string ( bson * b , const char * string , const int length ) { return bson_validate_string ( b , ( const unsigned char * ) string , length , 1 , 0 , 0 ) ; }\n", "\n", "1: CWE-190 static int bson_string_is_db_ref ( const unsigned char * string , const int length ) { int result = 0 ; if ( length >= 4 ) { if ( string [ 1 ] == 'r' && string [ 2 ] == 'e' && string [ 3 ] == 'f' ) result = 1 ; } else if ( length >= 3 ) { if ( string [ 1 ] == 'i' && string [ 2 ] == 'd' ) result = 1 ; else if ( string [ 1 ] == 'd' && string [ 2 ] == 'b' ) result = 1 ; } return result ; }\n", "\n", "\n", "Target: , message ) \\\\\\n{ if ( tile_image ) ) ; \\\\\\n} char geometry [ if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( length ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( length ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( length > image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; 0xff ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ;\n", "\n", "Sources:\n", "0: CWE-20 static Image * ReadPICTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowPICTException ( exception , message ) { if ( tile_image != ( Image * ) NULL ) tile_image = DestroyImage ( tile_image ) ; if ( read_info != ( ImageInfo * ) NULL ) read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char geometry [ MagickPathExtent ] , header_ole [ 4 ] ; Image * image , * tile_image ; ImageInfo * read_info ; int c , code ; MagickBooleanType jpeg , status ; PICTRectangle frame ; PICTPixmap pixmap ; Quantum index ; register Quantum * q ; register ssize_t i , x ; size_t extent , length ; ssize_t count , flags , j , version , y ; StringInfo * profile ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } read_info = ( ImageInfo * ) NULL ; tile_image = ( Image * ) NULL ; pixmap . bits_per_pixel = 0 ; pixmap . component_count = 0 ; header_ole [ 0 ] = ReadBlobByte ( image ) ; header_ole [ 1 ] = ReadBlobByte ( image ) ; header_ole [ 2 ] = ReadBlobByte ( image ) ; header_ole [ 3 ] = ReadBlobByte ( image ) ; if ( ! ( ( header_ole [ 0 ] == 0x50 ) && ( header_ole [ 1 ] == 0x49 ) && ( header_ole [ 2 ] == 0x43 ) && ( header_ole [ 3 ] == 0x54 ) ) ) for ( i = 0 ; i < 508 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; while ( ( c = ReadBlobByte ( image ) ) == 0 ) ; if ( c != 0x11 ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; version = ( ssize_t ) ReadBlobByte ( image ) ; if ( version == 2 ) { c = ReadBlobByte ( image ) ; if ( c != 0xff ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; } else if ( version != 1 ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( frame . left < 0 ) || ( frame . right < 0 ) || ( frame . top < 0 ) || ( frame . bottom < 0 ) || ( frame . left >= frame . right ) || ( frame . top >= frame . bottom ) ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; flags = 0 ; image -> depth = 8 ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; image -> resolution . x = DefaultResolution ; image -> resolution . y = DefaultResolution ; image -> units = UndefinedResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; jpeg = MagickFalse ; for ( code = 0 ; EOFBlob ( image ) == MagickFalse ; ) { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( ( version == 1 ) || ( ( TellBlob ( image ) % 2 ) != 0 ) ) code = ReadBlobByte ( image ) ; if ( version == 2 ) code = ReadBlobMSBSignedShort ( image ) ; if ( code < 0 ) break ; if ( code == 0 ) continue ; if ( code > 0xa1 ) { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"%04X:\" , code ) ; } else { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"%04X%s:%s\" , code , codes [ code ] . name , codes [ code ] . description ) ; switch ( code ) { case 0x01 : { length = ReadBlobMSBShort ( image ) ; if ( length != 0x000a ) { for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( ( frame . left & 0x8000 ) != 0 ) || ( ( frame . top & 0x8000 ) != 0 ) ) break ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; break ; } case 0x12 : case 0x13 : case 0x14 : { ssize_t pattern ; size_t height , width ; pattern = ( ssize_t ) ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < 8 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; if ( pattern == 2 ) { for ( i = 0 ; i < 5 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( pattern != 1 ) ThrowPICTException ( CorruptImageError , \"UnknownPatternType\" ) ; length = ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> depth = ( size_t ) pixmap . component_size ; image -> resolution . x = 1.0 * pixmap . horizontal_resolution ; image -> resolution . y = 1.0 * pixmap . vertical_resolution ; image -> units = PixelsPerInchResolution ; ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i <= ( ssize_t ) length ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; width = ( size_t ) ( frame . bottom - frame . top ) ; height = ( size_t ) ( frame . right - frame . left ) ; if ( pixmap . bits_per_pixel <= 8 ) length &= 0x7fff ; if ( pixmap . bits_per_pixel == 16 ) width <<= 1 ; if ( length == 0 ) length = width ; if ( length < 8 ) { for ( i = 0 ; i < ( ssize_t ) ( length * height ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( i = 0 ; i < ( ssize_t ) height ; i ++ ) { if ( EOFBlob ( image ) != MagickFalse ) break ; if ( length > 200 ) { for ( j = 0 ; j < ( ssize_t ) ReadBlobMSBShort ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( j = 0 ; j < ( ssize_t ) ReadBlobByte ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } break ; } case 0x1b : { image -> background_color . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; break ; } case 0x70 : case 0x71 : case 0x72 : case 0x73 : case 0x74 : case 0x75 : case 0x76 : case 0x77 : { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } case 0x90 : case 0x91 : case 0x98 : case 0x99 : case 0x9a : case 0x9b : { PICTRectangle source , destination ; register unsigned char * p ; size_t j ; ssize_t bytes_per_line ; unsigned char * pixels ; bytes_per_line = 0 ; if ( ( code != 0x9a ) && ( code != 0x9b ) ) bytes_per_line = ( ssize_t ) ReadBlobMSBShort ( image ) ; else { ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; tile_image = CloneImage ( image , ( size_t ) ( frame . right - frame . left ) , ( size_t ) ( frame . bottom - frame . top ) , MagickTrue , exception ) ; if ( tile_image == ( Image * ) NULL ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) { if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; tile_image -> depth = ( size_t ) pixmap . component_size ; tile_image -> alpha_trait = pixmap . component_count == 4 ? BlendPixelTrait : UndefinedPixelTrait ; tile_image -> resolution . x = ( double ) pixmap . horizontal_resolution ; tile_image -> resolution . y = ( double ) pixmap . vertical_resolution ; tile_image -> units = PixelsPerInchResolution ; if ( tile_image -> alpha_trait != UndefinedPixelTrait ) ( void ) SetImageAlpha ( tile_image , OpaqueAlpha , exception ) ; } if ( ( code != 0x9a ) && ( code != 0x9b ) ) { tile_image -> colors = 2 ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; tile_image -> colors = 1UL * ReadBlobMSBShort ( image ) + 1 ; } status = AcquireImageColormap ( tile_image , tile_image -> colors , exception ) ; if ( status == MagickFalse ) ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { j = ReadBlobMSBShort ( image ) % tile_image -> colors ; if ( ( flags & 0x8000 ) != 0 ) j = ( size_t ) i ; tile_image -> colormap [ j ] . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; } } else { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { tile_image -> colormap [ i ] . red = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . red ) ; tile_image -> colormap [ i ] . green = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . green ) ; tile_image -> colormap [ i ] . blue = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . blue ) ; } } } if ( EOFBlob ( image ) != MagickFalse ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ReadRectangle ( image , & source ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ReadRectangle ( image , & destination ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; ( void ) ReadBlobMSBShort ( image ) ; if ( ( code == 0x91 ) || ( code == 0x99 ) || ( code == 0x9b ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } if ( ( code != 0x9a ) && ( code != 0x9b ) && ( bytes_per_line & 0x8000 ) == 0 ) pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , 1 , & extent ) ; else pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , ( unsigned int ) pixmap . bits_per_pixel , & extent ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowPICTException ( CorruptImageError , \"UnableToUncompressImage\" ) ; p = pixels ; for ( y = 0 ; y < ( ssize_t ) tile_image -> rows ; y ++ ) { if ( p > ( pixels + extent + image -> columns ) ) { pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; } q = QueueAuthenticPixels ( tile_image , 0 , y , tile_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) tile_image -> columns ; x ++ ) { if ( tile_image -> storage_class == PseudoClass ) { index = ( Quantum ) ConstrainColormapIndex ( tile_image , ( ssize_t ) * p , exception ) ; SetPixelIndex ( tile_image , index , q ) ; SetPixelRed ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . red , q ) ; SetPixelGreen ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . green , q ) ; SetPixelBlue ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . blue , q ) ; } else { if ( pixmap . bits_per_pixel == 16 ) { i = ( ssize_t ) ( * p ++ ) ; j = ( size_t ) ( * p ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( i & 0x7c ) << 1 ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( ( i & 0x03 ) << 6 ) | ( ( j & 0xe0 ) >> 2 ) ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( j & 0x1f ) << 3 ) ) , q ) ; } else if ( tile_image -> alpha_trait == UndefinedPixelTrait ) { if ( p > ( pixels + extent + 2 * image -> columns ) ) ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; } else { if ( p > ( pixels + extent + 3 * image -> columns ) ) ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; SetPixelAlpha ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 3 * tile_image -> columns ) ) , q ) ; } } p ++ ; q += GetPixelChannels ( tile_image ) ; } if ( SyncAuthenticPixels ( tile_image , exception ) == MagickFalse ) break ; if ( ( tile_image -> storage_class == DirectClass ) && ( pixmap . bits_per_pixel != 16 ) ) { p += ( pixmap . component_count - 1 ) * tile_image -> columns ; if ( p < pixels ) break ; } status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , tile_image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( ( jpeg == MagickFalse ) && ( EOFBlob ( image ) == MagickFalse ) ) if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) destination . left , ( ssize_t ) destination . top , exception ) ; tile_image = DestroyImage ( tile_image ) ; break ; } case 0xa1 : { unsigned char * info ; size_t type ; type = ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; if ( length == 0 ) break ; ( void ) ReadBlobMSBLong ( image ) ; length -= MagickMin ( length , 4 ) ; if ( length == 0 ) break ; info = ( unsigned char * ) AcquireQuantumMemory ( length , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) break ; count = ReadBlob ( image , length , info ) ; if ( count != ( ssize_t ) length ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"UnableToReadImageData\" ) ; } switch ( type ) { case 0xe0 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , \"icc\" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case 0x1f2 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , \"iptc\" , profile , exception ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } profile = DestroyStringInfo ( profile ) ; break ; } default : break ; } info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; break ; } default : { if ( codes [ code ] . length == - 1 ) ( void ) ReadBlobMSBShort ( image ) ; else for ( i = 0 ; i < ( ssize_t ) codes [ code ] . length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } } } if ( code == 0xc00 ) { for ( i = 0 ; i < 24 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( ( code >= 0xb0 ) && ( code <= 0xcf ) ) || ( ( code >= 0x8000 ) && ( code <= 0x80ff ) ) ) continue ; if ( code == 0x8200 ) { char filename [ MaxTextExtent ] ; FILE * file ; int unique_file ; jpeg = MagickTrue ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; ( void ) FormatLocaleString ( read_info -> filename , MaxTextExtent , \"jpeg:%s\" , filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ( void ) CopyMagickString ( image -> filename , read_info -> filename , MagickPathExtent ) ; ThrowPICTException ( FileOpenError , \"UnableToCreateTemporaryFile\" ) ; } length = ReadBlobMSBLong ( image ) ; if ( length > 154 ) { for ( i = 0 ; i < 6 ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) { ( void ) fclose ( file ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < 122 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; for ( i = 0 ; i < ( ssize_t ) ( length - 154 ) ; i ++ ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; if ( fputc ( c , file ) != c ) break ; } } ( void ) fclose ( file ) ; ( void ) close ( unique_file ) ; tile_image = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( tile_image == ( Image * ) NULL ) continue ; ( void ) FormatLocaleString ( geometry , MagickPathExtent , \"%.20gx%.20g\" , ( double ) MagickMax ( image -> columns , tile_image -> columns ) , ( double ) MagickMax ( image -> rows , tile_image -> rows ) ) ; ( void ) SetImageExtent ( image , MagickMax ( image -> columns , tile_image -> columns ) , MagickMax ( image -> rows , tile_image -> rows ) , exception ) ; ( void ) TransformImageColorspace ( image , tile_image -> colorspace , exception ) ; ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) frame . left , ( ssize_t ) frame . right , exception ) ; image -> compression = tile_image -> compression ; tile_image = DestroyImage ( tile_image ) ; continue ; } if ( ( code == 0xff ) || ( code == 0xffff ) ) break ; if ( ( ( code >= 0xd0 ) && ( code <= 0xfe ) ) || ( ( code >= 0x8100 ) && ( code <= 0xffff ) ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( code >= 0x100 ) && ( code <= 0x7fff ) ) { length = ( size_t ) ( ( code >> 7 ) & 0xff ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-119 static Image * ReadPICTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowPICTException ( exception , message ) { if ( tile_image != ( Image * ) NULL ) tile_image = DestroyImage ( tile_image ) ; if ( read_info != ( ImageInfo * ) NULL ) read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char geometry [ MagickPathExtent ] , header_ole [ 4 ] ; Image * image , * tile_image ; ImageInfo * read_info ; int c , code ; MagickBooleanType jpeg , status ; PICTRectangle frame ; PICTPixmap pixmap ; Quantum index ; register Quantum * q ; register ssize_t i , x ; size_t extent , length ; ssize_t count , flags , j , version , y ; StringInfo * profile ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } read_info = ( ImageInfo * ) NULL ; tile_image = ( Image * ) NULL ; pixmap . bits_per_pixel = 0 ; pixmap . component_count = 0 ; header_ole [ 0 ] = ReadBlobByte ( image ) ; header_ole [ 1 ] = ReadBlobByte ( image ) ; header_ole [ 2 ] = ReadBlobByte ( image ) ; header_ole [ 3 ] = ReadBlobByte ( image ) ; if ( ! ( ( header_ole [ 0 ] == 0x50 ) && ( header_ole [ 1 ] == 0x49 ) && ( header_ole [ 2 ] == 0x43 ) && ( header_ole [ 3 ] == 0x54 ) ) ) for ( i = 0 ; i < 508 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; while ( ( c = ReadBlobByte ( image ) ) == 0 ) ; if ( c != 0x11 ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; version = ( ssize_t ) ReadBlobByte ( image ) ; if ( version == 2 ) { c = ReadBlobByte ( image ) ; if ( c != 0xff ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; } else if ( version != 1 ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( frame . left < 0 ) || ( frame . right < 0 ) || ( frame . top < 0 ) || ( frame . bottom < 0 ) || ( frame . left >= frame . right ) || ( frame . top >= frame . bottom ) ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; flags = 0 ; image -> depth = 8 ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; image -> resolution . x = DefaultResolution ; image -> resolution . y = DefaultResolution ; image -> units = UndefinedResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; jpeg = MagickFalse ; for ( code = 0 ; EOFBlob ( image ) == MagickFalse ; ) { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( ( version == 1 ) || ( ( TellBlob ( image ) % 2 ) != 0 ) ) code = ReadBlobByte ( image ) ; if ( version == 2 ) code = ReadBlobMSBSignedShort ( image ) ; if ( code < 0 ) break ; if ( code == 0 ) continue ; if ( code > 0xa1 ) { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"%04X:\" , code ) ; } else { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , \"%04X%s:%s\" , code , codes [ code ] . name , codes [ code ] . description ) ; switch ( code ) { case 0x01 : { length = ReadBlobMSBShort ( image ) ; if ( length != 0x000a ) { for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( ( frame . left & 0x8000 ) != 0 ) || ( ( frame . top & 0x8000 ) != 0 ) ) break ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; break ; } case 0x12 : case 0x13 : case 0x14 : { ssize_t pattern ; size_t height , width ; pattern = ( ssize_t ) ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < 8 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; if ( pattern == 2 ) { for ( i = 0 ; i < 5 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( pattern != 1 ) ThrowPICTException ( CorruptImageError , \"UnknownPatternType\" ) ; length = ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; image -> depth = ( size_t ) pixmap . component_size ; image -> resolution . x = 1.0 * pixmap . horizontal_resolution ; image -> resolution . y = 1.0 * pixmap . vertical_resolution ; image -> units = PixelsPerInchResolution ; ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i <= ( ssize_t ) length ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; width = ( size_t ) ( frame . bottom - frame . top ) ; height = ( size_t ) ( frame . right - frame . left ) ; if ( pixmap . bits_per_pixel <= 8 ) length &= 0x7fff ; if ( pixmap . bits_per_pixel == 16 ) width <<= 1 ; if ( length == 0 ) length = width ; if ( length < 8 ) { for ( i = 0 ; i < ( ssize_t ) ( length * height ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( i = 0 ; i < ( ssize_t ) height ; i ++ ) { if ( EOFBlob ( image ) != MagickFalse ) break ; if ( length > 200 ) { for ( j = 0 ; j < ( ssize_t ) ReadBlobMSBShort ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( j = 0 ; j < ( ssize_t ) ReadBlobByte ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } break ; } case 0x1b : { image -> background_color . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; break ; } case 0x70 : case 0x71 : case 0x72 : case 0x73 : case 0x74 : case 0x75 : case 0x76 : case 0x77 : { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } case 0x90 : case 0x91 : case 0x98 : case 0x99 : case 0x9a : case 0x9b : { PICTRectangle source , destination ; register unsigned char * p ; size_t j ; ssize_t bytes_per_line ; unsigned char * pixels ; bytes_per_line = 0 ; if ( ( code != 0x9a ) && ( code != 0x9b ) ) bytes_per_line = ( ssize_t ) ReadBlobMSBShort ( image ) ; else { ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; tile_image = CloneImage ( image , ( size_t ) ( frame . right - frame . left ) , ( size_t ) ( frame . bottom - frame . top ) , MagickTrue , exception ) ; if ( tile_image == ( Image * ) NULL ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) { if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; tile_image -> depth = ( size_t ) pixmap . component_size ; tile_image -> alpha_trait = pixmap . component_count == 4 ? BlendPixelTrait : UndefinedPixelTrait ; tile_image -> resolution . x = ( double ) pixmap . horizontal_resolution ; tile_image -> resolution . y = ( double ) pixmap . vertical_resolution ; tile_image -> units = PixelsPerInchResolution ; if ( tile_image -> alpha_trait != UndefinedPixelTrait ) ( void ) SetImageAlpha ( tile_image , OpaqueAlpha , exception ) ; } if ( ( code != 0x9a ) && ( code != 0x9b ) ) { tile_image -> colors = 2 ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; tile_image -> colors = 1UL * ReadBlobMSBShort ( image ) + 1 ; } status = AcquireImageColormap ( tile_image , tile_image -> colors , exception ) ; if ( status == MagickFalse ) ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { j = ReadBlobMSBShort ( image ) % tile_image -> colors ; if ( ( flags & 0x8000 ) != 0 ) j = ( size_t ) i ; tile_image -> colormap [ j ] . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; } } else { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { tile_image -> colormap [ i ] . red = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . red ) ; tile_image -> colormap [ i ] . green = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . green ) ; tile_image -> colormap [ i ] . blue = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . blue ) ; } } } if ( EOFBlob ( image ) != MagickFalse ) ThrowPICTException ( CorruptImageError , \"InsufficientImageDataInFile\" ) ; if ( ReadRectangle ( image , & source ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ReadRectangle ( image , & destination ) == MagickFalse ) ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; ( void ) ReadBlobMSBShort ( image ) ; if ( ( code == 0x91 ) || ( code == 0x99 ) || ( code == 0x9b ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } if ( ( code != 0x9a ) && ( code != 0x9b ) && ( bytes_per_line & 0x8000 ) == 0 ) pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , 1 , & extent ) ; else pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , ( unsigned int ) pixmap . bits_per_pixel , & extent ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowPICTException ( CorruptImageError , \"UnableToUncompressImage\" ) ; p = pixels ; for ( y = 0 ; y < ( ssize_t ) tile_image -> rows ; y ++ ) { if ( p > ( pixels + extent + image -> columns ) ) { pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; } q = QueueAuthenticPixels ( tile_image , 0 , y , tile_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) tile_image -> columns ; x ++ ) { if ( tile_image -> storage_class == PseudoClass ) { index = ( Quantum ) ConstrainColormapIndex ( tile_image , ( ssize_t ) * p , exception ) ; SetPixelIndex ( tile_image , index , q ) ; SetPixelRed ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . red , q ) ; SetPixelGreen ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . green , q ) ; SetPixelBlue ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . blue , q ) ; } else { if ( pixmap . bits_per_pixel == 16 ) { i = ( ssize_t ) ( * p ++ ) ; j = ( size_t ) ( * p ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( i & 0x7c ) << 1 ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( ( i & 0x03 ) << 6 ) | ( ( j & 0xe0 ) >> 2 ) ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( j & 0x1f ) << 3 ) ) , q ) ; } else if ( tile_image -> alpha_trait == UndefinedPixelTrait ) { if ( p > ( pixels + extent + 2 * image -> columns ) ) ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; } else { if ( p > ( pixels + extent + 3 * image -> columns ) ) ThrowPICTException ( CorruptImageError , \"NotEnoughPixelData\" ) ; SetPixelAlpha ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 3 * tile_image -> columns ) ) , q ) ; } } p ++ ; q += GetPixelChannels ( tile_image ) ; } if ( SyncAuthenticPixels ( tile_image , exception ) == MagickFalse ) break ; if ( ( tile_image -> storage_class == DirectClass ) && ( pixmap . bits_per_pixel != 16 ) ) { p += ( pixmap . component_count - 1 ) * tile_image -> columns ; if ( p < pixels ) break ; } status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , tile_image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( ( jpeg == MagickFalse ) && ( EOFBlob ( image ) == MagickFalse ) ) if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) destination . left , ( ssize_t ) destination . top , exception ) ; tile_image = DestroyImage ( tile_image ) ; break ; } case 0xa1 : { unsigned char * info ; size_t type ; type = ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; if ( length == 0 ) break ; ( void ) ReadBlobMSBLong ( image ) ; length -= MagickMin ( length , 4 ) ; if ( length == 0 ) break ; info = ( unsigned char * ) AcquireQuantumMemory ( length , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) break ; count = ReadBlob ( image , length , info ) ; if ( count != ( ssize_t ) length ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"UnableToReadImageData\" ) ; } switch ( type ) { case 0xe0 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , \"icc\" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } break ; } case 0x1f2 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , \"iptc\" , profile , exception ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; } profile = DestroyStringInfo ( profile ) ; break ; } default : break ; } info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; break ; } default : { if ( codes [ code ] . length == - 1 ) ( void ) ReadBlobMSBShort ( image ) ; else for ( i = 0 ; i < ( ssize_t ) codes [ code ] . length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } } } if ( code == 0xc00 ) { for ( i = 0 ; i < 24 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( ( code >= 0xb0 ) && ( code <= 0xcf ) ) || ( ( code >= 0x8000 ) && ( code <= 0x80ff ) ) ) continue ; if ( code == 0x8200 ) { char filename [ MaxTextExtent ] ; FILE * file ; int unique_file ; jpeg = MagickTrue ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; ( void ) FormatLocaleString ( read_info -> filename , MaxTextExtent , \"jpeg:%s\" , filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , \"wb\" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ( void ) CopyMagickString ( image -> filename , read_info -> filename , MagickPathExtent ) ; ThrowPICTException ( FileOpenError , \"UnableToCreateTemporaryFile\" ) ; } length = ReadBlobMSBLong ( image ) ; if ( length > 154 ) { for ( i = 0 ; i < 6 ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) { ( void ) fclose ( file ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ThrowPICTException ( CorruptImageError , \"ImproperImageHeader\" ) ; } for ( i = 0 ; i < 122 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; for ( i = 0 ; i < ( ssize_t ) ( length - 154 ) ; i ++ ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; if ( fputc ( c , file ) != c ) break ; } } ( void ) fclose ( file ) ; ( void ) close ( unique_file ) ; tile_image = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( tile_image == ( Image * ) NULL ) continue ; ( void ) FormatLocaleString ( geometry , MagickPathExtent , \"%.20gx%.20g\" , ( double ) MagickMax ( image -> columns , tile_image -> columns ) , ( double ) MagickMax ( image -> rows , tile_image -> rows ) ) ; ( void ) SetImageExtent ( image , MagickMax ( image -> columns , tile_image -> columns ) , MagickMax ( image -> rows , tile_image -> rows ) , exception ) ; ( void ) TransformImageColorspace ( image , tile_image -> colorspace , exception ) ; ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) frame . left , ( ssize_t ) frame . right , exception ) ; image -> compression = tile_image -> compression ; tile_image = DestroyImage ( tile_image ) ; continue ; } if ( ( code == 0xff ) || ( code == 0xffff ) ) break ; if ( ( ( code >= 0xd0 ) && ( code <= 0xfe ) ) || ( ( code >= 0x8100 ) && ( code <= 0xffff ) ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( code >= 0x100 ) && ( code <= 0x7fff ) ) { length = ( size_t ) ( ( code >> 7 ) & 0xff ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: gfn , page_size >> PAGE_SHIFT pfn , page_size >> PAGE_SHIFT\n", "\n", "Sources:\n", "0: CWE-189 int kvm_iommu_map_pages ( struct kvm * kvm , struct kvm_memory_slot * slot ) { gfn_t gfn , end_gfn ; pfn_t pfn ; int r = 0 ; struct iommu_domain * domain = kvm -> arch . iommu_domain ; int flags ; if ( ! domain ) return 0 ; gfn = slot -> base_gfn ; end_gfn = gfn + slot -> npages ; flags = IOMMU_READ ; if ( ! ( slot -> flags & KVM_MEM_READONLY ) ) flags |= IOMMU_WRITE ; if ( ! kvm -> arch . iommu_noncoherent ) flags |= IOMMU_CACHE ; while ( gfn < end_gfn ) { unsigned long page_size ; if ( iommu_iova_to_phys ( domain , gfn_to_gpa ( gfn ) ) ) { gfn += 1 ; continue ; } page_size = kvm_host_page_size ( kvm , gfn ) ; while ( ( gfn + ( page_size >> PAGE_SHIFT ) ) > end_gfn ) page_size >>= 1 ; while ( ( gfn << PAGE_SHIFT ) & ( page_size - 1 ) ) page_size >>= 1 ; while ( __gfn_to_hva_memslot ( slot , gfn ) & ( page_size - 1 ) ) page_size >>= 1 ; pfn = kvm_pin_pages ( slot , gfn , page_size ) ; if ( is_error_noslot_pfn ( pfn ) ) { gfn += 1 ; continue ; } r = iommu_map ( domain , gfn_to_gpa ( gfn ) , pfn_to_hpa ( pfn ) , page_size , flags ) ; if ( r ) { printk ( KERN_ERR \"kvm_iommu_map_address:\" \"iommufailedtomappfn=%llx\\\\n\" , pfn ) ; kvm_unpin_pages ( kvm , pfn , page_size ) ; goto unmap_pages ; } gfn += page_size >> PAGE_SHIFT ; } return 0 ; unmap_pages : kvm_iommu_put_pages ( kvm , slot -> base_gfn , gfn - slot -> base_gfn ) ; return r ; }\n", "\n", "1: CWE-119 int kvm_iommu_map_pages ( struct kvm * kvm , struct kvm_memory_slot * slot ) { gfn_t gfn , end_gfn ; pfn_t pfn ; int r = 0 ; struct iommu_domain * domain = kvm -> arch . iommu_domain ; int flags ; if ( ! domain ) return 0 ; gfn = slot -> base_gfn ; end_gfn = gfn + slot -> npages ; flags = IOMMU_READ ; if ( ! ( slot -> flags & KVM_MEM_READONLY ) ) flags |= IOMMU_WRITE ; if ( ! kvm -> arch . iommu_noncoherent ) flags |= IOMMU_CACHE ; while ( gfn < end_gfn ) { unsigned long page_size ; if ( iommu_iova_to_phys ( domain , gfn_to_gpa ( gfn ) ) ) { gfn += 1 ; continue ; } page_size = kvm_host_page_size ( kvm , gfn ) ; while ( ( gfn + ( page_size >> PAGE_SHIFT ) ) > end_gfn ) page_size >>= 1 ; while ( ( gfn << PAGE_SHIFT ) & ( page_size - 1 ) ) page_size >>= 1 ; while ( __gfn_to_hva_memslot ( slot , gfn ) & ( page_size - 1 ) ) page_size >>= 1 ; pfn = kvm_pin_pages ( slot , gfn , page_size ) ; if ( is_error_noslot_pfn ( pfn ) ) { gfn += 1 ; continue ; } r = iommu_map ( domain , gfn_to_gpa ( gfn ) , pfn_to_hpa ( pfn ) , page_size , flags ) ; if ( r ) { printk ( KERN_ERR \"kvm_iommu_map_address:\" \"iommufailedtomappfn=%llx\\\\n\" , pfn ) ; kvm_unpin_pages ( kvm , pfn , page_size ) ; goto unmap_pages ; } gfn += page_size >> PAGE_SHIFT ; } return 0 ; unmap_pages : kvm_iommu_put_pages ( kvm , slot -> base_gfn , gfn - slot -> base_gfn ) ; return r ; }\n", "\n", "\n", "Target: , VCPU_SREG_LDTR , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if\n", "\n", "Sources:\n", "0: CWE-264 static int load_state_from_tss32 ( struct x86_emulate_ctxt * ctxt , struct tss_segment_32 * tss ) { int ret ; u8 cpl ; if ( ctxt -> ops -> set_cr ( ctxt , 3 , tss -> cr3 ) ) return emulate_gp ( ctxt , 0 ) ; ctxt -> _eip = tss -> eip ; ctxt -> eflags = tss -> eflags | 2 ; * reg_write ( ctxt , VCPU_REGS_RAX ) = tss -> eax ; * reg_write ( ctxt , VCPU_REGS_RCX ) = tss -> ecx ; * reg_write ( ctxt , VCPU_REGS_RDX ) = tss -> edx ; * reg_write ( ctxt , VCPU_REGS_RBX ) = tss -> ebx ; * reg_write ( ctxt , VCPU_REGS_RSP ) = tss -> esp ; * reg_write ( ctxt , VCPU_REGS_RBP ) = tss -> ebp ; * reg_write ( ctxt , VCPU_REGS_RSI ) = tss -> esi ; * reg_write ( ctxt , VCPU_REGS_RDI ) = tss -> edi ; set_segment_selector ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR ) ; set_segment_selector ( ctxt , tss -> es , VCPU_SREG_ES ) ; set_segment_selector ( ctxt , tss -> cs , VCPU_SREG_CS ) ; set_segment_selector ( ctxt , tss -> ss , VCPU_SREG_SS ) ; set_segment_selector ( ctxt , tss -> ds , VCPU_SREG_DS ) ; set_segment_selector ( ctxt , tss -> fs , VCPU_SREG_FS ) ; set_segment_selector ( ctxt , tss -> gs , VCPU_SREG_GS ) ; if ( ctxt -> eflags & X86_EFLAGS_VM ) { ctxt -> mode = X86EMUL_MODE_VM86 ; cpl = 3 ; } else { ctxt -> mode = X86EMUL_MODE_PROT32 ; cpl = tss -> cs & 3 ; } ret = __load_segment_descriptor ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> es , VCPU_SREG_ES , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> cs , VCPU_SREG_CS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ss , VCPU_SREG_SS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ds , VCPU_SREG_DS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> fs , VCPU_SREG_FS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> gs , VCPU_SREG_GS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; return X86EMUL_CONTINUE ; }\n", "\n", "1: CWE-000 static int load_state_from_tss32 ( struct x86_emulate_ctxt * ctxt , struct tss_segment_32 * tss ) { int ret ; u8 cpl ; if ( ctxt -> ops -> set_cr ( ctxt , 3 , tss -> cr3 ) ) return emulate_gp ( ctxt , 0 ) ; ctxt -> _eip = tss -> eip ; ctxt -> eflags = tss -> eflags | 2 ; * reg_write ( ctxt , VCPU_REGS_RAX ) = tss -> eax ; * reg_write ( ctxt , VCPU_REGS_RCX ) = tss -> ecx ; * reg_write ( ctxt , VCPU_REGS_RDX ) = tss -> edx ; * reg_write ( ctxt , VCPU_REGS_RBX ) = tss -> ebx ; * reg_write ( ctxt , VCPU_REGS_RSP ) = tss -> esp ; * reg_write ( ctxt , VCPU_REGS_RBP ) = tss -> ebp ; * reg_write ( ctxt , VCPU_REGS_RSI ) = tss -> esi ; * reg_write ( ctxt , VCPU_REGS_RDI ) = tss -> edi ; set_segment_selector ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR ) ; set_segment_selector ( ctxt , tss -> es , VCPU_SREG_ES ) ; set_segment_selector ( ctxt , tss -> cs , VCPU_SREG_CS ) ; set_segment_selector ( ctxt , tss -> ss , VCPU_SREG_SS ) ; set_segment_selector ( ctxt , tss -> ds , VCPU_SREG_DS ) ; set_segment_selector ( ctxt , tss -> fs , VCPU_SREG_FS ) ; set_segment_selector ( ctxt , tss -> gs , VCPU_SREG_GS ) ; if ( ctxt -> eflags & X86_EFLAGS_VM ) { ctxt -> mode = X86EMUL_MODE_VM86 ; cpl = 3 ; } else { ctxt -> mode = X86EMUL_MODE_PROT32 ; cpl = tss -> cs & 3 ; } ret = __load_segment_descriptor ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> es , VCPU_SREG_ES , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> cs , VCPU_SREG_CS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ss , VCPU_SREG_SS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ds , VCPU_SREG_DS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> fs , VCPU_SREG_FS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> gs , VCPU_SREG_GS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; return X86EMUL_CONTINUE ; }\n", "\n", "\n", "Target: goto err ; err = - EINVAL ; if ( size != sizeof ( outarg ) + outarg . namelen + 1 ) goto err ; name . name = buf ; name . len = outarg . namelen ; err = fuse_copy_one ( cs , buf , outarg . namelen + 1 )\n", "\n", "Sources:\n", "0: CWE-119 static int fuse_notify_inval_entry ( struct fuse_conn * fc , unsigned int size , struct fuse_copy_state * cs ) { struct fuse_notify_inval_entry_out outarg ; int err = - ENOMEM ; char * buf ; struct qstr name ; buf = kzalloc ( FUSE_NAME_MAX + 1 , GFP_KERNEL ) ; if ( ! buf ) goto err ; err = - EINVAL ; if ( size < sizeof ( outarg ) ) goto err ; err = fuse_copy_one ( cs , & outarg , sizeof ( outarg ) ) ; if ( err ) goto err ; err = - ENAMETOOLONG ; if ( outarg . namelen > FUSE_NAME_MAX ) goto err ; name . name = buf ; name . len = outarg . namelen ; err = fuse_copy_one ( cs , buf , outarg . namelen + 1 ) ; if ( err ) goto err ; fuse_copy_finish ( cs ) ; buf [ outarg . namelen ] = 0 ; name . hash = full_name_hash ( name . name , name . len ) ; down_read ( & fc -> killsb ) ; err = - ENOENT ; if ( fc -> sb ) err = fuse_reverse_inval_entry ( fc -> sb , outarg . parent , & name ) ; up_read ( & fc -> killsb ) ; kfree ( buf ) ; return err ; err : kfree ( buf ) ; fuse_copy_finish ( cs ) ; return err ; }\n", "\n", "1: CWE-120 static int fuse_notify_inval_entry ( struct fuse_conn * fc , unsigned int size , struct fuse_copy_state * cs ) { struct fuse_notify_inval_entry_out outarg ; int err = - ENOMEM ; char * buf ; struct qstr name ; buf = kzalloc ( FUSE_NAME_MAX + 1 , GFP_KERNEL ) ; if ( ! buf ) goto err ; err = - EINVAL ; if ( size < sizeof ( outarg ) ) goto err ; err = fuse_copy_one ( cs , & outarg , sizeof ( outarg ) ) ; if ( err ) goto err ; err = - ENAMETOOLONG ; if ( outarg . namelen > FUSE_NAME_MAX ) goto err ; name . name = buf ; name . len = outarg . namelen ; err = fuse_copy_one ( cs , buf , outarg . namelen + 1 ) ; if ( err ) goto err ; fuse_copy_finish ( cs ) ; buf [ outarg . namelen ] = 0 ; name . hash = full_name_hash ( name . name , name . len ) ; down_read ( & fc -> killsb ) ; err = - ENOENT ; if ( fc -> sb ) err = fuse_reverse_inval_entry ( fc -> sb , outarg . parent , & name ) ; up_read ( & fc -> killsb ) ; kfree ( buf ) ; return err ; err : kfree ( buf ) ; fuse_copy_finish ( cs ) ; return err ; }\n", "\n", "\n", "Target: -> in_out_buffer ; int ret ; int ret ; mutex_lock ( & dev dev -> lock ) ; ret ; exit : mutex_unlock ( & dev dev -> lock ) ; return\n", "\n", "Sources:\n", "0: CWE-404 static int cp2112_gpio_direction_input ( struct gpio_chip * chip , unsigned offset ) { struct cp2112_device * dev = gpiochip_get_data ( chip ) ; struct hid_device * hdev = dev -> hdev ; u8 * buf = dev -> in_out_buffer ; unsigned long flags ; int ret ; spin_lock_irqsave ( & dev -> lock , flags ) ; ret = hid_hw_raw_request ( hdev , CP2112_GPIO_CONFIG , buf , CP2112_GPIO_CONFIG_LENGTH , HID_FEATURE_REPORT , HID_REQ_GET_REPORT ) ; if ( ret != CP2112_GPIO_CONFIG_LENGTH ) { hid_err ( hdev , \"errorrequestingGPIOconfig:%d\\\\n\" , ret ) ; goto exit ; } buf [ 1 ] &= ~ ( 1 << offset ) ; buf [ 2 ] = gpio_push_pull ; ret = hid_hw_raw_request ( hdev , CP2112_GPIO_CONFIG , buf , CP2112_GPIO_CONFIG_LENGTH , HID_FEATURE_REPORT , HID_REQ_SET_REPORT ) ; if ( ret < 0 ) { hid_err ( hdev , \"errorsettingGPIOconfig:%d\\\\n\" , ret ) ; goto exit ; } ret = 0 ; exit : spin_unlock_irqrestore ( & dev -> lock , flags ) ; return ret <= 0 ? ret : - EIO ; }\n", "\n", "1: CWE-404 static int cp2112_gpio_get_all ( struct gpio_chip * chip ) { struct cp2112_device * dev = gpiochip_get_data ( chip ) ; struct hid_device * hdev = dev -> hdev ; u8 * buf = dev -> in_out_buffer ; unsigned long flags ; int ret ; spin_lock_irqsave ( & dev -> lock , flags ) ; ret = hid_hw_raw_request ( hdev , CP2112_GPIO_GET , buf , CP2112_GPIO_GET_LENGTH , HID_FEATURE_REPORT , HID_REQ_GET_REPORT ) ; if ( ret != CP2112_GPIO_GET_LENGTH ) { hid_err ( hdev , \"errorrequestingGPIOvalues:%d\\\\n\" , ret ) ; ret = ret < 0 ? ret : - EIO ; goto exit ; } ret = buf [ 1 ] ; exit : spin_unlock_irqrestore ( & dev -> lock , flags ) ; return ret ; }\n", "\n", "\n", "Target: ; task -> tk_rebind_retry = 2 ; task ->\n", "\n", "Sources:\n", "0: CWE-399 static void rpc_init_task ( struct rpc_task * task , const struct rpc_task_setup * task_setup_data ) { memset ( task , 0 , sizeof ( * task ) ) ; atomic_set ( & task -> tk_count , 1 ) ; task -> tk_flags = task_setup_data -> flags ; task -> tk_ops = task_setup_data -> callback_ops ; task -> tk_calldata = task_setup_data -> callback_data ; INIT_LIST_HEAD ( & task -> tk_task ) ; task -> tk_garb_retry = 2 ; task -> tk_cred_retry = 2 ; task -> tk_priority = task_setup_data -> priority - RPC_PRIORITY_LOW ; task -> tk_owner = current -> tgid ; task -> tk_workqueue = task_setup_data -> workqueue ; if ( task -> tk_ops -> rpc_call_prepare != NULL ) task -> tk_action = rpc_prepare_task ; task -> tk_start = ktime_get ( ) ; dprintk ( \"RPC:newtaskinitialized,procpid%u\\\\n\" , task_pid_nr ( current ) ) ; }\n", "\n", "1: CWE-400 static void rpc_init_task ( struct rpc_task * task , const struct rpc_task_setup * task_setup_data ) { memset ( task , 0 , sizeof ( * task ) ) ; atomic_set ( & task -> tk_count , 1 ) ; task -> tk_flags = task_setup_data -> flags ; task -> tk_ops = task_setup_data -> callback_ops ; task -> tk_calldata = task_setup_data -> callback_data ; INIT_LIST_HEAD ( & task -> tk_task ) ; task -> tk_garb_retry = 2 ; task -> tk_cred_retry = 2 ; task -> tk_priority = task_setup_data -> priority - RPC_PRIORITY_LOW ; task -> tk_owner = current -> tgid ; task -> tk_workqueue = task_setup_data -> workqueue ; if ( task -> tk_ops -> rpc_call_prepare != NULL ) task -> tk_action = rpc_prepare_task ; task -> tk_start = ktime_get ( ) ; dprintk ( \"RPC:newtaskinitialized,procpid%u\\\\n\" , task_pid_nr ( current ) ) ; }\n", "\n", "\n", "Target: PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs , , 1 , regs , 0\n", "\n", "Sources:\n", "0: CWE-400 static int simulate_llsc ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == LL ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_ll ( regs , opcode ) ; } if ( ( opcode & OPCODE ) == SC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_sc ( regs , opcode ) ; } return - 1 ; }\n", "\n", "1: CWE-399 static int simulate_llsc ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == LL ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_ll ( regs , opcode ) ; } if ( ( opcode & OPCODE ) == SC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_sc ( regs , opcode ) ; } return - 1 ; }\n", "\n", "\n", "Target: ; int is_valid = ( error == GIT_OK ) giterr_clear ( ) ; error =\n", "\n", "Sources:\n", "0: CWE-284 static int http_connect ( http_subtransport * t ) { int error ; char * proxy_url ; if ( t -> connected && http_should_keep_alive ( & t -> parser ) && t -> parse_finished ) return 0 ; if ( t -> io ) { git_stream_close ( t -> io ) ; git_stream_free ( t -> io ) ; t -> io = NULL ; t -> connected = 0 ; } if ( t -> connection_data . use_ssl ) { error = git_tls_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; } else { # ifdef GIT_CURL error = git_curl_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # else error = git_socket_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # endif } if ( error < 0 ) return error ; GITERR_CHECK_VERSION ( t -> io , GIT_STREAM_VERSION , \"git_stream\" ) ; if ( git_stream_supports_proxy ( t -> io ) && ! git_remote__get_http_proxy ( t -> owner -> owner , ! ! t -> connection_data . use_ssl , & proxy_url ) ) { error = git_stream_set_proxy ( t -> io , proxy_url ) ; git__free ( proxy_url ) ; if ( error < 0 ) return error ; } error = git_stream_connect ( t -> io ) ; # if defined ( GIT_OPENSSL ) || defined ( GIT_SECURE_TRANSPORT ) || defined ( GIT_CURL ) if ( ( ! error || error == GIT_ECERTIFICATE ) && t -> owner -> certificate_check_cb != NULL && git_stream_is_encrypted ( t -> io ) ) { git_cert * cert ; int is_valid ; if ( ( error = git_stream_certificate ( & cert , t -> io ) ) < 0 ) return error ; giterr_clear ( ) ; is_valid = error != GIT_ECERTIFICATE ; error = t -> owner -> certificate_check_cb ( cert , is_valid , t -> connection_data . host , t -> owner -> message_cb_payload ) ; if ( error < 0 ) { if ( ! giterr_last ( ) ) giterr_set ( GITERR_NET , \"usercancelledcertificatecheck\" ) ; return error ; } } # endif if ( error < 0 ) return error ; t -> connected = 1 ; return 0 ; }\n", "\n", "1: CWE-284 static int http_connect ( http_subtransport * t ) { int error ; if ( t -> connected && http_should_keep_alive ( & t -> parser ) && t -> parse_finished ) return 0 ; if ( t -> io ) { git_stream_close ( t -> io ) ; git_stream_free ( t -> io ) ; t -> io = NULL ; t -> connected = 0 ; } if ( t -> connection_data . use_ssl ) { error = git_tls_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; } else { # ifdef GIT_CURL error = git_curl_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # else error = git_socket_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # endif } if ( error < 0 ) return error ; GITERR_CHECK_VERSION ( t -> io , GIT_STREAM_VERSION , \"git_stream\" ) ; apply_proxy_config ( t ) ; error = git_stream_connect ( t -> io ) ; if ( ( ! error || error == GIT_ECERTIFICATE ) && t -> owner -> certificate_check_cb != NULL && git_stream_is_encrypted ( t -> io ) ) { git_cert * cert ; int is_valid ; if ( ( error = git_stream_certificate ( & cert , t -> io ) ) < 0 ) return error ; giterr_clear ( ) ; is_valid = error != GIT_ECERTIFICATE ; error = t -> owner -> certificate_check_cb ( cert , is_valid , t -> connection_data . host , t -> owner -> message_cb_payload ) ; if ( error < 0 ) { if ( ! giterr_last ( ) ) giterr_set ( GITERR_NET , \"usercancelledcertificatecheck\" ) ; return error ; } } if ( error < 0 ) return error ; t -> connected = 1 ; return 0 ; }\n", "\n", "\n", "Target: -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels =\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; IndexPacket index ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register ssize_t x ; register PixelPacket * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , offset , pixel_info_length ; ssize_t count , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> matte = flags & 0x04 ? MagickTrue : MagickFalse ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 32 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; ( void ) ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\\\0' ; ( void ) SetImageProperty ( image , \"comment\" , comment ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( image -> matte != MagickFalse ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * number_planes_filled * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixel_info_length = image -> columns * image -> rows * number_planes_filled ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> matte == MagickFalse ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; operand ++ ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; p = pixels + offset ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( IsValidColormapIndex ( image , * p & mask , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { if ( IsValidColormapIndex ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> matte == MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) SetPixelIndex ( indexes + x , * p ++ ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelRed ( q , image -> colormap [ ( ssize_t ) index ] . red ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelGreen ( q , image -> colormap [ ( ssize_t ) index ] . green ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelBlue ( q , image -> colormap [ ( ssize_t ) index ] . blue ) ; SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelPacket * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-119 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; Quantum index ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , offset , pixel_info_length ; ssize_t count , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> alpha_trait = flags & 0x04 ? BlendPixelTrait : UndefinedPixelTrait ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 64 ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; count = ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\\\0' ; ( void ) SetImageProperty ( image , \"comment\" , comment , exception ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * number_planes_filled * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixel_info_length = image -> columns * image -> rows * number_planes_filled ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> alpha_trait == UndefinedPixelTrait ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { ValidateColormapValue ( image , * p & mask , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { ValidateColormapValue ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> alpha_trait == UndefinedPixelTrait ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . red ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . green ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . blue ) , q ) ; SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelInfo * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , \"\\\\122\\\\314\" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: uaddr_t a ; uaddr_t end_addr = 0 ; len , & end_addr ) ) return ( a = ROUNDDOWN ( uaddr , addr_incr ) ; a < ; a < end_addr ; a +=\n", "\n", "Sources:\n", "0: CWE-787 TEE_Result tee_mmu_check_access_rights ( const struct user_ta_ctx * utc , uint32_t flags , uaddr_t uaddr , size_t len ) { uaddr_t a ; size_t addr_incr = MIN ( CORE_MMU_USER_CODE_SIZE , CORE_MMU_USER_PARAM_SIZE ) ; if ( ADD_OVERFLOW ( uaddr , len , & a ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( flags & TEE_MEMORY_ACCESS_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ! ( flags & TEE_MEMORY_ACCESS_ANY_OWNER ) && ! tee_mmu_is_vbuf_inside_ta_private ( utc , ( void * ) uaddr , len ) ) return TEE_ERROR_ACCESS_DENIED ; for ( a = uaddr ; a < ( uaddr + len ) ; a += addr_incr ) { uint32_t attr ; TEE_Result res ; res = tee_mmu_user_va2pa_attr ( utc , ( void * ) a , NULL , & attr ) ; if ( res != TEE_SUCCESS ) return res ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_SECURE ) && ! ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_WRITE ) && ! ( attr & TEE_MATTR_UW ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_READ ) && ! ( attr & TEE_MATTR_UR ) ) return TEE_ERROR_ACCESS_DENIED ; } return TEE_SUCCESS ; }\n", "\n", "1: CWE-20 TEE_Result tee_mmu_check_access_rights ( const struct user_ta_ctx * utc , uint32_t flags , uaddr_t uaddr , size_t len ) { uaddr_t a ; size_t addr_incr = MIN ( CORE_MMU_USER_CODE_SIZE , CORE_MMU_USER_PARAM_SIZE ) ; if ( ADD_OVERFLOW ( uaddr , len , & a ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( flags & TEE_MEMORY_ACCESS_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ! ( flags & TEE_MEMORY_ACCESS_ANY_OWNER ) && ! tee_mmu_is_vbuf_inside_ta_private ( utc , ( void * ) uaddr , len ) ) return TEE_ERROR_ACCESS_DENIED ; for ( a = uaddr ; a < ( uaddr + len ) ; a += addr_incr ) { uint32_t attr ; TEE_Result res ; res = tee_mmu_user_va2pa_attr ( utc , ( void * ) a , NULL , & attr ) ; if ( res != TEE_SUCCESS ) return res ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_SECURE ) && ! ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_WRITE ) && ! ( attr & TEE_MATTR_UW ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_READ ) && ! ( attr & TEE_MATTR_UR ) ) return TEE_ERROR_ACCESS_DENIED ; } return TEE_SUCCESS ; }\n", "\n", "\n", "Target: ; Total += vpx_mse16x16 ( src +\n", "\n", "Sources:\n", "0: CWE-119 static int calc_partial_ssl_err ( YV12_BUFFER_CONFIG * source , YV12_BUFFER_CONFIG * dest ) { int i , j ; int Total = 0 ; int srcoffset , dstoffset ; unsigned char * src = source -> y_buffer ; unsigned char * dst = dest -> y_buffer ; int linestocopy ; linestocopy = ( source -> y_height >> 4 ) / PARTIAL_FRAME_FRACTION ; linestocopy = linestocopy ? linestocopy << 4 : 16 ; srcoffset = source -> y_stride * ( ( dest -> y_height >> 5 ) * 16 ) ; dstoffset = dest -> y_stride * ( ( dest -> y_height >> 5 ) * 16 ) ; src += srcoffset ; dst += dstoffset ; for ( i = 0 ; i < linestocopy ; i += 16 ) { for ( j = 0 ; j < source -> y_width ; j += 16 ) { unsigned int sse ; Total += vp8_mse16x16 ( src + j , source -> y_stride , dst + j , dest -> y_stride , & sse ) ; } src += 16 * source -> y_stride ; dst += 16 * dest -> y_stride ; } return Total ; }\n", "\n", "1: CWE-119 int vp8_calc_ss_err ( YV12_BUFFER_CONFIG * source , YV12_BUFFER_CONFIG * dest ) { int i , j ; int Total = 0 ; unsigned char * src = source -> y_buffer ; unsigned char * dst = dest -> y_buffer ; for ( i = 0 ; i < source -> y_height ; i += 16 ) { for ( j = 0 ; j < source -> y_width ; j += 16 ) { unsigned int sse ; Total += vp8_mse16x16 ( src + j , source -> y_stride , dst + j , dest -> y_stride , & sse ) ; } src += 16 * source -> y_stride ; dst += 16 * dest -> y_stride ; } return Total ; }\n", "\n", "\n", "Target: ( 2 * UPLOAD_BUFSIZE ) ; if ; } } DEBUGASSERT ( UPLOAD_BUFSIZE >= nread ) ;\n", "\n", "Sources:\n", "0: CWE-119 CURLcode Curl_smtp_escape_eob ( struct connectdata * conn , const ssize_t nread ) { ssize_t i ; ssize_t si ; struct Curl_easy * data = conn -> data ; struct SMTP * smtp = data -> req . protop ; char * scratch = data -> state . scratch ; char * newscratch = NULL ; char * oldscratch = NULL ; size_t eob_sent ; if ( ! scratch || data -> set . crlf ) { oldscratch = scratch ; scratch = newscratch = malloc ( 2 * data -> set . buffer_size ) ; if ( ! newscratch ) { failf ( data , \"Failedtoallocscratchbuffer!\" ) ; return CURLE_OUT_OF_MEMORY ; } } eob_sent = smtp -> eob ; for ( i = 0 , si = 0 ; i < nread ; i ++ ) { if ( SMTP_EOB [ smtp -> eob ] == data -> req . upload_fromhere [ i ] ) { smtp -> eob ++ ; if ( 2 == smtp -> eob || SMTP_EOB_LEN == smtp -> eob ) smtp -> trailing_crlf = TRUE ; else smtp -> trailing_crlf = FALSE ; } else if ( smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; if ( SMTP_EOB [ 0 ] == data -> req . upload_fromhere [ i ] ) smtp -> eob = 1 ; else smtp -> eob = 0 ; eob_sent = 0 ; smtp -> trailing_crlf = FALSE ; } if ( SMTP_EOB_FIND_LEN == smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB_REPL [ eob_sent ] , SMTP_EOB_REPL_LEN - eob_sent ) ; si += SMTP_EOB_REPL_LEN - eob_sent ; smtp -> eob = 0 ; eob_sent = 0 ; } else if ( ! smtp -> eob ) scratch [ si ++ ] = data -> req . upload_fromhere [ i ] ; } if ( smtp -> eob - eob_sent ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; } if ( si != nread ) { data -> req . upload_fromhere = scratch ; data -> state . scratch = scratch ; free ( oldscratch ) ; data -> req . upload_present = si ; } else free ( newscratch ) ; return CURLE_OK ; }\n", "\n", "1: CWE-787 CURLcode Curl_smtp_escape_eob ( struct connectdata * conn , const ssize_t nread ) { ssize_t i ; ssize_t si ; struct Curl_easy * data = conn -> data ; struct SMTP * smtp = data -> req . protop ; char * scratch = data -> state . scratch ; char * newscratch = NULL ; char * oldscratch = NULL ; size_t eob_sent ; if ( ! scratch || data -> set . crlf ) { oldscratch = scratch ; scratch = newscratch = malloc ( 2 * data -> set . buffer_size ) ; if ( ! newscratch ) { failf ( data , \"Failedtoallocscratchbuffer!\" ) ; return CURLE_OUT_OF_MEMORY ; } } eob_sent = smtp -> eob ; for ( i = 0 , si = 0 ; i < nread ; i ++ ) { if ( SMTP_EOB [ smtp -> eob ] == data -> req . upload_fromhere [ i ] ) { smtp -> eob ++ ; if ( 2 == smtp -> eob || SMTP_EOB_LEN == smtp -> eob ) smtp -> trailing_crlf = TRUE ; else smtp -> trailing_crlf = FALSE ; } else if ( smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; if ( SMTP_EOB [ 0 ] == data -> req . upload_fromhere [ i ] ) smtp -> eob = 1 ; else smtp -> eob = 0 ; eob_sent = 0 ; smtp -> trailing_crlf = FALSE ; } if ( SMTP_EOB_FIND_LEN == smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB_REPL [ eob_sent ] , SMTP_EOB_REPL_LEN - eob_sent ) ; si += SMTP_EOB_REPL_LEN - eob_sent ; smtp -> eob = 0 ; eob_sent = 0 ; } else if ( ! smtp -> eob ) scratch [ si ++ ] = data -> req . upload_fromhere [ i ] ; } if ( smtp -> eob - eob_sent ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; } if ( si != nread ) { data -> req . upload_fromhere = scratch ; data -> state . scratch = scratch ; free ( oldscratch ) ; data -> req . upload_present = si ; } else free ( newscratch ) ; return CURLE_OK ; }\n", "\n", "\n", "Target: ; if ( nlh -> nlmsg_len < NLMSG_HDRLEN || skb -> len < nlh -> nlmsg_len || struct nfgenmsg ) ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if\n", "\n", "Sources:\n", "0: CWE-125 static void nfnetlink_rcv_batch ( struct sk_buff * skb , struct nlmsghdr * nlh , u_int16_t subsys_id ) { struct sk_buff * oskb = skb ; struct net * net = sock_net ( skb -> sk ) ; const struct nfnetlink_subsystem * ss ; const struct nfnl_callback * nc ; static LIST_HEAD ( err_list ) ; u32 status ; int err ; if ( subsys_id >= NFNL_SUBSYS_COUNT ) return netlink_ack ( skb , nlh , - EINVAL ) ; replay : status = 0 ; skb = netlink_skb_clone ( oskb , GFP_KERNEL ) ; if ( ! skb ) return netlink_ack ( oskb , nlh , - ENOMEM ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) { # ifdef CONFIG_MODULES nfnl_unlock ( subsys_id ) ; request_module ( \"nfnetlink-subsys-%d\" , subsys_id ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) # endif { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } } if ( ! ss -> commit || ! ss -> abort ) { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } while ( skb -> len >= nlmsg_total_size ( 0 ) ) { int msglen , type ; nlh = nlmsg_hdr ( skb ) ; err = 0 ; if ( nlmsg_len ( nlh ) < sizeof ( struct nfgenmsg ) || skb -> len < nlh -> nlmsg_len ) { err = - EINVAL ; goto ack ; } if ( ! ( nlh -> nlmsg_flags & NLM_F_REQUEST ) ) { err = - EINVAL ; goto ack ; } type = nlh -> nlmsg_type ; if ( type == NFNL_MSG_BATCH_BEGIN ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } else if ( type == NFNL_MSG_BATCH_END ) { status |= NFNL_BATCH_DONE ; goto done ; } else if ( type < NLMSG_MIN_TYPE ) { err = - EINVAL ; goto ack ; } if ( NFNL_SUBSYS_ID ( type ) != subsys_id ) { err = - EINVAL ; goto ack ; } nc = nfnetlink_find_client ( type , ss ) ; if ( ! nc ) { err = - EINVAL ; goto ack ; } { int min_len = nlmsg_total_size ( sizeof ( struct nfgenmsg ) ) ; u_int8_t cb_id = NFNL_MSG_TYPE ( nlh -> nlmsg_type ) ; struct nlattr * cda [ ss -> cb [ cb_id ] . attr_count + 1 ] ; struct nlattr * attr = ( void * ) nlh + min_len ; int attrlen = nlh -> nlmsg_len - min_len ; err = nla_parse ( cda , ss -> cb [ cb_id ] . attr_count , attr , attrlen , ss -> cb [ cb_id ] . policy ) ; if ( err < 0 ) goto ack ; if ( nc -> call_batch ) { err = nc -> call_batch ( net , net -> nfnl , skb , nlh , ( const struct nlattr * * ) cda ) ; } if ( err == - EAGAIN ) { status |= NFNL_BATCH_REPLAY ; goto next ; } } ack : if ( nlh -> nlmsg_flags & NLM_F_ACK || err ) { if ( nfnl_err_add ( & err_list , nlh , err ) < 0 ) { nfnl_err_reset ( & err_list ) ; netlink_ack ( oskb , nlmsg_hdr ( oskb ) , - ENOMEM ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ( err ) status |= NFNL_BATCH_FAILURE ; } next : msglen = NLMSG_ALIGN ( nlh -> nlmsg_len ) ; if ( msglen > skb -> len ) msglen = skb -> len ; skb_pull ( skb , msglen ) ; } done : if ( status & NFNL_BATCH_REPLAY ) { ss -> abort ( net , oskb ) ; nfnl_err_reset ( & err_list ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; goto replay ; } else if ( status == NFNL_BATCH_DONE ) { ss -> commit ( net , oskb ) ; } else { ss -> abort ( net , oskb ) ; } nfnl_err_deliver ( & err_list , oskb ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; }\n", "\n", "1: CWE-200 static void nfnetlink_rcv_batch ( struct sk_buff * skb , struct nlmsghdr * nlh , u_int16_t subsys_id ) { struct sk_buff * oskb = skb ; struct net * net = sock_net ( skb -> sk ) ; const struct nfnetlink_subsystem * ss ; const struct nfnl_callback * nc ; static LIST_HEAD ( err_list ) ; u32 status ; int err ; if ( subsys_id >= NFNL_SUBSYS_COUNT ) return netlink_ack ( skb , nlh , - EINVAL ) ; replay : status = 0 ; skb = netlink_skb_clone ( oskb , GFP_KERNEL ) ; if ( ! skb ) return netlink_ack ( oskb , nlh , - ENOMEM ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) { # ifdef CONFIG_MODULES nfnl_unlock ( subsys_id ) ; request_module ( \"nfnetlink-subsys-%d\" , subsys_id ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) # endif { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } } if ( ! ss -> commit || ! ss -> abort ) { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } while ( skb -> len >= nlmsg_total_size ( 0 ) ) { int msglen , type ; nlh = nlmsg_hdr ( skb ) ; err = 0 ; if ( nlmsg_len ( nlh ) < sizeof ( struct nfgenmsg ) || skb -> len < nlh -> nlmsg_len ) { err = - EINVAL ; goto ack ; } if ( ! ( nlh -> nlmsg_flags & NLM_F_REQUEST ) ) { err = - EINVAL ; goto ack ; } type = nlh -> nlmsg_type ; if ( type == NFNL_MSG_BATCH_BEGIN ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } else if ( type == NFNL_MSG_BATCH_END ) { status |= NFNL_BATCH_DONE ; goto done ; } else if ( type < NLMSG_MIN_TYPE ) { err = - EINVAL ; goto ack ; } if ( NFNL_SUBSYS_ID ( type ) != subsys_id ) { err = - EINVAL ; goto ack ; } nc = nfnetlink_find_client ( type , ss ) ; if ( ! nc ) { err = - EINVAL ; goto ack ; } { int min_len = nlmsg_total_size ( sizeof ( struct nfgenmsg ) ) ; u_int8_t cb_id = NFNL_MSG_TYPE ( nlh -> nlmsg_type ) ; struct nlattr * cda [ ss -> cb [ cb_id ] . attr_count + 1 ] ; struct nlattr * attr = ( void * ) nlh + min_len ; int attrlen = nlh -> nlmsg_len - min_len ; err = nla_parse ( cda , ss -> cb [ cb_id ] . attr_count , attr , attrlen , ss -> cb [ cb_id ] . policy ) ; if ( err < 0 ) goto ack ; if ( nc -> call_batch ) { err = nc -> call_batch ( net , net -> nfnl , skb , nlh , ( const struct nlattr * * ) cda ) ; } if ( err == - EAGAIN ) { status |= NFNL_BATCH_REPLAY ; goto next ; } } ack : if ( nlh -> nlmsg_flags & NLM_F_ACK || err ) { if ( nfnl_err_add ( & err_list , nlh , err ) < 0 ) { nfnl_err_reset ( & err_list ) ; netlink_ack ( oskb , nlmsg_hdr ( oskb ) , - ENOMEM ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ( err ) status |= NFNL_BATCH_FAILURE ; } next : msglen = NLMSG_ALIGN ( nlh -> nlmsg_len ) ; if ( msglen > skb -> len ) msglen = skb -> len ; skb_pull ( skb , msglen ) ; } done : if ( status & NFNL_BATCH_REPLAY ) { ss -> abort ( net , oskb ) ; nfnl_err_reset ( & err_list ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; goto replay ; } else if ( status == NFNL_BATCH_DONE ) { ss -> commit ( net , oskb ) ; } else { ss -> abort ( net , oskb ) ; } nfnl_err_deliver ( & err_list , oskb ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; }\n", "\n", "\n", "Target: { if ( 3 == , o_element_count ) && 0 != * o_row_count && 0 != * o_column_count && 0 != * o_element_count ) { * o_column_idx\n", "\n", "Sources:\n", "0: CWE-119 int my_csr_reader ( const char * i_csr_file_in , unsigned int * * o_row_idx , unsigned int * * o_column_idx , REALTYPE * * o_values , unsigned int * o_row_count , unsigned int * o_column_count , unsigned int * o_element_count ) { FILE * l_csr_file_handle ; const unsigned int l_line_length = 512 ; char l_line [ 512 + 1 ] ; unsigned int l_header_read = 0 ; unsigned int * l_row_idx_id = NULL ; unsigned int l_i = 0 ; l_csr_file_handle = fopen ( i_csr_file_in , \"r\" ) ; if ( l_csr_file_handle == NULL ) { fprintf ( stderr , \"cannotopenCSRfile!\\\\n\" ) ; return - 1 ; } while ( fgets ( l_line , l_line_length , l_csr_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { fprintf ( stderr , \"couldnotreadfilelength!\\\\n\" ) ; return - 1 ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { if ( sscanf ( l_line , \"%u%u%u\" , o_row_count , o_column_count , o_element_count ) == 3 ) { * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; * o_row_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; * o_values = ( REALTYPE * ) malloc ( sizeof ( double ) * ( * o_element_count ) ) ; l_row_idx_id = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count ) ) ; if ( ( * o_row_idx == NULL ) || ( * o_column_idx == NULL ) || ( * o_values == NULL ) || ( l_row_idx_id == NULL ) ) { fprintf ( stderr , \"couldnotallocatespdata!\\\\n\" ) ; return - 1 ; } memset ( * o_row_idx , 0 , sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; memset ( * o_column_idx , 0 , sizeof ( unsigned int ) * ( * o_element_count ) ) ; memset ( * o_values , 0 , sizeof ( double ) * ( * o_element_count ) ) ; memset ( l_row_idx_id , 0 , sizeof ( unsigned int ) * ( * o_row_count ) ) ; for ( l_i = 0 ; l_i < ( * o_row_count + 1 ) ; l_i ++ ) ( * o_row_idx ) [ l_i ] = ( * o_element_count ) ; ( * o_row_idx ) [ 0 ] = 0 ; l_i = 0 ; l_header_read = 1 ; } else { fprintf ( stderr , \"couldnotcsrdescription!\\\\n\" ) ; return - 1 ; } } else { unsigned int l_row , l_column ; REALTYPE l_value ; if ( sscanf ( l_line , \"%u%u%lf\" , & l_row , & l_column , & l_value ) != 3 ) { fprintf ( stderr , \"couldnotreadelement!\\\\n\" ) ; return - 1 ; } l_row -- ; l_column -- ; ( * o_column_idx ) [ l_i ] = l_column ; ( * o_values ) [ l_i ] = l_value ; l_i ++ ; l_row_idx_id [ l_row ] = 1 ; ( * o_row_idx ) [ l_row + 1 ] = l_i ; } } } fclose ( l_csr_file_handle ) ; if ( l_i != ( * o_element_count ) ) { fprintf ( stderr , \"wewerenotabletoreadallelements!\\\\n\" ) ; return - 1 ; } for ( l_i = 0 ; l_i < ( * o_row_count ) ; l_i ++ ) { if ( l_row_idx_id [ l_i ] == 0 ) { ( * o_row_idx ) [ l_i + 1 ] = ( * o_row_idx ) [ l_i ] ; } } if ( l_row_idx_id != NULL ) { free ( l_row_idx_id ) ; } return 0 ; }\n", "\n", "1: CWE-119 void edge_sparse_csr_reader_double ( const char * i_csr_file_in , unsigned int * * o_row_idx , unsigned int * * o_column_idx , double * * o_values , unsigned int * o_row_count , unsigned int * o_column_count , unsigned int * o_element_count ) { FILE * l_csr_file_handle ; const unsigned int l_line_length = 512 ; char l_line [ 512 + 1 ] ; unsigned int l_header_read = 0 ; unsigned int * l_row_idx_id = NULL ; unsigned int l_i = 0 ; l_csr_file_handle = fopen ( i_csr_file_in , \"r\" ) ; if ( l_csr_file_handle == NULL ) { fprintf ( stderr , \"cannotopenCSRfile!\\\\n\" ) ; return ; } while ( fgets ( l_line , l_line_length , l_csr_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { fprintf ( stderr , \"couldnotreadfilelength!\\\\n\" ) ; return ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { if ( sscanf ( l_line , \"%u%u%u\" , o_row_count , o_column_count , o_element_count ) == 3 ) { * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; * o_row_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; * o_values = ( double * ) malloc ( sizeof ( double ) * ( * o_element_count ) ) ; l_row_idx_id = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count ) ) ; if ( ( * o_row_idx == NULL ) || ( * o_column_idx == NULL ) || ( * o_values == NULL ) || ( l_row_idx_id == NULL ) ) { fprintf ( stderr , \"couldnotallocatespdata!\\\\n\" ) ; return ; } memset ( * o_row_idx , 0 , sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; memset ( * o_column_idx , 0 , sizeof ( unsigned int ) * ( * o_element_count ) ) ; memset ( * o_values , 0 , sizeof ( double ) * ( * o_element_count ) ) ; memset ( l_row_idx_id , 0 , sizeof ( unsigned int ) * ( * o_row_count ) ) ; for ( l_i = 0 ; l_i < ( * o_row_count + 1 ) ; l_i ++ ) ( * o_row_idx ) [ l_i ] = ( * o_element_count ) ; ( * o_row_idx ) [ 0 ] = 0 ; l_i = 0 ; l_header_read = 1 ; } else { fprintf ( stderr , \"couldnotcsrdescription!\\\\n\" ) ; return ; } } else { unsigned int l_row , l_column ; double l_value ; if ( sscanf ( l_line , \"%u%u%lf\" , & l_row , & l_column , & l_value ) != 3 ) { fprintf ( stderr , \"couldnotreadelement!\\\\n\" ) ; return ; } l_row -- ; l_column -- ; ( * o_column_idx ) [ l_i ] = l_column ; ( * o_values ) [ l_i ] = l_value ; l_i ++ ; l_row_idx_id [ l_row ] = 1 ; ( * o_row_idx ) [ l_row + 1 ] = l_i ; } } } fclose ( l_csr_file_handle ) ; if ( l_i != ( * o_element_count ) ) { fprintf ( stderr , \"wewerenotabletoreadallelements!\\\\n\" ) ; return ; } for ( l_i = 0 ; l_i < ( * o_row_count ) ; l_i ++ ) { if ( l_row_idx_id [ l_i ] == 0 ) { ( * o_row_idx ) [ l_i + 1 ] = ( * o_row_idx ) [ l_i ] ; } } if ( l_row_idx_id != NULL ) { free ( l_row_idx_id ) ; } }\n", "\n", "\n", "Target: col < imagewidth && colb < imagew\n", "\n", "Sources:\n", "0: CWE-787 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , \"Error,can\\'treadtileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; }\n", "\n", "1: CWE-119 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , \"Error,can\\'treadtileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; }\n", "\n", "2: CWE-119 DECLAREwriteFunc ( writeBufferToContigTiles ) { uint32 imagew = TIFFScanlineSize ( out ) ; uint32 tilew = TIFFTileRowSize ( out ) ; int iskew = imagew - tilew ; tsize_t tilesize = TIFFTileSize ( out ) ; tdata_t obuf ; uint8 * bufp = ( uint8 * ) buf ; uint32 tl , tw ; uint32 row ; ( void ) spp ; obuf = _TIFFmalloc ( TIFFTileSize ( out ) ) ; if ( obuf == NULL ) return 0 ; _TIFFmemset ( obuf , 0 , tilesize ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILELENGTH , & tl ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILEWIDTH , & tw ) ; for ( row = 0 ; row < imagelength ; row += tilelength ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; int oskew = tilew - width ; cpStripToTile ( obuf , bufp + colb , nrow , width , oskew , oskew + iskew ) ; } else cpStripToTile ( obuf , bufp + colb , nrow , tilew , 0 , iskew ) ; if ( TIFFWriteTile ( out , obuf , col , row , 0 , 0 ) < 0 ) { TIFFError ( TIFFFileName ( out ) , \"Error,can\\'twritetileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; _TIFFfree ( obuf ) ; return 0 ; } colb += tilew ; } bufp += nrow * imagew ; } _TIFFfree ( obuf ) ; return 1 ; }\n", "\n", "3: CWE-787 DECLAREwriteFunc ( writeBufferToContigTiles ) { uint32 imagew = TIFFScanlineSize ( out ) ; uint32 tilew = TIFFTileRowSize ( out ) ; int iskew = imagew - tilew ; tsize_t tilesize = TIFFTileSize ( out ) ; tdata_t obuf ; uint8 * bufp = ( uint8 * ) buf ; uint32 tl , tw ; uint32 row ; ( void ) spp ; obuf = _TIFFmalloc ( TIFFTileSize ( out ) ) ; if ( obuf == NULL ) return 0 ; _TIFFmemset ( obuf , 0 , tilesize ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILELENGTH , & tl ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILEWIDTH , & tw ) ; for ( row = 0 ; row < imagelength ; row += tilelength ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; int oskew = tilew - width ; cpStripToTile ( obuf , bufp + colb , nrow , width , oskew , oskew + iskew ) ; } else cpStripToTile ( obuf , bufp + colb , nrow , tilew , 0 , iskew ) ; if ( TIFFWriteTile ( out , obuf , col , row , 0 , 0 ) < 0 ) { TIFFError ( TIFFFileName ( out ) , \"Error,can\\'twritetileat%lu%lu\" , ( unsigned long ) col , ( unsigned long ) row ) ; _TIFFfree ( obuf ) ; return 0 ; } colb += tilew ; } bufp += nrow * imagew ; } _TIFFfree ( obuf ) ; return 1 ; }\n", "\n", "\n", "Target: ( event , data , regs\n", "\n", "Sources:\n", "0: CWE-399 static void handle_associated_event ( struct cpu_hw_events * cpuc , int idx , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event * event = cpuc -> events [ idx ] ; struct hw_perf_event * hwc = & event -> hw ; mipspmu_event_update ( event , hwc , idx ) ; data -> period = event -> hw . last_period ; if ( ! mipspmu_event_set_period ( event , hwc , idx ) ) return ; if ( perf_event_overflow ( event , 0 , data , regs ) ) mipspmu -> disable_event ( idx ) ; }\n", "\n", "1: CWE-400 static void handle_associated_event ( struct cpu_hw_events * cpuc , int idx , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event * event = cpuc -> events [ idx ] ; struct hw_perf_event * hwc = & event -> hw ; mipspmu_event_update ( event , hwc , idx ) ; data -> period = event -> hw . last_period ; if ( ! mipspmu_event_set_period ( event , hwc , idx ) ) return ; if ( perf_event_overflow ( event , 0 , data , regs ) ) mipspmu -> disable_event ( idx ) ; }\n", "\n", "\n", "Target: bool sctp_verify_asconf ( const asoc , struct sctp_chunk * chunk , bool addr_param_needed , struct sctp_paramhdr errp ) { sctp_addip_chunk_t * addip = ( sctp_addip_chunk_t * ) chunk -> chunk_hdr ; union sctp_params sctp_params param ; bool addr_param_seen = false ; sctp_walk_params ( param , addip , addip_hdr . params ) { size_t length = ntohs ( param . p -> length ) ; * errp = param . p ; switch ( param . p -> type ) { case SCTP_PARAM_ERR_CAUSE : break ; case SCTP_PARAM_IPV4_ADDRESS : if ( length != sizeof ( sctp_ipv4addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_IPV6_ADDRESS : if ( length != sizeof ( sctp_ipv6addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : if ( addr_param_needed && ! addr_param_seen ) return false ; length = ntohs ( param . addip -> param_hdr . length ) ; if ( length < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return false ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return false ; break ; default : return false ; } } if ( addr_param_needed && ! addr_param_seen ) return false ; if ( ! addr_param_needed && addr_param_seen ) return false ; if ( param . v param . v != chunk -> chunk_end ) return false ; return true ; } \n", "\n", "Sources:\n", "0: CWE-399 int sctp_verify_asconf ( const struct sctp_association * asoc , struct sctp_paramhdr * param_hdr , void * chunk_end , struct sctp_paramhdr * * errp ) { sctp_addip_param_t * asconf_param ; union sctp_params param ; int length , plen ; param . v = ( sctp_paramhdr_t * ) param_hdr ; while ( param . v <= chunk_end - sizeof ( sctp_paramhdr_t ) ) { length = ntohs ( param . p -> length ) ; * errp = param . p ; if ( param . v > chunk_end - length || length < sizeof ( sctp_paramhdr_t ) ) return 0 ; switch ( param . p -> type ) { case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : asconf_param = ( sctp_addip_param_t * ) param . v ; plen = ntohs ( asconf_param -> param_hdr . length ) ; if ( plen < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return 0 ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return 0 ; break ; default : break ; } param . v += WORD_ROUND ( length ) ; } if ( param . v != chunk_end ) return 0 ; return 1 ; }\n", "\n", "1: CWE-20 int sctp_verify_asconf ( const struct sctp_association * asoc , struct sctp_paramhdr * param_hdr , void * chunk_end , struct sctp_paramhdr * * errp ) { sctp_addip_param_t * asconf_param ; union sctp_params param ; int length , plen ; param . v = ( sctp_paramhdr_t * ) param_hdr ; while ( param . v <= chunk_end - sizeof ( sctp_paramhdr_t ) ) { length = ntohs ( param . p -> length ) ; * errp = param . p ; if ( param . v > chunk_end - length || length < sizeof ( sctp_paramhdr_t ) ) return 0 ; switch ( param . p -> type ) { case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : asconf_param = ( sctp_addip_param_t * ) param . v ; plen = ntohs ( asconf_param -> param_hdr . length ) ; if ( plen < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return 0 ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return 0 ; break ; default : break ; } param . v += WORD_ROUND ( length ) ; } if ( param . v != chunk_end ) return 0 ; return 1 ; }\n", "\n", "\n", "Target: IOPRIO_NORM ) ; task_lock ( p ) ; -> ioprio ; task_unlock ( p ) ;\n", "\n", "Sources:\n", "0: CWE-362 static int get_task_ioprio ( struct task_struct * p ) { int ret ; ret = security_task_getioprio ( p ) ; if ( ret ) goto out ; ret = IOPRIO_PRIO_VALUE ( IOPRIO_CLASS_NONE , IOPRIO_NORM ) ; if ( p -> io_context ) ret = p -> io_context -> ioprio ; out : return ret ; }\n", "\n", "1: CWE-416 static int get_task_ioprio ( struct task_struct * p ) { int ret ; ret = security_task_getioprio ( p ) ; if ( ret ) goto out ; ret = IOPRIO_PRIO_VALUE ( IOPRIO_CLASS_NONE , IOPRIO_NORM ) ; if ( p -> io_context ) ret = p -> io_context -> ioprio ; out : return ret ; }\n", "\n", "\n", "Target: } ; return TEMP_FAILURE_RETRY ( , 0 ) )\n", "\n", "Sources:\n", "0: CWE-284 bool btsock_thread_remove_fd_and_close ( int thread_handle , int fd ) { if ( thread_handle < 0 || thread_handle >= MAX_THREAD ) { APPL_TRACE_ERROR ( \"%sinvalidthreadhandle:%d\" , __func__ , thread_handle ) ; return false ; } if ( fd == - 1 ) { APPL_TRACE_ERROR ( \"%sinvalidfiledescriptor.\" , __func__ ) ; return false ; } sock_cmd_t cmd = { CMD_REMOVE_FD , fd , 0 , 0 , 0 } ; return send ( ts [ thread_handle ] . cmd_fdw , & cmd , sizeof ( cmd ) , 0 ) == sizeof ( cmd ) ; }\n", "\n", "1: CWE-284 int btsock_thread_wakeup ( int h ) { if ( h < 0 || h >= MAX_THREAD ) { APPL_TRACE_ERROR ( \"invalidbtthreadhandle:%d\" , h ) ; return FALSE ; } if ( ts [ h ] . cmd_fdw == - 1 ) { APPL_TRACE_ERROR ( \"threadhandle:%d,cmdsocketisnotcreated\" , h ) ; return FALSE ; } sock_cmd_t cmd = { CMD_WAKEUP , 0 , 0 , 0 , 0 } ; return send ( ts [ h ] . cmd_fdw , & cmd , sizeof ( cmd ) , 0 ) == sizeof ( cmd ) ; }\n", "\n", "\n", "Target: ) ; } copy_file_as_user ( src , S_IWUSR ) ; fs_logger2 ( \"clone\" \"clone\" , dest ) ; unlink\n", "\n", "Sources:\n", "0: CWE-269 static void copy_xauthority ( void ) { char * src = RUN_XAUTHORITY_FILE ; char * dest ; if ( asprintf ( & dest , \"%s/.Xauthority\" , cfg . homedir ) == - 1 ) errExit ( \"asprintf\" ) ; if ( is_link ( dest ) ) { fprintf ( stderr , \"Error:%sisasymboliclink\\\\n\" , dest ) ; exit ( 1 ) ; } pid_t child = fork ( ) ; if ( child < 0 ) errExit ( \"fork\" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src , dest , getuid ( ) , getgid ( ) , S_IRUSR | S_IWUSR ) ; if ( rv ) fprintf ( stderr , \"Warning:cannottransfer.Xauthorityinprivatehomedirectory\\\\n\" ) ; else { fs_logger2 ( \"clone\" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; unlink ( src ) ; }\n", "\n", "1: CWE-269 static void copy_asoundrc ( void ) { char * src = RUN_ASOUNDRC_FILE ; char * dest ; if ( asprintf ( & dest , \"%s/.asoundrc\" , cfg . homedir ) == - 1 ) errExit ( \"asprintf\" ) ; if ( is_link ( dest ) ) { fprintf ( stderr , \"Error:%sisasymboliclink\\\\n\" , dest ) ; exit ( 1 ) ; } pid_t child = fork ( ) ; if ( child < 0 ) errExit ( \"fork\" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src , dest , getuid ( ) , getgid ( ) , S_IRUSR | S_IWUSR ) ; if ( rv ) fprintf ( stderr , \"Warning:cannottransfer.asoundrcinprivatehomedirectory\\\\n\" ) ; else { fs_logger2 ( \"clone\" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; unlink ( src ) ; }\n", "\n", "\n", "Target: ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : break ; default : return - EINVAL ; } lock_sock ( sk ) ; if ( . pg_vec ) { ret = - EBUSY ; - EBUSY ; } else { po -> tp_version = val ; ret = 0 ; } release_sock ( sk ) ; return ret ; } case PACKET_RESERVE\n", "\n", "Sources:\n", "0: CWE-362 static int packet_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct packet_sock * po = pkt_sk ( sk ) ; int ret ; if ( level != SOL_PACKET ) return - ENOPROTOOPT ; switch ( optname ) { case PACKET_ADD_MEMBERSHIP : case PACKET_DROP_MEMBERSHIP : { struct packet_mreq_max mreq ; int len = optlen ; memset ( & mreq , 0 , sizeof ( mreq ) ) ; if ( len < sizeof ( struct packet_mreq ) ) return - EINVAL ; if ( len > sizeof ( mreq ) ) len = sizeof ( mreq ) ; if ( copy_from_user ( & mreq , optval , len ) ) return - EFAULT ; if ( len < ( mreq . mr_alen + offsetof ( struct packet_mreq , mr_address ) ) ) return - EINVAL ; if ( optname == PACKET_ADD_MEMBERSHIP ) ret = packet_mc_add ( sk , & mreq ) ; else ret = packet_mc_drop ( sk , & mreq ) ; return ret ; } case PACKET_RX_RING : case PACKET_TX_RING : { union tpacket_req_u req_u ; int len ; switch ( po -> tp_version ) { case TPACKET_V1 : case TPACKET_V2 : len = sizeof ( req_u . req ) ; break ; case TPACKET_V3 : default : len = sizeof ( req_u . req3 ) ; break ; } if ( optlen < len ) return - EINVAL ; if ( copy_from_user ( & req_u . req , optval , len ) ) return - EFAULT ; return packet_set_ring ( sk , & req_u , 0 , optname == PACKET_TX_RING ) ; } case PACKET_COPY_THRESH : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; pkt_sk ( sk ) -> copy_thresh = val ; return 0 ; } case PACKET_VERSION : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : po -> tp_version = val ; return 0 ; default : return - EINVAL ; } } case PACKET_RESERVE : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_reserve = val ; return 0 ; } case PACKET_LOSS : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_loss = ! ! val ; return 0 ; } case PACKET_AUXDATA : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> auxdata = ! ! val ; return 0 ; } case PACKET_ORIGDEV : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> origdev = ! ! val ; return 0 ; } case PACKET_VNET_HDR : { int val ; if ( sock -> type != SOCK_RAW ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> has_vnet_hdr = ! ! val ; return 0 ; } case PACKET_TIMESTAMP : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tstamp = val ; return 0 ; } case PACKET_FANOUT : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; return fanout_add ( sk , val & 0xffff , val >> 16 ) ; } case PACKET_FANOUT_DATA : { if ( ! po -> fanout ) return - EINVAL ; return fanout_set_data ( po , optval , optlen ) ; } case PACKET_TX_HAS_OFF : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tx_has_off = ! ! val ; return 0 ; } case PACKET_QDISC_BYPASS : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> xmit = val ? packet_direct_xmit : dev_queue_xmit ; return 0 ; } default : return - ENOPROTOOPT ; } }\n", "\n", "1: CWE-416 static int packet_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct packet_sock * po = pkt_sk ( sk ) ; int ret ; if ( level != SOL_PACKET ) return - ENOPROTOOPT ; switch ( optname ) { case PACKET_ADD_MEMBERSHIP : case PACKET_DROP_MEMBERSHIP : { struct packet_mreq_max mreq ; int len = optlen ; memset ( & mreq , 0 , sizeof ( mreq ) ) ; if ( len < sizeof ( struct packet_mreq ) ) return - EINVAL ; if ( len > sizeof ( mreq ) ) len = sizeof ( mreq ) ; if ( copy_from_user ( & mreq , optval , len ) ) return - EFAULT ; if ( len < ( mreq . mr_alen + offsetof ( struct packet_mreq , mr_address ) ) ) return - EINVAL ; if ( optname == PACKET_ADD_MEMBERSHIP ) ret = packet_mc_add ( sk , & mreq ) ; else ret = packet_mc_drop ( sk , & mreq ) ; return ret ; } case PACKET_RX_RING : case PACKET_TX_RING : { union tpacket_req_u req_u ; int len ; switch ( po -> tp_version ) { case TPACKET_V1 : case TPACKET_V2 : len = sizeof ( req_u . req ) ; break ; case TPACKET_V3 : default : len = sizeof ( req_u . req3 ) ; break ; } if ( optlen < len ) return - EINVAL ; if ( copy_from_user ( & req_u . req , optval , len ) ) return - EFAULT ; return packet_set_ring ( sk , & req_u , 0 , optname == PACKET_TX_RING ) ; } case PACKET_COPY_THRESH : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; pkt_sk ( sk ) -> copy_thresh = val ; return 0 ; } case PACKET_VERSION : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : po -> tp_version = val ; return 0 ; default : return - EINVAL ; } } case PACKET_RESERVE : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_reserve = val ; return 0 ; } case PACKET_LOSS : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_loss = ! ! val ; return 0 ; } case PACKET_AUXDATA : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> auxdata = ! ! val ; return 0 ; } case PACKET_ORIGDEV : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> origdev = ! ! val ; return 0 ; } case PACKET_VNET_HDR : { int val ; if ( sock -> type != SOCK_RAW ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> has_vnet_hdr = ! ! val ; return 0 ; } case PACKET_TIMESTAMP : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tstamp = val ; return 0 ; } case PACKET_FANOUT : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; return fanout_add ( sk , val & 0xffff , val >> 16 ) ; } case PACKET_FANOUT_DATA : { if ( ! po -> fanout ) return - EINVAL ; return fanout_set_data ( po , optval , optlen ) ; } case PACKET_TX_HAS_OFF : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tx_has_off = ! ! val ; return 0 ; } case PACKET_QDISC_BYPASS : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> xmit = val ? packet_direct_xmit : dev_queue_xmit ; return 0 ; } default : return - ENOPROTOOPT ; } }\n", "\n", "\n" ] } ], "source": [ "unique_targets = train_df['target'].unique()\n", "\n", "for target_value in unique_targets:\n", " sources_for_target = train_df[train_df['target'] == target_value]['source'].unique()\n", "\n", " if len(sources_for_target) != 1:\n", " print(f\"Target: {target_value}\")\n", " print(\"Sources:\")\n", " for idx, source_value in enumerate(sources_for_target):\n", " print(f'{idx}: {source_value}')\n", " print()" ] }, { "cell_type": "code", "execution_count": 41, "id": "0bec8803", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Target: . left ; luaL_checkstack ( L , 1 , \"infunctionmp_unpack_full\" ) ;\n", "\n", "Sources:\n", "0: CWE-787 int mp_unpack_full ( lua_State * L , int limit , int offset ) { size_t len ; const char * s ; mp_cur c ; int cnt ; int decode_all = ( ! limit && ! offset ) ; s = luaL_checklstring ( L , 1 , & len ) ; if ( offset < 0 || limit < 0 ) return luaL_error ( L , \"Invalidrequesttounpackwithoffsetof%dandlimitof%d.\" , offset , len ) ; else if ( offset > len ) return luaL_error ( L , \"Startoffset%dgreaterthaninputlength%d.\" , offset , len ) ; if ( decode_all ) limit = INT_MAX ; mp_cur_init ( & c , ( const unsigned char * ) s + offset , len - offset ) ; for ( cnt = 0 ; c . left > 0 && cnt < limit ; cnt ++ ) { mp_decode_to_lua_type ( L , & c ) ; if ( c . err == MP_CUR_ERROR_EOF ) { return luaL_error ( L , \"Missingbytesininput.\" ) ; } else if ( c . err == MP_CUR_ERROR_BADFMT ) { return luaL_error ( L , \"Baddataformatininput.\" ) ; } } if ( ! decode_all ) { int offset = len - c . left ; lua_pushinteger ( L , c . left == 0 ? - 1 : offset ) ; lua_insert ( L , 2 ) ; cnt += 1 ; } return cnt ; }\n", "\n", "1: CWE-119 int mp_unpack_full ( lua_State * L , int limit , int offset ) { size_t len ; const char * s ; mp_cur c ; int cnt ; int decode_all = ( ! limit && ! offset ) ; s = luaL_checklstring ( L , 1 , & len ) ; if ( offset < 0 || limit < 0 ) return luaL_error ( L , \"Invalidrequesttounpackwithoffsetof%dandlimitof%d.\" , offset , len ) ; else if ( offset > len ) return luaL_error ( L , \"Startoffset%dgreaterthaninputlength%d.\" , offset , len ) ; if ( decode_all ) limit = INT_MAX ; mp_cur_init ( & c , ( const unsigned char * ) s + offset , len - offset ) ; for ( cnt = 0 ; c . left > 0 && cnt < limit ; cnt ++ ) { mp_decode_to_lua_type ( L , & c ) ; if ( c . err == MP_CUR_ERROR_EOF ) { return luaL_error ( L , \"Missingbytesininput.\" ) ; } else if ( c . err == MP_CUR_ERROR_BADFMT ) { return luaL_error ( L , \"Baddataformatininput.\" ) ; } } if ( ! decode_all ) { int offset = len - c . left ; lua_pushinteger ( L , c . left == 0 ? - 1 : offset ) ; lua_insert ( L , 2 ) ; cnt += 1 ; } return cnt ; }\n", "\n", "\n", "Target: { request_module ( \"crypto-%s\" , name ) ) request_module ( \"crypto-%s-all\" , name )\n", "\n", "Sources:\n", "0: CWE-269 struct crypto_alg * crypto_larval_lookup ( const char * name , u32 type , u32 mask ) { struct crypto_alg * alg ; if ( ! name ) return ERR_PTR ( - ENOENT ) ; mask &= ~ ( CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD ) ; type &= mask ; alg = crypto_alg_lookup ( name , type , mask ) ; if ( ! alg ) { request_module ( \"%s\" , name ) ; if ( ! ( ( type ^ CRYPTO_ALG_NEED_FALLBACK ) & mask & CRYPTO_ALG_NEED_FALLBACK ) ) request_module ( \"%s-all\" , name ) ; alg = crypto_alg_lookup ( name , type , mask ) ; } if ( alg ) return crypto_is_larval ( alg ) ? crypto_larval_wait ( alg ) : alg ; return crypto_larval_add ( name , type , mask ) ; }\n", "\n", "1: CWE-264 struct crypto_alg * crypto_larval_lookup ( const char * name , u32 type , u32 mask ) { struct crypto_alg * alg ; if ( ! name ) return ERR_PTR ( - ENOENT ) ; mask &= ~ ( CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD ) ; type &= mask ; alg = crypto_alg_lookup ( name , type , mask ) ; if ( ! alg ) { request_module ( \"%s\" , name ) ; if ( ! ( ( type ^ CRYPTO_ALG_NEED_FALLBACK ) & mask & CRYPTO_ALG_NEED_FALLBACK ) ) request_module ( \"%s-all\" , name ) ; alg = crypto_alg_lookup ( name , type , mask ) ; } if ( alg ) return crypto_is_larval ( alg ) ? crypto_larval_wait ( alg ) : alg ; return crypto_larval_add ( name , type , mask ) ; }\n", "\n", "\n", "Target: static\n", "\n", "Sources:\n", "0: CWE-119 void show_progress ( int frame_in , int frame_out , uint64_t dx_time ) { fprintf ( stderr , \"%ddecodedframes/%dshowedframesin%\" PRId64 \"us(%.2ffps)\\\\r\" , frame_in , frame_out , dx_time , ( double ) frame_out * 1000000.0 / ( double ) dx_time ) ; }\n", "\n", "1: CWE-119 int file_is_y4m ( const char detect [ 4 ] ) { if ( memcmp ( detect , \"YUV4\" , 4 ) == 0 ) { return 1 ; } return 0 ; }\n", "\n", "\n", "Target: ( ndo , \"%s\" , rpl_tstr ) ) ;\n", "\n", "Sources:\n", "0: CWE-125 static void rpl_dio_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const struct nd_rpl_dio * dio = ( const struct nd_rpl_dio * ) bp ; const char * dagid_str ; ND_TCHECK ( * dio ) ; dagid_str = ip6addr_string ( ndo , dio -> rpl_dagid ) ; ND_PRINT ( ( ndo , \"[dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]\" , dagid_str , dio -> rpl_dtsn , dio -> rpl_instanceid , EXTRACT_16BITS ( & dio -> rpl_dagrank ) , RPL_DIO_GROUNDED ( dio -> rpl_mopprf ) ? \"grounded,\" : \"\" , tok2str ( rpl_mop_values , \"mop%u\" , RPL_DIO_MOP ( dio -> rpl_mopprf ) ) , RPL_DIO_PRF ( dio -> rpl_mopprf ) ) ) ; if ( ndo -> ndo_vflag > 1 ) { const struct rpl_dio_genoption * opt = ( const struct rpl_dio_genoption * ) & dio [ 1 ] ; rpl_dio_printopt ( ndo , opt , length ) ; } return ; trunc : ND_PRINT ( ( ndo , \"[|truncated]\" ) ) ; return ; }\n", "\n", "1: CWE-125 static void rpl_daoack_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const struct nd_rpl_daoack * daoack = ( const struct nd_rpl_daoack * ) bp ; const char * dagid_str = \"\" ; ND_TCHECK2 ( * daoack , ND_RPL_DAOACK_MIN_LEN ) ; if ( length < ND_RPL_DAOACK_MIN_LEN ) goto tooshort ; bp += ND_RPL_DAOACK_MIN_LEN ; length -= ND_RPL_DAOACK_MIN_LEN ; if ( RPL_DAOACK_D ( daoack -> rpl_flags ) ) { ND_TCHECK2 ( daoack -> rpl_dagid , DAGID_LEN ) ; if ( length < DAGID_LEN ) goto tooshort ; dagid_str = ip6addr_string ( ndo , daoack -> rpl_dagid ) ; bp += DAGID_LEN ; length -= DAGID_LEN ; } ND_PRINT ( ( ndo , \"[dagid:%s,seq:%u,instance:%u,status:%u]\" , dagid_str , daoack -> rpl_daoseq , daoack -> rpl_instanceid , daoack -> rpl_status ) ) ; if ( ndo -> ndo_vflag > 1 ) { const struct rpl_dio_genoption * opt = ( const struct rpl_dio_genoption * ) bp ; rpl_dio_printopt ( ndo , opt , length ) ; } return ; trunc : ND_PRINT ( ( ndo , \"[|dao-truncated]\" ) ) ; return ; tooshort : ND_PRINT ( ( ndo , \"[|dao-lengthtooshort]\" ) ) ; return ; }\n", "\n", "\n", "Target: = NULL ; if ( ( & tmpname , \"/etc\" , \".vipw\" ) ) ==\n", "\n", "Sources:\n", "0: CWE-264 static FILE * pw_tmpfile ( int lockfd ) { FILE * fd ; char * tmpname = NULL ; char * dir = \"/etc\" ; if ( ( fd = xfmkstemp ( & tmpname , dir ) ) == NULL ) { ulckpwdf ( ) ; err ( EXIT_FAILURE , _ ( \"can\\'topentemporaryfile\" ) ) ; } copyfile ( lockfd , fileno ( fd ) ) ; tmp_file = tmpname ; return fd ; }\n", "\n", "1: CWE-000 static FILE * pw_tmpfile ( int lockfd ) { FILE * fd ; char * tmpname = NULL ; char * dir = \"/etc\" ; if ( ( fd = xfmkstemp ( & tmpname , dir ) ) == NULL ) { ulckpwdf ( ) ; err ( EXIT_FAILURE , _ ( \"can\\'topentemporaryfile\" ) ) ; } copyfile ( lockfd , fileno ( fd ) ) ; tmp_file = tmpname ; return fd ; }\n", "\n", "\n", "Target: rq ) ; prev -> sched_class\n", "\n", "Sources:\n", "0: CWE-835 static void put_prev_task ( struct rq * rq , struct task_struct * prev ) { if ( prev -> se . on_rq ) update_rq_clock ( rq ) ; rq -> skip_clock_update = 0 ; prev -> sched_class -> put_prev_task ( rq , prev ) ; }\n", "\n", "1: CWE-000 static void put_prev_task ( struct rq * rq , struct task_struct * prev ) { if ( prev -> se . on_rq ) update_rq_clock ( rq ) ; rq -> skip_clock_update = 0 ; prev -> sched_class -> put_prev_task ( rq , prev ) ; }\n", "\n", "\n", "Target: \n", "\n", "Sources:\n", "0: CWE-119 void cJSON_AddItemReferenceToObject ( cJSON * object , const char * string , cJSON * item ) { cJSON_AddItemToObject ( object , string , create_reference ( item ) ) ; }\n", "\n", "1: CWE-119 void cJSON_AddItemReferenceToArray ( cJSON * array , cJSON * item ) { cJSON_AddItemToArray ( array , create_reference ( item ) ) ; }\n", "\n", "2: CWE-119 void cJSON_DeleteItemFromArray ( cJSON * array , int which ) { cJSON_Delete ( cJSON_DetachItemFromArray ( array , which ) ) ; }\n", "\n", "3: CWE-119 cJSON * cJSON_CreateObject ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_Object ; return item ; }\n", "\n", "4: CWE-119 static cJSON * cJSON_New_Item ( void ) { cJSON * node = ( cJSON * ) cJSON_malloc ( sizeof ( cJSON ) ) ; if ( node ) memset ( node , 0 , sizeof ( cJSON ) ) ; return node ; }\n", "\n", "\n", "Target: , 1 , regs , address\n", "\n", "Sources:\n", "0: CWE-400 int handle_unaligned_access ( insn_size_t instruction , struct pt_regs * regs , struct mem_access * ma , int expected , unsigned long address ) { u_int rm ; int ret , index ; if ( instruction_size ( instruction ) != 2 ) return - EINVAL ; index = ( instruction >> 8 ) & 15 ; rm = regs -> regs [ index ] ; if ( ! expected ) { unaligned_fixups_notify ( current , instruction , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; } ret = - EFAULT ; switch ( instruction & 0xF000 ) { case 0x0000 : if ( instruction == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = regs -> pr ; } else if ( ( instruction & 0x00FF ) == 0x0023 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += rm + 4 ; } else if ( ( instruction & 0x00FF ) == 0x0003 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += rm + 4 ; } } else { goto simple ; } break ; case 0x1000 : goto simple ; case 0x2000 : goto simple ; case 0x4000 : if ( ( instruction & 0x00FF ) == 0x002B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = rm ; } else if ( ( instruction & 0x00FF ) == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc = rm ; } } else { goto simple ; } break ; case 0x5000 : goto simple ; case 0x6000 : goto simple ; case 0x8000 : switch ( instruction & 0x0F00 ) { case 0x0100 : goto simple ; case 0x0500 : goto simple ; case 0x0B00 : break ; case 0x0F00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) != 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; case 0x0900 : break ; case 0x0D00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) == 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; } break ; case 0xA000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; break ; case 0xB000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; } break ; } return ret ; simple : ret = handle_unaligned_ins ( instruction , regs , ma ) ; if ( ret == 0 ) regs -> pc += instruction_size ( instruction ) ; return ret ; }\n", "\n", "1: CWE-399 int handle_unaligned_access ( insn_size_t instruction , struct pt_regs * regs , struct mem_access * ma , int expected , unsigned long address ) { u_int rm ; int ret , index ; if ( instruction_size ( instruction ) != 2 ) return - EINVAL ; index = ( instruction >> 8 ) & 15 ; rm = regs -> regs [ index ] ; if ( ! expected ) { unaligned_fixups_notify ( current , instruction , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; } ret = - EFAULT ; switch ( instruction & 0xF000 ) { case 0x0000 : if ( instruction == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = regs -> pr ; } else if ( ( instruction & 0x00FF ) == 0x0023 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += rm + 4 ; } else if ( ( instruction & 0x00FF ) == 0x0003 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += rm + 4 ; } } else { goto simple ; } break ; case 0x1000 : goto simple ; case 0x2000 : goto simple ; case 0x4000 : if ( ( instruction & 0x00FF ) == 0x002B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = rm ; } else if ( ( instruction & 0x00FF ) == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc = rm ; } } else { goto simple ; } break ; case 0x5000 : goto simple ; case 0x6000 : goto simple ; case 0x8000 : switch ( instruction & 0x0F00 ) { case 0x0100 : goto simple ; case 0x0500 : goto simple ; case 0x0B00 : break ; case 0x0F00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) != 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; case 0x0900 : break ; case 0x0D00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) == 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; } break ; case 0xA000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; break ; case 0xB000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; } break ; } return ret ; simple : ret = handle_unaligned_ins ( instruction , regs , ma ) ; if ( ret == 0 ) regs -> pc += instruction_size ( instruction ) ; return ret ; }\n", "\n", "\n", "Target: ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; }\n", "\n", "Sources:\n", "0: CWE-119 static Image * ReadCMYKImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * canvas_image , * image ; MagickBooleanType status ; MagickOffsetType scene ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; size_t length ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , \"MustSpecifyImageSize\" ) ; SetImageColorspace ( image , CMYKColorspace ) ; if ( image_info -> interlace != PartitionInterlace ) { status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; } canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod ) ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; pixels = GetQuantumPixels ( quantum_info ) ; quantum_type = CMYKQuantum ; if ( LocaleCompare ( image_info -> magick , \"CMYKA\" ) == 0 ) { quantum_type = CMYKAQuantum ; image -> matte = MagickTrue ; } if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) break ; } } count = 0 ; length = 0 ; scene = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; SetImageColorspace ( image , CMYKColorspace ) ; switch ( image_info -> interlace ) { case NoInterlace : default : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; SetPixelGreen ( q , GetPixelGreen ( p ) ) ; SetPixelBlue ( q , GetPixelBlue ( p ) ) ; SetPixelBlack ( indexes + x , GetPixelBlack ( canvas_indexes + image -> extract_info . x + x ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } break ; } case LineInterlace : { static QuantumType quantum_types [ 5 ] = { CyanQuantum , MagentaQuantum , YellowQuantum , BlackQuantum , OpacityQuantum } ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } for ( i = 0 ; i < ( image -> matte != MagickFalse ? 5 : 4 ) ; i ++ ) { quantum_type = quantum_types [ i ] ; q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( quantum_type ) { case CyanQuantum : { SetPixelCyan ( q , GetPixelCyan ( p ) ) ; break ; } case MagentaQuantum : { SetPixelMagenta ( q , GetPixelMagenta ( p ) ) ; break ; } case YellowQuantum : { SetPixelYellow ( q , GetPixelYellow ( p ) ) ; break ; } case BlackQuantum : { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; break ; } case OpacityQuantum : { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; break ; } default : break ; } p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case PlaneInterlace : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , CyanQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , MagentaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlackQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 6 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , AlphaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 6 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 6 , 6 ) ; if ( status == MagickFalse ) break ; } break ; } case PartitionInterlace : { AppendImageFormat ( \"C\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , CyanQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"M\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , MagentaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , MagentaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"Y\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , YellowQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"K\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , BlackQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlackQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( \"A\" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , AlphaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 5 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 5 ) ; if ( status == MagickFalse ) break ; } break ; } } SetQuantumImageType ( image , quantum_type ) ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( count == ( ssize_t ) length ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } scene ++ ; } while ( count == ( ssize_t ) length ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; InheritException ( & image -> exception , & canvas_image -> exception ) ; canvas_image = DestroyImage ( canvas_image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "1: CWE-119 static Image * ReadAVSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; register PixelPacket * q ; register ssize_t x ; register unsigned char * p ; size_t height , width ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } width = ReadBlobMSBLong ( image ) ; height = ReadBlobMSBLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; if ( ( width == 0UL ) || ( height == 0UL ) ) ThrowReaderException ( CorruptImageError , \"ImproperImageHeader\" ) ; do { ssize_t length ; image -> columns = width ; image -> rows = height ; image -> depth = 8 ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 4 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , \"MemoryAllocationFailed\" ) ; length = ( size_t ) 4 * image -> columns ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != length ) ThrowReaderException ( CorruptImageError , \"UnableToReadImageData\" ) ; p = pixels ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( q -> opacity != OpaqueOpacity ) image -> matte = MagickTrue ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , \"UnexpectedEndOfFile\" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; width = ReadBlobMSBLong ( image ) ; height = ReadBlobMSBLong ( image ) ; if ( ( width != 0UL ) && ( height != 0UL ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( width != 0UL ) && ( height != 0UL ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }\n", "\n", "\n", "Target: if ( ! js_doregexec ( J , re -> prog\n", "\n", "Sources:\n", "0: CWE-674 static void Sp_search ( js_State * J ) { js_Regexp * re ; const char * text ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , \"\" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! js_regexec ( re -> prog , text , & m , 0 ) ) js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; else js_pushnumber ( J , - 1 ) ; }\n", "\n", "1: CWE-400 static void Sp_search ( js_State * J ) { js_Regexp * re ; const char * text ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , \"\" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! js_regexec ( re -> prog , text , & m , 0 ) ) js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; else js_pushnumber ( J , - 1 ) ; }\n", "\n", "\n", "Target: , int rep_quick , my_bool no_copy_stat 0 ) { myf flags = 0 ; if ( param -> testflag & T_BACKUP_DATA ) flags |= MY_REDEL_MAKE_BACKUP ; if ( no_copy_stat ) flags |= MY_REDEL_NO_COPY_STAT ; , DATA_TMP_EXT , flags ) || mi_open_datafile\n", "\n", "Sources:\n", "0: CWE-362 int mi_repair_parallel ( MI_CHECK * param , register MI_INFO * info , const char * name , int rep_quick ) { int got_error ; uint i , key , total_key_length , istep ; ulong rec_length ; ha_rows start_records ; my_off_t new_header_length , del ; File new_file ; MI_SORT_PARAM * sort_param = 0 ; MYISAM_SHARE * share = info -> s ; ulong * rec_per_key_part ; HA_KEYSEG * keyseg ; char llbuff [ 22 ] ; IO_CACHE new_data_cache ; IO_CACHE_SHARE io_share ; SORT_INFO sort_info ; ulonglong UNINIT_VAR ( key_map ) ; pthread_attr_t thr_attr ; ulong max_pack_reclength ; int error ; DBUG_ENTER ( \"mi_repair_parallel\" ) ; start_records = info -> state -> records ; got_error = 1 ; new_file = - 1 ; new_header_length = ( param -> testflag & T_UNPACK ) ? 0 : share -> pack . header_length ; if ( ! ( param -> testflag & T_SILENT ) ) { printf ( \"-parallelrecovering(withsort)MyISAM-table\\'%s\\'\\\\n\" , name ) ; printf ( \"Datarecords:%s\\\\n\" , llstr ( start_records , llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; DBUG_PRINT ( \"info\" , ( \"isquickrepair:%d\" , rep_quick ) ) ; bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ; mysql_mutex_init ( mi_key_mutex_MI_SORT_INFO_mutex , & sort_info . mutex , MY_MUTEX_INIT_FAST ) ; mysql_cond_init ( mi_key_cond_MI_SORT_INFO_cond , & sort_info . cond , 0 ) ; mysql_mutex_init ( mi_key_mutex_MI_CHECK_print_msg , & param -> print_msg_mutex , MY_MUTEX_INIT_FAST ) ; param -> need_print_msg_lock = 1 ; if ( ! ( sort_info . key_block = alloc_key_blocks ( param , ( uint ) param -> sort_key_blocks , share -> base . max_key_block_length ) ) || init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) || ( ! rep_quick && ( init_io_cache ( & info -> rec_cache , info -> dfile , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) & param -> myf_rw ) || init_io_cache ( & new_data_cache , - 1 , ( uint ) param -> write_buffer_length , READ_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_DONT_CHECK_FILESIZE ) ) ) ) ) goto err ; sort_info . key_block_end = sort_info . key_block + param -> sort_key_blocks ; info -> opt_flag |= WRITE_CACHE_USED ; info -> rec_cache . file = info -> dfile ; if ( ! rep_quick ) { if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , share -> data_file_name , \"\" , DATA_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) < 0 ) { mi_check_print_error ( param , \"Can\\'tcreatenewtempfile:\\'%s\\'\" , param -> temp_filename ) ; goto err ; } if ( new_header_length && filecopy ( param , new_file , info -> dfile , 0L , new_header_length , \"datafile-header\" ) ) goto err ; if ( param -> testflag & T_UNPACK ) { share -> options &= ~ HA_OPTION_COMPRESS_RECORD ; mi_int2store ( share -> state . header . options , share -> options ) ; } share -> state . dellink = HA_OFFSET_ERROR ; info -> rec_cache . file = new_file ; } info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; mi_drop_all_indexes ( param , info , FALSE ) ; key_map = share -> state . key_map ; if ( param -> testflag & T_CREATE_MISSING_KEYS ) { key_map = ~ key_map ; } sort_info . info = info ; sort_info . param = param ; set_data_file_type ( & sort_info , share ) ; sort_info . dupp = 0 ; sort_info . buff = 0 ; param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( param -> read_cache . file , 0L , MY_SEEK_END , MYF ( 0 ) ) ; if ( share -> data_file_type == DYNAMIC_RECORD ) rec_length = max ( share -> base . min_pack_length + 1 , share -> base . min_block_length ) ; else if ( share -> data_file_type == COMPRESSED_RECORD ) rec_length = share -> base . min_block_length ; else rec_length = share -> base . pack_reclength ; sort_info . max_records = ( ( param -> testflag & T_CREATE_MISSING_KEYS ) ? info -> state -> records + 1 : ( ha_rows ) ( sort_info . filelength / rec_length + 1 ) ) ; del = info -> state -> del ; param -> glob_crc = 0 ; max_pack_reclength = share -> base . pack_reclength ; if ( share -> options & HA_OPTION_COMPRESS_RECORD ) set_if_bigger ( max_pack_reclength , share -> max_pack_length ) ; if ( ! ( sort_param = ( MI_SORT_PARAM * ) my_malloc ( ( uint ) share -> base . keys * ( sizeof ( MI_SORT_PARAM ) + max_pack_reclength ) , MYF ( MY_ZEROFILL ) ) ) ) { mi_check_print_error ( param , \"Notenoughmemoryforkey!\" ) ; goto err ; } total_key_length = 0 ; rec_per_key_part = param -> rec_per_key_part ; info -> state -> records = info -> state -> del = share -> state . split = 0 ; info -> state -> empty = 0 ; for ( i = key = 0 , istep = 1 ; key < share -> base . keys ; rec_per_key_part += sort_param [ i ] . keyinfo -> keysegs , i += istep , key ++ ) { sort_param [ i ] . key = key ; sort_param [ i ] . keyinfo = share -> keyinfo + key ; sort_param [ i ] . seg = sort_param [ i ] . keyinfo -> seg ; if ( ! mi_is_key_active ( key_map , key ) ) { memcpy ( ( char * ) rec_per_key_part , ( char * ) ( share -> state . rec_per_key_part + ( uint ) ( rec_per_key_part - param -> rec_per_key_part ) ) , sort_param [ i ] . keyinfo -> keysegs * sizeof ( * rec_per_key_part ) ) ; istep = 0 ; continue ; } istep = 1 ; if ( ( ! ( param -> testflag & T_SILENT ) ) ) printf ( \"-Fixingindex%d\\\\n\" , key + 1 ) ; if ( sort_param [ i ] . keyinfo -> flag & HA_FULLTEXT ) { sort_param [ i ] . key_read = sort_ft_key_read ; sort_param [ i ] . key_write = sort_ft_key_write ; } else { sort_param [ i ] . key_read = sort_key_read ; sort_param [ i ] . key_write = sort_key_write ; } sort_param [ i ] . key_cmp = sort_key_cmp ; sort_param [ i ] . lock_in_memory = lock_memory ; sort_param [ i ] . tmpdir = param -> tmpdir ; sort_param [ i ] . sort_info = & sort_info ; sort_param [ i ] . master = 0 ; sort_param [ i ] . fix_datafile = 0 ; sort_param [ i ] . calc_checksum = 0 ; sort_param [ i ] . filepos = new_header_length ; sort_param [ i ] . max_pos = sort_param [ i ] . pos = share -> pack . header_length ; sort_param [ i ] . record = ( ( ( uchar * ) ( sort_param + share -> base . keys ) ) + ( max_pack_reclength * i ) ) ; if ( ! mi_alloc_rec_buff ( info , - 1 , & sort_param [ i ] . rec_buff ) ) { mi_check_print_error ( param , \"Notenoughmemory!\" ) ; goto err ; } sort_param [ i ] . key_length = share -> rec_reflength ; for ( keyseg = sort_param [ i ] . seg ; keyseg -> type != HA_KEYTYPE_END ; keyseg ++ ) { sort_param [ i ] . key_length += keyseg -> length ; if ( keyseg -> flag & HA_SPACE_PACK ) sort_param [ i ] . key_length += get_pack_length ( keyseg -> length ) ; if ( keyseg -> flag & ( HA_BLOB_PART | HA_VAR_LENGTH_PART ) ) sort_param [ i ] . key_length += 2 + test ( keyseg -> length >= 127 ) ; if ( keyseg -> flag & HA_NULL_PART ) sort_param [ i ] . key_length ++ ; } total_key_length += sort_param [ i ] . key_length ; if ( sort_param [ i ] . keyinfo -> flag & HA_FULLTEXT ) { uint ft_max_word_len_for_sort = FT_MAX_WORD_LEN_FOR_SORT * sort_param [ i ] . keyinfo -> seg -> charset -> mbmaxlen ; sort_param [ i ] . key_length += ft_max_word_len_for_sort - HA_FT_MAXBYTELEN ; init_alloc_root ( & sort_param [ i ] . wordroot , FTPARSER_MEMROOT_ALLOC_SIZE , 0 ) ; } } sort_info . total_keys = i ; sort_param [ 0 ] . master = 1 ; sort_param [ 0 ] . fix_datafile = ( my_bool ) ( ! rep_quick ) ; sort_param [ 0 ] . calc_checksum = test ( param -> testflag & T_CALC_CHECKSUM ) ; if ( ! ftparser_alloc_param ( info ) ) goto err ; sort_info . got_error = 0 ; mysql_mutex_lock ( & sort_info . mutex ) ; if ( i > 1 ) { if ( rep_quick ) init_io_cache_share ( & param -> read_cache , & io_share , NULL , i ) ; else init_io_cache_share ( & new_data_cache , & io_share , & info -> rec_cache , i ) ; } else io_share . total_threads = 0 ; ( void ) pthread_attr_init ( & thr_attr ) ; ( void ) pthread_attr_setdetachstate ( & thr_attr , PTHREAD_CREATE_DETACHED ) ; for ( i = 0 ; i < sort_info . total_keys ; i ++ ) { sort_param [ i ] . read_cache = ( ( rep_quick || ! i ) ? param -> read_cache : new_data_cache ) ; DBUG_PRINT ( \"io_cache_share\" , ( \"thread:%uread_cache:0x%lx\" , i , ( long ) & sort_param [ i ] . read_cache ) ) ; sort_param [ i ] . sortbuff_size = # ifndef USING_SECOND_APPROACH param -> sort_buffer_length / sort_info . total_keys ; # else param -> sort_buffer_length * sort_param [ i ] . key_length / total_key_length ; # endif if ( ( error = mysql_thread_create ( mi_key_thread_find_all_keys , & sort_param [ i ] . thr , & thr_attr , thr_find_all_keys , ( void * ) ( sort_param + i ) ) ) ) { mi_check_print_error ( param , \"Cannotstartarepairthread(errno=%d)\" , error ) ; if ( io_share . total_threads ) remove_io_thread ( & sort_param [ i ] . read_cache ) ; DBUG_PRINT ( \"error\" , ( \"Cannotstartarepairthread\" ) ) ; sort_info . got_error = 1 ; } else sort_info . threads_running ++ ; } ( void ) pthread_attr_destroy ( & thr_attr ) ; while ( sort_info . threads_running ) mysql_cond_wait ( & sort_info . cond , & sort_info . mutex ) ; mysql_mutex_unlock ( & sort_info . mutex ) ; if ( ( got_error = thr_write_keys ( sort_param ) ) ) { param -> retry_repair = 1 ; goto err ; } got_error = 1 ; if ( sort_param [ 0 ] . fix_datafile ) { if ( write_data_suffix ( & sort_info , 1 ) || end_io_cache ( & info -> rec_cache ) ) goto err ; if ( param -> testflag & T_SAFE_REPAIR ) { if ( info -> state -> records + 1 < start_records ) { info -> state -> records = start_records ; goto err ; } } share -> state . state . data_file_length = info -> state -> data_file_length = sort_param -> filepos ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; mysql_file_close ( info -> dfile , MYF ( 0 ) ) ; info -> dfile = new_file ; share -> data_file_type = sort_info . new_data_file_type ; share -> pack . header_length = ( ulong ) new_header_length ; } else info -> state -> data_file_length = sort_param -> max_pos ; if ( rep_quick && del + sort_info . dupp != info -> state -> del ) { mi_check_print_error ( param , \"Couldn\\'tfixtablewithquickrecovery:Foundwrongnumberofdeletedrecords\" ) ; mi_check_print_error ( param , \"Runrecoveryagainwithout-q\" ) ; param -> retry_repair = 1 ; param -> testflag |= T_RETRY_WITHOUT_QUICK ; goto err ; } if ( rep_quick & T_FORCE_UNIQUENESS ) { my_off_t skr = info -> state -> data_file_length + ( share -> options & HA_OPTION_COMPRESS_RECORD ? MEMMAP_EXTRA_MARGIN : 0 ) ; # ifdef USE_RELOC if ( share -> data_file_type == STATIC_RECORD && skr < share -> base . reloc * share -> base . min_pack_length ) skr = share -> base . reloc * share -> base . min_pack_length ; # endif if ( skr != sort_info . filelength ) if ( mysql_file_chsize ( info -> dfile , skr , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , \"Can\\'tchangesizeofdatafile,error:%d\" , my_errno ) ; } if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ; if ( mysql_file_chsize ( share -> kfile , info -> state -> key_file_length , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , \"Can\\'tchangesizeofindexfile,error:%d\" , my_errno ) ; if ( ! ( param -> testflag & T_SILENT ) ) { if ( start_records != info -> state -> records ) printf ( \"Datarecords:%s\\\\n\" , llstr ( info -> state -> records , llbuff ) ) ; if ( sort_info . dupp ) mi_check_print_warning ( param , \"%srecordshavebeenremoved\" , llstr ( sort_info . dupp , llbuff ) ) ; } got_error = 0 ; if ( & share -> state . state != info -> state ) memcpy ( & share -> state . state , info -> state , sizeof ( * info -> state ) ) ; err : got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; ( void ) end_io_cache ( & info -> rec_cache ) ; if ( ! rep_quick ) ( void ) end_io_cache ( & new_data_cache ) ; if ( ! got_error ) { if ( new_file >= 0 ) { mysql_file_close ( new_file , MYF ( 0 ) ) ; info -> dfile = new_file = - 1 ; if ( change_to_newfile ( share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT , ( param -> testflag & T_BACKUP_DATA ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) || mi_open_datafile ( info , share , name , - 1 ) ) got_error = 1 ; } } if ( got_error ) { if ( ! param -> error_printed ) mi_check_print_error ( param , \"%dwhenfixingtable\" , my_errno ) ; if ( new_file >= 0 ) { ( void ) mysql_file_close ( new_file , MYF ( 0 ) ) ; ( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ; if ( info -> dfile == new_file ) if ( unlikely ( mi_open_datafile ( info , share , name , - 1 ) ) ) param -> retry_repair = 0 ; } mi_mark_crashed_on_repair ( info ) ; } else if ( key_map == share -> state . key_map ) share -> state . changed &= ~ STATE_NOT_OPTIMIZED_KEYS ; share -> state . changed |= STATE_NOT_SORTED_PAGES ; mysql_cond_destroy ( & sort_info . cond ) ; mysql_mutex_destroy ( & sort_info . mutex ) ; mysql_mutex_destroy ( & param -> print_msg_mutex ) ; param -> need_print_msg_lock = 0 ; my_free ( sort_info . ft_buf ) ; my_free ( sort_info . key_block ) ; my_free ( sort_param ) ; my_free ( sort_info . buff ) ; ( void ) end_io_cache ( & param -> read_cache ) ; info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ; if ( ! got_error && ( param -> testflag & T_UNPACK ) ) { share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ; share -> pack . header_length = 0 ; } DBUG_RETURN ( got_error ) ; }\n", "\n", "1: CWE-362 int mi_repair_by_sort ( MI_CHECK * param , register MI_INFO * info , const char * name , int rep_quick ) { int got_error ; uint i ; ulong length ; ha_rows start_records ; my_off_t new_header_length , del ; File new_file ; MI_SORT_PARAM sort_param ; MYISAM_SHARE * share = info -> s ; HA_KEYSEG * keyseg ; ulong * rec_per_key_part ; char llbuff [ 22 ] ; SORT_INFO sort_info ; ulonglong UNINIT_VAR ( key_map ) ; DBUG_ENTER ( \"mi_repair_by_sort\" ) ; start_records = info -> state -> records ; got_error = 1 ; new_file = - 1 ; new_header_length = ( param -> testflag & T_UNPACK ) ? 0 : share -> pack . header_length ; if ( ! ( param -> testflag & T_SILENT ) ) { printf ( \"-recovering(withsort)MyISAM-table\\'%s\\'\\\\n\" , name ) ; printf ( \"Datarecords:%s\\\\n\" , llstr ( start_records , llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ; bzero ( ( char * ) & sort_param , sizeof ( sort_param ) ) ; if ( ! ( sort_info . key_block = alloc_key_blocks ( param , ( uint ) param -> sort_key_blocks , share -> base . max_key_block_length ) ) || init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) || ( ! rep_quick && init_io_cache ( & info -> rec_cache , info -> dfile , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) & param -> myf_rw ) ) ) goto err ; sort_info . key_block_end = sort_info . key_block + param -> sort_key_blocks ; info -> opt_flag |= WRITE_CACHE_USED ; info -> rec_cache . file = info -> dfile ; if ( ! mi_alloc_rec_buff ( info , - 1 , & sort_param . record ) || ! mi_alloc_rec_buff ( info , - 1 , & sort_param . rec_buff ) ) { mi_check_print_error ( param , \"Notenoughmemoryforextrarecord\" ) ; goto err ; } if ( ! rep_quick ) { if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , share -> data_file_name , \"\" , DATA_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) < 0 ) { mi_check_print_error ( param , \"Can\\'tcreatenewtempfile:\\'%s\\'\" , param -> temp_filename ) ; goto err ; } if ( new_header_length && filecopy ( param , new_file , info -> dfile , 0L , new_header_length , \"datafile-header\" ) ) goto err ; if ( param -> testflag & T_UNPACK ) { share -> options &= ~ HA_OPTION_COMPRESS_RECORD ; mi_int2store ( share -> state . header . options , share -> options ) ; } share -> state . dellink = HA_OFFSET_ERROR ; info -> rec_cache . file = new_file ; } info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; mi_drop_all_indexes ( param , info , FALSE ) ; key_map = share -> state . key_map ; if ( param -> testflag & T_CREATE_MISSING_KEYS ) { key_map = ~ key_map ; } sort_info . info = info ; sort_info . param = param ; set_data_file_type ( & sort_info , share ) ; sort_param . filepos = new_header_length ; sort_info . dupp = 0 ; sort_info . buff = 0 ; param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( param -> read_cache . file , 0L , MY_SEEK_END , MYF ( 0 ) ) ; sort_param . wordlist = NULL ; init_alloc_root ( & sort_param . wordroot , FTPARSER_MEMROOT_ALLOC_SIZE , 0 ) ; if ( share -> data_file_type == DYNAMIC_RECORD ) length = max ( share -> base . min_pack_length + 1 , share -> base . min_block_length ) ; else if ( share -> data_file_type == COMPRESSED_RECORD ) length = share -> base . min_block_length ; else length = share -> base . pack_reclength ; sort_info . max_records = ( ( param -> testflag & T_CREATE_MISSING_KEYS ) ? info -> state -> records : ( ha_rows ) ( sort_info . filelength / length + 1 ) ) ; sort_param . key_cmp = sort_key_cmp ; sort_param . lock_in_memory = lock_memory ; sort_param . tmpdir = param -> tmpdir ; sort_param . sort_info = & sort_info ; sort_param . fix_datafile = ( my_bool ) ( ! rep_quick ) ; sort_param . master = 1 ; del = info -> state -> del ; param -> glob_crc = 0 ; if ( param -> testflag & T_CALC_CHECKSUM ) sort_param . calc_checksum = 1 ; rec_per_key_part = param -> rec_per_key_part ; for ( sort_param . key = 0 ; sort_param . key < share -> base . keys ; rec_per_key_part += sort_param . keyinfo -> keysegs , sort_param . key ++ ) { sort_param . read_cache = param -> read_cache ; sort_param . keyinfo = share -> keyinfo + sort_param . key ; sort_param . seg = sort_param . keyinfo -> seg ; if ( ! mi_is_key_active ( key_map , sort_param . key ) ) { memcpy ( ( char * ) rec_per_key_part , ( char * ) ( share -> state . rec_per_key_part + ( uint ) ( rec_per_key_part - param -> rec_per_key_part ) ) , sort_param . keyinfo -> keysegs * sizeof ( * rec_per_key_part ) ) ; DBUG_PRINT ( \"repair\" , ( \"skippingseeminglydisabledindex#:%u\" , sort_param . key ) ) ; continue ; } if ( ( ! ( param -> testflag & T_SILENT ) ) ) printf ( \"-Fixingindex%d\\\\n\" , sort_param . key + 1 ) ; sort_param . max_pos = sort_param . pos = share -> pack . header_length ; keyseg = sort_param . seg ; bzero ( ( char * ) sort_param . unique , sizeof ( sort_param . unique ) ) ; sort_param . key_length = share -> rec_reflength ; for ( i = 0 ; keyseg [ i ] . type != HA_KEYTYPE_END ; i ++ ) { sort_param . key_length += keyseg [ i ] . length ; if ( keyseg [ i ] . flag & HA_SPACE_PACK ) sort_param . key_length += get_pack_length ( keyseg [ i ] . length ) ; if ( keyseg [ i ] . flag & ( HA_BLOB_PART | HA_VAR_LENGTH_PART ) ) sort_param . key_length += 2 + test ( keyseg [ i ] . length >= 127 ) ; if ( keyseg [ i ] . flag & HA_NULL_PART ) sort_param . key_length ++ ; } info -> state -> records = info -> state -> del = share -> state . split = 0 ; info -> state -> empty = 0 ; if ( sort_param . keyinfo -> flag & HA_FULLTEXT ) { uint ft_max_word_len_for_sort = FT_MAX_WORD_LEN_FOR_SORT * sort_param . keyinfo -> seg -> charset -> mbmaxlen ; sort_param . key_length += ft_max_word_len_for_sort - HA_FT_MAXBYTELEN ; if ( sort_param . keyinfo -> parser == & ft_default_parser ) { sort_info . max_records = ( ha_rows ) ( sort_info . filelength / ft_min_word_len + 1 ) ; } else { sort_info . max_records = 10 * max ( param -> sort_buffer_length , MIN_SORT_BUFFER ) / sort_param . key_length ; } sort_param . key_read = sort_ft_key_read ; sort_param . key_write = sort_ft_key_write ; } else { sort_param . key_read = sort_key_read ; sort_param . key_write = sort_key_write ; } if ( _create_index_by_sort ( & sort_param , ( my_bool ) ( ! ( param -> testflag & T_VERBOSE ) ) , param -> sort_buffer_length ) ) { param -> retry_repair = 1 ; goto err ; } sort_param . calc_checksum = 0 ; free_root ( & sort_param . wordroot , MYF ( 0 ) ) ; sort_info . max_records = ( ha_rows ) info -> state -> records ; if ( param -> testflag & T_STATISTICS ) update_key_parts ( sort_param . keyinfo , rec_per_key_part , sort_param . unique , param -> stats_method == MI_STATS_METHOD_IGNORE_NULLS ? sort_param . notnull : NULL , ( ulonglong ) info -> state -> records ) ; mi_set_key_active ( share -> state . key_map , sort_param . key ) ; DBUG_PRINT ( \"repair\" , ( \"setenabledindex#:%u\" , sort_param . key ) ) ; if ( sort_param . fix_datafile ) { param -> read_cache . end_of_file = sort_param . filepos ; if ( write_data_suffix ( & sort_info , 1 ) || end_io_cache ( & info -> rec_cache ) ) goto err ; if ( param -> testflag & T_SAFE_REPAIR ) { if ( info -> state -> records + 1 < start_records ) { info -> state -> records = start_records ; goto err ; } } share -> state . state . data_file_length = info -> state -> data_file_length = sort_param . filepos ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; mysql_file_close ( info -> dfile , MYF ( 0 ) ) ; info -> dfile = new_file ; share -> data_file_type = sort_info . new_data_file_type ; share -> pack . header_length = ( ulong ) new_header_length ; sort_param . fix_datafile = 0 ; } else info -> state -> data_file_length = sort_param . max_pos ; param -> read_cache . file = info -> dfile ; reinit_io_cache ( & param -> read_cache , READ_CACHE , share -> pack . header_length , 1 , 1 ) ; } if ( param -> testflag & T_WRITE_LOOP ) { ( void ) fputs ( \"\\\\r\" , stdout ) ; ( void ) fflush ( stdout ) ; } if ( rep_quick && del + sort_info . dupp != info -> state -> del ) { mi_check_print_error ( param , \"Couldn\\'tfixtablewithquickrecovery:Foundwrongnumberofdeletedrecords\" ) ; mi_check_print_error ( param , \"Runrecoveryagainwithout-q\" ) ; got_error = 1 ; param -> retry_repair = 1 ; param -> testflag |= T_RETRY_WITHOUT_QUICK ; goto err ; } if ( rep_quick & T_FORCE_UNIQUENESS ) { my_off_t skr = info -> state -> data_file_length + ( share -> options & HA_OPTION_COMPRESS_RECORD ? MEMMAP_EXTRA_MARGIN : 0 ) ; # ifdef USE_RELOC if ( share -> data_file_type == STATIC_RECORD && skr < share -> base . reloc * share -> base . min_pack_length ) skr = share -> base . reloc * share -> base . min_pack_length ; # endif if ( skr != sort_info . filelength ) if ( mysql_file_chsize ( info -> dfile , skr , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , \"Can\\'tchangesizeofdatafile,error:%d\" , my_errno ) ; } if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ; if ( mysql_file_chsize ( share -> kfile , info -> state -> key_file_length , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , \"Can\\'tchangesizeofindexfile,error:%d\" , my_errno ) ; if ( ! ( param -> testflag & T_SILENT ) ) { if ( start_records != info -> state -> records ) printf ( \"Datarecords:%s\\\\n\" , llstr ( info -> state -> records , llbuff ) ) ; if ( sort_info . dupp ) mi_check_print_warning ( param , \"%srecordshavebeenremoved\" , llstr ( sort_info . dupp , llbuff ) ) ; } got_error = 0 ; if ( & share -> state . state != info -> state ) memcpy ( & share -> state . state , info -> state , sizeof ( * info -> state ) ) ; err : got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; ( void ) end_io_cache ( & info -> rec_cache ) ; if ( ! got_error ) { if ( new_file >= 0 ) { mysql_file_close ( new_file , MYF ( 0 ) ) ; info -> dfile = new_file = - 1 ; if ( change_to_newfile ( share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT , ( param -> testflag & T_BACKUP_DATA ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) || mi_open_datafile ( info , share , name , - 1 ) ) got_error = 1 ; } } if ( got_error ) { if ( ! param -> error_printed ) mi_check_print_error ( param , \"%dwhenfixingtable\" , my_errno ) ; if ( new_file >= 0 ) { ( void ) mysql_file_close ( new_file , MYF ( 0 ) ) ; ( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ; if ( info -> dfile == new_file ) if ( unlikely ( mi_open_datafile ( info , share , name , - 1 ) ) ) param -> retry_repair = 0 ; } mi_mark_crashed_on_repair ( info ) ; } else if ( key_map == share -> state . key_map ) share -> state . changed &= ~ STATE_NOT_OPTIMIZED_KEYS ; share -> state . changed |= STATE_NOT_SORTED_PAGES ; my_free ( mi_get_rec_buff_ptr ( info , sort_param . rec_buff ) ) ; my_free ( mi_get_rec_buff_ptr ( info , sort_param . record ) ) ; my_free ( sort_info . key_block ) ; my_free ( sort_info . ft_buf ) ; my_free ( sort_info . buff ) ; ( void ) end_io_cache ( & param -> read_cache ) ; info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ; if ( ! got_error && ( param -> testflag & T_UNPACK ) ) { share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ; share -> pack . header_length = 0 ; } DBUG_RETURN ( got_error ) ; }\n", "\n", "\n", "Target: ; RAnalOp next_op = { 0 }\n", "\n", "Sources:\n", "0: CWE-416 INST_HANDLER ( cpse ) { int r = ( buf [ 0 ] & 0xf ) | ( ( buf [ 1 ] & 0x2 ) << 3 ) ; int d = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x1 ) << 4 ) ; RAnalOp next_op ; avr_op_analyze ( anal , & next_op , op -> addr + op -> size , buf + op -> size , len - op -> size , cpu ) ; r_strbuf_fini ( & next_op . esil ) ; op -> jump = op -> addr + next_op . size + 2 ; op -> cycles = 1 ; ESIL_A ( \"r%d,r%d,^,!,\" , r , d ) ; ESIL_A ( \"?{,%\" PFMT64d \",pc,=,},\" , op -> jump ) ; }\n", "\n", "1: CWE-908 INST_HANDLER ( cpse ) { int r = ( buf [ 0 ] & 0xf ) | ( ( buf [ 1 ] & 0x2 ) << 3 ) ; int d = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x1 ) << 4 ) ; RAnalOp next_op ; avr_op_analyze ( anal , & next_op , op -> addr + op -> size , buf + op -> size , len - op -> size , cpu ) ; r_strbuf_fini ( & next_op . esil ) ; op -> jump = op -> addr + next_op . size + 2 ; op -> cycles = 1 ; ESIL_A ( \"r%d,r%d,^,!,\" , r , d ) ; ESIL_A ( \"?{,%\" PFMT64d \",pc,=,},\" , op -> jump ) ; }\n", "\n", "\n", "Target: NULL ; return match ( prog eflags , sub , 0\n", "\n", "Sources:\n", "0: CWE-674 int regexec ( Reprog * prog , const char * sp , Resub * sub , int eflags ) { Resub scratch ; int i ; if ( ! sub ) sub = & scratch ; sub -> nsub = prog -> nsub ; for ( i = 0 ; i < MAXSUB ; ++ i ) sub -> sub [ i ] . sp = sub -> sub [ i ] . ep = NULL ; return ! match ( prog -> start , sp , sp , prog -> flags | eflags , sub ) ; }\n", "\n", "1: CWE-400 int regexec ( Reprog * prog , const char * sp , Resub * sub , int eflags ) { Resub scratch ; int i ; if ( ! sub ) sub = & scratch ; sub -> nsub = prog -> nsub ; for ( i = 0 ; i < MAXSUB ; ++ i ) sub -> sub [ i ] . sp = sub -> sub [ i ] . ep = NULL ; return ! match ( prog -> start , sp , sp , prog -> flags | eflags , sub ) ; }\n", "\n", "\n", "Target: action ) { char * outpos = outputbuffer ; action ) ; sendClean ( outputbuffer ) ;\n", "\n", "Sources:\n", "0: CWE-20 void BezierCircle ( double r , char * action ) { outpos += sprintf ( outpos , \"%12.3f0m%12.3f%12.3f%12.3f%12.3f0%12.3fc\\\\n\" , - r , - r , r * BzK , - r * BzK , r , r ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f%12.3f0c\\\\n\" , r * BzK , r , r , r * BzK , r ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f0%12.3fc\\\\n\" , r , - r * BzK , r * BzK , - r , - r ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f%12.3f0c%s\\\\n\" , - r * BzK , - r , - r , - r * BzK , - r , action ) ; } \n", "\n", "1: CWE-20 void BezierOval ( double w , double h , char * action ) { outpos += sprintf ( outpos , \"%12.3f0m%12.3f%12.3f%12.3f%12.3f0%12.3fc\\\\n\" , - w , - w , h * BzK , - w * BzK , h , h ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f%12.3f0c\\\\n\" , w * BzK , h , w , h * BzK , w ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f0%12.3fc\\\\n\" , w , - h * BzK , w * BzK , - h , - h ) ; outpos += sprintf ( outpos , \"%12.3f%12.3f%12.3f%12.3f%12.3f0c%s\\\\n\" , - w * BzK , - h , - w , - h * BzK , - w , action ) ; } \n", "\n", "\n", "Target: IPV6_DSTOPTS : { struct ipv6_txoptions * opt ; sk ) ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; ( sk , opt , optname\n", "\n", "Sources:\n", "0: CWE-416 static int do_ipv6_getsockopt ( struct sock * sk , int level , int optname , char __user * optval , int __user * optlen , unsigned int flags ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; int len ; int val ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_getsockopt ( sk , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; switch ( optname ) { case IPV6_ADDRFORM : if ( sk -> sk_protocol != IPPROTO_UDP && sk -> sk_protocol != IPPROTO_UDPLITE && sk -> sk_protocol != IPPROTO_TCP ) return - ENOPROTOOPT ; if ( sk -> sk_state != TCP_ESTABLISHED ) return - ENOTCONN ; val = sk -> sk_family ; break ; case MCAST_MSFILTER : { struct group_filter gsf ; int err ; if ( len < GROUP_FILTER_SIZE ( 0 ) ) return - EINVAL ; if ( copy_from_user ( & gsf , optval , GROUP_FILTER_SIZE ( 0 ) ) ) return - EFAULT ; if ( gsf . gf_group . ss_family != AF_INET6 ) return - EADDRNOTAVAIL ; lock_sock ( sk ) ; err = ip6_mc_msfget ( sk , & gsf , ( struct group_filter __user * ) optval , optlen ) ; release_sock ( sk ) ; return err ; } case IPV6_2292PKTOPTIONS : { struct msghdr msg ; struct sk_buff * skb ; if ( sk -> sk_type != SOCK_STREAM ) return - ENOPROTOOPT ; msg . msg_control = optval ; msg . msg_controllen = len ; msg . msg_flags = flags ; lock_sock ( sk ) ; skb = np -> pktoptions ; if ( skb ) ip6_datagram_recv_ctl ( sk , & msg , skb ) ; release_sock ( sk ) ; if ( ! skb ) { if ( np -> rxopt . bits . rxinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxhlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxtclass ) { int tclass = ( int ) ip6_tclass ( np -> rcv_flowinfo ) ; put_cmsg ( & msg , SOL_IPV6 , IPV6_TCLASS , sizeof ( tclass ) , & tclass ) ; } if ( np -> rxopt . bits . rxoinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxohlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxflow ) { __be32 flowinfo = np -> rcv_flowinfo ; put_cmsg ( & msg , SOL_IPV6 , IPV6_FLOWINFO , sizeof ( flowinfo ) , & flowinfo ) ; } } len -= msg . msg_controllen ; return put_user ( len , optlen ) ; } case IPV6_MTU : { struct dst_entry * dst ; val = 0 ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! val ) return - ENOTCONN ; break ; } case IPV6_V6ONLY : val = sk -> sk_ipv6only ; break ; case IPV6_RECVPKTINFO : val = np -> rxopt . bits . rxinfo ; break ; case IPV6_2292PKTINFO : val = np -> rxopt . bits . rxoinfo ; break ; case IPV6_RECVHOPLIMIT : val = np -> rxopt . bits . rxhlim ; break ; case IPV6_2292HOPLIMIT : val = np -> rxopt . bits . rxohlim ; break ; case IPV6_RECVRTHDR : val = np -> rxopt . bits . srcrt ; break ; case IPV6_2292RTHDR : val = np -> rxopt . bits . osrcrt ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { lock_sock ( sk ) ; len = ipv6_getsockopt_sticky ( sk , np -> opt , optname , optval , len ) ; release_sock ( sk ) ; if ( len < 0 ) return len ; return put_user ( len , optlen ) ; } case IPV6_RECVHOPOPTS : val = np -> rxopt . bits . hopopts ; break ; case IPV6_2292HOPOPTS : val = np -> rxopt . bits . ohopopts ; break ; case IPV6_RECVDSTOPTS : val = np -> rxopt . bits . dstopts ; break ; case IPV6_2292DSTOPTS : val = np -> rxopt . bits . odstopts ; break ; case IPV6_TCLASS : val = np -> tclass ; break ; case IPV6_RECVTCLASS : val = np -> rxopt . bits . rxtclass ; break ; case IPV6_FLOWINFO : val = np -> rxopt . bits . rxflow ; break ; case IPV6_RECVPATHMTU : val = np -> rxopt . bits . rxpmtu ; break ; case IPV6_PATHMTU : { struct dst_entry * dst ; struct ip6_mtuinfo mtuinfo ; if ( len < sizeof ( mtuinfo ) ) return - EINVAL ; len = sizeof ( mtuinfo ) ; memset ( & mtuinfo , 0 , sizeof ( mtuinfo ) ) ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) mtuinfo . ip6m_mtu = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! mtuinfo . ip6m_mtu ) return - ENOTCONN ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & mtuinfo , len ) ) return - EFAULT ; return 0 ; } case IPV6_TRANSPARENT : val = inet_sk ( sk ) -> transparent ; break ; case IPV6_RECVORIGDSTADDR : val = np -> rxopt . bits . rxorigdstaddr ; break ; case IPV6_UNICAST_HOPS : case IPV6_MULTICAST_HOPS : { struct dst_entry * dst ; if ( optname == IPV6_UNICAST_HOPS ) val = np -> hop_limit ; else val = np -> mcast_hops ; if ( val < 0 ) { rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = ip6_dst_hoplimit ( dst ) ; rcu_read_unlock ( ) ; } if ( val < 0 ) val = sock_net ( sk ) -> ipv6 . devconf_all -> hop_limit ; break ; } case IPV6_MULTICAST_LOOP : val = np -> mc_loop ; break ; case IPV6_MULTICAST_IF : val = np -> mcast_oif ; break ; case IPV6_UNICAST_IF : val = ( __force int ) htonl ( ( __u32 ) np -> ucast_oif ) ; break ; case IPV6_MTU_DISCOVER : val = np -> pmtudisc ; break ; case IPV6_RECVERR : val = np -> recverr ; break ; case IPV6_FLOWINFO_SEND : val = np -> sndflow ; break ; case IPV6_FLOWLABEL_MGR : { struct in6_flowlabel_req freq ; int flags ; if ( len < sizeof ( freq ) ) return - EINVAL ; if ( copy_from_user ( & freq , optval , sizeof ( freq ) ) ) return - EFAULT ; if ( freq . flr_action != IPV6_FL_A_GET ) return - EINVAL ; len = sizeof ( freq ) ; flags = freq . flr_flags ; memset ( & freq , 0 , sizeof ( freq ) ) ; val = ipv6_flowlabel_opt_get ( sk , & freq , flags ) ; if ( val < 0 ) return val ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & freq , len ) ) return - EFAULT ; return 0 ; } case IPV6_ADDR_PREFERENCES : val = 0 ; if ( np -> srcprefs & IPV6_PREFER_SRC_TMP ) val |= IPV6_PREFER_SRC_TMP ; else if ( np -> srcprefs & IPV6_PREFER_SRC_PUBLIC ) val |= IPV6_PREFER_SRC_PUBLIC ; else { val |= IPV6_PREFER_SRC_PUBTMP_DEFAULT ; } if ( np -> srcprefs & IPV6_PREFER_SRC_COA ) val |= IPV6_PREFER_SRC_COA ; else val |= IPV6_PREFER_SRC_HOME ; break ; case IPV6_MINHOPCOUNT : val = np -> min_hopcount ; break ; case IPV6_DONTFRAG : val = np -> dontfrag ; break ; case IPV6_AUTOFLOWLABEL : val = np -> autoflowlabel ; break ; default : return - ENOPROTOOPT ; } len = min_t ( unsigned int , sizeof ( int ) , len ) ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & val , len ) ) return - EFAULT ; return 0 ; }\n", "\n", "1: CWE-264 static int do_ipv6_getsockopt ( struct sock * sk , int level , int optname , char __user * optval , int __user * optlen , unsigned int flags ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; int len ; int val ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_getsockopt ( sk , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; switch ( optname ) { case IPV6_ADDRFORM : if ( sk -> sk_protocol != IPPROTO_UDP && sk -> sk_protocol != IPPROTO_UDPLITE && sk -> sk_protocol != IPPROTO_TCP ) return - ENOPROTOOPT ; if ( sk -> sk_state != TCP_ESTABLISHED ) return - ENOTCONN ; val = sk -> sk_family ; break ; case MCAST_MSFILTER : { struct group_filter gsf ; int err ; if ( len < GROUP_FILTER_SIZE ( 0 ) ) return - EINVAL ; if ( copy_from_user ( & gsf , optval , GROUP_FILTER_SIZE ( 0 ) ) ) return - EFAULT ; if ( gsf . gf_group . ss_family != AF_INET6 ) return - EADDRNOTAVAIL ; lock_sock ( sk ) ; err = ip6_mc_msfget ( sk , & gsf , ( struct group_filter __user * ) optval , optlen ) ; release_sock ( sk ) ; return err ; } case IPV6_2292PKTOPTIONS : { struct msghdr msg ; struct sk_buff * skb ; if ( sk -> sk_type != SOCK_STREAM ) return - ENOPROTOOPT ; msg . msg_control = optval ; msg . msg_controllen = len ; msg . msg_flags = flags ; lock_sock ( sk ) ; skb = np -> pktoptions ; if ( skb ) ip6_datagram_recv_ctl ( sk , & msg , skb ) ; release_sock ( sk ) ; if ( ! skb ) { if ( np -> rxopt . bits . rxinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxhlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxtclass ) { int tclass = ( int ) ip6_tclass ( np -> rcv_flowinfo ) ; put_cmsg ( & msg , SOL_IPV6 , IPV6_TCLASS , sizeof ( tclass ) , & tclass ) ; } if ( np -> rxopt . bits . rxoinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxohlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxflow ) { __be32 flowinfo = np -> rcv_flowinfo ; put_cmsg ( & msg , SOL_IPV6 , IPV6_FLOWINFO , sizeof ( flowinfo ) , & flowinfo ) ; } } len -= msg . msg_controllen ; return put_user ( len , optlen ) ; } case IPV6_MTU : { struct dst_entry * dst ; val = 0 ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! val ) return - ENOTCONN ; break ; } case IPV6_V6ONLY : val = sk -> sk_ipv6only ; break ; case IPV6_RECVPKTINFO : val = np -> rxopt . bits . rxinfo ; break ; case IPV6_2292PKTINFO : val = np -> rxopt . bits . rxoinfo ; break ; case IPV6_RECVHOPLIMIT : val = np -> rxopt . bits . rxhlim ; break ; case IPV6_2292HOPLIMIT : val = np -> rxopt . bits . rxohlim ; break ; case IPV6_RECVRTHDR : val = np -> rxopt . bits . srcrt ; break ; case IPV6_2292RTHDR : val = np -> rxopt . bits . osrcrt ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { lock_sock ( sk ) ; len = ipv6_getsockopt_sticky ( sk , np -> opt , optname , optval , len ) ; release_sock ( sk ) ; if ( len < 0 ) return len ; return put_user ( len , optlen ) ; } case IPV6_RECVHOPOPTS : val = np -> rxopt . bits . hopopts ; break ; case IPV6_2292HOPOPTS : val = np -> rxopt . bits . ohopopts ; break ; case IPV6_RECVDSTOPTS : val = np -> rxopt . bits . dstopts ; break ; case IPV6_2292DSTOPTS : val = np -> rxopt . bits . odstopts ; break ; case IPV6_TCLASS : val = np -> tclass ; break ; case IPV6_RECVTCLASS : val = np -> rxopt . bits . rxtclass ; break ; case IPV6_FLOWINFO : val = np -> rxopt . bits . rxflow ; break ; case IPV6_RECVPATHMTU : val = np -> rxopt . bits . rxpmtu ; break ; case IPV6_PATHMTU : { struct dst_entry * dst ; struct ip6_mtuinfo mtuinfo ; if ( len < sizeof ( mtuinfo ) ) return - EINVAL ; len = sizeof ( mtuinfo ) ; memset ( & mtuinfo , 0 , sizeof ( mtuinfo ) ) ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) mtuinfo . ip6m_mtu = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! mtuinfo . ip6m_mtu ) return - ENOTCONN ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & mtuinfo , len ) ) return - EFAULT ; return 0 ; } case IPV6_TRANSPARENT : val = inet_sk ( sk ) -> transparent ; break ; case IPV6_RECVORIGDSTADDR : val = np -> rxopt . bits . rxorigdstaddr ; break ; case IPV6_UNICAST_HOPS : case IPV6_MULTICAST_HOPS : { struct dst_entry * dst ; if ( optname == IPV6_UNICAST_HOPS ) val = np -> hop_limit ; else val = np -> mcast_hops ; if ( val < 0 ) { rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = ip6_dst_hoplimit ( dst ) ; rcu_read_unlock ( ) ; } if ( val < 0 ) val = sock_net ( sk ) -> ipv6 . devconf_all -> hop_limit ; break ; } case IPV6_MULTICAST_LOOP : val = np -> mc_loop ; break ; case IPV6_MULTICAST_IF : val = np -> mcast_oif ; break ; case IPV6_UNICAST_IF : val = ( __force int ) htonl ( ( __u32 ) np -> ucast_oif ) ; break ; case IPV6_MTU_DISCOVER : val = np -> pmtudisc ; break ; case IPV6_RECVERR : val = np -> recverr ; break ; case IPV6_FLOWINFO_SEND : val = np -> sndflow ; break ; case IPV6_FLOWLABEL_MGR : { struct in6_flowlabel_req freq ; int flags ; if ( len < sizeof ( freq ) ) return - EINVAL ; if ( copy_from_user ( & freq , optval , sizeof ( freq ) ) ) return - EFAULT ; if ( freq . flr_action != IPV6_FL_A_GET ) return - EINVAL ; len = sizeof ( freq ) ; flags = freq . flr_flags ; memset ( & freq , 0 , sizeof ( freq ) ) ; val = ipv6_flowlabel_opt_get ( sk , & freq , flags ) ; if ( val < 0 ) return val ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & freq , len ) ) return - EFAULT ; return 0 ; } case IPV6_ADDR_PREFERENCES : val = 0 ; if ( np -> srcprefs & IPV6_PREFER_SRC_TMP ) val |= IPV6_PREFER_SRC_TMP ; else if ( np -> srcprefs & IPV6_PREFER_SRC_PUBLIC ) val |= IPV6_PREFER_SRC_PUBLIC ; else { val |= IPV6_PREFER_SRC_PUBTMP_DEFAULT ; } if ( np -> srcprefs & IPV6_PREFER_SRC_COA ) val |= IPV6_PREFER_SRC_COA ; else val |= IPV6_PREFER_SRC_HOME ; break ; case IPV6_MINHOPCOUNT : val = np -> min_hopcount ; break ; case IPV6_DONTFRAG : val = np -> dontfrag ; break ; case IPV6_AUTOFLOWLABEL : val = np -> autoflowlabel ; break ; default : return - ENOPROTOOPT ; } len = min_t ( unsigned int , sizeof ( int ) , len ) ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & val , len ) ) return - EFAULT ; return 0 ; }\n", "\n", "\n", "Target: o ) { Py_RETURN_NONE ; } switch\n", "\n", "Sources:\n", "0: CWE-125 PyObject * ast2obj_mod ( void * _o ) { mod_ty o = ( mod_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case Module_kind : result = PyType_GenericNew ( Module_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Module . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Module . type_ignores , ast2obj_type_ignore ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_ignores , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Interactive_kind : result = PyType_GenericNew ( Interactive_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Interactive . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Expression_kind : result = PyType_GenericNew ( Expression_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Expression . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case FunctionType_kind : result = PyType_GenericNew ( FunctionType_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . FunctionType . argtypes , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_argtypes , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . FunctionType . returns ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_returns , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Suite_kind : result = PyType_GenericNew ( Suite_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Suite . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "1: CWE-125 PyObject * ast2obj_excepthandler ( void * _o ) { excepthandler_ty o = ( excepthandler_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case ExceptHandler_kind : result = PyType_GenericNew ( ExceptHandler_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . ExceptHandler . type ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_identifier ( o -> v . ExceptHandler . name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ExceptHandler . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; }\n", "\n", "\n", "Target: mq_ops ) { struct blk_mq_hw_ctx * hctx ; mq_flush_lock , flags ) ; hctx = q -> mq_ops -> map_queue ( q , flush_rq -> mq_ctx -> cpu ) ; blk_mq_tag_set_rq ( hctx , flush_rq -> tag , fq -> orig_rq\n", "\n", "Sources:\n", "0: CWE-362 static void flush_end_io ( struct request * flush_rq , int error ) { struct request_queue * q = flush_rq -> q ; struct list_head * running ; bool queued = false ; struct request * rq , * n ; unsigned long flags = 0 ; struct blk_flush_queue * fq = blk_get_flush_queue ( q , flush_rq -> mq_ctx ) ; if ( q -> mq_ops ) { spin_lock_irqsave ( & fq -> mq_flush_lock , flags ) ; flush_rq -> tag = - 1 ; } running = & fq -> flush_queue [ fq -> flush_running_idx ] ; BUG_ON ( fq -> flush_pending_idx == fq -> flush_running_idx ) ; fq -> flush_running_idx ^= 1 ; if ( ! q -> mq_ops ) elv_completed_request ( q , flush_rq ) ; list_for_each_entry_safe ( rq , n , running , flush . list ) { unsigned int seq = blk_flush_cur_seq ( rq ) ; BUG_ON ( seq != REQ_FSEQ_PREFLUSH && seq != REQ_FSEQ_POSTFLUSH ) ; queued |= blk_flush_complete_seq ( rq , fq , seq , error ) ; } if ( queued || fq -> flush_queue_delayed ) { WARN_ON ( q -> mq_ops ) ; blk_run_queue_async ( q ) ; } fq -> flush_queue_delayed = 0 ; if ( q -> mq_ops ) spin_unlock_irqrestore ( & fq -> mq_flush_lock , flags ) ; }\n", "\n", "1: CWE-264 static void flush_end_io ( struct request * flush_rq , int error ) { struct request_queue * q = flush_rq -> q ; struct list_head * running ; bool queued = false ; struct request * rq , * n ; unsigned long flags = 0 ; struct blk_flush_queue * fq = blk_get_flush_queue ( q , flush_rq -> mq_ctx ) ; if ( q -> mq_ops ) { spin_lock_irqsave ( & fq -> mq_flush_lock , flags ) ; flush_rq -> tag = - 1 ; } running = & fq -> flush_queue [ fq -> flush_running_idx ] ; BUG_ON ( fq -> flush_pending_idx == fq -> flush_running_idx ) ; fq -> flush_running_idx ^= 1 ; if ( ! q -> mq_ops ) elv_completed_request ( q , flush_rq ) ; list_for_each_entry_safe ( rq , n , running , flush . list ) { unsigned int seq = blk_flush_cur_seq ( rq ) ; BUG_ON ( seq != REQ_FSEQ_PREFLUSH && seq != REQ_FSEQ_POSTFLUSH ) ; queued |= blk_flush_complete_seq ( rq , fq , seq , error ) ; } if ( queued || fq -> flush_queue_delayed ) { WARN_ON ( q -> mq_ops ) ; blk_run_queue_async ( q ) ; } fq -> flush_queue_delayed = 0 ; if ( q -> mq_ops ) spin_unlock_irqrestore ( & fq -> mq_flush_lock , flags ) ; }\n", "\n", "\n", "Target: { option = ssplit ( option ,\n", "\n", "Sources:\n", "0: CWE-000 static int sessionCookieDirective ( MaState * state , cchar * key , cchar * value ) { char * options , * option , * ovalue , * tok ; if ( ! maTokenize ( state , value , \"%*\" , & options ) ) { return MPR_ERR_BAD_SYNTAX ; } if ( smatch ( options , \"disable\" ) ) { httpSetAuthSession ( state -> route -> auth , 0 ) ; return 0 ; } else if ( smatch ( options , \"enable\" ) ) { httpSetAuthSession ( state -> route -> auth , 1 ) ; return 0 ; } for ( option = maGetNextArg ( options , & tok ) ; option ; option = maGetNextArg ( tok , & tok ) ) { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( ! ovalue || * ovalue == '\\\\0' ) continue ; if ( smatch ( option , \"visible\" ) ) { httpSetRouteSessionVisibility ( state -> route , scaselessmatch ( ovalue , \"visible\" ) ) ; } else if ( smatch ( option , \"name\" ) ) { httpSetRouteCookie ( state -> route , ovalue ) ; } else { mprLog ( \"errorappwebconfig\" , 0 , \"UnknownSessionCookieoption%s\" , option ) ; return MPR_ERR_BAD_SYNTAX ; } } return 0 ; }\n", "\n", "1: CWE-000 static int errorLogDirective ( MaState * state , cchar * key , cchar * value ) { MprTicks stamp ; char * option , * ovalue , * tok , * path ; ssize size ; int level , flags , backup ; if ( mprGetCmdlineLogging ( ) ) { mprLog ( \"infoappwebconfig\" , 4 , \"Alreadylogging.IgnoringErrorLogdirective\" ) ; return 0 ; } size = MAXINT ; stamp = 0 ; level = 0 ; backup = 0 ; path = 0 ; flags = 0 ; for ( option = maGetNextArg ( sclone ( value ) , & tok ) ; option ; option = maGetNextArg ( tok , & tok ) ) { if ( ! path ) { path = mprJoinPath ( httpGetRouteVar ( state -> route , \"LOG_DIR\" ) , httpExpandRouteVars ( state -> route , option ) ) ; } else { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( smatch ( option , \"size\" ) ) { size = ( ssize ) getnum ( ovalue ) ; } else if ( smatch ( option , \"level\" ) ) { level = atoi ( ovalue ) ; } else if ( smatch ( option , \"backup\" ) ) { backup = atoi ( ovalue ) ; } else if ( smatch ( option , \"anew\" ) ) { flags |= MPR_LOG_ANEW ; } else if ( smatch ( option , \"stamp\" ) ) { stamp = httpGetTicks ( ovalue ) ; } else { mprLog ( \"errorappwebconfig\" , 0 , \"UnknownErrorLogoption%s\" , option ) ; } } } if ( size < ( 10 * 1000 ) ) { mprLog ( \"errorappwebconfig\" , 0 , \"Sizeistoosmall.Mustbelargerthan10K\" ) ; return MPR_ERR_BAD_SYNTAX ; } if ( path == 0 ) { mprLog ( \"errorappwebconfig\" , 0 , \"Missingfilename\" ) ; return MPR_ERR_BAD_SYNTAX ; } mprSetLogBackup ( size , backup , flags ) ; if ( ! smatch ( path , \"stdout\" ) && ! smatch ( path , \"stderr\" ) ) { path = httpMakePath ( state -> route , state -> configDir , path ) ; } if ( mprStartLogging ( path , MPR_LOG_DETAILED ) < 0 ) { mprLog ( \"errorappwebconfig\" , 0 , \"CannotwritetoErrorLog:%s\" , path ) ; return MPR_ERR_BAD_SYNTAX ; } mprSetLogLevel ( level ) ; mprLogHeader ( ) ; if ( stamp ) { httpSetTimestamp ( stamp ) ; } return 0 ; }\n", "\n", "2: CWE-000 static int traceDirective ( MaState * state , cchar * key , cchar * value ) { HttpRoute * route ; char * option , * ovalue , * tok ; route = state -> route ; route -> trace = httpCreateTrace ( route -> trace ) ; for ( option = stok ( sclone ( value ) , \"\\\\t\" , & tok ) ; option ; option = stok ( 0 , \"\\\\t\" , & tok ) ) { option = stok ( option , \"=\\\\t,\" , & ovalue ) ; ovalue = strim ( ovalue , \"\\\\\"\\'\" , MPR_TRIM_BOTH ) ; if ( smatch ( option , \"content\" ) ) { httpSetTraceContentSize ( route -> trace , ( ssize ) getnum ( ovalue ) ) ; } else { httpSetTraceEventLevel ( route -> trace , option , atoi ( ovalue ) ) ; } } return 0 ; }\n", "\n", "\n", "Target: iv ) ; rb_ivar_set ( self , id_key_set , Qtrue ) ;\n", "\n", "Sources:\n", "0: CWE-326 static VALUE ossl_cipher_pkcs5_keyivgen ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; const EVP_MD * digest ; VALUE vpass , vsalt , viter , vdigest ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , iv [ EVP_MAX_IV_LENGTH ] , * salt = NULL ; int iter ; rb_scan_args ( argc , argv , \"13\" , & vpass , & vsalt , & viter , & vdigest ) ; StringValue ( vpass ) ; if ( ! NIL_P ( vsalt ) ) { StringValue ( vsalt ) ; if ( RSTRING_LEN ( vsalt ) != PKCS5_SALT_LEN ) ossl_raise ( eCipherError , \"saltmustbean8-octetstring\" ) ; salt = ( unsigned char * ) RSTRING_PTR ( vsalt ) ; } iter = NIL_P ( viter ) ? 2048 : NUM2INT ( viter ) ; digest = NIL_P ( vdigest ) ? EVP_md5 ( ) : GetDigestPtr ( vdigest ) ; GetCipher ( self , ctx ) ; EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , digest , salt , ( unsigned char * ) RSTRING_PTR ( vpass ) , RSTRING_LENINT ( vpass ) , iter , key , iv ) ; if ( EVP_CipherInit_ex ( ctx , NULL , NULL , key , iv , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; OPENSSL_cleanse ( key , sizeof key ) ; OPENSSL_cleanse ( iv , sizeof iv ) ; return Qnil ; }\n", "\n", "1: CWE-310 static VALUE ossl_cipher_pkcs5_keyivgen ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; const EVP_MD * digest ; VALUE vpass , vsalt , viter , vdigest ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , iv [ EVP_MAX_IV_LENGTH ] , * salt = NULL ; int iter ; rb_scan_args ( argc , argv , \"13\" , & vpass , & vsalt , & viter , & vdigest ) ; StringValue ( vpass ) ; if ( ! NIL_P ( vsalt ) ) { StringValue ( vsalt ) ; if ( RSTRING_LEN ( vsalt ) != PKCS5_SALT_LEN ) ossl_raise ( eCipherError , \"saltmustbean8-octetstring\" ) ; salt = ( unsigned char * ) RSTRING_PTR ( vsalt ) ; } iter = NIL_P ( viter ) ? 2048 : NUM2INT ( viter ) ; digest = NIL_P ( vdigest ) ? EVP_md5 ( ) : GetDigestPtr ( vdigest ) ; GetCipher ( self , ctx ) ; EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , digest , salt , ( unsigned char * ) RSTRING_PTR ( vpass ) , RSTRING_LENINT ( vpass ) , iter , key , iv ) ; if ( EVP_CipherInit_ex ( ctx , NULL , NULL , key , iv , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; OPENSSL_cleanse ( key , sizeof key ) ; OPENSSL_cleanse ( iv , sizeof iv ) ; return Qnil ; }\n", "\n", "\n", "Target: = act_code ; if ( npix > 0 ) = casspecial ; if ( npix >= ( stack_top - stackp - stackp ) ) { WritePixels ( i , & context , stackp , stack_top - stackp ) ; } else if ( npix > 0 ) { WritePixels ( i , & context , stackp , npix ) ; } npix -= (\n", "\n", "Sources:\n", "0: CWE-119 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if ( ! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***ERROR***ImagebiggerthanglobalGIFcanvas!\\\\n\" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***WARNING***AdjustingXposition\\\\n\" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***WARNING***AdjustingYposition\\\\n\" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } context . Xtogo = i -> width ; context . curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif # else if ( i -> parent -> mode & NGIFLIB_MODE_INDEXED ) { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p32 = context . line_p . p32 + i -> posX ; # else context . frbuff_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } # endif npix = ( long ) i -> width * i -> height ; flags = GetByte ( i -> parent ) ; i -> interlaced = ( flags & 64 ) >> 6 ; context . pass = i -> interlaced ? 1 : 0 ; i -> sort_flag = ( flags & 32 ) >> 5 ; i -> localpalbits = ( flags & 7 ) + 1 ; if ( flags & 128 ) { int k ; int localpalsize = 1 << i -> localpalbits ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Localpalette\\\\n\" ) ; # endif i -> palette = ( struct ngiflib_rgb * ) ngiflib_malloc ( sizeof ( struct ngiflib_rgb ) * localpalsize ) ; for ( k = 0 ; k < localpalsize ; k ++ ) { i -> palette [ k ] . r = GetByte ( i -> parent ) ; i -> palette [ k ] . g = GetByte ( i -> parent ) ; i -> palette [ k ] . b = GetByte ( i -> parent ) ; } # ifdef NGIFLIB_ENABLE_CALLBACKS if ( i -> parent -> palette_cb ) i -> parent -> palette_cb ( i -> parent , i -> palette , localpalsize ) ; # endif } else { i -> palette = i -> parent -> palette ; i -> localpalbits = i -> parent -> imgbits ; } i -> ncolors = 1 << i -> localpalbits ; i -> imgbits = GetByte ( i -> parent ) ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) { if ( i -> interlaced ) fprintf ( i -> parent -> log , \"interlaced\" ) ; fprintf ( i -> parent -> log , \"imgpos(%hu,%hu)size%hux%hupalbits=%hhuimgbits=%hhuncolors=%hu\\\\n\" , i -> posX , i -> posY , i -> width , i -> height , i -> localpalbits , i -> imgbits , i -> ncolors ) ; } # endif if ( i -> imgbits == 1 ) { i -> imgbits = 2 ; } clr = 1 << i -> imgbits ; eof = clr + 1 ; free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; stackp = stack_top = ab_stack + 4096 ; context . restbits = 0 ; context . restbyte = 0 ; context . lbyte = 0 ; for ( ; ; ) { act_code = GetGifWord ( i , & context ) ; if ( act_code == eof ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Endofimagecode\\\\n\" ) ; # endif return 0 ; } if ( npix == 0 ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"assezdepixels,Onsecasse!\\\\n\" ) ; # endif return 1 ; } if ( act_code == clr ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Codeclear(free=%hu)npix=%ld\\\\n\" , free , npix ) ; # endif free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; act_code = GetGifWord ( i , & context ) ; casspecial = ( u8 ) act_code ; old_code = act_code ; WritePixel ( i , & context , casspecial ) ; npix -- ; } else { read_byt = act_code ; if ( act_code >= free ) { * ( -- stackp ) = casspecial ; act_code = old_code ; } while ( act_code > clr ) { * ( -- stackp ) = ab_suffx [ act_code ] ; act_code = ab_prfx [ act_code ] ; } casspecial = ( u8 ) act_code ; * ( -- stackp ) = casspecial ; WritePixels ( i , & context , stackp , stack_top - stackp ) ; npix -= ( stack_top - stackp ) ; stackp = stack_top ; if ( free < 4096 ) { ab_prfx [ free ] = old_code ; ab_suffx [ free ] = ( u8 ) act_code ; free ++ ; if ( ( free > context . max ) && ( context . nbbit < 12 ) ) { context . nbbit ++ ; context . max += context . max + 1 ; } } old_code = read_byt ; } } return 0 ; }\n", "\n", "1: CWE-787 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if ( ! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***ERROR***ImagebiggerthanglobalGIFcanvas!\\\\n\" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***WARNING***AdjustingXposition\\\\n\" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , \"***WARNING***AdjustingYposition\\\\n\" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } context . Xtogo = i -> width ; context . curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif # else if ( i -> parent -> mode & NGIFLIB_MODE_INDEXED ) { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p32 = context . line_p . p32 + i -> posX ; # else context . frbuff_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } # endif npix = ( long ) i -> width * i -> height ; flags = GetByte ( i -> parent ) ; i -> interlaced = ( flags & 64 ) >> 6 ; context . pass = i -> interlaced ? 1 : 0 ; i -> sort_flag = ( flags & 32 ) >> 5 ; i -> localpalbits = ( flags & 7 ) + 1 ; if ( flags & 128 ) { int k ; int localpalsize = 1 << i -> localpalbits ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Localpalette\\\\n\" ) ; # endif i -> palette = ( struct ngiflib_rgb * ) ngiflib_malloc ( sizeof ( struct ngiflib_rgb ) * localpalsize ) ; for ( k = 0 ; k < localpalsize ; k ++ ) { i -> palette [ k ] . r = GetByte ( i -> parent ) ; i -> palette [ k ] . g = GetByte ( i -> parent ) ; i -> palette [ k ] . b = GetByte ( i -> parent ) ; } # ifdef NGIFLIB_ENABLE_CALLBACKS if ( i -> parent -> palette_cb ) i -> parent -> palette_cb ( i -> parent , i -> palette , localpalsize ) ; # endif } else { i -> palette = i -> parent -> palette ; i -> localpalbits = i -> parent -> imgbits ; } i -> ncolors = 1 << i -> localpalbits ; i -> imgbits = GetByte ( i -> parent ) ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) { if ( i -> interlaced ) fprintf ( i -> parent -> log , \"interlaced\" ) ; fprintf ( i -> parent -> log , \"imgpos(%hu,%hu)size%hux%hupalbits=%hhuimgbits=%hhuncolors=%hu\\\\n\" , i -> posX , i -> posY , i -> width , i -> height , i -> localpalbits , i -> imgbits , i -> ncolors ) ; } # endif if ( i -> imgbits == 1 ) { i -> imgbits = 2 ; } clr = 1 << i -> imgbits ; eof = clr + 1 ; free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; stackp = stack_top = ab_stack + 4096 ; context . restbits = 0 ; context . restbyte = 0 ; context . lbyte = 0 ; for ( ; ; ) { act_code = GetGifWord ( i , & context ) ; if ( act_code == eof ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Endofimagecode\\\\n\" ) ; # endif return 0 ; } if ( npix == 0 ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"assezdepixels,Onsecasse!\\\\n\" ) ; # endif return 1 ; } if ( act_code == clr ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , \"Codeclear(free=%hu)npix=%ld\\\\n\" , free , npix ) ; # endif free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; act_code = GetGifWord ( i , & context ) ; casspecial = ( u8 ) act_code ; old_code = act_code ; WritePixel ( i , & context , casspecial ) ; npix -- ; } else { read_byt = act_code ; if ( act_code >= free ) { * ( -- stackp ) = casspecial ; act_code = old_code ; } while ( act_code > clr ) { * ( -- stackp ) = ab_suffx [ act_code ] ; act_code = ab_prfx [ act_code ] ; } casspecial = ( u8 ) act_code ; * ( -- stackp ) = casspecial ; WritePixels ( i , & context , stackp , stack_top - stackp ) ; npix -= ( stack_top - stackp ) ; stackp = stack_top ; if ( free < 4096 ) { ab_prfx [ free ] = old_code ; ab_suffx [ free ] = ( u8 ) act_code ; free ++ ; if ( ( free > context . max ) && ( context . nbbit < 12 ) ) { context . nbbit ++ ; context . max += context . max + 1 ; } } old_code = read_byt ; } } return 0 ; }\n", "\n", "\n", "Target: -> i_unique ; if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) { if ( iinfo -> i_lenAlloc != inode -> i_size ) goto out ; if ( inode -> i_size > inode -> i_sb -> s_blocksize - udf_file_entry_alloc_offset ( inode ) ) goto out ; }\n", "\n", "Sources:\n", "0: CWE-119 static int udf_read_inode ( struct inode * inode , bool hidden_inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; struct kernel_lb_addr * iloc = & iinfo -> i_location ; unsigned int link_count ; unsigned int indirections = 0 ; int ret = - EIO ; reread : if ( iloc -> logicalBlockNum >= sbi -> s_partmaps [ iloc -> partitionReferenceNum ] . s_partition_len ) { udf_debug ( \"block=%d,partition=%doutofrange\\\\n\" , iloc -> logicalBlockNum , iloc -> partitionReferenceNum ) ; return - EIO ; } bh = udf_read_ptagged ( inode -> i_sb , iloc , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , \"(ino%ld)failed!bh\\\\n\" , inode -> i_ino ) ; return - EIO ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , \"(ino%ld)failedident=%d\\\\n\" , inode -> i_ino , ident ) ; goto out ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , iloc , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength ) { brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , \"toomanyICBsinICBhierarchy\" \"(max%dsupported)\\\\n\" , UDF_MAX_ICB_NESTING ) ; goto out ; } brelse ( bh ) ; goto reread ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , \"unsupportedstrategytype:%d\\\\n\" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; goto out ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return 0 ; } ret = - EIO ; read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) { if ( ! hidden_inode ) { ret = - ESTALE ; goto out ; } link_count = 1 ; } set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } inode -> i_generation = iinfo -> i_unique ; switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( \"METADATAFILE-----\\\\n\" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( \"METADATAMIRRORFILE-----\\\\n\" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( \"METADATABITMAPFILE-----\\\\n\" ) ; break ; default : udf_err ( inode -> i_sb , \"(ino%ld)failedunknownfiletype=%d\\\\n\" , inode -> i_ino , fe -> icbTag . fileType ) ; goto out ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else goto out ; } ret = 0 ; out : brelse ( bh ) ; return ret ; }\n", "\n", "1: CWE-000 static int udf_read_inode ( struct inode * inode , bool hidden_inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; struct kernel_lb_addr * iloc = & iinfo -> i_location ; unsigned int link_count ; unsigned int indirections = 0 ; int ret = - EIO ; reread : if ( iloc -> logicalBlockNum >= sbi -> s_partmaps [ iloc -> partitionReferenceNum ] . s_partition_len ) { udf_debug ( \"block=%d,partition=%doutofrange\\\\n\" , iloc -> logicalBlockNum , iloc -> partitionReferenceNum ) ; return - EIO ; } bh = udf_read_ptagged ( inode -> i_sb , iloc , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , \"(ino%ld)failed!bh\\\\n\" , inode -> i_ino ) ; return - EIO ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , \"(ino%ld)failedident=%d\\\\n\" , inode -> i_ino , ident ) ; goto out ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , iloc , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength ) { brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , \"toomanyICBsinICBhierarchy\" \"(max%dsupported)\\\\n\" , UDF_MAX_ICB_NESTING ) ; goto out ; } brelse ( bh ) ; goto reread ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , \"unsupportedstrategytype:%d\\\\n\" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; goto out ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return 0 ; } ret = - EIO ; read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) { if ( ! hidden_inode ) { ret = - ESTALE ; goto out ; } link_count = 1 ; } set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } inode -> i_generation = iinfo -> i_unique ; switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( \"METADATAFILE-----\\\\n\" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( \"METADATAMIRRORFILE-----\\\\n\" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( \"METADATABITMAPFILE-----\\\\n\" ) ; break ; default : udf_err ( inode -> i_sb , \"(ino%ld)failedunknownfiletype=%d\\\\n\" , inode -> i_ino , fe -> icbTag . fileType ) ; goto out ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else goto out ; } ret = 0 ; out : brelse ( bh ) ; return ret ; }\n", "\n", "\n", "Target: buf + idx ) ; assert ( ( num_properties + 1 ) != 0 len ) ; assert ( ( idx + ( a -> names [ i ] . len * 2 ) ) <= len ) ; += 4 ; assert ( v -> len + idx <= len ) ; szMAPI_UNICODE_STRING ) { assert ( v -> len != 0 ) ;\n", "\n", "Sources:\n", "0: CWE-125 MAPI_Attr * * mapi_attr_read ( size_t len , unsigned char * buf ) { size_t idx = 0 ; uint32 i , j ; assert ( len > 4 ) ; uint32 num_properties = GETINT32 ( buf + idx ) ; MAPI_Attr * * attrs = CHECKED_XMALLOC ( MAPI_Attr * , ( num_properties + 1 ) ) ; idx += 4 ; if ( ! attrs ) return NULL ; for ( i = 0 ; i < num_properties ; i ++ ) { MAPI_Attr * a = attrs [ i ] = CHECKED_XCALLOC ( MAPI_Attr , 1 ) ; MAPI_Value * v = NULL ; CHECKINT16 ( idx , len ) ; a -> type = GETINT16 ( buf + idx ) ; idx += 2 ; CHECKINT16 ( idx , len ) ; a -> name = GETINT16 ( buf + idx ) ; idx += 2 ; if ( a -> name & GUID_EXISTS_FLAG ) { a -> guid = CHECKED_XMALLOC ( GUID , 1 ) ; copy_guid_from_buf ( a -> guid , buf + idx , len ) ; idx += sizeof ( GUID ) ; CHECKINT32 ( idx , len ) ; a -> num_names = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> num_names > 0 ) { size_t i ; a -> names = CHECKED_XCALLOC ( VarLenData , a -> num_names ) ; for ( i = 0 ; i < a -> num_names ; i ++ ) { size_t j ; CHECKINT32 ( idx , len ) ; a -> names [ i ] . len = GETINT32 ( buf + idx ) ; idx += 4 ; a -> names [ i ] . data = CHECKED_XMALLOC ( unsigned char , a -> names [ i ] . len ) ; for ( j = 0 ; j < ( a -> names [ i ] . len >> 1 ) ; j ++ ) a -> names [ i ] . data [ j ] = ( buf + idx ) [ j * 2 ] ; idx += pad_to_4byte ( a -> names [ i ] . len ) ; } } else { CHECKINT32 ( idx , len ) ; a -> name = GETINT32 ( buf + idx ) ; idx += 4 ; } } if ( a -> type & MULTI_VALUE_FLAG || a -> type == szMAPI_STRING || a -> type == szMAPI_UNICODE_STRING || a -> type == szMAPI_OBJECT || a -> type == szMAPI_BINARY ) { CHECKINT32 ( idx , len ) ; a -> num_values = GETINT32 ( buf + idx ) ; idx += 4 ; } else { a -> num_values = 1 ; } if ( a -> type & MULTI_VALUE_FLAG ) { a -> type -= MULTI_VALUE_FLAG ; } v = alloc_mapi_values ( a ) ; for ( j = 0 ; j < a -> num_values ; j ++ ) { switch ( a -> type ) { case szMAPI_SHORT : v -> len = 2 ; CHECKINT16 ( idx , len ) ; v -> data . bytes2 = GETINT16 ( buf + idx ) ; idx += 4 ; break ; case szMAPI_INT : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += 4 ; v ++ ; break ; case szMAPI_FLOAT : case szMAPI_BOOLEAN : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += v -> len ; break ; case szMAPI_SYSTIME : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += 8 ; v ++ ; break ; case szMAPI_DOUBLE : case szMAPI_APPTIME : case szMAPI_CURRENCY : case szMAPI_INT8BYTE : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += v -> len ; break ; case szMAPI_CLSID : v -> len = sizeof ( GUID ) ; copy_guid_from_buf ( & v -> data . guid , buf + idx , len ) ; idx += v -> len ; break ; case szMAPI_STRING : case szMAPI_UNICODE_STRING : case szMAPI_OBJECT : case szMAPI_BINARY : CHECKINT32 ( idx , len ) ; v -> len = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> type == szMAPI_UNICODE_STRING ) { v -> data . buf = ( unsigned char * ) unicode_to_utf8 ( v -> len , buf + idx ) ; } else { v -> data . buf = CHECKED_XMALLOC ( unsigned char , v -> len ) ; memmove ( v -> data . buf , buf + idx , v -> len ) ; } idx += pad_to_4byte ( v -> len ) ; v ++ ; break ; case szMAPI_NULL : case szMAPI_ERROR : case szMAPI_UNSPECIFIED : fprintf ( stderr , \"Invalidattribute,inputfilemaybecorrupted\\\\n\" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; default : fprintf ( stderr , \"Undefinedattribute,inputfilemaybecorrupted\\\\n\" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; } if ( DEBUG_ON ) mapi_attr_dump ( attrs [ i ] ) ; } } attrs [ i ] = NULL ; return attrs ; }\n", "\n", "1: CWE-787 MAPI_Attr * * mapi_attr_read ( size_t len , unsigned char * buf ) { size_t idx = 0 ; uint32 i , j ; assert ( len > 4 ) ; uint32 num_properties = GETINT32 ( buf + idx ) ; MAPI_Attr * * attrs = CHECKED_XMALLOC ( MAPI_Attr * , ( num_properties + 1 ) ) ; idx += 4 ; if ( ! attrs ) return NULL ; for ( i = 0 ; i < num_properties ; i ++ ) { MAPI_Attr * a = attrs [ i ] = CHECKED_XCALLOC ( MAPI_Attr , 1 ) ; MAPI_Value * v = NULL ; CHECKINT16 ( idx , len ) ; a -> type = GETINT16 ( buf + idx ) ; idx += 2 ; CHECKINT16 ( idx , len ) ; a -> name = GETINT16 ( buf + idx ) ; idx += 2 ; if ( a -> name & GUID_EXISTS_FLAG ) { a -> guid = CHECKED_XMALLOC ( GUID , 1 ) ; copy_guid_from_buf ( a -> guid , buf + idx , len ) ; idx += sizeof ( GUID ) ; CHECKINT32 ( idx , len ) ; a -> num_names = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> num_names > 0 ) { size_t i ; a -> names = CHECKED_XCALLOC ( VarLenData , a -> num_names ) ; for ( i = 0 ; i < a -> num_names ; i ++ ) { size_t j ; CHECKINT32 ( idx , len ) ; a -> names [ i ] . len = GETINT32 ( buf + idx ) ; idx += 4 ; a -> names [ i ] . data = CHECKED_XMALLOC ( unsigned char , a -> names [ i ] . len ) ; for ( j = 0 ; j < ( a -> names [ i ] . len >> 1 ) ; j ++ ) a -> names [ i ] . data [ j ] = ( buf + idx ) [ j * 2 ] ; idx += pad_to_4byte ( a -> names [ i ] . len ) ; } } else { CHECKINT32 ( idx , len ) ; a -> name = GETINT32 ( buf + idx ) ; idx += 4 ; } } if ( a -> type & MULTI_VALUE_FLAG || a -> type == szMAPI_STRING || a -> type == szMAPI_UNICODE_STRING || a -> type == szMAPI_OBJECT || a -> type == szMAPI_BINARY ) { CHECKINT32 ( idx , len ) ; a -> num_values = GETINT32 ( buf + idx ) ; idx += 4 ; } else { a -> num_values = 1 ; } if ( a -> type & MULTI_VALUE_FLAG ) { a -> type -= MULTI_VALUE_FLAG ; } v = alloc_mapi_values ( a ) ; for ( j = 0 ; j < a -> num_values ; j ++ ) { switch ( a -> type ) { case szMAPI_SHORT : v -> len = 2 ; CHECKINT16 ( idx , len ) ; v -> data . bytes2 = GETINT16 ( buf + idx ) ; idx += 4 ; break ; case szMAPI_INT : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += 4 ; v ++ ; break ; case szMAPI_FLOAT : case szMAPI_BOOLEAN : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += v -> len ; break ; case szMAPI_SYSTIME : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += 8 ; v ++ ; break ; case szMAPI_DOUBLE : case szMAPI_APPTIME : case szMAPI_CURRENCY : case szMAPI_INT8BYTE : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += v -> len ; break ; case szMAPI_CLSID : v -> len = sizeof ( GUID ) ; copy_guid_from_buf ( & v -> data . guid , buf + idx , len ) ; idx += v -> len ; break ; case szMAPI_STRING : case szMAPI_UNICODE_STRING : case szMAPI_OBJECT : case szMAPI_BINARY : CHECKINT32 ( idx , len ) ; v -> len = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> type == szMAPI_UNICODE_STRING ) { v -> data . buf = ( unsigned char * ) unicode_to_utf8 ( v -> len , buf + idx ) ; } else { v -> data . buf = CHECKED_XMALLOC ( unsigned char , v -> len ) ; memmove ( v -> data . buf , buf + idx , v -> len ) ; } idx += pad_to_4byte ( v -> len ) ; v ++ ; break ; case szMAPI_NULL : case szMAPI_ERROR : case szMAPI_UNSPECIFIED : fprintf ( stderr , \"Invalidattribute,inputfilemaybecorrupted\\\\n\" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; default : fprintf ( stderr , \"Undefinedattribute,inputfilemaybecorrupted\\\\n\" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; } if ( DEBUG_ON ) mapi_attr_dump ( attrs [ i ] ) ; } } attrs [ i ] = NULL ; return attrs ; }\n", "\n", "\n", "Target: ret = 0 ; if ( ! access_ok ( VERIFY_READ , uregs , sizeof ( elf_xtregs_t ) ) ) return - EFAULT\n", "\n", "Sources:\n", "0: CWE-20 int ptrace_setxregs ( struct task_struct * child , void __user * uregs ) { struct thread_info * ti = task_thread_info ( child ) ; struct pt_regs * regs = task_pt_regs ( child ) ; elf_xtregs_t * xtregs = uregs ; int ret = 0 ; # if XTENSA_HAVE_COPROCESSORS coprocessor_flush_all ( ti ) ; coprocessor_release_all ( ti ) ; ret |= __copy_from_user ( & ti -> xtregs_cp , & xtregs -> cp0 , sizeof ( xtregs_coprocessor_t ) ) ; # endif ret |= __copy_from_user ( & regs -> xtregs_opt , & xtregs -> opt , sizeof ( xtregs -> opt ) ) ; ret |= __copy_from_user ( & ti -> xtregs_user , & xtregs -> user , sizeof ( xtregs -> user ) ) ; return ret ? - EFAULT : 0 ; }\n", "\n", "1: CWE-200 int ptrace_setxregs ( struct task_struct * child , void __user * uregs ) { struct thread_info * ti = task_thread_info ( child ) ; struct pt_regs * regs = task_pt_regs ( child ) ; elf_xtregs_t * xtregs = uregs ; int ret = 0 ; # if XTENSA_HAVE_COPROCESSORS coprocessor_flush_all ( ti ) ; coprocessor_release_all ( ti ) ; ret |= __copy_from_user ( & ti -> xtregs_cp , & xtregs -> cp0 , sizeof ( xtregs_coprocessor_t ) ) ; # endif ret |= __copy_from_user ( & regs -> xtregs_opt , & xtregs -> opt , sizeof ( xtregs -> opt ) ) ; ret |= __copy_from_user ( & ti -> xtregs_user , & xtregs -> user , sizeof ( xtregs -> user ) ) ; return ret ? - EFAULT : 0 ; }\n", "\n", "\n", "Target: header . size , 0 )\n", "\n", "Sources:\n", "0: CWE-400 static void perf_event_comm_output ( struct perf_event * event , struct perf_comm_event * comm_event ) { struct perf_output_handle handle ; struct perf_sample_data sample ; int size = comm_event -> event_id . header . size ; int ret ; perf_event_header__init_id ( & comm_event -> event_id . header , & sample , event ) ; ret = perf_output_begin ( & handle , event , comm_event -> event_id . header . size , 0 , 0 ) ; if ( ret ) goto out ; comm_event -> event_id . pid = perf_event_pid ( event , comm_event -> task ) ; comm_event -> event_id . tid = perf_event_tid ( event , comm_event -> task ) ; perf_output_put ( & handle , comm_event -> event_id ) ; __output_copy ( & handle , comm_event -> comm , comm_event -> comm_size ) ; perf_event__output_id_sample ( event , & handle , & sample ) ; perf_output_end ( & handle ) ; out : comm_event -> event_id . header . size = size ; }\n", "\n", "1: CWE-400 static void perf_event_mmap_output ( struct perf_event * event , struct perf_mmap_event * mmap_event ) { struct perf_output_handle handle ; struct perf_sample_data sample ; int size = mmap_event -> event_id . header . size ; int ret ; perf_event_header__init_id ( & mmap_event -> event_id . header , & sample , event ) ; ret = perf_output_begin ( & handle , event , mmap_event -> event_id . header . size , 0 , 0 ) ; if ( ret ) goto out ; mmap_event -> event_id . pid = perf_event_pid ( event , current ) ; mmap_event -> event_id . tid = perf_event_tid ( event , current ) ; perf_output_put ( & handle , mmap_event -> event_id ) ; __output_copy ( & handle , mmap_event -> file_name , mmap_event -> file_size ) ; perf_event__output_id_sample ( event , & handle , & sample ) ; perf_output_end ( & handle ) ; out : mmap_event -> event_id . header . size = size ; }\n", "\n", "\n", "Target: crypto_report_kpp rkpp ; strncpy ( rkpp .\n", "\n", "Sources:\n", "0: CWE-200 static int crypto_report_kpp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_kpp rkpp ; strlcpy ( rkpp . type , \"kpp\" , sizeof ( rkpp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_KPP , sizeof ( struct crypto_report_kpp ) , & rkpp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "1: CWE-000 static int crypto_report_kpp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_kpp rkpp ; strlcpy ( rkpp . type , \"kpp\" , sizeof ( rkpp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_KPP , sizeof ( struct crypto_report_kpp ) , & rkpp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; }\n", "\n", "\n", "Target: ; if ( i < NCH ( n ) &&\n", "\n", "Sources:\n", "0: CWE-125 static int handle_keywordonly_args ( struct compiling * c , const node * n , int start , asdl_seq * kwonlyargs , asdl_seq * kwdefaults ) { PyObject * argname ; node * ch ; expr_ty expression , annotation ; arg_ty arg = NULL ; int i = start ; int j = 0 ; if ( kwonlyargs == NULL ) { ast_error ( c , CHILD ( n , start ) , \"namedargumentsmustfollowbare*\" ) ; return - 1 ; } assert ( kwdefaults != NULL ) ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case vfpdef : case tfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) goto error ; asdl_seq_SET ( kwdefaults , j , expression ) ; i += 2 ; } else { asdl_seq_SET ( kwdefaults , j , NULL ) ; } if ( NCH ( ch ) == 3 ) { annotation = ast_for_expr ( c , CHILD ( ch , 2 ) ) ; if ( ! annotation ) goto error ; } else { annotation = NULL ; } ch = CHILD ( ch , 0 ) ; argname = NEW_IDENTIFIER ( ch ) ; if ( ! argname ) goto error ; if ( forbidden_name ( c , argname , ch , 0 ) ) goto error ; arg = arg ( argname , annotation , NULL , LINENO ( ch ) , ch -> n_col_offset , c -> c_arena ) ; if ( ! arg ) goto error ; asdl_seq_SET ( kwonlyargs , j ++ , arg ) ; i += 1 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) goto error ; i += 1 ; break ; case DOUBLESTAR : return i ; default : ast_error ( c , ch , \"unexpectednode\" ) ; goto error ; } } return i ; error : return - 1 ; }\n", "\n", "1: CWE-125 static arguments_ty ast_for_arguments ( struct compiling * c , const node * n ) { int i , j , k , nposargs = 0 , nkwonlyargs = 0 ; int nposdefaults = 0 , found_default = 0 ; asdl_seq * posargs , * posdefaults , * kwonlyargs , * kwdefaults ; arg_ty vararg = NULL , kwarg = NULL ; arg_ty arg = NULL ; node * ch ; if ( TYPE ( n ) == parameters ) { if ( NCH ( n ) == 2 ) return arguments ( NULL , NULL , NULL , NULL , NULL , NULL , c -> c_arena ) ; n = CHILD ( n , 1 ) ; } assert ( TYPE ( n ) == typedargslist || TYPE ( n ) == varargslist ) ; for ( i = 0 ; i < NCH ( n ) ; i ++ ) { ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == STAR ) { i ++ ; if ( i < NCH ( n ) && ( TYPE ( CHILD ( n , i ) ) == tfpdef || TYPE ( CHILD ( n , i ) ) == vfpdef ) ) { i ++ ; } break ; } if ( TYPE ( ch ) == DOUBLESTAR ) break ; if ( TYPE ( ch ) == vfpdef || TYPE ( ch ) == tfpdef ) nposargs ++ ; if ( TYPE ( ch ) == EQUAL ) nposdefaults ++ ; } for ( ; i < NCH ( n ) ; ++ i ) { ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == DOUBLESTAR ) break ; if ( TYPE ( ch ) == tfpdef || TYPE ( ch ) == vfpdef ) nkwonlyargs ++ ; } posargs = ( nposargs ? _Py_asdl_seq_new ( nposargs , c -> c_arena ) : NULL ) ; if ( ! posargs && nposargs ) return NULL ; kwonlyargs = ( nkwonlyargs ? _Py_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwonlyargs && nkwonlyargs ) return NULL ; posdefaults = ( nposdefaults ? _Py_asdl_seq_new ( nposdefaults , c -> c_arena ) : NULL ) ; if ( ! posdefaults && nposdefaults ) return NULL ; kwdefaults = ( nkwonlyargs ? _Py_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwdefaults && nkwonlyargs ) return NULL ; i = 0 ; j = 0 ; k = 0 ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case tfpdef : case vfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expr_ty expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) return NULL ; assert ( posdefaults != NULL ) ; asdl_seq_SET ( posdefaults , j ++ , expression ) ; i += 2 ; found_default = 1 ; } else if ( found_default ) { ast_error ( c , n , \"non-defaultargumentfollowsdefaultargument\" ) ; return NULL ; } arg = ast_for_arg ( c , ch ) ; if ( ! arg ) return NULL ; asdl_seq_SET ( posargs , k ++ , arg ) ; i += 1 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case STAR : if ( i + 1 >= NCH ( n ) || ( i + 2 == NCH ( n ) && ( TYPE ( CHILD ( n , i + 1 ) ) == COMMA || TYPE ( CHILD ( n , i + 1 ) ) == TYPE_COMMENT ) ) ) { ast_error ( c , CHILD ( n , i ) , \"namedargumentsmustfollowbare*\" ) ; return NULL ; } ch = CHILD ( n , i + 1 ) ; if ( TYPE ( ch ) == COMMA ) { int res = 0 ; i += 2 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == TYPE_COMMENT ) { ast_error ( c , CHILD ( n , i ) , \"bare*hasassociatedtypecomment\" ) ; return NULL ; } res = handle_keywordonly_args ( c , n , i , kwonlyargs , kwdefaults ) ; if ( res == - 1 ) return NULL ; i = res ; } else { vararg = ast_for_arg ( c , ch ) ; if ( ! vararg ) return NULL ; i += 2 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == TYPE_COMMENT ) { vararg -> type_comment = NEW_TYPE_COMMENT ( CHILD ( n , i ) ) ; if ( ! vararg -> type_comment ) return NULL ; i += 1 ; } if ( i < NCH ( n ) && ( TYPE ( CHILD ( n , i ) ) == tfpdef || TYPE ( CHILD ( n , i ) ) == vfpdef ) ) { int res = 0 ; res = handle_keywordonly_args ( c , n , i , kwonlyargs , kwdefaults ) ; if ( res == - 1 ) return NULL ; i = res ; } } break ; case DOUBLESTAR : ch = CHILD ( n , i + 1 ) ; assert ( TYPE ( ch ) == tfpdef || TYPE ( ch ) == vfpdef ) ; kwarg = ast_for_arg ( c , ch ) ; if ( ! kwarg ) return NULL ; i += 2 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : assert ( i ) ; if ( kwarg ) arg = kwarg ; arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) return NULL ; i += 1 ; break ; default : PyErr_Format ( PyExc_SystemError , \"unexpectednodeinvarargslist:%d@%d\" , TYPE ( ch ) , i ) ; return NULL ; } } return arguments ( posargs , vararg , kwonlyargs , kwdefaults , kwarg , posdefaults , c -> c_arena ) ; }\n", "\n", "2: CWE-125 static int handle_keywordonly_args ( struct compiling * c , const node * n , int start , asdl_seq * kwonlyargs , asdl_seq * kwdefaults ) { PyObject * argname ; node * ch ; expr_ty expression , annotation ; arg_ty arg = NULL ; int i = start ; int j = 0 ; if ( kwonlyargs == NULL ) { ast_error ( c , CHILD ( n , start ) , \"namedargumentsmustfollowbare*\" ) ; return - 1 ; } assert ( kwdefaults != NULL ) ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case vfpdef : case tfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) goto error ; asdl_seq_SET ( kwdefaults , j , expression ) ; i += 2 ; } else { asdl_seq_SET ( kwdefaults , j , NULL ) ; } if ( NCH ( ch ) == 3 ) { annotation = ast_for_expr ( c , CHILD ( ch , 2 ) ) ; if ( ! annotation ) goto error ; } else { annotation = NULL ; } ch = CHILD ( ch , 0 ) ; argname = NEW_IDENTIFIER ( ch ) ; if ( ! argname ) goto error ; if ( forbidden_name ( c , argname , ch , 0 ) ) goto error ; arg = arg ( argname , annotation , NULL , LINENO ( ch ) , ch -> n_col_offset , ch -> n_end_lineno , ch -> n_end_col_offset , c -> c_arena ) ; if ( ! arg ) goto error ; asdl_seq_SET ( kwonlyargs , j ++ , arg ) ; i += 1 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) goto error ; i += 1 ; break ; case DOUBLESTAR : return i ; default : ast_error ( c , ch , \"unexpectednode\" ) ; goto error ; } } return i ; error : return - 1 ; }\n", "\n", "\n", "Target: drop ; } memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; == 5 ) return 0 ; return 0 ; opt -> optlen\n", "\n", "Sources:\n", "0: CWE-399 static int br_parse_ip_options ( struct sk_buff * skb ) { struct ip_options * opt ; struct iphdr * iph ; struct net_device * dev = skb -> dev ; u32 len ; iph = ip_hdr ( skb ) ; opt = & ( IPCB ( skb ) -> opt ) ; if ( iph -> ihl < 5 || iph -> version != 4 ) goto inhdr_error ; if ( ! pskb_may_pull ( skb , iph -> ihl * 4 ) ) goto inhdr_error ; iph = ip_hdr ( skb ) ; if ( unlikely ( ip_fast_csum ( ( u8 * ) iph , iph -> ihl ) ) ) goto inhdr_error ; len = ntohs ( iph -> tot_len ) ; if ( skb -> len < len ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INTRUNCATEDPKTS ) ; goto drop ; } else if ( len < ( iph -> ihl * 4 ) ) goto inhdr_error ; if ( pskb_trim_rcsum ( skb , len ) ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INDISCARDS ) ; goto drop ; } if ( iph -> ihl == 5 ) { memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; return 0 ; } opt -> optlen = iph -> ihl * 4 - sizeof ( struct iphdr ) ; if ( ip_options_compile ( dev_net ( dev ) , opt , skb ) ) goto inhdr_error ; if ( unlikely ( opt -> srr ) ) { struct in_device * in_dev = __in_dev_get_rcu ( dev ) ; if ( in_dev && ! IN_DEV_SOURCE_ROUTE ( in_dev ) ) goto drop ; if ( ip_options_rcv_srr ( skb ) ) goto drop ; } return 0 ; inhdr_error : IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INHDRERRORS ) ; drop : return - 1 ; }\n", "\n", "1: CWE-665 static int br_parse_ip_options ( struct sk_buff * skb ) { struct ip_options * opt ; struct iphdr * iph ; struct net_device * dev = skb -> dev ; u32 len ; iph = ip_hdr ( skb ) ; opt = & ( IPCB ( skb ) -> opt ) ; if ( iph -> ihl < 5 || iph -> version != 4 ) goto inhdr_error ; if ( ! pskb_may_pull ( skb , iph -> ihl * 4 ) ) goto inhdr_error ; iph = ip_hdr ( skb ) ; if ( unlikely ( ip_fast_csum ( ( u8 * ) iph , iph -> ihl ) ) ) goto inhdr_error ; len = ntohs ( iph -> tot_len ) ; if ( skb -> len < len ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INTRUNCATEDPKTS ) ; goto drop ; } else if ( len < ( iph -> ihl * 4 ) ) goto inhdr_error ; if ( pskb_trim_rcsum ( skb , len ) ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INDISCARDS ) ; goto drop ; } if ( iph -> ihl == 5 ) { memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; return 0 ; } opt -> optlen = iph -> ihl * 4 - sizeof ( struct iphdr ) ; if ( ip_options_compile ( dev_net ( dev ) , opt , skb ) ) goto inhdr_error ; if ( unlikely ( opt -> srr ) ) { struct in_device * in_dev = __in_dev_get_rcu ( dev ) ; if ( in_dev && ! IN_DEV_SOURCE_ROUTE ( in_dev ) ) goto drop ; if ( ip_options_rcv_srr ( skb ) ) goto drop ; } return 0 ; inhdr_error : IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INHDRERRORS ) ; drop : return - 1 ; }\n", "\n", "\n", "Target: ; if ( WARN_ON_ONCE ( ! head ) ) return - EINVAL - EINVAL ; hlist_add_head_rcu ( &\n", "\n", "Sources:\n", "0: CWE-362 static int perf_swevent_add ( struct perf_event * event , int flags ) { struct swevent_htable * swhash = this_cpu_ptr ( & swevent_htable ) ; struct hw_perf_event * hwc = & event -> hw ; struct hlist_head * head ; if ( is_sampling_event ( event ) ) { hwc -> last_period = hwc -> sample_period ; perf_swevent_set_period ( event ) ; } hwc -> state = ! ( flags & PERF_EF_START ) ; head = find_swevent_head ( swhash , event ) ; if ( ! head ) { WARN_ON_ONCE ( swhash -> online ) ; return - EINVAL ; } hlist_add_head_rcu ( & event -> hlist_entry , head ) ; perf_event_update_userpage ( event ) ; return 0 ; }\n", "\n", "1: CWE-416 static int perf_swevent_add ( struct perf_event * event , int flags ) { struct swevent_htable * swhash = this_cpu_ptr ( & swevent_htable ) ; struct hw_perf_event * hwc = & event -> hw ; struct hlist_head * head ; if ( is_sampling_event ( event ) ) { hwc -> last_period = hwc -> sample_period ; perf_swevent_set_period ( event ) ; } hwc -> state = ! ( flags & PERF_EF_START ) ; head = find_swevent_head ( swhash , event ) ; if ( ! head ) { WARN_ON_ONCE ( swhash -> online ) ; return - EINVAL ; } hlist_add_head_rcu ( & event -> hlist_entry , head ) ; perf_event_update_userpage ( event ) ; return 0 ; }\n", "\n", "\n", "Target: dref ) { GF_Box * dref ; ( \"[isofile]Missingdrefboxindinf\\\\n\" ) ) ; dref = gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF GF_DataReferenceBox * ) dref ; gf_isom_box_add_for_dump_mode ( s , dref ) ; }\n", "\n", "Sources:\n", "0: CWE-401 GF_Err dinf_Read ( GF_Box * s , GF_BitStream * bs ) { GF_Err e = gf_isom_box_array_read ( s , bs , dinf_AddBox ) ; if ( e ) { return e ; } if ( ! ( ( GF_DataInformationBox * ) s ) -> dref ) { GF_LOG ( GF_LOG_ERROR , GF_LOG_CONTAINER , ( \"[isofile]Missingdrefboxindinf\\\\n\" ) ) ; ( ( GF_DataInformationBox * ) s ) -> dref = ( GF_DataReferenceBox * ) gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF ) ; } return GF_OK ; }\n", "\n", "1: CWE-400 GF_Err dinf_Read ( GF_Box * s , GF_BitStream * bs ) { GF_Err e = gf_isom_box_array_read ( s , bs , dinf_AddBox ) ; if ( e ) { return e ; } if ( ! ( ( GF_DataInformationBox * ) s ) -> dref ) { GF_LOG ( GF_LOG_ERROR , GF_LOG_CONTAINER , ( \"[isofile]Missingdrefboxindinf\\\\n\" ) ) ; ( ( GF_DataInformationBox * ) s ) -> dref = ( GF_DataReferenceBox * ) gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF ) ; } return GF_OK ; }\n", "\n", "\n" ] } ], "source": [ "unique_targets = disjoint_test['target'].unique()\n", "\n", "for target_value in unique_targets:\n", " sources_for_target = disjoint_test[disjoint_test['target'] == target_value]['source'].unique()\n", "\n", " if len(sources_for_target) != 1:\n", " print(f\"Target: {target_value}\")\n", " print(\"Sources:\")\n", " for idx, source_value in enumerate(sources_for_target):\n", " print(f'{idx}: {source_value}')\n", " print()" ] }, { "cell_type": "code", "execution_count": 42, "id": "43c56574", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "25\n", "5\n", "9\n" ] } ], "source": [ "print(sum([elem.strip() == '' for elem in train_df['target']]))\n", "print(sum([elem.strip() == '' for elem in disjoint_test['target']]))\n", "print(sum([elem.strip() == '' for elem in test_df['target']]))\n" ] }, { "cell_type": "code", "execution_count": 43, "id": "1bf79fc0", "metadata": {}, "outputs": [], "source": [ "train_df = train_df[train_df['target'].str.strip() != '']\n", "disjoint_test = disjoint_test[disjoint_test['target'].str.strip() != '']\n", "test_df = test_df[test_df['target'].str.strip() != '']" ] }, { "cell_type": "code", "execution_count": 44, "id": "73ab5b69", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "0\n", "0\n" ] } ], "source": [ "print(sum([elem.strip() == '' for elem in train_df['target']]))\n", "print(sum([elem.strip() == '' for elem in disjoint_test['target']]))\n", "print(sum([elem.strip() == '' for elem in test_df['target']]))" ] }, { "cell_type": "code", "execution_count": 45, "id": "590b47a8", "metadata": {}, "outputs": [], "source": [ "train_df.to_csv('train.csv')\n", "disjoint_test.to_csv('cleantest.csv')\n", "test_df.to_csv('test.csv')" ] }, { "cell_type": "code", "execution_count": 46, "id": "4f10182d", "metadata": {}, "outputs": [], "source": [ "data = load_dataset(\"nus-yam/bigfixes\", streaming=True)\n", "\n", "train_data = data['train'].take(None)\n", "test_data = data['test'].take(None)\n", "clean_test = data['cleantest'].take(None)" ] }, { "cell_type": "code", "execution_count": 47, "id": "33e4a3af", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5158 1606 687\n" ] } ], "source": [ "print(len(list(train_data)), len(list(test_data)), len(list(clean_test)))" ] }, { "cell_type": "code", "execution_count": 48, "id": "0fe747f0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((1606, 8), (687, 8))" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test_df.shape, disjoint_test.shape" ] }, { "cell_type": "code", "execution_count": 49, "id": "9465e7cf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "program_1\n", "program_6776\n", "program_6777\n", "program_8479\n", "program_6779\n", "program_8479\n" ] } ], "source": [ "print(list(train_df.program_id.unique())[0])\n", "print(list(train_df.program_id.unique())[-1])\n", "\n", "print(list(test_df.program_id.unique())[0])\n", "print(list(test_df.program_id.unique())[-1])\n", "\n", "print(list(disjoint_test.program_id.unique())[0])\n", "print(list(disjoint_test.program_id.unique())[-1])" ] }, { "cell_type": "code", "execution_count": 50, "id": "25f6dac6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "any(program_id in test_df.program_id.unique() for program_id in train_df.program_id.unique())" ] }, { "cell_type": "code", "execution_count": 51, "id": "861bff1d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "any(program_id in disjoint_test.program_id.unique() for program_id in train_df.program_id.unique())" ] }, { "cell_type": "code", "execution_count": 52, "id": "cfc0e6ca", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "any(program_id in disjoint_test.program_id.unique() for program_id in test_df.program_id.unique())" ] }, { "cell_type": "code", "execution_count": null, "id": "542b73a8", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.0" } }, "nbformat": 4, "nbformat_minor": 5 }