diff --git "a/validation.jsonl" "b/validation.jsonl" --- "a/validation.jsonl" +++ "b/validation.jsonl" @@ -167,7 +167,6 @@ {"code": " $section = new section(intval($page));\r\n if ($section) {\r\n// self::deleteLevel($section->id);\r\n $section->delete();\r\n }\r\n }\r\n }\r", "label_name": "Base", "label": 1} {"code": "\tprotected function _downloadErrorLog()\n\t{\n\t\t$tmpDir = TMP . 'logs' . DS;\n\t\t$Folder = new Folder($tmpDir);\n\t\t$files = $Folder->read(true, true, false);\n\t\tif (count($files[0]) === 0 && count($files[1]) === 0) {\n\t\t\treturn false;\n\t\t}\n\t\t// ZIP\u5727\u7e2e\u3057\u3066\u51fa\u529b\n\t\t$fileName = 'basercms_logs_' . date('Ymd_His');\n\t\t$Simplezip = new Simplezip();\n\t\t$Simplezip->addFolder($tmpDir);\n\t\t$Simplezip->download($fileName);\n\t\treturn true;\n\t}", "label_name": "Base", "label": 1} {"code": " foreach ($val as $vkey => $value) {\n if ($vkey != 'LAST_UPDATED') {\n if ($vkey != 'UPDATED_BY') {\n if ($vkey == 'ID')\n echo '' . htmlentities($value) . '';\n else if ($vkey == 'SYEAR')\n echo '' . htmlentities($value) . '';\n else if ($vkey == 'TITLE')\n echo '' . htmlentities($value) . '';\n else if ($vkey == 'WWW_ADDRESS')\n echo '' . htmlentities($value) . '';\n else\n echo '<' . $vkey . '>' . htmlentities($value) . '';\n }\n }\n }", "label_name": "Base", "label": 1} -{"code": "function access_has_bug_level( $p_access_level, $p_bug_id, $p_user_id = null ) {\n\tif( $p_user_id === null ) {\n\t\t$p_user_id = auth_get_current_user_id();\n\t}\n\n\t# Deal with not logged in silently in this case\n\t# @@@ we may be able to remove this and just error\n\t# and once we default to anon login, we can remove it for sure\n\tif( empty( $p_user_id ) && !auth_is_user_authenticated() ) {\n\t\treturn false;\n\t}\n\n\t$t_project_id = bug_get_field( $p_bug_id, 'project_id' );\n\n\t# check limit_Reporter (Issue #4769)\n\t# reporters can view just issues they reported\n\t$t_limit_reporters = config_get( 'limit_reporters' );\n\tif(( ON === $t_limit_reporters ) && ( !bug_is_user_reporter( $p_bug_id, $p_user_id ) ) && ( !access_has_project_level( REPORTER + 1, $t_project_id, $p_user_id ) ) ) {\n\t\treturn false;\n\t}\n\n\t# If the bug is private and the user is not the reporter, then the\n\t# the user must also have higher access than private_bug_threshold\n\tif( VS_PRIVATE == bug_get_field( $p_bug_id, 'view_state' ) && !bug_is_user_reporter( $p_bug_id, $p_user_id ) ) {\n\t\t$p_access_level = max( $p_access_level, config_get( 'private_bug_threshold' ) );\n\t}\n\n\treturn access_has_project_level( $p_access_level, $t_project_id, $p_user_id );\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "\tpublic function addTable( $table, $alias ) {\n\t\tif ( empty( $table ) ) {\n\t\t\tthrow new \\MWException( __METHOD__ . ': An empty table name was passed.' );\n\t\t}\n\t\tif ( empty( $alias ) || is_numeric( $alias ) ) {\n\t\t\tthrow new \\MWException( __METHOD__ . ': An empty or numeric table alias was passed.' );\n\t\t}\n\t\tif ( !isset( $this->tables[$alias] ) ) {\n\t\t\t$this->tables[$alias] = $this->DB->tableName( $table );\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}", "label_name": "Class", "label": 2} {"code": "\tpublic function approve() {\n\t expHistory::set('editable', $this->params);\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\t \n\t if (empty($this->params['id'])) {\n\t flash('error', gt('No ID supplied for comment to approve'));\n\t expHistory::back();\n\t }\n\t \n\t $comment = new expComment($this->params['id']);\n\t assign_to_template(array(\n 'comment'=>$comment\n ));\n\t}", "label_name": "Class", "label": 2} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $category = $this->getCategory();\n\n $this->response->html($this->helper->layout->project('category/remove', array(\n 'project' => $project,\n 'category' => $category,\n )));\n }", "label_name": "Base", "label": 1} @@ -1017,7 +1016,6 @@ {"code": "void dhcpAddOption(DhcpMessage *message, uint8_t optionCode,\n const void *optionValue, size_t optionLen)\n{\n size_t n;\n DhcpOption *option;\n\n //Point to the very first option\n n = 0;\n\n //Parse DHCP options\n while(1)\n {\n //Point to the current option\n option = (DhcpOption *) (message->options + n);\n\n //End option detected?\n if(option->code == DHCP_OPT_END)\n break;\n\n //Jump to next the next option\n n += sizeof(DhcpOption) + option->length;\n }\n\n //Sanity check\n if(optionLen <= UINT8_MAX)\n {\n //Point to the buffer where the option is to be written\n option = (DhcpOption *) (message->options + n);\n\n //Option code\n option->code = optionCode;\n //Option length\n option->length = (uint8_t) optionLen;\n //Option value\n osMemcpy(option->value, optionValue, optionLen);\n\n //Jump to next the next option\n n += sizeof(DhcpOption) + option->length;\n\n //Point to the buffer where the option is to be written\n option = (DhcpOption *) (message->options + n);\n\n //Always terminate the options field with 255\n option->code = DHCP_OPT_END;\n }\n}", "label_name": "Class", "label": 2} {"code": "void pjsua_init_tpselector(pjsua_transport_id tp_id,\n\t\t\t pjsip_tpselector *sel)\n{\n pjsua_transport_data *tpdata;\n unsigned flag;\n\n pj_bzero(sel, sizeof(*sel));\n if (tp_id == PJSUA_INVALID_ID)\n\treturn;\n\n pj_assert(tp_id >= 0 && tp_id < (int)PJ_ARRAY_SIZE(pjsua_var.tpdata));\n tpdata = &pjsua_var.tpdata[tp_id];\n\n flag = pjsip_transport_get_flag_from_type(tpdata->type);\n\n if (flag & PJSIP_TRANSPORT_DATAGRAM) {\n\tsel->type = PJSIP_TPSELECTOR_TRANSPORT;\n\tsel->u.transport = tpdata->data.tp;\n } else {\n\tsel->type = PJSIP_TPSELECTOR_LISTENER;\n\tsel->u.listener = tpdata->data.factory;\n }\n}", "label_name": "Base", "label": 1} {"code": "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_name": "Base", "label": 1} -{"code": "static int apparmor_setprocattr(struct task_struct *task, char *name,\n\t\t\t\tvoid *value, size_t size)\n{\n\tstruct common_audit_data sa;\n\tstruct apparmor_audit_data aad = {0,};\n\tchar *command, *args = value;\n\tsize_t arg_size;\n\tint error;\n\n\tif (size == 0)\n\t\treturn -EINVAL;\n\t/* args points to a PAGE_SIZE buffer, AppArmor requires that\n\t * the buffer must be null terminated or have size <= PAGE_SIZE -1\n\t * so that AppArmor can null terminate them\n\t */\n\tif (args[size - 1] != '\\0') {\n\t\tif (size == PAGE_SIZE)\n\t\t\treturn -EINVAL;\n\t\targs[size] = '\\0';\n\t}\n\n\t/* task can only write its own attributes */\n\tif (current != task)\n\t\treturn -EACCES;\n\n\targs = value;\n\targs = strim(args);\n\tcommand = strsep(&args, \" \");\n\tif (!args)\n\t\treturn -EINVAL;\n\targs = skip_spaces(args);\n\tif (!*args)\n\t\treturn -EINVAL;\n\n\targ_size = size - (args - (char *) value);\n\tif (strcmp(name, \"current\") == 0) {\n\t\tif (strcmp(command, \"changehat\") == 0) {\n\t\t\terror = aa_setprocattr_changehat(args, arg_size,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\t} else if (strcmp(command, \"permhat\") == 0) {\n\t\t\terror = aa_setprocattr_changehat(args, arg_size,\n\t\t\t\t\t\t\t AA_DO_TEST);\n\t\t} else if (strcmp(command, \"changeprofile\") == 0) {\n\t\t\terror = aa_setprocattr_changeprofile(args, !AA_ONEXEC,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\t} else if (strcmp(command, \"permprofile\") == 0) {\n\t\t\terror = aa_setprocattr_changeprofile(args, !AA_ONEXEC,\n\t\t\t\t\t\t\t AA_DO_TEST);\n\t\t} else\n\t\t\tgoto fail;\n\t} else if (strcmp(name, \"exec\") == 0) {\n\t\tif (strcmp(command, \"exec\") == 0)\n\t\t\terror = aa_setprocattr_changeprofile(args, AA_ONEXEC,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\telse\n\t\t\tgoto fail;\n\t} else\n\t\t/* only support the \"current\" and \"exec\" process attributes */\n\t\treturn -EINVAL;\n\n\tif (!error)\n\t\terror = size;\n\treturn error;\n\nfail:\n\tsa.type = LSM_AUDIT_DATA_NONE;\n\tsa.aad = &aad;\n\taad.profile = aa_current_profile();\n\taad.op = OP_SETPROCATTR;\n\taad.info = name;\n\taad.error = -EINVAL;\n\taa_audit_msg(AUDIT_APPARMOR_DENIED, &sa, NULL);\n\treturn -EINVAL;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "int ppp_register_net_channel(struct net *net, struct ppp_channel *chan)\n{\n\tstruct channel *pch;\n\tstruct ppp_net *pn;\n\n\tpch = kzalloc(sizeof(struct channel), GFP_KERNEL);\n\tif (!pch)\n\t\treturn -ENOMEM;\n\n\tpn = ppp_pernet(net);\n\n\tpch->ppp = NULL;\n\tpch->chan = chan;\n\tpch->chan_net = net;\n\tchan->ppp = pch;\n\tinit_ppp_file(&pch->file, CHANNEL);\n\tpch->file.hdrlen = chan->hdrlen;\n#ifdef CONFIG_PPP_MULTILINK\n\tpch->lastseq = -1;\n#endif /* CONFIG_PPP_MULTILINK */\n\tinit_rwsem(&pch->chan_sem);\n\tspin_lock_init(&pch->downl);\n\trwlock_init(&pch->upl);\n\n\tspin_lock_bh(&pn->all_channels_lock);\n\tpch->file.index = ++pn->last_channel_index;\n\tlist_add(&pch->list, &pn->new_channels);\n\tatomic_inc(&channel_count);\n\tspin_unlock_bh(&pn->all_channels_lock);\n\n\treturn 0;\n}", "label_name": "Variant", "label": 0} {"code": "static void f_parser (lua_State *L, void *ud) {\n int i;\n Proto *tf;\n Closure *cl;\n struct SParser *p = cast(struct SParser *, ud);\n int c = luaZ_lookahead(p->z);\n luaC_checkGC(L);\n tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,\n &p->buff, p->name);\n cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));\n cl->l.p = tf;\n for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */\n cl->l.upvals[i] = luaF_newupval(L);\n setclvalue(L, L->top, cl);\n incr_top(L);\n}", "label_name": "CWE-17", "label": "CWE-17"} {"code": "static LUA_FUNCTION(openssl_x509_check_host)\n{\n X509 * cert = CHECK_OBJECT(1, X509, \"openssl.x509\");\n if (lua_isstring(L, 2))\n {\n const char *hostname = lua_tostring(L, 2);\n lua_pushboolean(L, X509_check_host(cert, hostname, strlen(hostname), 0, NULL));\n }\n else\n {\n lua_pushboolean(L, 0);\n }\n return 1;\n}", "label_name": "Base", "label": 1} @@ -1077,7 +1075,6 @@ {"code": "static int checkout_verify_paths(\n\tgit_repository *repo,\n\tint action,\n\tgit_diff_delta *delta)\n{\n\tunsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;\n\n\tif (action & CHECKOUT_ACTION__REMOVE) {\n\t\tif (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {\n\t\t\tgit_error_set(GIT_ERROR_CHECKOUT, \"cannot remove invalid path '%s'\", delta->old_file.path);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (action & ~CHECKOUT_ACTION__REMOVE) {\n\t\tif (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {\n\t\t\tgit_error_set(GIT_ERROR_CHECKOUT, \"cannot checkout to invalid path '%s'\", delta->new_file.path);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n}", "label_name": "Class", "label": 2} {"code": "static void prekey_handler(const char *userid,\n\t\t\t const uint8_t *key, size_t key_len,\n\t\t\t uint16_t id, const char *clientid,\n\t\t\t bool last, void *arg)\n{\n\tstruct session *sess;\n\tchar lclientid[64];\n\tint err;\n\n\toutput(\"prekey_handler: %zu bytes, user:%s[%u] -> %s\\n\",\n\t key_len, userid, id, clientid);\n\n\n\terr = client_id_load(lclientid, sizeof(lclientid));\n\tif (err) {\n\t\tdebug(\"my clientid not set -- cannot store prekeys\\n\");\n\t\treturn;\n\t}\n\n\tsess = cryptobox_session_find(g_cryptobox, userid, clientid, lclientid);\n\tif (sess) {\n\t\toutput(\"prekey: session found\\n\");\n\t}\n\telse {\n\t\tinfo(\"conv: adding key to cryptobox for clientid=%s\\n\",\n\t\t clientid);\n\n\t\terr = cryptobox_session_add_send(g_cryptobox, userid, clientid, lclientid,\n\t\t\t\t\t\t key, key_len);\n\t\tif (err) {\n\t\t\twarning(\"cryptobox_session_add_send failed (%m)\\n\",\n\t\t\t\terr);\n\t\t}\n\t}\n}", "label_name": "Base", "label": 1} {"code": "int read_file(struct sc_card *card, char *str_path, unsigned char **data, size_t *data_len)\n{\n\tstruct sc_path path;\n\tstruct sc_file *file;\n\tunsigned char *p;\n\tint ok = 0;\n\tint r;\n\tsize_t len;\n\n\tsc_format_path(str_path, &path);\n\tif (SC_SUCCESS != sc_select_file(card, &path, &file)) {\n\t\tgoto err;\n\t}\n\n\tlen = file ? file->size : 4096;\n\tp = realloc(*data, len);\n\tif (!p) {\n\t\tgoto err;\n\t}\n\t*data = p;\n\t*data_len = len;\n\n\tr = sc_read_binary(card, 0, p, len, 0);\n\tif (r < 0)\n\t\tgoto err;\n\n\t*data_len = r;\n\tok = 1;\n\nerr:\n\tsc_file_free(file);\n\n\treturn ok;\n}", "label_name": "Class", "label": 2} -{"code": "static struct ion_handle *ion_handle_get_by_id(struct ion_client *client,\n\t\t\t\t\t\tint id)\n{\n\tstruct ion_handle *handle;\n\n\tmutex_lock(&client->lock);\n\thandle = idr_find(&client->idr, id);\n\tif (handle)\n\t\tion_handle_get(handle);\n\tmutex_unlock(&client->lock);\n\n\treturn handle ? handle : ERR_PTR(-EINVAL);\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "static __inline__ void ipv6_select_ident(struct frag_hdr *fhdr)\n{\n\tstatic u32 ipv6_fragmentation_id = 1;\n\tstatic DEFINE_SPINLOCK(ip6_id_lock);\n\n\tspin_lock_bh(&ip6_id_lock);\n\tfhdr->identification = htonl(ipv6_fragmentation_id);\n\tif (++ipv6_fragmentation_id == 0)\n\t\tipv6_fragmentation_id = 1;\n\tspin_unlock_bh(&ip6_id_lock);\n}", "label_name": "NVD-CWE-Other", "label": "NVD-CWE-Other"} {"code": "int fscrypt_get_encryption_info(struct inode *inode)\n{\n\tstruct fscrypt_info *ci = inode->i_crypt_info;\n\n\tif (!ci ||\n\t\t(ci->ci_keyring_key &&\n\t\t (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |\n\t\t\t\t\t (1 << KEY_FLAG_REVOKED) |\n\t\t\t\t\t (1 << KEY_FLAG_DEAD)))))\n\t\treturn fscrypt_get_crypt_info(inode);\n\treturn 0;\n}", "label_name": "Variant", "label": 0} {"code": "ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)\n{\n /* async_funcdef: ASYNC funcdef */\n REQ(n, async_funcdef);\n REQ(CHILD(n, 0), ASYNC);\n REQ(CHILD(n, 1), funcdef);\n\n return ast_for_funcdef_impl(c, CHILD(n, 1), decorator_seq,\n 1 /* is_async */);\n}", "label_name": "Base", "label": 1} @@ -1102,12 +1099,10 @@ {"code": "static void cil_reset_classperms_set(struct cil_classperms_set *cp_set)\n{\n\tcil_reset_classpermission(cp_set->set);\n}", "label_name": "Variant", "label": 0} {"code": "static void perf_event_exit_cpu(int cpu)\n{\n\tstruct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);\n\n\tperf_event_exit_cpu_context(cpu);\n\n\tmutex_lock(&swhash->hlist_mutex);\n\tswhash->online = false;\n\tswevent_hlist_release(swhash);\n\tmutex_unlock(&swhash->hlist_mutex);\n}", "label_name": "Class", "label": 2} {"code": "static void gf_dump_vrml_simple_field(GF_SceneDumper *sdump, GF_FieldInfo field, GF_Node *parent)\n{\n\tu32 i, sf_type;\n\tGF_ChildNodeItem *list;\n\tvoid *slot_ptr;\n\n\tswitch (field.fieldType) {\n\tcase GF_SG_VRML_SFNODE:\n\t\tgf_dump_vrml_node(sdump, field.far_ptr ? *(GF_Node **)field.far_ptr : NULL, 0, NULL);\n\t\treturn;\n\tcase GF_SG_VRML_MFNODE:\n\t\tlist = * ((GF_ChildNodeItem **) field.far_ptr);\n\t\tassert( list );\n\t\tsdump->indent++;\n\t\twhile (list) {\n\t\t\tgf_dump_vrml_node(sdump, list->node, 1, NULL);\n\t\t\tlist = list->next;\n\t\t}\n\t\tsdump->indent--;\n\t\treturn;\n\tcase GF_SG_VRML_SFCOMMANDBUFFER:\n\t\treturn;\n\t}\n\tif (gf_sg_vrml_is_sf_field(field.fieldType)) {\n\t\tif (sdump->XMLDump) StartAttribute(sdump, \"value\");\n\t\tgf_dump_vrml_sffield(sdump, field.fieldType, field.far_ptr, 0, parent);\n\t\tif (sdump->XMLDump) EndAttribute(sdump);\n\t} else {\n\t\tGenMFField *mffield;\n\t\tmffield = (GenMFField *) field.far_ptr;\n\t\tsf_type = gf_sg_vrml_get_sf_type(field.fieldType);\n\t\tif (!sdump->XMLDump) {\n\t\t\tgf_fprintf(sdump->trace, \"[\");\n\t\t} else if (sf_type==GF_SG_VRML_SFSTRING) {\n\t\t\tgf_fprintf(sdump->trace, \" value=\\'\");\n\t\t} else {\n\t\t\tStartAttribute(sdump, \"value\");\n\t\t}\n\t\tfor (i=0; icount; i++) {\n\t\t\tif (i) gf_fprintf(sdump->trace, \" \");\n\t\t\tgf_sg_vrml_mf_get_item(field.far_ptr, field.fieldType, &slot_ptr, i);\n\t\t\t/*this is to cope with single MFString which shall appear as SF in XMT*/\n\t\t\tgf_dump_vrml_sffield(sdump, sf_type, slot_ptr, 1, parent);\n\t\t}\n\t\tif (!sdump->XMLDump) {\n\t\t\tgf_fprintf(sdump->trace, \"]\");\n\t\t} else if (sf_type==GF_SG_VRML_SFSTRING) {\n\t\t\tgf_fprintf(sdump->trace, \"\\'\");\n\t\t} else {\n\t\t\tEndAttribute(sdump);\n\t\t}\n\t}\n}", "label_name": "Base", "label": 1} -{"code": "static int cg_rmdir(const char *path)\n{\n\tstruct fuse_context *fc = fuse_get_context();\n\tchar *fpath = NULL, *cgdir = NULL, *controller;\n\tconst char *cgroup;\n\tint ret;\n\n\tif (!fc)\n\t\treturn -EIO;\n\n\tcontroller = pick_controller_from_path(fc, path);\n\tif (!controller)\n\t\treturn -EINVAL;\n\n\tcgroup = find_cgroup_in_path(path);\n\tif (!cgroup)\n\t\treturn -EINVAL;\n\n\tget_cgdir_and_path(cgroup, &cgdir, &fpath);\n\tif (!fpath) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tfprintf(stderr, \"rmdir: verifying access to %s:%s (req path %s)\\n\",\n\t\t\tcontroller, cgdir, path);\n\tif (!fc_may_access(fc, controller, cgdir, NULL, O_WRONLY)) {\n\t\tret = -EACCES;\n\t\tgoto out;\n\t}\n\tif (!caller_is_in_ancestor(fc->pid, controller, cgroup, NULL)) {\n\t\tret = -EACCES;\n\t\tgoto out;\n\t}\n\n\tif (!cgfs_remove(controller, cgroup)) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tret = 0;\n\nout:\n\tfree(cgdir);\n\treturn ret;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "int ipmi_si_port_setup(struct si_sm_io *io)\n{\n\tunsigned int addr = io->addr_data;\n\tint idx;\n\n\tif (!addr)\n\t\treturn -ENODEV;\n\n\tio->io_cleanup = port_cleanup;\n\n\t/*\n\t * Figure out the actual inb/inw/inl/etc routine to use based\n\t * upon the register size.\n\t */\n\tswitch (io->regsize) {\n\tcase 1:\n\t\tio->inputb = port_inb;\n\t\tio->outputb = port_outb;\n\t\tbreak;\n\tcase 2:\n\t\tio->inputb = port_inw;\n\t\tio->outputb = port_outw;\n\t\tbreak;\n\tcase 4:\n\t\tio->inputb = port_inl;\n\t\tio->outputb = port_outl;\n\t\tbreak;\n\tdefault:\n\t\tdev_warn(io->dev, \"Invalid register size: %d\\n\",\n\t\t\t io->regsize);\n\t\treturn -EINVAL;\n\t}\n\n\t/*\n\t * Some BIOSes reserve disjoint I/O regions in their ACPI\n\t * tables. This causes problems when trying to register the\n\t * entire I/O region. Therefore we must register each I/O\n\t * port separately.\n\t */\n\tfor (idx = 0; idx < io->io_size; idx++) {\n\t\tif (request_region(addr + idx * io->regspacing,\n\t\t\t\t io->regsize, DEVICE_NAME) == NULL) {\n\t\t\t/* Undo allocations */\n\t\t\twhile (idx--)\n\t\t\t\trelease_region(addr + idx * io->regspacing,\n\t\t\t\t\t io->regsize);\n\t\t\treturn -EIO;\n\t\t}\n\t}\n\treturn 0;\n}", "label_name": "Variant", "label": 0} {"code": "init_ctx_new(OM_uint32 *minor_status,\n\t spnego_gss_cred_id_t spcred,\n\t gss_ctx_id_t *ctx,\n\t send_token_flag *tokflag)\n{\n\tOM_uint32 ret;\n\tspnego_gss_ctx_id_t sc = NULL;\n\n\tsc = create_spnego_ctx();\n\tif (sc == NULL)\n\t\treturn GSS_S_FAILURE;\n\n\t/* determine negotiation mech set */\n\tret = get_negotiable_mechs(minor_status, spcred, GSS_C_INITIATE,\n\t\t\t\t &sc->mech_set);\n\tif (ret != GSS_S_COMPLETE)\n\t\tgoto cleanup;\n\n\t/* Set an initial internal mech to make the first context token. */\n\tsc->internal_mech = &sc->mech_set->elements[0];\n\n\tif (put_mech_set(sc->mech_set, &sc->DER_mechTypes) < 0) {\n\t\tret = GSS_S_FAILURE;\n\t\tgoto cleanup;\n\t}\n\t/*\n\t * The actual context is not yet determined, set the output\n\t * context handle to refer to the spnego context itself.\n\t */\n\tsc->ctx_handle = GSS_C_NO_CONTEXT;\n\t*ctx = (gss_ctx_id_t)sc;\n\tsc = NULL;\n\t*tokflag = INIT_TOKEN_SEND;\n\tret = GSS_S_CONTINUE_NEEDED;\n\ncleanup:\n\trelease_spnego_ctx(&sc);\n\treturn ret;\n}", "label_name": "Base", "label": 1} {"code": "int qeth_snmp_command(struct qeth_card *card, char __user *udata)\n{\n\tstruct qeth_cmd_buffer *iob;\n\tstruct qeth_ipa_cmd *cmd;\n\tstruct qeth_snmp_ureq *ureq;\n\tint req_len;\n\tstruct qeth_arp_query_info qinfo = {0, };\n\tint rc = 0;\n\n\tQETH_CARD_TEXT(card, 3, \"snmpcmd\");\n\n\tif (card->info.guestlan)\n\t\treturn -EOPNOTSUPP;\n\n\tif ((!qeth_adp_supported(card, IPA_SETADP_SET_SNMP_CONTROL)) &&\n\t (!card->options.layer2)) {\n\t\treturn -EOPNOTSUPP;\n\t}\n\t/* skip 4 bytes (data_len struct member) to get req_len */\n\tif (copy_from_user(&req_len, udata + sizeof(int), sizeof(int)))\n\t\treturn -EFAULT;\n\tureq = memdup_user(udata, req_len + sizeof(struct qeth_snmp_ureq_hdr));\n\tif (IS_ERR(ureq)) {\n\t\tQETH_CARD_TEXT(card, 2, \"snmpnome\");\n\t\treturn PTR_ERR(ureq);\n\t}\n\tqinfo.udata_len = ureq->hdr.data_len;\n\tqinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);\n\tif (!qinfo.udata) {\n\t\tkfree(ureq);\n\t\treturn -ENOMEM;\n\t}\n\tqinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);\n\n\tiob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,\n\t\t\t\t QETH_SNMP_SETADP_CMDLENGTH + req_len);\n\tcmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);\n\tmemcpy(&cmd->data.setadapterparms.data.snmp, &ureq->cmd, req_len);\n\trc = qeth_send_ipa_snmp_cmd(card, iob, QETH_SETADP_BASE_LEN + req_len,\n\t\t\t\t qeth_snmp_command_cb, (void *)&qinfo);\n\tif (rc)\n\t\tQETH_DBF_MESSAGE(2, \"SNMP command failed on %s: (0x%x)\\n\",\n\t\t\t QETH_CARD_IFNAME(card), rc);\n\telse {\n\t\tif (copy_to_user(udata, qinfo.udata, qinfo.udata_len))\n\t\t\trc = -EFAULT;\n\t}\n\n\tkfree(ureq);\n\tkfree(qinfo.udata);\n\treturn rc;\n}", "label_name": "Class", "label": 2} {"code": "choose_filters(struct archive_read *a)\n{\n\tint number_bidders, i, bid, best_bid;\n\tstruct archive_read_filter_bidder *bidder, *best_bidder;\n\tstruct archive_read_filter *filter;\n\tssize_t avail;\n\tint r;\n\n\tfor (;;) {\n\t\tnumber_bidders = sizeof(a->bidders) / sizeof(a->bidders[0]);\n\n\t\tbest_bid = 0;\n\t\tbest_bidder = NULL;\n\n\t\tbidder = a->bidders;\n\t\tfor (i = 0; i < number_bidders; i++, bidder++) {\n\t\t\tif (bidder->bid != NULL) {\n\t\t\t\tbid = (bidder->bid)(bidder, a->filter);\n\t\t\t\tif (bid > best_bid) {\n\t\t\t\t\tbest_bid = bid;\n\t\t\t\t\tbest_bidder = bidder;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* If no bidder, we're done. */\n\t\tif (best_bidder == NULL) {\n\t\t\t/* Verify the filter by asking it for some data. */\n\t\t\t__archive_read_filter_ahead(a->filter, 1, &avail);\n\t\t\tif (avail < 0) {\n\t\t\t\t__archive_read_close_filters(a);\n\t\t\t\t__archive_read_free_filters(a);\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->archive.compression_name = a->filter->name;\n\t\t\ta->archive.compression_code = a->filter->code;\n\t\t\treturn (ARCHIVE_OK);\n\t\t}\n\n\t\tfilter\n\t\t = (struct archive_read_filter *)calloc(1, sizeof(*filter));\n\t\tif (filter == NULL)\n\t\t\treturn (ARCHIVE_FATAL);\n\t\tfilter->bidder = best_bidder;\n\t\tfilter->archive = a;\n\t\tfilter->upstream = a->filter;\n\t\ta->filter = filter;\n\t\tr = (best_bidder->init)(a->filter);\n\t\tif (r != ARCHIVE_OK) {\n\t\t\t__archive_read_close_filters(a);\n\t\t\t__archive_read_free_filters(a);\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t}\n}", "label_name": "CWE-399", "label": "CWE-399"} -{"code": "int xt_compat_check_entry_offsets(const void *base,\n\t\t\t\t unsigned int target_offset,\n\t\t\t\t unsigned int next_offset)\n{\n\tconst struct compat_xt_entry_target *t;\n\tconst char *e = base;\n\n\tif (target_offset + sizeof(*t) > next_offset)\n\t\treturn -EINVAL;\n\n\tt = (void *)(e + target_offset);\n\tif (t->u.target_size < sizeof(*t))\n\t\treturn -EINVAL;\n\n\tif (target_offset + t->u.target_size > next_offset)\n\t\treturn -EINVAL;\n\n\tif (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&\n\t target_offset + sizeof(struct compat_xt_standard_target) != next_offset)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "void trustedDkgVerifyAES(int *errStatus, char *errString, const char *public_shares, const char *s_share,\n uint8_t *encryptedPrivateKey, uint64_t enc_len, unsigned _t, int _ind, int *result) {\n LOG_INFO(__FUNCTION__);\n\n INIT_ERROR_STATE\n\n CHECK_STATE(public_shares);\n CHECK_STATE(s_share);\n CHECK_STATE(encryptedPrivateKey);\n\n SAFE_CHAR_BUF(skey, ECDSA_SKEY_LEN);\n\n mpz_t s;\n mpz_init(s);\n\n int status = AES_decrypt(encryptedPrivateKey, enc_len, skey, ECDSA_SKEY_LEN);\n\n CHECK_STATUS2(\"AES_decrypt failed (in trustedDkgVerifyAES) with status %d\");\n\n SAFE_CHAR_BUF(encr_sshare, ECDSA_SKEY_LEN);\n\n strncpy(encr_sshare, s_share, ECDSA_SKEY_LEN - 1);\n\n SAFE_CHAR_BUF(common_key, ECDSA_SKEY_LEN);\n\n status = session_key_recover(skey, s_share, common_key);\n\n CHECK_STATUS(\"session_key_recover failed\");\n\n SAFE_CHAR_BUF(decr_sshare, ECDSA_SKEY_LEN);\n\n status=xor_decrypt(common_key, encr_sshare, decr_sshare);\n\n CHECK_STATUS(\"xor_decrypt failed\")\n\n\n status = mpz_set_str(s, decr_sshare, 16);\n CHECK_STATUS(\"invalid decr secret share\");\n\n *result = Verification(public_shares, s, _t, _ind);\n\n SET_SUCCESS\n clean:\n\n mpz_clear(s);\n LOG_INFO(__FUNCTION__ );\n LOG_INFO(\"SGX call completed\");\n}", "label_name": "Base", "label": 1} {"code": "static int validate_user_key(struct fscrypt_info *crypt_info,\n\t\t\tstruct fscrypt_context *ctx, u8 *raw_key,\n\t\t\tconst char *prefix)\n{\n\tchar *description;\n\tstruct key *keyring_key;\n\tstruct fscrypt_key *master_key;\n\tconst struct user_key_payload *ukp;\n\tint res;\n\n\tdescription = kasprintf(GFP_NOFS, \"%s%*phN\", prefix,\n\t\t\t\tFS_KEY_DESCRIPTOR_SIZE,\n\t\t\t\tctx->master_key_descriptor);\n\tif (!description)\n\t\treturn -ENOMEM;\n\n\tkeyring_key = request_key(&key_type_logon, description, NULL);\n\tkfree(description);\n\tif (IS_ERR(keyring_key))\n\t\treturn PTR_ERR(keyring_key);\n\n\tif (keyring_key->type != &key_type_logon) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key type must be logon\\n\", __func__);\n\t\tres = -ENOKEY;\n\t\tgoto out;\n\t}\n\tdown_read(&keyring_key->sem);\n\tukp = user_key_payload(keyring_key);\n\tif (ukp->datalen != sizeof(struct fscrypt_key)) {\n\t\tres = -EINVAL;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tmaster_key = (struct fscrypt_key *)ukp->data;\n\tBUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);\n\n\tif (master_key->size != FS_AES_256_XTS_KEY_SIZE) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key size incorrect: %d\\n\",\n\t\t\t\t__func__, master_key->size);\n\t\tres = -ENOKEY;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tres = derive_key_aes(ctx->nonce, master_key->raw, raw_key);\n\tup_read(&keyring_key->sem);\n\tif (res)\n\t\tgoto out;\n\n\tcrypt_info->ci_keyring_key = keyring_key;\n\treturn 0;\nout:\n\tkey_put(keyring_key);\n\treturn res;\n}", "label_name": "Base", "label": 1} {"code": "void TEMPLATE(process_block_dec)(decoder_info_t *decoder_info,int size,int yposY,int xposY,int sub)\n{\n int width = decoder_info->width;\n int height = decoder_info->height;\n stream_t *stream = decoder_info->stream;\n frame_type_t frame_type = decoder_info->frame_info.frame_type;\n int split_flag = 0;\n\n if (yposY >= height || xposY >= width)\n return;\n\n int decode_this_size = (yposY + size <= height) && (xposY + size <= width);\n int decode_rectangular_size = !decode_this_size && frame_type != I_FRAME;\n\n int bit_start = stream->bitcnt;\n\n int mode = MODE_SKIP;\n \n block_context_t block_context;\n TEMPLATE(find_block_contexts)(yposY, xposY, height, width, size, decoder_info->deblock_data, &block_context, decoder_info->use_block_contexts);\n decoder_info->block_context = &block_context;\n\n split_flag = decode_super_mode(decoder_info,size,decode_this_size);\n mode = decoder_info->mode;\n \n /* Read delta_qp and set block-level qp */\n if (size == (1<log2_sb_size) && (split_flag || mode != MODE_SKIP) && decoder_info->max_delta_qp > 0) {\n /* Read delta_qp */\n int delta_qp = read_delta_qp(stream);\n int prev_qp;\n if (yposY == 0 && xposY == 0)\n prev_qp = decoder_info->frame_info.qp;\n else\n prev_qp = decoder_info->frame_info.qpb;\n decoder_info->frame_info.qpb = prev_qp + delta_qp;\n }\n\n decoder_info->bit_count.super_mode[decoder_info->bit_count.stat_frame_type] += (stream->bitcnt - bit_start);\n\n if (split_flag){\n int new_size = size/2;\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+0*new_size,xposY+0*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+1*new_size,xposY+0*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+0*new_size,xposY+1*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+1*new_size,xposY+1*new_size,sub);\n }\n else if (decode_this_size || decode_rectangular_size){\n decode_block(decoder_info,size,yposY,xposY,sub);\n }\n}", "label_name": "Class", "label": 2} @@ -1160,7 +1155,6 @@ {"code": "static RFlagsAtOffset* r_flag_get_nearest_list(RFlag *f, ut64 off, int dir) {\n\tRFlagsAtOffset *flags = NULL;\n\tRFlagsAtOffset key;\n\tkey.off = off;\n\tif (dir >= 0) {\n\t\tflags = r_skiplist_get_geq (f->by_off, &key);\n\t} else {\n\t\tflags = r_skiplist_get_leq (f->by_off, &key);\n\t}\n\tif (dir == 0 && flags && flags->off != off) {\n\t\treturn NULL;\n\t}\n\treturn flags;\n}", "label_name": "Base", "label": 1} {"code": "static void __exit exit_ext2_fs(void)\n{\n\tunregister_filesystem(&ext2_fs_type);\n\tdestroy_inodecache();\n\texit_ext2_xattr();\n}", "label_name": "CWE-19", "label": "CWE-19"} {"code": "static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)\n{\n\tstruct sco_conn *conn = sco_pi(sk)->conn;\n\tstruct sk_buff *skb;\n\tint err;\n\n\t/* Check outgoing MTU */\n\tif (len > conn->mtu)\n\t\treturn -EINVAL;\n\n\tBT_DBG(\"sk %p len %d\", sk, len);\n\n\tskb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tif (memcpy_from_msg(skb_put(skb, len), msg, len)) {\n\t\tkfree_skb(skb);\n\t\treturn -EFAULT;\n\t}\n\n\thci_send_sco(conn->hcon, skb);\n\n\treturn len;\n}", "label_name": "Variant", "label": 0} -{"code": "int _mkp_stage_30(struct plugin *p,\n struct client_session *cs,\n struct session_request *sr)\n{\n mk_ptr_t referer;\n (void) p;\n (void) cs;\n\n PLUGIN_TRACE(\"[FD %i] Mandril validating URL\", cs->socket);\n if (mk_security_check_url(sr->uri) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, blocked URL\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n PLUGIN_TRACE(\"[FD %d] Mandril validating hotlinking\", cs->socket);\n referer = mk_api->header_get(&sr->headers_toc, \"Referer\", strlen(\"Referer\"));\n if (mk_security_check_hotlink(sr->uri_processed, sr->host, referer) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, deny hotlinking.\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n return MK_PLUGIN_RET_NOT_ME;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "static int vmci_transport_dgram_dequeue(struct kiocb *kiocb,\n\t\t\t\t\tstruct vsock_sock *vsk,\n\t\t\t\t\tstruct msghdr *msg, size_t len,\n\t\t\t\t\tint flags)\n{\n\tint err;\n\tint noblock;\n\tstruct vmci_datagram *dg;\n\tsize_t payload_len;\n\tstruct sk_buff *skb;\n\n\tnoblock = flags & MSG_DONTWAIT;\n\n\tif (flags & MSG_OOB || flags & MSG_ERRQUEUE)\n\t\treturn -EOPNOTSUPP;\n\n\tmsg->msg_namelen = 0;\n\n\t/* Retrieve the head sk_buff from the socket's receive queue. */\n\terr = 0;\n\tskb = skb_recv_datagram(&vsk->sk, flags, noblock, &err);\n\tif (err)\n\t\treturn err;\n\n\tif (!skb)\n\t\treturn -EAGAIN;\n\n\tdg = (struct vmci_datagram *)skb->data;\n\tif (!dg)\n\t\t/* err is 0, meaning we read zero bytes. */\n\t\tgoto out;\n\n\tpayload_len = dg->payload_size;\n\t/* Ensure the sk_buff matches the payload size claimed in the packet. */\n\tif (payload_len != skb->len - sizeof(*dg)) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tif (payload_len > len) {\n\t\tpayload_len = len;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\t/* Place the datagram payload in the user's iovec. */\n\terr = skb_copy_datagram_iovec(skb, sizeof(*dg), msg->msg_iov,\n\t\tpayload_len);\n\tif (err)\n\t\tgoto out;\n\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_vm *vm_addr;\n\n\t\t/* Provide the address of the sender. */\n\t\tvm_addr = (struct sockaddr_vm *)msg->msg_name;\n\t\tvsock_addr_init(vm_addr, dg->src.context, dg->src.resource);\n\t\tmsg->msg_namelen = sizeof(*vm_addr);\n\t}\n\terr = payload_len;\n\nout:\n\tskb_free_datagram(&vsk->sk, skb);\n\treturn err;\n}", "label_name": "Class", "label": 2} {"code": "static int generate(struct crypto_rng *tfm, const u8 *src, unsigned int slen,\n\t\t u8 *dst, unsigned int dlen)\n{\n\treturn crypto_old_rng_alg(tfm)->rng_make_random(tfm, dst, dlen);\n}", "label_name": "Base", "label": 1} {"code": "parse_field(netdissect_options *ndo, const char **pptr, int *len)\n{\n const char *s;\n\n if (*len <= 0 || !pptr || !*pptr)\n\treturn NULL;\n if (*pptr > (const char *) ndo->ndo_snapend)\n\treturn NULL;\n\n s = *pptr;\n while (*pptr <= (const char *) ndo->ndo_snapend && *len >= 0 && **pptr) {\n\t(*pptr)++;\n\t(*len)--;\n }\n (*pptr)++;\n (*len)--;\n if (*len < 0 || *pptr > (const char *) ndo->ndo_snapend)\n\treturn NULL;\n return s;\n}", "label_name": "Base", "label": 1} @@ -1170,7 +1164,6 @@ {"code": "static int save_dev(blkid_dev dev, FILE *file)\n{\n\tstruct list_head *p;\n\n\tif (!dev || dev->bid_name[0] != '/')\n\t\treturn 0;\n\n\tDBG(SAVE, ul_debug(\"device %s, type %s\", dev->bid_name, dev->bid_type ?\n\t\t dev->bid_type : \"(null)\"));\n\n\tfprintf(file, \"bid_devno,\n\t\t\t(long) dev->bid_time,\n\t\t\t(long) dev->bid_utime);\n\n\tif (dev->bid_pri)\n\t\tfprintf(file, \" PRI=\\\"%d\\\"\", dev->bid_pri);\n\tlist_for_each(p, &dev->bid_tags) {\n\t\tblkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);\n\t\tfprintf(file, \" %s=\\\"%s\\\"\", tag->bit_name,tag->bit_val);\n\t}\n\tfprintf(file, \">%s\\n\", dev->bid_name);\n\n\treturn 0;\n}", "label_name": "Class", "label": 2} {"code": "int read_filesystem_tables_4()\n{\n\tlong long directory_table_end, table_start;\n\n\tif(read_xattrs_from_disk(fd, &sBlk.s, no_xattrs, &table_start) == 0)\n\t\treturn FALSE;\n\n\tif(read_uids_guids(&table_start) == FALSE)\n\t\treturn FALSE;\n\n\tif(parse_exports_table(&table_start) == FALSE)\n\t\treturn FALSE;\n\n\tif(read_fragment_table(&directory_table_end) == FALSE)\n\t\treturn FALSE;\n\n\tif(read_inode_table(sBlk.s.inode_table_start,\n\t\t\t\tsBlk.s.directory_table_start) == FALSE)\n\t\treturn FALSE;\n\n\tif(read_directory_table(sBlk.s.directory_table_start,\n\t\t\t\tdirectory_table_end) == FALSE)\n\t\treturn FALSE;\n\n\tif(no_xattrs)\n\t\tsBlk.s.xattr_id_table_start = SQUASHFS_INVALID_BLK;\n\n\treturn TRUE;\n}", "label_name": "Class", "label": 2} {"code": "int bson_check_field_name( bson *b, const char *string,\n const int length ) {\n\n return bson_validate_string( b, ( const unsigned char * )string, length, 1, 1, 1 );\n}", "label_name": "Base", "label": 1} -{"code": "int perf_event_task_enable(void)\n{\n\tstruct perf_event *event;\n\n\tmutex_lock(¤t->perf_event_mutex);\n\tlist_for_each_entry(event, ¤t->perf_event_list, owner_entry)\n\t\tperf_event_for_each_child(event, perf_event_enable);\n\tmutex_unlock(¤t->perf_event_mutex);\n\n\treturn 0;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "static __init int seqgen_init(void)\n{\n\trekey_seq_generator(NULL);\n\treturn 0;\n}", "label_name": "NVD-CWE-Other", "label": "NVD-CWE-Other"} {"code": "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_name": "Class", "label": 2} {"code": "sraSpanInsertBefore(sraSpan *newspan, sraSpan *before) {\n newspan->_next = before;\n newspan->_prev = before->_prev;\n before->_prev->_next = newspan;\n before->_prev = newspan;\n}", "label_name": "Base", "label": 1} @@ -1180,7 +1173,6 @@ {"code": "process_bitmap_updates(STREAM s)\n{\n\tuint16 num_updates;\n\tuint16 left, top, right, bottom, width, height;\n\tuint16 cx, cy, bpp, Bpp, compress, bufsize, size;\n\tuint8 *data, *bmpdata;\n\tint i;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\n\tin_uint16_le(s, num_updates);\n\n\tfor (i = 0; i < num_updates; i++)\n\t{\n\t\tin_uint16_le(s, left);\n\t\tin_uint16_le(s, top);\n\t\tin_uint16_le(s, right);\n\t\tin_uint16_le(s, bottom);\n\t\tin_uint16_le(s, width);\n\t\tin_uint16_le(s, height);\n\t\tin_uint16_le(s, bpp);\n\t\tBpp = (bpp + 7) / 8;\n\t\tin_uint16_le(s, compress);\n\t\tin_uint16_le(s, bufsize);\n\n\t\tcx = right - left + 1;\n\t\tcy = bottom - top + 1;\n\n\t\tlogger(Graphics, Debug,\n\t\t \"process_bitmap_updates(), [%d,%d,%d,%d], [%d,%d], bpp=%d, compression=%d\",\n\t\t left, top, right, bottom, width, height, Bpp, compress);\n\n\t\tif (!compress)\n\t\t{\n\t\t\tint y;\n\t\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tin_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],\n\t\t\t\t\t width * Bpp);\n\t\t\t}\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t\txfree(bmpdata);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\tif (compress & 0x400)\n\t\t{\n\t\t\tsize = bufsize;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_uint8s(s, 2);\t/* pad */\n\t\t\tin_uint16_le(s, size);\n\t\t\tin_uint8s(s, 4);\t/* line_size, final_size */\n\t\t}\n\t\tin_uint8p(s, data, size);\n\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\tif (bitmap_decompress(bmpdata, width, height, data, size, Bpp))\n\t\t{\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t \"process_bitmap_updates(), failed to decompress bitmap\");\n\t\t}\n\n\t\txfree(bmpdata);\n\t}\n}", "label_name": "Base", "label": 1} {"code": "static bool disconnect_cb(struct io *io, void *user_data)\n{\n\tstruct bt_att_chan *chan = user_data;\n\tstruct bt_att *att = chan->att;\n\tint err;\n\tsocklen_t len;\n\n\tlen = sizeof(err);\n\n\tif (getsockopt(chan->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {\n\t\tutil_debug(chan->att->debug_callback, chan->att->debug_data,\n\t\t\t\t\t\"(chan %p) Failed to obtain disconnect\"\n\t\t\t\t\t\" error: %s\", chan, strerror(errno));\n\t\terr = 0;\n\t}\n\n\tutil_debug(chan->att->debug_callback, chan->att->debug_data,\n\t\t\t\t\t\"Channel %p disconnected: %s\",\n\t\t\t\t\tchan, strerror(err));\n\n\t/* Dettach channel */\n\tqueue_remove(att->chans, chan);\n\n\t/* Notify request callbacks */\n\tqueue_remove_all(att->req_queue, NULL, NULL, disc_att_send_op);\n\tqueue_remove_all(att->ind_queue, NULL, NULL, disc_att_send_op);\n\tqueue_remove_all(att->write_queue, NULL, NULL, disc_att_send_op);\n\n\tif (chan->pending_req) {\n\t\tdisc_att_send_op(chan->pending_req);\n\t\tchan->pending_req = NULL;\n\t}\n\n\tif (chan->pending_ind) {\n\t\tdisc_att_send_op(chan->pending_ind);\n\t\tchan->pending_ind = NULL;\n\t}\n\n\tbt_att_chan_free(chan);\n\n\t/* Don't run disconnect callback if there are channels left */\n\tif (!queue_isempty(att->chans))\n\t\treturn false;\n\n\tbt_att_ref(att);\n\n\tqueue_foreach(att->disconn_list, disconn_handler, INT_TO_PTR(err));\n\n\tbt_att_unregister_all(att);\n\tbt_att_unref(att);\n\n\treturn false;\n}", "label_name": "Variant", "label": 0} {"code": "static void utee_param_to_param(struct tee_ta_param *p, struct utee_params *up)\n{\n\tsize_t n;\n\tuint32_t types = up->types;\n\n\tp->types = types;\n\tfor (n = 0; n < TEE_NUM_PARAMS; n++) {\n\t\tuintptr_t a = up->vals[n * 2];\n\t\tsize_t b = up->vals[n * 2 + 1];\n\n\t\tswitch (TEE_PARAM_TYPE_GET(types, n)) {\n\t\tcase TEE_PARAM_TYPE_MEMREF_INPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_OUTPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_INOUT:\n\t\t\tp->u[n].mem.mobj = &mobj_virt;\n\t\t\tp->u[n].mem.offs = a;\n\t\t\tp->u[n].mem.size = b;\n\t\t\tbreak;\n\t\tcase TEE_PARAM_TYPE_VALUE_INPUT:\n\t\tcase TEE_PARAM_TYPE_VALUE_INOUT:\n\t\t\tp->u[n].val.a = a;\n\t\t\tp->u[n].val.b = b;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmemset(&p->u[n], 0, sizeof(p->u[n]));\n\t\t\tbreak;\n\t\t}\n\t}\n}", "label_name": "Base", "label": 1} -{"code": "static void bt_for_each(struct blk_mq_hw_ctx *hctx,\n\t\tstruct blk_mq_bitmap_tags *bt, unsigned int off,\n\t\tbusy_iter_fn *fn, void *data, bool reserved)\n{\n\tstruct request *rq;\n\tint bit, i;\n\n\tfor (i = 0; i < bt->map_nr; i++) {\n\t\tstruct blk_align_bitmap *bm = &bt->map[i];\n\n\t\tfor (bit = find_first_bit(&bm->word, bm->depth);\n\t\t bit < bm->depth;\n\t\t bit = find_next_bit(&bm->word, bm->depth, bit + 1)) {\n\t\t \trq = blk_mq_tag_to_rq(hctx->tags, off + bit);\n\t\t\tif (rq->q == hctx->queue)\n\t\t\t\tfn(hctx, rq, data, reserved);\n\t\t}\n\n\t\toff += (1 << bt->bits_per_word);\n\t}\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "PHP_FUNCTION(locale_accept_from_http)\n{\n\tUEnumeration *available;\n\tchar *http_accept = NULL;\n\tint http_accept_len;\n\tUErrorCode status = 0;\n\tint len;\n\tchar resultLocale[INTL_MAX_LOCALE_LEN+1];\n\tUAcceptResult outResult;\n\n\tif(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &http_accept, &http_accept_len) == FAILURE)\n\t{\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\n\t\t\"locale_accept_from_http: unable to parse input parameters\", 0 TSRMLS_CC );\n\t\tRETURN_FALSE;\n\t}\n\t\n\tavailable = ures_openAvailableLocales(NULL, &status);\n\tINTL_CHECK_STATUS(status, \"locale_accept_from_http: failed to retrieve locale list\");\n\tlen = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN, \n\t\t\t\t\t\t&outResult, http_accept, available, &status);\n\tuenum_close(available);\n\tINTL_CHECK_STATUS(status, \"locale_accept_from_http: failed to find acceptable locale\");\n\tif (len < 0 || outResult == ULOC_ACCEPT_FAILED) {\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_STRINGL(resultLocale, len, 1);\n}", "label_name": "Base", "label": 1} {"code": "int socket_accept(int fd, uint16_t port)\n{\n#ifdef WIN32\n\tint addr_len;\n#else\n\tsocklen_t addr_len;\n#endif\n\tint result;\n\tstruct sockaddr_in addr;\n\n\tmemset(&addr, 0, sizeof(addr));\n\taddr.sin_family = AF_INET;\n\taddr.sin_addr.s_addr = htonl(INADDR_ANY);\n\taddr.sin_port = htons(port);\n\n\taddr_len = sizeof(addr);\n\tresult = accept(fd, (struct sockaddr*)&addr, &addr_len);\n\n\treturn result;\n}", "label_name": "Pillar", "label": 3} {"code": "static __exit void sctp_exit(void)\n{\n\t/* BUG. This should probably do something useful like clean\n\t * up all the remaining associations and all that memory.\n\t */\n\n\t/* Unregister with inet6/inet layers. */\n\tsctp_v6_del_protocol();\n\tsctp_v4_del_protocol();\n\n\tunregister_pernet_subsys(&sctp_net_ops);\n\n\t/* Free protosw registrations */\n\tsctp_v6_protosw_exit();\n\tsctp_v4_protosw_exit();\n\n\t/* Unregister with socket layer. */\n\tsctp_v6_pf_exit();\n\tsctp_v4_pf_exit();\n\n\tsctp_sysctl_unregister();\n\n\tfree_pages((unsigned long)sctp_assoc_hashtable,\n\t\t get_order(sctp_assoc_hashsize *\n\t\t\t sizeof(struct sctp_hashbucket)));\n\tkfree(sctp_ep_hashtable);\n\tfree_pages((unsigned long)sctp_port_hashtable,\n\t\t get_order(sctp_port_hashsize *\n\t\t\t sizeof(struct sctp_bind_hashbucket)));\n\n\tpercpu_counter_destroy(&sctp_sockets_allocated);\n\n\trcu_barrier(); /* Wait for completion of call_rcu()'s */\n\n\tkmem_cache_destroy(sctp_chunk_cachep);\n\tkmem_cache_destroy(sctp_bucket_cachep);\n}", "label_name": "Class", "label": 2} @@ -1232,7 +1224,6 @@ {"code": "nautilus_file_mark_desktop_file_trusted (GFile *file,\n GtkWindow *parent_window,\n gboolean interactive,\n NautilusOpCallback done_callback,\n gpointer done_callback_data)\n{\n GTask *task;\n MarkTrustedJob *job;\n\n job = op_job_new (MarkTrustedJob, parent_window);\n job->file = g_object_ref (file);\n job->interactive = interactive;\n job->done_callback = done_callback;\n job->done_callback_data = done_callback_data;\n\n task = g_task_new (NULL, NULL, mark_trusted_task_done, job);\n g_task_set_task_data (task, job, NULL);\n g_task_run_in_thread (task, mark_trusted_task_thread_func);\n g_object_unref (task);\n}", "label_name": "Class", "label": 2} {"code": "int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)\n{\n\tstruct ip_options *opt;\n\n\topt = inet_sk(sk)->opt;\n\tif (opt == NULL || opt->cipso == 0)\n\t\treturn -ENOMSG;\n\n\treturn cipso_v4_getattr(opt->__data + opt->cipso - sizeof(struct iphdr),\n\t\t\t\tsecattr);\n}", "label_name": "Class", "label": 2} {"code": "static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct 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\tint copied, err;\n\n\tBT_DBG(\"sock %p, sk %p\", sock, sk);\n\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tif (sk->sk_state == BT_CLOSED)\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tmsg->msg_namelen = 0;\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\n\tswitch (hci_pi(sk)->channel) {\n\tcase HCI_CHANNEL_RAW:\n\t\thci_sock_cmsg(sk, msg, skb);\n\t\tbreak;\n\tcase HCI_CHANNEL_USER:\n\tcase HCI_CHANNEL_CONTROL:\n\tcase HCI_CHANNEL_MONITOR:\n\t\tsock_recv_timestamp(msg, sk, skb);\n\t\tbreak;\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label_name": "Class", "label": 2} -{"code": "static int __ptrace_may_access(struct task_struct *task, unsigned int mode)\n{\n\tconst struct cred *cred = current_cred(), *tcred;\n\n\t/* May we inspect the given task?\n\t * This check is used both for attaching with ptrace\n\t * and for allowing access to sensitive information in /proc.\n\t *\n\t * ptrace_attach denies several cases that /proc allows\n\t * because setting up the necessary parent/child relationship\n\t * or halting the specified task is impossible.\n\t */\n\tint dumpable = 0;\n\t/* Don't let security modules deny introspection */\n\tif (same_thread_group(task, current))\n\t\treturn 0;\n\trcu_read_lock();\n\ttcred = __task_cred(task);\n\tif (uid_eq(cred->uid, tcred->euid) &&\n\t uid_eq(cred->uid, tcred->suid) &&\n\t uid_eq(cred->uid, tcred->uid) &&\n\t gid_eq(cred->gid, tcred->egid) &&\n\t gid_eq(cred->gid, tcred->sgid) &&\n\t gid_eq(cred->gid, tcred->gid))\n\t\tgoto ok;\n\tif (ptrace_has_cap(tcred->user_ns, mode))\n\t\tgoto ok;\n\trcu_read_unlock();\n\treturn -EPERM;\nok:\n\trcu_read_unlock();\n\tsmp_rmb();\n\tif (task->mm)\n\t\tdumpable = get_dumpable(task->mm);\n\trcu_read_lock();\n\tif (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {\n\t\trcu_read_unlock();\n\t\treturn -EPERM;\n\t}\n\trcu_read_unlock();\n\n\treturn security_ptrace_access_check(task, mode);\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "processBatchMultiRuleset(batch_t *pBatch)\n{\n\truleset_t *currRuleset;\n\tbatch_t snglRuleBatch;\n\tint i;\n\tint iStart;\t/* start index of partial batch */\n\tint iNew;\t/* index for new (temporary) batch */\n\tDEFiRet;\n\n\tCHKiRet(batchInit(&snglRuleBatch, pBatch->nElem));\n\tsnglRuleBatch.pbShutdownImmediate = pBatch->pbShutdownImmediate;\n\n\twhile(1) { /* loop broken inside */\n\t\t/* search for first unprocessed element */\n\t\tfor(iStart = 0 ; iStart < pBatch->nElem && pBatch->pElem[iStart].state == BATCH_STATE_DISC ; ++iStart)\n\t\t\t/* just search, no action */;\n\n\t\tif(iStart == pBatch->nElem)\n\t\t\tFINALIZE; /* everything processed */\n\n\t\t/* prepare temporary batch */\n\t\tcurrRuleset = batchElemGetRuleset(pBatch, iStart);\n\t\tiNew = 0;\n\t\tfor(i = iStart ; i < pBatch->nElem ; ++i) {\n\t\t\tif(batchElemGetRuleset(pBatch, i) == currRuleset) {\n\t\t\t\tbatchCopyElem(&(snglRuleBatch.pElem[iNew++]), &(pBatch->pElem[i]));\n\t\t\t\t/* We indicate the element also as done, so it will not be processed again */\n\t\t\t\tpBatch->pElem[i].state = BATCH_STATE_DISC;\n\t\t\t}\n\t\t}\n\t\tsnglRuleBatch.nElem = iNew; /* was left just right by the for loop */\n\t\tbatchSetSingleRuleset(&snglRuleBatch, 1);\n\t\t/* process temp batch */\n\t\tprocessBatch(&snglRuleBatch);\n\t}\n\tbatchFree(&snglRuleBatch);\n\nfinalize_it:\n\tRETiRet;\n}", "label_name": "Base", "label": 1} {"code": "static int g2m_init_buffers(G2MContext *c)\n{\n int aligned_height;\n\n if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {\n c->framebuf_stride = FFALIGN(c->width * 3, 16);\n aligned_height = FFALIGN(c->height, 16);\n av_free(c->framebuf);\n c->framebuf = av_mallocz(c->framebuf_stride * aligned_height);\n if (!c->framebuf)\n return AVERROR(ENOMEM);\n }\n if (!c->synth_tile || !c->jpeg_tile ||\n c->old_tile_w < c->tile_width ||\n c->old_tile_h < c->tile_height) {\n c->tile_stride = FFALIGN(c->tile_width * 3, 16);\n aligned_height = FFALIGN(c->tile_height, 16);\n av_free(c->synth_tile);\n av_free(c->jpeg_tile);\n av_free(c->kempf_buf);\n av_free(c->kempf_flags);\n c->synth_tile = av_mallocz(c->tile_stride * aligned_height);\n c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height);\n c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height\n + FF_INPUT_BUFFER_PADDING_SIZE);\n c->kempf_flags = av_mallocz( c->tile_width * aligned_height);\n if (!c->synth_tile || !c->jpeg_tile ||\n !c->kempf_buf || !c->kempf_flags)\n return AVERROR(ENOMEM);\n }\n\n return 0;\n}", "label_name": "CWE-189", "label": "CWE-189"} {"code": "static LUA_FUNCTION(openssl_x509_check_email)\n{\n X509 * cert = CHECK_OBJECT(1, X509, \"openssl.x509\");\n if (lua_isstring(L, 2))\n {\n const char *email = lua_tostring(L, 2);\n lua_pushboolean(L, X509_check_email(cert, email, strlen(email), 0));\n }\n else\n {\n lua_pushboolean(L, 0);\n }\n return 1;\n}", "label_name": "Base", "label": 1} @@ -1242,7 +1233,6 @@ {"code": "int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)\n{\n\tu16 offset = sizeof(struct ipv6hdr);\n\tunsigned int packet_len = skb_tail_pointer(skb) -\n\t\tskb_network_header(skb);\n\tint found_rhdr = 0;\n\t*nexthdr = &ipv6_hdr(skb)->nexthdr;\n\n\twhile (offset <= packet_len) {\n\t\tstruct ipv6_opt_hdr *exthdr;\n\n\t\tswitch (**nexthdr) {\n\n\t\tcase NEXTHDR_HOP:\n\t\t\tbreak;\n\t\tcase NEXTHDR_ROUTING:\n\t\t\tfound_rhdr = 1;\n\t\t\tbreak;\n\t\tcase NEXTHDR_DEST:\n#if IS_ENABLED(CONFIG_IPV6_MIP6)\n\t\t\tif (ipv6_find_tlv(skb, offset, IPV6_TLV_HAO) >= 0)\n\t\t\t\tbreak;\n#endif\n\t\t\tif (found_rhdr)\n\t\t\t\treturn offset;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn offset;\n\t\t}\n\n\t\tif (offset + sizeof(struct ipv6_opt_hdr) > packet_len)\n\t\t\treturn -EINVAL;\n\n\t\texthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +\n\t\t\t\t\t\t offset);\n\t\toffset += ipv6_optlen(exthdr);\n\t\t*nexthdr = &exthdr->nexthdr;\n\t}\n\n\treturn -EINVAL;\n}", "label_name": "Base", "label": 1} {"code": "static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_blkcipher rblkcipher;\n\n\tsnprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"givcipher\");\n\tsnprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, \"%s\",\n\t\t alg->cra_ablkcipher.geniv ?: \"\");\n\n\trblkcipher.blocksize = alg->cra_blocksize;\n\trblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;\n\trblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize;\n\trblkcipher.ivsize = alg->cra_ablkcipher.ivsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER,\n\t\t sizeof(struct crypto_report_blkcipher), &rblkcipher))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label_name": "CWE-310", "label": "CWE-310"} {"code": "rs_filter_graph(RSFilter *filter)\n{\n\tg_return_if_fail(RS_IS_FILTER(filter));\n\tGString *str = g_string_new(\"digraph G {\\n\");\n\n\trs_filter_graph_helper(str, filter);\n\n\tg_string_append_printf(str, \"}\\n\");\n\tg_file_set_contents(\"/tmp/rs-filter-graph\", str->str, str->len, NULL);\n\n\tif (0 != system(\"dot -Tpng >/tmp/rs-filter-graph.png max_size) ||\n\t (*ppos + count > max_size) ||\n\t (*ppos + count < count) ||\n\t (count > uncopied_bytes))\n\t\treturn -EINVAL;\n\n\tif (copy_from_user(buf + (*ppos), user_buf, count)) {\n\t\tkfree(buf);\n\t\tbuf = NULL;\n\t\treturn -EFAULT;\n\t}\n\n\tuncopied_bytes -= count;\n\t*ppos += count;\n\n\tif (!uncopied_bytes) {\n\t\tstatus = acpi_install_method(buf);\n\t\tkfree(buf);\n\t\tbuf = NULL;\n\t\tif (ACPI_FAILURE(status))\n\t\t\treturn -EINVAL;\n\t\tadd_taint(TAINT_OVERRIDDEN_ACPI_TABLE);\n\t}\n\n\treturn count;\n}", "label_name": "CWE-264", "label": "CWE-264"} {"code": "static cchar *getVxCPU(cchar *arch)\n{\n char *cpu, *family;\n\n family = stok(sclone(arch), \":\", &cpu);\n if (!cpu || *cpu == '\\0') {\n if (smatch(family, \"i386\")) {\n cpu = \"I80386\";\n } else if (smatch(family, \"i486\")) {\n cpu = \"I80486\";\n } else if (smatch(family, \"x86\") | sends(family, \"86\")) {\n cpu = \"PENTIUM\";\n } else if (scaselessmatch(family, \"mips\")) {\n cpu = \"MIPS32\";\n } else if (scaselessmatch(family, \"arm\")) {\n cpu = \"ARM7TDMI\";\n } else if (scaselessmatch(family, \"ppc\")) {\n cpu = \"PPC\";\n } else {\n cpu = (char*) arch;\n }\n }\n return supper(cpu);\n}", "label_name": "NVD-CWE-Other", "label": "NVD-CWE-Other"} {"code": "static void prefetch_enc(void)\n{\n prefetch_table((const void *)encT, sizeof(encT));\n}", "label_name": "Class", "label": 2} {"code": "static inline void vmacache_invalidate(struct mm_struct *mm)\n{\n\tmm->vmacache_seqnum++;\n\n\t/* deal with overflows */\n\tif (unlikely(mm->vmacache_seqnum == 0))\n\t\tvmacache_flush_all(mm);\n}", "label_name": "Variant", "label": 0} @@ -1381,7 +1371,6 @@ {"code": "def upload_file(request):\n path = tempfile.mkdtemp()\n file_name = os.path.join(path, \"%s.txt\" % request.node.name)\n with open(file_name, \"w\") as f:\n f.write(request.node.name)\n return file_name", "label_name": "Base", "label": 1} {"code": " def __init__(\n self,\n *,\n resource_group: str,\n location: str,\n application_name: str,\n owner: str,\n client_id: Optional[str],\n client_secret: Optional[str],\n app_zip: str,\n tools: str,\n instance_specific: str,\n third_party: str,\n arm_template: str,\n workbook_data: str,\n create_registration: bool,\n migrations: List[str],\n export_appinsights: bool,\n log_service_principal: bool,\n multi_tenant_domain: str,\n upgrade: bool,\n subscription_id: Optional[str],\n admins: List[UUID]", "label_name": "Class", "label": 2} {"code": " def test_runAllImportStepsFromProfile_unicode_id_creates_reports(self):\n\n TITLE = 'original title'\n PROFILE_ID = u'snapshot-testing'\n site = self._makeSite(TITLE)\n tool = self._makeOne('setup_tool').__of__(site)\n\n registry = tool.getImportStepRegistry()\n registry.registerStep(\n 'dependable', '1', _underscoreSiteTitle, ('purging', ))\n registry.registerStep(\n 'dependent', '1', _uppercaseSiteTitle, ('dependable', ))\n registry.registerStep('purging', '1', _purgeIfRequired)\n\n tool.runAllImportStepsFromProfile(PROFILE_ID)\n\n prefix = str('import-all-%s' % PROFILE_ID)\n logged = [x for x in tool.objectIds('File') if x.startswith(prefix)]\n self.assertEqual(len(logged), 1)\n\n # Check acess restriction on log files\n logged = [x for x in tool.objectIds('File')]\n for file_id in logged:\n file_ob = tool._getOb(file_id)\n rop_info = file_ob.rolesOfPermission(view)\n allowed_roles = sorted([x['name'] for x in rop_info\n if x['selected']])\n self.assertEqual(allowed_roles, ['Manager', 'Owner'])\n self.assertFalse(file_ob.acquiredRolesAreUsedBy(view))", "label_name": "Class", "label": 2} -{"code": " def set_user_password(self, context, user_id, user):\n return self.update_user(context, user_id, user)", "label_name": "CWE-264", "label": "CWE-264"} {"code": " def test_can_read_token_from_headers(self):\n \"\"\"Tests that Sydent correct extracts an auth token from request headers\"\"\"\n self.sydent.run()\n\n request, _ = make_request(\n self.sydent.reactor, \"GET\", \"/_matrix/identity/v2/hash_details\"\n )\n request.requestHeaders.addRawHeader(\n b\"Authorization\", b\"Bearer \" + self.test_token.encode(\"ascii\")\n )\n\n token = tokenFromRequest(request)\n\n self.assertEqual(token, self.test_token)", "label_name": "Base", "label": 1} {"code": "def _get_object(data, position, as_class, tz_aware, uuid_subtype):\n obj_size = struct.unpack(\"\",part.tag)\n if part.tag == '{%s}Body' % NAMESPACE:\n for sub in part:\n try:\n body = saml2.create_class_from_element_tree(body_class, sub)\n except Exception:\n raise Exception(\n \"Wrong body type (%s) in SOAP envelope\" % sub.tag)\n elif part.tag == '{%s}Header' % NAMESPACE:\n if not header_class:\n raise Exception(\"Header where I didn't expect one\")\n # print(\"--- HEADER ---\")\n for sub in part:\n # print(\">>\",sub.tag)\n for klass in header_class:\n # print(\"?{%s}%s\" % (klass.c_namespace,klass.c_tag))\n if sub.tag == \"{%s}%s\" % (klass.c_namespace, klass.c_tag):\n header[sub.tag] = \\\n saml2.create_class_from_element_tree(klass, sub)\n break\n\n return body, header", "label_name": "Base", "label": 1} {"code": " def test_received_preq_completed_n_lt_data(self):\n inst, sock, map = self._makeOneWithMap()\n inst.server = DummyServer()\n preq = DummyParser()\n inst.request = preq\n preq.completed = True\n preq.empty = False\n line = b\"GET / HTTP/1.1\\n\\n\"\n preq.retval = len(line)\n inst.received(line + line)\n self.assertEqual(inst.request, None)\n self.assertEqual(len(inst.requests), 2)\n self.assertEqual(len(inst.server.tasks), 1)", "label_name": "Base", "label": 1} {"code": "def create_class_from_xml_string(target_class, xml_string):\n \"\"\"Creates an instance of the target class from a string.\n\n :param target_class: The class which will be instantiated and populated\n with the contents of the XML. This class must have a c_tag and a\n c_namespace class variable.\n :param xml_string: A string which contains valid XML. The root element\n of the XML string should match the tag and namespace of the desired\n class.\n\n :return: An instance of the target class with members assigned according to\n the contents of the XML - or None if the root XML tag and namespace did\n not match those of the target class.\n \"\"\"\n if not isinstance(xml_string, six.binary_type):\n xml_string = xml_string.encode('utf-8')\n tree = ElementTree.fromstring(xml_string)\n return create_class_from_element_tree(target_class, tree)", "label_name": "Base", "label": 1} @@ -1464,7 +1452,6 @@ {"code": " private void updateSecureSessionFlag() {\n try {\n ServletContext context = Jenkins.getInstance().servletContext;\n Method m;\n try {\n m = context.getClass().getMethod(\"getSessionCookieConfig\");\n } catch (NoSuchMethodException x) { // 3.0+\n LOGGER.log(Level.FINE, \"Failed to set secure cookie flag\", x);\n return;\n }\n Object sessionCookieConfig = m.invoke(context);\n\n // not exposing session cookie to JavaScript to mitigate damage caused by XSS\n Class scc = Class.forName(\"javax.servlet.SessionCookieConfig\");\n Method setHttpOnly = scc.getMethod(\"setHttpOnly\",boolean.class);\n setHttpOnly.invoke(sessionCookieConfig,true);\n\n Method setSecure = scc.getMethod(\"setSecure\",boolean.class);\n boolean v = fixNull(jenkinsUrl).startsWith(\"https\");\n setSecure.invoke(sessionCookieConfig,v);\n } catch (Exception e) {\n LOGGER.log(Level.WARNING, \"Failed to set secure cookie flag\", e);\n }\n }", "label_name": "CWE-254", "label": "CWE-254"} {"code": " public void annotatedSubClassExample() throws Exception {\n assertThat(ConstraintViolations.format(validator.validate(new AnnotatedSubclassExample())))\n .containsExactlyInAnyOrder(\n FAILED_RESULT,\n FAILED_RESULT+\"subclass\"\n );\n assertThat(TestLoggerFactory.getAllLoggingEvents())\n .isEmpty();\n }", "label_name": "Class", "label": 2} {"code": " protected void engineInit(\n byte[] params)\n throws IOException\n {\n try\n {\n ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(params);\n\n if (s.size() == 1)\n {\n this.currentSpec = new IESParameterSpec(null, null, ASN1Integer.getInstance(s.getObjectAt(0)).getValue().intValue());\n }\n else if (s.size() == 2)\n {\n ASN1TaggedObject tagged = ASN1TaggedObject.getInstance(s.getObjectAt(0));\n\n if (tagged.getTagNo() == 0)\n {\n this.currentSpec = new IESParameterSpec(ASN1OctetString.getInstance(tagged, false).getOctets(), null, ASN1Integer.getInstance(s.getObjectAt(1)).getValue().intValue());\n }\n else\n {\n this.currentSpec = new IESParameterSpec(null, ASN1OctetString.getInstance(tagged, false).getOctets(), ASN1Integer.getInstance(s.getObjectAt(1)).getValue().intValue());\n }\n }\n else\n {\n ASN1TaggedObject tagged1 = ASN1TaggedObject.getInstance(s.getObjectAt(0));\n ASN1TaggedObject tagged2 = ASN1TaggedObject.getInstance(s.getObjectAt(1));\n\n this.currentSpec = new IESParameterSpec(ASN1OctetString.getInstance(tagged1, false).getOctets(), ASN1OctetString.getInstance(tagged2, false).getOctets(), ASN1Integer.getInstance(s.getObjectAt(2)).getValue().intValue());\n }\n }\n catch (ClassCastException e)\n {\n throw new IOException(\"Not a valid IES Parameter encoding.\");\n }\n catch (ArrayIndexOutOfBoundsException e)\n {\n throw new IOException(\"Not a valid IES Parameter encoding.\");\n }\n }", "label_name": "CWE-310", "label": "CWE-310"} -{"code": " public static T find(Collection list, String className) {\n for (T d : list) {\n if(d.getClass().getName().equals(className))\n return d;\n }\n // Since we introduced Descriptor.getId(), it is a preferred method of identifying descriptor by a string.\n // To make that migration easier without breaking compatibility, let's also match up with the id.\n for (T d : list) {\n if(d.getId().equals(className))\n return d;\n }\n return null;\n }", "label_name": "CWE-264", "label": "CWE-264"} {"code": " public void setUp() throws Exception {\n super.setUp();\n TestUtil.createTempTable(con, \"xmltab\",\"x xml\");\n }", "label_name": "Base", "label": 1} {"code": " public void translate(ServerUpdateScorePacket packet, GeyserSession session) {\n WorldCache worldCache = session.getWorldCache();\n Scoreboard scoreboard = worldCache.getScoreboard();\n int pps = worldCache.increaseAndGetScoreboardPacketsPerSecond();\n\n Objective objective = scoreboard.getObjective(packet.getObjective());\n if (objective == null && packet.getAction() != ScoreboardAction.REMOVE) {\n logger.info(LanguageUtils.getLocaleStringLog(\"geyser.network.translator.score.failed_objective\", packet.getObjective()));\n return;\n }\n\n switch (packet.getAction()) {\n case ADD_OR_UPDATE:\n objective.setScore(packet.getEntry(), packet.getValue());\n break;\n case REMOVE:\n if (objective != null) {\n objective.removeScore(packet.getEntry());\n } else {\n for (Objective objective1 : scoreboard.getObjectives().values()) {\n objective1.removeScore(packet.getEntry());\n }\n }\n break;\n }\n\n // ScoreboardUpdater will handle it for us if the packets per second\n // (for score and team packets) is higher then the first threshold\n if (pps < ScoreboardUpdater.FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD) {\n scoreboard.onUpdate();\n }\n }", "label_name": "Class", "label": 2} {"code": "\tpublic void reportJobCaches(byte[] cacheInstanceBytes) {\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tCollection cacheInstances = (Collection) SerializationUtils\n\t\t\t\t.deserialize(cacheInstanceBytes);\n\t\tjobManager.reportJobCaches(getJobToken(), cacheInstances);\n\t}", "label_name": "Base", "label": 1} @@ -1507,7 +1494,6 @@ {"code": " public Optional convert(Object object, Class targetType, ConversionContext context) {\n CorsOriginConfiguration configuration = new CorsOriginConfiguration();\n if (object instanceof Map) {\n Map mapConfig = (Map) object;\n ConvertibleValues convertibleValues = new ConvertibleValuesMap<>(mapConfig);\n\n convertibleValues\n .get(ALLOWED_ORIGINS, Argument.listOf(String.class))\n .ifPresent(configuration::setAllowedOrigins);\n\n convertibleValues\n .get(ALLOWED_METHODS, Argument.listOf(HttpMethod.class))\n .ifPresent(configuration::setAllowedMethods);\n\n convertibleValues\n .get(ALLOWED_HEADERS, Argument.listOf(String.class))\n .ifPresent(configuration::setAllowedHeaders);\n\n convertibleValues\n .get(EXPOSED_HEADERS, Argument.listOf(String.class))\n .ifPresent(configuration::setExposedHeaders);\n\n convertibleValues\n .get(ALLOW_CREDENTIALS, Boolean.class)\n .ifPresent(configuration::setAllowCredentials);\n\n convertibleValues\n .get(MAX_AGE, Long.class)\n .ifPresent(configuration::setMaxAge);\n }\n return Optional.of(configuration);\n }", "label_name": "Class", "label": 2} {"code": "\tpublic static ResourceEvaluation evaluate(File file, String filename) {\n\t\tResourceEvaluation eval = new ResourceEvaluation();\n\t\ttry {\n\t\t\tImsManifestFileFilter visitor = new ImsManifestFileFilter();\n\t\t\tPath fPath = PathUtils.visit(file, filename, visitor);\n\t\t\tif(visitor.isValid()) {\n\t\t\t\tPath realManifestPath = visitor.getManifestPath();\n\t\t\t\tPath manifestPath = fPath.resolve(realManifestPath);\n\t\t\t\t\n\t\t\t\tRootSearcher rootSearcher = new RootSearcher();\n\t\t\t\tFiles.walkFileTree(fPath, rootSearcher);\n\t\t\t\tif(rootSearcher.foundRoot()) {\n\t\t\t\t\tmanifestPath = rootSearcher.getRoot().resolve(IMS_MANIFEST);\n\t\t\t\t} else {\n\t\t\t\t\tmanifestPath = fPath.resolve(IMS_MANIFEST);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tQTI21ContentPackage\tcp = new QTI21ContentPackage(manifestPath);\n\t\t\t\tif(validateImsManifest(cp, new PathResourceLocator(manifestPath.getParent()))) {\n\t\t\t\t\teval.setValid(true);\n\t\t\t\t} else {\n\t\t\t\t\teval.setValid(false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teval.setValid(false);\n\t\t\t}\n\t\t\tPathUtils.closeSubsequentFS(fPath);\n\t\t} catch (IOException | IllegalArgumentException e) {\n\t\t\tlog.error(\"\", e);\n\t\t\teval.setValid(false);\n\t\t}\n\t\treturn eval;\n\t}", "label_name": "Base", "label": 1} {"code": " public void corsNoTags() {\n InputStream is = getClass().getResourceAsStream(\"/access-sample1.xml\");\n PolicyRestrictor restrictor = new PolicyRestrictor(is);\n\n assertTrue(restrictor.isCorsAccessAllowed(\"http://bla.com\"));\n assertTrue(restrictor.isCorsAccessAllowed(\"http://www.jolokia.org\"));\n assertTrue(restrictor.isCorsAccessAllowed(\"https://www.consol.de\"));\n }", "label_name": "Compound", "label": 4} -{"code": " public void handle(HttpServletRequest request, HttpServletResponse response)\n throws Exception\n {\n // We're sending an XML response, so set the response content type to text/xml\n response.setContentType(\"text/xml\");\n\n // Parse the incoming request as XML\n SAXReader xmlReader = new SAXReader();\n Document doc = xmlReader.read(request.getInputStream());\n Element env = doc.getRootElement();\n\n Element body = env.element(\"body\");\n\n // First handle any new subscriptions\n List requests = new ArrayList();\n\n List elements = body.elements(\"subscribe\");\n for (Element e : elements)\n {\n requests.add(new SubscriptionRequest(e.attributeValue(\"topic\")));\n }\n\n ServletLifecycle.beginRequest(request);\n try\n {\n ServletContexts.instance().setRequest(request);\n\n Manager.instance().initializeTemporaryConversation();\n ServletLifecycle.resumeConversation(request);\n\n for (SubscriptionRequest req : requests)\n {\n req.subscribe();\n }\n\n // Then handle any unsubscriptions\n List unsubscribeTokens = new ArrayList();\n\n elements = body.elements(\"unsubscribe\");\n for (Element e : elements) \n {\n unsubscribeTokens.add(e.attributeValue(\"token\"));\n }\n\n for (String token : unsubscribeTokens) \n {\n RemoteSubscriber subscriber = SubscriptionRegistry.instance().\n getSubscription(token);\n if (subscriber != null)\n {\n subscriber.unsubscribe();\n }\n }\n }\n finally\n {\n Lifecycle.endRequest();\n }\n\n // Package up the response\n marshalResponse(requests, response.getOutputStream());\n }", "label_name": "CWE-264", "label": "CWE-264"} {"code": " public OldIES()\n {\n super(new OldIESEngine(new DHBasicAgreement(),\n new KDF2BytesGenerator(new SHA1Digest()),\n new HMac(new SHA1Digest())));\n }", "label_name": "CWE-310", "label": "CWE-310"} {"code": " protected XWikiDocument prepareEditedDocument(XWikiContext context) throws XWikiException\n {\n // Determine the edited document (translation).\n XWikiDocument editedDocument = getEditedDocument(context);\n EditForm editForm = (EditForm) context.getForm();\n\n // Update the edited document based on the template specified on the request.\n editedDocument.readFromTemplate(editForm, context);\n\n // The default values from the template can be overwritten by additional request parameters.\n updateDocumentTitleAndContentFromRequest(editedDocument, context);\n editedDocument.readObjectsFromForm(editForm, context);\n\n // Set the current user as creator, author and contentAuthor when the edited document is newly created to avoid\n // using XWikiGuest instead (because those fields were not previously initialized).\n if (editedDocument.isNew()) {\n editedDocument.setCreatorReference(context.getUserReference());\n editedDocument.setAuthorReference(context.getUserReference());\n editedDocument.setContentAuthorReference(context.getUserReference());\n }\n\n // Expose the edited document on the XWiki context and the Velocity context.\n putDocumentOnContext(editedDocument, context);\n\n return editedDocument;\n }", "label_name": "Class", "label": 2} {"code": "\tpublic static HColor noGradient(HColor color) {\n\t\tif (color instanceof HColorGradient) {\n\t\t\treturn ((HColorGradient) color).getColor1();\n\t\t}\n\t\treturn color;\n\t}", "label_name": "Base", "label": 1} @@ -1523,7 +1509,6 @@ {"code": " public OldECIESwithAES()\n {\n super(new AESEngine());\n }", "label_name": "CWE-310", "label": "CWE-310"} {"code": " public static Object deserialize(byte[] data)\n throws IOException, ClassNotFoundException\n {\n ByteArrayInputStream in = new ByteArrayInputStream(data);\n ObjectInputStream is = new ObjectInputStream(in);\n return is.readObject();\n }", "label_name": "Base", "label": 1} {"code": " public void encodeDeepBinaryJSONWithNullValue() throws JSONException {\n JSONObject data = new JSONObject(\"{a: \\\"b\\\", c: 4, e: {g: null}, h: null}\");\n data.put(\"h\", new byte[9]);\n\n Packet packet = new Packet<>(Parser.BINARY_EVENT);\n packet.data = data;\n packet.nsp = \"/\";\n packet.id = 600;\n Helpers.testBin(packet);\n }", "label_name": "Base", "label": 1} -{"code": " private FileItem getFileItem(HttpServletRequest request) throws FileUploadException {\n Iterator iterator = getServletFileUpload().parseRequest(request).iterator();\n while (iterator.hasNext()) {\n FileItem item = (FileItem) iterator.next();\n if (!item.isFormField()) {\n return item;\n }\n }\n return null;\n }", "label_name": "CWE-264", "label": "CWE-264"} {"code": " private String buildRedirectAuthnRequest(AuthnRequestType authnRequest, String relayState, boolean sign,\n PrivateKey key, Algorithm algorithm) throws SAMLException {\n try {\n byte[] xml = marshallToBytes(PROTOCOL_OBJECT_FACTORY.createAuthnRequest(authnRequest), AuthnRequestType.class);\n String encodedResult = deflateAndEncode(xml);\n String parameters = \"SAMLRequest=\" + URLEncoder.encode(encodedResult, \"UTF-8\");\n if (relayState != null) {\n parameters += \"&RelayState=\" + URLEncoder.encode(relayState, \"UTF-8\");\n }\n\n if (sign && key != null && algorithm != null) {\n Signature signature;\n parameters += \"&SigAlg=\" + URLEncoder.encode(algorithm.uri, \"UTF-8\");\n signature = Signature.getInstance(algorithm.name);\n signature.initSign(key);\n signature.update(parameters.getBytes(StandardCharsets.UTF_8));\n\n String signatureParameter = Base64.getEncoder().encodeToString(signature.sign());\n parameters += \"&Signature=\" + URLEncoder.encode(signatureParameter, \"UTF-8\");\n }\n\n return parameters;\n } catch (Exception e) {\n // Not possible but freak out\n throw new SAMLException(e);\n }\n }", "label_name": "Base", "label": 1} {"code": " private JWTClaimsSet fetchOidcProfile(BearerAccessToken accessToken) {\n final var userInfoRequest = new UserInfoRequest(configuration.findProviderMetadata().getUserInfoEndpointURI(),\n accessToken);\n final var userInfoHttpRequest = userInfoRequest.toHTTPRequest();\n configuration.configureHttpRequest(userInfoHttpRequest);\n try {\n final var httpResponse = userInfoHttpRequest.send();\n logger.debug(\"Token response: status={}, content={}\", httpResponse.getStatusCode(),\n httpResponse.getContent());\n final var userInfoResponse = UserInfoResponse.parse(httpResponse);\n if (userInfoResponse instanceof UserInfoErrorResponse) {\n logger.error(\"Bad User Info response, error={}\",\n ((UserInfoErrorResponse) userInfoResponse).getErrorObject().toJSONObject());\n throw new AuthenticationException();\n } else {\n final var userInfoSuccessResponse = (UserInfoSuccessResponse) userInfoResponse;\n final JWTClaimsSet userInfoClaimsSet;\n if (userInfoSuccessResponse.getUserInfo() != null) {\n userInfoClaimsSet = userInfoSuccessResponse.getUserInfo().toJWTClaimsSet();\n } else {\n userInfoClaimsSet = userInfoSuccessResponse.getUserInfoJWT().getJWTClaimsSet();\n }\n return userInfoClaimsSet;\n }\n } catch (IOException | ParseException | java.text.ParseException | AuthenticationException e) {\n throw new TechnicalException(e);\n }\n }", "label_name": "Base", "label": 1} {"code": "\tpublic int decryptWithAd(byte[] ad, byte[] ciphertext,\n\t\t\tint ciphertextOffset, byte[] plaintext, int plaintextOffset,\n\t\t\tint length) throws ShortBufferException, BadPaddingException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (length > space)\n\t\t\tthrow new ShortBufferException();\n\t\tif (plaintextOffset > plaintext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = plaintext.length - plaintextOffset;\n\t\tif (!haskey) {\n\t\t\t// The key is not set yet - return the ciphertext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (length < 16)\n\t\t\tNoise.throwBadTagException();\n\t\tint dataLen = length - 16;\n\t\tif (dataLen > space)\n\t\t\tthrow new ShortBufferException();\n\t\tsetup(ad);\n\t\tpoly.update(ciphertext, ciphertextOffset, dataLen);\n\t\tfinish(ad, dataLen);\n\t\tint temp = 0;\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\ttemp |= (polyKey[index] ^ ciphertext[ciphertextOffset + dataLen + index]);\n\t\tif ((temp & 0xFF) != 0)\n\t\t\tNoise.throwBadTagException();\n\t\tencrypt(ciphertext, ciphertextOffset, plaintext, plaintextOffset, dataLen);\n\t\treturn dataLen;\n\t}", "label_name": "Base", "label": 1} @@ -1541,7 +1526,6 @@ {"code": " setImmediate(() => {\n if (!this.pendingPublishRequestCount) {\n return;\n }\n const starving_subscription = this._find_starving_subscription();\n if (starving_subscription) {\n doDebug && debugLog(chalk.bgWhite.red(\"feeding most late subscription subscriptionId = \"), starving_subscription.id);\n starving_subscription.process_subscription();\n }\n });", "label_name": "Base", "label": 1} {"code": "\tpublic static Path visit(File file, String filename, FileVisitor visitor) \n\tthrows IOException, IllegalArgumentException {\n\t\tif(!StringHelper.containsNonWhitespace(filename)) {\n\t\t\tfilename = file.getName();\n\t\t}\n\t\t\n\t\tPath fPath = null;\n\t\tif(file.isDirectory()) {\n\t\t\tfPath = file.toPath();\n\t\t} else if(filename != null && filename.toLowerCase().endsWith(\".zip\")) {\n\t\t\ttry {\n\t\t\t\tfPath = FileSystems.newFileSystem(file.toPath(), null).getPath(\"/\");\n\t\t\t} catch (ProviderNotFoundException | ServiceConfigurationError e) {\n\t\t\t\tthrow new IOException(\"Unreadable file with .zip extension: \" + file, e);\n\t\t\t}\n\t\t} else {\n\t\t\tfPath = file.toPath();\n\t\t}\n\t\tif(fPath != null) {\n\t\t Files.walkFileTree(fPath, visitor);\n\t\t}\n\t\treturn fPath;\n\t}", "label_name": "Base", "label": 1} {"code": "\tpublic int decryptWithAd(byte[] ad, byte[] ciphertext,\n\t\t\tint ciphertextOffset, byte[] plaintext, int plaintextOffset,\n\t\t\tint length) throws ShortBufferException, BadPaddingException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (length > space)\n\t\t\tthrow new ShortBufferException();\n\t\tif (plaintextOffset > plaintext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = plaintext.length - plaintextOffset;\n\t\tif (!haskey) {\n\t\t\t// The key is not set yet - return the ciphertext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (length < 16)\n\t\t\tNoise.throwBadTagException();\n\t\tint dataLen = length - 16;\n\t\tif (dataLen > space)\n\t\t\tthrow new ShortBufferException();\n\t\tsetup(ad);\n\t\tghash.update(ciphertext, ciphertextOffset, dataLen);\n\t\tghash.pad(ad != null ? ad.length : 0, dataLen);\n\t\tghash.finish(enciv, 0, 16);\n\t\tint temp = 0;\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\ttemp |= (hashKey[index] ^ enciv[index] ^ ciphertext[ciphertextOffset + dataLen + index]);\n\t\tif ((temp & 0xFF) != 0)\n\t\t\tNoise.throwBadTagException();\n\t\tencryptCTR(ciphertext, ciphertextOffset, plaintext, plaintextOffset, dataLen);\n\t\treturn dataLen;\n\t}", "label_name": "Base", "label": 1} -{"code": " public void handle(HttpServletRequest request, final HttpServletResponse response)\n throws Exception\n {\n // We're sending an XML response, so set the response content type to text/xml\n response.setContentType(\"text/xml\");\n\n // Parse the incoming request as XML\n SAXReader xmlReader = new SAXReader();\n Document doc = xmlReader.read(request.getInputStream());\n Element env = doc.getRootElement();\n\n final List polls = unmarshalRequests(env);\n\n new ContextualHttpServletRequest(request)\n {\n @Override\n public void process() throws Exception\n { \n for (PollRequest req : polls)\n {\n req.poll();\n }\n \n // Package up the response\n marshalResponse(polls, response.getOutputStream()); \n }\n }.run();\n }", "label_name": "CWE-264", "label": "CWE-264"} {"code": "\tprivate Document parseXml(String xmlContent) {\n\t\ttry {\n\t\t\tDocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();\n\t\t\tDocument document = builder.parse(new InputSource(new StringReader(xmlContent)));\n\n\t\t\tdocument.getDocumentElement().normalize();\n\n\t\t\treturn document;\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Can not parse xml content\", e);\n\t\t}\n\t}", "label_name": "Base", "label": 1} {"code": " public void testPullCount() throws IOException {\n initializeSsl();\n String url = RepoUtils.getRemoteRepoURL() + \"/modules/info/\" + orgName + \"/\" + moduleName + \"/*/\";\n HttpURLConnection conn = createHttpUrlConnection(convertToUrl(url), \"\", 0, \"\", \"\");\n conn.setInstanceFollowRedirects(false);\n setRequestMethod(conn, Utils.RequestMethod.GET);\n\n int statusCode = conn.getResponseCode();\n if (statusCode == 200) {\n try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),\n Charset.defaultCharset()))) {\n StringBuilder result = new StringBuilder();\n String line;\n while ((line = reader.readLine()) != null) {\n result.append(line);\n }\n Object payload = JSONParser.parse(result.toString());\n if (payload instanceof MapValue) {\n long pullCount = ((MapValue) payload).getIntValue(\"totalPullCount\");\n Assert.assertEquals(pullCount, totalPullCount);\n } else {\n Assert.fail(\"error: invalid response received\");\n }\n }\n } else {\n Assert.fail(\"error: could not connect to remote repository to find the latest version of module\");\n }\n }", "label_name": "Base", "label": 1} {"code": " private BigInteger validate(BigInteger y, DHParameters dhParams)\n {\n if (dhParams.getQ() != null)\n {\n if (BigInteger.ONE.equals(y.modPow(dhParams.getQ(), dhParams.getP())))\n {\n return y;\n }\n\n throw new IllegalArgumentException(\"Y value does not appear to be in correct group\");\n }\n else\n {\n return y; // we can't validate without Q.\n }\n }", "label_name": "CWE-320", "label": "CWE-320"} @@ -1724,7 +1708,6 @@ {"code": " it \"sets the query operation's fields\" do\n query.select(a: 1)\n query.operation.fields.should eq(a: 1)\n end", "label_name": "Class", "label": 2} {"code": "def add_location_constraint(\n session, resource, node, score, force=false, autocorrect=true\n)\n if node == \"\"\n return \"Bad node\"\n end\n\n if score == \"\"\n nodescore = node\n else\n nodescore = node + \"=\" + score\n end\n\n cmd = [PCS, \"constraint\", \"location\", resource, \"prefers\", nodescore]\n cmd << '--force' if force\n cmd << '--autocorrect' if autocorrect\n\n stdout, stderr, retval = run_cmd(session, *cmd)\n return retval, stderr.join(' ')\nend", "label_name": "Compound", "label": 4} {"code": " def self.get_copies_folder(user_id)\n\n my_folder = User.get_my_folder(user_id)\n\n unless my_folder.nil?\n con = \"(parent_id=#{my_folder.id}) and (name='#{Item.copies_folder}')\"\n\n begin\n copies_folder = Folder.where(con).first\n rescue\n end\n if copies_folder.nil?\n folder = Folder.new\n folder.name = Item.copies_folder\n folder.parent_id = my_folder.id\n folder.owner_id = user_id.to_i\n folder.xtype = nil\n folder.read_users = '|' + user_id.to_s + '|'\n folder.write_users = '|' + user_id.to_s + '|'\n folder.save!\n\n copies_folder = folder\n end\n end\n\n return copies_folder\n end", "label_name": "Base", "label": 1} -{"code": " it \"parses yaml\" do\n YAML.should_receive(:load).with('body')\n subject.send(:yaml)\n end", "label_name": "CWE-264", "label": "CWE-264"} {"code": " it \"should should include the IndirectionHooks module in its indirection\" do\n Puppet::FileServing::Content.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)\n end", "label_name": "Class", "label": 2} {"code": "def cluster_start(params, request, session)\n if params[:name]\n code, response = send_request_with_token(\n session, params[:name], 'cluster_start', true\n )\n else\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n $logger.info \"Starting Daemons\"\n output = `#{PCS} cluster start`\n $logger.debug output\n return output\n end\nend", "label_name": "Compound", "label": 4} {"code": " def test_update_invalid\n Domain.any_instance.stubs(:valid?).returns(false)\n put :update, {:id => Domain.first.to_param, :domain => {:name => Domain.first.name }}, set_session_user\n assert_template 'edit'\n end", "label_name": "Class", "label": 2} @@ -1756,13 +1739,11 @@ {"code": " def copy\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n tmpl_id = params[:thetisBoxSelKeeper].split(':').last\n tmpl_item = Item.find(tmpl_id)\n\n item = tmpl_item.copy(@login_user.id, @login_user.get_my_folder.id)\n if item.public != false\n item.update_attribute(:public, false)\n end\n\n redirect_to(:controller => 'items', :action => 'edit', :id => item.id)\n\n rescue => evar\n Log.add_error(request, evar)\n\n redirect_to(:controller => 'items', :action => 'new')\n end", "label_name": "Base", "label": 1} {"code": " def email_verify_send\n\n raise Exceptions::UnprocessableEntity, 'No email!' if !params[:email]\n\n user = User.find_by(email: params[:email].downcase)\n if !user\n # result is always positive to avoid leaking of existing user accounts\n render json: { message: 'ok' }, status: :ok\n return\n end\n\n #if user.verified == true\n # render json: { error: 'Already verified!' }, status: :unprocessable_entity\n # return\n #end\n\n Token.create(action: 'Signup', user_id: user.id)\n\n result = User.signup_new_token(user)\n if result && result[:token]\n user = result[:user]\n NotificationFactory::Mailer.notification(\n template: 'signup',\n user: user,\n objects: result\n )\n\n # only if system is in develop mode, send token back to browser for browser tests\n if Setting.get('developer_mode') == true\n render json: { message: 'ok', token: result[:token].name }, status: :ok\n return\n end\n\n # token sent to user, send ok to browser\n render json: { message: 'ok' }, status: :ok\n return\n end\n\n # unable to generate token\n render json: { message: 'failed' }, status: :ok\n end", "label_name": "Class", "label": 2} {"code": " def self.validate_token(tokens, extra_chars=nil)\n\n extra_chars ||= []\n regexp = Regexp.new(\"^\\s*[a-zA-Z0-9_.#{extra_chars.join()}]+\\s*$\")\n\n [tokens].flatten.each do |token|\n next if token.blank?\n\n if token.to_s.match(regexp).nil?\n raise(\"[ERROR] SqlHelper.validate_token failed: #{token}\")\n end\n end\n end", "label_name": "Base", "label": 1} -{"code": " it 'should only print each format once with an exception' do\n lambda do\n @klass.format :foobar\n end.should raise_error(HTTParty::UnsupportedFormat, \"':foobar' Must be one of: html, json, plain, xml, yaml\")\n end", "label_name": "CWE-264", "label": "CWE-264"} {"code": " def scope_allowed_tags(tags)\n Rails::Html::WhiteListSanitizer.allowed_tags = tags\n yield Rails::Html::WhiteListSanitizer.new\n\n ensure\n Rails::Html::WhiteListSanitizer.allowed_tags = nil\n end", "label_name": "Base", "label": 1} {"code": " def get_auth_users\n Log.add_info(request, params.inspect)\n\n begin\n @folder = Folder.find(params[:id])\n rescue\n @folder = nil\n end\n\n @users = []\n\n session[:folder_id] = params[:id]\n\n if !@login_user.nil? and (@login_user.admin?(User::AUTH_FOLDER) or (!@folder.nil? and @folder.in_my_folder_of?(@login_user.id)))\n render(:partial => 'ajax_auth_users', :layout => false)\n else\n render(:partial => 'ajax_auth_disp', :layout => false)\n end\n end", "label_name": "Base", "label": 1} {"code": "def check_gui_status_of_nodes(session, nodes, check_mutuality=false, timeout=10)\n options = {}\n options[:check_auth_only] = '' if not check_mutuality\n threads = []\n not_authorized_nodes = []\n online_nodes = []\n offline_nodes = []\n\n nodes = nodes.uniq.sort\n nodes.each { |node|\n threads << Thread.new {\n code, response = send_request_with_token(\n session, node, 'check_auth', false, options, true, nil, timeout\n )\n if code == 200\n if check_mutuality\n begin\n parsed_response = JSON.parse(response)\n if parsed_response['node_list'] and parsed_response['node_list'].uniq.sort == nodes\n online_nodes << node\n else\n not_authorized_nodes << node\n end\n rescue\n not_authorized_nodes << node\n end\n else\n online_nodes << node\n end\n else\n begin\n parsed_response = JSON.parse(response)\n if parsed_response['notauthorized'] or parsed_response['notoken']\n not_authorized_nodes << node\n else\n offline_nodes << node\n end\n rescue JSON::ParserError\n end\n end\n }\n }\n threads.each { |t| t.join }\n return online_nodes, offline_nodes, not_authorized_nodes\nend", "label_name": "Compound", "label": 4} {"code": " def ajax_move_mails\n Log.add_info(request, params.inspect)\n\n folder_id = params[:thetisBoxSelKeeper].split(':').last\n mail_folder = MailFolder.find_by_id(folder_id)\n\n if folder_id == '0' \\\n or mail_folder.nil? \\\n or mail_folder.user_id != @login_user.id\n flash[:notice] = 'ERROR:' + t('msg.cannot_save_in_folder')\n get_mails\n return\n end\n\n unless params[:check_mail].blank?\n count = 0\n params[:check_mail].each do |email_id, value|\n if value == '1'\n\n begin\n email = Email.find(email_id)\n next if email.user_id != @login_user.id\n\n email.update_attribute(:mail_folder_id, folder_id)\n\n rescue => evar\n Log.add_error(request, evar)\n end\n\n count += 1\n end\n end\n flash[:notice] = t('mail.moved', :count => count)\n end\n\n get_mails\n end", "label_name": "Base", "label": 1} {"code": " def self.add_statistics_group(group_id)\n\n yaml = Research.get_config_yaml\n\n yaml = Hash.new if yaml.nil?\n\n if yaml[:statistics].nil?\n yaml[:statistics] = Hash.new\n end\n\n groups = yaml[:statistics][:groups]\n\n if groups.nil?\n\n yaml[:statistics][:groups] = group_id\n ary = [group_id.to_s]\n\n else\n\n ary = groups.split('|')\n ary << group_id\n\n ary.compact!\n ary.delete ''\n\n yaml[:statistics][:groups] = ary.join('|')\n end\n\n Research.save_config_yaml yaml\n\n return ary\n end", "label_name": "Base", "label": 1} -{"code": " it \"should reject a critical extension that isn't on the whitelist\" do\n @request.stubs(:request_extensions).returns [{ \"oid\" => \"banana\",\n \"value\" => \"yumm\",\n \"critical\" => true }]\n expect { @ca.sign(@name) }.to raise_error(\n Puppet::SSL::CertificateAuthority::CertificateSigningError,\n /request extensions that are not permitted/\n )\n end", "label_name": "CWE-264", "label": "CWE-264"} {"code": " def self.get_for_group(group_id, incl_img_content=false)\n\n SqlHelper.validate_token([group_id])\n\n if group_id.nil?\n office_map = nil\n else\n if incl_img_content\n office_map = OfficeMap.where(\"group_id=#{group_id}\").first\n else\n sql = 'select id, group_id, img_enabled, img_name, img_size, img_content_type, created_at, updated_at from office_maps'\n sql << \" where group_id=#{group_id}\"\n begin\n office_map = OfficeMap.find_by_sql(sql).first\n rescue\n end\n end\n end\n\n if office_map.nil?\n office_map = OfficeMap.new\n office_map.group_id = group_id.to_i unless group_id.nil?\n office_map.img_enabled = false\n end\n\n return office_map\n end", "label_name": "Base", "label": 1} {"code": " def update\n return unless access_granted?(params[:id])\n\n id = params[:article][:id] || params[:id]\n @article = Article.find(id)\n\n if params[:article][:draft]\n fetch_fresh_or_existing_draft_for_article\n else\n @article = Article.find(@article.parent_id) unless @article.parent_id.nil?\n end\n\n update_article_attributes\n\n if @article.draft\n @article.state = \"draft\"\n elsif @article.draft?\n @article.publish!\n end\n\n if @article.save\n Article.where(parent_id: @article.id).map(&:destroy) unless @article.draft\n flash[:success] = I18n.t(\"admin.content.update.success\")\n redirect_to action: \"index\"\n else\n @article.keywords = Tag.collection_to_string @article.tags\n load_resources\n render \"edit\"\n end\n end", "label_name": "Class", "label": 2} {"code": " def set_auth_groups\n Log.add_info(request, params.inspect)\n\n @folder = Folder.find(params[:id])\n\n if Folder.check_user_auth(@folder.id, @login_user, 'w', true)\n read_groups = []\n write_groups = []\n groups_auth = params[:groups_auth]\n unless groups_auth.nil?\n groups_auth.each do |auth_param|\n user_id = auth_param.split(':').first\n auths = auth_param.split(':').last.split('+')\n if auths.include?('r')\n read_groups << user_id\n end\n if auths.include?('w')\n write_groups << user_id\n end\n end\n end\n\n @folder.set_read_groups read_groups\n @folder.set_write_groups write_groups\n\n @folder.save\n\n flash[:notice] = t('msg.register_success')\n else\n flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify')\n end\n\n @groups = Group.where(nil).to_a\n render(:partial => 'ajax_auth_groups', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n render(:partial => 'ajax_auth_groups', :layout => false)\n end", "label_name": "Base", "label": 1} @@ -1778,7 +1759,6 @@ {"code": " def logout\n session.cluster.logout(name)\n end", "label_name": "Class", "label": 2} {"code": " it 'should return the right response for a single option' do\n DiscoursePoll::Poll.vote(\n user,\n post.id,\n DiscoursePoll::DEFAULT_POLL_NAME,\n [option_a, option_b]\n )\n\n get \"/polls/voters.json\", params: {\n post_id: post.id,\n poll_name: DiscoursePoll::DEFAULT_POLL_NAME,\n option_id: option_b\n }\n\n expect(response.status).to eq(200)\n\n poll = response.parsed_body[\"voters\"]\n\n expect(poll[option_a]).to eq(nil)\n\n option = poll[option_b]\n\n expect(option.length).to eq(1)\n expect(option.first[\"id\"]).to eq(user.id)\n expect(option.first[\"username\"]).to eq(user.username)\n end", "label_name": "NVD-CWE-Other", "label": "NVD-CWE-Other"} {"code": " it \"returns the same hash\" do\n Moped::BSON::ObjectId.new(bytes).hash.should eq Moped::BSON::ObjectId.new(bytes).hash\n end", "label_name": "Class", "label": 2} -{"code": " def create\n exists = true \n if params.has_key?(:inflated_object)\n params[:name] ||= params[:inflated_object].name\n # We can only get here if we're admin or the validator. Only\n # allow creating admin clients if we're already an admin.\n if @auth_user.admin\n params[:admin] ||= params[:inflated_object].admin\n else\n params[:admin] = false\n end\n end\n\n begin\n Chef::ApiClient.cdb_load(params[:name])\n rescue Chef::Exceptions::CouchDBNotFound\n exists = false \n end\n raise Conflict, \"Client already exists\" if exists\n\n @client = Chef::ApiClient.new\n @client.name(params[:name])\n @client.admin(params[:admin]) if params[:admin]\n @client.create_keys\n @client.cdb_save\n \n self.status = 201\n headers['Location'] = absolute_url(:client, @client.name)\n display({ :uri => absolute_url(:client, @client.name), :private_key => @client.private_key })\n end", "label_name": "CWE-264", "label": "CWE-264"} {"code": " it \"handles Symbol keys with tailing '='\" do\n cl = subject.build_command_line(\"true\", :abc= => \"def\")\n expect(cl).to eq \"true --abc=def\"\n end", "label_name": "Base", "label": 1} {"code": " it \"recognizes and generates #destroy\" do\n { :delete => \"/users/1\" }.should route_to(:controller => \"users\", :action => \"destroy\", :id => \"1\")\n end", "label_name": "Class", "label": 2} {"code": " def get_user_archive_fields(user_archive)\n user_archive_array = []\n topic_data = user_archive.topic\n user_archive = user_archive.as_json\n topic_data = Topic.with_deleted.find_by(id: user_archive['topic_id']) if topic_data.nil?\n return user_archive_array if topic_data.nil?\n\n categories = piped_category_name(topic_data.category_id)\n is_pm = topic_data.archetype == \"private_message\" ? I18n.t(\"csv_export.boolean_yes\") : I18n.t(\"csv_export.boolean_no\")\n url = \"#{Discourse.base_url}/t/#{topic_data.slug}/#{topic_data.id}/#{user_archive['post_number']}\"\n\n topic_hash = { \"post\" => user_archive['raw'], \"topic_title\" => topic_data.title, \"categories\" => categories, \"is_pm\" => is_pm, \"url\" => url }\n user_archive.merge!(topic_hash)\n\n HEADER_ATTRS_FOR['user_archive'].each do |attr|\n user_archive_array.push(user_archive[attr])\n end\n\n user_archive_array\n end", "label_name": "Class", "label": 2}