[ { "id": 1779, "func": "main(int argc, char *argv[])\n{\n int i, c;\n FILE *ifp = 0, *ofp = 0;\n const char *ifp_filename = \"\";\n const char *ofp_filename = \"\";\n const char *set_font_name = 0;\n struct font_reader fr;\n uint32_t rfork_len;\n int raw = 0, macbinary = 1, applesingle = 0, appledouble = 0, binhex = 0;\n\n Clp_Parser *clp =\n Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options);\n program_name = Clp_ProgramName(clp);\n\n /* interpret command line arguments using CLP */\n while (1) {\n int opt = Clp_Next(clp);\n switch (opt) {\n\n case RAW_OPT:\n raw = 1;\n macbinary = applesingle = appledouble = binhex = 0;\n break;\n\n case MACBINARY_OPT:\n macbinary = 1;\n raw = applesingle = appledouble = binhex = 0;\n break;\n\n case APPLESINGLE_OPT:\n applesingle = 1;\n raw = macbinary = appledouble = binhex = 0;\n break;\n\n case APPLEDOUBLE_OPT:\n appledouble = 1;\n raw = macbinary = applesingle = binhex = 0;\n break;\n\n case BINHEX_OPT:\n binhex = 1;\n raw = macbinary = applesingle = appledouble = 0;\n break;\n\n output_file:\n case OUTPUT_OPT:\n if (ofp)\n\tfatal_error(\"output file already specified\");\n if (strcmp(clp->vstr, \"-\") == 0)\n\tofp = stdout;\n else {\n\tofp_filename = clp->vstr;\n\tofp = fopen(ofp_filename, \"wb\");\n\tif (!ofp) fatal_error(\"%s: %s\", ofp_filename, strerror(errno));\n }\n break;\n\n case FILENAME_OPT:\n if (set_font_name)\n\tfatal_error(\"Macintosh font filename already specified\");\n set_font_name = clp->vstr;\n break;\n\n case HELP_OPT:\n usage();\n exit(0);\n break;\n\n case VERSION_OPT:\n printf(\"t1mac (LCDF t1utils) %s\\n\", VERSION);\n printf(\"Copyright (C) 2000-2010 Eddie Kohler et al.\\n\\\nThis is free software; see the source for copying conditions.\\n\\\nThere is NO warranty, not even for merchantability or fitness for a\\n\\\nparticular purpose.\\n\");\n exit(0);\n break;\n\n case Clp_NotOption:\n if (ifp && ofp)\n\tfatal_error(\"too many arguments\");\n else if (ifp)\n\tgoto output_file;\n if (strcmp(clp->vstr, \"-\") == 0)\n\tifp = stdin;\n else {\n\tifp_filename = clp->vstr;\n\tifp = fopen(clp->vstr, \"r\");\n\tif (!ifp) fatal_error(\"%s: %s\", clp->vstr, strerror(errno));\n }\n break;\n\n case Clp_Done:\n goto done;\n\n case Clp_BadOption:\n short_usage();\n exit(1);\n break;\n\n }\n }\n\n done:\n if (!ifp) ifp = stdin;\n if (!ofp) ofp = stdout;\n\n#if defined(_MSDOS) || defined(_WIN32)\n /* As we are processing a PFB (binary) output */\n /* file, we must set its file mode to binary. */\n _setmode(_fileno(ofp), _O_BINARY);\n#endif\n\n /* prepare font reader */\n fr.output_ascii = t1mac_output_ascii;\n fr.output_binary = t1mac_output_binary;\n fr.output_end = t1mac_output_end;\n\n /* prepare resource fork file */\n rfork_f = tmpfile();\n if (!rfork_f)\n fatal_error(\"cannot open temorary file: %s\", strerror(errno));\n for (i = 0; i < RFORK_HEADERLEN; i++)\n putc(0, rfork_f);\n init_current_post();\n\n /* peek at first byte to see if it is the PFB marker 0x80 */\n c = getc(ifp);\n ungetc(c, ifp);\n\n /* do the file */\n if (c == PFB_MARKER)\n process_pfb(ifp, ifp_filename, &fr);\n else if (c == '%')\n process_pfa(ifp, ifp_filename, &fr);\n else\n fatal_error(\"%s does not start with font marker (`%%' or 0x80)\", ifp_filename);\n if (ifp != stdin)\n fclose(ifp);\n\n /* check if anything was read */\n if (nrsrc == 0)\n error(\"no POST resources written -- are you sure this was a font?\");\n\n /* output large B/W icon */\n output_new_rsrc(\"ICN#\", 256, 32, (const char *)icon_bw_data, 256);\n /* output FREF */\n output_new_rsrc(\"FREF\", 256, 32, \"LWFN\\0\\0\\0\", 7);\n /* output BNDL */\n output_new_rsrc(\"BNDL\", 256, 32, \"T1UT\\0\\0\\0\\1FREF\\0\\0\\0\\0\\1\\0ICN#\\0\\0\\0\\0\\1\\0\", 28);\n /* output other icons */\n output_new_rsrc(\"icl8\", 256, 32, (const char *)icon_8_data, 1024);\n output_new_rsrc(\"icl4\", 256, 32, (const char *)icon_4_data, 512);\n output_new_rsrc(\"ics#\", 256, 32, (const char *)small_icon_bw_data, 64);\n output_new_rsrc(\"ics8\", 256, 32, (const char *)small_icon_8_data, 256);\n output_new_rsrc(\"ics4\", 256, 32, (const char *)small_icon_4_data, 128);\n /* output T1UT (signature) */\n output_new_rsrc(\"T1UT\", 0, 0, \"DConverted by t1mac (t1utils) \\251Eddie Kohler http://www.lcdf.org/type/\", 69);\n\n /* finish off resource file */\n rfork_len = complete_rfork();\n\n /* prepare font name */\n if (!set_font_name && font_name) {\n int part = 0, len = 0;\n char *x, *s;\n for (x = s = font_name; *s; s++)\n if (isupper(*s) || isdigit(*s)) {\n\t*x++ = *s;\n\tpart++;\n\tlen = 1;\n } else if (islower(*s)) {\n\tif (len < (part <= 1 ? 5 : 3))\n\t *x++ = *s;\n\tlen++;\n }\n *x++ = 0;\n set_font_name = font_name;\n } else if (!set_font_name)\n set_font_name = \"Unknown Font\";\n\n /* now, output the file */\n if (macbinary)\n output_macbinary(rfork_f, rfork_len, set_font_name, ofp);\n else if (raw)\n output_raw(rfork_f, rfork_len, ofp);\n else if (applesingle || appledouble)\n output_applesingle(rfork_f, rfork_len, set_font_name, ofp, appledouble);\n else if (binhex)\n output_binhex(rfork_f, rfork_len, set_font_name, ofp);\n else\n fatal_error(\"strange output format\");\n fclose(rfork_f);\n\n if (ofp != stdout)\n fclose(ofp);\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-3905", "cwe_id": "CWE-119" }, { "id": 1779, "func": "main(int argc, char *argv[])\n{\n int i, c;\n FILE *ifp = 0, *ofp = 0;\n const char *ifp_filename = \"\";\n const char *ofp_filename = \"\";\n const char *set_font_name = 0;\n struct font_reader fr;\n uint32_t rfork_len;\n int raw = 0, macbinary = 1, applesingle = 0, appledouble = 0, binhex = 0;\n\n Clp_Parser *clp =\n Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options);\n program_name = Clp_ProgramName(clp);\n\n /* interpret command line arguments using CLP */\n while (1) {\n int opt = Clp_Next(clp);\n switch (opt) {\n\n case RAW_OPT:\n raw = 1;\n macbinary = applesingle = appledouble = binhex = 0;\n break;\n\n case MACBINARY_OPT:\n macbinary = 1;\n raw = applesingle = appledouble = binhex = 0;\n break;\n\n case APPLESINGLE_OPT:\n applesingle = 1;\n raw = macbinary = appledouble = binhex = 0;\n break;\n\n case APPLEDOUBLE_OPT:\n appledouble = 1;\n raw = macbinary = applesingle = binhex = 0;\n break;\n\n case BINHEX_OPT:\n binhex = 1;\n raw = macbinary = applesingle = appledouble = 0;\n break;\n\n output_file:\n case OUTPUT_OPT:\n if (ofp)\n\tfatal_error(\"output file already specified\");\n if (strcmp(clp->vstr, \"-\") == 0)\n\tofp = stdout;\n else {\n\tofp_filename = clp->vstr;\n\tofp = fopen(ofp_filename, \"wb\");\n\tif (!ofp) fatal_error(\"%s: %s\", ofp_filename, strerror(errno));\n }\n break;\n\n case FILENAME_OPT:\n if (set_font_name)\n\tfatal_error(\"Macintosh font filename already specified\");\n set_font_name = clp->vstr;\n break;\n\n case HELP_OPT:\n usage();\n exit(0);\n break;\n\n case VERSION_OPT:\n printf(\"t1mac (LCDF t1utils) %s\\n\", VERSION);\n printf(\"Copyright (C) 2000-2010 Eddie Kohler et al.\\n\\\nThis is free software; see the source for copying conditions.\\n\\\nThere is NO warranty, not even for merchantability or fitness for a\\n\\\nparticular purpose.\\n\");\n exit(0);\n break;\n\n case Clp_NotOption:\n if (ifp && ofp)\n\tfatal_error(\"too many arguments\");\n else if (ifp)\n\tgoto output_file;\n if (strcmp(clp->vstr, \"-\") == 0)\n\tifp = stdin;\n else {\n\tifp_filename = clp->vstr;\n\tifp = fopen(clp->vstr, \"r\");\n\tif (!ifp) fatal_error(\"%s: %s\", clp->vstr, strerror(errno));\n }\n break;\n\n case Clp_Done:\n goto done;\n\n case Clp_BadOption:\n short_usage();\n exit(1);\n break;\n\n }\n }\n\n done:\n if (!ifp) ifp = stdin;\n if (!ofp) ofp = stdout;\n\n#if defined(_MSDOS) || defined(_WIN32)\n /* As we are processing a PFB (binary) output */\n /* file, we must set its file mode to binary. */\n _setmode(_fileno(ofp), _O_BINARY);\n#endif\n\n /* prepare font reader */\n fr.output_ascii = t1mac_output_ascii;\n fr.output_binary = t1mac_output_binary;\n fr.output_end = t1mac_output_end;\n\n /* prepare resource fork file */\n rfork_f = tmpfile();\n if (!rfork_f)\n fatal_error(\"cannot open temorary file: %s\", strerror(errno));\n for (i = 0; i < RFORK_HEADERLEN; i++)\n putc(0, rfork_f);\n init_current_post();\n\n /* peek at first byte to see if it is the PFB marker 0x80 */\n c = getc(ifp);\n ungetc(c, ifp);\n\n /* do the file */\n if (c == PFB_MARKER)\n process_pfb(ifp, ifp_filename, &fr);\n else if (c == '%')\n process_pfa(ifp, ifp_filename, &fr);\n else\n fatal_error(\"%s does not start with font marker (`%%' or 0x80)\", ifp_filename);\n if (ifp != stdin)\n fclose(ifp);\n\n /* check if anything was read */\n if (nrsrc == 0)\n error(\"no POST resources written -- are you sure this was a font?\");\n\n /* output large B/W icon */\n output_new_rsrc(\"ICN#\", 256, 32, (const char *)icon_bw_data, 256);\n /* output FREF */\n output_new_rsrc(\"FREF\", 256, 32, \"LWFN\\0\\0\\0\", 7);\n /* output BNDL */\n output_new_rsrc(\"BNDL\", 256, 32, \"T1UT\\0\\0\\0\\1FREF\\0\\0\\0\\0\\1\\0ICN#\\0\\0\\0\\0\\1\\0\", 28);\n /* output other icons */\n output_new_rsrc(\"icl8\", 256, 32, (const char *)icon_8_data, 1024);\n output_new_rsrc(\"icl4\", 256, 32, (const char *)icon_4_data, 512);\n output_new_rsrc(\"ics#\", 256, 32, (const char *)small_icon_bw_data, 64);\n output_new_rsrc(\"ics8\", 256, 32, (const char *)small_icon_8_data, 256);\n output_new_rsrc(\"ics4\", 256, 32, (const char *)small_icon_4_data, 128);\n /* output T1UT (signature) */\n output_new_rsrc(\"T1UT\", 0, 0, \"DConverted by t1mac (t1utils) \\251Eddie Kohler http://www.lcdf.org/type/\", 69);\n\n /* finish off resource file */\n rfork_len = complete_rfork();\n\n /* prepare font name */\n if (!set_font_name && font_name) {\n int part = 0, len = 0;\n char *x, *s;\n for (x = s = font_name; *s; s++)\n if (isupper((unsigned char) *s) || isdigit((unsigned char) *s)) {\n\t*x++ = *s;\n\tpart++;\n\tlen = 1;\n } else if (islower((unsigned char) *s)) {\n\tif (len < (part <= 1 ? 5 : 3))\n\t *x++ = *s;\n\tlen++;\n }\n *x++ = 0;\n set_font_name = font_name;\n } else if (!set_font_name)\n set_font_name = \"Unknown Font\";\n\n /* now, output the file */\n if (macbinary)\n output_macbinary(rfork_f, rfork_len, set_font_name, ofp);\n else if (raw)\n output_raw(rfork_f, rfork_len, ofp);\n else if (applesingle || appledouble)\n output_applesingle(rfork_f, rfork_len, set_font_name, ofp, appledouble);\n else if (binhex)\n output_binhex(rfork_f, rfork_len, set_font_name, ofp);\n else\n fatal_error(\"strange output format\");\n fclose(rfork_f);\n\n if (ofp != stdout)\n fclose(ofp);\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-3905", "cwe_id": "CWE-119" }, { "id": 113, "func": "static int jas_iccgetuint32(jas_stream_t *in, jas_iccuint32_t *val)\n{\n\tulonglong tmp;\n\tif (jas_iccgetuint(in, 4, &tmp))\n\t\treturn -1;\n\t*val = tmp;\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 113, "func": "static int jas_iccgetuint32(jas_stream_t *in, jas_iccuint32_t *val)\n{\n\tjas_ulonglong tmp;\n\tif (jas_iccgetuint(in, 4, &tmp))\n\t\treturn -1;\n\t*val = tmp;\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2107, "func": "static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,\n\t\t\t\tconst struct iovec *iv, unsigned long total_len,\n\t\t\t\tsize_t count, int noblock)\n{\n\tstruct sk_buff *skb;\n\tstruct macvlan_dev *vlan;\n\tunsigned long len = total_len;\n\tint err;\n\tstruct virtio_net_hdr vnet_hdr = { 0 };\n\tint vnet_hdr_len = 0;\n\tint copylen;\n\tbool zerocopy = false;\n\n\tif (q->flags & IFF_VNET_HDR) {\n\t\tvnet_hdr_len = q->vnet_hdr_sz;\n\n\t\terr = -EINVAL;\n\t\tif (len < vnet_hdr_len)\n\t\t\tgoto err;\n\t\tlen -= vnet_hdr_len;\n\n\t\terr = memcpy_fromiovecend((void *)&vnet_hdr, iv, 0,\n\t\t\t\t\t sizeof(vnet_hdr));\n\t\tif (err < 0)\n\t\t\tgoto err;\n\t\tif ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&\n\t\t vnet_hdr.csum_start + vnet_hdr.csum_offset + 2 >\n\t\t\t\t\t\t\tvnet_hdr.hdr_len)\n\t\t\tvnet_hdr.hdr_len = vnet_hdr.csum_start +\n\t\t\t\t\t\tvnet_hdr.csum_offset + 2;\n\t\terr = -EINVAL;\n\t\tif (vnet_hdr.hdr_len > len)\n\t\t\tgoto err;\n\t}\n\n\terr = -EINVAL;\n\tif (unlikely(len < ETH_HLEN))\n\t\tgoto err;\n\n\tif (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY))\n\t\tzerocopy = true;\n\n\tif (zerocopy) {\n\t\t/* There are 256 bytes to be copied in skb, so there is enough\n\t\t * room for skb expand head in case it is used.\n\t\t * The rest buffer is mapped from userspace.\n\t\t */\n\t\tcopylen = vnet_hdr.hdr_len;\n\t\tif (!copylen)\n\t\t\tcopylen = GOODCOPY_LEN;\n\t} else\n\t\tcopylen = len;\n\n\tskb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen,\n\t\t\t\tvnet_hdr.hdr_len, noblock, &err);\n\tif (!skb)\n\t\tgoto err;\n\n\tif (zerocopy)\n\t\terr = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count);\n\telse\n\t\terr = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len,\n\t\t\t\t\t\t len);\n\tif (err)\n\t\tgoto err_kfree;\n\n\tskb_set_network_header(skb, ETH_HLEN);\n\tskb_reset_mac_header(skb);\n\tskb->protocol = eth_hdr(skb)->h_proto;\n\n\tif (vnet_hdr_len) {\n\t\terr = macvtap_skb_from_vnet_hdr(skb, &vnet_hdr);\n\t\tif (err)\n\t\t\tgoto err_kfree;\n\t}\n\n\trcu_read_lock_bh();\n\tvlan = rcu_dereference_bh(q->vlan);\n\t/* copy skb_ubuf_info for callback when skb has no error */\n\tif (zerocopy) {\n\t\tskb_shinfo(skb)->destructor_arg = m->msg_control;\n\t\tskb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;\n\t}\n\tif (vlan)\n\t\tmacvlan_start_xmit(skb, vlan->dev);\n\telse\n\t\tkfree_skb(skb);\n\trcu_read_unlock_bh();\n\n\treturn total_len;\n\nerr_kfree:\n\tkfree_skb(skb);\n\nerr:\n\trcu_read_lock_bh();\n\tvlan = rcu_dereference_bh(q->vlan);\n\tif (vlan)\n\t\tvlan->dev->stats.tx_dropped++;\n\trcu_read_unlock_bh();\n\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-2119", "cwe_id": "CWE-119" }, { "id": 2107, "func": "static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,\n\t\t\t\tconst struct iovec *iv, unsigned long total_len,\n\t\t\t\tsize_t count, int noblock)\n{\n\tstruct sk_buff *skb;\n\tstruct macvlan_dev *vlan;\n\tunsigned long len = total_len;\n\tint err;\n\tstruct virtio_net_hdr vnet_hdr = { 0 };\n\tint vnet_hdr_len = 0;\n\tint copylen = 0;\n\tbool zerocopy = false;\n\n\tif (q->flags & IFF_VNET_HDR) {\n\t\tvnet_hdr_len = q->vnet_hdr_sz;\n\n\t\terr = -EINVAL;\n\t\tif (len < vnet_hdr_len)\n\t\t\tgoto err;\n\t\tlen -= vnet_hdr_len;\n\n\t\terr = memcpy_fromiovecend((void *)&vnet_hdr, iv, 0,\n\t\t\t\t\t sizeof(vnet_hdr));\n\t\tif (err < 0)\n\t\t\tgoto err;\n\t\tif ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&\n\t\t vnet_hdr.csum_start + vnet_hdr.csum_offset + 2 >\n\t\t\t\t\t\t\tvnet_hdr.hdr_len)\n\t\t\tvnet_hdr.hdr_len = vnet_hdr.csum_start +\n\t\t\t\t\t\tvnet_hdr.csum_offset + 2;\n\t\terr = -EINVAL;\n\t\tif (vnet_hdr.hdr_len > len)\n\t\t\tgoto err;\n\t}\n\n\terr = -EINVAL;\n\tif (unlikely(len < ETH_HLEN))\n\t\tgoto err;\n\n\terr = -EMSGSIZE;\n\tif (unlikely(count > UIO_MAXIOV))\n\t\tgoto err;\n\n\tif (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY))\n\t\tzerocopy = true;\n\n\tif (zerocopy) {\n\t\t/* Userspace may produce vectors with count greater than\n\t\t * MAX_SKB_FRAGS, so we need to linearize parts of the skb\n\t\t * to let the rest of data to be fit in the frags.\n\t\t */\n\t\tif (count > MAX_SKB_FRAGS) {\n\t\t\tcopylen = iov_length(iv, count - MAX_SKB_FRAGS);\n\t\t\tif (copylen < vnet_hdr_len)\n\t\t\t\tcopylen = 0;\n\t\t\telse\n\t\t\t\tcopylen -= vnet_hdr_len;\n\t\t}\n\t\t/* There are 256 bytes to be copied in skb, so there is enough\n\t\t * room for skb expand head in case it is used.\n\t\t * The rest buffer is mapped from userspace.\n\t\t */\n\t\tif (copylen < vnet_hdr.hdr_len)\n\t\t\tcopylen = vnet_hdr.hdr_len;\n\t\tif (!copylen)\n\t\t\tcopylen = GOODCOPY_LEN;\n\t} else\n\t\tcopylen = len;\n\n\tskb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen,\n\t\t\t\tvnet_hdr.hdr_len, noblock, &err);\n\tif (!skb)\n\t\tgoto err;\n\n\tif (zerocopy)\n\t\terr = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count);\n\telse\n\t\terr = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len,\n\t\t\t\t\t\t len);\n\tif (err)\n\t\tgoto err_kfree;\n\n\tskb_set_network_header(skb, ETH_HLEN);\n\tskb_reset_mac_header(skb);\n\tskb->protocol = eth_hdr(skb)->h_proto;\n\n\tif (vnet_hdr_len) {\n\t\terr = macvtap_skb_from_vnet_hdr(skb, &vnet_hdr);\n\t\tif (err)\n\t\t\tgoto err_kfree;\n\t}\n\n\trcu_read_lock_bh();\n\tvlan = rcu_dereference_bh(q->vlan);\n\t/* copy skb_ubuf_info for callback when skb has no error */\n\tif (zerocopy) {\n\t\tskb_shinfo(skb)->destructor_arg = m->msg_control;\n\t\tskb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;\n\t}\n\tif (vlan)\n\t\tmacvlan_start_xmit(skb, vlan->dev);\n\telse\n\t\tkfree_skb(skb);\n\trcu_read_unlock_bh();\n\n\treturn total_len;\n\nerr_kfree:\n\tkfree_skb(skb);\n\nerr:\n\trcu_read_lock_bh();\n\tvlan = rcu_dereference_bh(q->vlan);\n\tif (vlan)\n\t\tvlan->dev->stats.tx_dropped++;\n\trcu_read_unlock_bh();\n\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-2119", "cwe_id": "CWE-119" }, { "id": 271, "func": "uint16_t dm9000ReadPhyReg(uint8_t address)\n{\n //Write PHY register address\n dm9000WriteReg(DM9000_REG_EPAR, 0x40 | address);\n\n //Start the read operation\n dm9000WriteReg(DM9000_REG_EPCR, EPCR_EPOS | EPCR_ERPRR);\n //PHY access is still in progress?\n while((dm9000ReadReg(DM9000_REG_EPCR) & EPCR_ERRE) != 0)\n {\n }\n\n //Clear command register\n dm9000WriteReg(DM9000_REG_EPCR, EPCR_EPOS);\n //Wait 5us minimum\n usleep(5);\n\n //Return register value\n return (dm9000ReadReg(DM9000_REG_EPDRH) << 8) | dm9000ReadReg(DM9000_REG_EPDRL);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 271, "func": "uint16_t dm9000ReadPhyReg(uint8_t address)\n{\n //Write PHY register address\n dm9000WriteReg(DM9000_EPAR, 0x40 | address);\n\n //Start the read operation\n dm9000WriteReg(DM9000_EPCR, DM9000_EPCR_EPOS | DM9000_EPCR_ERPRR);\n\n //PHY access is still in progress?\n while((dm9000ReadReg(DM9000_EPCR) & DM9000_EPCR_ERRE) != 0)\n {\n }\n\n //Clear command register\n dm9000WriteReg(DM9000_EPCR, DM9000_EPCR_EPOS);\n //Wait 5us minimum\n usleep(5);\n\n //Return register value\n return (dm9000ReadReg(DM9000_EPDRH) << 8) | dm9000ReadReg(DM9000_EPDRL);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 3208, "func": "static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,\n\t\t\t\t unsigned long arg)\n{\n\tstruct snd_timer_user *tu;\n\tvoid __user *argp = (void __user *)arg;\n\tint __user *p = argp;\n\n\ttu = file->private_data;\n\tswitch (cmd) {\n\tcase SNDRV_TIMER_IOCTL_PVERSION:\n\t\treturn put_user(SNDRV_TIMER_VERSION, p) ? -EFAULT : 0;\n\tcase SNDRV_TIMER_IOCTL_NEXT_DEVICE:\n\t\treturn snd_timer_user_next_device(argp);\n\tcase SNDRV_TIMER_IOCTL_TREAD:\n\t{\n\t\tint xarg;\n\n\t\tmutex_lock(&tu->tread_sem);\n\t\tif (tu->timeri)\t{\t/* too late */\n\t\t\tmutex_unlock(&tu->tread_sem);\n\t\t\treturn -EBUSY;\n\t\t}\n\t\tif (get_user(xarg, p)) {\n\t\t\tmutex_unlock(&tu->tread_sem);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\ttu->tread = xarg ? 1 : 0;\n\t\tmutex_unlock(&tu->tread_sem);\n\t\treturn 0;\n\t}\n\tcase SNDRV_TIMER_IOCTL_GINFO:\n\t\treturn snd_timer_user_ginfo(file, argp);\n\tcase SNDRV_TIMER_IOCTL_GPARAMS:\n\t\treturn snd_timer_user_gparams(file, argp);\n\tcase SNDRV_TIMER_IOCTL_GSTATUS:\n\t\treturn snd_timer_user_gstatus(file, argp);\n\tcase SNDRV_TIMER_IOCTL_SELECT:\n\t\treturn snd_timer_user_tselect(file, argp);\n\tcase SNDRV_TIMER_IOCTL_INFO:\n\t\treturn snd_timer_user_info(file, argp);\n\tcase SNDRV_TIMER_IOCTL_PARAMS:\n\t\treturn snd_timer_user_params(file, argp);\n\tcase SNDRV_TIMER_IOCTL_STATUS:\n\t\treturn snd_timer_user_status(file, argp);\n\tcase SNDRV_TIMER_IOCTL_START:\n\tcase SNDRV_TIMER_IOCTL_START_OLD:\n\t\treturn snd_timer_user_start(file);\n\tcase SNDRV_TIMER_IOCTL_STOP:\n\tcase SNDRV_TIMER_IOCTL_STOP_OLD:\n\t\treturn snd_timer_user_stop(file);\n\tcase SNDRV_TIMER_IOCTL_CONTINUE:\n\tcase SNDRV_TIMER_IOCTL_CONTINUE_OLD:\n\t\treturn snd_timer_user_continue(file);\n\tcase SNDRV_TIMER_IOCTL_PAUSE:\n\tcase SNDRV_TIMER_IOCTL_PAUSE_OLD:\n\t\treturn snd_timer_user_pause(file);\n\t}\n\treturn -ENOTTY;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2546", "cwe_id": "CWE-362" }, { "id": 3208, "func": "static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,\n\t\t\t\t unsigned long arg)\n{\n\tstruct snd_timer_user *tu = file->private_data;\n\tlong ret;\n\n\tmutex_lock(&tu->ioctl_lock);\n\tret = __snd_timer_user_ioctl(file, cmd, arg);\n\tmutex_unlock(&tu->ioctl_lock);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2546", "cwe_id": "CWE-362" }, { "id": 2863, "func": "static int usbhid_parse(struct hid_device *hid)\n{\n\tstruct usb_interface *intf = to_usb_interface(hid->dev.parent);\n\tstruct usb_host_interface *interface = intf->cur_altsetting;\n\tstruct usb_device *dev = interface_to_usbdev (intf);\n\tstruct hid_descriptor *hdesc;\n\tu32 quirks = 0;\n\tunsigned int rsize = 0;\n\tchar *rdesc;\n\tint ret, n;\n\n\tquirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),\n\t\t\tle16_to_cpu(dev->descriptor.idProduct));\n\n\tif (quirks & HID_QUIRK_IGNORE)\n\t\treturn -ENODEV;\n\n\t/* Many keyboards and mice don't like to be polled for reports,\n\t * so we will always set the HID_QUIRK_NOGET flag for them. */\n\tif (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {\n\t\tif (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD ||\n\t\t\tinterface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)\n\t\t\t\tquirks |= HID_QUIRK_NOGET;\n\t}\n\n\tif (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&\n\t (!interface->desc.bNumEndpoints ||\n\t usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {\n\t\tdbg_hid(\"class descriptor not present\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\thid->version = le16_to_cpu(hdesc->bcdHID);\n\thid->country = hdesc->bCountryCode;\n\n\tfor (n = 0; n < hdesc->bNumDescriptors; n++)\n\t\tif (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)\n\t\t\trsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);\n\n\tif (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {\n\t\tdbg_hid(\"weird size of report descriptor (%u)\\n\", rsize);\n\t\treturn -EINVAL;\n\t}\n\n\trdesc = kmalloc(rsize, GFP_KERNEL);\n\tif (!rdesc)\n\t\treturn -ENOMEM;\n\n\thid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);\n\n\tret = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber,\n\t\t\tHID_DT_REPORT, rdesc, rsize);\n\tif (ret < 0) {\n\t\tdbg_hid(\"reading report descriptor failed\\n\");\n\t\tkfree(rdesc);\n\t\tgoto err;\n\t}\n\n\tret = hid_parse_report(hid, rdesc, rsize);\n\tkfree(rdesc);\n\tif (ret) {\n\t\tdbg_hid(\"parsing report descriptor failed\\n\");\n\t\tgoto err;\n\t}\n\n\thid->quirks |= quirks;\n\n\treturn 0;\nerr:\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-16533", "cwe_id": "CWE-125" }, { "id": 2863, "func": "static int usbhid_parse(struct hid_device *hid)\n{\n\tstruct usb_interface *intf = to_usb_interface(hid->dev.parent);\n\tstruct usb_host_interface *interface = intf->cur_altsetting;\n\tstruct usb_device *dev = interface_to_usbdev (intf);\n\tstruct hid_descriptor *hdesc;\n\tu32 quirks = 0;\n\tunsigned int rsize = 0;\n\tchar *rdesc;\n\tint ret, n;\n\tint num_descriptors;\n\tsize_t offset = offsetof(struct hid_descriptor, desc);\n\n\tquirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),\n\t\t\tle16_to_cpu(dev->descriptor.idProduct));\n\n\tif (quirks & HID_QUIRK_IGNORE)\n\t\treturn -ENODEV;\n\n\t/* Many keyboards and mice don't like to be polled for reports,\n\t * so we will always set the HID_QUIRK_NOGET flag for them. */\n\tif (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {\n\t\tif (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD ||\n\t\t\tinterface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)\n\t\t\t\tquirks |= HID_QUIRK_NOGET;\n\t}\n\n\tif (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&\n\t (!interface->desc.bNumEndpoints ||\n\t usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {\n\t\tdbg_hid(\"class descriptor not present\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tif (hdesc->bLength < sizeof(struct hid_descriptor)) {\n\t\tdbg_hid(\"hid descriptor is too short\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\thid->version = le16_to_cpu(hdesc->bcdHID);\n\thid->country = hdesc->bCountryCode;\n\n\tnum_descriptors = min_t(int, hdesc->bNumDescriptors,\n\t (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));\n\n\tfor (n = 0; n < num_descriptors; n++)\n\t\tif (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)\n\t\t\trsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);\n\n\tif (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {\n\t\tdbg_hid(\"weird size of report descriptor (%u)\\n\", rsize);\n\t\treturn -EINVAL;\n\t}\n\n\trdesc = kmalloc(rsize, GFP_KERNEL);\n\tif (!rdesc)\n\t\treturn -ENOMEM;\n\n\thid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);\n\n\tret = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber,\n\t\t\tHID_DT_REPORT, rdesc, rsize);\n\tif (ret < 0) {\n\t\tdbg_hid(\"reading report descriptor failed\\n\");\n\t\tkfree(rdesc);\n\t\tgoto err;\n\t}\n\n\tret = hid_parse_report(hid, rdesc, rsize);\n\tkfree(rdesc);\n\tif (ret) {\n\t\tdbg_hid(\"parsing report descriptor failed\\n\");\n\t\tgoto err;\n\t}\n\n\thid->quirks |= quirks;\n\n\treturn 0;\nerr:\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-16533", "cwe_id": "CWE-125" }, { "id": 1389, "func": "snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header,\n snmp_varbind_t *varbinds, uint32_t *varbind_num)\n{\n uint8_t type, len;\n uint32_t i, oid_len = SNMP_MSG_OID_MAX_LEN;\n\n buf = snmp_ber_decode_type(buf, &buf_len, &type);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode type\\n\");\n return NULL;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid type\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_length(buf, &buf_len, &len);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode length\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->version);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode version\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_string_len_buffer(buf, &buf_len, &header->community.community, &header->community.length);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode community\\n\");\n return NULL;\n }\n\n if(header->version != SNMP_VERSION_1 &&\n header->version != SNMP_VERSION_2C) {\n LOG_DBG(\"Invalid version\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_type(buf, &buf_len, &type);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode type\\n\");\n return NULL;\n }\n\n header->pdu_type = type;\n if(header->pdu_type != SNMP_DATA_TYPE_PDU_GET_REQUEST &&\n header->pdu_type != SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST &&\n header->pdu_type != SNMP_DATA_TYPE_PDU_GET_RESPONSE &&\n header->pdu_type != SNMP_DATA_TYPE_PDU_SET_REQUEST &&\n header->pdu_type != SNMP_DATA_TYPE_PDU_GET_BULK) {\n LOG_DBG(\"Invalid pdu type\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_length(buf, &buf_len, &len);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode length\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->request_id);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode request id\\n\");\n return NULL;\n }\n\n if(header->pdu_type == SNMP_DATA_TYPE_PDU_GET_BULK) {\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_status_non_repeaters.non_repeaters);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode error status\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_index_max_repetitions.max_repetitions);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode error index\\n\");\n return NULL;\n }\n } else {\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_status_non_repeaters.error_status);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode error status\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_index_max_repetitions.error_index);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode error index\\n\");\n return NULL;\n }\n }\n\n buf = snmp_ber_decode_type(buf, &buf_len, &type);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode type\\n\");\n return NULL;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid type\\n\");\n return NULL;\n }\n\n buf = snmp_ber_decode_length(buf, &buf_len, &len);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode length\\n\");\n return NULL;\n }\n\n for(i = 0; buf_len > 0; ++i) {\n if(i >= *varbind_num) {\n return NULL;\n }\n\n buf = snmp_ber_decode_type(buf, &buf_len, &type);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode type\\n\");\n return NULL;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid (%X) type\\n\", type);\n return NULL;\n }\n\n buf = snmp_ber_decode_length(buf, &buf_len, &len);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode length\\n\");\n return NULL;\n }\n\n buf = snmp_oid_decode_oid(buf, &buf_len, varbinds[i].oid, &oid_len);\n if(buf == NULL) {\n LOG_DBG(\"Could not decode oid\\n\");\n return NULL;\n }\n\n varbinds[i].value_type = *buf;\n\n switch(varbinds[i].value_type) {\n case BER_DATA_TYPE_INTEGER:\n buf = snmp_ber_decode_integer(buf, &buf_len, &varbinds[i].value.integer);\n break;\n case SNMP_DATA_TYPE_TIME_TICKS:\n buf = snmp_ber_decode_unsigned_integer(buf, &buf_len, varbinds[i].value_type, &varbinds[i].value.integer);\n break;\n case BER_DATA_TYPE_OCTET_STRING:\n buf = snmp_ber_decode_string_len_buffer(buf, &buf_len, &varbinds[i].value.string.string, &varbinds[i].value.string.length);\n break;\n case BER_DATA_TYPE_NULL:\n buf = snmp_ber_decode_null(buf, &buf_len);\n break;\n default:\n LOG_DBG(\"Invalid varbind type\\n\");\n return NULL;\n }\n\n if(buf == NULL) {\n LOG_DBG(\"Could varbind type\\n\");\n return NULL;\n }\n }\n\n *varbind_num = i;\n\n return buf;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 1389, "func": "snmp_message_decode(snmp_packet_t *snmp_packet, snmp_header_t *header, snmp_varbind_t *varbinds)\n{\n uint8_t type, len, i;\n\n if(!snmp_ber_decode_type(snmp_packet, &type)) {\n LOG_DBG(\"Could not decode type\\n\");\n return 0;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid type\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_length(snmp_packet, &len)) {\n LOG_DBG(\"Could not decode length\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_integer(snmp_packet, &header->version)) {\n LOG_DBG(\"Could not decode version\\n\");\n return 0;\n }\n\n switch(header->version) {\n case SNMP_VERSION_1:\n case SNMP_VERSION_2C:\n break;\n default:\n LOG_DBG(\"Invalid version\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_string_len_buffer(snmp_packet, &header->community.community, &header->community.length)) {\n LOG_DBG(\"Could not decode community\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_type(snmp_packet, &header->pdu_type)) {\n LOG_DBG(\"Could not decode pdu type\\n\");\n return 0;\n }\n\n switch(header->pdu_type) {\n case BER_DATA_TYPE_PDU_GET_REQUEST:\n case BER_DATA_TYPE_PDU_GET_NEXT_REQUEST:\n case BER_DATA_TYPE_PDU_GET_RESPONSE:\n case BER_DATA_TYPE_PDU_SET_REQUEST:\n case BER_DATA_TYPE_PDU_GET_BULK:\n break;\n default:\n LOG_DBG(\"Invalid version\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_length(snmp_packet, &len)) {\n LOG_DBG(\"Could not decode length\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_integer(snmp_packet, &header->request_id)) {\n LOG_DBG(\"Could not decode request id\\n\");\n return 0;\n }\n\n switch(header->pdu_type) {\n case BER_DATA_TYPE_PDU_GET_BULK:\n if(!snmp_ber_decode_integer(snmp_packet, &header->non_repeaters)) {\n LOG_DBG(\"Could not decode non repeaters\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_integer(snmp_packet, &header->max_repetitions)) {\n LOG_DBG(\"Could not decode max repetition\\n\");\n return 0;\n }\n break;\n default:\n if(!snmp_ber_decode_integer(snmp_packet, &header->error_status)) {\n LOG_DBG(\"Could not decode error status\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_integer(snmp_packet, &header->error_index)) {\n LOG_DBG(\"Could not decode error index\\n\");\n return 0;\n }\n break;\n }\n\n if(!snmp_ber_decode_type(snmp_packet, &type)) {\n LOG_DBG(\"Could not decode type\\n\");\n return 0;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid type\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_length(snmp_packet, &len)) {\n LOG_DBG(\"Could not decode length\\n\");\n return 0;\n }\n\n for(i = 0; snmp_packet->used > 0; ++i) {\n if(i >= SNMP_MAX_NR_VALUES) {\n LOG_DBG(\"OID's overflow\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_type(snmp_packet, &type)) {\n LOG_DBG(\"Could not decode type\\n\");\n return 0;\n }\n\n if(type != BER_DATA_TYPE_SEQUENCE) {\n LOG_DBG(\"Invalid (%X) type\\n\", type);\n return 0;\n }\n\n if(!snmp_ber_decode_length(snmp_packet, &len)) {\n LOG_DBG(\"Could not decode length\\n\");\n return 0;\n }\n\n if(!snmp_ber_decode_oid(snmp_packet, &varbinds[i].oid)) {\n LOG_DBG(\"Could not decode oid\\n\");\n return 0;\n }\n\n varbinds[i].value_type = *snmp_packet->in;\n\n switch(varbinds[i].value_type) {\n case BER_DATA_TYPE_INTEGER:\n if(!snmp_ber_decode_integer(snmp_packet, &varbinds[i].value.integer)) {\n LOG_DBG(\"Could not decode integer type\\n\");\n return 0;\n }\n break;\n case BER_DATA_TYPE_TIMETICKS:\n if(!snmp_ber_decode_timeticks(snmp_packet, &varbinds[i].value.integer)) {\n LOG_DBG(\"Could not decode timeticks type\\n\");\n return 0;\n }\n break;\n case BER_DATA_TYPE_OCTET_STRING:\n if(!snmp_ber_decode_string_len_buffer(snmp_packet, &varbinds[i].value.string.string, &varbinds[i].value.string.length)) {\n LOG_DBG(\"Could not decode octed string type\\n\");\n return 0;\n }\n break;\n case BER_DATA_TYPE_NULL:\n if(!snmp_ber_decode_null(snmp_packet)) {\n LOG_DBG(\"Could not decode null type\\n\");\n return 0;\n }\n break;\n default:\n LOG_DBG(\"Invalid varbind type\\n\");\n return 0;\n }\n }\n\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 2537, "func": "static void cil_reset_perm(struct cil_perm *perm)\n{\n\tcil_reset_classperms_list(perm->classperms);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36085", "cwe_id": "CWE-416" }, { "id": 2537, "func": "static void cil_reset_perm(struct cil_perm *perm)\n{\n\tcil_list_destroy(&perm->classperms, CIL_FALSE);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36085", "cwe_id": "CWE-416" }, { "id": 2579, "func": "activate_desktop_file (ActivateParameters *parameters,\n NautilusFile *file)\n{\n ActivateParametersDesktop *parameters_desktop;\n char *primary, *secondary, *display_name;\n GtkWidget *dialog;\n GdkScreen *screen;\n char *uri;\n\n screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));\n\n if (!nautilus_file_is_trusted_link (file))\n {\n /* copy the parts of parameters we are interested in as the orignal will be freed */\n parameters_desktop = g_new0 (ActivateParametersDesktop, 1);\n if (parameters->parent_window)\n {\n parameters_desktop->parent_window = parameters->parent_window;\n g_object_add_weak_pointer (G_OBJECT (parameters_desktop->parent_window), (gpointer *) ¶meters_desktop->parent_window);\n }\n parameters_desktop->file = nautilus_file_ref (file);\n\n primary = _(\"Untrusted application launcher\");\n display_name = nautilus_file_get_display_name (file);\n secondary =\n g_strdup_printf (_(\"The application launcher \u201c%s\u201d has not been marked as trusted. \"\n \"If you do not know the source of this file, launching it may be unsafe.\"\n ),\n display_name);\n\n dialog = gtk_message_dialog_new (parameters->parent_window,\n 0,\n GTK_MESSAGE_WARNING,\n GTK_BUTTONS_NONE,\n NULL);\n g_object_set (dialog,\n \"text\", primary,\n \"secondary-text\", secondary,\n NULL);\n gtk_dialog_add_button (GTK_DIALOG (dialog),\n _(\"_Launch Anyway\"), RESPONSE_RUN);\n if (nautilus_file_can_set_permissions (file))\n {\n gtk_dialog_add_button (GTK_DIALOG (dialog),\n _(\"Mark as _Trusted\"), RESPONSE_MARK_TRUSTED);\n }\n gtk_dialog_add_button (GTK_DIALOG (dialog),\n _(\"_Cancel\"), GTK_RESPONSE_CANCEL);\n gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);\n\n g_signal_connect (dialog, \"response\",\n G_CALLBACK (untrusted_launcher_response_callback),\n parameters_desktop);\n gtk_widget_show (dialog);\n\n g_free (display_name);\n g_free (secondary);\n return;\n }\n\n uri = nautilus_file_get_uri (file);\n DEBUG (\"Launching trusted launcher %s\", uri);\n nautilus_launch_desktop_file (screen, uri, NULL,\n parameters->parent_window);\n g_free (uri);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14604", "cwe_id": "CWE-20" }, { "id": 2579, "func": "activate_desktop_file (ActivateParameters *parameters,\n NautilusFile *file)\n{\n ActivateParametersDesktop *parameters_desktop;\n char *primary, *secondary, *display_name;\n GtkWidget *dialog;\n GdkScreen *screen;\n char *uri;\n\n screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));\n\n if (!nautilus_file_is_trusted_link (file))\n {\n /* copy the parts of parameters we are interested in as the orignal will be freed */\n parameters_desktop = g_new0 (ActivateParametersDesktop, 1);\n if (parameters->parent_window)\n {\n parameters_desktop->parent_window = parameters->parent_window;\n g_object_add_weak_pointer (G_OBJECT (parameters_desktop->parent_window), (gpointer *) ¶meters_desktop->parent_window);\n }\n parameters_desktop->file = nautilus_file_ref (file);\n\n primary = _(\"Untrusted application launcher\");\n display_name = nautilus_file_get_display_name (file);\n secondary =\n g_strdup_printf (_(\"The application launcher \u201c%s\u201d has not been marked as trusted. \"\n \"If you do not know the source of this file, launching it may be unsafe.\"\n ),\n display_name);\n\n dialog = gtk_message_dialog_new (parameters->parent_window,\n 0,\n GTK_MESSAGE_WARNING,\n GTK_BUTTONS_NONE,\n NULL);\n g_object_set (dialog,\n \"text\", primary,\n \"secondary-text\", secondary,\n NULL);\n\n gtk_dialog_add_button (GTK_DIALOG (dialog),\n _(\"_Cancel\"), GTK_RESPONSE_CANCEL);\n\n gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);\n if (nautilus_file_can_set_permissions (file))\n {\n gtk_dialog_add_button (GTK_DIALOG (dialog),\n _(\"Trust and _Launch\"), GTK_RESPONSE_OK);\n }\n g_signal_connect (dialog, \"response\",\n G_CALLBACK (untrusted_launcher_response_callback),\n parameters_desktop);\n gtk_widget_show (dialog);\n\n g_free (display_name);\n g_free (secondary);\n return;\n }\n\n uri = nautilus_file_get_uri (file);\n DEBUG (\"Launching trusted launcher %s\", uri);\n nautilus_launch_desktop_file (screen, uri, NULL,\n parameters->parent_window);\n g_free (uri);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14604", "cwe_id": "CWE-20" }, { "id": 2582, "func": "R_API RConfigNode* r_config_set(RConfig *cfg, const char *name, const char *value) {\n\tRConfigNode *node = NULL;\n\tchar *ov = NULL;\n\tut64 oi;\n\tif (!cfg || STRNULL (name)) {\n\t\treturn NULL;\n\t}\n\tnode = r_config_node_get (cfg, name);\n\tif (node) {\n\t\tif (node->flags & CN_RO) {\n\t\t\teprintf (\"(error: '%s' config key is read only)\\n\", name);\n\t\t\treturn node;\n\t\t}\n\t\toi = node->i_value;\n\t\tif (node->value) {\n\t\t\tov = strdup (node->value);\n\t\t\tif (!ov) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (\"\");\n\t\t}\n\t\tif (node->flags & CN_BOOL) {\n\t\t\tbool b = is_true (value);\n\t\t\tnode->i_value = (ut64) b? 1: 0;\n\t\t\tchar *value = strdup (r_str_bool (b));\n\t\t\tif (value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = value;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = strdup (\"\");\n\t\t\t\tnode->i_value = 0;\n\t\t\t} else {\n\t\t\t\tif (node->value == value) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = strdup (value);\n\t\t\t\tif (IS_DIGIT (*value)) {\n\t\t\t\t\tif (strchr (value, '/')) {\n\t\t\t\t\t\tnode->i_value = r_num_get (cfg->num, value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode->i_value = r_num_math (cfg->num, value);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnode->i_value = 0;\n\t\t\t\t}\n\t\t\t\tnode->flags |= CN_INT;\n\t\t\t}\n\t\t}\n\t} else { // Create a new RConfigNode\n\t\toi = UT64_MAX;\n\t\tif (!cfg->lock) {\n\t\t\tnode = r_config_node_new (name, value);\n\t\t\tif (node) {\n\t\t\t\tif (value && is_bool (value)) {\n\t\t\t\t\tnode->flags |= CN_BOOL;\n\t\t\t\t\tnode->i_value = is_true (value)? 1: 0;\n\t\t\t\t}\n\t\t\t\tif (cfg->ht) {\n\t\t\t\t\tht_insert (cfg->ht, node->name, node);\n\t\t\t\t\tr_list_append (cfg->nodes, node);\n\t\t\t\t\tcfg->n_nodes++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teprintf (\"r_config_set: unable to create a new RConfigNode\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"r_config_set: variable '%s' not found\\n\", name);\n\t\t}\n\t}\n\n\tif (node && node->setter) {\n\t\tint ret = node->setter (cfg->user, node);\n\t\tif (ret == false) {\n\t\t\tif (oi != UT64_MAX) {\n\t\t\t\tnode->i_value = oi;\n\t\t\t}\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (ov? ov: \"\");\n\t\t}\n\t}\nbeach:\n\tfree (ov);\n\treturn node;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9520", "cwe_id": "CWE-416" }, { "id": 2582, "func": "R_API RConfigNode* r_config_set(RConfig *cfg, const char *name, const char *value) {\n\tRConfigNode *node = NULL;\n\tchar *ov = NULL;\n\tut64 oi;\n\tif (!cfg || STRNULL (name)) {\n\t\treturn NULL;\n\t}\n\tnode = r_config_node_get (cfg, name);\n\tif (node) {\n\t\tif (node->flags & CN_RO) {\n\t\t\teprintf (\"(error: '%s' config key is read only)\\n\", name);\n\t\t\treturn node;\n\t\t}\n\t\toi = node->i_value;\n\t\tif (node->value) {\n\t\t\tov = strdup (node->value);\n\t\t\tif (!ov) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (\"\");\n\t\t}\n\t\tif (node->flags & CN_BOOL) {\n\t\t\tbool b = is_true (value);\n\t\t\tnode->i_value = (ut64) b? 1: 0;\n\t\t\tchar *value = strdup (r_str_bool (b));\n\t\t\tif (value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = value;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = strdup (\"\");\n\t\t\t\tnode->i_value = 0;\n\t\t\t} else {\n\t\t\t\tif (node->value == value) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tchar *tmp = node->value;\n\t\t\t\tnode->value = strdup (value);\n\t\t\t\tfree (tmp);\n\t\t\t\tif (IS_DIGIT (*value)) {\n\t\t\t\t\tif (strchr (value, '/')) {\n\t\t\t\t\t\tnode->i_value = r_num_get (cfg->num, value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode->i_value = r_num_math (cfg->num, value);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnode->i_value = 0;\n\t\t\t\t}\n\t\t\t\tnode->flags |= CN_INT;\n\t\t\t}\n\t\t}\n\t} else { // Create a new RConfigNode\n\t\toi = UT64_MAX;\n\t\tif (!cfg->lock) {\n\t\t\tnode = r_config_node_new (name, value);\n\t\t\tif (node) {\n\t\t\t\tif (value && is_bool (value)) {\n\t\t\t\t\tnode->flags |= CN_BOOL;\n\t\t\t\t\tnode->i_value = is_true (value)? 1: 0;\n\t\t\t\t}\n\t\t\t\tif (cfg->ht) {\n\t\t\t\t\tht_insert (cfg->ht, node->name, node);\n\t\t\t\t\tr_list_append (cfg->nodes, node);\n\t\t\t\t\tcfg->n_nodes++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teprintf (\"r_config_set: unable to create a new RConfigNode\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"r_config_set: variable '%s' not found\\n\", name);\n\t\t}\n\t}\n\n\tif (node && node->setter) {\n\t\tint ret = node->setter (cfg->user, node);\n\t\tif (ret == false) {\n\t\t\tif (oi != UT64_MAX) {\n\t\t\t\tnode->i_value = oi;\n\t\t\t}\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (ov? ov: \"\");\n\t\t}\n\t}\nbeach:\n\tfree (ov);\n\treturn node;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9520", "cwe_id": "CWE-416" }, { "id": 2446, "func": "static int jpc_pi_nextrlcp(register jpc_pi_t *pi)\n{\n\tjpc_pchg_t *pchg;\n\tint *prclyrno;\n\n\tpchg = pi->pchg;\n\tif (!pi->prgvolfirst) {\n\t\tassert(pi->prcno < pi->pirlvl->numprcs);\n\t\tprclyrno = &pi->pirlvl->prclyrnos[pi->prcno];\n\t\tgoto skip;\n\t} else {\n\t\tpi->prgvolfirst = 0;\n\t}\n\n\tfor (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&\n\t pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {\n\t\tfor (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <\n\t\t JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) {\n\t\t\tfor (pi->compno = pchg->compnostart, pi->picomp =\n\t\t\t &pi->picomps[pi->compno]; pi->compno < pi->numcomps &&\n\t\t\t pi->compno < JAS_CAST(int, pchg->compnoend); ++pi->compno, ++pi->picomp) {\n\t\t\t\tif (pi->rlvlno >= pi->picomp->numrlvls) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tpi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];\n\t\t\t\tfor (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos;\n\t\t\t\t pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) {\n\t\t\t\t\tif (pi->lyrno >= *prclyrno) {\n\t\t\t\t\t\t*prclyrno = pi->lyrno;\n\t\t\t\t\t\t++(*prclyrno);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\nskip:\n\t\t\t\t\t;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9583", "cwe_id": "CWE-125" }, { "id": 2446, "func": "static int jpc_pi_nextrlcp(register jpc_pi_t *pi)\n{\n\tjpc_pchg_t *pchg;\n\tint *prclyrno;\n\n\tpchg = pi->pchg;\n\tif (!pi->prgvolfirst) {\n\t\tassert(pi->prcno < pi->pirlvl->numprcs);\n\t\tprclyrno = &pi->pirlvl->prclyrnos[pi->prcno];\n\t\tgoto skip;\n\t} else {\n\t\tpi->prgvolfirst = 0;\n\t}\n\n\tfor (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls &&\n\t pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) {\n\t\tfor (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno <\n\t\t JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) {\n\t\t\tfor (pi->compno = pchg->compnostart, pi->picomp =\n\t\t\t &pi->picomps[pi->compno]; pi->compno < pi->numcomps &&\n\t\t\t pi->compno < JAS_CAST(int, pchg->compnoend); ++pi->compno,\n\t\t\t ++pi->picomp) {\n\t\t\t\tif (pi->rlvlno >= pi->picomp->numrlvls) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tpi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];\n\t\t\t\tfor (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos;\n\t\t\t\t pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) {\n\t\t\t\t\tif (pi->lyrno >= *prclyrno) {\n\t\t\t\t\t\t*prclyrno = pi->lyrno;\n\t\t\t\t\t\t++(*prclyrno);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\nskip:\n\t\t\t\t\t;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9583", "cwe_id": "CWE-125" }, { "id": 1616, "func": "diff_redraw(\n int\t\tdofold)\t // also recompute the folds\n{\n win_T\t*wp;\n win_T\t*wp_other = NULL;\n int\t\tused_max_fill_other = FALSE;\n int\t\tused_max_fill_curwin = FALSE;\n int\t\tn;\n\n need_diff_redraw = FALSE;\n FOR_ALL_WINDOWS(wp)\n\tif (wp->w_p_diff)\n\t{\n\t redraw_win_later(wp, SOME_VALID);\n\t if (wp != curwin)\n\t\twp_other = wp;\n#ifdef FEAT_FOLDING\n\t if (dofold && foldmethodIsDiff(wp))\n\t\tfoldUpdateAll(wp);\n#endif\n\t // A change may have made filler lines invalid, need to take care\n\t // of that for other windows.\n\t n = diff_check(wp, wp->w_topline);\n\t if ((wp != curwin && wp->w_topfill > 0) || n > 0)\n\t {\n\t\tif (wp->w_topfill > n)\n\t\t wp->w_topfill = (n < 0 ? 0 : n);\n\t\telse if (n > 0 && n > wp->w_topfill)\n\t\t{\n\t\t wp->w_topfill = n;\n\t\t if (wp == curwin)\n\t\t\tused_max_fill_curwin = TRUE;\n\t\t else if (wp_other != NULL)\n\t\t\tused_max_fill_other = TRUE;\n\t\t}\n\t\tcheck_topfill(wp, FALSE);\n\t }\n\t}\n\n if (wp_other != NULL && curwin->w_p_scb)\n {\n\tif (used_max_fill_curwin)\n\t // The current window was set to use the maximum number of filler\n\t // lines, may need to reduce them.\n\t diff_set_topline(wp_other, curwin);\n\telse if (used_max_fill_other)\n\t // The other window was set to use the maximum number of filler\n\t // lines, may need to reduce them.\n\t diff_set_topline(curwin, wp_other);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2208", "cwe_id": "CWE-476" }, { "id": 1616, "func": "diff_redraw(\n int\t\tdofold)\t // also recompute the folds\n{\n win_T\t*wp;\n win_T\t*wp_other = NULL;\n int\t\tused_max_fill_other = FALSE;\n int\t\tused_max_fill_curwin = FALSE;\n int\t\tn;\n\n need_diff_redraw = FALSE;\n FOR_ALL_WINDOWS(wp)\n\t// when closing windows or wiping buffers skip invalid window\n\tif (wp->w_p_diff && buf_valid(wp->w_buffer))\n\t{\n\t redraw_win_later(wp, SOME_VALID);\n\t if (wp != curwin)\n\t\twp_other = wp;\n#ifdef FEAT_FOLDING\n\t if (dofold && foldmethodIsDiff(wp))\n\t\tfoldUpdateAll(wp);\n#endif\n\t // A change may have made filler lines invalid, need to take care\n\t // of that for other windows.\n\t n = diff_check(wp, wp->w_topline);\n\t if ((wp != curwin && wp->w_topfill > 0) || n > 0)\n\t {\n\t\tif (wp->w_topfill > n)\n\t\t wp->w_topfill = (n < 0 ? 0 : n);\n\t\telse if (n > 0 && n > wp->w_topfill)\n\t\t{\n\t\t wp->w_topfill = n;\n\t\t if (wp == curwin)\n\t\t\tused_max_fill_curwin = TRUE;\n\t\t else if (wp_other != NULL)\n\t\t\tused_max_fill_other = TRUE;\n\t\t}\n\t\tcheck_topfill(wp, FALSE);\n\t }\n\t}\n\n if (wp_other != NULL && curwin->w_p_scb)\n {\n\tif (used_max_fill_curwin)\n\t // The current window was set to use the maximum number of filler\n\t // lines, may need to reduce them.\n\t diff_set_topline(wp_other, curwin);\n\telse if (used_max_fill_other)\n\t // The other window was set to use the maximum number of filler\n\t // lines, may need to reduce them.\n\t diff_set_topline(curwin, wp_other);\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2208", "cwe_id": "CWE-476" }, { "id": 2382, "func": "void jas_matrix_divpow2(jas_matrix_t *matrix, int n)\n{\n\tint i;\n\tint j;\n\tjas_seqent_t *rowstart;\n\tint rowstep;\n\tjas_seqent_t *data;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t rowstart += rowstep) {\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t ++data) {\n\t\t\t\t*data = (*data >= 0) ? ((*data) >> n) :\n\t\t\t\t (-((-(*data)) >> n));\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2382, "func": "void jas_matrix_divpow2(jas_matrix_t *matrix, int n)\n{\n\tjas_matind_t i;\n\tjas_matind_t j;\n\tjas_seqent_t *rowstart;\n\tjas_matind_t rowstep;\n\tjas_seqent_t *data;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t rowstart += rowstep) {\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t ++data) {\n\t\t\t\t*data = (*data >= 0) ? ((*data) >> n) :\n\t\t\t\t (-((-(*data)) >> n));\n\t\t\t}\n\t\t}\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1760, "func": "mrb_proc_copy(struct RProc *a, struct RProc *b)\n{\n if (a->body.irep) {\n /* already initialized proc */\n return;\n }\n a->flags = b->flags;\n a->body = b->body;\n if (!MRB_PROC_CFUNC_P(a) && a->body.irep) {\n mrb_irep_incref(NULL, (mrb_irep*)a->body.irep);\n }\n a->upper = b->upper;\n a->e.env = b->e.env;\n /* a->e.target_class = a->e.target_class; */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-4110", "cwe_id": "CWE-476" }, { "id": 1760, "func": "mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b)\n{\n if (a->body.irep) {\n /* already initialized proc */\n return;\n }\n a->flags = b->flags;\n a->body = b->body;\n a->upper = b->upper;\n if (!MRB_PROC_CFUNC_P(a) && a->body.irep) {\n mrb_irep_incref(mrb, (mrb_irep*)a->body.irep);\n }\n a->e.env = b->e.env;\n /* a->e.target_class = a->e.target_class; */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-4110", "cwe_id": "CWE-476" }, { "id": 695, "func": " void Compute(OpKernelContext* ctx) override {\n const Tensor& handle = ctx->input(0);\n const string& name = handle.scalar()();\n OP_REQUIRES_OK(ctx, ctx->session_state()->DeleteTensor(name));\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29518", "cwe_id": "CWE-476" }, { "id": 695, "func": " void Compute(OpKernelContext* ctx) override {\n const Tensor& handle = ctx->input(0);\n const string& name = handle.scalar()();\n auto session_state = ctx->session_state();\n OP_REQUIRES(ctx, session_state != nullptr,\n errors::FailedPrecondition(\n \"DeleteSessionTensor called on null session state\"));\n OP_REQUIRES_OK(ctx, session_state->DeleteTensor(name));\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29518", "cwe_id": "CWE-476" }, { "id": 1733, "func": "static void ssdp_recv(int sd)\n{\n\tssize_t len;\n\tstruct sockaddr sa;\n\tsocklen_t salen;\n\tchar buf[MAX_PKT_SIZE];\n\n\tmemset(buf, 0, sizeof(buf));\n\tlen = recvfrom(sd, buf, sizeof(buf), MSG_DONTWAIT, &sa, &salen);\n\tif (len > 0) {\n\t\tbuf[len] = 0;\n\n\t\tif (sa.sa_family != AF_INET)\n\t\t\treturn;\n\n\t\tif (strstr(buf, \"M-SEARCH *\")) {\n\t\t\tsize_t i;\n\t\t\tchar *ptr, *type;\n\t\t\tstruct ifsock *ifs;\n\t\t\tstruct sockaddr_in *sin = (struct sockaddr_in *)&sa;\n\n\t\t\tifs = find_outbound(&sa);\n\t\t\tif (!ifs) {\n\t\t\t\tlogit(LOG_DEBUG, \"No matching socket for client %s\", inet_ntoa(sin->sin_addr));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlogit(LOG_DEBUG, \"Matching socket for client %s\", inet_ntoa(sin->sin_addr));\n\n\t\t\ttype = strcasestr(buf, \"\\r\\nST:\");\n\t\t\tif (!type) {\n\t\t\t\tlogit(LOG_DEBUG, \"No Search Type (ST:) found in M-SEARCH *, assuming \" SSDP_ST_ALL);\n\t\t\t\ttype = SSDP_ST_ALL;\n\t\t\t\tsend_message(ifs, type, &sa);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttype = strchr(type, ':');\n\t\t\tif (!type)\n\t\t\t\treturn;\n\t\t\ttype++;\n\t\t\twhile (isspace(*type))\n\t\t\t\ttype++;\n\n\t\t\tptr = strstr(type, \"\\r\\n\");\n\t\t\tif (!ptr)\n\t\t\t\treturn;\n\t\t\t*ptr = 0;\n\n\t\t\tfor (i = 0; supported_types[i]; i++) {\n\t\t\t\tif (!strcmp(supported_types[i], type)) {\n\t\t\t\t\tlogit(LOG_DEBUG, \"M-SEARCH * ST: %s from %s port %d\", type,\n\t\t\t\t\t inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));\n\t\t\t\t\tsend_message(ifs, type, &sa);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogit(LOG_DEBUG, \"M-SEARCH * for unsupported ST: %s from %s\", type,\n\t\t\t inet_ntoa(sin->sin_addr));\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-14323", "cwe_id": "CWE-787" }, { "id": 1733, "func": "static void ssdp_recv(int sd)\n{\n\tssize_t len;\n\tstruct sockaddr sa;\n\tsocklen_t salen;\n\tchar buf[MAX_PKT_SIZE + 1];\n\n\tmemset(buf, 0, sizeof(buf));\n\tlen = recvfrom(sd, buf, sizeof(buf) - 1, MSG_DONTWAIT, &sa, &salen);\n\tif (len > 0) {\n\t\tif (sa.sa_family != AF_INET)\n\t\t\treturn;\n\n\t\tif (strstr(buf, \"M-SEARCH *\")) {\n\t\t\tsize_t i;\n\t\t\tchar *ptr, *type;\n\t\t\tstruct ifsock *ifs;\n\t\t\tstruct sockaddr_in *sin = (struct sockaddr_in *)&sa;\n\n\t\t\tifs = find_outbound(&sa);\n\t\t\tif (!ifs) {\n\t\t\t\tlogit(LOG_DEBUG, \"No matching socket for client %s\", inet_ntoa(sin->sin_addr));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlogit(LOG_DEBUG, \"Matching socket for client %s\", inet_ntoa(sin->sin_addr));\n\n\t\t\ttype = strcasestr(buf, \"\\r\\nST:\");\n\t\t\tif (!type) {\n\t\t\t\tlogit(LOG_DEBUG, \"No Search Type (ST:) found in M-SEARCH *, assuming \" SSDP_ST_ALL);\n\t\t\t\ttype = SSDP_ST_ALL;\n\t\t\t\tsend_message(ifs, type, &sa);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttype = strchr(type, ':');\n\t\t\tif (!type)\n\t\t\t\treturn;\n\t\t\ttype++;\n\t\t\twhile (isspace(*type))\n\t\t\t\ttype++;\n\n\t\t\tptr = strstr(type, \"\\r\\n\");\n\t\t\tif (!ptr)\n\t\t\t\treturn;\n\t\t\t*ptr = 0;\n\n\t\t\tfor (i = 0; supported_types[i]; i++) {\n\t\t\t\tif (!strcmp(supported_types[i], type)) {\n\t\t\t\t\tlogit(LOG_DEBUG, \"M-SEARCH * ST: %s from %s port %d\", type,\n\t\t\t\t\t inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));\n\t\t\t\t\tsend_message(ifs, type, &sa);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogit(LOG_DEBUG, \"M-SEARCH * for unsupported ST: %s from %s\", type,\n\t\t\t inet_ntoa(sin->sin_addr));\n\t\t}\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-14323", "cwe_id": "CWE-787" }, { "id": 2258, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, node->inputs->size, 1);\n TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputVariableId);\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumElements(input_resource_id_tensor), 1);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputValue);\n SetTensorToDynamic(output);\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2258, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, node->inputs->size, 1);\n TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputVariableId,\n &input_resource_id_tensor));\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumElements(input_resource_id_tensor), 1);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputValue, &output));\n SetTensorToDynamic(output);\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1982, "func": "jpc_streamlist_t *jpc_ppmstabtostreams(jpc_ppxstab_t *tab)\n{\n\tjpc_streamlist_t *streams;\n\tuchar *dataptr;\n\tuint_fast32_t datacnt;\n\tuint_fast32_t tpcnt;\n\tjpc_ppxstabent_t *ent;\n\tint entno;\n\tjas_stream_t *stream;\n\tint n;\n\n\tif (!(streams = jpc_streamlist_create())) {\n\t\tgoto error;\n\t}\n\n\tif (!tab->numents) {\n\t\treturn streams;\n\t}\n\n\tentno = 0;\n\tent = tab->ents[entno];\n\tdataptr = ent->data;\n\tdatacnt = ent->len;\n\tfor (;;) {\n\n\t\t/* Get the length of the packet header data for the current\n\t\t tile-part. */\n\t\tif (datacnt < 4) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (!(stream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jpc_streamlist_insert(streams, jpc_streamlist_numstreams(streams),\n\t\t stream)) {\n\t\t\tgoto error;\n\t\t}\n\t\ttpcnt = (dataptr[0] << 24) | (dataptr[1] << 16) | (dataptr[2] << 8)\n\t\t | dataptr[3];\n\t\tdatacnt -= 4;\n\t\tdataptr += 4;\n\n\t\t/* Get the packet header data for the current tile-part. */\n\t\twhile (tpcnt) {\n\t\t\tif (!datacnt) {\n\t\t\t\tif (++entno >= tab->numents) {\n\t\t\t\t\tgoto error;\n\t\t\t\t}\n\t\t\t\tent = tab->ents[entno];\n\t\t\t\tdataptr = ent->data;\n\t\t\t\tdatacnt = ent->len;\n\t\t\t}\n\t\t\tn = JAS_MIN(tpcnt, datacnt);\n\t\t\tif (jas_stream_write(stream, dataptr, n) != n) {\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\ttpcnt -= n;\n\t\t\tdataptr += n;\n\t\t\tdatacnt -= n;\n\t\t}\n\t\tjas_stream_rewind(stream);\n\t\tif (!datacnt) {\n\t\t\tif (++entno >= tab->numents) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tent = tab->ents[entno];\n\t\t\tdataptr = ent->data;\n\t\t\tdatacnt = ent->len;\n\t\t}\n\t}\n\n\treturn streams;\n\nerror:\n\tif (streams) {\n\t\tjpc_streamlist_destroy(streams);\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1982, "func": "jpc_streamlist_t *jpc_ppmstabtostreams(jpc_ppxstab_t *tab)\n{\n\tjpc_streamlist_t *streams;\n\tjas_uchar *dataptr;\n\tuint_fast32_t datacnt;\n\tuint_fast32_t tpcnt;\n\tjpc_ppxstabent_t *ent;\n\tint entno;\n\tjas_stream_t *stream;\n\tint n;\n\n\tif (!(streams = jpc_streamlist_create())) {\n\t\tgoto error;\n\t}\n\n\tif (!tab->numents) {\n\t\treturn streams;\n\t}\n\n\tentno = 0;\n\tent = tab->ents[entno];\n\tdataptr = ent->data;\n\tdatacnt = ent->len;\n\tfor (;;) {\n\n\t\t/* Get the length of the packet header data for the current\n\t\t tile-part. */\n\t\tif (datacnt < 4) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (!(stream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jpc_streamlist_insert(streams, jpc_streamlist_numstreams(streams),\n\t\t stream)) {\n\t\t\tgoto error;\n\t\t}\n\t\ttpcnt = (dataptr[0] << 24) | (dataptr[1] << 16) | (dataptr[2] << 8)\n\t\t | dataptr[3];\n\t\tdatacnt -= 4;\n\t\tdataptr += 4;\n\n\t\t/* Get the packet header data for the current tile-part. */\n\t\twhile (tpcnt) {\n\t\t\tif (!datacnt) {\n\t\t\t\tif (++entno >= tab->numents) {\n\t\t\t\t\tgoto error;\n\t\t\t\t}\n\t\t\t\tent = tab->ents[entno];\n\t\t\t\tdataptr = ent->data;\n\t\t\t\tdatacnt = ent->len;\n\t\t\t}\n\t\t\tn = JAS_MIN(tpcnt, datacnt);\n\t\t\tif (jas_stream_write(stream, dataptr, n) != n) {\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\ttpcnt -= n;\n\t\t\tdataptr += n;\n\t\t\tdatacnt -= n;\n\t\t}\n\t\tjas_stream_rewind(stream);\n\t\tif (!datacnt) {\n\t\t\tif (++entno >= tab->numents) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tent = tab->ents[entno];\n\t\t\tdataptr = ent->data;\n\t\t\tdatacnt = ent->len;\n\t\t}\n\t}\n\n\treturn streams;\n\nerror:\n\tif (streams) {\n\t\tjpc_streamlist_destroy(streams);\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1273, "func": "static int uas_use_uas_driver(struct usb_interface *intf,\n\t\t\t const struct usb_device_id *id,\n\t\t\t unsigned long *flags_ret)\n{\n\tstruct usb_host_endpoint *eps[4] = { };\n\tstruct usb_device *udev = interface_to_usbdev(intf);\n\tstruct usb_hcd *hcd = bus_to_hcd(udev->bus);\n\tunsigned long flags = id->driver_info;\n\tint r, alt;\n\n\n\talt = uas_find_uas_alt_setting(intf);\n\tif (alt < 0)\n\t\treturn 0;\n\n\tr = uas_find_endpoints(&intf->altsetting[alt], eps);\n\tif (r < 0)\n\t\treturn 0;\n\n\t/*\n\t * ASMedia has a number of usb3 to sata bridge chips, at the time of\n\t * this writing the following versions exist:\n\t * ASM1051 - no uas support version\n\t * ASM1051 - with broken (*) uas support\n\t * ASM1053 - with working uas support, but problems with large xfers\n\t * ASM1153 - with working uas support\n\t *\n\t * Devices with these chips re-use a number of device-ids over the\n\t * entire line, so the device-id is useless to determine if we're\n\t * dealing with an ASM1051 (which we want to avoid).\n\t *\n\t * The ASM1153 can be identified by config.MaxPower == 0,\n\t * where as the ASM105x models have config.MaxPower == 36.\n\t *\n\t * Differentiating between the ASM1053 and ASM1051 is trickier, when\n\t * connected over USB-3 we can look at the number of streams supported,\n\t * ASM1051 supports 32 streams, where as early ASM1053 versions support\n\t * 16 streams, newer ASM1053-s also support 32 streams, but have a\n\t * different prod-id.\n\t *\n\t * (*) ASM1051 chips do work with UAS with some disks (with the\n\t * US_FL_NO_REPORT_OPCODES quirk), but are broken with other disks\n\t */\n\tif (le16_to_cpu(udev->descriptor.idVendor) == 0x174c &&\n\t\t\t(le16_to_cpu(udev->descriptor.idProduct) == 0x5106 ||\n\t\t\t le16_to_cpu(udev->descriptor.idProduct) == 0x55aa)) {\n\t\tif (udev->actconfig->desc.bMaxPower == 0) {\n\t\t\t/* ASM1153, do nothing */\n\t\t} else if (udev->speed < USB_SPEED_SUPER) {\n\t\t\t/* No streams info, assume ASM1051 */\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else if (usb_ss_max_streams(&eps[1]->ss_ep_comp) == 32) {\n\t\t\t/* Possibly an ASM1051, disable uas */\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else {\n\t\t\t/* ASM1053, these have issues with large transfers */\n\t\t\tflags |= US_FL_MAX_SECTORS_240;\n\t\t}\n\t}\n\n\tusb_stor_adjust_quirks(udev, &flags);\n\n\tif (flags & US_FL_IGNORE_UAS) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"UAS is blacklisted for this device, using usb-storage instead\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->bus->sg_tablesize == 0) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"The driver for the USB controller %s does not support scatter-gather which is\\n\",\n\t\t\thcd->driver->description);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"required by the UAS driver. Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->speed >= USB_SPEED_SUPER && !hcd->can_do_streams) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"USB controller %s does not support streams, which are required by the UAS driver.\\n\",\n\t\t\thcd_to_bus(hcd)->bus_name);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (flags_ret)\n\t\t*flags_ret = flags;\n\n\treturn 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-16530", "cwe_id": "CWE-125" }, { "id": 1273, "func": "static int uas_use_uas_driver(struct usb_interface *intf,\n\t\t\t const struct usb_device_id *id,\n\t\t\t unsigned long *flags_ret)\n{\n\tstruct usb_host_endpoint *eps[4] = { };\n\tstruct usb_device *udev = interface_to_usbdev(intf);\n\tstruct usb_hcd *hcd = bus_to_hcd(udev->bus);\n\tunsigned long flags = id->driver_info;\n\tstruct usb_host_interface *alt;\n\tint r;\n\n\talt = uas_find_uas_alt_setting(intf);\n\tif (!alt)\n\t\treturn 0;\n\n\tr = uas_find_endpoints(alt, eps);\n\tif (r < 0)\n\t\treturn 0;\n\n\t/*\n\t * ASMedia has a number of usb3 to sata bridge chips, at the time of\n\t * this writing the following versions exist:\n\t * ASM1051 - no uas support version\n\t * ASM1051 - with broken (*) uas support\n\t * ASM1053 - with working uas support, but problems with large xfers\n\t * ASM1153 - with working uas support\n\t *\n\t * Devices with these chips re-use a number of device-ids over the\n\t * entire line, so the device-id is useless to determine if we're\n\t * dealing with an ASM1051 (which we want to avoid).\n\t *\n\t * The ASM1153 can be identified by config.MaxPower == 0,\n\t * where as the ASM105x models have config.MaxPower == 36.\n\t *\n\t * Differentiating between the ASM1053 and ASM1051 is trickier, when\n\t * connected over USB-3 we can look at the number of streams supported,\n\t * ASM1051 supports 32 streams, where as early ASM1053 versions support\n\t * 16 streams, newer ASM1053-s also support 32 streams, but have a\n\t * different prod-id.\n\t *\n\t * (*) ASM1051 chips do work with UAS with some disks (with the\n\t * US_FL_NO_REPORT_OPCODES quirk), but are broken with other disks\n\t */\n\tif (le16_to_cpu(udev->descriptor.idVendor) == 0x174c &&\n\t\t\t(le16_to_cpu(udev->descriptor.idProduct) == 0x5106 ||\n\t\t\t le16_to_cpu(udev->descriptor.idProduct) == 0x55aa)) {\n\t\tif (udev->actconfig->desc.bMaxPower == 0) {\n\t\t\t/* ASM1153, do nothing */\n\t\t} else if (udev->speed < USB_SPEED_SUPER) {\n\t\t\t/* No streams info, assume ASM1051 */\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else if (usb_ss_max_streams(&eps[1]->ss_ep_comp) == 32) {\n\t\t\t/* Possibly an ASM1051, disable uas */\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else {\n\t\t\t/* ASM1053, these have issues with large transfers */\n\t\t\tflags |= US_FL_MAX_SECTORS_240;\n\t\t}\n\t}\n\n\tusb_stor_adjust_quirks(udev, &flags);\n\n\tif (flags & US_FL_IGNORE_UAS) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"UAS is blacklisted for this device, using usb-storage instead\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->bus->sg_tablesize == 0) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"The driver for the USB controller %s does not support scatter-gather which is\\n\",\n\t\t\thcd->driver->description);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"required by the UAS driver. Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->speed >= USB_SPEED_SUPER && !hcd->can_do_streams) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"USB controller %s does not support streams, which are required by the UAS driver.\\n\",\n\t\t\thcd_to_bus(hcd)->bus_name);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (flags_ret)\n\t\t*flags_ret = flags;\n\n\treturn 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-16530", "cwe_id": "CWE-125" }, { "id": 1002, "func": "gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)\n{\n\tTIFF* tif = img->tif;\n\ttileContigRoutine put = img->put.contig;\n\tuint32 row, y, nrow, nrowsub, rowstoread;\n\ttmsize_t pos;\n\tunsigned char* buf = NULL;\n\tuint32 rowsperstrip;\n\tuint16 subsamplinghor,subsamplingver;\n\tuint32 imagewidth = img->width;\n\ttmsize_t scanline;\n\tint32 fromskew, toskew;\n\tint ret = 1, flip;\n tmsize_t maxstripsize;\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);\n\tif( subsamplingver == 0 ) {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"Invalid vertical YCbCr subsampling\");\n\t\treturn (0);\n\t}\n\t\n\tmaxstripsize = TIFFStripSize(tif);\n\n\tflip = setorientation(img);\n\tif (flip & FLIP_VERTICALLY) {\n\t\ty = h - 1;\n\t\ttoskew = -(int32)(w + w);\n\t} else {\n\t\ty = 0;\n\t\ttoskew = -(int32)(w - w);\n\t}\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);\n\n\tscanline = TIFFScanlineSize(tif);\n\tfromskew = (w < imagewidth ? imagewidth - w : 0);\n\tfor (row = 0; row < h; row += nrow)\n\t{\n\t\trowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;\n\t\tnrow = (row + rowstoread > h ? h - row : rowstoread);\n\t\tnrowsub = nrow;\n\t\tif ((nrowsub%subsamplingver)!=0)\n\t\t\tnrowsub+=subsamplingver-nrowsub%subsamplingver;\n\t\tif (_TIFFReadEncodedStripAndAllocBuffer(tif,\n\t\t TIFFComputeStrip(tif,row+img->row_offset, 0),\n\t\t (void**)(&buf),\n maxstripsize,\n\t\t ((row + img->row_offset)%rowsperstrip + nrowsub) * scanline)==(tmsize_t)(-1)\n\t\t && (buf == NULL || img->stoponerr))\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\tpos = ((row + img->row_offset) % rowsperstrip) * scanline + \\\n\t\t\t((tmsize_t) img->col_offset * img->samplesperpixel);\n\t\t(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos);\n\t\ty += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow);\n\t}\n\n\tif (flip & FLIP_HORIZONTALLY) {\n\t\tuint32 line;\n\n\t\tfor (line = 0; line < h; line++) {\n\t\t\tuint32 *left = raster + (line * w);\n\t\t\tuint32 *right = left + w - 1;\n\n\t\t\twhile ( left < right ) {\n\t\t\t\tuint32 temp = *left;\n\t\t\t\t*left = *right;\n\t\t\t\t*right = temp;\n\t\t\t\tleft++;\n\t\t\t\tright--;\n\t\t\t}\n\t\t}\n\t}\n\n\t_TIFFfree(buf);\n\treturn (ret);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-17546", "cwe_id": "CWE-787" }, { "id": 1002, "func": "gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)\n{\n\tTIFF* tif = img->tif;\n\ttileContigRoutine put = img->put.contig;\n\tuint32 row, y, nrow, nrowsub, rowstoread;\n\ttmsize_t pos;\n\tunsigned char* buf = NULL;\n\tuint32 rowsperstrip;\n\tuint16 subsamplinghor,subsamplingver;\n\tuint32 imagewidth = img->width;\n\ttmsize_t scanline;\n\tint32 fromskew, toskew;\n\tint ret = 1, flip;\n tmsize_t maxstripsize;\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);\n\tif( subsamplingver == 0 ) {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"Invalid vertical YCbCr subsampling\");\n\t\treturn (0);\n\t}\n\t\n\tmaxstripsize = TIFFStripSize(tif);\n\n\tflip = setorientation(img);\n\tif (flip & FLIP_VERTICALLY) {\n\t\ty = h - 1;\n\t\ttoskew = -(int32)(w + w);\n\t} else {\n\t\ty = 0;\n\t\ttoskew = -(int32)(w - w);\n\t}\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);\n\n\tscanline = TIFFScanlineSize(tif);\n\tfromskew = (w < imagewidth ? imagewidth - w : 0);\n\tfor (row = 0; row < h; row += nrow)\n\t{\n\t\tuint32 temp;\n\t\trowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;\n\t\tnrow = (row + rowstoread > h ? h - row : rowstoread);\n\t\tnrowsub = nrow;\n\t\tif ((nrowsub%subsamplingver)!=0)\n\t\t\tnrowsub+=subsamplingver-nrowsub%subsamplingver;\n\t\ttemp = (row + img->row_offset)%rowsperstrip + nrowsub;\n\t\tif( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) )\n\t\t{\n\t\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"Integer overflow in gtStripContig\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (_TIFFReadEncodedStripAndAllocBuffer(tif,\n\t\t TIFFComputeStrip(tif,row+img->row_offset, 0),\n\t\t (void**)(&buf),\n maxstripsize,\n\t\t temp * scanline)==(tmsize_t)(-1)\n\t\t && (buf == NULL || img->stoponerr))\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\tpos = ((row + img->row_offset) % rowsperstrip) * scanline + \\\n\t\t\t((tmsize_t) img->col_offset * img->samplesperpixel);\n\t\t(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos);\n\t\ty += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow);\n\t}\n\n\tif (flip & FLIP_HORIZONTALLY) {\n\t\tuint32 line;\n\n\t\tfor (line = 0; line < h; line++) {\n\t\t\tuint32 *left = raster + (line * w);\n\t\t\tuint32 *right = left + w - 1;\n\n\t\t\twhile ( left < right ) {\n\t\t\t\tuint32 temp = *left;\n\t\t\t\t*left = *right;\n\t\t\t\t*right = temp;\n\t\t\t\tleft++;\n\t\t\t\tright--;\n\t\t\t}\n\t\t}\n\t}\n\n\t_TIFFfree(buf);\n\treturn (ret);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-17546", "cwe_id": "CWE-787" }, { "id": 2499, "func": " State()\n : remote_complete_(false), local_complete_(false), has_1xx_headers_(false),\n created_filter_chain_(false), is_head_request_(false), is_grpc_request_(false),\n non_100_response_headers_encoded_(false), under_on_local_reply_(false),\n decoder_filter_chain_aborted_(false), encoder_filter_chain_aborted_(false),\n saw_downstream_reset_(false) {}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-43825", "cwe_id": "CWE-416" }, { "id": 2499, "func": " State()\n : remote_encode_complete_(false), remote_decode_complete_(false), local_complete_(false),\n has_1xx_headers_(false), created_filter_chain_(false), is_head_request_(false),\n is_grpc_request_(false), non_100_response_headers_encoded_(false),\n under_on_local_reply_(false), decoder_filter_chain_aborted_(false),\n encoder_filter_chain_aborted_(false), saw_downstream_reset_(false) {}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-43825", "cwe_id": "CWE-416" }, { "id": 2940, "func": "static int do_setxattr(struct btrfs_trans_handle *trans,\n\t\t struct inode *inode, const char *name,\n\t\t const void *value, size_t size, int flags)\n{\n\tstruct btrfs_dir_item *di;\n\tstruct btrfs_root *root = BTRFS_I(inode)->root;\n\tstruct btrfs_path *path;\n\tsize_t name_len = strlen(name);\n\tint ret = 0;\n\n\tif (name_len + size > BTRFS_MAX_XATTR_SIZE(root))\n\t\treturn -ENOSPC;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tif (flags & XATTR_REPLACE) {\n\t\tdi = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode), name,\n\t\t\t\t\tname_len, -1);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n\t\t\tgoto out;\n\t\t} else if (!di) {\n\t\t\tret = -ENODATA;\n\t\t\tgoto out;\n\t\t}\n\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\tif (ret)\n\t\t\tgoto out;\n\t\tbtrfs_release_path(path);\n\n\t\t/*\n\t\t * remove the attribute\n\t\t */\n\t\tif (!value)\n\t\t\tgoto out;\n\t} else {\n\t\tdi = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, 0);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n\t\t\tgoto out;\n\t\t}\n\t\tif (!di && !value)\n\t\t\tgoto out;\n\t\tbtrfs_release_path(path);\n\t}\n\nagain:\n\tret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode),\n\t\t\t\t name, name_len, value, size);\n\t/*\n\t * If we're setting an xattr to a new value but the new value is say\n\t * exactly BTRFS_MAX_XATTR_SIZE, we could end up with EOVERFLOW getting\n\t * back from split_leaf. This is because it thinks we'll be extending\n\t * the existing item size, but we're asking for enough space to add the\n\t * item itself. So if we get EOVERFLOW just set ret to EEXIST and let\n\t * the rest of the function figure it out.\n\t */\n\tif (ret == -EOVERFLOW)\n\t\tret = -EEXIST;\n\n\tif (ret == -EEXIST) {\n\t\tif (flags & XATTR_CREATE)\n\t\t\tgoto out;\n\t\t/*\n\t\t * We can't use the path we already have since we won't have the\n\t\t * proper locking for a delete, so release the path and\n\t\t * re-lookup to delete the thing.\n\t\t */\n\t\tbtrfs_release_path(path);\n\t\tdi = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, -1);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n\t\t\tgoto out;\n\t\t} else if (!di) {\n\t\t\t/* Shouldn't happen but just in case... */\n\t\t\tbtrfs_release_path(path);\n\t\t\tgoto again;\n\t\t}\n\n\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\tif (ret)\n\t\t\tgoto out;\n\n\t\t/*\n\t\t * We have a value to set, so go back and try to insert it now.\n\t\t */\n\t\tif (value) {\n\t\t\tbtrfs_release_path(path);\n\t\t\tgoto again;\n\t\t}\n\t}\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-9710", "cwe_id": "CWE-362" }, { "id": 2940, "func": "static int do_setxattr(struct btrfs_trans_handle *trans,\n\t\t struct inode *inode, const char *name,\n\t\t const void *value, size_t size, int flags)\n{\n\tstruct btrfs_dir_item *di = NULL;\n\tstruct btrfs_root *root = BTRFS_I(inode)->root;\n\tstruct btrfs_path *path;\n\tsize_t name_len = strlen(name);\n\tint ret = 0;\n\n\tif (name_len + size > BTRFS_MAX_XATTR_SIZE(root))\n\t\treturn -ENOSPC;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\tpath->skip_release_on_error = 1;\n\n\tif (!value) {\n\t\tdi = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, -1);\n\t\tif (!di && (flags & XATTR_REPLACE))\n\t\t\tret = -ENODATA;\n\t\telse if (di)\n\t\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\tgoto out;\n\t}\n\n\t/*\n\t * For a replace we can't just do the insert blindly.\n\t * Do a lookup first (read-only btrfs_search_slot), and return if xattr\n\t * doesn't exist. If it exists, fall down below to the insert/replace\n\t * path - we can't race with a concurrent xattr delete, because the VFS\n\t * locks the inode's i_mutex before calling setxattr or removexattr.\n\t */\n\tif (flags & XATTR_REPLACE) {\n\t\tASSERT(mutex_is_locked(&inode->i_mutex));\n\t\tdi = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, 0);\n\t\tif (!di) {\n\t\t\tret = -ENODATA;\n\t\t\tgoto out;\n\t\t}\n\t\tbtrfs_release_path(path);\n\t\tdi = NULL;\n\t}\n\n\tret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode),\n\t\t\t\t name, name_len, value, size);\n\tif (ret == -EOVERFLOW) {\n\t\t/*\n\t\t * We have an existing item in a leaf, split_leaf couldn't\n\t\t * expand it. That item might have or not a dir_item that\n\t\t * matches our target xattr, so lets check.\n\t\t */\n\t\tret = 0;\n\t\tbtrfs_assert_tree_locked(path->nodes[0]);\n\t\tdi = btrfs_match_dir_item_name(root, path, name, name_len);\n\t\tif (!di && !(flags & XATTR_REPLACE)) {\n\t\t\tret = -ENOSPC;\n\t\t\tgoto out;\n\t\t}\n\t} else if (ret == -EEXIST) {\n\t\tret = 0;\n\t\tdi = btrfs_match_dir_item_name(root, path, name, name_len);\n\t\tASSERT(di); /* logic error */\n\t} else if (ret) {\n\t\tgoto out;\n\t}\n\n\tif (di && (flags & XATTR_CREATE)) {\n\t\tret = -EEXIST;\n\t\tgoto out;\n\t}\n\n\tif (di) {\n\t\t/*\n\t\t * We're doing a replace, and it must be atomic, that is, at\n\t\t * any point in time we have either the old or the new xattr\n\t\t * value in the tree. We don't want readers (getxattr and\n\t\t * listxattrs) to miss a value, this is specially important\n\t\t * for ACLs.\n\t\t */\n\t\tconst int slot = path->slots[0];\n\t\tstruct extent_buffer *leaf = path->nodes[0];\n\t\tconst u16 old_data_len = btrfs_dir_data_len(leaf, di);\n\t\tconst u32 item_size = btrfs_item_size_nr(leaf, slot);\n\t\tconst u32 data_size = sizeof(*di) + name_len + size;\n\t\tstruct btrfs_item *item;\n\t\tunsigned long data_ptr;\n\t\tchar *ptr;\n\n\t\tif (size > old_data_len) {\n\t\t\tif (btrfs_leaf_free_space(root, leaf) <\n\t\t\t (size - old_data_len)) {\n\t\t\t\tret = -ENOSPC;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\n\t\tif (old_data_len + name_len + sizeof(*di) == item_size) {\n\t\t\t/* No other xattrs packed in the same leaf item. */\n\t\t\tif (size > old_data_len)\n\t\t\t\tbtrfs_extend_item(root, path,\n\t\t\t\t\t\t size - old_data_len);\n\t\t\telse if (size < old_data_len)\n\t\t\t\tbtrfs_truncate_item(root, path, data_size, 1);\n\t\t} else {\n\t\t\t/* There are other xattrs packed in the same item. */\n\t\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t\tbtrfs_extend_item(root, path, data_size);\n\t\t}\n\n\t\titem = btrfs_item_nr(slot);\n\t\tptr = btrfs_item_ptr(leaf, slot, char);\n\t\tptr += btrfs_item_size(leaf, item) - data_size;\n\t\tdi = (struct btrfs_dir_item *)ptr;\n\t\tbtrfs_set_dir_data_len(leaf, di, size);\n\t\tdata_ptr = ((unsigned long)(di + 1)) + name_len;\n\t\twrite_extent_buffer(leaf, value, data_ptr, size);\n\t\tbtrfs_mark_buffer_dirty(leaf);\n\t} else {\n\t\t/*\n\t\t * Insert, and we had space for the xattr, so path->slots[0] is\n\t\t * where our xattr dir_item is and btrfs_insert_xattr_item()\n\t\t * filled it.\n\t\t */\n\t}\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-9710", "cwe_id": "CWE-362" }, { "id": 173, "func": "psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)\n{\tva_list\targptr ;\n\tint\t\tmaxlen ;\n\tchar\t*start ;\n\n\tmaxlen = strlen ((char*) psf->header) ;\n\tstart\t= ((char*) psf->header) + maxlen ;\n\tmaxlen\t= sizeof (psf->header) - maxlen ;\n\n\tva_start (argptr, format) ;\n\tvsnprintf (start, maxlen, format, argptr) ;\n\tva_end (argptr) ;\n\n\t/* Make sure the string is properly terminated. */\n\tstart [maxlen - 1] = 0 ;\n\n\tpsf->headindex = strlen ((char*) psf->header) ;\n\n\treturn ;\n} /* psf_asciiheader_printf */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 173, "func": "psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)\n{\tva_list\targptr ;\n\tint\t\tmaxlen ;\n\tchar\t*start ;\n\n\tmaxlen = strlen ((char*) psf->header.ptr) ;\n\tstart\t= ((char*) psf->header.ptr) + maxlen ;\n\tmaxlen\t= psf->header.len - maxlen ;\n\n\tva_start (argptr, format) ;\n\tvsnprintf (start, maxlen, format, argptr) ;\n\tva_end (argptr) ;\n\n\t/* Make sure the string is properly terminated. */\n\tstart [maxlen - 1] = 0 ;\n\n\tpsf->header.indx = strlen ((char*) psf->header.ptr) ;\n\n\treturn ;\n} /* psf_asciiheader_printf */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 1952, "func": "error_t enc28j60Init(NetInterface *interface)\n{\n uint8_t revisionId;\n Enc28j60Context *context;\n\n //Debug message\n TRACE_INFO(\"Initializing ENC28J60 Ethernet controller...\\r\\n\");\n\n //Initialize SPI\n interface->spiDriver->init();\n //Initialize external interrupt line\n interface->extIntDriver->init();\n\n //Issue a system reset\n enc28j60SoftReset(interface);\n\n //After issuing the reset command, wait at least 1ms in firmware\n //for the device to be ready\n sleep(10);\n\n //Point to the driver context\n context = (Enc28j60Context *) interface->nicContext;\n\n //Initialize driver specific variables\n context->currentBank = UINT16_MAX;\n context->nextPacket = ENC28J60_RX_BUFFER_START;\n\n //Allocate RX buffer\n context->rxBuffer = memPoolAlloc(ETH_MAX_FRAME_SIZE);\n //Failed to allocate memory?\n if(context->rxBuffer == NULL)\n {\n return ERROR_OUT_OF_MEMORY;\n }\n\n //Read silicon revision ID\n revisionId = enc28j60ReadReg(interface, ENC28J60_REG_EREVID);\n\n //Debug message\n TRACE_INFO(\"ENC28J60 revision ID: 0x%02X\\r\\n\", revisionId);\n\n //Disable CLKOUT output\n enc28j60WriteReg(interface, ENC28J60_REG_ECOCON, 0x00);\n\n //Set the MAC address of the station\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR1, interface->macAddr.b[0]);\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR2, interface->macAddr.b[1]);\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR3, interface->macAddr.b[2]);\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR4, interface->macAddr.b[3]);\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR5, interface->macAddr.b[4]);\n enc28j60WriteReg(interface, ENC28J60_REG_MAADR6, interface->macAddr.b[5]);\n\n //Set receive buffer location\n enc28j60WriteReg(interface, ENC28J60_REG_ERXSTL, LSB(ENC28J60_RX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_REG_ERXSTH, MSB(ENC28J60_RX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_REG_ERXNDL, LSB(ENC28J60_RX_BUFFER_STOP));\n enc28j60WriteReg(interface, ENC28J60_REG_ERXNDH, MSB(ENC28J60_RX_BUFFER_STOP));\n\n //The ERXRDPT register defines a location within the FIFO\n //where the receive hardware is forbidden to write to\n enc28j60WriteReg(interface, ENC28J60_REG_ERXRDPTL, LSB(ENC28J60_RX_BUFFER_STOP));\n enc28j60WriteReg(interface, ENC28J60_REG_ERXRDPTH, MSB(ENC28J60_RX_BUFFER_STOP));\n\n //Configure the receive filters\n enc28j60WriteReg(interface, ENC28J60_REG_ERXFCON, ERXFCON_UCEN |\n ERXFCON_CRCEN | ERXFCON_HTEN | ERXFCON_BCEN);\n\n //Initialize the hash table\n enc28j60WriteReg(interface, ENC28J60_REG_EHT0, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT1, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT2, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT3, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT4, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT5, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT6, 0x00);\n enc28j60WriteReg(interface, ENC28J60_REG_EHT7, 0x00);\n\n //Pull the MAC out of reset\n enc28j60WriteReg(interface, ENC28J60_REG_MACON2, 0x00);\n\n //Enable the MAC to receive frames\n enc28j60WriteReg(interface, ENC28J60_REG_MACON1,\n MACON1_TXPAUS | MACON1_RXPAUS | MACON1_MARXEN);\n\n //Enable automatic padding to at least 60 bytes, always append a valid CRC\n //and check frame length. MAC can operate in half-duplex or full-duplex mode\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WriteReg(interface, ENC28J60_REG_MACON3, MACON3_PADCFG(1) |\n MACON3_TXCRCEN | MACON3_FRMLNEN | MACON3_FULDPX);\n#else\n enc28j60WriteReg(interface, ENC28J60_REG_MACON3, MACON3_PADCFG(1) |\n MACON3_TXCRCEN | MACON3_FRMLNEN);\n#endif\n\n //When the medium is occupied, the MAC will wait indefinitely for it to\n //become free when attempting to transmit\n enc28j60WriteReg(interface, ENC28J60_REG_MACON4, MACON4_DEFER);\n\n //Maximum frame length that can be received or transmitted\n enc28j60WriteReg(interface, ENC28J60_REG_MAMXFLL, LSB(ETH_MAX_FRAME_SIZE));\n enc28j60WriteReg(interface, ENC28J60_REG_MAMXFLH, MSB(ETH_MAX_FRAME_SIZE));\n\n //Configure the back-to-back inter-packet gap register\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WriteReg(interface, ENC28J60_REG_MABBIPG, 0x15);\n#else\n enc28j60WriteReg(interface, ENC28J60_REG_MABBIPG, 0x12);\n#endif\n\n //Configure the non-back-to-back inter-packet gap register\n enc28j60WriteReg(interface, ENC28J60_REG_MAIPGL, 0x12);\n enc28j60WriteReg(interface, ENC28J60_REG_MAIPGH, 0x0C);\n\n //Collision window register\n enc28j60WriteReg(interface, ENC28J60_REG_MACLCON2, 63);\n\n //Set the PHY to the proper duplex mode\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WritePhyReg(interface, ENC28J60_PHY_REG_PHCON1, PHCON1_PDPXMD);\n#else\n enc28j60WritePhyReg(interface, ENC28J60_PHY_REG_PHCON1, 0x0000);\n#endif\n\n //Disable half-duplex loopback in PHY\n enc28j60WritePhyReg(interface, ENC28J60_PHY_REG_PHCON2, PHCON2_HDLDIS);\n\n //LEDA displays link status and LEDB displays TX/RX activity\n enc28j60WritePhyReg(interface, ENC28J60_PHY_REG_PHLCON,\n PHLCON_LACFG(4) | PHLCON_LBCFG(7) | PHLCON_LFRQ(0) | PHLCON_STRCH);\n\n //Clear interrupt flags\n enc28j60WriteReg(interface, ENC28J60_REG_EIR, 0x00);\n\n //Configure interrupts as desired\n enc28j60WriteReg(interface, ENC28J60_REG_EIE, EIE_INTIE |\n EIE_PKTIE | EIE_LINKIE | EIE_TXIE | EIE_TXERIE);\n\n //Configure PHY interrupts as desired\n enc28j60WritePhyReg(interface, ENC28J60_PHY_REG_PHIE,\n PHIE_PLNKIE | PHIE_PGEIE);\n\n //Set RXEN to enable reception\n enc28j60SetBit(interface, ENC28J60_REG_ECON1, ECON1_RXEN);\n\n //Dump registers for debugging purpose\n enc28j60DumpReg(interface);\n enc28j60DumpPhyReg(interface);\n\n //Accept any packets from the upper layer\n osSetEvent(&interface->nicTxEvent);\n\n //Force the TCP/IP stack to poll the link state at startup\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n osSetEvent(&netEvent);\n\n //Successful initialization\n return NO_ERROR;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1952, "func": "error_t enc28j60Init(NetInterface *interface)\n{\n uint8_t revisionId;\n Enc28j60Context *context;\n\n //Debug message\n TRACE_INFO(\"Initializing ENC28J60 Ethernet controller...\\r\\n\");\n\n //Initialize SPI\n interface->spiDriver->init();\n //Initialize external interrupt line\n interface->extIntDriver->init();\n\n //Issue a system reset\n enc28j60SoftReset(interface);\n\n //After issuing the reset command, wait at least 1ms in firmware\n //for the device to be ready\n sleep(10);\n\n //Point to the driver context\n context = (Enc28j60Context *) interface->nicContext;\n\n //Initialize driver specific variables\n context->currentBank = UINT16_MAX;\n context->nextPacket = ENC28J60_RX_BUFFER_START;\n\n //Allocate RX buffer\n context->rxBuffer = memPoolAlloc(ETH_MAX_FRAME_SIZE);\n //Failed to allocate memory?\n if(context->rxBuffer == NULL)\n {\n return ERROR_OUT_OF_MEMORY;\n }\n\n //Read silicon revision ID\n revisionId = enc28j60ReadReg(interface, ENC28J60_EREVID);\n\n //Debug message\n TRACE_INFO(\"ENC28J60 revision ID: 0x%02X\\r\\n\", revisionId);\n\n //Disable CLKOUT output\n enc28j60WriteReg(interface, ENC28J60_ECOCON, ENC28J60_ECOCON_COCON_DISABLED);\n\n //Set the MAC address of the station\n enc28j60WriteReg(interface, ENC28J60_MAADR5, interface->macAddr.b[0]);\n enc28j60WriteReg(interface, ENC28J60_MAADR4, interface->macAddr.b[1]);\n enc28j60WriteReg(interface, ENC28J60_MAADR3, interface->macAddr.b[2]);\n enc28j60WriteReg(interface, ENC28J60_MAADR2, interface->macAddr.b[3]);\n enc28j60WriteReg(interface, ENC28J60_MAADR1, interface->macAddr.b[4]);\n enc28j60WriteReg(interface, ENC28J60_MAADR0, interface->macAddr.b[5]);\n\n //Set receive buffer location\n enc28j60WriteReg(interface, ENC28J60_ERXSTL, LSB(ENC28J60_RX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_ERXSTH, MSB(ENC28J60_RX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_ERXNDL, LSB(ENC28J60_RX_BUFFER_STOP));\n enc28j60WriteReg(interface, ENC28J60_ERXNDH, MSB(ENC28J60_RX_BUFFER_STOP));\n\n //The ERXRDPT register defines a location within the FIFO where the receive\n //hardware is forbidden to write to\n enc28j60WriteReg(interface, ENC28J60_ERXRDPTL, LSB(ENC28J60_RX_BUFFER_STOP));\n enc28j60WriteReg(interface, ENC28J60_ERXRDPTH, MSB(ENC28J60_RX_BUFFER_STOP));\n\n //Configure the receive filters\n enc28j60WriteReg(interface, ENC28J60_ERXFCON, ENC28J60_ERXFCON_UCEN |\n ENC28J60_ERXFCON_CRCEN | ENC28J60_ERXFCON_HTEN | ENC28J60_ERXFCON_BCEN);\n\n //Initialize the hash table\n enc28j60WriteReg(interface, ENC28J60_EHT0, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT1, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT2, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT3, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT4, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT5, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT6, 0x00);\n enc28j60WriteReg(interface, ENC28J60_EHT7, 0x00);\n\n //Pull the MAC out of reset\n enc28j60WriteReg(interface, ENC28J60_MACON2, 0x00);\n\n //Enable the MAC to receive frames\n enc28j60WriteReg(interface, ENC28J60_MACON1, ENC28J60_MACON1_TXPAUS |\n ENC28J60_MACON1_RXPAUS | ENC28J60_MACON1_MARXEN);\n\n //Enable automatic padding, always append a valid CRC and check frame\n //length. MAC can operate in half-duplex or full-duplex mode\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WriteReg(interface, ENC28J60_MACON3, ENC28J60_MACON3_PADCFG_AUTO |\n ENC28J60_MACON3_TXCRCEN | ENC28J60_MACON3_FRMLNEN |\n ENC28J60_MACON3_FULDPX);\n#else\n enc28j60WriteReg(interface, ENC28J60_MACON3, ENC28J60_MACON3_PADCFG_AUTO |\n ENC28J60_MACON3_TXCRCEN | ENC28J60_MACON3_FRMLNEN);\n#endif\n\n //When the medium is occupied, the MAC will wait indefinitely for it to\n //become free when attempting to transmit\n enc28j60WriteReg(interface, ENC28J60_MACON4, ENC28J60_MACON4_DEFER);\n\n //Maximum frame length that can be received or transmitted\n enc28j60WriteReg(interface, ENC28J60_MAMXFLL, LSB(ETH_MAX_FRAME_SIZE));\n enc28j60WriteReg(interface, ENC28J60_MAMXFLH, MSB(ETH_MAX_FRAME_SIZE));\n\n //Configure the back-to-back inter-packet gap register\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WriteReg(interface, ENC28J60_MABBIPG, ENC28J60_MABBIPG_DEFAULT_FD);\n#else\n enc28j60WriteReg(interface, ENC28J60_MABBIPG, ENC28J60_MABBIPG_DEFAULT_HD);\n#endif\n\n //Configure the non-back-to-back inter-packet gap register\n enc28j60WriteReg(interface, ENC28J60_MAIPGL, ENC28J60_MAIPGL_DEFAULT);\n enc28j60WriteReg(interface, ENC28J60_MAIPGH, ENC28J60_MAIPGH_DEFAULT);\n\n //Collision window register\n enc28j60WriteReg(interface, ENC28J60_MACLCON2,\n ENC28J60_MACLCON2_COLWIN_DEFAULT);\n\n //Set the PHY to the proper duplex mode\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n enc28j60WritePhyReg(interface, ENC28J60_PHCON1, ENC28J60_PHCON1_PDPXMD);\n#else\n enc28j60WritePhyReg(interface, ENC28J60_PHCON1, 0x0000);\n#endif\n\n //Disable half-duplex loopback in PHY\n enc28j60WritePhyReg(interface, ENC28J60_PHCON2, ENC28J60_PHCON2_HDLDIS);\n\n //LEDA displays link status and LEDB displays TX/RX activity\n enc28j60WritePhyReg(interface, ENC28J60_PHLCON,\n ENC28J60_PHLCON_LACFG_LINK | ENC28J60_PHLCON_LBCFG_TX_RX |\n ENC28J60_PHLCON_LFRQ_40_MS | ENC28J60_PHLCON_STRCH);\n\n //Clear interrupt flags\n enc28j60WriteReg(interface, ENC28J60_EIR, 0x00);\n\n //Configure interrupts as desired\n enc28j60WriteReg(interface, ENC28J60_EIE, ENC28J60_EIE_INTIE |\n ENC28J60_EIE_PKTIE | ENC28J60_EIE_LINKIE | ENC28J60_EIE_TXIE |\n ENC28J60_EIE_TXERIE);\n\n //Configure PHY interrupts as desired\n enc28j60WritePhyReg(interface, ENC28J60_PHIE, ENC28J60_PHIE_PLNKIE |\n ENC28J60_PHIE_PGEIE);\n\n //Set RXEN to enable reception\n enc28j60SetBit(interface, ENC28J60_ECON1, ENC28J60_ECON1_RXEN);\n\n //Dump registers for debugging purpose\n enc28j60DumpReg(interface);\n enc28j60DumpPhyReg(interface);\n\n //Accept any packets from the upper layer\n osSetEvent(&interface->nicTxEvent);\n\n //Force the TCP/IP stack to poll the link state at startup\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n osSetEvent(&netEvent);\n\n //Successful initialization\n return NO_ERROR;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2427, "func": "TfLiteStatus PreluEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n const TfLiteTensor* alpha = GetInput(context, node, 1);\n TfLiteTensor* output = GetOutput(context, node, 0);\n const PreluOpData* data = reinterpret_cast(node->user_data);\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kGenericOptimized) {\n tflite::ArithmeticParams op_params;\n bool need_broadcast = optimized_ops::ProcessBroadcastShapes(\n GetTensorShape(input), GetTensorShape(alpha), &op_params);\n if (need_broadcast) {\n optimized_ops::BroadcastPReluDispatch(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n } else {\n const int flat_size =\n MatchingElementsSize(GetTensorShape(input), GetTensorShape(alpha),\n GetTensorShape(output));\n optimized_ops::PReluElementWise(\n flat_size, op_params, GetTensorData(alpha),\n GetTensorData(input), GetTensorData(output));\n }\n } else {\n if (data->requires_broadcast) {\n reference_ops::BroadcastBinaryFunction4DSlow(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n } else {\n reference_ops::BinaryFunction(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n }\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n PreluParams op_params;\n op_params.input_offset = -input->params.zero_point;\n op_params.alpha_offset = -alpha->params.zero_point;\n op_params.output_offset = output->params.zero_point;\n op_params.output_multiplier_1 = data->output_multiplier_1;\n op_params.output_shift_1 = data->output_shift_1;\n op_params.output_multiplier_2 = data->output_multiplier_2;\n op_params.output_shift_2 = data->output_shift_2;\n if (data->requires_broadcast) {\n reference_ops::BroadcastPrelu4DSlow(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n } else {\n reference_ops::Prelu(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n PreluParams op_params;\n op_params.input_offset = -input->params.zero_point;\n op_params.alpha_offset = -alpha->params.zero_point;\n op_params.output_offset = output->params.zero_point;\n op_params.output_multiplier_1 = data->output_multiplier_1;\n op_params.output_shift_1 = data->output_shift_1;\n op_params.output_multiplier_2 = data->output_multiplier_2;\n op_params.output_shift_2 = data->output_shift_2;\n if (data->requires_broadcast) {\n reference_ops::BroadcastPrelu4DSlow(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n } else {\n reference_ops::Prelu(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(\n context,\n \"Only float32 and uint8 and int8 are supported currently, got %d.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2427, "func": "TfLiteStatus PreluEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n const TfLiteTensor* alpha;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &alpha));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n const PreluOpData* data = reinterpret_cast(node->user_data);\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kGenericOptimized) {\n tflite::ArithmeticParams op_params;\n bool need_broadcast = optimized_ops::ProcessBroadcastShapes(\n GetTensorShape(input), GetTensorShape(alpha), &op_params);\n if (need_broadcast) {\n optimized_ops::BroadcastPReluDispatch(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n } else {\n const int flat_size =\n MatchingElementsSize(GetTensorShape(input), GetTensorShape(alpha),\n GetTensorShape(output));\n optimized_ops::PReluElementWise(\n flat_size, op_params, GetTensorData(alpha),\n GetTensorData(input), GetTensorData(output));\n }\n } else {\n if (data->requires_broadcast) {\n reference_ops::BroadcastBinaryFunction4DSlow(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n } else {\n reference_ops::BinaryFunction(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output),\n ApplyPrelu);\n }\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n PreluParams op_params;\n op_params.input_offset = -input->params.zero_point;\n op_params.alpha_offset = -alpha->params.zero_point;\n op_params.output_offset = output->params.zero_point;\n op_params.output_multiplier_1 = data->output_multiplier_1;\n op_params.output_shift_1 = data->output_shift_1;\n op_params.output_multiplier_2 = data->output_multiplier_2;\n op_params.output_shift_2 = data->output_shift_2;\n if (data->requires_broadcast) {\n reference_ops::BroadcastPrelu4DSlow(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n } else {\n reference_ops::Prelu(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n PreluParams op_params;\n op_params.input_offset = -input->params.zero_point;\n op_params.alpha_offset = -alpha->params.zero_point;\n op_params.output_offset = output->params.zero_point;\n op_params.output_multiplier_1 = data->output_multiplier_1;\n op_params.output_shift_1 = data->output_shift_1;\n op_params.output_multiplier_2 = data->output_multiplier_2;\n op_params.output_shift_2 = data->output_shift_2;\n if (data->requires_broadcast) {\n reference_ops::BroadcastPrelu4DSlow(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n } else {\n reference_ops::Prelu(\n op_params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(alpha), GetTensorData(alpha),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(\n context,\n \"Only float32 and uint8 and int8 are supported currently, got %d.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 998, "func": "static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {\n\t// Skip whitespace\n\twhile (begin && isspace ((ut8)str[*begin])) {\n\t\t++(*begin);\n\t}\n\n\tif (!str[*begin]) { // null byte\n\t\t*end = *begin;\n\t\treturn TT_EOF;\n\t} else if (isalpha ((ut8)str[*begin])) { // word token\n\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) {\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_WORD;\n\t} else if (isdigit ((ut8)str[*begin])) { // number token\n\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex.\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_NUMBER;\n\t} else { // special character: [, ], +, *, ...\n\t\t*end = *begin + 1;\n\t\treturn TT_SPECIAL;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-19842", "cwe_id": "CWE-125" }, { "id": 998, "func": "static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {\n\tif (*begin > strlen (str)) {\n\t\treturn TT_EOF;\n\t}\n\t// Skip whitespace\n\twhile (begin && str[*begin] && isspace ((ut8)str[*begin])) {\n\t\t++(*begin);\n\t}\n\n\tif (!str[*begin]) { // null byte\n\t\t*end = *begin;\n\t\treturn TT_EOF;\n\t}\n\tif (isalpha ((ut8)str[*begin])) { // word token\n\t\t*end = *begin;\n\t\twhile (end && str[*end] && isalnum ((ut8)str[*end])) {\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_WORD;\n\t}\n\tif (isdigit ((ut8)str[*begin])) { // number token\n\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex.\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_NUMBER;\n\t} else { // special character: [, ], +, *, ...\n\t\t*end = *begin + 1;\n\t\treturn TT_SPECIAL;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-19842", "cwe_id": "CWE-125" }, { "id": 3194, "func": "hb_set_intersect (hb_set_t *set,\n\t\t const hb_set_t *other)\n{\n if (unlikely (hb_object_is_immutable (set)))\n return;\n\n set->intersect (*other);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-45931", "cwe_id": "CWE-787" }, { "id": 3194, "func": "hb_set_intersect (hb_set_t *set,\n\t\t const hb_set_t *other)\n{\n /* Immutible-safe. */\n set->intersect (*other);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-45931", "cwe_id": "CWE-787" }, { "id": 140, "func": "uint32_t GetPayloadTime(size_t handle, uint32_t index, float *in, float *out)\n{\n\tmp4object *mp4 = (mp4object *)handle;\n\tif (mp4 == NULL) return 0;\n\n\tif (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return 1;\n\n\t*in = (float)((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\t*out = (float)((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15146", "cwe_id": "CWE-125" }, { "id": 140, "func": "uint32_t GetPayloadTime(size_t handle, uint32_t index, double *in, double *out)\n{\n\tmp4object *mp4 = (mp4object *)handle;\n\tif (mp4 == NULL) return GPMF_ERROR_MEMORY;\n\n\tif (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return GPMF_ERROR_MEMORY;\n\n\t*in = ((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\t*out = ((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\treturn GPMF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15146", "cwe_id": "CWE-125" }, { "id": 2105, "func": "static int f2fs_set_data_page_dirty(struct page *page)\n{\n\tstruct address_space *mapping = page->mapping;\n\tstruct inode *inode = mapping->host;\n\n\ttrace_f2fs_set_page_dirty(page, DATA);\n\n\tif (!PageUptodate(page))\n\t\tSetPageUptodate(page);\n\n\tif (f2fs_is_atomic_file(inode) && !f2fs_is_commit_atomic_write(inode)) {\n\t\tif (!IS_ATOMIC_WRITTEN_PAGE(page)) {\n\t\t\tf2fs_register_inmem_page(inode, page);\n\t\t\treturn 1;\n\t\t}\n\t\t/*\n\t\t * Previously, this page has been registered, we just\n\t\t * return here.\n\t\t */\n\t\treturn 0;\n\t}\n\n\tif (!PageDirty(page)) {\n\t\t__set_page_dirty_nobuffers(page);\n\t\tf2fs_update_dirty_page(inode, page);\n\t\treturn 1;\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 2105, "func": "static int f2fs_set_data_page_dirty(struct page *page)\n{\n\tstruct inode *inode = page_file_mapping(page)->host;\n\n\ttrace_f2fs_set_page_dirty(page, DATA);\n\n\tif (!PageUptodate(page))\n\t\tSetPageUptodate(page);\n\tif (PageSwapCache(page))\n\t\treturn __set_page_dirty_nobuffers(page);\n\n\tif (f2fs_is_atomic_file(inode) && !f2fs_is_commit_atomic_write(inode)) {\n\t\tif (!IS_ATOMIC_WRITTEN_PAGE(page)) {\n\t\t\tf2fs_register_inmem_page(inode, page);\n\t\t\treturn 1;\n\t\t}\n\t\t/*\n\t\t * Previously, this page has been registered, we just\n\t\t * return here.\n\t\t */\n\t\treturn 0;\n\t}\n\n\tif (!PageDirty(page)) {\n\t\t__set_page_dirty_nobuffers(page);\n\t\tf2fs_update_dirty_page(inode, page);\n\t\treturn 1;\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 2162, "func": "static int __init ipip_init(void)\n{\n\tint err;\n\n\tprintk(banner);\n\n\tif (xfrm4_tunnel_register(&ipip_handler, AF_INET)) {\n\t\tprintk(KERN_INFO \"ipip init: can't register tunnel\\n\");\n\t\treturn -EAGAIN;\n\t}\n\n\terr = register_pernet_device(&ipip_net_ops);\n\tif (err)\n\t\txfrm4_tunnel_deregister(&ipip_handler, AF_INET);\n\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 2162, "func": "static int __init ipip_init(void)\n{\n\tint err;\n\n\tprintk(banner);\n\n\terr = register_pernet_device(&ipip_net_ops);\n\tif (err < 0)\n\t\treturn err;\n\terr = xfrm4_tunnel_register(&ipip_handler, AF_INET);\n\tif (err < 0) {\n\t\tunregister_pernet_device(&ipip_net_ops);\n\t\tprintk(KERN_INFO \"ipip init: can't register tunnel\\n\");\n\t}\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 161, "func": "header_put_be_3byte (SF_PRIVATE *psf, int x)\n{\tif (psf->headindex < SIGNED_SIZEOF (psf->header) - 3)\n\t{\tpsf->header [psf->headindex++] = (x >> 16) ;\n\t\tpsf->header [psf->headindex++] = (x >> 8) ;\n\t\tpsf->header [psf->headindex++] = x ;\n\t\t} ;\n} /* header_put_be_3byte */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 161, "func": "header_put_be_3byte (SF_PRIVATE *psf, int x)\n{\tpsf->header.ptr [psf->header.indx++] = (x >> 16) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 8) ;\n\tpsf->header.ptr [psf->header.indx++] = x ;\n} /* header_put_be_3byte */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 1084, "func": "static void ImportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info,\n const MagickSizeType number_pixels,const unsigned char *magick_restrict p,\n Quantum *magick_restrict q,ExceptionInfo *exception)\n{\n QuantumAny\n range;\n\n register ssize_t\n x;\n\n unsigned int\n pixel;\n\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n switch (quantum_info->depth)\n {\n case 10:\n {\n Quantum\n cbcr[4];\n\n pixel=0;\n if (quantum_info->pack == MagickFalse)\n {\n register ssize_t\n i;\n\n size_t\n quantum;\n\n ssize_t\n n;\n\n n=0;\n quantum=0;\n for (x=0; x < (ssize_t) number_pixels; x+=2)\n {\n for (i=0; i < 4; i++)\n {\n switch (n % 3)\n {\n case 0:\n {\n p=PushLongPixel(quantum_info->endian,p,&pixel);\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 22) & 0x3ff) << 6)));\n break;\n }\n case 1:\n {\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 12) & 0x3ff) << 6)));\n break;\n }\n case 2:\n {\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 2) & 0x3ff) << 6)));\n break;\n }\n }\n cbcr[i]=(Quantum) (quantum);\n n++;\n }\n p+=quantum_info->pad;\n SetPixelRed(image,cbcr[1],q);\n SetPixelGreen(image,cbcr[0],q);\n SetPixelBlue(image,cbcr[2],q);\n q+=GetPixelChannels(image);\n SetPixelRed(image,cbcr[3],q);\n SetPixelGreen(image,cbcr[0],q);\n SetPixelBlue(image,cbcr[2],q);\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n default:\n {\n range=GetQuantumRange(quantum_info->depth);\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushQuantumPixel(quantum_info,p,&pixel);\n SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);\n p=PushQuantumPixel(quantum_info,p,&pixel);\n SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7534", "cwe_id": "CWE-125" }, { "id": 1084, "func": "static void ImportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info,\n const MagickSizeType number_pixels,const unsigned char *magick_restrict p,\n Quantum *magick_restrict q,ExceptionInfo *exception)\n{\n QuantumAny\n range;\n\n register ssize_t\n x;\n\n unsigned int\n pixel;\n\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n switch (quantum_info->depth)\n {\n case 10:\n {\n Quantum\n cbcr[4];\n\n pixel=0;\n if (quantum_info->pack == MagickFalse)\n {\n register ssize_t\n i;\n\n size_t\n quantum;\n\n ssize_t\n n;\n\n n=0;\n quantum=0;\n for (x=0; x < (ssize_t) number_pixels; x+=4)\n {\n for (i=0; i < 4; i++)\n {\n switch (n % 3)\n {\n case 0:\n {\n p=PushLongPixel(quantum_info->endian,p,&pixel);\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 22) & 0x3ff) << 6)));\n break;\n }\n case 1:\n {\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 12) & 0x3ff) << 6)));\n break;\n }\n case 2:\n {\n quantum=(size_t) (ScaleShortToQuantum((unsigned short)\n (((pixel >> 2) & 0x3ff) << 6)));\n break;\n }\n }\n cbcr[i]=(Quantum) (quantum);\n n++;\n }\n p+=quantum_info->pad;\n SetPixelRed(image,cbcr[1],q);\n SetPixelGreen(image,cbcr[0],q);\n SetPixelBlue(image,cbcr[2],q);\n q+=GetPixelChannels(image);\n SetPixelRed(image,cbcr[3],q);\n SetPixelGreen(image,cbcr[0],q);\n SetPixelBlue(image,cbcr[2],q);\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n default:\n {\n range=GetQuantumRange(quantum_info->depth);\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushQuantumPixel(quantum_info,p,&pixel);\n SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);\n p=PushQuantumPixel(quantum_info,p,&pixel);\n SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7534", "cwe_id": "CWE-125" }, { "id": 989, "func": "void freeClient(redisClient *c) {\n listNode *ln;\n\n /* Note that if the client we are freeing is blocked into a blocking\n * call, we have to set querybuf to NULL *before* to call\n * unblockClientWaitingData() to avoid processInputBuffer() will get\n * called. Also it is important to remove the file events after\n * this, because this call adds the READABLE event. */\n sdsfree(c->querybuf);\n c->querybuf = NULL;\n if (c->flags & REDIS_BLOCKED)\n unblockClientWaitingData(c);\n\n /* UNWATCH all the keys */\n unwatchAllKeys(c);\n listRelease(c->watched_keys);\n /* Unsubscribe from all the pubsub channels */\n pubsubUnsubscribeAllChannels(c,0);\n pubsubUnsubscribeAllPatterns(c,0);\n dictRelease(c->pubsub_channels);\n listRelease(c->pubsub_patterns);\n /* Obvious cleanup */\n aeDeleteFileEvent(server.el,c->fd,AE_READABLE);\n aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);\n listRelease(c->reply);\n freeClientArgv(c);\n close(c->fd);\n /* Remove from the list of clients */\n ln = listSearchKey(server.clients,c);\n redisAssert(ln != NULL);\n listDelNode(server.clients,ln);\n /* Remove from the list of clients waiting for swapped keys, or ready\n * to be restarted, but not yet woken up again. */\n if (c->flags & REDIS_IO_WAIT) {\n redisAssert(server.vm_enabled);\n if (listLength(c->io_keys) == 0) {\n ln = listSearchKey(server.io_ready_clients,c);\n\n /* When this client is waiting to be woken up (REDIS_IO_WAIT),\n * it should be present in the list io_ready_clients */\n redisAssert(ln != NULL);\n listDelNode(server.io_ready_clients,ln);\n } else {\n while (listLength(c->io_keys)) {\n ln = listFirst(c->io_keys);\n dontWaitForSwappedKey(c,ln->value);\n }\n }\n server.vm_blocked_clients--;\n }\n listRelease(c->io_keys);\n /* Master/slave cleanup.\n * Case 1: we lost the connection with a slave. */\n if (c->flags & REDIS_SLAVE) {\n if (c->replstate == REDIS_REPL_SEND_BULK && c->repldbfd != -1)\n close(c->repldbfd);\n list *l = (c->flags & REDIS_MONITOR) ? server.monitors : server.slaves;\n ln = listSearchKey(l,c);\n redisAssert(ln != NULL);\n listDelNode(l,ln);\n }\n\n /* Case 2: we lost the connection with the master. */\n if (c->flags & REDIS_MASTER) {\n server.master = NULL;\n /* FIXME */\n server.replstate = REDIS_REPL_CONNECT;\n /* Since we lost the connection with the master, we should also\n * close the connection with all our slaves if we have any, so\n * when we'll resync with the master the other slaves will sync again\n * with us as well. Note that also when the slave is not connected\n * to the master it will keep refusing connections by other slaves. */\n while (listLength(server.slaves)) {\n ln = listFirst(server.slaves);\n freeClient((redisClient*)ln->value);\n }\n }\n /* Release memory */\n zfree(c->argv);\n freeClientMultiState(c);\n zfree(c);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-0178", "cwe_id": "CWE-20" }, { "id": 989, "func": "void freeClient(redisClient *c) {\n listNode *ln;\n\n /* Note that if the client we are freeing is blocked into a blocking\n * call, we have to set querybuf to NULL *before* to call\n * unblockClientWaitingData() to avoid processInputBuffer() will get\n * called. Also it is important to remove the file events after\n * this, because this call adds the READABLE event. */\n sdsfree(c->querybuf);\n c->querybuf = NULL;\n if (c->flags & REDIS_BLOCKED)\n unblockClientWaitingData(c);\n\n /* UNWATCH all the keys */\n unwatchAllKeys(c);\n listRelease(c->watched_keys);\n /* Unsubscribe from all the pubsub channels */\n pubsubUnsubscribeAllChannels(c,0);\n pubsubUnsubscribeAllPatterns(c,0);\n dictRelease(c->pubsub_channels);\n listRelease(c->pubsub_patterns);\n /* Obvious cleanup */\n aeDeleteFileEvent(server.el,c->fd,AE_READABLE);\n aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);\n listRelease(c->reply);\n freeClientArgv(c);\n close(c->fd);\n /* Remove from the list of clients */\n ln = listSearchKey(server.clients,c);\n redisAssert(ln != NULL);\n listDelNode(server.clients,ln);\n /* Remove from the list of clients waiting for swapped keys, or ready\n * to be restarted, but not yet woken up again. */\n if (c->flags & REDIS_IO_WAIT) {\n redisAssert(server.ds_enabled);\n if (listLength(c->io_keys) == 0) {\n ln = listSearchKey(server.io_ready_clients,c);\n\n /* When this client is waiting to be woken up (REDIS_IO_WAIT),\n * it should be present in the list io_ready_clients */\n redisAssert(ln != NULL);\n listDelNode(server.io_ready_clients,ln);\n } else {\n while (listLength(c->io_keys)) {\n ln = listFirst(c->io_keys);\n dontWaitForSwappedKey(c,ln->value);\n }\n }\n server.cache_blocked_clients--;\n }\n listRelease(c->io_keys);\n /* Master/slave cleanup.\n * Case 1: we lost the connection with a slave. */\n if (c->flags & REDIS_SLAVE) {\n if (c->replstate == REDIS_REPL_SEND_BULK && c->repldbfd != -1)\n close(c->repldbfd);\n list *l = (c->flags & REDIS_MONITOR) ? server.monitors : server.slaves;\n ln = listSearchKey(l,c);\n redisAssert(ln != NULL);\n listDelNode(l,ln);\n }\n\n /* Case 2: we lost the connection with the master. */\n if (c->flags & REDIS_MASTER) {\n server.master = NULL;\n /* FIXME */\n server.replstate = REDIS_REPL_CONNECT;\n /* Since we lost the connection with the master, we should also\n * close the connection with all our slaves if we have any, so\n * when we'll resync with the master the other slaves will sync again\n * with us as well. Note that also when the slave is not connected\n * to the master it will keep refusing connections by other slaves. */\n while (listLength(server.slaves)) {\n ln = listFirst(server.slaves);\n freeClient((redisClient*)ln->value);\n }\n }\n /* Release memory */\n zfree(c->argv);\n freeClientMultiState(c);\n zfree(c);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-0178", "cwe_id": "CWE-20" }, { "id": 2448, "func": "AP4_AvccAtom::InspectFields(AP4_AtomInspector& inspector)\n{\n inspector.AddField(\"Configuration Version\", m_ConfigurationVersion);\n const char* profile_name = GetProfileName(m_Profile);\n if (profile_name) {\n inspector.AddField(\"Profile\", profile_name);\n } else {\n inspector.AddField(\"Profile\", m_Profile);\n }\n inspector.AddField(\"Profile Compatibility\", m_ProfileCompatibility, AP4_AtomInspector::HINT_HEX);\n inspector.AddField(\"Level\", m_Level);\n inspector.AddField(\"NALU Length Size\", m_NaluLengthSize);\n for (unsigned int i=0; iname = malloc(strlen(n) + 1);\n strcpy(pdf->name, n);\n }\n else /* !name */\n {\n pdf->name = malloc(strlen(\"Unknown\") + 1);\n strcpy(pdf->name, \"Unknown\");\n }\n\n return pdf;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-14934", "cwe_id": "CWE-787" }, { "id": 1144, "func": "pdf_t *pdf_new(const char *name)\n{\n const char *n;\n pdf_t *pdf;\n \n pdf = safe_calloc(sizeof(pdf_t));\n\n if (name)\n {\n /* Just get the file name (not path) */\n if ((n = strrchr(name, '/')))\n ++n;\n else\n n = name;\n\n pdf->name = safe_calloc(strlen(n) + 1);\n strcpy(pdf->name, n);\n }\n else /* !name */\n {\n pdf->name = safe_calloc(strlen(\"Unknown\") + 1);\n strcpy(pdf->name, \"Unknown\");\n }\n\n return pdf;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-14934", "cwe_id": "CWE-787" }, { "id": 67, "func": "static void mongo_pass_digest( const char *user, const char *pass, char hex_digest[33] ) {\n mongo_md5_state_t st;\n mongo_md5_byte_t digest[16];\n\n mongo_md5_init( &st );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )user, strlen( user ) );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )\":mongo:\", 7 );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )pass, strlen( pass ) );\n mongo_md5_finish( &st, digest );\n digest2hex( digest, hex_digest );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 67, "func": "static void mongo_pass_digest( const char *user, const char *pass, char hex_digest[33] ) {\n mongo_md5_state_t st;\n mongo_md5_byte_t digest[16];\n\n mongo_md5_init( &st );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )user, ( int )strlen( user ) );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )\":mongo:\", 7 );\n mongo_md5_append( &st, ( const mongo_md5_byte_t * )pass, ( int )strlen( pass ) );\n mongo_md5_finish( &st, digest );\n digest2hex( digest, hex_digest );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2333, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n switch (output->type) {\n case kTfLiteFloat32: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteUInt8: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt16: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt32: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt64: {\n return ReverseSequenceHelper(context, node);\n }\n default: {\n context->ReportError(context,\n \"Type '%s' is not supported by reverse_sequence.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n} // namespace", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2333, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n switch (output->type) {\n case kTfLiteFloat32: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteUInt8: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt16: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt32: {\n return ReverseSequenceHelper(context, node);\n }\n case kTfLiteInt64: {\n return ReverseSequenceHelper(context, node);\n }\n default: {\n context->ReportError(context,\n \"Type '%s' is not supported by reverse_sequence.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n} // namespace", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2019, "func": "TfLiteStatus EvalHashtableSize(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputResourceIdTensor);\n int resource_id = input_resource_id_tensor->data.i32[0];\n\n TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor);\n auto* output_data = GetTensorData(output_tensor);\n\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n auto& resources = subgraph->resources();\n auto* lookup = resource::GetHashtableResource(&resources, resource_id);\n TF_LITE_ENSURE(context, lookup != nullptr);\n\n output_data[0] = lookup->Size();\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2019, "func": "TfLiteStatus EvalHashtableSize(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputResourceIdTensor,\n &input_resource_id_tensor));\n int resource_id = input_resource_id_tensor->data.i32[0];\n\n TfLiteTensor* output_tensor;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputTensor, &output_tensor));\n auto* output_data = GetTensorData(output_tensor);\n\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n auto& resources = subgraph->resources();\n auto* lookup = resource::GetHashtableResource(&resources, resource_id);\n TF_LITE_ENSURE(context, lookup != nullptr);\n\n output_data[0] = lookup->Size();\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 743, "func": "uc_list(char_u *name, size_t name_len)\n{\n int\t\ti, j;\n int\t\tfound = FALSE;\n ucmd_T\t*cmd;\n int\t\tlen;\n int\t\tover;\n long\ta;\n garray_T\t*gap;\n\n // In cmdwin, the alternative buffer should be used.\n gap =\n#ifdef FEAT_CMDWIN\n\t is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :\n#endif\n\t &curbuf->b_ucmds;\n for (;;)\n {\n\tfor (i = 0; i < gap->ga_len; ++i)\n\t{\n\t cmd = USER_CMD_GA(gap, i);\n\t a = (long)cmd->uc_argt;\n\n\t // Skip commands which don't match the requested prefix and\n\t // commands filtered out.\n\t if (STRNCMP(name, cmd->uc_name, name_len) != 0\n\t\t || message_filtered(cmd->uc_name))\n\t\tcontinue;\n\n\t // Put out the title first time\n\t if (!found)\n\t\tmsg_puts_title(_(\"\\n Name Args Address Complete Definition\"));\n\t found = TRUE;\n\t msg_putchar('\\n');\n\t if (got_int)\n\t\tbreak;\n\n\t // Special cases\n\t len = 4;\n\t if (a & EX_BANG)\n\t {\n\t\tmsg_putchar('!');\n\t\t--len;\n\t }\n\t if (a & EX_REGSTR)\n\t {\n\t\tmsg_putchar('\"');\n\t\t--len;\n\t }\n\t if (gap != &ucmds)\n\t {\n\t\tmsg_putchar('b');\n\t\t--len;\n\t }\n\t if (a & EX_TRLBAR)\n\t {\n\t\tmsg_putchar('|');\n\t\t--len;\n\t }\n\t while (len-- > 0)\n\t\tmsg_putchar(' ');\n\n\t msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));\n\t len = (int)STRLEN(cmd->uc_name) + 4;\n\n\t do {\n\t\tmsg_putchar(' ');\n\t\t++len;\n\t } while (len < 22);\n\n\t // \"over\" is how much longer the name is than the column width for\n\t // the name, we'll try to align what comes after.\n\t over = len - 22;\n\t len = 0;\n\n\t // Arguments\n\t switch ((int)(a & (EX_EXTRA|EX_NOSPC|EX_NEEDARG)))\n\t {\n\t\tcase 0:\t\t\t\tIObuff[len++] = '0'; break;\n\t\tcase (EX_EXTRA):\t\tIObuff[len++] = '*'; break;\n\t\tcase (EX_EXTRA|EX_NOSPC):\tIObuff[len++] = '?'; break;\n\t\tcase (EX_EXTRA|EX_NEEDARG):\tIObuff[len++] = '+'; break;\n\t\tcase (EX_EXTRA|EX_NOSPC|EX_NEEDARG): IObuff[len++] = '1'; break;\n\t }\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 5 - over);\n\n\t // Address / Range\n\t if (a & (EX_RANGE|EX_COUNT))\n\t {\n\t\tif (a & EX_COUNT)\n\t\t{\n\t\t // -count=N\n\t\t sprintf((char *)IObuff + len, \"%ldc\", cmd->uc_def);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t}\n\t\telse if (a & EX_DFLALL)\n\t\t IObuff[len++] = '%';\n\t\telse if (cmd->uc_def >= 0)\n\t\t{\n\t\t // -range=N\n\t\t sprintf((char *)IObuff + len, \"%ld\", cmd->uc_def);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t}\n\t\telse\n\t\t IObuff[len++] = '.';\n\t }\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 8 - over);\n\n\t // Address Type\n\t for (j = 0; addr_type_complete[j].expand != ADDR_NONE; ++j)\n\t\tif (addr_type_complete[j].expand != ADDR_LINES\n\t\t\t&& addr_type_complete[j].expand == cmd->uc_addr_type)\n\t\t{\n\t\t STRCPY(IObuff + len, addr_type_complete[j].shortname);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t break;\n\t\t}\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 13 - over);\n\n\t // Completion\n\t for (j = 0; command_complete[j].expand != 0; ++j)\n\t\tif (command_complete[j].expand == cmd->uc_compl)\n\t\t{\n\t\t STRCPY(IObuff + len, command_complete[j].name);\n\t\t len += (int)STRLEN(IObuff + len);\n#ifdef FEAT_EVAL\n\t\t if (p_verbose > 0 && cmd->uc_compl_arg != NULL\n\t\t\t\t\t && STRLEN(cmd->uc_compl_arg) < 200)\n\t\t {\n\t\t\tIObuff[len] = ',';\n\t\t\tSTRCPY(IObuff + len + 1, cmd->uc_compl_arg);\n\t\t\tlen += (int)STRLEN(IObuff + len);\n\t\t }\n#endif\n\t\t break;\n\t\t}\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 25 - over);\n\n\t IObuff[len] = '\\0';\n\t msg_outtrans(IObuff);\n\n\t msg_outtrans_special(cmd->uc_rep, FALSE,\n\t\t\t\t\t name_len == 0 ? Columns - 47 : 0);\n#ifdef FEAT_EVAL\n\t if (p_verbose > 0)\n\t\tlast_set_msg(cmd->uc_script_ctx);\n#endif\n\t out_flush();\n\t ui_breakcheck();\n\t if (got_int)\n\t\tbreak;\n\t}\n\tif (gap == &ucmds || i < gap->ga_len)\n\t break;\n\tgap = &ucmds;\n }\n\n if (!found)\n\tmsg(_(\"No user-defined commands found\"));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0696", "cwe_id": "CWE-476" }, { "id": 743, "func": "uc_list(char_u *name, size_t name_len)\n{\n int\t\ti, j;\n int\t\tfound = FALSE;\n ucmd_T\t*cmd;\n int\t\tlen;\n int\t\tover;\n long\ta;\n garray_T\t*gap;\n\n // In cmdwin, the alternative buffer should be used.\n gap = &prevwin_curwin()->w_buffer->b_ucmds;\n for (;;)\n {\n\tfor (i = 0; i < gap->ga_len; ++i)\n\t{\n\t cmd = USER_CMD_GA(gap, i);\n\t a = (long)cmd->uc_argt;\n\n\t // Skip commands which don't match the requested prefix and\n\t // commands filtered out.\n\t if (STRNCMP(name, cmd->uc_name, name_len) != 0\n\t\t || message_filtered(cmd->uc_name))\n\t\tcontinue;\n\n\t // Put out the title first time\n\t if (!found)\n\t\tmsg_puts_title(_(\"\\n Name Args Address Complete Definition\"));\n\t found = TRUE;\n\t msg_putchar('\\n');\n\t if (got_int)\n\t\tbreak;\n\n\t // Special cases\n\t len = 4;\n\t if (a & EX_BANG)\n\t {\n\t\tmsg_putchar('!');\n\t\t--len;\n\t }\n\t if (a & EX_REGSTR)\n\t {\n\t\tmsg_putchar('\"');\n\t\t--len;\n\t }\n\t if (gap != &ucmds)\n\t {\n\t\tmsg_putchar('b');\n\t\t--len;\n\t }\n\t if (a & EX_TRLBAR)\n\t {\n\t\tmsg_putchar('|');\n\t\t--len;\n\t }\n\t while (len-- > 0)\n\t\tmsg_putchar(' ');\n\n\t msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));\n\t len = (int)STRLEN(cmd->uc_name) + 4;\n\n\t do {\n\t\tmsg_putchar(' ');\n\t\t++len;\n\t } while (len < 22);\n\n\t // \"over\" is how much longer the name is than the column width for\n\t // the name, we'll try to align what comes after.\n\t over = len - 22;\n\t len = 0;\n\n\t // Arguments\n\t switch ((int)(a & (EX_EXTRA|EX_NOSPC|EX_NEEDARG)))\n\t {\n\t\tcase 0:\t\t\t\tIObuff[len++] = '0'; break;\n\t\tcase (EX_EXTRA):\t\tIObuff[len++] = '*'; break;\n\t\tcase (EX_EXTRA|EX_NOSPC):\tIObuff[len++] = '?'; break;\n\t\tcase (EX_EXTRA|EX_NEEDARG):\tIObuff[len++] = '+'; break;\n\t\tcase (EX_EXTRA|EX_NOSPC|EX_NEEDARG): IObuff[len++] = '1'; break;\n\t }\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 5 - over);\n\n\t // Address / Range\n\t if (a & (EX_RANGE|EX_COUNT))\n\t {\n\t\tif (a & EX_COUNT)\n\t\t{\n\t\t // -count=N\n\t\t sprintf((char *)IObuff + len, \"%ldc\", cmd->uc_def);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t}\n\t\telse if (a & EX_DFLALL)\n\t\t IObuff[len++] = '%';\n\t\telse if (cmd->uc_def >= 0)\n\t\t{\n\t\t // -range=N\n\t\t sprintf((char *)IObuff + len, \"%ld\", cmd->uc_def);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t}\n\t\telse\n\t\t IObuff[len++] = '.';\n\t }\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 8 - over);\n\n\t // Address Type\n\t for (j = 0; addr_type_complete[j].expand != ADDR_NONE; ++j)\n\t\tif (addr_type_complete[j].expand != ADDR_LINES\n\t\t\t&& addr_type_complete[j].expand == cmd->uc_addr_type)\n\t\t{\n\t\t STRCPY(IObuff + len, addr_type_complete[j].shortname);\n\t\t len += (int)STRLEN(IObuff + len);\n\t\t break;\n\t\t}\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 13 - over);\n\n\t // Completion\n\t for (j = 0; command_complete[j].expand != 0; ++j)\n\t\tif (command_complete[j].expand == cmd->uc_compl)\n\t\t{\n\t\t STRCPY(IObuff + len, command_complete[j].name);\n\t\t len += (int)STRLEN(IObuff + len);\n#ifdef FEAT_EVAL\n\t\t if (p_verbose > 0 && cmd->uc_compl_arg != NULL\n\t\t\t\t\t && STRLEN(cmd->uc_compl_arg) < 200)\n\t\t {\n\t\t\tIObuff[len] = ',';\n\t\t\tSTRCPY(IObuff + len + 1, cmd->uc_compl_arg);\n\t\t\tlen += (int)STRLEN(IObuff + len);\n\t\t }\n#endif\n\t\t break;\n\t\t}\n\n\t do {\n\t\tIObuff[len++] = ' ';\n\t } while (len < 25 - over);\n\n\t IObuff[len] = '\\0';\n\t msg_outtrans(IObuff);\n\n\t msg_outtrans_special(cmd->uc_rep, FALSE,\n\t\t\t\t\t name_len == 0 ? Columns - 47 : 0);\n#ifdef FEAT_EVAL\n\t if (p_verbose > 0)\n\t\tlast_set_msg(cmd->uc_script_ctx);\n#endif\n\t out_flush();\n\t ui_breakcheck();\n\t if (got_int)\n\t\tbreak;\n\t}\n\tif (gap == &ucmds || i < gap->ga_len)\n\t break;\n\tgap = &ucmds;\n }\n\n if (!found)\n\tmsg(_(\"No user-defined commands found\"));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0696", "cwe_id": "CWE-476" }, { "id": 1719, "func": "static int dex_loadcode(RBinFile *arch, RBinDexObj *bin) {\n\tstruct r_bin_t *rbin = arch->rbin;\n\tint i;\n\tint *methods = NULL;\n\tint sym_count = 0;\n\n\t// doublecheck??\n\tif (!bin || bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->code_from = UT64_MAX;\n\tbin->code_to = 0;\n\tbin->methods_list = r_list_newf ((RListFree)free);\n\tif (!bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->imports_list = r_list_newf ((RListFree)free);\n\tif (!bin->imports_list) {\n\t\tr_list_free (bin->methods_list);\n\t\treturn false;\n\t}\n\tbin->classes_list = r_list_newf ((RListFree)__r_bin_class_free);\n\tif (!bin->classes_list) {\n\t\tr_list_free (bin->methods_list);\n\t\tr_list_free (bin->imports_list);\n\t\treturn false;\n\t}\n\n\tif (bin->header.method_size>bin->size) {\n\t\tbin->header.method_size = 0;\n\t\treturn false;\n\t}\n\n\t/* WrapDown the header sizes to avoid huge allocations */\n\tbin->header.method_size = R_MIN (bin->header.method_size, bin->size);\n\tbin->header.class_size = R_MIN (bin->header.class_size, bin->size);\n\tbin->header.strings_size = R_MIN (bin->header.strings_size, bin->size);\n\n\t// TODO: is this posible after R_MIN ??\n\tif (bin->header.strings_size > bin->size) {\n\t\teprintf (\"Invalid strings size\\n\");\n\t\treturn false;\n\t}\n\n\tif (bin->classes) {\n\t\tut64 amount = sizeof (int) * bin->header.method_size;\n\t\tif (amount > UT32_MAX || amount < bin->header.method_size) {\n\t\t\treturn false;\n\t\t}\n\t\tmethods = calloc (1, amount + 1);\n\t\tfor (i = 0; i < bin->header.class_size; i++) {\n\t\t\tchar *super_name, *class_name;\n\t\t\tstruct dex_class_t *c = &bin->classes[i];\n\t\t\tclass_name = dex_class_name (bin, c);\n\t\t\tsuper_name = dex_class_super_name (bin, c);\n\t\t\tif (dexdump) { \n\t\t\t\trbin->cb_printf (\"Class #%d -\\n\", i);\n\t\t\t}\n\t\t\tparse_class (arch, bin, c, i, methods, &sym_count);\n\t\t\tfree (class_name);\n\t\t\tfree (super_name);\n\t\t}\n\t}\n\n\tif (methods) {\n\t\tint import_count = 0;\n\t\tint sym_count = bin->methods_list->length;\n\n\t\tfor (i = 0; i < bin->header.method_size; i++) {\n\t\t\tint len = 0;\n\t\t\tif (methods[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (bin->methods[i].class_id > bin->header.types_size - 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (is_class_idx_in_code_classes(bin, bin->methods[i].class_id)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchar *class_name = getstr (\n\t\t\t\tbin, bin->types[bin->methods[i].class_id]\n\t\t\t\t\t\t.descriptor_id);\n\t\t\tif (!class_name) {\n\t\t\t\tfree (class_name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlen = strlen (class_name);\n\t\t\tif (len < 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tclass_name[len - 1] = 0; // remove last char \";\"\n\t\t\tchar *method_name = dex_method_name (bin, i);\n\t\t\tchar *signature = dex_method_signature (bin, i);\n\t\t\tif (method_name && *method_name) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\timp->name = r_str_newf (\"%s.method.%s%s\", class_name, method_name, signature);\n\t\t\t\timp->type = r_str_const (\"FUNC\");\n\t\t\t\timp->bind = r_str_const (\"NONE\");\n\t\t\t\timp->ordinal = import_count++;\n\t\t\t\tr_list_append (bin->imports_list, imp);\n\n\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tsym->name = r_str_newf (\"imp.%s\", imp->name);\n\t\t\t\tsym->type = r_str_const (\"FUNC\");\n\t\t\t\tsym->bind = r_str_const (\"NONE\");\n\t\t\t\t//XXX so damn unsafe check buffer boundaries!!!!\n\t\t\t\t//XXX use r_buf API!!\n\t\t\t\tsym->paddr = sym->vaddr = bin->b->base + bin->header.method_offset + (sizeof (struct dex_method_t) * i) ;\n\t\t\t\tsym->ordinal = sym_count++;\n\t\t\t\tr_list_append (bin->methods_list, sym);\n\t\t\t\tsdb_num_set (mdb, sdb_fmt (0, \"method.%d\", i), sym->paddr, 0);\n\t\t\t}\n\t\t\tfree (method_name);\n\t\t\tfree (signature);\n\t\t\tfree (class_name);\n\t\t}\n\t\tfree (methods);\n\t}\n\treturn true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6387", "cwe_id": "CWE-125" }, { "id": 1719, "func": "static int dex_loadcode(RBinFile *arch, RBinDexObj *bin) {\n\tstruct r_bin_t *rbin = arch->rbin;\n\tint i;\n\tint *methods = NULL;\n\tint sym_count = 0;\n\n\t// doublecheck??\n\tif (!bin || bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->code_from = UT64_MAX;\n\tbin->code_to = 0;\n\tbin->methods_list = r_list_newf ((RListFree)free);\n\tif (!bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->imports_list = r_list_newf ((RListFree)free);\n\tif (!bin->imports_list) {\n\t\tr_list_free (bin->methods_list);\n\t\treturn false;\n\t}\n\tbin->classes_list = r_list_newf ((RListFree)__r_bin_class_free);\n\tif (!bin->classes_list) {\n\t\tr_list_free (bin->methods_list);\n\t\tr_list_free (bin->imports_list);\n\t\treturn false;\n\t}\n\n\tif (bin->header.method_size>bin->size) {\n\t\tbin->header.method_size = 0;\n\t\treturn false;\n\t}\n\n\t/* WrapDown the header sizes to avoid huge allocations */\n\tbin->header.method_size = R_MIN (bin->header.method_size, bin->size);\n\tbin->header.class_size = R_MIN (bin->header.class_size, bin->size);\n\tbin->header.strings_size = R_MIN (bin->header.strings_size, bin->size);\n\n\t// TODO: is this posible after R_MIN ??\n\tif (bin->header.strings_size > bin->size) {\n\t\teprintf (\"Invalid strings size\\n\");\n\t\treturn false;\n\t}\n\n\tif (bin->classes) {\n\t\tut64 amount = sizeof (int) * bin->header.method_size;\n\t\tif (amount > UT32_MAX || amount < bin->header.method_size) {\n\t\t\treturn false;\n\t\t}\n\t\tmethods = calloc (1, amount + 1);\n\t\tfor (i = 0; i < bin->header.class_size; i++) {\n\t\t\tchar *super_name, *class_name;\n\t\t\tstruct dex_class_t *c = &bin->classes[i];\n\t\t\tclass_name = dex_class_name (bin, c);\n\t\t\tsuper_name = dex_class_super_name (bin, c);\n\t\t\tif (dexdump) { \n\t\t\t\trbin->cb_printf (\"Class #%d -\\n\", i);\n\t\t\t}\n\t\t\tparse_class (arch, bin, c, i, methods, &sym_count);\n\t\t\tfree (class_name);\n\t\t\tfree (super_name);\n\t\t}\n\t}\n\n\tif (methods) {\n\t\tint import_count = 0;\n\t\tint sym_count = bin->methods_list->length;\n\n\t\tfor (i = 0; i < bin->header.method_size; i++) {\n\t\t\tint len = 0;\n\t\t\tif (methods[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (bin->methods[i].class_id > bin->header.types_size) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (is_class_idx_in_code_classes(bin, bin->methods[i].class_id)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchar *class_name = getstr (\n\t\t\t\tbin, bin->types[bin->methods[i].class_id]\n\t\t\t\t\t\t.descriptor_id);\n\t\t\tif (!class_name) {\n\t\t\t\tfree (class_name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlen = strlen (class_name);\n\t\t\tif (len < 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tclass_name[len - 1] = 0; // remove last char \";\"\n\t\t\tchar *method_name = dex_method_name (bin, i);\n\t\t\tchar *signature = dex_method_signature (bin, i);\n\t\t\tif (method_name && *method_name) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\timp->name = r_str_newf (\"%s.method.%s%s\", class_name, method_name, signature);\n\t\t\t\timp->type = r_str_const (\"FUNC\");\n\t\t\t\timp->bind = r_str_const (\"NONE\");\n\t\t\t\timp->ordinal = import_count++;\n\t\t\t\tr_list_append (bin->imports_list, imp);\n\n\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tsym->name = r_str_newf (\"imp.%s\", imp->name);\n\t\t\t\tsym->type = r_str_const (\"FUNC\");\n\t\t\t\tsym->bind = r_str_const (\"NONE\");\n\t\t\t\t//XXX so damn unsafe check buffer boundaries!!!!\n\t\t\t\t//XXX use r_buf API!!\n\t\t\t\tsym->paddr = sym->vaddr = bin->b->base + bin->header.method_offset + (sizeof (struct dex_method_t) * i) ;\n\t\t\t\tsym->ordinal = sym_count++;\n\t\t\t\tr_list_append (bin->methods_list, sym);\n\t\t\t\tsdb_num_set (mdb, sdb_fmt (0, \"method.%d\", i), sym->paddr, 0);\n\t\t\t}\n\t\t\tfree (method_name);\n\t\t\tfree (signature);\n\t\t\tfree (class_name);\n\t\t}\n\t\tfree (methods);\n\t}\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6387", "cwe_id": "CWE-125" }, { "id": 204, "func": "static void spl_filesystem_dir_it_rewind(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);\n\t\n\tobject->u.dir.index = 0;\n\tif (object->u.dir.dirp) {\n\t\tphp_stream_rewinddir(object->u.dir.dirp);\n\t}\n\tspl_filesystem_dir_read(object TSRMLS_CC);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 204, "func": "static void spl_filesystem_dir_it_rewind(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);\n\n\tobject->u.dir.index = 0;\n\tif (object->u.dir.dirp) {\n\t\tphp_stream_rewinddir(object->u.dir.dirp);\n\t}\n\tspl_filesystem_dir_read(object TSRMLS_CC);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 2348, "func": " void copyBytes(InStream* is, int length) {\n while (length > 0) {\n int n = check(1, length);\n is->readBytes(ptr, n);\n ptr += n;\n length -= n;\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2348, "func": " void copyBytes(InStream* is, size_t length) {\n while (length > 0) {\n size_t n = check(1, length);\n is->readBytes(ptr, n);\n ptr += n;\n length -= n;\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1715, "func": "static unsigned int ipv6_defrag(void *priv,\n\t\t\t\tstruct sk_buff *skb,\n\t\t\t\tconst struct nf_hook_state *state)\n{\n\tint err;\n\n#if IS_ENABLED(CONFIG_NF_CONNTRACK)\n\t/* Previously seen (loopback)?\t*/\n\tif (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))\n\t\treturn NF_ACCEPT;\n#endif\n\n\terr = nf_ct_frag6_gather(state->net, skb,\n\t\t\t\t nf_ct6_defrag_user(state->hook, skb));\n\t/* queued */\n\tif (err == -EINPROGRESS)\n\t\treturn NF_STOLEN;\n\n\treturn NF_ACCEPT;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9755", "cwe_id": "CWE-787" }, { "id": 1715, "func": "static unsigned int ipv6_defrag(void *priv,\n\t\t\t\tstruct sk_buff *skb,\n\t\t\t\tconst struct nf_hook_state *state)\n{\n\tint err;\n\n#if IS_ENABLED(CONFIG_NF_CONNTRACK)\n\t/* Previously seen (loopback)?\t*/\n\tif (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))\n\t\treturn NF_ACCEPT;\n#endif\n\n\terr = nf_ct_frag6_gather(state->net, skb,\n\t\t\t\t nf_ct6_defrag_user(state->hook, skb));\n\t/* queued */\n\tif (err == -EINPROGRESS)\n\t\treturn NF_STOLEN;\n\n\treturn err == 0 ? NF_ACCEPT : NF_DROP;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9755", "cwe_id": "CWE-787" }, { "id": 1176, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_sli(\n\t\t\t\t\tpjmedia_rtcp_session *session, \n\t\t\t\t\tvoid *buf,\n\t\t\t\t\tpj_size_t *length,\n\t\t\t\t\tunsigned sli_cnt,\n\t\t\t\t\tconst pjmedia_rtcp_fb_sli sli[])\n{\n pjmedia_rtcp_common *hdr;\n pj_uint8_t *p;\n unsigned len, i;\n\n PJ_ASSERT_RETURN(session && buf && length && sli_cnt && sli, PJ_EINVAL);\n\n len = (3 + sli_cnt) * 4;\n if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n /* Build RTCP-FB SLI header */\n hdr = (pjmedia_rtcp_common*)buf;\n pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));\n hdr->pt = RTCP_PSFB;\n hdr->count = 2; /* FMT = 2 */\n hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));\n\n /* Build RTCP-FB SLI FCI */\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < sli_cnt; ++i) {\n\t/* 'first' takes 13 bit */\n\t*p++ = (pj_uint8_t)((sli[i].first >> 5) & 0xFF); /* 8 MSB bits */\n\t*p = (pj_uint8_t)((sli[i].first & 31) << 3);\t /* 5 LSB bits */\n\t/* 'number' takes 13 bit */\n\t*p++ |= (pj_uint8_t)((sli[i].number >> 10) & 7); /* 3 MSB bits */\n\t*p++ = (pj_uint8_t)((sli[i].number >> 2) & 0xFF); /* 8 mid bits */\n\t*p = (pj_uint8_t)((sli[i].number & 3) << 6);\t /* 2 LSB bits */\n\t/* 'pict_id' takes 6 bit */\n\t*p++ |= (sli[i].pict_id & 63);\n }\n\n /* Finally */\n *length = len;\n\n return PJ_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 1176, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_sli(\n\t\t\t\t\tpjmedia_rtcp_session *session, \n\t\t\t\t\tvoid *buf,\n\t\t\t\t\tpj_size_t *length,\n\t\t\t\t\tunsigned sli_cnt,\n\t\t\t\t\tconst pjmedia_rtcp_fb_sli sli[])\n{\n pjmedia_rtcp_fb_common *hdr;\n pj_uint8_t *p;\n unsigned len, i;\n\n PJ_ASSERT_RETURN(session && buf && length && sli_cnt && sli, PJ_EINVAL);\n\n len = (3 + sli_cnt) * 4;\n if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n /* Build RTCP-FB SLI header */\n hdr = (pjmedia_rtcp_fb_common*)buf;\n pj_memcpy(hdr, &session->rtcp_fb_com, sizeof(*hdr));\n hdr->rtcp_common.pt = RTCP_PSFB;\n hdr->rtcp_common.count = 2; /* FMT = 2 */\n hdr->rtcp_common.length = pj_htons((pj_uint16_t)(len/4 - 1));\n\n /* Build RTCP-FB SLI FCI */\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < sli_cnt; ++i) {\n\t/* 'first' takes 13 bit */\n\t*p++ = (pj_uint8_t)((sli[i].first >> 5) & 0xFF); /* 8 MSB bits */\n\t*p = (pj_uint8_t)((sli[i].first & 31) << 3);\t /* 5 LSB bits */\n\t/* 'number' takes 13 bit */\n\t*p++ |= (pj_uint8_t)((sli[i].number >> 10) & 7); /* 3 MSB bits */\n\t*p++ = (pj_uint8_t)((sli[i].number >> 2) & 0xFF); /* 8 mid bits */\n\t*p = (pj_uint8_t)((sli[i].number & 3) << 6);\t /* 2 LSB bits */\n\t/* 'pict_id' takes 6 bit */\n\t*p++ |= (sli[i].pict_id & 63);\n }\n\n /* Finally */\n *length = len;\n\n return PJ_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 1698, "func": "static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint copied, err;\n\tstruct sockaddr_ll *sll;\n\tint vnet_hdr_len = 0;\n\n\terr = -EINVAL;\n\tif (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE))\n\t\tgoto out;\n\n#if 0\n\t/* What error should we return now? EUNATTACH? */\n\tif (pkt_sk(sk)->ifindex < 0)\n\t\treturn -ENODEV;\n#endif\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = sock_recv_errqueue(sk, msg, len,\n\t\t\t\t\t SOL_PACKET, PACKET_TX_TIMESTAMP);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tCall the generic datagram receiver. This handles all sorts\n\t *\tof horrible races and re-entrancy so we can forget about it\n\t *\tin the protocol layers.\n\t *\n\t *\tNow it will return ENETDOWN, if device have just gone down,\n\t *\tbut then it will block.\n\t */\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\n\t/*\n\t *\tAn error occurred so return it. Because skb_recv_datagram()\n\t *\thandles the blocking we don't see and worry about blocking\n\t *\tretries.\n\t */\n\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tif (pkt_sk(sk)->has_vnet_hdr) {\n\t\tstruct virtio_net_hdr vnet_hdr = { 0 };\n\n\t\terr = -EINVAL;\n\t\tvnet_hdr_len = sizeof(vnet_hdr);\n\t\tif (len < vnet_hdr_len)\n\t\t\tgoto out_free;\n\n\t\tlen -= vnet_hdr_len;\n\n\t\tif (skb_is_gso(skb)) {\n\t\t\tstruct skb_shared_info *sinfo = skb_shinfo(skb);\n\n\t\t\t/* This is a hint as to how much should be linear. */\n\t\t\tvnet_hdr.hdr_len = skb_headlen(skb);\n\t\t\tvnet_hdr.gso_size = sinfo->gso_size;\n\t\t\tif (sinfo->gso_type & SKB_GSO_TCPV4)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_TCPV6)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_UDP)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_FCOE)\n\t\t\t\tgoto out_free;\n\t\t\telse\n\t\t\t\tBUG();\n\t\t\tif (sinfo->gso_type & SKB_GSO_TCP_ECN)\n\t\t\t\tvnet_hdr.gso_type |= VIRTIO_NET_HDR_GSO_ECN;\n\t\t} else\n\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE;\n\n\t\tif (skb->ip_summed == CHECKSUM_PARTIAL) {\n\t\t\tvnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;\n\t\t\tvnet_hdr.csum_start = skb_checksum_start_offset(skb);\n\t\t\tvnet_hdr.csum_offset = skb->csum_offset;\n\t\t} else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {\n\t\t\tvnet_hdr.flags = VIRTIO_NET_HDR_F_DATA_VALID;\n\t\t} /* else everything is zero */\n\n\t\terr = memcpy_toiovec(msg->msg_iov, (void *)&vnet_hdr,\n\t\t\t\t vnet_hdr_len);\n\t\tif (err < 0)\n\t\t\tgoto out_free;\n\t}\n\n\t/*\n\t *\tIf the address length field is there to be filled in, we fill\n\t *\tit in now.\n\t */\n\n\tsll = &PACKET_SKB_CB(skb)->sa.ll;\n\tif (sock->type == SOCK_PACKET)\n\t\tmsg->msg_namelen = sizeof(struct sockaddr_pkt);\n\telse\n\t\tmsg->msg_namelen = sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr);\n\n\t/*\n\t *\tYou lose any data beyond the buffer you gave. If it worries a\n\t *\tuser program they can ask the device for its MTU anyway.\n\t */\n\n\tcopied = skb->len;\n\tif (copied > len) {\n\t\tcopied = len;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto out_free;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\tif (msg->msg_name)\n\t\tmemcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,\n\t\t msg->msg_namelen);\n\n\tif (pkt_sk(sk)->auxdata) {\n\t\tstruct tpacket_auxdata aux;\n\n\t\taux.tp_status = TP_STATUS_USER;\n\t\tif (skb->ip_summed == CHECKSUM_PARTIAL)\n\t\t\taux.tp_status |= TP_STATUS_CSUMNOTREADY;\n\t\taux.tp_len = PACKET_SKB_CB(skb)->origlen;\n\t\taux.tp_snaplen = skb->len;\n\t\taux.tp_mac = 0;\n\t\taux.tp_net = skb_network_offset(skb);\n\t\tif (vlan_tx_tag_present(skb)) {\n\t\t\taux.tp_vlan_tci = vlan_tx_tag_get(skb);\n\t\t\taux.tp_status |= TP_STATUS_VLAN_VALID;\n\t\t} else {\n\t\t\taux.tp_vlan_tci = 0;\n\t\t}\n\t\taux.tp_padding = 0;\n\t\tput_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);\n\t}\n\n\t/*\n\t *\tFree or return the buffer as appropriate. Again this\n\t *\thides all the races and re-entrancy issues from us.\n\t */\n\terr = vnet_hdr_len + ((flags&MSG_TRUNC) ? skb->len : copied);\n\nout_free:\n\tskb_free_datagram(sk, skb);\nout:\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 1698, "func": "static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint copied, err;\n\tint vnet_hdr_len = 0;\n\n\terr = -EINVAL;\n\tif (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE))\n\t\tgoto out;\n\n#if 0\n\t/* What error should we return now? EUNATTACH? */\n\tif (pkt_sk(sk)->ifindex < 0)\n\t\treturn -ENODEV;\n#endif\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = sock_recv_errqueue(sk, msg, len,\n\t\t\t\t\t SOL_PACKET, PACKET_TX_TIMESTAMP);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tCall the generic datagram receiver. This handles all sorts\n\t *\tof horrible races and re-entrancy so we can forget about it\n\t *\tin the protocol layers.\n\t *\n\t *\tNow it will return ENETDOWN, if device have just gone down,\n\t *\tbut then it will block.\n\t */\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\n\t/*\n\t *\tAn error occurred so return it. Because skb_recv_datagram()\n\t *\thandles the blocking we don't see and worry about blocking\n\t *\tretries.\n\t */\n\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tif (pkt_sk(sk)->has_vnet_hdr) {\n\t\tstruct virtio_net_hdr vnet_hdr = { 0 };\n\n\t\terr = -EINVAL;\n\t\tvnet_hdr_len = sizeof(vnet_hdr);\n\t\tif (len < vnet_hdr_len)\n\t\t\tgoto out_free;\n\n\t\tlen -= vnet_hdr_len;\n\n\t\tif (skb_is_gso(skb)) {\n\t\t\tstruct skb_shared_info *sinfo = skb_shinfo(skb);\n\n\t\t\t/* This is a hint as to how much should be linear. */\n\t\t\tvnet_hdr.hdr_len = skb_headlen(skb);\n\t\t\tvnet_hdr.gso_size = sinfo->gso_size;\n\t\t\tif (sinfo->gso_type & SKB_GSO_TCPV4)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_TCPV6)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_UDP)\n\t\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;\n\t\t\telse if (sinfo->gso_type & SKB_GSO_FCOE)\n\t\t\t\tgoto out_free;\n\t\t\telse\n\t\t\t\tBUG();\n\t\t\tif (sinfo->gso_type & SKB_GSO_TCP_ECN)\n\t\t\t\tvnet_hdr.gso_type |= VIRTIO_NET_HDR_GSO_ECN;\n\t\t} else\n\t\t\tvnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE;\n\n\t\tif (skb->ip_summed == CHECKSUM_PARTIAL) {\n\t\t\tvnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;\n\t\t\tvnet_hdr.csum_start = skb_checksum_start_offset(skb);\n\t\t\tvnet_hdr.csum_offset = skb->csum_offset;\n\t\t} else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {\n\t\t\tvnet_hdr.flags = VIRTIO_NET_HDR_F_DATA_VALID;\n\t\t} /* else everything is zero */\n\n\t\terr = memcpy_toiovec(msg->msg_iov, (void *)&vnet_hdr,\n\t\t\t\t vnet_hdr_len);\n\t\tif (err < 0)\n\t\t\tgoto out_free;\n\t}\n\n\t/* You lose any data beyond the buffer you gave. If it worries\n\t * a user program they can ask the device for its MTU\n\t * anyway.\n\t */\n\tcopied = skb->len;\n\tif (copied > len) {\n\t\tcopied = len;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto out_free;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\tif (msg->msg_name) {\n\t\t/* If the address length field is there to be filled\n\t\t * in, we fill it in now.\n\t\t */\n\t\tif (sock->type == SOCK_PACKET) {\n\t\t\tmsg->msg_namelen = sizeof(struct sockaddr_pkt);\n\t\t} else {\n\t\t\tstruct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;\n\t\t\tmsg->msg_namelen = sll->sll_halen +\n\t\t\t\toffsetof(struct sockaddr_ll, sll_addr);\n\t\t}\n\t\tmemcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,\n\t\t msg->msg_namelen);\n\t}\n\n\tif (pkt_sk(sk)->auxdata) {\n\t\tstruct tpacket_auxdata aux;\n\n\t\taux.tp_status = TP_STATUS_USER;\n\t\tif (skb->ip_summed == CHECKSUM_PARTIAL)\n\t\t\taux.tp_status |= TP_STATUS_CSUMNOTREADY;\n\t\taux.tp_len = PACKET_SKB_CB(skb)->origlen;\n\t\taux.tp_snaplen = skb->len;\n\t\taux.tp_mac = 0;\n\t\taux.tp_net = skb_network_offset(skb);\n\t\tif (vlan_tx_tag_present(skb)) {\n\t\t\taux.tp_vlan_tci = vlan_tx_tag_get(skb);\n\t\t\taux.tp_status |= TP_STATUS_VLAN_VALID;\n\t\t} else {\n\t\t\taux.tp_vlan_tci = 0;\n\t\t}\n\t\taux.tp_padding = 0;\n\t\tput_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);\n\t}\n\n\t/*\n\t *\tFree or return the buffer as appropriate. Again this\n\t *\thides all the races and re-entrancy issues from us.\n\t */\n\terr = vnet_hdr_len + ((flags&MSG_TRUNC) ? skb->len : copied);\n\nout_free:\n\tskb_free_datagram(sk, skb);\nout:\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 1636, "func": "void Context::onLog() {\n if (wasm_->onLog_) {\n wasm_->onLog_(this, id_);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 1636, "func": "void Context::onLog() {\n if (in_vm_context_created_ && wasm_->onLog_) {\n wasm_->onLog_(this, id_);\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 1730, "func": "GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tchar str[1024];\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\n\ti=0;\n\tstr[0]=0;\n\twhile (1) {\n\t\tstr[i] = gf_bs_read_u8(bs);\n\t\tif (!str[i]) break;\n\t\ti++;\n\t}\n\tISOM_DECREASE_SIZE(p, i);\n\n\tp->content_script_types = gf_strdup(str);\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-1441", "cwe_id": "CWE-119" }, { "id": 1730, "func": "GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\n\tp->content_script_types = gf_malloc(sizeof(char) * (s->size+1));\n\tif (!p->content_script_types) return GF_OUT_OF_MEM;\n\tgf_bs_read_data(bs, p->content_script_types, s->size);\n\tp->content_script_types[s->size] = 0;\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-1441", "cwe_id": "CWE-119" }, { "id": 2011, "func": "static Jsi_RC ObjListifyCallback(Jsi_Tree *tree, Jsi_TreeEntry *hPtr, void *data)\n{\n Jsi_Interp *interp = tree->opts.interp;\n Jsi_Obj *obj = (Jsi_Obj*)data;\n int n;\n if (!hPtr->f.bits.dontenum) {\n char *ep = NULL, *cp = (char*)Jsi_TreeKeyGet(hPtr);\n if (!cp || !isdigit(*cp))\n return JSI_OK;\n n = (int)strtol(cp, &ep, 0);\n if (n<0 || n >= interp->maxArrayList)\n return JSI_OK;\n hPtr->f.bits.isarrlist = 1;\n if (Jsi_ObjArraySizer(interp, obj, n) <= 0) \n return Jsi_LogError(\"too long\");\n obj->arr[n] = (Jsi_Value*)Jsi_TreeValueGet(hPtr);\n // obj->arrCnt++;\n }\n return JSI_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 2011, "func": "static Jsi_RC ObjListifyCallback(Jsi_Tree *tree, Jsi_TreeEntry *hPtr, void *data)\n{\n Jsi_Interp *interp = tree->opts.interp;\n Jsi_Obj *obj = (Jsi_Obj*)data;\n int n;\n if (!hPtr->f.bits.dontenum) {\n char *ep = NULL, *cp = (char*)Jsi_TreeKeyGet(hPtr);\n if (!cp || !isdigit(*cp))\n return JSI_OK;\n n = (int)strtol(cp, &ep, 0);\n if (n<0 || (uint)n >= interp->maxArrayList)\n return JSI_OK;\n hPtr->f.bits.isarrlist = 1;\n if (Jsi_ObjArraySizer(interp, obj, n) <= 0) \n return Jsi_LogError(\"too long\");\n obj->arr[n] = (Jsi_Value*)Jsi_TreeValueGet(hPtr);\n // obj->arrCnt++;\n }\n return JSI_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 2748, "func": "#else\n static int input (yyscan_t yyscanner)\n#endif\n\n{\n\tint c;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\t*yyg->yy_c_buf_p = yyg->yy_hold_char;\n\n\tif ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )\n\t\t{\n\t\t/* yy_c_buf_p now points to the character we want to return.\n\t\t * If this occurs *before* the EOB characters, then it's a\n\t\t * valid NUL; if not, then we've hit the end of the buffer.\n\t\t */\n\t\tif ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )\n\t\t\t/* This was really a NUL. */\n\t\t\t*yyg->yy_c_buf_p = '\\0';\n\n\t\telse\n\t\t\t{ /* need more input */\n\t\t\tyy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;\n\t\t\t++yyg->yy_c_buf_p;\n\n\t\t\tswitch ( yy_get_next_buffer( yyscanner ) )\n\t\t\t\t{\n\t\t\t\tcase EOB_ACT_LAST_MATCH:\n\t\t\t\t\t/* This happens because yy_g_n_b()\n\t\t\t\t\t * sees that we've accumulated a\n\t\t\t\t\t * token and flags that we need to\n\t\t\t\t\t * try matching the token before\n\t\t\t\t\t * proceeding. But for input(),\n\t\t\t\t\t * there's no matching to consider.\n\t\t\t\t\t * So convert the EOB_ACT_LAST_MATCH\n\t\t\t\t\t * to EOB_ACT_END_OF_FILE.\n\t\t\t\t\t */\n\n\t\t\t\t\t/* Reset buffer status. */\n\t\t\t\t\tre_yyrestart(yyin ,yyscanner);\n\n\t\t\t\t\t/*FALLTHROUGH*/\n\n\t\t\t\tcase EOB_ACT_END_OF_FILE:\n\t\t\t\t\t{\n\t\t\t\t\tif ( re_yywrap(yyscanner ) )\n\t\t\t\t\t\treturn EOF;\n\n\t\t\t\t\tif ( ! yyg->yy_did_buffer_switch_on_eof )\n\t\t\t\t\t\tYY_NEW_FILE;\n#ifdef __cplusplus\n\t\t\t\t\treturn yyinput(yyscanner);\n#else\n\t\t\t\t\treturn input(yyscanner);\n#endif\n\t\t\t\t\t}\n\n\t\t\t\tcase EOB_ACT_CONTINUE_SCAN:\n\t\t\t\t\tyyg->yy_c_buf_p = yyg->yytext_ptr + offset;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tc = *(unsigned char *) yyg->yy_c_buf_p;\t/* cast for 8-bit char's */\n\t*yyg->yy_c_buf_p = '\\0';\t/* preserve yytext */\n\tyyg->yy_hold_char = *++yyg->yy_c_buf_p;\n\n\tif ( c == '\\n' )\n\t\t \n do{ yylineno++;\n yycolumn=0;\n }while(0)\n;\n\n\treturn c;", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10210", "cwe_id": "CWE-476" }, { "id": 2748, "func": "#else\n static int input (yyscan_t yyscanner)\n#endif\n\n{\n\tint c;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\t*yyg->yy_c_buf_p = yyg->yy_hold_char;\n\n\tif ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )\n\t\t{\n\t\t/* yy_c_buf_p now points to the character we want to return.\n\t\t * If this occurs *before* the EOB characters, then it's a\n\t\t * valid NUL; if not, then we've hit the end of the buffer.\n\t\t */\n\t\tif ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )\n\t\t\t/* This was really a NUL. */\n\t\t\t*yyg->yy_c_buf_p = '\\0';\n\n\t\telse\n\t\t\t{ /* need more input */\n\t\t\tyy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;\n\t\t\t++yyg->yy_c_buf_p;\n\n\t\t\tswitch ( yy_get_next_buffer( yyscanner ) )\n\t\t\t\t{\n\t\t\t\tcase EOB_ACT_LAST_MATCH:\n\t\t\t\t\t/* This happens because yy_g_n_b()\n\t\t\t\t\t * sees that we've accumulated a\n\t\t\t\t\t * token and flags that we need to\n\t\t\t\t\t * try matching the token before\n\t\t\t\t\t * proceeding. But for input(),\n\t\t\t\t\t * there's no matching to consider.\n\t\t\t\t\t * So convert the EOB_ACT_LAST_MATCH\n\t\t\t\t\t * to EOB_ACT_END_OF_FILE.\n\t\t\t\t\t */\n\n\t\t\t\t\t/* Reset buffer status. */\n\t\t\t\t\tre_yyrestart(yyin ,yyscanner);\n\n\t\t\t\t\t/*FALLTHROUGH*/\n\n\t\t\t\tcase EOB_ACT_END_OF_FILE:\n\t\t\t\t\t{\n\t\t\t\t\tif ( re_yywrap(yyscanner ) )\n\t\t\t\t\t\treturn EOF;\n\n\t\t\t\t\tif ( ! yyg->yy_did_buffer_switch_on_eof )\n\t\t\t\t\t\tYY_NEW_FILE;\n#ifdef __cplusplus\n\t\t\t\t\treturn yyinput(yyscanner);\n#else\n\t\t\t\t\treturn input(yyscanner);\n#endif\n\t\t\t\t\t}\n\n\t\t\t\tcase EOB_ACT_CONTINUE_SCAN:\n\t\t\t\t\tyyg->yy_c_buf_p = yyg->yytext_ptr + offset;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tc = *(unsigned char *) yyg->yy_c_buf_p;\t/* cast for 8-bit char's */\n\t*yyg->yy_c_buf_p = '\\0';\t/* preserve yytext */\n\tyyg->yy_hold_char = *++yyg->yy_c_buf_p;\n\n\tif ( c == '\\n' )\n\t\t\n do{ yylineno++;\n yycolumn=0;\n }while(0)\n;\n\n\treturn c;", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10210", "cwe_id": "CWE-476" }, { "id": 72, "func": "pixHtmlViewer(const char *dirin,\n const char *dirout,\n const char *rootname,\n l_int32 thumbwidth,\n l_int32 viewwidth)\n{\nchar *fname, *fullname, *outname;\nchar *mainname, *linkname, *linknameshort;\nchar *viewfile, *thumbfile;\nchar *shtml, *slink;\nchar charbuf[512];\nchar htmlstring[] = \"\";\nchar framestring[] = \"\";\nl_int32 i, nfiles, index, w, d, nimages, ret;\nl_float32 factor;\nPIX *pix, *pixthumb, *pixview;\nSARRAY *safiles, *sathumbs, *saviews, *sahtml, *salink;\n\n PROCNAME(\"pixHtmlViewer\");\n\n if (!dirin)\n return ERROR_INT(\"dirin not defined\", procName, 1);\n if (!dirout)\n return ERROR_INT(\"dirout not defined\", procName, 1);\n if (!rootname)\n return ERROR_INT(\"rootname not defined\", procName, 1);\n\n if (thumbwidth == 0)\n thumbwidth = DEFAULT_THUMB_WIDTH;\n if (thumbwidth < MIN_THUMB_WIDTH) {\n L_WARNING(\"thumbwidth too small; using min value\\n\", procName);\n thumbwidth = MIN_THUMB_WIDTH;\n }\n if (viewwidth == 0)\n viewwidth = DEFAULT_VIEW_WIDTH;\n if (viewwidth < MIN_VIEW_WIDTH) {\n L_WARNING(\"viewwidth too small; using min value\\n\", procName);\n viewwidth = MIN_VIEW_WIDTH;\n }\n\n /* Make the output directory if it doesn't already exist */\n#ifndef _WIN32\n snprintf(charbuf, sizeof(charbuf), \"mkdir -p %s\", dirout);\n ret = system(charbuf);\n#else\n ret = CreateDirectory(dirout, NULL) ? 0 : 1;\n#endif /* !_WIN32 */\n if (ret) {\n L_ERROR(\"output directory %s not made\\n\", procName, dirout);\n return 1;\n }\n\n /* Capture the filenames in the input directory */\n if ((safiles = getFilenamesInDirectory(dirin)) == NULL)\n return ERROR_INT(\"safiles not made\", procName, 1);\n\n /* Generate output text file names */\n sprintf(charbuf, \"%s/%s.html\", dirout, rootname);\n mainname = stringNew(charbuf);\n sprintf(charbuf, \"%s/%s-links.html\", dirout, rootname);\n linkname = stringNew(charbuf);\n linknameshort = stringJoin(rootname, \"-links.html\");\n\n /* Generate the thumbs and views */\n sathumbs = sarrayCreate(0);\n saviews = sarrayCreate(0);\n nfiles = sarrayGetCount(safiles);\n index = 0;\n for (i = 0; i < nfiles; i++) {\n fname = sarrayGetString(safiles, i, L_NOCOPY);\n fullname = genPathname(dirin, fname);\n fprintf(stderr, \"name: %s\\n\", fullname);\n if ((pix = pixRead(fullname)) == NULL) {\n fprintf(stderr, \"file %s not a readable image\\n\", fullname);\n lept_free(fullname);\n continue;\n }\n lept_free(fullname);\n\n /* Make and store the thumbnail images */\n pixGetDimensions(pix, &w, NULL, &d);\n factor = (l_float32)thumbwidth / (l_float32)w;\n pixthumb = pixScale(pix, factor, factor);\n sprintf(charbuf, \"%s_thumb_%03d\", rootname, index);\n sarrayAddString(sathumbs, charbuf, L_COPY);\n outname = genPathname(dirout, charbuf);\n WriteFormattedPix(outname, pixthumb);\n lept_free(outname);\n pixDestroy(&pixthumb);\n\n /* Make and store the view images */\n factor = (l_float32)viewwidth / (l_float32)w;\n if (factor >= 1.0)\n pixview = pixClone(pix); /* no upscaling */\n else\n pixview = pixScale(pix, factor, factor);\n snprintf(charbuf, sizeof(charbuf), \"%s_view_%03d\", rootname, index);\n sarrayAddString(saviews, charbuf, L_COPY);\n outname = genPathname(dirout, charbuf);\n WriteFormattedPix(outname, pixview);\n lept_free(outname);\n pixDestroy(&pixview);\n pixDestroy(&pix);\n index++;\n }\n\n /* Generate the main html file */\n sahtml = sarrayCreate(0);\n sarrayAddString(sahtml, htmlstring, L_COPY);\n sprintf(charbuf, \"\", thumbwidth + 30);\n sarrayAddString(sahtml, charbuf, L_COPY);\n sprintf(charbuf, \"\", linknameshort);\n sarrayAddString(sahtml, charbuf, L_COPY);\n sprintf(charbuf, \"\",\n sarrayGetString(saviews, 0, L_NOCOPY));\n sarrayAddString(sahtml, charbuf, L_COPY);\n sarrayAddString(sahtml, framestring, L_COPY);\n shtml = sarrayToString(sahtml, 1);\n l_binaryWrite(mainname, \"w\", shtml, strlen(shtml));\n fprintf(stderr, \"******************************************\\n\"\n \"Writing html file: %s\\n\"\n \"******************************************\\n\", mainname);\n lept_free(shtml);\n lept_free(mainname);\n\n /* Generate the link html file */\n nimages = sarrayGetCount(saviews);\n fprintf(stderr, \"num. images = %d\\n\", nimages);\n salink = sarrayCreate(0);\n for (i = 0; i < nimages; i++) {\n viewfile = sarrayGetString(saviews, i, L_NOCOPY);\n thumbfile = sarrayGetString(sathumbs, i, L_NOCOPY);\n sprintf(charbuf, \"\",\n viewfile, thumbfile);\n sarrayAddString(salink, charbuf, L_COPY);\n }\n slink = sarrayToString(salink, 1);\n l_binaryWrite(linkname, \"w\", slink, strlen(slink));\n lept_free(slink);\n lept_free(linkname);\n lept_free(linknameshort);\n sarrayDestroy(&safiles);\n sarrayDestroy(&sathumbs);\n sarrayDestroy(&saviews);\n sarrayDestroy(&sahtml);\n sarrayDestroy(&salink);\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-7247", "cwe_id": "CWE-119" }, { "id": 72, "func": "pixHtmlViewer(const char *dirin,\n const char *dirout,\n const char *rootname,\n l_int32 thumbwidth,\n l_int32 viewwidth)\n{\nchar *fname, *fullname, *outname;\nchar *mainname, *linkname, *linknameshort;\nchar *viewfile, *thumbfile;\nchar *shtml, *slink;\nchar charbuf[512];\nchar htmlstring[] = \"\";\nchar framestring[] = \"\";\nl_int32 i, nfiles, index, w, d, nimages, ret;\nl_float32 factor;\nPIX *pix, *pixthumb, *pixview;\nSARRAY *safiles, *sathumbs, *saviews, *sahtml, *salink;\n\n PROCNAME(\"pixHtmlViewer\");\n\n if (!dirin)\n return ERROR_INT(\"dirin not defined\", procName, 1);\n if (!dirout)\n return ERROR_INT(\"dirout not defined\", procName, 1);\n if (!rootname)\n return ERROR_INT(\"rootname not defined\", procName, 1);\n\n if (thumbwidth == 0)\n thumbwidth = DEFAULT_THUMB_WIDTH;\n if (thumbwidth < MIN_THUMB_WIDTH) {\n L_WARNING(\"thumbwidth too small; using min value\\n\", procName);\n thumbwidth = MIN_THUMB_WIDTH;\n }\n if (viewwidth == 0)\n viewwidth = DEFAULT_VIEW_WIDTH;\n if (viewwidth < MIN_VIEW_WIDTH) {\n L_WARNING(\"viewwidth too small; using min value\\n\", procName);\n viewwidth = MIN_VIEW_WIDTH;\n }\n\n /* Make the output directory if it doesn't already exist */\n#ifndef _WIN32\n snprintf(charbuf, sizeof(charbuf), \"mkdir -p %s\", dirout);\n ret = system(charbuf);\n#else\n ret = CreateDirectory(dirout, NULL) ? 0 : 1;\n#endif /* !_WIN32 */\n if (ret) {\n L_ERROR(\"output directory %s not made\\n\", procName, dirout);\n return 1;\n }\n\n /* Capture the filenames in the input directory */\n if ((safiles = getFilenamesInDirectory(dirin)) == NULL)\n return ERROR_INT(\"safiles not made\", procName, 1);\n\n /* Generate output text file names */\n snprintf(charbuf, sizeof(charbuf), \"%s/%s.html\", dirout, rootname);\n mainname = stringNew(charbuf);\n snprintf(charbuf, sizeof(charbuf), \"%s/%s-links.html\", dirout, rootname);\n linkname = stringNew(charbuf);\n linknameshort = stringJoin(rootname, \"-links.html\");\n\n /* Generate the thumbs and views */\n sathumbs = sarrayCreate(0);\n saviews = sarrayCreate(0);\n nfiles = sarrayGetCount(safiles);\n index = 0;\n for (i = 0; i < nfiles; i++) {\n fname = sarrayGetString(safiles, i, L_NOCOPY);\n fullname = genPathname(dirin, fname);\n fprintf(stderr, \"name: %s\\n\", fullname);\n if ((pix = pixRead(fullname)) == NULL) {\n fprintf(stderr, \"file %s not a readable image\\n\", fullname);\n lept_free(fullname);\n continue;\n }\n lept_free(fullname);\n\n /* Make and store the thumbnail images */\n pixGetDimensions(pix, &w, NULL, &d);\n factor = (l_float32)thumbwidth / (l_float32)w;\n pixthumb = pixScale(pix, factor, factor);\n snprintf(charbuf, sizeof(charbuf), \"%s_thumb_%03d\", rootname, index);\n sarrayAddString(sathumbs, charbuf, L_COPY);\n outname = genPathname(dirout, charbuf);\n WriteFormattedPix(outname, pixthumb);\n lept_free(outname);\n pixDestroy(&pixthumb);\n\n /* Make and store the view images */\n factor = (l_float32)viewwidth / (l_float32)w;\n if (factor >= 1.0)\n pixview = pixClone(pix); /* no upscaling */\n else\n pixview = pixScale(pix, factor, factor);\n snprintf(charbuf, sizeof(charbuf), \"%s_view_%03d\", rootname, index);\n sarrayAddString(saviews, charbuf, L_COPY);\n outname = genPathname(dirout, charbuf);\n WriteFormattedPix(outname, pixview);\n lept_free(outname);\n pixDestroy(&pixview);\n pixDestroy(&pix);\n index++;\n }\n\n /* Generate the main html file */\n sahtml = sarrayCreate(0);\n sarrayAddString(sahtml, htmlstring, L_COPY);\n sprintf(charbuf, \"\", thumbwidth + 30);\n sarrayAddString(sahtml, charbuf, L_COPY);\n sprintf(charbuf, \"\", linknameshort);\n sarrayAddString(sahtml, charbuf, L_COPY);\n sprintf(charbuf, \"\",\n sarrayGetString(saviews, 0, L_NOCOPY));\n sarrayAddString(sahtml, charbuf, L_COPY);\n sarrayAddString(sahtml, framestring, L_COPY);\n shtml = sarrayToString(sahtml, 1);\n l_binaryWrite(mainname, \"w\", shtml, strlen(shtml));\n fprintf(stderr, \"******************************************\\n\"\n \"Writing html file: %s\\n\"\n \"******************************************\\n\", mainname);\n lept_free(shtml);\n lept_free(mainname);\n\n /* Generate the link html file */\n nimages = sarrayGetCount(saviews);\n fprintf(stderr, \"num. images = %d\\n\", nimages);\n salink = sarrayCreate(0);\n for (i = 0; i < nimages; i++) {\n viewfile = sarrayGetString(saviews, i, L_NOCOPY);\n thumbfile = sarrayGetString(sathumbs, i, L_NOCOPY);\n sprintf(charbuf, \"\",\n viewfile, thumbfile);\n sarrayAddString(salink, charbuf, L_COPY);\n }\n slink = sarrayToString(salink, 1);\n l_binaryWrite(linkname, \"w\", slink, strlen(slink));\n lept_free(slink);\n lept_free(linkname);\n lept_free(linknameshort);\n sarrayDestroy(&safiles);\n sarrayDestroy(&sathumbs);\n sarrayDestroy(&saviews);\n sarrayDestroy(&sahtml);\n sarrayDestroy(&salink);\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-7247", "cwe_id": "CWE-119" }, { "id": 3137, "func": "int FileInStream::overrun(int itemSize, int nItems, bool wait)\n{\n if (itemSize > (int)sizeof(b))\n throw Exception(\"FileInStream overrun: max itemSize exceeded\");\n\n if (end - ptr != 0)\n memmove(b, ptr, end - ptr);\n\n end -= ptr - b;\n ptr = b;\n\n\n while (end < b + itemSize) {\n size_t n = fread((U8 *)end, b + sizeof(b) - end, 1, file);\n if (n == 0) {\n if (ferror(file))\n throw SystemException(\"fread\", errno);\n if (feof(file))\n throw EndOfStream();\n return 0;\n }\n end += b + sizeof(b) - end;\n }\n\n if (itemSize * nItems > end - ptr)\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 3137, "func": "size_t FileInStream::overrun(size_t itemSize, size_t nItems, bool wait)\n{\n if (itemSize > sizeof(b))\n throw Exception(\"FileInStream overrun: max itemSize exceeded\");\n\n if (end - ptr != 0)\n memmove(b, ptr, end - ptr);\n\n end -= ptr - b;\n ptr = b;\n\n\n while (end < b + itemSize) {\n size_t n = fread((U8 *)end, b + sizeof(b) - end, 1, file);\n if (n == 0) {\n if (ferror(file))\n throw SystemException(\"fread\", errno);\n if (feof(file))\n throw EndOfStream();\n return 0;\n }\n end += b + sizeof(b) - end;\n }\n\n if (itemSize * nItems > (size_t)(end - ptr))\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 3139, "func": "static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,\n\t\t\t unsigned int cryptlen)\n{\n\tstruct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req);\n\tstruct crypto_aead *aead = crypto_aead_reqtfm(req);\n\tstruct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead);\n\tAHASH_REQUEST_ON_STACK(ahreq, ctx->mac);\n\tunsigned int assoclen = req->assoclen;\n\tstruct scatterlist sg[3];\n\tu8 odata[16];\n\tu8 idata[16];\n\tint ilen, err;\n\n\t/* format control data for input */\n\terr = format_input(odata, req, cryptlen);\n\tif (err)\n\t\tgoto out;\n\n\tsg_init_table(sg, 3);\n\tsg_set_buf(&sg[0], odata, 16);\n\n\t/* format associated data and compute into mac */\n\tif (assoclen) {\n\t\tilen = format_adata(idata, assoclen);\n\t\tsg_set_buf(&sg[1], idata, ilen);\n\t\tsg_chain(sg, 3, req->src);\n\t} else {\n\t\tilen = 0;\n\t\tsg_chain(sg, 2, req->src);\n\t}\n\n\tahash_request_set_tfm(ahreq, ctx->mac);\n\tahash_request_set_callback(ahreq, pctx->flags, NULL, NULL);\n\tahash_request_set_crypt(ahreq, sg, NULL, assoclen + ilen + 16);\n\terr = crypto_ahash_init(ahreq);\n\tif (err)\n\t\tgoto out;\n\terr = crypto_ahash_update(ahreq);\n\tif (err)\n\t\tgoto out;\n\n\t/* we need to pad the MAC input to a round multiple of the block size */\n\tilen = 16 - (assoclen + ilen) % 16;\n\tif (ilen < 16) {\n\t\tmemset(idata, 0, ilen);\n\t\tsg_init_table(sg, 2);\n\t\tsg_set_buf(&sg[0], idata, ilen);\n\t\tif (plain)\n\t\t\tsg_chain(sg, 2, plain);\n\t\tplain = sg;\n\t\tcryptlen += ilen;\n\t}\n\n\tahash_request_set_crypt(ahreq, plain, pctx->odata, cryptlen);\n\terr = crypto_ahash_finup(ahreq);\nout:\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-8065", "cwe_id": "CWE-119" }, { "id": 3139, "func": "static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,\n\t\t\t unsigned int cryptlen)\n{\n\tstruct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req);\n\tstruct crypto_aead *aead = crypto_aead_reqtfm(req);\n\tstruct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead);\n\tAHASH_REQUEST_ON_STACK(ahreq, ctx->mac);\n\tunsigned int assoclen = req->assoclen;\n\tstruct scatterlist sg[3];\n\tu8 *odata = pctx->odata;\n\tu8 *idata = pctx->idata;\n\tint ilen, err;\n\n\t/* format control data for input */\n\terr = format_input(odata, req, cryptlen);\n\tif (err)\n\t\tgoto out;\n\n\tsg_init_table(sg, 3);\n\tsg_set_buf(&sg[0], odata, 16);\n\n\t/* format associated data and compute into mac */\n\tif (assoclen) {\n\t\tilen = format_adata(idata, assoclen);\n\t\tsg_set_buf(&sg[1], idata, ilen);\n\t\tsg_chain(sg, 3, req->src);\n\t} else {\n\t\tilen = 0;\n\t\tsg_chain(sg, 2, req->src);\n\t}\n\n\tahash_request_set_tfm(ahreq, ctx->mac);\n\tahash_request_set_callback(ahreq, pctx->flags, NULL, NULL);\n\tahash_request_set_crypt(ahreq, sg, NULL, assoclen + ilen + 16);\n\terr = crypto_ahash_init(ahreq);\n\tif (err)\n\t\tgoto out;\n\terr = crypto_ahash_update(ahreq);\n\tif (err)\n\t\tgoto out;\n\n\t/* we need to pad the MAC input to a round multiple of the block size */\n\tilen = 16 - (assoclen + ilen) % 16;\n\tif (ilen < 16) {\n\t\tmemset(idata, 0, ilen);\n\t\tsg_init_table(sg, 2);\n\t\tsg_set_buf(&sg[0], idata, ilen);\n\t\tif (plain)\n\t\t\tsg_chain(sg, 2, plain);\n\t\tplain = sg;\n\t\tcryptlen += ilen;\n\t}\n\n\tahash_request_set_crypt(ahreq, plain, pctx->odata, cryptlen);\n\terr = crypto_ahash_finup(ahreq);\nout:\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-8065", "cwe_id": "CWE-119" }, { "id": 780, "func": "BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx)\n{\n\tint bitmap_caret = 0;\n\toTga *tga = NULL;\n\t/*\tint pixel_block_size = 0;\n\t\tint image_block_size = 0; */\n\tvolatile gdImagePtr image = NULL;\n\tint x = 0;\n\tint y = 0;\n\n\ttga = (oTga *) gdMalloc(sizeof(oTga));\n\tif (!tga) {\n\t\treturn NULL;\n\t}\n\n\ttga->bitmap = NULL;\n\ttga->ident = NULL;\n\n\tif (read_header_tga(ctx, tga) < 0) {\n\t\tfree_tga(tga);\n\t\treturn NULL;\n\t}\n\n\t/*TODO: Will this be used?\n\t\tpixel_block_size = tga->bits / 8;\n\t\timage_block_size = (tga->width * tga->height) * pixel_block_size;\n\t*/\n\n\tif (read_image_tga(ctx, tga) < 0) {\n\t\tfree_tga(tga);\n\t\treturn NULL;\n\t}\n\n\timage = gdImageCreateTrueColor((int)tga->width, (int)tga->height );\n\n\tif (image == 0) {\n\t\tfree_tga( tga );\n\t\treturn NULL;\n\t}\n\n\t/*!\t\\brief Populate GD image object\n\t * Copy the pixel data from our tga bitmap buffer into the GD image\n\t * Disable blending and save the alpha channel per default\n\t */\n\tif (tga->alphabits) {\n\t\tgdImageAlphaBlending(image, 0);\n\t\tgdImageSaveAlpha(image, 1);\n\t}\n\n\t/* TODO: use alphabits as soon as we support 24bit and other alpha bps (ie != 8bits) */\n\tfor (y = 0; y < tga->height; y++) {\n\t\tregister int *tpix = image->tpixels[y];\n\t\tfor ( x = 0; x < tga->width; x++, tpix++) {\n\t\t\tif (tga->bits == TGA_BPP_24) {\n\t\t\t\t*tpix = gdTrueColor(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret]);\n\t\t\t\tbitmap_caret += 3;\n\t\t\t} else if (tga->bits == TGA_BPP_32 || tga->alphabits) {\n\t\t\t\tregister int a = tga->bitmap[bitmap_caret + 3];\n\n\t\t\t\t*tpix = gdTrueColorAlpha(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret], gdAlphaMax - (a >> 1));\n\t\t\t\tbitmap_caret += 4;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (tga->flipv && tga->fliph) {\n\t\tgdImageFlipBoth(image);\n\t} else if (tga->flipv) {\n\t\tgdImageFlipVertical(image);\n\t} else if (tga->fliph) {\n\t\tgdImageFlipHorizontal(image);\n\t}\n\n\tfree_tga(tga);\n\n\treturn image;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-6214", "cwe_id": "CWE-125" }, { "id": 780, "func": "BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx)\n{\n\tint bitmap_caret = 0;\n\toTga *tga = NULL;\n\t/*\tint pixel_block_size = 0;\n\t\tint image_block_size = 0; */\n\tvolatile gdImagePtr image = NULL;\n\tint x = 0;\n\tint y = 0;\n\n\ttga = (oTga *) gdMalloc(sizeof(oTga));\n\tif (!tga) {\n\t\treturn NULL;\n\t}\n\n\ttga->bitmap = NULL;\n\ttga->ident = NULL;\n\n\tif (read_header_tga(ctx, tga) < 0) {\n\t\tfree_tga(tga);\n\t\treturn NULL;\n\t}\n\n\t/*TODO: Will this be used?\n\t\tpixel_block_size = tga->bits / 8;\n\t\timage_block_size = (tga->width * tga->height) * pixel_block_size;\n\t*/\n\n\tif (read_image_tga(ctx, tga) < 0) {\n\t\tfree_tga(tga);\n\t\treturn NULL;\n\t}\n\n\timage = gdImageCreateTrueColor((int)tga->width, (int)tga->height );\n\n\tif (image == 0) {\n\t\tfree_tga( tga );\n\t\treturn NULL;\n\t}\n\n\t/*!\t\\brief Populate GD image object\n\t * Copy the pixel data from our tga bitmap buffer into the GD image\n\t * Disable blending and save the alpha channel per default\n\t */\n\tif (tga->alphabits) {\n\t\tgdImageAlphaBlending(image, 0);\n\t\tgdImageSaveAlpha(image, 1);\n\t}\n\n\t/* TODO: use alphabits as soon as we support 24bit and other alpha bps (ie != 8bits) */\n\tfor (y = 0; y < tga->height; y++) {\n\t\tregister int *tpix = image->tpixels[y];\n\t\tfor ( x = 0; x < tga->width; x++, tpix++) {\n\t\t\tif (tga->bits == TGA_BPP_24) {\n\t\t\t\t*tpix = gdTrueColor(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret]);\n\t\t\t\tbitmap_caret += 3;\n\t\t\t} else if (tga->bits == TGA_BPP_32 && tga->alphabits) {\n\t\t\t\tregister int a = tga->bitmap[bitmap_caret + 3];\n\n\t\t\t\t*tpix = gdTrueColorAlpha(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret], gdAlphaMax - (a >> 1));\n\t\t\t\tbitmap_caret += 4;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (tga->flipv && tga->fliph) {\n\t\tgdImageFlipBoth(image);\n\t} else if (tga->flipv) {\n\t\tgdImageFlipVertical(image);\n\t} else if (tga->fliph) {\n\t\tgdImageFlipHorizontal(image);\n\t}\n\n\tfree_tga(tga);\n\n\treturn image;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-6214", "cwe_id": "CWE-125" }, { "id": 2061, "func": " int pos() { return ptr - start; }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2061, "func": " size_t pos() { return ptr - start; }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1276, "func": "TEST(BasicFlatBufferModel, TestHandleMalformedModel) {\n const auto model_paths = {\n // These models use the same tensor as both input and ouput of a node\n \"tensorflow/lite/testdata/add_shared_tensors.bin\",\n };\n\n for (const auto& model_path : model_paths) {\n std::unique_ptr model =\n FlatBufferModel::BuildFromFile(model_path);\n ASSERT_NE(model, nullptr);\n\n tflite::ops::builtin::BuiltinOpResolver resolver;\n InterpreterBuilder builder(*model, resolver);\n std::unique_ptr interpreter;\n ASSERT_EQ(builder(&interpreter), kTfLiteOk);\n ASSERT_NE(interpreter, nullptr);\n ASSERT_NE(interpreter->AllocateTensors(), kTfLiteOk);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15209", "cwe_id": "CWE-476" }, { "id": 1276, "func": "TEST(BasicFlatBufferModel, TestHandleMalformedModelInvalidBuffer) {\n const auto model_path =\n \"tensorflow/lite/testdata/segment_sum_invalid_buffer.bin\";\n\n std::unique_ptr model =\n FlatBufferModel::BuildFromFile(model_path);\n ASSERT_NE(model, nullptr);\n\n tflite::ops::builtin::BuiltinOpResolver resolver;\n InterpreterBuilder builder(*model, resolver);\n std::unique_ptr interpreter;\n ASSERT_EQ(builder(&interpreter), kTfLiteOk);\n ASSERT_NE(interpreter, nullptr);\n ASSERT_EQ(interpreter->AllocateTensors(), kTfLiteOk);\n ASSERT_NE(interpreter->Invoke(), kTfLiteOk);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15209", "cwe_id": "CWE-476" }, { "id": 3105, "func": "int rose_parse_facilities(unsigned char *p,\n\tstruct rose_facilities_struct *facilities)\n{\n\tint facilities_len, len;\n\n\tfacilities_len = *p++;\n\n\tif (facilities_len == 0)\n\t\treturn 0;\n\n\twhile (facilities_len > 0) {\n\t\tif (*p == 0x00) {\n\t\t\tfacilities_len--;\n\t\t\tp++;\n\n\t\t\tswitch (*p) {\n\t\t\tcase FAC_NATIONAL:\t\t/* National */\n\t\t\t\tlen = rose_parse_national(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tcase FAC_CCITT:\t\t/* CCITT */\n\t\t\t\tlen = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tprintk(KERN_DEBUG \"ROSE: rose_parse_facilities - unknown facilities family %02X\\n\", *p);\n\t\t\t\tfacilities_len--;\n\t\t\t\tp++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tbreak;\t/* Error in facilities format */\n\t}\n\n\treturn 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 3105, "func": "int rose_parse_facilities(unsigned char *p, unsigned packet_len,\n\tstruct rose_facilities_struct *facilities)\n{\n\tint facilities_len, len;\n\n\tfacilities_len = *p++;\n\n\tif (facilities_len == 0 || (unsigned)facilities_len > packet_len)\n\t\treturn 0;\n\n\twhile (facilities_len >= 3 && *p == 0x00) {\n\t\tfacilities_len--;\n\t\tp++;\n\n\t\tswitch (*p) {\n\t\tcase FAC_NATIONAL:\t\t/* National */\n\t\t\tlen = rose_parse_national(p + 1, facilities, facilities_len - 1);\n\t\t\tbreak;\n\n\t\tcase FAC_CCITT:\t\t/* CCITT */\n\t\t\tlen = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tprintk(KERN_DEBUG \"ROSE: rose_parse_facilities - unknown facilities family %02X\\n\", *p);\n\t\t\tlen = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (len < 0)\n\t\t\treturn 0;\n\t\tif (WARN_ON(len >= facilities_len))\n\t\t\treturn 0;\n\t\tfacilities_len -= len + 1;\n\t\tp += len + 1;\n\t}\n\n\treturn facilities_len == 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 2572, "func": "juniper_atm2_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n int llc_hdrlen;\n\n struct juniper_l2info_t l2info;\n\n l2info.pictype = DLT_JUNIPER_ATM2;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n\n if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */\n oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);\n return l2info.header_len;\n }\n\n if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */\n EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */\n\n llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);\n if (llc_hdrlen > 0)\n return l2info.header_len;\n }\n\n if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */\n (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {\n ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);\n return l2info.header_len;\n }\n\n if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */\n isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);\n /* FIXME check if frame was recognized */\n return l2info.header_len;\n }\n\n if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */\n return l2info.header_len;\n\n if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */\n return l2info.header_len;\n\n\treturn l2info.header_len;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 2572, "func": "juniper_atm2_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n int llc_hdrlen;\n\n struct juniper_l2info_t l2info;\n\n l2info.pictype = DLT_JUNIPER_ATM2;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n\n if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */\n oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);\n return l2info.header_len;\n }\n\n if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */\n EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */\n\n llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);\n if (llc_hdrlen > 0)\n return l2info.header_len;\n }\n\n if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */\n (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {\n ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);\n return l2info.header_len;\n }\n\n if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */\n isoclns_print(ndo, p + 1, l2info.length - 1);\n /* FIXME check if frame was recognized */\n return l2info.header_len;\n }\n\n if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */\n return l2info.header_len;\n\n if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */\n return l2info.header_len;\n\n\treturn l2info.header_len;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 803, "func": "compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_fw_xfer32 kfw32;\n\tstruct mpt_fw_xfer kfw;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\n\tif (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))\n\t\treturn -EFAULT;\n\n\t/* Verify intended MPT adapter */\n\tiocnumX = kfw32.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mptfwxfer_ioctl @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mptfwxfer_ioctl() called\\n\",\n\t iocp->name));\n\tkfw.iocnum = iocnum;\n\tkfw.fwlen = kfw32.fwlen;\n\tkfw.bufp = compat_ptr(kfw32.bufp);\n\n\tret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 803, "func": "compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_fw_xfer32 kfw32;\n\tstruct mpt_fw_xfer kfw;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\n\tif (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))\n\t\treturn -EFAULT;\n\n\t/* Verify intended MPT adapter */\n\tiocnumX = kfw32.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mptfwxfer_ioctl @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mptfwxfer_ioctl() called\\n\",\n\t iocp->name));\n\tkfw.iocnum = iocnum;\n\tkfw.fwlen = kfw32.fwlen;\n\tkfw.bufp = compat_ptr(kfw32.bufp);\n\n\tret = mptctl_do_fw_download(iocp, kfw.bufp, kfw.fwlen);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 1970, "func": "static int cdxl_decode_frame(AVCodecContext *avctx, void *data,\n int *got_frame, AVPacket *pkt)\n{\n CDXLVideoContext *c = avctx->priv_data;\n AVFrame * const p = data;\n int ret, w, h, encoding, aligned_width, buf_size = pkt->size;\n const uint8_t *buf = pkt->data;\n\n if (buf_size < 32)\n return AVERROR_INVALIDDATA;\n encoding = buf[1] & 7;\n c->format = buf[1] & 0xE0;\n w = AV_RB16(&buf[14]);\n h = AV_RB16(&buf[16]);\n c->bpp = buf[19];\n c->palette_size = AV_RB16(&buf[20]);\n c->palette = buf + 32;\n c->video = c->palette + c->palette_size;\n c->video_size = buf_size - c->palette_size - 32;\n\n if (c->palette_size > 512)\n return AVERROR_INVALIDDATA;\n if (buf_size < c->palette_size + 32)\n return AVERROR_INVALIDDATA;\n if (c->bpp < 1)\n return AVERROR_INVALIDDATA;\n if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) {\n avpriv_request_sample(avctx, \"Pixel format 0x%0x\", c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_set_dimensions(avctx, w, h)) < 0)\n return ret;\n\n if (c->format == CHUNKY)\n aligned_width = avctx->width;\n else\n aligned_width = FFALIGN(c->avctx->width, 16);\n c->padded_bits = aligned_width - c->avctx->width;\n if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp / 8)\n return AVERROR_INVALIDDATA;\n if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) {\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) {\n if (c->palette_size != (1 << (c->bpp - 1)))\n return AVERROR_INVALIDDATA;\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n } else if (!encoding && c->bpp == 24 && c->format == CHUNKY &&\n !c->palette_size) {\n avctx->pix_fmt = AV_PIX_FMT_RGB24;\n } else {\n avpriv_request_sample(avctx, \"Encoding %d, bpp %d and format 0x%x\",\n encoding, c->bpp, c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_get_buffer(avctx, p, 0)) < 0)\n return ret;\n p->pict_type = AV_PICTURE_TYPE_I;\n\n if (encoding) {\n av_fast_padded_malloc(&c->new_video, &c->new_video_size,\n h * w + AV_INPUT_BUFFER_PADDING_SIZE);\n if (!c->new_video)\n return AVERROR(ENOMEM);\n if (c->bpp == 8)\n cdxl_decode_ham8(c, p);\n else\n cdxl_decode_ham6(c, p);\n } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {\n cdxl_decode_rgb(c, p);\n } else {\n cdxl_decode_raw(c, p);\n }\n *got_frame = 1;\n\n return buf_size;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9996", "cwe_id": "CWE-119" }, { "id": 1970, "func": "static int cdxl_decode_frame(AVCodecContext *avctx, void *data,\n int *got_frame, AVPacket *pkt)\n{\n CDXLVideoContext *c = avctx->priv_data;\n AVFrame * const p = data;\n int ret, w, h, encoding, aligned_width, buf_size = pkt->size;\n const uint8_t *buf = pkt->data;\n\n if (buf_size < 32)\n return AVERROR_INVALIDDATA;\n encoding = buf[1] & 7;\n c->format = buf[1] & 0xE0;\n w = AV_RB16(&buf[14]);\n h = AV_RB16(&buf[16]);\n c->bpp = buf[19];\n c->palette_size = AV_RB16(&buf[20]);\n c->palette = buf + 32;\n c->video = c->palette + c->palette_size;\n c->video_size = buf_size - c->palette_size - 32;\n\n if (c->palette_size > 512)\n return AVERROR_INVALIDDATA;\n if (buf_size < c->palette_size + 32)\n return AVERROR_INVALIDDATA;\n if (c->bpp < 1)\n return AVERROR_INVALIDDATA;\n if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) {\n avpriv_request_sample(avctx, \"Pixel format 0x%0x\", c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_set_dimensions(avctx, w, h)) < 0)\n return ret;\n\n if (c->format == CHUNKY)\n aligned_width = avctx->width;\n else\n aligned_width = FFALIGN(c->avctx->width, 16);\n c->padded_bits = aligned_width - c->avctx->width;\n if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp / 8)\n return AVERROR_INVALIDDATA;\n if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) {\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8) && c->format != CHUNKY) {\n if (c->palette_size != (1 << (c->bpp - 1)))\n return AVERROR_INVALIDDATA;\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n } else if (!encoding && c->bpp == 24 && c->format == CHUNKY &&\n !c->palette_size) {\n avctx->pix_fmt = AV_PIX_FMT_RGB24;\n } else {\n avpriv_request_sample(avctx, \"Encoding %d, bpp %d and format 0x%x\",\n encoding, c->bpp, c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_get_buffer(avctx, p, 0)) < 0)\n return ret;\n p->pict_type = AV_PICTURE_TYPE_I;\n\n if (encoding) {\n av_fast_padded_malloc(&c->new_video, &c->new_video_size,\n h * w + AV_INPUT_BUFFER_PADDING_SIZE);\n if (!c->new_video)\n return AVERROR(ENOMEM);\n if (c->bpp == 8)\n cdxl_decode_ham8(c, p);\n else\n cdxl_decode_ham6(c, p);\n } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {\n cdxl_decode_rgb(c, p);\n } else {\n cdxl_decode_raw(c, p);\n }\n *got_frame = 1;\n\n return buf_size;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9996", "cwe_id": "CWE-119" }, { "id": 1834, "func": "error_t httpParseRequestLine(HttpConnection *connection, char_t *requestLine)\n{\n error_t error;\n char_t *token;\n char_t *p;\n char_t *s;\n\n //The Request-Line begins with a method token\n token = osStrtok_r(requestLine, \" \\r\\n\", &p);\n //Unable to retrieve the method?\n if(token == NULL)\n return ERROR_INVALID_REQUEST;\n\n //The Method token indicates the method to be performed on the\n //resource identified by the Request-URI\n error = strSafeCopy(connection->request.method, token, HTTP_SERVER_METHOD_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //The Request-URI is following the method token\n token = osStrtok_r(NULL, \" \\r\\n\", &p);\n //Unable to retrieve the Request-URI?\n if(token == NULL)\n return ERROR_INVALID_REQUEST;\n\n //Check whether a query string is present\n s = strchr(token, '?');\n\n //Query string found?\n if(s != NULL)\n {\n //Split the string\n *s = '\\0';\n\n //Save the Request-URI\n error = httpDecodePercentEncodedString(token,\n connection->request.uri, HTTP_SERVER_URI_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //Check the length of the query string\n if(osStrlen(s + 1) > HTTP_SERVER_QUERY_STRING_MAX_LEN)\n return ERROR_INVALID_REQUEST;\n\n //Save the query string\n osStrcpy(connection->request.queryString, s + 1);\n }\n else\n {\n //Save the Request-URI\n error = httpDecodePercentEncodedString(token,\n connection->request.uri, HTTP_SERVER_URI_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //No query string\n connection->request.queryString[0] = '\\0';\n }\n\n //Redirect to the default home page if necessary\n if(!osStrcasecmp(connection->request.uri, \"/\"))\n osStrcpy(connection->request.uri, connection->settings->defaultDocument);\n\n //Clean the resulting path\n pathCanonicalize(connection->request.uri);\n\n //The protocol version is following the Request-URI\n token = osStrtok_r(NULL, \" \\r\\n\", &p);\n\n //HTTP version 0.9?\n if(token == NULL)\n {\n //Save version number\n connection->request.version = HTTP_VERSION_0_9;\n //Persistent connections are not supported\n connection->request.keepAlive = FALSE;\n }\n //HTTP version 1.0?\n else if(!osStrcasecmp(token, \"HTTP/1.0\"))\n {\n //Save version number\n connection->request.version = HTTP_VERSION_1_0;\n //By default connections are not persistent\n connection->request.keepAlive = FALSE;\n }\n //HTTP version 1.1?\n else if(!osStrcasecmp(token, \"HTTP/1.1\"))\n {\n //Save version number\n connection->request.version = HTTP_VERSION_1_1;\n //HTTP 1.1 makes persistent connections the default\n connection->request.keepAlive = TRUE;\n }\n //HTTP version not supported?\n else\n {\n //Report an error\n return ERROR_INVALID_REQUEST;\n }\n\n //Successful processing\n return NO_ERROR;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1834, "func": "error_t httpParseRequestLine(HttpConnection *connection, char_t *requestLine)\n{\n error_t error;\n char_t *token;\n char_t *p;\n char_t *s;\n\n //The Request-Line begins with a method token\n token = osStrtok_r(requestLine, \" \\r\\n\", &p);\n //Unable to retrieve the method?\n if(token == NULL)\n return ERROR_INVALID_REQUEST;\n\n //The Method token indicates the method to be performed on the\n //resource identified by the Request-URI\n error = strSafeCopy(connection->request.method, token, HTTP_SERVER_METHOD_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //The Request-URI is following the method token\n token = osStrtok_r(NULL, \" \\r\\n\", &p);\n //Unable to retrieve the Request-URI?\n if(token == NULL)\n return ERROR_INVALID_REQUEST;\n\n //Check whether a query string is present\n s = osStrchr(token, '?');\n\n //Query string found?\n if(s != NULL)\n {\n //Split the string\n *s = '\\0';\n\n //Save the Request-URI\n error = httpDecodePercentEncodedString(token,\n connection->request.uri, HTTP_SERVER_URI_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //Check the length of the query string\n if(osStrlen(s + 1) > HTTP_SERVER_QUERY_STRING_MAX_LEN)\n return ERROR_INVALID_REQUEST;\n\n //Save the query string\n osStrcpy(connection->request.queryString, s + 1);\n }\n else\n {\n //Save the Request-URI\n error = httpDecodePercentEncodedString(token,\n connection->request.uri, HTTP_SERVER_URI_MAX_LEN);\n //Any error to report?\n if(error)\n return ERROR_INVALID_REQUEST;\n\n //No query string\n connection->request.queryString[0] = '\\0';\n }\n\n //Redirect to the default home page if necessary\n if(!osStrcasecmp(connection->request.uri, \"/\"))\n osStrcpy(connection->request.uri, connection->settings->defaultDocument);\n\n //Clean the resulting path\n pathCanonicalize(connection->request.uri);\n\n //The protocol version is following the Request-URI\n token = osStrtok_r(NULL, \" \\r\\n\", &p);\n\n //HTTP version 0.9?\n if(token == NULL)\n {\n //Save version number\n connection->request.version = HTTP_VERSION_0_9;\n //Persistent connections are not supported\n connection->request.keepAlive = FALSE;\n }\n //HTTP version 1.0?\n else if(!osStrcasecmp(token, \"HTTP/1.0\"))\n {\n //Save version number\n connection->request.version = HTTP_VERSION_1_0;\n //By default connections are not persistent\n connection->request.keepAlive = FALSE;\n }\n //HTTP version 1.1?\n else if(!osStrcasecmp(token, \"HTTP/1.1\"))\n {\n //Save version number\n connection->request.version = HTTP_VERSION_1_1;\n //HTTP 1.1 makes persistent connections the default\n connection->request.keepAlive = TRUE;\n }\n //HTTP version not supported?\n else\n {\n //Report an error\n return ERROR_INVALID_REQUEST;\n }\n\n //Successful processing\n return NO_ERROR;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1012, "func": "void MSG_WriteBits( msg_t *msg, int value, int bits ) {\n\tint\ti;\n\n\toldsize += bits;\n\n\t// this isn't an exact overflow check, but close enough\n\tif ( msg->maxsize - msg->cursize < 4 ) {\n\t\tmsg->overflowed = qtrue;\n\t\treturn;\n\t}\n\n\tif ( bits == 0 || bits < -31 || bits > 32 ) {\n\t\tCom_Error( ERR_DROP, \"MSG_WriteBits: bad bits %i\", bits );\n\t}\n\n\tif ( bits < 0 ) {\n\t\tbits = -bits;\n\t}\n\n\tif ( msg->oob ) {\n\t\tif ( bits == 8 ) {\n\t\t\tmsg->data[msg->cursize] = value;\n\t\t\tmsg->cursize += 1;\n\t\t\tmsg->bit += 8;\n\t\t} else if ( bits == 16 ) {\n\t\t\tshort temp = value;\n\n\t\t\tCopyLittleShort( &msg->data[msg->cursize], &temp );\n\t\t\tmsg->cursize += 2;\n\t\t\tmsg->bit += 16;\n\t\t} else if ( bits==32 ) {\n\t\t\tCopyLittleLong( &msg->data[msg->cursize], &value );\n\t\t\tmsg->cursize += 4;\n\t\t\tmsg->bit += 32;\n\t\t} else {\n\t\t\tCom_Error( ERR_DROP, \"can't write %d bits\", bits );\n\t\t}\n\t} else {\n\t\tvalue &= (0xffffffff >> (32 - bits));\n\t\tif ( bits&7 ) {\n\t\t\tint nbits;\n\t\t\tnbits = bits&7;\n\t\t\tfor( i = 0; i < nbits; i++ ) {\n\t\t\t\tHuff_putBit( (value & 1), msg->data, &msg->bit );\n\t\t\t\tvalue = (value >> 1);\n\t\t\t}\n\t\t\tbits = bits - nbits;\n\t\t}\n\t\tif ( bits ) {\n\t\t\tfor( i = 0; i < bits; i += 8 ) {\n\t\t\t\tHuff_offsetTransmit( &msgHuff.compressor, (value & 0xff), msg->data, &msg->bit );\n\t\t\t\tvalue = (value >> 8);\n\t\t\t}\n\t\t}\n\t\tmsg->cursize = (msg->bit >> 3) + 1;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-11721", "cwe_id": "CWE-119" }, { "id": 1012, "func": "void MSG_WriteBits( msg_t *msg, int value, int bits ) {\n\tint\ti;\n\n\toldsize += bits;\n\n\tif ( msg->overflowed ) {\n\t\treturn;\n\t}\n\n\tif ( bits == 0 || bits < -31 || bits > 32 ) {\n\t\tCom_Error( ERR_DROP, \"MSG_WriteBits: bad bits %i\", bits );\n\t}\n\n\tif ( bits < 0 ) {\n\t\tbits = -bits;\n\t}\n\n\tif ( msg->oob ) {\n\t\tif ( msg->cursize + ( bits >> 3 ) > msg->maxsize ) {\n\t\t\tmsg->overflowed = qtrue;\n\t\t\treturn;\n\t\t}\n\n\t\tif ( bits == 8 ) {\n\t\t\tmsg->data[msg->cursize] = value;\n\t\t\tmsg->cursize += 1;\n\t\t\tmsg->bit += 8;\n\t\t} else if ( bits == 16 ) {\n\t\t\tshort temp = value;\n\n\t\t\tCopyLittleShort( &msg->data[msg->cursize], &temp );\n\t\t\tmsg->cursize += 2;\n\t\t\tmsg->bit += 16;\n\t\t} else if ( bits==32 ) {\n\t\t\tCopyLittleLong( &msg->data[msg->cursize], &value );\n\t\t\tmsg->cursize += 4;\n\t\t\tmsg->bit += 32;\n\t\t} else {\n\t\t\tCom_Error( ERR_DROP, \"can't write %d bits\", bits );\n\t\t}\n\t} else {\n\t\tvalue &= (0xffffffff >> (32 - bits));\n\t\tif ( bits&7 ) {\n\t\t\tint nbits;\n\t\t\tnbits = bits&7;\n\t\t\tif ( msg->bit + nbits > msg->maxsize << 3 ) {\n\t\t\t\tmsg->overflowed = qtrue;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor( i = 0; i < nbits; i++ ) {\n\t\t\t\tHuff_putBit( (value & 1), msg->data, &msg->bit );\n\t\t\t\tvalue = (value >> 1);\n\t\t\t}\n\t\t\tbits = bits - nbits;\n\t\t}\n\t\tif ( bits ) {\n\t\t\tfor( i = 0; i < bits; i += 8 ) {\n\t\t\t\tHuff_offsetTransmit( &msgHuff.compressor, (value & 0xff), msg->data, &msg->bit, msg->maxsize << 3 );\n\t\t\t\tvalue = (value >> 8);\n\n\t\t\t\tif ( msg->bit > msg->maxsize << 3 ) {\n\t\t\t\t\tmsg->overflowed = qtrue;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmsg->cursize = (msg->bit >> 3) + 1;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-11721", "cwe_id": "CWE-119" }, { "id": 2017, "func": "TfLiteStatus ResizeOutputTensors(TfLiteContext* context, TfLiteNode* node,\n const TfLiteTensor* input,\n const TfLiteTensor* size_splits,\n const TfLiteTensor* axis) {\n int axis_value = GetTensorData(axis)[0];\n if (axis_value < 0) {\n axis_value += NumDimensions(input);\n }\n\n std::vector size_splits_vector;\n if (size_splits->type == kTfLiteInt32) {\n GetSizeSplitsVector(size_splits, &size_splits_vector);\n } else if (size_splits->type == kTfLiteInt64) {\n GetSizeSplitsVector(size_splits, &size_splits_vector);\n } else {\n context->ReportError(context, \"size_splits only support type int32|int64.\");\n return kTfLiteError;\n }\n\n int minus_one_index = -1;\n int64_t size_splits_sum = 0;\n\n for (int i = 0; i < size_splits_vector.size(); ++i) {\n if (size_splits_vector.at(i) == -1) {\n if (minus_one_index == -1) {\n minus_one_index = i;\n } else {\n context->ReportError(context,\n \"The size_splits contains more than one -1.\");\n }\n } else {\n size_splits_sum += size_splits_vector.at(i);\n }\n }\n\n const int input_size = SizeOfDimension(input, axis_value);\n\n if (minus_one_index != -1) {\n if (size_splits_sum > input_size) {\n context->ReportError(\n context,\n \"The sum of size_splits must be less than the dimension of value.\");\n } else {\n size_splits_vector[minus_one_index] = input_size - size_splits_sum;\n }\n } else if (size_splits_sum != input_size) {\n context->ReportError(\n context,\n \"The size_splits must sum to the dimension of value along axis.\");\n }\n\n for (int i = 0; i < NumOutputs(node); ++i) {\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output_dims->data[axis_value] = size_splits_vector.at(i);\n TfLiteTensor* output = GetOutput(context, node, i);\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_dims));\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2017, "func": "TfLiteStatus ResizeOutputTensors(TfLiteContext* context, TfLiteNode* node,\n const TfLiteTensor* input,\n const TfLiteTensor* size_splits,\n const TfLiteTensor* axis) {\n int axis_value = GetTensorData(axis)[0];\n if (axis_value < 0) {\n axis_value += NumDimensions(input);\n }\n\n std::vector size_splits_vector;\n if (size_splits->type == kTfLiteInt32) {\n GetSizeSplitsVector(size_splits, &size_splits_vector);\n } else if (size_splits->type == kTfLiteInt64) {\n GetSizeSplitsVector(size_splits, &size_splits_vector);\n } else {\n context->ReportError(context, \"size_splits only support type int32|int64.\");\n return kTfLiteError;\n }\n\n int minus_one_index = -1;\n int64_t size_splits_sum = 0;\n\n for (int i = 0; i < size_splits_vector.size(); ++i) {\n if (size_splits_vector.at(i) == -1) {\n if (minus_one_index == -1) {\n minus_one_index = i;\n } else {\n context->ReportError(context,\n \"The size_splits contains more than one -1.\");\n }\n } else {\n size_splits_sum += size_splits_vector.at(i);\n }\n }\n\n const int input_size = SizeOfDimension(input, axis_value);\n\n if (minus_one_index != -1) {\n if (size_splits_sum > input_size) {\n context->ReportError(\n context,\n \"The sum of size_splits must be less than the dimension of value.\");\n } else {\n size_splits_vector[minus_one_index] = input_size - size_splits_sum;\n }\n } else if (size_splits_sum != input_size) {\n context->ReportError(\n context,\n \"The size_splits must sum to the dimension of value along axis.\");\n }\n\n for (int i = 0; i < NumOutputs(node); ++i) {\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output_dims->data[axis_value] = size_splits_vector.at(i);\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, i, &output));\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_dims));\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2847, "func": "static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,\n AVFormatContext *fmt_ctx)\n{\n AVBPrint pbuf;\n char val_str[128];\n const char *s;\n int i;\n\n av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);\n\n writer_print_section_header(w, SECTION_ID_FRAME);\n\n s = av_get_media_type_string(stream->codecpar->codec_type);\n if (s) print_str (\"media_type\", s);\n else print_str_opt(\"media_type\", \"unknown\");\n print_int(\"stream_index\", stream->index);\n print_int(\"key_frame\", frame->key_frame);\n print_ts (\"pkt_pts\", frame->pts);\n print_time(\"pkt_pts_time\", frame->pts, &stream->time_base);\n print_ts (\"pkt_dts\", frame->pkt_dts);\n print_time(\"pkt_dts_time\", frame->pkt_dts, &stream->time_base);\n print_ts (\"best_effort_timestamp\", frame->best_effort_timestamp);\n print_time(\"best_effort_timestamp_time\", frame->best_effort_timestamp, &stream->time_base);\n print_duration_ts (\"pkt_duration\", frame->pkt_duration);\n print_duration_time(\"pkt_duration_time\", frame->pkt_duration, &stream->time_base);\n if (frame->pkt_pos != -1) print_fmt (\"pkt_pos\", \"%\"PRId64, frame->pkt_pos);\n else print_str_opt(\"pkt_pos\", \"N/A\");\n if (frame->pkt_size != -1) print_val (\"pkt_size\", frame->pkt_size, unit_byte_str);\n else print_str_opt(\"pkt_size\", \"N/A\");\n\n switch (stream->codecpar->codec_type) {\n AVRational sar;\n\n case AVMEDIA_TYPE_VIDEO:\n print_int(\"width\", frame->width);\n print_int(\"height\", frame->height);\n s = av_get_pix_fmt_name(frame->format);\n if (s) print_str (\"pix_fmt\", s);\n else print_str_opt(\"pix_fmt\", \"unknown\");\n sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);\n if (sar.num) {\n print_q(\"sample_aspect_ratio\", sar, ':');\n } else {\n print_str_opt(\"sample_aspect_ratio\", \"N/A\");\n }\n print_fmt(\"pict_type\", \"%c\", av_get_picture_type_char(frame->pict_type));\n print_int(\"coded_picture_number\", frame->coded_picture_number);\n print_int(\"display_picture_number\", frame->display_picture_number);\n print_int(\"interlaced_frame\", frame->interlaced_frame);\n print_int(\"top_field_first\", frame->top_field_first);\n print_int(\"repeat_pict\", frame->repeat_pict);\n\n if (frame->color_range != AVCOL_RANGE_UNSPECIFIED)\n print_str(\"color_range\", av_color_range_name(frame->color_range));\n else\n print_str_opt(\"color_range\", av_color_range_name(frame->color_range));\n\n if (frame->colorspace != AVCOL_SPC_UNSPECIFIED)\n print_str(\"color_space\", av_color_space_name(frame->colorspace));\n else\n print_str_opt(\"color_space\", av_color_space_name(frame->colorspace));\n\n if (frame->color_primaries != AVCOL_PRI_UNSPECIFIED)\n print_str(\"color_primaries\", av_color_primaries_name(frame->color_primaries));\n else\n print_str_opt(\"color_primaries\", av_color_primaries_name(frame->color_primaries));\n\n if (frame->color_trc != AVCOL_TRC_UNSPECIFIED)\n print_str(\"color_transfer\", av_color_transfer_name(frame->color_trc));\n else\n print_str_opt(\"color_transfer\", av_color_transfer_name(frame->color_trc));\n\n if (frame->chroma_location != AVCHROMA_LOC_UNSPECIFIED)\n print_str(\"chroma_location\", av_chroma_location_name(frame->chroma_location));\n else\n print_str_opt(\"chroma_location\", av_chroma_location_name(frame->chroma_location));\n break;\n\n case AVMEDIA_TYPE_AUDIO:\n s = av_get_sample_fmt_name(frame->format);\n if (s) print_str (\"sample_fmt\", s);\n else print_str_opt(\"sample_fmt\", \"unknown\");\n print_int(\"nb_samples\", frame->nb_samples);\n print_int(\"channels\", frame->channels);\n if (frame->channel_layout) {\n av_bprint_clear(&pbuf);\n av_bprint_channel_layout(&pbuf, frame->channels,\n frame->channel_layout);\n print_str (\"channel_layout\", pbuf.str);\n } else\n print_str_opt(\"channel_layout\", \"unknown\");\n break;\n }\n if (do_show_frame_tags)\n show_tags(w, frame->metadata, SECTION_ID_FRAME_TAGS);\n if (do_show_log)\n show_log(w, SECTION_ID_FRAME_LOGS, SECTION_ID_FRAME_LOG, do_show_log);\n if (frame->nb_side_data) {\n writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_LIST);\n for (i = 0; i < frame->nb_side_data; i++) {\n AVFrameSideData *sd = frame->side_data[i];\n const char *name;\n\n writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA);\n name = av_frame_side_data_name(sd->type);\n print_str(\"side_data_type\", name ? name : \"unknown\");\n if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {\n writer_print_integers(w, \"displaymatrix\", sd->data, 9, \" %11d\", 3, 4, 1);\n print_int(\"rotation\", av_display_rotation_get((int32_t *)sd->data));\n } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {\n char tcbuf[AV_TIMECODE_STR_SIZE];\n av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));\n print_str(\"timecode\", tcbuf);\n } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {\n AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;\n\n if (metadata->has_primaries) {\n print_q(\"red_x\", metadata->display_primaries[0][0], '/');\n print_q(\"red_y\", metadata->display_primaries[0][1], '/');\n print_q(\"green_x\", metadata->display_primaries[1][0], '/');\n print_q(\"green_y\", metadata->display_primaries[1][1], '/');\n print_q(\"blue_x\", metadata->display_primaries[2][0], '/');\n print_q(\"blue_y\", metadata->display_primaries[2][1], '/');\n\n print_q(\"white_point_x\", metadata->white_point[0], '/');\n print_q(\"white_point_y\", metadata->white_point[1], '/');\n }\n\n if (metadata->has_luminance) {\n print_q(\"min_luminance\", metadata->min_luminance, '/');\n print_q(\"max_luminance\", metadata->max_luminance, '/');\n }\n } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {\n AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;\n print_int(\"max_content\", metadata->MaxCLL);\n print_int(\"max_average\", metadata->MaxFALL);\n } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {\n AVDictionaryEntry *tag = av_dict_get(sd->metadata, \"name\", NULL, AV_DICT_MATCH_CASE);\n if (tag)\n print_str(tag->key, tag->value);\n print_int(\"size\", sd->size);\n }\n writer_print_section_footer(w);\n }\n writer_print_section_footer(w);\n }\n\n writer_print_section_footer(w);\n\n av_bprint_finalize(&pbuf, NULL);\n fflush(stdout);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14225", "cwe_id": "CWE-476" }, { "id": 2847, "func": "static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,\n AVFormatContext *fmt_ctx)\n{\n AVBPrint pbuf;\n char val_str[128];\n const char *s;\n int i;\n\n av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);\n\n writer_print_section_header(w, SECTION_ID_FRAME);\n\n s = av_get_media_type_string(stream->codecpar->codec_type);\n if (s) print_str (\"media_type\", s);\n else print_str_opt(\"media_type\", \"unknown\");\n print_int(\"stream_index\", stream->index);\n print_int(\"key_frame\", frame->key_frame);\n print_ts (\"pkt_pts\", frame->pts);\n print_time(\"pkt_pts_time\", frame->pts, &stream->time_base);\n print_ts (\"pkt_dts\", frame->pkt_dts);\n print_time(\"pkt_dts_time\", frame->pkt_dts, &stream->time_base);\n print_ts (\"best_effort_timestamp\", frame->best_effort_timestamp);\n print_time(\"best_effort_timestamp_time\", frame->best_effort_timestamp, &stream->time_base);\n print_duration_ts (\"pkt_duration\", frame->pkt_duration);\n print_duration_time(\"pkt_duration_time\", frame->pkt_duration, &stream->time_base);\n if (frame->pkt_pos != -1) print_fmt (\"pkt_pos\", \"%\"PRId64, frame->pkt_pos);\n else print_str_opt(\"pkt_pos\", \"N/A\");\n if (frame->pkt_size != -1) print_val (\"pkt_size\", frame->pkt_size, unit_byte_str);\n else print_str_opt(\"pkt_size\", \"N/A\");\n\n switch (stream->codecpar->codec_type) {\n AVRational sar;\n\n case AVMEDIA_TYPE_VIDEO:\n print_int(\"width\", frame->width);\n print_int(\"height\", frame->height);\n s = av_get_pix_fmt_name(frame->format);\n if (s) print_str (\"pix_fmt\", s);\n else print_str_opt(\"pix_fmt\", \"unknown\");\n sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);\n if (sar.num) {\n print_q(\"sample_aspect_ratio\", sar, ':');\n } else {\n print_str_opt(\"sample_aspect_ratio\", \"N/A\");\n }\n print_fmt(\"pict_type\", \"%c\", av_get_picture_type_char(frame->pict_type));\n print_int(\"coded_picture_number\", frame->coded_picture_number);\n print_int(\"display_picture_number\", frame->display_picture_number);\n print_int(\"interlaced_frame\", frame->interlaced_frame);\n print_int(\"top_field_first\", frame->top_field_first);\n print_int(\"repeat_pict\", frame->repeat_pict);\n\n if (frame->color_range != AVCOL_RANGE_UNSPECIFIED)\n print_str(\"color_range\", av_color_range_name(frame->color_range));\n else\n print_str_opt(\"color_range\", av_color_range_name(frame->color_range));\n\n if (frame->colorspace != AVCOL_SPC_UNSPECIFIED)\n print_str(\"color_space\", av_color_space_name(frame->colorspace));\n else\n print_str_opt(\"color_space\", av_color_space_name(frame->colorspace));\n\n print_primaries(w, frame->color_primaries);\n\n if (frame->color_trc != AVCOL_TRC_UNSPECIFIED)\n print_str(\"color_transfer\", av_color_transfer_name(frame->color_trc));\n else\n print_str_opt(\"color_transfer\", av_color_transfer_name(frame->color_trc));\n\n if (frame->chroma_location != AVCHROMA_LOC_UNSPECIFIED)\n print_str(\"chroma_location\", av_chroma_location_name(frame->chroma_location));\n else\n print_str_opt(\"chroma_location\", av_chroma_location_name(frame->chroma_location));\n break;\n\n case AVMEDIA_TYPE_AUDIO:\n s = av_get_sample_fmt_name(frame->format);\n if (s) print_str (\"sample_fmt\", s);\n else print_str_opt(\"sample_fmt\", \"unknown\");\n print_int(\"nb_samples\", frame->nb_samples);\n print_int(\"channels\", frame->channels);\n if (frame->channel_layout) {\n av_bprint_clear(&pbuf);\n av_bprint_channel_layout(&pbuf, frame->channels,\n frame->channel_layout);\n print_str (\"channel_layout\", pbuf.str);\n } else\n print_str_opt(\"channel_layout\", \"unknown\");\n break;\n }\n if (do_show_frame_tags)\n show_tags(w, frame->metadata, SECTION_ID_FRAME_TAGS);\n if (do_show_log)\n show_log(w, SECTION_ID_FRAME_LOGS, SECTION_ID_FRAME_LOG, do_show_log);\n if (frame->nb_side_data) {\n writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_LIST);\n for (i = 0; i < frame->nb_side_data; i++) {\n AVFrameSideData *sd = frame->side_data[i];\n const char *name;\n\n writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA);\n name = av_frame_side_data_name(sd->type);\n print_str(\"side_data_type\", name ? name : \"unknown\");\n if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {\n writer_print_integers(w, \"displaymatrix\", sd->data, 9, \" %11d\", 3, 4, 1);\n print_int(\"rotation\", av_display_rotation_get((int32_t *)sd->data));\n } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {\n char tcbuf[AV_TIMECODE_STR_SIZE];\n av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));\n print_str(\"timecode\", tcbuf);\n } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {\n AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;\n\n if (metadata->has_primaries) {\n print_q(\"red_x\", metadata->display_primaries[0][0], '/');\n print_q(\"red_y\", metadata->display_primaries[0][1], '/');\n print_q(\"green_x\", metadata->display_primaries[1][0], '/');\n print_q(\"green_y\", metadata->display_primaries[1][1], '/');\n print_q(\"blue_x\", metadata->display_primaries[2][0], '/');\n print_q(\"blue_y\", metadata->display_primaries[2][1], '/');\n\n print_q(\"white_point_x\", metadata->white_point[0], '/');\n print_q(\"white_point_y\", metadata->white_point[1], '/');\n }\n\n if (metadata->has_luminance) {\n print_q(\"min_luminance\", metadata->min_luminance, '/');\n print_q(\"max_luminance\", metadata->max_luminance, '/');\n }\n } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {\n AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;\n print_int(\"max_content\", metadata->MaxCLL);\n print_int(\"max_average\", metadata->MaxFALL);\n } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {\n AVDictionaryEntry *tag = av_dict_get(sd->metadata, \"name\", NULL, AV_DICT_MATCH_CASE);\n if (tag)\n print_str(tag->key, tag->value);\n print_int(\"size\", sd->size);\n }\n writer_print_section_footer(w);\n }\n writer_print_section_footer(w);\n }\n\n writer_print_section_footer(w);\n\n av_bprint_finalize(&pbuf, NULL);\n fflush(stdout);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14225", "cwe_id": "CWE-476" }, { "id": 1245, "func": "static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)\n{\n\text3_fsblk_t\tsb_block;\n\tchar\t\t*options = (char *) *data;\n\n\tif (!options || strncmp(options, \"sb=\", 3) != 0)\n\t\treturn 1;\t/* Default location */\n\toptions += 3;\n\t/*todo: use simple_strtoll with >32bit ext3 */\n\tsb_block = simple_strtoul(options, &options, 0);\n\tif (*options && *options != ',') {\n\t\text3_msg(sb, \"error: invalid sb specification: %s\",\n\t\t (char *) *data);\n\t\treturn 1;\n\t}\n\tif (*options == ',')\n\t\toptions++;\n\t*data = (void *) options;\n\treturn sb_block;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-1848", "cwe_id": "CWE-20" }, { "id": 1245, "func": "static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)\n{\n\text3_fsblk_t\tsb_block;\n\tchar\t\t*options = (char *) *data;\n\n\tif (!options || strncmp(options, \"sb=\", 3) != 0)\n\t\treturn 1;\t/* Default location */\n\toptions += 3;\n\t/*todo: use simple_strtoll with >32bit ext3 */\n\tsb_block = simple_strtoul(options, &options, 0);\n\tif (*options && *options != ',') {\n\t\text3_msg(sb, KERN_ERR, \"error: invalid sb specification: %s\",\n\t\t (char *) *data);\n\t\treturn 1;\n\t}\n\tif (*options == ',')\n\t\toptions++;\n\t*data = (void *) options;\n\treturn sb_block;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-1848", "cwe_id": "CWE-20" }, { "id": 1267, "func": "mobility_print(netdissect_options *ndo,\n const u_char *bp, const u_char *bp2 _U_)\n{\n\tconst struct ip6_mobility *mh;\n\tconst u_char *ep;\n\tunsigned mhlen, hlen;\n\tuint8_t type;\n\n\tmh = (const struct ip6_mobility *)bp;\n\n\t/* 'ep' points to the end of available data. */\n\tep = ndo->ndo_snapend;\n\n\tif (!ND_TTEST(mh->ip6m_len)) {\n\t\t/*\n\t\t * There's not enough captured data to include the\n\t\t * mobility header length.\n\t\t *\n\t\t * Our caller expects us to return the length, however,\n\t\t * so return a value that will run to the end of the\n\t\t * captured data.\n\t\t *\n\t\t * XXX - \"ip6_print()\" doesn't do anything with the\n\t\t * returned length, however, as it breaks out of the\n\t\t * header-processing loop.\n\t\t */\n\t\tmhlen = ep - bp;\n\t\tgoto trunc;\n\t}\n\tmhlen = (mh->ip6m_len + 1) << 3;\n\n\t/* XXX ip6m_cksum */\n\n\tND_TCHECK(mh->ip6m_type);\n\ttype = mh->ip6m_type;\n\tif (type <= IP6M_MAX && mhlen < ip6m_hdrlen[type]) {\n\t\tND_PRINT((ndo, \"(header length %u is too small for type %u)\", mhlen, type));\n\t\tgoto trunc;\n\t}\n\tND_PRINT((ndo, \"mobility: %s\", tok2str(ip6m_str, \"type-#%u\", type)));\n\tswitch (type) {\n\tcase IP6M_BINDING_REQUEST:\n\t\thlen = IP6M_MINLEN;\n\t\tbreak;\n\tcase IP6M_HOME_TEST_INIT:\n\tcase IP6M_CAREOF_TEST_INIT:\n\t\thlen = IP6M_MINLEN;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Init Cookie=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST_INIT ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tbreak;\n\tcase IP6M_HOME_TEST:\n\tcase IP6M_CAREOF_TEST:\n\t\tND_TCHECK(mh->ip6m_data16[0]);\n\t\tND_PRINT((ndo, \" nonce id=0x%x\", EXTRACT_16BITS(&mh->ip6m_data16[0])));\n\t\thlen = IP6M_MINLEN;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Init Cookie=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Keygen Token=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tbreak;\n\tcase IP6M_BINDING_UPDATE:\n\t\tND_TCHECK(mh->ip6m_data16[0]);\n\t\tND_PRINT((ndo, \" seq#=%u\", EXTRACT_16BITS(&mh->ip6m_data16[0])));\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 1);\n\t\tif (bp[hlen] & 0xf0)\n\t\t\tND_PRINT((ndo, \" \"));\n\t\tif (bp[hlen] & 0x80)\n\t\t\tND_PRINT((ndo, \"A\"));\n\t\tif (bp[hlen] & 0x40)\n\t\t\tND_PRINT((ndo, \"H\"));\n\t\tif (bp[hlen] & 0x20)\n\t\t\tND_PRINT((ndo, \"L\"));\n\t\tif (bp[hlen] & 0x10)\n\t\t\tND_PRINT((ndo, \"K\"));\n\t\t/* Reserved (4bits) */\n\t\thlen += 1;\n\t\t/* Reserved (8bits) */\n\t\thlen += 1;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\t/* units of 4 secs */\n\t\tND_PRINT((ndo, \" lifetime=%u\", EXTRACT_16BITS(&bp[hlen]) << 2));\n\t\thlen += 2;\n\t\tbreak;\n\tcase IP6M_BINDING_ACK:\n\t\tND_TCHECK(mh->ip6m_data8[0]);\n\t\tND_PRINT((ndo, \" status=%u\", mh->ip6m_data8[0]));\n\t\tif (mh->ip6m_data8[1] & 0x80)\n\t\t\tND_PRINT((ndo, \" K\"));\n\t\t/* Reserved (7bits) */\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\tND_PRINT((ndo, \" seq#=%u\", EXTRACT_16BITS(&bp[hlen])));\n\t\thlen += 2;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\t/* units of 4 secs */\n\t\tND_PRINT((ndo, \" lifetime=%u\", EXTRACT_16BITS(&bp[hlen]) << 2));\n\t\thlen += 2;\n\t\tbreak;\n\tcase IP6M_BINDING_ERROR:\n\t\tND_TCHECK(mh->ip6m_data8[0]);\n\t\tND_PRINT((ndo, \" status=%u\", mh->ip6m_data8[0]));\n\t\t/* Reserved */\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 16);\n\t\tND_PRINT((ndo, \" homeaddr %s\", ip6addr_string(ndo, &bp[hlen])));\n\t\thlen += 16;\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \" len=%u\", mh->ip6m_len));\n\t\treturn(mhlen);\n\t\tbreak;\n\t}\n\tif (ndo->ndo_vflag)\n\t\tif (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))\n\t\t\tgoto trunc;\n\n\treturn(mhlen);\n\n trunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n\treturn(mhlen);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12985", "cwe_id": "CWE-125" }, { "id": 1267, "func": "mobility_print(netdissect_options *ndo,\n const u_char *bp, const u_char *bp2 _U_)\n{\n\tconst struct ip6_mobility *mh;\n\tconst u_char *ep;\n\tunsigned mhlen, hlen;\n\tuint8_t type;\n\n\tmh = (const struct ip6_mobility *)bp;\n\n\t/* 'ep' points to the end of available data. */\n\tep = ndo->ndo_snapend;\n\n\tif (!ND_TTEST(mh->ip6m_len)) {\n\t\t/*\n\t\t * There's not enough captured data to include the\n\t\t * mobility header length.\n\t\t *\n\t\t * Our caller expects us to return the length, however,\n\t\t * so return a value that will run to the end of the\n\t\t * captured data.\n\t\t *\n\t\t * XXX - \"ip6_print()\" doesn't do anything with the\n\t\t * returned length, however, as it breaks out of the\n\t\t * header-processing loop.\n\t\t */\n\t\tmhlen = ep - bp;\n\t\tgoto trunc;\n\t}\n\tmhlen = (mh->ip6m_len + 1) << 3;\n\n\t/* XXX ip6m_cksum */\n\n\tND_TCHECK(mh->ip6m_type);\n\ttype = mh->ip6m_type;\n\tif (type <= IP6M_MAX && mhlen < ip6m_hdrlen[type]) {\n\t\tND_PRINT((ndo, \"(header length %u is too small for type %u)\", mhlen, type));\n\t\tgoto trunc;\n\t}\n\tND_PRINT((ndo, \"mobility: %s\", tok2str(ip6m_str, \"type-#%u\", type)));\n\tswitch (type) {\n\tcase IP6M_BINDING_REQUEST:\n\t\thlen = IP6M_MINLEN;\n\t\tbreak;\n\tcase IP6M_HOME_TEST_INIT:\n\tcase IP6M_CAREOF_TEST_INIT:\n\t\thlen = IP6M_MINLEN;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Init Cookie=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST_INIT ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tbreak;\n\tcase IP6M_HOME_TEST:\n\tcase IP6M_CAREOF_TEST:\n\t\tND_TCHECK(mh->ip6m_data16[0]);\n\t\tND_PRINT((ndo, \" nonce id=0x%x\", EXTRACT_16BITS(&mh->ip6m_data16[0])));\n\t\thlen = IP6M_MINLEN;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Init Cookie=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tif (ndo->ndo_vflag) {\n\t\t\tND_TCHECK2(*mh, hlen + 8);\n\t\t\tND_PRINT((ndo, \" %s Keygen Token=%08x:%08x\",\n\t\t\t type == IP6M_HOME_TEST ? \"Home\" : \"Care-of\",\n\t\t\t EXTRACT_32BITS(&bp[hlen]),\n\t\t\t EXTRACT_32BITS(&bp[hlen + 4])));\n\t\t}\n\t\thlen += 8;\n\t\tbreak;\n\tcase IP6M_BINDING_UPDATE:\n\t\tND_TCHECK(mh->ip6m_data16[0]);\n\t\tND_PRINT((ndo, \" seq#=%u\", EXTRACT_16BITS(&mh->ip6m_data16[0])));\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 1);\n\t\tif (bp[hlen] & 0xf0)\n\t\t\tND_PRINT((ndo, \" \"));\n\t\tif (bp[hlen] & 0x80)\n\t\t\tND_PRINT((ndo, \"A\"));\n\t\tif (bp[hlen] & 0x40)\n\t\t\tND_PRINT((ndo, \"H\"));\n\t\tif (bp[hlen] & 0x20)\n\t\t\tND_PRINT((ndo, \"L\"));\n\t\tif (bp[hlen] & 0x10)\n\t\t\tND_PRINT((ndo, \"K\"));\n\t\t/* Reserved (4bits) */\n\t\thlen += 1;\n\t\t/* Reserved (8bits) */\n\t\thlen += 1;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\t/* units of 4 secs */\n\t\tND_PRINT((ndo, \" lifetime=%u\", EXTRACT_16BITS(&bp[hlen]) << 2));\n\t\thlen += 2;\n\t\tbreak;\n\tcase IP6M_BINDING_ACK:\n\t\tND_TCHECK(mh->ip6m_data8[0]);\n\t\tND_PRINT((ndo, \" status=%u\", mh->ip6m_data8[0]));\n\t\tif (mh->ip6m_data8[1] & 0x80)\n\t\t\tND_PRINT((ndo, \" K\"));\n\t\t/* Reserved (7bits) */\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\tND_PRINT((ndo, \" seq#=%u\", EXTRACT_16BITS(&bp[hlen])));\n\t\thlen += 2;\n\t\tND_TCHECK2(*mh, hlen + 2);\n\t\t/* units of 4 secs */\n\t\tND_PRINT((ndo, \" lifetime=%u\", EXTRACT_16BITS(&bp[hlen]) << 2));\n\t\thlen += 2;\n\t\tbreak;\n\tcase IP6M_BINDING_ERROR:\n\t\tND_TCHECK(mh->ip6m_data8[0]);\n\t\tND_PRINT((ndo, \" status=%u\", mh->ip6m_data8[0]));\n\t\t/* Reserved */\n\t\thlen = IP6M_MINLEN;\n\t\tND_TCHECK2(*mh, hlen + 16);\n\t\tND_PRINT((ndo, \" homeaddr %s\", ip6addr_string(ndo, &bp[hlen])));\n\t\thlen += 16;\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \" len=%u\", mh->ip6m_len));\n\t\treturn(mhlen);\n\t\tbreak;\n\t}\n\tif (ndo->ndo_vflag)\n\t\tif (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))\n\t\t\tgoto trunc;\n\n\treturn(mhlen);\n\n trunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n\treturn(-1);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12985", "cwe_id": "CWE-125" }, { "id": 2653, "func": "void rdp_read_flow_control_pdu(wStream* s, UINT16* type)\n{\n\t/*\n\t * Read flow control PDU - documented in FlowPDU section in T.128\n\t * http://www.itu.int/rec/T-REC-T.128-199802-S/en\n\t * The specification for the PDU has pad8bits listed BEFORE pduTypeFlow.\n\t * However, so far pad8bits has always been observed to arrive AFTER pduTypeFlow.\n\t * Switched the order of these two fields to match this observation.\n\t */\n\tUINT8 pduType;\n\tStream_Read_UINT8(s, pduType); /* pduTypeFlow */\n\t*type = pduType;\n\tStream_Seek_UINT8(s); /* pad8bits */\n\tStream_Seek_UINT8(s); /* flowIdentifier */\n\tStream_Seek_UINT8(s); /* flowNumber */\n\tStream_Seek_UINT16(s); /* pduSource */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11048", "cwe_id": "CWE-125" }, { "id": 2653, "func": "BOOL rdp_read_flow_control_pdu(wStream* s, UINT16* type)\n{\n\t/*\n\t * Read flow control PDU - documented in FlowPDU section in T.128\n\t * http://www.itu.int/rec/T-REC-T.128-199802-S/en\n\t * The specification for the PDU has pad8bits listed BEFORE pduTypeFlow.\n\t * However, so far pad8bits has always been observed to arrive AFTER pduTypeFlow.\n\t * Switched the order of these two fields to match this observation.\n\t */\n\tUINT8 pduType;\n\tif (!type)\n\t\treturn FALSE;\n\tif (Stream_GetRemainingLength(s) < 6)\n\t\treturn FALSE;\n\tStream_Read_UINT8(s, pduType); /* pduTypeFlow */\n\t*type = pduType;\n\tStream_Seek_UINT8(s); /* pad8bits */\n\tStream_Seek_UINT8(s); /* flowIdentifier */\n\tStream_Seek_UINT8(s); /* flowNumber */\n\tStream_Seek_UINT16(s); /* pduSource */\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11048", "cwe_id": "CWE-125" }, { "id": 2068, "func": "void IGDstartelt(void * d, const char * name, int l)\n{\n\tstruct IGDdatas * datas = (struct IGDdatas *)d;\n\tmemcpy( datas->cureltname, name, l);\n\tdatas->cureltname[l] = '\\0';\n\tdatas->level++;\n\tif( (l==7) && !memcmp(name, \"service\", l) ) {\n\t\tdatas->tmp.controlurl[0] = '\\0';\n\t\tdatas->tmp.eventsuburl[0] = '\\0';\n\t\tdatas->tmp.scpdurl[0] = '\\0';\n\t\tdatas->tmp.servicetype[0] = '\\0';\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-6031", "cwe_id": "CWE-119" }, { "id": 2068, "func": "void IGDstartelt(void * d, const char * name, int l)\n{\n\tstruct IGDdatas * datas = (struct IGDdatas *)d;\n\tif(l >= MINIUPNPC_URL_MAXSIZE)\n\t\tl = MINIUPNPC_URL_MAXSIZE-1;\n\tmemcpy(datas->cureltname, name, l);\n\tdatas->cureltname[l] = '\\0';\n\tdatas->level++;\n\tif( (l==7) && !memcmp(name, \"service\", l) ) {\n\t\tdatas->tmp.controlurl[0] = '\\0';\n\t\tdatas->tmp.eventsuburl[0] = '\\0';\n\t\tdatas->tmp.scpdurl[0] = '\\0';\n\t\tdatas->tmp.servicetype[0] = '\\0';\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-6031", "cwe_id": "CWE-119" }, { "id": 2713, "func": "MONGO_EXPORT bson_type bson_iterator_next( bson_iterator *i ) {\n int ds;\n\n if ( i->first ) {\n i->first = 0;\n return ( bson_type )( *i->cur );\n }\n\n switch ( bson_iterator_type( i ) ) {\n case BSON_EOO:\n return BSON_EOO; /* don't advance */\n case BSON_UNDEFINED:\n case BSON_NULL:\n ds = 0;\n break;\n case BSON_BOOL:\n ds = 1;\n break;\n case BSON_INT:\n ds = 4;\n break;\n case BSON_LONG:\n case BSON_DOUBLE:\n case BSON_TIMESTAMP:\n case BSON_DATE:\n ds = 8;\n break;\n case BSON_OID:\n ds = 12;\n break;\n case BSON_STRING:\n case BSON_SYMBOL:\n case BSON_CODE:\n ds = 4 + bson_iterator_int_raw( i );\n break;\n case BSON_BINDATA:\n ds = 5 + bson_iterator_int_raw( i );\n break;\n case BSON_OBJECT:\n case BSON_ARRAY:\n case BSON_CODEWSCOPE:\n ds = bson_iterator_int_raw( i );\n break;\n case BSON_DBREF:\n ds = 4+12 + bson_iterator_int_raw( i );\n break;\n case BSON_REGEX: {\n const char *s = bson_iterator_value( i );\n const char *p = s;\n p += strlen( p )+1;\n p += strlen( p )+1;\n ds = p-s;\n break;\n }\n\n default: {\n char msg[] = \"unknown type: 000000000000\";\n bson_numstr( msg+14, ( unsigned )( i->cur[0] ) );\n bson_fatal_msg( 0, msg );\n return 0;\n }\n }\n\n i->cur += 1 + strlen( i->cur + 1 ) + 1 + ds;\n\n return ( bson_type )( *i->cur );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2713, "func": "MONGO_EXPORT bson_type bson_iterator_next( bson_iterator *i ) {\n size_t ds;\n\n if ( i->first ) {\n i->first = 0;\n return ( bson_type )( *i->cur );\n }\n\n switch ( bson_iterator_type( i ) ) {\n case BSON_EOO:\n return BSON_EOO; /* don't advance */\n case BSON_UNDEFINED:\n case BSON_NULL:\n ds = 0;\n break;\n case BSON_BOOL:\n ds = 1;\n break;\n case BSON_INT:\n ds = 4;\n break;\n case BSON_LONG:\n case BSON_DOUBLE:\n case BSON_TIMESTAMP:\n case BSON_DATE:\n ds = 8;\n break;\n case BSON_OID:\n ds = 12;\n break;\n case BSON_STRING:\n case BSON_SYMBOL:\n case BSON_CODE:\n ds = 4 + bson_iterator_int_raw( i );\n break;\n case BSON_BINDATA:\n ds = 5 + bson_iterator_int_raw( i );\n break;\n case BSON_OBJECT:\n case BSON_ARRAY:\n case BSON_CODEWSCOPE:\n ds = bson_iterator_int_raw( i );\n break;\n case BSON_DBREF:\n ds = 4+12 + bson_iterator_int_raw( i );\n break;\n case BSON_REGEX: {\n const char *s = bson_iterator_value( i );\n const char *p = s;\n p += strlen( p )+1;\n p += strlen( p )+1;\n ds = p-s;\n break;\n }\n\n default: {\n char msg[] = \"unknown type: 000000000000\";\n bson_numstr( msg+14, ( unsigned )( i->cur[0] ) );\n bson_fatal_msg( 0, msg );\n return 0;\n }\n }\n\n i->cur += 1 + strlen( i->cur + 1 ) + 1 + ds;\n\n return ( bson_type )( *i->cur );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2895, "func": "vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)\n{\n\tstruct drm_vc4_submit_cl *args = exec->args;\n\tvoid *temp = NULL;\n\tvoid *bin;\n\tint ret = 0;\n\tuint32_t bin_offset = 0;\n\tuint32_t shader_rec_offset = roundup(bin_offset + args->bin_cl_size,\n\t\t\t\t\t 16);\n\tuint32_t uniforms_offset = shader_rec_offset + args->shader_rec_size;\n\tuint32_t exec_size = uniforms_offset + args->uniforms_size;\n\tuint32_t temp_size = exec_size + (sizeof(struct vc4_shader_state) *\n\t\t\t\t\t args->shader_rec_count);\n\tstruct vc4_bo *bo;\n\n\tif (uniforms_offset < shader_rec_offset ||\n\t exec_size < uniforms_offset ||\n\t args->shader_rec_count >= (UINT_MAX /\n\t\t\t\t\t sizeof(struct vc4_shader_state)) ||\n\t temp_size < exec_size) {\n\t\tDRM_ERROR(\"overflow in exec arguments\\n\");\n\t\tgoto fail;\n\t}\n\n\t/* Allocate space where we'll store the copied in user command lists\n\t * and shader records.\n\t *\n\t * We don't just copy directly into the BOs because we need to\n\t * read the contents back for validation, and I think the\n\t * bo->vaddr is uncached access.\n\t */\n\ttemp = drm_malloc_ab(temp_size, 1);\n\tif (!temp) {\n\t\tDRM_ERROR(\"Failed to allocate storage for copying \"\n\t\t\t \"in bin/render CLs.\\n\");\n\t\tret = -ENOMEM;\n\t\tgoto fail;\n\t}\n\tbin = temp + bin_offset;\n\texec->shader_rec_u = temp + shader_rec_offset;\n\texec->uniforms_u = temp + uniforms_offset;\n\texec->shader_state = temp + exec_size;\n\texec->shader_state_size = args->shader_rec_count;\n\n\tif (copy_from_user(bin,\n\t\t\t (void __user *)(uintptr_t)args->bin_cl,\n\t\t\t args->bin_cl_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tif (copy_from_user(exec->shader_rec_u,\n\t\t\t (void __user *)(uintptr_t)args->shader_rec,\n\t\t\t args->shader_rec_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tif (copy_from_user(exec->uniforms_u,\n\t\t\t (void __user *)(uintptr_t)args->uniforms,\n\t\t\t args->uniforms_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tbo = vc4_bo_create(dev, exec_size, true);\n\tif (IS_ERR(bo)) {\n\t\tDRM_ERROR(\"Couldn't allocate BO for binning\\n\");\n\t\tret = PTR_ERR(bo);\n\t\tgoto fail;\n\t}\n\texec->exec_bo = &bo->base;\n\n\tlist_add_tail(&to_vc4_bo(&exec->exec_bo->base)->unref_head,\n\t\t &exec->unref_list);\n\n\texec->ct0ca = exec->exec_bo->paddr + bin_offset;\n\n\texec->bin_u = bin;\n\n\texec->shader_rec_v = exec->exec_bo->vaddr + shader_rec_offset;\n\texec->shader_rec_p = exec->exec_bo->paddr + shader_rec_offset;\n\texec->shader_rec_size = args->shader_rec_size;\n\n\texec->uniforms_v = exec->exec_bo->vaddr + uniforms_offset;\n\texec->uniforms_p = exec->exec_bo->paddr + uniforms_offset;\n\texec->uniforms_size = args->uniforms_size;\n\n\tret = vc4_validate_bin_cl(dev,\n\t\t\t\t exec->exec_bo->vaddr + bin_offset,\n\t\t\t\t bin,\n\t\t\t\t exec);\n\tif (ret)\n\t\tgoto fail;\n\n\tret = vc4_validate_shader_recs(dev, exec);\n\tif (ret)\n\t\tgoto fail;\n\n\t/* Block waiting on any previous rendering into the CS's VBO,\n\t * IB, or textures, so that pixels are actually written by the\n\t * time we try to read them.\n\t */\n\tret = vc4_wait_for_seqno(dev, exec->bin_dep_seqno, ~0ull, true);\n\nfail:\n\tdrm_free_large(temp);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-5576", "cwe_id": "CWE-190" }, { "id": 2895, "func": "vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)\n{\n\tstruct drm_vc4_submit_cl *args = exec->args;\n\tvoid *temp = NULL;\n\tvoid *bin;\n\tint ret = 0;\n\tuint32_t bin_offset = 0;\n\tuint32_t shader_rec_offset = roundup(bin_offset + args->bin_cl_size,\n\t\t\t\t\t 16);\n\tuint32_t uniforms_offset = shader_rec_offset + args->shader_rec_size;\n\tuint32_t exec_size = uniforms_offset + args->uniforms_size;\n\tuint32_t temp_size = exec_size + (sizeof(struct vc4_shader_state) *\n\t\t\t\t\t args->shader_rec_count);\n\tstruct vc4_bo *bo;\n\n\tif (shader_rec_offset < args->bin_cl_size ||\n\t uniforms_offset < shader_rec_offset ||\n\t exec_size < uniforms_offset ||\n\t args->shader_rec_count >= (UINT_MAX /\n\t\t\t\t\t sizeof(struct vc4_shader_state)) ||\n\t temp_size < exec_size) {\n\t\tDRM_ERROR(\"overflow in exec arguments\\n\");\n\t\tgoto fail;\n\t}\n\n\t/* Allocate space where we'll store the copied in user command lists\n\t * and shader records.\n\t *\n\t * We don't just copy directly into the BOs because we need to\n\t * read the contents back for validation, and I think the\n\t * bo->vaddr is uncached access.\n\t */\n\ttemp = drm_malloc_ab(temp_size, 1);\n\tif (!temp) {\n\t\tDRM_ERROR(\"Failed to allocate storage for copying \"\n\t\t\t \"in bin/render CLs.\\n\");\n\t\tret = -ENOMEM;\n\t\tgoto fail;\n\t}\n\tbin = temp + bin_offset;\n\texec->shader_rec_u = temp + shader_rec_offset;\n\texec->uniforms_u = temp + uniforms_offset;\n\texec->shader_state = temp + exec_size;\n\texec->shader_state_size = args->shader_rec_count;\n\n\tif (copy_from_user(bin,\n\t\t\t (void __user *)(uintptr_t)args->bin_cl,\n\t\t\t args->bin_cl_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tif (copy_from_user(exec->shader_rec_u,\n\t\t\t (void __user *)(uintptr_t)args->shader_rec,\n\t\t\t args->shader_rec_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tif (copy_from_user(exec->uniforms_u,\n\t\t\t (void __user *)(uintptr_t)args->uniforms,\n\t\t\t args->uniforms_size)) {\n\t\tret = -EFAULT;\n\t\tgoto fail;\n\t}\n\n\tbo = vc4_bo_create(dev, exec_size, true);\n\tif (IS_ERR(bo)) {\n\t\tDRM_ERROR(\"Couldn't allocate BO for binning\\n\");\n\t\tret = PTR_ERR(bo);\n\t\tgoto fail;\n\t}\n\texec->exec_bo = &bo->base;\n\n\tlist_add_tail(&to_vc4_bo(&exec->exec_bo->base)->unref_head,\n\t\t &exec->unref_list);\n\n\texec->ct0ca = exec->exec_bo->paddr + bin_offset;\n\n\texec->bin_u = bin;\n\n\texec->shader_rec_v = exec->exec_bo->vaddr + shader_rec_offset;\n\texec->shader_rec_p = exec->exec_bo->paddr + shader_rec_offset;\n\texec->shader_rec_size = args->shader_rec_size;\n\n\texec->uniforms_v = exec->exec_bo->vaddr + uniforms_offset;\n\texec->uniforms_p = exec->exec_bo->paddr + uniforms_offset;\n\texec->uniforms_size = args->uniforms_size;\n\n\tret = vc4_validate_bin_cl(dev,\n\t\t\t\t exec->exec_bo->vaddr + bin_offset,\n\t\t\t\t bin,\n\t\t\t\t exec);\n\tif (ret)\n\t\tgoto fail;\n\n\tret = vc4_validate_shader_recs(dev, exec);\n\tif (ret)\n\t\tgoto fail;\n\n\t/* Block waiting on any previous rendering into the CS's VBO,\n\t * IB, or textures, so that pixels are actually written by the\n\t * time we try to read them.\n\t */\n\tret = vc4_wait_for_seqno(dev, exec->bin_dep_seqno, ~0ull, true);\n\nfail:\n\tdrm_free_large(temp);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-5576", "cwe_id": "CWE-190" }, { "id": 3173, "func": "static int get_siz(Jpeg2000DecoderContext *s)\n{\n int i;\n int ncomponents;\n uint32_t log2_chroma_wh = 0;\n const enum AVPixelFormat *possible_fmts = NULL;\n int possible_fmts_nb = 0;\n\n if (bytestream2_get_bytes_left(&s->g) < 36)\n return AVERROR_INVALIDDATA;\n\n s->avctx->profile = bytestream2_get_be16u(&s->g); // Rsiz\n s->width = bytestream2_get_be32u(&s->g); // Width\n s->height = bytestream2_get_be32u(&s->g); // Height\n s->image_offset_x = bytestream2_get_be32u(&s->g); // X0Siz\n s->image_offset_y = bytestream2_get_be32u(&s->g); // Y0Siz\n s->tile_width = bytestream2_get_be32u(&s->g); // XTSiz\n s->tile_height = bytestream2_get_be32u(&s->g); // YTSiz\n s->tile_offset_x = bytestream2_get_be32u(&s->g); // XT0Siz\n s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz\n ncomponents = bytestream2_get_be16u(&s->g); // CSiz\n\n if (ncomponents <= 0) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid number of components: %d\\n\",\n s->ncomponents);\n return AVERROR_INVALIDDATA;\n }\n\n if (ncomponents > 4) {\n avpriv_request_sample(s->avctx, \"Support for %d components\",\n s->ncomponents);\n return AVERROR_PATCHWELCOME;\n }\n\n s->ncomponents = ncomponents;\n\n if (s->tile_width <= 0 || s->tile_height <= 0) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid tile dimension %dx%d.\\n\",\n s->tile_width, s->tile_height);\n return AVERROR_INVALIDDATA;\n }\n\n if (bytestream2_get_bytes_left(&s->g) < 3 * s->ncomponents)\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i\n uint8_t x = bytestream2_get_byteu(&s->g);\n s->cbps[i] = (x & 0x7f) + 1;\n s->precision = FFMAX(s->cbps[i], s->precision);\n s->sgnd[i] = !!(x & 0x80);\n s->cdx[i] = bytestream2_get_byteu(&s->g);\n s->cdy[i] = bytestream2_get_byteu(&s->g);\n if (!s->cdx[i] || !s->cdy[i]) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid sample seperation\\n\");\n return AVERROR_INVALIDDATA;\n }\n log2_chroma_wh |= s->cdy[i] >> 1 << i * 4 | s->cdx[i] >> 1 << i * 4 + 2;\n }\n\n s->numXtiles = ff_jpeg2000_ceildiv(s->width - s->tile_offset_x, s->tile_width);\n s->numYtiles = ff_jpeg2000_ceildiv(s->height - s->tile_offset_y, s->tile_height);\n\n if (s->numXtiles * (uint64_t)s->numYtiles > INT_MAX/sizeof(*s->tile)) {\n s->numXtiles = s->numYtiles = 0;\n return AVERROR(EINVAL);\n }\n\n s->tile = av_mallocz_array(s->numXtiles * s->numYtiles, sizeof(*s->tile));\n if (!s->tile) {\n s->numXtiles = s->numYtiles = 0;\n return AVERROR(ENOMEM);\n }\n\n for (i = 0; i < s->numXtiles * s->numYtiles; i++) {\n Jpeg2000Tile *tile = s->tile + i;\n\n tile->comp = av_mallocz(s->ncomponents * sizeof(*tile->comp));\n if (!tile->comp)\n return AVERROR(ENOMEM);\n }\n\n /* compute image size with reduction factor */\n s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,\n s->reduction_factor);\n s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,\n s->reduction_factor);\n\n if (s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_2K ||\n s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_4K) {\n possible_fmts = xyz_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(xyz_pix_fmts);\n } else {\n switch (s->colour_space) {\n case 16:\n possible_fmts = rgb_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(rgb_pix_fmts);\n break;\n case 17:\n possible_fmts = gray_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(gray_pix_fmts);\n break;\n case 18:\n possible_fmts = yuv_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(yuv_pix_fmts);\n break;\n default:\n possible_fmts = all_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(all_pix_fmts);\n break;\n }\n }\n for (i = 0; i < possible_fmts_nb; ++i) {\n if (pix_fmt_match(possible_fmts[i], ncomponents, s->precision, log2_chroma_wh, s->pal8)) {\n s->avctx->pix_fmt = possible_fmts[i];\n break;\n }\n }\n if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {\n av_log(s->avctx, AV_LOG_ERROR,\n \"Unknown pix_fmt, profile: %d, colour_space: %d, \"\n \"components: %d, precision: %d, \"\n \"cdx[1]: %d, cdy[1]: %d, cdx[2]: %d, cdy[2]: %d\\n\",\n s->avctx->profile, s->colour_space, ncomponents, s->precision,\n ncomponents > 2 ? s->cdx[1] : 0,\n ncomponents > 2 ? s->cdy[1] : 0,\n ncomponents > 2 ? s->cdx[2] : 0,\n ncomponents > 2 ? s->cdy[2] : 0);\n }\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7016", "cwe_id": "CWE-119" }, { "id": 3173, "func": "static int get_siz(Jpeg2000DecoderContext *s)\n{\n int i;\n int ncomponents;\n uint32_t log2_chroma_wh = 0;\n const enum AVPixelFormat *possible_fmts = NULL;\n int possible_fmts_nb = 0;\n\n if (bytestream2_get_bytes_left(&s->g) < 36)\n return AVERROR_INVALIDDATA;\n\n s->avctx->profile = bytestream2_get_be16u(&s->g); // Rsiz\n s->width = bytestream2_get_be32u(&s->g); // Width\n s->height = bytestream2_get_be32u(&s->g); // Height\n s->image_offset_x = bytestream2_get_be32u(&s->g); // X0Siz\n s->image_offset_y = bytestream2_get_be32u(&s->g); // Y0Siz\n s->tile_width = bytestream2_get_be32u(&s->g); // XTSiz\n s->tile_height = bytestream2_get_be32u(&s->g); // YTSiz\n s->tile_offset_x = bytestream2_get_be32u(&s->g); // XT0Siz\n s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz\n ncomponents = bytestream2_get_be16u(&s->g); // CSiz\n\n if (ncomponents <= 0) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid number of components: %d\\n\",\n s->ncomponents);\n return AVERROR_INVALIDDATA;\n }\n\n if (ncomponents > 4) {\n avpriv_request_sample(s->avctx, \"Support for %d components\",\n s->ncomponents);\n return AVERROR_PATCHWELCOME;\n }\n\n s->ncomponents = ncomponents;\n\n if (s->tile_width <= 0 || s->tile_height <= 0) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid tile dimension %dx%d.\\n\",\n s->tile_width, s->tile_height);\n return AVERROR_INVALIDDATA;\n }\n\n if (bytestream2_get_bytes_left(&s->g) < 3 * s->ncomponents)\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i\n uint8_t x = bytestream2_get_byteu(&s->g);\n s->cbps[i] = (x & 0x7f) + 1;\n s->precision = FFMAX(s->cbps[i], s->precision);\n s->sgnd[i] = !!(x & 0x80);\n s->cdx[i] = bytestream2_get_byteu(&s->g);\n s->cdy[i] = bytestream2_get_byteu(&s->g);\n if ( !s->cdx[i] || s->cdx[i] == 3 || s->cdx[i] > 4\n || !s->cdy[i] || s->cdy[i] == 3 || s->cdy[i] > 4) {\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid sample seperation\\n\");\n return AVERROR_INVALIDDATA;\n }\n log2_chroma_wh |= s->cdy[i] >> 1 << i * 4 | s->cdx[i] >> 1 << i * 4 + 2;\n }\n\n s->numXtiles = ff_jpeg2000_ceildiv(s->width - s->tile_offset_x, s->tile_width);\n s->numYtiles = ff_jpeg2000_ceildiv(s->height - s->tile_offset_y, s->tile_height);\n\n if (s->numXtiles * (uint64_t)s->numYtiles > INT_MAX/sizeof(*s->tile)) {\n s->numXtiles = s->numYtiles = 0;\n return AVERROR(EINVAL);\n }\n\n s->tile = av_mallocz_array(s->numXtiles * s->numYtiles, sizeof(*s->tile));\n if (!s->tile) {\n s->numXtiles = s->numYtiles = 0;\n return AVERROR(ENOMEM);\n }\n\n for (i = 0; i < s->numXtiles * s->numYtiles; i++) {\n Jpeg2000Tile *tile = s->tile + i;\n\n tile->comp = av_mallocz(s->ncomponents * sizeof(*tile->comp));\n if (!tile->comp)\n return AVERROR(ENOMEM);\n }\n\n /* compute image size with reduction factor */\n s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,\n s->reduction_factor);\n s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,\n s->reduction_factor);\n\n if (s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_2K ||\n s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_4K) {\n possible_fmts = xyz_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(xyz_pix_fmts);\n } else {\n switch (s->colour_space) {\n case 16:\n possible_fmts = rgb_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(rgb_pix_fmts);\n break;\n case 17:\n possible_fmts = gray_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(gray_pix_fmts);\n break;\n case 18:\n possible_fmts = yuv_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(yuv_pix_fmts);\n break;\n default:\n possible_fmts = all_pix_fmts;\n possible_fmts_nb = FF_ARRAY_ELEMS(all_pix_fmts);\n break;\n }\n }\n for (i = 0; i < possible_fmts_nb; ++i) {\n if (pix_fmt_match(possible_fmts[i], ncomponents, s->precision, log2_chroma_wh, s->pal8)) {\n s->avctx->pix_fmt = possible_fmts[i];\n break;\n }\n }\n if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {\n av_log(s->avctx, AV_LOG_ERROR,\n \"Unknown pix_fmt, profile: %d, colour_space: %d, \"\n \"components: %d, precision: %d, \"\n \"cdx[1]: %d, cdy[1]: %d, cdx[2]: %d, cdy[2]: %d\\n\",\n s->avctx->profile, s->colour_space, ncomponents, s->precision,\n ncomponents > 2 ? s->cdx[1] : 0,\n ncomponents > 2 ? s->cdy[1] : 0,\n ncomponents > 2 ? s->cdx[2] : 0,\n ncomponents > 2 ? s->cdy[2] : 0);\n }\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7016", "cwe_id": "CWE-119" }, { "id": 2580, "func": "untrusted_launcher_response_callback (GtkDialog *dialog,\n int response_id,\n ActivateParametersDesktop *parameters)\n{\n GdkScreen *screen;\n char *uri;\n GFile *file;\n\n switch (response_id)\n {\n case RESPONSE_RUN:\n {\n screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));\n uri = nautilus_file_get_uri (parameters->file);\n DEBUG (\"Launching untrusted launcher %s\", uri);\n nautilus_launch_desktop_file (screen, uri, NULL,\n parameters->parent_window);\n g_free (uri);\n }\n break;\n\n case RESPONSE_MARK_TRUSTED:\n {\n file = nautilus_file_get_location (parameters->file);\n nautilus_file_mark_desktop_file_trusted (file,\n parameters->parent_window,\n TRUE,\n NULL, NULL);\n g_object_unref (file);\n }\n break;\n\n default:\n {\n /* Just destroy dialog */\n }\n break;\n }\n\n gtk_widget_destroy (GTK_WIDGET (dialog));\n activate_parameters_desktop_free (parameters);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14604", "cwe_id": "CWE-20" }, { "id": 2580, "func": "untrusted_launcher_response_callback (GtkDialog *dialog,\n int response_id,\n ActivateParametersDesktop *parameters)\n{\n GdkScreen *screen;\n char *uri;\n GFile *file;\n\n switch (response_id)\n {\n case GTK_RESPONSE_OK:\n {\n file = nautilus_file_get_location (parameters->file);\n\n /* We need to do this in order to prevent malicious desktop files\n * with the executable bit already set.\n * See https://bugzilla.gnome.org/show_bug.cgi?id=777991\n */\n nautilus_file_set_metadata (parameters->file, NAUTILUS_METADATA_KEY_DESKTOP_FILE_TRUSTED,\n NULL,\n \"yes\");\n\n nautilus_file_mark_desktop_file_executable (file,\n parameters->parent_window,\n TRUE,\n NULL, NULL);\n\n /* Need to force a reload of the attributes so is_trusted is marked\n * correctly. Not sure why the general monitor doesn't fire in this\n * case when setting the metadata\n */\n nautilus_file_invalidate_all_attributes (parameters->file);\n\n screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));\n uri = nautilus_file_get_uri (parameters->file);\n DEBUG (\"Launching untrusted launcher %s\", uri);\n nautilus_launch_desktop_file (screen, uri, NULL,\n parameters->parent_window);\n g_free (uri);\n g_object_unref (file);\n }\n break;\n\n default:\n {\n /* Just destroy dialog */\n }\n break;\n }\n\n gtk_widget_destroy (GTK_WIDGET (dialog));\n activate_parameters_desktop_free (parameters);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14604", "cwe_id": "CWE-20" }, { "id": 3106, "func": "void rose_write_internal(struct sock *sk, int frametype)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\tstruct sk_buff *skb;\n\tunsigned char *dptr;\n\tunsigned char lci1, lci2;\n\tchar buffer[100];\n\tint len, faclen = 0;\n\n\tlen = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1;\n\n\tswitch (frametype) {\n\tcase ROSE_CALL_REQUEST:\n\t\tlen += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN;\n\t\tfaclen = rose_create_facilities(buffer, rose);\n\t\tlen += faclen;\n\t\tbreak;\n\tcase ROSE_CALL_ACCEPTED:\n\tcase ROSE_CLEAR_REQUEST:\n\tcase ROSE_RESET_REQUEST:\n\t\tlen += 2;\n\t\tbreak;\n\t}\n\n\tif ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)\n\t\treturn;\n\n\t/*\n\t *\tSpace for AX.25 header and PID.\n\t */\n\tskb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1);\n\n\tdptr = skb_put(skb, skb_tailroom(skb));\n\n\tlci1 = (rose->lci >> 8) & 0x0F;\n\tlci2 = (rose->lci >> 0) & 0xFF;\n\n\tswitch (frametype) {\n\tcase ROSE_CALL_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = 0xAA;\n\t\tmemcpy(dptr, &rose->dest_addr, ROSE_ADDR_LEN);\n\t\tdptr += ROSE_ADDR_LEN;\n\t\tmemcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN);\n\t\tdptr += ROSE_ADDR_LEN;\n\t\tmemcpy(dptr, buffer, faclen);\n\t\tdptr += faclen;\n\t\tbreak;\n\n\tcase ROSE_CALL_ACCEPTED:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = 0x00;\t\t/* Address length */\n\t\t*dptr++ = 0;\t\t/* Facilities length */\n\t\tbreak;\n\n\tcase ROSE_CLEAR_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = rose->cause;\n\t\t*dptr++ = rose->diagnostic;\n\t\tbreak;\n\n\tcase ROSE_RESET_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = ROSE_DTE_ORIGINATED;\n\t\t*dptr++ = 0;\n\t\tbreak;\n\n\tcase ROSE_RR:\n\tcase ROSE_RNR:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr = frametype;\n\t\t*dptr++ |= (rose->vr << 5) & 0xE0;\n\t\tbreak;\n\n\tcase ROSE_CLEAR_CONFIRMATION:\n\tcase ROSE_RESET_CONFIRMATION:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\tbreak;\n\n\tdefault:\n\t\tprintk(KERN_ERR \"ROSE: rose_write_internal - invalid frametype %02X\\n\", frametype);\n\t\tkfree_skb(skb);\n\t\treturn;\n\t}\n\n\trose_transmit_link(skb, rose->neighbour);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 3106, "func": "void rose_write_internal(struct sock *sk, int frametype)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\tstruct sk_buff *skb;\n\tunsigned char *dptr;\n\tunsigned char lci1, lci2;\n\tchar buffer[100];\n\tint len, faclen = 0;\n\n\tlen = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1;\n\n\tswitch (frametype) {\n\tcase ROSE_CALL_REQUEST:\n\t\tlen += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN;\n\t\tfaclen = rose_create_facilities(buffer, rose);\n\t\tlen += faclen;\n\t\tbreak;\n\tcase ROSE_CALL_ACCEPTED:\n\tcase ROSE_CLEAR_REQUEST:\n\tcase ROSE_RESET_REQUEST:\n\t\tlen += 2;\n\t\tbreak;\n\t}\n\n\tif ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)\n\t\treturn;\n\n\t/*\n\t *\tSpace for AX.25 header and PID.\n\t */\n\tskb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1);\n\n\tdptr = skb_put(skb, skb_tailroom(skb));\n\n\tlci1 = (rose->lci >> 8) & 0x0F;\n\tlci2 = (rose->lci >> 0) & 0xFF;\n\n\tswitch (frametype) {\n\tcase ROSE_CALL_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = ROSE_CALL_REQ_ADDR_LEN_VAL;\n\t\tmemcpy(dptr, &rose->dest_addr, ROSE_ADDR_LEN);\n\t\tdptr += ROSE_ADDR_LEN;\n\t\tmemcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN);\n\t\tdptr += ROSE_ADDR_LEN;\n\t\tmemcpy(dptr, buffer, faclen);\n\t\tdptr += faclen;\n\t\tbreak;\n\n\tcase ROSE_CALL_ACCEPTED:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = 0x00;\t\t/* Address length */\n\t\t*dptr++ = 0;\t\t/* Facilities length */\n\t\tbreak;\n\n\tcase ROSE_CLEAR_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = rose->cause;\n\t\t*dptr++ = rose->diagnostic;\n\t\tbreak;\n\n\tcase ROSE_RESET_REQUEST:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\t*dptr++ = ROSE_DTE_ORIGINATED;\n\t\t*dptr++ = 0;\n\t\tbreak;\n\n\tcase ROSE_RR:\n\tcase ROSE_RNR:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr = frametype;\n\t\t*dptr++ |= (rose->vr << 5) & 0xE0;\n\t\tbreak;\n\n\tcase ROSE_CLEAR_CONFIRMATION:\n\tcase ROSE_RESET_CONFIRMATION:\n\t\t*dptr++ = ROSE_GFI | lci1;\n\t\t*dptr++ = lci2;\n\t\t*dptr++ = frametype;\n\t\tbreak;\n\n\tdefault:\n\t\tprintk(KERN_ERR \"ROSE: rose_write_internal - invalid frametype %02X\\n\", frametype);\n\t\tkfree_skb(skb);\n\t\treturn;\n\t}\n\n\trose_transmit_link(skb, rose->neighbour);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 1041, "func": "void CLASS foveon_load_camf()\n{\n unsigned type, wide, high, i, j, row, col, diff;\n ushort huff[258], vpred[2][2] = {{512,512},{512,512}}, hpred[2];\n\n fseek (ifp, meta_offset, SEEK_SET);\n type = get4(); get4(); get4();\n wide = get4();\n high = get4();\n if (type == 2) {\n fread (meta_data, 1, meta_length, ifp);\n for (i=0; i < meta_length; i++) {\n high = (high * 1597 + 51749) % 244944;\n wide = high * (INT64) 301593171 >> 24;\n meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17;\n }\n } else if (type == 4) {\n free (meta_data);\n meta_data = (char *) malloc (meta_length = wide*high*3/2);\n merror (meta_data, \"foveon_load_camf()\");\n foveon_huff (huff);\n get4();\n getbits(-1);\n for (j=row=0; row < high; row++) {\n for (col=0; col < wide; col++) {\n\tdiff = ljpeg_diff(huff);\n\tif (col < 2) hpred[col] = vpred[row & 1][col] += diff;\n\telse hpred[col & 1] += diff;\n\tif (col & 1) {\n\t meta_data[j++] = hpred[0] >> 4;\n\t meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8;\n\t meta_data[j++] = hpred[1];\n }\n }\n }\n } else\n fprintf (stderr,_(\"%s has unknown CAMF type %d.\\n\"), ifname, type);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6889", "cwe_id": "CWE-190" }, { "id": 1041, "func": "void CLASS foveon_load_camf()\n{\n unsigned type, wide, high, i, j, row, col, diff;\n ushort huff[1024], vpred[2][2] = {{512,512},{512,512}}, hpred[2];\n\n fseek (ifp, meta_offset, SEEK_SET);\n type = get4(); get4(); get4();\n wide = get4();\n high = get4();\n#ifdef LIBRAW_LIBRARY_BUILD\n if(wide>32767 || high > 32767 || wide*high > 20000000)\n throw LIBRAW_EXCEPTION_IO_CORRUPT;\n#endif\n if (type == 2) {\n fread (meta_data, 1, meta_length, ifp);\n for (i=0; i < meta_length; i++) {\n high = (high * 1597 + 51749) % 244944;\n wide = high * (INT64) 301593171 >> 24;\n meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17;\n }\n } else if (type == 4) {\n free (meta_data);\n meta_data = (char *) malloc (meta_length = wide*high*3/2);\n merror (meta_data, \"foveon_load_camf()\");\n foveon_huff (huff);\n get4();\n getbits(-1);\n for (j=row=0; row < high; row++) {\n for (col=0; col < wide; col++) {\n\tdiff = ljpeg_diff(huff);\n\tif (col < 2) hpred[col] = vpred[row & 1][col] += diff;\n\telse hpred[col & 1] += diff;\n\tif (col & 1) {\n\t meta_data[j++] = hpred[0] >> 4;\n\t meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8;\n\t meta_data[j++] = hpred[1];\n }\n }\n }\n } else\n fprintf (stderr,_(\"%s has unknown CAMF type %d.\\n\"), ifname, type);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6889", "cwe_id": "CWE-190" }, { "id": 901, "func": "static void record_recent_object(struct object *obj,\n\t\t\t\t struct strbuf *path,\n\t\t\t\t const char *last,\n\t\t\t\t void *data)\n{\n\tsha1_array_append(&recent_objects, obj->oid.hash);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 901, "func": "static void record_recent_object(struct object *obj,\n\t\t\t\t const char *name,\n\t\t\t\t void *data)\n{\n\tsha1_array_append(&recent_objects, obj->oid.hash);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 772, "func": "static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,\n\t\t\t\t char __user *optval,\n\t\t\t\t int __user *optlen)\n{\n\tstruct sctp_assoc_stats sas;\n\tstruct sctp_association *asoc = NULL;\n\n\t/* User must provide at least the assoc id */\n\tif (len < sizeof(sctp_assoc_t))\n\t\treturn -EINVAL;\n\n\tif (copy_from_user(&sas, optval, len))\n\t\treturn -EFAULT;\n\n\tasoc = sctp_id2assoc(sk, sas.sas_assoc_id);\n\tif (!asoc)\n\t\treturn -EINVAL;\n\n\tsas.sas_rtxchunks = asoc->stats.rtxchunks;\n\tsas.sas_gapcnt = asoc->stats.gapcnt;\n\tsas.sas_outofseqtsns = asoc->stats.outofseqtsns;\n\tsas.sas_osacks = asoc->stats.osacks;\n\tsas.sas_isacks = asoc->stats.isacks;\n\tsas.sas_octrlchunks = asoc->stats.octrlchunks;\n\tsas.sas_ictrlchunks = asoc->stats.ictrlchunks;\n\tsas.sas_oodchunks = asoc->stats.oodchunks;\n\tsas.sas_iodchunks = asoc->stats.iodchunks;\n\tsas.sas_ouodchunks = asoc->stats.ouodchunks;\n\tsas.sas_iuodchunks = asoc->stats.iuodchunks;\n\tsas.sas_idupchunks = asoc->stats.idupchunks;\n\tsas.sas_opackets = asoc->stats.opackets;\n\tsas.sas_ipackets = asoc->stats.ipackets;\n\n\t/* New high max rto observed, will return 0 if not a single\n\t * RTO update took place. obs_rto_ipaddr will be bogus\n\t * in such a case\n\t */\n\tsas.sas_maxrto = asoc->stats.max_obs_rto;\n\tmemcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr,\n\t\tsizeof(struct sockaddr_storage));\n\n\t/* Mark beginning of a new observation period */\n\tasoc->stats.max_obs_rto = asoc->rto_min;\n\n\t/* Allow the struct to grow and fill in as much as possible */\n\tlen = min_t(size_t, len, sizeof(sas));\n\n\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\n\tSCTP_DEBUG_PRINTK(\"sctp_getsockopt_assoc_stat(%d): %d\\n\",\n\t\t\t len, sas.sas_assoc_id);\n\n\tif (copy_to_user(optval, &sas, len))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-1828", "cwe_id": "CWE-20" }, { "id": 772, "func": "static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,\n\t\t\t\t char __user *optval,\n\t\t\t\t int __user *optlen)\n{\n\tstruct sctp_assoc_stats sas;\n\tstruct sctp_association *asoc = NULL;\n\n\t/* User must provide at least the assoc id */\n\tif (len < sizeof(sctp_assoc_t))\n\t\treturn -EINVAL;\n\n\t/* Allow the struct to grow and fill in as much as possible */\n\tlen = min_t(size_t, len, sizeof(sas));\n\n\tif (copy_from_user(&sas, optval, len))\n\t\treturn -EFAULT;\n\n\tasoc = sctp_id2assoc(sk, sas.sas_assoc_id);\n\tif (!asoc)\n\t\treturn -EINVAL;\n\n\tsas.sas_rtxchunks = asoc->stats.rtxchunks;\n\tsas.sas_gapcnt = asoc->stats.gapcnt;\n\tsas.sas_outofseqtsns = asoc->stats.outofseqtsns;\n\tsas.sas_osacks = asoc->stats.osacks;\n\tsas.sas_isacks = asoc->stats.isacks;\n\tsas.sas_octrlchunks = asoc->stats.octrlchunks;\n\tsas.sas_ictrlchunks = asoc->stats.ictrlchunks;\n\tsas.sas_oodchunks = asoc->stats.oodchunks;\n\tsas.sas_iodchunks = asoc->stats.iodchunks;\n\tsas.sas_ouodchunks = asoc->stats.ouodchunks;\n\tsas.sas_iuodchunks = asoc->stats.iuodchunks;\n\tsas.sas_idupchunks = asoc->stats.idupchunks;\n\tsas.sas_opackets = asoc->stats.opackets;\n\tsas.sas_ipackets = asoc->stats.ipackets;\n\n\t/* New high max rto observed, will return 0 if not a single\n\t * RTO update took place. obs_rto_ipaddr will be bogus\n\t * in such a case\n\t */\n\tsas.sas_maxrto = asoc->stats.max_obs_rto;\n\tmemcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr,\n\t\tsizeof(struct sockaddr_storage));\n\n\t/* Mark beginning of a new observation period */\n\tasoc->stats.max_obs_rto = asoc->rto_min;\n\n\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\n\tSCTP_DEBUG_PRINTK(\"sctp_getsockopt_assoc_stat(%d): %d\\n\",\n\t\t\t len, sas.sas_assoc_id);\n\n\tif (copy_to_user(optval, &sas, len))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-1828", "cwe_id": "CWE-20" }, { "id": 950, "func": "PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s)\n{\n\tstatic const char module[] = \"PredictorEncodeTile\";\n\tTIFFPredictorState *sp = PredictorState(tif);\n uint8 *working_copy;\n\ttmsize_t cc = cc0, rowsize;\n\tunsigned char* bp;\n int result_code;\n\n\tassert(sp != NULL);\n\tassert(sp->encodepfunc != NULL);\n\tassert(sp->encodetile != NULL);\n\n /* \n * Do predictor manipulation in a working buffer to avoid altering\n * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965\n */\n working_copy = (uint8*) _TIFFmalloc(cc0);\n if( working_copy == NULL )\n {\n TIFFErrorExt(tif->tif_clientdata, module, \n \"Out of memory allocating \" TIFF_SSIZE_FORMAT \" byte temp buffer.\",\n cc0 );\n return 0;\n }\n memcpy( working_copy, bp0, cc0 );\n bp = working_copy;\n\n\trowsize = sp->rowsize;\n\tassert(rowsize > 0);\n\tassert((cc0%rowsize)==0);\n\twhile (cc > 0) {\n\t\t(*sp->encodepfunc)(tif, bp, rowsize);\n\t\tcc -= rowsize;\n\t\tbp += rowsize;\n\t}\n\tresult_code = (*sp->encodetile)(tif, working_copy, cc0, s);\n\n _TIFFfree( working_copy );\n\n return result_code;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9535", "cwe_id": "CWE-119" }, { "id": 950, "func": "PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s)\n{\n\tstatic const char module[] = \"PredictorEncodeTile\";\n\tTIFFPredictorState *sp = PredictorState(tif);\n uint8 *working_copy;\n\ttmsize_t cc = cc0, rowsize;\n\tunsigned char* bp;\n int result_code;\n\n\tassert(sp != NULL);\n\tassert(sp->encodepfunc != NULL);\n\tassert(sp->encodetile != NULL);\n\n /* \n * Do predictor manipulation in a working buffer to avoid altering\n * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965\n */\n working_copy = (uint8*) _TIFFmalloc(cc0);\n if( working_copy == NULL )\n {\n TIFFErrorExt(tif->tif_clientdata, module, \n \"Out of memory allocating \" TIFF_SSIZE_FORMAT \" byte temp buffer.\",\n cc0 );\n return 0;\n }\n memcpy( working_copy, bp0, cc0 );\n bp = working_copy;\n\n\trowsize = sp->rowsize;\n\tassert(rowsize > 0);\n\tif((cc0%rowsize)!=0)\n {\n TIFFErrorExt(tif->tif_clientdata, \"PredictorEncodeTile\",\n \"%s\", \"(cc0%rowsize)!=0\");\n return 0;\n }\n\twhile (cc > 0) {\n\t\t(*sp->encodepfunc)(tif, bp, rowsize);\n\t\tcc -= rowsize;\n\t\tbp += rowsize;\n\t}\n\tresult_code = (*sp->encodetile)(tif, working_copy, cc0, s);\n\n _TIFFfree( working_copy );\n\n return result_code;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9535", "cwe_id": "CWE-119" }, { "id": 2765, "func": "static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)\n{\n\treturn F2FS_M_SB(page->mapping);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 2765, "func": "static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)\n{\n\treturn F2FS_M_SB(page_file_mapping(page));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 611, "func": "static int iscsi_add_notunderstood_response(\n\tchar *key,\n\tchar *value,\n\tstruct iscsi_param_list *param_list)\n{\n\tstruct iscsi_extra_response *extra_response;\n\n\tif (strlen(value) > VALUE_MAXLEN) {\n\t\tpr_err(\"Value for notunderstood key \\\"%s\\\" exceeds %d,\"\n\t\t\t\" protocol error.\\n\", key, VALUE_MAXLEN);\n\t\treturn -1;\n\t}\n\n\textra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL);\n\tif (!extra_response) {\n\t\tpr_err(\"Unable to allocate memory for\"\n\t\t\t\" struct iscsi_extra_response.\\n\");\n\t\treturn -1;\n\t}\n\tINIT_LIST_HEAD(&extra_response->er_list);\n\n\tstrncpy(extra_response->key, key, strlen(key) + 1);\n\tstrncpy(extra_response->value, NOTUNDERSTOOD,\n\t\t\tstrlen(NOTUNDERSTOOD) + 1);\n\n\tlist_add_tail(&extra_response->er_list,\n\t\t\t¶m_list->extra_response_list);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-2850", "cwe_id": "CWE-119" }, { "id": 611, "func": "static int iscsi_add_notunderstood_response(\n\tchar *key,\n\tchar *value,\n\tstruct iscsi_param_list *param_list)\n{\n\tstruct iscsi_extra_response *extra_response;\n\n\tif (strlen(value) > VALUE_MAXLEN) {\n\t\tpr_err(\"Value for notunderstood key \\\"%s\\\" exceeds %d,\"\n\t\t\t\" protocol error.\\n\", key, VALUE_MAXLEN);\n\t\treturn -1;\n\t}\n\n\textra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL);\n\tif (!extra_response) {\n\t\tpr_err(\"Unable to allocate memory for\"\n\t\t\t\" struct iscsi_extra_response.\\n\");\n\t\treturn -1;\n\t}\n\tINIT_LIST_HEAD(&extra_response->er_list);\n\n\tstrlcpy(extra_response->key, key, sizeof(extra_response->key));\n\tstrlcpy(extra_response->value, NOTUNDERSTOOD,\n\t\tsizeof(extra_response->value));\n\n\tlist_add_tail(&extra_response->er_list,\n\t\t\t¶m_list->extra_response_list);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-2850", "cwe_id": "CWE-119" }, { "id": 1598, "func": "\nstatic int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)\n{\n\tstruct cfg80211_registered_device *rdev = info->user_ptr[0];\n\tstruct net_device *dev = info->user_ptr[1];\n\tstruct cfg80211_scan_request *request;\n\tstruct nlattr *attr;\n\tstruct wiphy *wiphy;\n\tint err, tmp, n_ssids = 0, n_channels, i;\n\tenum ieee80211_band band;\n\tsize_t ie_len;\n\n\tif (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))\n\t\treturn -EINVAL;\n\n\twiphy = &rdev->wiphy;\n\n\tif (!rdev->ops->scan)\n\t\treturn -EOPNOTSUPP;\n\n\tif (rdev->scan_req)\n\t\treturn -EBUSY;\n\n\tif (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {\n\t\tn_channels = validate_scan_freqs(\n\t\t\t\tinfo->attrs[NL80211_ATTR_SCAN_FREQUENCIES]);\n\t\tif (!n_channels)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tn_channels = 0;\n\n\t\tfor (band = 0; band < IEEE80211_NUM_BANDS; band++)\n\t\t\tif (wiphy->bands[band])\n\t\t\t\tn_channels += wiphy->bands[band]->n_channels;\n\t}\n\n\tif (info->attrs[NL80211_ATTR_SCAN_SSIDS])\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp)\n\t\t\tn_ssids++;\n\n\tif (n_ssids > wiphy->max_scan_ssids)\n\t\treturn -EINVAL;\n\n\tif (info->attrs[NL80211_ATTR_IE])\n\t\tie_len = nla_len(info->attrs[NL80211_ATTR_IE]);\n\telse\n\t\tie_len = 0;\n\n\tif (ie_len > wiphy->max_scan_ie_len)\n\t\treturn -EINVAL;\n\n\trequest = kzalloc(sizeof(*request)\n\t\t\t+ sizeof(*request->ssids) * n_ssids\n\t\t\t+ sizeof(*request->channels) * n_channels\n\t\t\t+ ie_len, GFP_KERNEL);\n\tif (!request)\n\t\treturn -ENOMEM;\n\n\tif (n_ssids)\n\t\trequest->ssids = (void *)&request->channels[n_channels];\n\trequest->n_ssids = n_ssids;\n\tif (ie_len) {\n\t\tif (request->ssids)\n\t\t\trequest->ie = (void *)(request->ssids + n_ssids);\n\t\telse\n\t\t\trequest->ie = (void *)(request->channels + n_channels);\n\t}\n\n\ti = 0;\n\tif (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {\n\t\t/* user specified, bail out if channel not found */\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_FREQUENCIES], tmp) {\n\t\t\tstruct ieee80211_channel *chan;\n\n\t\t\tchan = ieee80211_get_channel(wiphy, nla_get_u32(attr));\n\n\t\t\tif (!chan) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto out_free;\n\t\t\t}\n\n\t\t\t/* ignore disabled channels */\n\t\t\tif (chan->flags & IEEE80211_CHAN_DISABLED)\n\t\t\t\tcontinue;\n\n\t\t\trequest->channels[i] = chan;\n\t\t\ti++;\n\t\t}\n\t} else {\n\t\t/* all channels */\n\t\tfor (band = 0; band < IEEE80211_NUM_BANDS; band++) {\n\t\t\tint j;\n\t\t\tif (!wiphy->bands[band])\n\t\t\t\tcontinue;\n\t\t\tfor (j = 0; j < wiphy->bands[band]->n_channels; j++) {\n\t\t\t\tstruct ieee80211_channel *chan;\n\n\t\t\t\tchan = &wiphy->bands[band]->channels[j];\n\n\t\t\t\tif (chan->flags & IEEE80211_CHAN_DISABLED)\n\t\t\t\t\tcontinue;\n\n\t\t\t\trequest->channels[i] = chan;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!i) {\n\t\terr = -EINVAL;\n\t\tgoto out_free;\n\t}\n\n\trequest->n_channels = i;\n\n\ti = 0;\n\tif (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {\n\t\t\tif (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto out_free;\n\t\t\t}\n\t\t\tmemcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));\n\t\t\trequest->ssids[i].ssid_len = nla_len(attr);\n\t\t\ti++;\n\t\t}\n\t}\n\n\tif (info->attrs[NL80211_ATTR_IE]) {\n\t\trequest->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);\n\t\tmemcpy((void *)request->ie,\n\t\t nla_data(info->attrs[NL80211_ATTR_IE]),\n\t\t request->ie_len);\n\t}\n\n\trequest->dev = dev;\n\trequest->wiphy = &rdev->wiphy;\n\n\trdev->scan_req = request;\n\terr = rdev->ops->scan(&rdev->wiphy, dev, request);\n\n\tif (!err) {\n\t\tnl80211_send_scan_start(rdev, dev);\n\t\tdev_hold(dev);\n\t} else {\n out_free:\n\t\trdev->scan_req = NULL;\n\t\tkfree(request);\n\t}\n\n\treturn err;", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-2517", "cwe_id": "CWE-119" }, { "id": 1598, "func": "\nstatic int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)\n{\n\tstruct cfg80211_registered_device *rdev = info->user_ptr[0];\n\tstruct net_device *dev = info->user_ptr[1];\n\tstruct cfg80211_scan_request *request;\n\tstruct nlattr *attr;\n\tstruct wiphy *wiphy;\n\tint err, tmp, n_ssids = 0, n_channels, i;\n\tenum ieee80211_band band;\n\tsize_t ie_len;\n\n\tif (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))\n\t\treturn -EINVAL;\n\n\twiphy = &rdev->wiphy;\n\n\tif (!rdev->ops->scan)\n\t\treturn -EOPNOTSUPP;\n\n\tif (rdev->scan_req)\n\t\treturn -EBUSY;\n\n\tif (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {\n\t\tn_channels = validate_scan_freqs(\n\t\t\t\tinfo->attrs[NL80211_ATTR_SCAN_FREQUENCIES]);\n\t\tif (!n_channels)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tn_channels = 0;\n\n\t\tfor (band = 0; band < IEEE80211_NUM_BANDS; band++)\n\t\t\tif (wiphy->bands[band])\n\t\t\t\tn_channels += wiphy->bands[band]->n_channels;\n\t}\n\n\tif (info->attrs[NL80211_ATTR_SCAN_SSIDS])\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp)\n\t\t\tn_ssids++;\n\n\tif (n_ssids > wiphy->max_scan_ssids)\n\t\treturn -EINVAL;\n\n\tif (info->attrs[NL80211_ATTR_IE])\n\t\tie_len = nla_len(info->attrs[NL80211_ATTR_IE]);\n\telse\n\t\tie_len = 0;\n\n\tif (ie_len > wiphy->max_scan_ie_len)\n\t\treturn -EINVAL;\n\n\trequest = kzalloc(sizeof(*request)\n\t\t\t+ sizeof(*request->ssids) * n_ssids\n\t\t\t+ sizeof(*request->channels) * n_channels\n\t\t\t+ ie_len, GFP_KERNEL);\n\tif (!request)\n\t\treturn -ENOMEM;\n\n\tif (n_ssids)\n\t\trequest->ssids = (void *)&request->channels[n_channels];\n\trequest->n_ssids = n_ssids;\n\tif (ie_len) {\n\t\tif (request->ssids)\n\t\t\trequest->ie = (void *)(request->ssids + n_ssids);\n\t\telse\n\t\t\trequest->ie = (void *)(request->channels + n_channels);\n\t}\n\n\ti = 0;\n\tif (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {\n\t\t/* user specified, bail out if channel not found */\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_FREQUENCIES], tmp) {\n\t\t\tstruct ieee80211_channel *chan;\n\n\t\t\tchan = ieee80211_get_channel(wiphy, nla_get_u32(attr));\n\n\t\t\tif (!chan) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto out_free;\n\t\t\t}\n\n\t\t\t/* ignore disabled channels */\n\t\t\tif (chan->flags & IEEE80211_CHAN_DISABLED)\n\t\t\t\tcontinue;\n\n\t\t\trequest->channels[i] = chan;\n\t\t\ti++;\n\t\t}\n\t} else {\n\t\t/* all channels */\n\t\tfor (band = 0; band < IEEE80211_NUM_BANDS; band++) {\n\t\t\tint j;\n\t\t\tif (!wiphy->bands[band])\n\t\t\t\tcontinue;\n\t\t\tfor (j = 0; j < wiphy->bands[band]->n_channels; j++) {\n\t\t\t\tstruct ieee80211_channel *chan;\n\n\t\t\t\tchan = &wiphy->bands[band]->channels[j];\n\n\t\t\t\tif (chan->flags & IEEE80211_CHAN_DISABLED)\n\t\t\t\t\tcontinue;\n\n\t\t\t\trequest->channels[i] = chan;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!i) {\n\t\terr = -EINVAL;\n\t\tgoto out_free;\n\t}\n\n\trequest->n_channels = i;\n\n\ti = 0;\n\tif (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {\n\t\tnla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {\n\t\t\trequest->ssids[i].ssid_len = nla_len(attr);\n\t\t\tif (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto out_free;\n\t\t\t}\n\t\t\tmemcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));\n\t\t\ti++;\n\t\t}\n\t}\n\n\tif (info->attrs[NL80211_ATTR_IE]) {\n\t\trequest->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);\n\t\tmemcpy((void *)request->ie,\n\t\t nla_data(info->attrs[NL80211_ATTR_IE]),\n\t\t request->ie_len);\n\t}\n\n\trequest->dev = dev;\n\trequest->wiphy = &rdev->wiphy;\n\n\trdev->scan_req = request;\n\terr = rdev->ops->scan(&rdev->wiphy, dev, request);\n\n\tif (!err) {\n\t\tnl80211_send_scan_start(rdev, dev);\n\t\tdev_hold(dev);\n\t} else {\n out_free:\n\t\trdev->scan_req = NULL;\n\t\tkfree(request);\n\t}\n\n\treturn err;", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-2517", "cwe_id": "CWE-119" }, { "id": 477, "func": "obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n identifier arg;\n expr_ty annotation;\n int lineno;\n int col_offset;\n int end_lineno;\n int end_col_offset;\n\n if (_PyObject_LookupAttrId(obj, &PyId_arg, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"arg\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_identifier(tmp, &arg, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_annotation, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n annotation = NULL;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &annotation, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_col_offset, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"col_offset\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_end_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n end_lineno = 0;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &end_lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_end_col_offset, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n end_col_offset = 0;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &end_col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = arg(arg, annotation, lineno, col_offset, end_lineno, end_col_offset,\n arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 477, "func": "obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n identifier arg;\n expr_ty annotation;\n string type_comment;\n int lineno;\n int col_offset;\n int end_lineno;\n int end_col_offset;\n\n if (_PyObject_LookupAttrId(obj, &PyId_arg, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"arg\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_identifier(tmp, &arg, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_annotation, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n annotation = NULL;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &annotation, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_type_comment, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n type_comment = NULL;\n }\n else {\n int res;\n res = obj2ast_string(tmp, &type_comment, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_col_offset, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"col_offset\\\" missing from arg\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_end_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n end_lineno = 0;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &end_lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_end_col_offset, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n end_col_offset = 0;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &end_col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = arg(arg, annotation, type_comment, lineno, col_offset, end_lineno,\n end_col_offset, arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 558, "func": "static void array_cleanup( char* arr[] , int arr_size)\n{\n\tint i=0;\n\tfor( i=0; i< arr_size; i++ ){ \n\t\tif( arr[i*2] ){\n\t\t\tefree( arr[i*2]);\n\t\t}\n\t}\n\tefree(arr);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 558, "func": "static void array_cleanup( char* arr[] , int arr_size)\n{\n\tint i=0;\n\tfor( i=0; i< arr_size; i++ ){\n\t\tif( arr[i*2] ){\n\t\t\tefree( arr[i*2]);\n\t\t}\n\t}\n\tefree(arr);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 2878, "func": "_pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self)\n/*[clinic end generated code: output=e12af7e9bc1e4c77 input=97769247ce032c1d]*/\n{\n Py_ssize_t i;\n PyObject *new_memo = PyDict_New();\n if (new_memo == NULL)\n return NULL;\n\n for (i = 0; i < self->unpickler->memo_size; i++) {\n int status;\n PyObject *key, *value;\n\n value = self->unpickler->memo[i];\n if (value == NULL)\n continue;\n\n key = PyLong_FromSsize_t(i);\n if (key == NULL)\n goto error;\n status = PyDict_SetItem(new_memo, key, value);\n Py_DECREF(key);\n if (status < 0)\n goto error;\n }\n return new_memo;\n\nerror:\n Py_DECREF(new_memo);\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 2878, "func": "_pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self)\n/*[clinic end generated code: output=e12af7e9bc1e4c77 input=97769247ce032c1d]*/\n{\n size_t i;\n PyObject *new_memo = PyDict_New();\n if (new_memo == NULL)\n return NULL;\n\n for (i = 0; i < self->unpickler->memo_size; i++) {\n int status;\n PyObject *key, *value;\n\n value = self->unpickler->memo[i];\n if (value == NULL)\n continue;\n\n key = PyLong_FromSsize_t(i);\n if (key == NULL)\n goto error;\n status = PyDict_SetItem(new_memo, key, value);\n Py_DECREF(key);\n if (status < 0)\n goto error;\n }\n return new_memo;\n\nerror:\n Py_DECREF(new_memo);\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 280, "func": "TfLiteStatus EvalSum(TfLiteContext* context, TfLiteNode* node) {\n OpContext op_context(context, node);\n ruy::profiler::ScopeLabel label(\"Sum\");\n const auto& input = op_context.input;\n const auto& output = op_context.output;\n const bool same_scale =\n (input->params.scale == output->params.scale &&\n input->params.zero_point == output->params.zero_point);\n const bool eight_bit_quantized =\n input->type == kTfLiteUInt8 || input->type == kTfLiteInt8;\n const bool need_rescale = (eight_bit_quantized && !same_scale);\n if (need_rescale) {\n // Rescaling 8bit reduce sum.\n int num_axis = static_cast(NumElements(op_context.axis));\n TfLiteTensor* temp_index = GetTemporary(context, node, /*index=*/0);\n TfLiteTensor* resolved_axis = GetTemporary(context, node, /*index=*/1);\n TfLiteTensor* temp_sum = GetTemporary(context, node, /*index=*/2);\n // Resize the output tensor if the output tensor is dynamic.\n if (IsDynamicTensor(op_context.output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeTempAxis(context, &op_context, resolved_axis));\n TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, &op_context));\n TF_LITE_ENSURE_OK(context, ResizeTempSum(context, &op_context, temp_sum));\n }\n if (input->type == kTfLiteUInt8) {\n TF_LITE_ENSURE(\n context,\n reference_ops::QuantizedMeanOrSum<>(\n GetTensorData(op_context.input),\n op_context.input->params.zero_point,\n op_context.input->params.scale, op_context.input->dims->data,\n op_context.input->dims->size,\n GetTensorData(op_context.output),\n op_context.output->params.zero_point,\n op_context.output->params.scale, op_context.output->dims->data,\n op_context.output->dims->size,\n GetTensorData(op_context.axis), num_axis,\n op_context.params->keep_dims, GetTensorData(temp_index),\n GetTensorData(resolved_axis), GetTensorData(temp_sum),\n /*compute_sum=*/true));\n }\n if (input->type == kTfLiteInt8) {\n TF_LITE_ENSURE(\n context,\n reference_ops::QuantizedMeanOrSum<>(\n GetTensorData(op_context.input),\n op_context.input->params.zero_point,\n op_context.input->params.scale, op_context.input->dims->data,\n op_context.input->dims->size,\n GetTensorData(op_context.output),\n op_context.output->params.zero_point,\n op_context.output->params.scale, op_context.output->dims->data,\n op_context.output->dims->size,\n GetTensorData(op_context.axis), num_axis,\n op_context.params->keep_dims, GetTensorData(temp_index),\n GetTensorData(resolved_axis), GetTensorData(temp_sum),\n /*compute_sum=*/true));\n }\n } else {\n return EvalGeneric(context, node);\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 280, "func": "TfLiteStatus EvalSum(TfLiteContext* context, TfLiteNode* node) {\n OpContext op_context(context, node);\n ruy::profiler::ScopeLabel label(\"Sum\");\n const auto& input = op_context.input;\n const auto& output = op_context.output;\n const bool same_scale =\n (input->params.scale == output->params.scale &&\n input->params.zero_point == output->params.zero_point);\n const bool eight_bit_quantized =\n input->type == kTfLiteUInt8 || input->type == kTfLiteInt8;\n const bool need_rescale = (eight_bit_quantized && !same_scale);\n if (need_rescale) {\n // Rescaling 8bit reduce sum.\n int num_axis = static_cast(NumElements(op_context.axis));\n TfLiteTensor* temp_index;\n TF_LITE_ENSURE_OK(\n context, GetTemporarySafe(context, node, /*index=*/0, &temp_index));\n TfLiteTensor* resolved_axis;\n TF_LITE_ENSURE_OK(\n context, GetTemporarySafe(context, node, /*index=*/1, &resolved_axis));\n TfLiteTensor* temp_sum;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, /*index=*/2, &temp_sum));\n // Resize the output tensor if the output tensor is dynamic.\n if (IsDynamicTensor(op_context.output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeTempAxis(context, &op_context, resolved_axis));\n TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, &op_context));\n TF_LITE_ENSURE_OK(context, ResizeTempSum(context, &op_context, temp_sum));\n }\n if (input->type == kTfLiteUInt8) {\n TF_LITE_ENSURE(\n context,\n reference_ops::QuantizedMeanOrSum<>(\n GetTensorData(op_context.input),\n op_context.input->params.zero_point,\n op_context.input->params.scale, op_context.input->dims->data,\n op_context.input->dims->size,\n GetTensorData(op_context.output),\n op_context.output->params.zero_point,\n op_context.output->params.scale, op_context.output->dims->data,\n op_context.output->dims->size,\n GetTensorData(op_context.axis), num_axis,\n op_context.params->keep_dims, GetTensorData(temp_index),\n GetTensorData(resolved_axis), GetTensorData(temp_sum),\n /*compute_sum=*/true));\n }\n if (input->type == kTfLiteInt8) {\n TF_LITE_ENSURE(\n context,\n reference_ops::QuantizedMeanOrSum<>(\n GetTensorData(op_context.input),\n op_context.input->params.zero_point,\n op_context.input->params.scale, op_context.input->dims->data,\n op_context.input->dims->size,\n GetTensorData(op_context.output),\n op_context.output->params.zero_point,\n op_context.output->params.scale, op_context.output->dims->data,\n op_context.output->dims->size,\n GetTensorData(op_context.axis), num_axis,\n op_context.params->keep_dims, GetTensorData(temp_index),\n GetTensorData(resolved_axis), GetTensorData(temp_sum),\n /*compute_sum=*/true));\n }\n } else {\n return EvalGeneric(context, node);\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2977, "func": "static inline ulong encode_twos_comp(long n, int prec)\n{\n\tulong result;\n\tassert(prec >= 2);\n\tjas_eprintf(\"warning: support for signed data is untested\\n\");\n\t// NOTE: Is this correct?\n\tif (n < 0) {\n\t\tresult = -n;\n\t\tresult = (result ^ 0xffffffffUL) + 1;\n\t\tresult &= (1 << prec) - 1;\n\t} else {\n\t\tresult = n;\n\t}\n\treturn result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2977, "func": "static inline jas_ulong encode_twos_comp(long n, int prec)\n{\n\tjas_ulong result;\n\tassert(prec >= 2);\n\tjas_eprintf(\"warning: support for signed data is untested\\n\");\n\t// NOTE: Is this correct?\n\tif (n < 0) {\n\t\tresult = -n;\n\t\tresult = (result ^ 0xffffffffUL) + 1;\n\t\tresult &= (1 << prec) - 1;\n\t} else {\n\t\tresult = n;\n\t}\n\treturn result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2672, "func": "get_function_line(\n\texarg_T\t\t*eap,\n\tchar_u\t\t**line_to_free,\n\tint\t\tindent,\n\tgetline_opt_T\tgetline_options)\n{\n char_u *theline;\n\n if (eap->getline == NULL)\n\ttheline = getcmdline(':', 0L, indent, 0);\n else\n\ttheline = eap->getline(':', eap->cookie, indent, getline_options);\n if (theline != NULL)\n {\n\tif (*eap->cmdlinep == *line_to_free)\n\t *eap->cmdlinep = theline;\n\tvim_free(*line_to_free);\n\t*line_to_free = theline;\n }\n\n return theline;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0156", "cwe_id": "CWE-416" }, { "id": 2672, "func": "get_function_line(\n\texarg_T\t\t*eap,\n\tgarray_T\t*lines_to_free,\n\tint\t\tindent,\n\tgetline_opt_T\tgetline_options)\n{\n char_u *theline;\n\n if (eap->getline == NULL)\n\ttheline = getcmdline(':', 0L, indent, 0);\n else\n\ttheline = eap->getline(':', eap->cookie, indent, getline_options);\n if (theline != NULL)\n {\n\tif (lines_to_free->ga_len > 0\n\t\t&& *eap->cmdlinep == ((char_u **)lines_to_free->ga_data)\n\t\t\t\t\t\t [lines_to_free->ga_len - 1])\n\t *eap->cmdlinep = theline;\n\tga_add_string(lines_to_free, theline);\n }\n\n return theline;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0156", "cwe_id": "CWE-416" }, { "id": 338, "func": "read_subpkt(cdk_stream_t inp, cdk_subpkt_t * r_ctx, size_t * r_nbytes)\n{\n\tbyte c, c1;\n\tsize_t size, nread, n;\n\tcdk_subpkt_t node;\n\tcdk_error_t rc;\n\n\tif (!inp || !r_nbytes)\n\t\treturn CDK_Inv_Value;\n\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\"read_subpkt:\\n\");\n\n\tn = 0;\n\t*r_nbytes = 0;\n\tc = cdk_stream_getc(inp);\n\tn++;\n\tif (c == 255) {\n\t\tsize = read_32(inp);\n\t\tn += 4;\n\t} else if (c >= 192 && c < 255) {\n\t\tc1 = cdk_stream_getc(inp);\n\t\tn++;\n\t\tif (c1 == 0)\n\t\t\treturn 0;\n\t\tsize = ((c - 192) << 8) + c1 + 192;\n\t} else if (c < 192)\n\t\tsize = c;\n\telse\n\t\treturn CDK_Inv_Packet;\n\n\tnode = cdk_subpkt_new(size);\n\tif (!node)\n\t\treturn CDK_Out_Of_Core;\n\tnode->size = size;\n\tnode->type = cdk_stream_getc(inp);\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\" %d octets %d type\\n\", node->size,\n\t\t\t\t node->type);\n\tn++;\n\tnode->size--;\n\trc = stream_read(inp, node->d, node->size, &nread);\n\tn += nread;\n\tif (rc) {\n\t\tcdk_subpkt_free(node);\n\t\treturn rc;\n\t}\n\t*r_nbytes = n;\n\tif (!*r_ctx)\n\t\t*r_ctx = node;\n\telse\n\t\tcdk_subpkt_add(*r_ctx, node);\n\treturn rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-5335", "cwe_id": "CWE-125" }, { "id": 338, "func": "read_subpkt(cdk_stream_t inp, cdk_subpkt_t * r_ctx, size_t * r_nbytes)\n{\n\tint c, c1;\n\tsize_t size, nread, n;\n\tcdk_subpkt_t node;\n\tcdk_error_t rc;\n\n\tif (!inp || !r_nbytes)\n\t\treturn CDK_Inv_Value;\n\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\"read_subpkt:\\n\");\n\n\tn = 0;\n\t*r_nbytes = 0;\n\tc = cdk_stream_getc(inp);\n\tn++;\n\n\tif (c == 255) {\n\t\tsize = read_32(inp);\n\t\tif (size == (u32)-1)\n\t\t\treturn CDK_Inv_Packet;\n\n\t\tn += 4;\n\t} else if (c >= 192 && c < 255) {\n\t\tc1 = cdk_stream_getc(inp);\n\t\tif (c1 == EOF)\n\t\t\treturn CDK_Inv_Packet;\n\n\t\tn++;\n\t\tif (c1 == 0)\n\t\t\treturn 0;\n\t\tsize = ((c - 192) << 8) + c1 + 192;\n\t} else if (c < 192)\n\t\tsize = c;\n\telse\n\t\treturn CDK_Inv_Packet;\n\n\tnode = cdk_subpkt_new(size);\n\tif (!node)\n\t\treturn CDK_Out_Of_Core;\n\tnode->size = size;\n\tnode->type = cdk_stream_getc(inp);\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\" %d octets %d type\\n\", node->size,\n\t\t\t\t node->type);\n\tn++;\n\tnode->size--;\n\trc = stream_read(inp, node->d, node->size, &nread);\n\tn += nread;\n\tif (rc) {\n\t\tcdk_subpkt_free(node);\n\t\treturn rc;\n\t}\n\t*r_nbytes = n;\n\tif (!*r_ctx)\n\t\t*r_ctx = node;\n\telse\n\t\tcdk_subpkt_add(*r_ctx, node);\n\treturn rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-5335", "cwe_id": "CWE-125" }, { "id": 1872, "func": "int wait_for_key_construction(struct key *key, bool intr)\n{\n\tint ret;\n\n\tret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT,\n\t\t\t intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);\n\tif (ret)\n\t\treturn -ERESTARTSYS;\n\tif (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {\n\t\tsmp_rmb();\n\t\treturn key->reject_error;\n\t}\n\treturn key_validate(key);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-15951", "cwe_id": "CWE-20" }, { "id": 1872, "func": "int wait_for_key_construction(struct key *key, bool intr)\n{\n\tint ret;\n\n\tret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT,\n\t\t\t intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);\n\tif (ret)\n\t\treturn -ERESTARTSYS;\n\tret = key_read_state(key);\n\tif (ret < 0)\n\t\treturn ret;\n\treturn key_validate(key);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-15951", "cwe_id": "CWE-20" }, { "id": 2942, "func": "DU_getStringDOElement(DcmItem *obj, DcmTagKey t, char *s, size_t bufsize)\n{\n DcmByteString *elem;\n DcmStack stack;\n OFCondition ec = EC_Normal;\n char* aString;\n\n ec = obj->search(t, stack);\n elem = (DcmByteString*) stack.top();\n if (ec == EC_Normal && elem != NULL) {\n if (elem->getLength() == 0) {\n s[0] = '\\0';\n } else {\n ec = elem->getString(aString);\n OFStandard::strlcpy(s, aString, bufsize);\n }\n }\n return (ec == EC_Normal);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-41689", "cwe_id": "CWE-476" }, { "id": 2942, "func": "DU_getStringDOElement(DcmItem *obj, DcmTagKey t, char *s, size_t bufsize)\n{\n DcmByteString *elem;\n DcmStack stack;\n OFCondition ec = EC_Normal;\n char* aString;\n\n ec = obj->search(t, stack);\n elem = (DcmByteString*) stack.top();\n if (ec == EC_Normal && elem != NULL) {\n if (elem->getLength() == 0) {\n s[0] = '\\0';\n } else {\n ec = elem->getString(aString);\n if (ec == EC_Normal)\n OFStandard::strlcpy(s, aString, bufsize);\n }\n }\n return (ec == EC_Normal);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-41689", "cwe_id": "CWE-476" }, { "id": 513, "func": "static bool parse_notify(struct pool *pool, json_t *val)\n{\n\tchar *job_id, *prev_hash, *coinbase1, *coinbase2, *bbversion, *nbit,\n\t *ntime, header[228];\n\tunsigned char *cb1 = NULL, *cb2 = NULL;\n\tsize_t cb1_len, cb2_len, alloc_len;\n\tbool clean, ret = false;\n\tint merkles, i;\n\tjson_t *arr;\n\n\tarr = json_array_get(val, 4);\n\tif (!arr || !json_is_array(arr))\n\t\tgoto out;\n\n\tmerkles = json_array_size(arr);\n\n\tjob_id = json_array_string(val, 0);\n\tprev_hash = __json_array_string(val, 1);\n\tcoinbase1 = json_array_string(val, 2);\n\tcoinbase2 = json_array_string(val, 3);\n\tbbversion = __json_array_string(val, 5);\n\tnbit = __json_array_string(val, 6);\n\tntime = __json_array_string(val, 7);\n\tclean = json_is_true(json_array_get(val, 8));\n\n\tif (!job_id || !prev_hash || !coinbase1 || !coinbase2 || !bbversion || !nbit || !ntime) {\n\t\t/* Annoying but we must not leak memory */\n\t\tif (job_id)\n\t\t\tfree(job_id);\n\t\tif (coinbase1)\n\t\t\tfree(coinbase1);\n\t\tif (coinbase2)\n\t\t\tfree(coinbase2);\n\t\tgoto out;\n\t}\n\n\tcg_wlock(&pool->data_lock);\n\tfree(pool->swork.job_id);\n\tpool->swork.job_id = job_id;\n\tsnprintf(pool->prev_hash, 65, \"%s\", prev_hash);\n\tcb1_len = strlen(coinbase1) / 2;\n\tcb2_len = strlen(coinbase2) / 2;\n\tsnprintf(pool->bbversion, 9, \"%s\", bbversion);\n\tsnprintf(pool->nbit, 9, \"%s\", nbit);\n\tsnprintf(pool->ntime, 9, \"%s\", ntime);\n\tpool->swork.clean = clean;\n\talloc_len = pool->coinbase_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;\n\tpool->nonce2_offset = cb1_len + pool->n1_len;\n\n\tfor (i = 0; i < pool->merkles; i++)\n\t\tfree(pool->swork.merkle_bin[i]);\n\tif (merkles) {\n\t\tpool->swork.merkle_bin = realloc(pool->swork.merkle_bin,\n\t\t\t\t\t\t sizeof(char *) * merkles + 1);\n\t\tfor (i = 0; i < merkles; i++) {\n\t\t\tchar *merkle = json_array_string(arr, i);\n\n\t\t\tpool->swork.merkle_bin[i] = malloc(32);\n\t\t\tif (unlikely(!pool->swork.merkle_bin[i]))\n\t\t\t\tquit(1, \"Failed to malloc pool swork merkle_bin\");\n\t\t\tif (opt_protocol)\n\t\t\t\tapplog(LOG_DEBUG, \"merkle %d: %s\", i, merkle);\n\t\t\tret = hex2bin(pool->swork.merkle_bin[i], merkle, 32);\n\t\t\tfree(merkle);\n\t\t\tif (unlikely(!ret)) {\n\t\t\t\tapplog(LOG_ERR, \"Failed to convert merkle to merkle_bin in parse_notify\");\n\t\t\t\tgoto out_unlock;\n\t\t\t}\n\t\t}\n\t}\n\tpool->merkles = merkles;\n\tif (clean)\n\t\tpool->nonce2 = 0;\n#if 0\n\theader_len = \t\t strlen(pool->bbversion) +\n\t\t\t\t strlen(pool->prev_hash);\n\t/* merkle_hash */\t 32 +\n\t\t\t\t strlen(pool->ntime) +\n\t\t\t\t strlen(pool->nbit) +\n\t/* nonce */\t\t 8 +\n\t/* workpadding */\t 96;\n#endif\n\tsnprintf(header, 225,\n\t\t\"%s%s%s%s%s%s%s\",\n\t\tpool->bbversion,\n\t\tpool->prev_hash,\n\t\tblank_merkle,\n\t\tpool->ntime,\n\t\tpool->nbit,\n\t\t\"00000000\", /* nonce */\n\t\tworkpadding);\n\tret = hex2bin(pool->header_bin, header, 112);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert header to header_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\n\tcb1 = alloca(cb1_len);\n\tret = hex2bin(cb1, coinbase1, cb1_len);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert cb1 to cb1_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\tcb2 = alloca(cb2_len);\n\tret = hex2bin(cb2, coinbase2, cb2_len);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert cb2 to cb2_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\tfree(pool->coinbase);\n\talign_len(&alloc_len);\n\tpool->coinbase = calloc(alloc_len, 1);\n\tif (unlikely(!pool->coinbase))\n\t\tquit(1, \"Failed to calloc pool coinbase in parse_notify\");\n\tmemcpy(pool->coinbase, cb1, cb1_len);\n\tmemcpy(pool->coinbase + cb1_len, pool->nonce1bin, pool->n1_len);\n\tmemcpy(pool->coinbase + cb1_len + pool->n1_len + pool->n2size, cb2, cb2_len);\n\tif (opt_debug) {\n\t\tchar *cb = bin2hex(pool->coinbase, pool->coinbase_len);\n\n\t\tapplog(LOG_DEBUG, \"Pool %d coinbase %s\", pool->pool_no, cb);\n\t\tfree(cb);\n\t}\nout_unlock:\n\tcg_wunlock(&pool->data_lock);\n\n\tif (opt_protocol) {\n\t\tapplog(LOG_DEBUG, \"job_id: %s\", job_id);\n\t\tapplog(LOG_DEBUG, \"prev_hash: %s\", prev_hash);\n\t\tapplog(LOG_DEBUG, \"coinbase1: %s\", coinbase1);\n\t\tapplog(LOG_DEBUG, \"coinbase2: %s\", coinbase2);\n\t\tapplog(LOG_DEBUG, \"bbversion: %s\", bbversion);\n\t\tapplog(LOG_DEBUG, \"nbit: %s\", nbit);\n\t\tapplog(LOG_DEBUG, \"ntime: %s\", ntime);\n\t\tapplog(LOG_DEBUG, \"clean: %s\", clean ? \"yes\" : \"no\");\n\t}\n\tfree(coinbase1);\n\tfree(coinbase2);\n\n\t/* A notify message is the closest stratum gets to a getwork */\n\tpool->getwork_requested++;\n\ttotal_getworks++;\n\tif (pool == current_pool())\n\t\topt_work_update = true;\nout:\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-4501", "cwe_id": "CWE-119" }, { "id": 513, "func": "static bool parse_notify(struct pool *pool, json_t *val)\n{\n\tchar *job_id, *prev_hash, *coinbase1, *coinbase2, *bbversion, *nbit,\n\t *ntime, header[228];\n\tunsigned char *cb1 = NULL, *cb2 = NULL;\n\tsize_t cb1_len, cb2_len, alloc_len;\n\tbool clean, ret = false;\n\tint merkles, i;\n\tjson_t *arr;\n\n\tarr = json_array_get(val, 4);\n\tif (!arr || !json_is_array(arr))\n\t\tgoto out;\n\n\tmerkles = json_array_size(arr);\n\n\tjob_id = json_array_string(val, 0);\n\tprev_hash = __json_array_string(val, 1);\n\tcoinbase1 = json_array_string(val, 2);\n\tcoinbase2 = json_array_string(val, 3);\n\tbbversion = __json_array_string(val, 5);\n\tnbit = __json_array_string(val, 6);\n\tntime = __json_array_string(val, 7);\n\tclean = json_is_true(json_array_get(val, 8));\n\n\tif (!valid_hex(job_id) || !valid_hex(prev_hash) || !valid_hex(coinbase1) ||\n\t !valid_hex(coinbase2) || !valid_hex(bbversion) || !valid_hex(nbit) ||\n\t !valid_hex(ntime)) {\n\t\t/* Annoying but we must not leak memory */\n\t\tfree(job_id);\n\t\tfree(coinbase1);\n\t\tfree(coinbase2);\n\t\tgoto out;\n\t}\n\n\tcg_wlock(&pool->data_lock);\n\tfree(pool->swork.job_id);\n\tpool->swork.job_id = job_id;\n\tsnprintf(pool->prev_hash, 65, \"%s\", prev_hash);\n\tcb1_len = strlen(coinbase1) / 2;\n\tcb2_len = strlen(coinbase2) / 2;\n\tsnprintf(pool->bbversion, 9, \"%s\", bbversion);\n\tsnprintf(pool->nbit, 9, \"%s\", nbit);\n\tsnprintf(pool->ntime, 9, \"%s\", ntime);\n\tpool->swork.clean = clean;\n\talloc_len = pool->coinbase_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;\n\tpool->nonce2_offset = cb1_len + pool->n1_len;\n\n\tfor (i = 0; i < pool->merkles; i++)\n\t\tfree(pool->swork.merkle_bin[i]);\n\tif (merkles) {\n\t\tpool->swork.merkle_bin = realloc(pool->swork.merkle_bin,\n\t\t\t\t\t\t sizeof(char *) * merkles + 1);\n\t\tfor (i = 0; i < merkles; i++) {\n\t\t\tchar *merkle = json_array_string(arr, i);\n\n\t\t\tpool->swork.merkle_bin[i] = malloc(32);\n\t\t\tif (unlikely(!pool->swork.merkle_bin[i]))\n\t\t\t\tquit(1, \"Failed to malloc pool swork merkle_bin\");\n\t\t\tif (opt_protocol)\n\t\t\t\tapplog(LOG_DEBUG, \"merkle %d: %s\", i, merkle);\n\t\t\tret = hex2bin(pool->swork.merkle_bin[i], merkle, 32);\n\t\t\tfree(merkle);\n\t\t\tif (unlikely(!ret)) {\n\t\t\t\tapplog(LOG_ERR, \"Failed to convert merkle to merkle_bin in parse_notify\");\n\t\t\t\tgoto out_unlock;\n\t\t\t}\n\t\t}\n\t}\n\tpool->merkles = merkles;\n\tif (clean)\n\t\tpool->nonce2 = 0;\n#if 0\n\theader_len = \t\t strlen(pool->bbversion) +\n\t\t\t\t strlen(pool->prev_hash);\n\t/* merkle_hash */\t 32 +\n\t\t\t\t strlen(pool->ntime) +\n\t\t\t\t strlen(pool->nbit) +\n\t/* nonce */\t\t 8 +\n\t/* workpadding */\t 96;\n#endif\n\tsnprintf(header, 225,\n\t\t\"%s%s%s%s%s%s%s\",\n\t\tpool->bbversion,\n\t\tpool->prev_hash,\n\t\tblank_merkle,\n\t\tpool->ntime,\n\t\tpool->nbit,\n\t\t\"00000000\", /* nonce */\n\t\tworkpadding);\n\tret = hex2bin(pool->header_bin, header, 112);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert header to header_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\n\tcb1 = alloca(cb1_len);\n\tret = hex2bin(cb1, coinbase1, cb1_len);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert cb1 to cb1_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\tcb2 = alloca(cb2_len);\n\tret = hex2bin(cb2, coinbase2, cb2_len);\n\tif (unlikely(!ret)) {\n\t\tapplog(LOG_ERR, \"Failed to convert cb2 to cb2_bin in parse_notify\");\n\t\tgoto out_unlock;\n\t}\n\tfree(pool->coinbase);\n\talign_len(&alloc_len);\n\tpool->coinbase = calloc(alloc_len, 1);\n\tif (unlikely(!pool->coinbase))\n\t\tquit(1, \"Failed to calloc pool coinbase in parse_notify\");\n\tmemcpy(pool->coinbase, cb1, cb1_len);\n\tmemcpy(pool->coinbase + cb1_len, pool->nonce1bin, pool->n1_len);\n\tmemcpy(pool->coinbase + cb1_len + pool->n1_len + pool->n2size, cb2, cb2_len);\n\tif (opt_debug) {\n\t\tchar *cb = bin2hex(pool->coinbase, pool->coinbase_len);\n\n\t\tapplog(LOG_DEBUG, \"Pool %d coinbase %s\", pool->pool_no, cb);\n\t\tfree(cb);\n\t}\nout_unlock:\n\tcg_wunlock(&pool->data_lock);\n\n\tif (opt_protocol) {\n\t\tapplog(LOG_DEBUG, \"job_id: %s\", job_id);\n\t\tapplog(LOG_DEBUG, \"prev_hash: %s\", prev_hash);\n\t\tapplog(LOG_DEBUG, \"coinbase1: %s\", coinbase1);\n\t\tapplog(LOG_DEBUG, \"coinbase2: %s\", coinbase2);\n\t\tapplog(LOG_DEBUG, \"bbversion: %s\", bbversion);\n\t\tapplog(LOG_DEBUG, \"nbit: %s\", nbit);\n\t\tapplog(LOG_DEBUG, \"ntime: %s\", ntime);\n\t\tapplog(LOG_DEBUG, \"clean: %s\", clean ? \"yes\" : \"no\");\n\t}\n\tfree(coinbase1);\n\tfree(coinbase2);\n\n\t/* A notify message is the closest stratum gets to a getwork */\n\tpool->getwork_requested++;\n\ttotal_getworks++;\n\tif (pool == current_pool())\n\t\topt_work_update = true;\nout:\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-4501", "cwe_id": "CWE-119" }, { "id": 918, "func": "static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)\n{\n\tint ret;\n\n\tret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),\n\t\t\t PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0,\n\t\t\t indx, data, size, 100);\n\tif (ret < 0)\n\t\tnetif_dbg(pegasus, drv, pegasus->net,\n\t\t\t \"%s returned %d\\n\", __func__, ret);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-8068", "cwe_id": "CWE-119" }, { "id": 918, "func": "static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,\n\t\t\t const void *data)\n{\n\tu8 *buf;\n\tint ret;\n\n\tbuf = kmemdup(data, size, GFP_NOIO);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),\n\t\t\t PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0,\n\t\t\t indx, buf, size, 100);\n\tif (ret < 0)\n\t\tnetif_dbg(pegasus, drv, pegasus->net,\n\t\t\t \"%s returned %d\\n\", __func__, ret);\n\tkfree(buf);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-8068", "cwe_id": "CWE-119" }, { "id": 1992, "func": "static void iwjpeg_scan_exif(struct iwjpegrcontext *rctx,\n\t\tconst iw_byte *d, size_t d_len)\n{\n\tstruct iw_exif_state e;\n\tiw_uint32 ifd;\n\n\tif(d_len<8) return;\n\n\tiw_zeromem(&e,sizeof(struct iw_exif_state));\n\te.d = d;\n\te.d_len = d_len;\n\n\te.endian = d[0]=='I' ? IW_ENDIAN_LITTLE : IW_ENDIAN_BIG;\n\n\tifd = iw_get_ui32_e(&d[4],e.endian);\n\n\tiwjpeg_scan_exif_ifd(rctx,&e,ifd);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9204", "cwe_id": "CWE-125" }, { "id": 1992, "func": "static void iwjpeg_scan_exif(struct iwjpegrcontext *rctx,\n\t\tconst iw_byte *d, size_t d_len)\n{\n\tstruct iw_exif_state e;\n\tiw_uint32 ifd;\n\n\tif(d_len<8) return;\n\n\tiw_zeromem(&e,sizeof(struct iw_exif_state));\n\te.d = d;\n\te.d_len = d_len;\n\n\te.endian = d[0]=='I' ? IW_ENDIAN_LITTLE : IW_ENDIAN_BIG;\n\n\tifd = get_exif_ui32(&e, 4);\n\n\tiwjpeg_scan_exif_ifd(rctx,&e,ifd);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9204", "cwe_id": "CWE-125" }, { "id": 1717, "func": "static PyObject* patch(PyObject* self, PyObject* args)\n{\n char *origData, *newData, *diffBlock, *extraBlock, *diffPtr, *extraPtr;\n Py_ssize_t origDataLength, newDataLength, diffBlockLength, extraBlockLength;\n PyObject *controlTuples, *tuple, *results;\n off_t oldpos, newpos, x, y, z;\n int i, j, numTuples;\n\n if (!PyArg_ParseTuple(args, \"s#nO!s#s#\",\n &origData, &origDataLength, &newDataLength,\n &PyList_Type, &controlTuples,\n &diffBlock, &diffBlockLength,\n &extraBlock, &extraBlockLength))\n return NULL;\n\n /* allocate the memory for the new data */\n newData = PyMem_Malloc(newDataLength + 1);\n if (!newData)\n return PyErr_NoMemory();\n\n oldpos = 0;\n newpos = 0;\n diffPtr = diffBlock;\n extraPtr = extraBlock;\n numTuples = PyList_GET_SIZE(controlTuples);\n for (i = 0; i < numTuples; i++) {\n tuple = PyList_GET_ITEM(controlTuples, i);\n if (!PyTuple_Check(tuple)) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_TypeError, \"expecting tuple\");\n return NULL;\n }\n if (PyTuple_GET_SIZE(tuple) != 3) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_TypeError, \"expecting tuple of size 3\");\n return NULL;\n }\n x = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 0));\n y = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 1));\n z = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 2));\n if (newpos + x > newDataLength ||\n diffPtr + x > diffBlock + diffBlockLength ||\n extraPtr + y > extraBlock + extraBlockLength) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_ValueError, \"corrupt patch (overflow)\");\n return NULL;\n }\n memcpy(newData + newpos, diffPtr, x);\n diffPtr += x;\n for (j = 0; j < x; j++)\n if ((oldpos + j >= 0) && (oldpos + j < origDataLength))\n newData[newpos + j] += origData[oldpos + j];\n newpos += x;\n oldpos += x;\n memcpy(newData + newpos, extraPtr, y);\n extraPtr += y;\n newpos += y;\n oldpos += z;\n }\n\n /* confirm that a valid patch was applied */\n if (newpos != newDataLength ||\n diffPtr != diffBlock + diffBlockLength ||\n extraPtr != extraBlock + extraBlockLength) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_ValueError, \"corrupt patch (underflow)\");\n return NULL;\n }\n\n results = PyBytes_FromStringAndSize(newData, newDataLength);\n PyMem_Free(newData);\n return results;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15904", "cwe_id": "CWE-787" }, { "id": 1717, "func": "static PyObject* patch(PyObject* self, PyObject* args)\n{\n char *origData, *newData, *diffBlock, *extraBlock, *diffPtr, *extraPtr;\n Py_ssize_t origDataLength, newDataLength, diffBlockLength, extraBlockLength;\n PyObject *controlTuples, *tuple, *results;\n off_t oldpos, newpos, x, y, z;\n int i, j, numTuples;\n\n if (!PyArg_ParseTuple(args, \"s#nO!s#s#\",\n &origData, &origDataLength, &newDataLength,\n &PyList_Type, &controlTuples,\n &diffBlock, &diffBlockLength,\n &extraBlock, &extraBlockLength))\n return NULL;\n\n /* allocate the memory for the new data */\n newData = PyMem_Malloc(newDataLength + 1);\n if (!newData)\n return PyErr_NoMemory();\n\n oldpos = 0;\n newpos = 0;\n diffPtr = diffBlock;\n extraPtr = extraBlock;\n numTuples = PyList_GET_SIZE(controlTuples);\n for (i = 0; i < numTuples; i++) {\n tuple = PyList_GET_ITEM(controlTuples, i);\n if (!PyTuple_Check(tuple)) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_TypeError, \"expecting tuple\");\n return NULL;\n }\n if (PyTuple_GET_SIZE(tuple) != 3) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_TypeError, \"expecting tuple of size 3\");\n return NULL;\n }\n x = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 0));\n y = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 1));\n z = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 2));\n if (newpos + x > newDataLength ||\n diffPtr + x > diffBlock + diffBlockLength) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_ValueError, \"corrupt patch (overflow)\");\n return NULL;\n }\n memcpy(newData + newpos, diffPtr, x);\n diffPtr += x;\n for (j = 0; j < x; j++)\n if ((oldpos + j >= 0) && (oldpos + j < origDataLength))\n newData[newpos + j] += origData[oldpos + j];\n newpos += x;\n oldpos += x;\n if (newpos + y > newDataLength ||\n extraPtr + y > extraBlock + extraBlockLength) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_ValueError, \"corrupt patch (overflow)\");\n return NULL;\n }\n memcpy(newData + newpos, extraPtr, y);\n extraPtr += y;\n newpos += y;\n oldpos += z;\n }\n\n /* confirm that a valid patch was applied */\n if (newpos != newDataLength ||\n diffPtr != diffBlock + diffBlockLength ||\n extraPtr != extraBlock + extraBlockLength) {\n PyMem_Free(newData);\n PyErr_SetString(PyExc_ValueError, \"corrupt patch (underflow)\");\n return NULL;\n }\n\n results = PyBytes_FromStringAndSize(newData, newDataLength);\n PyMem_Free(newData);\n return results;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15904", "cwe_id": "CWE-787" }, { "id": 2732, "func": "static bcon_error_t bson_append_bcon_with_state(bson *b, const bcon *bc, bcon_state_t start_state) {\n bcon_error_t ret = BCON_OK;\n bcon_state_t state = start_state;\n char *key = 0;\n char *typespec = 0;\n unsigned char doc_stack[DOC_STACK_SIZE];\n size_t doc_stack_pointer = 0;\n size_t array_index = 0;\n unsigned int array_index_stack[ARRAY_INDEX_STACK_SIZE];\n size_t array_index_stack_pointer = 0;\n char array_index_buffer[ARRAY_INDEX_BUFFER_SIZE]; /* max BSON size */\n int end_of_data;\n const bcon *bcp;\n for (end_of_data = 0, bcp = bc; ret == BCON_OK && !end_of_data; bcp++) {\n bcon bci = *bcp;\n char *s = bci.s;\n switch (state) {\n case State_Element:\n switch (bcon_token(s)) {\n case Token_CloseBrace:\n bson_append_finish_object( b );\n DOC_POP_STATE; /* state = ...; */\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n key = s;\n state = State_DocSpecValue;\n break;\n }\n break;\n case State_DocSpecValue:\n switch (bcon_token(s)) {\n case Token_Typespec:\n typespec = s;\n state = State_DocValue;\n break;\n case Token_OpenBrace:\n bson_append_start_object( b, key );\n DOC_PUSH_STATE(State_Element);\n state = State_Element;\n break;\n case Token_OpenBracket:\n bson_append_start_array( b, key );\n ARRAY_PUSH_RESET_INDEX_STATE(State_Element);\n state = State_ArraySpecValue;\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_Element;\n break;\n }\n break;\n case State_DocValue:\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_Element;\n typespec = 0;\n break;\n case State_ArraySpecValue:\n switch (bcon_token(s)) {\n case Token_Typespec:\n typespec = s;\n state = State_ArrayValue;\n break;\n case Token_OpenBrace:\n key = ARRAY_KEY_STRING(array_index++);\n bson_append_start_object( b, key );\n DOC_PUSH_STATE(State_ArraySpecValue);\n state = State_Element;\n break;\n case Token_OpenBracket:\n key = ARRAY_KEY_STRING(array_index++);\n bson_append_start_array( b, key );\n ARRAY_PUSH_RESET_INDEX_STATE(State_ArraySpecValue);\n /* state = State_ArraySpecValue; */\n break;\n case Token_CloseBracket:\n bson_append_finish_array( b );\n ARRAY_POP_INDEX_STATE; /* state = ...; */\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n key = ARRAY_KEY_STRING(array_index++);\n ret = bson_bcon_key_value(b, key, typespec, bci);\n /* state = State_ArraySpecValue; */\n break;\n }\n break;\n case State_ArrayValue:\n key = ARRAY_KEY_STRING(array_index++);\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_ArraySpecValue;\n typespec = 0;\n break;\n default: assert(NOT_REACHED); break;\n }\n }\n return state == start_state ? BCON_OK : BCON_DOCUMENT_INCOMPLETE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2732, "func": "static bcon_error_t bson_append_bcon_with_state(bson *b, const bcon *bc, bcon_state_t start_state) {\n bcon_error_t ret = BCON_OK;\n bcon_state_t state = start_state;\n char *key = 0;\n char *typespec = 0;\n unsigned char doc_stack[DOC_STACK_SIZE];\n size_t doc_stack_pointer = 0;\n size_t array_index = 0;\n size_t array_index_stack[ARRAY_INDEX_STACK_SIZE];\n size_t array_index_stack_pointer = 0;\n char array_index_buffer[ARRAY_INDEX_BUFFER_SIZE]; /* max BSON size */\n int end_of_data;\n const bcon *bcp;\n for (end_of_data = 0, bcp = bc; ret == BCON_OK && !end_of_data; bcp++) {\n bcon bci = *bcp;\n char *s = bci.s;\n switch (state) {\n case State_Element:\n switch (bcon_token(s)) {\n case Token_CloseBrace:\n bson_append_finish_object( b );\n DOC_POP_STATE; /* state = ...; */\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n key = s;\n state = State_DocSpecValue;\n break;\n }\n break;\n case State_DocSpecValue:\n switch (bcon_token(s)) {\n case Token_Typespec:\n typespec = s;\n state = State_DocValue;\n break;\n case Token_OpenBrace:\n bson_append_start_object( b, key );\n DOC_PUSH_STATE(State_Element);\n state = State_Element;\n break;\n case Token_OpenBracket:\n bson_append_start_array( b, key );\n ARRAY_PUSH_RESET_INDEX_STATE(State_Element);\n state = State_ArraySpecValue;\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_Element;\n break;\n }\n break;\n case State_DocValue:\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_Element;\n typespec = 0;\n break;\n case State_ArraySpecValue:\n switch (bcon_token(s)) {\n case Token_Typespec:\n typespec = s;\n state = State_ArrayValue;\n break;\n case Token_OpenBrace:\n key = ARRAY_KEY_STRING(array_index++);\n bson_append_start_object( b, key );\n DOC_PUSH_STATE(State_ArraySpecValue);\n state = State_Element;\n break;\n case Token_OpenBracket:\n key = ARRAY_KEY_STRING(array_index++);\n bson_append_start_array( b, key );\n ARRAY_PUSH_RESET_INDEX_STATE(State_ArraySpecValue);\n /* state = State_ArraySpecValue; */\n break;\n case Token_CloseBracket:\n bson_append_finish_array( b );\n ARRAY_POP_INDEX_STATE; /* state = ...; */\n break;\n case Token_End:\n end_of_data = 1;\n break;\n default:\n key = ARRAY_KEY_STRING(array_index++);\n ret = bson_bcon_key_value(b, key, typespec, bci);\n /* state = State_ArraySpecValue; */\n break;\n }\n break;\n case State_ArrayValue:\n key = ARRAY_KEY_STRING(array_index++);\n ret = bson_bcon_key_value(b, key, typespec, bci);\n state = State_ArraySpecValue;\n typespec = 0;\n break;\n default: assert(NOT_REACHED); break;\n }\n }\n return state == start_state ? BCON_OK : BCON_DOCUMENT_INCOMPLETE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2928, "func": "cdf_read_short_sector_chain(const cdf_header_t *h,\n const cdf_sat_t *ssat, const cdf_stream_t *sst,\n cdf_secid_t sid, size_t len, cdf_stream_t *scn)\n{\n\tsize_t ss = CDF_SEC_SIZE(h), i, j;\n\tscn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));\n\tscn->sst_dirlen = len;\n\n\tif (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)\n\t\treturn -1;\n\n\tscn->sst_tab = calloc(scn->sst_len, ss);\n\tif (scn->sst_tab == NULL)\n\t\treturn -1;\n\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read short sector chain loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (i >= scn->sst_len) {\n\t\t\tDPRINTF((\"Out of bounds reading short sector chain \"\n\t\t\t \"%\" SIZE_T_FORMAT \"u > %\" SIZE_T_FORMAT \"u\\n\",\n\t\t\t i, scn->sst_len));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,\n\t\t sid) != (ssize_t)ss) {\n\t\t\tDPRINTF((\"Reading short sector chain %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);\n\t}\n\treturn 0;\nout:\n\tfree(scn->sst_tab);\n\treturn -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-1571", "cwe_id": "CWE-119" }, { "id": 2928, "func": "cdf_read_short_sector_chain(const cdf_header_t *h,\n const cdf_sat_t *ssat, const cdf_stream_t *sst,\n cdf_secid_t sid, size_t len, cdf_stream_t *scn)\n{\n\tsize_t ss = CDF_SHORT_SEC_SIZE(h), i, j;\n\tscn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));\n\tscn->sst_dirlen = len;\n\n\tif (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)\n\t\treturn -1;\n\n\tscn->sst_tab = calloc(scn->sst_len, ss);\n\tif (scn->sst_tab == NULL)\n\t\treturn -1;\n\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read short sector chain loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (i >= scn->sst_len) {\n\t\t\tDPRINTF((\"Out of bounds reading short sector chain \"\n\t\t\t \"%\" SIZE_T_FORMAT \"u > %\" SIZE_T_FORMAT \"u\\n\",\n\t\t\t i, scn->sst_len));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,\n\t\t sid) != (ssize_t)ss) {\n\t\t\tDPRINTF((\"Reading short sector chain %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);\n\t}\n\treturn 0;\nout:\n\tfree(scn->sst_tab);\n\treturn -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-1571", "cwe_id": "CWE-119" }, { "id": 2708, "func": "MONGO_EXPORT int bson_append_symbol_n( bson *b, const char *name, const char *value, int len ) {\n return bson_append_string_base( b, name, value, len, BSON_SYMBOL );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2708, "func": "MONGO_EXPORT int bson_append_symbol_n( bson *b, const char *name, const char *value, size_t len ) {\n return bson_append_string_base( b, name, value, len, BSON_SYMBOL );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 928, "func": "static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,\n size_t size, bool no_rss)\n{\n VirtIONet *n = qemu_get_nic_opaque(nc);\n VirtIONetQueue *q = virtio_net_get_subqueue(nc);\n VirtIODevice *vdev = VIRTIO_DEVICE(n);\n struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];\n struct virtio_net_hdr_mrg_rxbuf mhdr;\n unsigned mhdr_cnt = 0;\n size_t offset, i, guest_offset;\n\n if (!virtio_net_can_receive(nc)) {\n return -1;\n }\n\n if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss) {\n int index = virtio_net_process_rss(nc, buf, size);\n if (index >= 0) {\n NetClientState *nc2 = qemu_get_subqueue(n->nic, index);\n return virtio_net_receive_rcu(nc2, buf, size, true);\n }\n }\n\n /* hdr_len refers to the header we supply to the guest */\n if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {\n return 0;\n }\n\n if (!receive_filter(n, buf, size))\n return size;\n\n offset = i = 0;\n\n while (offset < size) {\n VirtQueueElement *elem;\n int len, total;\n const struct iovec *sg;\n\n total = 0;\n\n elem = virtqueue_pop(q->rx_vq, sizeof(VirtQueueElement));\n if (!elem) {\n if (i) {\n virtio_error(vdev, \"virtio-net unexpected empty queue: \"\n \"i %zd mergeable %d offset %zd, size %zd, \"\n \"guest hdr len %zd, host hdr len %zd \"\n \"guest features 0x%\" PRIx64,\n i, n->mergeable_rx_bufs, offset, size,\n n->guest_hdr_len, n->host_hdr_len,\n vdev->guest_features);\n }\n return -1;\n }\n\n if (elem->in_num < 1) {\n virtio_error(vdev,\n \"virtio-net receive queue contains no in buffers\");\n virtqueue_detach_element(q->rx_vq, elem, 0);\n g_free(elem);\n return -1;\n }\n\n sg = elem->in_sg;\n if (i == 0) {\n assert(offset == 0);\n if (n->mergeable_rx_bufs) {\n mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),\n sg, elem->in_num,\n offsetof(typeof(mhdr), num_buffers),\n sizeof(mhdr.num_buffers));\n }\n\n receive_header(n, sg, elem->in_num, buf, size);\n if (n->rss_data.populate_hash) {\n offset = sizeof(mhdr);\n iov_from_buf(sg, elem->in_num, offset,\n buf + offset, n->host_hdr_len - sizeof(mhdr));\n }\n offset = n->host_hdr_len;\n total += n->guest_hdr_len;\n guest_offset = n->guest_hdr_len;\n } else {\n guest_offset = 0;\n }\n\n /* copy in packet. ugh */\n len = iov_from_buf(sg, elem->in_num, guest_offset,\n buf + offset, size - offset);\n total += len;\n offset += len;\n /* If buffers can't be merged, at this point we\n * must have consumed the complete packet.\n * Otherwise, drop it. */\n if (!n->mergeable_rx_bufs && offset < size) {\n virtqueue_unpop(q->rx_vq, elem, total);\n g_free(elem);\n return size;\n }\n\n /* signal other side */\n virtqueue_fill(q->rx_vq, elem, total, i++);\n g_free(elem);\n }\n\n if (mhdr_cnt) {\n virtio_stw_p(vdev, &mhdr.num_buffers, i);\n iov_from_buf(mhdr_sg, mhdr_cnt,\n 0,\n &mhdr.num_buffers, sizeof mhdr.num_buffers);\n }\n\n virtqueue_flush(q->rx_vq, i);\n virtio_notify(vdev, q->rx_vq);\n\n return size;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-3748", "cwe_id": "CWE-416" }, { "id": 928, "func": "static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,\n size_t size, bool no_rss)\n{\n VirtIONet *n = qemu_get_nic_opaque(nc);\n VirtIONetQueue *q = virtio_net_get_subqueue(nc);\n VirtIODevice *vdev = VIRTIO_DEVICE(n);\n VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE];\n size_t lens[VIRTQUEUE_MAX_SIZE];\n struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];\n struct virtio_net_hdr_mrg_rxbuf mhdr;\n unsigned mhdr_cnt = 0;\n size_t offset, i, guest_offset, j;\n ssize_t err;\n\n if (!virtio_net_can_receive(nc)) {\n return -1;\n }\n\n if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss) {\n int index = virtio_net_process_rss(nc, buf, size);\n if (index >= 0) {\n NetClientState *nc2 = qemu_get_subqueue(n->nic, index);\n return virtio_net_receive_rcu(nc2, buf, size, true);\n }\n }\n\n /* hdr_len refers to the header we supply to the guest */\n if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {\n return 0;\n }\n\n if (!receive_filter(n, buf, size))\n return size;\n\n offset = i = 0;\n\n while (offset < size) {\n VirtQueueElement *elem;\n int len, total;\n const struct iovec *sg;\n\n total = 0;\n\n if (i == VIRTQUEUE_MAX_SIZE) {\n virtio_error(vdev, \"virtio-net unexpected long buffer chain\");\n err = size;\n goto err;\n }\n\n elem = virtqueue_pop(q->rx_vq, sizeof(VirtQueueElement));\n if (!elem) {\n if (i) {\n virtio_error(vdev, \"virtio-net unexpected empty queue: \"\n \"i %zd mergeable %d offset %zd, size %zd, \"\n \"guest hdr len %zd, host hdr len %zd \"\n \"guest features 0x%\" PRIx64,\n i, n->mergeable_rx_bufs, offset, size,\n n->guest_hdr_len, n->host_hdr_len,\n vdev->guest_features);\n }\n err = -1;\n goto err;\n }\n\n if (elem->in_num < 1) {\n virtio_error(vdev,\n \"virtio-net receive queue contains no in buffers\");\n virtqueue_detach_element(q->rx_vq, elem, 0);\n g_free(elem);\n err = -1;\n goto err;\n }\n\n sg = elem->in_sg;\n if (i == 0) {\n assert(offset == 0);\n if (n->mergeable_rx_bufs) {\n mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),\n sg, elem->in_num,\n offsetof(typeof(mhdr), num_buffers),\n sizeof(mhdr.num_buffers));\n }\n\n receive_header(n, sg, elem->in_num, buf, size);\n if (n->rss_data.populate_hash) {\n offset = sizeof(mhdr);\n iov_from_buf(sg, elem->in_num, offset,\n buf + offset, n->host_hdr_len - sizeof(mhdr));\n }\n offset = n->host_hdr_len;\n total += n->guest_hdr_len;\n guest_offset = n->guest_hdr_len;\n } else {\n guest_offset = 0;\n }\n\n /* copy in packet. ugh */\n len = iov_from_buf(sg, elem->in_num, guest_offset,\n buf + offset, size - offset);\n total += len;\n offset += len;\n /* If buffers can't be merged, at this point we\n * must have consumed the complete packet.\n * Otherwise, drop it. */\n if (!n->mergeable_rx_bufs && offset < size) {\n virtqueue_unpop(q->rx_vq, elem, total);\n g_free(elem);\n err = size;\n goto err;\n }\n\n elems[i] = elem;\n lens[i] = total;\n i++;\n }\n\n if (mhdr_cnt) {\n virtio_stw_p(vdev, &mhdr.num_buffers, i);\n iov_from_buf(mhdr_sg, mhdr_cnt,\n 0,\n &mhdr.num_buffers, sizeof mhdr.num_buffers);\n }\n\n for (j = 0; j < i; j++) {\n /* signal other side */\n virtqueue_fill(q->rx_vq, elems[j], lens[j], j);\n g_free(elems[j]);\n }\n\n virtqueue_flush(q->rx_vq, i);\n virtio_notify(vdev, q->rx_vq);\n\n return size;\n\nerr:\n for (j = 0; j < i; j++) {\n g_free(elems[j]);\n }\n\n return err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-3748", "cwe_id": "CWE-416" }, { "id": 682, "func": "static int netlbl_cipsov4_add_common(struct genl_info *info,\n\t\t\t\t struct cipso_v4_doi *doi_def)\n{\n\tstruct nlattr *nla;\n\tint nla_rem;\n\tu32 iter = 0;\n\n\tdoi_def->doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);\n\n\tif (nla_validate_nested(info->attrs[NLBL_CIPSOV4_A_TAGLST],\n\t\t\t\tNLBL_CIPSOV4_A_MAX,\n\t\t\t\tnetlbl_cipsov4_genl_policy) != 0)\n\t\treturn -EINVAL;\n\n\tnla_for_each_nested(nla, info->attrs[NLBL_CIPSOV4_A_TAGLST], nla_rem)\n\t\tif (nla->nla_type == NLBL_CIPSOV4_A_TAG) {\n\t\t\tif (iter > CIPSO_V4_TAG_MAXCNT)\n\t\t\t\treturn -EINVAL;\n\t\t\tdoi_def->tags[iter++] = nla_get_u8(nla);\n\t\t}\n\tif (iter < CIPSO_V4_TAG_MAXCNT)\n\t\tdoi_def->tags[iter] = CIPSO_V4_TAG_INVALID;\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2007-6762", "cwe_id": "CWE-119" }, { "id": 682, "func": "static int netlbl_cipsov4_add_common(struct genl_info *info,\n\t\t\t\t struct cipso_v4_doi *doi_def)\n{\n\tstruct nlattr *nla;\n\tint nla_rem;\n\tu32 iter = 0;\n\n\tdoi_def->doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);\n\n\tif (nla_validate_nested(info->attrs[NLBL_CIPSOV4_A_TAGLST],\n\t\t\t\tNLBL_CIPSOV4_A_MAX,\n\t\t\t\tnetlbl_cipsov4_genl_policy) != 0)\n\t\treturn -EINVAL;\n\n\tnla_for_each_nested(nla, info->attrs[NLBL_CIPSOV4_A_TAGLST], nla_rem)\n\t\tif (nla->nla_type == NLBL_CIPSOV4_A_TAG) {\n\t\t\tif (iter >= CIPSO_V4_TAG_MAXCNT)\n\t\t\t\treturn -EINVAL;\n\t\t\tdoi_def->tags[iter++] = nla_get_u8(nla);\n\t\t}\n\twhile (iter < CIPSO_V4_TAG_MAXCNT)\n\t\tdoi_def->tags[iter++] = CIPSO_V4_TAG_INVALID;\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2007-6762", "cwe_id": "CWE-119" }, { "id": 1821, "func": "static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info,\n\t\t\t\t void __user *arg)\n{\n\tstruct btrfs_ioctl_dev_info_args *di_args;\n\tstruct btrfs_device *dev;\n\tint ret = 0;\n\tchar *s_uuid = NULL;\n\n\tdi_args = memdup_user(arg, sizeof(*di_args));\n\tif (IS_ERR(di_args))\n\t\treturn PTR_ERR(di_args);\n\n\tif (!btrfs_is_empty_uuid(di_args->uuid))\n\t\ts_uuid = di_args->uuid;\n\n\trcu_read_lock();\n\tdev = btrfs_find_device(fs_info->fs_devices, di_args->devid, s_uuid,\n\t\t\t\tNULL);\n\n\tif (!dev) {\n\t\tret = -ENODEV;\n\t\tgoto out;\n\t}\n\n\tdi_args->devid = dev->devid;\n\tdi_args->bytes_used = btrfs_device_get_bytes_used(dev);\n\tdi_args->total_bytes = btrfs_device_get_total_bytes(dev);\n\tmemcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));\n\tif (dev->name) {\n\t\tstrncpy(di_args->path, rcu_str_deref(dev->name),\n\t\t\t\tsizeof(di_args->path) - 1);\n\t\tdi_args->path[sizeof(di_args->path) - 1] = 0;\n\t} else {\n\t\tdi_args->path[0] = '\\0';\n\t}\n\nout:\n\trcu_read_unlock();\n\tif (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))\n\t\tret = -EFAULT;\n\n\tkfree(di_args);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 1821, "func": "static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info,\n\t\t\t\t void __user *arg)\n{\n\tstruct btrfs_ioctl_dev_info_args *di_args;\n\tstruct btrfs_device *dev;\n\tint ret = 0;\n\tchar *s_uuid = NULL;\n\n\tdi_args = memdup_user(arg, sizeof(*di_args));\n\tif (IS_ERR(di_args))\n\t\treturn PTR_ERR(di_args);\n\n\tif (!btrfs_is_empty_uuid(di_args->uuid))\n\t\ts_uuid = di_args->uuid;\n\n\trcu_read_lock();\n\tdev = btrfs_find_device(fs_info->fs_devices, di_args->devid, s_uuid,\n\t\t\t\tNULL, true);\n\n\tif (!dev) {\n\t\tret = -ENODEV;\n\t\tgoto out;\n\t}\n\n\tdi_args->devid = dev->devid;\n\tdi_args->bytes_used = btrfs_device_get_bytes_used(dev);\n\tdi_args->total_bytes = btrfs_device_get_total_bytes(dev);\n\tmemcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));\n\tif (dev->name) {\n\t\tstrncpy(di_args->path, rcu_str_deref(dev->name),\n\t\t\t\tsizeof(di_args->path) - 1);\n\t\tdi_args->path[sizeof(di_args->path) - 1] = 0;\n\t} else {\n\t\tdi_args->path[0] = '\\0';\n\t}\n\nout:\n\trcu_read_unlock();\n\tif (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))\n\t\tret = -EFAULT;\n\n\tkfree(di_args);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 1387, "func": "void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)\n{\n\tint dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;\n\tint wid;\n\tint w, wstart;\n\tint thick = im->thick;\n\n\tif (color == gdAntiAliased) {\n\t\t/* \n\t\t gdAntiAliased passed as color: use the much faster, much cheaper\n\t\t and equally attractive gdImageAALine implementation. That\n\t\t clips too, so don't clip twice.\n\t\t */\n\t\tgdImageAALine(im, x1, y1, x2, y2, im->AA_color); \n\t\treturn;\n\t}\n\n\t/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */\n\tif (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {\n\t\treturn;\n\t}\n\n\tdx = abs (x2 - x1);\n\tdy = abs (y2 - y1);\n\n\tif (dx == 0) {\n\t\tgdImageVLine(im, x1, y1, y2, color);\n\t\treturn;\n\t} else if (dy == 0) {\n\t\tgdImageHLine(im, y1, x1, x2, color);\n\t\treturn;\n\t}\n\n\tif (dy <= dx) {\n\t\t/* More-or-less horizontal. use wid for vertical stroke */\n\t\t/* Doug Claar: watch out for NaN in atan2 (2.0.5) */\n\t\tif ((dx == 0) && (dy == 0)) {\n\t\t\twid = 1;\n\t\t} else {\n\t\t\t/* 2.0.12: Michael Schwartz: divide rather than multiply;\nTBB: but watch out for /0! */\n\t\t\tdouble ac = cos (atan2 (dy, dx));\n\t\t\tif (ac != 0) {\n\t\t\t\twid = thick / ac;\n\t\t\t} else {\n\t\t\t\twid = 1;\n\t\t\t}\n\t\t\tif (wid == 0) {\n\t\t\t\twid = 1;\n\t\t\t}\n\t\t}\n\t\td = 2 * dy - dx;\n\t\tincr1 = 2 * dy;\n\t\tincr2 = 2 * (dy - dx);\n\t\tif (x1 > x2) {\n\t\t\tx = x2;\n\t\t\ty = y2;\n\t\t\tydirflag = (-1);\n\t\t\txend = x1;\n\t\t} else {\n\t\t\tx = x1;\n\t\t\ty = y1;\n\t\t\tydirflag = 1;\n\t\t\txend = x2;\n\t\t}\n\n\t\t/* Set up line thickness */\n\t\twstart = y - wid / 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel(im, x, w, color);\n\t\t}\n\n\t\tif (((y2 - y1) * ydirflag) > 0) {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* More-or-less vertical. use wid for horizontal stroke */\n\t\t/* 2.0.12: Michael Schwartz: divide rather than multiply;\n\t\t TBB: but watch out for /0! */\n\t\tdouble as = sin (atan2 (dy, dx));\n\t\tif (as != 0) {\n\t\t\twid = thick / as;\n\t\t} else {\n\t\t\twid = 1;\n\t\t}\n\t\tif (wid == 0) {\n\t\t\twid = 1;\n\t\t}\n\n\t\td = 2 * dx - dy;\n\t\tincr1 = 2 * dx;\n\t\tincr2 = 2 * (dx - dy);\n\t\tif (y1 > y2) {\n\t\t\ty = y2;\n\t\t\tx = x2;\n\t\t\tyend = y1;\n\t\t\txdirflag = (-1);\n\t\t} else {\n\t\t\ty = y1;\n\t\t\tx = x1;\n\t\t\tyend = y2;\n\t\t\txdirflag = 1;\n\t\t}\n\n\t\t/* Set up line thickness */\n\t\twstart = x - wid / 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t}\n\n\t\tif (((x2 - x1) * xdirflag) > 0) {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5767", "cwe_id": "CWE-190" }, { "id": 1387, "func": "void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)\n{\n\tint dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;\n\tint wid;\n\tint w, wstart;\n\tint thick = im->thick;\n\n\tif (color == gdAntiAliased) {\n\t\t/*\n\t\t gdAntiAliased passed as color: use the much faster, much cheaper\n\t\t and equally attractive gdImageAALine implementation. That\n\t\t clips too, so don't clip twice.\n\t\t */\n\t\tgdImageAALine(im, x1, y1, x2, y2, im->AA_color);\n\t\treturn;\n\t}\n\n\t/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */\n\tif (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {\n\t\treturn;\n\t}\n\n\tdx = abs (x2 - x1);\n\tdy = abs (y2 - y1);\n\n\tif (dx == 0) {\n\t\tgdImageVLine(im, x1, y1, y2, color);\n\t\treturn;\n\t} else if (dy == 0) {\n\t\tgdImageHLine(im, y1, x1, x2, color);\n\t\treturn;\n\t}\n\n\tif (dy <= dx) {\n\t\t/* More-or-less horizontal. use wid for vertical stroke */\n\t\t/* Doug Claar: watch out for NaN in atan2 (2.0.5) */\n\t\tif ((dx == 0) && (dy == 0)) {\n\t\t\twid = 1;\n\t\t} else {\n\t\t\t/* 2.0.12: Michael Schwartz: divide rather than multiply;\nTBB: but watch out for /0! */\n\t\t\tdouble ac = cos (atan2 (dy, dx));\n\t\t\tif (ac != 0) {\n\t\t\t\twid = thick / ac;\n\t\t\t} else {\n\t\t\t\twid = 1;\n\t\t\t}\n\t\t\tif (wid == 0) {\n\t\t\t\twid = 1;\n\t\t\t}\n\t\t}\n\t\td = 2 * dy - dx;\n\t\tincr1 = 2 * dy;\n\t\tincr2 = 2 * (dy - dx);\n\t\tif (x1 > x2) {\n\t\t\tx = x2;\n\t\t\ty = y2;\n\t\t\tydirflag = (-1);\n\t\t\txend = x1;\n\t\t} else {\n\t\t\tx = x1;\n\t\t\ty = y1;\n\t\t\tydirflag = 1;\n\t\t\txend = x2;\n\t\t}\n\n\t\t/* Set up line thickness */\n\t\twstart = y - wid / 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel(im, x, w, color);\n\t\t}\n\n\t\tif (((y2 - y1) * ydirflag) > 0) {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* More-or-less vertical. use wid for horizontal stroke */\n\t\t/* 2.0.12: Michael Schwartz: divide rather than multiply;\n\t\t TBB: but watch out for /0! */\n\t\tdouble as = sin (atan2 (dy, dx));\n\t\tif (as != 0) {\n\t\t\twid = thick / as;\n\t\t} else {\n\t\t\twid = 1;\n\t\t}\n\t\tif (wid == 0) {\n\t\t\twid = 1;\n\t\t}\n\n\t\td = 2 * dx - dy;\n\t\tincr1 = 2 * dx;\n\t\tincr2 = 2 * (dx - dy);\n\t\tif (y1 > y2) {\n\t\t\ty = y2;\n\t\t\tx = x2;\n\t\t\tyend = y1;\n\t\t\txdirflag = (-1);\n\t\t} else {\n\t\t\ty = y1;\n\t\t\tx = x1;\n\t\t\tyend = y2;\n\t\t\txdirflag = 1;\n\t\t}\n\n\t\t/* Set up line thickness */\n\t\twstart = x - wid / 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t}\n\n\t\tif (((x2 - x1) * xdirflag) > 0) {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid / 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5767", "cwe_id": "CWE-190" }, { "id": 3255, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n if (output->type == kTfLiteFloat32) {\n EvalAddN(context, node);\n } else if (output->type == kTfLiteInt32) {\n EvalAddN(context, node);\n } else {\n context->ReportError(context,\n \"AddN only supports FLOAT32|INT32 now, got %s.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3255, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n if (output->type == kTfLiteFloat32) {\n EvalAddN(context, node);\n } else if (output->type == kTfLiteInt32) {\n EvalAddN(context, node);\n } else {\n context->ReportError(context,\n \"AddN only supports FLOAT32|INT32 now, got %s.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1076, "func": "int ecall_restore(const char *input, uint64_t input_len, char **output,\n uint64_t *output_len) {\n if (!asylo::primitives::TrustedPrimitives::IsOutsideEnclave(input,\n input_len)) {\n asylo::primitives::TrustedPrimitives::BestEffortAbort(\n \"ecall_restore: input found to not be in untrusted memory.\");\n }\n int result = 0;\n size_t tmp_output_len;\n try {\n result = asylo::Restore(input, static_cast(input_len), output,\n &tmp_output_len);\n } catch (...) {\n LOG(FATAL) << \"Uncaught exception in enclave\";\n }\n\n if (output_len) {\n *output_len = static_cast(tmp_output_len);\n }\n return result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-8904", "cwe_id": "CWE-119" }, { "id": 1076, "func": "int ecall_restore(const char *input, uint64_t input_len, char **output,\n uint64_t *output_len) {\n if (!asylo::primitives::TrustedPrimitives::IsOutsideEnclave(input,\n input_len) ||\n !asylo::primitives::TrustedPrimitives::IsOutsideEnclave(\n output_len, sizeof(uint64_t))) {\n asylo::primitives::TrustedPrimitives::BestEffortAbort(\n \"ecall_restore: input/output found to not be in untrusted memory.\");\n }\n int result = 0;\n size_t tmp_output_len;\n try {\n result = asylo::Restore(input, static_cast(input_len), output,\n &tmp_output_len);\n } catch (...) {\n LOG(FATAL) << \"Uncaught exception in enclave\";\n }\n\n if (output_len) {\n *output_len = static_cast(tmp_output_len);\n }\n return result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-8904", "cwe_id": "CWE-119" }, { "id": 1186, "func": "error_t udpSendDatagram(Socket *socket, const SocketMsg *message, uint_t flags)\n{\n error_t error;\n size_t offset;\n NetBuffer *buffer;\n NetTxAncillary ancillary;\n\n //Allocate a memory buffer to hold the UDP datagram\n buffer = udpAllocBuffer(0, &offset);\n //Failed to allocate buffer?\n if(buffer == NULL)\n return ERROR_OUT_OF_MEMORY;\n\n //Copy data payload\n error = netBufferAppend(buffer, message->data, message->length);\n\n //Successful processing?\n if(!error)\n {\n //Additional options can be passed to the stack along with the packet\n ancillary = NET_DEFAULT_TX_ANCILLARY;\n\n //Set the TTL value to be used\n if(message->ttl != 0)\n {\n ancillary.ttl = message->ttl;\n }\n else if(ipIsMulticastAddr(&message->destIpAddr))\n {\n ancillary.ttl = socket->multicastTtl;\n }\n else\n {\n ancillary.ttl = socket->ttl;\n }\n\n //This flag tells the stack that the destination is on a locally attached\n //network and not to perform a lookup of the routing table\n if(flags & SOCKET_FLAG_DONT_ROUTE)\n {\n ancillary.dontRoute = TRUE;\n }\n\n#if (IP_DIFF_SERV_SUPPORT == ENABLED)\n //Set DSCP field\n ancillary.dscp = socket->dscp;\n#endif\n\n#if (ETH_SUPPORT == ENABLED)\n //Set source and destination MAC addresses\n ancillary.srcMacAddr = message->srcMacAddr;\n ancillary.destMacAddr = message->destMacAddr;\n#endif\n\n#if (ETH_VLAN_SUPPORT == ENABLED)\n //Set VLAN PCP and DEI fields\n ancillary.vlanPcp = socket->vlanPcp;\n ancillary.vlanDei = socket->vlanDei;\n#endif\n\n#if (ETH_VMAN_SUPPORT == ENABLED)\n //Set VMAN PCP and DEI fields\n ancillary.vmanPcp = socket->vmanPcp;\n ancillary.vmanDei = socket->vmanDei;\n#endif\n\n#if (ETH_PORT_TAGGING_SUPPORT == ENABLED)\n //Set switch port identifier\n ancillary.port = message->switchPort;\n#endif\n\n#if (ETH_TIMESTAMP_SUPPORT == ENABLED)\n //Unique identifier for hardware time stamping\n ancillary.timestampId = message->timestampId;\n#endif\n\n //Send UDP datagram\n error = udpSendBuffer(socket->interface, &message->srcIpAddr,\n socket->localPort, &message->destIpAddr, message->destPort, buffer,\n offset, &ancillary);\n }\n\n //Free previously allocated memory\n netBufferFree(buffer);\n\n //Return status code\n return error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1186, "func": "error_t udpSendDatagram(Socket *socket, const SocketMsg *message, uint_t flags)\n{\n error_t error;\n size_t offset;\n NetBuffer *buffer;\n NetInterface *interface;\n NetTxAncillary ancillary;\n\n //Select the relevant network interface\n if(message->interface != NULL)\n {\n interface = message->interface;\n }\n else\n {\n interface = socket->interface;\n }\n\n //Allocate a memory buffer to hold the UDP datagram\n buffer = udpAllocBuffer(0, &offset);\n //Failed to allocate buffer?\n if(buffer == NULL)\n return ERROR_OUT_OF_MEMORY;\n\n //Copy data payload\n error = netBufferAppend(buffer, message->data, message->length);\n\n //Successful processing?\n if(!error)\n {\n //Additional options can be passed to the stack along with the packet\n ancillary = NET_DEFAULT_TX_ANCILLARY;\n\n //Set the TTL value to be used\n if(message->ttl != 0)\n {\n ancillary.ttl = message->ttl;\n }\n else if(ipIsMulticastAddr(&message->destIpAddr))\n {\n ancillary.ttl = socket->multicastTtl;\n }\n else\n {\n ancillary.ttl = socket->ttl;\n }\n\n //This flag tells the stack that the destination is on a locally attached\n //network and not to perform a lookup of the routing table\n if(flags & SOCKET_FLAG_DONT_ROUTE)\n {\n ancillary.dontRoute = TRUE;\n }\n\n#if (IP_DIFF_SERV_SUPPORT == ENABLED)\n //Set DSCP field\n ancillary.dscp = socket->dscp;\n#endif\n\n#if (ETH_SUPPORT == ENABLED)\n //Set source and destination MAC addresses\n ancillary.srcMacAddr = message->srcMacAddr;\n ancillary.destMacAddr = message->destMacAddr;\n#endif\n\n#if (ETH_VLAN_SUPPORT == ENABLED)\n //Set VLAN PCP and DEI fields\n ancillary.vlanPcp = socket->vlanPcp;\n ancillary.vlanDei = socket->vlanDei;\n#endif\n\n#if (ETH_VMAN_SUPPORT == ENABLED)\n //Set VMAN PCP and DEI fields\n ancillary.vmanPcp = socket->vmanPcp;\n ancillary.vmanDei = socket->vmanDei;\n#endif\n\n#if (ETH_PORT_TAGGING_SUPPORT == ENABLED)\n //Set switch port identifier\n ancillary.port = message->switchPort;\n#endif\n\n#if (ETH_TIMESTAMP_SUPPORT == ENABLED)\n //Unique identifier for hardware time stamping\n ancillary.timestampId = message->timestampId;\n#endif\n\n //Send UDP datagram\n error = udpSendBuffer(interface, &message->srcIpAddr, socket->localPort,\n &message->destIpAddr, message->destPort, buffer, offset, &ancillary);\n }\n\n //Free previously allocated memory\n netBufferFree(buffer);\n\n //Return status code\n return error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 3042, "func": "static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {\n _cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;\n AsyncPolkitQuery *q = userdata;\n int r;\n\n assert(reply);\n assert(q);\n\n q->slot = sd_bus_slot_unref(q->slot);\n q->reply = sd_bus_message_ref(reply);\n\n r = sd_bus_message_rewind(q->request, true);\n if (r < 0) {\n r = sd_bus_reply_method_errno(q->request, r, NULL);\n goto finish;\n }\n\n r = q->callback(q->request, q->userdata, &error_buffer);\n r = bus_maybe_reply_error(q->request, r, &error_buffer);\n\nfinish:\n async_polkit_query_free(q);\n\n return r;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-1712", "cwe_id": "CWE-416" }, { "id": 3042, "func": "static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {\n _cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;\n AsyncPolkitQuery *q = userdata;\n int r;\n\n assert(reply);\n assert(q);\n\n assert(q->slot);\n q->slot = sd_bus_slot_unref(q->slot);\n\n assert(!q->reply);\n q->reply = sd_bus_message_ref(reply);\n\n /* Now, let's dispatch the original message a second time be re-enqueing. This will then traverse the\n * whole message processing again, and thus re-validating and re-retrieving the \"userdata\" field\n * again.\n *\n * We install an idle event loop event to clean-up the PolicyKit request data when we are idle again,\n * i.e. after the second time the message is processed is complete. */\n\n assert(!q->defer_event_source);\n r = sd_event_add_defer(sd_bus_get_event(sd_bus_message_get_bus(reply)), &q->defer_event_source, async_polkit_defer, q);\n if (r < 0)\n goto fail;\n\n r = sd_event_source_set_priority(q->defer_event_source, SD_EVENT_PRIORITY_IDLE);\n if (r < 0)\n goto fail;\n\n r = sd_event_source_set_enabled(q->defer_event_source, SD_EVENT_ONESHOT);\n if (r < 0)\n goto fail;\n\n r = sd_bus_message_rewind(q->request, true);\n if (r < 0)\n goto fail;\n\n r = sd_bus_enqeue_for_read(sd_bus_message_get_bus(q->request), q->request);\n if (r < 0)\n goto fail;\n\n return 1;\n\nfail:\n log_debug_errno(r, \"Processing asynchronous PolicyKit reply failed, ignoring: %m\");\n (void) sd_bus_reply_method_errno(q->request, r, NULL);\n async_polkit_query_free(q);\n return r;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-1712", "cwe_id": "CWE-416" }, { "id": 586, "func": "exif_mnote_data_fuji_load (ExifMnoteData *en,\n\tconst unsigned char *buf, unsigned int buf_size)\n{\n\tExifMnoteDataFuji *n = (ExifMnoteDataFuji*) en;\n\tExifLong c;\n\tsize_t i, tcount, o, datao;\n\n\tif (!n || !buf || !buf_size) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\tdatao = 6 + n->offset;\n\tif ((datao + 12 < datao) || (datao + 12 < 12) || (datao + 12 > buf_size)) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\n\tn->order = EXIF_BYTE_ORDER_INTEL;\n\tdatao += exif_get_long (buf + datao + 8, EXIF_BYTE_ORDER_INTEL);\n\tif ((datao + 2 < datao) || (datao + 2 < 2) ||\n\t (datao + 2 > buf_size)) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\n\t/* Read the number of tags */\n\tc = exif_get_short (buf + datao, EXIF_BYTE_ORDER_INTEL);\n\tdatao += 2;\n\n\t/* Remove any old entries */\n\texif_mnote_data_fuji_clear (n);\n\n\t/* Reserve enough space for all the possible MakerNote tags */\n\tn->entries = exif_mem_alloc (en->mem, sizeof (MnoteFujiEntry) * c);\n\tif (!n->entries) {\n\t\tEXIF_LOG_NO_MEMORY(en->log, \"ExifMnoteDataFuji\", sizeof (MnoteFujiEntry) * c);\n\t\treturn;\n\t}\n\n\t/* Parse all c entries, storing ones that are successfully parsed */\n\ttcount = 0;\n\tfor (i = c, o = datao; i; --i, o += 12) {\n\t\tsize_t s;\n\t\tif ((o + 12 < o) || (o + 12 < 12) || (o + 12 > buf_size)) {\n\t\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\t\tbreak;\n\t\t}\n\n\t\tn->entries[tcount].tag = exif_get_short (buf + o, n->order);\n\t\tn->entries[tcount].format = exif_get_short (buf + o + 2, n->order);\n\t\tn->entries[tcount].components = exif_get_long (buf + o + 4, n->order);\n\t\tn->entries[tcount].order = n->order;\n\n\t\texif_log (en->log, EXIF_LOG_CODE_DEBUG, \"ExifMnoteDataFuji\",\n\t\t\t \"Loading entry 0x%x ('%s')...\", n->entries[tcount].tag,\n\t\t\t mnote_fuji_tag_get_name (n->entries[tcount].tag));\n\n\t\t/*\n\t\t * Size? If bigger than 4 bytes, the actual data is not\n\t\t * in the entry but somewhere else (offset).\n\t\t */\n\t\ts = exif_format_get_size (n->entries[tcount].format) * n->entries[tcount].components;\n\t\tn->entries[tcount].size = s;\n\t\tif (s) {\n\t\t\tsize_t dataofs = o + 8;\n\t\t\tif (s > 4)\n\t\t\t\t/* The data in this case is merely a pointer */\n\t\t\t\tdataofs = exif_get_long (buf + dataofs, n->order) + 6 + n->offset;\n\t\t\tif ((dataofs + s < dataofs) || (dataofs + s < s) ||\n\t\t\t\t(dataofs + s >= buf_size)) {\n\t\t\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t\t\t \"ExifMnoteDataFuji\", \"Tag data past end of \"\n\t\t\t\t\t \"buffer (%u >= %u)\", (unsigned)(dataofs + s), buf_size);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tn->entries[tcount].data = exif_mem_alloc (en->mem, s);\n\t\t\tif (!n->entries[tcount].data) {\n\t\t\t\tEXIF_LOG_NO_MEMORY(en->log, \"ExifMnoteDataFuji\", s);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmemcpy (n->entries[tcount].data, buf + dataofs, s);\n\t\t}\n\n\t\t/* Tag was successfully parsed */\n\t\t++tcount;\n\t}\n\t/* Store the count of successfully parsed tags */\n\tn->count = tcount;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-13112", "cwe_id": "CWE-125" }, { "id": 586, "func": "exif_mnote_data_fuji_load (ExifMnoteData *en,\n\tconst unsigned char *buf, unsigned int buf_size)\n{\n\tExifMnoteDataFuji *n = (ExifMnoteDataFuji*) en;\n\tExifLong c;\n\tsize_t i, tcount, o, datao;\n\n\tif (!n || !buf || !buf_size) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\tdatao = 6 + n->offset;\n\tif (CHECKOVERFLOW(datao, buf_size, 12)) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\n\tn->order = EXIF_BYTE_ORDER_INTEL;\n\n\tdatao += exif_get_long (buf + datao + 8, EXIF_BYTE_ORDER_INTEL);\n\tif (CHECKOVERFLOW(datao, buf_size, 2)) {\n\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\treturn;\n\t}\n\n\t/* Read the number of tags */\n\tc = exif_get_short (buf + datao, EXIF_BYTE_ORDER_INTEL);\n\tdatao += 2;\n\n\t/* Remove any old entries */\n\texif_mnote_data_fuji_clear (n);\n\n\t/* Reserve enough space for all the possible MakerNote tags */\n\tn->entries = exif_mem_alloc (en->mem, sizeof (MnoteFujiEntry) * c);\n\tif (!n->entries) {\n\t\tEXIF_LOG_NO_MEMORY(en->log, \"ExifMnoteDataFuji\", sizeof (MnoteFujiEntry) * c);\n\t\treturn;\n\t}\n\n\t/* Parse all c entries, storing ones that are successfully parsed */\n\ttcount = 0;\n\tfor (i = c, o = datao; i; --i, o += 12) {\n\t\tsize_t s;\n\n\t\tif (CHECKOVERFLOW(o, buf_size, 12)) {\n\t\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t \"ExifMnoteDataFuji\", \"Short MakerNote\");\n\t\t\tbreak;\n\t\t}\n\n\t\tn->entries[tcount].tag = exif_get_short (buf + o, n->order);\n\t\tn->entries[tcount].format = exif_get_short (buf + o + 2, n->order);\n\t\tn->entries[tcount].components = exif_get_long (buf + o + 4, n->order);\n\t\tn->entries[tcount].order = n->order;\n\n\t\texif_log (en->log, EXIF_LOG_CODE_DEBUG, \"ExifMnoteDataFuji\",\n\t\t\t \"Loading entry 0x%x ('%s')...\", n->entries[tcount].tag,\n\t\t\t mnote_fuji_tag_get_name (n->entries[tcount].tag));\n\n\t\t/* Check if we overflow the multiplication. Use buf_size as the max size for integer overflow detection,\n\t\t * we will check the buffer sizes closer later. */\n\t\tif (\texif_format_get_size (n->entries[tcount].format) &&\n\t\t\tbuf_size / exif_format_get_size (n->entries[tcount].format) < n->entries[tcount].components\n\t\t) {\n\t\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t\t \"ExifMnoteDataFuji\", \"Tag size overflow detected (%u * %lu)\", exif_format_get_size (n->entries[tcount].format), n->entries[tcount].components);\n\t\t\tcontinue;\n\t\t}\n\t\t/*\n\t\t * Size? If bigger than 4 bytes, the actual data is not\n\t\t * in the entry but somewhere else (offset).\n\t\t */\n\t\ts = exif_format_get_size (n->entries[tcount].format) * n->entries[tcount].components;\n\t\tn->entries[tcount].size = s;\n\t\tif (s) {\n\t\t\tsize_t dataofs = o + 8;\n\t\t\tif (s > 4)\n\t\t\t\t/* The data in this case is merely a pointer */\n\t\t\t\tdataofs = exif_get_long (buf + dataofs, n->order) + 6 + n->offset;\n\n\t\t\tif (CHECKOVERFLOW(dataofs, buf_size, s)) {\n\t\t\t\texif_log (en->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t\t\t \"ExifMnoteDataFuji\", \"Tag data past end of \"\n\t\t\t\t\t \"buffer (%u >= %u)\", (unsigned)(dataofs + s), buf_size);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tn->entries[tcount].data = exif_mem_alloc (en->mem, s);\n\t\t\tif (!n->entries[tcount].data) {\n\t\t\t\tEXIF_LOG_NO_MEMORY(en->log, \"ExifMnoteDataFuji\", s);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmemcpy (n->entries[tcount].data, buf + dataofs, s);\n\t\t}\n\n\t\t/* Tag was successfully parsed */\n\t\t++tcount;\n\t}\n\t/* Store the count of successfully parsed tags */\n\tn->count = tcount;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-13112", "cwe_id": "CWE-125" }, { "id": 887, "func": "brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,\n\t\t\tstruct cfg80211_ap_settings *settings)\n{\n\ts32 ie_offset;\n\tstruct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);\n\tstruct brcmf_if *ifp = netdev_priv(ndev);\n\tconst struct brcmf_tlv *ssid_ie;\n\tconst struct brcmf_tlv *country_ie;\n\tstruct brcmf_ssid_le ssid_le;\n\ts32 err = -EPERM;\n\tconst struct brcmf_tlv *rsn_ie;\n\tconst struct brcmf_vs_tlv *wpa_ie;\n\tstruct brcmf_join_params join_params;\n\tenum nl80211_iftype dev_role;\n\tstruct brcmf_fil_bss_enable_le bss_enable;\n\tu16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef);\n\tbool mbss;\n\tint is_11d;\n\n\tbrcmf_dbg(TRACE, \"ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, dtim_period=%d,\\n\",\n\t\t settings->chandef.chan->hw_value,\n\t\t settings->chandef.center_freq1, settings->chandef.width,\n\t\t settings->beacon_interval, settings->dtim_period);\n\tbrcmf_dbg(TRACE, \"ssid=%s(%zu), auth_type=%d, inactivity_timeout=%d\\n\",\n\t\t settings->ssid, settings->ssid_len, settings->auth_type,\n\t\t settings->inactivity_timeout);\n\tdev_role = ifp->vif->wdev.iftype;\n\tmbss = ifp->vif->mbss;\n\n\t/* store current 11d setting */\n\tbrcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY, &ifp->vif->is_11d);\n\tcountry_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len,\n\t\t\t\t WLAN_EID_COUNTRY);\n\tis_11d = country_ie ? 1 : 0;\n\n\tmemset(&ssid_le, 0, sizeof(ssid_le));\n\tif (settings->ssid == NULL || settings->ssid_len == 0) {\n\t\tie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN;\n\t\tssid_ie = brcmf_parse_tlvs(\n\t\t\t\t(u8 *)&settings->beacon.head[ie_offset],\n\t\t\t\tsettings->beacon.head_len - ie_offset,\n\t\t\t\tWLAN_EID_SSID);\n\t\tif (!ssid_ie)\n\t\t\treturn -EINVAL;\n\n\t\tmemcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len);\n\t\tssid_le.SSID_len = cpu_to_le32(ssid_ie->len);\n\t\tbrcmf_dbg(TRACE, \"SSID is (%s) in Head\\n\", ssid_le.SSID);\n\t} else {\n\t\tmemcpy(ssid_le.SSID, settings->ssid, settings->ssid_len);\n\t\tssid_le.SSID_len = cpu_to_le32((u32)settings->ssid_len);\n\t}\n\n\tif (!mbss) {\n\t\tbrcmf_set_mpc(ifp, 0);\n\t\tbrcmf_configure_arp_nd_offload(ifp, false);\n\t}\n\n\t/* find the RSN_IE */\n\trsn_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len, WLAN_EID_RSN);\n\n\t/* find the WPA_IE */\n\twpa_ie = brcmf_find_wpaie((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len);\n\n\tif ((wpa_ie != NULL || rsn_ie != NULL)) {\n\t\tbrcmf_dbg(TRACE, \"WPA(2) IE is found\\n\");\n\t\tif (wpa_ie != NULL) {\n\t\t\t/* WPA IE */\n\t\t\terr = brcmf_configure_wpaie(ifp, wpa_ie, false);\n\t\t\tif (err < 0)\n\t\t\t\tgoto exit;\n\t\t} else {\n\t\t\tstruct brcmf_vs_tlv *tmp_ie;\n\n\t\t\ttmp_ie = (struct brcmf_vs_tlv *)rsn_ie;\n\n\t\t\t/* RSN IE */\n\t\t\terr = brcmf_configure_wpaie(ifp, tmp_ie, true);\n\t\t\tif (err < 0)\n\t\t\t\tgoto exit;\n\t\t}\n\t} else {\n\t\tbrcmf_dbg(TRACE, \"No WPA(2) IEs found\\n\");\n\t\tbrcmf_configure_opensecurity(ifp);\n\t}\n\n\tbrcmf_config_ap_mgmt_ie(ifp->vif, &settings->beacon);\n\n\t/* Parameters shared by all radio interfaces */\n\tif (!mbss) {\n\t\tif (is_11d != ifp->vif->is_11d) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,\n\t\t\t\t\t\t is_11d);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Regulatory Set Error, %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\tif (settings->beacon_interval) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD,\n\t\t\t\t\t\t settings->beacon_interval);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Beacon Interval Set Error, %d\\n\",\n\t\t\t\t\t err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\tif (settings->dtim_period) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_DTIMPRD,\n\t\t\t\t\t\t settings->dtim_period);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"DTIM Interval Set Error, %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\n\t\tif ((dev_role == NL80211_IFTYPE_AP) &&\n\t\t ((ifp->ifidx == 0) ||\n\t\t !brcmf_feat_is_enabled(ifp, BRCMF_FEAT_RSDB))) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"BRCMF_C_DOWN error %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t\tbrcmf_fil_iovar_int_set(ifp, \"apsta\", 0);\n\t\t}\n\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"SET INFRA error %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t} else if (WARN_ON(is_11d != ifp->vif->is_11d)) {\n\t\t/* Multiple-BSS should use same 11d configuration */\n\t\terr = -EINVAL;\n\t\tgoto exit;\n\t}\n\n\t/* Interface specific setup */\n\tif (dev_role == NL80211_IFTYPE_AP) {\n\t\tif ((brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) && (!mbss))\n\t\t\tbrcmf_fil_iovar_int_set(ifp, \"mbss\", 1);\n\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"setting AP mode failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\tif (!mbss) {\n\t\t\t/* Firmware 10.x requires setting channel after enabling\n\t\t\t * AP and before bringing interface up.\n\t\t\t */\n\t\t\terr = brcmf_fil_iovar_int_set(ifp, \"chanspec\", chanspec);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Set Channel failed: chspec=%d, %d\\n\",\n\t\t\t\t\t chanspec, err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"BRCMF_C_UP error (%d)\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\t/* On DOWN the firmware removes the WEP keys, reconfigure\n\t\t * them if they were set.\n\t\t */\n\t\tbrcmf_cfg80211_reconfigure_wep(ifp);\n\n\t\tmemset(&join_params, 0, sizeof(join_params));\n\t\t/* join parameters starts with ssid */\n\t\tmemcpy(&join_params.ssid_le, &ssid_le, sizeof(ssid_le));\n\t\t/* create softap */\n\t\terr = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,\n\t\t\t\t\t &join_params, sizeof(join_params));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"SET SSID error (%d)\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\n\t\tif (settings->hidden_ssid) {\n\t\t\terr = brcmf_fil_iovar_int_set(ifp, \"closednet\", 1);\n\t\t\tif (err) {\n\t\t\t\tbrcmf_err(\"closednet error (%d)\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\n\t\tbrcmf_dbg(TRACE, \"AP mode configuration complete\\n\");\n\t} else if (dev_role == NL80211_IFTYPE_P2P_GO) {\n\t\terr = brcmf_fil_iovar_int_set(ifp, \"chanspec\", chanspec);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"Set Channel failed: chspec=%d, %d\\n\",\n\t\t\t\t chanspec, err);\n\t\t\tgoto exit;\n\t\t}\n\t\terr = brcmf_fil_bsscfg_data_set(ifp, \"ssid\", &ssid_le,\n\t\t\t\t\t\tsizeof(ssid_le));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"setting ssid failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\tbss_enable.bsscfgidx = cpu_to_le32(ifp->bsscfgidx);\n\t\tbss_enable.enable = cpu_to_le32(1);\n\t\terr = brcmf_fil_iovar_data_set(ifp, \"bss\", &bss_enable,\n\t\t\t\t\t sizeof(bss_enable));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"bss_enable config failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\n\t\tbrcmf_dbg(TRACE, \"GO mode configuration complete\\n\");\n\t} else {\n\t\tWARN_ON(1);\n\t}\n\n\tset_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state);\n\tbrcmf_net_setcarrier(ifp, true);\n\nexit:\n\tif ((err) && (!mbss)) {\n\t\tbrcmf_set_mpc(ifp, 1);\n\t\tbrcmf_configure_arp_nd_offload(ifp, true);\n\t}\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-8658", "cwe_id": "CWE-119" }, { "id": 887, "func": "brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,\n\t\t\tstruct cfg80211_ap_settings *settings)\n{\n\ts32 ie_offset;\n\tstruct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);\n\tstruct brcmf_if *ifp = netdev_priv(ndev);\n\tconst struct brcmf_tlv *ssid_ie;\n\tconst struct brcmf_tlv *country_ie;\n\tstruct brcmf_ssid_le ssid_le;\n\ts32 err = -EPERM;\n\tconst struct brcmf_tlv *rsn_ie;\n\tconst struct brcmf_vs_tlv *wpa_ie;\n\tstruct brcmf_join_params join_params;\n\tenum nl80211_iftype dev_role;\n\tstruct brcmf_fil_bss_enable_le bss_enable;\n\tu16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef);\n\tbool mbss;\n\tint is_11d;\n\n\tbrcmf_dbg(TRACE, \"ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, dtim_period=%d,\\n\",\n\t\t settings->chandef.chan->hw_value,\n\t\t settings->chandef.center_freq1, settings->chandef.width,\n\t\t settings->beacon_interval, settings->dtim_period);\n\tbrcmf_dbg(TRACE, \"ssid=%s(%zu), auth_type=%d, inactivity_timeout=%d\\n\",\n\t\t settings->ssid, settings->ssid_len, settings->auth_type,\n\t\t settings->inactivity_timeout);\n\tdev_role = ifp->vif->wdev.iftype;\n\tmbss = ifp->vif->mbss;\n\n\t/* store current 11d setting */\n\tbrcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY, &ifp->vif->is_11d);\n\tcountry_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len,\n\t\t\t\t WLAN_EID_COUNTRY);\n\tis_11d = country_ie ? 1 : 0;\n\n\tmemset(&ssid_le, 0, sizeof(ssid_le));\n\tif (settings->ssid == NULL || settings->ssid_len == 0) {\n\t\tie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN;\n\t\tssid_ie = brcmf_parse_tlvs(\n\t\t\t\t(u8 *)&settings->beacon.head[ie_offset],\n\t\t\t\tsettings->beacon.head_len - ie_offset,\n\t\t\t\tWLAN_EID_SSID);\n\t\tif (!ssid_ie || ssid_ie->len > IEEE80211_MAX_SSID_LEN)\n\t\t\treturn -EINVAL;\n\n\t\tmemcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len);\n\t\tssid_le.SSID_len = cpu_to_le32(ssid_ie->len);\n\t\tbrcmf_dbg(TRACE, \"SSID is (%s) in Head\\n\", ssid_le.SSID);\n\t} else {\n\t\tmemcpy(ssid_le.SSID, settings->ssid, settings->ssid_len);\n\t\tssid_le.SSID_len = cpu_to_le32((u32)settings->ssid_len);\n\t}\n\n\tif (!mbss) {\n\t\tbrcmf_set_mpc(ifp, 0);\n\t\tbrcmf_configure_arp_nd_offload(ifp, false);\n\t}\n\n\t/* find the RSN_IE */\n\trsn_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len, WLAN_EID_RSN);\n\n\t/* find the WPA_IE */\n\twpa_ie = brcmf_find_wpaie((u8 *)settings->beacon.tail,\n\t\t\t\t settings->beacon.tail_len);\n\n\tif ((wpa_ie != NULL || rsn_ie != NULL)) {\n\t\tbrcmf_dbg(TRACE, \"WPA(2) IE is found\\n\");\n\t\tif (wpa_ie != NULL) {\n\t\t\t/* WPA IE */\n\t\t\terr = brcmf_configure_wpaie(ifp, wpa_ie, false);\n\t\t\tif (err < 0)\n\t\t\t\tgoto exit;\n\t\t} else {\n\t\t\tstruct brcmf_vs_tlv *tmp_ie;\n\n\t\t\ttmp_ie = (struct brcmf_vs_tlv *)rsn_ie;\n\n\t\t\t/* RSN IE */\n\t\t\terr = brcmf_configure_wpaie(ifp, tmp_ie, true);\n\t\t\tif (err < 0)\n\t\t\t\tgoto exit;\n\t\t}\n\t} else {\n\t\tbrcmf_dbg(TRACE, \"No WPA(2) IEs found\\n\");\n\t\tbrcmf_configure_opensecurity(ifp);\n\t}\n\n\tbrcmf_config_ap_mgmt_ie(ifp->vif, &settings->beacon);\n\n\t/* Parameters shared by all radio interfaces */\n\tif (!mbss) {\n\t\tif (is_11d != ifp->vif->is_11d) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,\n\t\t\t\t\t\t is_11d);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Regulatory Set Error, %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\tif (settings->beacon_interval) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD,\n\t\t\t\t\t\t settings->beacon_interval);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Beacon Interval Set Error, %d\\n\",\n\t\t\t\t\t err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\tif (settings->dtim_period) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_DTIMPRD,\n\t\t\t\t\t\t settings->dtim_period);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"DTIM Interval Set Error, %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\n\t\tif ((dev_role == NL80211_IFTYPE_AP) &&\n\t\t ((ifp->ifidx == 0) ||\n\t\t !brcmf_feat_is_enabled(ifp, BRCMF_FEAT_RSDB))) {\n\t\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"BRCMF_C_DOWN error %d\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t\tbrcmf_fil_iovar_int_set(ifp, \"apsta\", 0);\n\t\t}\n\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"SET INFRA error %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t} else if (WARN_ON(is_11d != ifp->vif->is_11d)) {\n\t\t/* Multiple-BSS should use same 11d configuration */\n\t\terr = -EINVAL;\n\t\tgoto exit;\n\t}\n\n\t/* Interface specific setup */\n\tif (dev_role == NL80211_IFTYPE_AP) {\n\t\tif ((brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) && (!mbss))\n\t\t\tbrcmf_fil_iovar_int_set(ifp, \"mbss\", 1);\n\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"setting AP mode failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\tif (!mbss) {\n\t\t\t/* Firmware 10.x requires setting channel after enabling\n\t\t\t * AP and before bringing interface up.\n\t\t\t */\n\t\t\terr = brcmf_fil_iovar_int_set(ifp, \"chanspec\", chanspec);\n\t\t\tif (err < 0) {\n\t\t\t\tbrcmf_err(\"Set Channel failed: chspec=%d, %d\\n\",\n\t\t\t\t\t chanspec, err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t\terr = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"BRCMF_C_UP error (%d)\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\t/* On DOWN the firmware removes the WEP keys, reconfigure\n\t\t * them if they were set.\n\t\t */\n\t\tbrcmf_cfg80211_reconfigure_wep(ifp);\n\n\t\tmemset(&join_params, 0, sizeof(join_params));\n\t\t/* join parameters starts with ssid */\n\t\tmemcpy(&join_params.ssid_le, &ssid_le, sizeof(ssid_le));\n\t\t/* create softap */\n\t\terr = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,\n\t\t\t\t\t &join_params, sizeof(join_params));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"SET SSID error (%d)\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\n\t\tif (settings->hidden_ssid) {\n\t\t\terr = brcmf_fil_iovar_int_set(ifp, \"closednet\", 1);\n\t\t\tif (err) {\n\t\t\t\tbrcmf_err(\"closednet error (%d)\\n\", err);\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\n\t\tbrcmf_dbg(TRACE, \"AP mode configuration complete\\n\");\n\t} else if (dev_role == NL80211_IFTYPE_P2P_GO) {\n\t\terr = brcmf_fil_iovar_int_set(ifp, \"chanspec\", chanspec);\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"Set Channel failed: chspec=%d, %d\\n\",\n\t\t\t\t chanspec, err);\n\t\t\tgoto exit;\n\t\t}\n\t\terr = brcmf_fil_bsscfg_data_set(ifp, \"ssid\", &ssid_le,\n\t\t\t\t\t\tsizeof(ssid_le));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"setting ssid failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\t\tbss_enable.bsscfgidx = cpu_to_le32(ifp->bsscfgidx);\n\t\tbss_enable.enable = cpu_to_le32(1);\n\t\terr = brcmf_fil_iovar_data_set(ifp, \"bss\", &bss_enable,\n\t\t\t\t\t sizeof(bss_enable));\n\t\tif (err < 0) {\n\t\t\tbrcmf_err(\"bss_enable config failed %d\\n\", err);\n\t\t\tgoto exit;\n\t\t}\n\n\t\tbrcmf_dbg(TRACE, \"GO mode configuration complete\\n\");\n\t} else {\n\t\tWARN_ON(1);\n\t}\n\n\tset_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state);\n\tbrcmf_net_setcarrier(ifp, true);\n\nexit:\n\tif ((err) && (!mbss)) {\n\t\tbrcmf_set_mpc(ifp, 1);\n\t\tbrcmf_configure_arp_nd_offload(ifp, true);\n\t}\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-8658", "cwe_id": "CWE-119" }, { "id": 1391, "func": "static int __videobuf_mmap_mapper(struct videobuf_queue *q,\n\t\t\t struct vm_area_struct *vma)\n{\n\tstruct videbuf_vmalloc_memory *mem;\n\tstruct videobuf_mapping *map;\n\tunsigned int first;\n\tint retval;\n\tunsigned long offset = vma->vm_pgoff << PAGE_SHIFT;\n\n\tif (! (vma->vm_flags & VM_WRITE) || ! (vma->vm_flags & VM_SHARED))\n\t\treturn -EINVAL;\n\n\t/* look for first buffer to map */\n\tfor (first = 0; first < VIDEO_MAX_FRAME; first++) {\n\t\tif (NULL == q->bufs[first])\n\t\t\tcontinue;\n\n\t\tif (V4L2_MEMORY_MMAP != q->bufs[first]->memory)\n\t\t\tcontinue;\n\t\tif (q->bufs[first]->boff == offset)\n\t\t\tbreak;\n\t}\n\tif (VIDEO_MAX_FRAME == first) {\n\t\tdprintk(1,\"mmap app bug: offset invalid [offset=0x%lx]\\n\",\n\t\t\t(vma->vm_pgoff << PAGE_SHIFT));\n\t\treturn -EINVAL;\n\t}\n\n\t/* create mapping + update buffer list */\n\tmap = q->bufs[first]->map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL);\n\tif (NULL == map)\n\t\treturn -ENOMEM;\n\n\tmap->start = vma->vm_start;\n\tmap->end = vma->vm_end;\n\tmap->q = q;\n\n\tq->bufs[first]->baddr = vma->vm_start;\n\n\tvma->vm_ops = &videobuf_vm_ops;\n\tvma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;\n\tvma->vm_private_data = map;\n\n\tmem=q->bufs[first]->priv;\n\tBUG_ON (!mem);\n\tMAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);\n\n\t/* Try to remap memory */\n\tretval=remap_vmalloc_range(vma, mem->vmalloc,0);\n\tif (retval<0) {\n\t\tdprintk(1,\"mmap: postponing remap_vmalloc_range\\n\");\n\n\t\tmem->vma=kmalloc(sizeof(*vma),GFP_KERNEL);\n\t\tif (!mem->vma) {\n\t\t\tkfree(map);\n\t\t\tq->bufs[first]->map=NULL;\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tmemcpy(mem->vma,vma,sizeof(*vma));\n\t}\n\n\tdprintk(1,\"mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\\n\",\n\t\tmap,q,vma->vm_start,vma->vm_end,\n\t\t(long int) q->bufs[first]->bsize,\n\t\tvma->vm_pgoff,first);\n\n\tvideobuf_vm_open(vma);\n\n\treturn (0);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2007-6761", "cwe_id": "CWE-119" }, { "id": 1391, "func": "static int __videobuf_mmap_mapper(struct videobuf_queue *q,\n\t\t\t struct vm_area_struct *vma)\n{\n\tstruct videbuf_vmalloc_memory *mem;\n\tstruct videobuf_mapping *map;\n\tunsigned int first;\n\tint retval;\n\tunsigned long offset = vma->vm_pgoff << PAGE_SHIFT;\n\n\tif (! (vma->vm_flags & VM_WRITE) || ! (vma->vm_flags & VM_SHARED))\n\t\treturn -EINVAL;\n\n\t/* look for first buffer to map */\n\tfor (first = 0; first < VIDEO_MAX_FRAME; first++) {\n\t\tif (NULL == q->bufs[first])\n\t\t\tcontinue;\n\n\t\tif (V4L2_MEMORY_MMAP != q->bufs[first]->memory)\n\t\t\tcontinue;\n\t\tif (q->bufs[first]->boff == offset)\n\t\t\tbreak;\n\t}\n\tif (VIDEO_MAX_FRAME == first) {\n\t\tdprintk(1,\"mmap app bug: offset invalid [offset=0x%lx]\\n\",\n\t\t\t(vma->vm_pgoff << PAGE_SHIFT));\n\t\treturn -EINVAL;\n\t}\n\n\t/* create mapping + update buffer list */\n\tmap = q->bufs[first]->map = kzalloc(sizeof(struct videobuf_mapping),GFP_KERNEL);\n\tif (NULL == map)\n\t\treturn -ENOMEM;\n\n\tmap->start = vma->vm_start;\n\tmap->end = vma->vm_end;\n\tmap->q = q;\n\n\tq->bufs[first]->baddr = vma->vm_start;\n\n\tvma->vm_ops = &videobuf_vm_ops;\n\tvma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;\n\tvma->vm_private_data = map;\n\n\tmem=q->bufs[first]->priv;\n\tBUG_ON (!mem);\n\tMAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);\n\n\t/* Try to remap memory */\n\tretval=remap_vmalloc_range(vma, mem->vmalloc,0);\n\tif (retval<0) {\n\t\tdprintk(1,\"mmap: postponing remap_vmalloc_range\\n\");\n\n\t\tmem->vma=kmalloc(sizeof(*vma),GFP_KERNEL);\n\t\tif (!mem->vma) {\n\t\t\tkfree(map);\n\t\t\tq->bufs[first]->map=NULL;\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tmemcpy(mem->vma,vma,sizeof(*vma));\n\t}\n\n\tdprintk(1,\"mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\\n\",\n\t\tmap,q,vma->vm_start,vma->vm_end,\n\t\t(long int) q->bufs[first]->bsize,\n\t\tvma->vm_pgoff,first);\n\n\tvideobuf_vm_open(vma);\n\n\treturn (0);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2007-6761", "cwe_id": "CWE-119" }, { "id": 3257, "func": "int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,\n\t\t struct sockaddr_storage *kern_address, int mode)\n{\n\tint tot_len;\n\n\tif (kern_msg->msg_namelen) {\n\t\tif (mode == VERIFY_READ) {\n\t\t\tint err = move_addr_to_kernel(kern_msg->msg_name,\n\t\t\t\t\t\t kern_msg->msg_namelen,\n\t\t\t\t\t\t kern_address);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t}\n\t\tkern_msg->msg_name = kern_address;\n\t} else\n\t\tkern_msg->msg_name = NULL;\n\n\ttot_len = iov_from_user_compat_to_kern(kern_iov,\n\t\t\t\t\t (struct compat_iovec __user *)kern_msg->msg_iov,\n\t\t\t\t\t kern_msg->msg_iovlen);\n\tif (tot_len >= 0)\n\t\tkern_msg->msg_iov = kern_iov;\n\n\treturn tot_len;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 3257, "func": "int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,\n\t\t struct sockaddr_storage *kern_address, int mode)\n{\n\tint tot_len;\n\n\tif (kern_msg->msg_namelen) {\n\t\tif (mode == VERIFY_READ) {\n\t\t\tint err = move_addr_to_kernel(kern_msg->msg_name,\n\t\t\t\t\t\t kern_msg->msg_namelen,\n\t\t\t\t\t\t kern_address);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t}\n\t\tif (kern_msg->msg_name)\n\t\t\tkern_msg->msg_name = kern_address;\n\t} else\n\t\tkern_msg->msg_name = NULL;\n\n\ttot_len = iov_from_user_compat_to_kern(kern_iov,\n\t\t\t\t\t (struct compat_iovec __user *)kern_msg->msg_iov,\n\t\t\t\t\t kern_msg->msg_iovlen);\n\tif (tot_len >= 0)\n\t\tkern_msg->msg_iov = kern_iov;\n\n\treturn tot_len;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 938, "func": "static size_t ntlm_av_pair_get_next_offset(NTLM_AV_PAIR* pAvPair)\n{\n\treturn ntlm_av_pair_get_len(pAvPair) + sizeof(NTLM_AV_PAIR);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11097", "cwe_id": "CWE-125" }, { "id": 938, "func": "static BOOL ntlm_av_pair_get_next_offset(const NTLM_AV_PAIR* pAvPair, size_t size, size_t* pOffset)\n{\n\tsize_t avLen;\n\tif (!pOffset)\n\t\treturn FALSE;\n\n\tif (!ntlm_av_pair_get_len(pAvPair, size, &avLen))\n\t\treturn FALSE;\n\t*pOffset = avLen + sizeof(NTLM_AV_PAIR);\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11097", "cwe_id": "CWE-125" }, { "id": 1303, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output_values = GetOutput(context, node, kOutputValues);\n TfLiteTensor* output_indexes = GetOutput(context, node, kOutputIndexes);\n if (IsDynamicTensor(output_values)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n }\n const TfLiteTensor* top_k = GetInput(context, node, kInputTopK);\n const int32 k = top_k->data.i32[0];\n // The tensor can have more than 2 dimensions or even be a vector, the code\n // anyway calls the internal dimension as row;\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const int32 row_size = input->dims->data[input->dims->size - 1];\n int32 num_rows = 1;\n for (int i = 0; i < input->dims->size - 1; ++i) {\n num_rows *= input->dims->data[i];\n }\n switch (output_values->type) {\n case kTfLiteFloat32:\n TopK(row_size, num_rows, GetTensorData(input), k,\n output_indexes->data.i32, GetTensorData(output_values));\n break;\n case kTfLiteUInt8:\n TopK(row_size, num_rows, input->data.uint8, k, output_indexes->data.i32,\n output_values->data.uint8);\n break;\n case kTfLiteInt8:\n TopK(row_size, num_rows, input->data.int8, k, output_indexes->data.i32,\n output_values->data.int8);\n break;\n case kTfLiteInt32:\n TopK(row_size, num_rows, input->data.i32, k, output_indexes->data.i32,\n output_values->data.i32);\n break;\n case kTfLiteInt64:\n TopK(row_size, num_rows, input->data.i64, k, output_indexes->data.i32,\n output_values->data.i64);\n break;\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s is currently not supported by TopK.\",\n TfLiteTypeGetName(output_values->type));\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1303, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output_values;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputValues, &output_values));\n TfLiteTensor* output_indexes;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputIndexes, &output_indexes));\n if (IsDynamicTensor(output_values)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n }\n const TfLiteTensor* top_k;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTopK, &top_k));\n const int32 k = top_k->data.i32[0];\n // The tensor can have more than 2 dimensions or even be a vector, the code\n // anyway calls the internal dimension as row;\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const int32 row_size = input->dims->data[input->dims->size - 1];\n int32 num_rows = 1;\n for (int i = 0; i < input->dims->size - 1; ++i) {\n num_rows *= input->dims->data[i];\n }\n switch (output_values->type) {\n case kTfLiteFloat32:\n TopK(row_size, num_rows, GetTensorData(input), k,\n output_indexes->data.i32, GetTensorData(output_values));\n break;\n case kTfLiteUInt8:\n TopK(row_size, num_rows, input->data.uint8, k, output_indexes->data.i32,\n output_values->data.uint8);\n break;\n case kTfLiteInt8:\n TopK(row_size, num_rows, input->data.int8, k, output_indexes->data.i32,\n output_values->data.int8);\n break;\n case kTfLiteInt32:\n TopK(row_size, num_rows, input->data.i32, k, output_indexes->data.i32,\n output_values->data.i32);\n break;\n case kTfLiteInt64:\n TopK(row_size, num_rows, input->data.i64, k, output_indexes->data.i32,\n output_values->data.i64);\n break;\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s is currently not supported by TopK.\",\n TfLiteTypeGetName(output_values->type));\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 737, "func": "static int ovl_rename2(struct inode *olddir, struct dentry *old,\n\t\t struct inode *newdir, struct dentry *new,\n\t\t unsigned int flags)\n{\n\tint err;\n\tenum ovl_path_type old_type;\n\tenum ovl_path_type new_type;\n\tstruct dentry *old_upperdir;\n\tstruct dentry *new_upperdir;\n\tstruct dentry *olddentry;\n\tstruct dentry *newdentry;\n\tstruct dentry *trap;\n\tbool old_opaque;\n\tbool new_opaque;\n\tbool new_create = false;\n\tbool cleanup_whiteout = false;\n\tbool overwrite = !(flags & RENAME_EXCHANGE);\n\tbool is_dir = d_is_dir(old);\n\tbool new_is_dir = false;\n\tstruct dentry *opaquedir = NULL;\n\tconst struct cred *old_cred = NULL;\n\tstruct cred *override_cred = NULL;\n\n\terr = -EINVAL;\n\tif (flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE))\n\t\tgoto out;\n\n\tflags &= ~RENAME_NOREPLACE;\n\n\terr = ovl_check_sticky(old);\n\tif (err)\n\t\tgoto out;\n\n\t/* Don't copy up directory trees */\n\told_type = ovl_path_type(old);\n\terr = -EXDEV;\n\tif (OVL_TYPE_MERGE_OR_LOWER(old_type) && is_dir)\n\t\tgoto out;\n\n\tif (new->d_inode) {\n\t\terr = ovl_check_sticky(new);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\tif (d_is_dir(new))\n\t\t\tnew_is_dir = true;\n\n\t\tnew_type = ovl_path_type(new);\n\t\terr = -EXDEV;\n\t\tif (!overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir)\n\t\t\tgoto out;\n\n\t\terr = 0;\n\t\tif (!OVL_TYPE_UPPER(new_type) && !OVL_TYPE_UPPER(old_type)) {\n\t\t\tif (ovl_dentry_lower(old)->d_inode ==\n\t\t\t ovl_dentry_lower(new)->d_inode)\n\t\t\t\tgoto out;\n\t\t}\n\t\tif (OVL_TYPE_UPPER(new_type) && OVL_TYPE_UPPER(old_type)) {\n\t\t\tif (ovl_dentry_upper(old)->d_inode ==\n\t\t\t ovl_dentry_upper(new)->d_inode)\n\t\t\t\tgoto out;\n\t\t}\n\t} else {\n\t\tif (ovl_dentry_is_opaque(new))\n\t\t\tnew_type = __OVL_PATH_UPPER;\n\t\telse\n\t\t\tnew_type = __OVL_PATH_UPPER | __OVL_PATH_PURE;\n\t}\n\n\terr = ovl_want_write(old);\n\tif (err)\n\t\tgoto out;\n\n\terr = ovl_copy_up(old);\n\tif (err)\n\t\tgoto out_drop_write;\n\n\terr = ovl_copy_up(new->d_parent);\n\tif (err)\n\t\tgoto out_drop_write;\n\tif (!overwrite) {\n\t\terr = ovl_copy_up(new);\n\t\tif (err)\n\t\t\tgoto out_drop_write;\n\t}\n\n\told_opaque = !OVL_TYPE_PURE_UPPER(old_type);\n\tnew_opaque = !OVL_TYPE_PURE_UPPER(new_type);\n\n\tif (old_opaque || new_opaque) {\n\t\terr = -ENOMEM;\n\t\toverride_cred = prepare_creds();\n\t\tif (!override_cred)\n\t\t\tgoto out_drop_write;\n\n\t\t/*\n\t\t * CAP_SYS_ADMIN for setting xattr on whiteout, opaque dir\n\t\t * CAP_DAC_OVERRIDE for create in workdir\n\t\t * CAP_FOWNER for removing whiteout from sticky dir\n\t\t * CAP_FSETID for chmod of opaque dir\n\t\t * CAP_CHOWN for chown of opaque dir\n\t\t */\n\t\tcap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);\n\t\tcap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);\n\t\tcap_raise(override_cred->cap_effective, CAP_FOWNER);\n\t\tcap_raise(override_cred->cap_effective, CAP_FSETID);\n\t\tcap_raise(override_cred->cap_effective, CAP_CHOWN);\n\t\told_cred = override_creds(override_cred);\n\t}\n\n\tif (overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir) {\n\t\topaquedir = ovl_check_empty_and_clear(new);\n\t\terr = PTR_ERR(opaquedir);\n\t\tif (IS_ERR(opaquedir)) {\n\t\t\topaquedir = NULL;\n\t\t\tgoto out_revert_creds;\n\t\t}\n\t}\n\n\tif (overwrite) {\n\t\tif (old_opaque) {\n\t\t\tif (new->d_inode || !new_opaque) {\n\t\t\t\t/* Whiteout source */\n\t\t\t\tflags |= RENAME_WHITEOUT;\n\t\t\t} else {\n\t\t\t\t/* Switch whiteouts */\n\t\t\t\tflags |= RENAME_EXCHANGE;\n\t\t\t}\n\t\t} else if (is_dir && !new->d_inode && new_opaque) {\n\t\t\tflags |= RENAME_EXCHANGE;\n\t\t\tcleanup_whiteout = true;\n\t\t}\n\t}\n\n\told_upperdir = ovl_dentry_upper(old->d_parent);\n\tnew_upperdir = ovl_dentry_upper(new->d_parent);\n\n\ttrap = lock_rename(new_upperdir, old_upperdir);\n\n\tolddentry = ovl_dentry_upper(old);\n\tnewdentry = ovl_dentry_upper(new);\n\tif (newdentry) {\n\t\tif (opaquedir) {\n\t\t\tnewdentry = opaquedir;\n\t\t\topaquedir = NULL;\n\t\t} else {\n\t\t\tdget(newdentry);\n\t\t}\n\t} else {\n\t\tnew_create = true;\n\t\tnewdentry = lookup_one_len(new->d_name.name, new_upperdir,\n\t\t\t\t\t new->d_name.len);\n\t\terr = PTR_ERR(newdentry);\n\t\tif (IS_ERR(newdentry))\n\t\t\tgoto out_unlock;\n\t}\n\n\terr = -ESTALE;\n\tif (olddentry->d_parent != old_upperdir)\n\t\tgoto out_dput;\n\tif (newdentry->d_parent != new_upperdir)\n\t\tgoto out_dput;\n\tif (olddentry == trap)\n\t\tgoto out_dput;\n\tif (newdentry == trap)\n\t\tgoto out_dput;\n\n\tif (is_dir && !old_opaque && new_opaque) {\n\t\terr = ovl_set_opaque(olddentry);\n\t\tif (err)\n\t\t\tgoto out_dput;\n\t}\n\tif (!overwrite && new_is_dir && old_opaque && !new_opaque) {\n\t\terr = ovl_set_opaque(newdentry);\n\t\tif (err)\n\t\t\tgoto out_dput;\n\t}\n\n\tif (old_opaque || new_opaque) {\n\t\terr = ovl_do_rename(old_upperdir->d_inode, olddentry,\n\t\t\t\t new_upperdir->d_inode, newdentry,\n\t\t\t\t flags);\n\t} else {\n\t\t/* No debug for the plain case */\n\t\tBUG_ON(flags & ~RENAME_EXCHANGE);\n\t\terr = vfs_rename(old_upperdir->d_inode, olddentry,\n\t\t\t\t new_upperdir->d_inode, newdentry,\n\t\t\t\t NULL, flags);\n\t}\n\n\tif (err) {\n\t\tif (is_dir && !old_opaque && new_opaque)\n\t\t\tovl_remove_opaque(olddentry);\n\t\tif (!overwrite && new_is_dir && old_opaque && !new_opaque)\n\t\t\tovl_remove_opaque(newdentry);\n\t\tgoto out_dput;\n\t}\n\n\tif (is_dir && old_opaque && !new_opaque)\n\t\tovl_remove_opaque(olddentry);\n\tif (!overwrite && new_is_dir && !old_opaque && new_opaque)\n\t\tovl_remove_opaque(newdentry);\n\n\t/*\n\t * Old dentry now lives in different location. Dentries in\n\t * lowerstack are stale. We cannot drop them here because\n\t * access to them is lockless. This could be only pure upper\n\t * or opaque directory - numlower is zero. Or upper non-dir\n\t * entry - its pureness is tracked by flag opaque.\n\t */\n\tif (old_opaque != new_opaque) {\n\t\tovl_dentry_set_opaque(old, new_opaque);\n\t\tif (!overwrite)\n\t\t\tovl_dentry_set_opaque(new, old_opaque);\n\t}\n\n\tif (cleanup_whiteout)\n\t\tovl_cleanup(old_upperdir->d_inode, newdentry);\n\n\tovl_dentry_version_inc(old->d_parent);\n\tovl_dentry_version_inc(new->d_parent);\n\nout_dput:\n\tdput(newdentry);\nout_unlock:\n\tunlock_rename(new_upperdir, old_upperdir);\nout_revert_creds:\n\tif (old_opaque || new_opaque) {\n\t\trevert_creds(old_cred);\n\t\tput_cred(override_cred);\n\t}\nout_drop_write:\n\tovl_drop_write(old);\nout:\n\tdput(opaquedir);\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-6197", "cwe_id": "CWE-20" }, { "id": 737, "func": "static int ovl_rename2(struct inode *olddir, struct dentry *old,\n\t\t struct inode *newdir, struct dentry *new,\n\t\t unsigned int flags)\n{\n\tint err;\n\tenum ovl_path_type old_type;\n\tenum ovl_path_type new_type;\n\tstruct dentry *old_upperdir;\n\tstruct dentry *new_upperdir;\n\tstruct dentry *olddentry;\n\tstruct dentry *newdentry;\n\tstruct dentry *trap;\n\tbool old_opaque;\n\tbool new_opaque;\n\tbool new_create = false;\n\tbool cleanup_whiteout = false;\n\tbool overwrite = !(flags & RENAME_EXCHANGE);\n\tbool is_dir = d_is_dir(old);\n\tbool new_is_dir = false;\n\tstruct dentry *opaquedir = NULL;\n\tconst struct cred *old_cred = NULL;\n\tstruct cred *override_cred = NULL;\n\n\terr = -EINVAL;\n\tif (flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE))\n\t\tgoto out;\n\n\tflags &= ~RENAME_NOREPLACE;\n\n\terr = ovl_check_sticky(old);\n\tif (err)\n\t\tgoto out;\n\n\t/* Don't copy up directory trees */\n\told_type = ovl_path_type(old);\n\terr = -EXDEV;\n\tif (OVL_TYPE_MERGE_OR_LOWER(old_type) && is_dir)\n\t\tgoto out;\n\n\tif (new->d_inode) {\n\t\terr = ovl_check_sticky(new);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\tif (d_is_dir(new))\n\t\t\tnew_is_dir = true;\n\n\t\tnew_type = ovl_path_type(new);\n\t\terr = -EXDEV;\n\t\tif (!overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir)\n\t\t\tgoto out;\n\n\t\terr = 0;\n\t\tif (!OVL_TYPE_UPPER(new_type) && !OVL_TYPE_UPPER(old_type)) {\n\t\t\tif (ovl_dentry_lower(old)->d_inode ==\n\t\t\t ovl_dentry_lower(new)->d_inode)\n\t\t\t\tgoto out;\n\t\t}\n\t\tif (OVL_TYPE_UPPER(new_type) && OVL_TYPE_UPPER(old_type)) {\n\t\t\tif (ovl_dentry_upper(old)->d_inode ==\n\t\t\t ovl_dentry_upper(new)->d_inode)\n\t\t\t\tgoto out;\n\t\t}\n\t} else {\n\t\tif (ovl_dentry_is_opaque(new))\n\t\t\tnew_type = __OVL_PATH_UPPER;\n\t\telse\n\t\t\tnew_type = __OVL_PATH_UPPER | __OVL_PATH_PURE;\n\t}\n\n\terr = ovl_want_write(old);\n\tif (err)\n\t\tgoto out;\n\n\terr = ovl_copy_up(old);\n\tif (err)\n\t\tgoto out_drop_write;\n\n\terr = ovl_copy_up(new->d_parent);\n\tif (err)\n\t\tgoto out_drop_write;\n\tif (!overwrite) {\n\t\terr = ovl_copy_up(new);\n\t\tif (err)\n\t\t\tgoto out_drop_write;\n\t}\n\n\told_opaque = !OVL_TYPE_PURE_UPPER(old_type);\n\tnew_opaque = !OVL_TYPE_PURE_UPPER(new_type);\n\n\tif (old_opaque || new_opaque) {\n\t\terr = -ENOMEM;\n\t\toverride_cred = prepare_creds();\n\t\tif (!override_cred)\n\t\t\tgoto out_drop_write;\n\n\t\t/*\n\t\t * CAP_SYS_ADMIN for setting xattr on whiteout, opaque dir\n\t\t * CAP_DAC_OVERRIDE for create in workdir\n\t\t * CAP_FOWNER for removing whiteout from sticky dir\n\t\t * CAP_FSETID for chmod of opaque dir\n\t\t * CAP_CHOWN for chown of opaque dir\n\t\t */\n\t\tcap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);\n\t\tcap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);\n\t\tcap_raise(override_cred->cap_effective, CAP_FOWNER);\n\t\tcap_raise(override_cred->cap_effective, CAP_FSETID);\n\t\tcap_raise(override_cred->cap_effective, CAP_CHOWN);\n\t\told_cred = override_creds(override_cred);\n\t}\n\n\tif (overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir) {\n\t\topaquedir = ovl_check_empty_and_clear(new);\n\t\terr = PTR_ERR(opaquedir);\n\t\tif (IS_ERR(opaquedir)) {\n\t\t\topaquedir = NULL;\n\t\t\tgoto out_revert_creds;\n\t\t}\n\t}\n\n\tif (overwrite) {\n\t\tif (old_opaque) {\n\t\t\tif (new->d_inode || !new_opaque) {\n\t\t\t\t/* Whiteout source */\n\t\t\t\tflags |= RENAME_WHITEOUT;\n\t\t\t} else {\n\t\t\t\t/* Switch whiteouts */\n\t\t\t\tflags |= RENAME_EXCHANGE;\n\t\t\t}\n\t\t} else if (is_dir && !new->d_inode && new_opaque) {\n\t\t\tflags |= RENAME_EXCHANGE;\n\t\t\tcleanup_whiteout = true;\n\t\t}\n\t}\n\n\told_upperdir = ovl_dentry_upper(old->d_parent);\n\tnew_upperdir = ovl_dentry_upper(new->d_parent);\n\n\ttrap = lock_rename(new_upperdir, old_upperdir);\n\n\n\tolddentry = lookup_one_len(old->d_name.name, old_upperdir,\n\t\t\t\t old->d_name.len);\n\terr = PTR_ERR(olddentry);\n\tif (IS_ERR(olddentry))\n\t\tgoto out_unlock;\n\n\terr = -ESTALE;\n\tif (olddentry != ovl_dentry_upper(old))\n\t\tgoto out_dput_old;\n\n\tnewdentry = lookup_one_len(new->d_name.name, new_upperdir,\n\t\t\t\t new->d_name.len);\n\terr = PTR_ERR(newdentry);\n\tif (IS_ERR(newdentry))\n\t\tgoto out_dput_old;\n\n\terr = -ESTALE;\n\tif (ovl_dentry_upper(new)) {\n\t\tif (opaquedir) {\n\t\t\tif (newdentry != opaquedir)\n\t\t\t\tgoto out_dput;\n\t\t} else {\n\t\t\tif (newdentry != ovl_dentry_upper(new))\n\t\t\t\tgoto out_dput;\n\t\t}\n\t} else {\n\t\tnew_create = true;\n\t\tif (!d_is_negative(newdentry) &&\n\t\t (!new_opaque || !ovl_is_whiteout(newdentry)))\n\t\t\tgoto out_dput;\n\t}\n\n\tif (olddentry == trap)\n\t\tgoto out_dput;\n\tif (newdentry == trap)\n\t\tgoto out_dput;\n\n\tif (is_dir && !old_opaque && new_opaque) {\n\t\terr = ovl_set_opaque(olddentry);\n\t\tif (err)\n\t\t\tgoto out_dput;\n\t}\n\tif (!overwrite && new_is_dir && old_opaque && !new_opaque) {\n\t\terr = ovl_set_opaque(newdentry);\n\t\tif (err)\n\t\t\tgoto out_dput;\n\t}\n\n\tif (old_opaque || new_opaque) {\n\t\terr = ovl_do_rename(old_upperdir->d_inode, olddentry,\n\t\t\t\t new_upperdir->d_inode, newdentry,\n\t\t\t\t flags);\n\t} else {\n\t\t/* No debug for the plain case */\n\t\tBUG_ON(flags & ~RENAME_EXCHANGE);\n\t\terr = vfs_rename(old_upperdir->d_inode, olddentry,\n\t\t\t\t new_upperdir->d_inode, newdentry,\n\t\t\t\t NULL, flags);\n\t}\n\n\tif (err) {\n\t\tif (is_dir && !old_opaque && new_opaque)\n\t\t\tovl_remove_opaque(olddentry);\n\t\tif (!overwrite && new_is_dir && old_opaque && !new_opaque)\n\t\t\tovl_remove_opaque(newdentry);\n\t\tgoto out_dput;\n\t}\n\n\tif (is_dir && old_opaque && !new_opaque)\n\t\tovl_remove_opaque(olddentry);\n\tif (!overwrite && new_is_dir && !old_opaque && new_opaque)\n\t\tovl_remove_opaque(newdentry);\n\n\t/*\n\t * Old dentry now lives in different location. Dentries in\n\t * lowerstack are stale. We cannot drop them here because\n\t * access to them is lockless. This could be only pure upper\n\t * or opaque directory - numlower is zero. Or upper non-dir\n\t * entry - its pureness is tracked by flag opaque.\n\t */\n\tif (old_opaque != new_opaque) {\n\t\tovl_dentry_set_opaque(old, new_opaque);\n\t\tif (!overwrite)\n\t\t\tovl_dentry_set_opaque(new, old_opaque);\n\t}\n\n\tif (cleanup_whiteout)\n\t\tovl_cleanup(old_upperdir->d_inode, newdentry);\n\n\tovl_dentry_version_inc(old->d_parent);\n\tovl_dentry_version_inc(new->d_parent);\n\nout_dput:\n\tdput(newdentry);\nout_dput_old:\n\tdput(olddentry);\nout_unlock:\n\tunlock_rename(new_upperdir, old_upperdir);\nout_revert_creds:\n\tif (old_opaque || new_opaque) {\n\t\trevert_creds(old_cred);\n\t\tput_cred(override_cred);\n\t}\nout_drop_write:\n\tovl_drop_write(old);\nout:\n\tdput(opaquedir);\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-6197", "cwe_id": "CWE-20" }, { "id": 999, "func": "void HeaderTable::setCapacity(uint32_t capacity) {\n auto oldCapacity = capacity_;\n capacity_ = capacity;\n if (capacity_ <= oldCapacity) {\n evict(0);\n } else {\n auto oldTail = tail();\n auto oldLength = table_.size();\n uint32_t newLength = (capacity_ >> 5) + 1;\n table_.resize(newLength);\n if (size_ > 0 && oldTail > head_) {\n // the list wrapped around, need to move oldTail..oldLength to the end of\n // the now-larger table_\n std::copy(table_.begin() + oldTail, table_.begin() + oldLength,\n table_.begin() + newLength - (oldLength - oldTail));\n // Update the names indecies that pointed to the old range\n for (auto& names_it: names_) {\n for (auto& idx: names_it.second) {\n if (idx >= oldTail) {\n DCHECK_LT(idx + (table_.size() - oldLength), table_.size());\n idx += (table_.size() - oldLength);\n } else {\n // remaining indecies in the list were smaller than oldTail, so\n // should be indexed from 0\n break;\n }\n }\n }\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11940", "cwe_id": "CWE-416" }, { "id": 999, "func": "void HeaderTable::setCapacity(uint32_t capacity) {\n // TODO: ddmello - the below is a little dangerous as we update the\n // capacity right away. Some properties of the class utilize that variable\n // and so might be better to refactor and update capacity at the end of the\n // method (and update other methods)\n auto oldCapacity = capacity_;\n capacity_ = capacity;\n if (capacity_ == oldCapacity) {\n return;\n } else if (capacity_ < oldCapacity) {\n // NOTE: currently no actual resizing is performed...\n evict(0);\n } else {\n // NOTE: due to the above lack of resizing, we must determine whether a\n // resize is actually appropriate (to handle cases where the underlying\n // vector is still >= to the size related to the new capacity requested)\n uint32_t newLength = (capacity_ >> 5) + 1;\n if (newLength > table_.size()) {\n auto oldTail = tail();\n auto oldLength = table_.size();\n table_.resize(newLength);\n if (size_ > 0 && oldTail > head_) {\n // the list wrapped around, need to move oldTail..oldLength to the end\n // of the now-larger table_\n std::copy(table_.begin() + oldTail, table_.begin() + oldLength,\n table_.begin() + newLength - (oldLength - oldTail));\n // Update the names indecies that pointed to the old range\n for (auto& names_it: names_) {\n for (auto& idx: names_it.second) {\n if (idx >= oldTail) {\n DCHECK_LT(idx + (table_.size() - oldLength), table_.size());\n idx += (table_.size() - oldLength);\n } else {\n // remaining indecies in the list were smaller than oldTail, so\n // should be indexed from 0\n break;\n }\n }\n }\n }\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11940", "cwe_id": "CWE-416" }, { "id": 1059, "func": "void CIRCSock::ReadLine(const CString& sData) {\n CString sLine = sData;\n\n sLine.TrimRight(\"\\n\\r\");\n\n DEBUG(\"(\" << m_pNetwork->GetUser()->GetUserName() << \"/\"\n << m_pNetwork->GetName() << \") IRC -> ZNC [\" << sLine << \"]\");\n\n bool bReturn = false;\n IRCSOCKMODULECALL(OnRaw(sLine), &bReturn);\n if (bReturn) return;\n\n CMessage Message(sLine);\n Message.SetNetwork(m_pNetwork);\n\n IRCSOCKMODULECALL(OnRawMessage(Message), &bReturn);\n if (bReturn) return;\n\n switch (Message.GetType()) {\n case CMessage::Type::Account:\n bReturn = OnAccountMessage(Message);\n break;\n case CMessage::Type::Action:\n bReturn = OnActionMessage(Message);\n break;\n case CMessage::Type::Away:\n bReturn = OnAwayMessage(Message);\n break;\n case CMessage::Type::Capability:\n bReturn = OnCapabilityMessage(Message);\n break;\n case CMessage::Type::CTCP:\n bReturn = OnCTCPMessage(Message);\n break;\n case CMessage::Type::Error:\n bReturn = OnErrorMessage(Message);\n break;\n case CMessage::Type::Invite:\n bReturn = OnInviteMessage(Message);\n break;\n case CMessage::Type::Join:\n bReturn = OnJoinMessage(Message);\n break;\n case CMessage::Type::Kick:\n bReturn = OnKickMessage(Message);\n break;\n case CMessage::Type::Mode:\n bReturn = OnModeMessage(Message);\n break;\n case CMessage::Type::Nick:\n bReturn = OnNickMessage(Message);\n break;\n case CMessage::Type::Notice:\n bReturn = OnNoticeMessage(Message);\n break;\n case CMessage::Type::Numeric:\n bReturn = OnNumericMessage(Message);\n break;\n case CMessage::Type::Part:\n bReturn = OnPartMessage(Message);\n break;\n case CMessage::Type::Ping:\n bReturn = OnPingMessage(Message);\n break;\n case CMessage::Type::Pong:\n bReturn = OnPongMessage(Message);\n break;\n case CMessage::Type::Quit:\n bReturn = OnQuitMessage(Message);\n break;\n case CMessage::Type::Text:\n bReturn = OnTextMessage(Message);\n break;\n case CMessage::Type::Topic:\n bReturn = OnTopicMessage(Message);\n break;\n case CMessage::Type::Wallops:\n bReturn = OnWallopsMessage(Message);\n break;\n default:\n break;\n }\n if (bReturn) return;\n\n m_pNetwork->PutUser(Message);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-14055", "cwe_id": "CWE-20" }, { "id": 1059, "func": "void CIRCSock::ReadLine(const CString& sData) {\n CString sLine = sData;\n\n sLine.Replace(\"\\n\", \"\");\n sLine.Replace(\"\\r\", \"\");\n\n DEBUG(\"(\" << m_pNetwork->GetUser()->GetUserName() << \"/\"\n << m_pNetwork->GetName() << \") IRC -> ZNC [\" << sLine << \"]\");\n\n bool bReturn = false;\n IRCSOCKMODULECALL(OnRaw(sLine), &bReturn);\n if (bReturn) return;\n\n CMessage Message(sLine);\n Message.SetNetwork(m_pNetwork);\n\n IRCSOCKMODULECALL(OnRawMessage(Message), &bReturn);\n if (bReturn) return;\n\n switch (Message.GetType()) {\n case CMessage::Type::Account:\n bReturn = OnAccountMessage(Message);\n break;\n case CMessage::Type::Action:\n bReturn = OnActionMessage(Message);\n break;\n case CMessage::Type::Away:\n bReturn = OnAwayMessage(Message);\n break;\n case CMessage::Type::Capability:\n bReturn = OnCapabilityMessage(Message);\n break;\n case CMessage::Type::CTCP:\n bReturn = OnCTCPMessage(Message);\n break;\n case CMessage::Type::Error:\n bReturn = OnErrorMessage(Message);\n break;\n case CMessage::Type::Invite:\n bReturn = OnInviteMessage(Message);\n break;\n case CMessage::Type::Join:\n bReturn = OnJoinMessage(Message);\n break;\n case CMessage::Type::Kick:\n bReturn = OnKickMessage(Message);\n break;\n case CMessage::Type::Mode:\n bReturn = OnModeMessage(Message);\n break;\n case CMessage::Type::Nick:\n bReturn = OnNickMessage(Message);\n break;\n case CMessage::Type::Notice:\n bReturn = OnNoticeMessage(Message);\n break;\n case CMessage::Type::Numeric:\n bReturn = OnNumericMessage(Message);\n break;\n case CMessage::Type::Part:\n bReturn = OnPartMessage(Message);\n break;\n case CMessage::Type::Ping:\n bReturn = OnPingMessage(Message);\n break;\n case CMessage::Type::Pong:\n bReturn = OnPongMessage(Message);\n break;\n case CMessage::Type::Quit:\n bReturn = OnQuitMessage(Message);\n break;\n case CMessage::Type::Text:\n bReturn = OnTextMessage(Message);\n break;\n case CMessage::Type::Topic:\n bReturn = OnTopicMessage(Message);\n break;\n case CMessage::Type::Wallops:\n bReturn = OnWallopsMessage(Message);\n break;\n default:\n break;\n }\n if (bReturn) return;\n\n m_pNetwork->PutUser(Message);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-14055", "cwe_id": "CWE-20" }, { "id": 2108, "func": "static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,\n\t\t\t\t int offset, size_t count)\n{\n\tint len = iov_length(from, count) - offset;\n\tint copy = skb_headlen(skb);\n\tint size, offset1 = 0;\n\tint i = 0;\n\n\t/* Skip over from offset */\n\twhile (count && (offset >= from->iov_len)) {\n\t\toffset -= from->iov_len;\n\t\t++from;\n\t\t--count;\n\t}\n\n\t/* copy up to skb headlen */\n\twhile (count && (copy > 0)) {\n\t\tsize = min_t(unsigned int, copy, from->iov_len - offset);\n\t\tif (copy_from_user(skb->data + offset1, from->iov_base + offset,\n\t\t\t\t size))\n\t\t\treturn -EFAULT;\n\t\tif (copy > size) {\n\t\t\t++from;\n\t\t\t--count;\n\t\t\toffset = 0;\n\t\t} else\n\t\t\toffset += size;\n\t\tcopy -= size;\n\t\toffset1 += size;\n\t}\n\n\tif (len == offset1)\n\t\treturn 0;\n\n\twhile (count--) {\n\t\tstruct page *page[MAX_SKB_FRAGS];\n\t\tint num_pages;\n\t\tunsigned long base;\n\t\tunsigned long truesize;\n\n\t\tlen = from->iov_len - offset;\n\t\tif (!len) {\n\t\t\toffset = 0;\n\t\t\t++from;\n\t\t\tcontinue;\n\t\t}\n\t\tbase = (unsigned long)from->iov_base + offset;\n\t\tsize = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;\n\t\tnum_pages = get_user_pages_fast(base, size, 0, &page[i]);\n\t\tif ((num_pages != size) ||\n\t\t (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags)) {\n\t\t\tfor (i = 0; i < num_pages; i++)\n\t\t\t\tput_page(page[i]);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\ttruesize = size * PAGE_SIZE;\n\t\tskb->data_len += len;\n\t\tskb->len += len;\n\t\tskb->truesize += truesize;\n\t\tatomic_add(truesize, &skb->sk->sk_wmem_alloc);\n\t\twhile (len) {\n\t\t\tint off = base & ~PAGE_MASK;\n\t\t\tint size = min_t(int, len, PAGE_SIZE - off);\n\t\t\t__skb_fill_page_desc(skb, i, page[i], off, size);\n\t\t\tskb_shinfo(skb)->nr_frags++;\n\t\t\t/* increase sk_wmem_alloc */\n\t\t\tbase += size;\n\t\t\tlen -= size;\n\t\t\ti++;\n\t\t}\n\t\toffset = 0;\n\t\t++from;\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-2119", "cwe_id": "CWE-119" }, { "id": 2108, "func": "static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,\n\t\t\t\t int offset, size_t count)\n{\n\tint len = iov_length(from, count) - offset;\n\tint copy = skb_headlen(skb);\n\tint size, offset1 = 0;\n\tint i = 0;\n\n\t/* Skip over from offset */\n\twhile (count && (offset >= from->iov_len)) {\n\t\toffset -= from->iov_len;\n\t\t++from;\n\t\t--count;\n\t}\n\n\t/* copy up to skb headlen */\n\twhile (count && (copy > 0)) {\n\t\tsize = min_t(unsigned int, copy, from->iov_len - offset);\n\t\tif (copy_from_user(skb->data + offset1, from->iov_base + offset,\n\t\t\t\t size))\n\t\t\treturn -EFAULT;\n\t\tif (copy > size) {\n\t\t\t++from;\n\t\t\t--count;\n\t\t\toffset = 0;\n\t\t} else\n\t\t\toffset += size;\n\t\tcopy -= size;\n\t\toffset1 += size;\n\t}\n\n\tif (len == offset1)\n\t\treturn 0;\n\n\twhile (count--) {\n\t\tstruct page *page[MAX_SKB_FRAGS];\n\t\tint num_pages;\n\t\tunsigned long base;\n\t\tunsigned long truesize;\n\n\t\tlen = from->iov_len - offset;\n\t\tif (!len) {\n\t\t\toffset = 0;\n\t\t\t++from;\n\t\t\tcontinue;\n\t\t}\n\t\tbase = (unsigned long)from->iov_base + offset;\n\t\tsize = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;\n\t\tif (i + size > MAX_SKB_FRAGS)\n\t\t\treturn -EMSGSIZE;\n\t\tnum_pages = get_user_pages_fast(base, size, 0, &page[i]);\n\t\tif (num_pages != size) {\n\t\t\tfor (i = 0; i < num_pages; i++)\n\t\t\t\tput_page(page[i]);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\ttruesize = size * PAGE_SIZE;\n\t\tskb->data_len += len;\n\t\tskb->len += len;\n\t\tskb->truesize += truesize;\n\t\tatomic_add(truesize, &skb->sk->sk_wmem_alloc);\n\t\twhile (len) {\n\t\t\tint off = base & ~PAGE_MASK;\n\t\t\tint size = min_t(int, len, PAGE_SIZE - off);\n\t\t\t__skb_fill_page_desc(skb, i, page[i], off, size);\n\t\t\tskb_shinfo(skb)->nr_frags++;\n\t\t\t/* increase sk_wmem_alloc */\n\t\t\tbase += size;\n\t\t\tlen -= size;\n\t\t\ti++;\n\t\t}\n\t\toffset = 0;\n\t\t++from;\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-2119", "cwe_id": "CWE-119" }, { "id": 3009, "func": "static void nsc_encode_subsampling(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tBYTE* co_dst;\n\tBYTE* cg_dst;\n\tINT8* co_src0;\n\tINT8* co_src1;\n\tINT8* cg_src0;\n\tINT8* cg_src1;\n\tUINT32 tempWidth;\n\tUINT32 tempHeight;\n\ttempWidth = ROUND_UP_TO(context->width, 8);\n\ttempHeight = ROUND_UP_TO(context->height, 2);\n\n\tfor (y = 0; y < tempHeight >> 1; y++)\n\t{\n\t\tco_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1);\n\t\tcg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1);\n\t\tco_src0 = (INT8*) context->priv->PlaneBuffers[1] + (y << 1) * tempWidth;\n\t\tco_src1 = co_src0 + tempWidth;\n\t\tcg_src0 = (INT8*) context->priv->PlaneBuffers[2] + (y << 1) * tempWidth;\n\t\tcg_src1 = cg_src0 + tempWidth;\n\n\t\tfor (x = 0; x < tempWidth >> 1; x++)\n\t\t{\n\t\t\t*co_dst++ = (BYTE)(((INT16) * co_src0 + (INT16) * (co_src0 + 1) +\n\t\t\t (INT16) * co_src1 + (INT16) * (co_src1 + 1)) >> 2);\n\t\t\t*cg_dst++ = (BYTE)(((INT16) * cg_src0 + (INT16) * (cg_src0 + 1) +\n\t\t\t (INT16) * cg_src1 + (INT16) * (cg_src1 + 1)) >> 2);\n\t\t\tco_src0 += 2;\n\t\t\tco_src1 += 2;\n\t\t\tcg_src0 += 2;\n\t\t\tcg_src1 += 2;\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 3009, "func": "static BOOL nsc_encode_subsampling(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tUINT32 tempWidth;\n\tUINT32 tempHeight;\n\n\tif (!context)\n\t\treturn FALSE;\n\n\ttempWidth = ROUND_UP_TO(context->width, 8);\n\ttempHeight = ROUND_UP_TO(context->height, 2);\n\n\tif (tempHeight == 0)\n\t\treturn FALSE;\n\n\tif (tempWidth > context->priv->PlaneBuffersLength / tempHeight)\n\t\treturn FALSE;\n\n\tfor (y = 0; y < tempHeight >> 1; y++)\n\t{\n\t\tBYTE* co_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1);\n\t\tBYTE* cg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1);\n\t\tconst INT8* co_src0 = (INT8*) context->priv->PlaneBuffers[1] + (y << 1) * tempWidth;\n\t\tconst INT8* co_src1 = co_src0 + tempWidth;\n\t\tconst INT8* cg_src0 = (INT8*) context->priv->PlaneBuffers[2] + (y << 1) * tempWidth;\n\t\tconst INT8* cg_src1 = cg_src0 + tempWidth;\n\n\t\tfor (x = 0; x < tempWidth >> 1; x++)\n\t\t{\n\t\t\t*co_dst++ = (BYTE)(((INT16) * co_src0 + (INT16) * (co_src0 + 1) +\n\t\t\t (INT16) * co_src1 + (INT16) * (co_src1 + 1)) >> 2);\n\t\t\t*cg_dst++ = (BYTE)(((INT16) * cg_src0 + (INT16) * (cg_src0 + 1) +\n\t\t\t (INT16) * cg_src1 + (INT16) * (cg_src1 + 1)) >> 2);\n\t\t\tco_src0 += 2;\n\t\t\tco_src1 += 2;\n\t\t\tcg_src0 += 2;\n\t\t\tcg_src1 += 2;\n\t\t}\n\t}\n\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 663, "func": "int irssi_ssl_handshake(GIOChannel *handle)\n{\n\tGIOSSLChannel *chan = (GIOSSLChannel *)handle;\n\tint ret, err;\n\tX509 *cert;\n\tconst char *errstr;\n\n\tret = SSL_connect(chan->ssl);\n\tif (ret <= 0) {\n\t\terr = SSL_get_error(chan->ssl, ret);\n\t\tswitch (err) {\n\t\t\tcase SSL_ERROR_WANT_READ:\n\t\t\t\treturn 1;\n\t\t\tcase SSL_ERROR_WANT_WRITE:\n\t\t\t\treturn 3;\n\t\t\tcase SSL_ERROR_ZERO_RETURN:\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", \"server closed connection\");\n\t\t\t\treturn -1;\n\t\t\tcase SSL_ERROR_SYSCALL:\n\t\t\t\terrstr = ERR_reason_error_string(ERR_get_error());\n\t\t\t\tif (errstr == NULL && ret == -1)\n\t\t\t\t\terrstr = strerror(errno);\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", errstr != NULL ? errstr : \"server closed connection unexpectedly\");\n\t\t\t\treturn -1;\n\t\t\tdefault:\n\t\t\t\terrstr = ERR_reason_error_string(ERR_get_error());\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", errstr != NULL ? errstr : \"unknown SSL error\");\n\t\t\t\treturn -1;\n\t\t}\n\t}\n\n\tcert = SSL_get_peer_certificate(chan->ssl);\n\tif (cert == NULL) {\n\t\tg_warning(\"SSL server supplied no certificate\");\n\t\treturn -1;\n\t}\n\tret = !chan->verify || irssi_ssl_verify(chan->ssl, chan->ctx, cert);\n\tX509_free(cert);\n\treturn ret ? 0 : -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2010-1155", "cwe_id": "CWE-20" }, { "id": 663, "func": "int irssi_ssl_handshake(GIOChannel *handle)\n{\n\tGIOSSLChannel *chan = (GIOSSLChannel *)handle;\n\tint ret, err;\n\tX509 *cert;\n\tconst char *errstr;\n\n\tret = SSL_connect(chan->ssl);\n\tif (ret <= 0) {\n\t\terr = SSL_get_error(chan->ssl, ret);\n\t\tswitch (err) {\n\t\t\tcase SSL_ERROR_WANT_READ:\n\t\t\t\treturn 1;\n\t\t\tcase SSL_ERROR_WANT_WRITE:\n\t\t\t\treturn 3;\n\t\t\tcase SSL_ERROR_ZERO_RETURN:\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", \"server closed connection\");\n\t\t\t\treturn -1;\n\t\t\tcase SSL_ERROR_SYSCALL:\n\t\t\t\terrstr = ERR_reason_error_string(ERR_get_error());\n\t\t\t\tif (errstr == NULL && ret == -1)\n\t\t\t\t\terrstr = strerror(errno);\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", errstr != NULL ? errstr : \"server closed connection unexpectedly\");\n\t\t\t\treturn -1;\n\t\t\tdefault:\n\t\t\t\terrstr = ERR_reason_error_string(ERR_get_error());\n\t\t\t\tg_warning(\"SSL handshake failed: %s\", errstr != NULL ? errstr : \"unknown SSL error\");\n\t\t\t\treturn -1;\n\t\t}\n\t}\n\n\tcert = SSL_get_peer_certificate(chan->ssl);\n\tif (cert == NULL) {\n\t\tg_warning(\"SSL server supplied no certificate\");\n\t\treturn -1;\n\t}\n\tret = !chan->verify || irssi_ssl_verify(chan->ssl, chan->ctx, chan->hostname, cert);\n\tX509_free(cert);\n\treturn ret ? 0 : -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2010-1155", "cwe_id": "CWE-20" }, { "id": 233, "func": "SYSCALL_DEFINE5(add_key, const char __user *, _type,\n\t\tconst char __user *, _description,\n\t\tconst void __user *, _payload,\n\t\tsize_t, plen,\n\t\tkey_serial_t, ringid)\n{\n\tkey_ref_t keyring_ref, key_ref;\n\tchar type[32], *description;\n\tvoid *payload;\n\tlong ret;\n\n\tret = -EINVAL;\n\tif (plen > 1024 * 1024 - 1)\n\t\tgoto error;\n\n\t/* draw all the data into kernel space */\n\tret = key_get_type_from_user(type, _type, sizeof(type));\n\tif (ret < 0)\n\t\tgoto error;\n\n\tdescription = NULL;\n\tif (_description) {\n\t\tdescription = strndup_user(_description, KEY_MAX_DESC_SIZE);\n\t\tif (IS_ERR(description)) {\n\t\t\tret = PTR_ERR(description);\n\t\t\tgoto error;\n\t\t}\n\t\tif (!*description) {\n\t\t\tkfree(description);\n\t\t\tdescription = NULL;\n\t\t} else if ((description[0] == '.') &&\n\t\t\t (strncmp(type, \"keyring\", 7) == 0)) {\n\t\t\tret = -EPERM;\n\t\t\tgoto error2;\n\t\t}\n\t}\n\n\t/* pull the payload in if one was supplied */\n\tpayload = NULL;\n\n\tif (_payload) {\n\t\tret = -ENOMEM;\n\t\tpayload = kvmalloc(plen, GFP_KERNEL);\n\t\tif (!payload)\n\t\t\tgoto error2;\n\n\t\tret = -EFAULT;\n\t\tif (copy_from_user(payload, _payload, plen) != 0)\n\t\t\tgoto error3;\n\t}\n\n\t/* find the target keyring (which must be writable) */\n\tkeyring_ref = lookup_user_key(ringid, KEY_LOOKUP_CREATE, KEY_NEED_WRITE);\n\tif (IS_ERR(keyring_ref)) {\n\t\tret = PTR_ERR(keyring_ref);\n\t\tgoto error3;\n\t}\n\n\t/* create or update the requested key and add it to the target\n\t * keyring */\n\tkey_ref = key_create_or_update(keyring_ref, type, description,\n\t\t\t\t payload, plen, KEY_PERM_UNDEF,\n\t\t\t\t KEY_ALLOC_IN_QUOTA);\n\tif (!IS_ERR(key_ref)) {\n\t\tret = key_ref_to_ptr(key_ref)->serial;\n\t\tkey_ref_put(key_ref);\n\t}\n\telse {\n\t\tret = PTR_ERR(key_ref);\n\t}\n\n\tkey_ref_put(keyring_ref);\n error3:\n\tkvfree(payload);\n error2:\n\tkfree(description);\n error:\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-15274", "cwe_id": "CWE-476" }, { "id": 233, "func": "SYSCALL_DEFINE5(add_key, const char __user *, _type,\n\t\tconst char __user *, _description,\n\t\tconst void __user *, _payload,\n\t\tsize_t, plen,\n\t\tkey_serial_t, ringid)\n{\n\tkey_ref_t keyring_ref, key_ref;\n\tchar type[32], *description;\n\tvoid *payload;\n\tlong ret;\n\n\tret = -EINVAL;\n\tif (plen > 1024 * 1024 - 1)\n\t\tgoto error;\n\n\t/* draw all the data into kernel space */\n\tret = key_get_type_from_user(type, _type, sizeof(type));\n\tif (ret < 0)\n\t\tgoto error;\n\n\tdescription = NULL;\n\tif (_description) {\n\t\tdescription = strndup_user(_description, KEY_MAX_DESC_SIZE);\n\t\tif (IS_ERR(description)) {\n\t\t\tret = PTR_ERR(description);\n\t\t\tgoto error;\n\t\t}\n\t\tif (!*description) {\n\t\t\tkfree(description);\n\t\t\tdescription = NULL;\n\t\t} else if ((description[0] == '.') &&\n\t\t\t (strncmp(type, \"keyring\", 7) == 0)) {\n\t\t\tret = -EPERM;\n\t\t\tgoto error2;\n\t\t}\n\t}\n\n\t/* pull the payload in if one was supplied */\n\tpayload = NULL;\n\n\tif (plen) {\n\t\tret = -ENOMEM;\n\t\tpayload = kvmalloc(plen, GFP_KERNEL);\n\t\tif (!payload)\n\t\t\tgoto error2;\n\n\t\tret = -EFAULT;\n\t\tif (copy_from_user(payload, _payload, plen) != 0)\n\t\t\tgoto error3;\n\t}\n\n\t/* find the target keyring (which must be writable) */\n\tkeyring_ref = lookup_user_key(ringid, KEY_LOOKUP_CREATE, KEY_NEED_WRITE);\n\tif (IS_ERR(keyring_ref)) {\n\t\tret = PTR_ERR(keyring_ref);\n\t\tgoto error3;\n\t}\n\n\t/* create or update the requested key and add it to the target\n\t * keyring */\n\tkey_ref = key_create_or_update(keyring_ref, type, description,\n\t\t\t\t payload, plen, KEY_PERM_UNDEF,\n\t\t\t\t KEY_ALLOC_IN_QUOTA);\n\tif (!IS_ERR(key_ref)) {\n\t\tret = key_ref_to_ptr(key_ref)->serial;\n\t\tkey_ref_put(key_ref);\n\t}\n\telse {\n\t\tret = PTR_ERR(key_ref);\n\t}\n\n\tkey_ref_put(keyring_ref);\n error3:\n\tkvfree(payload);\n error2:\n\tkfree(description);\n error:\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-15274", "cwe_id": "CWE-476" }, { "id": 1629, "func": "get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)\n{\n\tint\t\t\t\ttmp;\n\tstruct usb_host_interface\t*alt;\n\tstruct usb_host_endpoint\t*in, *out;\n\tstruct usb_host_endpoint\t*iso_in, *iso_out;\n\tstruct usb_host_endpoint\t*int_in, *int_out;\n\tstruct usb_device\t\t*udev;\n\n\tfor (tmp = 0; tmp < intf->num_altsetting; tmp++) {\n\t\tunsigned\tep;\n\n\t\tin = out = NULL;\n\t\tiso_in = iso_out = NULL;\n\t\tint_in = int_out = NULL;\n\t\talt = intf->altsetting + tmp;\n\n\t\tif (override_alt >= 0 &&\n\t\t\t\toverride_alt != alt->desc.bAlternateSetting)\n\t\t\tcontinue;\n\n\t\t/* take the first altsetting with in-bulk + out-bulk;\n\t\t * ignore other endpoints and altsettings.\n\t\t */\n\t\tfor (ep = 0; ep < alt->desc.bNumEndpoints; ep++) {\n\t\t\tstruct usb_host_endpoint\t*e;\n\t\t\tint edi;\n\n\t\t\te = alt->endpoint + ep;\n\t\t\tedi = usb_endpoint_dir_in(&e->desc);\n\n\t\t\tswitch (usb_endpoint_type(&e->desc)) {\n\t\t\tcase USB_ENDPOINT_XFER_BULK:\n\t\t\t\tendpoint_update(edi, &in, &out, e);\n\t\t\t\tcontinue;\n\t\t\tcase USB_ENDPOINT_XFER_INT:\n\t\t\t\tif (dev->info->intr)\n\t\t\t\t\tendpoint_update(edi, &int_in, &int_out, e);\n\t\t\t\tcontinue;\n\t\t\tcase USB_ENDPOINT_XFER_ISOC:\n\t\t\t\tif (dev->info->iso)\n\t\t\t\t\tendpoint_update(edi, &iso_in, &iso_out, e);\n\t\t\t\t/* FALLTHROUGH */\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif ((in && out) || iso_in || iso_out || int_in || int_out)\n\t\t\tgoto found;\n\t}\n\treturn -EINVAL;\n\nfound:\n\tudev = testdev_to_usbdev(dev);\n\tdev->info->alt = alt->desc.bAlternateSetting;\n\tif (alt->desc.bAlternateSetting != 0) {\n\t\ttmp = usb_set_interface(udev,\n\t\t\t\talt->desc.bInterfaceNumber,\n\t\t\t\talt->desc.bAlternateSetting);\n\t\tif (tmp < 0)\n\t\t\treturn tmp;\n\t}\n\n\tif (in) {\n\t\tdev->in_pipe = usb_rcvbulkpipe(udev,\n\t\t\tin->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);\n\t\tdev->out_pipe = usb_sndbulkpipe(udev,\n\t\t\tout->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);\n\t}\n\tif (iso_in) {\n\t\tdev->iso_in = &iso_in->desc;\n\t\tdev->in_iso_pipe = usb_rcvisocpipe(udev,\n\t\t\t\tiso_in->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (iso_out) {\n\t\tdev->iso_out = &iso_out->desc;\n\t\tdev->out_iso_pipe = usb_sndisocpipe(udev,\n\t\t\t\tiso_out->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (int_in) {\n\t\tdev->int_in = &int_in->desc;\n\t\tdev->in_int_pipe = usb_rcvintpipe(udev,\n\t\t\t\tint_in->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (int_out) {\n\t\tdev->int_out = &int_out->desc;\n\t\tdev->out_int_pipe = usb_sndintpipe(udev,\n\t\t\t\tint_out->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-16532", "cwe_id": "CWE-476" }, { "id": 1629, "func": "get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)\n{\n\tint\t\t\t\ttmp;\n\tstruct usb_host_interface\t*alt;\n\tstruct usb_host_endpoint\t*in, *out;\n\tstruct usb_host_endpoint\t*iso_in, *iso_out;\n\tstruct usb_host_endpoint\t*int_in, *int_out;\n\tstruct usb_device\t\t*udev;\n\n\tfor (tmp = 0; tmp < intf->num_altsetting; tmp++) {\n\t\tunsigned\tep;\n\n\t\tin = out = NULL;\n\t\tiso_in = iso_out = NULL;\n\t\tint_in = int_out = NULL;\n\t\talt = intf->altsetting + tmp;\n\n\t\tif (override_alt >= 0 &&\n\t\t\t\toverride_alt != alt->desc.bAlternateSetting)\n\t\t\tcontinue;\n\n\t\t/* take the first altsetting with in-bulk + out-bulk;\n\t\t * ignore other endpoints and altsettings.\n\t\t */\n\t\tfor (ep = 0; ep < alt->desc.bNumEndpoints; ep++) {\n\t\t\tstruct usb_host_endpoint\t*e;\n\t\t\tint edi;\n\n\t\t\te = alt->endpoint + ep;\n\t\t\tedi = usb_endpoint_dir_in(&e->desc);\n\n\t\t\tswitch (usb_endpoint_type(&e->desc)) {\n\t\t\tcase USB_ENDPOINT_XFER_BULK:\n\t\t\t\tendpoint_update(edi, &in, &out, e);\n\t\t\t\tcontinue;\n\t\t\tcase USB_ENDPOINT_XFER_INT:\n\t\t\t\tif (dev->info->intr)\n\t\t\t\t\tendpoint_update(edi, &int_in, &int_out, e);\n\t\t\t\tcontinue;\n\t\t\tcase USB_ENDPOINT_XFER_ISOC:\n\t\t\t\tif (dev->info->iso)\n\t\t\t\t\tendpoint_update(edi, &iso_in, &iso_out, e);\n\t\t\t\t/* FALLTHROUGH */\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif ((in && out) || iso_in || iso_out || int_in || int_out)\n\t\t\tgoto found;\n\t}\n\treturn -EINVAL;\n\nfound:\n\tudev = testdev_to_usbdev(dev);\n\tdev->info->alt = alt->desc.bAlternateSetting;\n\tif (alt->desc.bAlternateSetting != 0) {\n\t\ttmp = usb_set_interface(udev,\n\t\t\t\talt->desc.bInterfaceNumber,\n\t\t\t\talt->desc.bAlternateSetting);\n\t\tif (tmp < 0)\n\t\t\treturn tmp;\n\t}\n\n\tif (in)\n\t\tdev->in_pipe = usb_rcvbulkpipe(udev,\n\t\t\tin->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);\n\tif (out)\n\t\tdev->out_pipe = usb_sndbulkpipe(udev,\n\t\t\tout->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);\n\n\tif (iso_in) {\n\t\tdev->iso_in = &iso_in->desc;\n\t\tdev->in_iso_pipe = usb_rcvisocpipe(udev,\n\t\t\t\tiso_in->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (iso_out) {\n\t\tdev->iso_out = &iso_out->desc;\n\t\tdev->out_iso_pipe = usb_sndisocpipe(udev,\n\t\t\t\tiso_out->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (int_in) {\n\t\tdev->int_in = &int_in->desc;\n\t\tdev->in_int_pipe = usb_rcvintpipe(udev,\n\t\t\t\tint_in->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\n\tif (int_out) {\n\t\tdev->int_out = &int_out->desc;\n\t\tdev->out_int_pipe = usb_sndintpipe(udev,\n\t\t\t\tint_out->desc.bEndpointAddress\n\t\t\t\t\t& USB_ENDPOINT_NUMBER_MASK);\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-16532", "cwe_id": "CWE-476" }, { "id": 1953, "func": "bool_t enc28j60IrqHandler(NetInterface *interface)\n{\n bool_t flag;\n uint8_t status;\n\n //This flag will be set if a higher priority task must be woken\n flag = FALSE;\n\n //Clear the INTIE bit, immediately after an interrupt event\n enc28j60ClearBit(interface, ENC28J60_REG_EIE, EIE_INTIE);\n\n //Read interrupt status register\n status = enc28j60ReadReg(interface, ENC28J60_REG_EIR);\n\n //Link status change?\n if((status & EIR_LINKIF) != 0)\n {\n //Disable LINKIE interrupt\n enc28j60ClearBit(interface, ENC28J60_REG_EIE, EIE_LINKIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet received?\n if((status & EIR_PKTIF) != 0)\n {\n //Disable PKTIE interrupt\n enc28j60ClearBit(interface, ENC28J60_REG_EIE, EIE_PKTIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet transmission complete?\n if((status & (EIR_TXIF | EIE_TXERIE)) != 0)\n {\n //Clear interrupt flags\n enc28j60ClearBit(interface, ENC28J60_REG_EIR, EIR_TXIF | EIE_TXERIE);\n\n //Notify the TCP/IP stack that the transmitter is ready to send\n flag |= osSetEventFromIsr(&interface->nicTxEvent);\n }\n\n //Once the interrupt has been serviced, the INTIE bit\n //is set again to re-enable interrupts\n enc28j60SetBit(interface, ENC28J60_REG_EIE, EIE_INTIE);\n\n //A higher priority task must be woken?\n return flag;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1953, "func": "bool_t enc28j60IrqHandler(NetInterface *interface)\n{\n bool_t flag;\n uint8_t status;\n\n //This flag will be set if a higher priority task must be woken\n flag = FALSE;\n\n //Clear the INTIE bit, immediately after an interrupt event\n enc28j60ClearBit(interface, ENC28J60_EIE, ENC28J60_EIE_INTIE);\n\n //Read interrupt status register\n status = enc28j60ReadReg(interface, ENC28J60_EIR);\n\n //Link status change?\n if((status & ENC28J60_EIR_LINKIF) != 0)\n {\n //Disable LINKIE interrupt\n enc28j60ClearBit(interface, ENC28J60_EIE, ENC28J60_EIE_LINKIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet received?\n if(enc28j60ReadReg(interface, ENC28J60_EPKTCNT) != 0)\n {\n //Disable PKTIE interrupt\n enc28j60ClearBit(interface, ENC28J60_EIE, ENC28J60_EIE_PKTIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet transmission complete?\n if((status & (ENC28J60_EIR_TXIF | ENC28J60_EIE_TXERIE)) != 0)\n {\n //Clear interrupt flags\n enc28j60ClearBit(interface, ENC28J60_EIR, ENC28J60_EIR_TXIF |\n ENC28J60_EIE_TXERIE);\n\n //Notify the TCP/IP stack that the transmitter is ready to send\n flag |= osSetEventFromIsr(&interface->nicTxEvent);\n }\n\n //Once the interrupt has been serviced, the INTIE bit\n //is set again to re-enable interrupts\n enc28j60SetBit(interface, ENC28J60_EIE, ENC28J60_EIE_INTIE);\n\n //A higher priority task must be woken?\n return flag;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2924, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n // Check we have all the inputs and outputs we need.\n TF_LITE_ENSURE_EQ(context, node->inputs->size, 5);\n TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* input_weights = GetInput(context, node, kWeightsTensor);\n const TfLiteTensor* recurrent_weights =\n GetInput(context, node, kRecurrentWeightsTensor);\n const TfLiteTensor* bias = GetInput(context, node, kBiasTensor);\n const TfLiteTensor* hidden_state =\n GetInput(context, node, kHiddenStateTensor);\n\n // Check all the parameters of tensor match within themselves and match the\n // input configuration.\n auto* params = reinterpret_cast(node->builtin_data);\n const bool time_major = params->time_major;\n const int batch_size =\n (time_major) ? input->dims->data[1] : input->dims->data[0];\n const int max_time =\n (time_major) ? input->dims->data[0] : input->dims->data[1];\n const int num_units = input_weights->dims->data[0];\n TF_LITE_ENSURE_EQ(context, input->dims->data[2],\n input_weights->dims->data[1]);\n TF_LITE_ENSURE_EQ(context, input_weights->dims->data[0], bias->dims->data[0]);\n TF_LITE_ENSURE_EQ(context, recurrent_weights->dims->data[0],\n bias->dims->data[0]);\n TF_LITE_ENSURE_EQ(context, recurrent_weights->dims->data[1],\n bias->dims->data[0]);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input_weights->type,\n recurrent_weights->type);\n TF_LITE_ENSURE_EQ(context, NumDimensions(hidden_state), 2);\n TF_LITE_ENSURE_EQ(context, hidden_state->dims->data[0], batch_size);\n TF_LITE_ENSURE_EQ(context, hidden_state->dims->data[1], num_units);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n // Resize output.\n TfLiteIntArray* output_size_array = TfLiteIntArrayCreate(3);\n output_size_array->data[0] = (time_major) ? max_time : batch_size;\n output_size_array->data[1] = (time_major) ? batch_size : max_time;\n output_size_array->data[2] = num_units;\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_size_array));\n\n const bool is_hybrid = IsHybridOp(input, input_weights);\n\n // Allocate temporary tensors to store quantized values of input and\n // hidden_state tensors.\n if (is_hybrid) {\n auto* op_data = reinterpret_cast(node->user_data);\n op_data->compute_row_sums = true;\n TfLiteIntArrayFree(node->temporaries);\n node->temporaries = TfLiteIntArrayCreate(6);\n node->temporaries->data[0] = op_data->scratch_tensor_index;\n TfLiteTensor* input_quantized = GetTemporary(context, node, /*index=*/0);\n input_quantized->type = input_weights->type;\n input_quantized->allocation_type = kTfLiteArenaRw;\n if (!TfLiteIntArrayEqual(input_quantized->dims, input->dims)) {\n TfLiteIntArray* input_quantized_size = TfLiteIntArrayCopy(input->dims);\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, input_quantized,\n input_quantized_size));\n }\n node->temporaries->data[1] = op_data->scratch_tensor_index + 1;\n TfLiteTensor* hidden_state_quantized =\n GetTemporary(context, node, /*index=*/1);\n hidden_state_quantized->type = input_weights->type;\n hidden_state_quantized->allocation_type = kTfLiteArenaRw;\n if (!TfLiteIntArrayEqual(hidden_state_quantized->dims,\n hidden_state->dims)) {\n TfLiteIntArray* hidden_state_quantized_size =\n TfLiteIntArrayCopy(hidden_state->dims);\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, hidden_state_quantized,\n hidden_state_quantized_size));\n }\n node->temporaries->data[2] = op_data->scratch_tensor_index + 2;\n TfLiteTensor* scaling_factors = GetTemporary(context, node, /*index=*/2);\n scaling_factors->type = kTfLiteFloat32;\n scaling_factors->allocation_type = kTfLiteArenaRw;\n int scaling_dims[1] = {batch_size};\n if (!TfLiteIntArrayEqualsArray(scaling_factors->dims, 1, scaling_dims)) {\n TfLiteIntArray* scaling_factors_size = TfLiteIntArrayCreate(1);\n scaling_factors_size->data[0] = batch_size;\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, scaling_factors,\n scaling_factors_size));\n }\n node->temporaries->data[3] = op_data->scratch_tensor_index + 3;\n TfLiteTensor* accum_scratch = GetTemporary(context, node, /*index=*/3);\n accum_scratch->type = kTfLiteInt32;\n accum_scratch->allocation_type = kTfLiteArenaRw;\n int accum_scratch_dims[2] = {num_units, batch_size};\n if (!TfLiteIntArrayEqualsArray(accum_scratch->dims, 2,\n accum_scratch_dims)) {\n TfLiteIntArray* accum_scratch_size = TfLiteIntArrayCreate(2);\n accum_scratch_size->data[0] = accum_scratch_dims[0];\n accum_scratch_size->data[1] = accum_scratch_dims[1];\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, accum_scratch,\n accum_scratch_size));\n }\n node->temporaries->data[4] = op_data->scratch_tensor_index + 4;\n TfLiteTensor* zero_points = GetTemporary(context, node, /*index=*/4);\n zero_points->type = kTfLiteInt32;\n zero_points->allocation_type = kTfLiteArenaRw;\n int zero_points_dims[1] = {batch_size};\n if (!TfLiteIntArrayEqualsArray(zero_points->dims, 1, zero_points_dims)) {\n TfLiteIntArray* zero_points_size = TfLiteIntArrayCreate(1);\n zero_points_size->data[0] = batch_size;\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, zero_points,\n zero_points_size));\n }\n node->temporaries->data[5] = op_data->scratch_tensor_index + 5;\n TfLiteTensor* row_sums = GetTemporary(context, node, /*index=*/5);\n row_sums->type = kTfLiteInt32;\n row_sums->allocation_type = kTfLiteArenaRwPersistent;\n int row_sums_dims[2] = {2, num_units};\n if (!TfLiteIntArrayEqualsArray(row_sums->dims, 2, row_sums_dims)) {\n TfLiteIntArray* row_sums_size = TfLiteIntArrayCreate(2);\n row_sums_size->data[0] = row_sums_dims[0];\n row_sums_size->data[1] = row_sums_dims[1];\n TF_LITE_ENSURE_OK(\n context, context->ResizeTensor(context, row_sums, row_sums_size));\n }\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2924, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n // Check we have all the inputs and outputs we need.\n TF_LITE_ENSURE_EQ(context, node->inputs->size, 5);\n TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* input_weights;\n TF_LITE_ENSURE_OK(\n context, GetInputSafe(context, node, kWeightsTensor, &input_weights));\n const TfLiteTensor* recurrent_weights;\n TF_LITE_ENSURE_OK(\n context,\n GetInputSafe(context, node, kRecurrentWeightsTensor, &recurrent_weights));\n const TfLiteTensor* bias;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kBiasTensor, &bias));\n const TfLiteTensor* hidden_state;\n TF_LITE_ENSURE_OK(\n context, GetInputSafe(context, node, kHiddenStateTensor, &hidden_state));\n\n // Check all the parameters of tensor match within themselves and match the\n // input configuration.\n auto* params = reinterpret_cast(node->builtin_data);\n const bool time_major = params->time_major;\n const int batch_size =\n (time_major) ? input->dims->data[1] : input->dims->data[0];\n const int max_time =\n (time_major) ? input->dims->data[0] : input->dims->data[1];\n const int num_units = input_weights->dims->data[0];\n TF_LITE_ENSURE_EQ(context, input->dims->data[2],\n input_weights->dims->data[1]);\n TF_LITE_ENSURE_EQ(context, input_weights->dims->data[0], bias->dims->data[0]);\n TF_LITE_ENSURE_EQ(context, recurrent_weights->dims->data[0],\n bias->dims->data[0]);\n TF_LITE_ENSURE_EQ(context, recurrent_weights->dims->data[1],\n bias->dims->data[0]);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input_weights->type,\n recurrent_weights->type);\n TF_LITE_ENSURE_EQ(context, NumDimensions(hidden_state), 2);\n TF_LITE_ENSURE_EQ(context, hidden_state->dims->data[0], batch_size);\n TF_LITE_ENSURE_EQ(context, hidden_state->dims->data[1], num_units);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n // Resize output.\n TfLiteIntArray* output_size_array = TfLiteIntArrayCreate(3);\n output_size_array->data[0] = (time_major) ? max_time : batch_size;\n output_size_array->data[1] = (time_major) ? batch_size : max_time;\n output_size_array->data[2] = num_units;\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_size_array));\n\n const bool is_hybrid = IsHybridOp(input, input_weights);\n\n // Allocate temporary tensors to store quantized values of input and\n // hidden_state tensors.\n if (is_hybrid) {\n auto* op_data = reinterpret_cast(node->user_data);\n op_data->compute_row_sums = true;\n TfLiteIntArrayFree(node->temporaries);\n node->temporaries = TfLiteIntArrayCreate(6);\n node->temporaries->data[0] = op_data->scratch_tensor_index;\n TfLiteTensor* input_quantized;\n TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, /*index=*/0,\n &input_quantized));\n input_quantized->type = input_weights->type;\n input_quantized->allocation_type = kTfLiteArenaRw;\n if (!TfLiteIntArrayEqual(input_quantized->dims, input->dims)) {\n TfLiteIntArray* input_quantized_size = TfLiteIntArrayCopy(input->dims);\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, input_quantized,\n input_quantized_size));\n }\n node->temporaries->data[1] = op_data->scratch_tensor_index + 1;\n TfLiteTensor* hidden_state_quantized;\n TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, /*index=*/1,\n &hidden_state_quantized));\n hidden_state_quantized->type = input_weights->type;\n hidden_state_quantized->allocation_type = kTfLiteArenaRw;\n if (!TfLiteIntArrayEqual(hidden_state_quantized->dims,\n hidden_state->dims)) {\n TfLiteIntArray* hidden_state_quantized_size =\n TfLiteIntArrayCopy(hidden_state->dims);\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, hidden_state_quantized,\n hidden_state_quantized_size));\n }\n node->temporaries->data[2] = op_data->scratch_tensor_index + 2;\n TfLiteTensor* scaling_factors;\n TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, /*index=*/2,\n &scaling_factors));\n scaling_factors->type = kTfLiteFloat32;\n scaling_factors->allocation_type = kTfLiteArenaRw;\n int scaling_dims[1] = {batch_size};\n if (!TfLiteIntArrayEqualsArray(scaling_factors->dims, 1, scaling_dims)) {\n TfLiteIntArray* scaling_factors_size = TfLiteIntArrayCreate(1);\n scaling_factors_size->data[0] = batch_size;\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, scaling_factors,\n scaling_factors_size));\n }\n node->temporaries->data[3] = op_data->scratch_tensor_index + 3;\n TfLiteTensor* accum_scratch;\n TF_LITE_ENSURE_OK(\n context, GetTemporarySafe(context, node, /*index=*/3, &accum_scratch));\n accum_scratch->type = kTfLiteInt32;\n accum_scratch->allocation_type = kTfLiteArenaRw;\n int accum_scratch_dims[2] = {num_units, batch_size};\n if (!TfLiteIntArrayEqualsArray(accum_scratch->dims, 2,\n accum_scratch_dims)) {\n TfLiteIntArray* accum_scratch_size = TfLiteIntArrayCreate(2);\n accum_scratch_size->data[0] = accum_scratch_dims[0];\n accum_scratch_size->data[1] = accum_scratch_dims[1];\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, accum_scratch,\n accum_scratch_size));\n }\n node->temporaries->data[4] = op_data->scratch_tensor_index + 4;\n TfLiteTensor* zero_points;\n TF_LITE_ENSURE_OK(\n context, GetTemporarySafe(context, node, /*index=*/4, &zero_points));\n zero_points->type = kTfLiteInt32;\n zero_points->allocation_type = kTfLiteArenaRw;\n int zero_points_dims[1] = {batch_size};\n if (!TfLiteIntArrayEqualsArray(zero_points->dims, 1, zero_points_dims)) {\n TfLiteIntArray* zero_points_size = TfLiteIntArrayCreate(1);\n zero_points_size->data[0] = batch_size;\n TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, zero_points,\n zero_points_size));\n }\n node->temporaries->data[5] = op_data->scratch_tensor_index + 5;\n TfLiteTensor* row_sums;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, /*index=*/5, &row_sums));\n row_sums->type = kTfLiteInt32;\n row_sums->allocation_type = kTfLiteArenaRwPersistent;\n int row_sums_dims[2] = {2, num_units};\n if (!TfLiteIntArrayEqualsArray(row_sums->dims, 2, row_sums_dims)) {\n TfLiteIntArray* row_sums_size = TfLiteIntArrayCreate(2);\n row_sums_size->data[0] = row_sums_dims[0];\n row_sums_size->data[1] = row_sums_dims[1];\n TF_LITE_ENSURE_OK(\n context, context->ResizeTensor(context, row_sums, row_sums_size));\n }\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 681, "func": "write_file(tree_t *t,\t\t/* I - Tree entry */\n FILE *fp,\t\t/* I - File to write to */\n int col)\t\t/* I - Current column */\n{\n int\ti;\t\t\t/* Looping var */\n uchar\t*ptr;\t\t\t/* Character pointer */\n\n\n while (t != NULL)\n {\n if (t->markup == MARKUP_NONE)\n {\n if (t->preformatted)\n {\n for (ptr = t->data; *ptr != '\\0'; ptr ++)\n fputs((char *)iso8859(*ptr), fp);\n\n\tif (t->data[strlen((char *)t->data) - 1] == '\\n')\n col = 0;\n\telse\n col += strlen((char *)t->data);\n }\n else\n {\n\tif ((col + (int)strlen((char *)t->data)) > 72 && col > 0)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n\n for (ptr = t->data; *ptr != '\\0'; ptr ++)\n fputs((char *)iso8859(*ptr), fp);\n\n\tcol += strlen((char *)t->data);\n\n\tif (col > 72)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n }\n }\n else if (t->markup == MARKUP_COMMENT)\n fprintf(fp, \"\\n\\n\", t->data);\n else if (t->markup > 0)\n {\n switch (t->markup)\n {\n case MARKUP_AREA :\n case MARKUP_BR :\n case MARKUP_CENTER :\n case MARKUP_COMMENT :\n case MARKUP_DD :\n case MARKUP_DL :\n case MARKUP_DT :\n case MARKUP_H1 :\n case MARKUP_H2 :\n case MARKUP_H3 :\n case MARKUP_H4 :\n case MARKUP_H5 :\n case MARKUP_H6 :\n case MARKUP_HEAD :\n case MARKUP_HR :\n case MARKUP_LI :\n case MARKUP_MAP :\n case MARKUP_OL :\n case MARKUP_P :\n case MARKUP_PRE :\n case MARKUP_TABLE :\n case MARKUP_TITLE :\n case MARKUP_TR :\n case MARKUP_UL :\n\tcase MARKUP_DIR :\n\tcase MARKUP_MENU :\n if (col > 0)\n {\n putc('\\n', fp);\n col = 0;\n }\n default :\n break;\n }\n\n col += fprintf(fp, \"<%s\", _htmlMarkups[t->markup]);\n for (i = 0; i < t->nvars; i ++)\n {\n\tif (col > 72 && !t->preformatted)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n\n if (col > 0)\n {\n putc(' ', fp);\n col ++;\n }\n\n\tif (t->vars[i].value == NULL)\n col += fprintf(fp, \"%s\", t->vars[i].name);\n\telse if (strchr((char *)t->vars[i].value, '\\\"') != NULL)\n col += fprintf(fp, \"%s=\\'%s\\'\", t->vars[i].name, t->vars[i].value);\n\telse\n col += fprintf(fp, \"%s=\\\"%s\\\"\", t->vars[i].name, t->vars[i].value);\n }\n\n putc('>', fp);\n col ++;\n\n if (col > 72 && !t->preformatted)\n {\n\tputc('\\n', fp);\n\tcol = 0;\n }\n\n if (t->child != NULL)\n {\n\tcol = write_file(t->child, fp, col);\n\n\tif (col > 72 && !t->preformatted)\n\t{\n\t putc('\\n', fp);\n\t col = 0;\n\t}\n\n col += fprintf(fp, \"\", _htmlMarkups[t->markup]);\n switch (t->markup)\n {\n case MARKUP_AREA :\n case MARKUP_BR :\n case MARKUP_CENTER :\n case MARKUP_COMMENT :\n case MARKUP_DD :\n case MARKUP_DL :\n case MARKUP_DT :\n case MARKUP_H1 :\n case MARKUP_H2 :\n case MARKUP_H3 :\n case MARKUP_H4 :\n case MARKUP_H5 :\n case MARKUP_H6 :\n case MARKUP_HEAD :\n case MARKUP_HR :\n case MARKUP_LI :\n case MARKUP_MAP :\n case MARKUP_OL :\n case MARKUP_P :\n case MARKUP_PRE :\n case MARKUP_TABLE :\n case MARKUP_TITLE :\n case MARKUP_TR :\n case MARKUP_UL :\n case MARKUP_DIR :\n case MARKUP_MENU :\n putc('\\n', fp);\n col = 0;\n default :\n\t break;\n }\n }\n }\n\n t = t->next;\n }\n\n return (col);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-34033", "cwe_id": "CWE-787" }, { "id": 681, "func": "write_file(tree_t *t,\t\t/* I - Tree entry */\n FILE *fp,\t\t/* I - File to write to */\n int col)\t\t/* I - Current column */\n{\n int\ti;\t\t\t/* Looping var */\n uchar\t*ptr;\t\t\t/* Character pointer */\n\n\n while (t != NULL)\n {\n if (t->markup == MARKUP_NONE)\n {\n if (t->preformatted)\n {\n for (ptr = t->data; *ptr != '\\0'; ptr ++)\n fputs((char *)iso8859(*ptr), fp);\n\n\tif (t->data[0] && t->data[strlen((char *)t->data) - 1] == '\\n')\n col = 0;\n\telse\n col += strlen((char *)t->data);\n }\n else\n {\n\tif ((col + (int)strlen((char *)t->data)) > 72 && col > 0)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n\n for (ptr = t->data; *ptr != '\\0'; ptr ++)\n fputs((char *)iso8859(*ptr), fp);\n\n\tcol += strlen((char *)t->data);\n\n\tif (col > 72)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n }\n }\n else if (t->markup == MARKUP_COMMENT)\n fprintf(fp, \"\\n\\n\", t->data);\n else if (t->markup > 0)\n {\n switch (t->markup)\n {\n case MARKUP_AREA :\n case MARKUP_BR :\n case MARKUP_CENTER :\n case MARKUP_COMMENT :\n case MARKUP_DD :\n case MARKUP_DL :\n case MARKUP_DT :\n case MARKUP_H1 :\n case MARKUP_H2 :\n case MARKUP_H3 :\n case MARKUP_H4 :\n case MARKUP_H5 :\n case MARKUP_H6 :\n case MARKUP_HEAD :\n case MARKUP_HR :\n case MARKUP_LI :\n case MARKUP_MAP :\n case MARKUP_OL :\n case MARKUP_P :\n case MARKUP_PRE :\n case MARKUP_TABLE :\n case MARKUP_TITLE :\n case MARKUP_TR :\n case MARKUP_UL :\n\tcase MARKUP_DIR :\n\tcase MARKUP_MENU :\n if (col > 0)\n {\n putc('\\n', fp);\n col = 0;\n }\n default :\n break;\n }\n\n col += fprintf(fp, \"<%s\", _htmlMarkups[t->markup]);\n for (i = 0; i < t->nvars; i ++)\n {\n\tif (col > 72 && !t->preformatted)\n\t{\n putc('\\n', fp);\n col = 0;\n\t}\n\n if (col > 0)\n {\n putc(' ', fp);\n col ++;\n }\n\n\tif (t->vars[i].value == NULL)\n col += fprintf(fp, \"%s\", t->vars[i].name);\n\telse if (strchr((char *)t->vars[i].value, '\\\"') != NULL)\n col += fprintf(fp, \"%s=\\'%s\\'\", t->vars[i].name, t->vars[i].value);\n\telse\n col += fprintf(fp, \"%s=\\\"%s\\\"\", t->vars[i].name, t->vars[i].value);\n }\n\n putc('>', fp);\n col ++;\n\n if (col > 72 && !t->preformatted)\n {\n\tputc('\\n', fp);\n\tcol = 0;\n }\n\n if (t->child != NULL)\n {\n\tcol = write_file(t->child, fp, col);\n\n\tif (col > 72 && !t->preformatted)\n\t{\n\t putc('\\n', fp);\n\t col = 0;\n\t}\n\n col += fprintf(fp, \"\", _htmlMarkups[t->markup]);\n switch (t->markup)\n {\n case MARKUP_AREA :\n case MARKUP_BR :\n case MARKUP_CENTER :\n case MARKUP_COMMENT :\n case MARKUP_DD :\n case MARKUP_DL :\n case MARKUP_DT :\n case MARKUP_H1 :\n case MARKUP_H2 :\n case MARKUP_H3 :\n case MARKUP_H4 :\n case MARKUP_H5 :\n case MARKUP_H6 :\n case MARKUP_HEAD :\n case MARKUP_HR :\n case MARKUP_LI :\n case MARKUP_MAP :\n case MARKUP_OL :\n case MARKUP_P :\n case MARKUP_PRE :\n case MARKUP_TABLE :\n case MARKUP_TITLE :\n case MARKUP_TR :\n case MARKUP_UL :\n case MARKUP_DIR :\n case MARKUP_MENU :\n putc('\\n', fp);\n col = 0;\n default :\n\t break;\n }\n }\n }\n\n t = t->next;\n }\n\n return (col);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-34033", "cwe_id": "CWE-787" }, { "id": 499, "func": "mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sk_buff\t\t*skb;\n\tstruct sock\t\t*sk = sock->sk;\n\tstruct sockaddr_mISDN\t*maddr;\n\n\tint\t\tcopied, err;\n\n\tif (*debug & DEBUG_SOCKET)\n\t\tprintk(KERN_DEBUG \"%s: len %d, flags %x ch.nr %d, proto %x\\n\",\n\t\t __func__, (int)len, flags, _pms(sk)->ch.nr,\n\t\t sk->sk_protocol);\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tif (sk->sk_state == MISDN_CLOSED)\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tif (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) {\n\t\tmsg->msg_namelen = sizeof(struct sockaddr_mISDN);\n\t\tmaddr = (struct sockaddr_mISDN *)msg->msg_name;\n\t\tmaddr->family = AF_ISDN;\n\t\tmaddr->dev = _pms(sk)->dev->id;\n\t\tif ((sk->sk_protocol == ISDN_P_LAPD_TE) ||\n\t\t (sk->sk_protocol == ISDN_P_LAPD_NT)) {\n\t\t\tmaddr->channel = (mISDN_HEAD_ID(skb) >> 16) & 0xff;\n\t\t\tmaddr->tei = (mISDN_HEAD_ID(skb) >> 8) & 0xff;\n\t\t\tmaddr->sapi = mISDN_HEAD_ID(skb) & 0xff;\n\t\t} else {\n\t\t\tmaddr->channel = _pms(sk)->ch.nr;\n\t\t\tmaddr->sapi = _pms(sk)->ch.addr & 0xFF;\n\t\t\tmaddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF;\n\t\t}\n\t} else {\n\t\tif (msg->msg_namelen)\n\t\t\tprintk(KERN_WARNING \"%s: too small namelen %d\\n\",\n\t\t\t __func__, msg->msg_namelen);\n\t\tmsg->msg_namelen = 0;\n\t}\n\n\tcopied = skb->len + MISDN_HEADER_LEN;\n\tif (len < copied) {\n\t\tif (flags & MSG_PEEK)\n\t\t\tatomic_dec(&skb->users);\n\t\telse\n\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\treturn -ENOSPC;\n\t}\n\tmemcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb),\n\t MISDN_HEADER_LEN);\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tmISDN_sock_cmsg(sk, msg, skb);\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 499, "func": "mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sk_buff\t\t*skb;\n\tstruct sock\t\t*sk = sock->sk;\n\n\tint\t\tcopied, err;\n\n\tif (*debug & DEBUG_SOCKET)\n\t\tprintk(KERN_DEBUG \"%s: len %d, flags %x ch.nr %d, proto %x\\n\",\n\t\t __func__, (int)len, flags, _pms(sk)->ch.nr,\n\t\t sk->sk_protocol);\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tif (sk->sk_state == MISDN_CLOSED)\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_mISDN *maddr = msg->msg_name;\n\n\t\tmaddr->family = AF_ISDN;\n\t\tmaddr->dev = _pms(sk)->dev->id;\n\t\tif ((sk->sk_protocol == ISDN_P_LAPD_TE) ||\n\t\t (sk->sk_protocol == ISDN_P_LAPD_NT)) {\n\t\t\tmaddr->channel = (mISDN_HEAD_ID(skb) >> 16) & 0xff;\n\t\t\tmaddr->tei = (mISDN_HEAD_ID(skb) >> 8) & 0xff;\n\t\t\tmaddr->sapi = mISDN_HEAD_ID(skb) & 0xff;\n\t\t} else {\n\t\t\tmaddr->channel = _pms(sk)->ch.nr;\n\t\t\tmaddr->sapi = _pms(sk)->ch.addr & 0xFF;\n\t\t\tmaddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF;\n\t\t}\n\t\tmsg->msg_namelen = sizeof(*maddr);\n\t}\n\n\tcopied = skb->len + MISDN_HEADER_LEN;\n\tif (len < copied) {\n\t\tif (flags & MSG_PEEK)\n\t\t\tatomic_dec(&skb->users);\n\t\telse\n\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\treturn -ENOSPC;\n\t}\n\tmemcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb),\n\t MISDN_HEADER_LEN);\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tmISDN_sock_cmsg(sk, msg, skb);\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 910, "func": "int ZlibInStream::overrun(int itemSize, int nItems, bool wait)\n{\n if (itemSize > bufSize)\n throw Exception(\"ZlibInStream overrun: max itemSize exceeded\");\n\n if (end - ptr != 0)\n memmove(start, ptr, end - ptr);\n\n offset += ptr - start;\n end -= ptr - start;\n ptr = start;\n\n while (end - ptr < itemSize) {\n if (!decompress(wait))\n return 0;\n }\n\n if (itemSize * nItems > end - ptr)\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 910, "func": "size_t ZlibInStream::overrun(size_t itemSize, size_t nItems, bool wait)\n{\n if (itemSize > bufSize)\n throw Exception(\"ZlibInStream overrun: max itemSize exceeded\");\n\n if (end - ptr != 0)\n memmove(start, ptr, end - ptr);\n\n offset += ptr - start;\n end -= ptr - start;\n ptr = start;\n\n while ((size_t)(end - ptr) < itemSize) {\n if (!decompress(wait))\n return 0;\n }\n\n if (itemSize * nItems > (size_t)(end - ptr))\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 203, "func": "static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);\n\t\n\tobject->u.dir.index++;\n\tspl_filesystem_dir_read(object TSRMLS_CC);\n\tif (object->file_name) {\n\t\tefree(object->file_name);\n\t\tobject->file_name = NULL;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 203, "func": "static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);\n\n\tobject->u.dir.index++;\n\tspl_filesystem_dir_read(object TSRMLS_CC);\n\tif (object->file_name) {\n\t\tefree(object->file_name);\n\t\tobject->file_name = NULL;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 8, "func": "int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t\tstruct msghdr *msg, size_t len, int flags)\n{\n\tint noblock = flags & MSG_DONTWAIT;\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tsize_t copied;\n\tint err;\n\n\tBT_DBG(\"sock %p sk %p len %zu\", sock, sk, len);\n\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb) {\n\t\tif (sk->sk_shutdown & RCV_SHUTDOWN) {\n\t\t\tmsg->msg_namelen = 0;\n\t\t\treturn 0;\n\t\t}\n\t\treturn err;\n\t}\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\tskb_reset_transport_header(skb);\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err == 0) {\n\t\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t\tif (bt_sk(sk)->skb_msg_name)\n\t\t\tbt_sk(sk)->skb_msg_name(skb, msg->msg_name,\n\t\t\t\t\t\t&msg->msg_namelen);\n\t\telse\n\t\t\tmsg->msg_namelen = 0;\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 8, "func": "int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t\tstruct msghdr *msg, size_t len, int flags)\n{\n\tint noblock = flags & MSG_DONTWAIT;\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tsize_t copied;\n\tint err;\n\n\tBT_DBG(\"sock %p sk %p len %zu\", sock, sk, len);\n\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb) {\n\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\treturn 0;\n\n\t\treturn err;\n\t}\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\tskb_reset_transport_header(skb);\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err == 0) {\n\t\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t\tif (bt_sk(sk)->skb_msg_name)\n\t\t\tbt_sk(sk)->skb_msg_name(skb, msg->msg_name,\n\t\t\t\t\t\t&msg->msg_namelen);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 2392, "func": "void carray2Hex(const unsigned char *d, uint64_t _len, char *_hexArray,\n uint64_t _hexArrayLen) {\n\n CHECK_STATE(d);\n CHECK_STATE(_hexArray);\n\n char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n CHECK_STATE(_hexArrayLen > 2 * _len);\n\n for (int j = 0; j < _len; j++) {\n _hexArray[j * 2] = hexval[((d[j] >> 4) & 0xF)];\n _hexArray[j * 2 + 1] = hexval[(d[j]) & 0x0F];\n }\n\n _hexArray[_len * 2] = 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 2392, "func": "void carray2Hex(const unsigned char *d, uint64_t _len, char *_hexArray,\n uint64_t _hexArrayLen) {\n\n CHECK_STATE(d);\n CHECK_STATE(_hexArray);\n\n char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n CHECK_STATE(_hexArrayLen > 2 * _len);\n\n for (uint64_t j = 0; j < _len; j++) {\n _hexArray[j * 2] = hexval[((d[j] >> 4) & 0xF)];\n _hexArray[j * 2 + 1] = hexval[(d[j]) & 0x0F];\n }\n\n _hexArray[_len * 2] = 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 1100, "func": "evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *outlen)\n{\n\tint port;\n\tchar buf[128];\n\tconst char *cp, *addr_part, *port_part;\n\tint is_ipv6;\n\t/* recognized formats are:\n\t * [ipv6]:port\n\t * ipv6\n\t * [ipv6]\n\t * ipv4:port\n\t * ipv4\n\t */\n\n\tcp = strchr(ip_as_string, ':');\n\tif (*ip_as_string == '[') {\n\t\tint len;\n\t\tif (!(cp = strchr(ip_as_string, ']'))) {\n\t\t\treturn -1;\n\t\t}\n\t\tlen = (int) ( cp-(ip_as_string + 1) );\n\t\tif (len > (int)sizeof(buf)-1) {\n\t\t\treturn -1;\n\t\t}\n\t\tmemcpy(buf, ip_as_string+1, len);\n\t\tbuf[len] = '\\0';\n\t\taddr_part = buf;\n\t\tif (cp[1] == ':')\n\t\t\tport_part = cp+2;\n\t\telse\n\t\t\tport_part = NULL;\n\t\tis_ipv6 = 1;\n\t} else if (cp && strchr(cp+1, ':')) {\n\t\tis_ipv6 = 1;\n\t\taddr_part = ip_as_string;\n\t\tport_part = NULL;\n\t} else if (cp) {\n\t\tis_ipv6 = 0;\n\t\tif (cp - ip_as_string > (int)sizeof(buf)-1) {\n\t\t\treturn -1;\n\t\t}\n\t\tmemcpy(buf, ip_as_string, cp-ip_as_string);\n\t\tbuf[cp-ip_as_string] = '\\0';\n\t\taddr_part = buf;\n\t\tport_part = cp+1;\n\t} else {\n\t\taddr_part = ip_as_string;\n\t\tport_part = NULL;\n\t\tis_ipv6 = 0;\n\t}\n\n\tif (port_part == NULL) {\n\t\tport = 0;\n\t} else {\n\t\tport = atoi(port_part);\n\t\tif (port <= 0 || port > 65535) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (!addr_part)\n\t\treturn -1; /* Should be impossible. */\n#ifdef AF_INET6\n\tif (is_ipv6)\n\t{\n\t\tstruct sockaddr_in6 sin6;\n\t\tmemset(&sin6, 0, sizeof(sin6));\n#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN\n\t\tsin6.sin6_len = sizeof(sin6);\n#endif\n\t\tsin6.sin6_family = AF_INET6;\n\t\tsin6.sin6_port = htons(port);\n\t\tif (1 != evutil_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr))\n\t\t\treturn -1;\n\t\tif ((int)sizeof(sin6) > *outlen)\n\t\t\treturn -1;\n\t\tmemset(out, 0, *outlen);\n\t\tmemcpy(out, &sin6, sizeof(sin6));\n\t\t*outlen = sizeof(sin6);\n\t\treturn 0;\n\t}\n\telse\n#endif\n\t{\n\t\tstruct sockaddr_in sin;\n\t\tmemset(&sin, 0, sizeof(sin));\n#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN\n\t\tsin.sin_len = sizeof(sin);\n#endif\n\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = htons(port);\n\t\tif (1 != evutil_inet_pton(AF_INET, addr_part, &sin.sin_addr))\n\t\t\treturn -1;\n\t\tif ((int)sizeof(sin) > *outlen)\n\t\t\treturn -1;\n\t\tmemset(out, 0, *outlen);\n\t\tmemcpy(out, &sin, sizeof(sin));\n\t\t*outlen = sizeof(sin);\n\t\treturn 0;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10196", "cwe_id": "CWE-787" }, { "id": 1100, "func": "evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *outlen)\n{\n\tint port;\n\tchar buf[128];\n\tconst char *cp, *addr_part, *port_part;\n\tint is_ipv6;\n\t/* recognized formats are:\n\t * [ipv6]:port\n\t * ipv6\n\t * [ipv6]\n\t * ipv4:port\n\t * ipv4\n\t */\n\n\tcp = strchr(ip_as_string, ':');\n\tif (*ip_as_string == '[') {\n\t\tsize_t len;\n\t\tif (!(cp = strchr(ip_as_string, ']'))) {\n\t\t\treturn -1;\n\t\t}\n\t\tlen = ( cp-(ip_as_string + 1) );\n\t\tif (len > sizeof(buf)-1) {\n\t\t\treturn -1;\n\t\t}\n\t\tmemcpy(buf, ip_as_string+1, len);\n\t\tbuf[len] = '\\0';\n\t\taddr_part = buf;\n\t\tif (cp[1] == ':')\n\t\t\tport_part = cp+2;\n\t\telse\n\t\t\tport_part = NULL;\n\t\tis_ipv6 = 1;\n\t} else if (cp && strchr(cp+1, ':')) {\n\t\tis_ipv6 = 1;\n\t\taddr_part = ip_as_string;\n\t\tport_part = NULL;\n\t} else if (cp) {\n\t\tis_ipv6 = 0;\n\t\tif (cp - ip_as_string > (int)sizeof(buf)-1) {\n\t\t\treturn -1;\n\t\t}\n\t\tmemcpy(buf, ip_as_string, cp-ip_as_string);\n\t\tbuf[cp-ip_as_string] = '\\0';\n\t\taddr_part = buf;\n\t\tport_part = cp+1;\n\t} else {\n\t\taddr_part = ip_as_string;\n\t\tport_part = NULL;\n\t\tis_ipv6 = 0;\n\t}\n\n\tif (port_part == NULL) {\n\t\tport = 0;\n\t} else {\n\t\tport = atoi(port_part);\n\t\tif (port <= 0 || port > 65535) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (!addr_part)\n\t\treturn -1; /* Should be impossible. */\n#ifdef AF_INET6\n\tif (is_ipv6)\n\t{\n\t\tstruct sockaddr_in6 sin6;\n\t\tmemset(&sin6, 0, sizeof(sin6));\n#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN\n\t\tsin6.sin6_len = sizeof(sin6);\n#endif\n\t\tsin6.sin6_family = AF_INET6;\n\t\tsin6.sin6_port = htons(port);\n\t\tif (1 != evutil_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr))\n\t\t\treturn -1;\n\t\tif ((int)sizeof(sin6) > *outlen)\n\t\t\treturn -1;\n\t\tmemset(out, 0, *outlen);\n\t\tmemcpy(out, &sin6, sizeof(sin6));\n\t\t*outlen = sizeof(sin6);\n\t\treturn 0;\n\t}\n\telse\n#endif\n\t{\n\t\tstruct sockaddr_in sin;\n\t\tmemset(&sin, 0, sizeof(sin));\n#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN\n\t\tsin.sin_len = sizeof(sin);\n#endif\n\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = htons(port);\n\t\tif (1 != evutil_inet_pton(AF_INET, addr_part, &sin.sin_addr))\n\t\t\treturn -1;\n\t\tif ((int)sizeof(sin) > *outlen)\n\t\t\treturn -1;\n\t\tmemset(out, 0, *outlen);\n\t\tmemcpy(out, &sin, sizeof(sin));\n\t\t*outlen = sizeof(sin);\n\t\treturn 0;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10196", "cwe_id": "CWE-787" }, { "id": 945, "func": "static int perf_swevent_add(struct perf_event *event, int flags)\n{\n\tstruct swevent_htable *swhash = this_cpu_ptr(&swevent_htable);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct hlist_head *head;\n\n\tif (is_sampling_event(event)) {\n\t\thwc->last_period = hwc->sample_period;\n\t\tperf_swevent_set_period(event);\n\t}\n\n\thwc->state = !(flags & PERF_EF_START);\n\n\thead = find_swevent_head(swhash, event);\n\tif (!head) {\n\t\t/*\n\t\t * We can race with cpu hotplug code. Do not\n\t\t * WARN if the cpu just got unplugged.\n\t\t */\n\t\tWARN_ON_ONCE(swhash->online);\n\t\treturn -EINVAL;\n\t}\n\n\thlist_add_head_rcu(&event->hlist_entry, head);\n\tperf_event_update_userpage(event);\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-8963", "cwe_id": "CWE-362" }, { "id": 945, "func": "static int perf_swevent_add(struct perf_event *event, int flags)\n{\n\tstruct swevent_htable *swhash = this_cpu_ptr(&swevent_htable);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct hlist_head *head;\n\n\tif (is_sampling_event(event)) {\n\t\thwc->last_period = hwc->sample_period;\n\t\tperf_swevent_set_period(event);\n\t}\n\n\thwc->state = !(flags & PERF_EF_START);\n\n\thead = find_swevent_head(swhash, event);\n\tif (WARN_ON_ONCE(!head))\n\t\treturn -EINVAL;\n\n\thlist_add_head_rcu(&event->hlist_entry, head);\n\tperf_event_update_userpage(event);\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-8963", "cwe_id": "CWE-362" }, { "id": 2828, "func": "long kvm_arch_vcpu_ioctl(struct file *filp,\n\t\t\t unsigned int ioctl, unsigned long arg)\n{\n\tstruct kvm_vcpu *vcpu = filp->private_data;\n\tvoid __user *argp = (void __user *)arg;\n\tint r;\n\tunion {\n\t\tstruct kvm_lapic_state *lapic;\n\t\tstruct kvm_xsave *xsave;\n\t\tstruct kvm_xcrs *xcrs;\n\t\tvoid *buffer;\n\t} u;\n\n\tu.buffer = NULL;\n\tswitch (ioctl) {\n\tcase KVM_GET_LAPIC: {\n\t\tr = -EINVAL;\n\t\tif (!vcpu->arch.apic)\n\t\t\tgoto out;\n\t\tu.lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);\n\n\t\tr = -ENOMEM;\n\t\tif (!u.lapic)\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_get_lapic(vcpu, u.lapic);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.lapic, sizeof(struct kvm_lapic_state)))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_LAPIC: {\n\t\tr = -EINVAL;\n\t\tif (!vcpu->arch.apic)\n\t\t\tgoto out;\n\t\tu.lapic = memdup_user(argp, sizeof(*u.lapic));\n\t\tif (IS_ERR(u.lapic))\n\t\t\treturn PTR_ERR(u.lapic);\n\n\t\tr = kvm_vcpu_ioctl_set_lapic(vcpu, u.lapic);\n\t\tbreak;\n\t}\n\tcase KVM_INTERRUPT: {\n\t\tstruct kvm_interrupt irq;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&irq, argp, sizeof irq))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_interrupt(vcpu, &irq);\n\t\tbreak;\n\t}\n\tcase KVM_NMI: {\n\t\tr = kvm_vcpu_ioctl_nmi(vcpu);\n\t\tbreak;\n\t}\n\tcase KVM_SET_CPUID: {\n\t\tstruct kvm_cpuid __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_set_cpuid(vcpu, &cpuid, cpuid_arg->entries);\n\t\tbreak;\n\t}\n\tcase KVM_SET_CPUID2: {\n\t\tstruct kvm_cpuid2 __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid2 cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_set_cpuid2(vcpu, &cpuid,\n\t\t\t\t\t cpuid_arg->entries);\n\t\tbreak;\n\t}\n\tcase KVM_GET_CPUID2: {\n\t\tstruct kvm_cpuid2 __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid2 cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_get_cpuid2(vcpu, &cpuid,\n\t\t\t\t\t cpuid_arg->entries);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_GET_MSRS:\n\t\tr = msr_io(vcpu, argp, kvm_get_msr, 1);\n\t\tbreak;\n\tcase KVM_SET_MSRS:\n\t\tr = msr_io(vcpu, argp, do_set_msr, 0);\n\t\tbreak;\n\tcase KVM_TPR_ACCESS_REPORTING: {\n\t\tstruct kvm_tpr_access_ctl tac;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&tac, argp, sizeof tac))\n\t\t\tgoto out;\n\t\tr = vcpu_ioctl_tpr_access_reporting(vcpu, &tac);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &tac, sizeof tac))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t};\n\tcase KVM_SET_VAPIC_ADDR: {\n\t\tstruct kvm_vapic_addr va;\n\n\t\tr = -EINVAL;\n\t\tif (!irqchip_in_kernel(vcpu->kvm))\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&va, argp, sizeof va))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tkvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);\n\t\tbreak;\n\t}\n\tcase KVM_X86_SETUP_MCE: {\n\t\tu64 mcg_cap;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&mcg_cap, argp, sizeof mcg_cap))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_x86_setup_mce(vcpu, mcg_cap);\n\t\tbreak;\n\t}\n\tcase KVM_X86_SET_MCE: {\n\t\tstruct kvm_x86_mce mce;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&mce, argp, sizeof mce))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_x86_set_mce(vcpu, &mce);\n\t\tbreak;\n\t}\n\tcase KVM_GET_VCPU_EVENTS: {\n\t\tstruct kvm_vcpu_events events;\n\n\t\tkvm_vcpu_ioctl_x86_get_vcpu_events(vcpu, &events);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &events, sizeof(struct kvm_vcpu_events)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_VCPU_EVENTS: {\n\t\tstruct kvm_vcpu_events events;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&events, argp, sizeof(struct kvm_vcpu_events)))\n\t\t\tbreak;\n\n\t\tr = kvm_vcpu_ioctl_x86_set_vcpu_events(vcpu, &events);\n\t\tbreak;\n\t}\n\tcase KVM_GET_DEBUGREGS: {\n\t\tstruct kvm_debugregs dbgregs;\n\n\t\tkvm_vcpu_ioctl_x86_get_debugregs(vcpu, &dbgregs);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &dbgregs,\n\t\t\t\t sizeof(struct kvm_debugregs)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_DEBUGREGS: {\n\t\tstruct kvm_debugregs dbgregs;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&dbgregs, argp,\n\t\t\t\t sizeof(struct kvm_debugregs)))\n\t\t\tbreak;\n\n\t\tr = kvm_vcpu_ioctl_x86_set_debugregs(vcpu, &dbgregs);\n\t\tbreak;\n\t}\n\tcase KVM_GET_XSAVE: {\n\t\tu.xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);\n\t\tr = -ENOMEM;\n\t\tif (!u.xsave)\n\t\t\tbreak;\n\n\t\tkvm_vcpu_ioctl_x86_get_xsave(vcpu, u.xsave);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.xsave, sizeof(struct kvm_xsave)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_XSAVE: {\n\t\tu.xsave = memdup_user(argp, sizeof(*u.xsave));\n\t\tif (IS_ERR(u.xsave))\n\t\t\treturn PTR_ERR(u.xsave);\n\n\t\tr = kvm_vcpu_ioctl_x86_set_xsave(vcpu, u.xsave);\n\t\tbreak;\n\t}\n\tcase KVM_GET_XCRS: {\n\t\tu.xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);\n\t\tr = -ENOMEM;\n\t\tif (!u.xcrs)\n\t\t\tbreak;\n\n\t\tkvm_vcpu_ioctl_x86_get_xcrs(vcpu, u.xcrs);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.xcrs,\n\t\t\t\t sizeof(struct kvm_xcrs)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_XCRS: {\n\t\tu.xcrs = memdup_user(argp, sizeof(*u.xcrs));\n\t\tif (IS_ERR(u.xcrs))\n\t\t\treturn PTR_ERR(u.xcrs);\n\n\t\tr = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs);\n\t\tbreak;\n\t}\n\tcase KVM_SET_TSC_KHZ: {\n\t\tu32 user_tsc_khz;\n\n\t\tr = -EINVAL;\n\t\tuser_tsc_khz = (u32)arg;\n\n\t\tif (user_tsc_khz >= kvm_max_guest_tsc_khz)\n\t\t\tgoto out;\n\n\t\tif (user_tsc_khz == 0)\n\t\t\tuser_tsc_khz = tsc_khz;\n\n\t\tkvm_set_tsc_khz(vcpu, user_tsc_khz);\n\n\t\tr = 0;\n\t\tgoto out;\n\t}\n\tcase KVM_GET_TSC_KHZ: {\n\t\tr = vcpu->arch.virtual_tsc_khz;\n\t\tgoto out;\n\t}\n\tcase KVM_KVMCLOCK_CTRL: {\n\t\tr = kvm_set_guest_paused(vcpu);\n\t\tgoto out;\n\t}\n\tdefault:\n\t\tr = -EINVAL;\n\t}\nout:\n\tkfree(u.buffer);\n\treturn r;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-6368", "cwe_id": "CWE-20" }, { "id": 2828, "func": "long kvm_arch_vcpu_ioctl(struct file *filp,\n\t\t\t unsigned int ioctl, unsigned long arg)\n{\n\tstruct kvm_vcpu *vcpu = filp->private_data;\n\tvoid __user *argp = (void __user *)arg;\n\tint r;\n\tunion {\n\t\tstruct kvm_lapic_state *lapic;\n\t\tstruct kvm_xsave *xsave;\n\t\tstruct kvm_xcrs *xcrs;\n\t\tvoid *buffer;\n\t} u;\n\n\tu.buffer = NULL;\n\tswitch (ioctl) {\n\tcase KVM_GET_LAPIC: {\n\t\tr = -EINVAL;\n\t\tif (!vcpu->arch.apic)\n\t\t\tgoto out;\n\t\tu.lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);\n\n\t\tr = -ENOMEM;\n\t\tif (!u.lapic)\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_get_lapic(vcpu, u.lapic);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.lapic, sizeof(struct kvm_lapic_state)))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_LAPIC: {\n\t\tr = -EINVAL;\n\t\tif (!vcpu->arch.apic)\n\t\t\tgoto out;\n\t\tu.lapic = memdup_user(argp, sizeof(*u.lapic));\n\t\tif (IS_ERR(u.lapic))\n\t\t\treturn PTR_ERR(u.lapic);\n\n\t\tr = kvm_vcpu_ioctl_set_lapic(vcpu, u.lapic);\n\t\tbreak;\n\t}\n\tcase KVM_INTERRUPT: {\n\t\tstruct kvm_interrupt irq;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&irq, argp, sizeof irq))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_interrupt(vcpu, &irq);\n\t\tbreak;\n\t}\n\tcase KVM_NMI: {\n\t\tr = kvm_vcpu_ioctl_nmi(vcpu);\n\t\tbreak;\n\t}\n\tcase KVM_SET_CPUID: {\n\t\tstruct kvm_cpuid __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_set_cpuid(vcpu, &cpuid, cpuid_arg->entries);\n\t\tbreak;\n\t}\n\tcase KVM_SET_CPUID2: {\n\t\tstruct kvm_cpuid2 __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid2 cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_set_cpuid2(vcpu, &cpuid,\n\t\t\t\t\t cpuid_arg->entries);\n\t\tbreak;\n\t}\n\tcase KVM_GET_CPUID2: {\n\t\tstruct kvm_cpuid2 __user *cpuid_arg = argp;\n\t\tstruct kvm_cpuid2 cpuid;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_get_cpuid2(vcpu, &cpuid,\n\t\t\t\t\t cpuid_arg->entries);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_GET_MSRS:\n\t\tr = msr_io(vcpu, argp, kvm_get_msr, 1);\n\t\tbreak;\n\tcase KVM_SET_MSRS:\n\t\tr = msr_io(vcpu, argp, do_set_msr, 0);\n\t\tbreak;\n\tcase KVM_TPR_ACCESS_REPORTING: {\n\t\tstruct kvm_tpr_access_ctl tac;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&tac, argp, sizeof tac))\n\t\t\tgoto out;\n\t\tr = vcpu_ioctl_tpr_access_reporting(vcpu, &tac);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &tac, sizeof tac))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t};\n\tcase KVM_SET_VAPIC_ADDR: {\n\t\tstruct kvm_vapic_addr va;\n\n\t\tr = -EINVAL;\n\t\tif (!irqchip_in_kernel(vcpu->kvm))\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&va, argp, sizeof va))\n\t\t\tgoto out;\n\t\tr = kvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);\n\t\tbreak;\n\t}\n\tcase KVM_X86_SETUP_MCE: {\n\t\tu64 mcg_cap;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&mcg_cap, argp, sizeof mcg_cap))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_x86_setup_mce(vcpu, mcg_cap);\n\t\tbreak;\n\t}\n\tcase KVM_X86_SET_MCE: {\n\t\tstruct kvm_x86_mce mce;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&mce, argp, sizeof mce))\n\t\t\tgoto out;\n\t\tr = kvm_vcpu_ioctl_x86_set_mce(vcpu, &mce);\n\t\tbreak;\n\t}\n\tcase KVM_GET_VCPU_EVENTS: {\n\t\tstruct kvm_vcpu_events events;\n\n\t\tkvm_vcpu_ioctl_x86_get_vcpu_events(vcpu, &events);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &events, sizeof(struct kvm_vcpu_events)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_VCPU_EVENTS: {\n\t\tstruct kvm_vcpu_events events;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&events, argp, sizeof(struct kvm_vcpu_events)))\n\t\t\tbreak;\n\n\t\tr = kvm_vcpu_ioctl_x86_set_vcpu_events(vcpu, &events);\n\t\tbreak;\n\t}\n\tcase KVM_GET_DEBUGREGS: {\n\t\tstruct kvm_debugregs dbgregs;\n\n\t\tkvm_vcpu_ioctl_x86_get_debugregs(vcpu, &dbgregs);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &dbgregs,\n\t\t\t\t sizeof(struct kvm_debugregs)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_DEBUGREGS: {\n\t\tstruct kvm_debugregs dbgregs;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&dbgregs, argp,\n\t\t\t\t sizeof(struct kvm_debugregs)))\n\t\t\tbreak;\n\n\t\tr = kvm_vcpu_ioctl_x86_set_debugregs(vcpu, &dbgregs);\n\t\tbreak;\n\t}\n\tcase KVM_GET_XSAVE: {\n\t\tu.xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);\n\t\tr = -ENOMEM;\n\t\tif (!u.xsave)\n\t\t\tbreak;\n\n\t\tkvm_vcpu_ioctl_x86_get_xsave(vcpu, u.xsave);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.xsave, sizeof(struct kvm_xsave)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_XSAVE: {\n\t\tu.xsave = memdup_user(argp, sizeof(*u.xsave));\n\t\tif (IS_ERR(u.xsave))\n\t\t\treturn PTR_ERR(u.xsave);\n\n\t\tr = kvm_vcpu_ioctl_x86_set_xsave(vcpu, u.xsave);\n\t\tbreak;\n\t}\n\tcase KVM_GET_XCRS: {\n\t\tu.xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);\n\t\tr = -ENOMEM;\n\t\tif (!u.xcrs)\n\t\t\tbreak;\n\n\t\tkvm_vcpu_ioctl_x86_get_xcrs(vcpu, u.xcrs);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, u.xcrs,\n\t\t\t\t sizeof(struct kvm_xcrs)))\n\t\t\tbreak;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_XCRS: {\n\t\tu.xcrs = memdup_user(argp, sizeof(*u.xcrs));\n\t\tif (IS_ERR(u.xcrs))\n\t\t\treturn PTR_ERR(u.xcrs);\n\n\t\tr = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs);\n\t\tbreak;\n\t}\n\tcase KVM_SET_TSC_KHZ: {\n\t\tu32 user_tsc_khz;\n\n\t\tr = -EINVAL;\n\t\tuser_tsc_khz = (u32)arg;\n\n\t\tif (user_tsc_khz >= kvm_max_guest_tsc_khz)\n\t\t\tgoto out;\n\n\t\tif (user_tsc_khz == 0)\n\t\t\tuser_tsc_khz = tsc_khz;\n\n\t\tkvm_set_tsc_khz(vcpu, user_tsc_khz);\n\n\t\tr = 0;\n\t\tgoto out;\n\t}\n\tcase KVM_GET_TSC_KHZ: {\n\t\tr = vcpu->arch.virtual_tsc_khz;\n\t\tgoto out;\n\t}\n\tcase KVM_KVMCLOCK_CTRL: {\n\t\tr = kvm_set_guest_paused(vcpu);\n\t\tgoto out;\n\t}\n\tdefault:\n\t\tr = -EINVAL;\n\t}\nout:\n\tkfree(u.buffer);\n\treturn r;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-6368", "cwe_id": "CWE-20" }, { "id": 842, "func": "print_attr_string(netdissect_options *ndo,\n register const u_char *data, u_int length, u_short attr_code)\n{\n register u_int i;\n\n ND_TCHECK2(data[0],length);\n\n switch(attr_code)\n {\n case TUNNEL_PASS:\n if (length < 3)\n {\n ND_PRINT((ndo, \"%s\", tstr));\n return;\n }\n if (*data && (*data <=0x1F) )\n ND_PRINT((ndo, \"Tag[%u] \", *data));\n else\n ND_PRINT((ndo, \"Tag[Unused] \"));\n data++;\n length--;\n ND_PRINT((ndo, \"Salt %u \", EXTRACT_16BITS(data)));\n data+=2;\n length-=2;\n break;\n case TUNNEL_CLIENT_END:\n case TUNNEL_SERVER_END:\n case TUNNEL_PRIV_GROUP:\n case TUNNEL_ASSIGN_ID:\n case TUNNEL_CLIENT_AUTH:\n case TUNNEL_SERVER_AUTH:\n if (*data <= 0x1F)\n {\n if (length < 1)\n {\n ND_PRINT((ndo, \"%s\", tstr));\n return;\n }\n if (*data)\n ND_PRINT((ndo, \"Tag[%u] \", *data));\n else\n ND_PRINT((ndo, \"Tag[Unused] \"));\n data++;\n length--;\n }\n break;\n case EGRESS_VLAN_NAME:\n ND_PRINT((ndo, \"%s (0x%02x) \",\n tok2str(rfc4675_tagged,\"Unknown tag\",*data),\n *data));\n data++;\n length--;\n break;\n }\n\n for (i=0; *data && i < length ; i++, data++)\n ND_PRINT((ndo, \"%c\", (*data < 32 || *data > 126) ? '.' : *data));\n\n return;\n\n trunc:\n ND_PRINT((ndo, \"%s\", tstr));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13032", "cwe_id": "CWE-125" }, { "id": 842, "func": "print_attr_string(netdissect_options *ndo,\n register const u_char *data, u_int length, u_short attr_code)\n{\n register u_int i;\n\n ND_TCHECK2(data[0],length);\n\n switch(attr_code)\n {\n case TUNNEL_PASS:\n if (length < 3)\n goto trunc;\n if (*data && (*data <=0x1F) )\n ND_PRINT((ndo, \"Tag[%u] \", *data));\n else\n ND_PRINT((ndo, \"Tag[Unused] \"));\n data++;\n length--;\n ND_PRINT((ndo, \"Salt %u \", EXTRACT_16BITS(data)));\n data+=2;\n length-=2;\n break;\n case TUNNEL_CLIENT_END:\n case TUNNEL_SERVER_END:\n case TUNNEL_PRIV_GROUP:\n case TUNNEL_ASSIGN_ID:\n case TUNNEL_CLIENT_AUTH:\n case TUNNEL_SERVER_AUTH:\n if (*data <= 0x1F)\n {\n if (length < 1)\n goto trunc;\n if (*data)\n ND_PRINT((ndo, \"Tag[%u] \", *data));\n else\n ND_PRINT((ndo, \"Tag[Unused] \"));\n data++;\n length--;\n }\n break;\n case EGRESS_VLAN_NAME:\n if (length < 1)\n goto trunc;\n ND_PRINT((ndo, \"%s (0x%02x) \",\n tok2str(rfc4675_tagged,\"Unknown tag\",*data),\n *data));\n data++;\n length--;\n break;\n }\n\n for (i=0; i < length && *data; i++, data++)\n ND_PRINT((ndo, \"%c\", (*data < 32 || *data > 126) ? '.' : *data));\n\n return;\n\n trunc:\n ND_PRINT((ndo, \"%s\", tstr));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13032", "cwe_id": "CWE-125" }, { "id": 419, "func": "static MagickPixelPacket **AcquirePixelThreadSet(const Image *image)\n{\n MagickPixelPacket\n **pixels;\n\n register ssize_t\n i,\n j;\n\n size_t\n number_threads;\n\n number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n pixels=(MagickPixelPacket **) AcquireQuantumMemory(number_threads,\n sizeof(*pixels));\n if (pixels == (MagickPixelPacket **) NULL)\n return((MagickPixelPacket **) NULL);\n (void) memset(pixels,0,number_threads*sizeof(*pixels));\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(image->columns,\n sizeof(**pixels));\n if (pixels[i] == (MagickPixelPacket *) NULL)\n return(DestroyPixelThreadSet(pixels));\n for (j=0; j < (ssize_t) image->columns; j++)\n GetMagickPixelPacket(image,&pixels[i][j]);\n }\n return(pixels);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-13300", "cwe_id": "CWE-787" }, { "id": 419, "func": "static MagickPixelPacket **AcquirePixelThreadSet(const Image *images)\n{\n const Image\n *next;\n\n MagickPixelPacket\n **pixels;\n\n register ssize_t\n i,\n j;\n\n size_t\n columns,\n number_threads;\n\n number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n pixels=(MagickPixelPacket **) AcquireQuantumMemory(number_threads,\n sizeof(*pixels));\n if (pixels == (MagickPixelPacket **) NULL)\n return((MagickPixelPacket **) NULL);\n (void) memset(pixels,0,number_threads*sizeof(*pixels));\n columns=images->columns;\n for (next=images; next != (Image *) NULL; next=next->next)\n columns=MagickMax(next->columns,columns);\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(columns,\n sizeof(**pixels));\n if (pixels[i] == (MagickPixelPacket *) NULL)\n return(DestroyPixelThreadSet(pixels));\n for (j=0; j < (ssize_t) columns; j++)\n GetMagickPixelPacket(images,&pixels[i][j]);\n }\n return(pixels);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-13300", "cwe_id": "CWE-787" }, { "id": 2876, "func": "_Unpickler_ResizeMemoList(UnpicklerObject *self, Py_ssize_t new_size)\n{\n Py_ssize_t i;\n\n assert(new_size > self->memo_size);\n\n PyObject **memo_new = self->memo;\n PyMem_RESIZE(memo_new, PyObject *, new_size);\n if (memo_new == NULL) {\n PyErr_NoMemory();\n return -1;\n }\n self->memo = memo_new;\n for (i = self->memo_size; i < new_size; i++)\n self->memo[i] = NULL;\n self->memo_size = new_size;\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 2876, "func": "_Unpickler_ResizeMemoList(UnpicklerObject *self, size_t new_size)\n{\n size_t i;\n\n assert(new_size > self->memo_size);\n\n PyObject **memo_new = self->memo;\n PyMem_RESIZE(memo_new, PyObject *, new_size);\n if (memo_new == NULL) {\n PyErr_NoMemory();\n return -1;\n }\n self->memo = memo_new;\n for (i = self->memo_size; i < new_size; i++)\n self->memo[i] = NULL;\n self->memo_size = new_size;\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 2492, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n output->type = input2->type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2492, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n output->type = input2->type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2696, "func": "decodeJsonStructure(void *dst, const UA_DataType *type, CtxJson *ctx, \n ParseCtx *parseCtx, UA_Boolean moveToken) {\n (void) moveToken;\n /* Check the recursion limit */\n if(ctx->depth > UA_JSON_ENCODING_MAX_RECURSION)\n return UA_STATUSCODE_BADENCODINGERROR;\n ctx->depth++;\n\n uintptr_t ptr = (uintptr_t)dst;\n status ret = UA_STATUSCODE_GOOD;\n u8 membersSize = type->membersSize;\n const UA_DataType *typelists[2] = { UA_TYPES, &type[-type->typeIndex] };\n \n UA_STACKARRAY(DecodeEntry, entries, membersSize);\n\n for(size_t i = 0; i < membersSize && ret == UA_STATUSCODE_GOOD; ++i) {\n const UA_DataTypeMember *m = &type->members[i];\n const UA_DataType *mt = &typelists[!m->namespaceZero][m->memberTypeIndex];\n\n entries[i].type = mt;\n if(!m->isArray) {\n ptr += m->padding;\n entries[i].fieldName = m->memberName;\n entries[i].fieldPointer = (void*)ptr;\n entries[i].function = decodeJsonJumpTable[mt->typeKind];\n entries[i].found = false;\n ptr += mt->memSize;\n } else {\n ptr += m->padding;\n ptr += sizeof(size_t);\n entries[i].fieldName = m->memberName;\n entries[i].fieldPointer = (void*)ptr;\n entries[i].function = (decodeJsonSignature)Array_decodeJson;\n entries[i].found = false;\n ptr += sizeof(void*);\n }\n }\n \n ret = decodeFields(ctx, parseCtx, entries, membersSize, type);\n\n ctx->depth--;\n return ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-36429", "cwe_id": "CWE-787" }, { "id": 2696, "func": "decodeJsonStructure(void *dst, const UA_DataType *type, CtxJson *ctx, \n ParseCtx *parseCtx, UA_Boolean moveToken) {\n (void) moveToken;\n /* Check the recursion limit */\n if(ctx->depth >= UA_JSON_ENCODING_MAX_RECURSION)\n return UA_STATUSCODE_BADENCODINGERROR;\n ctx->depth++;\n\n uintptr_t ptr = (uintptr_t)dst;\n status ret = UA_STATUSCODE_GOOD;\n u8 membersSize = type->membersSize;\n const UA_DataType *typelists[2] = { UA_TYPES, &type[-type->typeIndex] };\n \n UA_STACKARRAY(DecodeEntry, entries, membersSize);\n\n for(size_t i = 0; i < membersSize && ret == UA_STATUSCODE_GOOD; ++i) {\n const UA_DataTypeMember *m = &type->members[i];\n const UA_DataType *mt = &typelists[!m->namespaceZero][m->memberTypeIndex];\n\n entries[i].type = mt;\n if(!m->isArray) {\n ptr += m->padding;\n entries[i].fieldName = m->memberName;\n entries[i].fieldPointer = (void*)ptr;\n entries[i].function = decodeJsonJumpTable[mt->typeKind];\n entries[i].found = false;\n ptr += mt->memSize;\n } else {\n ptr += m->padding;\n ptr += sizeof(size_t);\n entries[i].fieldName = m->memberName;\n entries[i].fieldPointer = (void*)ptr;\n entries[i].function = (decodeJsonSignature)Array_decodeJson;\n entries[i].found = false;\n ptr += sizeof(void*);\n }\n }\n \n ret = decodeFields(ctx, parseCtx, entries, membersSize, type);\n\n ctx->depth--;\n return ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-36429", "cwe_id": "CWE-787" }, { "id": 2800, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output = GetOutput(context, node, 0);\n TfLiteTensor* hits = GetOutput(context, node, 1);\n const TfLiteTensor* lookup = GetInput(context, node, 0);\n const TfLiteTensor* key = GetInput(context, node, 1);\n const TfLiteTensor* value = GetInput(context, node, 2);\n\n const int num_rows = SizeOfDimension(value, 0);\n const int row_bytes = value->bytes / num_rows;\n void* pointer = nullptr;\n DynamicBuffer buf;\n\n for (int i = 0; i < SizeOfDimension(lookup, 0); i++) {\n int idx = -1;\n pointer = bsearch(&(lookup->data.i32[i]), key->data.i32, num_rows,\n sizeof(int32_t), greater);\n if (pointer != nullptr) {\n idx = (reinterpret_cast(pointer) - (key->data.raw)) /\n sizeof(int32_t);\n }\n\n if (idx >= num_rows || idx < 0) {\n if (output->type == kTfLiteString) {\n buf.AddString(nullptr, 0);\n } else {\n memset(output->data.raw + i * row_bytes, 0, row_bytes);\n }\n hits->data.uint8[i] = 0;\n } else {\n if (output->type == kTfLiteString) {\n buf.AddString(GetString(value, idx));\n } else {\n memcpy(output->data.raw + i * row_bytes,\n value->data.raw + idx * row_bytes, row_bytes);\n }\n hits->data.uint8[i] = 1;\n }\n }\n if (output->type == kTfLiteString) {\n buf.WriteToTensorAsVector(output);\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2800, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TfLiteTensor* hits;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 1, &hits));\n const TfLiteTensor* lookup;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &lookup));\n const TfLiteTensor* key;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &key));\n const TfLiteTensor* value;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 2, &value));\n\n const int num_rows = SizeOfDimension(value, 0);\n const int row_bytes = value->bytes / num_rows;\n void* pointer = nullptr;\n DynamicBuffer buf;\n\n for (int i = 0; i < SizeOfDimension(lookup, 0); i++) {\n int idx = -1;\n pointer = bsearch(&(lookup->data.i32[i]), key->data.i32, num_rows,\n sizeof(int32_t), greater);\n if (pointer != nullptr) {\n idx = (reinterpret_cast(pointer) - (key->data.raw)) /\n sizeof(int32_t);\n }\n\n if (idx >= num_rows || idx < 0) {\n if (output->type == kTfLiteString) {\n buf.AddString(nullptr, 0);\n } else {\n memset(output->data.raw + i * row_bytes, 0, row_bytes);\n }\n hits->data.uint8[i] = 0;\n } else {\n if (output->type == kTfLiteString) {\n buf.AddString(GetString(value, idx));\n } else {\n memcpy(output->data.raw + i * row_bytes,\n value->data.raw + idx * row_bytes, row_bytes);\n }\n hits->data.uint8[i] = 1;\n }\n }\n if (output->type == kTfLiteString) {\n buf.WriteToTensorAsVector(output);\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2324, "func": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20174", "cwe_id": "CWE-125" }, { "id": 2324, "func": "ber_parse_header(STREAM s, int tagval, uint32 *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20174", "cwe_id": "CWE-125" }, { "id": 1180, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(\n\t\t\t\t\tconst void *buf,\n\t\t\t\t\tpj_size_t length,\n\t\t\t\t\tunsigned *sli_cnt,\n\t\t\t\t\tpjmedia_rtcp_fb_sli sli[])\n{\n pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;\n pj_uint8_t *p;\n unsigned cnt, i;\n\n PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);\n PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);\n\n /* PLI uses pt==RTCP_PSFB and FMT==2 */\n if (hdr->pt != RTCP_PSFB || hdr->count != 2)\n\treturn PJ_ENOTFOUND;\n\n cnt = pj_ntohs((pj_uint16_t)hdr->length) - 2;\n if (length < (cnt+3)*4)\n\treturn PJ_ETOOSMALL;\n\n *sli_cnt = PJ_MIN(*sli_cnt, cnt);\n\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < *sli_cnt; ++i) {\n\t/* 'first' takes 13 bit */\n\tsli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);\n\t/* 'number' takes 13 bit */\n\tsli[i].number = ((p[1] & 0x07) << 10) +\n\t\t\t(p[2] << 2) +\n\t\t\t((p[3] & 0xC0) >> 6);\n\t/* 'pict_id' takes 6 bit */\n\tsli[i].pict_id = (p[3] & 0x3F);\n\tp += 4;\n }\n\n return PJ_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 1180, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(\n\t\t\t\t\tconst void *buf,\n\t\t\t\t\tpj_size_t length,\n\t\t\t\t\tunsigned *sli_cnt,\n\t\t\t\t\tpjmedia_rtcp_fb_sli sli[])\n{\n pjmedia_rtcp_fb_common *hdr = (pjmedia_rtcp_fb_common*) buf;\n pj_uint8_t *p;\n unsigned cnt, i;\n\n PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);\n PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_fb_common), PJ_ETOOSMALL);\n\n /* PLI uses pt==RTCP_PSFB and FMT==2 */\n if (hdr->rtcp_common.pt != RTCP_PSFB || hdr->rtcp_common.count != 2)\n\treturn PJ_ENOTFOUND;\n\n cnt = pj_ntohs((pj_uint16_t)hdr->rtcp_common.length) - 2;\n if (length < (cnt+3)*4)\n\treturn PJ_ETOOSMALL;\n\n *sli_cnt = PJ_MIN(*sli_cnt, cnt);\n\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < *sli_cnt; ++i) {\n\t/* 'first' takes 13 bit */\n\tsli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);\n\t/* 'number' takes 13 bit */\n\tsli[i].number = ((p[1] & 0x07) << 10) +\n\t\t\t(p[2] << 2) +\n\t\t\t((p[3] & 0xC0) >> 6);\n\t/* 'pict_id' takes 6 bit */\n\tsli[i].pict_id = (p[3] & 0x3F);\n\tp += 4;\n }\n\n return PJ_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 422, "func": "static void numtostr(js_State *J, const char *fmt, int w, double n)\n{\n\tchar buf[32], *e;\n\tsprintf(buf, fmt, w, n);\n\te = strchr(buf, 'e');\n\tif (e) {\n\t\tint exp = atoi(e+1);\n\t\tsprintf(e, \"e%+d\", exp);\n\t}\n\tjs_pushstring(J, buf);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11411", "cwe_id": "CWE-787" }, { "id": 422, "func": "static void numtostr(js_State *J, const char *fmt, int w, double n)\n{\n\t/* buf needs to fit printf(\"%.20f\", 1e20) */\n\tchar buf[50], *e;\n\tsprintf(buf, fmt, w, n);\n\te = strchr(buf, 'e');\n\tif (e) {\n\t\tint exp = atoi(e+1);\n\t\tsprintf(e, \"e%+d\", exp);\n\t}\n\tjs_pushstring(J, buf);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11411", "cwe_id": "CWE-787" }, { "id": 1374, "func": "compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)\n{\n int\t\tis_global = *eap->arg == 'g' && eap->arg[1] == ':';\n char_u\t*name_start = eap->arg;\n char_u\t*name_end = to_name_end(eap->arg, TRUE);\n int\t\toff;\n char_u\t*func_name;\n char_u\t*lambda_name;\n ufunc_T\t*ufunc;\n int\t\tr = FAIL;\n compiletype_T compile_type;\n isn_T\t*funcref_isn = NULL;\n\n if (eap->forceit)\n {\n\temsg(_(e_cannot_use_bang_with_nested_def));\n\treturn NULL;\n }\n\n if (*name_start == '/')\n {\n\tname_end = skip_regexp(name_start + 1, '/', TRUE);\n\tif (*name_end == '/')\n\t ++name_end;\n\tset_nextcmd(eap, name_end);\n }\n if (name_end == name_start || *skipwhite(name_end) != '(')\n {\n\tif (!ends_excmd2(name_start, name_end))\n\t{\n\t if (*skipwhite(name_end) == '.')\n\t\tsemsg(_(e_cannot_define_dict_func_in_vim9_script_str),\n\t\t\t\t\t\t\t\t eap->cmd);\n\t else\n\t\tsemsg(_(e_invalid_command_str), eap->cmd);\n\t return NULL;\n\t}\n\n\t// \"def\" or \"def Name\": list functions\n\tif (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)\n\t return NULL;\n\treturn eap->nextcmd == NULL ? (char_u *)\"\" : eap->nextcmd;\n }\n\n // Only g:Func() can use a namespace.\n if (name_start[1] == ':' && !is_global)\n {\n\tsemsg(_(e_namespace_not_supported_str), name_start);\n\treturn NULL;\n }\n if (cctx->ctx_skip != SKIP_YES\n\t && check_defined(name_start, name_end - name_start, cctx,\n\t\t\t\t\t\t\t NULL, FALSE) == FAIL)\n\treturn NULL;\n if (!ASCII_ISUPPER(is_global ? name_start[2] : name_start[0]))\n {\n\tsemsg(_(e_function_name_must_start_with_capital_str), name_start);\n\treturn NULL;\n }\n\n eap->arg = name_end;\n fill_exarg_from_cctx(eap, cctx);\n\n eap->forceit = FALSE;\n // We use the special 99 name, but it's not really a lambda.\n lambda_name = vim_strsave(get_lambda_name());\n if (lambda_name == NULL)\n\treturn NULL;\n\n // This may free the current line, make a copy of the name.\n off = is_global ? 2 : 0;\n func_name = vim_strnsave(name_start + off, name_end - name_start - off);\n if (func_name == NULL)\n {\n\tr = FAIL;\n\tgoto theend;\n }\n\n ufunc = define_function(eap, lambda_name, lines_to_free);\n if (ufunc == NULL)\n {\n\tr = eap->skip ? OK : FAIL;\n\tgoto theend;\n }\n if (eap->nextcmd != NULL)\n {\n\tsemsg(_(e_text_found_after_str_str),\n\t eap->cmdidx == CMD_def ? \"enddef\" : \"endfunction\", eap->nextcmd);\n\tr = FAIL;\n\tfunc_ptr_unref(ufunc);\n\tgoto theend;\n }\n\n // copy over the block scope IDs before compiling\n if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)\n {\n\tint block_depth = cctx->ctx_ufunc->uf_block_depth;\n\n\tufunc->uf_block_ids = ALLOC_MULT(int, block_depth);\n\tif (ufunc->uf_block_ids != NULL)\n\t{\n\t mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,\n\t\t\t\t\t\t sizeof(int) * block_depth);\n\t ufunc->uf_block_depth = block_depth;\n\t}\n }\n\n // Define the funcref before compiling, so that it is found by any\n // recursive call.\n if (is_global)\n {\n\tr = generate_NEWFUNC(cctx, lambda_name, func_name);\n\tfunc_name = NULL;\n\tlambda_name = NULL;\n }\n else\n {\n\t// Define a local variable for the function reference.\n\tlvar_T\t*lvar = reserve_local(cctx, func_name, name_end - name_start,\n\t\t\t\t\t\t TRUE, ufunc->uf_func_type);\n\n\tif (lvar == NULL)\n\t goto theend;\n\tif (generate_FUNCREF(cctx, ufunc, &funcref_isn) == FAIL)\n\t goto theend;\n\tr = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);\n }\n\n compile_type = get_compile_type(ufunc);\n#ifdef FEAT_PROFILE\n // If the outer function is profiled, also compile the nested function for\n // profiling.\n if (cctx->ctx_compile_type == CT_PROFILE)\n\tcompile_type = CT_PROFILE;\n#endif\n if (func_needs_compiling(ufunc, compile_type)\n\t && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)\n {\n\tfunc_ptr_unref(ufunc);\n\tgoto theend;\n }\n\n#ifdef FEAT_PROFILE\n // When the outer function is compiled for profiling, the nested function\n // may be called without profiling. Compile it here in the right context.\n if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))\n\tcompile_def_function(ufunc, FALSE, CT_NONE, cctx);\n#endif\n\n // If a FUNCREF instruction was generated, set the index after compiling.\n if (funcref_isn != NULL && ufunc->uf_def_status == UF_COMPILED)\n\tfuncref_isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx;\n\ntheend:\n vim_free(lambda_name);\n vim_free(func_name);\n return r == FAIL ? NULL : (char_u *)\"\";\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2862", "cwe_id": "CWE-416" }, { "id": 1374, "func": "compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)\n{\n int\t\tis_global = *eap->arg == 'g' && eap->arg[1] == ':';\n char_u\t*name_start = eap->arg;\n char_u\t*name_end = to_name_end(eap->arg, TRUE);\n int\t\toff;\n char_u\t*func_name;\n char_u\t*lambda_name;\n ufunc_T\t*ufunc;\n int\t\tr = FAIL;\n compiletype_T compile_type;\n isn_T\t*funcref_isn = NULL;\n lvar_T\t*lvar = NULL;\n\n if (eap->forceit)\n {\n\temsg(_(e_cannot_use_bang_with_nested_def));\n\treturn NULL;\n }\n\n if (*name_start == '/')\n {\n\tname_end = skip_regexp(name_start + 1, '/', TRUE);\n\tif (*name_end == '/')\n\t ++name_end;\n\tset_nextcmd(eap, name_end);\n }\n if (name_end == name_start || *skipwhite(name_end) != '(')\n {\n\tif (!ends_excmd2(name_start, name_end))\n\t{\n\t if (*skipwhite(name_end) == '.')\n\t\tsemsg(_(e_cannot_define_dict_func_in_vim9_script_str),\n\t\t\t\t\t\t\t\t eap->cmd);\n\t else\n\t\tsemsg(_(e_invalid_command_str), eap->cmd);\n\t return NULL;\n\t}\n\n\t// \"def\" or \"def Name\": list functions\n\tif (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)\n\t return NULL;\n\treturn eap->nextcmd == NULL ? (char_u *)\"\" : eap->nextcmd;\n }\n\n // Only g:Func() can use a namespace.\n if (name_start[1] == ':' && !is_global)\n {\n\tsemsg(_(e_namespace_not_supported_str), name_start);\n\treturn NULL;\n }\n if (cctx->ctx_skip != SKIP_YES\n\t && check_defined(name_start, name_end - name_start, cctx,\n\t\t\t\t\t\t\t NULL, FALSE) == FAIL)\n\treturn NULL;\n if (!ASCII_ISUPPER(is_global ? name_start[2] : name_start[0]))\n {\n\tsemsg(_(e_function_name_must_start_with_capital_str), name_start);\n\treturn NULL;\n }\n\n eap->arg = name_end;\n fill_exarg_from_cctx(eap, cctx);\n\n eap->forceit = FALSE;\n // We use the special 99 name, but it's not really a lambda.\n lambda_name = vim_strsave(get_lambda_name());\n if (lambda_name == NULL)\n\treturn NULL;\n\n // This may free the current line, make a copy of the name.\n off = is_global ? 2 : 0;\n func_name = vim_strnsave(name_start + off, name_end - name_start - off);\n if (func_name == NULL)\n {\n\tr = FAIL;\n\tgoto theend;\n }\n\n ufunc = define_function(eap, lambda_name, lines_to_free);\n if (ufunc == NULL)\n {\n\tr = eap->skip ? OK : FAIL;\n\tgoto theend;\n }\n if (eap->nextcmd != NULL)\n {\n\tsemsg(_(e_text_found_after_str_str),\n\t eap->cmdidx == CMD_def ? \"enddef\" : \"endfunction\", eap->nextcmd);\n\tr = FAIL;\n\tfunc_ptr_unref(ufunc);\n\tgoto theend;\n }\n\n // copy over the block scope IDs before compiling\n if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)\n {\n\tint block_depth = cctx->ctx_ufunc->uf_block_depth;\n\n\tufunc->uf_block_ids = ALLOC_MULT(int, block_depth);\n\tif (ufunc->uf_block_ids != NULL)\n\t{\n\t mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,\n\t\t\t\t\t\t sizeof(int) * block_depth);\n\t ufunc->uf_block_depth = block_depth;\n\t}\n }\n\n // Define the funcref before compiling, so that it is found by any\n // recursive call.\n if (is_global)\n {\n\tr = generate_NEWFUNC(cctx, lambda_name, func_name);\n\tfunc_name = NULL;\n\tlambda_name = NULL;\n }\n else\n {\n\t// Define a local variable for the function reference.\n\tlvar = reserve_local(cctx, func_name, name_end - name_start,\n\t\t\t\t\t\t TRUE, ufunc->uf_func_type);\n\tif (lvar == NULL)\n\t goto theend;\n\tif (generate_FUNCREF(cctx, ufunc, &funcref_isn) == FAIL)\n\t goto theend;\n\tr = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);\n }\n\n compile_type = get_compile_type(ufunc);\n#ifdef FEAT_PROFILE\n // If the outer function is profiled, also compile the nested function for\n // profiling.\n if (cctx->ctx_compile_type == CT_PROFILE)\n\tcompile_type = CT_PROFILE;\n#endif\n if (func_needs_compiling(ufunc, compile_type)\n\t && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)\n {\n\tfunc_ptr_unref(ufunc);\n\tif (lvar != NULL)\n\t // Now the local variable can't be used.\n\t *lvar->lv_name = '/'; // impossible value\n\tgoto theend;\n }\n\n#ifdef FEAT_PROFILE\n // When the outer function is compiled for profiling, the nested function\n // may be called without profiling. Compile it here in the right context.\n if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))\n\tcompile_def_function(ufunc, FALSE, CT_NONE, cctx);\n#endif\n\n // If a FUNCREF instruction was generated, set the index after compiling.\n if (funcref_isn != NULL && ufunc->uf_def_status == UF_COMPILED)\n\tfuncref_isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx;\n\ntheend:\n vim_free(lambda_name);\n vim_free(func_name);\n return r == FAIL ? NULL : (char_u *)\"\";\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2862", "cwe_id": "CWE-416" }, { "id": 80, "func": "atmarp_print(netdissect_options *ndo,\n\t const u_char *bp, u_int length, u_int caplen)\n{\n\tconst struct atmarp_pkthdr *ap;\n\tu_short pro, hrd, op;\n\n\tap = (const struct atmarp_pkthdr *)bp;\n\tND_TCHECK(*ap);\n\n\thrd = ATMHRD(ap);\n\tpro = ATMPRO(ap);\n\top = ATMOP(ap);\n\n\tif (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\tND_DEFAULTPRINT((const u_char *)ap, length);\n\t\treturn;\n\t}\n\n if (!ndo->ndo_eflag) {\n ND_PRINT((ndo, \"ARP, \"));\n }\n\n\tif ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||\n\t ATMSPROTO_LEN(ap) != 4 ||\n ATMTPROTO_LEN(ap) != 4 ||\n ndo->ndo_vflag) {\n ND_PRINT((ndo, \"%s, %s (len %u/%u)\",\n tok2str(arphrd_values, \"Unknown Hardware (%u)\", hrd),\n tok2str(ethertype_values, \"Unknown Protocol (0x%04x)\", pro),\n ATMSPROTO_LEN(ap),\n ATMTPROTO_LEN(ap)));\n\n /* don't know know about the address formats */\n if (!ndo->ndo_vflag) {\n goto out;\n }\n\t}\n\n /* print operation */\n ND_PRINT((ndo, \"%s%s \",\n ndo->ndo_vflag ? \", \" : \"\",\n tok2str(arpop_values, \"Unknown (%u)\", op)));\n\n\tswitch (op) {\n\n\tcase ARPOP_REQUEST:\n\t\tND_PRINT((ndo, \"who-has %s\", ipaddr_string(ndo, ATMTPA(ap))));\n\t\tif (ATMTHRD_LEN(ap) != 0) {\n\t\t\tND_PRINT((ndo, \" (\"));\n\t\t\tatmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),\n\t\t\t ATMTSA(ap), ATMTSLN(ap));\n\t\t\tND_PRINT((ndo, \")\"));\n\t\t}\n\t\tND_PRINT((ndo, \"tell %s\", ipaddr_string(ndo, ATMSPA(ap))));\n\t\tbreak;\n\n\tcase ARPOP_REPLY:\n\t\tND_PRINT((ndo, \"%s is-at \", ipaddr_string(ndo, ATMSPA(ap))));\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n ATMSSLN(ap));\n\t\tbreak;\n\n\tcase ARPOP_INVREQUEST:\n\t\tND_PRINT((ndo, \"who-is \"));\n\t\tatmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),\n\t\t ATMTSLN(ap));\n\t\tND_PRINT((ndo, \" tell \"));\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n\t\t ATMSSLN(ap));\n\t\tbreak;\n\n\tcase ARPOP_INVREPLY:\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n\t\t ATMSSLN(ap));\n\t\tND_PRINT((ndo, \"at %s\", ipaddr_string(ndo, ATMSPA(ap))));\n\t\tbreak;\n\n\tcase ARPOP_NAK:\n\t\tND_PRINT((ndo, \"for %s\", ipaddr_string(ndo, ATMSPA(ap))));\n\t\tbreak;\n\n\tdefault:\n\t\tND_DEFAULTPRINT((const u_char *)ap, caplen);\n\t\treturn;\n\t}\n\n out:\n ND_PRINT((ndo, \", length %u\", length));\n return;\n\ntrunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13013", "cwe_id": "CWE-125" }, { "id": 80, "func": "atmarp_print(netdissect_options *ndo,\n\t const u_char *bp, u_int length, u_int caplen)\n{\n\tconst struct atmarp_pkthdr *ap;\n\tu_short pro, hrd, op;\n\n\tap = (const struct atmarp_pkthdr *)bp;\n\tND_TCHECK(*ap);\n\n\thrd = ATMHRD(ap);\n\tpro = ATMPRO(ap);\n\top = ATMOP(ap);\n\n\tif (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\tND_DEFAULTPRINT((const u_char *)ap, length);\n\t\treturn;\n\t}\n\n if (!ndo->ndo_eflag) {\n ND_PRINT((ndo, \"ARP, \"));\n }\n\n\tif ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||\n\t ATMSPROTO_LEN(ap) != 4 ||\n ATMTPROTO_LEN(ap) != 4 ||\n ndo->ndo_vflag) {\n ND_PRINT((ndo, \"%s, %s (len %u/%u)\",\n tok2str(arphrd_values, \"Unknown Hardware (%u)\", hrd),\n tok2str(ethertype_values, \"Unknown Protocol (0x%04x)\", pro),\n ATMSPROTO_LEN(ap),\n ATMTPROTO_LEN(ap)));\n\n /* don't know know about the address formats */\n if (!ndo->ndo_vflag) {\n goto out;\n }\n\t}\n\n /* print operation */\n ND_PRINT((ndo, \"%s%s \",\n ndo->ndo_vflag ? \", \" : \"\",\n tok2str(arpop_values, \"Unknown (%u)\", op)));\n\n\tswitch (op) {\n\n\tcase ARPOP_REQUEST:\n\t\tND_PRINT((ndo, \"who-has \"));\n\t\tatmarp_tpaddr_print(ndo, ap, pro);\n\t\tif (ATMTHRD_LEN(ap) != 0) {\n\t\t\tND_PRINT((ndo, \" (\"));\n\t\t\tatmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),\n\t\t\t ATMTSA(ap), ATMTSLN(ap));\n\t\t\tND_PRINT((ndo, \")\"));\n\t\t}\n\t\tND_PRINT((ndo, \" tell \"));\n\t\tatmarp_spaddr_print(ndo, ap, pro);\n\t\tbreak;\n\n\tcase ARPOP_REPLY:\n\t\tatmarp_spaddr_print(ndo, ap, pro);\n\t\tND_PRINT((ndo, \" is-at \"));\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n ATMSSLN(ap));\n\t\tbreak;\n\n\tcase ARPOP_INVREQUEST:\n\t\tND_PRINT((ndo, \"who-is \"));\n\t\tatmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),\n\t\t ATMTSLN(ap));\n\t\tND_PRINT((ndo, \" tell \"));\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n\t\t ATMSSLN(ap));\n\t\tbreak;\n\n\tcase ARPOP_INVREPLY:\n\t\tatmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),\n\t\t ATMSSLN(ap));\n\t\tND_PRINT((ndo, \"at \"));\n\t\tatmarp_spaddr_print(ndo, ap, pro);\n\t\tbreak;\n\n\tcase ARPOP_NAK:\n\t\tND_PRINT((ndo, \"for \"));\n\t\tatmarp_spaddr_print(ndo, ap, pro);\n\t\tbreak;\n\n\tdefault:\n\t\tND_DEFAULTPRINT((const u_char *)ap, caplen);\n\t\treturn;\n\t}\n\n out:\n ND_PRINT((ndo, \", length %u\", length));\n return;\n\ntrunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13013", "cwe_id": "CWE-125" }, { "id": 1802, "func": "ast_for_for_stmt(struct compiling *c, const node *n0, bool is_async)\n{\n const node * const n = is_async ? CHILD(n0, 1) : n0;\n asdl_seq *_target, *seq = NULL, *suite_seq;\n expr_ty expression;\n expr_ty target, first;\n const node *node_target;\n int end_lineno, end_col_offset;\n /* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */\n REQ(n, for_stmt);\n\n if (NCH(n) == 9) {\n seq = ast_for_suite(c, CHILD(n, 8));\n if (!seq)\n return NULL;\n }\n\n node_target = CHILD(n, 1);\n _target = ast_for_exprlist(c, node_target, Store);\n if (!_target)\n return NULL;\n /* Check the # of children rather than the length of _target, since\n for x, in ... has 1 element in _target, but still requires a Tuple. */\n first = (expr_ty)asdl_seq_GET(_target, 0);\n if (NCH(node_target) == 1)\n target = first;\n else\n target = Tuple(_target, Store, first->lineno, first->col_offset,\n node_target->n_end_lineno, node_target->n_end_col_offset,\n c->c_arena);\n\n expression = ast_for_testlist(c, CHILD(n, 3));\n if (!expression)\n return NULL;\n suite_seq = ast_for_suite(c, CHILD(n, 5));\n if (!suite_seq)\n return NULL;\n\n if (seq != NULL) {\n get_last_end_pos(seq, &end_lineno, &end_col_offset);\n } else {\n get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);\n }\n if (is_async)\n return AsyncFor(target, expression, suite_seq, seq,\n LINENO(n0), n0->n_col_offset,\n end_lineno, end_col_offset, c->c_arena);\n else\n return For(target, expression, suite_seq, seq,\n LINENO(n), n->n_col_offset,\n end_lineno, end_col_offset, c->c_arena);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1802, "func": "ast_for_for_stmt(struct compiling *c, const node *n0, bool is_async)\n{\n const node * const n = is_async ? CHILD(n0, 1) : n0;\n asdl_seq *_target, *seq = NULL, *suite_seq;\n expr_ty expression;\n expr_ty target, first;\n const node *node_target;\n int end_lineno, end_col_offset;\n int has_type_comment;\n string type_comment;\n /* for_stmt: 'for' exprlist 'in' testlist ':' [TYPE_COMMENT] suite ['else' ':' suite] */\n REQ(n, for_stmt);\n\n has_type_comment = TYPE(CHILD(n, 5)) == TYPE_COMMENT;\n\n if (NCH(n) == 9 + has_type_comment) {\n seq = ast_for_suite(c, CHILD(n, 8 + has_type_comment));\n if (!seq)\n return NULL;\n }\n\n node_target = CHILD(n, 1);\n _target = ast_for_exprlist(c, node_target, Store);\n if (!_target)\n return NULL;\n /* Check the # of children rather than the length of _target, since\n for x, in ... has 1 element in _target, but still requires a Tuple. */\n first = (expr_ty)asdl_seq_GET(_target, 0);\n if (NCH(node_target) == 1)\n target = first;\n else\n target = Tuple(_target, Store, first->lineno, first->col_offset,\n node_target->n_end_lineno, node_target->n_end_col_offset,\n c->c_arena);\n\n expression = ast_for_testlist(c, CHILD(n, 3));\n if (!expression)\n return NULL;\n suite_seq = ast_for_suite(c, CHILD(n, 5 + has_type_comment));\n if (!suite_seq)\n return NULL;\n\n if (seq != NULL) {\n get_last_end_pos(seq, &end_lineno, &end_col_offset);\n } else {\n get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);\n }\n\n if (has_type_comment) {\n type_comment = NEW_TYPE_COMMENT(CHILD(n, 5));\n if (!type_comment)\n return NULL;\n }\n else\n type_comment = NULL;\n\n if (is_async)\n return AsyncFor(target, expression, suite_seq, seq, type_comment,\n LINENO(n0), n0->n_col_offset,\n end_lineno, end_col_offset, c->c_arena);\n else\n return For(target, expression, suite_seq, seq, type_comment,\n LINENO(n), n->n_col_offset,\n end_lineno, end_col_offset, c->c_arena);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1456, "func": "void luaD_call (lua_State *L, StkId func, int nresults) {\n lua_CFunction f;\n retry:\n switch (ttypetag(s2v(func))) {\n case LUA_VCCL: /* C closure */\n f = clCvalue(s2v(func))->f;\n goto Cfunc;\n case LUA_VLCF: /* light C function */\n f = fvalue(s2v(func));\n Cfunc: {\n int n; /* number of returns */\n CallInfo *ci = next_ci(L);\n checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */\n ci->nresults = nresults;\n ci->callstatus = CIST_C;\n ci->top = L->top + LUA_MINSTACK;\n ci->func = func;\n L->ci = ci;\n lua_assert(ci->top <= L->stack_last);\n if (L->hookmask & LUA_MASKCALL) {\n int narg = cast_int(L->top - func) - 1;\n luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);\n }\n lua_unlock(L);\n n = (*f)(L); /* do the actual call */\n lua_lock(L);\n api_checknelems(L, n);\n luaD_poscall(L, ci, n);\n break;\n }\n case LUA_VLCL: { /* Lua function */\n CallInfo *ci = next_ci(L);\n Proto *p = clLvalue(s2v(func))->p;\n int narg = cast_int(L->top - func) - 1; /* number of real arguments */\n int nfixparams = p->numparams;\n int fsize = p->maxstacksize; /* frame size */\n checkstackp(L, fsize, func);\n ci->nresults = nresults;\n ci->u.l.savedpc = p->code; /* starting point */\n ci->callstatus = 0;\n ci->top = func + 1 + fsize;\n ci->func = func;\n L->ci = ci;\n for (; narg < nfixparams; narg++)\n setnilvalue(s2v(L->top++)); /* complete missing arguments */\n lua_assert(ci->top <= L->stack_last);\n luaV_execute(L, ci); /* run the function */\n break;\n }\n default: { /* not a function */\n checkstackp(L, 1, func); /* space for metamethod */\n luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */\n goto retry; /* try again with metamethod */\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15888", "cwe_id": "CWE-125" }, { "id": 1456, "func": "void luaD_call (lua_State *L, StkId func, int nresults) {\n lua_CFunction f;\n retry:\n switch (ttypetag(s2v(func))) {\n case LUA_VCCL: /* C closure */\n f = clCvalue(s2v(func))->f;\n goto Cfunc;\n case LUA_VLCF: /* light C function */\n f = fvalue(s2v(func));\n Cfunc: {\n int n; /* number of returns */\n CallInfo *ci;\n checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */\n L->ci = ci = next_ci(L);\n ci->nresults = nresults;\n ci->callstatus = CIST_C;\n ci->top = L->top + LUA_MINSTACK;\n ci->func = func;\n lua_assert(ci->top <= L->stack_last);\n if (L->hookmask & LUA_MASKCALL) {\n int narg = cast_int(L->top - func) - 1;\n luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);\n }\n lua_unlock(L);\n n = (*f)(L); /* do the actual call */\n lua_lock(L);\n api_checknelems(L, n);\n luaD_poscall(L, ci, n);\n break;\n }\n case LUA_VLCL: { /* Lua function */\n CallInfo *ci;\n Proto *p = clLvalue(s2v(func))->p;\n int narg = cast_int(L->top - func) - 1; /* number of real arguments */\n int nfixparams = p->numparams;\n int fsize = p->maxstacksize; /* frame size */\n checkstackGCp(L, fsize, func);\n L->ci = ci = next_ci(L);\n ci->nresults = nresults;\n ci->u.l.savedpc = p->code; /* starting point */\n ci->callstatus = 0;\n ci->top = func + 1 + fsize;\n ci->func = func;\n L->ci = ci;\n for (; narg < nfixparams; narg++)\n setnilvalue(s2v(L->top++)); /* complete missing arguments */\n lua_assert(ci->top <= L->stack_last);\n luaV_execute(L, ci); /* run the function */\n break;\n }\n default: { /* not a function */\n checkstackGCp(L, 1, func); /* space for metamethod */\n luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */\n goto retry; /* try again with metamethod */\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15888", "cwe_id": "CWE-125" }, { "id": 817, "func": "mptctl_replace_fw (unsigned long arg)\n{\n\tstruct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg;\n\tstruct mpt_ioctl_replace_fw\t karg;\n\tMPT_ADAPTER\t\t *ioc;\n\tint\t\t\t iocnum;\n\tint\t\t\t newFwSize;\n\n\tif (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_replace_fw - \"\n\t\t\t\"Unable to read in mpt_ioctl_replace_fw struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\tif (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||\n\t (ioc == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"%s::mptctl_replace_fw() @%d - ioc%d not found!\\n\",\n\t\t\t\t__FILE__, __LINE__, iocnum);\n\t\treturn -ENODEV;\n\t}\n\n\tdctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT \"mptctl_replace_fw called.\\n\",\n\t ioc->name));\n\t/* If caching FW, Free the old FW image\n\t */\n\tif (ioc->cached_fw == NULL)\n\t\treturn 0;\n\n\tmpt_free_fw_memory(ioc);\n\n\t/* Allocate memory for the new FW image\n\t */\n\tnewFwSize = ALIGN(karg.newImageSize, 4);\n\n\tmpt_alloc_fw_memory(ioc, newFwSize);\n\tif (ioc->cached_fw == NULL)\n\t\treturn -ENOMEM;\n\n\t/* Copy the data from user memory to kernel space\n\t */\n\tif (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) {\n\t\tprintk(MYIOC_s_ERR_FMT \"%s@%d::mptctl_replace_fw - \"\n\t\t\t\t\"Unable to read in mpt_ioctl_replace_fw image \"\n\t\t\t\t\"@ %p\\n\", ioc->name, __FILE__, __LINE__, uarg);\n\t\tmpt_free_fw_memory(ioc);\n\t\treturn -EFAULT;\n\t}\n\n\t/* Update IOCFactsReply\n\t */\n\tioc->facts.FWImageSize = newFwSize;\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 817, "func": "mptctl_replace_fw (MPT_ADAPTER *ioc, unsigned long arg)\n{\n\tstruct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg;\n\tstruct mpt_ioctl_replace_fw\t karg;\n\tint\t\t\t newFwSize;\n\n\tif (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_replace_fw - \"\n\t\t\t\"Unable to read in mpt_ioctl_replace_fw struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\tdctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT \"mptctl_replace_fw called.\\n\",\n\t ioc->name));\n\t/* If caching FW, Free the old FW image\n\t */\n\tif (ioc->cached_fw == NULL)\n\t\treturn 0;\n\n\tmpt_free_fw_memory(ioc);\n\n\t/* Allocate memory for the new FW image\n\t */\n\tnewFwSize = ALIGN(karg.newImageSize, 4);\n\n\tmpt_alloc_fw_memory(ioc, newFwSize);\n\tif (ioc->cached_fw == NULL)\n\t\treturn -ENOMEM;\n\n\t/* Copy the data from user memory to kernel space\n\t */\n\tif (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) {\n\t\tprintk(MYIOC_s_ERR_FMT \"%s@%d::mptctl_replace_fw - \"\n\t\t\t\t\"Unable to read in mpt_ioctl_replace_fw image \"\n\t\t\t\t\"@ %p\\n\", ioc->name, __FILE__, __LINE__, uarg);\n\t\tmpt_free_fw_memory(ioc);\n\t\treturn -EFAULT;\n\t}\n\n\t/* Update IOCFactsReply\n\t */\n\tioc->facts.FWImageSize = newFwSize;\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 1951, "func": "void enc28j60EventHandler(NetInterface *interface)\n{\n error_t error;\n uint16_t status;\n uint16_t value;\n\n //Read interrupt status register\n status = enc28j60ReadReg(interface, ENC28J60_REG_EIR);\n\n //Check whether the link state has changed\n if((status & EIR_LINKIF) != 0)\n {\n //Clear PHY interrupts flags\n enc28j60ReadPhyReg(interface, ENC28J60_PHY_REG_PHIR);\n //Clear interrupt flag\n enc28j60ClearBit(interface, ENC28J60_REG_EIR, EIR_LINKIF);\n //Read PHY status register\n value = enc28j60ReadPhyReg(interface, ENC28J60_PHY_REG_PHSTAT2);\n\n //Check link state\n if((value & PHSTAT2_LSTAT) != 0)\n {\n //Link speed\n interface->linkSpeed = NIC_LINK_SPEED_10MBPS;\n\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n //Full-duplex mode\n interface->duplexMode = NIC_FULL_DUPLEX_MODE;\n#else\n //Half-duplex mode\n interface->duplexMode = NIC_HALF_DUPLEX_MODE;\n#endif\n //Link is up\n interface->linkState = TRUE;\n }\n else\n {\n //Link is down\n interface->linkState = FALSE;\n }\n\n //Process link state change event\n nicNotifyLinkChange(interface);\n }\n\n //Check whether a packet has been received?\n if((status & EIR_PKTIF) != 0)\n {\n //Clear interrupt flag\n enc28j60ClearBit(interface, ENC28J60_REG_EIR, EIR_PKTIF);\n\n //Process all pending packets\n do\n {\n //Read incoming packet\n error = enc28j60ReceivePacket(interface);\n\n //No more data in the receive buffer?\n } while(error != ERROR_BUFFER_EMPTY);\n }\n\n //Re-enable LINKIE and PKTIE interrupts\n enc28j60SetBit(interface, ENC28J60_REG_EIE, EIE_LINKIE | EIE_PKTIE);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1951, "func": "void enc28j60EventHandler(NetInterface *interface)\n{\n error_t error;\n uint16_t status;\n uint16_t value;\n\n //Read interrupt status register\n status = enc28j60ReadReg(interface, ENC28J60_EIR);\n\n //Check whether the link state has changed\n if((status & ENC28J60_EIR_LINKIF) != 0)\n {\n //Clear PHY interrupts flags\n enc28j60ReadPhyReg(interface, ENC28J60_PHIR);\n //Clear interrupt flag\n enc28j60ClearBit(interface, ENC28J60_EIR, ENC28J60_EIR_LINKIF);\n //Read PHY status register\n value = enc28j60ReadPhyReg(interface, ENC28J60_PHSTAT2);\n\n //Check link state\n if((value & ENC28J60_PHSTAT2_LSTAT) != 0)\n {\n //Link speed\n interface->linkSpeed = NIC_LINK_SPEED_10MBPS;\n\n#if (ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED)\n //Full-duplex mode\n interface->duplexMode = NIC_FULL_DUPLEX_MODE;\n#else\n //Half-duplex mode\n interface->duplexMode = NIC_HALF_DUPLEX_MODE;\n#endif\n //Link is up\n interface->linkState = TRUE;\n }\n else\n {\n //Link is down\n interface->linkState = FALSE;\n }\n\n //Process link state change event\n nicNotifyLinkChange(interface);\n }\n\n //Check whether a packet has been received?\n if(enc28j60ReadReg(interface, ENC28J60_EPKTCNT) != 0)\n {\n //Clear interrupt flag\n enc28j60ClearBit(interface, ENC28J60_EIR, ENC28J60_EIR_PKTIF);\n\n //Process all pending packets\n do\n {\n //Read incoming packet\n error = enc28j60ReceivePacket(interface);\n\n //No more data in the receive buffer?\n } while(error != ERROR_BUFFER_EMPTY);\n }\n\n //Re-enable LINKIE and PKTIE interrupts\n enc28j60SetBit(interface, ENC28J60_EIE, ENC28J60_EIE_LINKIE |\n ENC28J60_EIE_PKTIE);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2857, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n output->type = input->type;\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims);\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2857, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n output->type = input->type;\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims);\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1575, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n void * pvReturn = NULL;\r\n static uint8_t * pucAlignedHeap = NULL;\r\n\r\n /* Ensure that blocks are always aligned to the required number of bytes. */\r\n #if ( portBYTE_ALIGNMENT != 1 )\r\n {\r\n if( xWantedSize & portBYTE_ALIGNMENT_MASK )\r\n {\r\n /* Byte alignment required. */\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n }\r\n }\r\n #endif\r\n\r\n vTaskSuspendAll();\r\n {\r\n if( pucAlignedHeap == NULL )\r\n {\r\n /* Ensure the heap starts on a correctly aligned boundary. */\r\n pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r\n }\r\n\r\n /* Check there is enough room left for the allocation. */\r\n if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&\r\n ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */\r\n {\r\n /* Return the next free byte then increment the index past this\r\n * block. */\r\n pvReturn = pucAlignedHeap + xNextFreeByte;\r\n xNextFreeByte += xWantedSize;\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n }\r\n #endif\r\n\r\n return pvReturn;\r\n}\r", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 1575, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n void * pvReturn = NULL;\r\n static uint8_t * pucAlignedHeap = NULL;\r\n\r\n /* Ensure that blocks are always aligned. */\r\n #if ( portBYTE_ALIGNMENT != 1 )\r\n {\r\n if( xWantedSize & portBYTE_ALIGNMENT_MASK )\r\n {\r\n /* Byte alignment required. Check for overflow. */\r\n if ( (xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) )) > xWantedSize )\r\n {\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n } \r\n else \r\n {\r\n xWantedSize = 0;\r\n }\r\n }\r\n }\r\n #endif\r\n\r\n vTaskSuspendAll();\r\n {\r\n if( pucAlignedHeap == NULL )\r\n {\r\n /* Ensure the heap starts on a correctly aligned boundary. */\r\n pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r\n }\r\n\r\n /* Check there is enough room left for the allocation and. */\r\n if( ( xWantedSize > 0 ) && /* valid size */\r\n ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&\r\n ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */\r\n {\r\n /* Return the next free byte then increment the index past this\r\n * block. */\r\n pvReturn = pucAlignedHeap + xNextFreeByte;\r\n xNextFreeByte += xWantedSize;\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n }\r\n #endif\r\n\r\n return pvReturn;\r\n}\r", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 621, "func": "char* _single_string_alloc_and_copy( LPCWSTR in )\n{\n char *chr;\n int len = 0;\n\n if ( !in )\n {\n return in;\n }\n\n while ( in[ len ] != 0 )\n {\n len ++;\n }\n\n chr = malloc( len + 1 );\n\n len = 0;\n while ( in[ len ] != 0 )\n {\n chr[ len ] = 0xFF & in[ len ];\n len ++;\n }\n chr[ len ++ ] = '\\0';\n\n return chr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-7485", "cwe_id": "CWE-119" }, { "id": 621, "func": "char* _single_string_alloc_and_copy( LPCWSTR in )\n{\n char *chr;\n int len = 0;\n\n if ( !in )\n {\n return NULL;\n }\n\n while ( in[ len ] != 0 )\n {\n len ++;\n }\n\n chr = malloc( len + 1 );\n\n len = 0;\n while ( in[ len ] != 0 )\n {\n chr[ len ] = 0xFF & in[ len ];\n len ++;\n }\n chr[ len ++ ] = '\\0';\n\n return chr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-7485", "cwe_id": "CWE-119" }, { "id": 524, "func": "static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len)\n{\n\t/* OpenSc Operation values for each command operation-type */\n\tconst int df_idx[8] = {\t /* byte 1 = OpenSC type of AC Bit0, byte 2 = OpenSC type of AC Bit1 ...*/\n\t\tSC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\tSC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};\n\tconst int ef_idx[8] = {\n\t\tSC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\t-1, SC_AC_OP_ERASE, -1};\n\tconst int efi_idx[8] = { /* internal EF used for RSA keys */\n\t\tSC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\t-1, SC_AC_OP_ERASE, -1};\n\n\tu8\t\tbValue;\n\tint\t\ti;\n\tint\t\tiKeyRef = 0;\n\tint\t\tiMethod;\n\tint\t\tiPinCount;\n\tint\t\tiOffset = 0;\n\tint\t\tiOperation;\n\tconst int*\tp_idx;\n\n\t/* Check all sub-AC definitions within the total AC */\n\twhile (len > 1) {\t\t\t\t/* minimum length = 2 */\n\t\tsize_t iACLen = buf[iOffset] & 0x0F;\n\t\tif (iACLen > len)\n\t\t\tbreak;\n\n\t\tiMethod = SC_AC_NONE;\t\t/* default no authentication required */\n\n\t\tif (buf[iOffset] & 0X80) { /* AC in adaptive coding */\n\t\t\t/* Evaluates only the command-byte, not the optional P1/P2/Option bytes */\n\t\t\tsize_t\tiParmLen = 1;\t\t\t/* command-byte is always present */\n\t\t\tsize_t\tiKeyLen = 0;\t\t\t/* Encryption key is optional */\n\n\t\t\tif (buf[iOffset] & 0x20) iKeyLen++;\n\t\t\tif (buf[iOffset+1] & 0x40) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x20) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x10) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x08) iParmLen++;\n\n\t\t\t/* Get KeyNumber if available */\n\t\t\tif(iKeyLen) {\n\t\t\t\tint iSC;\n\t\t\t\tif (len < 1+(size_t)iACLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiSC = buf[iOffset+iACLen];\n\n\t\t\t\tswitch( (iSC>>5) & 0x03 ){\n\t\t\t\tcase 0:\n\t\t\t\t\tiMethod = SC_AC_TERM;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tiMethod = SC_AC_AUT;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\tcase 3:\n\t\t\t\t\tiMethod = SC_AC_PRO;\t\t/* secure messaging */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tiKeyRef = iSC & 0x1F;\t\t\t/* get key number */\n\t\t\t}\n\n\t\t\t/* Get PinNumber if available */\n\t\t\tif (iACLen > (1+iParmLen+iKeyLen)) { /* check via total length if pin is present */\n\t\t\t\tif (len < 1+1+1+(size_t)iParmLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiKeyRef = buf[iOffset+1+1+iParmLen]; /* PTL + AM-header + parameter-bytes */\n\t\t\t\tiMethod = SC_AC_CHV;\n\t\t\t}\n\n\t\t\t/* Convert SETCOS command to OpenSC command group */\n\t\t\tif (len < 1+2)\n\t\t\t\tbreak;\n\t\t\tswitch(buf[iOffset+2]){\n\t\t\tcase 0x2A:\t\t\t/* crypto operation */\n\t\t\t\tiOperation = SC_AC_OP_CRYPTO;\n\t\t\t\tbreak;\n\t\t\tcase 0x46:\t\t\t/* key-generation operation */\n\t\t\t\tiOperation = SC_AC_OP_UPDATE;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tiOperation = SC_AC_OP_SELECT;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsc_file_add_acl_entry(file, iOperation, iMethod, iKeyRef);\n\t\t}\n\t\telse { /* AC in simple coding */\n\t\t\t /* Initial AC is treated as an operational AC */\n\n\t\t\t/* Get specific Cmd groups for specified file-type */\n\t\t\tswitch (file->type) {\n\t\t\tcase SC_FILE_TYPE_DF: /* DF */\n\t\t\t\tp_idx = df_idx;\n\t\t\t\tbreak;\n\t\t\tcase SC_FILE_TYPE_INTERNAL_EF: /* EF for RSA keys */\n\t\t\t\tp_idx = efi_idx;\n\t\t\t\tbreak;\n\t\t\tdefault: /* EF */\n\t\t\t\tp_idx = ef_idx;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* Encryption key present ? */\n\t\t\tiPinCount = iACLen - 1;\t\t\n\n\t\t\tif (buf[iOffset] & 0x20) {\n\t\t\t\tint iSC;\n\t\t\t\tif (len < 1 + (size_t)iACLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiSC = buf[iOffset + iACLen];\n\n\t\t\t\tswitch( (iSC>>5) & 0x03 ) {\n\t\t\t\tcase 0:\n\t\t\t\t\tiMethod = SC_AC_TERM;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tiMethod = SC_AC_AUT;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\tcase 3:\n\t\t\t\t\tiMethod = SC_AC_PRO;\t\t/* secure messaging */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tiKeyRef = iSC & 0x1F;\t\t\t/* get key number */\n\n\t\t\t\tiPinCount--;\t\t\t\t/* one byte used for keyReference */\n\t\t\t}\n\n\t\t\t/* Pin present ? */\n\t\t\tif ( iPinCount > 0 ) {\n\t\t\t\tif (len < 1 + 2)\n\t\t\t\t\tbreak;\n\t\t\t\tiKeyRef = buf[iOffset + 2];\t/* pin ref */\n\t\t\t\tiMethod = SC_AC_CHV;\n\t\t\t}\n\n\t\t\t/* Add AC for each command-operationType into OpenSc structure */\n\t\t\tbValue = buf[iOffset + 1];\n\t\t\tfor (i = 0; i < 8; i++) {\n\t\t\t\tif((bValue & 1) && (p_idx[i] >= 0))\n\t\t\t\t\tsc_file_add_acl_entry(file, p_idx[i], iMethod, iKeyRef);\n\t\t\t\tbValue >>= 1;\n\t\t\t}\n\t\t}\n\t\t/* Current field treated, get next AC sub-field */\n\t\tiOffset += iACLen +1;\t\t/* AC + PTL-byte */\n\t\tlen -= iACLen +1;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19479", "cwe_id": "CWE-125" }, { "id": 524, "func": "static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len)\n{\n\t/* OpenSc Operation values for each command operation-type */\n\tconst int df_idx[8] = {\t /* byte 1 = OpenSC type of AC Bit0, byte 2 = OpenSC type of AC Bit1 ...*/\n\t\tSC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\tSC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};\n\tconst int ef_idx[8] = {\n\t\tSC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\t-1, SC_AC_OP_ERASE, -1};\n\tconst int efi_idx[8] = { /* internal EF used for RSA keys */\n\t\tSC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,\n\t\tSC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,\n\t\t-1, SC_AC_OP_ERASE, -1};\n\n\tu8\t\tbValue;\n\tint\t\ti;\n\tint\t\tiKeyRef = 0;\n\tint\t\tiMethod;\n\tint\t\tiPinCount;\n\tint\t\tiOffset = 0;\n\tint\t\tiOperation;\n\tconst int*\tp_idx;\n\n\t/* Check all sub-AC definitions within the total AC */\n\twhile (len > 1) {\t\t\t\t/* minimum length = 2 */\n\t\tsize_t iACLen = buf[iOffset] & 0x0F;\n\t\tif (iACLen > len)\n\t\t\tbreak;\n\n\t\tiMethod = SC_AC_NONE;\t\t/* default no authentication required */\n\n\t\tif (buf[iOffset] & 0X80) { /* AC in adaptive coding */\n\t\t\t/* Evaluates only the command-byte, not the optional P1/P2/Option bytes */\n\t\t\tsize_t\tiParmLen = 1;\t\t\t/* command-byte is always present */\n\t\t\tsize_t\tiKeyLen = 0;\t\t\t/* Encryption key is optional */\n\n\t\t\tif (buf[iOffset] & 0x20) iKeyLen++;\n\t\t\tif (buf[iOffset+1] & 0x40) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x20) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x10) iParmLen++;\n\t\t\tif (buf[iOffset+1] & 0x08) iParmLen++;\n\n\t\t\t/* Get KeyNumber if available */\n\t\t\tif(iKeyLen) {\n\t\t\t\tint iSC;\n\t\t\t\tif (len < 1+(size_t)iACLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiSC = buf[iOffset+iACLen];\n\n\t\t\t\tswitch( (iSC>>5) & 0x03 ){\n\t\t\t\tcase 0:\n\t\t\t\t\tiMethod = SC_AC_TERM;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tiMethod = SC_AC_AUT;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\tcase 3:\n\t\t\t\t\tiMethod = SC_AC_PRO;\t\t/* secure messaging */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tiKeyRef = iSC & 0x1F;\t\t\t/* get key number */\n\t\t\t}\n\n\t\t\t/* Get PinNumber if available */\n\t\t\tif (iACLen > (1+iParmLen+iKeyLen)) { /* check via total length if pin is present */\n\t\t\t\tif (len < 1+1+1+(size_t)iParmLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiKeyRef = buf[iOffset+1+1+iParmLen]; /* PTL + AM-header + parameter-bytes */\n\t\t\t\tiMethod = SC_AC_CHV;\n\t\t\t}\n\n\t\t\t/* Convert SETCOS command to OpenSC command group */\n\t\t\tif (len < 1+2)\n\t\t\t\tbreak;\n\t\t\tswitch(buf[iOffset+2]){\n\t\t\tcase 0x2A:\t\t\t/* crypto operation */\n\t\t\t\tiOperation = SC_AC_OP_CRYPTO;\n\t\t\t\tbreak;\n\t\t\tcase 0x46:\t\t\t/* key-generation operation */\n\t\t\t\tiOperation = SC_AC_OP_UPDATE;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tiOperation = SC_AC_OP_SELECT;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsc_file_add_acl_entry(file, iOperation, iMethod, iKeyRef);\n\t\t}\n\t\telse { /* AC in simple coding */\n\t\t\t /* Initial AC is treated as an operational AC */\n\n\t\t\t/* Get specific Cmd groups for specified file-type */\n\t\t\tswitch (file->type) {\n\t\t\tcase SC_FILE_TYPE_DF: /* DF */\n\t\t\t\tp_idx = df_idx;\n\t\t\t\tbreak;\n\t\t\tcase SC_FILE_TYPE_INTERNAL_EF: /* EF for RSA keys */\n\t\t\t\tp_idx = efi_idx;\n\t\t\t\tbreak;\n\t\t\tdefault: /* EF */\n\t\t\t\tp_idx = ef_idx;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* Encryption key present ? */\n\t\t\tiPinCount = iACLen > 0 ? iACLen - 1 : 0;\n\n\t\t\tif (buf[iOffset] & 0x20) {\n\t\t\t\tint iSC;\n\t\t\t\tif (len < 1 + (size_t)iACLen)\n\t\t\t\t\tbreak;\n\t\t\t\tiSC = buf[iOffset + iACLen];\n\n\t\t\t\tswitch( (iSC>>5) & 0x03 ) {\n\t\t\t\tcase 0:\n\t\t\t\t\tiMethod = SC_AC_TERM;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tiMethod = SC_AC_AUT;\t\t/* key authentication */\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\tcase 3:\n\t\t\t\t\tiMethod = SC_AC_PRO;\t\t/* secure messaging */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tiKeyRef = iSC & 0x1F;\t\t\t/* get key number */\n\n\t\t\t\tiPinCount--;\t\t\t\t/* one byte used for keyReference */\n\t\t\t}\n\n\t\t\t/* Pin present ? */\n\t\t\tif ( iPinCount > 0 ) {\n\t\t\t\tif (len < 1 + 2)\n\t\t\t\t\tbreak;\n\t\t\t\tiKeyRef = buf[iOffset + 2];\t/* pin ref */\n\t\t\t\tiMethod = SC_AC_CHV;\n\t\t\t}\n\n\t\t\t/* Add AC for each command-operationType into OpenSc structure */\n\t\t\tbValue = buf[iOffset + 1];\n\t\t\tfor (i = 0; i < 8; i++) {\n\t\t\t\tif((bValue & 1) && (p_idx[i] >= 0))\n\t\t\t\t\tsc_file_add_acl_entry(file, p_idx[i], iMethod, iKeyRef);\n\t\t\t\tbValue >>= 1;\n\t\t\t}\n\t\t}\n\t\t/* Current field treated, get next AC sub-field */\n\t\tiOffset += iACLen +1;\t\t/* AC + PTL-byte */\n\t\tlen -= iACLen +1;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19479", "cwe_id": "CWE-125" }, { "id": 1314, "func": "messageFindArgument(const message *m, const char *variable)\n{\n\tint i;\n\tsize_t len;\n\n\tassert(m != NULL);\n\tassert(variable != NULL);\n\n\tlen = strlen(variable);\n\n\tfor(i = 0; i < m->numberOfArguments; i++) {\n\t\tconst char *ptr;\n\n\t\tptr = messageGetArgument(m, i);\n\t\tif((ptr == NULL) || (*ptr == '\\0'))\n\t\t\tcontinue;\n#ifdef\tCL_DEBUG\n\t\tcli_dbgmsg(\"messageFindArgument: compare %lu bytes of %s with %s\\n\",\n\t\t\t(unsigned long)len, variable, ptr);\n#endif\n\t\tif(strncasecmp(ptr, variable, len) == 0) {\n\t\t\tptr = &ptr[len];\n\t\t\twhile(isspace(*ptr))\n\t\t\t\tptr++;\n\t\t\tif(*ptr != '=') {\n\t\t\t\tcli_dbgmsg(\"messageFindArgument: no '=' sign found in MIME header '%s' (%s)\\n\", variable, messageGetArgument(m, i));\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif((*++ptr == '\"') && (strchr(&ptr[1], '\"') != NULL)) {\n\t\t\t\t/* Remove any quote characters */\n\t\t\t\tchar *ret = cli_strdup(++ptr);\n\t\t\t\tchar *p;\n\n\t\t\t\tif(ret == NULL)\n\t\t\t\t\treturn NULL;\n\n\t\t\t\t/*\n\t\t\t\t * fix un-quoting of boundary strings from\n\t\t\t\t * header, occurs if boundary was given as\n\t\t\t\t *\t'boundary=\"_Test_\";'\n\t\t\t\t *\n\t\t\t\t * At least two quotes in string, assume\n\t\t\t\t * quoted argument\n\t\t\t\t * end string at next quote\n\t\t\t\t */\n\t\t\t\tif((p = strchr(ret, '\"')) != NULL) {\n\t\t\t\t\tret[strlen(ret) - 1] = '\\0';\n\t\t\t\t\t*p = '\\0';\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\treturn cli_strdup(ptr);\n\t\t}\n\t}\n\treturn NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6418", "cwe_id": "CWE-125" }, { "id": 1314, "func": "messageFindArgument(const message *m, const char *variable)\n{\n\tint i;\n\tsize_t len;\n\n\tassert(m != NULL);\n\tassert(variable != NULL);\n\n\tlen = strlen(variable);\n\n\tfor(i = 0; i < m->numberOfArguments; i++) {\n\t\tconst char *ptr;\n\n\t\tptr = messageGetArgument(m, i);\n\t\tif((ptr == NULL) || (*ptr == '\\0'))\n\t\t\tcontinue;\n#ifdef\tCL_DEBUG\n\t\tcli_dbgmsg(\"messageFindArgument: compare %lu bytes of %s with %s\\n\",\n\t\t\t(unsigned long)len, variable, ptr);\n#endif\n\t\tif(strncasecmp(ptr, variable, len) == 0) {\n\t\t\tptr = &ptr[len];\n\t\t\twhile(isspace(*ptr))\n\t\t\t\tptr++;\n\t\t\tif(*ptr != '=') {\n\t\t\t\tcli_dbgmsg(\"messageFindArgument: no '=' sign found in MIME header '%s' (%s)\\n\", variable, messageGetArgument(m, i));\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif((strlen(ptr) > 2) && (*++ptr == '\"') && (strchr(&ptr[1], '\"') != NULL)) {\n\t\t\t\t/* Remove any quote characters */\n\t\t\t\tchar *ret = cli_strdup(++ptr);\n\t\t\t\tchar *p;\n\n\t\t\t\tif(ret == NULL)\n\t\t\t\t\treturn NULL;\n\n\t\t\t\t/*\n\t\t\t\t * fix un-quoting of boundary strings from\n\t\t\t\t * header, occurs if boundary was given as\n\t\t\t\t *\t'boundary=\"_Test_\";'\n\t\t\t\t *\n\t\t\t\t * At least two quotes in string, assume\n\t\t\t\t * quoted argument\n\t\t\t\t * end string at next quote\n\t\t\t\t */\n\t\t\t\tif((p = strchr(ret, '\"')) != NULL) {\n\t\t\t\t\tret[strlen(ret) - 1] = '\\0';\n\t\t\t\t\t*p = '\\0';\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\treturn cli_strdup(ptr);\n\t\t}\n\t}\n\treturn NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6418", "cwe_id": "CWE-125" }, { "id": 2532, "func": "horizontalDifference16(unsigned short *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From14)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n/* assumption is unsigned pixel values */\n#undef CLAMP\n#define CLAMP(v) From14[(v) >> 2]\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\twp += 3;\n\t\tip += 3;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\twp += 4;\n\t\tip += 4;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1;\n\t }\n\t} else {\n\t ip += n - 1;\t/* point to last one */\n\t wp += n - 1;\t/* point to last one */\n\t n -= stride;\n\t while (n > 0) {\n\t\tREPEAT(stride, wp[0] = CLAMP(ip[0]);\n\t\t\t\twp[stride] -= wp[0];\n\t\t\t\twp[stride] &= mask;\n\t\t\t\twp--; ip--)\n\t\tn -= stride;\n\t }\n\t REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--)\n\t}\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9533", "cwe_id": "CWE-119" }, { "id": 2532, "func": "horizontalDifference16(unsigned short *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From14)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n/* assumption is unsigned pixel values */\n#undef CLAMP\n#define CLAMP(v) From14[(v) >> 2]\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\twp += 3;\n\t\tip += 3;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\twp += 4;\n\t\tip += 4;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1;\n\t }\n\t} else {\n REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)\n\t n -= stride;\n\t while (n > 0) {\n REPEAT(stride,\n wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);\n wp++; ip++)\n n -= stride;\n }\n\t}\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9533", "cwe_id": "CWE-119" }, { "id": 1652, "func": "static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx,\n int_fast32_t tly, int_fast32_t hstep, int_fast32_t vstep,\n int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd,\n uint_fast32_t inmem)\n{\n\tjas_image_cmpt_t *cmpt;\n\tsize_t size;\n\n\tcmpt = 0;\n\tif (width < 0 || height < 0 || hstep <= 0 || vstep <= 0) {\n\t\tgoto error;\n\t}\n\tif (!jas_safe_intfast32_add(tlx, width, 0) ||\n\t !jas_safe_intfast32_add(tly, height, 0)) {\n\t\tgoto error;\n\t}\n\n\tif (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {\n\t\tgoto error;\n\t}\n\n\tcmpt->type_ = JAS_IMAGE_CT_UNKNOWN;\n\tcmpt->tlx_ = tlx;\n\tcmpt->tly_ = tly;\n\tcmpt->hstep_ = hstep;\n\tcmpt->vstep_ = vstep;\n\tcmpt->width_ = width;\n\tcmpt->height_ = height;\n\tcmpt->prec_ = depth;\n\tcmpt->sgnd_ = sgnd;\n\tcmpt->stream_ = 0;\n\tcmpt->cps_ = (depth + 7) / 8;\n\n\t// Compute the number of samples in the image component, while protecting\n\t// against overflow.\n\t// size = cmpt->width_ * cmpt->height_ * cmpt->cps_;\n\tif (!jas_safe_size_mul(cmpt->width_, cmpt->height_, &size) ||\n\t !jas_safe_size_mul(size, cmpt->cps_, &size)) {\n\t\tgoto error;\n\t}\n\tcmpt->stream_ = (inmem) ? jas_stream_memopen(0, size) :\n\t jas_stream_tmpfile();\n\tif (!cmpt->stream_) {\n\t\tgoto error;\n\t}\n\n\t/* Zero the component data. This isn't necessary, but it is\n\tconvenient for debugging purposes. */\n\t/* Note: conversion of size - 1 to long can overflow */\n\tif (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||\n\t jas_stream_putc(cmpt->stream_, 0) == EOF ||\n\t jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {\n\t\tgoto error;\n\t}\n\n\treturn cmpt;\n\nerror:\n\tif (cmpt) {\n\t\tjas_image_cmpt_destroy(cmpt);\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9262", "cwe_id": "CWE-190" }, { "id": 1652, "func": "static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx,\n int_fast32_t tly, int_fast32_t hstep, int_fast32_t vstep,\n int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd,\n uint_fast32_t inmem)\n{\n\tjas_image_cmpt_t *cmpt;\n\tsize_t size;\n\n\tcmpt = 0;\n\tif (width < 0 || height < 0 || hstep <= 0 || vstep <= 0) {\n\t\tgoto error;\n\t}\n\tif (!jas_safe_intfast32_add(tlx, width, 0) ||\n\t !jas_safe_intfast32_add(tly, height, 0)) {\n\t\tgoto error;\n\t}\n\n\tif (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {\n\t\tgoto error;\n\t}\n\n\tcmpt->type_ = JAS_IMAGE_CT_UNKNOWN;\n\tcmpt->tlx_ = tlx;\n\tcmpt->tly_ = tly;\n\tcmpt->hstep_ = hstep;\n\tcmpt->vstep_ = vstep;\n\tcmpt->width_ = width;\n\tcmpt->height_ = height;\n\tcmpt->prec_ = depth;\n\tcmpt->sgnd_ = sgnd;\n\tcmpt->stream_ = 0;\n\tcmpt->cps_ = (depth + 7) / 8;\n\n\t// Compute the number of samples in the image component, while protecting\n\t// against overflow.\n\t// size = cmpt->width_ * cmpt->height_ * cmpt->cps_;\n\tif (!jas_safe_size_mul(cmpt->width_, cmpt->height_, &size) ||\n\t !jas_safe_size_mul(size, cmpt->cps_, &size)) {\n\t\tgoto error;\n\t}\n\tcmpt->stream_ = (inmem) ? jas_stream_memopen2(0, size) :\n\t jas_stream_tmpfile();\n\tif (!cmpt->stream_) {\n\t\tgoto error;\n\t}\n\n\t/* Zero the component data. This isn't necessary, but it is\n\tconvenient for debugging purposes. */\n\t/* Note: conversion of size - 1 to long can overflow */\n\tif (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||\n\t jas_stream_putc(cmpt->stream_, 0) == EOF ||\n\t jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {\n\t\tgoto error;\n\t}\n\n\treturn cmpt;\n\nerror:\n\tif (cmpt) {\n\t\tjas_image_cmpt_destroy(cmpt);\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9262", "cwe_id": "CWE-190" }, { "id": 1923, "func": "int _yr_scan_verify_re_match(\n YR_SCAN_CONTEXT* context,\n YR_AC_MATCH* ac_match,\n uint8_t* data,\n size_t data_size,\n size_t data_base,\n size_t offset)\n{\n CALLBACK_ARGS callback_args;\n RE_EXEC_FUNC exec;\n\n int forward_matches = -1;\n int backward_matches = -1;\n int flags = 0;\n\n if (STRING_IS_GREEDY_REGEXP(ac_match->string))\n flags |= RE_FLAGS_GREEDY;\n\n if (STRING_IS_NO_CASE(ac_match->string))\n flags |= RE_FLAGS_NO_CASE;\n\n if (STRING_IS_DOT_ALL(ac_match->string))\n flags |= RE_FLAGS_DOT_ALL;\n\n if (STRING_IS_FAST_REGEXP(ac_match->string))\n exec = yr_re_fast_exec;\n else\n exec = yr_re_exec;\n\n if (STRING_IS_ASCII(ac_match->string))\n {\n forward_matches = exec(\n ac_match->forward_code,\n data + offset,\n data_size - offset,\n offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags,\n NULL,\n NULL);\n }\n\n if (STRING_IS_WIDE(ac_match->string) && forward_matches == -1)\n {\n flags |= RE_FLAGS_WIDE;\n forward_matches = exec(\n ac_match->forward_code,\n data + offset,\n data_size - offset,\n offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags,\n NULL,\n NULL);\n }\n\n switch(forward_matches)\n {\n case -1:\n return ERROR_SUCCESS;\n case -2:\n return ERROR_INSUFFICIENT_MEMORY;\n case -3:\n return ERROR_TOO_MANY_MATCHES;\n case -4:\n return ERROR_TOO_MANY_RE_FIBERS;\n case -5:\n return ERROR_INTERNAL_FATAL_ERROR;\n }\n\n if (forward_matches == 0 && ac_match->backward_code == NULL)\n return ERROR_SUCCESS;\n\n callback_args.string = ac_match->string;\n callback_args.context = context;\n callback_args.data = data;\n callback_args.data_size = data_size;\n callback_args.data_base = data_base;\n callback_args.forward_matches = forward_matches;\n callback_args.full_word = STRING_IS_FULL_WORD(ac_match->string);\n\n if (ac_match->backward_code != NULL)\n {\n backward_matches = exec(\n ac_match->backward_code,\n data + offset,\n offset,\n flags | RE_FLAGS_BACKWARDS | RE_FLAGS_EXHAUSTIVE,\n _yr_scan_match_callback,\n (void*) &callback_args);\n\n switch(backward_matches)\n {\n case -2:\n return ERROR_INSUFFICIENT_MEMORY;\n case -3:\n return ERROR_TOO_MANY_MATCHES;\n case -4:\n return ERROR_TOO_MANY_RE_FIBERS;\n case -5:\n return ERROR_INTERNAL_FATAL_ERROR;\n }\n }\n else\n {\n FAIL_ON_ERROR(_yr_scan_match_callback(\n data + offset, 0, flags, &callback_args));\n }\n\n return ERROR_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-8294", "cwe_id": "CWE-125" }, { "id": 1923, "func": "int _yr_scan_verify_re_match(\n YR_SCAN_CONTEXT* context,\n YR_AC_MATCH* ac_match,\n uint8_t* data,\n size_t data_size,\n size_t data_base,\n size_t offset)\n{\n CALLBACK_ARGS callback_args;\n RE_EXEC_FUNC exec;\n\n int forward_matches = -1;\n int backward_matches = -1;\n int flags = 0;\n\n if (STRING_IS_GREEDY_REGEXP(ac_match->string))\n flags |= RE_FLAGS_GREEDY;\n\n if (STRING_IS_NO_CASE(ac_match->string))\n flags |= RE_FLAGS_NO_CASE;\n\n if (STRING_IS_DOT_ALL(ac_match->string))\n flags |= RE_FLAGS_DOT_ALL;\n\n if (STRING_IS_FAST_REGEXP(ac_match->string))\n exec = yr_re_fast_exec;\n else\n exec = yr_re_exec;\n\n if (STRING_IS_ASCII(ac_match->string))\n {\n forward_matches = exec(\n ac_match->forward_code,\n data + offset,\n data_size - offset,\n offset,\n flags,\n NULL,\n NULL);\n }\n\n if (STRING_IS_WIDE(ac_match->string) && forward_matches == -1)\n {\n flags |= RE_FLAGS_WIDE;\n forward_matches = exec(\n ac_match->forward_code,\n data + offset,\n data_size - offset,\n offset,\n flags,\n NULL,\n NULL);\n }\n\n switch(forward_matches)\n {\n case -1:\n return ERROR_SUCCESS;\n case -2:\n return ERROR_INSUFFICIENT_MEMORY;\n case -3:\n return ERROR_TOO_MANY_MATCHES;\n case -4:\n return ERROR_TOO_MANY_RE_FIBERS;\n case -5:\n return ERROR_INTERNAL_FATAL_ERROR;\n }\n\n if (forward_matches == 0 && ac_match->backward_code == NULL)\n return ERROR_SUCCESS;\n\n callback_args.string = ac_match->string;\n callback_args.context = context;\n callback_args.data = data;\n callback_args.data_size = data_size;\n callback_args.data_base = data_base;\n callback_args.forward_matches = forward_matches;\n callback_args.full_word = STRING_IS_FULL_WORD(ac_match->string);\n\n if (ac_match->backward_code != NULL)\n {\n backward_matches = exec(\n ac_match->backward_code,\n data + offset,\n data_size - offset,\n offset,\n flags | RE_FLAGS_BACKWARDS | RE_FLAGS_EXHAUSTIVE,\n _yr_scan_match_callback,\n (void*) &callback_args);\n\n switch(backward_matches)\n {\n case -2:\n return ERROR_INSUFFICIENT_MEMORY;\n case -3:\n return ERROR_TOO_MANY_MATCHES;\n case -4:\n return ERROR_TOO_MANY_RE_FIBERS;\n case -5:\n return ERROR_INTERNAL_FATAL_ERROR;\n }\n }\n else\n {\n FAIL_ON_ERROR(_yr_scan_match_callback(\n data + offset, 0, flags, &callback_args));\n }\n\n return ERROR_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-8294", "cwe_id": "CWE-125" }, { "id": 2305, "func": "static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,\n\t\t\t\t int tlen, int offset)\n{\n\t__wsum csum = skb->csum;\n\n\tif (skb->ip_summed != CHECKSUM_COMPLETE)\n\t\treturn;\n\n\tif (offset != 0)\n\t\tcsum = csum_sub(csum,\n\t\t\t\tcsum_partial(skb_transport_header(skb) + tlen,\n\t\t\t\t\t offset, 0));\n\n\tput_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6347", "cwe_id": "CWE-125" }, { "id": 2305, "func": "static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,\n\t\t\t\t int tlen, int offset)\n{\n\t__wsum csum = skb->csum;\n\n\tif (skb->ip_summed != CHECKSUM_COMPLETE)\n\t\treturn;\n\n\tif (offset != 0) {\n\t\tint tend_off = skb_transport_offset(skb) + tlen;\n\t\tcsum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0));\n\t}\n\n\tput_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6347", "cwe_id": "CWE-125" }, { "id": 2097, "func": "get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n/* This version is for reading raw-word-format PPM files with any maxval */\n{\n ppm_source_ptr source = (ppm_source_ptr)sinfo;\n register JSAMPROW ptr;\n register U_CHAR *bufferptr;\n register JSAMPLE *rescale = source->rescale;\n JDIMENSION col;\n unsigned int maxval = source->maxval;\n\n if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))\n ERREXIT(cinfo, JERR_INPUT_EOF);\n ptr = source->pub.buffer[0];\n bufferptr = source->iobuffer;\n for (col = cinfo->image_width; col > 0; col--) {\n register unsigned int temp;\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n *ptr++ = rescale[temp];\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n *ptr++ = rescale[temp];\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n *ptr++ = rescale[temp];\n }\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-46822", "cwe_id": "CWE-787" }, { "id": 2097, "func": "get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n/* This version is for reading raw-word-format PPM files with any maxval */\n{\n ppm_source_ptr source = (ppm_source_ptr)sinfo;\n register JSAMPROW ptr;\n register U_CHAR *bufferptr;\n register JSAMPLE *rescale = source->rescale;\n JDIMENSION col;\n unsigned int maxval = source->maxval;\n register int rindex = rgb_red[cinfo->in_color_space];\n register int gindex = rgb_green[cinfo->in_color_space];\n register int bindex = rgb_blue[cinfo->in_color_space];\n register int aindex = alpha_index[cinfo->in_color_space];\n register int ps = rgb_pixelsize[cinfo->in_color_space];\n\n if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))\n ERREXIT(cinfo, JERR_INPUT_EOF);\n ptr = source->pub.buffer[0];\n bufferptr = source->iobuffer;\n for (col = cinfo->image_width; col > 0; col--) {\n register unsigned int temp;\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n ptr[rindex] = rescale[temp];\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n ptr[gindex] = rescale[temp];\n temp = UCH(*bufferptr++) << 8;\n temp |= UCH(*bufferptr++);\n if (temp > maxval)\n ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);\n ptr[bindex] = rescale[temp];\n if (aindex >= 0)\n ptr[aindex] = 0xFF;\n ptr += ps;\n }\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-46822", "cwe_id": "CWE-787" }, { "id": 1125, "func": "static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)\n{\n\tstruct syscall_metadata *sys_data;\n\tstruct syscall_trace_exit *rec;\n\tstruct hlist_head *head;\n\tint syscall_nr;\n\tint rctx;\n\tint size;\n\n\tsyscall_nr = trace_get_syscall_nr(current, regs);\n\tif (syscall_nr < 0)\n\t\treturn;\n\tif (!test_bit(syscall_nr, enabled_perf_exit_syscalls))\n\t\treturn;\n\n\tsys_data = syscall_nr_to_meta(syscall_nr);\n\tif (!sys_data)\n\t\treturn;\n\n\thead = this_cpu_ptr(sys_data->exit_event->perf_events);\n\tif (hlist_empty(head))\n\t\treturn;\n\n\t/* We can probably do that at build time */\n\tsize = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));\n\tsize -= sizeof(u32);\n\n\trec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,\n\t\t\t\tsys_data->exit_event->event.type, regs, &rctx);\n\tif (!rec)\n\t\treturn;\n\n\trec->nr = syscall_nr;\n\trec->ret = syscall_get_return_value(current, regs);\n\tperf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-7825", "cwe_id": "CWE-125" }, { "id": 1125, "func": "static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)\n{\n\tstruct syscall_metadata *sys_data;\n\tstruct syscall_trace_exit *rec;\n\tstruct hlist_head *head;\n\tint syscall_nr;\n\tint rctx;\n\tint size;\n\n\tsyscall_nr = trace_get_syscall_nr(current, regs);\n\tif (syscall_nr < 0 || syscall_nr >= NR_syscalls)\n\t\treturn;\n\tif (!test_bit(syscall_nr, enabled_perf_exit_syscalls))\n\t\treturn;\n\n\tsys_data = syscall_nr_to_meta(syscall_nr);\n\tif (!sys_data)\n\t\treturn;\n\n\thead = this_cpu_ptr(sys_data->exit_event->perf_events);\n\tif (hlist_empty(head))\n\t\treturn;\n\n\t/* We can probably do that at build time */\n\tsize = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));\n\tsize -= sizeof(u32);\n\n\trec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,\n\t\t\t\tsys_data->exit_event->event.type, regs, &rctx);\n\tif (!rec)\n\t\treturn;\n\n\trec->nr = syscall_nr;\n\trec->ret = syscall_get_return_value(current, regs);\n\tperf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-7825", "cwe_id": "CWE-125" }, { "id": 1766, "func": "static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, int bits, R_OWN char *file_name) {\n\tD eprintf (\"Dragons at 0x%x\\n\", off);\n\tut64 size = r_buf_size (buf);\n\tif (off >= size) {\n\t\treturn NULL;\n\t}\n\tsize -= off;\n\tif (!size) {\n\t\treturn NULL;\n\t}\n\tut8 *b = malloc (size);\n\tif (!b) {\n\t\treturn NULL;\n\t}\n\tint available = r_buf_read_at (buf, off, b, size);\n\tif (available != size) {\n\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\treturn NULL;\n\t}\n#if 0\n\t// after the list of sections, there's a bunch of unknown\n\t// data, brobably dwords, and then the same section list again\n\t// this function aims to parse it.\n\t0x00000138 |1a2b b2a1 0300 0000 1a2b b2a1 e055 0000| .+.......+...U..\n n_segments ----. .--- how many sections ?\n\t0x00000148 |0100 0000 ca55 0000 0400 0000 1800 0000| .....U..........\n\t .---- how many symbols? 0xc7\n\t0x00000158 |c700 0000 0000 0000 0000 0000 0104 0000| ................\n\t0x00000168 |250b e803 0000 0100 0000 0000 bd55 0000| %............U..\n\t0x00000178 |91bb e903 e35a b42c 93a4 340a 8746 9489| .....Z.,..4..F..\n\t0x00000188 |0cea 4c40 0c00 0000 0900 0000 0000 0000| ..L@............\n\t0x00000198 |0000 0000 0000 0000 0000 0000 0000 0000| ................\n\t0x000001a8 |0080 0000 0000 0000 5f5f 5445 5854 0000| ........__TEXT..\n\t0x000001b8 |0000 0000 0000 0000 0080 0000 0000 0000| ................\n\t0x000001c8 |0040 0000 0000 0000 5f5f 4441 5441 0000| .@......__DATA..\n\t0x000001d8 |0000 0000 0000 0000 00c0 0000 0000 0000| ................\n\t0x000001e8 |0000 0100 0000 0000 5f5f 4c4c 564d 0000| ........__LLVM..\n\t0x000001f8 |0000 0000 0000 0000 00c0 0100 0000 0000| ................\n\t0x00000208 |00c0 0000 0000 0000 5f5f 4c49 4e4b 4544| ........__LINKED\n\t0x00000218 |4954 0000 0000 0000 0000 0000 d069 0000| IT...........i..\n#endif\n\t// eprintf (\"Dragon's magic:\\n\");\n\tint magicCombo = 0;\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { // 0x130 ?\n\t\tmagicCombo++;\n\t}\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b + 8, 4)) {\n\t\tmagicCombo++;\n\t}\n\tif (magicCombo != 2) {\n\t\t// hack for C22F7494\n\t\tavailable = r_buf_read_at (buf, off - 8, b, size);\n\t\tif (available != size) {\n\t\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { // 0x130 ?\n\t\t\toff -= 8;\n\t\t} else {\n\t\t\teprintf (\"0x%08x parsing error: invalid magic retry\\n\", off);\n\t\t}\n\t}\n\tD eprintf (\"0x%08x magic OK\\n\", off);\n\tD {\n\t\tconst int e0ss = r_read_le32 (b + 12);\n\t\teprintf (\"0x%08x eoss 0x%x\\n\", off + 12, e0ss);\n\t}\n\tfree (b);\n\treturn r_coresym_cache_element_new (bf, buf, off + 16, bits, file_name);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-1061", "cwe_id": "CWE-787" }, { "id": 1766, "func": "static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, int bits, R_OWN char *file_name) {\n\tD eprintf (\"Dragons at 0x%x\\n\", off);\n\tst64 size = r_buf_size (buf);\n\tif (off >= size) {\n\t\treturn NULL;\n\t}\n\tsize -= off;\n\tif (!size) {\n\t\treturn NULL;\n\t}\n\tif (size < 32) {\n\t\treturn NULL;\n\t}\n\tut8 *b = malloc (size);\n\tif (!b) {\n\t\treturn NULL;\n\t}\n\tint available = r_buf_read_at (buf, off, b, size);\n\tif (available != size) {\n\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\treturn NULL;\n\t}\n#if 0\n\t// after the list of sections, there's a bunch of unknown\n\t// data, brobably dwords, and then the same section list again\n\t// this function aims to parse it.\n\t0x00000138 |1a2b b2a1 0300 0000 1a2b b2a1 e055 0000| .+.......+...U..\n n_segments ----. .--- how many sections ?\n\t0x00000148 |0100 0000 ca55 0000 0400 0000 1800 0000| .....U..........\n\t .---- how many symbols? 0xc7\n\t0x00000158 |c700 0000 0000 0000 0000 0000 0104 0000| ................\n\t0x00000168 |250b e803 0000 0100 0000 0000 bd55 0000| %............U..\n\t0x00000178 |91bb e903 e35a b42c 93a4 340a 8746 9489| .....Z.,..4..F..\n\t0x00000188 |0cea 4c40 0c00 0000 0900 0000 0000 0000| ..L@............\n\t0x00000198 |0000 0000 0000 0000 0000 0000 0000 0000| ................\n\t0x000001a8 |0080 0000 0000 0000 5f5f 5445 5854 0000| ........__TEXT..\n\t0x000001b8 |0000 0000 0000 0000 0080 0000 0000 0000| ................\n\t0x000001c8 |0040 0000 0000 0000 5f5f 4441 5441 0000| .@......__DATA..\n\t0x000001d8 |0000 0000 0000 0000 00c0 0000 0000 0000| ................\n\t0x000001e8 |0000 0100 0000 0000 5f5f 4c4c 564d 0000| ........__LLVM..\n\t0x000001f8 |0000 0000 0000 0000 00c0 0100 0000 0000| ................\n\t0x00000208 |00c0 0000 0000 0000 5f5f 4c49 4e4b 4544| ........__LINKED\n\t0x00000218 |4954 0000 0000 0000 0000 0000 d069 0000| IT...........i..\n#endif\n\t// eprintf (\"Dragon's magic:\\n\");\n\tint magicCombo = 0;\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { // 0x130 ?\n\t\tmagicCombo++;\n\t}\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b + 8, 4)) {\n\t\tmagicCombo++;\n\t}\n\tif (magicCombo != 2) {\n\t\t// hack for C22F7494\n\t\tavailable = r_buf_read_at (buf, off - 8, b, size);\n\t\tif (available != size) {\n\t\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { // 0x130 ?\n\t\t\toff -= 8;\n\t\t} else {\n\t\t\teprintf (\"0x%08x parsing error: invalid magic retry\\n\", off);\n\t\t}\n\t}\n\tD eprintf (\"0x%08x magic OK\\n\", off);\n\tD {\n\t\tconst int e0ss = r_read_le32 (b + 12);\n\t\teprintf (\"0x%08x eoss 0x%x\\n\", off + 12, e0ss);\n\t}\n\tfree (b);\n\treturn r_coresym_cache_element_new (bf, buf, off + 16, bits, file_name);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-1061", "cwe_id": "CWE-787" }, { "id": 15, "func": "sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)\n{\n\tsc_card_t *card = p15card->card;\n\tunsigned char buff[128];\n\tint r, i;\n\tsize_t field_length = 0, modulus_length = 0;\n\tsc_path_t tmppath;\n\n\tset_string (&p15card->tokeninfo->label, \"ID-kaart\");\n\tset_string (&p15card->tokeninfo->manufacturer_id, \"AS Sertifitseerimiskeskus\");\n\n\t/* Select application directory */\n\tsc_format_path (\"3f00eeee5044\", &tmppath);\n\tr = sc_select_file (card, &tmppath, NULL);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"select esteid PD failed\");\n\n\t/* read the serial (document number) */\n\tr = sc_read_record (card, SC_ESTEID_PD_DOCUMENT_NR, buff, sizeof(buff), SC_RECORD_BY_REC_NR);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"read document number failed\");\n\tbuff[r] = '\\0';\n\tset_string (&p15card->tokeninfo->serial_number, (const char *) buff);\n\n\tp15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION\n\t\t\t\t | SC_PKCS15_TOKEN_EID_COMPLIANT\n\t\t\t\t | SC_PKCS15_TOKEN_READONLY;\n\n\t/* add certificates */\n\tfor (i = 0; i < 2; i++) {\n\t\tstatic const char *esteid_cert_names[2] = {\n\t\t\t\"Isikutuvastus\",\n\t\t\t\"Allkirjastamine\"};\n\t\tstatic char const *esteid_cert_paths[2] = {\n\t\t\t\"3f00eeeeaace\",\n\t\t\t\"3f00eeeeddce\"};\n\t\tstatic int esteid_cert_ids[2] = {1, 2};\n\n\t\tstruct sc_pkcs15_cert_info cert_info;\n\t\tstruct sc_pkcs15_object cert_obj;\n\n\t\tmemset(&cert_info, 0, sizeof(cert_info));\n\t\tmemset(&cert_obj, 0, sizeof(cert_obj));\n\n\t\tcert_info.id.value[0] = esteid_cert_ids[i];\n\t\tcert_info.id.len = 1;\n\t\tsc_format_path(esteid_cert_paths[i], &cert_info.path);\n\t\tstrlcpy(cert_obj.label, esteid_cert_names[i], sizeof(cert_obj.label));\n\t\tr = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t\tif (i == 0) {\n\t\t\tsc_pkcs15_cert_t *cert = NULL;\n\t\t\tr = sc_pkcs15_read_certificate(p15card, &cert_info, &cert);\n\t\t\tif (r < 0)\n\t\t\t\treturn SC_ERROR_INTERNAL;\n\t\t\tif (cert->key->algorithm == SC_ALGORITHM_EC)\n\t\t\t\tfield_length = cert->key->u.ec.params.field_length;\n\t\t\telse\n\t\t\t\tmodulus_length = cert->key->u.rsa.modulus.len * 8;\n\t\t\tif (r == SC_SUCCESS) {\n\t\t\t\tstatic const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};\n\t\t\t\tu8 *cn_name = NULL;\n\t\t\t\tsize_t cn_len = 0;\n\t\t\t\tsc_pkcs15_get_name_from_dn(card->ctx, cert->subject,\n\t\t\t\t\tcert->subject_len, &cn_oid, &cn_name, &cn_len);\n\t\t\t\tif (cn_len > 0) {\n\t\t\t\t\tchar *token_name = malloc(cn_len+1);\n\t\t\t\t\tif (token_name) {\n\t\t\t\t\t\tmemcpy(token_name, cn_name, cn_len);\n\t\t\t\t\t\ttoken_name[cn_len] = '\\0';\n\t\t\t\t\t\tset_string(&p15card->tokeninfo->label, (const char*)token_name);\n\t\t\t\t\t\tfree(token_name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfree(cn_name);\n\t\t\t\tsc_pkcs15_free_certificate(cert);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* the file with key pin info (tries left) */\n\tsc_format_path (\"3f000016\", &tmppath);\n\tr = sc_select_file (card, &tmppath, NULL);\n\tif (r < 0)\n\t\treturn SC_ERROR_INTERNAL;\n\n\t/* add pins */\n\tfor (i = 0; i < 3; i++) {\n\t\tunsigned char tries_left;\n\t\tstatic const char *esteid_pin_names[3] = {\n\t\t\t\"PIN1\",\n\t\t\t\"PIN2\",\n\t\t\t\"PUK\" };\n\t\t\t\n\t\tstatic const int esteid_pin_min[3] = {4, 5, 8};\n\t\tstatic const int esteid_pin_ref[3] = {1, 2, 0};\n\t\tstatic const int esteid_pin_authid[3] = {1, 2, 3};\n\t\tstatic const int esteid_pin_flags[3] = {0, 0, SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN};\n\t\t\n\t\tstruct sc_pkcs15_auth_info pin_info;\n\t\tstruct sc_pkcs15_object pin_obj;\n\n\t\tmemset(&pin_info, 0, sizeof(pin_info));\n\t\tmemset(&pin_obj, 0, sizeof(pin_obj));\n\n\t\t/* read the number of tries left for the PIN */\n\t\tr = sc_read_record (card, i + 1, buff, sizeof(buff), SC_RECORD_BY_REC_NR);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t\ttries_left = buff[5];\n\n\t\tpin_info.auth_id.len = 1;\n\t\tpin_info.auth_id.value[0] = esteid_pin_authid[i];\n\t\tpin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;\n\t\tpin_info.attrs.pin.reference = esteid_pin_ref[i];\n\t\tpin_info.attrs.pin.flags = esteid_pin_flags[i];\n\t\tpin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;\n\t\tpin_info.attrs.pin.min_length = esteid_pin_min[i];\n\t\tpin_info.attrs.pin.stored_length = 12;\n\t\tpin_info.attrs.pin.max_length = 12;\n\t\tpin_info.attrs.pin.pad_char = '\\0';\n\t\tpin_info.tries_left = (int)tries_left;\n\t\tpin_info.max_tries = 3;\n\n\t\tstrlcpy(pin_obj.label, esteid_pin_names[i], sizeof(pin_obj.label));\n\t\tpin_obj.flags = esteid_pin_flags[i];\n\n\t\t/* Link normal PINs with PUK */\n\t\tif (i < 2) {\n\t\t\tpin_obj.auth_id.len = 1;\n\t\t\tpin_obj.auth_id.value[0] = 3;\n\t\t}\n\n\t\tr = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t}\n\n\t/* add private keys */\n\tfor (i = 0; i < 2; i++) {\n\t\tstatic int prkey_pin[2] = {1, 2};\n\n\t\tstatic const char *prkey_name[2] = {\n\t\t\t\"Isikutuvastus\",\n\t\t\t\"Allkirjastamine\"};\n\n\t\tstruct sc_pkcs15_prkey_info prkey_info;\n\t\tstruct sc_pkcs15_object prkey_obj;\n\n\t\tmemset(&prkey_info, 0, sizeof(prkey_info));\n\t\tmemset(&prkey_obj, 0, sizeof(prkey_obj));\n\n\t\tprkey_info.id.len = 1;\n\t\tprkey_info.id.value[0] = prkey_pin[i];\n\t\tprkey_info.native = 1;\n\t\tprkey_info.key_reference = i + 1;\n\t\tprkey_info.field_length = field_length;\n\t\tprkey_info.modulus_length = modulus_length;\n\t\tif (i == 1)\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;\n\t\telse if(field_length > 0) // ECC has sign and derive usage\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DERIVE;\n\t\telse\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;\n\n\t\tstrlcpy(prkey_obj.label, prkey_name[i], sizeof(prkey_obj.label));\n\t\tprkey_obj.auth_id.len = 1;\n\t\tprkey_obj.auth_id.value[0] = prkey_pin[i];\n\t\tprkey_obj.user_consent = 0;\n\t\tprkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;\n\n\t\tif(field_length > 0)\n\t\t\tr = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);\n\t\telse\n\t\t\tr = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t}\n\n\treturn SC_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 15, "func": "sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)\n{\n\tsc_card_t *card = p15card->card;\n\tunsigned char buff[128];\n\tint r, i;\n\tsize_t field_length = 0, modulus_length = 0;\n\tsc_path_t tmppath;\n\n\tset_string (&p15card->tokeninfo->label, \"ID-kaart\");\n\tset_string (&p15card->tokeninfo->manufacturer_id, \"AS Sertifitseerimiskeskus\");\n\n\t/* Select application directory */\n\tsc_format_path (\"3f00eeee5044\", &tmppath);\n\tr = sc_select_file (card, &tmppath, NULL);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"select esteid PD failed\");\n\n\t/* read the serial (document number) */\n\tr = sc_read_record (card, SC_ESTEID_PD_DOCUMENT_NR, buff, sizeof(buff), SC_RECORD_BY_REC_NR);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"read document number failed\");\n\tbuff[MIN((size_t) r, (sizeof buff)-1)] = '\\0';\n\tset_string (&p15card->tokeninfo->serial_number, (const char *) buff);\n\n\tp15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION\n\t\t\t\t | SC_PKCS15_TOKEN_EID_COMPLIANT\n\t\t\t\t | SC_PKCS15_TOKEN_READONLY;\n\n\t/* add certificates */\n\tfor (i = 0; i < 2; i++) {\n\t\tstatic const char *esteid_cert_names[2] = {\n\t\t\t\"Isikutuvastus\",\n\t\t\t\"Allkirjastamine\"};\n\t\tstatic char const *esteid_cert_paths[2] = {\n\t\t\t\"3f00eeeeaace\",\n\t\t\t\"3f00eeeeddce\"};\n\t\tstatic int esteid_cert_ids[2] = {1, 2};\n\n\t\tstruct sc_pkcs15_cert_info cert_info;\n\t\tstruct sc_pkcs15_object cert_obj;\n\n\t\tmemset(&cert_info, 0, sizeof(cert_info));\n\t\tmemset(&cert_obj, 0, sizeof(cert_obj));\n\n\t\tcert_info.id.value[0] = esteid_cert_ids[i];\n\t\tcert_info.id.len = 1;\n\t\tsc_format_path(esteid_cert_paths[i], &cert_info.path);\n\t\tstrlcpy(cert_obj.label, esteid_cert_names[i], sizeof(cert_obj.label));\n\t\tr = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t\tif (i == 0) {\n\t\t\tsc_pkcs15_cert_t *cert = NULL;\n\t\t\tr = sc_pkcs15_read_certificate(p15card, &cert_info, &cert);\n\t\t\tif (r < 0)\n\t\t\t\treturn SC_ERROR_INTERNAL;\n\t\t\tif (cert->key->algorithm == SC_ALGORITHM_EC)\n\t\t\t\tfield_length = cert->key->u.ec.params.field_length;\n\t\t\telse\n\t\t\t\tmodulus_length = cert->key->u.rsa.modulus.len * 8;\n\t\t\tif (r == SC_SUCCESS) {\n\t\t\t\tstatic const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};\n\t\t\t\tu8 *cn_name = NULL;\n\t\t\t\tsize_t cn_len = 0;\n\t\t\t\tsc_pkcs15_get_name_from_dn(card->ctx, cert->subject,\n\t\t\t\t\tcert->subject_len, &cn_oid, &cn_name, &cn_len);\n\t\t\t\tif (cn_len > 0) {\n\t\t\t\t\tchar *token_name = malloc(cn_len+1);\n\t\t\t\t\tif (token_name) {\n\t\t\t\t\t\tmemcpy(token_name, cn_name, cn_len);\n\t\t\t\t\t\ttoken_name[cn_len] = '\\0';\n\t\t\t\t\t\tset_string(&p15card->tokeninfo->label, (const char*)token_name);\n\t\t\t\t\t\tfree(token_name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfree(cn_name);\n\t\t\t\tsc_pkcs15_free_certificate(cert);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* the file with key pin info (tries left) */\n\tsc_format_path (\"3f000016\", &tmppath);\n\tr = sc_select_file (card, &tmppath, NULL);\n\tif (r < 0)\n\t\treturn SC_ERROR_INTERNAL;\n\n\t/* add pins */\n\tfor (i = 0; i < 3; i++) {\n\t\tunsigned char tries_left;\n\t\tstatic const char *esteid_pin_names[3] = {\n\t\t\t\"PIN1\",\n\t\t\t\"PIN2\",\n\t\t\t\"PUK\" };\n\t\t\t\n\t\tstatic const int esteid_pin_min[3] = {4, 5, 8};\n\t\tstatic const int esteid_pin_ref[3] = {1, 2, 0};\n\t\tstatic const int esteid_pin_authid[3] = {1, 2, 3};\n\t\tstatic const int esteid_pin_flags[3] = {0, 0, SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN};\n\t\t\n\t\tstruct sc_pkcs15_auth_info pin_info;\n\t\tstruct sc_pkcs15_object pin_obj;\n\n\t\tmemset(&pin_info, 0, sizeof(pin_info));\n\t\tmemset(&pin_obj, 0, sizeof(pin_obj));\n\n\t\t/* read the number of tries left for the PIN */\n\t\tr = sc_read_record (card, i + 1, buff, sizeof(buff), SC_RECORD_BY_REC_NR);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t\ttries_left = buff[5];\n\n\t\tpin_info.auth_id.len = 1;\n\t\tpin_info.auth_id.value[0] = esteid_pin_authid[i];\n\t\tpin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;\n\t\tpin_info.attrs.pin.reference = esteid_pin_ref[i];\n\t\tpin_info.attrs.pin.flags = esteid_pin_flags[i];\n\t\tpin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;\n\t\tpin_info.attrs.pin.min_length = esteid_pin_min[i];\n\t\tpin_info.attrs.pin.stored_length = 12;\n\t\tpin_info.attrs.pin.max_length = 12;\n\t\tpin_info.attrs.pin.pad_char = '\\0';\n\t\tpin_info.tries_left = (int)tries_left;\n\t\tpin_info.max_tries = 3;\n\n\t\tstrlcpy(pin_obj.label, esteid_pin_names[i], sizeof(pin_obj.label));\n\t\tpin_obj.flags = esteid_pin_flags[i];\n\n\t\t/* Link normal PINs with PUK */\n\t\tif (i < 2) {\n\t\t\tpin_obj.auth_id.len = 1;\n\t\t\tpin_obj.auth_id.value[0] = 3;\n\t\t}\n\n\t\tr = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t}\n\n\t/* add private keys */\n\tfor (i = 0; i < 2; i++) {\n\t\tstatic int prkey_pin[2] = {1, 2};\n\n\t\tstatic const char *prkey_name[2] = {\n\t\t\t\"Isikutuvastus\",\n\t\t\t\"Allkirjastamine\"};\n\n\t\tstruct sc_pkcs15_prkey_info prkey_info;\n\t\tstruct sc_pkcs15_object prkey_obj;\n\n\t\tmemset(&prkey_info, 0, sizeof(prkey_info));\n\t\tmemset(&prkey_obj, 0, sizeof(prkey_obj));\n\n\t\tprkey_info.id.len = 1;\n\t\tprkey_info.id.value[0] = prkey_pin[i];\n\t\tprkey_info.native = 1;\n\t\tprkey_info.key_reference = i + 1;\n\t\tprkey_info.field_length = field_length;\n\t\tprkey_info.modulus_length = modulus_length;\n\t\tif (i == 1)\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;\n\t\telse if(field_length > 0) // ECC has sign and derive usage\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DERIVE;\n\t\telse\n\t\t\tprkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;\n\n\t\tstrlcpy(prkey_obj.label, prkey_name[i], sizeof(prkey_obj.label));\n\t\tprkey_obj.auth_id.len = 1;\n\t\tprkey_obj.auth_id.value[0] = prkey_pin[i];\n\t\tprkey_obj.user_consent = 0;\n\t\tprkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;\n\n\t\tif(field_length > 0)\n\t\t\tr = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);\n\t\telse\n\t\t\tr = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);\n\t\tif (r < 0)\n\t\t\treturn SC_ERROR_INTERNAL;\n\t}\n\n\treturn SC_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 1803, "func": "ast_for_funcdef_impl(struct compiling *c, const node *n0,\n asdl_seq *decorator_seq, bool is_async)\n{\n /* funcdef: 'def' NAME parameters ['->' test] ':' suite */\n const node * const n = is_async ? CHILD(n0, 1) : n0;\n identifier name;\n arguments_ty args;\n asdl_seq *body;\n expr_ty returns = NULL;\n int name_i = 1;\n int end_lineno, end_col_offset;\n\n REQ(n, funcdef);\n\n name = NEW_IDENTIFIER(CHILD(n, name_i));\n if (!name)\n return NULL;\n if (forbidden_name(c, name, CHILD(n, name_i), 0))\n return NULL;\n args = ast_for_arguments(c, CHILD(n, name_i + 1));\n if (!args)\n return NULL;\n if (TYPE(CHILD(n, name_i+2)) == RARROW) {\n returns = ast_for_expr(c, CHILD(n, name_i + 3));\n if (!returns)\n return NULL;\n name_i += 2;\n }\n body = ast_for_suite(c, CHILD(n, name_i + 3));\n if (!body)\n return NULL;\n get_last_end_pos(body, &end_lineno, &end_col_offset);\n\n if (is_async)\n return AsyncFunctionDef(name, args, body, decorator_seq, returns,\n LINENO(n0), n0->n_col_offset, end_lineno, end_col_offset, c->c_arena);\n else\n return FunctionDef(name, args, body, decorator_seq, returns,\n LINENO(n), n->n_col_offset, end_lineno, end_col_offset, c->c_arena);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1803, "func": "ast_for_funcdef_impl(struct compiling *c, const node *n0,\n asdl_seq *decorator_seq, bool is_async)\n{\n /* funcdef: 'def' NAME parameters ['->' test] ':' [TYPE_COMMENT] suite */\n const node * const n = is_async ? CHILD(n0, 1) : n0;\n identifier name;\n arguments_ty args;\n asdl_seq *body;\n expr_ty returns = NULL;\n int name_i = 1;\n int end_lineno, end_col_offset;\n node *tc;\n string type_comment = NULL;\n\n REQ(n, funcdef);\n\n name = NEW_IDENTIFIER(CHILD(n, name_i));\n if (!name)\n return NULL;\n if (forbidden_name(c, name, CHILD(n, name_i), 0))\n return NULL;\n args = ast_for_arguments(c, CHILD(n, name_i + 1));\n if (!args)\n return NULL;\n if (TYPE(CHILD(n, name_i+2)) == RARROW) {\n returns = ast_for_expr(c, CHILD(n, name_i + 3));\n if (!returns)\n return NULL;\n name_i += 2;\n }\n if (TYPE(CHILD(n, name_i + 3)) == TYPE_COMMENT) {\n type_comment = NEW_TYPE_COMMENT(CHILD(n, name_i + 3));\n if (!type_comment)\n return NULL;\n name_i += 1;\n }\n body = ast_for_suite(c, CHILD(n, name_i + 3));\n if (!body)\n return NULL;\n get_last_end_pos(body, &end_lineno, &end_col_offset);\n\n if (NCH(CHILD(n, name_i + 3)) > 1) {\n /* Check if the suite has a type comment in it. */\n tc = CHILD(CHILD(n, name_i + 3), 1);\n\n if (TYPE(tc) == TYPE_COMMENT) {\n if (type_comment != NULL) {\n ast_error(c, n, \"Cannot have two type comments on def\");\n return NULL;\n }\n type_comment = NEW_TYPE_COMMENT(tc);\n if (!type_comment)\n return NULL;\n }\n }\n\n if (is_async)\n return AsyncFunctionDef(name, args, body, decorator_seq, returns, type_comment,\n LINENO(n0), n0->n_col_offset, end_lineno, end_col_offset, c->c_arena);\n else\n return FunctionDef(name, args, body, decorator_seq, returns, type_comment,\n LINENO(n), n->n_col_offset, end_lineno, end_col_offset, c->c_arena);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 201, "func": "zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator;\n\tspl_filesystem_object *dir_object;\n\n\tif (by_ref) {\n\t\tzend_error(E_ERROR, \"An iterator cannot be used with foreach by reference\");\n\t}\n\tdir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);\n\titerator = spl_filesystem_object_to_iterator(dir_object);\n\n\t/* initialize iterator if it wasn't gotten before */\n\tif (iterator->intern.data == NULL) {\n\t\titerator->intern.data = object;\n\t\titerator->intern.funcs = &spl_filesystem_dir_it_funcs;\n\t\t/* ->current must be initialized; rewind doesn't set it and valid\n\t\t * doesn't check whether it's set */\n\t\titerator->current = object;\n\t}\n\tzval_add_ref(&object);\n\t\n\treturn (zend_object_iterator*)iterator;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 201, "func": "zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator;\n\tspl_filesystem_object *dir_object;\n\n\tif (by_ref) {\n\t\tzend_error(E_ERROR, \"An iterator cannot be used with foreach by reference\");\n\t}\n\tdir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);\n\titerator = spl_filesystem_object_to_iterator(dir_object);\n\n\t/* initialize iterator if it wasn't gotten before */\n\tif (iterator->intern.data == NULL) {\n\t\titerator->intern.data = object;\n\t\titerator->intern.funcs = &spl_filesystem_dir_it_funcs;\n\t\t/* ->current must be initialized; rewind doesn't set it and valid\n\t\t * doesn't check whether it's set */\n\t\titerator->current = object;\n\t}\n\tzval_add_ref(&object);\n\n\treturn (zend_object_iterator*)iterator;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 2530, "func": "static int __init xfrm6_tunnel_init(void)\n{\n\tint rv;\n\n\trv = xfrm_register_type(&xfrm6_tunnel_type, AF_INET6);\n\tif (rv < 0)\n\t\tgoto err;\n\trv = xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6);\n\tif (rv < 0)\n\t\tgoto unreg;\n\trv = xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET);\n\tif (rv < 0)\n\t\tgoto dereg6;\n\trv = xfrm6_tunnel_spi_init();\n\tif (rv < 0)\n\t\tgoto dereg46;\n\trv = register_pernet_subsys(&xfrm6_tunnel_net_ops);\n\tif (rv < 0)\n\t\tgoto deregspi;\n\treturn 0;\n\nderegspi:\n\txfrm6_tunnel_spi_fini();\ndereg46:\n\txfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET);\ndereg6:\n\txfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);\nunreg:\n\txfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);\nerr:\n\treturn rv;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 2530, "func": "static int __init xfrm6_tunnel_init(void)\n{\n\tint rv;\n\n\txfrm6_tunnel_spi_kmem = kmem_cache_create(\"xfrm6_tunnel_spi\",\n\t\t\t\t\t\t sizeof(struct xfrm6_tunnel_spi),\n\t\t\t\t\t\t 0, SLAB_HWCACHE_ALIGN,\n\t\t\t\t\t\t NULL);\n\tif (!xfrm6_tunnel_spi_kmem)\n\t\treturn -ENOMEM;\n\trv = register_pernet_subsys(&xfrm6_tunnel_net_ops);\n\tif (rv < 0)\n\t\tgoto out_pernet;\n\trv = xfrm_register_type(&xfrm6_tunnel_type, AF_INET6);\n\tif (rv < 0)\n\t\tgoto out_type;\n\trv = xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6);\n\tif (rv < 0)\n\t\tgoto out_xfrm6;\n\trv = xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET);\n\tif (rv < 0)\n\t\tgoto out_xfrm46;\n\treturn 0;\n\nout_xfrm46:\n\txfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);\nout_xfrm6:\n\txfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);\nout_type:\n\tunregister_pernet_subsys(&xfrm6_tunnel_net_ops);\nout_pernet:\n\tkmem_cache_destroy(xfrm6_tunnel_spi_kmem);\n\treturn rv;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 3180, "func": "static int jpc_pi_nextcprl(register jpc_pi_t *pi)\n{\n\tint rlvlno;\n\tjpc_pirlvl_t *pirlvl;\n\tjpc_pchg_t *pchg;\n\tint prchind;\n\tint prcvind;\n\tint *prclyrno;\n\tuint_fast32_t trx0;\n\tuint_fast32_t try0;\n\tuint_fast32_t r;\n\tuint_fast32_t rpx;\n\tuint_fast32_t rpy;\n\n\tpchg = pi->pchg;\n\tif (!pi->prgvolfirst) {\n\t\tgoto skip;\n\t} else {\n\t\tpi->prgvolfirst = 0;\n\t}\n\n\tfor (pi->compno = pchg->compnostart, pi->picomp =\n\t &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno,\n\t ++pi->picomp) {\n\t\tpirlvl = pi->picomp->pirlvls;\n\t\tpi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn +\n\t\t pi->picomp->numrlvls - 1));\n\t\tpi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn +\n\t\t pi->picomp->numrlvls - 1));\n\t\tfor (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1];\n\t\t rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) {\n\t\t\tpi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 <<\n\t\t\t (pirlvl->prcwidthexpn + pi->picomp->numrlvls -\n\t\t\t rlvlno - 1)));\n\t\t\tpi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 <<\n\t\t\t (pirlvl->prcheightexpn + pi->picomp->numrlvls -\n\t\t\t rlvlno - 1)));\n\t\t}\n\t\tfor (pi->y = pi->ystart; pi->y < pi->yend;\n\t\t pi->y += pi->ystep - (pi->y % pi->ystep)) {\n\t\t\tfor (pi->x = pi->xstart; pi->x < pi->xend;\n\t\t\t pi->x += pi->xstep - (pi->x % pi->xstep)) {\n\t\t\t\tfor (pi->rlvlno = pchg->rlvlnostart,\n\t\t\t\t pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];\n\t\t\t\t pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno <\n\t\t\t\t pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) {\n\t\t\t\t\tif (pi->pirlvl->numprcs == 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tr = pi->picomp->numrlvls - 1 - pi->rlvlno;\n\t\t\t\t\ttrx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);\n\t\t\t\t\ttry0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);\n\t\t\t\t\trpx = r + pi->pirlvl->prcwidthexpn;\n\t\t\t\t\trpy = r + pi->pirlvl->prcheightexpn;\n\t\t\t\t\tif (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||\n\t\t\t\t\t !(pi->x % (pi->picomp->hsamp << rpx))) &&\n\t\t\t\t\t ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||\n\t\t\t\t\t !(pi->y % (pi->picomp->vsamp << rpy)))) {\n\t\t\t\t\t\tprchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,\n\t\t\t\t\t\t pi->pirlvl->prcwidthexpn);\n\t\t\t\t\t\tprcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,\n\t\t\t\t\t\t pi->pirlvl->prcheightexpn);\n\t\t\t\t\t\tpi->prcno = prcvind *\n\t\t\t\t\t\t pi->pirlvl->numhprcs +\n\t\t\t\t\t\t prchind;\n\t\t\t\t\t\tassert(pi->prcno <\n\t\t\t\t\t\t pi->pirlvl->numprcs);\n\t\t\t\t\t\tfor (pi->lyrno = 0; pi->lyrno <\n\t\t\t\t\t\t pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) {\n\t\t\t\t\t\t\tprclyrno = &pi->pirlvl->prclyrnos[pi->prcno];\n\t\t\t\t\t\t\tif (pi->lyrno >= *prclyrno) {\n\t\t\t\t\t\t\t\t++(*prclyrno);\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\nskip:\n\t\t\t\t\t\t\t;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10251", "cwe_id": "CWE-190" }, { "id": 3180, "func": "static int jpc_pi_nextcprl(register jpc_pi_t *pi)\n{\n\tint rlvlno;\n\tjpc_pirlvl_t *pirlvl;\n\tjpc_pchg_t *pchg;\n\tint prchind;\n\tint prcvind;\n\tint *prclyrno;\n\tuint_fast32_t trx0;\n\tuint_fast32_t try0;\n\tuint_fast32_t r;\n\tuint_fast32_t rpx;\n\tuint_fast32_t rpy;\n\n\tpchg = pi->pchg;\n\tif (!pi->prgvolfirst) {\n\t\tgoto skip;\n\t} else {\n\t\tpi->prgvolfirst = 0;\n\t}\n\n\tfor (pi->compno = pchg->compnostart, pi->picomp =\n\t &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno,\n\t ++pi->picomp) {\n\t\tpirlvl = pi->picomp->pirlvls;\n\t\tpi->xstep = pi->picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) <<\n\t\t (pirlvl->prcwidthexpn + pi->picomp->numrlvls - 1));\n\t\tpi->ystep = pi->picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) <<\n\t\t (pirlvl->prcheightexpn + pi->picomp->numrlvls - 1));\n\t\tfor (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1];\n\t\t rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) {\n\t\t\tpi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp *\n\t\t\t (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcwidthexpn +\n\t\t\t pi->picomp->numrlvls - rlvlno - 1)));\n\t\t\tpi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp *\n\t\t\t (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcheightexpn +\n\t\t\t pi->picomp->numrlvls - rlvlno - 1)));\n\t\t}\n\t\tfor (pi->y = pi->ystart; pi->y < pi->yend;\n\t\t pi->y += pi->ystep - (pi->y % pi->ystep)) {\n\t\t\tfor (pi->x = pi->xstart; pi->x < pi->xend;\n\t\t\t pi->x += pi->xstep - (pi->x % pi->xstep)) {\n\t\t\t\tfor (pi->rlvlno = pchg->rlvlnostart,\n\t\t\t\t pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];\n\t\t\t\t pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno <\n\t\t\t\t pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) {\n\t\t\t\t\tif (pi->pirlvl->numprcs == 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tr = pi->picomp->numrlvls - 1 - pi->rlvlno;\n\t\t\t\t\ttrx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);\n\t\t\t\t\ttry0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);\n\t\t\t\t\trpx = r + pi->pirlvl->prcwidthexpn;\n\t\t\t\t\trpy = r + pi->pirlvl->prcheightexpn;\n\t\t\t\t\tif (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||\n\t\t\t\t\t !(pi->x % (pi->picomp->hsamp << rpx))) &&\n\t\t\t\t\t ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||\n\t\t\t\t\t !(pi->y % (pi->picomp->vsamp << rpy)))) {\n\t\t\t\t\t\tprchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,\n\t\t\t\t\t\t pi->pirlvl->prcwidthexpn);\n\t\t\t\t\t\tprcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,\n\t\t\t\t\t\t pi->pirlvl->prcheightexpn);\n\t\t\t\t\t\tpi->prcno = prcvind *\n\t\t\t\t\t\t pi->pirlvl->numhprcs +\n\t\t\t\t\t\t prchind;\n\t\t\t\t\t\tassert(pi->prcno <\n\t\t\t\t\t\t pi->pirlvl->numprcs);\n\t\t\t\t\t\tfor (pi->lyrno = 0; pi->lyrno <\n\t\t\t\t\t\t pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) {\n\t\t\t\t\t\t\tprclyrno = &pi->pirlvl->prclyrnos[pi->prcno];\n\t\t\t\t\t\t\tif (pi->lyrno >= *prclyrno) {\n\t\t\t\t\t\t\t\t++(*prclyrno);\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\nskip:\n\t\t\t\t\t\t\t;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10251", "cwe_id": "CWE-190" }, { "id": 1557, "func": "find_file (const char *currpath, grub_fshelp_node_t currroot,\n\t grub_fshelp_node_t *currfound,\n\t struct grub_fshelp_find_file_closure *c)\n{\n#ifndef _MSC_VER\n\tchar fpath[grub_strlen (currpath) + 1];\n#else\n\tchar *fpath = grub_malloc (grub_strlen (currpath) + 1);\n#endif\n char *name = fpath;\n char *next;\n enum grub_fshelp_filetype type = GRUB_FSHELP_DIR;\n grub_fshelp_node_t currnode = currroot;\n grub_fshelp_node_t oldnode = currroot;\n\n c->currroot = currroot;\n\n grub_strncpy (fpath, currpath, grub_strlen (currpath) + 1);\n\n /* Remove all leading slashes. */\n while (*name == '/')\n name++;\n\n if (! *name)\n {\n *currfound = currnode;\n return 0;\n }\n\n for (;;)\n {\n int found;\n struct find_file_closure cc;\n\n /* Extract the actual part from the pathname. */\n next = grub_strchr (name, '/');\n if (next)\n\t{\n\t /* Remove all leading slashes. */\n\t while (*next == '/')\n\t *(next++) = '\\0';\n\t}\n\n /* At this point it is expected that the current node is a\n\t directory, check if this is true. */\n if (type != GRUB_FSHELP_DIR)\n\t{\n\t free_node (currnode, c);\n\t return grub_error (GRUB_ERR_BAD_FILE_TYPE, \"not a directory\");\n\t}\n\n cc.name = name;\n cc.type = &type;\n cc.oldnode = &oldnode;\n cc.currnode = &currnode;\n /* Iterate over the directory. */\n found = c->iterate_dir (currnode, iterate, &cc);\n if (! found)\n\t{\n\t if (grub_errno)\n\t return grub_errno;\n\n\t break;\n\t}\n\n /* Read in the symlink and follow it. */\n if (type == GRUB_FSHELP_SYMLINK)\n\t{\n\t char *symlink;\n\n\t /* Test if the symlink does not loop. */\n\t if (++(c->symlinknest) == 8)\n\t {\n\t free_node (currnode, c);\n\t free_node (oldnode, c);\n\t return grub_error (GRUB_ERR_SYMLINK_LOOP,\n\t\t\t\t \"too deep nesting of symlinks\");\n\t }\n\n\t symlink = c->read_symlink (currnode);\n\t free_node (currnode, c);\n\n\t if (!symlink)\n\t {\n\t free_node (oldnode, c);\n\t return grub_errno;\n\t }\n\n\t /* The symlink is an absolute path, go back to the root inode. */\n\t if (symlink[0] == '/')\n\t {\n\t free_node (oldnode, c);\n\t oldnode = c->rootnode;\n\t }\n\n\t /* Lookup the node the symlink points to. */\n\t find_file (symlink, oldnode, &currnode, c);\n\t type = c->foundtype;\n\t grub_free (symlink);\n\n\t if (grub_errno)\n\t {\n\t free_node (oldnode, c);\n\t return grub_errno;\n\t }\n\t}\n\n free_node (oldnode, c);\n\n /* Found the node! */\n if (! next || *next == '\\0')\n\t{\n\t *currfound = currnode;\n\t c->foundtype = type;\n\t return 0;\n\t}\n\n name = next;\n }\n\n return grub_error (GRUB_ERR_FILE_NOT_FOUND, \"file not found\");\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9763", "cwe_id": "CWE-119" }, { "id": 1557, "func": "find_file (const char *currpath, grub_fshelp_node_t currroot,\n\t grub_fshelp_node_t *currfound,\n\t struct grub_fshelp_find_file_closure *c)\n{\n\tchar *fpath = grub_malloc (grub_strlen (currpath) + 1);\n char *name = fpath;\n char *next;\n enum grub_fshelp_filetype type = GRUB_FSHELP_DIR;\n grub_fshelp_node_t currnode = currroot;\n grub_fshelp_node_t oldnode = currroot;\n\n c->currroot = currroot;\n\n grub_strncpy (fpath, currpath, grub_strlen (currpath) + 1);\n\n /* Remove all leading slashes. */\n while (*name == '/')\n name++;\n\n if (! *name)\n {\n *currfound = currnode;\nfree (fpath);\n return 0;\n }\n\n for (;;)\n {\n int found;\n struct find_file_closure cc;\n\n /* Extract the actual part from the pathname. */\n next = grub_strchr (name, '/');\n if (next)\n\t{\n\t /* Remove all leading slashes. */\n\t while (*next == '/')\n\t *(next++) = '\\0';\n\t}\n\n /* At this point it is expected that the current node is a\n\t directory, check if this is true. */\n if (type != GRUB_FSHELP_DIR)\n\t{\n\t free_node (currnode, c);\nfree (fpath);\n\t return grub_error (GRUB_ERR_BAD_FILE_TYPE, \"not a directory\");\n\t}\n\n cc.name = name;\n cc.type = &type;\n cc.oldnode = &oldnode;\n cc.currnode = &currnode;\n /* Iterate over the directory. */\n found = c->iterate_dir (currnode, iterate, &cc);\n if (! found)\n\t{\n\t if (grub_errno) {\nfree (fpath);\n\t return grub_errno;\n}\n\n\t break;\n\t}\n\n /* Read in the symlink and follow it. */\n if (type == GRUB_FSHELP_SYMLINK)\n\t{\n\t char *symlink;\n\n\t /* Test if the symlink does not loop. */\n\t if (++(c->symlinknest) == 8)\n\t {\n\t free_node (currnode, c);\n\t free_node (oldnode, c);\nfree (fpath);\n\t return grub_error (GRUB_ERR_SYMLINK_LOOP,\n\t\t\t\t \"too deep nesting of symlinks\");\n\t }\n\n\t symlink = c->read_symlink (currnode);\n\t free_node (currnode, c);\n\n\t if (!symlink)\n\t {\n\t free_node (oldnode, c);\nfree (fpath);\n\t return grub_errno;\n\t }\n\n\t /* The symlink is an absolute path, go back to the root inode. */\n\t if (symlink[0] == '/')\n\t {\n\t free_node (oldnode, c);\n\t oldnode = c->rootnode;\n\t }\n\n\t /* Lookup the node the symlink points to. */\n\t find_file (symlink, oldnode, &currnode, c);\n\t type = c->foundtype;\n\t grub_free (symlink);\n\n\t if (grub_errno)\n\t {\n\t free_node (oldnode, c);\nfree (fpath);\n\t return grub_errno;\n\t }\n\t}\n\n free_node (oldnode, c);\n\n /* Found the node! */\n if (! next || *next == '\\0')\n\t{\n\t *currfound = currnode;\n\t c->foundtype = type;\nfree (fpath);\n\t return 0;\n\t}\n\n name = next;\n }\n\nfree (fpath);\n return grub_error (GRUB_ERR_FILE_NOT_FOUND, \"file not found\");\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9763", "cwe_id": "CWE-119" }, { "id": 1048, "func": "TEE_Result syscall_asymm_verify(unsigned long state,\n\t\t\tconst struct utee_attribute *usr_params,\n\t\t\tsize_t num_params, const void *data, size_t data_len,\n\t\t\tconst void *sig, size_t sig_len)\n{\n\tTEE_Result res;\n\tstruct tee_cryp_state *cs;\n\tstruct tee_ta_session *sess;\n\tstruct tee_obj *o;\n\tsize_t hash_size;\n\tint salt_len = 0;\n\tTEE_Attribute *params = NULL;\n\tuint32_t hash_algo;\n\tstruct user_ta_ctx *utc;\n\n\tres = tee_ta_get_current_session(&sess);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\tutc = to_user_ta_ctx(sess->ctx);\n\n\tres = tee_svc_cryp_get_state(sess, tee_svc_uref_to_vaddr(state), &cs);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tif (cs->mode != TEE_MODE_VERIFY)\n\t\treturn TEE_ERROR_BAD_PARAMETERS;\n\n\tres = tee_mmu_check_access_rights(utc,\n\t\t\t\t\t TEE_MEMORY_ACCESS_READ |\n\t\t\t\t\t TEE_MEMORY_ACCESS_ANY_OWNER,\n\t\t\t\t\t (uaddr_t)data, data_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_mmu_check_access_rights(utc,\n\t\t\t\t\t TEE_MEMORY_ACCESS_READ |\n\t\t\t\t\t TEE_MEMORY_ACCESS_ANY_OWNER,\n\t\t\t\t\t (uaddr_t)sig, sig_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tparams = malloc(sizeof(TEE_Attribute) * num_params);\n\tif (!params)\n\t\treturn TEE_ERROR_OUT_OF_MEMORY;\n\tres = copy_in_attrs(utc, usr_params, num_params, params);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\n\tres = tee_obj_get(utc, cs->key1, &o);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\tif ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) == 0) {\n\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\tgoto out;\n\t}\n\n\tswitch (TEE_ALG_GET_MAIN_ALG(cs->algo)) {\n\tcase TEE_MAIN_ALGO_RSA:\n\t\tif (cs->algo != TEE_ALG_RSASSA_PKCS1_V1_5) {\n\t\t\thash_algo = TEE_DIGEST_HASH_TO_ALGO(cs->algo);\n\t\t\tres = tee_hash_get_digest_size(hash_algo, &hash_size);\n\t\t\tif (res != TEE_SUCCESS)\n\t\t\t\tbreak;\n\t\t\tif (data_len != hash_size) {\n\t\t\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsalt_len = pkcs1_get_salt_len(params, num_params,\n\t\t\t\t\t\t hash_size);\n\t\t}\n\t\tres = crypto_acipher_rsassa_verify(cs->algo, o->attr, salt_len,\n\t\t\t\t\t\t data, data_len, sig,\n\t\t\t\t\t\t sig_len);\n\t\tbreak;\n\n\tcase TEE_MAIN_ALGO_DSA:\n\t\thash_algo = TEE_DIGEST_HASH_TO_ALGO(cs->algo);\n\t\tres = tee_hash_get_digest_size(hash_algo, &hash_size);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tbreak;\n\t\t/*\n\t\t * Depending on the DSA algorithm (NIST), the digital signature\n\t\t * output size may be truncated to the size of a key pair\n\t\t * (Q prime size). Q prime size must be less or equal than the\n\t\t * hash output length of the hash algorithm involved.\n\t\t */\n\t\tif (data_len > hash_size) {\n\t\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\t\tbreak;\n\t\t}\n\t\tres = crypto_acipher_dsa_verify(cs->algo, o->attr, data,\n\t\t\t\t\t\tdata_len, sig, sig_len);\n\t\tbreak;\n\n\tcase TEE_MAIN_ALGO_ECDSA:\n\t\tres = crypto_acipher_ecc_verify(cs->algo, o->attr, data,\n\t\t\t\t\t\tdata_len, sig, sig_len);\n\t\tbreak;\n\n\tdefault:\n\t\tres = TEE_ERROR_NOT_SUPPORTED;\n\t}\n\nout:\n\tfree(params);\n\treturn res;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-1010298", "cwe_id": "CWE-787" }, { "id": 1048, "func": "TEE_Result syscall_asymm_verify(unsigned long state,\n\t\t\tconst struct utee_attribute *usr_params,\n\t\t\tsize_t num_params, const void *data, size_t data_len,\n\t\t\tconst void *sig, size_t sig_len)\n{\n\tTEE_Result res;\n\tstruct tee_cryp_state *cs;\n\tstruct tee_ta_session *sess;\n\tstruct tee_obj *o;\n\tsize_t hash_size;\n\tint salt_len = 0;\n\tTEE_Attribute *params = NULL;\n\tuint32_t hash_algo;\n\tstruct user_ta_ctx *utc;\n\n\tres = tee_ta_get_current_session(&sess);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\tutc = to_user_ta_ctx(sess->ctx);\n\n\tres = tee_svc_cryp_get_state(sess, tee_svc_uref_to_vaddr(state), &cs);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tif (cs->mode != TEE_MODE_VERIFY)\n\t\treturn TEE_ERROR_BAD_PARAMETERS;\n\n\tres = tee_mmu_check_access_rights(utc,\n\t\t\t\t\t TEE_MEMORY_ACCESS_READ |\n\t\t\t\t\t TEE_MEMORY_ACCESS_ANY_OWNER,\n\t\t\t\t\t (uaddr_t)data, data_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_mmu_check_access_rights(utc,\n\t\t\t\t\t TEE_MEMORY_ACCESS_READ |\n\t\t\t\t\t TEE_MEMORY_ACCESS_ANY_OWNER,\n\t\t\t\t\t (uaddr_t)sig, sig_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tsize_t alloc_size = 0;\n\n\tif (MUL_OVERFLOW(sizeof(TEE_Attribute), num_params, &alloc_size))\n\t\treturn TEE_ERROR_OVERFLOW;\n\n\tparams = malloc(alloc_size);\n\tif (!params)\n\t\treturn TEE_ERROR_OUT_OF_MEMORY;\n\tres = copy_in_attrs(utc, usr_params, num_params, params);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\n\tres = tee_obj_get(utc, cs->key1, &o);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\tif ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) == 0) {\n\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\tgoto out;\n\t}\n\n\tswitch (TEE_ALG_GET_MAIN_ALG(cs->algo)) {\n\tcase TEE_MAIN_ALGO_RSA:\n\t\tif (cs->algo != TEE_ALG_RSASSA_PKCS1_V1_5) {\n\t\t\thash_algo = TEE_DIGEST_HASH_TO_ALGO(cs->algo);\n\t\t\tres = tee_hash_get_digest_size(hash_algo, &hash_size);\n\t\t\tif (res != TEE_SUCCESS)\n\t\t\t\tbreak;\n\t\t\tif (data_len != hash_size) {\n\t\t\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsalt_len = pkcs1_get_salt_len(params, num_params,\n\t\t\t\t\t\t hash_size);\n\t\t}\n\t\tres = crypto_acipher_rsassa_verify(cs->algo, o->attr, salt_len,\n\t\t\t\t\t\t data, data_len, sig,\n\t\t\t\t\t\t sig_len);\n\t\tbreak;\n\n\tcase TEE_MAIN_ALGO_DSA:\n\t\thash_algo = TEE_DIGEST_HASH_TO_ALGO(cs->algo);\n\t\tres = tee_hash_get_digest_size(hash_algo, &hash_size);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tbreak;\n\t\t/*\n\t\t * Depending on the DSA algorithm (NIST), the digital signature\n\t\t * output size may be truncated to the size of a key pair\n\t\t * (Q prime size). Q prime size must be less or equal than the\n\t\t * hash output length of the hash algorithm involved.\n\t\t */\n\t\tif (data_len > hash_size) {\n\t\t\tres = TEE_ERROR_BAD_PARAMETERS;\n\t\t\tbreak;\n\t\t}\n\t\tres = crypto_acipher_dsa_verify(cs->algo, o->attr, data,\n\t\t\t\t\t\tdata_len, sig, sig_len);\n\t\tbreak;\n\n\tcase TEE_MAIN_ALGO_ECDSA:\n\t\tres = crypto_acipher_ecc_verify(cs->algo, o->attr, data,\n\t\t\t\t\t\tdata_len, sig, sig_len);\n\t\tbreak;\n\n\tdefault:\n\t\tres = TEE_ERROR_NOT_SUPPORTED;\n\t}\n\nout:\n\tfree(params);\n\treturn res;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-1010298", "cwe_id": "CWE-787" }, { "id": 2303, "func": "static struct dst_entry *ip6_sk_dst_check(struct sock *sk,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t const struct flowi6 *fl6)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct rt6_info *rt = (struct rt6_info *)dst;\n\n\tif (!dst)\n\t\tgoto out;\n\n\t/* Yes, checking route validity in not connected\n\t * case is not very simple. Take into account,\n\t * that we do not support routing by source, TOS,\n\t * and MSG_DONTROUTE \t\t--ANK (980726)\n\t *\n\t * 1. ip6_rt_check(): If route was host route,\n\t * check that cached destination is current.\n\t * If it is network route, we still may\n\t * check its validity using saved pointer\n\t * to the last used address: daddr_cache.\n\t * We do not want to save whole address now,\n\t * (because main consumer of this service\n\t * is tcp, which has not this problem),\n\t * so that the last trick works only on connected\n\t * sockets.\n\t * 2. oif also should be the same.\n\t */\n\tif (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) ||\n#ifdef CONFIG_IPV6_SUBTREES\n\t ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) ||\n#endif\n\t (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) {\n\t\tdst_release(dst);\n\t\tdst = NULL;\n\t}\n\nout:\n\treturn dst;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-2232", "cwe_id": "CWE-20" }, { "id": 2303, "func": "static struct dst_entry *ip6_sk_dst_check(struct sock *sk,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t const struct flowi6 *fl6)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct rt6_info *rt;\n\n\tif (!dst)\n\t\tgoto out;\n\n\tif (dst->ops->family != AF_INET6) {\n\t\tdst_release(dst);\n\t\treturn NULL;\n\t}\n\n\trt = (struct rt6_info *)dst;\n\t/* Yes, checking route validity in not connected\n\t * case is not very simple. Take into account,\n\t * that we do not support routing by source, TOS,\n\t * and MSG_DONTROUTE \t\t--ANK (980726)\n\t *\n\t * 1. ip6_rt_check(): If route was host route,\n\t * check that cached destination is current.\n\t * If it is network route, we still may\n\t * check its validity using saved pointer\n\t * to the last used address: daddr_cache.\n\t * We do not want to save whole address now,\n\t * (because main consumer of this service\n\t * is tcp, which has not this problem),\n\t * so that the last trick works only on connected\n\t * sockets.\n\t * 2. oif also should be the same.\n\t */\n\tif (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) ||\n#ifdef CONFIG_IPV6_SUBTREES\n\t ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) ||\n#endif\n\t (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) {\n\t\tdst_release(dst);\n\t\tdst = NULL;\n\t}\n\nout:\n\treturn dst;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-2232", "cwe_id": "CWE-20" }, { "id": 1033, "func": "reg_match_visual(void)\n{\n pos_T\ttop, bot;\n linenr_T lnum;\n colnr_T\tcol;\n win_T\t*wp = rex.reg_win == NULL ? curwin : rex.reg_win;\n int\t\tmode;\n colnr_T\tstart, end;\n colnr_T\tstart2, end2;\n colnr_T\tcols;\n colnr_T\tcurswant;\n\n // Check if the buffer is the current buffer.\n if (rex.reg_buf != curbuf || VIsual.lnum == 0)\n\treturn FALSE;\n\n if (VIsual_active)\n {\n\tif (LT_POS(VIsual, wp->w_cursor))\n\t{\n\t top = VIsual;\n\t bot = wp->w_cursor;\n\t}\n\telse\n\t{\n\t top = wp->w_cursor;\n\t bot = VIsual;\n\t}\n\tmode = VIsual_mode;\n\tcurswant = wp->w_curswant;\n }\n else\n {\n\tif (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))\n\t{\n\t top = curbuf->b_visual.vi_start;\n\t bot = curbuf->b_visual.vi_end;\n\t}\n\telse\n\t{\n\t top = curbuf->b_visual.vi_end;\n\t bot = curbuf->b_visual.vi_start;\n\t}\n\tmode = curbuf->b_visual.vi_mode;\n\tcurswant = curbuf->b_visual.vi_curswant;\n }\n lnum = rex.lnum + rex.reg_firstlnum;\n if (lnum < top.lnum || lnum > bot.lnum)\n\treturn FALSE;\n\n if (mode == 'v')\n {\n\tcol = (colnr_T)(rex.input - rex.line);\n\tif ((lnum == top.lnum && col < top.col)\n\t\t|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))\n\t return FALSE;\n }\n else if (mode == Ctrl_V)\n {\n\tgetvvcol(wp, &top, &start, NULL, &end);\n\tgetvvcol(wp, &bot, &start2, NULL, &end2);\n\tif (start2 < start)\n\t start = start2;\n\tif (end2 > end)\n\t end = end2;\n\tif (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)\n\t end = MAXCOL;\n\tcols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));\n\tif (cols < start || cols > end - (*p_sel == 'e'))\n\t return FALSE;\n }\n return TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-4192", "cwe_id": "CWE-416" }, { "id": 1033, "func": "reg_match_visual(void)\n{\n pos_T\ttop, bot;\n linenr_T lnum;\n colnr_T\tcol;\n win_T\t*wp = rex.reg_win == NULL ? curwin : rex.reg_win;\n int\t\tmode;\n colnr_T\tstart, end;\n colnr_T\tstart2, end2;\n colnr_T\tcols;\n colnr_T\tcurswant;\n\n // Check if the buffer is the current buffer.\n if (rex.reg_buf != curbuf || VIsual.lnum == 0)\n\treturn FALSE;\n\n if (VIsual_active)\n {\n\tif (LT_POS(VIsual, wp->w_cursor))\n\t{\n\t top = VIsual;\n\t bot = wp->w_cursor;\n\t}\n\telse\n\t{\n\t top = wp->w_cursor;\n\t bot = VIsual;\n\t}\n\tmode = VIsual_mode;\n\tcurswant = wp->w_curswant;\n }\n else\n {\n\tif (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))\n\t{\n\t top = curbuf->b_visual.vi_start;\n\t bot = curbuf->b_visual.vi_end;\n\t}\n\telse\n\t{\n\t top = curbuf->b_visual.vi_end;\n\t bot = curbuf->b_visual.vi_start;\n\t}\n\tmode = curbuf->b_visual.vi_mode;\n\tcurswant = curbuf->b_visual.vi_curswant;\n }\n lnum = rex.lnum + rex.reg_firstlnum;\n if (lnum < top.lnum || lnum > bot.lnum)\n\treturn FALSE;\n\n col = (colnr_T)(rex.input - rex.line);\n if (mode == 'v')\n {\n\tif ((lnum == top.lnum && col < top.col)\n\t\t|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))\n\t return FALSE;\n }\n else if (mode == Ctrl_V)\n {\n\tgetvvcol(wp, &top, &start, NULL, &end);\n\tgetvvcol(wp, &bot, &start2, NULL, &end2);\n\tif (start2 < start)\n\t start = start2;\n\tif (end2 > end)\n\t end = end2;\n\tif (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)\n\t end = MAXCOL;\n\n\t// getvvcol() flushes rex.line, need to get it again\n\trex.line = reg_getline(rex.lnum);\n\trex.input = rex.line + col;\n\n\tcols = win_linetabsize(wp, rex.line, col);\n\tif (cols < start || cols > end - (*p_sel == 'e'))\n\t return FALSE;\n }\n return TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-4192", "cwe_id": "CWE-416" }, { "id": 2313, "func": " void Compute(OpKernelContext* context) override {\n const Tensor& input = context->input(0);\n const float input_min = context->input(1).flat()(0);\n const float input_max = context->input(2).flat()(0);\n const Tensor& mean = context->input(3);\n const float mean_min = context->input(4).flat()(0);\n const float mean_max = context->input(5).flat()(0);\n const Tensor& var = context->input(6);\n const float var_min = context->input(7).flat()(0);\n const float var_max = context->input(8).flat()(0);\n const Tensor& beta = context->input(9);\n const float beta_min = context->input(10).flat()(0);\n const float beta_max = context->input(11).flat()(0);\n const Tensor& gamma = context->input(12);\n const float gamma_min = context->input(13).flat()(0);\n const float gamma_max = context->input(14).flat()(0);\n\n OP_REQUIRES(context, input.dims() == 4,\n errors::InvalidArgument(\"input must be 4-dimensional\",\n input.shape().DebugString()));\n OP_REQUIRES(context, mean.dims() == 1,\n errors::InvalidArgument(\"mean must be 1-dimensional\",\n mean.shape().DebugString()));\n OP_REQUIRES(context, var.dims() == 1,\n errors::InvalidArgument(\"var must be 1-dimensional\",\n var.shape().DebugString()));\n OP_REQUIRES(context, beta.dims() == 1,\n errors::InvalidArgument(\"beta must be 1-dimensional\",\n beta.shape().DebugString()));\n OP_REQUIRES(context, gamma.dims() == 1,\n errors::InvalidArgument(\"gamma must be 1-dimensional\",\n gamma.shape().DebugString()));\n\n Tensor* output = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(0, input.shape(), &output));\n float output_min;\n float output_max;\n FixedPointBatchNorm(input, input_min, input_max, mean, mean_min,\n mean_max, var, var_min, var_max, beta, beta_min,\n beta_max, gamma, gamma_min, gamma_max,\n variance_epsilon_, scale_after_normalization_,\n output, &output_min, &output_max);\n\n Tensor* output_min_tensor = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(1, {}, &output_min_tensor));\n output_min_tensor->flat()(0) = output_min;\n\n Tensor* output_max_tensor = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(2, {}, &output_max_tensor));\n output_max_tensor->flat()(0) = output_max;\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29547", "cwe_id": "CWE-125" }, { "id": 2313, "func": " void Compute(OpKernelContext* context) override {\n const Tensor& input = context->input(0);\n const auto& input_min_tensor = context->input(1);\n OP_REQUIRES(context, input_min_tensor.NumElements() == 1,\n errors::InvalidArgument(\"input_min must have 1 element\"));\n const float input_min = input_min_tensor.flat()(0);\n const auto& input_max_tensor = context->input(2);\n OP_REQUIRES(context, input_max_tensor.NumElements() == 1,\n errors::InvalidArgument(\"input_max must have 1 element\"));\n const float input_max = input_max_tensor.flat()(0);\n const Tensor& mean = context->input(3);\n const auto& mean_min_tensor = context->input(4);\n OP_REQUIRES(context, mean_min_tensor.NumElements() == 1,\n errors::InvalidArgument(\"mean_min must have 1 element\"));\n const float mean_min = mean_min_tensor.flat()(0);\n const auto& mean_max_tensor = context->input(5);\n OP_REQUIRES(context, mean_max_tensor.NumElements() == 1,\n errors::InvalidArgument(\"mean_max must have 1 element\"));\n const float mean_max = mean_max_tensor.flat()(0);\n const Tensor& var = context->input(6);\n const auto& var_min_tensor = context->input(7);\n OP_REQUIRES(context, var_min_tensor.NumElements() == 1,\n errors::InvalidArgument(\"var_min must have 1 element\"));\n const float var_min = var_min_tensor.flat()(0);\n const auto& var_max_tensor = context->input(8);\n OP_REQUIRES(context, var_max_tensor.NumElements() == 1,\n errors::InvalidArgument(\"var_max must have 1 element\"));\n const float var_max = var_max_tensor.flat()(0);\n const Tensor& beta = context->input(9);\n const auto& beta_min_tensor = context->input(10);\n OP_REQUIRES(context, beta_min_tensor.NumElements() == 1,\n errors::InvalidArgument(\"beta_min must have 1 element\"));\n const float beta_min = beta_min_tensor.flat()(0);\n const auto& beta_max_tensor = context->input(11);\n OP_REQUIRES(context, beta_max_tensor.NumElements() == 1,\n errors::InvalidArgument(\"beta_max must have 1 element\"));\n const float beta_max = beta_max_tensor.flat()(0);\n const Tensor& gamma = context->input(12);\n const auto& gamma_min_tensor = context->input(13);\n OP_REQUIRES(context, gamma_min_tensor.NumElements() == 1,\n errors::InvalidArgument(\"gamma_min must have 1 element\"));\n const float gamma_min = gamma_min_tensor.flat()(0);\n const auto& gamma_max_tensor = context->input(14);\n OP_REQUIRES(context, gamma_max_tensor.NumElements() == 1,\n errors::InvalidArgument(\"gamma_max must have 1 element\"));\n const float gamma_max = gamma_max_tensor.flat()(0);\n\n OP_REQUIRES(context, input.dims() == 4,\n errors::InvalidArgument(\"input must be 4-dimensional\",\n input.shape().DebugString()));\n OP_REQUIRES(context, mean.dims() == 1,\n errors::InvalidArgument(\"mean must be 1-dimensional\",\n mean.shape().DebugString()));\n OP_REQUIRES(context, var.dims() == 1,\n errors::InvalidArgument(\"var must be 1-dimensional\",\n var.shape().DebugString()));\n OP_REQUIRES(context, beta.dims() == 1,\n errors::InvalidArgument(\"beta must be 1-dimensional\",\n beta.shape().DebugString()));\n OP_REQUIRES(context, gamma.dims() == 1,\n errors::InvalidArgument(\"gamma must be 1-dimensional\",\n gamma.shape().DebugString()));\n OP_REQUIRES(context, mean.NumElements() > 1,\n errors::InvalidArgument(\"Must have at least a mean value\",\n gamma.shape().DebugString()));\n OP_REQUIRES(context, mean.NumElements() > 1,\n errors::InvalidArgument(\"Must have at least a mean value\"));\n const auto last_dim = input.shape().dims() - 1;\n OP_REQUIRES(context,\n mean.shape().dim_size(0) == input.shape().dim_size(last_dim),\n errors::InvalidArgument(\"Must provide as many means as the \"\n \"last dimension of the input tensor: \",\n mean.shape().DebugString(), \" vs. \",\n input.shape().DebugString()));\n OP_REQUIRES(\n context, mean.shape().dim_size(0) == var.shape().dim_size(0),\n errors::InvalidArgument(\n \"Mean and variance tensors must have the same shape: \",\n mean.shape().DebugString(), \" vs. \", var.shape().DebugString()));\n OP_REQUIRES(\n context, mean.shape().dim_size(0) == beta.shape().dim_size(0),\n errors::InvalidArgument(\n \"Mean and beta tensors must have the same shape: \",\n mean.shape().DebugString(), \" vs. \", beta.shape().DebugString()));\n OP_REQUIRES(\n context, mean.shape().dim_size(0) == gamma.shape().dim_size(0),\n errors::InvalidArgument(\n \"Mean and gamma tensors must have the same shape: \",\n mean.shape().DebugString(), \" vs. \", gamma.shape().DebugString()));\n\n Tensor* output = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(0, input.shape(), &output));\n float output_min;\n float output_max;\n FixedPointBatchNorm(input, input_min, input_max, mean, mean_min,\n mean_max, var, var_min, var_max, beta, beta_min,\n beta_max, gamma, gamma_min, gamma_max,\n variance_epsilon_, scale_after_normalization_,\n output, &output_min, &output_max);\n\n Tensor* output_min_tensor = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(1, {}, &output_min_tensor));\n output_min_tensor->flat()(0) = output_min;\n\n Tensor* output_max_tensor = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(2, {}, &output_max_tensor));\n output_max_tensor->flat()(0) = output_max;\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29547", "cwe_id": "CWE-125" }, { "id": 244, "func": "static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,\n\t\tint closing, int tx_ring)\n{\n\tstruct pgv *pg_vec = NULL;\n\tstruct packet_sock *po = pkt_sk(sk);\n\tint was_running, order = 0;\n\tstruct packet_ring_buffer *rb;\n\tstruct sk_buff_head *rb_queue;\n\t__be16 num;\n\tint err = -EINVAL;\n\t/* Added to avoid minimal code churn */\n\tstruct tpacket_req *req = &req_u->req;\n\n\t/* Opening a Tx-ring is NOT supported in TPACKET_V3 */\n\tif (!closing && tx_ring && (po->tp_version > TPACKET_V2)) {\n\t\tnet_warn_ratelimited(\"Tx-ring is not supported.\\n\");\n\t\tgoto out;\n\t}\n\n\trb = tx_ring ? &po->tx_ring : &po->rx_ring;\n\trb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue;\n\n\terr = -EBUSY;\n\tif (!closing) {\n\t\tif (atomic_read(&po->mapped))\n\t\t\tgoto out;\n\t\tif (packet_read_pending(rb))\n\t\t\tgoto out;\n\t}\n\n\tif (req->tp_block_nr) {\n\t\t/* Sanity tests and some calculations */\n\t\terr = -EBUSY;\n\t\tif (unlikely(rb->pg_vec))\n\t\t\tgoto out;\n\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V1:\n\t\t\tpo->tp_hdrlen = TPACKET_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V2:\n\t\t\tpo->tp_hdrlen = TPACKET2_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V3:\n\t\t\tpo->tp_hdrlen = TPACKET3_HDRLEN;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = -EINVAL;\n\t\tif (unlikely((int)req->tp_block_size <= 0))\n\t\t\tgoto out;\n\t\tif (unlikely(!PAGE_ALIGNED(req->tp_block_size)))\n\t\t\tgoto out;\n\t\tif (po->tp_version >= TPACKET_V3 &&\n\t\t (int)(req->tp_block_size -\n\t\t\t BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size < po->tp_hdrlen +\n\t\t\t\t\tpo->tp_reserve))\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))\n\t\t\tgoto out;\n\n\t\trb->frames_per_block = req->tp_block_size / req->tp_frame_size;\n\t\tif (unlikely(rb->frames_per_block == 0))\n\t\t\tgoto out;\n\t\tif (unlikely((rb->frames_per_block * req->tp_block_nr) !=\n\t\t\t\t\treq->tp_frame_nr))\n\t\t\tgoto out;\n\n\t\terr = -ENOMEM;\n\t\torder = get_order(req->tp_block_size);\n\t\tpg_vec = alloc_pg_vec(req, order);\n\t\tif (unlikely(!pg_vec))\n\t\t\tgoto out;\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V3:\n\t\t/* Transmit path is not supported. We checked\n\t\t * it above but just being paranoid\n\t\t */\n\t\t\tif (!tx_ring)\n\t\t\t\tinit_prb_bdqc(po, rb, pg_vec, req_u);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\t/* Done */\n\telse {\n\t\terr = -EINVAL;\n\t\tif (unlikely(req->tp_frame_nr))\n\t\t\tgoto out;\n\t}\n\n\tlock_sock(sk);\n\n\t/* Detach socket from network */\n\tspin_lock(&po->bind_lock);\n\twas_running = po->running;\n\tnum = po->num;\n\tif (was_running) {\n\t\tpo->num = 0;\n\t\t__unregister_prot_hook(sk, false);\n\t}\n\tspin_unlock(&po->bind_lock);\n\n\tsynchronize_net();\n\n\terr = -EBUSY;\n\tmutex_lock(&po->pg_vec_lock);\n\tif (closing || atomic_read(&po->mapped) == 0) {\n\t\terr = 0;\n\t\tspin_lock_bh(&rb_queue->lock);\n\t\tswap(rb->pg_vec, pg_vec);\n\t\trb->frame_max = (req->tp_frame_nr - 1);\n\t\trb->head = 0;\n\t\trb->frame_size = req->tp_frame_size;\n\t\tspin_unlock_bh(&rb_queue->lock);\n\n\t\tswap(rb->pg_vec_order, order);\n\t\tswap(rb->pg_vec_len, req->tp_block_nr);\n\n\t\trb->pg_vec_pages = req->tp_block_size/PAGE_SIZE;\n\t\tpo->prot_hook.func = (po->rx_ring.pg_vec) ?\n\t\t\t\t\t\ttpacket_rcv : packet_rcv;\n\t\tskb_queue_purge(rb_queue);\n\t\tif (atomic_read(&po->mapped))\n\t\t\tpr_err(\"packet_mmap: vma is busy: %d\\n\",\n\t\t\t atomic_read(&po->mapped));\n\t}\n\tmutex_unlock(&po->pg_vec_lock);\n\n\tspin_lock(&po->bind_lock);\n\tif (was_running) {\n\t\tpo->num = num;\n\t\tregister_prot_hook(sk);\n\t}\n\tspin_unlock(&po->bind_lock);\n\tif (closing && (po->tp_version > TPACKET_V2)) {\n\t\t/* Because we don't support block-based V3 on tx-ring */\n\t\tif (!tx_ring)\n\t\t\tprb_shutdown_retire_blk_timer(po, rb_queue);\n\t}\n\trelease_sock(sk);\n\n\tif (pg_vec)\n\t\tfree_pg_vec(pg_vec, order, req->tp_block_nr);\nout:\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-8655", "cwe_id": "CWE-362" }, { "id": 244, "func": "static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,\n\t\tint closing, int tx_ring)\n{\n\tstruct pgv *pg_vec = NULL;\n\tstruct packet_sock *po = pkt_sk(sk);\n\tint was_running, order = 0;\n\tstruct packet_ring_buffer *rb;\n\tstruct sk_buff_head *rb_queue;\n\t__be16 num;\n\tint err = -EINVAL;\n\t/* Added to avoid minimal code churn */\n\tstruct tpacket_req *req = &req_u->req;\n\n\tlock_sock(sk);\n\t/* Opening a Tx-ring is NOT supported in TPACKET_V3 */\n\tif (!closing && tx_ring && (po->tp_version > TPACKET_V2)) {\n\t\tnet_warn_ratelimited(\"Tx-ring is not supported.\\n\");\n\t\tgoto out;\n\t}\n\n\trb = tx_ring ? &po->tx_ring : &po->rx_ring;\n\trb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue;\n\n\terr = -EBUSY;\n\tif (!closing) {\n\t\tif (atomic_read(&po->mapped))\n\t\t\tgoto out;\n\t\tif (packet_read_pending(rb))\n\t\t\tgoto out;\n\t}\n\n\tif (req->tp_block_nr) {\n\t\t/* Sanity tests and some calculations */\n\t\terr = -EBUSY;\n\t\tif (unlikely(rb->pg_vec))\n\t\t\tgoto out;\n\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V1:\n\t\t\tpo->tp_hdrlen = TPACKET_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V2:\n\t\t\tpo->tp_hdrlen = TPACKET2_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V3:\n\t\t\tpo->tp_hdrlen = TPACKET3_HDRLEN;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = -EINVAL;\n\t\tif (unlikely((int)req->tp_block_size <= 0))\n\t\t\tgoto out;\n\t\tif (unlikely(!PAGE_ALIGNED(req->tp_block_size)))\n\t\t\tgoto out;\n\t\tif (po->tp_version >= TPACKET_V3 &&\n\t\t (int)(req->tp_block_size -\n\t\t\t BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size < po->tp_hdrlen +\n\t\t\t\t\tpo->tp_reserve))\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))\n\t\t\tgoto out;\n\n\t\trb->frames_per_block = req->tp_block_size / req->tp_frame_size;\n\t\tif (unlikely(rb->frames_per_block == 0))\n\t\t\tgoto out;\n\t\tif (unlikely((rb->frames_per_block * req->tp_block_nr) !=\n\t\t\t\t\treq->tp_frame_nr))\n\t\t\tgoto out;\n\n\t\terr = -ENOMEM;\n\t\torder = get_order(req->tp_block_size);\n\t\tpg_vec = alloc_pg_vec(req, order);\n\t\tif (unlikely(!pg_vec))\n\t\t\tgoto out;\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V3:\n\t\t/* Transmit path is not supported. We checked\n\t\t * it above but just being paranoid\n\t\t */\n\t\t\tif (!tx_ring)\n\t\t\t\tinit_prb_bdqc(po, rb, pg_vec, req_u);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\t/* Done */\n\telse {\n\t\terr = -EINVAL;\n\t\tif (unlikely(req->tp_frame_nr))\n\t\t\tgoto out;\n\t}\n\n\n\t/* Detach socket from network */\n\tspin_lock(&po->bind_lock);\n\twas_running = po->running;\n\tnum = po->num;\n\tif (was_running) {\n\t\tpo->num = 0;\n\t\t__unregister_prot_hook(sk, false);\n\t}\n\tspin_unlock(&po->bind_lock);\n\n\tsynchronize_net();\n\n\terr = -EBUSY;\n\tmutex_lock(&po->pg_vec_lock);\n\tif (closing || atomic_read(&po->mapped) == 0) {\n\t\terr = 0;\n\t\tspin_lock_bh(&rb_queue->lock);\n\t\tswap(rb->pg_vec, pg_vec);\n\t\trb->frame_max = (req->tp_frame_nr - 1);\n\t\trb->head = 0;\n\t\trb->frame_size = req->tp_frame_size;\n\t\tspin_unlock_bh(&rb_queue->lock);\n\n\t\tswap(rb->pg_vec_order, order);\n\t\tswap(rb->pg_vec_len, req->tp_block_nr);\n\n\t\trb->pg_vec_pages = req->tp_block_size/PAGE_SIZE;\n\t\tpo->prot_hook.func = (po->rx_ring.pg_vec) ?\n\t\t\t\t\t\ttpacket_rcv : packet_rcv;\n\t\tskb_queue_purge(rb_queue);\n\t\tif (atomic_read(&po->mapped))\n\t\t\tpr_err(\"packet_mmap: vma is busy: %d\\n\",\n\t\t\t atomic_read(&po->mapped));\n\t}\n\tmutex_unlock(&po->pg_vec_lock);\n\n\tspin_lock(&po->bind_lock);\n\tif (was_running) {\n\t\tpo->num = num;\n\t\tregister_prot_hook(sk);\n\t}\n\tspin_unlock(&po->bind_lock);\n\tif (closing && (po->tp_version > TPACKET_V2)) {\n\t\t/* Because we don't support block-based V3 on tx-ring */\n\t\tif (!tx_ring)\n\t\t\tprb_shutdown_retire_blk_timer(po, rb_queue);\n\t}\n\n\tif (pg_vec)\n\t\tfree_pg_vec(pg_vec, order, req->tp_block_nr);\nout:\n\trelease_sock(sk);\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-8655", "cwe_id": "CWE-362" }, { "id": 1682, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLitePackParams* data =\n reinterpret_cast(node->builtin_data);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n switch (output->type) {\n case kTfLiteFloat32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteUInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt16: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt64: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n default: {\n context->ReportError(context, \"Type '%s' is not supported by pack.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1682, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLitePackParams* data =\n reinterpret_cast(node->builtin_data);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n switch (output->type) {\n case kTfLiteFloat32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteUInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt16: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt64: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n default: {\n context->ReportError(context, \"Type '%s' is not supported by pack.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1686, "func": "static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen)\n{\n\tstruct page *pages[NFS4ACL_MAXPAGES] = {NULL, };\n\tstruct nfs_getaclargs args = {\n\t\t.fh = NFS_FH(inode),\n\t\t.acl_pages = pages,\n\t\t.acl_len = buflen,\n\t};\n\tstruct nfs_getaclres res = {\n\t\t.acl_len = buflen,\n\t};\n\tstruct rpc_message msg = {\n\t\t.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETACL],\n\t\t.rpc_argp = &args,\n\t\t.rpc_resp = &res,\n\t};\n\tunsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE);\n\tint ret = -ENOMEM, i;\n\n\t/* As long as we're doing a round trip to the server anyway,\n\t * let's be prepared for a page of acl data. */\n\tif (npages == 0)\n\t\tnpages = 1;\n\tif (npages > ARRAY_SIZE(pages))\n\t\treturn -ERANGE;\n\n\tfor (i = 0; i < npages; i++) {\n\t\tpages[i] = alloc_page(GFP_KERNEL);\n\t\tif (!pages[i])\n\t\t\tgoto out_free;\n\t}\n\n\t/* for decoding across pages */\n\tres.acl_scratch = alloc_page(GFP_KERNEL);\n\tif (!res.acl_scratch)\n\t\tgoto out_free;\n\n\targs.acl_len = npages * PAGE_SIZE;\n\targs.acl_pgbase = 0;\n\n\tdprintk(\"%s buf %p buflen %zu npages %d args.acl_len %zu\\n\",\n\t\t__func__, buf, buflen, npages, args.acl_len);\n\tret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode),\n\t\t\t &msg, &args.seq_args, &res.seq_res, 0);\n\tif (ret)\n\t\tgoto out_free;\n\n\t/* Handle the case where the passed-in buffer is too short */\n\tif (res.acl_flags & NFS4_ACL_TRUNC) {\n\t\t/* Did the user only issue a request for the acl length? */\n\t\tif (buf == NULL)\n\t\t\tgoto out_ok;\n\t\tret = -ERANGE;\n\t\tgoto out_free;\n\t}\n\tnfs4_write_cached_acl(inode, pages, res.acl_data_offset, res.acl_len);\n\tif (buf)\n\t\t_copy_from_pages(buf, pages, res.acl_data_offset, res.acl_len);\nout_ok:\n\tret = res.acl_len;\nout_free:\n\tfor (i = 0; i < npages; i++)\n\t\tif (pages[i])\n\t\t\t__free_page(pages[i]);\n\tif (res.acl_scratch)\n\t\t__free_page(res.acl_scratch);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-4591", "cwe_id": "CWE-119" }, { "id": 1686, "func": "static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen)\n{\n\tstruct page *pages[NFS4ACL_MAXPAGES] = {NULL, };\n\tstruct nfs_getaclargs args = {\n\t\t.fh = NFS_FH(inode),\n\t\t.acl_pages = pages,\n\t\t.acl_len = buflen,\n\t};\n\tstruct nfs_getaclres res = {\n\t\t.acl_len = buflen,\n\t};\n\tstruct rpc_message msg = {\n\t\t.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETACL],\n\t\t.rpc_argp = &args,\n\t\t.rpc_resp = &res,\n\t};\n\tunsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE);\n\tint ret = -ENOMEM, i;\n\n\t/* As long as we're doing a round trip to the server anyway,\n\t * let's be prepared for a page of acl data. */\n\tif (npages == 0)\n\t\tnpages = 1;\n\tif (npages > ARRAY_SIZE(pages))\n\t\treturn -ERANGE;\n\n\tfor (i = 0; i < npages; i++) {\n\t\tpages[i] = alloc_page(GFP_KERNEL);\n\t\tif (!pages[i])\n\t\t\tgoto out_free;\n\t}\n\n\t/* for decoding across pages */\n\tres.acl_scratch = alloc_page(GFP_KERNEL);\n\tif (!res.acl_scratch)\n\t\tgoto out_free;\n\n\targs.acl_len = npages * PAGE_SIZE;\n\targs.acl_pgbase = 0;\n\n\tdprintk(\"%s buf %p buflen %zu npages %d args.acl_len %zu\\n\",\n\t\t__func__, buf, buflen, npages, args.acl_len);\n\tret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode),\n\t\t\t &msg, &args.seq_args, &res.seq_res, 0);\n\tif (ret)\n\t\tgoto out_free;\n\n\t/* Handle the case where the passed-in buffer is too short */\n\tif (res.acl_flags & NFS4_ACL_TRUNC) {\n\t\t/* Did the user only issue a request for the acl length? */\n\t\tif (buf == NULL)\n\t\t\tgoto out_ok;\n\t\tret = -ERANGE;\n\t\tgoto out_free;\n\t}\n\tnfs4_write_cached_acl(inode, pages, res.acl_data_offset, res.acl_len);\n\tif (buf) {\n\t\tif (res.acl_len > buflen) {\n\t\t\tret = -ERANGE;\n\t\t\tgoto out_free;\n\t\t}\n\t\t_copy_from_pages(buf, pages, res.acl_data_offset, res.acl_len);\n\t}\nout_ok:\n\tret = res.acl_len;\nout_free:\n\tfor (i = 0; i < npages; i++)\n\t\tif (pages[i])\n\t\t\t__free_page(pages[i]);\n\tif (res.acl_scratch)\n\t\t__free_page(res.acl_scratch);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-4591", "cwe_id": "CWE-119" }, { "id": 2488, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n switch (output->type) {\n case kTfLiteInt32: {\n // TensorFlow does not support negative for int32.\n TF_LITE_ENSURE_OK(context, CheckValue(context, input2));\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n case kTfLiteFloat32: {\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n default: {\n context->ReportError(context, \"Unsupported data type: %d\", output->type);\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2488, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n switch (output->type) {\n case kTfLiteInt32: {\n // TensorFlow does not support negative for int32.\n TF_LITE_ENSURE_OK(context, CheckValue(context, input2));\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n case kTfLiteFloat32: {\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n default: {\n context->ReportError(context, \"Unsupported data type: %d\", output->type);\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2678, "func": "static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)\n{\n int dy = y1 - y0;\n int adx = x1 - x0;\n int ady = abs(dy);\n int base;\n int x=x0,y=y0;\n int err = 0;\n int sy;\n\n#ifdef STB_VORBIS_DIVIDE_TABLE\n if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {\n if (dy < 0) {\n base = -integer_divide_table[ady][adx];\n sy = base-1;\n } else {\n base = integer_divide_table[ady][adx];\n sy = base+1;\n }\n } else {\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n }\n#else\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n#endif\n ady -= abs(base) * adx;\n if (x1 > n) x1 = n;\n if (x < x1) {\n LINE_OP(output[x], inverse_db_table[y]);\n for (++x; x < x1; ++x) {\n err += ady;\n if (err >= adx) {\n err -= adx;\n y += sy;\n } else\n y += base;\n LINE_OP(output[x], inverse_db_table[y]);\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-13217", "cwe_id": "CWE-787" }, { "id": 2678, "func": "static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)\n{\n int dy = y1 - y0;\n int adx = x1 - x0;\n int ady = abs(dy);\n int base;\n int x=x0,y=y0;\n int err = 0;\n int sy;\n\n#ifdef STB_VORBIS_DIVIDE_TABLE\n if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {\n if (dy < 0) {\n base = -integer_divide_table[ady][adx];\n sy = base-1;\n } else {\n base = integer_divide_table[ady][adx];\n sy = base+1;\n }\n } else {\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n }\n#else\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n#endif\n ady -= abs(base) * adx;\n if (x1 > n) x1 = n;\n if (x < x1) {\n LINE_OP(output[x], inverse_db_table[y&255]);\n for (++x; x < x1; ++x) {\n err += ady;\n if (err >= adx) {\n err -= adx;\n y += sy;\n } else\n y += base;\n LINE_OP(output[x], inverse_db_table[y&255]);\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-13217", "cwe_id": "CWE-787" }, { "id": 2140, "func": "void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];\n\tjpc_fix_t *buf = joinbuf;\n\tjpc_fix_t *srcptr;\n\tjpc_fix_t *dstptr;\n\tregister jpc_fix_t *srcptr2;\n\tregister jpc_fix_t *dstptr2;\n\tregister int n;\n\tregister int i;\n\tint hstartcol;\n\n\t/* Allocate memory for the join buffer from the heap. */\n\tif (bufsize > QMFB_JOINBUFSIZE) {\n\t\tif (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE, sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\thstartcol = (numrows + 1 - parity) >> 1;\n\n\t/* Save the samples from the lowpass channel. */\n\tn = hstartcol;\n\tsrcptr = &a[0];\n\tdstptr = buf;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tsrcptr += stride;\n\t\tdstptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\t/* Copy the samples from the highpass channel into place. */\n\tsrcptr = &a[hstartcol * stride];\n\tdstptr = &a[(1 - parity) * stride];\n\tn = numrows - hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += stride;\n\t}\n\t/* Copy the samples from the lowpass channel into place. */\n\tsrcptr = buf;\n\tdstptr = &a[parity * stride];\n\tn = hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\n\t/* If the join buffer was allocated on the heap, free this memory. */\n\tif (buf != joinbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-8654", "cwe_id": "CWE-119" }, { "id": 2140, "func": "void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];\n\tjpc_fix_t *buf = joinbuf;\n\tjpc_fix_t *srcptr;\n\tjpc_fix_t *dstptr;\n\tregister jpc_fix_t *srcptr2;\n\tregister jpc_fix_t *dstptr2;\n\tregister int n;\n\tregister int i;\n\tint hstartcol;\n\n\t/* Allocate memory for the join buffer from the heap. */\n\tif (bufsize > QMFB_JOINBUFSIZE) {\n\t\tif (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE,\n\t\t sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\thstartcol = (numrows + 1 - parity) >> 1;\n\n\t/* Save the samples from the lowpass channel. */\n\tn = hstartcol;\n\tsrcptr = &a[0];\n\tdstptr = buf;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tsrcptr += stride;\n\t\tdstptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\t/* Copy the samples from the highpass channel into place. */\n\tsrcptr = &a[hstartcol * stride];\n\tdstptr = &a[(1 - parity) * stride];\n\tn = numrows - hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += stride;\n\t}\n\t/* Copy the samples from the lowpass channel into place. */\n\tsrcptr = buf;\n\tdstptr = &a[parity * stride];\n\tn = hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\n\t/* If the join buffer was allocated on the heap, free this memory. */\n\tif (buf != joinbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-8654", "cwe_id": "CWE-119" }, { "id": 2360, "func": "atm_if_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, const u_char *p)\n{\n\tu_int caplen = h->caplen;\n\tu_int length = h->len;\n\tuint32_t llchdr;\n\tu_int hdrlen = 0;\n\n\tif (caplen < 1 || length < 1) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\treturn (caplen);\n\t}\n\n /* Cisco Style NLPID ? */\n if (*p == LLC_UI) {\n if (ndo->ndo_eflag)\n ND_PRINT((ndo, \"CNLPID \"));\n isoclns_print(ndo, p + 1, length - 1, caplen - 1);\n return hdrlen;\n }\n\n\t/*\n\t * Must have at least a DSAP, an SSAP, and the first byte of the\n\t * control field.\n\t */\n\tif (caplen < 3 || length < 3) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\treturn (caplen);\n\t}\n\n\t/*\n\t * Extract the presumed LLC header into a variable, for quick\n\t * testing.\n\t * Then check for a header that's neither a header for a SNAP\n\t * packet nor an RFC 2684 routed NLPID-formatted PDU nor\n\t * an 802.2-but-no-SNAP IP packet.\n\t */\n\tllchdr = EXTRACT_24BITS(p);\n\tif (llchdr != LLC_UI_HDR(LLCSAP_SNAP) &&\n\t llchdr != LLC_UI_HDR(LLCSAP_ISONS) &&\n\t llchdr != LLC_UI_HDR(LLCSAP_IP)) {\n\t\t/*\n\t\t * XXX - assume 802.6 MAC header from Fore driver.\n\t\t *\n\t\t * Unfortunately, the above list doesn't check for\n\t\t * all known SAPs, doesn't check for headers where\n\t\t * the source and destination SAP aren't the same,\n\t\t * and doesn't check for non-UI frames. It also\n\t\t * runs the risk of an 802.6 MAC header that happens\n\t\t * to begin with one of those values being\n\t\t * incorrectly treated as an 802.2 header.\n\t\t *\n\t\t * So is that Fore driver still around? And, if so,\n\t\t * is it still putting 802.6 MAC headers on ATM\n\t\t * packets? If so, could it be changed to use a\n\t\t * new DLT_IEEE802_6 value if we added it?\n\t\t */\n\t\tif (caplen < 20 || length < 20) {\n\t\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\t\treturn (caplen);\n\t\t}\n\t\tif (ndo->ndo_eflag)\n\t\t\tND_PRINT((ndo, \"%08x%08x %08x%08x \",\n\t\t\t EXTRACT_32BITS(p),\n\t\t\t EXTRACT_32BITS(p+4),\n\t\t\t EXTRACT_32BITS(p+8),\n\t\t\t EXTRACT_32BITS(p+12)));\n\t\tp += 20;\n\t\tlength -= 20;\n\t\tcaplen -= 20;\n\t\thdrlen += 20;\n\t}\n\thdrlen += atm_llc_print(ndo, p, length, caplen);\n\treturn (hdrlen);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 2360, "func": "atm_if_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, const u_char *p)\n{\n\tu_int caplen = h->caplen;\n\tu_int length = h->len;\n\tuint32_t llchdr;\n\tu_int hdrlen = 0;\n\n\tif (caplen < 1 || length < 1) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\treturn (caplen);\n\t}\n\n /* Cisco Style NLPID ? */\n if (*p == LLC_UI) {\n if (ndo->ndo_eflag)\n ND_PRINT((ndo, \"CNLPID \"));\n isoclns_print(ndo, p + 1, length - 1);\n return hdrlen;\n }\n\n\t/*\n\t * Must have at least a DSAP, an SSAP, and the first byte of the\n\t * control field.\n\t */\n\tif (caplen < 3 || length < 3) {\n\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\treturn (caplen);\n\t}\n\n\t/*\n\t * Extract the presumed LLC header into a variable, for quick\n\t * testing.\n\t * Then check for a header that's neither a header for a SNAP\n\t * packet nor an RFC 2684 routed NLPID-formatted PDU nor\n\t * an 802.2-but-no-SNAP IP packet.\n\t */\n\tllchdr = EXTRACT_24BITS(p);\n\tif (llchdr != LLC_UI_HDR(LLCSAP_SNAP) &&\n\t llchdr != LLC_UI_HDR(LLCSAP_ISONS) &&\n\t llchdr != LLC_UI_HDR(LLCSAP_IP)) {\n\t\t/*\n\t\t * XXX - assume 802.6 MAC header from Fore driver.\n\t\t *\n\t\t * Unfortunately, the above list doesn't check for\n\t\t * all known SAPs, doesn't check for headers where\n\t\t * the source and destination SAP aren't the same,\n\t\t * and doesn't check for non-UI frames. It also\n\t\t * runs the risk of an 802.6 MAC header that happens\n\t\t * to begin with one of those values being\n\t\t * incorrectly treated as an 802.2 header.\n\t\t *\n\t\t * So is that Fore driver still around? And, if so,\n\t\t * is it still putting 802.6 MAC headers on ATM\n\t\t * packets? If so, could it be changed to use a\n\t\t * new DLT_IEEE802_6 value if we added it?\n\t\t */\n\t\tif (caplen < 20 || length < 20) {\n\t\t\tND_PRINT((ndo, \"%s\", tstr));\n\t\t\treturn (caplen);\n\t\t}\n\t\tif (ndo->ndo_eflag)\n\t\t\tND_PRINT((ndo, \"%08x%08x %08x%08x \",\n\t\t\t EXTRACT_32BITS(p),\n\t\t\t EXTRACT_32BITS(p+4),\n\t\t\t EXTRACT_32BITS(p+8),\n\t\t\t EXTRACT_32BITS(p+12)));\n\t\tp += 20;\n\t\tlength -= 20;\n\t\tcaplen -= 20;\n\t\thdrlen += 20;\n\t}\n\thdrlen += atm_llc_print(ndo, p, length, caplen);\n\treturn (hdrlen);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 1660, "func": "void* sspi_SecureHandleGetUpperPointer(SecHandle* handle)\n{\n\tvoid* pointer;\n\n\tif (!handle)\n\t\treturn NULL;\n\n\tpointer = (void*) ~((size_t) handle->dwUpper);\n\n\treturn pointer;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-4119", "cwe_id": "CWE-476" }, { "id": 1660, "func": "void* sspi_SecureHandleGetUpperPointer(SecHandle* handle)\n{\n\tvoid* pointer;\n\n\tif (!handle || !SecIsValidHandle(handle))\n\t\treturn NULL;\n\n\tpointer = (void*) ~((size_t) handle->dwUpper);\n\n\treturn pointer;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-4119", "cwe_id": "CWE-476" }, { "id": 428, "func": "static void labeljumps(JF, js_JumpList *jump, int baddr, int caddr)\n{\n\twhile (jump) {\n\t\tif (jump->type == STM_BREAK)\n\t\t\tlabelto(J, F, jump->inst, baddr);\n\t\tif (jump->type == STM_CONTINUE)\n\t\t\tlabelto(J, F, jump->inst, caddr);\n\t\tjump = jump->next;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-45005", "cwe_id": "CWE-787" }, { "id": 428, "func": "static void labeljumps(JF, js_Ast *stm, int baddr, int caddr)\n{\n\tjs_JumpList *jump = stm->jumps;\n\twhile (jump) {\n\t\tjs_JumpList *next = jump->next;\n\t\tif (jump->type == STM_BREAK)\n\t\t\tlabelto(J, F, jump->inst, baddr);\n\t\tif (jump->type == STM_CONTINUE)\n\t\t\tlabelto(J, F, jump->inst, caddr);\n\t\tjs_free(J, jump);\n\t\tjump = next;\n\t}\n\tstm->jumps = NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-45005", "cwe_id": "CWE-787" }, { "id": 1248, "func": "static enum try_read_result try_read_network(conn *c) {\n enum try_read_result gotdata = READ_NO_DATA_RECEIVED;\n int res;\n\n assert(c != NULL);\n\n if (c->rcurr != c->rbuf) {\n if (c->rbytes != 0) /* otherwise there's nothing to copy */\n memmove(c->rbuf, c->rcurr, c->rbytes);\n c->rcurr = c->rbuf;\n }\n\n while (1) {\n if (c->rbytes >= c->rsize) {\n char *new_rbuf = realloc(c->rbuf, c->rsize * 2);\n if (!new_rbuf) {\n if (settings.verbose > 0)\n fprintf(stderr, \"Couldn't realloc input buffer\\n\");\n c->rbytes = 0; /* ignore what we read */\n out_string(c, \"SERVER_ERROR out of memory reading request\");\n c->write_and_go = conn_closing;\n return READ_MEMORY_ERROR;\n }\n c->rcurr = c->rbuf = new_rbuf;\n c->rsize *= 2;\n }\n\n int avail = c->rsize - c->rbytes;\n res = read(c->sfd, c->rbuf + c->rbytes, avail);\n if (res > 0) {\n pthread_mutex_lock(&c->thread->stats.mutex);\n c->thread->stats.bytes_read += res;\n pthread_mutex_unlock(&c->thread->stats.mutex);\n gotdata = READ_DATA_RECEIVED;\n c->rbytes += res;\n if (res == avail) {\n continue;\n } else {\n break;\n }\n }\n if (res == 0) {\n return READ_ERROR;\n }\n if (res == -1) {\n if (errno == EAGAIN || errno == EWOULDBLOCK) {\n break;\n }\n return READ_ERROR;\n }\n }\n return gotdata;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2010-1152", "cwe_id": "CWE-20" }, { "id": 1248, "func": "static enum try_read_result try_read_network(conn *c) {\n enum try_read_result gotdata = READ_NO_DATA_RECEIVED;\n int res;\n int num_allocs = 0;\n assert(c != NULL);\n\n if (c->rcurr != c->rbuf) {\n if (c->rbytes != 0) /* otherwise there's nothing to copy */\n memmove(c->rbuf, c->rcurr, c->rbytes);\n c->rcurr = c->rbuf;\n }\n\n while (1) {\n if (c->rbytes >= c->rsize) {\n if (num_allocs == 4) {\n return gotdata;\n }\n ++num_allocs;\n char *new_rbuf = realloc(c->rbuf, c->rsize * 2);\n if (!new_rbuf) {\n if (settings.verbose > 0)\n fprintf(stderr, \"Couldn't realloc input buffer\\n\");\n c->rbytes = 0; /* ignore what we read */\n out_string(c, \"SERVER_ERROR out of memory reading request\");\n c->write_and_go = conn_closing;\n return READ_MEMORY_ERROR;\n }\n c->rcurr = c->rbuf = new_rbuf;\n c->rsize *= 2;\n }\n\n int avail = c->rsize - c->rbytes;\n res = read(c->sfd, c->rbuf + c->rbytes, avail);\n if (res > 0) {\n pthread_mutex_lock(&c->thread->stats.mutex);\n c->thread->stats.bytes_read += res;\n pthread_mutex_unlock(&c->thread->stats.mutex);\n gotdata = READ_DATA_RECEIVED;\n c->rbytes += res;\n if (res == avail) {\n continue;\n } else {\n break;\n }\n }\n if (res == 0) {\n return READ_ERROR;\n }\n if (res == -1) {\n if (errno == EAGAIN || errno == EWOULDBLOCK) {\n break;\n }\n return READ_ERROR;\n }\n }\n return gotdata;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2010-1152", "cwe_id": "CWE-20" }, { "id": 1442, "func": "xfs_attr_shortform_to_leaf(\n\tstruct xfs_da_args\t*args,\n\tstruct xfs_buf\t\t**leaf_bp)\n{\n\txfs_inode_t *dp;\n\txfs_attr_shortform_t *sf;\n\txfs_attr_sf_entry_t *sfe;\n\txfs_da_args_t nargs;\n\tchar *tmpbuffer;\n\tint error, i, size;\n\txfs_dablk_t blkno;\n\tstruct xfs_buf *bp;\n\txfs_ifork_t *ifp;\n\n\ttrace_xfs_attr_sf_to_leaf(args);\n\n\tdp = args->dp;\n\tifp = dp->i_afp;\n\tsf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;\n\tsize = be16_to_cpu(sf->hdr.totsize);\n\ttmpbuffer = kmem_alloc(size, KM_SLEEP);\n\tASSERT(tmpbuffer != NULL);\n\tmemcpy(tmpbuffer, ifp->if_u1.if_data, size);\n\tsf = (xfs_attr_shortform_t *)tmpbuffer;\n\n\txfs_idata_realloc(dp, -size, XFS_ATTR_FORK);\n\txfs_bmap_local_to_extents_empty(dp, XFS_ATTR_FORK);\n\n\tbp = NULL;\n\terror = xfs_da_grow_inode(args, &blkno);\n\tif (error) {\n\t\t/*\n\t\t * If we hit an IO error middle of the transaction inside\n\t\t * grow_inode(), we may have inconsistent data. Bail out.\n\t\t */\n\t\tif (error == -EIO)\n\t\t\tgoto out;\n\t\txfs_idata_realloc(dp, size, XFS_ATTR_FORK);\t/* try to put */\n\t\tmemcpy(ifp->if_u1.if_data, tmpbuffer, size);\t/* it back */\n\t\tgoto out;\n\t}\n\n\tASSERT(blkno == 0);\n\terror = xfs_attr3_leaf_create(args, blkno, &bp);\n\tif (error) {\n\t\terror = xfs_da_shrink_inode(args, 0, bp);\n\t\tbp = NULL;\n\t\tif (error)\n\t\t\tgoto out;\n\t\txfs_idata_realloc(dp, size, XFS_ATTR_FORK);\t/* try to put */\n\t\tmemcpy(ifp->if_u1.if_data, tmpbuffer, size);\t/* it back */\n\t\tgoto out;\n\t}\n\n\tmemset((char *)&nargs, 0, sizeof(nargs));\n\tnargs.dp = dp;\n\tnargs.geo = args->geo;\n\tnargs.firstblock = args->firstblock;\n\tnargs.dfops = args->dfops;\n\tnargs.total = args->total;\n\tnargs.whichfork = XFS_ATTR_FORK;\n\tnargs.trans = args->trans;\n\tnargs.op_flags = XFS_DA_OP_OKNOENT;\n\n\tsfe = &sf->list[0];\n\tfor (i = 0; i < sf->hdr.count; i++) {\n\t\tnargs.name = sfe->nameval;\n\t\tnargs.namelen = sfe->namelen;\n\t\tnargs.value = &sfe->nameval[nargs.namelen];\n\t\tnargs.valuelen = sfe->valuelen;\n\t\tnargs.hashval = xfs_da_hashname(sfe->nameval,\n\t\t\t\t\t\tsfe->namelen);\n\t\tnargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);\n\t\terror = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */\n\t\tASSERT(error == -ENOATTR);\n\t\terror = xfs_attr3_leaf_add(bp, &nargs);\n\t\tASSERT(error != -ENOSPC);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tsfe = XFS_ATTR_SF_NEXTENTRY(sfe);\n\t}\n\terror = 0;\n\t*leaf_bp = bp;\nout:\n\tkmem_free(tmpbuffer);\n\treturn error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-13094", "cwe_id": "CWE-476" }, { "id": 1442, "func": "xfs_attr_shortform_to_leaf(\n\tstruct xfs_da_args\t*args,\n\tstruct xfs_buf\t\t**leaf_bp)\n{\n\txfs_inode_t *dp;\n\txfs_attr_shortform_t *sf;\n\txfs_attr_sf_entry_t *sfe;\n\txfs_da_args_t nargs;\n\tchar *tmpbuffer;\n\tint error, i, size;\n\txfs_dablk_t blkno;\n\tstruct xfs_buf *bp;\n\txfs_ifork_t *ifp;\n\n\ttrace_xfs_attr_sf_to_leaf(args);\n\n\tdp = args->dp;\n\tifp = dp->i_afp;\n\tsf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;\n\tsize = be16_to_cpu(sf->hdr.totsize);\n\ttmpbuffer = kmem_alloc(size, KM_SLEEP);\n\tASSERT(tmpbuffer != NULL);\n\tmemcpy(tmpbuffer, ifp->if_u1.if_data, size);\n\tsf = (xfs_attr_shortform_t *)tmpbuffer;\n\n\txfs_idata_realloc(dp, -size, XFS_ATTR_FORK);\n\txfs_bmap_local_to_extents_empty(dp, XFS_ATTR_FORK);\n\n\tbp = NULL;\n\terror = xfs_da_grow_inode(args, &blkno);\n\tif (error) {\n\t\t/*\n\t\t * If we hit an IO error middle of the transaction inside\n\t\t * grow_inode(), we may have inconsistent data. Bail out.\n\t\t */\n\t\tif (error == -EIO)\n\t\t\tgoto out;\n\t\txfs_idata_realloc(dp, size, XFS_ATTR_FORK);\t/* try to put */\n\t\tmemcpy(ifp->if_u1.if_data, tmpbuffer, size);\t/* it back */\n\t\tgoto out;\n\t}\n\n\tASSERT(blkno == 0);\n\terror = xfs_attr3_leaf_create(args, blkno, &bp);\n\tif (error) {\n\t\t/* xfs_attr3_leaf_create may not have instantiated a block */\n\t\tif (bp && (xfs_da_shrink_inode(args, 0, bp) != 0))\n\t\t\tgoto out;\n\t\txfs_idata_realloc(dp, size, XFS_ATTR_FORK);\t/* try to put */\n\t\tmemcpy(ifp->if_u1.if_data, tmpbuffer, size);\t/* it back */\n\t\tgoto out;\n\t}\n\n\tmemset((char *)&nargs, 0, sizeof(nargs));\n\tnargs.dp = dp;\n\tnargs.geo = args->geo;\n\tnargs.firstblock = args->firstblock;\n\tnargs.dfops = args->dfops;\n\tnargs.total = args->total;\n\tnargs.whichfork = XFS_ATTR_FORK;\n\tnargs.trans = args->trans;\n\tnargs.op_flags = XFS_DA_OP_OKNOENT;\n\n\tsfe = &sf->list[0];\n\tfor (i = 0; i < sf->hdr.count; i++) {\n\t\tnargs.name = sfe->nameval;\n\t\tnargs.namelen = sfe->namelen;\n\t\tnargs.value = &sfe->nameval[nargs.namelen];\n\t\tnargs.valuelen = sfe->valuelen;\n\t\tnargs.hashval = xfs_da_hashname(sfe->nameval,\n\t\t\t\t\t\tsfe->namelen);\n\t\tnargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);\n\t\terror = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */\n\t\tASSERT(error == -ENOATTR);\n\t\terror = xfs_attr3_leaf_add(bp, &nargs);\n\t\tASSERT(error != -ENOSPC);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tsfe = XFS_ATTR_SF_NEXTENTRY(sfe);\n\t}\n\terror = 0;\n\t*leaf_bp = bp;\nout:\n\tkmem_free(tmpbuffer);\n\treturn error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-13094", "cwe_id": "CWE-476" }, { "id": 1056, "func": "void sctp_generate_t3_rtx_event(unsigned long peer)\n{\n\tint error;\n\tstruct sctp_transport *transport = (struct sctp_transport *) peer;\n\tstruct sctp_association *asoc = transport->asoc;\n\tstruct net *net = sock_net(asoc->base.sk);\n\n\t/* Check whether a task is in the sock. */\n\n\tbh_lock_sock(asoc->base.sk);\n\tif (sock_owned_by_user(asoc->base.sk)) {\n\t\tpr_debug(\"%s: sock is busy\\n\", __func__);\n\n\t\t/* Try again later. */\n\t\tif (!mod_timer(&transport->T3_rtx_timer, jiffies + (HZ/20)))\n\t\t\tsctp_transport_hold(transport);\n\t\tgoto out_unlock;\n\t}\n\n\t/* Is this transport really dead and just waiting around for\n\t * the timer to let go of the reference?\n\t */\n\tif (transport->dead)\n\t\tgoto out_unlock;\n\n\t/* Run through the state machine. */\n\terror = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,\n\t\t\t SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),\n\t\t\t asoc->state,\n\t\t\t asoc->ep, asoc,\n\t\t\t transport, GFP_ATOMIC);\n\n\tif (error)\n\t\tasoc->base.sk->sk_err = -error;\n\nout_unlock:\n\tbh_unlock_sock(asoc->base.sk);\n\tsctp_transport_put(transport);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-8767", "cwe_id": "CWE-362" }, { "id": 1056, "func": "void sctp_generate_t3_rtx_event(unsigned long peer)\n{\n\tint error;\n\tstruct sctp_transport *transport = (struct sctp_transport *) peer;\n\tstruct sctp_association *asoc = transport->asoc;\n\tstruct sock *sk = asoc->base.sk;\n\tstruct net *net = sock_net(sk);\n\n\t/* Check whether a task is in the sock. */\n\n\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk)) {\n\t\tpr_debug(\"%s: sock is busy\\n\", __func__);\n\n\t\t/* Try again later. */\n\t\tif (!mod_timer(&transport->T3_rtx_timer, jiffies + (HZ/20)))\n\t\t\tsctp_transport_hold(transport);\n\t\tgoto out_unlock;\n\t}\n\n\t/* Is this transport really dead and just waiting around for\n\t * the timer to let go of the reference?\n\t */\n\tif (transport->dead)\n\t\tgoto out_unlock;\n\n\t/* Run through the state machine. */\n\terror = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,\n\t\t\t SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),\n\t\t\t asoc->state,\n\t\t\t asoc->ep, asoc,\n\t\t\t transport, GFP_ATOMIC);\n\n\tif (error)\n\t\tsk->sk_err = -error;\n\nout_unlock:\n\tbh_unlock_sock(sk);\n\tsctp_transport_put(transport);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-8767", "cwe_id": "CWE-362" }, { "id": 399, "func": "AsyncSocket::WriteResult AsyncSSLSocket::performWrite(\n const iovec* vec,\n uint32_t count,\n WriteFlags flags,\n uint32_t* countWritten,\n uint32_t* partialWritten) {\n if (sslState_ == STATE_UNENCRYPTED) {\n return AsyncSocket::performWrite(\n vec, count, flags, countWritten, partialWritten);\n }\n if (sslState_ != STATE_ESTABLISHED) {\n LOG(ERROR) << \"AsyncSSLSocket(fd=\" << fd_ << \", state=\" << int(state_)\n << \", sslState=\" << sslState_ << \", events=\" << eventFlags_\n << \"): \"\n << \"TODO: AsyncSSLSocket currently does not support calling \"\n << \"write() before the handshake has fully completed\";\n return WriteResult(\n WRITE_ERROR, std::make_unique(SSLError::EARLY_WRITE));\n }\n\n // Declare a buffer used to hold small write requests. It could point to a\n // memory block either on stack or on heap. If it is on heap, we release it\n // manually when scope exits\n char* combinedBuf{nullptr};\n SCOPE_EXIT {\n // Note, always keep this check consistent with what we do below\n if (combinedBuf != nullptr && minWriteSize_ > MAX_STACK_BUF_SIZE) {\n delete[] combinedBuf;\n }\n };\n\n *countWritten = 0;\n *partialWritten = 0;\n ssize_t totalWritten = 0;\n size_t bytesStolenFromNextBuffer = 0;\n for (uint32_t i = 0; i < count; i++) {\n const iovec* v = vec + i;\n size_t offset = bytesStolenFromNextBuffer;\n bytesStolenFromNextBuffer = 0;\n size_t len = v->iov_len - offset;\n const void* buf;\n if (len == 0) {\n (*countWritten)++;\n continue;\n }\n buf = ((const char*)v->iov_base) + offset;\n\n ssize_t bytes;\n uint32_t buffersStolen = 0;\n auto sslWriteBuf = buf;\n if ((len < minWriteSize_) && ((i + 1) < count)) {\n // Combine this buffer with part or all of the next buffers in\n // order to avoid really small-grained calls to SSL_write().\n // Each call to SSL_write() produces a separate record in\n // the egress SSL stream, and we've found that some low-end\n // mobile clients can't handle receiving an HTTP response\n // header and the first part of the response body in two\n // separate SSL records (even if those two records are in\n // the same TCP packet).\n\n if (combinedBuf == nullptr) {\n if (minWriteSize_ > MAX_STACK_BUF_SIZE) {\n // Allocate the buffer on heap\n combinedBuf = new char[minWriteSize_];\n } else {\n // Allocate the buffer on stack\n combinedBuf = (char*)alloca(minWriteSize_);\n }\n }\n assert(combinedBuf != nullptr);\n sslWriteBuf = combinedBuf;\n\n memcpy(combinedBuf, buf, len);\n do {\n // INVARIANT: i + buffersStolen == complete chunks serialized\n uint32_t nextIndex = i + buffersStolen + 1;\n bytesStolenFromNextBuffer =\n std::min(vec[nextIndex].iov_len, minWriteSize_ - len);\n if (bytesStolenFromNextBuffer > 0) {\n assert(vec[nextIndex].iov_base != nullptr);\n ::memcpy(\n combinedBuf + len,\n vec[nextIndex].iov_base,\n bytesStolenFromNextBuffer);\n }\n len += bytesStolenFromNextBuffer;\n if (bytesStolenFromNextBuffer < vec[nextIndex].iov_len) {\n // couldn't steal the whole buffer\n break;\n } else {\n bytesStolenFromNextBuffer = 0;\n buffersStolen++;\n }\n } while ((i + buffersStolen + 1) < count && (len < minWriteSize_));\n }\n\n // Advance any empty buffers immediately after.\n if (bytesStolenFromNextBuffer == 0) {\n while ((i + buffersStolen + 1) < count &&\n vec[i + buffersStolen + 1].iov_len == 0) {\n buffersStolen++;\n }\n }\n\n // cork the current write if the original flags included CORK or if there\n // are remaining iovec to write\n corkCurrentWrite_ =\n isSet(flags, WriteFlags::CORK) || (i + buffersStolen + 1 < count);\n\n // track the EoR if:\n // (1) there are write flags that require EoR tracking (EOR / TIMESTAMP_TX)\n // (2) if the buffer includes the EOR byte\n appEorByteWriteFlags_ = flags & kEorRelevantWriteFlags;\n bool trackEor = appEorByteWriteFlags_ != folly::WriteFlags::NONE &&\n (i + buffersStolen + 1 == count);\n bytes = eorAwareSSLWrite(ssl_, sslWriteBuf, int(len), trackEor);\n\n if (bytes <= 0) {\n int error = SSL_get_error(ssl_.get(), int(bytes));\n if (error == SSL_ERROR_WANT_WRITE) {\n // The caller will register for write event if not already.\n *partialWritten = uint32_t(offset);\n return WriteResult(totalWritten);\n }\n auto writeResult = interpretSSLError(int(bytes), error);\n if (writeResult.writeReturn < 0) {\n return writeResult;\n } // else fall through to below to correctly record totalWritten\n }\n\n totalWritten += bytes;\n\n if (bytes == (ssize_t)len) {\n // The full iovec is written.\n (*countWritten) += 1 + buffersStolen;\n i += buffersStolen;\n // continue\n } else {\n bytes += offset; // adjust bytes to account for all of v\n while (bytes >= (ssize_t)v->iov_len) {\n // We combined this buf with part or all of the next one, and\n // we managed to write all of this buf but not all of the bytes\n // from the next one that we'd hoped to write.\n bytes -= v->iov_len;\n (*countWritten)++;\n v = &(vec[++i]);\n }\n *partialWritten = uint32_t(bytes);\n return WriteResult(totalWritten);\n }\n }\n\n return WriteResult(totalWritten);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11934", "cwe_id": "CWE-125" }, { "id": 399, "func": "AsyncSocket::WriteResult AsyncSSLSocket::performWrite(\n const iovec* vec,\n uint32_t count,\n WriteFlags flags,\n uint32_t* countWritten,\n uint32_t* partialWritten) {\n if (sslState_ == STATE_UNENCRYPTED) {\n return AsyncSocket::performWrite(\n vec, count, flags, countWritten, partialWritten);\n }\n if (sslState_ != STATE_ESTABLISHED) {\n LOG(ERROR) << \"AsyncSSLSocket(fd=\" << fd_ << \", state=\" << int(state_)\n << \", sslState=\" << sslState_ << \", events=\" << eventFlags_\n << \"): \"\n << \"TODO: AsyncSSLSocket currently does not support calling \"\n << \"write() before the handshake has fully completed\";\n return WriteResult(\n WRITE_ERROR, std::make_unique(SSLError::EARLY_WRITE));\n }\n\n // Declare a buffer used to hold small write requests. It could point to a\n // memory block either on stack or on heap. If it is on heap, we release it\n // manually when scope exits\n char* combinedBuf{nullptr};\n SCOPE_EXIT {\n // Note, always keep this check consistent with what we do below\n if (combinedBuf != nullptr && minWriteSize_ > MAX_STACK_BUF_SIZE) {\n delete[] combinedBuf;\n }\n };\n\n *countWritten = 0;\n *partialWritten = 0;\n ssize_t totalWritten = 0;\n size_t bytesStolenFromNextBuffer = 0;\n for (uint32_t i = 0; i < count; i++) {\n const iovec* v = vec + i;\n size_t offset = bytesStolenFromNextBuffer;\n bytesStolenFromNextBuffer = 0;\n size_t len = v->iov_len - offset;\n const void* buf;\n if (len == 0) {\n (*countWritten)++;\n continue;\n }\n buf = ((const char*)v->iov_base) + offset;\n\n ssize_t bytes;\n uint32_t buffersStolen = 0;\n auto sslWriteBuf = buf;\n if ((len < minWriteSize_) && ((i + 1) < count)) {\n // Combine this buffer with part or all of the next buffers in\n // order to avoid really small-grained calls to SSL_write().\n // Each call to SSL_write() produces a separate record in\n // the egress SSL stream, and we've found that some low-end\n // mobile clients can't handle receiving an HTTP response\n // header and the first part of the response body in two\n // separate SSL records (even if those two records are in\n // the same TCP packet).\n\n if (combinedBuf == nullptr) {\n if (minWriteSize_ > MAX_STACK_BUF_SIZE) {\n // Allocate the buffer on heap\n combinedBuf = new char[minWriteSize_];\n } else {\n // Allocate the buffer on stack\n combinedBuf = (char*)alloca(minWriteSize_);\n }\n }\n assert(combinedBuf != nullptr);\n sslWriteBuf = combinedBuf;\n\n memcpy(combinedBuf, buf, len);\n do {\n // INVARIANT: i + buffersStolen == complete chunks serialized\n uint32_t nextIndex = i + buffersStolen + 1;\n bytesStolenFromNextBuffer =\n std::min(vec[nextIndex].iov_len, minWriteSize_ - len);\n if (bytesStolenFromNextBuffer > 0) {\n assert(vec[nextIndex].iov_base != nullptr);\n ::memcpy(\n combinedBuf + len,\n vec[nextIndex].iov_base,\n bytesStolenFromNextBuffer);\n }\n len += bytesStolenFromNextBuffer;\n if (bytesStolenFromNextBuffer < vec[nextIndex].iov_len) {\n // couldn't steal the whole buffer\n break;\n } else {\n bytesStolenFromNextBuffer = 0;\n buffersStolen++;\n }\n } while ((i + buffersStolen + 1) < count && (len < minWriteSize_));\n }\n\n // Advance any empty buffers immediately after.\n if (bytesStolenFromNextBuffer == 0) {\n while ((i + buffersStolen + 1) < count &&\n vec[i + buffersStolen + 1].iov_len == 0) {\n buffersStolen++;\n }\n }\n\n // cork the current write if the original flags included CORK or if there\n // are remaining iovec to write\n corkCurrentWrite_ =\n isSet(flags, WriteFlags::CORK) || (i + buffersStolen + 1 < count);\n\n // track the EoR if:\n // (1) there are write flags that require EoR tracking (EOR / TIMESTAMP_TX)\n // (2) if the buffer includes the EOR byte\n appEorByteWriteFlags_ = flags & kEorRelevantWriteFlags;\n bool trackEor = appEorByteWriteFlags_ != folly::WriteFlags::NONE &&\n (i + buffersStolen + 1 == count);\n bytes = eorAwareSSLWrite(ssl_, sslWriteBuf, int(len), trackEor);\n\n if (bytes <= 0) {\n int error = SSL_get_error(ssl_.get(), int(bytes));\n if (error == SSL_ERROR_WANT_WRITE) {\n // The caller will register for write event if not already.\n *partialWritten = uint32_t(offset);\n return WriteResult(totalWritten);\n }\n return interpretSSLError(int(bytes), error);\n }\n\n totalWritten += bytes;\n\n if (bytes == (ssize_t)len) {\n // The full iovec is written.\n (*countWritten) += 1 + buffersStolen;\n i += buffersStolen;\n // continue\n } else {\n bytes += offset; // adjust bytes to account for all of v\n while (bytes >= (ssize_t)v->iov_len) {\n // We combined this buf with part or all of the next one, and\n // we managed to write all of this buf but not all of the bytes\n // from the next one that we'd hoped to write.\n bytes -= v->iov_len;\n (*countWritten)++;\n v = &(vec[++i]);\n }\n *partialWritten = uint32_t(bytes);\n return WriteResult(totalWritten);\n }\n }\n\n return WriteResult(totalWritten);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11934", "cwe_id": "CWE-125" }, { "id": 1928, "func": " bool CheckRegion(int nPos, int nSize)\n {\n return (nPos >= 0 && nPos + nSize >= nPos && nPos + nSize <= m_nLen);\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-29777", "cwe_id": "CWE-787" }, { "id": 1928, "func": " bool CheckRegion(const unsigned int& nPos, const unsigned int& nSize)\n {\n return (m_nLen >= nSize && nPos <= (m_nLen - nSize));\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-29777", "cwe_id": "CWE-787" }, { "id": 1470, "func": "ast2obj_withitem(void* _o)\n{\n withitem_ty o = (withitem_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n result = PyType_GenericNew(withitem_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_expr(o->context_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->optional_vars);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1470, "func": "ast2obj_withitem(void* _o)\n{\n withitem_ty o = (withitem_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_RETURN_NONE;\n }\n\n result = PyType_GenericNew(withitem_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_expr(o->context_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->optional_vars);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1822, "func": "static noinline int btrfs_ioctl_resize(struct file *file,\n\t\t\t\t\tvoid __user *arg)\n{\n\tstruct inode *inode = file_inode(file);\n\tstruct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);\n\tu64 new_size;\n\tu64 old_size;\n\tu64 devid = 1;\n\tstruct btrfs_root *root = BTRFS_I(inode)->root;\n\tstruct btrfs_ioctl_vol_args *vol_args;\n\tstruct btrfs_trans_handle *trans;\n\tstruct btrfs_device *device = NULL;\n\tchar *sizestr;\n\tchar *retptr;\n\tchar *devstr = NULL;\n\tint ret = 0;\n\tint mod = 0;\n\n\tif (!capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\tret = mnt_want_write_file(file);\n\tif (ret)\n\t\treturn ret;\n\n\tif (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) {\n\t\tmnt_drop_write_file(file);\n\t\treturn BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;\n\t}\n\n\tvol_args = memdup_user(arg, sizeof(*vol_args));\n\tif (IS_ERR(vol_args)) {\n\t\tret = PTR_ERR(vol_args);\n\t\tgoto out;\n\t}\n\n\tvol_args->name[BTRFS_PATH_NAME_MAX] = '\\0';\n\n\tsizestr = vol_args->name;\n\tdevstr = strchr(sizestr, ':');\n\tif (devstr) {\n\t\tsizestr = devstr + 1;\n\t\t*devstr = '\\0';\n\t\tdevstr = vol_args->name;\n\t\tret = kstrtoull(devstr, 10, &devid);\n\t\tif (ret)\n\t\t\tgoto out_free;\n\t\tif (!devid) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t\tbtrfs_info(fs_info, \"resizing devid %llu\", devid);\n\t}\n\n\tdevice = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL);\n\tif (!device) {\n\t\tbtrfs_info(fs_info, \"resizer unable to find device %llu\",\n\t\t\t devid);\n\t\tret = -ENODEV;\n\t\tgoto out_free;\n\t}\n\n\tif (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tbtrfs_info(fs_info,\n\t\t\t \"resizer unable to apply on readonly device %llu\",\n\t\t devid);\n\t\tret = -EPERM;\n\t\tgoto out_free;\n\t}\n\n\tif (!strcmp(sizestr, \"max\"))\n\t\tnew_size = device->bdev->bd_inode->i_size;\n\telse {\n\t\tif (sizestr[0] == '-') {\n\t\t\tmod = -1;\n\t\t\tsizestr++;\n\t\t} else if (sizestr[0] == '+') {\n\t\t\tmod = 1;\n\t\t\tsizestr++;\n\t\t}\n\t\tnew_size = memparse(sizestr, &retptr);\n\t\tif (*retptr != '\\0' || new_size == 0) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tret = -EPERM;\n\t\tgoto out_free;\n\t}\n\n\told_size = btrfs_device_get_total_bytes(device);\n\n\tif (mod < 0) {\n\t\tif (new_size > old_size) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t\tnew_size = old_size - new_size;\n\t} else if (mod > 0) {\n\t\tif (new_size > ULLONG_MAX - old_size) {\n\t\t\tret = -ERANGE;\n\t\t\tgoto out_free;\n\t\t}\n\t\tnew_size = old_size + new_size;\n\t}\n\n\tif (new_size < SZ_256M) {\n\t\tret = -EINVAL;\n\t\tgoto out_free;\n\t}\n\tif (new_size > device->bdev->bd_inode->i_size) {\n\t\tret = -EFBIG;\n\t\tgoto out_free;\n\t}\n\n\tnew_size = round_down(new_size, fs_info->sectorsize);\n\n\tbtrfs_info_in_rcu(fs_info, \"new size for %s is %llu\",\n\t\t\t rcu_str_deref(device->name), new_size);\n\n\tif (new_size > old_size) {\n\t\ttrans = btrfs_start_transaction(root, 0);\n\t\tif (IS_ERR(trans)) {\n\t\t\tret = PTR_ERR(trans);\n\t\t\tgoto out_free;\n\t\t}\n\t\tret = btrfs_grow_device(trans, device, new_size);\n\t\tbtrfs_commit_transaction(trans);\n\t} else if (new_size < old_size) {\n\t\tret = btrfs_shrink_device(device, new_size);\n\t} /* equal, nothing need to do */\n\nout_free:\n\tkfree(vol_args);\nout:\n\tclear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);\n\tmnt_drop_write_file(file);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 1822, "func": "static noinline int btrfs_ioctl_resize(struct file *file,\n\t\t\t\t\tvoid __user *arg)\n{\n\tstruct inode *inode = file_inode(file);\n\tstruct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);\n\tu64 new_size;\n\tu64 old_size;\n\tu64 devid = 1;\n\tstruct btrfs_root *root = BTRFS_I(inode)->root;\n\tstruct btrfs_ioctl_vol_args *vol_args;\n\tstruct btrfs_trans_handle *trans;\n\tstruct btrfs_device *device = NULL;\n\tchar *sizestr;\n\tchar *retptr;\n\tchar *devstr = NULL;\n\tint ret = 0;\n\tint mod = 0;\n\n\tif (!capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\tret = mnt_want_write_file(file);\n\tif (ret)\n\t\treturn ret;\n\n\tif (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) {\n\t\tmnt_drop_write_file(file);\n\t\treturn BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;\n\t}\n\n\tvol_args = memdup_user(arg, sizeof(*vol_args));\n\tif (IS_ERR(vol_args)) {\n\t\tret = PTR_ERR(vol_args);\n\t\tgoto out;\n\t}\n\n\tvol_args->name[BTRFS_PATH_NAME_MAX] = '\\0';\n\n\tsizestr = vol_args->name;\n\tdevstr = strchr(sizestr, ':');\n\tif (devstr) {\n\t\tsizestr = devstr + 1;\n\t\t*devstr = '\\0';\n\t\tdevstr = vol_args->name;\n\t\tret = kstrtoull(devstr, 10, &devid);\n\t\tif (ret)\n\t\t\tgoto out_free;\n\t\tif (!devid) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t\tbtrfs_info(fs_info, \"resizing devid %llu\", devid);\n\t}\n\n\tdevice = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL, true);\n\tif (!device) {\n\t\tbtrfs_info(fs_info, \"resizer unable to find device %llu\",\n\t\t\t devid);\n\t\tret = -ENODEV;\n\t\tgoto out_free;\n\t}\n\n\tif (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tbtrfs_info(fs_info,\n\t\t\t \"resizer unable to apply on readonly device %llu\",\n\t\t devid);\n\t\tret = -EPERM;\n\t\tgoto out_free;\n\t}\n\n\tif (!strcmp(sizestr, \"max\"))\n\t\tnew_size = device->bdev->bd_inode->i_size;\n\telse {\n\t\tif (sizestr[0] == '-') {\n\t\t\tmod = -1;\n\t\t\tsizestr++;\n\t\t} else if (sizestr[0] == '+') {\n\t\t\tmod = 1;\n\t\t\tsizestr++;\n\t\t}\n\t\tnew_size = memparse(sizestr, &retptr);\n\t\tif (*retptr != '\\0' || new_size == 0) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tret = -EPERM;\n\t\tgoto out_free;\n\t}\n\n\told_size = btrfs_device_get_total_bytes(device);\n\n\tif (mod < 0) {\n\t\tif (new_size > old_size) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_free;\n\t\t}\n\t\tnew_size = old_size - new_size;\n\t} else if (mod > 0) {\n\t\tif (new_size > ULLONG_MAX - old_size) {\n\t\t\tret = -ERANGE;\n\t\t\tgoto out_free;\n\t\t}\n\t\tnew_size = old_size + new_size;\n\t}\n\n\tif (new_size < SZ_256M) {\n\t\tret = -EINVAL;\n\t\tgoto out_free;\n\t}\n\tif (new_size > device->bdev->bd_inode->i_size) {\n\t\tret = -EFBIG;\n\t\tgoto out_free;\n\t}\n\n\tnew_size = round_down(new_size, fs_info->sectorsize);\n\n\tbtrfs_info_in_rcu(fs_info, \"new size for %s is %llu\",\n\t\t\t rcu_str_deref(device->name), new_size);\n\n\tif (new_size > old_size) {\n\t\ttrans = btrfs_start_transaction(root, 0);\n\t\tif (IS_ERR(trans)) {\n\t\t\tret = PTR_ERR(trans);\n\t\t\tgoto out_free;\n\t\t}\n\t\tret = btrfs_grow_device(trans, device, new_size);\n\t\tbtrfs_commit_transaction(trans);\n\t} else if (new_size < old_size) {\n\t\tret = btrfs_shrink_device(device, new_size);\n\t} /* equal, nothing need to do */\n\nout_free:\n\tkfree(vol_args);\nout:\n\tclear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);\n\tmnt_drop_write_file(file);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 1768, "func": "static int filter_frame(AVFilterLink *inlink, AVFrame *frame)\n{\n AVFilterContext *ctx = inlink->dst;\n FieldOrderContext *s = ctx->priv;\n AVFilterLink *outlink = ctx->outputs[0];\n int h, plane, line_step, line_size, line;\n uint8_t *data;\n\n if (!frame->interlaced_frame ||\n frame->top_field_first == s->dst_tff)\n return ff_filter_frame(outlink, frame);\n\n av_dlog(ctx,\n \"picture will move %s one line\\n\",\n s->dst_tff ? \"up\" : \"down\");\n h = frame->height;\n for (plane = 0; plane < 4 && frame->data[plane]; plane++) {\n line_step = frame->linesize[plane];\n line_size = s->line_size[plane];\n data = frame->data[plane];\n if (s->dst_tff) {\n /** Move every line up one line, working from\n * the top to the bottom of the frame.\n * The original top line is lost.\n * The new last line is created as a copy of the\n * penultimate line from that field. */\n for (line = 0; line < h; line++) {\n if (1 + line < frame->height) {\n memcpy(data, data + line_step, line_size);\n } else {\n memcpy(data, data - line_step - line_step, line_size);\n }\n data += line_step;\n }\n } else {\n /** Move every line down one line, working from\n * the bottom to the top of the frame.\n * The original bottom line is lost.\n * The new first line is created as a copy of the\n * second line from that field. */\n data += (h - 1) * line_step;\n for (line = h - 1; line >= 0 ; line--) {\n if (line > 0) {\n memcpy(data, data - line_step, line_size);\n } else {\n memcpy(data, data + line_step + line_step, line_size);\n }\n data -= line_step;\n }\n }\n }\n frame->top_field_first = s->dst_tff;\n\n return ff_filter_frame(outlink, frame);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-4263", "cwe_id": "CWE-119" }, { "id": 1768, "func": "static int filter_frame(AVFilterLink *inlink, AVFrame *frame)\n{\n AVFilterContext *ctx = inlink->dst;\n FieldOrderContext *s = ctx->priv;\n AVFilterLink *outlink = ctx->outputs[0];\n int h, plane, line_step, line_size, line;\n uint8_t *data;\n\n if (!frame->interlaced_frame ||\n frame->top_field_first == s->dst_tff)\n return ff_filter_frame(outlink, frame);\n\n av_dlog(ctx,\n \"picture will move %s one line\\n\",\n s->dst_tff ? \"up\" : \"down\");\n h = frame->height;\n for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) {\n line_step = frame->linesize[plane];\n line_size = s->line_size[plane];\n data = frame->data[plane];\n if (s->dst_tff) {\n /** Move every line up one line, working from\n * the top to the bottom of the frame.\n * The original top line is lost.\n * The new last line is created as a copy of the\n * penultimate line from that field. */\n for (line = 0; line < h; line++) {\n if (1 + line < frame->height) {\n memcpy(data, data + line_step, line_size);\n } else {\n memcpy(data, data - line_step - line_step, line_size);\n }\n data += line_step;\n }\n } else {\n /** Move every line down one line, working from\n * the bottom to the top of the frame.\n * The original bottom line is lost.\n * The new first line is created as a copy of the\n * second line from that field. */\n data += (h - 1) * line_step;\n for (line = h - 1; line >= 0 ; line--) {\n if (line > 0) {\n memcpy(data, data - line_step, line_size);\n } else {\n memcpy(data, data + line_step + line_step, line_size);\n }\n data -= line_step;\n }\n }\n }\n frame->top_field_first = s->dst_tff;\n\n return ff_filter_frame(outlink, frame);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-4263", "cwe_id": "CWE-119" }, { "id": 180, "func": "bool initiate_stratum(struct pool *pool)\n{\n\tbool ret = false, recvd = false, noresume = false, sockd = false;\n\tchar s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid;\n\tjson_t *val = NULL, *res_val, *err_val;\n\tjson_error_t err;\n\tint n2size;\n\nresend:\n\tif (!setup_stratum_socket(pool)) {\n\t\t/* FIXME: change to LOG_DEBUG when issue #88 resolved */\n\t\tapplog(LOG_INFO, \"setup_stratum_socket() on %s failed\", get_pool_name(pool));\n\t\tsockd = false;\n\t\tgoto out;\n\t}\n\n\tsockd = true;\n\n\tif (recvd) {\n\t\t/* Get rid of any crap lying around if we're resending */\n\t\tclear_sock(pool);\n\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": []}\", swork_id++);\n\t} else {\n\t\tif (pool->sessionid)\n\t\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": [\\\"\"PACKAGE\"/\"VERSION\"\\\", \\\"%s\\\"]}\", swork_id++, pool->sessionid);\n\t\telse\n\t\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": [\\\"\"PACKAGE\"/\"VERSION\"\\\"]}\", swork_id++);\n\t}\n\n\tif (__stratum_send(pool, s, strlen(s)) != SEND_OK) {\n\t\tapplog(LOG_DEBUG, \"Failed to send s in initiate_stratum\");\n\t\tgoto out;\n\t}\n\n\tif (!socket_full(pool, DEFAULT_SOCKWAIT)) {\n\t\tapplog(LOG_DEBUG, \"Timed out waiting for response in initiate_stratum\");\n\t\tgoto out;\n\t}\n\n\tsret = recv_line(pool);\n\tif (!sret)\n\t\tgoto out;\n\n\trecvd = true;\n\n\tval = JSON_LOADS(sret, &err);\n\tfree(sret);\n\tif (!val) {\n\t\tapplog(LOG_INFO, \"JSON decode failed(%d): %s\", err.line, err.text);\n\t\tgoto out;\n\t}\n\n\tres_val = json_object_get(val, \"result\");\n\terr_val = json_object_get(val, \"error\");\n\n\tif (!res_val || json_is_null(res_val) ||\n\t (err_val && !json_is_null(err_val))) {\n\t\tchar *ss;\n\n\t\tif (err_val)\n\t\t\tss = json_dumps(err_val, JSON_INDENT(3));\n\t\telse\n\t\t\tss = strdup(\"(unknown reason)\");\n\n\t\tapplog(LOG_INFO, \"JSON-RPC decode failed: %s\", ss);\n\n\t\tfree(ss);\n\n\t\tgoto out;\n\t}\n\n\tsessionid = get_sessionid(res_val);\n\tif (!sessionid)\n\t\tapplog(LOG_DEBUG, \"Failed to get sessionid in initiate_stratum\");\n\tnonce1 = json_array_string(res_val, 1);\n\tif (!nonce1) {\n\t\tapplog(LOG_INFO, \"Failed to get nonce1 in initiate_stratum\");\n\t\tfree(sessionid);\n\t\tgoto out;\n\t}\n\tn2size = json_integer_value(json_array_get(res_val, 2));\n\tif (!n2size) {\n\t\tapplog(LOG_INFO, \"Failed to get n2size in initiate_stratum\");\n\t\tfree(sessionid);\n\t\tfree(nonce1);\n\t\tgoto out;\n\t}\n\n\tcg_wlock(&pool->data_lock);\n\tpool->sessionid = sessionid;\n\tpool->nonce1 = nonce1;\n\tpool->n1_len = strlen(nonce1) / 2;\n\tfree(pool->nonce1bin);\n\tpool->nonce1bin = (unsigned char *)calloc(pool->n1_len, 1);\n\tif (unlikely(!pool->nonce1bin))\n\t\tquithere(1, \"Failed to calloc pool->nonce1bin\");\n\thex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);\n\tpool->n2size = n2size;\n\tcg_wunlock(&pool->data_lock);\n\n\tif (sessionid)\n\t\tapplog(LOG_DEBUG, \"%s stratum session id: %s\", get_pool_name(pool), pool->sessionid);\n\n\tret = true;\nout:\n\tif (ret) {\n\t\tif (!pool->stratum_url)\n\t\t\tpool->stratum_url = pool->sockaddr_url;\n\t\tpool->stratum_active = true;\n\t\tpool->swork.diff = 1;\n\t\tif (opt_protocol) {\n\t\t\tapplog(LOG_DEBUG, \"%s confirmed mining.subscribe with extranonce1 %s extran2size %d\",\n\t\t\t get_pool_name(pool), pool->nonce1, pool->n2size);\n\t\t}\n\t} else {\n\t\tif (recvd && !noresume) {\n\t\t\t/* Reset the sessionid used for stratum resuming in case the pool\n\t\t\t* does not support it, or does not know how to respond to the\n\t\t\t* presence of the sessionid parameter. */\n\t\t\tcg_wlock(&pool->data_lock);\n\t\t\tfree(pool->sessionid);\n\t\t\tfree(pool->nonce1);\n\t\t\tpool->sessionid = pool->nonce1 = NULL;\n\t\t\tcg_wunlock(&pool->data_lock);\n\n\t\t\tapplog(LOG_DEBUG, \"Failed to resume stratum, trying afresh\");\n\t\t\tnoresume = true;\n\t\t\tjson_decref(val);\n\t\t\tgoto resend;\n\t\t}\n\t\tapplog(LOG_DEBUG, \"Initiating stratum failed on %s\", get_pool_name(pool));\n\t\tif (sockd) {\n\t\t applog(LOG_DEBUG, \"Suspending stratum on %s\", get_pool_name(pool));\n\t\t\tsuspend_stratum(pool);\n\t\t}\n\t}\n\n\tjson_decref(val);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-4502", "cwe_id": "CWE-119" }, { "id": 180, "func": "bool initiate_stratum(struct pool *pool)\n{\n\tbool ret = false, recvd = false, noresume = false, sockd = false;\n\tchar s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid;\n\tjson_t *val = NULL, *res_val, *err_val;\n\tjson_error_t err;\n\tint n2size;\n\nresend:\n\tif (!setup_stratum_socket(pool)) {\n\t\t/* FIXME: change to LOG_DEBUG when issue #88 resolved */\n\t\tapplog(LOG_INFO, \"setup_stratum_socket() on %s failed\", get_pool_name(pool));\n\t\tsockd = false;\n\t\tgoto out;\n\t}\n\n\tsockd = true;\n\n\tif (recvd) {\n\t\t/* Get rid of any crap lying around if we're resending */\n\t\tclear_sock(pool);\n\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": []}\", swork_id++);\n\t} else {\n\t\tif (pool->sessionid)\n\t\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": [\\\"\"PACKAGE\"/\"VERSION\"\\\", \\\"%s\\\"]}\", swork_id++, pool->sessionid);\n\t\telse\n\t\t\tsprintf(s, \"{\\\"id\\\": %d, \\\"method\\\": \\\"mining.subscribe\\\", \\\"params\\\": [\\\"\"PACKAGE\"/\"VERSION\"\\\"]}\", swork_id++);\n\t}\n\n\tif (__stratum_send(pool, s, strlen(s)) != SEND_OK) {\n\t\tapplog(LOG_DEBUG, \"Failed to send s in initiate_stratum\");\n\t\tgoto out;\n\t}\n\n\tif (!socket_full(pool, DEFAULT_SOCKWAIT)) {\n\t\tapplog(LOG_DEBUG, \"Timed out waiting for response in initiate_stratum\");\n\t\tgoto out;\n\t}\n\n\tsret = recv_line(pool);\n\tif (!sret)\n\t\tgoto out;\n\n\trecvd = true;\n\n\tval = JSON_LOADS(sret, &err);\n\tfree(sret);\n\tif (!val) {\n\t\tapplog(LOG_INFO, \"JSON decode failed(%d): %s\", err.line, err.text);\n\t\tgoto out;\n\t}\n\n\tres_val = json_object_get(val, \"result\");\n\terr_val = json_object_get(val, \"error\");\n\n\tif (!res_val || json_is_null(res_val) ||\n\t (err_val && !json_is_null(err_val))) {\n\t\tchar *ss;\n\n\t\tif (err_val)\n\t\t\tss = json_dumps(err_val, JSON_INDENT(3));\n\t\telse\n\t\t\tss = strdup(\"(unknown reason)\");\n\n\t\tapplog(LOG_INFO, \"JSON-RPC decode failed: %s\", ss);\n\n\t\tfree(ss);\n\n\t\tgoto out;\n\t}\n\n\tsessionid = get_sessionid(res_val);\n\tif (!sessionid)\n\t\tapplog(LOG_DEBUG, \"Failed to get sessionid in initiate_stratum\");\n\tnonce1 = json_array_string(res_val, 1);\n\tif (!nonce1) {\n\t\tapplog(LOG_INFO, \"Failed to get nonce1 in initiate_stratum\");\n\t\tfree(sessionid);\n\t\tgoto out;\n\t}\n\tn2size = json_integer_value(json_array_get(res_val, 2));\n\tif (n2size < 1)\n\t{\n\t\tapplog(LOG_INFO, \"Failed to get n2size in initiate_stratum\");\n\t\tfree(sessionid);\n\t\tfree(nonce1);\n\t\tgoto out;\n\t}\n\n\tcg_wlock(&pool->data_lock);\n\tpool->sessionid = sessionid;\n\tpool->nonce1 = nonce1;\n\tpool->n1_len = strlen(nonce1) / 2;\n\tfree(pool->nonce1bin);\n\tpool->nonce1bin = (unsigned char *)calloc(pool->n1_len, 1);\n\tif (unlikely(!pool->nonce1bin))\n\t\tquithere(1, \"Failed to calloc pool->nonce1bin\");\n\thex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);\n\tpool->n2size = n2size;\n\tcg_wunlock(&pool->data_lock);\n\n\tif (sessionid)\n\t\tapplog(LOG_DEBUG, \"%s stratum session id: %s\", get_pool_name(pool), pool->sessionid);\n\n\tret = true;\nout:\n\tif (ret) {\n\t\tif (!pool->stratum_url)\n\t\t\tpool->stratum_url = pool->sockaddr_url;\n\t\tpool->stratum_active = true;\n\t\tpool->swork.diff = 1;\n\t\tif (opt_protocol) {\n\t\t\tapplog(LOG_DEBUG, \"%s confirmed mining.subscribe with extranonce1 %s extran2size %d\",\n\t\t\t get_pool_name(pool), pool->nonce1, pool->n2size);\n\t\t}\n\t} else {\n\t\tif (recvd && !noresume) {\n\t\t\t/* Reset the sessionid used for stratum resuming in case the pool\n\t\t\t* does not support it, or does not know how to respond to the\n\t\t\t* presence of the sessionid parameter. */\n\t\t\tcg_wlock(&pool->data_lock);\n\t\t\tfree(pool->sessionid);\n\t\t\tfree(pool->nonce1);\n\t\t\tpool->sessionid = pool->nonce1 = NULL;\n\t\t\tcg_wunlock(&pool->data_lock);\n\n\t\t\tapplog(LOG_DEBUG, \"Failed to resume stratum, trying afresh\");\n\t\t\tnoresume = true;\n\t\t\tjson_decref(val);\n\t\t\tgoto resend;\n\t\t}\n\t\tapplog(LOG_DEBUG, \"Initiating stratum failed on %s\", get_pool_name(pool));\n\t\tif (sockd) {\n\t\t applog(LOG_DEBUG, \"Suspending stratum on %s\", get_pool_name(pool));\n\t\t\tsuspend_stratum(pool);\n\t\t}\n\t}\n\n\tjson_decref(val);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-4502", "cwe_id": "CWE-119" }, { "id": 3016, "func": "void APar_ExtractDetails(FILE *isofile, uint8_t optional_output) {\n char uint32_buffer[5];\n Trackage track = {0};\n\n AtomicInfo *mvhdAtom = APar_FindAtom(\"moov.mvhd\", false, VERSIONED_ATOM, 0);\n if (mvhdAtom != NULL) {\n APar_ExtractMovieDetails(uint32_buffer, isofile, mvhdAtom);\n fprintf(stdout,\n \"Movie duration: %.3lf seconds (%s) - %.2lf* kbp/sec bitrate \"\n \"(*=approximate)\\n\",\n movie_info.seconds,\n secsTOtime(movie_info.seconds),\n movie_info.simple_bitrate_calc);\n if (optional_output & SHOW_DATE_INFO) {\n fprintf(stdout,\n \" Presentation Creation Date (UTC): %s\\n\",\n APar_extract_UTC(movie_info.creation_time));\n fprintf(stdout,\n \" Presentation Modification Date (UTC): %s\\n\",\n APar_extract_UTC(movie_info.modified_time));\n }\n }\n\n AtomicInfo *iodsAtom = APar_FindAtom(\"moov.iods\", false, VERSIONED_ATOM, 0);\n if (iodsAtom != NULL) {\n movie_info.contains_iods = true;\n APar_Extract_iods_Info(isofile, iodsAtom);\n }\n\n if (optional_output & SHOW_TRACK_INFO) {\n APar_TrackLevelInfo(&track,\n NULL); // With track_num set to 0, it will return the\n // total trak atom into total_tracks here.\n\n fprintf(\n stdout, \"Low-level details. Total tracks: %u\\n\", track.total_tracks);\n fprintf(stdout,\n \"Trk Type Handler Kind Lang Bytes\\n\");\n\n if (track.total_tracks > 0) {\n while (track.total_tracks > track.track_num) {\n track.track_num += 1;\n TrackInfo track_info = {0};\n\n // tracknum, handler type, handler name\n APar_ExtractTrackDetails(uint32_buffer, isofile, &track, &track_info);\n uint16_t more_whitespace =\n purge_extraneous_characters(track_info.track_hdlr_name);\n\n if (strlen(track_info.track_hdlr_name) == 0) {\n memcpy(track_info.track_hdlr_name, \"[none listed]\", 13);\n }\n fprintf(stdout,\n \"%u %s %s\",\n track.track_num,\n uint32tochar4(track_info.track_type, uint32_buffer),\n track_info.track_hdlr_name);\n\n uint16_t handler_len = strlen(track_info.track_hdlr_name);\n if (handler_len < 25 + more_whitespace) {\n for (uint16_t i = handler_len; i < 25 + more_whitespace; i++) {\n fprintf(stdout, \" \");\n }\n }\n\n // codec, language\n fprintf(stdout,\n \" %s %s %\" PRIu64,\n uint32tochar4(track_info.track_codec, uint32_buffer),\n track_info.unpacked_lang,\n track_info.sample_aggregate);\n\n if (track_info.encoder_name[0] != 0 && track_info.contains_esds) {\n purge_extraneous_characters(track_info.encoder_name);\n fprintf(stdout, \" Encoder: %s\", track_info.encoder_name);\n }\n if (track_info.type_of_track & DRM_PROTECTED_TRACK) {\n fprintf(stdout,\n \" (protected %s)\",\n uint32tochar4(track_info.protected_codec, uint32_buffer));\n }\n\n fprintf(stdout, \"\\n\");\n /*---------------------------------*/\n\n if (track_info.type_of_track & VIDEO_TRACK ||\n track_info.type_of_track & AUDIO_TRACK) {\n APar_Print_TrackDetails(&track_info);\n }\n\n if (optional_output & SHOW_DATE_INFO) {\n fprintf(stdout,\n \" Creation Date (UTC): %s\\n\",\n APar_extract_UTC(track_info.creation_time));\n fprintf(stdout,\n \" Modification Date (UTC): %s\\n\",\n APar_extract_UTC(track_info.modified_time));\n }\n }\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-37232", "cwe_id": "CWE-787" }, { "id": 3016, "func": "void APar_ExtractDetails(FILE *isofile, uint8_t optional_output) {\n char uint32_buffer[8];\n Trackage track = {0};\n\n AtomicInfo *mvhdAtom = APar_FindAtom(\"moov.mvhd\", false, VERSIONED_ATOM, 0);\n if (mvhdAtom != NULL) {\n APar_ExtractMovieDetails(uint32_buffer, isofile, mvhdAtom);\n fprintf(stdout,\n \"Movie duration: %.3lf seconds (%s) - %.2lf* kbp/sec bitrate \"\n \"(*=approximate)\\n\",\n movie_info.seconds,\n secsTOtime(movie_info.seconds),\n movie_info.simple_bitrate_calc);\n if (optional_output & SHOW_DATE_INFO) {\n fprintf(stdout,\n \" Presentation Creation Date (UTC): %s\\n\",\n APar_extract_UTC(movie_info.creation_time));\n fprintf(stdout,\n \" Presentation Modification Date (UTC): %s\\n\",\n APar_extract_UTC(movie_info.modified_time));\n }\n }\n\n AtomicInfo *iodsAtom = APar_FindAtom(\"moov.iods\", false, VERSIONED_ATOM, 0);\n if (iodsAtom != NULL) {\n movie_info.contains_iods = true;\n APar_Extract_iods_Info(isofile, iodsAtom);\n }\n\n if (optional_output & SHOW_TRACK_INFO) {\n APar_TrackLevelInfo(&track,\n NULL); // With track_num set to 0, it will return the\n // total trak atom into total_tracks here.\n\n fprintf(\n stdout, \"Low-level details. Total tracks: %u\\n\", track.total_tracks);\n fprintf(stdout,\n \"Trk Type Handler Kind Lang Bytes\\n\");\n\n if (track.total_tracks > 0) {\n while (track.total_tracks > track.track_num) {\n track.track_num += 1;\n TrackInfo track_info = {0};\n\n // tracknum, handler type, handler name\n APar_ExtractTrackDetails(uint32_buffer, isofile, &track, &track_info);\n uint16_t more_whitespace =\n purge_extraneous_characters(track_info.track_hdlr_name);\n\n if (strlen(track_info.track_hdlr_name) == 0) {\n memcpy(track_info.track_hdlr_name, \"[none listed]\", 13);\n }\n fprintf(stdout,\n \"%u %s %s\",\n track.track_num,\n uint32tochar4(track_info.track_type, uint32_buffer),\n track_info.track_hdlr_name);\n\n uint16_t handler_len = strlen(track_info.track_hdlr_name);\n if (handler_len < 25 + more_whitespace) {\n for (uint16_t i = handler_len; i < 25 + more_whitespace; i++) {\n fprintf(stdout, \" \");\n }\n }\n\n // codec, language\n fprintf(stdout,\n \" %s %s %\" PRIu64,\n uint32tochar4(track_info.track_codec, uint32_buffer),\n track_info.unpacked_lang,\n track_info.sample_aggregate);\n\n if (track_info.encoder_name[0] != 0 && track_info.contains_esds) {\n purge_extraneous_characters(track_info.encoder_name);\n fprintf(stdout, \" Encoder: %s\", track_info.encoder_name);\n }\n if (track_info.type_of_track & DRM_PROTECTED_TRACK) {\n fprintf(stdout,\n \" (protected %s)\",\n uint32tochar4(track_info.protected_codec, uint32_buffer));\n }\n\n fprintf(stdout, \"\\n\");\n /*---------------------------------*/\n\n if (track_info.type_of_track & VIDEO_TRACK ||\n track_info.type_of_track & AUDIO_TRACK) {\n APar_Print_TrackDetails(&track_info);\n }\n\n if (optional_output & SHOW_DATE_INFO) {\n fprintf(stdout,\n \" Creation Date (UTC): %s\\n\",\n APar_extract_UTC(track_info.creation_time));\n fprintf(stdout,\n \" Modification Date (UTC): %s\\n\",\n APar_extract_UTC(track_info.modified_time));\n }\n }\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-37232", "cwe_id": "CWE-787" }, { "id": 122, "func": "cleanup_pathname(struct archive_write_disk *a)\n{\n\tchar *dest, *src;\n\tchar separator = '\\0';\n\n\tdest = src = a->name;\n\tif (*src == '\\0') {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"Invalid empty pathname\");\n\t\treturn (ARCHIVE_FAILED);\n\t}\n\n#if defined(__CYGWIN__)\n\tcleanup_pathname_win(a);\n#endif\n\t/* Skip leading '/'. */\n\tif (*src == '/') {\n\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t \"Path is absolute\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\n\t\tseparator = *src++;\n\t}\n\n\t/* Scan the pathname one element at a time. */\n\tfor (;;) {\n\t\t/* src points to first char after '/' */\n\t\tif (src[0] == '\\0') {\n\t\t\tbreak;\n\t\t} else if (src[0] == '/') {\n\t\t\t/* Found '//', ignore second one. */\n\t\t\tsrc++;\n\t\t\tcontinue;\n\t\t} else if (src[0] == '.') {\n\t\t\tif (src[1] == '\\0') {\n\t\t\t\t/* Ignore trailing '.' */\n\t\t\t\tbreak;\n\t\t\t} else if (src[1] == '/') {\n\t\t\t\t/* Skip './'. */\n\t\t\t\tsrc += 2;\n\t\t\t\tcontinue;\n\t\t\t} else if (src[1] == '.') {\n\t\t\t\tif (src[2] == '/' || src[2] == '\\0') {\n\t\t\t\t\t/* Conditionally warn about '..' */\n\t\t\t\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {\n\t\t\t\t\t\tarchive_set_error(&a->archive,\n\t\t\t\t\t\t ARCHIVE_ERRNO_MISC,\n\t\t\t\t\t\t \"Path contains '..'\");\n\t\t\t\t\t\treturn (ARCHIVE_FAILED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/*\n\t\t\t\t * Note: Under no circumstances do we\n\t\t\t\t * remove '..' elements. In\n\t\t\t\t * particular, restoring\n\t\t\t\t * '/foo/../bar/' should create the\n\t\t\t\t * 'foo' dir as a side-effect.\n\t\t\t\t */\n\t\t\t}\n\t\t}\n\n\t\t/* Copy current element, including leading '/'. */\n\t\tif (separator)\n\t\t\t*dest++ = '/';\n\t\twhile (*src != '\\0' && *src != '/') {\n\t\t\t*dest++ = *src++;\n\t\t}\n\n\t\tif (*src == '\\0')\n\t\t\tbreak;\n\n\t\t/* Skip '/' separator. */\n\t\tseparator = *src++;\n\t}\n\t/*\n\t * We've just copied zero or more path elements, not including the\n\t * final '/'.\n\t */\n\tif (dest == a->name) {\n\t\t/*\n\t\t * Nothing got copied. The path must have been something\n\t\t * like '.' or '/' or './' or '/././././/./'.\n\t\t */\n\t\tif (separator)\n\t\t\t*dest++ = '/';\n\t\telse\n\t\t\t*dest++ = '.';\n\t}\n\t/* Terminate the result. */\n\t*dest = '\\0';\n\treturn (ARCHIVE_OK);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5418", "cwe_id": "CWE-20" }, { "id": 122, "func": "cleanup_pathname(struct archive_write_disk *a)\n{\n\tstruct archive_string error_string;\n\tint error_number;\n\tint rc;\n\tarchive_string_init(&error_string);\n\trc = cleanup_pathname_fsobj(a->name, &error_number, &error_string, a->flags);\n\tif (rc != ARCHIVE_OK) {\n\t\tarchive_set_error(&a->archive, error_number, \"%s\", error_string.s);\n\t}\n\tarchive_string_free(&error_string);\n\treturn rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5418", "cwe_id": "CWE-20" }, { "id": 347, "func": "ut64 MACH0_(get_main)(struct MACH0_(obj_t)* bin) {\n\tut64 addr = 0LL;\n\tstruct symbol_t *symbols;\n\tint i;\n\n\tif (!(symbols = MACH0_(get_symbols) (bin))) {\n\t\treturn 0;\n\t}\n\tfor (i = 0; !symbols[i].last; i++) {\n\t\tif (!strcmp (symbols[i].name, \"_main\")) {\n\t\t\taddr = symbols[i].addr;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfree (symbols);\n\n\tif (!addr && bin->main_cmd.cmd == LC_MAIN) {\n\t\taddr = bin->entry + bin->baddr;\n\t}\n\n\tif (!addr) {\n\t\tut8 b[128];\n\t\tut64 entry = addr_to_offset(bin, bin->entry);\n\t\t// XXX: X86 only and hacky!\n\t\tif (entry > bin->size || entry + sizeof (b) > bin->size)\n\t\t\treturn 0;\n\t\ti = r_buf_read_at (bin->b, entry, b, sizeof (b));\n\t\tif (i < 1) {\n\t\t\treturn 0;\n\t\t}\n\t\tfor (i = 0; i < 64; i++) {\n\t\t\tif (b[i] == 0xe8 && !b[i+3] && !b[i+4]) {\n\t\t\t\tint delta = b[i+1] | (b[i+2] << 8) | (b[i+3] << 16) | (b[i+4] << 24);\n\t\t\t\treturn bin->entry + i + 5 + delta;\n\n\t\t\t}\n\t\t}\n\t}\n\treturn addr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7946", "cwe_id": "CWE-416" }, { "id": 347, "func": "ut64 MACH0_(get_main)(struct MACH0_(obj_t)* bin) {\n\tut64 addr = 0LL;\n\tstruct symbol_t *symbols;\n\tint i;\n\n\tif (!(symbols = MACH0_(get_symbols) (bin))) {\n\t\treturn 0;\n\t}\n\tfor (i = 0; !symbols[i].last; i++) {\n\t\tif (!strcmp (symbols[i].name, \"_main\")) {\n\t\t\taddr = symbols[i].addr;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfree (symbols);\n\n\tif (!addr && bin->main_cmd.cmd == LC_MAIN) {\n\t\taddr = bin->entry + bin->baddr;\n\t}\n\n\tif (!addr) {\n\t\tut8 b[128];\n\t\tut64 entry = addr_to_offset(bin, bin->entry);\n\t\t// XXX: X86 only and hacky!\n\t\tif (entry > bin->size || entry + sizeof (b) > bin->size) {\n\t\t\treturn 0;\n\t\t}\n\t\ti = r_buf_read_at (bin->b, entry, b, sizeof (b));\n\t\tif (i < 1) {\n\t\t\treturn 0;\n\t\t}\n\t\tfor (i = 0; i < 64; i++) {\n\t\t\tif (b[i] == 0xe8 && !b[i+3] && !b[i+4]) {\n\t\t\t\tint delta = b[i+1] | (b[i+2] << 8) | (b[i+3] << 16) | (b[i+4] << 24);\n\t\t\t\treturn bin->entry + i + 5 + delta;\n\n\t\t\t}\n\t\t}\n\t}\n\treturn addr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7946", "cwe_id": "CWE-416" }, { "id": 155, "func": " bool IsOpened() {return hFile!=FILE_BAD_HANDLE;};", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 155, "func": " virtual bool IsOpened() {return hFile!=FILE_BAD_HANDLE;};", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 2943, "func": "\tint lazy_bdecode(char const* start, char const* end, lazy_entry& ret\n\t\t, error_code& ec, int* error_pos, int depth_limit, int item_limit)\n\t{\n\t\tchar const* const orig_start = start;\n\t\tret.clear();\n\t\tif (start == end) return 0;\n\n\t\tstd::vector stack;\n\n\t\tstack.push_back(&ret);\n\t\twhile (start <= end)\n\t\t{\n\t\t\tif (stack.empty()) break; // done!\n\n\t\t\tlazy_entry* top = stack.back();\n\n\t\t\tif (int(stack.size()) > depth_limit) TORRENT_FAIL_BDECODE(bdecode_errors::depth_exceeded);\n\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\tchar t = *start;\n\t\t\t++start;\n\t\t\tif (start >= end && t != 'e') TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\tswitch (top->type())\n\t\t\t{\n\t\t\t\tcase lazy_entry::dict_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!numeric(t)) TORRENT_FAIL_BDECODE(bdecode_errors::expected_string);\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\n\t\t\t\t\tif (start + len + 1 > end)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tlazy_entry* ent = top->dict_append(start);\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstart += len;\n\t\t\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tt = *start;\n\t\t\t\t\t++start;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase lazy_entry::list_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlazy_entry* ent = top->list_append();\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: break;\n\t\t\t}\n\n\t\t\t--item_limit;\n\t\t\tif (item_limit <= 0) TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);\n\n\t\t\ttop = stack.back();\n\t\t\tswitch (t)\n\t\t\t{\n\t\t\t\tcase 'd':\n\t\t\t\t\ttop->construct_dict(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'l':\n\t\t\t\t\ttop->construct_list(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'i':\n\t\t\t\t{\n\t\t\t\t\tchar const* int_start = start;\n\t\t\t\t\tstart = find_char(start, end, 'e');\n\t\t\t\t\ttop->construct_int(int_start, start - int_start);\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tTORRENT_ASSERT(*start == 'e');\n\t\t\t\t\t++start;\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tif (!numeric(t))\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_value);\n\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\t\t\t\t\tif (start + len + 1 > end)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\ttop->construct_string(start, int(len));\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tstart += len;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\treturn 0;\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-5685", "cwe_id": "CWE-20" }, { "id": 2943, "func": "\tint lazy_bdecode(char const* start, char const* end, lazy_entry& ret\n\t\t, error_code& ec, int* error_pos, int depth_limit, int item_limit)\n\t{\n\t\tchar const* const orig_start = start;\n\t\tret.clear();\n\t\tif (start == end) return 0;\n\n\t\tstd::vector stack;\n\n\t\tstack.push_back(&ret);\n\t\twhile (start <= end)\n\t\t{\n\t\t\tif (stack.empty()) break; // done!\n\n\t\t\tlazy_entry* top = stack.back();\n\n\t\t\tif (int(stack.size()) > depth_limit) TORRENT_FAIL_BDECODE(bdecode_errors::depth_exceeded);\n\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\tchar t = *start;\n\t\t\t++start;\n\t\t\tif (start >= end && t != 'e') TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\tswitch (top->type())\n\t\t\t{\n\t\t\t\tcase lazy_entry::dict_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!numeric(t)) TORRENT_FAIL_BDECODE(bdecode_errors::expected_string);\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\n\t\t\t\t\t// remaining buffer size excluding ':'\n\t\t\t\t\tconst ptrdiff_t buff_size = end - start - 1;\n\t\t\t\t\tif (len > buff_size)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tlazy_entry* ent = top->dict_append(start);\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstart += len;\n\t\t\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tt = *start;\n\t\t\t\t\t++start;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase lazy_entry::list_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlazy_entry* ent = top->list_append();\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: break;\n\t\t\t}\n\n\t\t\t--item_limit;\n\t\t\tif (item_limit <= 0) TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);\n\n\t\t\ttop = stack.back();\n\t\t\tswitch (t)\n\t\t\t{\n\t\t\t\tcase 'd':\n\t\t\t\t\ttop->construct_dict(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'l':\n\t\t\t\t\ttop->construct_list(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'i':\n\t\t\t\t{\n\t\t\t\t\tchar const* int_start = start;\n\t\t\t\t\tstart = find_char(start, end, 'e');\n\t\t\t\t\ttop->construct_int(int_start, start - int_start);\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tTORRENT_ASSERT(*start == 'e');\n\t\t\t\t\t++start;\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tif (!numeric(t))\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_value);\n\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\n\t\t\t\t\t// remaining buffer size excluding ':'\n\t\t\t\t\tconst ptrdiff_t buff_size = end - start - 1;\n\t\t\t\t\tif (len > buff_size)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\ttop->construct_string(start, int(len));\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tstart += len;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\treturn 0;\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-5685", "cwe_id": "CWE-20" }, { "id": 2101, "func": "static enum count_type __read_io_type(struct page *page)\n{\n\tstruct address_space *mapping = page->mapping;\n\n\tif (mapping) {\n\t\tstruct inode *inode = mapping->host;\n\t\tstruct f2fs_sb_info *sbi = F2FS_I_SB(inode);\n\n\t\tif (inode->i_ino == F2FS_META_INO(sbi))\n\t\t\treturn F2FS_RD_META;\n\n\t\tif (inode->i_ino == F2FS_NODE_INO(sbi))\n\t\t\treturn F2FS_RD_NODE;\n\t}\n\treturn F2FS_RD_DATA;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 2101, "func": "static enum count_type __read_io_type(struct page *page)\n{\n\tstruct address_space *mapping = page_file_mapping(page);\n\n\tif (mapping) {\n\t\tstruct inode *inode = mapping->host;\n\t\tstruct f2fs_sb_info *sbi = F2FS_I_SB(inode);\n\n\t\tif (inode->i_ino == F2FS_META_INO(sbi))\n\t\t\treturn F2FS_RD_META;\n\n\t\tif (inode->i_ino == F2FS_NODE_INO(sbi))\n\t\t\treturn F2FS_RD_NODE;\n\t}\n\treturn F2FS_RD_DATA;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19815", "cwe_id": "CWE-476" }, { "id": 2171, "func": "static void timerfd_setup_cancel(struct timerfd_ctx *ctx, int flags)\n{\n\tif ((ctx->clockid == CLOCK_REALTIME ||\n\t ctx->clockid == CLOCK_REALTIME_ALARM) &&\n\t (flags & TFD_TIMER_ABSTIME) && (flags & TFD_TIMER_CANCEL_ON_SET)) {\n\t\tif (!ctx->might_cancel) {\n\t\t\tctx->might_cancel = true;\n\t\t\tspin_lock(&cancel_lock);\n\t\t\tlist_add_rcu(&ctx->clist, &cancel_list);\n\t\t\tspin_unlock(&cancel_lock);\n\t\t}\n\t} else if (ctx->might_cancel) {\n\t\ttimerfd_remove_cancel(ctx);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-10661", "cwe_id": "CWE-416" }, { "id": 2171, "func": "static void timerfd_setup_cancel(struct timerfd_ctx *ctx, int flags)\n{\n\tspin_lock(&ctx->cancel_lock);\n\tif ((ctx->clockid == CLOCK_REALTIME ||\n\t ctx->clockid == CLOCK_REALTIME_ALARM) &&\n\t (flags & TFD_TIMER_ABSTIME) && (flags & TFD_TIMER_CANCEL_ON_SET)) {\n\t\tif (!ctx->might_cancel) {\n\t\t\tctx->might_cancel = true;\n\t\t\tspin_lock(&cancel_lock);\n\t\t\tlist_add_rcu(&ctx->clist, &cancel_list);\n\t\t\tspin_unlock(&cancel_lock);\n\t\t}\n\t} else {\n\t\t__timerfd_remove_cancel(ctx);\n\t}\n\tspin_unlock(&ctx->cancel_lock);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-10661", "cwe_id": "CWE-416" }, { "id": 290, "func": "sysServices_handler(snmp_varbind_t *varbind, uint32_t *oid)\n{\n snmp_api_set_time_ticks(varbind, oid, clock_seconds() * 100);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 290, "func": "sysServices_handler(snmp_varbind_t *varbind, snmp_oid_t *oid)\n{\n snmp_api_set_time_ticks(varbind, oid, clock_seconds() * 100);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 2056, "func": "GF_AV1Config *gf_isom_av1_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex)\n{\n\tGF_TrackBox *trak;\n\tGF_MPEGVisualSampleEntryBox *entry;\n\tif (gf_isom_get_reference_count(the_file, trackNumber, GF_ISOM_REF_TBAS)) {\n\t\tu32 ref_track;\n\t\tGF_Err e = gf_isom_get_reference(the_file, trackNumber, GF_ISOM_REF_TBAS, 1, &ref_track);\n\t\tif (e == GF_OK) {\n\t\t\ttrackNumber = ref_track;\n\t\t}\n\t}\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !trak->Media || !DescriptionIndex) return NULL;\n\tentry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex - 1);\n\tif (!entry || !entry->av1_config) return NULL;\n\treturn AV1_DuplicateConfig(entry->av1_config->config);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-31262", "cwe_id": "CWE-476" }, { "id": 2056, "func": "GF_AV1Config *gf_isom_av1_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex)\n{\n\tGF_TrackBox *trak;\n\tGF_MPEGVisualSampleEntryBox *entry;\n\tif (gf_isom_get_reference_count(the_file, trackNumber, GF_ISOM_REF_TBAS)) {\n\t\tu32 ref_track;\n\t\tGF_Err e = gf_isom_get_reference(the_file, trackNumber, GF_ISOM_REF_TBAS, 1, &ref_track);\n\t\tif (e == GF_OK) {\n\t\t\ttrackNumber = ref_track;\n\t\t}\n\t}\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !trak->Media || !DescriptionIndex) return NULL;\n\tentry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex - 1);\n\tif (!entry || !entry->av1_config|| !entry->av1_config->config) return NULL;\n\treturn AV1_DuplicateConfig(entry->av1_config->config);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-31262", "cwe_id": "CWE-476" }, { "id": 344, "func": "INTERNAL void vterm_allocator_free(VTerm *vt, void *ptr)\n{\n (*vt->allocator->free)(ptr, vt->allocdata);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20786", "cwe_id": "CWE-476" }, { "id": 344, "func": "INTERNAL void vterm_allocator_free(VTerm *vt, void *ptr)\n{\n if (ptr)\n (*vt->allocator->free)(ptr, vt->allocdata);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20786", "cwe_id": "CWE-476" }, { "id": 2756, "func": "getvcol(\n win_T\t*wp,\n pos_T\t*pos,\n colnr_T\t*start,\n colnr_T\t*cursor,\n colnr_T\t*end)\n{\n colnr_T\tvcol;\n char_u\t*ptr;\t\t// points to current char\n char_u\t*posptr;\t// points to char at pos->col\n char_u\t*line;\t\t// start of the line\n int\t\tincr;\n int\t\thead;\n#ifdef FEAT_VARTABS\n int\t\t*vts = wp->w_buffer->b_p_vts_array;\n#endif\n int\t\tts = wp->w_buffer->b_p_ts;\n int\t\tc;\n\n vcol = 0;\n line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);\n if (pos->col == MAXCOL)\n\tposptr = NULL; // continue until the NUL\n else\n {\n\t// Special check for an empty line, which can happen on exit, when\n\t// ml_get_buf() always returns an empty string.\n\tif (*ptr == NUL)\n\t pos->col = 0;\n\tposptr = ptr + pos->col;\n\tif (has_mbyte)\n\t // always start on the first byte\n\t posptr -= (*mb_head_off)(line, posptr);\n }\n\n /*\n * This function is used very often, do some speed optimizations.\n * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set\n * use a simple loop.\n * Also use this when 'list' is set but tabs take their normal size.\n */\n if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)\n#ifdef FEAT_LINEBREAK\n\t && !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri\n#endif\n )\n {\n\tfor (;;)\n\t{\n\t head = 0;\n\t c = *ptr;\n\t // make sure we don't go past the end of the line\n\t if (c == NUL)\n\t {\n\t\tincr = 1;\t// NUL at end of line only takes one column\n\t\tbreak;\n\t }\n\t // A tab gets expanded, depending on the current column\n\t if (c == TAB)\n#ifdef FEAT_VARTABS\n\t\tincr = tabstop_padding(vcol, ts, vts);\n#else\n\t\tincr = ts - (vcol % ts);\n#endif\n\t else\n\t {\n\t\tif (has_mbyte)\n\t\t{\n\t\t // For utf-8, if the byte is >= 0x80, need to look at\n\t\t // further bytes to find the cell width.\n\t\t if (enc_utf8 && c >= 0x80)\n\t\t\tincr = utf_ptr2cells(ptr);\n\t\t else\n\t\t\tincr = g_chartab[c] & CT_CELL_MASK;\n\n\t\t // If a double-cell char doesn't fit at the end of a line\n\t\t // it wraps to the next line, it's like this char is three\n\t\t // cells wide.\n\t\t if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1\n\t\t\t && in_win_border(wp, vcol))\n\t\t {\n\t\t\t++incr;\n\t\t\thead = 1;\n\t\t }\n\t\t}\n\t\telse\n\t\t incr = g_chartab[c] & CT_CELL_MASK;\n\t }\n\n\t if (posptr != NULL && ptr >= posptr) // character at pos->col\n\t\tbreak;\n\n\t vcol += incr;\n\t MB_PTR_ADV(ptr);\n\t}\n }\n else\n {\n\tfor (;;)\n\t{\n\t // A tab gets expanded, depending on the current column\n\t head = 0;\n\t incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);\n\t // make sure we don't go past the end of the line\n\t if (*ptr == NUL)\n\t {\n\t\tincr = 1;\t// NUL at end of line only takes one column\n\t\tbreak;\n\t }\n\n\t if (posptr != NULL && ptr >= posptr) // character at pos->col\n\t\tbreak;\n\n\t vcol += incr;\n\t MB_PTR_ADV(ptr);\n\t}\n }\n if (start != NULL)\n\t*start = vcol + head;\n if (end != NULL)\n\t*end = vcol + incr - 1;\n if (cursor != NULL)\n {\n\tif (*ptr == TAB\n\t\t&& (State & NORMAL)\n\t\t&& !wp->w_p_list\n\t\t&& !virtual_active()\n\t\t&& !(VIsual_active\n\t\t\t\t&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))\n\t\t)\n\t *cursor = vcol + incr - 1;\t // cursor at end\n\telse\n\t *cursor = vcol + head;\t // cursor at start\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-4193", "cwe_id": "CWE-125" }, { "id": 2756, "func": "getvcol(\n win_T\t*wp,\n pos_T\t*pos,\n colnr_T\t*start,\n colnr_T\t*cursor,\n colnr_T\t*end)\n{\n colnr_T\tvcol;\n char_u\t*ptr;\t\t// points to current char\n char_u\t*posptr;\t// points to char at pos->col\n char_u\t*line;\t\t// start of the line\n int\t\tincr;\n int\t\thead;\n#ifdef FEAT_VARTABS\n int\t\t*vts = wp->w_buffer->b_p_vts_array;\n#endif\n int\t\tts = wp->w_buffer->b_p_ts;\n int\t\tc;\n\n vcol = 0;\n line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);\n if (pos->col == MAXCOL)\n\tposptr = NULL; // continue until the NUL\n else\n {\n\tcolnr_T i;\n\n\t// In a few cases the position can be beyond the end of the line.\n\tfor (i = 0; i < pos->col; ++i)\n\t if (ptr[i] == NUL)\n\t {\n\t\tpos->col = i;\n\t\tbreak;\n\t }\n\tposptr = ptr + pos->col;\n\tif (has_mbyte)\n\t // always start on the first byte\n\t posptr -= (*mb_head_off)(line, posptr);\n }\n\n /*\n * This function is used very often, do some speed optimizations.\n * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set\n * use a simple loop.\n * Also use this when 'list' is set but tabs take their normal size.\n */\n if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)\n#ifdef FEAT_LINEBREAK\n\t && !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri\n#endif\n )\n {\n\tfor (;;)\n\t{\n\t head = 0;\n\t c = *ptr;\n\t // make sure we don't go past the end of the line\n\t if (c == NUL)\n\t {\n\t\tincr = 1;\t// NUL at end of line only takes one column\n\t\tbreak;\n\t }\n\t // A tab gets expanded, depending on the current column\n\t if (c == TAB)\n#ifdef FEAT_VARTABS\n\t\tincr = tabstop_padding(vcol, ts, vts);\n#else\n\t\tincr = ts - (vcol % ts);\n#endif\n\t else\n\t {\n\t\tif (has_mbyte)\n\t\t{\n\t\t // For utf-8, if the byte is >= 0x80, need to look at\n\t\t // further bytes to find the cell width.\n\t\t if (enc_utf8 && c >= 0x80)\n\t\t\tincr = utf_ptr2cells(ptr);\n\t\t else\n\t\t\tincr = g_chartab[c] & CT_CELL_MASK;\n\n\t\t // If a double-cell char doesn't fit at the end of a line\n\t\t // it wraps to the next line, it's like this char is three\n\t\t // cells wide.\n\t\t if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1\n\t\t\t && in_win_border(wp, vcol))\n\t\t {\n\t\t\t++incr;\n\t\t\thead = 1;\n\t\t }\n\t\t}\n\t\telse\n\t\t incr = g_chartab[c] & CT_CELL_MASK;\n\t }\n\n\t if (posptr != NULL && ptr >= posptr) // character at pos->col\n\t\tbreak;\n\n\t vcol += incr;\n\t MB_PTR_ADV(ptr);\n\t}\n }\n else\n {\n\tfor (;;)\n\t{\n\t // A tab gets expanded, depending on the current column\n\t head = 0;\n\t incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);\n\t // make sure we don't go past the end of the line\n\t if (*ptr == NUL)\n\t {\n\t\tincr = 1;\t// NUL at end of line only takes one column\n\t\tbreak;\n\t }\n\n\t if (posptr != NULL && ptr >= posptr) // character at pos->col\n\t\tbreak;\n\n\t vcol += incr;\n\t MB_PTR_ADV(ptr);\n\t}\n }\n if (start != NULL)\n\t*start = vcol + head;\n if (end != NULL)\n\t*end = vcol + incr - 1;\n if (cursor != NULL)\n {\n\tif (*ptr == TAB\n\t\t&& (State & NORMAL)\n\t\t&& !wp->w_p_list\n\t\t&& !virtual_active()\n\t\t&& !(VIsual_active\n\t\t\t\t&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))\n\t\t)\n\t *cursor = vcol + incr - 1;\t // cursor at end\n\telse\n\t *cursor = vcol + head;\t // cursor at start\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-4193", "cwe_id": "CWE-125" }, { "id": 2020, "func": "TfLiteStatus PrepareHashtableSize(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputResourceIdTensor);\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1);\n\n TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output_tensor != nullptr);\n TF_LITE_ENSURE_EQ(context, output_tensor->type, kTfLiteInt64);\n TfLiteIntArray* outputSize = TfLiteIntArrayCreate(1);\n outputSize->data[0] = 1;\n return context->ResizeTensor(context, output_tensor, outputSize);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2020, "func": "TfLiteStatus PrepareHashtableSize(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputResourceIdTensor,\n &input_resource_id_tensor));\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1);\n\n TfLiteTensor* output_tensor;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputTensor, &output_tensor));\n TF_LITE_ENSURE_EQ(context, output_tensor->type, kTfLiteInt64);\n TfLiteIntArray* outputSize = TfLiteIntArrayCreate(1);\n outputSize->data[0] = 1;\n return context->ResizeTensor(context, output_tensor, outputSize);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2257, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputVariableId);\n int resource_id = input_resource_id_tensor->data.i32[0];\n auto& resources = subgraph->resources();\n auto* variable = resource::GetResourceVariable(&resources, resource_id);\n TF_LITE_ENSURE(context, variable != nullptr);\n\n TfLiteTensor* variable_tensor = variable->GetTensor();\n TfLiteTensor* output = GetOutput(context, node, kOutputValue);\n\n TF_LITE_ENSURE_TYPES_EQ(context, variable_tensor->type, output->type);\n TF_LITE_ENSURE_OK(\n context, context->ResizeTensor(\n context, output, TfLiteIntArrayCopy(variable_tensor->dims)));\n memcpy(output->data.raw, variable_tensor->data.raw, output->bytes);\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2257, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputVariableId,\n &input_resource_id_tensor));\n int resource_id = input_resource_id_tensor->data.i32[0];\n auto& resources = subgraph->resources();\n auto* variable = resource::GetResourceVariable(&resources, resource_id);\n TF_LITE_ENSURE(context, variable != nullptr);\n\n TfLiteTensor* variable_tensor = variable->GetTensor();\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputValue, &output));\n\n TF_LITE_ENSURE_TYPES_EQ(context, variable_tensor->type, output->type);\n TF_LITE_ENSURE_OK(\n context, context->ResizeTensor(\n context, output, TfLiteIntArrayCopy(variable_tensor->dims)));\n memcpy(output->data.raw, variable_tensor->data.raw, output->bytes);\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2522, "func": "bool AES_GCM_EncryptContext::Encrypt(\n\tconst void *pPlaintextData, size_t cbPlaintextData,\n\tconst void *pIV,\n\tvoid *pEncryptedDataAndTag, uint32 *pcbEncryptedDataAndTag,\n\tconst void *pAdditionalAuthenticationData, size_t cbAuthenticationData\n) {\n unsigned long long pcbEncryptedDataAndTag_longlong = *pcbEncryptedDataAndTag;\n\n crypto_aead_aes256gcm_encrypt_afternm(\n\t\tstatic_cast( pEncryptedDataAndTag ), &pcbEncryptedDataAndTag_longlong,\n\t\tstatic_cast( pPlaintextData ), cbPlaintextData,\n\t\tstatic_cast(pAdditionalAuthenticationData), cbAuthenticationData,\n\t\tnullptr,\n\t\tstatic_cast( pIV ),\n\t\tstatic_cast( m_ctx )\n\t);\n\n *pcbEncryptedDataAndTag = pcbEncryptedDataAndTag_longlong;\n\n return true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-6018", "cwe_id": "CWE-787" }, { "id": 2522, "func": "bool AES_GCM_EncryptContext::Encrypt(\n\tconst void *pPlaintextData, size_t cbPlaintextData,\n\tconst void *pIV,\n\tvoid *pEncryptedDataAndTag, uint32 *pcbEncryptedDataAndTag,\n\tconst void *pAdditionalAuthenticationData, size_t cbAuthenticationData\n) {\n\n\t// Make sure caller's buffer is big enough to hold the result.\n\tif ( cbPlaintextData + crypto_aead_aes256gcm_ABYTES > *pcbEncryptedDataAndTag )\n\t{\n\t\t*pcbEncryptedDataAndTag = 0;\n\t\treturn false;\n\t}\n\n unsigned long long cbEncryptedDataAndTag_longlong;\n crypto_aead_aes256gcm_encrypt_afternm(\n\t\tstatic_cast( pEncryptedDataAndTag ), &cbEncryptedDataAndTag_longlong,\n\t\tstatic_cast( pPlaintextData ), cbPlaintextData,\n\t\tstatic_cast(pAdditionalAuthenticationData), cbAuthenticationData,\n\t\tnullptr,\n\t\tstatic_cast( pIV ),\n\t\tstatic_cast( m_ctx )\n\t);\n\n *pcbEncryptedDataAndTag = cbEncryptedDataAndTag_longlong;\n\n return true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-6018", "cwe_id": "CWE-787" }, { "id": 2767, "func": "diff_mark_adjust_tp(\n tabpage_T\t*tp,\n int\t\tidx,\n linenr_T\tline1,\n linenr_T\tline2,\n long\tamount,\n long\tamount_after)\n{\n diff_T\t*dp;\n diff_T\t*dprev;\n diff_T\t*dnext;\n int\t\ti;\n int\t\tinserted, deleted;\n int\t\tn, off;\n linenr_T\tlast;\n linenr_T\tlnum_deleted = line1;\t// lnum of remaining deletion\n int\t\tcheck_unchanged;\n\n if (diff_internal())\n {\n\t// Will update diffs before redrawing. Set _invalid to update the\n\t// diffs themselves, set _update to also update folds properly just\n\t// before redrawing.\n\t// Do update marks here, it is needed for :%diffput.\n\ttp->tp_diff_invalid = TRUE;\n\ttp->tp_diff_update = TRUE;\n }\n\n if (line2 == MAXLNUM)\n {\n\t// mark_adjust(99, MAXLNUM, 9, 0): insert lines\n\tinserted = amount;\n\tdeleted = 0;\n }\n else if (amount_after > 0)\n {\n\t// mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines\n\tinserted = amount_after;\n\tdeleted = 0;\n }\n else\n {\n\t// mark_adjust(98, 99, MAXLNUM, -2): delete lines\n\tinserted = 0;\n\tdeleted = -amount_after;\n }\n\n dprev = NULL;\n dp = tp->tp_first_diff;\n for (;;)\n {\n\t// If the change is after the previous diff block and before the next\n\t// diff block, thus not touching an existing change, create a new diff\n\t// block. Don't do this when ex_diffgetput() is busy.\n\tif ((dp == NULL || dp->df_lnum[idx] - 1 > line2\n\t\t || (line2 == MAXLNUM && dp->df_lnum[idx] > line1))\n\t\t&& (dprev == NULL\n\t\t || dprev->df_lnum[idx] + dprev->df_count[idx] < line1)\n\t\t&& !diff_busy)\n\t{\n\t dnext = diff_alloc_new(tp, dprev, dp);\n\t if (dnext == NULL)\n\t\treturn;\n\n\t dnext->df_lnum[idx] = line1;\n\t dnext->df_count[idx] = inserted;\n\t for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t{\n\t\t if (dprev == NULL)\n\t\t\tdnext->df_lnum[i] = line1;\n\t\t else\n\t\t\tdnext->df_lnum[i] = line1\n\t\t\t + (dprev->df_lnum[i] + dprev->df_count[i])\n\t\t\t - (dprev->df_lnum[idx] + dprev->df_count[idx]);\n\t\t dnext->df_count[i] = deleted;\n\t\t}\n\t}\n\n\t// if at end of the list, quit\n\tif (dp == NULL)\n\t break;\n\n\t/*\n\t * Check for these situations:\n\t *\t 1 2\t3\n\t *\t 1 2\t3\n\t * line1 2\t3 4 5\n\t *\t 2\t3 4 5\n\t *\t 2\t3 4 5\n\t * line2 2\t3 4 5\n\t *\t\t3 5 6\n\t *\t\t3 5 6\n\t */\n\t// compute last line of this change\n\tlast = dp->df_lnum[idx] + dp->df_count[idx] - 1;\n\n\t// 1. change completely above line1: nothing to do\n\tif (last >= line1 - 1)\n\t{\n\t // 6. change below line2: only adjust for amount_after; also when\n\t // \"deleted\" became zero when deleted all lines between two diffs\n\t if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2)\n\t {\n\t\tif (amount_after == 0)\n\t\t break;\t// nothing left to change\n\t\tdp->df_lnum[idx] += amount_after;\n\t }\n\t else\n\t {\n\t\tcheck_unchanged = FALSE;\n\n\t\t// 2. 3. 4. 5.: inserted/deleted lines touching this diff.\n\t\tif (deleted > 0)\n\t\t{\n\t\t if (dp->df_lnum[idx] >= line1)\n\t\t {\n\t\t\toff = dp->df_lnum[idx] - lnum_deleted;\n\t\t\tif (last <= line2)\n\t\t\t{\n\t\t\t // 4. delete all lines of diff\n\t\t\t if (dp->df_next != NULL\n\t\t\t\t && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t {\n\t\t\t\t// delete continues in next diff, only do\n\t\t\t\t// lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - lnum_deleted;\n\t\t\t\tdeleted -= n;\n\t\t\t\tn -= dp->df_count[idx];\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t }\n\t\t\t else\n\t\t\t\tn = deleted - dp->df_count[idx];\n\t\t\t dp->df_count[idx] = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t // 5. delete lines at or just before top of diff\n\t\t\t n = off;\n\t\t\t dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;\n\t\t\t check_unchanged = TRUE;\n\t\t\t}\n\t\t\tdp->df_lnum[idx] = line1;\n\t\t }\n\t\t else\n\t\t {\n\t\t\toff = 0;\n\t\t\tif (last < line2)\n\t\t\t{\n\t\t\t // 2. delete at end of diff\n\t\t\t dp->df_count[idx] -= last - lnum_deleted + 1;\n\t\t\t if (dp->df_next != NULL\n\t\t\t\t && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t {\n\t\t\t\t// delete continues in next diff, only do\n\t\t\t\t// lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - 1 - last;\n\t\t\t\tdeleted -= dp->df_next->df_lnum[idx]\n\t\t\t\t\t\t\t - lnum_deleted;\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t }\n\t\t\t else\n\t\t\t\tn = line2 - last;\n\t\t\t check_unchanged = TRUE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t // 3. delete lines inside the diff\n\t\t\t n = 0;\n\t\t\t dp->df_count[idx] -= deleted;\n\t\t\t}\n\t\t }\n\n\t\t for (i = 0; i < DB_COUNT; ++i)\n\t\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t\t{\n\t\t\t dp->df_lnum[i] -= off;\n\t\t\t dp->df_count[i] += n;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t if (dp->df_lnum[idx] <= line1)\n\t\t {\n\t\t\t// inserted lines somewhere in this diff\n\t\t\tdp->df_count[idx] += inserted;\n\t\t\tcheck_unchanged = TRUE;\n\t\t }\n\t\t else\n\t\t\t// inserted lines somewhere above this diff\n\t\t\tdp->df_lnum[idx] += inserted;\n\t\t}\n\n\t\tif (check_unchanged)\n\t\t // Check if inserted lines are equal, may reduce the\n\t\t // size of the diff. TODO: also check for equal lines\n\t\t // in the middle and perhaps split the block.\n\t\t diff_check_unchanged(tp, dp);\n\t }\n\t}\n\n\t// check if this block touches the previous one, may merge them.\n\tif (dprev != NULL && dprev->df_lnum[idx] + dprev->df_count[idx]\n\t\t\t\t\t\t\t == dp->df_lnum[idx])\n\t{\n\t for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL)\n\t\t dprev->df_count[i] += dp->df_count[i];\n\t dprev->df_next = dp->df_next;\n\t vim_free(dp);\n\t dp = dprev->df_next;\n\t}\n\telse\n\t{\n\t // Advance to next entry.\n\t dprev = dp;\n\t dp = dp->df_next;\n\t}\n }\n\n dprev = NULL;\n dp = tp->tp_first_diff;\n while (dp != NULL)\n {\n\t// All counts are zero, remove this entry.\n\tfor (i = 0; i < DB_COUNT; ++i)\n\t if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0)\n\t\tbreak;\n\tif (i == DB_COUNT)\n\t{\n\t dnext = dp->df_next;\n\t vim_free(dp);\n\t dp = dnext;\n\t if (dprev == NULL)\n\t\ttp->tp_first_diff = dnext;\n\t else\n\t\tdprev->df_next = dnext;\n\t}\n\telse\n\t{\n\t // Advance to next entry.\n\t dprev = dp;\n\t dp = dp->df_next;\n\t}\n\n }\n\n if (tp == curtab)\n {\n\t// Don't redraw right away, this updates the diffs, which can be slow.\n\tneed_diff_redraw = TRUE;\n\n\t// Need to recompute the scroll binding, may remove or add filler\n\t// lines (e.g., when adding lines above w_topline). But it's slow when\n\t// making many changes, postpone until redrawing.\n\tdiff_need_scrollbind = TRUE;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2210", "cwe_id": "CWE-787" }, { "id": 2767, "func": "diff_mark_adjust_tp(\n tabpage_T\t*tp,\n int\t\tidx,\n linenr_T\tline1,\n linenr_T\tline2,\n long\tamount,\n long\tamount_after)\n{\n diff_T\t*dp;\n diff_T\t*dprev;\n diff_T\t*dnext;\n int\t\ti;\n int\t\tinserted, deleted;\n int\t\tn, off;\n linenr_T\tlast;\n linenr_T\tlnum_deleted = line1;\t// lnum of remaining deletion\n int\t\tcheck_unchanged;\n\n if (diff_internal())\n {\n\t// Will update diffs before redrawing. Set _invalid to update the\n\t// diffs themselves, set _update to also update folds properly just\n\t// before redrawing.\n\t// Do update marks here, it is needed for :%diffput.\n\ttp->tp_diff_invalid = TRUE;\n\ttp->tp_diff_update = TRUE;\n }\n\n if (line2 == MAXLNUM)\n {\n\t// mark_adjust(99, MAXLNUM, 9, 0): insert lines\n\tinserted = amount;\n\tdeleted = 0;\n }\n else if (amount_after > 0)\n {\n\t// mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines\n\tinserted = amount_after;\n\tdeleted = 0;\n }\n else\n {\n\t// mark_adjust(98, 99, MAXLNUM, -2): delete lines\n\tinserted = 0;\n\tdeleted = -amount_after;\n }\n\n dprev = NULL;\n dp = tp->tp_first_diff;\n for (;;)\n {\n\t// If the change is after the previous diff block and before the next\n\t// diff block, thus not touching an existing change, create a new diff\n\t// block. Don't do this when ex_diffgetput() is busy.\n\tif ((dp == NULL || dp->df_lnum[idx] - 1 > line2\n\t\t || (line2 == MAXLNUM && dp->df_lnum[idx] > line1))\n\t\t&& (dprev == NULL\n\t\t || dprev->df_lnum[idx] + dprev->df_count[idx] < line1)\n\t\t&& !diff_busy)\n\t{\n\t dnext = diff_alloc_new(tp, dprev, dp);\n\t if (dnext == NULL)\n\t\treturn;\n\n\t dnext->df_lnum[idx] = line1;\n\t dnext->df_count[idx] = inserted;\n\t for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t{\n\t\t if (dprev == NULL)\n\t\t\tdnext->df_lnum[i] = line1;\n\t\t else\n\t\t\tdnext->df_lnum[i] = line1\n\t\t\t + (dprev->df_lnum[i] + dprev->df_count[i])\n\t\t\t - (dprev->df_lnum[idx] + dprev->df_count[idx]);\n\t\t dnext->df_count[i] = deleted;\n\t\t}\n\t}\n\n\t// if at end of the list, quit\n\tif (dp == NULL)\n\t break;\n\n\t/*\n\t * Check for these situations:\n\t *\t 1 2\t3\n\t *\t 1 2\t3\n\t * line1 2\t3 4 5\n\t *\t 2\t3 4 5\n\t *\t 2\t3 4 5\n\t * line2 2\t3 4 5\n\t *\t\t3 5 6\n\t *\t\t3 5 6\n\t */\n\t// compute last line of this change\n\tlast = dp->df_lnum[idx] + dp->df_count[idx] - 1;\n\n\t// 1. change completely above line1: nothing to do\n\tif (last >= line1 - 1)\n\t{\n\t // 6. change below line2: only adjust for amount_after; also when\n\t // \"deleted\" became zero when deleted all lines between two diffs\n\t if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2)\n\t {\n\t\tif (amount_after == 0)\n\t\t break;\t// nothing left to change\n\t\tdp->df_lnum[idx] += amount_after;\n\t }\n\t else\n\t {\n\t\tcheck_unchanged = FALSE;\n\n\t\t// 2. 3. 4. 5.: inserted/deleted lines touching this diff.\n\t\tif (deleted > 0)\n\t\t{\n\t\t off = 0;\n\t\t if (dp->df_lnum[idx] >= line1)\n\t\t {\n\t\t\tif (last <= line2)\n\t\t\t{\n\t\t\t // 4. delete all lines of diff\n\t\t\t if (dp->df_next != NULL\n\t\t\t\t && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t {\n\t\t\t\t// delete continues in next diff, only do\n\t\t\t\t// lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - lnum_deleted;\n\t\t\t\tdeleted -= n;\n\t\t\t\tn -= dp->df_count[idx];\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t }\n\t\t\t else\n\t\t\t\tn = deleted - dp->df_count[idx];\n\t\t\t dp->df_count[idx] = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t // 5. delete lines at or just before top of diff\n\t\t\t off = dp->df_lnum[idx] - lnum_deleted;\n\t\t\t n = off;\n\t\t\t dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;\n\t\t\t check_unchanged = TRUE;\n\t\t\t}\n\t\t\tdp->df_lnum[idx] = line1;\n\t\t }\n\t\t else\n\t\t {\n\t\t\tif (last < line2)\n\t\t\t{\n\t\t\t // 2. delete at end of diff\n\t\t\t dp->df_count[idx] -= last - lnum_deleted + 1;\n\t\t\t if (dp->df_next != NULL\n\t\t\t\t && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t {\n\t\t\t\t// delete continues in next diff, only do\n\t\t\t\t// lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - 1 - last;\n\t\t\t\tdeleted -= dp->df_next->df_lnum[idx]\n\t\t\t\t\t\t\t - lnum_deleted;\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t }\n\t\t\t else\n\t\t\t\tn = line2 - last;\n\t\t\t check_unchanged = TRUE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t // 3. delete lines inside the diff\n\t\t\t n = 0;\n\t\t\t dp->df_count[idx] -= deleted;\n\t\t\t}\n\t\t }\n\n\t\t for (i = 0; i < DB_COUNT; ++i)\n\t\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t\t{\n\t\t\t dp->df_lnum[i] -= off;\n\t\t\t dp->df_count[i] += n;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t if (dp->df_lnum[idx] <= line1)\n\t\t {\n\t\t\t// inserted lines somewhere in this diff\n\t\t\tdp->df_count[idx] += inserted;\n\t\t\tcheck_unchanged = TRUE;\n\t\t }\n\t\t else\n\t\t\t// inserted lines somewhere above this diff\n\t\t\tdp->df_lnum[idx] += inserted;\n\t\t}\n\n\t\tif (check_unchanged)\n\t\t // Check if inserted lines are equal, may reduce the\n\t\t // size of the diff. TODO: also check for equal lines\n\t\t // in the middle and perhaps split the block.\n\t\t diff_check_unchanged(tp, dp);\n\t }\n\t}\n\n\t// check if this block touches the previous one, may merge them.\n\tif (dprev != NULL && dprev->df_lnum[idx] + dprev->df_count[idx]\n\t\t\t\t\t\t\t == dp->df_lnum[idx])\n\t{\n\t for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL)\n\t\t dprev->df_count[i] += dp->df_count[i];\n\t dprev->df_next = dp->df_next;\n\t vim_free(dp);\n\t dp = dprev->df_next;\n\t}\n\telse\n\t{\n\t // Advance to next entry.\n\t dprev = dp;\n\t dp = dp->df_next;\n\t}\n }\n\n dprev = NULL;\n dp = tp->tp_first_diff;\n while (dp != NULL)\n {\n\t// All counts are zero, remove this entry.\n\tfor (i = 0; i < DB_COUNT; ++i)\n\t if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0)\n\t\tbreak;\n\tif (i == DB_COUNT)\n\t{\n\t dnext = dp->df_next;\n\t vim_free(dp);\n\t dp = dnext;\n\t if (dprev == NULL)\n\t\ttp->tp_first_diff = dnext;\n\t else\n\t\tdprev->df_next = dnext;\n\t}\n\telse\n\t{\n\t // Advance to next entry.\n\t dprev = dp;\n\t dp = dp->df_next;\n\t}\n\n }\n\n if (tp == curtab)\n {\n\t// Don't redraw right away, this updates the diffs, which can be slow.\n\tneed_diff_redraw = TRUE;\n\n\t// Need to recompute the scroll binding, may remove or add filler\n\t// lines (e.g., when adding lines above w_topline). But it's slow when\n\t// making many changes, postpone until redrawing.\n\tdiff_need_scrollbind = TRUE;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2210", "cwe_id": "CWE-787" }, { "id": 912, "func": "void ZlibInStream::setUnderlying(InStream* is, int bytesIn_)\n{\n underlying = is;\n bytesIn = bytesIn_;\n ptr = end = start;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 912, "func": "void ZlibInStream::setUnderlying(InStream* is, size_t bytesIn_)\n{\n underlying = is;\n bytesIn = bytesIn_;\n ptr = end = start;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1004, "func": "FdOutStream::FdOutStream(int fd_, bool blocking_, int timeoutms_, int bufSize_)\n : fd(fd_), blocking(blocking_), timeoutms(timeoutms_),\n bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)\n{\n ptr = start = sentUpTo = new U8[bufSize];\n end = start + bufSize;\n\n gettimeofday(&lastWrite, NULL);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1004, "func": "FdOutStream::FdOutStream(int fd_, bool blocking_, int timeoutms_, size_t bufSize_)\n : fd(fd_), blocking(blocking_), timeoutms(timeoutms_),\n bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)\n{\n ptr = start = sentUpTo = new U8[bufSize];\n end = start + bufSize;\n\n gettimeofday(&lastWrite, NULL);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 3127, "func": "char *path_name(const struct name_path *path, const char *name)\n{\n\tconst struct name_path *p;\n\tchar *n, *m;\n\tint nlen = strlen(name);\n\tint len = nlen + 1;\n\n\tfor (p = path; p; p = p->up) {\n\t\tif (p->elem_len)\n\t\t\tlen += p->elem_len + 1;\n\t}\n\tn = xmalloc(len);\n\tm = n + len - (nlen + 1);\n\tstrcpy(m, name);\n\tfor (p = path; p; p = p->up) {\n\t\tif (p->elem_len) {\n\t\t\tm -= p->elem_len + 1;\n\t\t\tmemcpy(m, p->elem, p->elem_len);\n\t\t\tm[p->elem_len] = '/';\n\t\t}\n\t}\n\treturn n;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 3127, "func": "char *path_name(const struct name_path *path, const char *name)\n{\n\tconst struct name_path *p;\n\tchar *n, *m;\n\tint nlen = strlen(name);\n\tint len = nlen + 1;\n\n\tfor (p = path; p; p = p->up) {\n\t\tif (p->elem_len)\n\t\t\tlen += p->elem_len + 1;\n\t}\n\tn = xmalloc(len);\n\tm = n + len - (nlen + 1);\n\tmemcpy(m, name, nlen + 1);\n\tfor (p = path; p; p = p->up) {\n\t\tif (p->elem_len) {\n\t\t\tm -= p->elem_len + 1;\n\t\t\tmemcpy(m, p->elem, p->elem_len);\n\t\t\tm[p->elem_len] = '/';\n\t\t}\n\t}\n\treturn n;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 481, "func": "void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)\n{\n\t__issue_discard_cmd(sbi, false);\n\t__drop_discard_cmd(sbi);\n\t__wait_discard_cmd(sbi, false);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18200", "cwe_id": "CWE-20" }, { "id": 481, "func": "void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi, bool umount)\n{\n\t__issue_discard_cmd(sbi, false);\n\t__drop_discard_cmd(sbi);\n\t__wait_discard_cmd(sbi, !umount);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18200", "cwe_id": "CWE-20" }, { "id": 2279, "func": "mp_capable_print(netdissect_options *ndo,\n const u_char *opt, u_int opt_len, u_char flags)\n{\n const struct mp_capable *mpc = (const struct mp_capable *) opt;\n\n if (!(opt_len == 12 && flags & TH_SYN) &&\n !(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))\n return 0;\n\n if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {\n ND_PRINT((ndo, \" Unknown Version (%d)\", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));\n return 1;\n }\n\n if (mpc->flags & MP_CAPABLE_C)\n ND_PRINT((ndo, \" csum\"));\n ND_PRINT((ndo, \" {0x%\" PRIx64, EXTRACT_64BITS(mpc->sender_key)));\n if (opt_len == 20) /* ACK */\n ND_PRINT((ndo, \",0x%\" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));\n ND_PRINT((ndo, \"}\"));\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13040", "cwe_id": "CWE-125" }, { "id": 2279, "func": "mp_capable_print(netdissect_options *ndo,\n const u_char *opt, u_int opt_len, u_char flags)\n{\n const struct mp_capable *mpc = (const struct mp_capable *) opt;\n\n if (!(opt_len == 12 && (flags & TH_SYN)) &&\n !(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))\n return 0;\n\n if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {\n ND_PRINT((ndo, \" Unknown Version (%d)\", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));\n return 1;\n }\n\n if (mpc->flags & MP_CAPABLE_C)\n ND_PRINT((ndo, \" csum\"));\n ND_PRINT((ndo, \" {0x%\" PRIx64, EXTRACT_64BITS(mpc->sender_key)));\n if (opt_len == 20) /* ACK */\n ND_PRINT((ndo, \",0x%\" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));\n ND_PRINT((ndo, \"}\"));\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13040", "cwe_id": "CWE-125" }, { "id": 1399, "func": "local block_state deflate_huff(s, flush)\n deflate_state *s;\n int flush;\n{\n int bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s->lookahead == 0) {\n fill_window(s);\n if (s->lookahead == 0) {\n if (flush == Z_NO_FLUSH)\n return need_more;\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s->match_length = 0;\n Tracevv((stderr,\"%c\", s->window[s->strstart]));\n _tr_tally_lit (s, s->window[s->strstart], bflush);\n s->lookahead--;\n s->strstart++;\n if (bflush) FLUSH_BLOCK(s, 0);\n }\n s->insert = 0;\n if (flush == Z_FINISH) {\n FLUSH_BLOCK(s, 1);\n return finish_done;\n }\n if (s->last_lit)\n FLUSH_BLOCK(s, 0);\n return block_done;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-25032", "cwe_id": "CWE-787" }, { "id": 1399, "func": "local block_state deflate_huff(s, flush)\n deflate_state *s;\n int flush;\n{\n int bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s->lookahead == 0) {\n fill_window(s);\n if (s->lookahead == 0) {\n if (flush == Z_NO_FLUSH)\n return need_more;\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s->match_length = 0;\n Tracevv((stderr,\"%c\", s->window[s->strstart]));\n _tr_tally_lit (s, s->window[s->strstart], bflush);\n s->lookahead--;\n s->strstart++;\n if (bflush) FLUSH_BLOCK(s, 0);\n }\n s->insert = 0;\n if (flush == Z_FINISH) {\n FLUSH_BLOCK(s, 1);\n return finish_done;\n }\n if (s->sym_next)\n FLUSH_BLOCK(s, 0);\n return block_done;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-25032", "cwe_id": "CWE-787" }, { "id": 2479, "func": "BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,\n UINT16* flags)\n{\n\tBYTE bitsPerPixelId;\n\tBITMAP_DATA_EX* bitmapData;\n\n\tif (!Stream_EnsureRemainingCapacity(\n\t s, update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, flags)))\n\t\treturn FALSE;\n\n\tbitmapData = &cache_bitmap_v3->bitmapData;\n\tbitsPerPixelId = BPP_CBR23[cache_bitmap_v3->bpp];\n\t*flags = (cache_bitmap_v3->cacheId & 0x00000003) |\n\t ((cache_bitmap_v3->flags << 7) & 0x0000FF80) | ((bitsPerPixelId << 3) & 0x00000078);\n\tStream_Write_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */\n\tStream_Write_UINT8(s, bitmapData->bpp);\n\tStream_Write_UINT8(s, 0); /* reserved1 (1 byte) */\n\tStream_Write_UINT8(s, 0); /* reserved2 (1 byte) */\n\tStream_Write_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */\n\tStream_Write_UINT16(s, bitmapData->width); /* width (2 bytes) */\n\tStream_Write_UINT16(s, bitmapData->height); /* height (2 bytes) */\n\tStream_Write_UINT32(s, bitmapData->length); /* length (4 bytes) */\n\tStream_Write(s, bitmapData->data, bitmapData->length);\n\treturn TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 2479, "func": "BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,\n UINT16* flags)\n{\n\tBOOL rc;\n\tBYTE bitsPerPixelId;\n\tBITMAP_DATA_EX* bitmapData;\n\n\tif (!Stream_EnsureRemainingCapacity(\n\t s, update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, flags)))\n\t\treturn FALSE;\n\n\tbitmapData = &cache_bitmap_v3->bitmapData;\n\tbitsPerPixelId = get_bpp_bmf(cache_bitmap_v3->bpp, &rc);\n\tif (!rc)\n\t\treturn FALSE;\n\t*flags = (cache_bitmap_v3->cacheId & 0x00000003) |\n\t ((cache_bitmap_v3->flags << 7) & 0x0000FF80) | ((bitsPerPixelId << 3) & 0x00000078);\n\tStream_Write_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */\n\tStream_Write_UINT8(s, bitmapData->bpp);\n\tStream_Write_UINT8(s, 0); /* reserved1 (1 byte) */\n\tStream_Write_UINT8(s, 0); /* reserved2 (1 byte) */\n\tStream_Write_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */\n\tStream_Write_UINT16(s, bitmapData->width); /* width (2 bytes) */\n\tStream_Write_UINT16(s, bitmapData->height); /* height (2 bytes) */\n\tStream_Write_UINT32(s, bitmapData->length); /* length (4 bytes) */\n\tStream_Write(s, bitmapData->data, bitmapData->length);\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 1480, "func": "obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n identifier arg;\n expr_ty value;\n\n if (exists_not_none(obj, &PyId_arg)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_arg);\n if (tmp == NULL) goto failed;\n res = obj2ast_identifier(tmp, &arg, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n arg = NULL;\n }\n if (_PyObject_HasAttrId(obj, &PyId_value)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_value);\n if (tmp == NULL) goto failed;\n res = obj2ast_expr(tmp, &value, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"value\\\" missing from keyword\");\n return 1;\n }\n *out = keyword(arg, value, arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1480, "func": "obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n identifier arg;\n expr_ty value;\n\n if (lookup_attr_id(obj, &PyId_arg, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n arg = NULL;\n }\n else {\n int res;\n res = obj2ast_identifier(tmp, &arg, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (lookup_attr_id(obj, &PyId_value, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"value\\\" missing from keyword\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &value, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = keyword(arg, value, arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2560, "func": "int pure_strcmp(const char * const s1, const char * const s2)\n{\n return pure_memcmp(s1, s2, strlen(s1) + 1U);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-9365", "cwe_id": "CWE-125" }, { "id": 2560, "func": "int pure_strcmp(const char * const s1, const char * const s2)\n{\n const size_t s1_len = strlen(s1);\n const size_t s2_len = strlen(s2);\n const size_t len = (s1_len < s2_len) ? s1_len : s2_len;\n\n return pure_memcmp(s1, s2, len + 1);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-9365", "cwe_id": "CWE-125" }, { "id": 1467, "func": "ast2obj_slice(void* _o)\n{\n slice_ty o = (slice_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n switch (o->kind) {\n case Slice_kind:\n result = PyType_GenericNew(Slice_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_expr(o->v.Slice.lower);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->v.Slice.upper);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->v.Slice.step);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n case ExtSlice_kind:\n result = PyType_GenericNew(ExtSlice_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n case Index_kind:\n result = PyType_GenericNew(Index_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_expr(o->v.Index.value);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n }\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1467, "func": "ast2obj_slice(void* _o)\n{\n slice_ty o = (slice_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_RETURN_NONE;\n }\n\n switch (o->kind) {\n case Slice_kind:\n result = PyType_GenericNew(Slice_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_expr(o->v.Slice.lower);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->v.Slice.upper);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->v.Slice.step);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n case ExtSlice_kind:\n result = PyType_GenericNew(ExtSlice_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n case Index_kind:\n result = PyType_GenericNew(Index_type, NULL, NULL);\n if (!result) goto failed;\n value = ast2obj_expr(o->v.Index.value);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)\n goto failed;\n Py_DECREF(value);\n break;\n }\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1069, "func": "\tint lazy_bdecode(char const* start, char const* end, lazy_entry& ret\n\t\t, error_code& ec, int* error_pos, int depth_limit, int item_limit)\n\t{\n\t\tchar const* const orig_start = start;\n\t\tret.clear();\n\t\tif (start == end) return 0;\n\n\t\tstd::vector stack;\n\n\t\tstack.push_back(&ret);\n\t\twhile (start < end)\n\t\t{\n\t\t\tif (stack.empty()) break; // done!\n\n\t\t\tlazy_entry* top = stack.back();\n\n\t\t\tif (int(stack.size()) > depth_limit) TORRENT_FAIL_BDECODE(bdecode_errors::depth_exceeded);\n\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\tchar t = *start;\n\t\t\t++start;\n\t\t\tif (start >= end && t != 'e') TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\tswitch (top->type())\n\t\t\t{\n\t\t\t\tcase lazy_entry::dict_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!is_digit(t)) TORRENT_FAIL_BDECODE(bdecode_errors::expected_string);\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tstart = parse_int(start, end, ':', len);\n\t\t\t\t\tif (start == 0 || start + len + 3 > end || *start != ':')\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_colon);\n\t\t\t\t\t++start;\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tlazy_entry* ent = top->dict_append(start);\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstart += len;\n\t\t\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tt = *start;\n\t\t\t\t\t++start;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase lazy_entry::list_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlazy_entry* ent = top->list_append();\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: break;\n\t\t\t}\n\n\t\t\t--item_limit;\n\t\t\tif (item_limit <= 0) TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);\n\n\t\t\ttop = stack.back();\n\t\t\tswitch (t)\n\t\t\t{\n\t\t\t\tcase 'd':\n\t\t\t\t\ttop->construct_dict(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'l':\n\t\t\t\t\ttop->construct_list(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'i':\n\t\t\t\t{\n\t\t\t\t\tchar const* int_start = start;\n\t\t\t\t\tstart = find_char(start, end, 'e');\n\t\t\t\t\ttop->construct_int(int_start, start - int_start);\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tTORRENT_ASSERT(*start == 'e');\n\t\t\t\t\t++start;\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tif (!is_digit(t))\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_value);\n\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tstart = parse_int(start, end, ':', len);\n\t\t\t\t\tif (start == 0 || start + len + 1 > end || *start != ':')\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_colon);\n\t\t\t\t\t++start;\n\t\t\t\t\ttop->construct_string(start, int(len));\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tstart += len;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\treturn 0;\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-8509", "cwe_id": "CWE-119" }, { "id": 1069, "func": "\tint lazy_bdecode(char const* start, char const* end, lazy_entry& ret\n\t\t, error_code& ec, int* error_pos, int depth_limit, int item_limit)\n\t{\n\t\tchar const* const orig_start = start;\n\t\tret.clear();\n\t\tif (start == end) return 0;\n\n\t\tstd::vector stack;\n\n\t\tstack.push_back(&ret);\n\t\twhile (start <= end)\n\t\t{\n\t\t\tif (stack.empty()) break; // done!\n\n\t\t\tlazy_entry* top = stack.back();\n\n\t\t\tif (int(stack.size()) > depth_limit) TORRENT_FAIL_BDECODE(bdecode_errors::depth_exceeded);\n\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\tchar t = *start;\n\t\t\t++start;\n\t\t\tif (start >= end && t != 'e') TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\tswitch (top->type())\n\t\t\t{\n\t\t\t\tcase lazy_entry::dict_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!numeric(t)) TORRENT_FAIL_BDECODE(bdecode_errors::expected_string);\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\n\t\t\t\t\tif (start + len + 1 > end)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tlazy_entry* ent = top->dict_append(start);\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstart += len;\n\t\t\t\t\tif (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tt = *start;\n\t\t\t\t\t++start;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase lazy_entry::list_t:\n\t\t\t\t{\n\t\t\t\t\tif (t == 'e')\n\t\t\t\t\t{\n\t\t\t\t\t\ttop->set_end(start);\n\t\t\t\t\t\tstack.pop_back();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlazy_entry* ent = top->list_append();\n\t\t\t\t\tif (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);\n\t\t\t\t\tstack.push_back(ent);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: break;\n\t\t\t}\n\n\t\t\t--item_limit;\n\t\t\tif (item_limit <= 0) TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);\n\n\t\t\ttop = stack.back();\n\t\t\tswitch (t)\n\t\t\t{\n\t\t\t\tcase 'd':\n\t\t\t\t\ttop->construct_dict(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'l':\n\t\t\t\t\ttop->construct_list(start - 1);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase 'i':\n\t\t\t\t{\n\t\t\t\t\tchar const* int_start = start;\n\t\t\t\t\tstart = find_char(start, end, 'e');\n\t\t\t\t\ttop->construct_int(int_start, start - int_start);\n\t\t\t\t\tif (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tTORRENT_ASSERT(*start == 'e');\n\t\t\t\t\t++start;\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tif (!numeric(t))\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::expected_value);\n\n\t\t\t\t\tboost::int64_t len = t - '0';\n\t\t\t\t\tbdecode_errors::error_code_enum e = bdecode_errors::no_error;\n\t\t\t\t\tstart = parse_int(start, end, ':', len, e);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(e);\n\t\t\t\t\tif (start + len + 1 > end)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tTORRENT_FAIL_BDECODE(bdecode_errors::overflow);\n\n\t\t\t\t\t++start;\n\t\t\t\t\ttop->construct_string(start, int(len));\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tstart += len;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\treturn 0;\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-8509", "cwe_id": "CWE-119" }, { "id": 2641, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputData);\n const TfLiteTensor* prev_activation =\n GetInput(context, node, kInputPrevActivation);\n const TfLiteTensor* weights = GetInput(context, node, kInputWeights);\n const TfLiteTensor* bias = GetInput(context, node, kInputBiases);\n const TfLiteTensor* prev_state = GetInput(context, node, kInputPrevState);\n\n TfLiteTensor* activation_out = GetOutput(context, node, kOutputActivation);\n TfLiteTensor* state_out = GetOutput(context, node, kOutputState);\n TfLiteTensor* concat_temp = GetOutput(context, node, kOutputConcatTemp);\n TfLiteTensor* activation_temp =\n GetOutput(context, node, kOutputActivationTemp);\n\n if (input->type == kTfLiteFloat32 &&\n prev_activation->type == kTfLiteFloat32 &&\n weights->type == kTfLiteFloat32 && bias->type == kTfLiteFloat32 &&\n prev_state->type == kTfLiteFloat32 && state_out->type == kTfLiteFloat32 &&\n activation_out->type == kTfLiteFloat32 &&\n concat_temp->type == kTfLiteFloat32 &&\n activation_temp->type == kTfLiteFloat32) {\n tflite::LstmCellParams op_params;\n // Float LSTM cell does not need parameters to be set: leave untouched.\n optimized_ops::LstmCell(\n op_params,\n // Inputs.\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(prev_activation), GetTensorData(prev_activation),\n GetTensorShape(weights), GetTensorData(weights),\n GetTensorShape(bias), GetTensorData(bias),\n GetTensorShape(prev_state), GetTensorData(prev_state),\n // Outputs.\n GetTensorShape(state_out), GetTensorData(state_out),\n GetTensorShape(activation_out), GetTensorData(activation_out),\n GetTensorShape(concat_temp), GetTensorData(concat_temp),\n GetTensorShape(activation_temp), GetTensorData(activation_temp),\n CpuBackendContext::GetFromContext(context));\n } else if (input->type == kTfLiteUInt8 &&\n prev_activation->type == kTfLiteUInt8 &&\n weights->type == kTfLiteUInt8 && bias->type == kTfLiteInt32 &&\n prev_state->type == kTfLiteInt16 &&\n state_out->type == kTfLiteInt16 &&\n activation_out->type == kTfLiteUInt8 &&\n concat_temp->type == kTfLiteUInt8 &&\n activation_temp->type == kTfLiteInt16) {\n int state_scale_log2_rounded;\n if (!CheckedLog2(state_out->params.scale, &state_scale_log2_rounded)) {\n context->ReportError(\n context,\n \"The internal state of a LSTM cell must have a power-of-two scale.\");\n return kTfLiteError;\n }\n const int state_integer_bits = 15 + state_scale_log2_rounded;\n if (state_integer_bits != 4) {\n context->ReportError(context,\n \"The only case of quantized LstmCell currently \"\n \"supported is with StateIntegerBits==4\");\n return kTfLiteError;\n }\n\n double real_accum_multiplier = 4096 * bias->params.scale;\n int32 accum_multiplier;\n int accum_shift;\n tflite::QuantizeMultiplier(real_accum_multiplier, &accum_multiplier,\n &accum_shift);\n tflite::LstmCellParams op_params;\n op_params.weights_zero_point = weights->params.zero_point;\n op_params.accum_multiplier = accum_multiplier;\n op_params.accum_shift = accum_shift;\n optimized_ops::LstmCell<4>(\n op_params,\n // Inputs.\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(prev_activation),\n GetTensorData(prev_activation), GetTensorShape(weights),\n GetTensorData(weights), GetTensorShape(bias),\n GetTensorData(bias), GetTensorShape(prev_state),\n GetTensorData(prev_state),\n // Outputs.\n GetTensorShape(state_out), GetTensorData(state_out),\n GetTensorShape(activation_out), GetTensorData(activation_out),\n GetTensorShape(concat_temp), GetTensorData(concat_temp),\n GetTensorShape(activation_temp),\n GetTensorData(activation_temp),\n CpuBackendContext::GetFromContext(context));\n } else {\n context->ReportError(context,\n \"Unsupported combination of data types for LstmCell\");\n return kTfLiteError;\n }\n\n // TODO(ycling): Investigate if this copy can be avoided with the 5-inputs\n // LSTM kernel.\n memcpy(prev_activation->data.raw, activation_out->data.raw,\n activation_out->bytes);\n memcpy(prev_state->data.raw, state_out->data.raw, state_out->bytes);\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2641, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputData, &input));\n const TfLiteTensor* prev_activation;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputPrevActivation,\n &prev_activation));\n const TfLiteTensor* weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputWeights, &weights));\n const TfLiteTensor* bias;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputBiases, &bias));\n const TfLiteTensor* prev_state;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputPrevState, &prev_state));\n\n TfLiteTensor* activation_out;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputActivation,\n &activation_out));\n TfLiteTensor* state_out;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputState, &state_out));\n TfLiteTensor* concat_temp;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputConcatTemp, &concat_temp));\n TfLiteTensor* activation_temp;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputActivationTemp,\n &activation_temp));\n\n if (input->type == kTfLiteFloat32 &&\n prev_activation->type == kTfLiteFloat32 &&\n weights->type == kTfLiteFloat32 && bias->type == kTfLiteFloat32 &&\n prev_state->type == kTfLiteFloat32 && state_out->type == kTfLiteFloat32 &&\n activation_out->type == kTfLiteFloat32 &&\n concat_temp->type == kTfLiteFloat32 &&\n activation_temp->type == kTfLiteFloat32) {\n tflite::LstmCellParams op_params;\n // Float LSTM cell does not need parameters to be set: leave untouched.\n optimized_ops::LstmCell(\n op_params,\n // Inputs.\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(prev_activation), GetTensorData(prev_activation),\n GetTensorShape(weights), GetTensorData(weights),\n GetTensorShape(bias), GetTensorData(bias),\n GetTensorShape(prev_state), GetTensorData(prev_state),\n // Outputs.\n GetTensorShape(state_out), GetTensorData(state_out),\n GetTensorShape(activation_out), GetTensorData(activation_out),\n GetTensorShape(concat_temp), GetTensorData(concat_temp),\n GetTensorShape(activation_temp), GetTensorData(activation_temp),\n CpuBackendContext::GetFromContext(context));\n } else if (input->type == kTfLiteUInt8 &&\n prev_activation->type == kTfLiteUInt8 &&\n weights->type == kTfLiteUInt8 && bias->type == kTfLiteInt32 &&\n prev_state->type == kTfLiteInt16 &&\n state_out->type == kTfLiteInt16 &&\n activation_out->type == kTfLiteUInt8 &&\n concat_temp->type == kTfLiteUInt8 &&\n activation_temp->type == kTfLiteInt16) {\n int state_scale_log2_rounded;\n if (!CheckedLog2(state_out->params.scale, &state_scale_log2_rounded)) {\n context->ReportError(\n context,\n \"The internal state of a LSTM cell must have a power-of-two scale.\");\n return kTfLiteError;\n }\n const int state_integer_bits = 15 + state_scale_log2_rounded;\n if (state_integer_bits != 4) {\n context->ReportError(context,\n \"The only case of quantized LstmCell currently \"\n \"supported is with StateIntegerBits==4\");\n return kTfLiteError;\n }\n\n double real_accum_multiplier = 4096 * bias->params.scale;\n int32 accum_multiplier;\n int accum_shift;\n tflite::QuantizeMultiplier(real_accum_multiplier, &accum_multiplier,\n &accum_shift);\n tflite::LstmCellParams op_params;\n op_params.weights_zero_point = weights->params.zero_point;\n op_params.accum_multiplier = accum_multiplier;\n op_params.accum_shift = accum_shift;\n optimized_ops::LstmCell<4>(\n op_params,\n // Inputs.\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(prev_activation),\n GetTensorData(prev_activation), GetTensorShape(weights),\n GetTensorData(weights), GetTensorShape(bias),\n GetTensorData(bias), GetTensorShape(prev_state),\n GetTensorData(prev_state),\n // Outputs.\n GetTensorShape(state_out), GetTensorData(state_out),\n GetTensorShape(activation_out), GetTensorData(activation_out),\n GetTensorShape(concat_temp), GetTensorData(concat_temp),\n GetTensorShape(activation_temp),\n GetTensorData(activation_temp),\n CpuBackendContext::GetFromContext(context));\n } else {\n context->ReportError(context,\n \"Unsupported combination of data types for LstmCell\");\n return kTfLiteError;\n }\n\n // TODO(ycling): Investigate if this copy can be avoided with the 5-inputs\n // LSTM kernel.\n memcpy(prev_activation->data.raw, activation_out->data.raw,\n activation_out->bytes);\n memcpy(prev_state->data.raw, state_out->data.raw, state_out->bytes);\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 581, "func": "static inline int unicode_cp_is_allowed(unsigned uni_cp, int document_type)\n{\n\t/* XML 1.0\t\t\t\tHTML 4.01\t\t\tHTML 5\n\t * 0x09..0x0A\t\t\t0x09..0x0A\t\t\t0x09..0x0A\n\t * 0x0D\t\t\t\t\t0x0D\t\t\t\t0x0C..0x0D\n\t * 0x0020..0xD7FF\t\t0x20..0x7E\t\t\t0x20..0x7E\n\t *\t\t\t\t\t\t0x00A0..0xD7FF\t\t0x00A0..0xD7FF\n\t * 0xE000..0xFFFD\t\t0xE000..0x10FFFF\t0xE000..0xFDCF\n\t * 0x010000..0x10FFFF\t\t\t\t\t\t0xFDF0..0x10FFFF (*)\n\t *\n\t * (*) exclude code points where ((code & 0xFFFF) >= 0xFFFE)\n\t *\n\t * References:\n\t * XML 1.0: \n\t * HTML 4.01: \n\t * HTML 5: \n\t *\n\t * Not sure this is the relevant part for HTML 5, though. I opted to\n\t * disallow the characters that would result in a parse error when\n\t * preprocessing of the input stream. See also section 8.1.3.\n\t * \n\t * It's unclear if XHTML 1.0 allows C1 characters. I'll opt to apply to\n\t * XHTML 1.0 the same rules as for XML 1.0.\n\t * See .\n\t */\n\n\tswitch (document_type) {\n\tcase ENT_HTML_DOC_HTML401:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF);\n\tcase ENT_HTML_DOC_HTML5:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp >= 0x09 && uni_cp <= 0x0D && uni_cp != 0x0B) || /* form feed U+0C allowed */\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF &&\n\t\t\t\t((uni_cp & 0xFFFF) < 0xFFFE) && /* last two of each plane (nonchars) disallowed */\n\t\t\t\t(uni_cp < 0xFDD0 || uni_cp > 0xFDEF)); /* U+FDD0-U+FDEF (nonchars) disallowed */\n\tcase ENT_HTML_DOC_XHTML:\n\tcase ENT_HTML_DOC_XML1:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF && uni_cp != 0xFFFE && uni_cp != 0xFFFF);\n\tdefault:\n\t\treturn 1;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 581, "func": "static inline int unicode_cp_is_allowed(unsigned uni_cp, int document_type)\n{\n\t/* XML 1.0\t\t\t\tHTML 4.01\t\t\tHTML 5\n\t * 0x09..0x0A\t\t\t0x09..0x0A\t\t\t0x09..0x0A\n\t * 0x0D\t\t\t\t\t0x0D\t\t\t\t0x0C..0x0D\n\t * 0x0020..0xD7FF\t\t0x20..0x7E\t\t\t0x20..0x7E\n\t *\t\t\t\t\t\t0x00A0..0xD7FF\t\t0x00A0..0xD7FF\n\t * 0xE000..0xFFFD\t\t0xE000..0x10FFFF\t0xE000..0xFDCF\n\t * 0x010000..0x10FFFF\t\t\t\t\t\t0xFDF0..0x10FFFF (*)\n\t *\n\t * (*) exclude code points where ((code & 0xFFFF) >= 0xFFFE)\n\t *\n\t * References:\n\t * XML 1.0: \n\t * HTML 4.01: \n\t * HTML 5: \n\t *\n\t * Not sure this is the relevant part for HTML 5, though. I opted to\n\t * disallow the characters that would result in a parse error when\n\t * preprocessing of the input stream. See also section 8.1.3.\n\t *\n\t * It's unclear if XHTML 1.0 allows C1 characters. I'll opt to apply to\n\t * XHTML 1.0 the same rules as for XML 1.0.\n\t * See .\n\t */\n\n\tswitch (document_type) {\n\tcase ENT_HTML_DOC_HTML401:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF);\n\tcase ENT_HTML_DOC_HTML5:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp >= 0x09 && uni_cp <= 0x0D && uni_cp != 0x0B) || /* form feed U+0C allowed */\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF &&\n\t\t\t\t((uni_cp & 0xFFFF) < 0xFFFE) && /* last two of each plane (nonchars) disallowed */\n\t\t\t\t(uni_cp < 0xFDD0 || uni_cp > 0xFDEF)); /* U+FDD0-U+FDEF (nonchars) disallowed */\n\tcase ENT_HTML_DOC_XHTML:\n\tcase ENT_HTML_DOC_XML1:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF && uni_cp != 0xFFFE && uni_cp != 0xFFFF);\n\tdefault:\n\t\treturn 1;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 2669, "func": "ex_function(exarg_T *eap)\n{\n char_u *line_to_free = NULL;\n\n (void)define_function(eap, NULL, &line_to_free);\n vim_free(line_to_free);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0156", "cwe_id": "CWE-416" }, { "id": 2669, "func": "ex_function(exarg_T *eap)\n{\n garray_T lines_to_free;\n\n ga_init2(&lines_to_free, sizeof(char_u *), 50);\n (void)define_function(eap, NULL, &lines_to_free);\n ga_clear_strings(&lines_to_free);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0156", "cwe_id": "CWE-416" }, { "id": 395, "func": "snmp_ber_encode_null(unsigned char *out, uint32_t *out_len, uint8_t type)\n{\n (*out_len)++;\n *out-- = 0x00;\n out = snmp_ber_encode_type(out, out_len, type);\n\n return out;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 395, "func": "snmp_ber_encode_null(snmp_packet_t *snmp_packet, uint8_t type)\n{\n\n if(snmp_packet->used == snmp_packet->max) {\n return 0;\n }\n\n *snmp_packet->out-- = 0x00;\n snmp_packet->used++;\n\n return snmp_ber_encode_type(snmp_packet, type);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 1377, "func": " RectangleRequest &operator=(const struct RectangleRequest &req)\n { \n // Not nice, but this is really faster and simpler\n memcpy(this,&req,sizeof(struct RectangleRequest));\n // Not linked in any way if this is new.\n rr_pNext = NULL;\n //\n return *this;\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-31620", "cwe_id": "CWE-119" }, { "id": 1377, "func": " RectangleRequest &operator=(const struct RectangleRequest &req)\n { \n // Not linked in any way if this is new.\n rr_pNext = NULL;\n rr_Request = req.rr_Request;\n rr_usFirstComponent = req.rr_usFirstComponent;\n rr_usLastComponent = req.rr_usLastComponent;\n rr_cPriority = req.rr_cPriority;\n rr_bIncludeAlpha = req.rr_bIncludeAlpha;\n rr_bUpsampling = req.rr_bUpsampling;\n rr_bColorTrafo = req.rr_bColorTrafo;\n //\n return *this;\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-31620", "cwe_id": "CWE-119" }, { "id": 821, "func": "void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)\n{\n // Map inconvertible characters to private use Unicode area 0xE000.\n // Mark such string by placing special non-character code before\n // first inconvertible character.\n Success=false;\n bool MarkAdded=false;\n uint SrcPos=0,DestPos=0;\n while (DestPos=0x80)\n {\n if (!MarkAdded)\n {\n Dest[DestPos++]=MappedStringMark;\n MarkAdded=true;\n if (DestPos>=DestSize)\n break;\n }\n Dest[DestPos++]=byte(Src[SrcPos++])+MapAreaStart;\n }\n else\n break;\n }\n else\n {\n memset(&ps,0,sizeof(ps));\n int Length=mbrlen(Src+SrcPos,MB_CUR_MAX,&ps);\n SrcPos+=Max(Length,1);\n DestPos++;\n }\n }\n Dest[Min(DestPos,DestSize-1)]=0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 821, "func": "void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)\n{\n // Map inconvertible characters to private use Unicode area 0xE000.\n // Mark such string by placing special non-character code before\n // first inconvertible character.\n Success=false;\n bool MarkAdded=false;\n uint SrcPos=0,DestPos=0;\n while (DestPos=0x80)\n {\n if (!MarkAdded)\n {\n Dest[DestPos++]=MappedStringMark;\n MarkAdded=true;\n if (DestPos>=DestSize)\n break;\n }\n Dest[DestPos++]=byte(Src[SrcPos++])+MapAreaStart;\n }\n else\n break;\n }\n else\n {\n memset(&ps,0,sizeof(ps));\n int Length=mbrlen(Src+SrcPos,MB_CUR_MAX,&ps);\n SrcPos+=Max(Length,1);\n DestPos++;\n }\n }\n Dest[Min(DestPos,DestSize-1)]=0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 2212, "func": "static int t220_frontend_attach(struct dvb_usb_adapter *d)\n{\n\tu8 obuf[3] = { 0xe, 0x87, 0 };\n\tu8 ibuf[] = { 0 };\n\n\tif (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tobuf[0] = 0xe;\n\tobuf[1] = 0x86;\n\tobuf[2] = 1;\n\n\tif (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tobuf[0] = 0xe;\n\tobuf[1] = 0x80;\n\tobuf[2] = 0;\n\n\tif (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tmsleep(50);\n\n\tobuf[0] = 0xe;\n\tobuf[1] = 0x80;\n\tobuf[2] = 1;\n\n\tif (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tobuf[0] = 0x51;\n\n\tif (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)\n\t\terr(\"command 0x51 transfer failed.\");\n\n\td->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config,\n\t\t\t\t\t&d->dev->i2c_adap, NULL);\n\tif (d->fe_adap[0].fe != NULL) {\n\t\tif (dvb_attach(tda18271_attach, d->fe_adap[0].fe, 0x60,\n\t\t\t\t\t&d->dev->i2c_adap, &tda18271_config)) {\n\t\t\tinfo(\"Attached TDA18271HD/CXD2820R!\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tinfo(\"Failed to attach TDA18271HD/CXD2820R!\");\n\treturn -EIO;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-8062", "cwe_id": "CWE-119" }, { "id": 2212, "func": "static int t220_frontend_attach(struct dvb_usb_adapter *adap)\n{\n\tstruct dvb_usb_device *d = adap->dev;\n\tstruct dw2102_state *state = d->priv;\n\n\tmutex_lock(&d->data_mutex);\n\n\tstate->data[0] = 0xe;\n\tstate->data[1] = 0x87;\n\tstate->data[2] = 0x0;\n\n\tif (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tstate->data[0] = 0xe;\n\tstate->data[1] = 0x86;\n\tstate->data[2] = 1;\n\n\tif (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tstate->data[0] = 0xe;\n\tstate->data[1] = 0x80;\n\tstate->data[2] = 0;\n\n\tif (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tmsleep(50);\n\n\tstate->data[0] = 0xe;\n\tstate->data[1] = 0x80;\n\tstate->data[2] = 1;\n\n\tif (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)\n\t\terr(\"command 0x0e transfer failed.\");\n\n\tstate->data[0] = 0x51;\n\n\tif (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0)\n\t\terr(\"command 0x51 transfer failed.\");\n\n\tmutex_unlock(&d->data_mutex);\n\n\tadap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config,\n\t\t\t\t\t&d->i2c_adap, NULL);\n\tif (adap->fe_adap[0].fe != NULL) {\n\t\tif (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60,\n\t\t\t\t\t&d->i2c_adap, &tda18271_config)) {\n\t\t\tinfo(\"Attached TDA18271HD/CXD2820R!\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tinfo(\"Failed to attach TDA18271HD/CXD2820R!\");\n\treturn -EIO;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-8062", "cwe_id": "CWE-119" }, { "id": 1612, "func": "ip_printts(netdissect_options *ndo,\n register const u_char *cp, u_int length)\n{\n\tregister u_int ptr;\n\tregister u_int len;\n\tint hoplen;\n\tconst char *type;\n\n\tif (length < 4) {\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\t\treturn;\n\t}\n\tND_PRINT((ndo, \" TS{\"));\n\thoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;\n\tif ((length - 4) & (hoplen-1))\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\tptr = cp[2] - 1;\n\tlen = 0;\n\tif (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)\n\t\tND_PRINT((ndo, \"[bad ptr %u]\", cp[2]));\n\tswitch (cp[3]&0xF) {\n\tcase IPOPT_TS_TSONLY:\n\t\tND_PRINT((ndo, \"TSONLY\"));\n\t\tbreak;\n\tcase IPOPT_TS_TSANDADDR:\n\t\tND_PRINT((ndo, \"TS+ADDR\"));\n\t\tbreak;\n\t/*\n\t * prespecified should really be 3, but some ones might send 2\n\t * instead, and the IPOPT_TS_PRESPEC constant can apparently\n\t * have both values, so we have to hard-code it here.\n\t */\n\n\tcase 2:\n\t\tND_PRINT((ndo, \"PRESPEC2.0\"));\n\t\tbreak;\n\tcase 3:\t\t\t/* IPOPT_TS_PRESPEC */\n\t\tND_PRINT((ndo, \"PRESPEC\"));\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \"[bad ts type %d]\", cp[3]&0xF));\n\t\tgoto done;\n\t}\n\n\ttype = \" \";\n\tfor (len = 4; len < length; len += hoplen) {\n\t\tif (ptr == len)\n\t\t\ttype = \" ^ \";\n\t\tND_PRINT((ndo, \"%s%d@%s\", type, EXTRACT_32BITS(&cp[len+hoplen-4]),\n\t\t hoplen!=8 ? \"\" : ipaddr_string(ndo, &cp[len])));\n\t\ttype = \" \";\n\t}\n\ndone:\n\tND_PRINT((ndo, \"%s\", ptr == len ? \" ^ \" : \"\"));\n\n\tif (cp[3]>>4)\n\t\tND_PRINT((ndo, \" [%d hops not recorded]} \", cp[3]>>4));\n\telse\n\t\tND_PRINT((ndo, \"}\"));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13037", "cwe_id": "CWE-125" }, { "id": 1612, "func": "ip_printts(netdissect_options *ndo,\n register const u_char *cp, u_int length)\n{\n\tregister u_int ptr;\n\tregister u_int len;\n\tint hoplen;\n\tconst char *type;\n\n\tif (length < 4) {\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\t\treturn (0);\n\t}\n\tND_PRINT((ndo, \" TS{\"));\n\thoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;\n\tif ((length - 4) & (hoplen-1))\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\tND_TCHECK(cp[2]);\n\tptr = cp[2] - 1;\n\tlen = 0;\n\tif (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)\n\t\tND_PRINT((ndo, \"[bad ptr %u]\", cp[2]));\n\tND_TCHECK(cp[3]);\n\tswitch (cp[3]&0xF) {\n\tcase IPOPT_TS_TSONLY:\n\t\tND_PRINT((ndo, \"TSONLY\"));\n\t\tbreak;\n\tcase IPOPT_TS_TSANDADDR:\n\t\tND_PRINT((ndo, \"TS+ADDR\"));\n\t\tbreak;\n\t/*\n\t * prespecified should really be 3, but some ones might send 2\n\t * instead, and the IPOPT_TS_PRESPEC constant can apparently\n\t * have both values, so we have to hard-code it here.\n\t */\n\n\tcase 2:\n\t\tND_PRINT((ndo, \"PRESPEC2.0\"));\n\t\tbreak;\n\tcase 3:\t\t\t/* IPOPT_TS_PRESPEC */\n\t\tND_PRINT((ndo, \"PRESPEC\"));\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \"[bad ts type %d]\", cp[3]&0xF));\n\t\tgoto done;\n\t}\n\n\ttype = \" \";\n\tfor (len = 4; len < length; len += hoplen) {\n\t\tif (ptr == len)\n\t\t\ttype = \" ^ \";\n\t\tND_TCHECK2(cp[len], hoplen);\n\t\tND_PRINT((ndo, \"%s%d@%s\", type, EXTRACT_32BITS(&cp[len+hoplen-4]),\n\t\t hoplen!=8 ? \"\" : ipaddr_string(ndo, &cp[len])));\n\t\ttype = \" \";\n\t}\n\ndone:\n\tND_PRINT((ndo, \"%s\", ptr == len ? \" ^ \" : \"\"));\n\n\tif (cp[3]>>4)\n\t\tND_PRINT((ndo, \" [%d hops not recorded]} \", cp[3]>>4));\n\telse\n\t\tND_PRINT((ndo, \"}\"));\n\treturn (0);\n\ntrunc:\n\treturn (-1);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13037", "cwe_id": "CWE-125" }, { "id": 50, "func": "NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)\n{\n\tstatic const char module[] = \"NeXTDecode\";\n\tunsigned char *bp, *op;\n\ttmsize_t cc;\n\tuint8* row;\n\ttmsize_t scanline, n;\n\n\t(void) s;\n\t/*\n\t * Each scanline is assumed to start off as all\n\t * white (we assume a PhotometricInterpretation\n\t * of ``min-is-black'').\n\t */\n\tfor (op = (unsigned char*) buf, cc = occ; cc-- > 0;)\n\t\t*op++ = 0xff;\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n\tcc = tif->tif_rawcc;\n\tscanline = tif->tif_scanlinesize;\n\tif (occ % scanline)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata, module, \"Fractional scanlines cannot be read\");\n\t\treturn (0);\n\t}\n\tfor (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {\n\t\tn = *bp++, cc--;\n\t\tswitch (n) {\n\t\tcase LITERALROW:\n\t\t\t/*\n\t\t\t * The entire scanline is given as literal values.\n\t\t\t */\n\t\t\tif (cc < scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row, bp, scanline);\n\t\t\tbp += scanline;\n\t\t\tcc -= scanline;\n\t\t\tbreak;\n\t\tcase LITERALSPAN: {\n\t\t\ttmsize_t off;\n\t\t\t/*\n\t\t\t * The scanline has a literal span that begins at some\n\t\t\t * offset.\n\t\t\t */\n\t\t\tif( cc < 4 )\n\t\t\t\tgoto bad;\n\t\t\toff = (bp[0] * 256) + bp[1];\n\t\t\tn = (bp[2] * 256) + bp[3];\n\t\t\tif (cc < 4+n || off+n > scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row+off, bp+4, n);\n\t\t\tbp += 4+n;\n\t\t\tcc -= 4+n;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tuint32 npixels = 0, grey;\n\t\t\tuint32 imagewidth = tif->tif_dir.td_imagewidth;\n if( isTiled(tif) )\n imagewidth = tif->tif_dir.td_tilewidth;\n\n\t\t\t/*\n\t\t\t * The scanline is composed of a sequence of constant\n\t\t\t * color ``runs''. We shift into ``run mode'' and\n\t\t\t * interpret bytes as codes of the form\n\t\t\t * until we've filled the scanline.\n\t\t\t */\n\t\t\top = row;\n\t\t\tfor (;;) {\n\t\t\t\tgrey = (uint32)((n>>6) & 0x3);\n\t\t\t\tn &= 0x3f;\n\t\t\t\t/*\n\t\t\t\t * Ensure the run does not exceed the scanline\n\t\t\t\t * bounds, potentially resulting in a security\n\t\t\t\t * issue.\n\t\t\t\t */\n\t\t\t\twhile (n-- > 0 && npixels < imagewidth)\n\t\t\t\t\tSETPIXEL(op, grey);\n\t\t\t\tif (npixels >= imagewidth)\n\t\t\t\t\tbreak;\n\t\t\t\tif (cc == 0)\n\t\t\t\t\tgoto bad;\n\t\t\t\tn = *bp++, cc--;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t}\n\ttif->tif_rawcp = (uint8*) bp;\n\ttif->tif_rawcc = cc;\n\treturn (1);\nbad:\n\tTIFFErrorExt(tif->tif_clientdata, module, \"Not enough data for scanline %ld\",\n\t (long) tif->tif_row);\n\treturn (0);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-8784", "cwe_id": "CWE-787" }, { "id": 50, "func": "NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)\n{\n\tstatic const char module[] = \"NeXTDecode\";\n\tunsigned char *bp, *op;\n\ttmsize_t cc;\n\tuint8* row;\n\ttmsize_t scanline, n;\n\n\t(void) s;\n\t/*\n\t * Each scanline is assumed to start off as all\n\t * white (we assume a PhotometricInterpretation\n\t * of ``min-is-black'').\n\t */\n\tfor (op = (unsigned char*) buf, cc = occ; cc-- > 0;)\n\t\t*op++ = 0xff;\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n\tcc = tif->tif_rawcc;\n\tscanline = tif->tif_scanlinesize;\n\tif (occ % scanline)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata, module, \"Fractional scanlines cannot be read\");\n\t\treturn (0);\n\t}\n\tfor (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {\n\t\tn = *bp++, cc--;\n\t\tswitch (n) {\n\t\tcase LITERALROW:\n\t\t\t/*\n\t\t\t * The entire scanline is given as literal values.\n\t\t\t */\n\t\t\tif (cc < scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row, bp, scanline);\n\t\t\tbp += scanline;\n\t\t\tcc -= scanline;\n\t\t\tbreak;\n\t\tcase LITERALSPAN: {\n\t\t\ttmsize_t off;\n\t\t\t/*\n\t\t\t * The scanline has a literal span that begins at some\n\t\t\t * offset.\n\t\t\t */\n\t\t\tif( cc < 4 )\n\t\t\t\tgoto bad;\n\t\t\toff = (bp[0] * 256) + bp[1];\n\t\t\tn = (bp[2] * 256) + bp[3];\n\t\t\tif (cc < 4+n || off+n > scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row+off, bp+4, n);\n\t\t\tbp += 4+n;\n\t\t\tcc -= 4+n;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tuint32 npixels = 0, grey;\n\t\t\tuint32 imagewidth = tif->tif_dir.td_imagewidth;\n if( isTiled(tif) )\n imagewidth = tif->tif_dir.td_tilewidth;\n tmsize_t op_offset = 0;\n\n\t\t\t/*\n\t\t\t * The scanline is composed of a sequence of constant\n\t\t\t * color ``runs''. We shift into ``run mode'' and\n\t\t\t * interpret bytes as codes of the form\n\t\t\t * until we've filled the scanline.\n\t\t\t */\n\t\t\top = row;\n\t\t\tfor (;;) {\n\t\t\t\tgrey = (uint32)((n>>6) & 0x3);\n\t\t\t\tn &= 0x3f;\n\t\t\t\t/*\n\t\t\t\t * Ensure the run does not exceed the scanline\n\t\t\t\t * bounds, potentially resulting in a security\n\t\t\t\t * issue.\n\t\t\t\t */\n\t\t\t\twhile (n-- > 0 && npixels < imagewidth && op_offset < scanline)\n\t\t\t\t\tSETPIXEL(op, grey);\n\t\t\t\tif (npixels >= imagewidth)\n\t\t\t\t\tbreak;\n if (op_offset >= scanline ) {\n TIFFErrorExt(tif->tif_clientdata, module, \"Invalid data for scanline %ld\",\n (long) tif->tif_row);\n return (0);\n }\n\t\t\t\tif (cc == 0)\n\t\t\t\t\tgoto bad;\n\t\t\t\tn = *bp++, cc--;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t}\n\ttif->tif_rawcp = (uint8*) bp;\n\ttif->tif_rawcc = cc;\n\treturn (1);\nbad:\n\tTIFFErrorExt(tif->tif_clientdata, module, \"Not enough data for scanline %ld\",\n\t (long) tif->tif_row);\n\treturn (0);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-8784", "cwe_id": "CWE-787" }, { "id": 798, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n FillDiagHelper(input, output);\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 798, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n FillDiagHelper(input, output);\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 907, "func": "int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info,\n bool* found_unknown_shapes) {\n int64_t total_output_size = 0;\n // Use float as default for calculations.\n for (const auto& output : op_info.outputs()) {\n DataType dt = output.dtype();\n const auto& original_output_shape = output.shape();\n int64_t output_size = DataTypeSize(BaseType(dt));\n int num_dims = std::max(1, original_output_shape.dim_size());\n auto output_shape = MaybeGetMinimumShape(original_output_shape, num_dims,\n found_unknown_shapes);\n for (const auto& dim : output_shape.dim()) {\n output_size *= dim.size();\n }\n total_output_size += output_size;\n VLOG(1) << \"Output Size: \" << output_size\n << \" Total Output Size:\" << total_output_size;\n }\n return total_output_size;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-23576", "cwe_id": "CWE-190" }, { "id": 907, "func": "int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info,\n bool* found_unknown_shapes) {\n int64_t total_output_size = 0;\n // Use float as default for calculations.\n for (const auto& output : op_info.outputs()) {\n DataType dt = output.dtype();\n const auto& original_output_shape = output.shape();\n int64_t output_size = DataTypeSize(BaseType(dt));\n int num_dims = std::max(1, original_output_shape.dim_size());\n auto output_shape = MaybeGetMinimumShape(original_output_shape, num_dims,\n found_unknown_shapes);\n for (const auto& dim : output_shape.dim()) {\n int64_t new_output_size =\n MultiplyWithoutOverflow(output_size, dim.size());\n if (new_output_size < 0) {\n VLOG(1) << \"Overflow encountered when estimating cost, multiplying \"\n << output_size << \" with \" << dim.size();\n return -1;\n }\n output_size = new_output_size;\n }\n total_output_size += output_size;\n VLOG(1) << \"Output Size: \" << output_size\n << \" Total Output Size:\" << total_output_size;\n }\n return total_output_size;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-23576", "cwe_id": "CWE-190" }, { "id": 7, "func": "bool logToUSDT(const Array& bt) {\n std::lock_guard lock(usdt_mutex);\n\n memset(&bt_slab, 0, sizeof(bt_slab));\n\n int i = 0;\n IterateVNoInc(\n bt.get(),\n [&](TypedValue tv) -> bool {\n\n if (i >= strobelight::kMaxStackframes) {\n return true;\n }\n\n assertx(isArrayLikeType(type(tv)));\n ArrayData* bt_frame = val(tv).parr;\n strobelight::backtrace_frame_t* frame = &bt_slab.frames[i];\n\n auto const line = bt_frame->get(s_line.get());\n if (line.is_init()) {\n assertx(isIntType(type(line)));\n frame->line = val(line).num;\n }\n\n auto const file_name = bt_frame->get(s_file.get());\n if (file_name.is_init()) {\n assertx(isStringType(type(file_name)));\n strncpy(frame->file_name,\n val(file_name).pstr->data(),\n std::min(val(file_name).pstr->size(), strobelight::kFileNameMax));\n frame->file_name[strobelight::kFileNameMax - 1] = '\\0';\n }\n\n auto const class_name = bt_frame->get(s_class.get());\n if (class_name.is_init()) {\n assertx(isStringType(type(class_name)));\n strncpy(frame->class_name,\n val(class_name).pstr->data(),\n std::min(val(class_name).pstr->size(), strobelight::kClassNameMax));\n frame->class_name[strobelight::kClassNameMax - 1] = '\\0';\n }\n\n auto const function_name = bt_frame->get(s_function.get());\n if (function_name.is_init()) {\n assertx(isStringType(type(function_name)));\n strncpy(frame->function,\n val(function_name).pstr->data(),\n std::min(val(function_name).pstr->size(),\n strobelight::kFunctionMax));\n frame->function[strobelight::kFunctionMax - 1] = '\\0';\n }\n\n i++;\n return false;\n }\n );\n bt_slab.len = i;\n\n // Allow BPF to read the now-formatted stacktrace\n FOLLY_SDT_WITH_SEMAPHORE(hhvm, hhvm_stack, &bt_slab);\n\n return true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-1917", "cwe_id": "CWE-787" }, { "id": 7, "func": "bool logToUSDT(const Array& bt) {\n std::lock_guard lock(usdt_mutex);\n\n memset(&bt_slab, 0, sizeof(bt_slab));\n\n int i = 0;\n IterateVNoInc(\n bt.get(),\n [&](TypedValue tv) -> bool {\n\n if (i >= strobelight::kMaxStackframes) {\n return true;\n }\n\n assertx(isArrayLikeType(type(tv)));\n ArrayData* bt_frame = val(tv).parr;\n strobelight::backtrace_frame_t* frame = &bt_slab.frames[i];\n\n auto const line = bt_frame->get(s_line.get());\n if (line.is_init()) {\n assertx(isIntType(type(line)));\n frame->line = val(line).num;\n }\n\n auto const file_name = bt_frame->get(s_file.get());\n if (file_name.is_init()) {\n assertx(isStringType(type(file_name)));\n strncpy(frame->file_name,\n val(file_name).pstr->data(),\n std::min(\n val(file_name).pstr->size(),\n strobelight::kFileNameMax\n ));\n frame->file_name[strobelight::kFileNameMax - 1] = '\\0';\n }\n\n auto const class_name = bt_frame->get(s_class.get());\n if (class_name.is_init()) {\n assertx(isStringType(type(class_name)));\n strncpy(frame->class_name,\n val(class_name).pstr->data(),\n std::min(\n val(class_name).pstr->size(),\n strobelight::kClassNameMax\n ));\n frame->class_name[strobelight::kClassNameMax - 1] = '\\0';\n }\n\n auto const function_name = bt_frame->get(s_function.get());\n if (function_name.is_init()) {\n assertx(isStringType(type(function_name)));\n strncpy(frame->function,\n val(function_name).pstr->data(),\n std::min(\n val(function_name).pstr->size(),\n strobelight::kFunctionMax\n ));\n frame->function[strobelight::kFunctionMax - 1] = '\\0';\n }\n\n i++;\n return false;\n }\n );\n bt_slab.len = i;\n\n // Allow BPF to read the now-formatted stacktrace\n FOLLY_SDT_WITH_SEMAPHORE(hhvm, hhvm_stack, &bt_slab);\n\n return true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-1917", "cwe_id": "CWE-787" }, { "id": 1500, "func": "void ntlm_write_message_fields(wStream* s, NTLM_MESSAGE_FIELDS* fields)\n{\n\tif (fields->MaxLen < 1)\n\t\tfields->MaxLen = fields->Len;\n\n\tStream_Write_UINT16(s, fields->Len); /* Len (2 bytes) */\n\tStream_Write_UINT16(s, fields->MaxLen); /* MaxLen (2 bytes) */\n\tStream_Write_UINT32(s, fields->BufferOffset); /* BufferOffset (4 bytes) */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8789", "cwe_id": "CWE-125" }, { "id": 1500, "func": "static void ntlm_write_message_fields(wStream* s, NTLM_MESSAGE_FIELDS* fields)\n{\n\tif (fields->MaxLen < 1)\n\t\tfields->MaxLen = fields->Len;\n\n\tStream_Write_UINT16(s, fields->Len); /* Len (2 bytes) */\n\tStream_Write_UINT16(s, fields->MaxLen); /* MaxLen (2 bytes) */\n\tStream_Write_UINT32(s, fields->BufferOffset); /* BufferOffset (4 bytes) */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8789", "cwe_id": "CWE-125" }, { "id": 376, "func": "SPL_METHOD(SplObjectStorage, unserialize)\n{\n\tspl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());\n\n\tchar *buf;\n\tsize_t buf_len;\n\tconst unsigned char *p, *s;\n\tphp_unserialize_data_t var_hash;\n\tzval entry, inf;\n\tzval *pcount, *pmembers;\n\tspl_SplObjectStorageElement *element;\n\tzend_long count;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s\", &buf, &buf_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (buf_len == 0) {\n\t\treturn;\n\t}\n\n\t/* storage */\n\ts = p = (const unsigned char*)buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tif (*p!= 'x' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tpcount = var_tmp_var(&var_hash);\n\tif (!php_var_unserialize(pcount, &p, s + buf_len, &var_hash) || Z_TYPE_P(pcount) != IS_LONG) {\n\t\tgoto outexcept;\n\t}\n\n\t--p; /* for ';' */\n\tcount = Z_LVAL_P(pcount);\n\n\twhile (count-- > 0) {\n\t\tspl_SplObjectStorageElement *pelement;\n\t\tzend_string *hash;\n\n\t\tif (*p != ';') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\t++p;\n\t\tif(*p != 'O' && *p != 'C' && *p != 'r') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\t/* store reference to allow cross-references between different elements */\n\t\tif (!php_var_unserialize(&entry, &p, s + buf_len, &var_hash)) {\n\t\t\tgoto outexcept;\n\t\t}\n\t\tif (Z_TYPE(entry) != IS_OBJECT) {\n\t\t\tzval_ptr_dtor(&entry);\n\t\t\tgoto outexcept;\n\t\t}\n\t\tif (*p == ',') { /* new version has inf */\n\t\t\t++p;\n\t\t\tif (!php_var_unserialize(&inf, &p, s + buf_len, &var_hash)) {\n\t\t\t\tzval_ptr_dtor(&entry);\n\t\t\t\tgoto outexcept;\n\t\t\t}\n\t\t} else {\n\t\t\tZVAL_UNDEF(&inf);\n\t\t}\n\n\t\thash = spl_object_storage_get_hash(intern, getThis(), &entry);\n\t\tif (!hash) {\n\t\t\tzval_ptr_dtor(&entry);\n\t\t\tzval_ptr_dtor(&inf);\n\t\t\tgoto outexcept;\n\t\t}\n\t\tpelement = spl_object_storage_get(intern, hash);\n\t\tspl_object_storage_free_hash(intern, hash);\n\t\tif (pelement) {\n\t\t\tif (!Z_ISUNDEF(pelement->inf)) {\n\t\t\t\tvar_push_dtor(&var_hash, &pelement->inf);\n\t\t\t}\n\t\t\tif (!Z_ISUNDEF(pelement->obj)) {\n\t\t\t\tvar_push_dtor(&var_hash, &pelement->obj);\n\t\t\t}\n\t\t}\n\t\telement = spl_object_storage_attach(intern, getThis(), &entry, Z_ISUNDEF(inf)?NULL:&inf);\n\t\tvar_replace(&var_hash, &entry, &element->obj);\n\t\tvar_replace(&var_hash, &inf, &element->inf);\n\t\tzval_ptr_dtor(&entry);\n\t\tZVAL_UNDEF(&entry);\n\t\tzval_ptr_dtor(&inf);\n\t\tZVAL_UNDEF(&inf);\n\t}\n\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\t/* members */\n\tif (*p!= 'm' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tpmembers = var_tmp_var(&var_hash);\n\tif (!php_var_unserialize(pmembers, &p, s + buf_len, &var_hash) || Z_TYPE_P(pmembers) != IS_ARRAY) {\n\t\tgoto outexcept;\n\t}\n\n\t/* copy members */\n\tobject_properties_load(&intern->std, Z_ARRVAL_P(pmembers));\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\treturn;\n\noutexcept:\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, \"Error at offset %pd of %d bytes\", (zend_long)((char*)p - buf), buf_len);\n\treturn;\n\n} /* }}} */", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7480", "cwe_id": "CWE-119" }, { "id": 376, "func": "SPL_METHOD(SplObjectStorage, unserialize)\n{\n\tspl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());\n\n\tchar *buf;\n\tsize_t buf_len;\n\tconst unsigned char *p, *s;\n\tphp_unserialize_data_t var_hash;\n\tzval entry, inf;\n\tzval *pcount, *pmembers;\n\tspl_SplObjectStorageElement *element;\n\tzend_long count;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s\", &buf, &buf_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (buf_len == 0) {\n\t\treturn;\n\t}\n\n\t/* storage */\n\ts = p = (const unsigned char*)buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tif (*p!= 'x' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tpcount = var_tmp_var(&var_hash);\n\tif (!php_var_unserialize(pcount, &p, s + buf_len, &var_hash) || Z_TYPE_P(pcount) != IS_LONG) {\n\t\tgoto outexcept;\n\t}\n\n\t--p; /* for ';' */\n\tcount = Z_LVAL_P(pcount);\n\n\tZVAL_UNDEF(&entry);\n\tZVAL_UNDEF(&inf);\n\n\twhile (count-- > 0) {\n\t\tspl_SplObjectStorageElement *pelement;\n\t\tzend_string *hash;\n\n\t\tif (*p != ';') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\t++p;\n\t\tif(*p != 'O' && *p != 'C' && *p != 'r') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\t/* store reference to allow cross-references between different elements */\n\t\tif (!php_var_unserialize(&entry, &p, s + buf_len, &var_hash)) {\n\t\t\tgoto outexcept;\n\t\t}\n\t\tif (*p == ',') { /* new version has inf */\n\t\t\t++p;\n\t\t\tif (!php_var_unserialize(&inf, &p, s + buf_len, &var_hash)) {\n\t\t\t\tzval_ptr_dtor(&entry);\n\t\t\t\tgoto outexcept;\n\t\t\t}\n\t\t}\n\t\tif (Z_TYPE(entry) != IS_OBJECT) {\n\t\t\tzval_ptr_dtor(&entry);\n\t\t\tzval_ptr_dtor(&inf);\n\t\t\tgoto outexcept;\n\t\t}\n\n\t\thash = spl_object_storage_get_hash(intern, getThis(), &entry);\n\t\tif (!hash) {\n\t\t\tzval_ptr_dtor(&entry);\n\t\t\tzval_ptr_dtor(&inf);\n\t\t\tgoto outexcept;\n\t\t}\n\t\tpelement = spl_object_storage_get(intern, hash);\n\t\tspl_object_storage_free_hash(intern, hash);\n\t\tif (pelement) {\n\t\t\tif (!Z_ISUNDEF(pelement->inf)) {\n\t\t\t\tvar_push_dtor(&var_hash, &pelement->inf);\n\t\t\t}\n\t\t\tif (!Z_ISUNDEF(pelement->obj)) {\n\t\t\t\tvar_push_dtor(&var_hash, &pelement->obj);\n\t\t\t}\n\t\t}\n\t\telement = spl_object_storage_attach(intern, getThis(), &entry, Z_ISUNDEF(inf)?NULL:&inf);\n\t\tvar_replace(&var_hash, &entry, &element->obj);\n\t\tvar_replace(&var_hash, &inf, &element->inf);\n\t\tzval_ptr_dtor(&entry);\n\t\tZVAL_UNDEF(&entry);\n\t\tzval_ptr_dtor(&inf);\n\t\tZVAL_UNDEF(&inf);\n\t}\n\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\t/* members */\n\tif (*p!= 'm' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tpmembers = var_tmp_var(&var_hash);\n\tif (!php_var_unserialize(pmembers, &p, s + buf_len, &var_hash) || Z_TYPE_P(pmembers) != IS_ARRAY) {\n\t\tgoto outexcept;\n\t}\n\n\t/* copy members */\n\tobject_properties_load(&intern->std, Z_ARRVAL_P(pmembers));\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\treturn;\n\noutexcept:\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, \"Error at offset %pd of %d bytes\", (zend_long)((char*)p - buf), buf_len);\n\treturn;\n\n} /* }}} */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7480", "cwe_id": "CWE-119" }, { "id": 446, "func": "parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,\n char *line, int *err, gchar **err_info)\n{\n\tunion wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;\n\tint\tnum_items_scanned;\n\tint\tyy, mm, dd, hr, min, sec, csec;\n\tguint\tpkt_len;\n\tint\tpro, off, pri, rm, error;\n\tguint\tcode1, code2;\n\tchar\tif_name[COSINE_MAX_IF_NAME_LEN] = \"\", direction[6] = \"\";\n\tstruct\ttm tm;\n\tguint8 *pd;\n\tint\ti, hex_lines, n, caplen = 0;\n\n\tif (sscanf(line, \"%4d-%2d-%2d,%2d:%2d:%2d.%9d:\",\n\t\t &yy, &mm, &dd, &hr, &min, &sec, &csec) == 7) {\n\t\t/* appears to be output to a control blade */\n\t\tnum_items_scanned = sscanf(line,\n\t\t \"%4d-%2d-%2d,%2d:%2d:%2d.%9d: %5s (%127[A-Za-z0-9/:]), Length:%9u, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]\",\n\t\t\t&yy, &mm, &dd, &hr, &min, &sec, &csec,\n\t\t\t\t direction, if_name, &pkt_len,\n\t\t\t\t &pro, &off, &pri, &rm, &error,\n\t\t\t\t &code1, &code2);\n\n\t\tif (num_items_scanned != 17) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: purported control blade line doesn't have code values\");\n\t\t\treturn FALSE;\n\t\t}\n\t} else {\n\t\t/* appears to be output to PE */\n\t\tnum_items_scanned = sscanf(line,\n\t\t \"%5s (%127[A-Za-z0-9/:]), Length:%9u, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]\",\n\t\t\t\t direction, if_name, &pkt_len,\n\t\t\t\t &pro, &off, &pri, &rm, &error,\n\t\t\t\t &code1, &code2);\n\n\t\tif (num_items_scanned != 10) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: header line is neither control blade nor PE output\");\n\t\t\treturn FALSE;\n\t\t}\n\t\tyy = mm = dd = hr = min = sec = csec = 0;\n\t}\n\tif (pkt_len > WTAP_MAX_PACKET_SIZE) {\n\t\t/*\n\t\t * Probably a corrupt capture file; don't blow up trying\n\t\t * to allocate space for an immensely-large packet.\n\t\t */\n\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t*err_info = g_strdup_printf(\"cosine: File has %u-byte packet, bigger than maximum of %u\",\n\t\t pkt_len, WTAP_MAX_PACKET_SIZE);\n\t\treturn FALSE;\n\t}\n\n\tphdr->rec_type = REC_TYPE_PACKET;\n\tphdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;\n\ttm.tm_year = yy - 1900;\n\ttm.tm_mon = mm - 1;\n\ttm.tm_mday = dd;\n\ttm.tm_hour = hr;\n\ttm.tm_min = min;\n\ttm.tm_sec = sec;\n\ttm.tm_isdst = -1;\n\tphdr->ts.secs = mktime(&tm);\n\tphdr->ts.nsecs = csec * 10000000;\n\tphdr->len = pkt_len;\n\n\t/* XXX need to handle other encapsulations like Cisco HDLC,\n\t Frame Relay and ATM */\n\tif (strncmp(if_name, \"TEST:\", 5) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_TEST;\n\t} else if (strncmp(if_name, \"PPoATM:\", 7) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPoATM;\n\t} else if (strncmp(if_name, \"PPoFR:\", 6) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPoFR;\n\t} else if (strncmp(if_name, \"ATM:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_ATM;\n\t} else if (strncmp(if_name, \"FR:\", 3) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_FR;\n\t} else if (strncmp(if_name, \"HDLC:\", 5) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_HDLC;\n\t} else if (strncmp(if_name, \"PPP:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPP;\n\t} else if (strncmp(if_name, \"ETH:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_ETH;\n\t} else {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_UNKNOWN;\n\t}\n\tif (strncmp(direction, \"l2-tx\", 5) == 0) {\n\t\tpseudo_header->cosine.direction = COSINE_DIR_TX;\n\t} else if (strncmp(direction, \"l2-rx\", 5) == 0) {\n\t\tpseudo_header->cosine.direction = COSINE_DIR_RX;\n\t}\n\tg_strlcpy(pseudo_header->cosine.if_name, if_name,\n\t\tCOSINE_MAX_IF_NAME_LEN);\n\tpseudo_header->cosine.pro = pro;\n\tpseudo_header->cosine.off = off;\n\tpseudo_header->cosine.pri = pri;\n\tpseudo_header->cosine.rm = rm;\n\tpseudo_header->cosine.err = error;\n\n\t/* Make sure we have enough room for the packet */\n\tws_buffer_assure_space(buf, pkt_len);\n\tpd = ws_buffer_start_ptr(buf);\n\n\t/* Calculate the number of hex dump lines, each\n\t * containing 16 bytes of data */\n\thex_lines = pkt_len / 16 + ((pkt_len % 16) ? 1 : 0);\n\n\tfor (i = 0; i < hex_lines; i++) {\n\t\tif (file_gets(line, COSINE_LINE_LENGTH, fh) == NULL) {\n\t\t\t*err = file_error(fh, err_info);\n\t\t\tif (*err == 0) {\n\t\t\t\t*err = WTAP_ERR_SHORT_READ;\n\t\t\t}\n\t\t\treturn FALSE;\n\t\t}\n\t\tif (empty_line(line)) {\n\t\t\tbreak;\n\t\t}\n\t\tif ((n = parse_single_hex_dump_line(line, pd, i*16)) == -1) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: hex dump line doesn't have 16 numbers\");\n\t\t\treturn FALSE;\n\t\t}\n\t\tcaplen += n;\n\t}\n\tphdr->caplen = caplen;\n\treturn TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5356", "cwe_id": "CWE-119" }, { "id": 446, "func": "parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,\n char *line, int *err, gchar **err_info)\n{\n\tunion wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;\n\tint\tnum_items_scanned;\n\tint\tyy, mm, dd, hr, min, sec, csec, pkt_len;\n\tint\tpro, off, pri, rm, error;\n\tguint\tcode1, code2;\n\tchar\tif_name[COSINE_MAX_IF_NAME_LEN] = \"\", direction[6] = \"\";\n\tstruct\ttm tm;\n\tguint8 *pd;\n\tint\ti, hex_lines, n, caplen = 0;\n\n\tif (sscanf(line, \"%4d-%2d-%2d,%2d:%2d:%2d.%9d:\",\n\t\t &yy, &mm, &dd, &hr, &min, &sec, &csec) == 7) {\n\t\t/* appears to be output to a control blade */\n\t\tnum_items_scanned = sscanf(line,\n\t\t \"%4d-%2d-%2d,%2d:%2d:%2d.%9d: %5s (%127[A-Za-z0-9/:]), Length:%9d, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]\",\n\t\t\t&yy, &mm, &dd, &hr, &min, &sec, &csec,\n\t\t\t\t direction, if_name, &pkt_len,\n\t\t\t\t &pro, &off, &pri, &rm, &error,\n\t\t\t\t &code1, &code2);\n\n\t\tif (num_items_scanned != 17) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: purported control blade line doesn't have code values\");\n\t\t\treturn FALSE;\n\t\t}\n\t} else {\n\t\t/* appears to be output to PE */\n\t\tnum_items_scanned = sscanf(line,\n\t\t \"%5s (%127[A-Za-z0-9/:]), Length:%9d, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]\",\n\t\t\t\t direction, if_name, &pkt_len,\n\t\t\t\t &pro, &off, &pri, &rm, &error,\n\t\t\t\t &code1, &code2);\n\n\t\tif (num_items_scanned != 10) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: header line is neither control blade nor PE output\");\n\t\t\treturn FALSE;\n\t\t}\n\t\tyy = mm = dd = hr = min = sec = csec = 0;\n\t}\n\tif (pkt_len < 0) {\n\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t*err_info = g_strdup(\"cosine: packet header has a negative packet length\");\n\t\treturn FALSE;\n\t}\n\tif (pkt_len > WTAP_MAX_PACKET_SIZE) {\n\t\t/*\n\t\t * Probably a corrupt capture file; don't blow up trying\n\t\t * to allocate space for an immensely-large packet.\n\t\t */\n\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t*err_info = g_strdup_printf(\"cosine: File has %u-byte packet, bigger than maximum of %u\",\n\t\t pkt_len, WTAP_MAX_PACKET_SIZE);\n\t\treturn FALSE;\n\t}\n\n\tphdr->rec_type = REC_TYPE_PACKET;\n\tphdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;\n\ttm.tm_year = yy - 1900;\n\ttm.tm_mon = mm - 1;\n\ttm.tm_mday = dd;\n\ttm.tm_hour = hr;\n\ttm.tm_min = min;\n\ttm.tm_sec = sec;\n\ttm.tm_isdst = -1;\n\tphdr->ts.secs = mktime(&tm);\n\tphdr->ts.nsecs = csec * 10000000;\n\tphdr->len = pkt_len;\n\n\t/* XXX need to handle other encapsulations like Cisco HDLC,\n\t Frame Relay and ATM */\n\tif (strncmp(if_name, \"TEST:\", 5) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_TEST;\n\t} else if (strncmp(if_name, \"PPoATM:\", 7) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPoATM;\n\t} else if (strncmp(if_name, \"PPoFR:\", 6) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPoFR;\n\t} else if (strncmp(if_name, \"ATM:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_ATM;\n\t} else if (strncmp(if_name, \"FR:\", 3) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_FR;\n\t} else if (strncmp(if_name, \"HDLC:\", 5) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_HDLC;\n\t} else if (strncmp(if_name, \"PPP:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_PPP;\n\t} else if (strncmp(if_name, \"ETH:\", 4) == 0) {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_ETH;\n\t} else {\n\t\tpseudo_header->cosine.encap = COSINE_ENCAP_UNKNOWN;\n\t}\n\tif (strncmp(direction, \"l2-tx\", 5) == 0) {\n\t\tpseudo_header->cosine.direction = COSINE_DIR_TX;\n\t} else if (strncmp(direction, \"l2-rx\", 5) == 0) {\n\t\tpseudo_header->cosine.direction = COSINE_DIR_RX;\n\t}\n\tg_strlcpy(pseudo_header->cosine.if_name, if_name,\n\t\tCOSINE_MAX_IF_NAME_LEN);\n\tpseudo_header->cosine.pro = pro;\n\tpseudo_header->cosine.off = off;\n\tpseudo_header->cosine.pri = pri;\n\tpseudo_header->cosine.rm = rm;\n\tpseudo_header->cosine.err = error;\n\n\t/* Make sure we have enough room for the packet */\n\tws_buffer_assure_space(buf, pkt_len);\n\tpd = ws_buffer_start_ptr(buf);\n\n\t/* Calculate the number of hex dump lines, each\n\t * containing 16 bytes of data */\n\thex_lines = pkt_len / 16 + ((pkt_len % 16) ? 1 : 0);\n\n\tfor (i = 0; i < hex_lines; i++) {\n\t\tif (file_gets(line, COSINE_LINE_LENGTH, fh) == NULL) {\n\t\t\t*err = file_error(fh, err_info);\n\t\t\tif (*err == 0) {\n\t\t\t\t*err = WTAP_ERR_SHORT_READ;\n\t\t\t}\n\t\t\treturn FALSE;\n\t\t}\n\t\tif (empty_line(line)) {\n\t\t\tbreak;\n\t\t}\n\t\tif ((n = parse_single_hex_dump_line(line, pd, i*16)) == -1) {\n\t\t\t*err = WTAP_ERR_BAD_FILE;\n\t\t\t*err_info = g_strdup(\"cosine: hex dump line doesn't have 16 numbers\");\n\t\t\treturn FALSE;\n\t\t}\n\t\tcaplen += n;\n\t}\n\tphdr->caplen = caplen;\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5356", "cwe_id": "CWE-119" }, { "id": 2622, "func": "error_t coapServerInitResponse(CoapServerContext *context)\n{\n CoapMessageHeader *requestHeader;\n CoapMessageHeader *responseHeader;\n\n //Point to the CoAP request header\n requestHeader = (CoapMessageHeader *) context->request.buffer;\n //Point to the CoAP response header\n responseHeader = (CoapMessageHeader *) context->response.buffer;\n\n //Format message header\n responseHeader->version = COAP_VERSION_1;\n responseHeader->tokenLen = requestHeader->tokenLen;\n responseHeader->code = COAP_CODE_INTERNAL_SERVER;\n responseHeader->mid = requestHeader->mid;\n\n //If immediately available, the response to a request carried in a\n //Confirmable message is carried in an Acknowledgement (ACK) message\n if(requestHeader->type == COAP_TYPE_CON)\n {\n responseHeader->type = COAP_TYPE_ACK;\n }\n else\n {\n responseHeader->type = COAP_TYPE_NON;\n }\n\n //The token is used to match a response with a request\n osMemcpy(responseHeader->token, requestHeader->token,\n requestHeader->tokenLen);\n\n //Set the length of the CoAP message\n context->response.length = sizeof(CoapMessageHeader) + responseHeader->tokenLen;\n context->response.pos = 0;\n\n //Sucessful processing\n return NO_ERROR;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2622, "func": "error_t coapServerInitResponse(CoapServerContext *context)\n{\n CoapMessageHeader *requestHeader;\n CoapMessageHeader *responseHeader;\n\n //Point to the CoAP request header\n requestHeader = (CoapMessageHeader *) context->request.buffer;\n //Point to the CoAP response header\n responseHeader = (CoapMessageHeader *) context->response.buffer;\n\n //Format message header\n responseHeader->version = COAP_VERSION_1;\n responseHeader->tokenLen = requestHeader->tokenLen;\n responseHeader->code = COAP_CODE_INTERNAL_SERVER;\n responseHeader->mid = requestHeader->mid;\n\n //If immediately available, the response to a request carried in a\n //Confirmable message is carried in an Acknowledgement (ACK) message\n if(requestHeader->type == COAP_TYPE_CON)\n {\n responseHeader->type = COAP_TYPE_ACK;\n }\n else\n {\n responseHeader->type = COAP_TYPE_NON;\n }\n\n //The token is used to match a response with a request\n osMemcpy(responseHeader->token, requestHeader->token,\n requestHeader->tokenLen);\n\n //Set the length of the CoAP message\n context->response.length = sizeof(CoapMessageHeader) + responseHeader->tokenLen;\n context->response.pos = 0;\n\n //Successful processing\n return NO_ERROR;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2474, "func": "static CACHE_BITMAP_V2_ORDER* update_read_cache_bitmap_v2_order(rdpUpdate* update, wStream* s,\n BOOL compressed, UINT16 flags)\n{\n\tBYTE bitsPerPixelId;\n\tCACHE_BITMAP_V2_ORDER* cache_bitmap_v2;\n\n\tif (!update || !s)\n\t\treturn NULL;\n\n\tcache_bitmap_v2 = calloc(1, sizeof(CACHE_BITMAP_V2_ORDER));\n\n\tif (!cache_bitmap_v2)\n\t\tgoto fail;\n\n\tcache_bitmap_v2->cacheId = flags & 0x0003;\n\tcache_bitmap_v2->flags = (flags & 0xFF80) >> 7;\n\tbitsPerPixelId = (flags & 0x0078) >> 3;\n\tcache_bitmap_v2->bitmapBpp = CBR2_BPP[bitsPerPixelId];\n\n\tif (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)\n\t{\n\t\tif (Stream_GetRemainingLength(s) < 8)\n\t\t\tgoto fail;\n\n\t\tStream_Read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */\n\t\tStream_Read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)\n\t{\n\t\tif (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */\n\t\t\tgoto fail;\n\n\t\tcache_bitmap_v2->bitmapHeight = cache_bitmap_v2->bitmapWidth;\n\t}\n\telse\n\t{\n\t\tif (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */\n\t\t !update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */\n\t\t\tgoto fail;\n\t}\n\n\tif (!update_read_4byte_unsigned(s, &cache_bitmap_v2->bitmapLength) || /* bitmapLength */\n\t !update_read_2byte_unsigned(s, &cache_bitmap_v2->cacheIndex)) /* cacheIndex */\n\t\tgoto fail;\n\n\tif (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)\n\t\tcache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;\n\n\tif (compressed)\n\t{\n\t\tif (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))\n\t\t{\n\t\t\tif (Stream_GetRemainingLength(s) < 8)\n\t\t\t\tgoto fail;\n\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */\n\t\t\tStream_Read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */\n\t\t\tcache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;\n\t\t}\n\t}\n\n\tif (cache_bitmap_v2->bitmapLength == 0)\n\t\tgoto fail;\n\n\tif (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength)\n\t\tgoto fail;\n\n\tif (cache_bitmap_v2->bitmapLength == 0)\n\t\tgoto fail;\n\n\tcache_bitmap_v2->bitmapDataStream = malloc(cache_bitmap_v2->bitmapLength);\n\n\tif (!cache_bitmap_v2->bitmapDataStream)\n\t\tgoto fail;\n\n\tStream_Read(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\tcache_bitmap_v2->compressed = compressed;\n\treturn cache_bitmap_v2;\nfail:\n\tfree_cache_bitmap_v2_order(update->context, cache_bitmap_v2);\n\treturn NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 2474, "func": "static CACHE_BITMAP_V2_ORDER* update_read_cache_bitmap_v2_order(rdpUpdate* update, wStream* s,\n BOOL compressed, UINT16 flags)\n{\n\tBOOL rc;\n\tBYTE bitsPerPixelId;\n\tCACHE_BITMAP_V2_ORDER* cache_bitmap_v2;\n\n\tif (!update || !s)\n\t\treturn NULL;\n\n\tcache_bitmap_v2 = calloc(1, sizeof(CACHE_BITMAP_V2_ORDER));\n\n\tif (!cache_bitmap_v2)\n\t\tgoto fail;\n\n\tcache_bitmap_v2->cacheId = flags & 0x0003;\n\tcache_bitmap_v2->flags = (flags & 0xFF80) >> 7;\n\tbitsPerPixelId = (flags & 0x0078) >> 3;\n\tcache_bitmap_v2->bitmapBpp = get_cbr2_bpp(bitsPerPixelId, &rc);\n\tif (!rc)\n\t\tgoto fail;\n\n\tif (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)\n\t{\n\t\tif (Stream_GetRemainingLength(s) < 8)\n\t\t\tgoto fail;\n\n\t\tStream_Read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */\n\t\tStream_Read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)\n\t{\n\t\tif (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */\n\t\t\tgoto fail;\n\n\t\tcache_bitmap_v2->bitmapHeight = cache_bitmap_v2->bitmapWidth;\n\t}\n\telse\n\t{\n\t\tif (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */\n\t\t !update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */\n\t\t\tgoto fail;\n\t}\n\n\tif (!update_read_4byte_unsigned(s, &cache_bitmap_v2->bitmapLength) || /* bitmapLength */\n\t !update_read_2byte_unsigned(s, &cache_bitmap_v2->cacheIndex)) /* cacheIndex */\n\t\tgoto fail;\n\n\tif (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)\n\t\tcache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;\n\n\tif (compressed)\n\t{\n\t\tif (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))\n\t\t{\n\t\t\tif (Stream_GetRemainingLength(s) < 8)\n\t\t\t\tgoto fail;\n\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */\n\t\t\tStream_Read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */\n\t\t\tStream_Read_UINT16(\n\t\t\t s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */\n\t\t\tcache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;\n\t\t}\n\t}\n\n\tif (cache_bitmap_v2->bitmapLength == 0)\n\t\tgoto fail;\n\n\tif (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength)\n\t\tgoto fail;\n\n\tif (cache_bitmap_v2->bitmapLength == 0)\n\t\tgoto fail;\n\n\tcache_bitmap_v2->bitmapDataStream = malloc(cache_bitmap_v2->bitmapLength);\n\n\tif (!cache_bitmap_v2->bitmapDataStream)\n\t\tgoto fail;\n\n\tStream_Read(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\tcache_bitmap_v2->compressed = compressed;\n\treturn cache_bitmap_v2;\nfail:\n\tfree_cache_bitmap_v2_order(update->context, cache_bitmap_v2);\n\treturn NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 1360, "func": "\t__must_hold(&ctx->completion_lock)\n{\n\tu32 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);\n\n\tspin_lock_irq(&ctx->timeout_lock);\n\twhile (!list_empty(&ctx->timeout_list)) {\n\t\tu32 events_needed, events_got;\n\t\tstruct io_kiocb *req = list_first_entry(&ctx->timeout_list,\n\t\t\t\t\t\tstruct io_kiocb, timeout.list);\n\n\t\tif (io_is_timeout_noseq(req))\n\t\t\tbreak;\n\n\t\t/*\n\t\t * Since seq can easily wrap around over time, subtract\n\t\t * the last seq at which timeouts were flushed before comparing.\n\t\t * Assuming not more than 2^31-1 events have happened since,\n\t\t * these subtractions won't have wrapped, so we can check if\n\t\t * target is in [last_seq, current_seq] by comparing the two.\n\t\t */\n\t\tevents_needed = req->timeout.target_seq - ctx->cq_last_tm_flush;\n\t\tevents_got = seq - ctx->cq_last_tm_flush;\n\t\tif (events_got < events_needed)\n\t\t\tbreak;\n\n\t\tlist_del_init(&req->timeout.list);\n\t\tio_kill_timeout(req, 0);\n\t}\n\tctx->cq_last_tm_flush = seq;\n\tspin_unlock_irq(&ctx->timeout_lock);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-29582", "cwe_id": "CWE-416" }, { "id": 1360, "func": "\t__must_hold(&ctx->completion_lock)\n{\n\tu32 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);\n\tstruct io_kiocb *req, *tmp;\n\n\tspin_lock_irq(&ctx->timeout_lock);\n\tlist_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {\n\t\tu32 events_needed, events_got;\n\n\t\tif (io_is_timeout_noseq(req))\n\t\t\tbreak;\n\n\t\t/*\n\t\t * Since seq can easily wrap around over time, subtract\n\t\t * the last seq at which timeouts were flushed before comparing.\n\t\t * Assuming not more than 2^31-1 events have happened since,\n\t\t * these subtractions won't have wrapped, so we can check if\n\t\t * target is in [last_seq, current_seq] by comparing the two.\n\t\t */\n\t\tevents_needed = req->timeout.target_seq - ctx->cq_last_tm_flush;\n\t\tevents_got = seq - ctx->cq_last_tm_flush;\n\t\tif (events_got < events_needed)\n\t\t\tbreak;\n\n\t\tio_kill_timeout(req, 0);\n\t}\n\tctx->cq_last_tm_flush = seq;\n\tspin_unlock_irq(&ctx->timeout_lock);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-29582", "cwe_id": "CWE-416" }, { "id": 2326, "func": "static int java_switch_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {\n\tut8 op_byte = data[0];\n\tut64 offset = addr - java_get_method_start ();\n\tut8 pos = (offset+1)%4 ? 1 + 4 - (offset+1)%4 : 1;\n\n\tif (op_byte == 0xaa) {\n\t\t// handle a table switch condition\n\t\tif (pos + 8 > len) {\n\t\t\treturn op->size;\n\t\t}\n\t\tint min_val = (ut32)(UINT (data, pos + 4)),\n\t\t\tmax_val = (ut32)(UINT (data, pos + 8));\n\n\t\tut32 default_loc = (ut32) (UINT (data, pos)), cur_case = 0;\n\t\top->switch_op = r_anal_switch_op_new (addr, min_val, default_loc);\n\t\tRAnalCaseOp *caseop = NULL;\n\t\tpos += 12;\n\t\tif (max_val > min_val && ((max_val - min_val)<(UT16_MAX/4))) {\n\t\t\t//caseop = r_anal_switch_op_add_case(op->switch_op, addr+default_loc, -1, addr+offset);\n\t\t\tfor (cur_case = 0; cur_case <= max_val - min_val; pos += 4, cur_case++) {\n\t\t\t\t//ut32 value = (ut32)(UINT (data, pos));\n\t\t\t\tif (pos + 4 >= len) {\n\t\t\t\t\t// switch is too big cant read further\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tint offset = (int)(ut32)(R_BIN_JAVA_UINT (data, pos));\n\t\t\t\tcaseop = r_anal_switch_op_add_case (op->switch_op,\n\t\t\t\t\taddr + pos, cur_case + min_val, addr + offset);\n\t\t\t\tif (caseop) {\n\t\t\t\t\tcaseop->bb_ref_to = addr+offset;\n\t\t\t\t\tcaseop->bb_ref_from = addr; // TODO figure this one out\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"Invalid switch boundaries at 0x%\"PFMT64x\"\\n\", addr);\n\t\t}\n\t}\n\top->size = pos;\n\treturn op->size;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-12321", "cwe_id": "CWE-125" }, { "id": 2326, "func": "static int java_switch_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {\n\tut8 op_byte = data[0];\n\tut64 offset = addr - java_get_method_start ();\n\tut8 pos = (offset+1)%4 ? 1 + 4 - (offset+1)%4 : 1;\n\n\tif (op_byte == 0xaa) {\n\t\t// handle a table switch condition\n\t\tif (pos + 8 + 8 > len) {\n\t\t\treturn op->size;\n\t\t}\n\t\tconst int min_val = (ut32)(UINT (data, pos + 4));\n\t\tconst int max_val = (ut32)(UINT (data, pos + 8));\n\n\t\tut32 default_loc = (ut32) (UINT (data, pos)), cur_case = 0;\n\t\top->switch_op = r_anal_switch_op_new (addr, min_val, default_loc);\n\t\tRAnalCaseOp *caseop = NULL;\n\t\tpos += 12;\n\t\tif (max_val > min_val && ((max_val - min_val)<(UT16_MAX/4))) {\n\t\t\t//caseop = r_anal_switch_op_add_case(op->switch_op, addr+default_loc, -1, addr+offset);\n\t\t\tfor (cur_case = 0; cur_case <= max_val - min_val; pos += 4, cur_case++) {\n\t\t\t\t//ut32 value = (ut32)(UINT (data, pos));\n\t\t\t\tif (pos + 4 >= len) {\n\t\t\t\t\t// switch is too big cant read further\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tint offset = (int)(ut32)(R_BIN_JAVA_UINT (data, pos));\n\t\t\t\tcaseop = r_anal_switch_op_add_case (op->switch_op,\n\t\t\t\t\taddr + pos, cur_case + min_val, addr + offset);\n\t\t\t\tif (caseop) {\n\t\t\t\t\tcaseop->bb_ref_to = addr+offset;\n\t\t\t\t\tcaseop->bb_ref_from = addr; // TODO figure this one out\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"Invalid switch boundaries at 0x%\"PFMT64x\"\\n\", addr);\n\t\t}\n\t}\n\top->size = pos;\n\treturn op->size;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-12321", "cwe_id": "CWE-125" }, { "id": 3140, "func": "static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,\n\t\t\t\tsize_t msg_len)\n{\n\tstruct sock *sk = asoc->base.sk;\n\tint err = 0;\n\tlong current_timeo = *timeo_p;\n\tDEFINE_WAIT(wait);\n\n\tpr_debug(\"%s: asoc:%p, timeo:%ld, msg_len:%zu\\n\", __func__, asoc,\n\t\t *timeo_p, msg_len);\n\n\t/* Increment the association's refcnt. */\n\tsctp_association_hold(asoc);\n\n\t/* Wait on the association specific sndbuf space. */\n\tfor (;;) {\n\t\tprepare_to_wait_exclusive(&asoc->wait, &wait,\n\t\t\t\t\t TASK_INTERRUPTIBLE);\n\t\tif (!*timeo_p)\n\t\t\tgoto do_nonblock;\n\t\tif (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||\n\t\t asoc->base.dead)\n\t\t\tgoto do_error;\n\t\tif (signal_pending(current))\n\t\t\tgoto do_interrupted;\n\t\tif (msg_len <= sctp_wspace(asoc))\n\t\t\tbreak;\n\n\t\t/* Let another process have a go. Since we are going\n\t\t * to sleep anyway.\n\t\t */\n\t\trelease_sock(sk);\n\t\tcurrent_timeo = schedule_timeout(current_timeo);\n\t\tBUG_ON(sk != asoc->base.sk);\n\t\tlock_sock(sk);\n\n\t\t*timeo_p = current_timeo;\n\t}\n\nout:\n\tfinish_wait(&asoc->wait, &wait);\n\n\t/* Release the association's refcnt. */\n\tsctp_association_put(asoc);\n\n\treturn err;\n\ndo_error:\n\terr = -EPIPE;\n\tgoto out;\n\ndo_interrupted:\n\terr = sock_intr_errno(*timeo_p);\n\tgoto out;\n\ndo_nonblock:\n\terr = -EAGAIN;\n\tgoto out;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-5986", "cwe_id": "CWE-362" }, { "id": 3140, "func": "static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,\n\t\t\t\tsize_t msg_len)\n{\n\tstruct sock *sk = asoc->base.sk;\n\tint err = 0;\n\tlong current_timeo = *timeo_p;\n\tDEFINE_WAIT(wait);\n\n\tpr_debug(\"%s: asoc:%p, timeo:%ld, msg_len:%zu\\n\", __func__, asoc,\n\t\t *timeo_p, msg_len);\n\n\t/* Increment the association's refcnt. */\n\tsctp_association_hold(asoc);\n\n\t/* Wait on the association specific sndbuf space. */\n\tfor (;;) {\n\t\tprepare_to_wait_exclusive(&asoc->wait, &wait,\n\t\t\t\t\t TASK_INTERRUPTIBLE);\n\t\tif (!*timeo_p)\n\t\t\tgoto do_nonblock;\n\t\tif (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||\n\t\t asoc->base.dead)\n\t\t\tgoto do_error;\n\t\tif (signal_pending(current))\n\t\t\tgoto do_interrupted;\n\t\tif (msg_len <= sctp_wspace(asoc))\n\t\t\tbreak;\n\n\t\t/* Let another process have a go. Since we are going\n\t\t * to sleep anyway.\n\t\t */\n\t\trelease_sock(sk);\n\t\tcurrent_timeo = schedule_timeout(current_timeo);\n\t\tif (sk != asoc->base.sk)\n\t\t\tgoto do_error;\n\t\tlock_sock(sk);\n\n\t\t*timeo_p = current_timeo;\n\t}\n\nout:\n\tfinish_wait(&asoc->wait, &wait);\n\n\t/* Release the association's refcnt. */\n\tsctp_association_put(asoc);\n\n\treturn err;\n\ndo_error:\n\terr = -EPIPE;\n\tgoto out;\n\ndo_interrupted:\n\terr = sock_intr_errno(*timeo_p);\n\tgoto out;\n\ndo_nonblock:\n\terr = -EAGAIN;\n\tgoto out;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-5986", "cwe_id": "CWE-362" }, { "id": 2631, "func": "int my_csr_reader( const char* i_csr_file_in,\n unsigned int** o_row_idx,\n unsigned int** o_column_idx,\n REALTYPE** o_values,\n unsigned int* o_row_count,\n unsigned int* o_column_count,\n unsigned int* o_element_count ) {\n FILE *l_csr_file_handle;\n const unsigned int l_line_length = 512;\n char l_line[512/*l_line_length*/+1];\n unsigned int l_header_read = 0;\n unsigned int* l_row_idx_id = NULL;\n unsigned int l_i = 0;\n\n l_csr_file_handle = fopen( i_csr_file_in, \"r\" );\n if ( l_csr_file_handle == NULL ) {\n fprintf( stderr, \"cannot open CSR file!\\n\" );\n return -1;\n }\n\n while (fgets(l_line, l_line_length, l_csr_file_handle) != NULL) {\n if ( strlen(l_line) == l_line_length ) {\n fprintf( stderr, \"could not read file length!\\n\" );\n return -1;\n }\n /* check if we are still reading comments header */\n if ( l_line[0] == '%' ) {\n continue;\n } else {\n /* if we are the first line after comment header, we allocate our data structures */\n if ( l_header_read == 0 ) {\n if ( sscanf(l_line, \"%u %u %u\", o_row_count, o_column_count, o_element_count) == 3 ) {\n /* allocate CSC datastructure matching mtx file */\n *o_column_idx = (unsigned int*) malloc(sizeof(unsigned int) * (*o_element_count));\n *o_row_idx = (unsigned int*) malloc(sizeof(unsigned int) * (*o_row_count + 1));\n *o_values = (REALTYPE*) malloc(sizeof(double) * (*o_element_count));\n l_row_idx_id = (unsigned int*) malloc(sizeof(unsigned int) * (*o_row_count));\n\n /* check if mallocs were successful */\n if ( ( *o_row_idx == NULL ) ||\n ( *o_column_idx == NULL ) ||\n ( *o_values == NULL ) ||\n ( l_row_idx_id == NULL ) ) {\n fprintf( stderr, \"could not allocate sp data!\\n\" );\n return -1;\n }\n\n /* set everything to zero for init */\n memset(*o_row_idx, 0, sizeof(unsigned int)*(*o_row_count + 1));\n memset(*o_column_idx, 0, sizeof(unsigned int)*(*o_element_count));\n memset(*o_values, 0, sizeof(double)*(*o_element_count));\n memset(l_row_idx_id, 0, sizeof(unsigned int)*(*o_row_count));\n\n /* init column idx */\n for ( l_i = 0; l_i < (*o_row_count + 1); l_i++)\n (*o_row_idx)[l_i] = (*o_element_count);\n\n /* init */\n (*o_row_idx)[0] = 0;\n l_i = 0;\n l_header_read = 1;\n } else {\n fprintf( stderr, \"could not csr description!\\n\" );\n return -1;\n }\n /* now we read the actual content */\n } else {\n unsigned int l_row, l_column;\n REALTYPE l_value;\n /* read a line of content */\n if ( sscanf(l_line, \"%u %u %lf\", &l_row, &l_column, &l_value) != 3 ) {\n fprintf( stderr, \"could not read element!\\n\" );\n return -1;\n }\n /* adjust numbers to zero termination */\n l_row--;\n l_column--;\n /* add these values to row and value structure */\n (*o_column_idx)[l_i] = l_column;\n (*o_values)[l_i] = l_value;\n l_i++;\n /* handle columns, set id to own for this column, yeah we need to handle empty columns */\n l_row_idx_id[l_row] = 1;\n (*o_row_idx)[l_row+1] = l_i;\n }\n }\n }\n\n /* close mtx file */\n fclose( l_csr_file_handle );\n\n /* check if we read a file which was consistent */\n if ( l_i != (*o_element_count) ) {\n fprintf( stderr, \"we were not able to read all elements!\\n\" );\n return -1;\n }\n\n /* let's handle empty rows */\n for ( l_i = 0; l_i < (*o_row_count); l_i++) {\n if ( l_row_idx_id[l_i] == 0 ) {\n (*o_row_idx)[l_i+1] = (*o_row_idx)[l_i];\n }\n }\n\n /* free helper data structure */\n if ( l_row_idx_id != NULL ) {\n free( l_row_idx_id );\n }\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20541", "cwe_id": "CWE-787" }, { "id": 2631, "func": "int my_csr_reader( const char* i_csr_file_in,\n unsigned int** o_row_idx,\n unsigned int** o_column_idx,\n REALTYPE** o_values,\n unsigned int* o_row_count,\n unsigned int* o_column_count,\n unsigned int* o_element_count ) {\n FILE *l_csr_file_handle;\n const unsigned int l_line_length = 512;\n char l_line[512/*l_line_length*/+1];\n unsigned int l_header_read = 0;\n unsigned int* l_row_idx_id = NULL;\n unsigned int l_i = 0;\n\n l_csr_file_handle = fopen( i_csr_file_in, \"r\" );\n if ( l_csr_file_handle == NULL ) {\n fprintf( stderr, \"cannot open CSR file!\\n\" );\n return -1;\n }\n\n while (fgets(l_line, l_line_length, l_csr_file_handle) != NULL) {\n if ( strlen(l_line) == l_line_length ) {\n fprintf( stderr, \"could not read file length!\\n\" );\n return -1;\n }\n /* check if we are still reading comments header */\n if ( l_line[0] == '%' ) {\n continue;\n } else {\n /* if we are the first line after comment header, we allocate our data structures */\n if ( l_header_read == 0 ) {\n if (3 == sscanf(l_line, \"%u %u %u\", o_row_count, o_column_count, o_element_count) &&\n 0 != *o_row_count && 0 != *o_column_count && 0 != *o_element_count)\n {\n /* allocate CSC datastructure matching mtx file */\n *o_column_idx = (unsigned int*) malloc(sizeof(unsigned int) * (*o_element_count));\n *o_row_idx = (unsigned int*) malloc(sizeof(unsigned int) * (*o_row_count + 1));\n *o_values = (REALTYPE*) malloc(sizeof(double) * (*o_element_count));\n l_row_idx_id = (unsigned int*) malloc(sizeof(unsigned int) * (*o_row_count));\n\n /* check if mallocs were successful */\n if ( ( *o_row_idx == NULL ) ||\n ( *o_column_idx == NULL ) ||\n ( *o_values == NULL ) ||\n ( l_row_idx_id == NULL ) ) {\n fprintf( stderr, \"could not allocate sp data!\\n\" );\n return -1;\n }\n\n /* set everything to zero for init */\n memset(*o_row_idx, 0, sizeof(unsigned int)*(*o_row_count + 1));\n memset(*o_column_idx, 0, sizeof(unsigned int)*(*o_element_count));\n memset(*o_values, 0, sizeof(double)*(*o_element_count));\n memset(l_row_idx_id, 0, sizeof(unsigned int)*(*o_row_count));\n\n /* init column idx */\n for ( l_i = 0; l_i < (*o_row_count + 1); l_i++)\n (*o_row_idx)[l_i] = (*o_element_count);\n\n /* init */\n (*o_row_idx)[0] = 0;\n l_i = 0;\n l_header_read = 1;\n } else {\n fprintf( stderr, \"could not csr description!\\n\" );\n return -1;\n }\n /* now we read the actual content */\n } else {\n unsigned int l_row, l_column;\n REALTYPE l_value;\n /* read a line of content */\n if ( sscanf(l_line, \"%u %u %lf\", &l_row, &l_column, &l_value) != 3 ) {\n fprintf( stderr, \"could not read element!\\n\" );\n return -1;\n }\n /* adjust numbers to zero termination */\n l_row--;\n l_column--;\n /* add these values to row and value structure */\n (*o_column_idx)[l_i] = l_column;\n (*o_values)[l_i] = l_value;\n l_i++;\n /* handle columns, set id to own for this column, yeah we need to handle empty columns */\n l_row_idx_id[l_row] = 1;\n (*o_row_idx)[l_row+1] = l_i;\n }\n }\n }\n\n /* close mtx file */\n fclose( l_csr_file_handle );\n\n /* check if we read a file which was consistent */\n if ( l_i != (*o_element_count) ) {\n fprintf( stderr, \"we were not able to read all elements!\\n\" );\n return -1;\n }\n\n /* let's handle empty rows */\n for ( l_i = 0; l_i < (*o_row_count); l_i++) {\n if ( l_row_idx_id[l_i] == 0 ) {\n (*o_row_idx)[l_i+1] = (*o_row_idx)[l_i];\n }\n }\n\n /* free helper data structure */\n if ( l_row_idx_id != NULL ) {\n free( l_row_idx_id );\n }\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20541", "cwe_id": "CWE-787" }, { "id": 282, "func": "TfLiteStatus PrepareAny(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n const TfLiteTensor* input = GetInput(context, node, 0);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteBool);\n return PrepareSimple(context, node);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 282, "func": "TfLiteStatus PrepareAny(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteBool);\n return PrepareSimple(context, node);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 377, "func": "next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type,\n\t\t enum CCSTATE* state, ScanEnv* env)\n{\n int r;\n\n if (*state == CCS_RANGE)\n return ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE;\n\n if (*state == CCS_VALUE && *type != CCV_CLASS) {\n if (*type == CCV_SB)\n BITSET_SET_BIT(cc->bs, (int )(*vs));\n else if (*type == CCV_CODE_POINT) {\n r = add_code_range(&(cc->mbuf), env, *vs, *vs);\n if (r < 0) return r;\n }\n }\n\n *state = CCS_VALUE;\n *type = CCV_CLASS;\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9228", "cwe_id": "CWE-787" }, { "id": 377, "func": "next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type,\n\t\t enum CCSTATE* state, ScanEnv* env)\n{\n int r;\n\n if (*state == CCS_RANGE)\n return ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE;\n\n if (*state == CCS_VALUE && *type != CCV_CLASS) {\n if (*type == CCV_SB)\n BITSET_SET_BIT(cc->bs, (int )(*vs));\n else if (*type == CCV_CODE_POINT) {\n r = add_code_range(&(cc->mbuf), env, *vs, *vs);\n if (r < 0) return r;\n }\n }\n\n if (*state != CCS_START)\n *state = CCS_VALUE;\n\n *type = CCV_CLASS;\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9228", "cwe_id": "CWE-787" }, { "id": 1614, "func": "tcpmss_mangle_packet(struct sk_buff *skb,\n\t\t const struct xt_action_param *par,\n\t\t unsigned int family,\n\t\t unsigned int tcphoff,\n\t\t unsigned int minlen)\n{\n\tconst struct xt_tcpmss_info *info = par->targinfo;\n\tstruct tcphdr *tcph;\n\tint len, tcp_hdrlen;\n\tunsigned int i;\n\t__be16 oldval;\n\tu16 newmss;\n\tu8 *opt;\n\n\t/* This is a fragment, no TCP header is available */\n\tif (par->fragoff != 0)\n\t\treturn 0;\n\n\tif (!skb_make_writable(skb, skb->len))\n\t\treturn -1;\n\n\tlen = skb->len - tcphoff;\n\tif (len < (int)sizeof(struct tcphdr))\n\t\treturn -1;\n\n\ttcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);\n\ttcp_hdrlen = tcph->doff * 4;\n\n\tif (len < tcp_hdrlen)\n\t\treturn -1;\n\n\tif (info->mss == XT_TCPMSS_CLAMP_PMTU) {\n\t\tstruct net *net = xt_net(par);\n\t\tunsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family);\n\t\tunsigned int min_mtu = min(dst_mtu(skb_dst(skb)), in_mtu);\n\n\t\tif (min_mtu <= minlen) {\n\t\t\tnet_err_ratelimited(\"unknown or invalid path-MTU (%u)\\n\",\n\t\t\t\t\t min_mtu);\n\t\t\treturn -1;\n\t\t}\n\t\tnewmss = min_mtu - minlen;\n\t} else\n\t\tnewmss = info->mss;\n\n\topt = (u_int8_t *)tcph;\n\tfor (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {\n\t\tif (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {\n\t\t\tu_int16_t oldmss;\n\n\t\t\toldmss = (opt[i+2] << 8) | opt[i+3];\n\n\t\t\t/* Never increase MSS, even when setting it, as\n\t\t\t * doing so results in problems for hosts that rely\n\t\t\t * on MSS being set correctly.\n\t\t\t */\n\t\t\tif (oldmss <= newmss)\n\t\t\t\treturn 0;\n\n\t\t\topt[i+2] = (newmss & 0xff00) >> 8;\n\t\t\topt[i+3] = newmss & 0x00ff;\n\n\t\t\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t\t\t htons(oldmss), htons(newmss),\n\t\t\t\t\t\t false);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/* There is data after the header so the option can't be added\n\t * without moving it, and doing so may make the SYN packet\n\t * itself too large. Accept the packet unmodified instead.\n\t */\n\tif (len > tcp_hdrlen)\n\t\treturn 0;\n\n\t/*\n\t * MSS Option not found ?! add it..\n\t */\n\tif (skb_tailroom(skb) < TCPOLEN_MSS) {\n\t\tif (pskb_expand_head(skb, 0,\n\t\t\t\t TCPOLEN_MSS - skb_tailroom(skb),\n\t\t\t\t GFP_ATOMIC))\n\t\t\treturn -1;\n\t\ttcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);\n\t}\n\n\tskb_put(skb, TCPOLEN_MSS);\n\n\t/*\n\t * IPv4: RFC 1122 states \"If an MSS option is not received at\n\t * connection setup, TCP MUST assume a default send MSS of 536\".\n\t * IPv6: RFC 2460 states IPv6 has a minimum MTU of 1280 and a minimum\n\t * length IPv6 header of 60, ergo the default MSS value is 1220\n\t * Since no MSS was provided, we must use the default values\n\t */\n\tif (xt_family(par) == NFPROTO_IPV4)\n\t\tnewmss = min(newmss, (u16)536);\n\telse\n\t\tnewmss = min(newmss, (u16)1220);\n\n\topt = (u_int8_t *)tcph + sizeof(struct tcphdr);\n\tmemmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));\n\n\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t htons(len), htons(len + TCPOLEN_MSS), true);\n\topt[0] = TCPOPT_MSS;\n\topt[1] = TCPOLEN_MSS;\n\topt[2] = (newmss & 0xff00) >> 8;\n\topt[3] = newmss & 0x00ff;\n\n\tinet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), false);\n\n\toldval = ((__be16 *)tcph)[6];\n\ttcph->doff += TCPOLEN_MSS/4;\n\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t oldval, ((__be16 *)tcph)[6], false);\n\treturn TCPOLEN_MSS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18017", "cwe_id": "CWE-416" }, { "id": 1614, "func": "tcpmss_mangle_packet(struct sk_buff *skb,\n\t\t const struct xt_action_param *par,\n\t\t unsigned int family,\n\t\t unsigned int tcphoff,\n\t\t unsigned int minlen)\n{\n\tconst struct xt_tcpmss_info *info = par->targinfo;\n\tstruct tcphdr *tcph;\n\tint len, tcp_hdrlen;\n\tunsigned int i;\n\t__be16 oldval;\n\tu16 newmss;\n\tu8 *opt;\n\n\t/* This is a fragment, no TCP header is available */\n\tif (par->fragoff != 0)\n\t\treturn 0;\n\n\tif (!skb_make_writable(skb, skb->len))\n\t\treturn -1;\n\n\tlen = skb->len - tcphoff;\n\tif (len < (int)sizeof(struct tcphdr))\n\t\treturn -1;\n\n\ttcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);\n\ttcp_hdrlen = tcph->doff * 4;\n\n\tif (len < tcp_hdrlen || tcp_hdrlen < sizeof(struct tcphdr))\n\t\treturn -1;\n\n\tif (info->mss == XT_TCPMSS_CLAMP_PMTU) {\n\t\tstruct net *net = xt_net(par);\n\t\tunsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family);\n\t\tunsigned int min_mtu = min(dst_mtu(skb_dst(skb)), in_mtu);\n\n\t\tif (min_mtu <= minlen) {\n\t\t\tnet_err_ratelimited(\"unknown or invalid path-MTU (%u)\\n\",\n\t\t\t\t\t min_mtu);\n\t\t\treturn -1;\n\t\t}\n\t\tnewmss = min_mtu - minlen;\n\t} else\n\t\tnewmss = info->mss;\n\n\topt = (u_int8_t *)tcph;\n\tfor (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {\n\t\tif (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {\n\t\t\tu_int16_t oldmss;\n\n\t\t\toldmss = (opt[i+2] << 8) | opt[i+3];\n\n\t\t\t/* Never increase MSS, even when setting it, as\n\t\t\t * doing so results in problems for hosts that rely\n\t\t\t * on MSS being set correctly.\n\t\t\t */\n\t\t\tif (oldmss <= newmss)\n\t\t\t\treturn 0;\n\n\t\t\topt[i+2] = (newmss & 0xff00) >> 8;\n\t\t\topt[i+3] = newmss & 0x00ff;\n\n\t\t\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t\t\t htons(oldmss), htons(newmss),\n\t\t\t\t\t\t false);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/* There is data after the header so the option can't be added\n\t * without moving it, and doing so may make the SYN packet\n\t * itself too large. Accept the packet unmodified instead.\n\t */\n\tif (len > tcp_hdrlen)\n\t\treturn 0;\n\n\t/* tcph->doff has 4 bits, do not wrap it to 0 */\n\tif (tcp_hdrlen >= 15 * 4)\n\t\treturn 0;\n\n\t/*\n\t * MSS Option not found ?! add it..\n\t */\n\tif (skb_tailroom(skb) < TCPOLEN_MSS) {\n\t\tif (pskb_expand_head(skb, 0,\n\t\t\t\t TCPOLEN_MSS - skb_tailroom(skb),\n\t\t\t\t GFP_ATOMIC))\n\t\t\treturn -1;\n\t\ttcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);\n\t}\n\n\tskb_put(skb, TCPOLEN_MSS);\n\n\t/*\n\t * IPv4: RFC 1122 states \"If an MSS option is not received at\n\t * connection setup, TCP MUST assume a default send MSS of 536\".\n\t * IPv6: RFC 2460 states IPv6 has a minimum MTU of 1280 and a minimum\n\t * length IPv6 header of 60, ergo the default MSS value is 1220\n\t * Since no MSS was provided, we must use the default values\n\t */\n\tif (xt_family(par) == NFPROTO_IPV4)\n\t\tnewmss = min(newmss, (u16)536);\n\telse\n\t\tnewmss = min(newmss, (u16)1220);\n\n\topt = (u_int8_t *)tcph + sizeof(struct tcphdr);\n\tmemmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));\n\n\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t htons(len), htons(len + TCPOLEN_MSS), true);\n\topt[0] = TCPOPT_MSS;\n\topt[1] = TCPOLEN_MSS;\n\topt[2] = (newmss & 0xff00) >> 8;\n\topt[3] = newmss & 0x00ff;\n\n\tinet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), false);\n\n\toldval = ((__be16 *)tcph)[6];\n\ttcph->doff += TCPOLEN_MSS/4;\n\tinet_proto_csum_replace2(&tcph->check, skb,\n\t\t\t\t oldval, ((__be16 *)tcph)[6], false);\n\treturn TCPOLEN_MSS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18017", "cwe_id": "CWE-416" }, { "id": 261, "func": "int string_rfind(const char *input, int len, const char *s, int s_len,\n int pos, bool case_sensitive) {\n assertx(input);\n assertx(s);\n if (!s_len || pos < -len || pos > len) {\n return -1;\n }\n void *ptr;\n if (case_sensitive) {\n if (pos >= 0) {\n ptr = bstrrstr(input + pos, len - pos, s, s_len);\n } else {\n ptr = bstrrstr(input, len + pos + s_len, s, s_len);\n }\n } else {\n if (pos >= 0) {\n ptr = bstrrcasestr(input + pos, len - pos, s, s_len);\n } else {\n ptr = bstrrcasestr(input, len + pos + s_len, s, s_len);\n }\n }\n if (ptr != nullptr) {\n return (int)((const char *)ptr - input);\n }\n return -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-3561", "cwe_id": "CWE-125" }, { "id": 261, "func": "int string_rfind(const char *input, int len, const char *s, int s_len,\n int pos, bool case_sensitive) {\n assertx(input);\n assertx(s);\n if (!s_len || pos < -len || pos > len) {\n return -1;\n }\n void *ptr;\n if (case_sensitive) {\n if (pos >= 0) {\n ptr = bstrrstr(input + pos, len - pos, s, s_len);\n } else {\n ptr = bstrrstr(input, len + std::min(pos + s_len, 0), s, s_len);\n }\n } else {\n if (pos >= 0) {\n ptr = bstrrcasestr(input + pos, len - pos, s, s_len);\n } else {\n ptr = bstrrcasestr(input, len + std::min(pos + s_len, 0), s, s_len);\n }\n }\n if (ptr != nullptr) {\n return (int)((const char *)ptr - input);\n }\n return -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-3561", "cwe_id": "CWE-125" }, { "id": 1099, "func": "static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)\n{\n\tstruct usb_host_interface *alt;\n\tstruct sd *sd = (struct sd *) gspca_dev;\n\n\t/* Start isoc bandwidth \"negotiation\" at max isoc bandwidth */\n\talt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];\n\talt->endpoint[0].desc.wMaxPacketSize =\n\t\tcpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11609", "cwe_id": "CWE-476" }, { "id": 1099, "func": "static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)\n{\n\tstruct usb_interface_cache *intfc;\n\tstruct usb_host_interface *alt;\n\tstruct sd *sd = (struct sd *) gspca_dev;\n\n\tintfc = gspca_dev->dev->actconfig->intf_cache[0];\n\n\tif (intfc->num_altsetting < 2)\n\t\treturn -ENODEV;\n\n\talt = &intfc->altsetting[1];\n\n\tif (alt->desc.bNumEndpoints < 1)\n\t\treturn -ENODEV;\n\n\t/* Start isoc bandwidth \"negotiation\" at max isoc bandwidth */\n\talt->endpoint[0].desc.wMaxPacketSize =\n\t\tcpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11609", "cwe_id": "CWE-476" }, { "id": 1484, "func": "obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)TypeIgnore_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n int lineno;\n\n if (_PyObject_HasAttrId(obj, &PyId_lineno)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_lineno);\n if (tmp == NULL) goto failed;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from TypeIgnore\");\n return 1;\n }\n *out = TypeIgnore(lineno, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of type_ignore, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1484, "func": "obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)TypeIgnore_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n int lineno;\n\n if (lookup_attr_id(obj, &PyId_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from TypeIgnore\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = TypeIgnore(lineno, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of type_ignore, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2388, "func": "jas_matrix_t *jas_seq2d_input(FILE *in)\n{\n\tjas_matrix_t *matrix;\n\tint i;\n\tint j;\n\tlong x;\n\tint numrows;\n\tint numcols;\n\tint xoff;\n\tint yoff;\n\n\tif (fscanf(in, \"%d %d\", &xoff, &yoff) != 2)\n\t\treturn 0;\n\tif (fscanf(in, \"%d %d\", &numcols, &numrows) != 2)\n\t\treturn 0;\n\tif (!(matrix = jas_seq2d_create(xoff, yoff, xoff + numcols, yoff + numrows)))\n\t\treturn 0;\n\n\tif (jas_matrix_numrows(matrix) != numrows ||\n\t jas_matrix_numcols(matrix) != numcols) {\n\t\tabort();\n\t}\n\n\t/* Get matrix data. */\n\tfor (i = 0; i < jas_matrix_numrows(matrix); i++) {\n\t\tfor (j = 0; j < jas_matrix_numcols(matrix); j++) {\n\t\t\tif (fscanf(in, \"%ld\", &x) != 1) {\n\t\t\t\tjas_matrix_destroy(matrix);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tjas_matrix_set(matrix, i, j, JAS_CAST(jas_seqent_t, x));\n\t\t}\n\t}\n\n\treturn matrix;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2388, "func": "jas_matrix_t *jas_seq2d_input(FILE *in)\n{\n\tjas_matrix_t *matrix;\n\tjas_matind_t i;\n\tjas_matind_t j;\n\tlong x;\n\tjas_matind_t numrows;\n\tjas_matind_t numcols;\n\tjas_matind_t xoff;\n\tjas_matind_t yoff;\n\tlong tmp_xoff;\n\tlong tmp_yoff;\n\tlong tmp_numrows;\n\tlong tmp_numcols;\n\n\tif (fscanf(in, \"%ld %ld\", &tmp_xoff, &tmp_yoff) != 2) {\n\t\treturn 0;\n\t}\n\txoff = tmp_xoff;\n\tyoff = tmp_yoff;\n\tif (fscanf(in, \"%ld %ld\", &tmp_numcols, &tmp_numrows) != 2) {\n\t\treturn 0;\n\t}\n\tnumrows = tmp_numrows;\n\tnumcols = tmp_numcols;\n\tif (!(matrix = jas_seq2d_create(xoff, yoff, xoff + numcols,\n\t yoff + numrows))) {\n\t\treturn 0;\n\t}\n\n\tif (jas_matrix_numrows(matrix) != numrows ||\n\t jas_matrix_numcols(matrix) != numcols) {\n\t\tabort();\n\t}\n\n\t/* Get matrix data. */\n\tfor (i = 0; i < jas_matrix_numrows(matrix); i++) {\n\t\tfor (j = 0; j < jas_matrix_numcols(matrix); j++) {\n\t\t\tif (fscanf(in, \"%ld\", &x) != 1) {\n\t\t\t\tjas_matrix_destroy(matrix);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tjas_matrix_set(matrix, i, j, JAS_CAST(jas_seqent_t, x));\n\t\t}\n\t}\n\n\treturn matrix;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2190, "func": "static int string_scan_range(RList *list, RBinFile *bf, int min,\n\t\t\t const ut64 from, const ut64 to, int type) {\n\tut8 tmp[R_STRING_SCAN_BUFFER_SIZE];\n\tut64 str_start, needle = from;\n\tint count = 0, i, rc, runes;\n\tint str_type = R_STRING_TYPE_DETECT;\n\n\tif (type == -1) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t}\n\tif (from >= to) {\n\t\teprintf (\"Invalid range to find strings 0x%llx .. 0x%llx\\n\", from, to);\n\t\treturn -1;\n\t}\n\tut8 *buf = calloc (to - from, 1);\n\tif (!buf || !min) {\n\t\treturn -1;\n\t}\n\tr_buf_read_at (bf->buf, from, buf, to - from);\n\t// may oobread\n\twhile (needle < to) {\n\t\trc = r_utf8_decode (buf + needle - from, to - needle, NULL);\n\t\tif (!rc) {\n\t\t\tneedle++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (type == R_STRING_TYPE_DETECT) {\n\t\t\tchar *w = (char *)buf + needle + rc - from;\n\t\t\tif ((to - needle) > 5) {\n\t\t\t\tbool is_wide32 = needle + rc + 2 < to && !w[0] && !w[1] && !w[2] && w[3] && !w[4];\n\t\t\t\tif (is_wide32) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_WIDE32;\n\t\t\t\t} else {\n\t\t\t\t\tbool is_wide = needle + rc + 2 < to && !w[0] && w[1] && !w[2];\n\t\t\t\t\tstr_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr_type = R_STRING_TYPE_ASCII;\n\t\t\t}\n\t\t} else {\n\t\t\tstr_type = type;\n\t\t}\n\t\trunes = 0;\n\t\tstr_start = needle;\n\n\t\t/* Eat a whole C string */\n\t\tfor (rc = i = 0; i < sizeof (tmp) - 3 && needle < to; i += rc) {\n\t\t\tRRune r = {0};\n\n\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\trc = r_utf32le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc) {\n\t\t\t\t\trc = 4;\n\t\t\t\t}\n\t\t\t} else if (str_type == R_STRING_TYPE_WIDE) {\n\t\t\t\trc = r_utf16le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc == 1) {\n\t\t\t\t\trc = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trc = r_utf8_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Invalid sequence detected */\n\t\t\tif (!rc) {\n\t\t\t\tneedle++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tneedle += rc;\n\n\t\t\tif (r_isprint (r) && r != '\\\\') {\n\t\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\t\tif (r == 0xff) {\n\t\t\t\t\t\tr = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = r_utf8_encode (&tmp[i], r);\n\t\t\t\trunes++;\n\t\t\t\t/* Print the escape code */\n\t\t\t} else if (r && r < 0x100 && strchr (\"\\b\\v\\f\\n\\r\\t\\a\\033\\\\\", (char)r)) {\n\t\t\t\tif ((i + 32) < sizeof (tmp) && r < 93) {\n\t\t\t\t\ttmp[i + 0] = '\\\\';\n\t\t\t\t\ttmp[i + 1] = \" abtnvfr e \"\n\t\t\t\t\t \" \"\n\t\t\t\t\t \" \"\n\t\t\t\t\t \" \\\\\"[r];\n\t\t\t\t} else {\n\t\t\t\t\t// string too long\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trc = 2;\n\t\t\t\trunes++;\n\t\t\t} else {\n\t\t\t\t/* \\0 marks the end of C-strings */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\ttmp[i++] = '\\0';\n\n\t\tif (runes >= min) {\n\t\t\tif (str_type == R_STRING_TYPE_ASCII) {\n\t\t\t\t// reduce false positives\n\t\t\t\tint j;\n\t\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\t\tchar ch = tmp[j];\n\t\t\t\t\tif (ch != '\\n' && ch != '\\r' && ch != '\\t') {\n\t\t\t\t\t\tif (!IS_PRINTABLE (tmp[j])) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tRBinString *bs = R_NEW0 (RBinString);\n\t\t\tif (!bs) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->type = str_type;\n\t\t\tbs->length = runes;\n\t\t\tbs->size = needle - str_start;\n\t\t\tbs->ordinal = count++;\n\t\t\t// TODO: move into adjust_offset\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\t\tif (str_start -from> 1) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 2 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 2; // \\xff\\xfe\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tif (str_start -from> 3) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 4 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 4; // \\xff\\xfe\\x00\\x00\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->paddr = bs->vaddr = str_start;\n\t\t\tbs->string = r_str_ndup ((const char *)tmp, i);\n\t\t\tif (list) {\n\t\t\t\tr_list_append (list, bs);\n\t\t\t} else {\n\t\t\t\tprint_string (bs, bf);\n\t\t\t\tr_bin_string_free (bs);\n\t\t\t}\n\t\t}\n\t}\n\tfree (buf);\n\treturn count;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11381", "cwe_id": "CWE-125" }, { "id": 2190, "func": "static int string_scan_range(RList *list, RBinFile *bf, int min,\n\t\t\t const ut64 from, const ut64 to, int type) {\n\tut8 tmp[R_STRING_SCAN_BUFFER_SIZE];\n\tut64 str_start, needle = from;\n\tint count = 0, i, rc, runes;\n\tint str_type = R_STRING_TYPE_DETECT;\n\n\tif (type == -1) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t}\n\tif (from >= to) {\n\t\teprintf (\"Invalid range to find strings 0x%llx .. 0x%llx\\n\", from, to);\n\t\treturn -1;\n\t}\n\tint len = to - from;\n\tut8 *buf = calloc (len, 1);\n\tif (!buf || !min) {\n\t\treturn -1;\n\t}\n\tr_buf_read_at (bf->buf, from, buf, len);\n\t// may oobread\n\twhile (needle < to) {\n\t\trc = r_utf8_decode (buf + needle - from, to - needle, NULL);\n\t\tif (!rc) {\n\t\t\tneedle++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (type == R_STRING_TYPE_DETECT) {\n\t\t\tchar *w = (char *)buf + needle + rc - from;\n\t\t\tif ((to - needle) > 5 + rc) {\n\t\t\t\tbool is_wide32 = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]);\n\t\t\t\tif (is_wide32) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_WIDE32;\n\t\t\t\t} else {\n\t\t\t\t\tbool is_wide = needle + rc + 2 < to && !w[0] && w[1] && !w[2];\n\t\t\t\t\tstr_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr_type = R_STRING_TYPE_ASCII;\n\t\t\t}\n\t\t} else {\n\t\t\tstr_type = type;\n\t\t}\n\t\trunes = 0;\n\t\tstr_start = needle;\n\n\t\t/* Eat a whole C string */\n\t\tfor (rc = i = 0; i < sizeof (tmp) - 3 && needle < to; i += rc) {\n\t\t\tRRune r = {0};\n\n\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\trc = r_utf32le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc) {\n\t\t\t\t\trc = 4;\n\t\t\t\t}\n\t\t\t} else if (str_type == R_STRING_TYPE_WIDE) {\n\t\t\t\trc = r_utf16le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc == 1) {\n\t\t\t\t\trc = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trc = r_utf8_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Invalid sequence detected */\n\t\t\tif (!rc) {\n\t\t\t\tneedle++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tneedle += rc;\n\n\t\t\tif (r_isprint (r) && r != '\\\\') {\n\t\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\t\tif (r == 0xff) {\n\t\t\t\t\t\tr = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = r_utf8_encode (&tmp[i], r);\n\t\t\t\trunes++;\n\t\t\t\t/* Print the escape code */\n\t\t\t} else if (r && r < 0x100 && strchr (\"\\b\\v\\f\\n\\r\\t\\a\\033\\\\\", (char)r)) {\n\t\t\t\tif ((i + 32) < sizeof (tmp) && r < 93) {\n\t\t\t\t\ttmp[i + 0] = '\\\\';\n\t\t\t\t\ttmp[i + 1] = \" abtnvfr e \"\n\t\t\t\t\t \" \"\n\t\t\t\t\t \" \"\n\t\t\t\t\t \" \\\\\"[r];\n\t\t\t\t} else {\n\t\t\t\t\t// string too long\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trc = 2;\n\t\t\t\trunes++;\n\t\t\t} else {\n\t\t\t\t/* \\0 marks the end of C-strings */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\ttmp[i++] = '\\0';\n\n\t\tif (runes >= min) {\n\t\t\tif (str_type == R_STRING_TYPE_ASCII) {\n\t\t\t\t// reduce false positives\n\t\t\t\tint j;\n\t\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\t\tchar ch = tmp[j];\n\t\t\t\t\tif (ch != '\\n' && ch != '\\r' && ch != '\\t') {\n\t\t\t\t\t\tif (!IS_PRINTABLE (tmp[j])) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tRBinString *bs = R_NEW0 (RBinString);\n\t\t\tif (!bs) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->type = str_type;\n\t\t\tbs->length = runes;\n\t\t\tbs->size = needle - str_start;\n\t\t\tbs->ordinal = count++;\n\t\t\t// TODO: move into adjust_offset\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\t\tif (str_start -from> 1) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 2 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 2; // \\xff\\xfe\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tif (str_start -from> 3) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 4 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 4; // \\xff\\xfe\\x00\\x00\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->paddr = bs->vaddr = str_start;\n\t\t\tbs->string = r_str_ndup ((const char *)tmp, i);\n\t\t\tif (list) {\n\t\t\t\tr_list_append (list, bs);\n\t\t\t} else {\n\t\t\t\tprint_string (bs, bf);\n\t\t\t\tr_bin_string_free (bs);\n\t\t\t}\n\t\t}\n\t}\n\tfree (buf);\n\treturn count;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-11381", "cwe_id": "CWE-125" }, { "id": 1826, "func": "GF_Err text_box_size(GF_Box *s)\n{\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\t/*base + this + string length*/\n\ts->size += 51 + 1;\n\tif (ptr->textName)\n\t\ts->size += strlen(ptr->textName);\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32139", "cwe_id": "CWE-476" }, { "id": 1826, "func": "GF_Err text_box_size(GF_Box *s)\n{\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\ts->size += 8;\n\t/*base + this + string length*/\n\ts->size += 43 + 1;\n\tif (ptr->textName)\n\t\ts->size += strlen(ptr->textName);\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32139", "cwe_id": "CWE-476" }, { "id": 1866, "func": "TfLiteStatus ResizeOutputandTemporaryTensors(TfLiteContext* context,\n TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const int num_dims = NumDimensions(input);\n TF_LITE_ENSURE(context, num_dims >= 2);\n const TfLiteTensor* fft_length = GetInput(context, node, kFftLengthTensor);\n const int32_t* fft_length_data = GetTensorData(fft_length);\n // The lib, fft2d, can only handle fft_lengths of power of 2.\n TF_LITE_ENSURE(context, IsPowerOfTwo(fft_length_data[0]));\n TF_LITE_ENSURE(context, IsPowerOfTwo(fft_length_data[1]));\n\n int fft_height, fft_width;\n fft_height = fft_length_data[0];\n fft_width = fft_length_data[1];\n int fft_working_length = std::max(fft_height, fft_width / 2);\n int half_fft_working_length = fft_working_length / 2;\n\n // Resize output tensor.\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TfLiteIntArray* output_shape = TfLiteIntArrayCopy(input->dims);\n output_shape->data[num_dims - 2] = fft_length_data[0];\n output_shape->data[num_dims - 1] = fft_length_data[1] / 2 + 1;\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_shape));\n\n // Resize temporary tensors, fft_integer_working_area.\n TfLiteTensor* fft_integer_working_area =\n GetTemporary(context, node, kFftIntegerWorkingAreaTensor);\n TfLiteIntArray* fft_integer_working_area_shape = TfLiteIntArrayCreate(1);\n fft_integer_working_area_shape->data[0] =\n 2 + static_cast(sqrt(fft_working_length));\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, fft_integer_working_area,\n fft_integer_working_area_shape));\n\n // Resize temporary tensors, fft_double_working_area.\n TfLiteTensor* fft_double_working_area =\n GetTemporary(context, node, kFftDoubleWorkingAreaTensor);\n TfLiteIntArray* fft_double_working_area_shape = TfLiteIntArrayCreate(1);\n fft_double_working_area_shape->data[0] =\n half_fft_working_length + fft_width / 4;\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, fft_double_working_area,\n fft_double_working_area_shape));\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1866, "func": "TfLiteStatus ResizeOutputandTemporaryTensors(TfLiteContext* context,\n TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const int num_dims = NumDimensions(input);\n TF_LITE_ENSURE(context, num_dims >= 2);\n const TfLiteTensor* fft_length;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kFftLengthTensor, &fft_length));\n const int32_t* fft_length_data = GetTensorData(fft_length);\n // The lib, fft2d, can only handle fft_lengths of power of 2.\n TF_LITE_ENSURE(context, IsPowerOfTwo(fft_length_data[0]));\n TF_LITE_ENSURE(context, IsPowerOfTwo(fft_length_data[1]));\n\n int fft_height, fft_width;\n fft_height = fft_length_data[0];\n fft_width = fft_length_data[1];\n int fft_working_length = std::max(fft_height, fft_width / 2);\n int half_fft_working_length = fft_working_length / 2;\n\n // Resize output tensor.\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n TfLiteIntArray* output_shape = TfLiteIntArrayCopy(input->dims);\n output_shape->data[num_dims - 2] = fft_length_data[0];\n output_shape->data[num_dims - 1] = fft_length_data[1] / 2 + 1;\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_shape));\n\n // Resize temporary tensors, fft_integer_working_area.\n TfLiteTensor* fft_integer_working_area;\n TF_LITE_ENSURE_OK(\n context, GetTemporarySafe(context, node, kFftIntegerWorkingAreaTensor,\n &fft_integer_working_area));\n TfLiteIntArray* fft_integer_working_area_shape = TfLiteIntArrayCreate(1);\n fft_integer_working_area_shape->data[0] =\n 2 + static_cast(sqrt(fft_working_length));\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, fft_integer_working_area,\n fft_integer_working_area_shape));\n\n // Resize temporary tensors, fft_double_working_area.\n TfLiteTensor* fft_double_working_area;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, kFftDoubleWorkingAreaTensor,\n &fft_double_working_area));\n TfLiteIntArray* fft_double_working_area_shape = TfLiteIntArrayCreate(1);\n fft_double_working_area_shape->data[0] =\n half_fft_working_length + fft_width / 4;\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, fft_double_working_area,\n fft_double_working_area_shape));\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 28, "func": "qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t\tconst char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\tchar nfunc[32];\n\n\tmemset(nfunc, 0, sizeof(nfunc));\n\tmemcpy(nfunc, func, sizeof(nfunc) - 1);\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (!(qedi_dbg_log & QEDI_LOG_NOTICE))\n\t\tgoto ret;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_notice(\"[%s]:[%s:%d]:%d: %pV\",\n\t\t\t dev_name(&qedi->pdev->dev), nfunc, line,\n\t\t\t qedi->host_no, &vaf);\n\telse\n\t\tpr_notice(\"[0000:00:00.0]:[%s:%d]: %pV\", nfunc, line, &vaf);\n\nret:\n\tva_end(va);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15090", "cwe_id": "CWE-125" }, { "id": 28, "func": "qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t\tconst char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (!(qedi_dbg_log & QEDI_LOG_NOTICE))\n\t\tgoto ret;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_notice(\"[%s]:[%s:%d]:%d: %pV\",\n\t\t\t dev_name(&qedi->pdev->dev), func, line,\n\t\t\t qedi->host_no, &vaf);\n\telse\n\t\tpr_notice(\"[0000:00:00.0]:[%s:%d]: %pV\", func, line, &vaf);\n\nret:\n\tva_end(va);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15090", "cwe_id": "CWE-125" }, { "id": 2762, "func": "usage (int status)\n{\n if (status != EXIT_SUCCESS)\n fprintf (stderr, _(\"Try `%s --help' for more information.\\n\"),\n\t program_name);\n else\n {\n printf (_(\"\\\nUsage: %s [OPTION]... [STRINGS]...\\n\\\n\"), program_name);\n fputs (_(\"\\\nInternationalized Domain Name (IDNA2008) convert STRINGS, or standard input.\\n\\\n\\n\\\n\"), stdout);\n fputs (_(\"\\\nCommand line interface to the Libidn2 implementation of IDNA2008.\\n\\\n\\n\\\nAll strings are expected to be encoded in the locale charset.\\n\\\n\\n\\\nTo process a string that starts with `-', for example `-foo', use `--'\\n\\\nto signal the end of parameters, as in `idn2 --quiet -- -foo'.\\n\\\n\\n\\\nMandatory arguments to long options are mandatory for short options too.\\n\\\n\"), stdout);\n fputs (_(\"\\\n -h, --help Print help and exit\\n\\\n -V, --version Print version and exit\\n\\\n\"), stdout);\n fputs (_(\"\\\n -d, --decode Decode (punycode) domain name\\n\\\n -l, --lookup Lookup domain name (default)\\n\\\n -r, --register Register label\\n\\\n\"), stdout);\n fputs (_(\"\\\n -T, --tr46t Enable TR46 transitional processing\\n\\\n -N, --tr46nt Enable TR46 non-transitional processing\\n\\\n --no-tr46 Disable TR46 processing\\n\\\n\"), stdout);\n fputs (_(\"\\\n --usestd3asciirules Enable STD3 ASCII rules\\n\\\n --debug Print debugging information\\n\\\n --quiet Silent operation\\n\\\n\"), stdout);\n emit_bug_reporting_address ();\n }\n exit (status);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-12290", "cwe_id": "CWE-20" }, { "id": 2762, "func": "usage (int status)\n{\n if (status != EXIT_SUCCESS)\n fprintf (stderr, _(\"Try `%s --help' for more information.\\n\"),\n\t program_name);\n else\n {\n printf (_(\"\\\nUsage: %s [OPTION]... [STRINGS]...\\n\\\n\"), program_name);\n fputs (_(\"\\\nInternationalized Domain Name (IDNA2008) convert STRINGS, or standard input.\\n\\\n\\n\\\n\"), stdout);\n fputs (_(\"\\\nCommand line interface to the Libidn2 implementation of IDNA2008.\\n\\\n\\n\\\nAll strings are expected to be encoded in the locale charset.\\n\\\n\\n\\\nTo process a string that starts with `-', for example `-foo', use `--'\\n\\\nto signal the end of parameters, as in `idn2 --quiet -- -foo'.\\n\\\n\\n\\\nMandatory arguments to long options are mandatory for short options too.\\n\\\n\"), stdout);\n fputs (_(\"\\\n -h, --help Print help and exit\\n\\\n -V, --version Print version and exit\\n\\\n\"), stdout);\n fputs (_(\"\\\n -d, --decode Decode (punycode) domain name\\n\\\n -l, --lookup Lookup domain name (default)\\n\\\n -r, --register Register label\\n\\\n\"), stdout);\n fputs (_(\"\\\n -T, --tr46t Enable TR46 transitional processing\\n\\\n -N, --tr46nt Enable TR46 non-transitional processing\\n\\\n --no-tr46 Disable TR46 processing\\n\\\n\"), stdout);\n fputs (_(\"\\\n --usestd3asciirules Enable STD3 ASCII rules\\n\\\n --no-alabelroundtrip Disable ALabel rountrip for lookups\\n\\\n --debug Print debugging information\\n\\\n --quiet Silent operation\\n\\\n\"), stdout);\n emit_bug_reporting_address ();\n }\n exit (status);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-12290", "cwe_id": "CWE-20" }, { "id": 2048, "func": "static void copyIPv6IfDifferent(void * dest, const void * src)\n{\n\tif(dest != src) {\n\t\tmemcpy(dest, src, sizeof(struct in6_addr));\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-12111", "cwe_id": "CWE-476" }, { "id": 2048, "func": "static void copyIPv6IfDifferent(void * dest, const void * src)\n{\n\tif(dest != src && src != NULL) {\n\t\tmemcpy(dest, src, sizeof(struct in6_addr));\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-12111", "cwe_id": "CWE-476" }, { "id": 1412, "func": "static Jsi_RC jsi_ArrayFlatSub(Jsi_Interp *interp, Jsi_Obj* nobj, Jsi_Value *arr, int depth) {\n \n int i, n = 0, len = jsi_SizeOfArray(interp, arr->d.obj);\n if (len <= 0) return JSI_OK;\n Jsi_RC rc = JSI_OK;\n int clen = jsi_SizeOfArray(interp, nobj);\n for (i = 0; i < len && rc == JSI_OK; i++) {\n Jsi_Value *t = Jsi_ValueArrayIndex(interp, arr, i);\n if (t && depth>0 && Jsi_ValueIsArray(interp, t))\n rc = jsi_ArrayFlatSub(interp, nobj, t , depth-1);\n else if (!Jsi_ValueIsUndef(interp, t))\n Jsi_ObjArrayAdd(interp, nobj, t);\n if ((++n + clen)>interp->maxArrayList)\n return Jsi_LogError(\"array size exceeded\");\n }\n return rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 1412, "func": "static Jsi_RC jsi_ArrayFlatSub(Jsi_Interp *interp, Jsi_Obj* nobj, Jsi_Value *arr, int depth) {\n \n int i, n = 0, len = jsi_SizeOfArray(interp, arr->d.obj);\n if (len <= 0) return JSI_OK;\n Jsi_RC rc = JSI_OK;\n int clen = jsi_SizeOfArray(interp, nobj);\n for (i = 0; i < len && rc == JSI_OK; i++) {\n Jsi_Value *t = Jsi_ValueArrayIndex(interp, arr, i);\n if (t && depth>0 && Jsi_ValueIsArray(interp, t))\n rc = jsi_ArrayFlatSub(interp, nobj, t , depth-1);\n else if (!Jsi_ValueIsUndef(interp, t))\n Jsi_ObjArrayAdd(interp, nobj, t);\n if ((uint)(++n + clen)>interp->maxArrayList)\n return Jsi_LogError(\"array size exceeded\");\n }\n return rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 219, "func": "static void spl_filesystem_tree_it_move_forward(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object(iterator);\n\t\n\tobject->u.dir.index++;\n\tdo {\n\t\tspl_filesystem_dir_read(object TSRMLS_CC);\n\t} while (spl_filesystem_is_dot(object->u.dir.entry.d_name));\n\tif (object->file_name) {\n\t\tefree(object->file_name);\n\t\tobject->file_name = NULL;\n\t}\n\tif (iterator->current) {\n\t\tzval_ptr_dtor(&iterator->current);\n\t\titerator->current = NULL;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 219, "func": "static void spl_filesystem_tree_it_move_forward(zend_object_iterator *iter TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object(iterator);\n\n\tobject->u.dir.index++;\n\tdo {\n\t\tspl_filesystem_dir_read(object TSRMLS_CC);\n\t} while (spl_filesystem_is_dot(object->u.dir.entry.d_name));\n\tif (object->file_name) {\n\t\tefree(object->file_name);\n\t\tobject->file_name = NULL;\n\t}\n\tif (iterator->current) {\n\t\tzval_ptr_dtor(&iterator->current);\n\t\titerator->current = NULL;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 1736, "func": " void Compute(tensorflow::OpKernelContext* context) override {\n const tensorflow::Tensor* data;\n OP_REQUIRES_OK(context, context->input(\"data\", &data));\n const auto& input_data = data->flat().data();\n\n const tensorflow::Tensor* splits;\n OP_REQUIRES_OK(context, context->input(\"data_splits\", &splits));\n const auto& splits_vec = splits->flat();\n\n // Validate that the splits are valid indices into data\n const int input_data_size = data->flat().size();\n const int splits_vec_size = splits_vec.size();\n for (int i = 0; i < splits_vec_size; ++i) {\n bool valid_splits = splits_vec(i) >= 0;\n valid_splits = valid_splits && (splits_vec(i) <= input_data_size);\n OP_REQUIRES(\n context, valid_splits,\n errors::InvalidArgument(\"Invalid split value \", splits_vec(i),\n \", must be in [0,\", input_data_size, \"]\"));\n }\n\n int num_batch_items = splits_vec.size() - 1;\n tensorflow::Tensor* ngrams_splits;\n OP_REQUIRES_OK(\n context, context->allocate_output(1, splits->shape(), &ngrams_splits));\n auto ngrams_splits_data = ngrams_splits->flat().data();\n\n // If there is no data or size, return an empty RT.\n if (data->flat().size() == 0 || splits_vec.size() == 0) {\n tensorflow::Tensor* empty;\n OP_REQUIRES_OK(context,\n context->allocate_output(0, data->shape(), &empty));\n for (int i = 0; i <= num_batch_items; ++i) {\n ngrams_splits_data[i] = 0;\n }\n return;\n }\n\n ngrams_splits_data[0] = 0;\n for (int i = 1; i <= num_batch_items; ++i) {\n int length = splits_vec(i) - splits_vec(i - 1);\n int num_ngrams = 0;\n for (int ngram_width : ngram_widths_)\n num_ngrams += get_num_ngrams(length, ngram_width);\n if (preserve_short_ && length > 0 && num_ngrams == 0) {\n num_ngrams = 1;\n }\n ngrams_splits_data[i] = ngrams_splits_data[i - 1] + num_ngrams;\n }\n\n tensorflow::Tensor* ngrams;\n OP_REQUIRES_OK(\n context,\n context->allocate_output(\n 0, TensorShape({ngrams_splits_data[num_batch_items]}), &ngrams));\n auto ngrams_data = ngrams->flat().data();\n\n for (int i = 0; i < num_batch_items; ++i) {\n auto data_start = &input_data[splits_vec(i)];\n int output_start_idx = ngrams_splits_data[i];\n for (int ngram_width : ngram_widths_) {\n auto output_start = &ngrams_data[output_start_idx];\n int length = splits_vec(i + 1) - splits_vec(i);\n int num_ngrams = get_num_ngrams(length, ngram_width);\n CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n output_start_idx += num_ngrams;\n }\n // If we're preserving short sequences, check to see if no sequence was\n // generated by comparing the current output start idx to the original\n // one (ngram_splits_data). If no ngrams were generated, then they will\n // be equal (since we increment output_start_idx by num_ngrams every\n // time we create a set of ngrams.)\n if (preserve_short_ && output_start_idx == ngrams_splits_data[i]) {\n int data_length = splits_vec(i + 1) - splits_vec(i);\n // One legitimate reason to not have any ngrams when preserve_short_\n // is true is if the sequence itself is empty. In that case, move on.\n if (data_length == 0) {\n continue;\n }\n // We don't have to worry about dynamic padding sizes here: if padding\n // was dynamic, every sequence would have had sufficient padding to\n // generate at least one ngram.\n int ngram_width = data_length + 2 * pad_width_;\n auto output_start = &ngrams_data[output_start_idx];\n int num_ngrams = 1;\n CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n }\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29541", "cwe_id": "CWE-476" }, { "id": 1736, "func": " void Compute(tensorflow::OpKernelContext* context) override {\n const tensorflow::Tensor* data;\n OP_REQUIRES_OK(context, context->input(\"data\", &data));\n const auto& input_data = data->flat().data();\n\n const tensorflow::Tensor* splits;\n OP_REQUIRES_OK(context, context->input(\"data_splits\", &splits));\n const auto& splits_vec = splits->flat();\n\n // Validate that the splits are valid indices into data, only if there are\n // splits specified.\n const int input_data_size = data->flat().size();\n const int splits_vec_size = splits_vec.size();\n if (splits_vec_size > 0) {\n int prev_split = splits_vec(0);\n OP_REQUIRES(context, prev_split == 0,\n errors::InvalidArgument(\"First split value must be 0, got \",\n prev_split));\n for (int i = 1; i < splits_vec_size; ++i) {\n bool valid_splits = splits_vec(i) >= prev_split;\n valid_splits = valid_splits && (splits_vec(i) <= input_data_size);\n OP_REQUIRES(context, valid_splits,\n errors::InvalidArgument(\n \"Invalid split value \", splits_vec(i), \", must be in [\",\n prev_split, \", \", input_data_size, \"]\"));\n prev_split = splits_vec(i);\n }\n OP_REQUIRES(context, prev_split == input_data_size,\n errors::InvalidArgument(\n \"Last split value must be data size. Expected \",\n input_data_size, \", got \", prev_split));\n }\n\n int num_batch_items = splits_vec.size() - 1;\n tensorflow::Tensor* ngrams_splits;\n OP_REQUIRES_OK(\n context, context->allocate_output(1, splits->shape(), &ngrams_splits));\n auto ngrams_splits_data = ngrams_splits->flat().data();\n\n // If there is no data or size, return an empty RT.\n if (data->flat().size() == 0 || splits_vec.size() == 0) {\n tensorflow::Tensor* empty;\n OP_REQUIRES_OK(context,\n context->allocate_output(0, data->shape(), &empty));\n for (int i = 0; i <= num_batch_items; ++i) {\n ngrams_splits_data[i] = 0;\n }\n return;\n }\n\n ngrams_splits_data[0] = 0;\n for (int i = 1; i <= num_batch_items; ++i) {\n int length = splits_vec(i) - splits_vec(i - 1);\n int num_ngrams = 0;\n for (int ngram_width : ngram_widths_)\n num_ngrams += get_num_ngrams(length, ngram_width);\n if (preserve_short_ && length > 0 && num_ngrams == 0) {\n num_ngrams = 1;\n }\n ngrams_splits_data[i] = ngrams_splits_data[i - 1] + num_ngrams;\n }\n\n tensorflow::Tensor* ngrams;\n OP_REQUIRES_OK(\n context,\n context->allocate_output(\n 0, TensorShape({ngrams_splits_data[num_batch_items]}), &ngrams));\n auto ngrams_data = ngrams->flat().data();\n\n for (int i = 0; i < num_batch_items; ++i) {\n auto data_start = &input_data[splits_vec(i)];\n int output_start_idx = ngrams_splits_data[i];\n for (int ngram_width : ngram_widths_) {\n auto output_start = &ngrams_data[output_start_idx];\n int length = splits_vec(i + 1) - splits_vec(i);\n int num_ngrams = get_num_ngrams(length, ngram_width);\n CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n output_start_idx += num_ngrams;\n }\n // If we're preserving short sequences, check to see if no sequence was\n // generated by comparing the current output start idx to the original\n // one (ngram_splits_data). If no ngrams were generated, then they will\n // be equal (since we increment output_start_idx by num_ngrams every\n // time we create a set of ngrams.)\n if (preserve_short_ && output_start_idx == ngrams_splits_data[i]) {\n int data_length = splits_vec(i + 1) - splits_vec(i);\n // One legitimate reason to not have any ngrams when preserve_short_\n // is true is if the sequence itself is empty. In that case, move on.\n if (data_length == 0) {\n continue;\n }\n // We don't have to worry about dynamic padding sizes here: if padding\n // was dynamic, every sequence would have had sufficient padding to\n // generate at least one ngram.\n int ngram_width = data_length + 2 * pad_width_;\n auto output_start = &ngrams_data[output_start_idx];\n int num_ngrams = 1;\n CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n }\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29541", "cwe_id": "CWE-476" }, { "id": 207, "func": "static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_include_path, int silent TSRMLS_DC) /* {{{ */\n{\n\tzval tmp;\n\n\tintern->type = SPL_FS_FILE;\n\n\tphp_stat(intern->file_name, intern->file_name_len, FS_IS_DIR, &tmp TSRMLS_CC);\n\tif (Z_LVAL(tmp)) {\n\t\tintern->u.file.open_mode = NULL;\n\t\tintern->file_name = NULL;\n\t\tzend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, \"Cannot use SplFileObject with directories\");\n\t\treturn FAILURE;\n\t}\n\n\tintern->u.file.context = php_stream_context_from_zval(intern->u.file.zcontext, 0);\n\tintern->u.file.stream = php_stream_open_wrapper_ex(intern->file_name, intern->u.file.open_mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, intern->u.file.context);\n\n\tif (!intern->file_name_len || !intern->u.file.stream) {\n\t\tif (!EG(exception)) {\n\t\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, \"Cannot open file '%s'\", intern->file_name_len ? intern->file_name : \"\");\n\t\t}\n\t\tintern->file_name = NULL; /* until here it is not a copy */\n\t\tintern->u.file.open_mode = NULL;\n\t\treturn FAILURE;\n\t}\n\n\tif (intern->u.file.zcontext) {\n\t\tzend_list_addref(Z_RESVAL_P(intern->u.file.zcontext));\n\t}\n\n\tif (intern->file_name_len > 1 && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) {\n\t\tintern->file_name_len--;\n\t}\n\n\tintern->orig_path = estrndup(intern->u.file.stream->orig_path, strlen(intern->u.file.stream->orig_path));\n\n\tintern->file_name = estrndup(intern->file_name, intern->file_name_len);\n\tintern->u.file.open_mode = estrndup(intern->u.file.open_mode, intern->u.file.open_mode_len);\n\n\t/* avoid reference counting in debug mode, thus do it manually */\n\tZVAL_RESOURCE(&intern->u.file.zresource, php_stream_get_resource_id(intern->u.file.stream));\n\tZ_SET_REFCOUNT(intern->u.file.zresource, 1);\n\t\n\tintern->u.file.delimiter = ',';\n\tintern->u.file.enclosure = '\"';\n\tintern->u.file.escape = '\\\\';\n\n\tzend_hash_find(&intern->std.ce->function_table, \"getcurrentline\", sizeof(\"getcurrentline\"), (void **) &intern->u.file.func_getCurr);\n\n\treturn SUCCESS;\n} /* }}} */", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 207, "func": "static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_include_path, int silent TSRMLS_DC) /* {{{ */\n{\n\tzval tmp;\n\n\tintern->type = SPL_FS_FILE;\n\n\tphp_stat(intern->file_name, intern->file_name_len, FS_IS_DIR, &tmp TSRMLS_CC);\n\tif (Z_LVAL(tmp)) {\n\t\tintern->u.file.open_mode = NULL;\n\t\tintern->file_name = NULL;\n\t\tzend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, \"Cannot use SplFileObject with directories\");\n\t\treturn FAILURE;\n\t}\n\n\tintern->u.file.context = php_stream_context_from_zval(intern->u.file.zcontext, 0);\n\tintern->u.file.stream = php_stream_open_wrapper_ex(intern->file_name, intern->u.file.open_mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, intern->u.file.context);\n\n\tif (!intern->file_name_len || !intern->u.file.stream) {\n\t\tif (!EG(exception)) {\n\t\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, \"Cannot open file '%s'\", intern->file_name_len ? intern->file_name : \"\");\n\t\t}\n\t\tintern->file_name = NULL; /* until here it is not a copy */\n\t\tintern->u.file.open_mode = NULL;\n\t\treturn FAILURE;\n\t}\n\n\tif (intern->u.file.zcontext) {\n\t\tzend_list_addref(Z_RESVAL_P(intern->u.file.zcontext));\n\t}\n\n\tif (intern->file_name_len > 1 && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) {\n\t\tintern->file_name_len--;\n\t}\n\n\tintern->orig_path = estrndup(intern->u.file.stream->orig_path, strlen(intern->u.file.stream->orig_path));\n\n\tintern->file_name = estrndup(intern->file_name, intern->file_name_len);\n\tintern->u.file.open_mode = estrndup(intern->u.file.open_mode, intern->u.file.open_mode_len);\n\n\t/* avoid reference counting in debug mode, thus do it manually */\n\tZVAL_RESOURCE(&intern->u.file.zresource, php_stream_get_resource_id(intern->u.file.stream));\n\tZ_SET_REFCOUNT(intern->u.file.zresource, 1);\n\n\tintern->u.file.delimiter = ',';\n\tintern->u.file.enclosure = '\"';\n\tintern->u.file.escape = '\\\\';\n\n\tzend_hash_find(&intern->std.ce->function_table, \"getcurrentline\", sizeof(\"getcurrentline\"), (void **) &intern->u.file.func_getCurr);\n\n\treturn SUCCESS;\n} /* }}} */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 748, "func": "static ssize_t driver_override_store(struct device *dev,\n\t\t\t\t struct device_attribute *attr,\n\t\t\t\t const char *buf, size_t count)\n{\n\tstruct platform_device *pdev = to_platform_device(dev);\n\tchar *driver_override, *old = pdev->driver_override, *cp;\n\n\tif (count > PATH_MAX)\n\t\treturn -EINVAL;\n\n\tdriver_override = kstrndup(buf, count, GFP_KERNEL);\n\tif (!driver_override)\n\t\treturn -ENOMEM;\n\n\tcp = strchr(driver_override, '\\n');\n\tif (cp)\n\t\t*cp = '\\0';\n\n\tif (strlen(driver_override)) {\n\t\tpdev->driver_override = driver_override;\n\t} else {\n\t\tkfree(driver_override);\n\t\tpdev->driver_override = NULL;\n\t}\n\n\tkfree(old);\n\n\treturn count;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12146", "cwe_id": "CWE-362" }, { "id": 748, "func": "static ssize_t driver_override_store(struct device *dev,\n\t\t\t\t struct device_attribute *attr,\n\t\t\t\t const char *buf, size_t count)\n{\n\tstruct platform_device *pdev = to_platform_device(dev);\n\tchar *driver_override, *old, *cp;\n\n\tif (count > PATH_MAX)\n\t\treturn -EINVAL;\n\n\tdriver_override = kstrndup(buf, count, GFP_KERNEL);\n\tif (!driver_override)\n\t\treturn -ENOMEM;\n\n\tcp = strchr(driver_override, '\\n');\n\tif (cp)\n\t\t*cp = '\\0';\n\n\tdevice_lock(dev);\n\told = pdev->driver_override;\n\tif (strlen(driver_override)) {\n\t\tpdev->driver_override = driver_override;\n\t} else {\n\t\tkfree(driver_override);\n\t\tpdev->driver_override = NULL;\n\t}\n\tdevice_unlock(dev);\n\n\tkfree(old);\n\n\treturn count;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12146", "cwe_id": "CWE-362" }, { "id": 3036, "func": "static void buffer_pipe_buf_get(struct pipe_inode_info *pipe,\n\t\t\t\tstruct pipe_buffer *buf)\n{\n\tstruct buffer_ref *ref = (struct buffer_ref *)buf->private;\n\n\tref->ref++;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11487", "cwe_id": "CWE-416" }, { "id": 3036, "func": "static bool buffer_pipe_buf_get(struct pipe_inode_info *pipe,\n\t\t\t\tstruct pipe_buffer *buf)\n{\n\tstruct buffer_ref *ref = (struct buffer_ref *)buf->private;\n\n\tif (ref->ref > INT_MAX/2)\n\t\treturn false;\n\n\tref->ref++;\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11487", "cwe_id": "CWE-416" }, { "id": 163, "func": "header_put_be_int (SF_PRIVATE *psf, int x)\n{\tif (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)\n\t{\tpsf->header [psf->headindex++] = (x >> 24) ;\n\t\tpsf->header [psf->headindex++] = (x >> 16) ;\n\t\tpsf->header [psf->headindex++] = (x >> 8) ;\n\t\tpsf->header [psf->headindex++] = x ;\n\t\t} ;\n} /* header_put_be_int */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 163, "func": "header_put_be_int (SF_PRIVATE *psf, int x)\n{\tpsf->header.ptr [psf->header.indx++] = (x >> 24) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 16) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 8) ;\n\tpsf->header.ptr [psf->header.indx++] = x ;\n} /* header_put_be_int */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 840, "func": "static void wdm_in_callback(struct urb *urb)\n{\n\tstruct wdm_device *desc = urb->context;\n\tint status = urb->status;\n\n\tspin_lock(&desc->iuspin);\n\tclear_bit(WDM_RESPONDING, &desc->flags);\n\n\tif (status) {\n\t\tswitch (status) {\n\t\tcase -ENOENT:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ENOENT\");\n\t\t\tgoto skip_error;\n\t\tcase -ECONNRESET:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ECONNRESET\");\n\t\t\tgoto skip_error;\n\t\tcase -ESHUTDOWN:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ESHUTDOWN\");\n\t\t\tgoto skip_error;\n\t\tcase -EPIPE:\n\t\t\tdev_err(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -EPIPE\\n\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tdev_err(&desc->intf->dev,\n\t\t\t\t\"Unexpected error %d\\n\", status);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tdesc->rerr = status;\n\tdesc->reslength = urb->actual_length;\n\tmemmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);\n\tdesc->length += desc->reslength;\nskip_error:\n\twake_up(&desc->wait);\n\n\tset_bit(WDM_READ, &desc->flags);\n\tspin_unlock(&desc->iuspin);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-1860", "cwe_id": "CWE-119" }, { "id": 840, "func": "static void wdm_in_callback(struct urb *urb)\n{\n\tstruct wdm_device *desc = urb->context;\n\tint status = urb->status;\n\tint length = urb->actual_length;\n\n\tspin_lock(&desc->iuspin);\n\tclear_bit(WDM_RESPONDING, &desc->flags);\n\n\tif (status) {\n\t\tswitch (status) {\n\t\tcase -ENOENT:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ENOENT\");\n\t\t\tgoto skip_error;\n\t\tcase -ECONNRESET:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ECONNRESET\");\n\t\t\tgoto skip_error;\n\t\tcase -ESHUTDOWN:\n\t\t\tdev_dbg(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -ESHUTDOWN\");\n\t\t\tgoto skip_error;\n\t\tcase -EPIPE:\n\t\t\tdev_err(&desc->intf->dev,\n\t\t\t\t\"nonzero urb status received: -EPIPE\\n\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tdev_err(&desc->intf->dev,\n\t\t\t\t\"Unexpected error %d\\n\", status);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tdesc->rerr = status;\n\tif (length + desc->length > desc->wMaxCommand) {\n\t\t/* The buffer would overflow */\n\t\tset_bit(WDM_OVERFLOW, &desc->flags);\n\t} else {\n\t\t/* we may already be in overflow */\n\t\tif (!test_bit(WDM_OVERFLOW, &desc->flags)) {\n\t\t\tmemmove(desc->ubuf + desc->length, desc->inbuf, length);\n\t\t\tdesc->length += length;\n\t\t\tdesc->reslength = length;\n\t\t}\n\t}\nskip_error:\n\twake_up(&desc->wait);\n\n\tset_bit(WDM_READ, &desc->flags);\n\tspin_unlock(&desc->iuspin);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-1860", "cwe_id": "CWE-119" }, { "id": 162, "func": "header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x)\n{\tif (psf->headindex < SIGNED_SIZEOF (psf->header) - 8)\n\t{\tpsf->header [psf->headindex++] = 0 ;\n\t\tpsf->header [psf->headindex++] = 0 ;\n\t\tpsf->header [psf->headindex++] = 0 ;\n\t\tpsf->header [psf->headindex++] = 0 ;\n\t\tpsf->header [psf->headindex++] = (x >> 24) ;\n\t\tpsf->header [psf->headindex++] = (x >> 16) ;\n\t\tpsf->header [psf->headindex++] = (x >> 8) ;\n\t\tpsf->header [psf->headindex++] = x ;\n\t\t} ;\n} /* header_put_be_8byte */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 162, "func": "header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x)\n{\tpsf->header.ptr [psf->header.indx++] = (x >> 56) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 48) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 40) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 32) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 24) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 16) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 8) ;\n\tpsf->header.ptr [psf->header.indx++] = x ;\n} /* header_put_be_8byte */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 1134, "func": "static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor) \n{\n\tconst gdFixed f_127 = gd_itofx(127);\n\tregister int c = src->tpixels[y][x];\n\tc = c | (( (int) (gd_fxtof(gd_mulfx(coverage, f_127)) + 50.5f)) << 24);\n\treturn _color_blend(bgColor, c);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7456", "cwe_id": "CWE-125" }, { "id": 1134, "func": "static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)\n{\n\tconst gdFixed f_127 = gd_itofx(127);\n\tregister int c = src->tpixels[y][x];\n\tc = c | (( (int) (gd_fxtof(gd_mulfx(coverage, f_127)) + 50.5f)) << 24);\n\treturn _color_blend(bgColor, c);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7456", "cwe_id": "CWE-125" }, { "id": 859, "func": "void AllocateDataSet(cmsIT8* it8)\n{\n TABLE* t = GetTable(it8);\n\n if (t -> Data) return; // Already allocated\n\n t-> nSamples = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_FIELDS\"));\n t-> nPatches = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_SETS\"));\n\n t-> Data = (char**)AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * ((cmsUInt32Number) t->nPatches + 1) *sizeof (char*));\n if (t->Data == NULL) {\n\n SynError(it8, \"AllocateDataSet: Unable to allocate data array\");\n }\n\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-16435", "cwe_id": "CWE-787" }, { "id": 859, "func": "void AllocateDataSet(cmsIT8* it8)\n{\n TABLE* t = GetTable(it8);\n\n if (t -> Data) return; // Already allocated\n\n t-> nSamples = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_FIELDS\"));\n t-> nPatches = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_SETS\"));\n\n if (t -> nSamples < 0 || t->nSamples > 0x7ffe || t->nPatches < 0 || t->nPatches > 0x7ffe)\n {\n SynError(it8, \"AllocateDataSet: too much data\");\n }\n else {\n t->Data = (char**)AllocChunk(it8, ((cmsUInt32Number)t->nSamples + 1) * ((cmsUInt32Number)t->nPatches + 1) * sizeof(char*));\n if (t->Data == NULL) {\n\n SynError(it8, \"AllocateDataSet: Unable to allocate data array\");\n }\n }\n\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-16435", "cwe_id": "CWE-787" }, { "id": 2637, "func": "static int nfc_llcp_build_gb(struct nfc_llcp_local *local)\n{\n\tu8 *gb_cur, *version_tlv, version, version_length;\n\tu8 *lto_tlv, lto_length;\n\tu8 *wks_tlv, wks_length;\n\tu8 *miux_tlv, miux_length;\n\t__be16 wks = cpu_to_be16(local->local_wks);\n\tu8 gb_len = 0;\n\tint ret = 0;\n\n\tversion = LLCP_VERSION_11;\n\tversion_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version,\n\t\t\t\t\t 1, &version_length);\n\tgb_len += version_length;\n\n\tlto_tlv = nfc_llcp_build_tlv(LLCP_TLV_LTO, &local->lto, 1, <o_length);\n\tgb_len += lto_length;\n\n\tpr_debug(\"Local wks 0x%lx\\n\", local->local_wks);\n\twks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&wks, 2, &wks_length);\n\tgb_len += wks_length;\n\n\tmiux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&local->miux, 0,\n\t\t\t\t &miux_length);\n\tgb_len += miux_length;\n\n\tgb_len += ARRAY_SIZE(llcp_magic);\n\n\tif (gb_len > NFC_MAX_GT_LEN) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tgb_cur = local->gb;\n\n\tmemcpy(gb_cur, llcp_magic, ARRAY_SIZE(llcp_magic));\n\tgb_cur += ARRAY_SIZE(llcp_magic);\n\n\tmemcpy(gb_cur, version_tlv, version_length);\n\tgb_cur += version_length;\n\n\tmemcpy(gb_cur, lto_tlv, lto_length);\n\tgb_cur += lto_length;\n\n\tmemcpy(gb_cur, wks_tlv, wks_length);\n\tgb_cur += wks_length;\n\n\tmemcpy(gb_cur, miux_tlv, miux_length);\n\tgb_cur += miux_length;\n\n\tlocal->gb_len = gb_len;\n\nout:\n\tkfree(version_tlv);\n\tkfree(lto_tlv);\n\tkfree(wks_tlv);\n\tkfree(miux_tlv);\n\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-12818", "cwe_id": "CWE-476" }, { "id": 2637, "func": "static int nfc_llcp_build_gb(struct nfc_llcp_local *local)\n{\n\tu8 *gb_cur, version, version_length;\n\tu8 lto_length, wks_length, miux_length;\n\tu8 *version_tlv = NULL, *lto_tlv = NULL,\n\t *wks_tlv = NULL, *miux_tlv = NULL;\n\t__be16 wks = cpu_to_be16(local->local_wks);\n\tu8 gb_len = 0;\n\tint ret = 0;\n\n\tversion = LLCP_VERSION_11;\n\tversion_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version,\n\t\t\t\t\t 1, &version_length);\n\tif (!version_tlv) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tgb_len += version_length;\n\n\tlto_tlv = nfc_llcp_build_tlv(LLCP_TLV_LTO, &local->lto, 1, <o_length);\n\tif (!lto_tlv) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tgb_len += lto_length;\n\n\tpr_debug(\"Local wks 0x%lx\\n\", local->local_wks);\n\twks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&wks, 2, &wks_length);\n\tif (!wks_tlv) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tgb_len += wks_length;\n\n\tmiux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&local->miux, 0,\n\t\t\t\t &miux_length);\n\tif (!miux_tlv) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tgb_len += miux_length;\n\n\tgb_len += ARRAY_SIZE(llcp_magic);\n\n\tif (gb_len > NFC_MAX_GT_LEN) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tgb_cur = local->gb;\n\n\tmemcpy(gb_cur, llcp_magic, ARRAY_SIZE(llcp_magic));\n\tgb_cur += ARRAY_SIZE(llcp_magic);\n\n\tmemcpy(gb_cur, version_tlv, version_length);\n\tgb_cur += version_length;\n\n\tmemcpy(gb_cur, lto_tlv, lto_length);\n\tgb_cur += lto_length;\n\n\tmemcpy(gb_cur, wks_tlv, wks_length);\n\tgb_cur += wks_length;\n\n\tmemcpy(gb_cur, miux_tlv, miux_length);\n\tgb_cur += miux_length;\n\n\tlocal->gb_len = gb_len;\n\nout:\n\tkfree(version_tlv);\n\tkfree(lto_tlv);\n\tkfree(wks_tlv);\n\tkfree(miux_tlv);\n\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-12818", "cwe_id": "CWE-476" }, { "id": 2914, "func": "static int stszin(int size)\n{\n int cnt;\n uint32_t ofs;\n\n // version/flags\n u32in();\n // Sample size\n u32in();\n // Number of entries\n mp4config.frame.ents = u32in();\n // fixme: check atom size\n mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)\n * (mp4config.frame.ents + 1));\n\n if (!mp4config.frame.data)\n return ERR_FAIL;\n\n ofs = 0;\n mp4config.frame.data[0] = ofs;\n for (cnt = 0; cnt < mp4config.frame.ents; cnt++)\n {\n uint32_t fsize = u32in();\n\n ofs += fsize;\n if (mp4config.frame.maxsize < fsize)\n mp4config.frame.maxsize = fsize;\n\n mp4config.frame.data[cnt + 1] = ofs;\n\n if (ofs < mp4config.frame.data[cnt])\n return ERR_FAIL;\n }\n\n return size;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32272", "cwe_id": "CWE-787" }, { "id": 2914, "func": "static int stszin(int size)\n{\n int cnt;\n uint32_t ofs;\n\n // version/flags\n u32in();\n // Sample size\n u32in();\n // Number of entries\n mp4config.frame.ents = u32in();\n\n if (!(mp4config.frame.ents + 1))\n return ERR_FAIL;\n\n mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)\n * (mp4config.frame.ents + 1));\n\n if (!mp4config.frame.data)\n return ERR_FAIL;\n\n ofs = 0;\n mp4config.frame.data[0] = ofs;\n for (cnt = 0; cnt < mp4config.frame.ents; cnt++)\n {\n uint32_t fsize = u32in();\n\n ofs += fsize;\n if (mp4config.frame.maxsize < fsize)\n mp4config.frame.maxsize = fsize;\n\n mp4config.frame.data[cnt + 1] = ofs;\n\n if (ofs < mp4config.frame.data[cnt])\n return ERR_FAIL;\n }\n\n return size;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32272", "cwe_id": "CWE-787" }, { "id": 858, "func": "int pgx_validate(jas_stream_t *in)\n{\n\tuchar buf[PGX_MAGICLEN];\n\tuint_fast32_t magic;\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= PGX_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, PGX_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Did we read enough data? */\n\tif (n < PGX_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\t/* Compute the signature value. */\n\tmagic = (buf[0] << 8) | buf[1];\n\n\t/* Ensure that the signature is correct for this format. */\n\tif (magic != PGX_MAGIC) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 858, "func": "int pgx_validate(jas_stream_t *in)\n{\n\tjas_uchar buf[PGX_MAGICLEN];\n\tuint_fast32_t magic;\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= PGX_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, PGX_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Did we read enough data? */\n\tif (n < PGX_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\t/* Compute the signature value. */\n\tmagic = (buf[0] << 8) | buf[1];\n\n\t/* Ensure that the signature is correct for this format. */\n\tif (magic != PGX_MAGIC) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2007, "func": "key_ref_t keyring_search(key_ref_t keyring,\n\t\t\t struct key_type *type,\n\t\t\t const char *description)\n{\n\tstruct keyring_search_context ctx = {\n\t\t.index_key.type\t\t= type,\n\t\t.index_key.description\t= description,\n\t\t.cred\t\t\t= current_cred(),\n\t\t.match_data.cmp\t\t= type->match,\n\t\t.match_data.raw_data\t= description,\n\t\t.match_data.lookup_type\t= KEYRING_SEARCH_LOOKUP_DIRECT,\n\t\t.flags\t\t\t= KEYRING_SEARCH_DO_STATE_CHECK,\n\t};\n\tkey_ref_t key;\n\tint ret;\n\n\tif (!ctx.match_data.cmp)\n\t\treturn ERR_PTR(-ENOKEY);\n\n\tif (type->match_preparse) {\n\t\tret = type->match_preparse(&ctx.match_data);\n\t\tif (ret < 0)\n\t\t\treturn ERR_PTR(ret);\n\t}\n\n\tkey = keyring_search_aux(keyring, &ctx);\n\n\tif (type->match_free)\n\t\ttype->match_free(&ctx.match_data);\n\treturn key;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-2647", "cwe_id": "CWE-476" }, { "id": 2007, "func": "key_ref_t keyring_search(key_ref_t keyring,\n\t\t\t struct key_type *type,\n\t\t\t const char *description)\n{\n\tstruct keyring_search_context ctx = {\n\t\t.index_key.type\t\t= type,\n\t\t.index_key.description\t= description,\n\t\t.cred\t\t\t= current_cred(),\n\t\t.match_data.cmp\t\t= key_default_cmp,\n\t\t.match_data.raw_data\t= description,\n\t\t.match_data.lookup_type\t= KEYRING_SEARCH_LOOKUP_DIRECT,\n\t\t.flags\t\t\t= KEYRING_SEARCH_DO_STATE_CHECK,\n\t};\n\tkey_ref_t key;\n\tint ret;\n\n\tif (type->match_preparse) {\n\t\tret = type->match_preparse(&ctx.match_data);\n\t\tif (ret < 0)\n\t\t\treturn ERR_PTR(ret);\n\t}\n\n\tkey = keyring_search_aux(keyring, &ctx);\n\n\tif (type->match_free)\n\t\ttype->match_free(&ctx.match_data);\n\treturn key;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-2647", "cwe_id": "CWE-476" }, { "id": 71, "func": "static struct page *follow_page_pte(struct vm_area_struct *vma,\n\t\tunsigned long address, pmd_t *pmd, unsigned int flags)\n{\n\tstruct mm_struct *mm = vma->vm_mm;\n\tstruct dev_pagemap *pgmap = NULL;\n\tstruct page *page;\n\tspinlock_t *ptl;\n\tpte_t *ptep, pte;\n\nretry:\n\tif (unlikely(pmd_bad(*pmd)))\n\t\treturn no_page_table(vma, flags);\n\n\tptep = pte_offset_map_lock(mm, pmd, address, &ptl);\n\tpte = *ptep;\n\tif (!pte_present(pte)) {\n\t\tswp_entry_t entry;\n\t\t/*\n\t\t * KSM's break_ksm() relies upon recognizing a ksm page\n\t\t * even while it is being migrated, so for that case we\n\t\t * need migration_entry_wait().\n\t\t */\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\tgoto no_page;\n\t\tif (pte_none(pte))\n\t\t\tgoto no_page;\n\t\tentry = pte_to_swp_entry(pte);\n\t\tif (!is_migration_entry(entry))\n\t\t\tgoto no_page;\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\tmigration_entry_wait(mm, pmd, address);\n\t\tgoto retry;\n\t}\n\tif ((flags & FOLL_NUMA) && pte_protnone(pte))\n\t\tgoto no_page;\n\tif ((flags & FOLL_WRITE) && !pte_write(pte)) {\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\treturn NULL;\n\t}\n\n\tpage = vm_normal_page(vma, address, pte);\n\tif (!page && pte_devmap(pte) && (flags & FOLL_GET)) {\n\t\t/*\n\t\t * Only return device mapping pages in the FOLL_GET case since\n\t\t * they are only valid while holding the pgmap reference.\n\t\t */\n\t\tpgmap = get_dev_pagemap(pte_pfn(pte), NULL);\n\t\tif (pgmap)\n\t\t\tpage = pte_page(pte);\n\t\telse\n\t\t\tgoto no_page;\n\t} else if (unlikely(!page)) {\n\t\tif (flags & FOLL_DUMP) {\n\t\t\t/* Avoid special (like zero) pages in core dumps */\n\t\t\tpage = ERR_PTR(-EFAULT);\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (is_zero_pfn(pte_pfn(pte))) {\n\t\t\tpage = pte_page(pte);\n\t\t} else {\n\t\t\tint ret;\n\n\t\t\tret = follow_pfn_pte(vma, address, ptep, flags);\n\t\t\tpage = ERR_PTR(ret);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tif (flags & FOLL_SPLIT && PageTransCompound(page)) {\n\t\tint ret;\n\t\tget_page(page);\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\tlock_page(page);\n\t\tret = split_huge_page(page);\n\t\tunlock_page(page);\n\t\tput_page(page);\n\t\tif (ret)\n\t\t\treturn ERR_PTR(ret);\n\t\tgoto retry;\n\t}\n\n\tif (flags & FOLL_GET) {\n\t\tget_page(page);\n\n\t\t/* drop the pgmap reference now that we hold the page */\n\t\tif (pgmap) {\n\t\t\tput_dev_pagemap(pgmap);\n\t\t\tpgmap = NULL;\n\t\t}\n\t}\n\tif (flags & FOLL_TOUCH) {\n\t\tif ((flags & FOLL_WRITE) &&\n\t\t !pte_dirty(pte) && !PageDirty(page))\n\t\t\tset_page_dirty(page);\n\t\t/*\n\t\t * pte_mkyoung() would be more correct here, but atomic care\n\t\t * is needed to avoid losing the dirty bit: it is easier to use\n\t\t * mark_page_accessed().\n\t\t */\n\t\tmark_page_accessed(page);\n\t}\n\tif ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {\n\t\t/* Do not mlock pte-mapped THP */\n\t\tif (PageTransCompound(page))\n\t\t\tgoto out;\n\n\t\t/*\n\t\t * The preliminary mapping check is mainly to avoid the\n\t\t * pointless overhead of lock_page on the ZERO_PAGE\n\t\t * which might bounce very badly if there is contention.\n\t\t *\n\t\t * If the page is already locked, we don't need to\n\t\t * handle it now - vmscan will handle it later if and\n\t\t * when it attempts to reclaim the page.\n\t\t */\n\t\tif (page->mapping && trylock_page(page)) {\n\t\t\tlru_add_drain(); /* push cached pages to LRU */\n\t\t\t/*\n\t\t\t * Because we lock page here, and migration is\n\t\t\t * blocked by the pte's page reference, and we\n\t\t\t * know the page is still mapped, we don't even\n\t\t\t * need to check for file-cache page truncation.\n\t\t\t */\n\t\t\tmlock_vma_page(page);\n\t\t\tunlock_page(page);\n\t\t}\n\t}\nout:\n\tpte_unmap_unlock(ptep, ptl);\n\treturn page;\nno_page:\n\tpte_unmap_unlock(ptep, ptl);\n\tif (!pte_none(pte))\n\t\treturn NULL;\n\treturn no_page_table(vma, flags);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5195", "cwe_id": "CWE-362" }, { "id": 71, "func": "static struct page *follow_page_pte(struct vm_area_struct *vma,\n\t\tunsigned long address, pmd_t *pmd, unsigned int flags)\n{\n\tstruct mm_struct *mm = vma->vm_mm;\n\tstruct dev_pagemap *pgmap = NULL;\n\tstruct page *page;\n\tspinlock_t *ptl;\n\tpte_t *ptep, pte;\n\nretry:\n\tif (unlikely(pmd_bad(*pmd)))\n\t\treturn no_page_table(vma, flags);\n\n\tptep = pte_offset_map_lock(mm, pmd, address, &ptl);\n\tpte = *ptep;\n\tif (!pte_present(pte)) {\n\t\tswp_entry_t entry;\n\t\t/*\n\t\t * KSM's break_ksm() relies upon recognizing a ksm page\n\t\t * even while it is being migrated, so for that case we\n\t\t * need migration_entry_wait().\n\t\t */\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\tgoto no_page;\n\t\tif (pte_none(pte))\n\t\t\tgoto no_page;\n\t\tentry = pte_to_swp_entry(pte);\n\t\tif (!is_migration_entry(entry))\n\t\t\tgoto no_page;\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\tmigration_entry_wait(mm, pmd, address);\n\t\tgoto retry;\n\t}\n\tif ((flags & FOLL_NUMA) && pte_protnone(pte))\n\t\tgoto no_page;\n\tif ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) {\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\treturn NULL;\n\t}\n\n\tpage = vm_normal_page(vma, address, pte);\n\tif (!page && pte_devmap(pte) && (flags & FOLL_GET)) {\n\t\t/*\n\t\t * Only return device mapping pages in the FOLL_GET case since\n\t\t * they are only valid while holding the pgmap reference.\n\t\t */\n\t\tpgmap = get_dev_pagemap(pte_pfn(pte), NULL);\n\t\tif (pgmap)\n\t\t\tpage = pte_page(pte);\n\t\telse\n\t\t\tgoto no_page;\n\t} else if (unlikely(!page)) {\n\t\tif (flags & FOLL_DUMP) {\n\t\t\t/* Avoid special (like zero) pages in core dumps */\n\t\t\tpage = ERR_PTR(-EFAULT);\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (is_zero_pfn(pte_pfn(pte))) {\n\t\t\tpage = pte_page(pte);\n\t\t} else {\n\t\t\tint ret;\n\n\t\t\tret = follow_pfn_pte(vma, address, ptep, flags);\n\t\t\tpage = ERR_PTR(ret);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tif (flags & FOLL_SPLIT && PageTransCompound(page)) {\n\t\tint ret;\n\t\tget_page(page);\n\t\tpte_unmap_unlock(ptep, ptl);\n\t\tlock_page(page);\n\t\tret = split_huge_page(page);\n\t\tunlock_page(page);\n\t\tput_page(page);\n\t\tif (ret)\n\t\t\treturn ERR_PTR(ret);\n\t\tgoto retry;\n\t}\n\n\tif (flags & FOLL_GET) {\n\t\tget_page(page);\n\n\t\t/* drop the pgmap reference now that we hold the page */\n\t\tif (pgmap) {\n\t\t\tput_dev_pagemap(pgmap);\n\t\t\tpgmap = NULL;\n\t\t}\n\t}\n\tif (flags & FOLL_TOUCH) {\n\t\tif ((flags & FOLL_WRITE) &&\n\t\t !pte_dirty(pte) && !PageDirty(page))\n\t\t\tset_page_dirty(page);\n\t\t/*\n\t\t * pte_mkyoung() would be more correct here, but atomic care\n\t\t * is needed to avoid losing the dirty bit: it is easier to use\n\t\t * mark_page_accessed().\n\t\t */\n\t\tmark_page_accessed(page);\n\t}\n\tif ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {\n\t\t/* Do not mlock pte-mapped THP */\n\t\tif (PageTransCompound(page))\n\t\t\tgoto out;\n\n\t\t/*\n\t\t * The preliminary mapping check is mainly to avoid the\n\t\t * pointless overhead of lock_page on the ZERO_PAGE\n\t\t * which might bounce very badly if there is contention.\n\t\t *\n\t\t * If the page is already locked, we don't need to\n\t\t * handle it now - vmscan will handle it later if and\n\t\t * when it attempts to reclaim the page.\n\t\t */\n\t\tif (page->mapping && trylock_page(page)) {\n\t\t\tlru_add_drain(); /* push cached pages to LRU */\n\t\t\t/*\n\t\t\t * Because we lock page here, and migration is\n\t\t\t * blocked by the pte's page reference, and we\n\t\t\t * know the page is still mapped, we don't even\n\t\t\t * need to check for file-cache page truncation.\n\t\t\t */\n\t\t\tmlock_vma_page(page);\n\t\t\tunlock_page(page);\n\t\t}\n\t}\nout:\n\tpte_unmap_unlock(ptep, ptl);\n\treturn page;\nno_page:\n\tpte_unmap_unlock(ptep, ptl);\n\tif (!pte_none(pte))\n\t\treturn NULL;\n\treturn no_page_table(vma, flags);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5195", "cwe_id": "CWE-362" }, { "id": 2421, "func": "TfLiteStatus HardSwishEval(TfLiteContext* context, TfLiteNode* node) {\n HardSwishData* data = static_cast(node->user_data);\n\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n HardSwishParams& params = data->params;\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n HardSwishParams& params = data->params;\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(\n context,\n \"Only float32, uint8 and int8 are supported currently, got %s.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2421, "func": "TfLiteStatus HardSwishEval(TfLiteContext* context, TfLiteNode* node) {\n HardSwishData* data = static_cast(node->user_data);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n HardSwishParams& params = data->params;\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n HardSwishParams& params = data->params;\n if (kernel_type == kReference) {\n reference_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::HardSwish(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(\n context,\n \"Only float32, uint8 and int8 are supported currently, got %s.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2590, "func": "GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const GF_SLConfig *slConfig)\n{\n\tGF_TrackBox *trak;\n\tGF_SampleEntryBox *entry;\n\tGF_Err e;\n\tGF_SLConfig **slc;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\te = Media_GetSampleDesc(trak->Media, StreamDescriptionIndex, &entry, NULL);\n\tif (e) return e;\n\n\t//we must be sure we are not using a remote ESD\n\tswitch (entry->type) {\n\tcase GF_ISOM_BOX_TYPE_MP4S:\n\t\tif (((GF_MPEGSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;\n\t\tslc = & ((GF_MPEGSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MP4A:\n\t\tif (((GF_MPEGAudioSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;\n\t\tslc = & ((GF_MPEGAudioSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MP4V:\n\t\tif (((GF_MPEGVisualSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;\n\t\tslc = & ((GF_MPEGVisualSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tdefault:\n\t\treturn GF_BAD_PARAM;\n\t}\n\n\tif (*slc) {\n\t\tgf_odf_desc_del((GF_Descriptor *)*slc);\n\t\t*slc = NULL;\n\t}\n\tif (!slConfig) return GF_OK;\n\t//finally duplicate the SL\n\treturn gf_odf_desc_copy((GF_Descriptor *) slConfig, (GF_Descriptor **) slc);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-31258", "cwe_id": "CWE-476" }, { "id": 2590, "func": "GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const GF_SLConfig *slConfig)\n{\n\tGF_TrackBox *trak;\n\tGF_SampleEntryBox *entry;\n\tGF_Err e;\n\tGF_SLConfig **slc;\n\tGF_ESDBox *esds;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\te = Media_GetSampleDesc(trak->Media, StreamDescriptionIndex, &entry, NULL);\n\tif (e) return e;\n\n\t//we must be sure we are not using a remote ESD\n\tswitch (entry->type) {\n\tcase GF_ISOM_BOX_TYPE_MP4S:\n\t\tesds = ((GF_MPEGSampleEntryBox *)entry)->esd;\n\t\tif (!esds || !esds->desc || !esds->desc->slConfig || (esds->desc->slConfig->predefined != SLPredef_MP4))\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\tslc = & ((GF_MPEGSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MP4A:\n\t\tesds = ((GF_MPEGAudioSampleEntryBox *)entry)->esd;\n\t\tif (!esds || !esds->desc || !esds->desc->slConfig || (esds->desc->slConfig->predefined != SLPredef_MP4))\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\tslc = & ((GF_MPEGAudioSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MP4V:\n\t\tesds = ((GF_MPEGVisualSampleEntryBox *)entry)->esd;\n\t\tif (!esds || !esds->desc || !esds->desc->slConfig || (esds->desc->slConfig->predefined != SLPredef_MP4))\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\tslc = & ((GF_MPEGVisualSampleEntryBox *)entry)->slc;\n\t\tbreak;\n\tdefault:\n\t\treturn GF_BAD_PARAM;\n\t}\n\n\tif (*slc) {\n\t\tgf_odf_desc_del((GF_Descriptor *)*slc);\n\t\t*slc = NULL;\n\t}\n\tif (!slConfig) return GF_OK;\n\t//finally duplicate the SL\n\treturn gf_odf_desc_copy((GF_Descriptor *) slConfig, (GF_Descriptor **) slc);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-31258", "cwe_id": "CWE-476" }, { "id": 1037, "func": "void Transform::interpolate_nearestneighbour( RawTile& in, unsigned int resampled_width, unsigned int resampled_height ){\n\n // Pointer to input buffer\n unsigned char *input = (unsigned char*) in.data;\n\n int channels = in.channels;\n unsigned int width = in.width;\n unsigned int height = in.height;\n\n // Pointer to output buffer\n unsigned char *output;\n\n // Create new buffer if size is larger than input size\n bool new_buffer = false;\n if( resampled_width*resampled_height > in.width*in.height ){\n new_buffer = true;\n output = new unsigned char[(unsigned long long)resampled_width*resampled_height*in.channels];\n }\n else output = (unsigned char*) in.data;\n\n // Calculate our scale\n float xscale = (float)width / (float)resampled_width;\n float yscale = (float)height / (float)resampled_height;\n\n for( unsigned int j=0; j in.width*in.height ){\n new_buffer = true;\n output = new unsigned char[(unsigned long long)resampled_width*resampled_height*in.channels];\n }\n else output = (unsigned char*) in.data;\n\n // Calculate our scale\n float xscale = (float)width / (float)resampled_width;\n float yscale = (float)height / (float)resampled_height;\n\n for( unsigned int j=0; j SpecializeType(const AttrSlice& attrs,\n const OpDef& op_def) {\n FullTypeDef ft;\n ft.set_type_id(TFT_PRODUCT);\n\n for (int i = 0; i < op_def.output_arg_size(); i++) {\n auto* t = ft.add_args();\n\n *t = op_def.output_arg(i).experimental_full_type();\n\n // Resolve dependent types. The convention for op registrations is to use\n // attributes as type variables.\n // See https://www.tensorflow.org/guide/create_op#type_polymorphism.\n // Once the op signature can be defined entirely in FullType, this\n // convention can be deprecated.\n //\n // Note: While this code performs some basic verifications, it generally\n // assumes consistent op defs and attributes. If more complete\n // verifications are needed, they should be done by separately, and in a\n // way that can be reused for type inference.\n for (int j = 0; j < t->args_size(); j++) {\n auto* arg = t->mutable_args(i);\n if (arg->type_id() == TFT_VAR) {\n const auto* attr = attrs.Find(arg->s());\n if (attr == nullptr) {\n return Status(\n error::INVALID_ARGUMENT,\n absl::StrCat(\"Could not find an attribute for key \", arg->s()));\n }\n if (attr->value_case() == AttrValue::kList) {\n const auto& attr_list = attr->list();\n arg->set_type_id(TFT_PRODUCT);\n for (int i = 0; i < attr_list.type_size(); i++) {\n map_dtype_to_tensor(attr_list.type(i), arg->add_args());\n }\n\n } else if (attr->value_case() == AttrValue::kType) {\n map_dtype_to_tensor(attr->type(), arg);\n\n } else {\n return Status(error::UNIMPLEMENTED,\n absl::StrCat(\"unknown attribute type\",\n attrs.DebugString(), \" key=\", arg->s()));\n }\n\n arg->clear_s();\n }\n }\n }\n\n return ft;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-23574", "cwe_id": "CWE-125" }, { "id": 2131, "func": "StatusOr SpecializeType(const AttrSlice& attrs,\n const OpDef& op_def) {\n FullTypeDef ft;\n ft.set_type_id(TFT_PRODUCT);\n\n for (int i = 0; i < op_def.output_arg_size(); i++) {\n auto* t = ft.add_args();\n\n *t = op_def.output_arg(i).experimental_full_type();\n\n // Resolve dependent types. The convention for op registrations is to use\n // attributes as type variables.\n // See https://www.tensorflow.org/guide/create_op#type_polymorphism.\n // Once the op signature can be defined entirely in FullType, this\n // convention can be deprecated.\n //\n // Note: While this code performs some basic verifications, it generally\n // assumes consistent op defs and attributes. If more complete\n // verifications are needed, they should be done by separately, and in a\n // way that can be reused for type inference.\n for (int j = 0; j < t->args_size(); j++) {\n auto* arg = t->mutable_args(j);\n if (arg->type_id() == TFT_VAR) {\n const auto* attr = attrs.Find(arg->s());\n if (attr == nullptr) {\n return Status(\n error::INVALID_ARGUMENT,\n absl::StrCat(\"Could not find an attribute for key \", arg->s()));\n }\n if (attr->value_case() == AttrValue::kList) {\n const auto& attr_list = attr->list();\n arg->set_type_id(TFT_PRODUCT);\n for (int i = 0; i < attr_list.type_size(); i++) {\n map_dtype_to_tensor(attr_list.type(i), arg->add_args());\n }\n\n } else if (attr->value_case() == AttrValue::kType) {\n map_dtype_to_tensor(attr->type(), arg);\n\n } else {\n return Status(error::UNIMPLEMENTED,\n absl::StrCat(\"unknown attribute type\",\n attrs.DebugString(), \" key=\", arg->s()));\n }\n\n arg->clear_s();\n }\n }\n }\n\n return ft;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-23574", "cwe_id": "CWE-125" }, { "id": 416, "func": "set_curbuf(buf_T *buf, int action)\n{\n buf_T\t*prevbuf;\n int\t\tunload = (action == DOBUF_UNLOAD || action == DOBUF_DEL\n\t\t\t|| action == DOBUF_WIPE || action == DOBUF_WIPE_REUSE);\n#ifdef FEAT_SYN_HL\n long\told_tw = curbuf->b_p_tw;\n#endif\n bufref_T\tnewbufref;\n bufref_T\tprevbufref;\n\n setpcmark();\n if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)\n\tcurwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file\n buflist_altfpos(curwin);\t\t\t // remember curpos\n\n // Don't restart Select mode after switching to another buffer.\n VIsual_reselect = FALSE;\n\n // close_windows() or apply_autocmds() may change curbuf and wipe out \"buf\"\n prevbuf = curbuf;\n set_bufref(&prevbufref, prevbuf);\n set_bufref(&newbufref, buf);\n\n // Autocommands may delete the current buffer and/or the buffer we want to\n // go to. In those cases don't close the buffer.\n if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)\n\t || (bufref_valid(&prevbufref)\n\t\t&& bufref_valid(&newbufref)\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t ))\n {\n#ifdef FEAT_SYN_HL\n\tif (prevbuf == curwin->w_buffer)\n\t reset_synblock(curwin);\n#endif\n\tif (unload)\n\t close_windows(prevbuf, FALSE);\n#if defined(FEAT_EVAL)\n\tif (bufref_valid(&prevbufref) && !aborting())\n#else\n\tif (bufref_valid(&prevbufref))\n#endif\n\t{\n\t win_T *previouswin = curwin;\n\n\t // Do not sync when in Insert mode and the buffer is open in\n\t // another window, might be a timer doing something in another\n\t // window.\n\t if (prevbuf == curbuf\n\t\t\t && ((State & INSERT) == 0 || curbuf->b_nwindows <= 1))\n\t\tu_sync(FALSE);\n\t close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,\n\t\t unload ? action : (action == DOBUF_GOTO\n\t\t\t&& !buf_hide(prevbuf)\n\t\t\t&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0,\n\t\t FALSE, FALSE);\n\t if (curwin != previouswin && win_valid(previouswin))\n\t // autocommands changed curwin, Grr!\n\t curwin = previouswin;\n\t}\n }\n // An autocommand may have deleted \"buf\", already entered it (e.g., when\n // it did \":bunload\") or aborted the script processing.\n // If curwin->w_buffer is null, enter_buffer() will make it valid again\n if ((buf_valid(buf) && buf != curbuf\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t) || curwin->w_buffer == NULL)\n {\n\tenter_buffer(buf);\n#ifdef FEAT_SYN_HL\n\tif (old_tw != curbuf->b_p_tw)\n\t check_colorcolumn(curwin);\n#endif\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0443", "cwe_id": "CWE-416" }, { "id": 416, "func": "set_curbuf(buf_T *buf, int action)\n{\n buf_T\t*prevbuf;\n int\t\tunload = (action == DOBUF_UNLOAD || action == DOBUF_DEL\n\t\t\t|| action == DOBUF_WIPE || action == DOBUF_WIPE_REUSE);\n#ifdef FEAT_SYN_HL\n long\told_tw = curbuf->b_p_tw;\n#endif\n bufref_T\tnewbufref;\n bufref_T\tprevbufref;\n int\t\tvalid;\n\n setpcmark();\n if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)\n\tcurwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file\n buflist_altfpos(curwin);\t\t\t // remember curpos\n\n // Don't restart Select mode after switching to another buffer.\n VIsual_reselect = FALSE;\n\n // close_windows() or apply_autocmds() may change curbuf and wipe out \"buf\"\n prevbuf = curbuf;\n set_bufref(&prevbufref, prevbuf);\n set_bufref(&newbufref, buf);\n\n // Autocommands may delete the current buffer and/or the buffer we want to\n // go to. In those cases don't close the buffer.\n if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)\n\t || (bufref_valid(&prevbufref)\n\t\t&& bufref_valid(&newbufref)\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t ))\n {\n#ifdef FEAT_SYN_HL\n\tif (prevbuf == curwin->w_buffer)\n\t reset_synblock(curwin);\n#endif\n\tif (unload)\n\t close_windows(prevbuf, FALSE);\n#if defined(FEAT_EVAL)\n\tif (bufref_valid(&prevbufref) && !aborting())\n#else\n\tif (bufref_valid(&prevbufref))\n#endif\n\t{\n\t win_T *previouswin = curwin;\n\n\t // Do not sync when in Insert mode and the buffer is open in\n\t // another window, might be a timer doing something in another\n\t // window.\n\t if (prevbuf == curbuf\n\t\t\t && ((State & INSERT) == 0 || curbuf->b_nwindows <= 1))\n\t\tu_sync(FALSE);\n\t close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,\n\t\t unload ? action : (action == DOBUF_GOTO\n\t\t\t&& !buf_hide(prevbuf)\n\t\t\t&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0,\n\t\t FALSE, FALSE);\n\t if (curwin != previouswin && win_valid(previouswin))\n\t // autocommands changed curwin, Grr!\n\t curwin = previouswin;\n\t}\n }\n // An autocommand may have deleted \"buf\", already entered it (e.g., when\n // it did \":bunload\") or aborted the script processing.\n // If curwin->w_buffer is null, enter_buffer() will make it valid again\n valid = buf_valid(buf);\n if ((valid && buf != curbuf\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t) || curwin->w_buffer == NULL)\n {\n\t// If the buffer is not valid but curwin->w_buffer is NULL we must\n\t// enter some buffer. Using the last one is hopefully OK.\n\tif (!valid)\n\t enter_buffer(lastbuf);\n\telse\n\t enter_buffer(buf);\n#ifdef FEAT_SYN_HL\n\tif (old_tw != curbuf->b_p_tw)\n\t check_colorcolumn(curwin);\n#endif\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0443", "cwe_id": "CWE-416" }, { "id": 3172, "func": "vips_foreign_load_gif_scan_image( VipsForeignLoadGif *gif ) \n{\n\tVipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif );\n\tGifFileType *file = gif->file;\n\tColorMapObject *map = file->Image.ColorMap ?\n\t\tfile->Image.ColorMap : file->SColorMap;\n\n\tGifByteType *extension;\n\n\tif( DGifGetImageDesc( gif->file ) == GIF_ERROR ) {\n\t\tvips_foreign_load_gif_error( gif ); \n\t\treturn( -1 );\n\t}\n\n\t/* Check that the frame looks sane. Perhaps giflib checks\n\t * this for us.\n\t */\n\tif( file->Image.Left < 0 ||\n\t\tfile->Image.Width < 1 ||\n\t\tfile->Image.Width > 10000 ||\n\t\tfile->Image.Left + file->Image.Width > file->SWidth ||\n\t\tfile->Image.Top < 0 ||\n\t\tfile->Image.Height < 1 ||\n\t\tfile->Image.Height > 10000 ||\n\t\tfile->Image.Top + file->Image.Height > file->SHeight ) {\n\t\tvips_error( class->nickname, \"%s\", _( \"bad frame size\" ) ); \n\t\treturn( -1 ); \n\t}\n\n\t/* Test for a non-greyscale colourmap for this frame.\n\t */\n\tif( !gif->has_colour &&\n\t\tmap ) {\n\t\tint i;\n\n\t\tfor( i = 0; i < map->ColorCount; i++ ) \n\t\t\tif( map->Colors[i].Red != map->Colors[i].Green ||\n\t\t\t\tmap->Colors[i].Green != map->Colors[i].Blue ) {\n\t\t\t\tgif->has_colour = TRUE;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\n\t/* Step over compressed image data.\n\t */\n\tdo {\n\t\tif( vips_foreign_load_gif_code_next( gif, &extension ) ) \n\t\t\treturn( -1 );\n\t} while( extension != NULL );\n\n\treturn( 0 );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-17534", "cwe_id": "CWE-416" }, { "id": 3172, "func": "vips_foreign_load_gif_scan_image( VipsForeignLoadGif *gif ) \n{\n\tVipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif );\n\tGifFileType *file = gif->file;\n\n\tColorMapObject *map;\n\tGifByteType *extension;\n\n\tif( DGifGetImageDesc( gif->file ) == GIF_ERROR ) {\n\t\tvips_foreign_load_gif_error( gif ); \n\t\treturn( -1 );\n\t}\n\n\t/* Check that the frame looks sane. Perhaps giflib checks\n\t * this for us.\n\t */\n\tif( file->Image.Left < 0 ||\n\t\tfile->Image.Width < 1 ||\n\t\tfile->Image.Width > 10000 ||\n\t\tfile->Image.Left + file->Image.Width > file->SWidth ||\n\t\tfile->Image.Top < 0 ||\n\t\tfile->Image.Height < 1 ||\n\t\tfile->Image.Height > 10000 ||\n\t\tfile->Image.Top + file->Image.Height > file->SHeight ) {\n\t\tvips_error( class->nickname, \"%s\", _( \"bad frame size\" ) ); \n\t\treturn( -1 ); \n\t}\n\n\t/* Test for a non-greyscale colourmap for this frame.\n\t */\n\tmap = file->Image.ColorMap ? file->Image.ColorMap : file->SColorMap;\n\tif( !gif->has_colour &&\n\t\tmap ) {\n\t\tint i;\n\n\t\tfor( i = 0; i < map->ColorCount; i++ ) \n\t\t\tif( map->Colors[i].Red != map->Colors[i].Green ||\n\t\t\t\tmap->Colors[i].Green != map->Colors[i].Blue ) {\n\t\t\t\tgif->has_colour = TRUE;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\n\t/* Step over compressed image data.\n\t */\n\tdo {\n\t\tif( vips_foreign_load_gif_code_next( gif, &extension ) ) \n\t\t\treturn( -1 );\n\t} while( extension != NULL );\n\n\treturn( 0 );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-17534", "cwe_id": "CWE-416" }, { "id": 3002, "func": "ecma_op_internal_buffer_append (ecma_collection_t *container_p, /**< internal container pointer */\n ecma_value_t key_arg, /**< key argument */\n ecma_value_t value_arg, /**< value argument */\n lit_magic_string_id_t lit_id) /**< class id */\n{\n JERRY_ASSERT (container_p != NULL);\n\n ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (key_arg));\n\n if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_MAP_UL)\n {\n ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (value_arg));\n }\n\n ECMA_CONTAINER_SET_SIZE (container_p, ECMA_CONTAINER_GET_SIZE (container_p) + 1);\n} /* ecma_op_internal_buffer_append */", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-14163", "cwe_id": "CWE-125" }, { "id": 3002, "func": "ecma_op_internal_buffer_append (ecma_collection_t *container_p, /**< internal container pointer */\n ecma_value_t key_arg, /**< key argument */\n ecma_value_t value_arg, /**< value argument */\n lit_magic_string_id_t lit_id) /**< class id */\n{\n JERRY_ASSERT (container_p != NULL);\n\n if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_MAP_UL)\n {\n ecma_value_t values[] = { ecma_copy_value_if_not_object (key_arg), ecma_copy_value_if_not_object (value_arg) };\n ecma_collection_append (container_p, values, 2);\n }\n else\n {\n ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (key_arg));\n }\n\n ECMA_CONTAINER_SET_SIZE (container_p, ECMA_CONTAINER_GET_SIZE (container_p) + 1);\n} /* ecma_op_internal_buffer_append */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-14163", "cwe_id": "CWE-125" }, { "id": 1807, "func": "fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,\n expr_ty *expression, struct compiling *c, const node *n)\n{\n /* Return -1 on error, else 0. */\n\n const char *expr_start;\n const char *expr_end;\n expr_ty simple_expression;\n expr_ty format_spec = NULL; /* Optional format specifier. */\n int conversion = -1; /* The conversion char. -1 if not specified. */\n\n /* 0 if we're not in a string, else the quote char we're trying to\n match (single or double quote). */\n char quote_char = 0;\n\n /* If we're inside a string, 1=normal, 3=triple-quoted. */\n int string_type = 0;\n\n /* Keep track of nesting level for braces/parens/brackets in\n expressions. */\n Py_ssize_t nested_depth = 0;\n char parenstack[MAXLEVEL];\n\n /* Can only nest one level deep. */\n if (recurse_lvl >= 2) {\n ast_error(c, n, \"f-string: expressions nested too deeply\");\n return -1;\n }\n\n /* The first char must be a left brace, or we wouldn't have gotten\n here. Skip over it. */\n assert(**str == '{');\n *str += 1;\n\n expr_start = *str;\n for (; *str < end; (*str)++) {\n char ch;\n\n /* Loop invariants. */\n assert(nested_depth >= 0);\n assert(*str >= expr_start && *str < end);\n if (quote_char)\n assert(string_type == 1 || string_type == 3);\n else\n assert(string_type == 0);\n\n ch = **str;\n /* Nowhere inside an expression is a backslash allowed. */\n if (ch == '\\\\') {\n /* Error: can't include a backslash character, inside\n parens or strings or not. */\n ast_error(c, n, \"f-string expression part \"\n \"cannot include a backslash\");\n return -1;\n }\n if (quote_char) {\n /* We're inside a string. See if we're at the end. */\n /* This code needs to implement the same non-error logic\n as tok_get from tokenizer.c, at the letter_quote\n label. To actually share that code would be a\n nightmare. But, it's unlikely to change and is small,\n so duplicate it here. Note we don't need to catch all\n of the errors, since they'll be caught when parsing the\n expression. We just need to match the non-error\n cases. Thus we can ignore \\n in single-quoted strings,\n for example. Or non-terminated strings. */\n if (ch == quote_char) {\n /* Does this match the string_type (single or triple\n quoted)? */\n if (string_type == 3) {\n if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {\n /* We're at the end of a triple quoted string. */\n *str += 2;\n string_type = 0;\n quote_char = 0;\n continue;\n }\n } else {\n /* We're at the end of a normal string. */\n quote_char = 0;\n string_type = 0;\n continue;\n }\n }\n } else if (ch == '\\'' || ch == '\"') {\n /* Is this a triple quoted string? */\n if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {\n string_type = 3;\n *str += 2;\n } else {\n /* Start of a normal string. */\n string_type = 1;\n }\n /* Start looking for the end of the string. */\n quote_char = ch;\n } else if (ch == '[' || ch == '{' || ch == '(') {\n if (nested_depth >= MAXLEVEL) {\n ast_error(c, n, \"f-string: too many nested parenthesis\");\n return -1;\n }\n parenstack[nested_depth] = ch;\n nested_depth++;\n } else if (ch == '#') {\n /* Error: can't include a comment character, inside parens\n or not. */\n ast_error(c, n, \"f-string expression part cannot include '#'\");\n return -1;\n } else if (nested_depth == 0 &&\n (ch == '!' || ch == ':' || ch == '}')) {\n /* First, test for the special case of \"!=\". Since '=' is\n not an allowed conversion character, nothing is lost in\n this test. */\n if (ch == '!' && *str+1 < end && *(*str+1) == '=') {\n /* This isn't a conversion character, just continue. */\n continue;\n }\n /* Normal way out of this loop. */\n break;\n } else if (ch == ']' || ch == '}' || ch == ')') {\n if (!nested_depth) {\n ast_error(c, n, \"f-string: unmatched '%c'\", ch);\n return -1;\n }\n nested_depth--;\n int opening = parenstack[nested_depth];\n if (!((opening == '(' && ch == ')') ||\n (opening == '[' && ch == ']') ||\n (opening == '{' && ch == '}')))\n {\n ast_error(c, n,\n \"f-string: closing parenthesis '%c' \"\n \"does not match opening parenthesis '%c'\",\n ch, opening);\n return -1;\n }\n } else {\n /* Just consume this char and loop around. */\n }\n }\n expr_end = *str;\n /* If we leave this loop in a string or with mismatched parens, we\n don't care. We'll get a syntax error when compiling the\n expression. But, we can produce a better error message, so\n let's just do that.*/\n if (quote_char) {\n ast_error(c, n, \"f-string: unterminated string\");\n return -1;\n }\n if (nested_depth) {\n int opening = parenstack[nested_depth - 1];\n ast_error(c, n, \"f-string: unmatched '%c'\", opening);\n return -1;\n }\n\n if (*str >= end)\n goto unexpected_end_of_string;\n\n /* Compile the expression as soon as possible, so we show errors\n related to the expression before errors related to the\n conversion or format_spec. */\n simple_expression = fstring_compile_expr(expr_start, expr_end, c, n);\n if (!simple_expression)\n return -1;\n\n /* Check for a conversion char, if present. */\n if (**str == '!') {\n *str += 1;\n if (*str >= end)\n goto unexpected_end_of_string;\n\n conversion = **str;\n *str += 1;\n\n /* Validate the conversion. */\n if (!(conversion == 's' || conversion == 'r'\n || conversion == 'a')) {\n ast_error(c, n, \"f-string: invalid conversion character: \"\n \"expected 's', 'r', or 'a'\");\n return -1;\n }\n }\n\n /* Check for the format spec, if present. */\n if (*str >= end)\n goto unexpected_end_of_string;\n if (**str == ':') {\n *str += 1;\n if (*str >= end)\n goto unexpected_end_of_string;\n\n /* Parse the format spec. */\n format_spec = fstring_parse(str, end, raw, recurse_lvl+1, c, n);\n if (!format_spec)\n return -1;\n }\n\n if (*str >= end || **str != '}')\n goto unexpected_end_of_string;\n\n /* We're at a right brace. Consume it. */\n assert(*str < end);\n assert(**str == '}');\n *str += 1;\n\n /* And now create the FormattedValue node that represents this\n entire expression with the conversion and format spec. */\n *expression = FormattedValue(simple_expression, conversion,\n format_spec, LINENO(n), n->n_col_offset,\n n->n_end_lineno, n->n_end_col_offset,\n c->c_arena);\n if (!*expression)\n return -1;\n\n return 0;\n\nunexpected_end_of_string:\n ast_error(c, n, \"f-string: expecting '}'\");\n return -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1807, "func": "fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,\n expr_ty *expression, struct compiling *c, const node *n)\n{\n /* Return -1 on error, else 0. */\n\n const char *expr_start;\n const char *expr_end;\n expr_ty simple_expression;\n expr_ty format_spec = NULL; /* Optional format specifier. */\n int conversion = -1; /* The conversion char. -1 if not specified. */\n\n /* 0 if we're not in a string, else the quote char we're trying to\n match (single or double quote). */\n char quote_char = 0;\n\n /* If we're inside a string, 1=normal, 3=triple-quoted. */\n int string_type = 0;\n\n /* Keep track of nesting level for braces/parens/brackets in\n expressions. */\n Py_ssize_t nested_depth = 0;\n char parenstack[MAXLEVEL];\n\n /* Can only nest one level deep. */\n if (recurse_lvl >= 2) {\n ast_error(c, n, \"f-string: expressions nested too deeply\");\n return -1;\n }\n\n /* The first char must be a left brace, or we wouldn't have gotten\n here. Skip over it. */\n assert(**str == '{');\n *str += 1;\n\n expr_start = *str;\n for (; *str < end; (*str)++) {\n char ch;\n\n /* Loop invariants. */\n assert(nested_depth >= 0);\n assert(*str >= expr_start && *str < end);\n if (quote_char)\n assert(string_type == 1 || string_type == 3);\n else\n assert(string_type == 0);\n\n ch = **str;\n /* Nowhere inside an expression is a backslash allowed. */\n if (ch == '\\\\') {\n /* Error: can't include a backslash character, inside\n parens or strings or not. */\n ast_error(c, n,\n \"f-string expression part \"\n \"cannot include a backslash\");\n return -1;\n }\n if (quote_char) {\n /* We're inside a string. See if we're at the end. */\n /* This code needs to implement the same non-error logic\n as tok_get from tokenizer.c, at the letter_quote\n label. To actually share that code would be a\n nightmare. But, it's unlikely to change and is small,\n so duplicate it here. Note we don't need to catch all\n of the errors, since they'll be caught when parsing the\n expression. We just need to match the non-error\n cases. Thus we can ignore \\n in single-quoted strings,\n for example. Or non-terminated strings. */\n if (ch == quote_char) {\n /* Does this match the string_type (single or triple\n quoted)? */\n if (string_type == 3) {\n if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {\n /* We're at the end of a triple quoted string. */\n *str += 2;\n string_type = 0;\n quote_char = 0;\n continue;\n }\n } else {\n /* We're at the end of a normal string. */\n quote_char = 0;\n string_type = 0;\n continue;\n }\n }\n } else if (ch == '\\'' || ch == '\"') {\n /* Is this a triple quoted string? */\n if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {\n string_type = 3;\n *str += 2;\n } else {\n /* Start of a normal string. */\n string_type = 1;\n }\n /* Start looking for the end of the string. */\n quote_char = ch;\n } else if (ch == '[' || ch == '{' || ch == '(') {\n if (nested_depth >= MAXLEVEL) {\n ast_error(c, n, \"f-string: too many nested parenthesis\");\n return -1;\n }\n parenstack[nested_depth] = ch;\n nested_depth++;\n } else if (ch == '#') {\n /* Error: can't include a comment character, inside parens\n or not. */\n ast_error(c, n, \"f-string expression part cannot include '#'\");\n return -1;\n } else if (nested_depth == 0 &&\n (ch == '!' || ch == ':' || ch == '}')) {\n /* First, test for the special case of \"!=\". Since '=' is\n not an allowed conversion character, nothing is lost in\n this test. */\n if (ch == '!' && *str+1 < end && *(*str+1) == '=') {\n /* This isn't a conversion character, just continue. */\n continue;\n }\n /* Normal way out of this loop. */\n break;\n } else if (ch == ']' || ch == '}' || ch == ')') {\n if (!nested_depth) {\n ast_error(c, n, \"f-string: unmatched '%c'\", ch);\n return -1;\n }\n nested_depth--;\n int opening = parenstack[nested_depth];\n if (!((opening == '(' && ch == ')') ||\n (opening == '[' && ch == ']') ||\n (opening == '{' && ch == '}')))\n {\n ast_error(c, n,\n \"f-string: closing parenthesis '%c' \"\n \"does not match opening parenthesis '%c'\",\n ch, opening);\n return -1;\n }\n } else {\n /* Just consume this char and loop around. */\n }\n }\n expr_end = *str;\n /* If we leave this loop in a string or with mismatched parens, we\n don't care. We'll get a syntax error when compiling the\n expression. But, we can produce a better error message, so\n let's just do that.*/\n if (quote_char) {\n ast_error(c, n, \"f-string: unterminated string\");\n return -1;\n }\n if (nested_depth) {\n int opening = parenstack[nested_depth - 1];\n ast_error(c, n, \"f-string: unmatched '%c'\", opening);\n return -1;\n }\n\n if (*str >= end)\n goto unexpected_end_of_string;\n\n /* Compile the expression as soon as possible, so we show errors\n related to the expression before errors related to the\n conversion or format_spec. */\n simple_expression = fstring_compile_expr(expr_start, expr_end, c, n);\n if (!simple_expression)\n return -1;\n\n /* Check for a conversion char, if present. */\n if (**str == '!') {\n *str += 1;\n if (*str >= end)\n goto unexpected_end_of_string;\n\n conversion = **str;\n *str += 1;\n\n /* Validate the conversion. */\n if (!(conversion == 's' || conversion == 'r'\n || conversion == 'a')) {\n ast_error(c, n,\n \"f-string: invalid conversion character: \"\n \"expected 's', 'r', or 'a'\");\n return -1;\n }\n }\n\n /* Check for the format spec, if present. */\n if (*str >= end)\n goto unexpected_end_of_string;\n if (**str == ':') {\n *str += 1;\n if (*str >= end)\n goto unexpected_end_of_string;\n\n /* Parse the format spec. */\n format_spec = fstring_parse(str, end, raw, recurse_lvl+1, c, n);\n if (!format_spec)\n return -1;\n }\n\n if (*str >= end || **str != '}')\n goto unexpected_end_of_string;\n\n /* We're at a right brace. Consume it. */\n assert(*str < end);\n assert(**str == '}');\n *str += 1;\n\n /* And now create the FormattedValue node that represents this\n entire expression with the conversion and format spec. */\n *expression = FormattedValue(simple_expression, conversion,\n format_spec, LINENO(n), n->n_col_offset,\n n->n_end_lineno, n->n_end_col_offset,\n c->c_arena);\n if (!*expression)\n return -1;\n\n return 0;\n\nunexpected_end_of_string:\n ast_error(c, n, \"f-string: expecting '}'\");\n return -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2661, "func": "static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int force_reconnect)\n{\n HTTPContext *s = h->priv_data;\n URLContext *old_hd = s->hd;\n int64_t old_off = s->off;\n uint8_t old_buf[BUFFER_SIZE];\n int old_buf_size, ret;\n AVDictionary *options = NULL;\n\n if (whence == AVSEEK_SIZE)\n return s->filesize;\n else if (!force_reconnect &&\n ((whence == SEEK_CUR && off == 0) ||\n (whence == SEEK_SET && off == s->off)))\n return s->off;\n else if ((s->filesize == -1 && whence == SEEK_END))\n return AVERROR(ENOSYS);\n\n if (whence == SEEK_CUR)\n off += s->off;\n else if (whence == SEEK_END)\n off += s->filesize;\n else if (whence != SEEK_SET)\n return AVERROR(EINVAL);\n if (off < 0)\n return AVERROR(EINVAL);\n s->off = off;\n\n if (s->off && h->is_streamed)\n return AVERROR(ENOSYS);\n\n /* we save the old context in case the seek fails */\n old_buf_size = s->buf_end - s->buf_ptr;\n memcpy(old_buf, s->buf_ptr, old_buf_size);\n s->hd = NULL;\n\n /* if it fails, continue on old connection */\n if ((ret = http_open_cnx(h, &options)) < 0) {\n av_dict_free(&options);\n memcpy(s->buffer, old_buf, old_buf_size);\n s->buf_ptr = s->buffer;\n s->buf_end = s->buffer + old_buf_size;\n s->hd = old_hd;\n s->off = old_off;\n return ret;\n }\n av_dict_free(&options);\n ffurl_close(old_hd);\n return off;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 2661, "func": "static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int force_reconnect)\n{\n HTTPContext *s = h->priv_data;\n URLContext *old_hd = s->hd;\n uint64_t old_off = s->off;\n uint8_t old_buf[BUFFER_SIZE];\n int old_buf_size, ret;\n AVDictionary *options = NULL;\n\n if (whence == AVSEEK_SIZE)\n return s->filesize;\n else if (!force_reconnect &&\n ((whence == SEEK_CUR && off == 0) ||\n (whence == SEEK_SET && off == s->off)))\n return s->off;\n else if ((s->filesize == UINT64_MAX && whence == SEEK_END))\n return AVERROR(ENOSYS);\n\n if (whence == SEEK_CUR)\n off += s->off;\n else if (whence == SEEK_END)\n off += s->filesize;\n else if (whence != SEEK_SET)\n return AVERROR(EINVAL);\n if (off < 0)\n return AVERROR(EINVAL);\n s->off = off;\n\n if (s->off && h->is_streamed)\n return AVERROR(ENOSYS);\n\n /* we save the old context in case the seek fails */\n old_buf_size = s->buf_end - s->buf_ptr;\n memcpy(old_buf, s->buf_ptr, old_buf_size);\n s->hd = NULL;\n\n /* if it fails, continue on old connection */\n if ((ret = http_open_cnx(h, &options)) < 0) {\n av_dict_free(&options);\n memcpy(s->buffer, old_buf, old_buf_size);\n s->buf_ptr = s->buffer;\n s->buf_end = s->buffer + old_buf_size;\n s->hd = old_hd;\n s->off = old_off;\n return ret;\n }\n av_dict_free(&options);\n ffurl_close(old_hd);\n return off;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 2539, "func": "static char *pool_strdup(const char *s)\n{\n\tchar *r = pool_alloc(strlen(s) + 1);\n\tstrcpy(r, s);\n\treturn r;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 2539, "func": "static char *pool_strdup(const char *s)\n{\n\tsize_t len = strlen(s) + 1;\n\tchar *r = pool_alloc(len);\n\tmemcpy(r, s, len);\n\treturn r;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 174, "func": "psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)\n{\tva_list\t\t\targptr ;\n\tsf_count_t\t\t*countptr, countdata ;\n\tunsigned char\t*ucptr, sixteen_bytes [16] ;\n\tunsigned int \t*intptr, intdata ;\n\tunsigned short\t*shortptr ;\n\tchar\t\t\t*charptr ;\n\tfloat\t\t\t*floatptr ;\n\tdouble\t\t\t*doubleptr ;\n\tchar\t\t\tc ;\n\tint\t\t\t\tbyte_count = 0, count ;\n\n\tif (! format)\n\t\treturn psf_ftell (psf) ;\n\n\tva_start (argptr, format) ;\n\n\twhile ((c = *format++))\n\t{\tswitch (c)\n\t\t{\tcase 'e' : /* All conversions are now from LE to host. */\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_LITTLE ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'E' : /* All conversions are now from BE to host. */\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_BIG ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'm' : /* 4 byte marker value eg 'RIFF' */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\t*intptr = GET_MARKER (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'h' :\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;\n\t\t\t\t\t{\tint k ;\n\t\t\t\t\t\tintdata = 0 ;\n\t\t\t\t\t\tfor (k = 0 ; k < 16 ; k++)\n\t\t\t\t\t\t\tintdata ^= sixteen_bytes [k] << k ;\n\t\t\t\t\t\t}\n\t\t\t\t\t*intptr = intdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '1' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\t*charptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, charptr, sizeof (char)) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '2' : /* 2 byte value with the current endian-ness */\n\t\t\t\t\tshortptr = va_arg (argptr, unsigned short*) ;\n\t\t\t\t\t*shortptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) shortptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (short)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*shortptr = GET_BE_SHORT (ucptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*shortptr = GET_LE_SHORT (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '3' : /* 3 byte value with the current endian-ness */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 3) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = GET_BE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = GET_LE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '4' : /* 4 byte value with the current endian-ness */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = psf_get_be32 (ucptr, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = psf_get_le32 (ucptr, 0) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '8' : /* 8 byte value with the current endian-ness */\n\t\t\t\t\tcountptr = va_arg (argptr, sf_count_t *) ;\n\t\t\t\t\t*countptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 8) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\tcountdata = psf_get_be64 (sixteen_bytes, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\tcountdata = psf_get_le64 (sixteen_bytes, 0) ;\n\t\t\t\t\t*countptr = countdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'f' : /* Float conversion */\n\t\t\t\t\tfloatptr = va_arg (argptr, float *) ;\n\t\t\t\t\t*floatptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, floatptr, sizeof (float)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*floatptr = float32_be_read ((unsigned char*) floatptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*floatptr = float32_le_read ((unsigned char*) floatptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'd' : /* double conversion */\n\t\t\t\t\tdoubleptr = va_arg (argptr, double *) ;\n\t\t\t\t\t*doubleptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, doubleptr, sizeof (double)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*doubleptr = double64_le_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 's' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 's' not implemented yet.\\n\") ;\n\t\t\t\t\t/*\n\t\t\t\t\tstrptr = va_arg (argptr, char *) ;\n\t\t\t\t\tsize = strlen (strptr) + 1 ;\n\t\t\t\t\tsize += (size & 1) ;\n\t\t\t\t\tlongdata = H2LE_32 (size) ;\n\t\t\t\t\tget_int (psf, longdata) ;\n\t\t\t\t\tmemcpy (&(psf->header [psf->headindex]), strptr, size) ;\n\t\t\t\t\tpsf->headindex += size ;\n\t\t\t\t\t*/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'b' : /* Raw bytes */\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tif (count > 0)\n\t\t\t\t\t\tbyte_count += header_read (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'G' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tif (count > 0)\n\t\t\t\t\t\tbyte_count += header_gets (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'z' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 'z' not implemented yet.\\n\") ;\n\t\t\t\t\t/*\n\t\t\t\t\tsize = va_arg (argptr, size_t) ;\n\t\t\t\t\twhile (size)\n\t\t\t\t\t{\tpsf->header [psf->headindex] = 0 ;\n\t\t\t\t\t\tpsf->headindex ++ ;\n\t\t\t\t\t\tsize -- ;\n\t\t\t\t\t\t} ;\n\t\t\t\t\t*/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'p' :\n\t\t\t\t\t/* Get the seek position first. */\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\theader_seek (psf, count, SEEK_SET) ;\n\t\t\t\t\tbyte_count = count ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'j' :\n\t\t\t\t\t/* Get the seek position first. */\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tif (count)\n\t\t\t\t\t{\theader_seek (psf, count, SEEK_CUR) ;\n\t\t\t\t\t\tbyte_count += count ;\n\t\t\t\t\t\t} ;\n\t\t\t\t\tbreak ;\n\n\t\t\tdefault :\n\t\t\t\tpsf_log_printf (psf, \"*** Invalid format specifier `%c'\\n\", c) ;\n\t\t\t\tpsf->error = SFE_INTERNAL ;\n\t\t\t\tbreak ;\n\t\t\t} ;\n\t\t} ;\n\n\tva_end (argptr) ;\n\n\treturn byte_count ;\n} /* psf_binheader_readf */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 174, "func": "psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)\n{\tva_list\t\t\targptr ;\n\tsf_count_t\t\t*countptr, countdata ;\n\tunsigned char\t*ucptr, sixteen_bytes [16] ;\n\tunsigned int \t*intptr, intdata ;\n\tunsigned short\t*shortptr ;\n\tchar\t\t\t*charptr ;\n\tfloat\t\t\t*floatptr ;\n\tdouble\t\t\t*doubleptr ;\n\tchar\t\t\tc ;\n\tint\t\t\t\tbyte_count = 0, count = 0 ;\n\n\tif (! format)\n\t\treturn psf_ftell (psf) ;\n\n\tva_start (argptr, format) ;\n\n\twhile ((c = *format++))\n\t{\n\t\tif (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))\n\t\t\treturn count ;\n\n\t\tswitch (c)\n\t\t{\tcase 'e' : /* All conversions are now from LE to host. */\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_LITTLE ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'E' : /* All conversions are now from BE to host. */\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_BIG ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'm' : /* 4 byte marker value eg 'RIFF' */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\t*intptr = GET_MARKER (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'h' :\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;\n\t\t\t\t\t{\tint k ;\n\t\t\t\t\t\tintdata = 0 ;\n\t\t\t\t\t\tfor (k = 0 ; k < 16 ; k++)\n\t\t\t\t\t\t\tintdata ^= sixteen_bytes [k] << k ;\n\t\t\t\t\t\t}\n\t\t\t\t\t*intptr = intdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '1' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\t*charptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, charptr, sizeof (char)) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '2' : /* 2 byte value with the current endian-ness */\n\t\t\t\t\tshortptr = va_arg (argptr, unsigned short*) ;\n\t\t\t\t\t*shortptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) shortptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (short)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*shortptr = GET_BE_SHORT (ucptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*shortptr = GET_LE_SHORT (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '3' : /* 3 byte value with the current endian-ness */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 3) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = GET_BE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = GET_LE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '4' : /* 4 byte value with the current endian-ness */\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = psf_get_be32 (ucptr, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = psf_get_le32 (ucptr, 0) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '8' : /* 8 byte value with the current endian-ness */\n\t\t\t\t\tcountptr = va_arg (argptr, sf_count_t *) ;\n\t\t\t\t\t*countptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 8) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\tcountdata = psf_get_be64 (sixteen_bytes, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\tcountdata = psf_get_le64 (sixteen_bytes, 0) ;\n\t\t\t\t\t*countptr = countdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'f' : /* Float conversion */\n\t\t\t\t\tfloatptr = va_arg (argptr, float *) ;\n\t\t\t\t\t*floatptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, floatptr, sizeof (float)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*floatptr = float32_be_read ((unsigned char*) floatptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*floatptr = float32_le_read ((unsigned char*) floatptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'd' : /* double conversion */\n\t\t\t\t\tdoubleptr = va_arg (argptr, double *) ;\n\t\t\t\t\t*doubleptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, doubleptr, sizeof (double)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*doubleptr = double64_le_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 's' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 's' not implemented yet.\\n\") ;\n\t\t\t\t\t/*\n\t\t\t\t\tstrptr = va_arg (argptr, char *) ;\n\t\t\t\t\tsize = strlen (strptr) + 1 ;\n\t\t\t\t\tsize += (size & 1) ;\n\t\t\t\t\tlongdata = H2LE_32 (size) ;\n\t\t\t\t\tget_int (psf, longdata) ;\n\t\t\t\t\tmemcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;\n\t\t\t\t\tpsf->header.indx += size ;\n\t\t\t\t\t*/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'b' : /* Raw bytes */\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tmemset (charptr, 0, count) ;\n\t\t\t\t\tbyte_count += header_read (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'G' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tmemset (charptr, 0, count) ;\n\n\t\t\t\t\tif (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))\n\t\t\t\t\t\treturn 0 ;\n\n\t\t\t\t\tbyte_count += header_gets (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'z' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 'z' not implemented yet.\\n\") ;\n\t\t\t\t\t/*\n\t\t\t\t\tsize = va_arg (argptr, size_t) ;\n\t\t\t\t\twhile (size)\n\t\t\t\t\t{\tpsf->header.ptr [psf->header.indx] = 0 ;\n\t\t\t\t\t\tpsf->header.indx ++ ;\n\t\t\t\t\t\tsize -- ;\n\t\t\t\t\t\t} ;\n\t\t\t\t\t*/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'p' :\t/* Seek to position from start. */\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\theader_seek (psf, count, SEEK_SET) ;\n\t\t\t\t\tbyte_count = count ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'j' :\t/* Seek to position from current position. */\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\theader_seek (psf, count, SEEK_CUR) ;\n\t\t\t\t\tbyte_count += count ;\n\t\t\t\t\tbreak ;\n\n\t\t\tdefault :\n\t\t\t\tpsf_log_printf (psf, \"*** Invalid format specifier `%c'\\n\", c) ;\n\t\t\t\tpsf->error = SFE_INTERNAL ;\n\t\t\t\tbreak ;\n\t\t\t} ;\n\t\t} ;\n\n\tva_end (argptr) ;\n\n\treturn byte_count ;\n} /* psf_binheader_readf */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 54, "func": "std::string decodeBase64(\n const std::string& encoded) {\n\n if (encoded.size() == 0) {\n // special case, to prevent an integer overflow down below.\n return \"\";\n }\n\n using namespace boost::archive::iterators;\n using b64it =\n transform_width, 8, 6>;\n\n std::string decoded = std::string(b64it(std::begin(encoded)),\n b64it(std::end(encoded)));\n\n uint32_t numPadding = std::count(encoded.begin(), encoded.end(), '=');\n decoded.erase(decoded.end() - numPadding, decoded.end());\n\n return decoded;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11921", "cwe_id": "CWE-787" }, { "id": 54, "func": "std::string decodeBase64(\n const std::string& encoded) {\n\n if (encoded.size() == 0) {\n // special case, to prevent an integer overflow down below.\n return std::string();\n }\n\n int padding = 0;\n for (auto it = encoded.rbegin();\n padding < 2 && it != encoded.rend() && *it == '=';\n ++it) {\n ++padding;\n }\n\n return Base64::decode(encoded, padding);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11921", "cwe_id": "CWE-787" }, { "id": 623, "func": "error_t ipv6ComputeSolicitedNodeAddr(const Ipv6Addr *ipAddr,\n Ipv6Addr *solicitedNodeAddr)\n{\n error_t error;\n\n //Ensure the specified address is a valid unicast or anycast address\n if(!ipv6IsMulticastAddr(ipAddr))\n {\n //Copy the 104-bit prefix\n ipv6CopyAddr(solicitedNodeAddr, &IPV6_SOLICITED_NODE_ADDR_PREFIX);\n\n //Take the low-order 24 bits of the address (unicast or anycast) and\n //append those bits to the prefix\n solicitedNodeAddr->b[13] = ipAddr->b[13];\n solicitedNodeAddr->b[14] = ipAddr->b[14];\n solicitedNodeAddr->b[15] = ipAddr->b[15];\n\n //Sucessful processing\n error = NO_ERROR;\n }\n else\n {\n //Report an error\n error = ERROR_INVALID_ADDRESS;\n }\n\n //Return status code\n return error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 623, "func": "error_t ipv6ComputeSolicitedNodeAddr(const Ipv6Addr *ipAddr,\n Ipv6Addr *solicitedNodeAddr)\n{\n error_t error;\n\n //Ensure the specified address is a valid unicast or anycast address\n if(!ipv6IsMulticastAddr(ipAddr))\n {\n //Copy the 104-bit prefix\n ipv6CopyAddr(solicitedNodeAddr, &IPV6_SOLICITED_NODE_ADDR_PREFIX);\n\n //Take the low-order 24 bits of the address (unicast or anycast) and\n //append those bits to the prefix\n solicitedNodeAddr->b[13] = ipAddr->b[13];\n solicitedNodeAddr->b[14] = ipAddr->b[14];\n solicitedNodeAddr->b[15] = ipAddr->b[15];\n\n //Successful processing\n error = NO_ERROR;\n }\n else\n {\n //Report an error\n error = ERROR_INVALID_ADDRESS;\n }\n\n //Return status code\n return error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 337, "func": "read_old_length(cdk_stream_t inp, int ctb, size_t * r_len, size_t * r_size)\n{\n\tint llen = ctb & 0x03;\n\n\tif (llen == 0) {\n\t\t*r_len = cdk_stream_getc(inp);\n\t\t(*r_size)++;\n\t} else if (llen == 1) {\n\t\t*r_len = read_16(inp);\n\t\t(*r_size) += 2;\n\t} else if (llen == 2) {\n\t\t*r_len = read_32(inp);\n\t\t(*r_size) += 4;\n\t} else {\n\t\t*r_len = 0;\n\t\t*r_size = 0;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-5335", "cwe_id": "CWE-125" }, { "id": 337, "func": "read_old_length(cdk_stream_t inp, int ctb, size_t * r_len, size_t * r_size)\n{\n\tint llen = ctb & 0x03;\n\tint c;\n\n\tif (llen == 0) {\n\t\tc = cdk_stream_getc(inp);\n\t\tif (c == EOF)\n\t\t\tgoto fail;\n\n\t\t*r_len = c;\n\t\t(*r_size)++;\n\t} else if (llen == 1) {\n\t\t*r_len = read_16(inp);\n\t\tif (*r_len == (u16)-1)\n\t\t\tgoto fail;\n\t\t(*r_size) += 2;\n\t} else if (llen == 2) {\n\t\t*r_len = read_32(inp);\n\t\tif (*r_len == (u32)-1) {\n\t\t\tgoto fail;\n\t\t}\n\n\t\t(*r_size) += 4;\n\t} else {\n fail:\n\t\t*r_len = 0;\n\t\t*r_size = 0;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-5335", "cwe_id": "CWE-125" }, { "id": 371, "func": "static int do_ip_getsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, int __user *optlen)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tint val;\n\tint len;\n\n\tif (level != SOL_IP)\n\t\treturn -EOPNOTSUPP;\n\n\tif (ip_mroute_opt(optname))\n\t\treturn ip_mroute_getsockopt(sk, optname, optval, optlen);\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (len < 0)\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase IP_OPTIONS:\n\t{\n\t\tunsigned char optbuf[sizeof(struct ip_options)+40];\n\t\tstruct ip_options * opt = (struct ip_options *)optbuf;\n\t\topt->optlen = 0;\n\t\tif (inet->opt)\n\t\t\tmemcpy(optbuf, inet->opt,\n\t\t\t sizeof(struct ip_options)+\n\t\t\t inet->opt->optlen);\n\t\trelease_sock(sk);\n\n\t\tif (opt->optlen == 0)\n\t\t\treturn put_user(0, optlen);\n\n\t\tip_options_undo(opt);\n\n\t\tlen = min_t(unsigned int, len, opt->optlen);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, opt->__data, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase IP_PKTINFO:\n\t\tval = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0;\n\t\tbreak;\n\tcase IP_RECVTTL:\n\t\tval = (inet->cmsg_flags & IP_CMSG_TTL) != 0;\n\t\tbreak;\n\tcase IP_RECVTOS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_TOS) != 0;\n\t\tbreak;\n\tcase IP_RECVOPTS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0;\n\t\tbreak;\n\tcase IP_RETOPTS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0;\n\t\tbreak;\n\tcase IP_PASSSEC:\n\t\tval = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0;\n\t\tbreak;\n\tcase IP_RECVORIGDSTADDR:\n\t\tval = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0;\n\t\tbreak;\n\tcase IP_TOS:\n\t\tval = inet->tos;\n\t\tbreak;\n\tcase IP_TTL:\n\t\tval = (inet->uc_ttl == -1 ?\n\t\t sysctl_ip_default_ttl :\n\t\t inet->uc_ttl);\n\t\tbreak;\n\tcase IP_HDRINCL:\n\t\tval = inet->hdrincl;\n\t\tbreak;\n\tcase IP_NODEFRAG:\n\t\tval = inet->nodefrag;\n\t\tbreak;\n\tcase IP_MTU_DISCOVER:\n\t\tval = inet->pmtudisc;\n\t\tbreak;\n\tcase IP_MTU:\n\t{\n\t\tstruct dst_entry *dst;\n\t\tval = 0;\n\t\tdst = sk_dst_get(sk);\n\t\tif (dst) {\n\t\t\tval = dst_mtu(dst);\n\t\t\tdst_release(dst);\n\t\t}\n\t\tif (!val) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -ENOTCONN;\n\t\t}\n\t\tbreak;\n\t}\n\tcase IP_RECVERR:\n\t\tval = inet->recverr;\n\t\tbreak;\n\tcase IP_MULTICAST_TTL:\n\t\tval = inet->mc_ttl;\n\t\tbreak;\n\tcase IP_MULTICAST_LOOP:\n\t\tval = inet->mc_loop;\n\t\tbreak;\n\tcase IP_MULTICAST_IF:\n\t{\n\t\tstruct in_addr addr;\n\t\tlen = min_t(unsigned int, len, sizeof(struct in_addr));\n\t\taddr.s_addr = inet->mc_addr;\n\t\trelease_sock(sk);\n\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &addr, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase IP_MSFILTER:\n\t{\n\t\tstruct ip_msfilter msf;\n\t\tint err;\n\n\t\tif (len < IP_MSFILTER_SIZE(0)) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\terr = ip_mc_msfget(sk, &msf,\n\t\t\t\t (struct ip_msfilter __user *)optval, optlen);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tcase MCAST_MSFILTER:\n\t{\n\t\tstruct group_filter gsf;\n\t\tint err;\n\n\t\tif (len < GROUP_FILTER_SIZE(0)) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\terr = ip_mc_gsfget(sk, &gsf,\n\t\t\t\t (struct group_filter __user *)optval,\n\t\t\t\t optlen);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tcase IP_MULTICAST_ALL:\n\t\tval = inet->mc_all;\n\t\tbreak;\n\tcase IP_PKTOPTIONS:\n\t{\n\t\tstruct msghdr msg;\n\n\t\trelease_sock(sk);\n\n\t\tif (sk->sk_type != SOCK_STREAM)\n\t\t\treturn -ENOPROTOOPT;\n\n\t\tmsg.msg_control = optval;\n\t\tmsg.msg_controllen = len;\n\t\tmsg.msg_flags = 0;\n\n\t\tif (inet->cmsg_flags & IP_CMSG_PKTINFO) {\n\t\t\tstruct in_pktinfo info;\n\n\t\t\tinfo.ipi_addr.s_addr = inet->inet_rcv_saddr;\n\t\t\tinfo.ipi_spec_dst.s_addr = inet->inet_rcv_saddr;\n\t\t\tinfo.ipi_ifindex = inet->mc_index;\n\t\t\tput_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info);\n\t\t}\n\t\tif (inet->cmsg_flags & IP_CMSG_TTL) {\n\t\t\tint hlim = inet->mc_ttl;\n\t\t\tput_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);\n\t\t}\n\t\tlen -= msg.msg_controllen;\n\t\treturn put_user(len, optlen);\n\t}\n\tcase IP_FREEBIND:\n\t\tval = inet->freebind;\n\t\tbreak;\n\tcase IP_TRANSPARENT:\n\t\tval = inet->transparent;\n\t\tbreak;\n\tcase IP_MINTTL:\n\t\tval = inet->min_ttl;\n\t\tbreak;\n\tdefault:\n\t\trelease_sock(sk);\n\t\treturn -ENOPROTOOPT;\n\t}\n\trelease_sock(sk);\n\n\tif (len < sizeof(int) && len > 0 && val >= 0 && val <= 255) {\n\t\tunsigned char ucval = (unsigned char)val;\n\t\tlen = 1;\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &ucval, 1))\n\t\t\treturn -EFAULT;\n\t} else {\n\t\tlen = min_t(unsigned int, sizeof(int), len);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &val, len))\n\t\t\treturn -EFAULT;\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 371, "func": "static int do_ip_getsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, int __user *optlen)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tint val;\n\tint len;\n\n\tif (level != SOL_IP)\n\t\treturn -EOPNOTSUPP;\n\n\tif (ip_mroute_opt(optname))\n\t\treturn ip_mroute_getsockopt(sk, optname, optval, optlen);\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (len < 0)\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase IP_OPTIONS:\n\t{\n\t\tunsigned char optbuf[sizeof(struct ip_options)+40];\n\t\tstruct ip_options *opt = (struct ip_options *)optbuf;\n\t\tstruct ip_options_rcu *inet_opt;\n\n\t\tinet_opt = rcu_dereference_protected(inet->inet_opt,\n\t\t\t\t\t\t sock_owned_by_user(sk));\n\t\topt->optlen = 0;\n\t\tif (inet_opt)\n\t\t\tmemcpy(optbuf, &inet_opt->opt,\n\t\t\t sizeof(struct ip_options) +\n\t\t\t inet_opt->opt.optlen);\n\t\trelease_sock(sk);\n\n\t\tif (opt->optlen == 0)\n\t\t\treturn put_user(0, optlen);\n\n\t\tip_options_undo(opt);\n\n\t\tlen = min_t(unsigned int, len, opt->optlen);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, opt->__data, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase IP_PKTINFO:\n\t\tval = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0;\n\t\tbreak;\n\tcase IP_RECVTTL:\n\t\tval = (inet->cmsg_flags & IP_CMSG_TTL) != 0;\n\t\tbreak;\n\tcase IP_RECVTOS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_TOS) != 0;\n\t\tbreak;\n\tcase IP_RECVOPTS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0;\n\t\tbreak;\n\tcase IP_RETOPTS:\n\t\tval = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0;\n\t\tbreak;\n\tcase IP_PASSSEC:\n\t\tval = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0;\n\t\tbreak;\n\tcase IP_RECVORIGDSTADDR:\n\t\tval = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0;\n\t\tbreak;\n\tcase IP_TOS:\n\t\tval = inet->tos;\n\t\tbreak;\n\tcase IP_TTL:\n\t\tval = (inet->uc_ttl == -1 ?\n\t\t sysctl_ip_default_ttl :\n\t\t inet->uc_ttl);\n\t\tbreak;\n\tcase IP_HDRINCL:\n\t\tval = inet->hdrincl;\n\t\tbreak;\n\tcase IP_NODEFRAG:\n\t\tval = inet->nodefrag;\n\t\tbreak;\n\tcase IP_MTU_DISCOVER:\n\t\tval = inet->pmtudisc;\n\t\tbreak;\n\tcase IP_MTU:\n\t{\n\t\tstruct dst_entry *dst;\n\t\tval = 0;\n\t\tdst = sk_dst_get(sk);\n\t\tif (dst) {\n\t\t\tval = dst_mtu(dst);\n\t\t\tdst_release(dst);\n\t\t}\n\t\tif (!val) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -ENOTCONN;\n\t\t}\n\t\tbreak;\n\t}\n\tcase IP_RECVERR:\n\t\tval = inet->recverr;\n\t\tbreak;\n\tcase IP_MULTICAST_TTL:\n\t\tval = inet->mc_ttl;\n\t\tbreak;\n\tcase IP_MULTICAST_LOOP:\n\t\tval = inet->mc_loop;\n\t\tbreak;\n\tcase IP_MULTICAST_IF:\n\t{\n\t\tstruct in_addr addr;\n\t\tlen = min_t(unsigned int, len, sizeof(struct in_addr));\n\t\taddr.s_addr = inet->mc_addr;\n\t\trelease_sock(sk);\n\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &addr, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase IP_MSFILTER:\n\t{\n\t\tstruct ip_msfilter msf;\n\t\tint err;\n\n\t\tif (len < IP_MSFILTER_SIZE(0)) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\terr = ip_mc_msfget(sk, &msf,\n\t\t\t\t (struct ip_msfilter __user *)optval, optlen);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tcase MCAST_MSFILTER:\n\t{\n\t\tstruct group_filter gsf;\n\t\tint err;\n\n\t\tif (len < GROUP_FILTER_SIZE(0)) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {\n\t\t\trelease_sock(sk);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\terr = ip_mc_gsfget(sk, &gsf,\n\t\t\t\t (struct group_filter __user *)optval,\n\t\t\t\t optlen);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tcase IP_MULTICAST_ALL:\n\t\tval = inet->mc_all;\n\t\tbreak;\n\tcase IP_PKTOPTIONS:\n\t{\n\t\tstruct msghdr msg;\n\n\t\trelease_sock(sk);\n\n\t\tif (sk->sk_type != SOCK_STREAM)\n\t\t\treturn -ENOPROTOOPT;\n\n\t\tmsg.msg_control = optval;\n\t\tmsg.msg_controllen = len;\n\t\tmsg.msg_flags = 0;\n\n\t\tif (inet->cmsg_flags & IP_CMSG_PKTINFO) {\n\t\t\tstruct in_pktinfo info;\n\n\t\t\tinfo.ipi_addr.s_addr = inet->inet_rcv_saddr;\n\t\t\tinfo.ipi_spec_dst.s_addr = inet->inet_rcv_saddr;\n\t\t\tinfo.ipi_ifindex = inet->mc_index;\n\t\t\tput_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info);\n\t\t}\n\t\tif (inet->cmsg_flags & IP_CMSG_TTL) {\n\t\t\tint hlim = inet->mc_ttl;\n\t\t\tput_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);\n\t\t}\n\t\tlen -= msg.msg_controllen;\n\t\treturn put_user(len, optlen);\n\t}\n\tcase IP_FREEBIND:\n\t\tval = inet->freebind;\n\t\tbreak;\n\tcase IP_TRANSPARENT:\n\t\tval = inet->transparent;\n\t\tbreak;\n\tcase IP_MINTTL:\n\t\tval = inet->min_ttl;\n\t\tbreak;\n\tdefault:\n\t\trelease_sock(sk);\n\t\treturn -ENOPROTOOPT;\n\t}\n\trelease_sock(sk);\n\n\tif (len < sizeof(int) && len > 0 && val >= 0 && val <= 255) {\n\t\tunsigned char ucval = (unsigned char)val;\n\t\tlen = 1;\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &ucval, 1))\n\t\t\treturn -EFAULT;\n\t} else {\n\t\tlen = min_t(unsigned int, sizeof(int), len);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &val, len))\n\t\t\treturn -EFAULT;\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 3248, "func": "static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct ipcm_cookie ipc;\n\tstruct rtable *rt = NULL;\n\tint free = 0;\n\t__be32 daddr;\n\t__be32 saddr;\n\tu8 tos;\n\tint err;\n\n\terr = -EMSGSIZE;\n\tif (len > 0xFFFF)\n\t\tgoto out;\n\n\t/*\n\t *\tCheck the flags.\n\t */\n\n\terr = -EOPNOTSUPP;\n\tif (msg->msg_flags & MSG_OOB)\t/* Mirror BSD error message */\n\t\tgoto out; /* compatibility */\n\n\t/*\n\t *\tGet and verify the address.\n\t */\n\n\tif (msg->msg_namelen) {\n\t\tstruct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name;\n\t\terr = -EINVAL;\n\t\tif (msg->msg_namelen < sizeof(*usin))\n\t\t\tgoto out;\n\t\tif (usin->sin_family != AF_INET) {\n\t\t\tstatic int complained;\n\t\t\tif (!complained++)\n\t\t\t\tprintk(KERN_INFO \"%s forgot to set AF_INET in \"\n\t\t\t\t\t\t \"raw sendmsg. Fix it!\\n\",\n\t\t\t\t\t\t current->comm);\n\t\t\terr = -EAFNOSUPPORT;\n\t\t\tif (usin->sin_family)\n\t\t\t\tgoto out;\n\t\t}\n\t\tdaddr = usin->sin_addr.s_addr;\n\t\t/* ANK: I did not forget to get protocol from port field.\n\t\t * I just do not know, who uses this weirdness.\n\t\t * IP_HDRINCL is much more convenient.\n\t\t */\n\t} else {\n\t\terr = -EDESTADDRREQ;\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\tgoto out;\n\t\tdaddr = inet->inet_daddr;\n\t}\n\n\tipc.addr = inet->inet_saddr;\n\tipc.opt = NULL;\n\tipc.tx_flags = 0;\n\tipc.oif = sk->sk_bound_dev_if;\n\n\tif (msg->msg_controllen) {\n\t\terr = ip_cmsg_send(sock_net(sk), msg, &ipc);\n\t\tif (err)\n\t\t\tgoto out;\n\t\tif (ipc.opt)\n\t\t\tfree = 1;\n\t}\n\n\tsaddr = ipc.addr;\n\tipc.addr = daddr;\n\n\tif (!ipc.opt)\n\t\tipc.opt = inet->opt;\n\n\tif (ipc.opt) {\n\t\terr = -EINVAL;\n\t\t/* Linux does not mangle headers on raw sockets,\n\t\t * so that IP options + IP_HDRINCL is non-sense.\n\t\t */\n\t\tif (inet->hdrincl)\n\t\t\tgoto done;\n\t\tif (ipc.opt->srr) {\n\t\t\tif (!daddr)\n\t\t\t\tgoto done;\n\t\t\tdaddr = ipc.opt->faddr;\n\t\t}\n\t}\n\ttos = RT_CONN_FLAGS(sk);\n\tif (msg->msg_flags & MSG_DONTROUTE)\n\t\ttos |= RTO_ONLINK;\n\n\tif (ipv4_is_multicast(daddr)) {\n\t\tif (!ipc.oif)\n\t\t\tipc.oif = inet->mc_index;\n\t\tif (!saddr)\n\t\t\tsaddr = inet->mc_addr;\n\t}\n\n\t{\n\t\tstruct flowi4 fl4;\n\n\t\tflowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,\n\t\t\t\t RT_SCOPE_UNIVERSE,\n\t\t\t\t inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,\n\t\t\t\t FLOWI_FLAG_CAN_SLEEP, daddr, saddr, 0, 0);\n\n\t\tif (!inet->hdrincl) {\n\t\t\terr = raw_probe_proto_opt(&fl4, msg);\n\t\t\tif (err)\n\t\t\t\tgoto done;\n\t\t}\n\n\t\tsecurity_sk_classify_flow(sk, flowi4_to_flowi(&fl4));\n\t\trt = ip_route_output_flow(sock_net(sk), &fl4, sk);\n\t\tif (IS_ERR(rt)) {\n\t\t\terr = PTR_ERR(rt);\n\t\t\trt = NULL;\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\terr = -EACCES;\n\tif (rt->rt_flags & RTCF_BROADCAST && !sock_flag(sk, SOCK_BROADCAST))\n\t\tgoto done;\n\n\tif (msg->msg_flags & MSG_CONFIRM)\n\t\tgoto do_confirm;\nback_from_confirm:\n\n\tif (inet->hdrincl)\n\t\terr = raw_send_hdrinc(sk, msg->msg_iov, len,\n\t\t\t\t\t&rt, msg->msg_flags);\n\n\t else {\n\t\tif (!ipc.addr)\n\t\t\tipc.addr = rt->rt_dst;\n\t\tlock_sock(sk);\n\t\terr = ip_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0,\n\t\t\t\t\t&ipc, &rt, msg->msg_flags);\n\t\tif (err)\n\t\t\tip_flush_pending_frames(sk);\n\t\telse if (!(msg->msg_flags & MSG_MORE)) {\n\t\t\terr = ip_push_pending_frames(sk);\n\t\t\tif (err == -ENOBUFS && !inet->recverr)\n\t\t\t\terr = 0;\n\t\t}\n\t\trelease_sock(sk);\n\t}\ndone:\n\tif (free)\n\t\tkfree(ipc.opt);\n\tip_rt_put(rt);\n\nout:\n\tif (err < 0)\n\t\treturn err;\n\treturn len;\n\ndo_confirm:\n\tdst_confirm(&rt->dst);\n\tif (!(msg->msg_flags & MSG_PROBE) || len)\n\t\tgoto back_from_confirm;\n\terr = 0;\n\tgoto done;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 3248, "func": "static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct ipcm_cookie ipc;\n\tstruct rtable *rt = NULL;\n\tint free = 0;\n\t__be32 daddr;\n\t__be32 saddr;\n\tu8 tos;\n\tint err;\n\tstruct ip_options_data opt_copy;\n\n\terr = -EMSGSIZE;\n\tif (len > 0xFFFF)\n\t\tgoto out;\n\n\t/*\n\t *\tCheck the flags.\n\t */\n\n\terr = -EOPNOTSUPP;\n\tif (msg->msg_flags & MSG_OOB)\t/* Mirror BSD error message */\n\t\tgoto out; /* compatibility */\n\n\t/*\n\t *\tGet and verify the address.\n\t */\n\n\tif (msg->msg_namelen) {\n\t\tstruct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name;\n\t\terr = -EINVAL;\n\t\tif (msg->msg_namelen < sizeof(*usin))\n\t\t\tgoto out;\n\t\tif (usin->sin_family != AF_INET) {\n\t\t\tstatic int complained;\n\t\t\tif (!complained++)\n\t\t\t\tprintk(KERN_INFO \"%s forgot to set AF_INET in \"\n\t\t\t\t\t\t \"raw sendmsg. Fix it!\\n\",\n\t\t\t\t\t\t current->comm);\n\t\t\terr = -EAFNOSUPPORT;\n\t\t\tif (usin->sin_family)\n\t\t\t\tgoto out;\n\t\t}\n\t\tdaddr = usin->sin_addr.s_addr;\n\t\t/* ANK: I did not forget to get protocol from port field.\n\t\t * I just do not know, who uses this weirdness.\n\t\t * IP_HDRINCL is much more convenient.\n\t\t */\n\t} else {\n\t\terr = -EDESTADDRREQ;\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\tgoto out;\n\t\tdaddr = inet->inet_daddr;\n\t}\n\n\tipc.addr = inet->inet_saddr;\n\tipc.opt = NULL;\n\tipc.tx_flags = 0;\n\tipc.oif = sk->sk_bound_dev_if;\n\n\tif (msg->msg_controllen) {\n\t\terr = ip_cmsg_send(sock_net(sk), msg, &ipc);\n\t\tif (err)\n\t\t\tgoto out;\n\t\tif (ipc.opt)\n\t\t\tfree = 1;\n\t}\n\n\tsaddr = ipc.addr;\n\tipc.addr = daddr;\n\n\tif (!ipc.opt) {\n\t\tstruct ip_options_rcu *inet_opt;\n\n\t\trcu_read_lock();\n\t\tinet_opt = rcu_dereference(inet->inet_opt);\n\t\tif (inet_opt) {\n\t\t\tmemcpy(&opt_copy, inet_opt,\n\t\t\t sizeof(*inet_opt) + inet_opt->opt.optlen);\n\t\t\tipc.opt = &opt_copy.opt;\n\t\t}\n\t\trcu_read_unlock();\n\t}\n\n\tif (ipc.opt) {\n\t\terr = -EINVAL;\n\t\t/* Linux does not mangle headers on raw sockets,\n\t\t * so that IP options + IP_HDRINCL is non-sense.\n\t\t */\n\t\tif (inet->hdrincl)\n\t\t\tgoto done;\n\t\tif (ipc.opt->opt.srr) {\n\t\t\tif (!daddr)\n\t\t\t\tgoto done;\n\t\t\tdaddr = ipc.opt->opt.faddr;\n\t\t}\n\t}\n\ttos = RT_CONN_FLAGS(sk);\n\tif (msg->msg_flags & MSG_DONTROUTE)\n\t\ttos |= RTO_ONLINK;\n\n\tif (ipv4_is_multicast(daddr)) {\n\t\tif (!ipc.oif)\n\t\t\tipc.oif = inet->mc_index;\n\t\tif (!saddr)\n\t\t\tsaddr = inet->mc_addr;\n\t}\n\n\t{\n\t\tstruct flowi4 fl4;\n\n\t\tflowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,\n\t\t\t\t RT_SCOPE_UNIVERSE,\n\t\t\t\t inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,\n\t\t\t\t FLOWI_FLAG_CAN_SLEEP, daddr, saddr, 0, 0);\n\n\t\tif (!inet->hdrincl) {\n\t\t\terr = raw_probe_proto_opt(&fl4, msg);\n\t\t\tif (err)\n\t\t\t\tgoto done;\n\t\t}\n\n\t\tsecurity_sk_classify_flow(sk, flowi4_to_flowi(&fl4));\n\t\trt = ip_route_output_flow(sock_net(sk), &fl4, sk);\n\t\tif (IS_ERR(rt)) {\n\t\t\terr = PTR_ERR(rt);\n\t\t\trt = NULL;\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\terr = -EACCES;\n\tif (rt->rt_flags & RTCF_BROADCAST && !sock_flag(sk, SOCK_BROADCAST))\n\t\tgoto done;\n\n\tif (msg->msg_flags & MSG_CONFIRM)\n\t\tgoto do_confirm;\nback_from_confirm:\n\n\tif (inet->hdrincl)\n\t\terr = raw_send_hdrinc(sk, msg->msg_iov, len,\n\t\t\t\t\t&rt, msg->msg_flags);\n\n\t else {\n\t\tif (!ipc.addr)\n\t\t\tipc.addr = rt->rt_dst;\n\t\tlock_sock(sk);\n\t\terr = ip_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0,\n\t\t\t\t\t&ipc, &rt, msg->msg_flags);\n\t\tif (err)\n\t\t\tip_flush_pending_frames(sk);\n\t\telse if (!(msg->msg_flags & MSG_MORE)) {\n\t\t\terr = ip_push_pending_frames(sk);\n\t\t\tif (err == -ENOBUFS && !inet->recverr)\n\t\t\t\terr = 0;\n\t\t}\n\t\trelease_sock(sk);\n\t}\ndone:\n\tif (free)\n\t\tkfree(ipc.opt);\n\tip_rt_put(rt);\n\nout:\n\tif (err < 0)\n\t\treturn err;\n\treturn len;\n\ndo_confirm:\n\tdst_confirm(&rt->dst);\n\tif (!(msg->msg_flags & MSG_PROBE) || len)\n\t\tgoto back_from_confirm;\n\terr = 0;\n\tgoto done;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 2779, "func": "static Jsi_RC jsi_ArrayFlatSub(Jsi_Interp *interp, Jsi_Obj* nobj, Jsi_Value *arr, int depth) {\n \n int i, n = 0, len = Jsi_ObjGetLength(interp, arr->d.obj);\n if (len <= 0) return JSI_OK;\n Jsi_RC rc = JSI_OK;\n int clen = Jsi_ObjGetLength(interp, nobj);\n for (i = 0; i < len && rc == JSI_OK; i++) {\n Jsi_Value *t = Jsi_ValueArrayIndex(interp, arr, i);\n if (t && depth>0 && Jsi_ValueIsArray(interp, t))\n rc = jsi_ArrayFlatSub(interp, nobj, t , depth-1);\n else if (!Jsi_ValueIsUndef(interp, t))\n Jsi_ObjArrayAdd(interp, nobj, t);\n if ((++n + clen)>interp->maxArrayList)\n return Jsi_LogError(\"array size exceeded\");\n }\n return rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 2779, "func": "static Jsi_RC jsi_ArrayFlatSub(Jsi_Interp *interp, Jsi_Obj* nobj, Jsi_Value *arr, int depth) {\n \n int i, n = 0, len = jsi_SizeOfArray(interp, arr->d.obj);\n if (len <= 0) return JSI_OK;\n Jsi_RC rc = JSI_OK;\n int clen = jsi_SizeOfArray(interp, nobj);\n for (i = 0; i < len && rc == JSI_OK; i++) {\n Jsi_Value *t = Jsi_ValueArrayIndex(interp, arr, i);\n if (t && depth>0 && Jsi_ValueIsArray(interp, t))\n rc = jsi_ArrayFlatSub(interp, nobj, t , depth-1);\n else if (!Jsi_ValueIsUndef(interp, t))\n Jsi_ObjArrayAdd(interp, nobj, t);\n if ((++n + clen)>interp->maxArrayList)\n return Jsi_LogError(\"array size exceeded\");\n }\n return rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 3225, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n if (input->type != kTfLiteFloat32) {\n TF_LITE_UNSUPPORTED_TYPE(context, input->type, \"Ceil\");\n }\n\n optimized_ops::Ceil(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3225, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n if (input->type != kTfLiteFloat32) {\n TF_LITE_UNSUPPORTED_TYPE(context, input->type, \"Ceil\");\n }\n\n optimized_ops::Ceil(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 834, "func": "static int filter_frame(AVFilterLink *inlink, AVFrame *in)\n{\n PadContext *s = inlink->dst->priv;\n AVFrame *out;\n int needs_copy = frame_needs_copy(s, in);\n\n if (needs_copy) {\n av_log(inlink->dst, AV_LOG_DEBUG, \"Direct padding impossible allocating new frame\\n\");\n out = ff_get_video_buffer(inlink->dst->outputs[0],\n FFMAX(inlink->w, s->w),\n FFMAX(inlink->h, s->h));\n if (!out) {\n av_frame_free(&in);\n return AVERROR(ENOMEM);\n }\n\n av_frame_copy_props(out, in);\n } else {\n int i;\n\n out = in;\n for (i = 0; i < 4 && out->data[i]; i++) {\n int hsub = s->draw.hsub[i];\n int vsub = s->draw.vsub[i];\n out->data[i] -= (s->x >> hsub) * s->draw.pixelstep[i] +\n (s->y >> vsub) * out->linesize[i];\n }\n }\n\n /* top bar */\n if (s->y) {\n ff_fill_rectangle(&s->draw, &s->color,\n out->data, out->linesize,\n 0, 0, s->w, s->y);\n }\n\n /* bottom bar */\n if (s->h > s->y + s->in_h) {\n ff_fill_rectangle(&s->draw, &s->color,\n out->data, out->linesize,\n 0, s->y + s->in_h, s->w, s->h - s->y - s->in_h);\n }\n\n /* left border */\n ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize,\n 0, s->y, s->x, in->height);\n\n if (needs_copy) {\n ff_copy_rectangle2(&s->draw,\n out->data, out->linesize, in->data, in->linesize,\n s->x, s->y, 0, 0, in->width, in->height);\n }\n\n /* right border */\n ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize,\n s->x + s->in_w, s->y, s->w - s->x - s->in_w,\n in->height);\n\n out->width = s->w;\n out->height = s->h;\n\n if (in != out)\n av_frame_free(&in);\n return ff_filter_frame(inlink->dst->outputs[0], out);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-4263", "cwe_id": "CWE-119" }, { "id": 834, "func": "static int filter_frame(AVFilterLink *inlink, AVFrame *in)\n{\n PadContext *s = inlink->dst->priv;\n AVFrame *out;\n int needs_copy = frame_needs_copy(s, in);\n\n if (needs_copy) {\n av_log(inlink->dst, AV_LOG_DEBUG, \"Direct padding impossible allocating new frame\\n\");\n out = ff_get_video_buffer(inlink->dst->outputs[0],\n FFMAX(inlink->w, s->w),\n FFMAX(inlink->h, s->h));\n if (!out) {\n av_frame_free(&in);\n return AVERROR(ENOMEM);\n }\n\n av_frame_copy_props(out, in);\n } else {\n int i;\n\n out = in;\n for (i = 0; i < 4 && out->data[i] && out->linesize[i]; i++) {\n int hsub = s->draw.hsub[i];\n int vsub = s->draw.vsub[i];\n out->data[i] -= (s->x >> hsub) * s->draw.pixelstep[i] +\n (s->y >> vsub) * out->linesize[i];\n }\n }\n\n /* top bar */\n if (s->y) {\n ff_fill_rectangle(&s->draw, &s->color,\n out->data, out->linesize,\n 0, 0, s->w, s->y);\n }\n\n /* bottom bar */\n if (s->h > s->y + s->in_h) {\n ff_fill_rectangle(&s->draw, &s->color,\n out->data, out->linesize,\n 0, s->y + s->in_h, s->w, s->h - s->y - s->in_h);\n }\n\n /* left border */\n ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize,\n 0, s->y, s->x, in->height);\n\n if (needs_copy) {\n ff_copy_rectangle2(&s->draw,\n out->data, out->linesize, in->data, in->linesize,\n s->x, s->y, 0, 0, in->width, in->height);\n }\n\n /* right border */\n ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize,\n s->x + s->in_w, s->y, s->w - s->x - s->in_w,\n in->height);\n\n out->width = s->w;\n out->height = s->h;\n\n if (in != out)\n av_frame_free(&in);\n return ff_filter_frame(inlink->dst->outputs[0], out);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-4263", "cwe_id": "CWE-119" }, { "id": 1213, "func": " void Compute(OpKernelContext *ctx) override {\n const Tensor *indices_t, *values_t, *shape_t, *dense_t;\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_indices\", &indices_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_values\", &values_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_shape\", &shape_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"dense\", &dense_t));\n\n // Validations.\n OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices_t->shape()),\n errors::InvalidArgument(\n \"Input sp_indices should be a matrix but received shape: \",\n indices_t->shape().DebugString()));\n OP_REQUIRES(ctx,\n TensorShapeUtils::IsVector(values_t->shape()) &&\n TensorShapeUtils::IsVector(shape_t->shape()),\n errors::InvalidArgument(\n \"Inputs sp_values and sp_shape should be vectors \"\n \"but received shapes: \",\n values_t->shape().DebugString(), \" and \",\n shape_t->shape().DebugString()));\n OP_REQUIRES(\n ctx, TensorShapeUtils::IsVector(shape_t->shape()),\n errors::InvalidArgument(\"Input sp_shape must be a vector. Got: \",\n shape_t->shape().DebugString()));\n OP_REQUIRES(\n ctx, values_t->dim_size(0) == indices_t->dim_size(0),\n errors::InvalidArgument(\n \"The first dimension of values and indices should match. (\",\n values_t->dim_size(0), \" vs. \", indices_t->dim_size(0), \")\"));\n OP_REQUIRES(\n ctx, shape_t->shape().dim_size(0) == indices_t->shape().dim_size(1),\n errors::InvalidArgument(\n \"Number of dimensions must match second dimension of indices. \",\n \"Got \", shape_t->shape().dim_size(0),\n \" dimensions, indices shape: \", indices_t->shape().DebugString()));\n OP_REQUIRES(ctx, shape_t->NumElements() > 0,\n errors::InvalidArgument(\n \"The shape argument requires at least one element.\"));\n\n const auto indices_mat = indices_t->matrix();\n const auto shape_vec = shape_t->vec();\n const auto lhs_dims = BCast::FromShape(TensorShape(shape_vec));\n const auto rhs_dims = BCast::FromShape(dense_t->shape());\n BCast b(lhs_dims, rhs_dims, false); // false for keeping the same num dims.\n\n // True iff (size(lhs) >= size(rhs)) and all dims in lhs is greater or equal\n // to dims in rhs (from right to left).\n auto VecGreaterEq = [](ArraySlice lhs, ArraySlice rhs) {\n if (lhs.size() < rhs.size()) return false;\n for (size_t i = 0; i < rhs.size(); ++i) {\n if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false;\n }\n return true;\n };\n OP_REQUIRES(ctx, VecGreaterEq(lhs_dims, rhs_dims) && b.IsValid(),\n errors::InvalidArgument(\n \"SparseDenseBinaryOpShared broadcasts dense to sparse \"\n \"only; got incompatible shapes: [\",\n absl::StrJoin(lhs_dims, \",\"), \"] vs. [\",\n absl::StrJoin(rhs_dims, \",\"), \"]\"));\n\n Tensor *output_values = nullptr;\n Tensor dense_gathered;\n const int64_t nnz = indices_t->dim_size(0);\n OP_REQUIRES_OK(ctx,\n ctx->allocate_output(0, TensorShape({nnz}), &output_values));\n OP_REQUIRES_OK(\n ctx, ctx->allocate_temp(DataTypeToEnum::value, TensorShape({nnz}),\n &dense_gathered));\n bool op_is_div = false;\n if (absl::StrContains(ctx->op_kernel().type_string_view(), \"Div\")) {\n op_is_div = true;\n }\n // Pulls relevant entries from the dense side, with reshape and broadcasting\n // *of the dense side* taken into account. Use a TensorRef to avoid blowing\n // up memory.\n //\n // We can directly use the sparse indices to look up dense side, because\n // \"b.y_reshape()\" and \"b.y_bcast()\" are guaranteed to have rank \"ndims\".\n auto dense_gathered_flat = dense_gathered.flat();\n const int ndims = lhs_dims.size();\n switch (ndims) {\n#define CASE(NDIM) \\\n case NDIM: { \\\n TensorRef> rhs_ref = \\\n dense_t->shaped(b.y_reshape()) \\\n .broadcast(BCast::ToIndexArray(b.y_bcast())); \\\n Eigen::array idx; \\\n bool indices_valid = true; \\\n for (int i = 0; i < nnz; ++i) { \\\n for (int d = 0; d < NDIM; ++d) { \\\n idx[d] = internal::SubtleMustCopy(indices_mat(i, d)); \\\n if (!FastBoundsCheck(idx[d], rhs_ref.dimension(d))) { \\\n indices_valid = false; \\\n } \\\n } \\\n OP_REQUIRES( \\\n ctx, indices_valid, \\\n errors::InvalidArgument(\"Provided indices are out-of-bounds w.r.t. \" \\\n \"dense side with broadcasted shape\")); \\\n dense_gathered_flat(i) = rhs_ref.coeff(idx); \\\n if (op_is_div) { \\\n OP_REQUIRES(ctx, dense_gathered_flat(i) != 0, \\\n errors::InvalidArgument( \\\n \"SparseDenseCwiseDiv cannot divide by zero,\" \\\n \"but input dense tensor contains zero \")); \\\n } \\\n } \\\n break; \\\n }\n\n CASE(1);\n CASE(2);\n CASE(3);\n CASE(4);\n CASE(5);\n default:\n OP_REQUIRES(\n ctx, false,\n errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n \"are currently supported. Tensor rank: \",\n ndims));\n#undef CASE\n }\n\n output_values->flat().device(ctx->eigen_device()) =\n values_t->flat().binaryExpr(dense_gathered_flat,\n typename Functor::func());\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-23567", "cwe_id": "CWE-190" }, { "id": 1213, "func": " void Compute(OpKernelContext *ctx) override {\n const Tensor *indices_t, *values_t, *shape_t, *dense_t;\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_indices\", &indices_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_values\", &values_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"sp_shape\", &shape_t));\n OP_REQUIRES_OK(ctx, ctx->input(\"dense\", &dense_t));\n\n // Validations.\n OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices_t->shape()),\n errors::InvalidArgument(\n \"Input sp_indices should be a matrix but received shape: \",\n indices_t->shape().DebugString()));\n OP_REQUIRES(ctx,\n TensorShapeUtils::IsVector(values_t->shape()) &&\n TensorShapeUtils::IsVector(shape_t->shape()),\n errors::InvalidArgument(\n \"Inputs sp_values and sp_shape should be vectors \"\n \"but received shapes: \",\n values_t->shape().DebugString(), \" and \",\n shape_t->shape().DebugString()));\n OP_REQUIRES(\n ctx, TensorShapeUtils::IsVector(shape_t->shape()),\n errors::InvalidArgument(\"Input sp_shape must be a vector. Got: \",\n shape_t->shape().DebugString()));\n OP_REQUIRES(\n ctx, values_t->dim_size(0) == indices_t->dim_size(0),\n errors::InvalidArgument(\n \"The first dimension of values and indices should match. (\",\n values_t->dim_size(0), \" vs. \", indices_t->dim_size(0), \")\"));\n OP_REQUIRES(\n ctx, shape_t->shape().dim_size(0) == indices_t->shape().dim_size(1),\n errors::InvalidArgument(\n \"Number of dimensions must match second dimension of indices. \",\n \"Got \", shape_t->shape().dim_size(0),\n \" dimensions, indices shape: \", indices_t->shape().DebugString()));\n OP_REQUIRES(ctx, shape_t->NumElements() > 0,\n errors::InvalidArgument(\n \"The shape argument requires at least one element.\"));\n\n const auto indices_mat = indices_t->matrix();\n const auto shape_vec = shape_t->vec();\n TensorShape lhs_shape;\n OP_REQUIRES_OK(ctx, TensorShape::BuildTensorShape(shape_vec, &lhs_shape));\n const auto lhs_dims = BCast::FromShape(lhs_shape);\n const auto rhs_dims = BCast::FromShape(dense_t->shape());\n BCast b(lhs_dims, rhs_dims, false); // false for keeping the same num dims.\n\n // True iff (size(lhs) >= size(rhs)) and all dims in lhs is greater or equal\n // to dims in rhs (from right to left).\n auto VecGreaterEq = [](ArraySlice lhs, ArraySlice rhs) {\n if (lhs.size() < rhs.size()) return false;\n for (size_t i = 0; i < rhs.size(); ++i) {\n if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false;\n }\n return true;\n };\n OP_REQUIRES(ctx, VecGreaterEq(lhs_dims, rhs_dims) && b.IsValid(),\n errors::InvalidArgument(\n \"SparseDenseBinaryOpShared broadcasts dense to sparse \"\n \"only; got incompatible shapes: [\",\n absl::StrJoin(lhs_dims, \",\"), \"] vs. [\",\n absl::StrJoin(rhs_dims, \",\"), \"]\"));\n\n Tensor *output_values = nullptr;\n Tensor dense_gathered;\n const int64_t nnz = indices_t->dim_size(0);\n OP_REQUIRES_OK(ctx,\n ctx->allocate_output(0, TensorShape({nnz}), &output_values));\n OP_REQUIRES_OK(\n ctx, ctx->allocate_temp(DataTypeToEnum::value, TensorShape({nnz}),\n &dense_gathered));\n bool op_is_div = false;\n if (absl::StrContains(ctx->op_kernel().type_string_view(), \"Div\")) {\n op_is_div = true;\n }\n // Pulls relevant entries from the dense side, with reshape and broadcasting\n // *of the dense side* taken into account. Use a TensorRef to avoid blowing\n // up memory.\n //\n // We can directly use the sparse indices to look up dense side, because\n // \"b.y_reshape()\" and \"b.y_bcast()\" are guaranteed to have rank \"ndims\".\n auto dense_gathered_flat = dense_gathered.flat();\n const int ndims = lhs_dims.size();\n switch (ndims) {\n#define CASE(NDIM) \\\n case NDIM: { \\\n TensorRef> rhs_ref = \\\n dense_t->shaped(b.y_reshape()) \\\n .broadcast(BCast::ToIndexArray(b.y_bcast())); \\\n Eigen::array idx; \\\n bool indices_valid = true; \\\n for (int i = 0; i < nnz; ++i) { \\\n for (int d = 0; d < NDIM; ++d) { \\\n idx[d] = internal::SubtleMustCopy(indices_mat(i, d)); \\\n if (!FastBoundsCheck(idx[d], rhs_ref.dimension(d))) { \\\n indices_valid = false; \\\n } \\\n } \\\n OP_REQUIRES( \\\n ctx, indices_valid, \\\n errors::InvalidArgument(\"Provided indices are out-of-bounds w.r.t. \" \\\n \"dense side with broadcasted shape\")); \\\n dense_gathered_flat(i) = rhs_ref.coeff(idx); \\\n if (op_is_div) { \\\n OP_REQUIRES(ctx, dense_gathered_flat(i) != 0, \\\n errors::InvalidArgument( \\\n \"SparseDenseCwiseDiv cannot divide by zero,\" \\\n \"but input dense tensor contains zero \")); \\\n } \\\n } \\\n break; \\\n }\n\n CASE(1);\n CASE(2);\n CASE(3);\n CASE(4);\n CASE(5);\n default:\n OP_REQUIRES(\n ctx, false,\n errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n \"are currently supported. Tensor rank: \",\n ndims));\n#undef CASE\n }\n\n output_values->flat().device(ctx->eigen_device()) =\n values_t->flat().binaryExpr(dense_gathered_flat,\n typename Functor::func());\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-23567", "cwe_id": "CWE-190" }, { "id": 119, "func": "vhost_scsi_make_tpg(struct se_wwn *wwn,\n\t\t struct config_group *group,\n\t\t const char *name)\n{\n\tstruct vhost_scsi_tport *tport = container_of(wwn,\n\t\t\tstruct vhost_scsi_tport, tport_wwn);\n\n\tstruct vhost_scsi_tpg *tpg;\n\tunsigned long tpgt;\n\tint ret;\n\n\tif (strstr(name, \"tpgt_\") != name)\n\t\treturn ERR_PTR(-EINVAL);\n\tif (kstrtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n\t\treturn ERR_PTR(-EINVAL);\n\n\ttpg = kzalloc(sizeof(struct vhost_scsi_tpg), GFP_KERNEL);\n\tif (!tpg) {\n\t\tpr_err(\"Unable to allocate struct vhost_scsi_tpg\");\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\tmutex_init(&tpg->tv_tpg_mutex);\n\tINIT_LIST_HEAD(&tpg->tv_tpg_list);\n\ttpg->tport = tport;\n\ttpg->tport_tpgt = tpgt;\n\n\tret = core_tpg_register(&vhost_scsi_fabric_configfs->tf_ops, wwn,\n\t\t\t\t&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);\n\tif (ret < 0) {\n\t\tkfree(tpg);\n\t\treturn NULL;\n\t}\n\tmutex_lock(&vhost_scsi_mutex);\n\tlist_add_tail(&tpg->tv_tpg_list, &vhost_scsi_list);\n\tmutex_unlock(&vhost_scsi_mutex);\n\n\treturn &tpg->se_tpg;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-4036", "cwe_id": "CWE-119" }, { "id": 119, "func": "vhost_scsi_make_tpg(struct se_wwn *wwn,\n\t\t struct config_group *group,\n\t\t const char *name)\n{\n\tstruct vhost_scsi_tport *tport = container_of(wwn,\n\t\t\tstruct vhost_scsi_tport, tport_wwn);\n\n\tstruct vhost_scsi_tpg *tpg;\n\tu16 tpgt;\n\tint ret;\n\n\tif (strstr(name, \"tpgt_\") != name)\n\t\treturn ERR_PTR(-EINVAL);\n\tif (kstrtou16(name + 5, 10, &tpgt) || tpgt >= VHOST_SCSI_MAX_TARGET)\n\t\treturn ERR_PTR(-EINVAL);\n\n\ttpg = kzalloc(sizeof(struct vhost_scsi_tpg), GFP_KERNEL);\n\tif (!tpg) {\n\t\tpr_err(\"Unable to allocate struct vhost_scsi_tpg\");\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\tmutex_init(&tpg->tv_tpg_mutex);\n\tINIT_LIST_HEAD(&tpg->tv_tpg_list);\n\ttpg->tport = tport;\n\ttpg->tport_tpgt = tpgt;\n\n\tret = core_tpg_register(&vhost_scsi_fabric_configfs->tf_ops, wwn,\n\t\t\t\t&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);\n\tif (ret < 0) {\n\t\tkfree(tpg);\n\t\treturn NULL;\n\t}\n\tmutex_lock(&vhost_scsi_mutex);\n\tlist_add_tail(&tpg->tv_tpg_list, &vhost_scsi_list);\n\tmutex_unlock(&vhost_scsi_mutex);\n\n\treturn &tpg->se_tpg;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-4036", "cwe_id": "CWE-119" }, { "id": 1119, "func": "void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,\n\t\t struct ath_node *an)\n{\n\tstruct ath_atx_tid *tid;\n\tstruct ath_atx_ac *ac;\n\tstruct ath_txq *txq;\n\tbool buffered;\n\tint tidno;\n\n\tfor (tidno = 0, tid = &an->tid[tidno];\n\t tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {\n\n\t\tif (!tid->sched)\n\t\t\tcontinue;\n\n\t\tac = tid->ac;\n\t\ttxq = ac->txq;\n\n\t\tath_txq_lock(sc, txq);\n\n\t\tbuffered = ath_tid_has_buffered(tid);\n\n\t\ttid->sched = false;\n\t\tlist_del(&tid->list);\n\n\t\tif (ac->sched) {\n\t\t\tac->sched = false;\n\t\t\tlist_del(&ac->list);\n\t\t}\n\n\t\tath_txq_unlock(sc, txq);\n\n\t\tieee80211_sta_set_buffered(sta, tidno, buffered);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-2672", "cwe_id": "CWE-362" }, { "id": 1119, "func": "void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,\n\t\t struct ath_node *an)\n{\n\tstruct ath_atx_tid *tid;\n\tstruct ath_atx_ac *ac;\n\tstruct ath_txq *txq;\n\tbool buffered;\n\tint tidno;\n\n\tfor (tidno = 0, tid = &an->tid[tidno];\n\t tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {\n\n\t\tac = tid->ac;\n\t\ttxq = ac->txq;\n\n\t\tath_txq_lock(sc, txq);\n\n\t\tif (!tid->sched) {\n\t\t\tath_txq_unlock(sc, txq);\n\t\t\tcontinue;\n\t\t}\n\n\t\tbuffered = ath_tid_has_buffered(tid);\n\n\t\ttid->sched = false;\n\t\tlist_del(&tid->list);\n\n\t\tif (ac->sched) {\n\t\t\tac->sched = false;\n\t\t\tlist_del(&ac->list);\n\t\t}\n\n\t\tath_txq_unlock(sc, txq);\n\n\t\tieee80211_sta_set_buffered(sta, tidno, buffered);\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-2672", "cwe_id": "CWE-362" }, { "id": 1306, "func": "GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod, Bool single_group, Bool hint_no_offset)\n{\n\tGF_ESD *esd;\n\tGF_InitialObjectDescriptor *iod;\n\tu32 i, val, res, streamType;\n\tu32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type;\n\tGF_Err e;\n\tchar szPayload[30];\n\tGF_RTPHinter *hinter;\n\tBool copy, has_iod, single_av;\n\tu8 init_payt = BASE_PAYT;\n\tu32 mtype;\n\tGF_SDP_IODProfile iod_mode = GF_SDP_IOD_NONE;\n\tu32 media_group = 0;\n\tu8 media_prio = 0;\n\n\ttot_bw = 0;\n\tprev_ocr = 0;\n\tsingle_ocr = 1;\n\n\thas_iod = 1;\n\tiod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);\n\tif (!iod) has_iod = 0;\n\telse {\n\t\tif (!gf_list_count(iod->ESDescriptors)) has_iod = 0;\n\t\tgf_odf_desc_del((GF_Descriptor *) iod);\n\t}\n\n\tspec_type = gf_isom_guess_specification(file);\n\tsingle_av = single_group ? 1 : gf_isom_is_single_av(file);\n\n\t/*first make sure we use a systems track as base OCR*/\n\tfor (i=0; idecoderConfig->streamType;\n\t\t\tif (!prev_ocr) {\n\t\t\t\tprev_ocr = esd->OCRESID;\n\t\t\t\tif (!esd->OCRESID) prev_ocr = esd->ESID;\n\t\t\t} else if (esd->OCRESID && prev_ocr != esd->OCRESID) {\n\t\t\t\tsingle_ocr = 0;\n\t\t\t}\n\t\t\t/*OD MUST BE WITHOUT REFERENCES*/\n\t\t\tif (streamType==1) copy = 1;\n\t\t}\n\t\tgf_odf_desc_del((GF_Descriptor *) esd);\n\n\t\tif (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) {\n\t\t\t/*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*/\n\t\t\tif (gf_isom_get_sample_count(file, i+1)==1) {\n\t\t\t\tGF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val);\n\t\t\t\tif (streamType) {\n\t\t\t\t\tres = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType);\n\t\t\t\t} else {\n\t\t\t\t\t/*not a system track, we shall hint it*/\n\t\t\t\t\tres = 0;\n\t\t\t\t}\n\t\t\t\tif (samp) gf_isom_sample_del(&samp);\n\t\t\t\tif (res) continue;\n\t\t\t}\n\t\t}\n\t\tif (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING;\n\n\t\thinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e);\n\n\t\tif (!hinter) {\n\t\t\tif (e) {\n\t\t\t\tM4_LOG(nb_done ? GF_LOG_WARNING : GF_LOG_ERROR, (\"Cannot create hinter (%s)\\n\", gf_error_to_string(e) ));\n\t\t\t\tif (!nb_done) return e;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hint_no_offset)\n\t\t\tgf_hinter_track_force_no_offsets(hinter);\n\n\t\tbw = gf_hinter_track_get_bandwidth(hinter);\n\t\ttot_bw += bw;\n\t\tflags = gf_hinter_track_get_flags(hinter);\n\n\t\t//set extraction mode for AVC/SVC\n\t\tgf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY);\n\n\t\tgf_hinter_track_get_payload_name(hinter, szPayload);\n\t\tM4_LOG(GF_LOG_INFO, (\"Hinting track ID %d - Type \\\"%s:%s\\\" (%s) - BW %d kbps\\n\", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw));\n\t\tif (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) M4_LOG(GF_LOG_INFO, (\"\\tMPEG-4 Systems stream carousel enabled\\n\"));\n\t\te = gf_hinter_track_process(hinter);\n\n\t\tif (!e) e = gf_hinter_track_finalize(hinter, has_iod);\n\t\tgf_hinter_track_del(hinter);\n\n\t\tif (e) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Error while hinting (%s)\\n\", gf_error_to_string(e)));\n\t\t\tif (!nb_done) return e;\n\t\t}\n\t\tinit_payt++;\n\t\tnb_done ++;\n\t}\n\n\tif (has_iod) {\n\t\tiod_mode = GF_SDP_IOD_ISMA;\n\t\tif (regular_iod) iod_mode = GF_SDP_IOD_REGULAR;\n\t} else {\n\t\tiod_mode = GF_SDP_IOD_NONE;\n\t}\n\tgf_hinter_finalize(file, iod_mode, tot_bw);\n\n\tif (!single_ocr)\n\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: at least 2 timelines found in the file\\nThis may not be supported by servers/players\\n\\n\"));\n\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-31257", "cwe_id": "CWE-476" }, { "id": 1306, "func": "GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod, Bool single_group, Bool hint_no_offset)\n{\n\tGF_ESD *esd;\n\tGF_InitialObjectDescriptor *iod;\n\tu32 i, val, res, streamType;\n\tu32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type;\n\tGF_Err e;\n\tchar szPayload[30];\n\tGF_RTPHinter *hinter;\n\tBool copy, has_iod, single_av;\n\tu8 init_payt = BASE_PAYT;\n\tu32 mtype;\n\tGF_SDP_IODProfile iod_mode = GF_SDP_IOD_NONE;\n\tu32 media_group = 0;\n\tu8 media_prio = 0;\n\n\ttot_bw = 0;\n\tprev_ocr = 0;\n\tsingle_ocr = 1;\n\n\thas_iod = 1;\n\tiod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);\n\tif (!iod) has_iod = 0;\n\telse {\n\t\tif (!gf_list_count(iod->ESDescriptors)) has_iod = 0;\n\t\tgf_odf_desc_del((GF_Descriptor *) iod);\n\t}\n\n\tspec_type = gf_isom_guess_specification(file);\n\tsingle_av = single_group ? 1 : gf_isom_is_single_av(file);\n\n\t/*first make sure we use a systems track as base OCR*/\n\tfor (i=0; idecoderConfig) {\n\t\t\tstreamType = esd->decoderConfig->streamType;\n\t\t\tif (!prev_ocr) {\n\t\t\t\tprev_ocr = esd->OCRESID;\n\t\t\t\tif (!esd->OCRESID) prev_ocr = esd->ESID;\n\t\t\t} else if (esd->OCRESID && prev_ocr != esd->OCRESID) {\n\t\t\t\tsingle_ocr = 0;\n\t\t\t}\n\t\t\t/*OD MUST BE WITHOUT REFERENCES*/\n\t\t\tif (streamType==1) copy = 1;\n\t\t}\n\t\tgf_odf_desc_del((GF_Descriptor *) esd);\n\n\t\tif (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) {\n\t\t\t/*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*/\n\t\t\tif (gf_isom_get_sample_count(file, i+1)==1) {\n\t\t\t\tGF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val);\n\t\t\t\tif (streamType) {\n\t\t\t\t\tres = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType);\n\t\t\t\t} else {\n\t\t\t\t\t/*not a system track, we shall hint it*/\n\t\t\t\t\tres = 0;\n\t\t\t\t}\n\t\t\t\tif (samp) gf_isom_sample_del(&samp);\n\t\t\t\tif (res) continue;\n\t\t\t}\n\t\t}\n\t\tif (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING;\n\n\t\thinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e);\n\n\t\tif (!hinter) {\n\t\t\tif (e) {\n\t\t\t\tM4_LOG(nb_done ? GF_LOG_WARNING : GF_LOG_ERROR, (\"Cannot create hinter (%s)\\n\", gf_error_to_string(e) ));\n\t\t\t\tif (!nb_done) return e;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hint_no_offset)\n\t\t\tgf_hinter_track_force_no_offsets(hinter);\n\n\t\tbw = gf_hinter_track_get_bandwidth(hinter);\n\t\ttot_bw += bw;\n\t\tflags = gf_hinter_track_get_flags(hinter);\n\n\t\t//set extraction mode for AVC/SVC\n\t\tgf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY);\n\n\t\tgf_hinter_track_get_payload_name(hinter, szPayload);\n\t\tM4_LOG(GF_LOG_INFO, (\"Hinting track ID %d - Type \\\"%s:%s\\\" (%s) - BW %d kbps\\n\", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw));\n\t\tif (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) M4_LOG(GF_LOG_INFO, (\"\\tMPEG-4 Systems stream carousel enabled\\n\"));\n\t\te = gf_hinter_track_process(hinter);\n\n\t\tif (!e) e = gf_hinter_track_finalize(hinter, has_iod);\n\t\tgf_hinter_track_del(hinter);\n\n\t\tif (e) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Error while hinting (%s)\\n\", gf_error_to_string(e)));\n\t\t\tif (!nb_done) return e;\n\t\t}\n\t\tinit_payt++;\n\t\tnb_done ++;\n\t}\n\n\tif (has_iod) {\n\t\tiod_mode = GF_SDP_IOD_ISMA;\n\t\tif (regular_iod) iod_mode = GF_SDP_IOD_REGULAR;\n\t} else {\n\t\tiod_mode = GF_SDP_IOD_NONE;\n\t}\n\tgf_hinter_finalize(file, iod_mode, tot_bw);\n\n\tif (!single_ocr)\n\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: at least 2 timelines found in the file\\nThis may not be supported by servers/players\\n\\n\"));\n\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-31257", "cwe_id": "CWE-476" }, { "id": 326, "func": "trustedGenDkgSecretAES(int *errStatus, char *errString, uint8_t *encrypted_dkg_secret, uint32_t *enc_len, size_t _t) {\n LOG_INFO(__FUNCTION__);\n INIT_ERROR_STATE\n\n CHECK_STATE(encrypted_dkg_secret);\n\n SAFE_CHAR_BUF(dkg_secret, DKG_BUFER_LENGTH);\n\n int status = gen_dkg_poly(dkg_secret, _t);\n\n CHECK_STATUS(\"gen_dkg_poly failed\")\n\n status = AES_encrypt(dkg_secret, encrypted_dkg_secret, 3 * BUF_LEN);\n\n CHECK_STATUS(\"SGX AES encrypt DKG poly failed\");\n\n *enc_len = strlen(dkg_secret) + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE;\n\n SAFE_CHAR_BUF(decr_dkg_secret, DKG_BUFER_LENGTH);\n\n status = AES_decrypt(encrypted_dkg_secret, *enc_len, decr_dkg_secret,\n DKG_BUFER_LENGTH);\n\n CHECK_STATUS(\"aes decrypt dkg poly failed\");\n\n if (strcmp(dkg_secret, decr_dkg_secret) != 0) {\n snprintf(errString, BUF_LEN,\n \"encrypted poly is not equal to decrypted poly\");\n LOG_ERROR(errString);\n *errStatus = -333;\n goto clean;\n }\n\n SET_SUCCESS\n clean:\n ;\n LOG_INFO(__FUNCTION__ );\n LOG_INFO(\"SGX call completed\");\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 326, "func": "trustedGenDkgSecretAES(int *errStatus, char *errString, uint8_t *encrypted_dkg_secret, uint64_t *enc_len, size_t _t) {\n LOG_INFO(__FUNCTION__);\n INIT_ERROR_STATE\n\n CHECK_STATE(encrypted_dkg_secret);\n\n SAFE_CHAR_BUF(dkg_secret, DKG_BUFER_LENGTH);\n\n int status = gen_dkg_poly(dkg_secret, _t);\n\n CHECK_STATUS(\"gen_dkg_poly failed\")\n\n status = AES_encrypt(dkg_secret, encrypted_dkg_secret, 3 * BUF_LEN,\n DKG, DECRYPTABLE, enc_len);\n\n CHECK_STATUS(\"SGX AES encrypt DKG poly failed\");\n\n\n\n SAFE_CHAR_BUF(decr_dkg_secret, DKG_BUFER_LENGTH);\n\n status = AES_decrypt(encrypted_dkg_secret, *enc_len, decr_dkg_secret,\n DKG_BUFER_LENGTH);\n\n CHECK_STATUS(\"aes decrypt dkg poly failed\");\n\n if (strcmp(dkg_secret, decr_dkg_secret) != 0) {\n snprintf(errString, BUF_LEN,\n \"encrypted poly is not equal to decrypted poly\");\n LOG_ERROR(errString);\n *errStatus = -333;\n goto clean;\n }\n\n SET_SUCCESS\n clean:\n ;\n LOG_INFO(__FUNCTION__ );\n LOG_INFO(\"SGX call completed\");\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 247, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n#define TF_LITE_DEPTH_TO_SPACE(type, scalar) \\\n tflite::DepthToSpaceParams op_params; \\\n op_params.block_size = params->block_size; \\\n type::DepthToSpace(op_params, GetTensorShape(input), \\\n GetTensorData(input), GetTensorShape(output), \\\n GetTensorData(output))\n switch (input->type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, float);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, float);\n }\n break;\n case kTfLiteUInt8:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, uint8_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, uint8_t);\n }\n break;\n case kTfLiteInt8:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int8_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int8_t);\n }\n break;\n case kTfLiteInt32:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int32_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int32_t);\n }\n break;\n case kTfLiteInt64:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int64_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int64_t);\n }\n break;\n default:\n context->ReportError(context, \"Type '%s' not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n#undef TF_LITE_DEPTH_TO_SPACE\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 247, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n#define TF_LITE_DEPTH_TO_SPACE(type, scalar) \\\n tflite::DepthToSpaceParams op_params; \\\n op_params.block_size = params->block_size; \\\n type::DepthToSpace(op_params, GetTensorShape(input), \\\n GetTensorData(input), GetTensorShape(output), \\\n GetTensorData(output))\n switch (input->type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, float);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, float);\n }\n break;\n case kTfLiteUInt8:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, uint8_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, uint8_t);\n }\n break;\n case kTfLiteInt8:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int8_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int8_t);\n }\n break;\n case kTfLiteInt32:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int32_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int32_t);\n }\n break;\n case kTfLiteInt64:\n if (kernel_type == kReference) {\n TF_LITE_DEPTH_TO_SPACE(reference_ops, int64_t);\n } else {\n TF_LITE_DEPTH_TO_SPACE(optimized_ops, int64_t);\n }\n break;\n default:\n context->ReportError(context, \"Type '%s' not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n#undef TF_LITE_DEPTH_TO_SPACE\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 991, "func": "l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {\n CallInfo *ci = L->ci;\n const char *msg;\n va_list argp;\n luaC_checkGC(L); /* error message uses memory */\n va_start(argp, fmt);\n msg = luaO_pushvfstring(L, fmt, argp); /* format message */\n va_end(argp);\n if (isLua(ci)) /* if Lua function, add source:line information */\n luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));\n luaG_errormsg(L);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-33099", "cwe_id": "CWE-787" }, { "id": 991, "func": "l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {\n CallInfo *ci = L->ci;\n const char *msg;\n va_list argp;\n luaC_checkGC(L); /* error message uses memory */\n va_start(argp, fmt);\n msg = luaO_pushvfstring(L, fmt, argp); /* format message */\n va_end(argp);\n if (isLua(ci)) { /* if Lua function, add source:line information */\n luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));\n setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */\n L->top--;\n }\n luaG_errormsg(L);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-33099", "cwe_id": "CWE-787" }, { "id": 3027, "func": "int cipso_v4_sock_setattr(struct sock *sk,\n\t\t\t const struct cipso_v4_doi *doi_def,\n\t\t\t const struct netlbl_lsm_secattr *secattr)\n{\n\tint ret_val = -EPERM;\n\tunsigned char *buf = NULL;\n\tu32 buf_len;\n\tu32 opt_len;\n\tstruct ip_options *opt = NULL;\n\tstruct inet_sock *sk_inet;\n\tstruct inet_connection_sock *sk_conn;\n\n\t/* In the case of sock_create_lite(), the sock->sk field is not\n\t * defined yet but it is not a problem as the only users of these\n\t * \"lite\" PF_INET sockets are functions which do an accept() call\n\t * afterwards so we will label the socket as part of the accept(). */\n\tif (sk == NULL)\n\t\treturn 0;\n\n\t/* We allocate the maximum CIPSO option size here so we are probably\n\t * being a little wasteful, but it makes our life _much_ easier later\n\t * on and after all we are only talking about 40 bytes. */\n\tbuf_len = CIPSO_V4_OPT_LEN_MAX;\n\tbuf = kmalloc(buf_len, GFP_ATOMIC);\n\tif (buf == NULL) {\n\t\tret_val = -ENOMEM;\n\t\tgoto socket_setattr_failure;\n\t}\n\n\tret_val = cipso_v4_genopt(buf, buf_len, doi_def, secattr);\n\tif (ret_val < 0)\n\t\tgoto socket_setattr_failure;\n\tbuf_len = ret_val;\n\n\t/* We can't use ip_options_get() directly because it makes a call to\n\t * ip_options_get_alloc() which allocates memory with GFP_KERNEL and\n\t * we won't always have CAP_NET_RAW even though we _always_ want to\n\t * set the IPOPT_CIPSO option. */\n\topt_len = (buf_len + 3) & ~3;\n\topt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);\n\tif (opt == NULL) {\n\t\tret_val = -ENOMEM;\n\t\tgoto socket_setattr_failure;\n\t}\n\tmemcpy(opt->__data, buf, buf_len);\n\topt->optlen = opt_len;\n\topt->cipso = sizeof(struct iphdr);\n\tkfree(buf);\n\tbuf = NULL;\n\n\tsk_inet = inet_sk(sk);\n\tif (sk_inet->is_icsk) {\n\t\tsk_conn = inet_csk(sk);\n\t\tif (sk_inet->opt)\n\t\t\tsk_conn->icsk_ext_hdr_len -= sk_inet->opt->optlen;\n\t\tsk_conn->icsk_ext_hdr_len += opt->optlen;\n\t\tsk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);\n\t}\n\topt = xchg(&sk_inet->opt, opt);\n\tkfree(opt);\n\n\treturn 0;\n\nsocket_setattr_failure:\n\tkfree(buf);\n\tkfree(opt);\n\treturn ret_val;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 3027, "func": "int cipso_v4_sock_setattr(struct sock *sk,\n\t\t\t const struct cipso_v4_doi *doi_def,\n\t\t\t const struct netlbl_lsm_secattr *secattr)\n{\n\tint ret_val = -EPERM;\n\tunsigned char *buf = NULL;\n\tu32 buf_len;\n\tu32 opt_len;\n\tstruct ip_options_rcu *old, *opt = NULL;\n\tstruct inet_sock *sk_inet;\n\tstruct inet_connection_sock *sk_conn;\n\n\t/* In the case of sock_create_lite(), the sock->sk field is not\n\t * defined yet but it is not a problem as the only users of these\n\t * \"lite\" PF_INET sockets are functions which do an accept() call\n\t * afterwards so we will label the socket as part of the accept(). */\n\tif (sk == NULL)\n\t\treturn 0;\n\n\t/* We allocate the maximum CIPSO option size here so we are probably\n\t * being a little wasteful, but it makes our life _much_ easier later\n\t * on and after all we are only talking about 40 bytes. */\n\tbuf_len = CIPSO_V4_OPT_LEN_MAX;\n\tbuf = kmalloc(buf_len, GFP_ATOMIC);\n\tif (buf == NULL) {\n\t\tret_val = -ENOMEM;\n\t\tgoto socket_setattr_failure;\n\t}\n\n\tret_val = cipso_v4_genopt(buf, buf_len, doi_def, secattr);\n\tif (ret_val < 0)\n\t\tgoto socket_setattr_failure;\n\tbuf_len = ret_val;\n\n\t/* We can't use ip_options_get() directly because it makes a call to\n\t * ip_options_get_alloc() which allocates memory with GFP_KERNEL and\n\t * we won't always have CAP_NET_RAW even though we _always_ want to\n\t * set the IPOPT_CIPSO option. */\n\topt_len = (buf_len + 3) & ~3;\n\topt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);\n\tif (opt == NULL) {\n\t\tret_val = -ENOMEM;\n\t\tgoto socket_setattr_failure;\n\t}\n\tmemcpy(opt->opt.__data, buf, buf_len);\n\topt->opt.optlen = opt_len;\n\topt->opt.cipso = sizeof(struct iphdr);\n\tkfree(buf);\n\tbuf = NULL;\n\n\tsk_inet = inet_sk(sk);\n\n\told = rcu_dereference_protected(sk_inet->inet_opt, sock_owned_by_user(sk));\n\tif (sk_inet->is_icsk) {\n\t\tsk_conn = inet_csk(sk);\n\t\tif (old)\n\t\t\tsk_conn->icsk_ext_hdr_len -= old->opt.optlen;\n\t\tsk_conn->icsk_ext_hdr_len += opt->opt.optlen;\n\t\tsk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);\n\t}\n\trcu_assign_pointer(sk_inet->inet_opt, opt);\n\tif (old)\n\t\tcall_rcu(&old->rcu, opt_kfree_rcu);\n\n\treturn 0;\n\nsocket_setattr_failure:\n\tkfree(buf);\n\tkfree(opt);\n\treturn ret_val;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 3051, "func": "static int pop_fetch_message (CONTEXT* ctx, MESSAGE* msg, int msgno)\n{\n int ret;\n void *uidl;\n char buf[LONG_STRING];\n char path[_POSIX_PATH_MAX];\n progress_t progressbar;\n POP_DATA *pop_data = (POP_DATA *)ctx->data;\n POP_CACHE *cache;\n HEADER *h = ctx->hdrs[msgno];\n unsigned short bcache = 1;\n\n /* see if we already have the message in body cache */\n if ((msg->fp = mutt_bcache_get (pop_data->bcache, h->data)))\n return 0;\n\n /*\n * see if we already have the message in our cache in\n * case $message_cachedir is unset\n */\n cache = &pop_data->cache[h->index % POP_CACHE_LEN];\n\n if (cache->path)\n {\n if (cache->index == h->index)\n {\n /* yes, so just return a pointer to the message */\n msg->fp = fopen (cache->path, \"r\");\n if (msg->fp)\n\treturn 0;\n \n mutt_perror (cache->path);\n mutt_sleep (2);\n return -1;\n }\n else\n {\n /* clear the previous entry */\n unlink (cache->path);\n FREE (&cache->path);\n }\n }\n\n FOREVER\n {\n if (pop_reconnect (ctx) < 0)\n return -1;\n\n /* verify that massage index is correct */\n if (h->refno < 0)\n {\n mutt_error _(\"The message index is incorrect. Try reopening the mailbox.\");\n mutt_sleep (2);\n return -1;\n }\n\n mutt_progress_init (&progressbar, _(\"Fetching message...\"),\n\t\t\tMUTT_PROGRESS_SIZE, NetInc, h->content->length + h->content->offset - 1);\n\n /* see if we can put in body cache; use our cache as fallback */\n if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data, 1)))\n {\n /* no */\n bcache = 0;\n mutt_mktemp (path, sizeof (path));\n if (!(msg->fp = safe_fopen (path, \"w+\")))\n {\n\tmutt_perror (path);\n\tmutt_sleep (2);\n\treturn -1;\n }\n }\n\n snprintf (buf, sizeof (buf), \"RETR %d\\r\\n\", h->refno);\n\n ret = pop_fetch_data (pop_data, buf, &progressbar, fetch_message, msg->fp);\n if (ret == 0)\n break;\n\n safe_fclose (&msg->fp);\n\n /* if RETR failed (e.g. connection closed), be sure to remove either\n * the file in bcache or from POP's own cache since the next iteration\n * of the loop will re-attempt to put() the message */\n if (!bcache)\n unlink (path);\n\n if (ret == -2)\n {\n mutt_error (\"%s\", pop_data->err_msg);\n mutt_sleep (2);\n return -1;\n }\n\n if (ret == -3)\n {\n mutt_error _(\"Can't write message to temporary file!\");\n mutt_sleep (2);\n return -1;\n }\n }\n\n /* Update the header information. Previously, we only downloaded a\n * portion of the headers, those required for the main display.\n */\n if (bcache)\n mutt_bcache_commit (pop_data->bcache, h->data);\n else\n {\n cache->index = h->index;\n cache->path = safe_strdup (path);\n }\n rewind (msg->fp);\n uidl = h->data;\n\n /* we replace envelop, key in subj_hash has to be updated as well */\n if (ctx->subj_hash && h->env->real_subj)\n hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);\n mutt_label_hash_remove (ctx, h);\n mutt_free_envelope (&h->env);\n h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);\n if (ctx->subj_hash && h->env->real_subj)\n hash_insert (ctx->subj_hash, h->env->real_subj, h);\n mutt_label_hash_add (ctx, h);\n\n h->data = uidl;\n h->lines = 0;\n fgets (buf, sizeof (buf), msg->fp);\n while (!feof (msg->fp))\n {\n ctx->hdrs[msgno]->lines++;\n fgets (buf, sizeof (buf), msg->fp);\n }\n\n h->content->length = ftello (msg->fp) - h->content->offset;\n\n /* This needs to be done in case this is a multipart message */\n if (!WithCrypto)\n h->security = crypt_query (h->content);\n\n mutt_clear_error();\n rewind (msg->fp);\n\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-14362", "cwe_id": "CWE-119" }, { "id": 3051, "func": "static int pop_fetch_message (CONTEXT* ctx, MESSAGE* msg, int msgno)\n{\n int ret;\n void *uidl;\n char buf[LONG_STRING];\n char path[_POSIX_PATH_MAX];\n progress_t progressbar;\n POP_DATA *pop_data = (POP_DATA *)ctx->data;\n POP_CACHE *cache;\n HEADER *h = ctx->hdrs[msgno];\n unsigned short bcache = 1;\n\n /* see if we already have the message in body cache */\n if ((msg->fp = mutt_bcache_get (pop_data->bcache, cache_id (h->data))))\n return 0;\n\n /*\n * see if we already have the message in our cache in\n * case $message_cachedir is unset\n */\n cache = &pop_data->cache[h->index % POP_CACHE_LEN];\n\n if (cache->path)\n {\n if (cache->index == h->index)\n {\n /* yes, so just return a pointer to the message */\n msg->fp = fopen (cache->path, \"r\");\n if (msg->fp)\n\treturn 0;\n \n mutt_perror (cache->path);\n mutt_sleep (2);\n return -1;\n }\n else\n {\n /* clear the previous entry */\n unlink (cache->path);\n FREE (&cache->path);\n }\n }\n\n FOREVER\n {\n if (pop_reconnect (ctx) < 0)\n return -1;\n\n /* verify that massage index is correct */\n if (h->refno < 0)\n {\n mutt_error _(\"The message index is incorrect. Try reopening the mailbox.\");\n mutt_sleep (2);\n return -1;\n }\n\n mutt_progress_init (&progressbar, _(\"Fetching message...\"),\n\t\t\tMUTT_PROGRESS_SIZE, NetInc, h->content->length + h->content->offset - 1);\n\n /* see if we can put in body cache; use our cache as fallback */\n if (!(msg->fp = mutt_bcache_put (pop_data->bcache, cache_id (h->data), 1)))\n {\n /* no */\n bcache = 0;\n mutt_mktemp (path, sizeof (path));\n if (!(msg->fp = safe_fopen (path, \"w+\")))\n {\n\tmutt_perror (path);\n\tmutt_sleep (2);\n\treturn -1;\n }\n }\n\n snprintf (buf, sizeof (buf), \"RETR %d\\r\\n\", h->refno);\n\n ret = pop_fetch_data (pop_data, buf, &progressbar, fetch_message, msg->fp);\n if (ret == 0)\n break;\n\n safe_fclose (&msg->fp);\n\n /* if RETR failed (e.g. connection closed), be sure to remove either\n * the file in bcache or from POP's own cache since the next iteration\n * of the loop will re-attempt to put() the message */\n if (!bcache)\n unlink (path);\n\n if (ret == -2)\n {\n mutt_error (\"%s\", pop_data->err_msg);\n mutt_sleep (2);\n return -1;\n }\n\n if (ret == -3)\n {\n mutt_error _(\"Can't write message to temporary file!\");\n mutt_sleep (2);\n return -1;\n }\n }\n\n /* Update the header information. Previously, we only downloaded a\n * portion of the headers, those required for the main display.\n */\n if (bcache)\n mutt_bcache_commit (pop_data->bcache, cache_id (h->data));\n else\n {\n cache->index = h->index;\n cache->path = safe_strdup (path);\n }\n rewind (msg->fp);\n uidl = h->data;\n\n /* we replace envelop, key in subj_hash has to be updated as well */\n if (ctx->subj_hash && h->env->real_subj)\n hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);\n mutt_label_hash_remove (ctx, h);\n mutt_free_envelope (&h->env);\n h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);\n if (ctx->subj_hash && h->env->real_subj)\n hash_insert (ctx->subj_hash, h->env->real_subj, h);\n mutt_label_hash_add (ctx, h);\n\n h->data = uidl;\n h->lines = 0;\n fgets (buf, sizeof (buf), msg->fp);\n while (!feof (msg->fp))\n {\n ctx->hdrs[msgno]->lines++;\n fgets (buf, sizeof (buf), msg->fp);\n }\n\n h->content->length = ftello (msg->fp) - h->content->offset;\n\n /* This needs to be done in case this is a multipart message */\n if (!WithCrypto)\n h->security = crypt_query (h->content);\n\n mutt_clear_error();\n rewind (msg->fp);\n\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-14362", "cwe_id": "CWE-119" }, { "id": 2542, "func": "ast_for_arguments(struct compiling *c, const node *n)\n{\n /* This function handles both typedargslist (function definition)\n and varargslist (lambda definition).\n\n parameters: '(' [typedargslist] ')'\n typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [\n '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]\n | '**' tfpdef [',']]]\n | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]\n | '**' tfpdef [','])\n tfpdef: NAME [':' test]\n varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [\n '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]\n | '**' vfpdef [',']]]\n | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]\n | '**' vfpdef [',']\n )\n vfpdef: NAME\n\n */\n int i, j, k, nposargs = 0, nkwonlyargs = 0;\n int nposdefaults = 0, found_default = 0;\n asdl_seq *posargs, *posdefaults, *kwonlyargs, *kwdefaults;\n arg_ty vararg = NULL, kwarg = NULL;\n arg_ty arg = NULL;\n node *ch;\n\n if (TYPE(n) == parameters) {\n if (NCH(n) == 2) /* () as argument list */\n return arguments(NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena);\n n = CHILD(n, 1);\n }\n assert(TYPE(n) == typedargslist || TYPE(n) == varargslist);\n\n /* First count the number of positional args & defaults. The\n variable i is the loop index for this for loop and the next.\n The next loop picks up where the first leaves off.\n */\n for (i = 0; i < NCH(n); i++) {\n ch = CHILD(n, i);\n if (TYPE(ch) == STAR) {\n /* skip star */\n i++;\n if (i < NCH(n) && /* skip argument following star */\n (TYPE(CHILD(n, i)) == tfpdef ||\n TYPE(CHILD(n, i)) == vfpdef)) {\n i++;\n }\n break;\n }\n if (TYPE(ch) == DOUBLESTAR) break;\n if (TYPE(ch) == vfpdef || TYPE(ch) == tfpdef) nposargs++;\n if (TYPE(ch) == EQUAL) nposdefaults++;\n }\n /* count the number of keyword only args &\n defaults for keyword only args */\n for ( ; i < NCH(n); ++i) {\n ch = CHILD(n, i);\n if (TYPE(ch) == DOUBLESTAR) break;\n if (TYPE(ch) == tfpdef || TYPE(ch) == vfpdef) nkwonlyargs++;\n }\n posargs = (nposargs ? _Py_asdl_seq_new(nposargs, c->c_arena) : NULL);\n if (!posargs && nposargs)\n return NULL;\n kwonlyargs = (nkwonlyargs ?\n _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);\n if (!kwonlyargs && nkwonlyargs)\n return NULL;\n posdefaults = (nposdefaults ?\n _Py_asdl_seq_new(nposdefaults, c->c_arena) : NULL);\n if (!posdefaults && nposdefaults)\n return NULL;\n /* The length of kwonlyargs and kwdefaults are same\n since we set NULL as default for keyword only argument w/o default\n - we have sequence data structure, but no dictionary */\n kwdefaults = (nkwonlyargs ?\n _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);\n if (!kwdefaults && nkwonlyargs)\n return NULL;\n\n /* tfpdef: NAME [':' test]\n vfpdef: NAME\n */\n i = 0;\n j = 0; /* index for defaults */\n k = 0; /* index for args */\n while (i < NCH(n)) {\n ch = CHILD(n, i);\n switch (TYPE(ch)) {\n case tfpdef:\n case vfpdef:\n /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is\n anything other than EQUAL or a comma? */\n /* XXX Should NCH(n) check be made a separate check? */\n if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {\n expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));\n if (!expression)\n return NULL;\n assert(posdefaults != NULL);\n asdl_seq_SET(posdefaults, j++, expression);\n i += 2;\n found_default = 1;\n }\n else if (found_default) {\n ast_error(c, n,\n \"non-default argument follows default argument\");\n return NULL;\n }\n arg = ast_for_arg(c, ch);\n if (!arg)\n return NULL;\n asdl_seq_SET(posargs, k++, arg);\n i += 1; /* the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case STAR:\n if (i+1 >= NCH(n) ||\n (i+2 == NCH(n) && (TYPE(CHILD(n, i+1)) == COMMA\n || TYPE(CHILD(n, i+1)) == TYPE_COMMENT))) {\n ast_error(c, CHILD(n, i),\n \"named arguments must follow bare *\");\n return NULL;\n }\n ch = CHILD(n, i+1); /* tfpdef or COMMA */\n if (TYPE(ch) == COMMA) {\n int res = 0;\n i += 2; /* now follows keyword only arguments */\n\n if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {\n ast_error(c, CHILD(n, i),\n \"bare * has associated type comment\");\n return NULL;\n }\n\n res = handle_keywordonly_args(c, n, i,\n kwonlyargs, kwdefaults);\n if (res == -1) return NULL;\n i = res; /* res has new position to process */\n }\n else {\n vararg = ast_for_arg(c, ch);\n if (!vararg)\n return NULL;\n\n i += 2; /* the star and the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n\n if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {\n vararg->type_comment = NEW_TYPE_COMMENT(CHILD(n, i));\n if (!vararg->type_comment)\n return NULL;\n i += 1;\n }\n\n if (i < NCH(n) && (TYPE(CHILD(n, i)) == tfpdef\n || TYPE(CHILD(n, i)) == vfpdef)) {\n int res = 0;\n res = handle_keywordonly_args(c, n, i,\n kwonlyargs, kwdefaults);\n if (res == -1) return NULL;\n i = res; /* res has new position to process */\n }\n }\n break;\n case DOUBLESTAR:\n ch = CHILD(n, i+1); /* tfpdef */\n assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);\n kwarg = ast_for_arg(c, ch);\n if (!kwarg)\n return NULL;\n i += 2; /* the double star and the name */\n if (TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case TYPE_COMMENT:\n assert(i);\n\n if (kwarg)\n arg = kwarg;\n\n /* arg will be equal to the last argument processed */\n arg->type_comment = NEW_TYPE_COMMENT(ch);\n if (!arg->type_comment)\n return NULL;\n i += 1;\n break;\n default:\n PyErr_Format(PyExc_SystemError,\n \"unexpected node in varargslist: %d @ %d\",\n TYPE(ch), i);\n return NULL;\n }\n }\n return arguments(posargs, vararg, kwonlyargs, kwdefaults, kwarg, posdefaults, c->c_arena);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2542, "func": "ast_for_arguments(struct compiling *c, const node *n)\n{\n /* This function handles both typedargslist (function definition)\n and varargslist (lambda definition).\n\n parameters: '(' [typedargslist] ')'\n typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [\n '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]\n | '**' tfpdef [',']]]\n | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]\n | '**' tfpdef [','])\n tfpdef: NAME [':' test]\n varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [\n '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]\n | '**' vfpdef [',']]]\n | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]\n | '**' vfpdef [',']\n )\n vfpdef: NAME\n\n */\n int i, j, k, nposargs = 0, nkwonlyargs = 0;\n int nposdefaults = 0, found_default = 0;\n asdl_seq *posargs, *posdefaults, *kwonlyargs, *kwdefaults;\n arg_ty vararg = NULL, kwarg = NULL;\n arg_ty arg = NULL;\n node *ch;\n\n if (TYPE(n) == parameters) {\n if (NCH(n) == 2) /* () as argument list */\n return arguments(NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena);\n n = CHILD(n, 1);\n }\n assert(TYPE(n) == typedargslist || TYPE(n) == varargslist);\n\n /* First count the number of positional args & defaults. The\n variable i is the loop index for this for loop and the next.\n The next loop picks up where the first leaves off.\n */\n for (i = 0; i < NCH(n); i++) {\n ch = CHILD(n, i);\n if (TYPE(ch) == STAR) {\n /* skip star */\n i++;\n if (i < NCH(n) && /* skip argument following star */\n (TYPE(CHILD(n, i)) == tfpdef ||\n TYPE(CHILD(n, i)) == vfpdef)) {\n i++;\n }\n break;\n }\n if (TYPE(ch) == DOUBLESTAR) break;\n if (TYPE(ch) == vfpdef || TYPE(ch) == tfpdef) nposargs++;\n if (TYPE(ch) == EQUAL) nposdefaults++;\n }\n /* count the number of keyword only args &\n defaults for keyword only args */\n for ( ; i < NCH(n); ++i) {\n ch = CHILD(n, i);\n if (TYPE(ch) == DOUBLESTAR) break;\n if (TYPE(ch) == tfpdef || TYPE(ch) == vfpdef) nkwonlyargs++;\n }\n posargs = (nposargs ? _Py_asdl_seq_new(nposargs, c->c_arena) : NULL);\n if (!posargs && nposargs)\n return NULL;\n kwonlyargs = (nkwonlyargs ?\n _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);\n if (!kwonlyargs && nkwonlyargs)\n return NULL;\n posdefaults = (nposdefaults ?\n _Py_asdl_seq_new(nposdefaults, c->c_arena) : NULL);\n if (!posdefaults && nposdefaults)\n return NULL;\n /* The length of kwonlyargs and kwdefaults are same\n since we set NULL as default for keyword only argument w/o default\n - we have sequence data structure, but no dictionary */\n kwdefaults = (nkwonlyargs ?\n _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);\n if (!kwdefaults && nkwonlyargs)\n return NULL;\n\n /* tfpdef: NAME [':' test]\n vfpdef: NAME\n */\n i = 0;\n j = 0; /* index for defaults */\n k = 0; /* index for args */\n while (i < NCH(n)) {\n ch = CHILD(n, i);\n switch (TYPE(ch)) {\n case tfpdef:\n case vfpdef:\n /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is\n anything other than EQUAL or a comma? */\n /* XXX Should NCH(n) check be made a separate check? */\n if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {\n expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));\n if (!expression)\n return NULL;\n assert(posdefaults != NULL);\n asdl_seq_SET(posdefaults, j++, expression);\n i += 2;\n found_default = 1;\n }\n else if (found_default) {\n ast_error(c, n,\n \"non-default argument follows default argument\");\n return NULL;\n }\n arg = ast_for_arg(c, ch);\n if (!arg)\n return NULL;\n asdl_seq_SET(posargs, k++, arg);\n i += 1; /* the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case STAR:\n if (i+1 >= NCH(n) ||\n (i+2 == NCH(n) && (TYPE(CHILD(n, i+1)) == COMMA\n || TYPE(CHILD(n, i+1)) == TYPE_COMMENT))) {\n ast_error(c, CHILD(n, i),\n \"named arguments must follow bare *\");\n return NULL;\n }\n ch = CHILD(n, i+1); /* tfpdef or COMMA */\n if (TYPE(ch) == COMMA) {\n int res = 0;\n i += 2; /* now follows keyword only arguments */\n\n if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {\n ast_error(c, CHILD(n, i),\n \"bare * has associated type comment\");\n return NULL;\n }\n\n res = handle_keywordonly_args(c, n, i,\n kwonlyargs, kwdefaults);\n if (res == -1) return NULL;\n i = res; /* res has new position to process */\n }\n else {\n vararg = ast_for_arg(c, ch);\n if (!vararg)\n return NULL;\n\n i += 2; /* the star and the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n\n if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {\n vararg->type_comment = NEW_TYPE_COMMENT(CHILD(n, i));\n if (!vararg->type_comment)\n return NULL;\n i += 1;\n }\n\n if (i < NCH(n) && (TYPE(CHILD(n, i)) == tfpdef\n || TYPE(CHILD(n, i)) == vfpdef)) {\n int res = 0;\n res = handle_keywordonly_args(c, n, i,\n kwonlyargs, kwdefaults);\n if (res == -1) return NULL;\n i = res; /* res has new position to process */\n }\n }\n break;\n case DOUBLESTAR:\n ch = CHILD(n, i+1); /* tfpdef */\n assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);\n kwarg = ast_for_arg(c, ch);\n if (!kwarg)\n return NULL;\n i += 2; /* the double star and the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case TYPE_COMMENT:\n assert(i);\n\n if (kwarg)\n arg = kwarg;\n\n /* arg will be equal to the last argument processed */\n arg->type_comment = NEW_TYPE_COMMENT(ch);\n if (!arg->type_comment)\n return NULL;\n i += 1;\n break;\n default:\n PyErr_Format(PyExc_SystemError,\n \"unexpected node in varargslist: %d @ %d\",\n TYPE(ch), i);\n return NULL;\n }\n }\n return arguments(posargs, vararg, kwonlyargs, kwdefaults, kwarg, posdefaults, c->c_arena);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 3119, "func": "enum_func_status\nphp_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,\n\t\t\t\t\t\t\t\t\tunsigned int field_count, const MYSQLND_FIELD * fields_metadata,\n\t\t\t\t\t\t\t\t\tzend_bool as_int_or_float, zend_bool copy_data, MYSQLND_STATS * stats TSRMLS_DC)\n{\n\t\n\tunsigned int i;\n\tzend_bool last_field_was_string = FALSE;\n\tzval **current_field, **end_field, **start_field;\n\tzend_uchar * p = row_buffer->ptr;\n\tsize_t data_size = row_buffer->app;\n\tzend_uchar * bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */\n\n\tDBG_ENTER(\"php_mysqlnd_rowp_read_text_protocol_aux\");\n\n\tif (!fields) {\n\t\tDBG_RETURN(FAIL);\n\t}\n\n\tend_field = (start_field = fields) + field_count;\n\n\tfor (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {\n\t\tDBG_INF(\"Directly creating zval\");\n\t\tMAKE_STD_ZVAL(*current_field);\n\t\tif (!*current_field) {\n\t\t\tDBG_RETURN(FAIL);\n\t\t}\n\t}\n\n\tfor (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {\n\t\t/* Don't reverse the order. It is significant!*/\n\t\tzend_uchar *this_field_len_pos = p;\n\t\t/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */\n\t\tunsigned long len = php_mysqlnd_net_field_length(&p);\n\n\t\tif (copy_data == FALSE && current_field > start_field && last_field_was_string) {\n\t\t\t/*\n\t\t\t Normal queries:\n\t\t\t We have to put \\0 now to the end of the previous field, if it was\n\t\t\t a string. IS_NULL doesn't matter. Because we have already read our\n\t\t\t length, then we can overwrite it in the row buffer.\n\t\t\t This statement terminates the previous field, not the current one.\n\n\t\t\t NULL_LENGTH is encoded in one byte, so we can stick a \\0 there.\n\t\t\t Any string's length is encoded in at least one byte, so we can stick\n\t\t\t a \\0 there.\n\t\t\t*/\n\n\t\t\t*this_field_len_pos = '\\0';\n\t\t}\n\n\t\t/* NULL or NOT NULL, this is the question! */\n\t\tif (len == MYSQLND_NULL_LENGTH) {\n\t\t\tZVAL_NULL(*current_field);\n\t\t\tlast_field_was_string = FALSE;\n\t\t} else {\n#if defined(MYSQLND_STRING_TO_INT_CONVERSION)\n\t\t\tstruct st_mysqlnd_perm_bind perm_bind =\n\t\t\t\t\tmysqlnd_ps_fetch_functions[fields_metadata[i].type];\n#endif\n\t\t\tif (MYSQLND_G(collect_statistics)) {\n\t\t\t\tenum_mysqlnd_collected_stats statistic;\n\t\t\t\tswitch (fields_metadata[i].type) {\n\t\t\t\t\tcase MYSQL_TYPE_DECIMAL:\tstatistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;\n\t\t\t\t\tcase MYSQL_TYPE_TINY:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT8; break;\n\t\t\t\t\tcase MYSQL_TYPE_SHORT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT16; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONG:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT32; break;\n\t\t\t\t\tcase MYSQL_TYPE_FLOAT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_FLOAT; break;\n\t\t\t\t\tcase MYSQL_TYPE_DOUBLE:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_DOUBLE; break;\n\t\t\t\t\tcase MYSQL_TYPE_NULL:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_NULL; break;\n\t\t\t\t\tcase MYSQL_TYPE_TIMESTAMP:\tstatistic = STAT_TEXT_TYPE_FETCHED_TIMESTAMP; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONGLONG:\tstatistic = STAT_TEXT_TYPE_FETCHED_INT64; break;\n\t\t\t\t\tcase MYSQL_TYPE_INT24:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT24; break;\n\t\t\t\t\tcase MYSQL_TYPE_DATE:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_DATE; break;\n\t\t\t\t\tcase MYSQL_TYPE_TIME:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_TIME; break;\n\t\t\t\t\tcase MYSQL_TYPE_DATETIME:\tstatistic = STAT_TEXT_TYPE_FETCHED_DATETIME; break;\n\t\t\t\t\tcase MYSQL_TYPE_YEAR:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_YEAR; break;\n\t\t\t\t\tcase MYSQL_TYPE_NEWDATE:\tstatistic = STAT_TEXT_TYPE_FETCHED_DATE; break;\n\t\t\t\t\tcase MYSQL_TYPE_VARCHAR:\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_BIT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_BIT; break;\n\t\t\t\t\tcase MYSQL_TYPE_NEWDECIMAL:\tstatistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;\n\t\t\t\t\tcase MYSQL_TYPE_ENUM:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_ENUM; break;\n\t\t\t\t\tcase MYSQL_TYPE_SET:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_SET; break;\n\t\t\t\t\tcase MYSQL_TYPE_JSON:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_JSON; break;\n\t\t\t\t\tcase MYSQL_TYPE_TINY_BLOB:\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_MEDIUM_BLOB:statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONG_BLOB:\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_BLOB:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_VAR_STRING:\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_STRING:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_GEOMETRY:\tstatistic = STAT_TEXT_TYPE_FETCHED_GEOMETRY; break;\n\t\t\t\t\tdefault: statistic = STAT_TEXT_TYPE_FETCHED_OTHER; break;\n\t\t\t\t}\n\t\t\t\tMYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1, STAT_BYTES_RECEIVED_PURE_DATA_TEXT, len);\n\t\t\t}\n#ifdef MYSQLND_STRING_TO_INT_CONVERSION\n\t\t\tif (as_int_or_float && perm_bind.php_type == IS_LONG) {\n\t\t\t\tzend_uchar save = *(p + len);\n\t\t\t\t/* We have to make it ASCIIZ temporarily */\n\t\t\t\t*(p + len) = '\\0';\n\t\t\t\tif (perm_bind.pack_len < SIZEOF_LONG) {\n\t\t\t\t\t/* direct conversion */\n\t\t\t\t\tint64_t v =\n#ifndef PHP_WIN32\n\t\t\t\t\t\tatoll((char *) p);\n#else\n\t\t\t\t\t\t_atoi64((char *) p);\n#endif\n\t\t\t\t\tZVAL_LONG(*current_field, (long) v); /* the cast is safe */\n\t\t\t\t} else {\n\t\t\t\t\tuint64_t v =\n#ifndef PHP_WIN32\n\t\t\t\t\t\t(uint64_t) atoll((char *) p);\n#else\n\t\t\t\t\t\t(uint64_t) _atoi64((char *) p);\n#endif\n\t\t\t\t\tzend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;\n\t\t\t\t\t/* We have to make it ASCIIZ temporarily */\n#if SIZEOF_LONG==8\n\t\t\t\t\tif (uns == TRUE && v > 9223372036854775807L)\n#elif SIZEOF_LONG==4\n\t\t\t\t\tif ((uns == TRUE && v > L64(2147483647)) ||\n\t\t\t\t\t\t(uns == FALSE && (( L64(2147483647) < (int64_t) v) ||\n\t\t\t\t\t\t(L64(-2147483648) > (int64_t) v))))\n#else\n#error Need fix for this architecture\n#endif /* SIZEOF */\n\t\t\t\t\t{\n\t\t\t\t\t\tZVAL_STRINGL(*current_field, (char *)p, len, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tZVAL_LONG(*current_field, (long) v); /* the cast is safe */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t*(p + len) = save;\n\t\t\t} else if (as_int_or_float && perm_bind.php_type == IS_DOUBLE) {\n\t\t\t\tzend_uchar save = *(p + len);\n\t\t\t\t/* We have to make it ASCIIZ temporarily */\n\t\t\t\t*(p + len) = '\\0';\n\t\t\t\tZVAL_DOUBLE(*current_field, atof((char *) p));\n\t\t\t\t*(p + len) = save;\n\t\t\t} else\n#endif /* MYSQLND_STRING_TO_INT_CONVERSION */\n\t\t\tif (fields_metadata[i].type == MYSQL_TYPE_BIT) {\n\t\t\t\t/*\n\t\t\t\t BIT fields are specially handled. As they come as bit mask, we have\n\t\t\t\t to convert it to human-readable representation. As the bits take\n\t\t\t\t less space in the protocol than the numbers they represent, we don't\n\t\t\t\t have enough space in the packet buffer to overwrite inside.\n\t\t\t\t Thus, a bit more space is pre-allocated at the end of the buffer,\n\t\t\t\t see php_mysqlnd_rowp_read(). And we add the strings at the end.\n\t\t\t\t Definitely not nice, _hackish_ :(, but works.\n\t\t\t\t*/\n\t\t\t\tzend_uchar *start = bit_area;\n\t\t\t\tps_fetch_from_1_to_8_bytes(*current_field, &(fields_metadata[i]), 0, &p, len TSRMLS_CC);\n\t\t\t\t/*\n\t\t\t\t We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because\n\t\t\t\t later in this function there will be an advancement.\n\t\t\t\t*/\n\t\t\t\tp -= len;\n\t\t\t\tif (Z_TYPE_PP(current_field) == IS_LONG) {\n\t\t\t\t\tbit_area += 1 + sprintf((char *)start, \"%ld\", Z_LVAL_PP(current_field));\n\t\t\t\t\tZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);\n\t\t\t\t} else if (Z_TYPE_PP(current_field) == IS_STRING){\n\t\t\t\t\tmemcpy(bit_area, Z_STRVAL_PP(current_field), Z_STRLEN_PP(current_field));\n\t\t\t\t\tbit_area += Z_STRLEN_PP(current_field);\n\t\t\t\t\t*bit_area++ = '\\0';\n\t\t\t\t\tzval_dtor(*current_field);\n\t\t\t\t\tZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tZVAL_STRINGL(*current_field, (char *)p, len, copy_data);\n\t\t\t}\n\t\t\tp += len;\n\t\t\tlast_field_was_string = TRUE;\n\t\t}\n\t}\n\tif (copy_data == FALSE && last_field_was_string) {\n\t\t/* Normal queries: The buffer has one more byte at the end, because we need it */\n\t\trow_buffer->ptr[data_size] = '\\0';\n\t}\n\n\tDBG_RETURN(PASS);", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7412", "cwe_id": "CWE-119" }, { "id": 3119, "func": "enum_func_status\nphp_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,\n\t\t\t\t\t\t\t\t\tunsigned int field_count, const MYSQLND_FIELD * fields_metadata,\n\t\t\t\t\t\t\t\t\tzend_bool as_int_or_float, zend_bool copy_data, MYSQLND_STATS * stats TSRMLS_DC)\n{\n\t\n\tunsigned int i;\n\tzend_bool last_field_was_string = FALSE;\n\tzval **current_field, **end_field, **start_field;\n\tzend_uchar * p = row_buffer->ptr;\n\tsize_t data_size = row_buffer->app;\n\tzend_uchar * bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */\n\tconst zend_uchar * const packet_end = (zend_uchar*) row_buffer->ptr + data_size;\n\n\tDBG_ENTER(\"php_mysqlnd_rowp_read_text_protocol_aux\");\n\n\tif (!fields) {\n\t\tDBG_RETURN(FAIL);\n\t}\n\n\tend_field = (start_field = fields) + field_count;\n\n\tfor (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {\n\t\tDBG_INF(\"Directly creating zval\");\n\t\tMAKE_STD_ZVAL(*current_field);\n\t\tif (!*current_field) {\n\t\t\tDBG_RETURN(FAIL);\n\t\t}\n\t}\n\n\tfor (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {\n\t\t/* Don't reverse the order. It is significant!*/\n\t\tzend_uchar *this_field_len_pos = p;\n\t\t/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */\n\t\tconst unsigned long len = php_mysqlnd_net_field_length(&p);\n\n\t\tif (len != MYSQLND_NULL_LENGTH && ((p + len) > packet_end)) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"Malformed server packet. Field length pointing \"MYSQLND_SZ_T_SPEC\n\t\t\t\t\t\t\t\t\t\t\t \" bytes after end of packet\", (p + len) - packet_end - 1);\n\t\t\tDBG_RETURN(FAIL);\n\t\t}\n\t\tif (copy_data == FALSE && current_field > start_field && last_field_was_string) {\n\t\t\t/*\n\t\t\t Normal queries:\n\t\t\t We have to put \\0 now to the end of the previous field, if it was\n\t\t\t a string. IS_NULL doesn't matter. Because we have already read our\n\t\t\t length, then we can overwrite it in the row buffer.\n\t\t\t This statement terminates the previous field, not the current one.\n\n\t\t\t NULL_LENGTH is encoded in one byte, so we can stick a \\0 there.\n\t\t\t Any string's length is encoded in at least one byte, so we can stick\n\t\t\t a \\0 there.\n\t\t\t*/\n\n\t\t\t*this_field_len_pos = '\\0';\n\t\t}\n\n\t\t/* NULL or NOT NULL, this is the question! */\n\t\tif (len == MYSQLND_NULL_LENGTH) {\n\t\t\tZVAL_NULL(*current_field);\n\t\t\tlast_field_was_string = FALSE;\n\t\t} else {\n#if defined(MYSQLND_STRING_TO_INT_CONVERSION)\n\t\t\tstruct st_mysqlnd_perm_bind perm_bind =\n\t\t\t\t\tmysqlnd_ps_fetch_functions[fields_metadata[i].type];\n#endif\n\t\t\tif (MYSQLND_G(collect_statistics)) {\n\t\t\t\tenum_mysqlnd_collected_stats statistic;\n\t\t\t\tswitch (fields_metadata[i].type) {\n\t\t\t\t\tcase MYSQL_TYPE_DECIMAL:\tstatistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;\n\t\t\t\t\tcase MYSQL_TYPE_TINY:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT8; break;\n\t\t\t\t\tcase MYSQL_TYPE_SHORT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT16; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONG:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT32; break;\n\t\t\t\t\tcase MYSQL_TYPE_FLOAT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_FLOAT; break;\n\t\t\t\t\tcase MYSQL_TYPE_DOUBLE:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_DOUBLE; break;\n\t\t\t\t\tcase MYSQL_TYPE_NULL:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_NULL; break;\n\t\t\t\t\tcase MYSQL_TYPE_TIMESTAMP:\tstatistic = STAT_TEXT_TYPE_FETCHED_TIMESTAMP; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONGLONG:\tstatistic = STAT_TEXT_TYPE_FETCHED_INT64; break;\n\t\t\t\t\tcase MYSQL_TYPE_INT24:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_INT24; break;\n\t\t\t\t\tcase MYSQL_TYPE_DATE:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_DATE; break;\n\t\t\t\t\tcase MYSQL_TYPE_TIME:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_TIME; break;\n\t\t\t\t\tcase MYSQL_TYPE_DATETIME:\tstatistic = STAT_TEXT_TYPE_FETCHED_DATETIME; break;\n\t\t\t\t\tcase MYSQL_TYPE_YEAR:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_YEAR; break;\n\t\t\t\t\tcase MYSQL_TYPE_NEWDATE:\tstatistic = STAT_TEXT_TYPE_FETCHED_DATE; break;\n\t\t\t\t\tcase MYSQL_TYPE_VARCHAR:\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_BIT:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_BIT; break;\n\t\t\t\t\tcase MYSQL_TYPE_NEWDECIMAL:\tstatistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;\n\t\t\t\t\tcase MYSQL_TYPE_ENUM:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_ENUM; break;\n\t\t\t\t\tcase MYSQL_TYPE_SET:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_SET; break;\n\t\t\t\t\tcase MYSQL_TYPE_JSON:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_JSON; break;\n\t\t\t\t\tcase MYSQL_TYPE_TINY_BLOB:\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_MEDIUM_BLOB:statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_LONG_BLOB:\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_BLOB:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;\n\t\t\t\t\tcase MYSQL_TYPE_VAR_STRING:\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_STRING:\t\tstatistic = STAT_TEXT_TYPE_FETCHED_STRING; break;\n\t\t\t\t\tcase MYSQL_TYPE_GEOMETRY:\tstatistic = STAT_TEXT_TYPE_FETCHED_GEOMETRY; break;\n\t\t\t\t\tdefault: statistic = STAT_TEXT_TYPE_FETCHED_OTHER; break;\n\t\t\t\t}\n\t\t\t\tMYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1, STAT_BYTES_RECEIVED_PURE_DATA_TEXT, len);\n\t\t\t}\n#ifdef MYSQLND_STRING_TO_INT_CONVERSION\n\t\t\tif (as_int_or_float && perm_bind.php_type == IS_LONG) {\n\t\t\t\tzend_uchar save = *(p + len);\n\t\t\t\t/* We have to make it ASCIIZ temporarily */\n\t\t\t\t*(p + len) = '\\0';\n\t\t\t\tif (perm_bind.pack_len < SIZEOF_LONG) {\n\t\t\t\t\t/* direct conversion */\n\t\t\t\t\tint64_t v =\n#ifndef PHP_WIN32\n\t\t\t\t\t\tatoll((char *) p);\n#else\n\t\t\t\t\t\t_atoi64((char *) p);\n#endif\n\t\t\t\t\tZVAL_LONG(*current_field, (long) v); /* the cast is safe */\n\t\t\t\t} else {\n\t\t\t\t\tuint64_t v =\n#ifndef PHP_WIN32\n\t\t\t\t\t\t(uint64_t) atoll((char *) p);\n#else\n\t\t\t\t\t\t(uint64_t) _atoi64((char *) p);\n#endif\n\t\t\t\t\tzend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;\n\t\t\t\t\t/* We have to make it ASCIIZ temporarily */\n#if SIZEOF_LONG==8\n\t\t\t\t\tif (uns == TRUE && v > 9223372036854775807L)\n#elif SIZEOF_LONG==4\n\t\t\t\t\tif ((uns == TRUE && v > L64(2147483647)) ||\n\t\t\t\t\t\t(uns == FALSE && (( L64(2147483647) < (int64_t) v) ||\n\t\t\t\t\t\t(L64(-2147483648) > (int64_t) v))))\n#else\n#error Need fix for this architecture\n#endif /* SIZEOF */\n\t\t\t\t\t{\n\t\t\t\t\t\tZVAL_STRINGL(*current_field, (char *)p, len, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tZVAL_LONG(*current_field, (long) v); /* the cast is safe */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t*(p + len) = save;\n\t\t\t} else if (as_int_or_float && perm_bind.php_type == IS_DOUBLE) {\n\t\t\t\tzend_uchar save = *(p + len);\n\t\t\t\t/* We have to make it ASCIIZ temporarily */\n\t\t\t\t*(p + len) = '\\0';\n\t\t\t\tZVAL_DOUBLE(*current_field, atof((char *) p));\n\t\t\t\t*(p + len) = save;\n\t\t\t} else\n#endif /* MYSQLND_STRING_TO_INT_CONVERSION */\n\t\t\tif (fields_metadata[i].type == MYSQL_TYPE_BIT) {\n\t\t\t\t/*\n\t\t\t\t BIT fields are specially handled. As they come as bit mask, we have\n\t\t\t\t to convert it to human-readable representation. As the bits take\n\t\t\t\t less space in the protocol than the numbers they represent, we don't\n\t\t\t\t have enough space in the packet buffer to overwrite inside.\n\t\t\t\t Thus, a bit more space is pre-allocated at the end of the buffer,\n\t\t\t\t see php_mysqlnd_rowp_read(). And we add the strings at the end.\n\t\t\t\t Definitely not nice, _hackish_ :(, but works.\n\t\t\t\t*/\n\t\t\t\tzend_uchar *start = bit_area;\n\t\t\t\tps_fetch_from_1_to_8_bytes(*current_field, &(fields_metadata[i]), 0, &p, len TSRMLS_CC);\n\t\t\t\t/*\n\t\t\t\t We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because\n\t\t\t\t later in this function there will be an advancement.\n\t\t\t\t*/\n\t\t\t\tp -= len;\n\t\t\t\tif (Z_TYPE_PP(current_field) == IS_LONG) {\n\t\t\t\t\tbit_area += 1 + sprintf((char *)start, \"%ld\", Z_LVAL_PP(current_field));\n\t\t\t\t\tZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);\n\t\t\t\t} else if (Z_TYPE_PP(current_field) == IS_STRING){\n\t\t\t\t\tmemcpy(bit_area, Z_STRVAL_PP(current_field), Z_STRLEN_PP(current_field));\n\t\t\t\t\tbit_area += Z_STRLEN_PP(current_field);\n\t\t\t\t\t*bit_area++ = '\\0';\n\t\t\t\t\tzval_dtor(*current_field);\n\t\t\t\t\tZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tZVAL_STRINGL(*current_field, (char *)p, len, copy_data);\n\t\t\t}\n\t\t\tp += len;\n\t\t\tlast_field_was_string = TRUE;\n\t\t}\n\t}\n\tif (copy_data == FALSE && last_field_was_string) {\n\t\t/* Normal queries: The buffer has one more byte at the end, because we need it */\n\t\trow_buffer->ptr[data_size] = '\\0';\n\t}\n\n\tDBG_RETURN(PASS);", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7412", "cwe_id": "CWE-119" }, { "id": 2693, "func": "void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)\n{\n\tstruct snd_timer_instance *ti, *ts, *tmp;\n\tunsigned long resolution, ticks;\n\tstruct list_head *p, *ack_list_head;\n\tunsigned long flags;\n\tint use_tasklet = 0;\n\n\tif (timer == NULL)\n\t\treturn;\n\n\tspin_lock_irqsave(&timer->lock, flags);\n\n\t/* remember the current resolution */\n\tif (timer->hw.c_resolution)\n\t\tresolution = timer->hw.c_resolution(timer);\n\telse\n\t\tresolution = timer->hw.resolution;\n\n\t/* loop for all active instances\n\t * Here we cannot use list_for_each_entry because the active_list of a\n\t * processed instance is relinked to done_list_head before the callback\n\t * is called.\n\t */\n\tlist_for_each_entry_safe(ti, tmp, &timer->active_list_head,\n\t\t\t\t active_list) {\n\t\tif (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))\n\t\t\tcontinue;\n\t\tti->pticks += ticks_left;\n\t\tti->resolution = resolution;\n\t\tif (ti->cticks < ticks_left)\n\t\t\tti->cticks = 0;\n\t\telse\n\t\t\tti->cticks -= ticks_left;\n\t\tif (ti->cticks) /* not expired */\n\t\t\tcontinue;\n\t\tif (ti->flags & SNDRV_TIMER_IFLG_AUTO) {\n\t\t\tti->cticks = ti->ticks;\n\t\t} else {\n\t\t\tti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;\n\t\t\tif (--timer->running)\n\t\t\t\tlist_del(&ti->active_list);\n\t\t}\n\t\tif ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||\n\t\t (ti->flags & SNDRV_TIMER_IFLG_FAST))\n\t\t\tack_list_head = &timer->ack_list_head;\n\t\telse\n\t\t\tack_list_head = &timer->sack_list_head;\n\t\tif (list_empty(&ti->ack_list))\n\t\t\tlist_add_tail(&ti->ack_list, ack_list_head);\n\t\tlist_for_each_entry(ts, &ti->slave_active_head, active_list) {\n\t\t\tts->pticks = ti->pticks;\n\t\t\tts->resolution = resolution;\n\t\t\tif (list_empty(&ts->ack_list))\n\t\t\t\tlist_add_tail(&ts->ack_list, ack_list_head);\n\t\t}\n\t}\n\tif (timer->flags & SNDRV_TIMER_FLG_RESCHED)\n\t\tsnd_timer_reschedule(timer, timer->sticks);\n\tif (timer->running) {\n\t\tif (timer->hw.flags & SNDRV_TIMER_HW_STOP) {\n\t\t\ttimer->hw.stop(timer);\n\t\t\ttimer->flags |= SNDRV_TIMER_FLG_CHANGE;\n\t\t}\n\t\tif (!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||\n\t\t (timer->flags & SNDRV_TIMER_FLG_CHANGE)) {\n\t\t\t/* restart timer */\n\t\t\ttimer->flags &= ~SNDRV_TIMER_FLG_CHANGE;\n\t\t\ttimer->hw.start(timer);\n\t\t}\n\t} else {\n\t\ttimer->hw.stop(timer);\n\t}\n\n\t/* now process all fast callbacks */\n\twhile (!list_empty(&timer->ack_list_head)) {\n\t\tp = timer->ack_list_head.next;\t\t/* get first item */\n\t\tti = list_entry(p, struct snd_timer_instance, ack_list);\n\n\t\t/* remove from ack_list and make empty */\n\t\tlist_del_init(p);\n\n\t\tticks = ti->pticks;\n\t\tti->pticks = 0;\n\n\t\tti->flags |= SNDRV_TIMER_IFLG_CALLBACK;\n\t\tspin_unlock(&timer->lock);\n\t\tif (ti->callback)\n\t\t\tti->callback(ti, resolution, ticks);\n\t\tspin_lock(&timer->lock);\n\t\tti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;\n\t}\n\n\t/* do we have any slow callbacks? */\n\tuse_tasklet = !list_empty(&timer->sack_list_head);\n\tspin_unlock_irqrestore(&timer->lock, flags);\n\n\tif (use_tasklet)\n\t\ttasklet_schedule(&timer->task_queue);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2545", "cwe_id": "CWE-362" }, { "id": 2693, "func": "void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)\n{\n\tstruct snd_timer_instance *ti, *ts, *tmp;\n\tunsigned long resolution, ticks;\n\tstruct list_head *p, *ack_list_head;\n\tunsigned long flags;\n\tint use_tasklet = 0;\n\n\tif (timer == NULL)\n\t\treturn;\n\n\tspin_lock_irqsave(&timer->lock, flags);\n\n\t/* remember the current resolution */\n\tif (timer->hw.c_resolution)\n\t\tresolution = timer->hw.c_resolution(timer);\n\telse\n\t\tresolution = timer->hw.resolution;\n\n\t/* loop for all active instances\n\t * Here we cannot use list_for_each_entry because the active_list of a\n\t * processed instance is relinked to done_list_head before the callback\n\t * is called.\n\t */\n\tlist_for_each_entry_safe(ti, tmp, &timer->active_list_head,\n\t\t\t\t active_list) {\n\t\tif (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))\n\t\t\tcontinue;\n\t\tti->pticks += ticks_left;\n\t\tti->resolution = resolution;\n\t\tif (ti->cticks < ticks_left)\n\t\t\tti->cticks = 0;\n\t\telse\n\t\t\tti->cticks -= ticks_left;\n\t\tif (ti->cticks) /* not expired */\n\t\t\tcontinue;\n\t\tif (ti->flags & SNDRV_TIMER_IFLG_AUTO) {\n\t\t\tti->cticks = ti->ticks;\n\t\t} else {\n\t\t\tti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;\n\t\t\tif (--timer->running)\n\t\t\t\tlist_del_init(&ti->active_list);\n\t\t}\n\t\tif ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||\n\t\t (ti->flags & SNDRV_TIMER_IFLG_FAST))\n\t\t\tack_list_head = &timer->ack_list_head;\n\t\telse\n\t\t\tack_list_head = &timer->sack_list_head;\n\t\tif (list_empty(&ti->ack_list))\n\t\t\tlist_add_tail(&ti->ack_list, ack_list_head);\n\t\tlist_for_each_entry(ts, &ti->slave_active_head, active_list) {\n\t\t\tts->pticks = ti->pticks;\n\t\t\tts->resolution = resolution;\n\t\t\tif (list_empty(&ts->ack_list))\n\t\t\t\tlist_add_tail(&ts->ack_list, ack_list_head);\n\t\t}\n\t}\n\tif (timer->flags & SNDRV_TIMER_FLG_RESCHED)\n\t\tsnd_timer_reschedule(timer, timer->sticks);\n\tif (timer->running) {\n\t\tif (timer->hw.flags & SNDRV_TIMER_HW_STOP) {\n\t\t\ttimer->hw.stop(timer);\n\t\t\ttimer->flags |= SNDRV_TIMER_FLG_CHANGE;\n\t\t}\n\t\tif (!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||\n\t\t (timer->flags & SNDRV_TIMER_FLG_CHANGE)) {\n\t\t\t/* restart timer */\n\t\t\ttimer->flags &= ~SNDRV_TIMER_FLG_CHANGE;\n\t\t\ttimer->hw.start(timer);\n\t\t}\n\t} else {\n\t\ttimer->hw.stop(timer);\n\t}\n\n\t/* now process all fast callbacks */\n\twhile (!list_empty(&timer->ack_list_head)) {\n\t\tp = timer->ack_list_head.next;\t\t/* get first item */\n\t\tti = list_entry(p, struct snd_timer_instance, ack_list);\n\n\t\t/* remove from ack_list and make empty */\n\t\tlist_del_init(p);\n\n\t\tticks = ti->pticks;\n\t\tti->pticks = 0;\n\n\t\tti->flags |= SNDRV_TIMER_IFLG_CALLBACK;\n\t\tspin_unlock(&timer->lock);\n\t\tif (ti->callback)\n\t\t\tti->callback(ti, resolution, ticks);\n\t\tspin_lock(&timer->lock);\n\t\tti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;\n\t}\n\n\t/* do we have any slow callbacks? */\n\tuse_tasklet = !list_empty(&timer->sack_list_head);\n\tspin_unlock_irqrestore(&timer->lock, flags);\n\n\tif (use_tasklet)\n\t\ttasklet_schedule(&timer->task_queue);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2545", "cwe_id": "CWE-362" }, { "id": 2240, "func": "readSampleCountForLineBlock(InputStreamMutex* streamData,\n DeepScanLineInputFile::Data* data,\n int lineBlockId)\n{\n streamData->is->seekg(data->lineOffsets[lineBlockId]);\n\n if (isMultiPart(data->version))\n {\n int partNumber;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, partNumber);\n\n if (partNumber != data->partNumber)\n throw IEX_NAMESPACE::ArgExc(\"Unexpected part number.\");\n }\n\n int minY;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, minY);\n\n //\n // Check the correctness of minY.\n //\n\n if (minY != data->minY + lineBlockId * data->linesInBuffer)\n throw IEX_NAMESPACE::ArgExc(\"Unexpected data block y coordinate.\");\n\n int maxY;\n maxY = min(minY + data->linesInBuffer - 1, data->maxY);\n\n uint64_t sampleCountTableDataSize;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, sampleCountTableDataSize);\n\n \n \n if(sampleCountTableDataSize>static_cast(data->maxSampleCountTableSize))\n {\n THROW (IEX_NAMESPACE::ArgExc, \"Bad sampleCountTableDataSize read from chunk \"<< lineBlockId << \": expected \" << data->maxSampleCountTableSize << \" or less, got \"<< sampleCountTableDataSize);\n }\n \n uint64_t packedDataSize;\n uint64_t unpackedDataSize;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, packedDataSize);\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, unpackedDataSize);\n\n \n \n //\n // We make a check on the data size requirements here.\n // Whilst we wish to store 64bit sizes on disk, not all the compressors\n // have been made to work with such data sizes and are still limited to\n // using signed 32 bit (int) for the data size. As such, this version\n // insists that we validate that the data size does not exceed the data\n // type max limit.\n // @TODO refactor the compressor code to ensure full 64-bit support.\n //\n\n int compressorMaxDataSize = std::numeric_limits::max();\n if (sampleCountTableDataSize > uint64_t(compressorMaxDataSize))\n {\n THROW (IEX_NAMESPACE::ArgExc, \"This version of the library does not \"\n << \"support the allocation of data with size > \"\n << compressorMaxDataSize\n << \" file table size :\" << sampleCountTableDataSize << \".\\n\");\n }\n streamData->is->read(data->sampleCountTableBuffer, static_cast(sampleCountTableDataSize));\n \n const char* readPtr;\n\n //\n // If the sample count table is compressed, we'll uncompress it.\n //\n\n\n if (sampleCountTableDataSize < static_cast(data->maxSampleCountTableSize))\n {\n if(!data->sampleCountTableComp)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline data corrupt at chunk \" << lineBlockId << \" (sampleCountTableDataSize error)\");\n }\n data->sampleCountTableComp->uncompress(data->sampleCountTableBuffer,\n static_cast(sampleCountTableDataSize),\n minY,\n readPtr);\n }\n else readPtr = data->sampleCountTableBuffer;\n\n char* base = data->sampleCountSliceBase;\n int xStride = data->sampleCountXStride;\n int yStride = data->sampleCountYStride;\n\n // total number of samples in block: used to check samplecount table doesn't\n // reference more data than exists\n \n size_t cumulative_total_samples=0;\n \n for (int y = minY; y <= maxY; y++)\n {\n int yInDataWindow = y - data->minY;\n data->lineSampleCount[yInDataWindow] = 0;\n\n int lastAccumulatedCount = 0;\n for (int x = data->minX; x <= data->maxX; x++)\n {\n int accumulatedCount, count;\n\n //\n // Read the sample count for pixel (x, y).\n //\n\n Xdr::read (readPtr, accumulatedCount);\n \n // sample count table should always contain monotonically\n // increasing values.\n if (accumulatedCount < lastAccumulatedCount)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline sampleCount data corrupt at chunk \" << lineBlockId << \" (negative sample count detected)\");\n }\n\n count = accumulatedCount - lastAccumulatedCount;\n lastAccumulatedCount = accumulatedCount;\n\n //\n // Store the data in both internal and external data structure.\n //\n\n data->sampleCount[yInDataWindow][x - data->minX] = count;\n data->lineSampleCount[yInDataWindow] += count;\n sampleCount(base, xStride, yStride, x, y) = count;\n }\n cumulative_total_samples+=data->lineSampleCount[yInDataWindow];\n if(cumulative_total_samples*data->combinedSampleSize > unpackedDataSize)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline sampleCount data corrupt at chunk \" << lineBlockId << \": pixel data only contains \" << unpackedDataSize \n << \" bytes of data but table references at least \" << cumulative_total_samples*data->combinedSampleSize << \" bytes of sample data\" ); \n }\n data->gotSampleCount[y - data->minY] = true;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-45942", "cwe_id": "CWE-787" }, { "id": 2240, "func": "readSampleCountForLineBlock(InputStreamMutex* streamData,\n DeepScanLineInputFile::Data* data,\n int lineBlockId)\n{\n streamData->is->seekg(data->lineOffsets[lineBlockId]);\n\n if (isMultiPart(data->version))\n {\n int partNumber;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, partNumber);\n\n if (partNumber != data->partNumber)\n throw IEX_NAMESPACE::ArgExc(\"Unexpected part number.\");\n }\n\n int minY;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, minY);\n\n //\n // Check the correctness of minY.\n //\n\n if (minY != data->minY + lineBlockId * data->linesInBuffer)\n throw IEX_NAMESPACE::ArgExc(\"Unexpected data block y coordinate.\");\n\n int maxY;\n maxY = min(minY + data->linesInBuffer - 1, data->maxY);\n\n uint64_t sampleCountTableDataSize;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, sampleCountTableDataSize);\n\n \n \n if(sampleCountTableDataSize>static_cast(data->maxSampleCountTableSize))\n {\n THROW (IEX_NAMESPACE::ArgExc, \"Bad sampleCountTableDataSize read from chunk \"<< lineBlockId << \": expected \" << data->maxSampleCountTableSize << \" or less, got \"<< sampleCountTableDataSize);\n }\n \n uint64_t packedDataSize;\n uint64_t unpackedDataSize;\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, packedDataSize);\n OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read (*streamData->is, unpackedDataSize);\n\n \n \n //\n // We make a check on the data size requirements here.\n // Whilst we wish to store 64bit sizes on disk, not all the compressors\n // have been made to work with such data sizes and are still limited to\n // using signed 32 bit (int) for the data size. As such, this version\n // insists that we validate that the data size does not exceed the data\n // type max limit.\n // @TODO refactor the compressor code to ensure full 64-bit support.\n //\n\n uint64_t compressorMaxDataSize = static_cast(std::numeric_limits::max());\n if (packedDataSize > compressorMaxDataSize ||\n unpackedDataSize > compressorMaxDataSize ||\n sampleCountTableDataSize > compressorMaxDataSize)\n {\n THROW (IEX_NAMESPACE::ArgExc, \"This version of the library does not\"\n << \"support the allocation of data with size > \"\n << compressorMaxDataSize\n << \" file table size :\" << sampleCountTableDataSize\n << \" file unpacked size :\" << unpackedDataSize\n << \" file packed size :\" << packedDataSize << \".\\n\");\n }\n\n\n streamData->is->read(data->sampleCountTableBuffer, static_cast(sampleCountTableDataSize));\n \n const char* readPtr;\n\n //\n // If the sample count table is compressed, we'll uncompress it.\n //\n\n\n if (sampleCountTableDataSize < static_cast(data->maxSampleCountTableSize))\n {\n if(!data->sampleCountTableComp)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline data corrupt at chunk \" << lineBlockId << \" (sampleCountTableDataSize error)\");\n }\n data->sampleCountTableComp->uncompress(data->sampleCountTableBuffer,\n static_cast(sampleCountTableDataSize),\n minY,\n readPtr);\n }\n else readPtr = data->sampleCountTableBuffer;\n\n char* base = data->sampleCountSliceBase;\n int xStride = data->sampleCountXStride;\n int yStride = data->sampleCountYStride;\n\n // total number of samples in block: used to check samplecount table doesn't\n // reference more data than exists\n \n size_t cumulative_total_samples=0;\n \n for (int y = minY; y <= maxY; y++)\n {\n int yInDataWindow = y - data->minY;\n data->lineSampleCount[yInDataWindow] = 0;\n\n int lastAccumulatedCount = 0;\n for (int x = data->minX; x <= data->maxX; x++)\n {\n int accumulatedCount, count;\n\n //\n // Read the sample count for pixel (x, y).\n //\n\n Xdr::read (readPtr, accumulatedCount);\n \n // sample count table should always contain monotonically\n // increasing values.\n if (accumulatedCount < lastAccumulatedCount)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline sampleCount data corrupt at chunk \" << lineBlockId << \" (negative sample count detected)\");\n }\n\n count = accumulatedCount - lastAccumulatedCount;\n lastAccumulatedCount = accumulatedCount;\n\n //\n // Store the data in both internal and external data structure.\n //\n\n data->sampleCount[yInDataWindow][x - data->minX] = count;\n data->lineSampleCount[yInDataWindow] += count;\n sampleCount(base, xStride, yStride, x, y) = count;\n }\n cumulative_total_samples+=data->lineSampleCount[yInDataWindow];\n if(cumulative_total_samples*data->combinedSampleSize > unpackedDataSize)\n {\n THROW(IEX_NAMESPACE::ArgExc,\"Deep scanline sampleCount data corrupt at chunk \" << lineBlockId << \": pixel data only contains \" << unpackedDataSize \n << \" bytes of data but table references at least \" << cumulative_total_samples*data->combinedSampleSize << \" bytes of sample data\" ); \n }\n data->gotSampleCount[y - data->minY] = true;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-45942", "cwe_id": "CWE-787" }, { "id": 2062, "func": " void reposition(int pos) { ptr = start + pos; }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2062, "func": " void reposition(size_t pos) { ptr = start + pos; }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1622, "func": "static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)\n{\n\tbool unaligned_chunks = mr->flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG;\n\tu32 chunk_size = mr->chunk_size, headroom = mr->headroom;\n\tunsigned int chunks, chunks_per_page;\n\tu64 addr = mr->addr, size = mr->len;\n\tint size_chk, err;\n\n\tif (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) {\n\t\t/* Strictly speaking we could support this, if:\n\t\t * - huge pages, or*\n\t\t * - using an IOMMU, or\n\t\t * - making sure the memory area is consecutive\n\t\t * but for now, we simply say \"computer says no\".\n\t\t */\n\t\treturn -EINVAL;\n\t}\n\n\tif (mr->flags & ~(XDP_UMEM_UNALIGNED_CHUNK_FLAG |\n\t\t\tXDP_UMEM_USES_NEED_WAKEUP))\n\t\treturn -EINVAL;\n\n\tif (!unaligned_chunks && !is_power_of_2(chunk_size))\n\t\treturn -EINVAL;\n\n\tif (!PAGE_ALIGNED(addr)) {\n\t\t/* Memory area has to be page size aligned. For\n\t\t * simplicity, this might change.\n\t\t */\n\t\treturn -EINVAL;\n\t}\n\n\tif ((addr + size) < addr)\n\t\treturn -EINVAL;\n\n\tchunks = (unsigned int)div_u64(size, chunk_size);\n\tif (chunks == 0)\n\t\treturn -EINVAL;\n\n\tif (!unaligned_chunks) {\n\t\tchunks_per_page = PAGE_SIZE / chunk_size;\n\t\tif (chunks < chunks_per_page || chunks % chunks_per_page)\n\t\t\treturn -EINVAL;\n\t}\n\n\tsize_chk = chunk_size - headroom - XDP_PACKET_HEADROOM;\n\tif (size_chk < 0)\n\t\treturn -EINVAL;\n\n\tumem->address = (unsigned long)addr;\n\tumem->chunk_mask = unaligned_chunks ? XSK_UNALIGNED_BUF_ADDR_MASK\n\t\t\t\t\t : ~((u64)chunk_size - 1);\n\tumem->size = size;\n\tumem->headroom = headroom;\n\tumem->chunk_size_nohr = chunk_size - headroom;\n\tumem->npgs = size / PAGE_SIZE;\n\tumem->pgs = NULL;\n\tumem->user = NULL;\n\tumem->flags = mr->flags;\n\tINIT_LIST_HEAD(&umem->xsk_list);\n\tspin_lock_init(&umem->xsk_list_lock);\n\n\trefcount_set(&umem->users, 1);\n\n\terr = xdp_umem_account_pages(umem);\n\tif (err)\n\t\treturn err;\n\n\terr = xdp_umem_pin_pages(umem);\n\tif (err)\n\t\tgoto out_account;\n\n\tumem->pages = kvcalloc(umem->npgs, sizeof(*umem->pages),\n\t\t\t GFP_KERNEL_ACCOUNT);\n\tif (!umem->pages) {\n\t\terr = -ENOMEM;\n\t\tgoto out_pin;\n\t}\n\n\terr = xdp_umem_map_pages(umem);\n\tif (!err)\n\t\treturn 0;\n\n\tkvfree(umem->pages);\n\nout_pin:\n\txdp_umem_unpin_pages(umem);\nout_account:\n\txdp_umem_unaccount_pages(umem);\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12659", "cwe_id": "CWE-787" }, { "id": 1622, "func": "static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)\n{\n\tbool unaligned_chunks = mr->flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG;\n\tu32 chunk_size = mr->chunk_size, headroom = mr->headroom;\n\tunsigned int chunks, chunks_per_page;\n\tu64 addr = mr->addr, size = mr->len;\n\tint err;\n\n\tif (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) {\n\t\t/* Strictly speaking we could support this, if:\n\t\t * - huge pages, or*\n\t\t * - using an IOMMU, or\n\t\t * - making sure the memory area is consecutive\n\t\t * but for now, we simply say \"computer says no\".\n\t\t */\n\t\treturn -EINVAL;\n\t}\n\n\tif (mr->flags & ~(XDP_UMEM_UNALIGNED_CHUNK_FLAG |\n\t\t\tXDP_UMEM_USES_NEED_WAKEUP))\n\t\treturn -EINVAL;\n\n\tif (!unaligned_chunks && !is_power_of_2(chunk_size))\n\t\treturn -EINVAL;\n\n\tif (!PAGE_ALIGNED(addr)) {\n\t\t/* Memory area has to be page size aligned. For\n\t\t * simplicity, this might change.\n\t\t */\n\t\treturn -EINVAL;\n\t}\n\n\tif ((addr + size) < addr)\n\t\treturn -EINVAL;\n\n\tchunks = (unsigned int)div_u64(size, chunk_size);\n\tif (chunks == 0)\n\t\treturn -EINVAL;\n\n\tif (!unaligned_chunks) {\n\t\tchunks_per_page = PAGE_SIZE / chunk_size;\n\t\tif (chunks < chunks_per_page || chunks % chunks_per_page)\n\t\t\treturn -EINVAL;\n\t}\n\n\tif (headroom >= chunk_size - XDP_PACKET_HEADROOM)\n\t\treturn -EINVAL;\n\n\tumem->address = (unsigned long)addr;\n\tumem->chunk_mask = unaligned_chunks ? XSK_UNALIGNED_BUF_ADDR_MASK\n\t\t\t\t\t : ~((u64)chunk_size - 1);\n\tumem->size = size;\n\tumem->headroom = headroom;\n\tumem->chunk_size_nohr = chunk_size - headroom;\n\tumem->npgs = size / PAGE_SIZE;\n\tumem->pgs = NULL;\n\tumem->user = NULL;\n\tumem->flags = mr->flags;\n\tINIT_LIST_HEAD(&umem->xsk_list);\n\tspin_lock_init(&umem->xsk_list_lock);\n\n\trefcount_set(&umem->users, 1);\n\n\terr = xdp_umem_account_pages(umem);\n\tif (err)\n\t\treturn err;\n\n\terr = xdp_umem_pin_pages(umem);\n\tif (err)\n\t\tgoto out_account;\n\n\tumem->pages = kvcalloc(umem->npgs, sizeof(*umem->pages),\n\t\t\t GFP_KERNEL_ACCOUNT);\n\tif (!umem->pages) {\n\t\terr = -ENOMEM;\n\t\tgoto out_pin;\n\t}\n\n\terr = xdp_umem_map_pages(umem);\n\tif (!err)\n\t\treturn 0;\n\n\tkvfree(umem->pages);\n\nout_pin:\n\txdp_umem_unpin_pages(umem);\nout_account:\n\txdp_umem_unaccount_pages(umem);\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12659", "cwe_id": "CWE-787" }, { "id": 627, "func": "static apr_status_t parse_chunk_size(http_ctx_t *ctx, const char *buffer,\n apr_size_t len, int linelimit)\n{\n apr_size_t i = 0;\n\n while (i < len) {\n char c = buffer[i];\n\n ap_xlate_proto_from_ascii(&c, 1);\n\n /* handle CRLF after the chunk */\n if (ctx->state == BODY_CHUNK_END) {\n if (c == LF) {\n ctx->state = BODY_CHUNK;\n }\n i++;\n continue;\n }\n\n /* handle start of the chunk */\n if (ctx->state == BODY_CHUNK) {\n if (!apr_isxdigit(c)) {\n /*\n * Detect invalid character at beginning. This also works for empty\n * chunk size lines.\n */\n return APR_EGENERAL;\n }\n else {\n ctx->state = BODY_CHUNK_PART;\n }\n ctx->remaining = 0;\n ctx->chunkbits = sizeof(long) * 8;\n ctx->chunk_used = 0;\n }\n\n /* handle a chunk part, or a chunk extension */\n /*\n * In theory, we are supposed to expect CRLF only, but our\n * test suite sends LF only. Tolerate a missing CR.\n */\n if (c == ';' || c == CR) {\n ctx->state = BODY_CHUNK_EXT;\n }\n else if (c == LF) {\n if (ctx->remaining) {\n ctx->state = BODY_CHUNK_DATA;\n }\n else {\n ctx->state = BODY_CHUNK_TRAILER;\n }\n }\n else if (ctx->state != BODY_CHUNK_EXT) {\n int xvalue = 0;\n\n /* ignore leading zeros */\n if (!ctx->remaining && c == '0') {\n i++;\n continue;\n }\n\n if (c >= '0' && c <= '9') {\n xvalue = c - '0';\n }\n else if (c >= 'A' && c <= 'F') {\n xvalue = c - 'A' + 0xa;\n }\n else if (c >= 'a' && c <= 'f') {\n xvalue = c - 'a' + 0xa;\n }\n else {\n /* bogus character */\n return APR_EGENERAL;\n }\n\n ctx->remaining = (ctx->remaining << 4) | xvalue;\n ctx->chunkbits -= 4;\n if (ctx->chunkbits <= 0 || ctx->remaining < 0) {\n /* overflow */\n return APR_ENOSPC;\n }\n\n }\n\n i++;\n }\n\n /* sanity check */\n ctx->chunk_used += len;\n if (ctx->chunk_used < 0 || ctx->chunk_used > linelimit) {\n return APR_ENOSPC;\n }\n\n return APR_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-3183", "cwe_id": "CWE-20" }, { "id": 627, "func": "static apr_status_t parse_chunk_size(http_ctx_t *ctx, const char *buffer,\n apr_size_t len, int linelimit)\n{\n apr_size_t i = 0;\n\n while (i < len) {\n char c = buffer[i];\n\n ap_xlate_proto_from_ascii(&c, 1);\n\n /* handle CRLF after the chunk */\n if (ctx->state == BODY_CHUNK_END\n || ctx->state == BODY_CHUNK_END_LF) {\n if (c == LF) {\n ctx->state = BODY_CHUNK;\n }\n else if (c == CR && ctx->state == BODY_CHUNK_END) {\n ctx->state = BODY_CHUNK_END_LF;\n }\n else {\n /*\n * LF expected.\n */\n return APR_EINVAL;\n }\n i++;\n continue;\n }\n\n /* handle start of the chunk */\n if (ctx->state == BODY_CHUNK) {\n if (!apr_isxdigit(c)) {\n /*\n * Detect invalid character at beginning. This also works for\n * empty chunk size lines.\n */\n return APR_EINVAL;\n }\n else {\n ctx->state = BODY_CHUNK_PART;\n }\n ctx->remaining = 0;\n ctx->chunkbits = sizeof(apr_off_t) * 8;\n ctx->chunk_used = 0;\n }\n\n if (c == LF) {\n if (ctx->remaining) {\n ctx->state = BODY_CHUNK_DATA;\n }\n else {\n ctx->state = BODY_CHUNK_TRAILER;\n }\n }\n else if (ctx->state == BODY_CHUNK_LF) {\n /*\n * LF expected.\n */\n return APR_EINVAL;\n }\n else if (c == CR) {\n ctx->state = BODY_CHUNK_LF;\n }\n else if (c == ';') {\n ctx->state = BODY_CHUNK_EXT;\n }\n else if (ctx->state == BODY_CHUNK_EXT) {\n /*\n * Control chars (but tabs) are invalid.\n */\n if (c != '\\t' && apr_iscntrl(c)) {\n return APR_EINVAL;\n }\n }\n else if (ctx->state == BODY_CHUNK_PART) {\n int xvalue;\n\n /* ignore leading zeros */\n if (!ctx->remaining && c == '0') {\n i++;\n continue;\n }\n\n ctx->chunkbits -= 4;\n if (ctx->chunkbits < 0) {\n /* overflow */\n return APR_ENOSPC;\n }\n\n if (c >= '0' && c <= '9') {\n xvalue = c - '0';\n }\n else if (c >= 'A' && c <= 'F') {\n xvalue = c - 'A' + 0xa;\n }\n else if (c >= 'a' && c <= 'f') {\n xvalue = c - 'a' + 0xa;\n }\n else {\n /* bogus character */\n return APR_EINVAL;\n }\n\n ctx->remaining = (ctx->remaining << 4) | xvalue;\n if (ctx->remaining < 0) {\n /* overflow */\n return APR_ENOSPC;\n }\n }\n else {\n /* Should not happen */\n return APR_EGENERAL;\n }\n\n i++;\n }\n\n /* sanity check */\n ctx->chunk_used += len;\n if (ctx->chunk_used < 0 || ctx->chunk_used > linelimit) {\n return APR_ENOSPC;\n }\n\n return APR_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-3183", "cwe_id": "CWE-20" }, { "id": 2628, "func": "JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *options) {\n if (width<=0 || height<=0 || width>32767 || height>32767) {\n jsExceptionHere(JSET_ERROR, \"Invalid Size\");\n return 0;\n }\n if (!isValidBPP(bpp)) {\n jsExceptionHere(JSET_ERROR, \"Invalid BPP\");\n return 0;\n }\n\n JsVar *parent = jspNewObject(0, \"Graphics\");\n if (!parent) return 0; // low memory\n\n JsGraphics gfx;\n graphicsStructInit(&gfx);\n gfx.data.type = JSGRAPHICSTYPE_ARRAYBUFFER;\n gfx.data.flags = JSGRAPHICSFLAGS_NONE;\n gfx.graphicsVar = parent;\n gfx.data.width = (unsigned short)width;\n gfx.data.height = (unsigned short)height;\n gfx.data.bpp = (unsigned char)bpp;\n\n if (jsvIsObject(options)) {\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"zigzag\", 0)))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_ZIGZAG);\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"msb\", 0)))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_MSB);\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"vertical_byte\", 0))) {\n if (gfx.data.bpp==1)\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE);\n else\n jsWarn(\"vertical_byte only works for 1bpp ArrayBuffers\\n\");\n }\n JsVar *colorv = jsvObjectGetChild(options, \"color_order\", 0);\n if (colorv) {\n if (jsvIsStringEqual(colorv, \"rgb\")) ; // The default\n else if (!jsvIsStringEqual(colorv, \"brg\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_BRG);\n else if (!jsvIsStringEqual(colorv, \"bgr\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_BGR);\n else if (!jsvIsStringEqual(colorv, \"gbr\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_GBR);\n else if (!jsvIsStringEqual(colorv, \"grb\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_GRB);\n else if (!jsvIsStringEqual(colorv, \"rbg\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_RBG);\n else\n jsWarn(\"color_order must be 3 characters\");\n jsvUnLock(colorv);\n }\n }\n\n lcdInit_ArrayBuffer(&gfx);\n graphicsSetVar(&gfx);\n return parent;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11592", "cwe_id": "CWE-125" }, { "id": 2628, "func": "JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *options) {\n if (width<=0 || height<=0 || width>32767 || height>32767) {\n jsExceptionHere(JSET_ERROR, \"Invalid Size\");\n return 0;\n }\n if (!isValidBPP(bpp)) {\n jsExceptionHere(JSET_ERROR, \"Invalid BPP\");\n return 0;\n }\n\n JsVar *parent = jspNewObject(0, \"Graphics\");\n if (!parent) return 0; // low memory\n\n JsGraphics gfx;\n graphicsStructInit(&gfx);\n gfx.data.type = JSGRAPHICSTYPE_ARRAYBUFFER;\n gfx.data.flags = JSGRAPHICSFLAGS_NONE;\n gfx.graphicsVar = parent;\n gfx.data.width = (unsigned short)width;\n gfx.data.height = (unsigned short)height;\n gfx.data.bpp = (unsigned char)bpp;\n\n if (jsvIsObject(options)) {\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"zigzag\", 0)))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_ZIGZAG);\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"msb\", 0)))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_MSB);\n if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, \"vertical_byte\", 0))) {\n if (gfx.data.bpp==1)\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE);\n else {\n jsExceptionHere(JSET_ERROR, \"vertical_byte only works for 1bpp ArrayBuffers\\n\");\n return 0;\n }\n if (gfx.data.height&7) {\n jsExceptionHere(JSET_ERROR, \"height must be a multiple of 8 when using vertical_byte\\n\");\n return 0;\n }\n }\n JsVar *colorv = jsvObjectGetChild(options, \"color_order\", 0);\n if (colorv) {\n if (jsvIsStringEqual(colorv, \"rgb\")) ; // The default\n else if (!jsvIsStringEqual(colorv, \"brg\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_BRG);\n else if (!jsvIsStringEqual(colorv, \"bgr\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_BGR);\n else if (!jsvIsStringEqual(colorv, \"gbr\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_GBR);\n else if (!jsvIsStringEqual(colorv, \"grb\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_GRB);\n else if (!jsvIsStringEqual(colorv, \"rbg\"))\n gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_COLOR_RBG);\n else\n jsWarn(\"color_order must be 3 characters\");\n jsvUnLock(colorv);\n }\n }\n\n lcdInit_ArrayBuffer(&gfx);\n graphicsSetVar(&gfx);\n return parent;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-11592", "cwe_id": "CWE-125" }, { "id": 553, "func": "PHP_FUNCTION( locale_get_region ) \n{\n\tget_icu_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 553, "func": "PHP_FUNCTION( locale_get_region )\n{\n\tget_icu_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 308, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = static_cast(node->user_data);\n\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n\n const RuntimeShape input_shape = GetTensorShape(input);\n const RuntimeShape output_shape = GetTensorShape(output);\n\n switch (input->type) {\n case kTfLiteFloat32: {\n // Float to int8, uint8, int16.\n tflite::QuantizationParams op_params;\n op_params.zero_point = output->params.zero_point;\n op_params.scale = output->params.scale;\n const float* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteInt16:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteInt16: {\n // int16 to int8 or int16.\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(GetTensorData(input),\n MatchingFlatSize(input_shape, output_shape),\n data->output_multiplier, data->output_shift,\n input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteInt16:\n Requantize(GetTensorData(input),\n MatchingFlatSize(input_shape, output_shape),\n data->output_multiplier, data->output_shift,\n input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteInt8: {\n // int8 to int8, uint8.\n const int32_t size = MatchingFlatSize(input_shape, output_shape);\n const int8_t* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteUInt8: {\n // uint8 to int8, uint8.\n const int32_t size = MatchingFlatSize(input_shape, output_shape);\n const uint8_t* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 308, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = static_cast(node->user_data);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n\n const RuntimeShape input_shape = GetTensorShape(input);\n const RuntimeShape output_shape = GetTensorShape(output);\n\n switch (input->type) {\n case kTfLiteFloat32: {\n // Float to int8, uint8, int16.\n tflite::QuantizationParams op_params;\n op_params.zero_point = output->params.zero_point;\n op_params.scale = output->params.scale;\n const float* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteInt16:\n AffineQuantize(op_params, input_shape, input_data,\n output_shape,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteInt16: {\n // int16 to int8 or int16.\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(GetTensorData(input),\n MatchingFlatSize(input_shape, output_shape),\n data->output_multiplier, data->output_shift,\n input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteInt16:\n Requantize(GetTensorData(input),\n MatchingFlatSize(input_shape, output_shape),\n data->output_multiplier, data->output_shift,\n input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteInt8: {\n // int8 to int8, uint8.\n const int32_t size = MatchingFlatSize(input_shape, output_shape);\n const int8_t* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n case kTfLiteUInt8: {\n // uint8 to int8, uint8.\n const int32_t size = MatchingFlatSize(input_shape, output_shape);\n const uint8_t* input_data = GetTensorData(input);\n switch (output->type) {\n case kTfLiteInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n case kTfLiteUInt8:\n Requantize(input_data, size, data->output_multiplier,\n data->output_shift, input->params.zero_point,\n output->params.zero_point,\n GetTensorData(output));\n return kTfLiteOk;\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n }\n default:\n ReportError(context, input->type, output->type);\n return kTfLiteError;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 919, "func": "rad_get_vendor_attr(u_int32_t *vendor, const void **data, size_t *len)\n{\n\tstruct vendor_attribute *attr;\n\n\tattr = (struct vendor_attribute *)*data;\n\t*vendor = ntohl(attr->vendor_value);\n\t*data = attr->attrib_data;\n\t*len = attr->attrib_len - 2;\n\n\treturn (attr->attrib_type);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-2220", "cwe_id": "CWE-119" }, { "id": 919, "func": "rad_get_vendor_attr(u_int32_t *vendor, unsigned char *type, const void **data, size_t *len, const void *raw, size_t raw_len)\n{\n\tstruct vendor_attribute *attr;\n\n\tif (raw_len < sizeof(struct vendor_attribute)) {\n\t\treturn -1;\n\t}\n\n\tattr = (struct vendor_attribute *) raw;\n\t*vendor = ntohl(attr->vendor_value);\n\t*type = attr->attrib_type;\n\t*data = attr->attrib_data;\n\t*len = attr->attrib_len - 2;\n\n\tif ((attr->attrib_len + 4) > raw_len) {\n\t\treturn -1;\n\t}\n\n\treturn (attr->attrib_type);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-2220", "cwe_id": "CWE-119" }, { "id": 439, "func": "static void scsi_read_complete(void * opaque, int ret)\n{\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n int n;\n\n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->bs, &r->acct);\n }\n\n if (ret) {\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_READ)) {\n return;\n }\n }\n\n DPRINTF(\"Data ready tag=0x%x len=%zd\\n\", r->req.tag, r->iov.iov_len);\n\n n = r->iov.iov_len / 512;\n r->sector += n;\n r->sector_count -= n;\n scsi_req_data(&r->req, r->iov.iov_len);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-3346", "cwe_id": "CWE-119" }, { "id": 439, "func": "static void scsi_read_complete(void * opaque, int ret)\n{\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n int n;\n\n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->bs, &r->acct);\n }\n\n if (ret) {\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_READ)) {\n return;\n }\n }\n\n DPRINTF(\"Data ready tag=0x%x len=%zd\\n\", r->req.tag, r->qiov.size);\n\n n = r->qiov.size / 512;\n r->sector += n;\n r->sector_count -= n;\n scsi_req_data(&r->req, r->qiov.size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-3346", "cwe_id": "CWE-119" }, { "id": 1227, "func": "static int handle_emulation_failure(struct kvm_vcpu *vcpu)\n{\n\t++vcpu->stat.insn_emulation_fail;\n\ttrace_kvm_emulate_insn_failed(vcpu);\n\tvcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;\n\tvcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;\n\tvcpu->run->internal.ndata = 0;\n\tkvm_queue_exception(vcpu, UD_VECTOR);\n\treturn EMULATE_FAIL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2010-5313", "cwe_id": "CWE-362" }, { "id": 1227, "func": "static int handle_emulation_failure(struct kvm_vcpu *vcpu)\n{\n\tint r = EMULATE_DONE;\n\n\t++vcpu->stat.insn_emulation_fail;\n\ttrace_kvm_emulate_insn_failed(vcpu);\n\tif (!is_guest_mode(vcpu)) {\n\t\tvcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;\n\t\tvcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;\n\t\tvcpu->run->internal.ndata = 0;\n\t\tr = EMULATE_FAIL;\n\t}\n\tkvm_queue_exception(vcpu, UD_VECTOR);\n\n\treturn r;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2010-5313", "cwe_id": "CWE-362" }, { "id": 2395, "func": "static int __init big_key_init(void)\n{\n\treturn register_key_type(&key_type_big_key);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9313", "cwe_id": "CWE-476" }, { "id": 2395, "func": "static int __init big_key_init(void)\n{\n\tstruct crypto_skcipher *cipher;\n\tstruct crypto_rng *rng;\n\tint ret;\n\n\trng = crypto_alloc_rng(big_key_rng_name, 0, 0);\n\tif (IS_ERR(rng)) {\n\t\tpr_err(\"Can't alloc rng: %ld\\n\", PTR_ERR(rng));\n\t\treturn PTR_ERR(rng);\n\t}\n\n\tbig_key_rng = rng;\n\n\t/* seed RNG */\n\tret = crypto_rng_reset(rng, NULL, crypto_rng_seedsize(rng));\n\tif (ret) {\n\t\tpr_err(\"Can't reset rng: %d\\n\", ret);\n\t\tgoto error_rng;\n\t}\n\n\t/* init block cipher */\n\tcipher = crypto_alloc_skcipher(big_key_alg_name, 0, CRYPTO_ALG_ASYNC);\n\tif (IS_ERR(cipher)) {\n\t\tret = PTR_ERR(cipher);\n\t\tpr_err(\"Can't alloc crypto: %d\\n\", ret);\n\t\tgoto error_rng;\n\t}\n\n\tbig_key_skcipher = cipher;\n\n\tret = register_key_type(&key_type_big_key);\n\tif (ret < 0) {\n\t\tpr_err(\"Can't register type: %d\\n\", ret);\n\t\tgoto error_cipher;\n\t}\n\n\treturn 0;\n\nerror_cipher:\n\tcrypto_free_skcipher(big_key_skcipher);\nerror_rng:\n\tcrypto_free_rng(big_key_rng);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9313", "cwe_id": "CWE-476" } ]