func
stringlengths
269
194k
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void usbtest_disconnect(struct usb_interface *intf) { struct usbtest_dev *dev = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); dev_dbg(&intf->dev, "disconnect\n"); kfree(dev); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [char *make_config_name() { const char *t=X509_get_default_cert_area(); size_t len; char *p; len=strlen(t)+strlen(OPENSSL_CONF)+2; p=OPENSSL_malloc(len); BUF_strlcpy(p,t,len); #ifndef OPENSSL_SYS_VMS BUF_strlcat(p,"/",len); #endif BUF_strlcat(p,OPENSSL_CONF,len); return p; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, struct mm_struct *mm) { const struct cred *cred; unsigned int i, len; /* first copy the parameters from user space */ memset(psinfo, 0, sizeof(struct elf_prpsinfo)); len = mm->arg_end - mm->arg_start; if (len >= ELF_PRARGSZ) len = ELF_PRARGSZ-1; if (copy_from_user(&psinfo->pr_psargs, (const char __user *)mm->arg_start, len)) return -EFAULT; for(i = 0; i < len; i++) if (psinfo->pr_psargs[i] == 0) psinfo->pr_psargs[i] = ' '; psinfo->pr_psargs[len] = 0; rcu_read_lock(); psinfo->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent)); rcu_read_unlock(); psinfo->pr_pid = task_pid_vnr(p); psinfo->pr_pgrp = task_pgrp_vnr(p); psinfo->pr_sid = task_session_vnr(p); i = p->state ? ffz(~p->state) + 1 : 0; psinfo->pr_state = i; psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i]; psinfo->pr_zomb = psinfo->pr_sname == 'Z'; psinfo->pr_nice = task_nice(p); psinfo->pr_flag = p->flags; rcu_read_lock(); cred = __task_cred(p); SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid)); SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid)); rcu_read_unlock(); strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname)); return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [dhcpv6_print(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { u_int i, t; const u_char *tlv, *value; uint16_t type, optlen; i = 0; while (i < length) { tlv = cp + i; type = EXTRACT_16BITS(tlv); optlen = EXTRACT_16BITS(tlv + 2); value = tlv + 4; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); ND_PRINT((ndo, "%s", tok2str(dh6opt_str, "Unknown", type))); ND_PRINT((ndo," (%u)", optlen + 4 )); switch (type) { case DH6OPT_DNS_SERVERS: case DH6OPT_SNTP_SERVERS: { if (optlen % 16 != 0) { ND_PRINT((ndo, " %s", istr)); return -1; } for (t = 0; t < optlen; t += 16) ND_PRINT((ndo, " %s", ip6addr_string(ndo, value + t))); } break; case DH6OPT_DOMAIN_LIST: { const u_char *tp = value; while (tp < value + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL) return -1; } } break; } i += 4 + optlen; } return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void br_multicast_stop(struct net_bridge *br) { struct net_bridge_mdb_htable *mdb; struct net_bridge_mdb_entry *mp; struct hlist_node *n; u32 ver; int i; del_timer_sync(&br->multicast_router_timer); del_timer_sync(&br->multicast_querier_timer); del_timer_sync(&br->multicast_query_timer); spin_lock_bh(&br->multicast_lock); mdb = mlock_dereference(br->mdb, br); if (!mdb) goto out; br->mdb = NULL; ver = mdb->ver; for (i = 0; i < mdb->max; i++) { hlist_for_each_entry_safe(mp, n, &mdb->mhash[i], hlist[ver]) { del_timer(&mp->timer); call_rcu_bh(&mp->rcu, br_multicast_free_group); } } if (mdb->old) { spin_unlock_bh(&br->multicast_lock); rcu_barrier_bh(); spin_lock_bh(&br->multicast_lock); WARN_ON(mdb->old); } mdb->old = mdb; call_rcu_bh(&mdb->rcu, br_mdb_free); out: spin_unlock_bh(&br->multicast_lock); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInfo field) { u32 i, sf_type; Bool needs_field_container; GF_ChildNodeItem *list; void *slot_ptr; switch (field.fieldType) { case GF_SG_VRML_SFNODE: assert ( *(GF_Node **)field.far_ptr); if (sdump->XMLDump) { if (!sdump->X3DDump) { StartElement(sdump, (char *) field.name); EndElementHeader(sdump, 1); sdump->indent++; } } else { StartAttribute(sdump, field.name); } gf_dump_vrml_node(sdump, *(GF_Node **)field.far_ptr, 0, NULL); if (sdump->XMLDump) { if (!sdump->X3DDump) { sdump->indent--; EndElement(sdump, (char *) field.name, 1); } } else { EndAttribute(sdump); } return; case GF_SG_VRML_MFNODE: needs_field_container = 0; if (sdump->XMLDump && sdump->X3DDump) { u32 count, nb_ndt; GF_FieldInfo info; if (!strcmp(field.name, "children")) { needs_field_container = 0; } else { nb_ndt = 0; count = gf_node_get_field_count(node); for (i=0; i<count; i++) { gf_node_get_field(node, i, &info); if ((info.eventType==GF_SG_EVENT_IN) || (info.eventType==GF_SG_EVENT_OUT)) continue; if (info.NDTtype==field.NDTtype) nb_ndt++; } needs_field_container = (nb_ndt>1) ? 1 : 0; } } #ifndef GPAC_DISABLE_X3D if (!sdump->X3DDump) { if (gf_node_get_tag(node)==TAG_X3D_Switch) field.name = "choice"; } #endif list = * ((GF_ChildNodeItem **) field.far_ptr); assert(list); if (!sdump->XMLDump || !sdump->X3DDump) StartList(sdump, field.name); sdump->indent++; while (list) { gf_dump_vrml_node(sdump, list->node, 1, needs_field_container ? (char *) field.name : NULL); list = list->next; } sdump->indent--; if (!sdump->XMLDump || !sdump->X3DDump) EndList(sdump, field.name); return; case GF_SG_VRML_SFCOMMANDBUFFER: { SFCommandBuffer *cb = (SFCommandBuffer *)field.far_ptr; StartElement(sdump, (char *) field.name); EndElementHeader(sdump, 1); sdump->indent++; if (!gf_list_count(cb->commandList)) { /*the arch does not allow for that (we would need a codec and so on, or decompress the command list in all cases...)*/ if (sdump->trace && cb->bufferSize) { if (sdump->XMLDump) gf_fprintf(sdump->trace, "<!--SFCommandBuffer cannot be dumped while playing - use MP4Box instead-->\n"); else gf_fprintf(sdump->trace, "#SFCommandBuffer cannot be dumped while playing - use MP4Box instead\n"); } } else { gf_sm_dump_command_list(sdump, cb->commandList, sdump->indent, 0); } sdump->indent--; EndElement(sdump, (char *) field.name, 1); } return; case GF_SG_VRML_MFATTRREF: if (sdump->XMLDump) { MFAttrRef *ar = (MFAttrRef *)field.far_ptr; StartElement(sdump, (char *) field.name); EndElementHeader(sdump, 1); sdump->indent++; for (i=0; i<ar->count; i++) { if (ar->vals[i].node) { GF_FieldInfo pinfo; DUMP_IND(sdump); gf_node_get_field(ar->vals[i].node, ar->vals[i].fieldIndex, &pinfo); gf_fprintf(sdump->trace, "<store node=\""); scene_dump_vrml_id(sdump, ar->vals[i].node); gf_fprintf(sdump->trace, "\" field=\"%s\"/>\n", pinfo.name); } } sdump->indent--; EndElement(sdump, (char *) field.name, 1); return; } break; } if (gf_sg_vrml_is_sf_field(field.fieldType)) { StartAttribute(sdump, field.name); gf_dump_vrml_sffield(sdump, field.fieldType, field.far_ptr, 0, node); EndAttribute(sdump); } else { GenMFField *mffield = (GenMFField *) field.far_ptr; sf_type = gf_sg_vrml_get_sf_type(field.fieldType); if (sdump->XMLDump && sdump->X3DDump) { switch (sf_type) { case GF_SG_VRML_SFSTRING: case GF_SG_VRML_SFSCRIPT: case GF_SG_VRML_SFURL: gf_fprintf(sdump->trace, " %s=\'", (char *) field.name); break; default: StartAttribute(sdump, field.name); break; } } else { StartAttribute(sdump, field.name); } if (!sdump->XMLDump) gf_fprintf(sdump->trace, "["); if (mffield) { for (i=0; i<mffield->count; i++) { if (i) gf_fprintf(sdump->trace, " "); gf_sg_vrml_mf_get_item(field.far_ptr, field.fieldType, &slot_ptr, i); gf_dump_vrml_sffield(sdump, sf_type, slot_ptr, 1, node); } } if (!sdump->XMLDump) gf_fprintf(sdump->trace, "]"); if (sdump->XMLDump && sdump->X3DDump) { switch (sf_type) { case GF_SG_VRML_SFSTRING: case GF_SG_VRML_SFSCRIPT: case GF_SG_VRML_SFURL: gf_fprintf(sdump->trace, "\'"); break; default: EndAttribute(sdump); break; } } else { EndAttribute(sdump); } } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [flatpak_context_save_metadata (FlatpakContext *context, gboolean flatten, GKeyFile *metakey) { g_auto(GStrv) shared = NULL; g_auto(GStrv) sockets = NULL; g_auto(GStrv) devices = NULL; g_auto(GStrv) features = NULL; GHashTableIter iter; gpointer key, value; FlatpakContextShares shares_mask = context->shares; FlatpakContextShares shares_valid = context->shares_valid; FlatpakContextSockets sockets_mask = context->sockets; FlatpakContextSockets sockets_valid = context->sockets_valid; FlatpakContextDevices devices_mask = context->devices; FlatpakContextDevices devices_valid = context->devices_valid; FlatpakContextFeatures features_mask = context->features; FlatpakContextFeatures features_valid = context->features_valid; g_auto(GStrv) groups = NULL; int i; if (flatten) { /* A flattened format means we don't expect this to be merged on top of another context. In that case we never need to negate any flags. We calculate this by removing the zero parts of the mask from the valid set. */ /* First we make sure only the valid parts of the mask are set, in case we got some leftover */ shares_mask &= shares_valid; sockets_mask &= sockets_valid; devices_mask &= devices_valid; features_mask &= features_valid; /* Then just set the valid set to be the mask set */ shares_valid = shares_mask; sockets_valid = sockets_mask; devices_valid = devices_mask; features_valid = features_mask; } shared = flatpak_context_shared_to_string (shares_mask, shares_valid); sockets = flatpak_context_sockets_to_string (sockets_mask, sockets_valid); devices = flatpak_context_devices_to_string (devices_mask, devices_valid); features = flatpak_context_features_to_string (features_mask, features_valid); if (shared[0] != NULL) { g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SHARED, (const char * const *) shared, g_strv_length (shared)); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SHARED, NULL); } if (sockets[0] != NULL) { g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SOCKETS, (const char * const *) sockets, g_strv_length (sockets)); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SOCKETS, NULL); } if (devices[0] != NULL) { g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_DEVICES, (const char * const *) devices, g_strv_length (devices)); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_DEVICES, NULL); } if (features[0] != NULL) { g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FEATURES, (const char * const *) features, g_strv_length (features)); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FEATURES, NULL); } if (g_hash_table_size (context->filesystems) > 0) { g_autoptr(GPtrArray) array = g_ptr_array_new_with_free_func (g_free); g_hash_table_iter_init (&iter, context->filesystems); while (g_hash_table_iter_next (&iter, &key, &value)) { FlatpakFilesystemMode mode = GPOINTER_TO_INT (value); g_ptr_array_add (array, unparse_filesystem_flags (key, mode)); } g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FILESYSTEMS, (const char * const *) array->pdata, array->len); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FILESYSTEMS, NULL); } if (g_hash_table_size (context->persistent) > 0) { g_autofree char **keys = (char **) g_hash_table_get_keys_as_array (context->persistent, NULL); g_key_file_set_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_PERSISTENT, (const char * const *) keys, g_strv_length (keys)); } else { g_key_file_remove_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_PERSISTENT, NULL); } g_key_file_remove_group (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, NULL); g_hash_table_iter_init (&iter, context->session_bus_policy); while (g_hash_table_iter_next (&iter, &key, &value)) { FlatpakPolicy policy = GPOINTER_TO_INT (value); if (flatten && (policy == 0)) continue; g_key_file_set_string (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, (char *) key, flatpak_policy_to_string (policy)); } g_key_file_remove_group (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, NULL); g_hash_table_iter_init (&iter, context->system_bus_policy); while (g_hash_table_iter_next (&iter, &key, &value)) { FlatpakPolicy policy = GPOINTER_TO_INT (value); if (flatten && (policy == 0)) continue; g_key_file_set_string (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, (char *) key, flatpak_policy_to_string (policy)); } g_key_file_remove_group (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, NULL); g_hash_table_iter_init (&iter, context->env_vars); while (g_hash_table_iter_next (&iter, &key, &value)) { g_key_file_set_string (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, (char *) key, (char *) value); } groups = g_key_file_get_groups (metakey, NULL); for (i = 0; groups[i] != NULL; i++) { const char *group = groups[i]; if (g_str_has_prefix (group, FLATPAK_METADATA_GROUP_PREFIX_POLICY)) g_key_file_remove_group (metakey, group, NULL); } g_hash_table_iter_init (&iter, context->generic_policy); while (g_hash_table_iter_next (&iter, &key, &value)) { g_auto(GStrv) parts = g_strsplit ((const char *) key, ".", 2); g_autofree char *group = NULL; g_assert (parts[1] != NULL); const char **policy_values = (const char **) value; g_autoptr(GPtrArray) new = g_ptr_array_new (); for (i = 0; policy_values[i] != NULL; i++) { const char *policy_value = policy_values[i]; if (!flatten || policy_value[0] != '!') g_ptr_array_add (new, (char *) policy_value); } if (new->len > 0) { group = g_strconcat (FLATPAK_METADATA_GROUP_PREFIX_POLICY, parts[0], NULL); g_key_file_set_string_list (metakey, group, parts[1], (const char * const *) new->pdata, new->len); } } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [rsCStrExtendBuf(cstr_t *pThis, size_t iMinNeeded) { uchar *pNewBuf; unsigned short iNewSize; DEFiRet; /* first compute the new size needed */ if(iMinNeeded > RS_STRINGBUF_ALLOC_INCREMENT) { /* we allocate "n" ALLOC_INCREMENTs. Usually, that should * leave some room after the absolutely needed one. It also * reduces memory fragmentation. Note that all of this are * integer operations (very important to understand what is * going on)! Parenthesis are for better readibility. */ iNewSize = (iMinNeeded / RS_STRINGBUF_ALLOC_INCREMENT + 1) * RS_STRINGBUF_ALLOC_INCREMENT; } else { iNewSize = pThis->iBufSize + RS_STRINGBUF_ALLOC_INCREMENT; } iNewSize += pThis->iBufSize; /* add current size */ /* DEV debugging only: dbgprintf("extending string buffer, old %d, new %d\n", pThis->iBufSize, iNewSize); */ CHKmalloc(pNewBuf = (uchar*) realloc(pThis->pBuf, iNewSize * sizeof(uchar))); pThis->iBufSize = iNewSize; pThis->pBuf = pNewBuf; finalize_it: RETiRet; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data, unsigned data_len, int *al) { unsigned i; unsigned proto_len; if (data_len < 2) goto parse_error; /* * data should contain a uint16 length followed by a series of 8-bit, * length-prefixed strings. */ i = ((unsigned)data[0]) << 8 | ((unsigned)data[1]); data_len -= 2; data += 2; if (data_len != i) goto parse_error; if (data_len < 2) goto parse_error; for (i = 0; i < data_len;) { proto_len = data[i]; i++; if (proto_len == 0) goto parse_error; if (i + proto_len < i || i + proto_len > data_len) goto parse_error; i += proto_len; } if (s->cert->alpn_proposed != NULL) OPENSSL_free(s->cert->alpn_proposed); s->cert->alpn_proposed = OPENSSL_malloc(data_len); if (s->cert->alpn_proposed == NULL) { *al = SSL_AD_INTERNAL_ERROR; return -1; } memcpy(s->cert->alpn_proposed, data, data_len); s->cert->alpn_proposed_len = data_len; return 0; parse_error: *al = SSL_AD_DECODE_ERROR; return -1; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ GF_Err rvcc_Size(GF_Box *s) { GF_RVCConfigurationBox *ptr = (GF_RVCConfigurationBox *)s; ptr->size += 2; if (! ptr->predefined_rvc_config) ptr->size += 2; return GF_OK;] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void __fastcall TCustomDialog::SetUpComboBox(TCustomCombo * Combo, TStrings * Items, bool OneLine) { if (Items != NULL) { Combo->Items = Items; } if (OneLine) { int Width = 0; for (int Index = 0; Index < Combo->Items->Count; Index++) { Width = Max(Width, Combo->Canvas->TextWidth(Combo->Items->Strings[Index])); } Width += ScaleByTextHeight(Combo, 4 + 16 + 14); Width = Max(Width, HelpButton->Width); Combo->Width = Width; Combo->Left = GetDefaultParent()->ClientWidth - FHorizontalMargin - Width; } TComboBox * PublicCombo = reinterpret_cast<TComboBox *>(Combo); if (PublicCombo->OnChange == NULL) { PublicCombo->OnChange = Change; } } ] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, const unsigned char *sess_id, int sesslen, SSL_SESSION **psess) { SSL_SESSION *sess; unsigned char *sdec; const unsigned char *p; int slen, mlen, renew_ticket = 0; unsigned char tick_hmac[EVP_MAX_MD_SIZE]; HMAC_CTX hctx; EVP_CIPHER_CTX ctx; SSL_CTX *tctx = s->initial_ctx; /* Need at least keyname + iv + some encrypted data */ if (eticklen < 48) return 2; /* Initialize session ticket encryption and HMAC contexts */ HMAC_CTX_init(&hctx); EVP_CIPHER_CTX_init(&ctx); if (tctx->tlsext_ticket_key_cb) { unsigned char *nctick = (unsigned char *)etick; int rv = tctx->tlsext_ticket_key_cb(s, nctick, nctick + 16, &ctx, &hctx, 0); if (rv < 0) return -1; if (rv == 0) return 2; if (rv == 2) renew_ticket = 1; } else { /* Check key name matches */ if (memcmp(etick, tctx->tlsext_tick_key_name, 16)) return 2; HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, tlsext_tick_md(), NULL); EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, tctx->tlsext_tick_aes_key, etick + 16); } /* Attempt to process session ticket, first conduct sanity and * integrity checks on ticket. */ mlen = HMAC_size(&hctx); if (mlen < 0) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } eticklen -= mlen; /* Check HMAC of encrypted ticket */ HMAC_Update(&hctx, etick, eticklen); HMAC_Final(&hctx, tick_hmac, NULL); HMAC_CTX_cleanup(&hctx); if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) return 2; /* Attempt to decrypt session data */ /* Move p after IV to start of encrypted ticket, update length */ p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx); eticklen -= 16 + EVP_CIPHER_CTX_iv_length(&ctx); sdec = OPENSSL_malloc(eticklen); if (!sdec) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } EVP_DecryptUpdate(&ctx, sdec, &slen, p, eticklen); if (EVP_DecryptFinal(&ctx, sdec + slen, &mlen) <= 0) { EVP_CIPHER_CTX_cleanup(&ctx); OPENSSL_free(sdec); return 2; } slen += mlen; EVP_CIPHER_CTX_cleanup(&ctx); p = sdec; sess = d2i_SSL_SESSION(NULL, &p, slen); OPENSSL_free(sdec); if (sess) { /* The session ID, if non-empty, is used by some clients to * detect that the ticket has been accepted. So we copy it to * the session structure. If it is empty set length to zero * as required by standard. */ if (sesslen) memcpy(sess->session_id, sess_id, sesslen); sess->session_id_length = sesslen; *psess = sess; if (renew_ticket) return 4; else return 3; } ERR_clear_error(); /* For session parse failure, indicate that we need to send a new * ticket. */ return 2; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ */ PHP_MINIT_FUNCTION(imap) { unsigned long sa_all = SA_MESSAGES | SA_RECENT | SA_UNSEEN | SA_UIDNEXT | SA_UIDVALIDITY; #ifndef PHP_WIN32 mail_link(&unixdriver); /* link in the unix driver */ mail_link(&mhdriver); /* link in the mh driver */ /* mail_link(&mxdriver); */ /* According to c-client docs (internal.txt) this shouldn't be used. */ mail_link(&mmdfdriver); /* link in the mmdf driver */ mail_link(&newsdriver); /* link in the news driver */ mail_link(&philedriver); /* link in the phile driver */ #endif mail_link(&imapdriver); /* link in the imap driver */ mail_link(&nntpdriver); /* link in the nntp driver */ mail_link(&pop3driver); /* link in the pop3 driver */ mail_link(&mbxdriver); /* link in the mbx driver */ mail_link(&tenexdriver); /* link in the tenex driver */ mail_link(&mtxdriver); /* link in the mtx driver */ mail_link(&dummydriver); /* link in the dummy driver */ #ifndef PHP_WIN32 auth_link(&auth_log); /* link in the log authenticator */ auth_link(&auth_md5); /* link in the cram-md5 authenticator */ #if HAVE_IMAP_KRB && defined(HAVE_IMAP_AUTH_GSS) auth_link(&auth_gss); /* link in the gss authenticator */ #endif auth_link(&auth_pla); /* link in the plain authenticator */ #endif #ifdef HAVE_IMAP_SSL ssl_onceonlyinit (); #endif /* lets allow NIL */ REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS); /* plug in our gets */ mail_parameters(NIL, SET_GETS, (void *) NIL); /* set default timeout values */ mail_parameters(NIL, SET_OPENTIMEOUT, (void *) FG(default_socket_timeout)); mail_parameters(NIL, SET_READTIMEOUT, (void *) FG(default_socket_timeout)); mail_parameters(NIL, SET_WRITETIMEOUT, (void *) FG(default_socket_timeout)); mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) FG(default_socket_timeout)); /* timeout constants */ REGISTER_LONG_CONSTANT("IMAP_OPENTIMEOUT", 1, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("IMAP_READTIMEOUT", 2, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("IMAP_WRITETIMEOUT", 3, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("IMAP_CLOSETIMEOUT", 4, CONST_PERSISTENT | CONST_CS); /* Open Options */ REGISTER_LONG_CONSTANT("OP_DEBUG", OP_DEBUG, CONST_PERSISTENT | CONST_CS); /* debug protocol negotiations */ REGISTER_LONG_CONSTANT("OP_READONLY", OP_READONLY, CONST_PERSISTENT | CONST_CS); /* read-only open */ REGISTER_LONG_CONSTANT("OP_ANONYMOUS", OP_ANONYMOUS, CONST_PERSISTENT | CONST_CS); /* anonymous open of newsgroup */ REGISTER_LONG_CONSTANT("OP_SHORTCACHE", OP_SHORTCACHE, CONST_PERSISTENT | CONST_CS); /* short (elt-only) caching */ REGISTER_LONG_CONSTANT("OP_SILENT", OP_SILENT, CONST_PERSISTENT | CONST_CS); /* don't pass up events (internal use) */ REGISTER_LONG_CONSTANT("OP_PROTOTYPE", OP_PROTOTYPE, CONST_PERSISTENT | CONST_CS); /* return driver prototype */ REGISTER_LONG_CONSTANT("OP_HALFOPEN", OP_HALFOPEN, CONST_PERSISTENT | CONST_CS); /* half-open (IMAP connect but no select) */ REGISTER_LONG_CONSTANT("OP_EXPUNGE", OP_EXPUNGE, CONST_PERSISTENT | CONST_CS); /* silently expunge recycle stream */ REGISTER_LONG_CONSTANT("OP_SECURE", OP_SECURE, CONST_PERSISTENT | CONST_CS); /* don't do non-secure authentication */ /* PHP re-assigns CL_EXPUNGE a custom value that can be used as part of the imap_open() bitfield because it seems like a good idea to be able to indicate that the mailbox should be automatically expunged during imap_open in case the script get interrupted and it doesn't get to the imap_close() where this option is normally placed. If the c-client library adds other options and the value for this one conflicts, simply make PHP_EXPUNGE higher at the top of this file */ REGISTER_LONG_CONSTANT("CL_EXPUNGE", PHP_EXPUNGE, CONST_PERSISTENT | CONST_CS); /* expunge silently */ /* Fetch options */ REGISTER_LONG_CONSTANT("FT_UID", FT_UID, CONST_PERSISTENT | CONST_CS); /* argument is a UID */ REGISTER_LONG_CONSTANT("FT_PEEK", FT_PEEK, CONST_PERSISTENT | CONST_CS); /* peek at data */ REGISTER_LONG_CONSTANT("FT_NOT", FT_NOT, CONST_PERSISTENT | CONST_CS); /* NOT flag for header lines fetch */ REGISTER_LONG_CONSTANT("FT_INTERNAL", FT_INTERNAL, CONST_PERSISTENT | CONST_CS); /* text can be internal strings */ REGISTER_LONG_CONSTANT("FT_PREFETCHTEXT", FT_PREFETCHTEXT, CONST_PERSISTENT | CONST_CS); /* IMAP prefetch text when fetching header */ /* Flagging options */ REGISTER_LONG_CONSTANT("ST_UID", ST_UID, CONST_PERSISTENT | CONST_CS); /* argument is a UID sequence */ REGISTER_LONG_CONSTANT("ST_SILENT", ST_SILENT, CONST_PERSISTENT | CONST_CS); /* don't return results */ REGISTER_LONG_CONSTANT("ST_SET", ST_SET, CONST_PERSISTENT | CONST_CS); /* set vs. clear */ /* Copy options */ REGISTER_LONG_CONSTANT("CP_UID", CP_UID, CONST_PERSISTENT | CONST_CS); /* argument is a UID sequence */ REGISTER_LONG_CONSTANT("CP_MOVE", CP_MOVE, CONST_PERSISTENT | CONST_CS); /* delete from source after copying */ /* Search/sort options */ REGISTER_LONG_CONSTANT("SE_UID", SE_UID, CONST_PERSISTENT | CONST_CS); /* return UID */ REGISTER_LONG_CONSTANT("SE_FREE", SE_FREE, CONST_PERSISTENT | CONST_CS); /* free search program after finished */ REGISTER_LONG_CONSTANT("SE_NOPREFETCH", SE_NOPREFETCH, CONST_PERSISTENT | CONST_CS); /* no search prefetching */ REGISTER_LONG_CONSTANT("SO_FREE", SO_FREE, CONST_PERSISTENT | CONST_CS); /* free sort program after finished */ REGISTER_LONG_CONSTANT("SO_NOSERVER", SO_NOSERVER, CONST_PERSISTENT | CONST_CS); /* don't do server-based sort */ /* Status options */ REGISTER_LONG_CONSTANT("SA_MESSAGES", SA_MESSAGES , CONST_PERSISTENT | CONST_CS); /* number of messages */ REGISTER_LONG_CONSTANT("SA_RECENT", SA_RECENT, CONST_PERSISTENT | CONST_CS); /* number of recent messages */ REGISTER_LONG_CONSTANT("SA_UNSEEN", SA_UNSEEN , CONST_PERSISTENT | CONST_CS); /* number of unseen messages */ REGISTER_LONG_CONSTANT("SA_UIDNEXT", SA_UIDNEXT, CONST_PERSISTENT | CONST_CS); /* next UID to be assigned */ REGISTER_LONG_CONSTANT("SA_UIDVALIDITY", SA_UIDVALIDITY , CONST_PERSISTENT | CONST_CS); /* UID validity value */ REGISTER_LONG_CONSTANT("SA_ALL", sa_all, CONST_PERSISTENT | CONST_CS); /* get all status information */ /* Bits for mm_list() and mm_lsub() */ REGISTER_LONG_CONSTANT("LATT_NOINFERIORS", LATT_NOINFERIORS , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LATT_NOSELECT", LATT_NOSELECT, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LATT_MARKED", LATT_MARKED, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LATT_UNMARKED", LATT_UNMARKED , CONST_PERSISTENT | CONST_CS); #ifdef LATT_REFERRAL REGISTER_LONG_CONSTANT("LATT_REFERRAL", LATT_REFERRAL, CONST_PERSISTENT | CONST_CS); #endif #ifdef LATT_HASCHILDREN REGISTER_LONG_CONSTANT("LATT_HASCHILDREN", LATT_HASCHILDREN, CONST_PERSISTENT | CONST_CS); #endif #ifdef LATT_HASNOCHILDREN REGISTER_LONG_CONSTANT("LATT_HASNOCHILDREN", LATT_HASNOCHILDREN, CONST_PERSISTENT | CONST_CS); #endif /* Sort functions */ REGISTER_LONG_CONSTANT("SORTDATE", SORTDATE , CONST_PERSISTENT | CONST_CS); /* date */ REGISTER_LONG_CONSTANT("SORTARRIVAL", SORTARRIVAL , CONST_PERSISTENT | CONST_CS); /* arrival date */ REGISTER_LONG_CONSTANT("SORTFROM", SORTFROM , CONST_PERSISTENT | CONST_CS); /* from */ REGISTER_LONG_CONSTANT("SORTSUBJECT", SORTSUBJECT , CONST_PERSISTENT | CONST_CS); /* subject */ REGISTER_LONG_CONSTANT("SORTTO", SORTTO , CONST_PERSISTENT | CONST_CS); /* to */ REGISTER_LONG_CONSTANT("SORTCC", SORTCC , CONST_PERSISTENT | CONST_CS); /* cc */ REGISTER_LONG_CONSTANT("SORTSIZE", SORTSIZE , CONST_PERSISTENT | CONST_CS); /* size */ REGISTER_LONG_CONSTANT("TYPETEXT", TYPETEXT , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEMULTIPART", TYPEMULTIPART , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEMESSAGE", TYPEMESSAGE , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEAPPLICATION", TYPEAPPLICATION , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEAUDIO", TYPEAUDIO , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEIMAGE", TYPEIMAGE , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEVIDEO", TYPEVIDEO , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEMODEL", TYPEMODEL , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("TYPEOTHER", TYPEOTHER , CONST_PERSISTENT | CONST_CS); /* TYPETEXT unformatted text TYPEMULTIPART multiple part TYPEMESSAGE encapsulated message TYPEAPPLICATION application data TYPEAUDIO audio TYPEIMAGE static image (GIF, JPEG, etc.) TYPEVIDEO video TYPEMODEL model TYPEOTHER unknown */ REGISTER_LONG_CONSTANT("ENC7BIT", ENC7BIT , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("ENC8BIT", ENC8BIT , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("ENCBINARY", ENCBINARY , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("ENCBASE64", ENCBASE64, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("ENCQUOTEDPRINTABLE", ENCQUOTEDPRINTABLE , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("ENCOTHER", ENCOTHER , CONST_PERSISTENT | CONST_CS); /* ENC7BIT 7 bit SMTP semantic data ENC8BIT 8 bit SMTP semantic data ENCBINARY 8 bit binary data ENCBASE64 base-64 encoded data ENCQUOTEDPRINTABLE human-readable 8-as-7 bit data ENCOTHER unknown */ REGISTER_LONG_CONSTANT("IMAP_GC_ELT", GC_ELT , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("IMAP_GC_ENV", GC_ENV , CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("IMAP_GC_TEXTS", GC_TEXTS , CONST_PERSISTENT | CONST_CS); /* GC_ELT message cache elements GC_ENV ENVELOPEs and BODYs GC_TEXTS texts */ le_imap = zend_register_list_destructors_ex(mail_close_it, NULL, "imap", module_number); return SUCCESS;] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [pci_lintr_deassert(struct pci_vdev *dev) { assert(dev->lintr.pin > 0); pthread_mutex_lock(&dev->lintr.lock); if (dev->lintr.state == ASSERTED) { dev->lintr.state = IDLE; pci_irq_deassert(dev); } else if (dev->lintr.state == PENDING) dev->lintr.state = IDLE; pthread_mutex_unlock(&dev->lintr.lock); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [mrb_mod_include_p(mrb_state *mrb, mrb_value mod) { mrb_value mod2; struct RClass *c = mrb_class_ptr(mod); mrb_get_args(mrb, "C", &mod2); mrb_check_type(mrb, mod2, MRB_TT_MODULE); while (c) { if (c->tt == MRB_TT_ICLASS) { if (c->c == mrb_class_ptr(mod2)) return mrb_true_value(); } c = c->super; } return mrb_false_value(); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static PHP_FUNCTION(xmlwriter_text) { php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteString, NULL); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ClientHttpRequest::mRangeCLen() { int64_t clen = 0; MemBuf mb; assert(memObject()); mb.init(); HttpHdrRange::iterator pos = request->range->begin(); while (pos != request->range->end()) { /* account for headers for this range */ mb.reset(); clientPackRangeHdr(&storeEntry()->mem().freshestReply(), *pos, range_iter.boundary, &mb); clen += mb.size; /* account for range content */ clen += (*pos)->length; debugs(33, 6, "clientMRangeCLen: (clen += " << mb.size << " + " << (*pos)->length << ") == " << clen); ++pos; } /* account for the terminating boundary */ mb.reset(); clientPackTermBound(range_iter.boundary, &mb); clen += mb.size; mb.clean(); return clen; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs, size_t len, const cdf_header_t *h, cdf_secid_t id) { size_t ss = CDF_SHORT_SEC_SIZE(h); size_t pos = CDF_SHORT_SEC_POS(h, id); assert(ss == len); if (sst->sst_len < (size_t)id) { DPRINTF(("bad sector id %d > %d\n", id, sst->sst_len)); return -1; } (void)memcpy(((char *)buf) + offs, ((const char *)sst->sst_tab) + pos, len); return len; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) { struct grub_ext2_data *data = node->data; struct grub_ext2_inode *inode = &node->inode; int blknr = -1; unsigned int blksz = EXT2_BLOCK_SIZE (data); int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data); if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG) { #ifndef _MSC_VER char buf[EXT2_BLOCK_SIZE (data)]; #else char * buf = grub_malloc (EXT2_BLOCK_SIZE(data)); #endif struct grub_ext4_extent_header *leaf; struct grub_ext4_extent *ext; int i; leaf = grub_ext4_find_leaf (data, buf, (struct grub_ext4_extent_header *) inode->blocks.dir_blocks, fileblock); if (! leaf) { grub_error (GRUB_ERR_BAD_FS, "invalid extent"); return -1; } ext = (struct grub_ext4_extent *) (leaf + 1); for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++) { if (fileblock < grub_le_to_cpu32 (ext[i].block)) break; } if (--i >= 0) { fileblock -= grub_le_to_cpu32 (ext[i].block); if (fileblock >= grub_le_to_cpu16 (ext[i].len)) return 0; else { grub_disk_addr_t start; start = grub_le_to_cpu16 (ext[i].start_hi); start = (start << 32) + grub_le_to_cpu32 (ext[i].start); return fileblock + start; } } else { grub_error (GRUB_ERR_BAD_FS, "something wrong with extent"); return -1; } } /* Direct blocks. */ if (fileblock < INDIRECT_BLOCKS) blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]); /* Indirect. */ else if (fileblock < INDIRECT_BLOCKS + blksz / 4) { grub_uint32_t *indir; indir = grub_malloc (blksz); if (! indir) return grub_errno; if (grub_disk_read (data->disk, ((grub_disk_addr_t) grub_le_to_cpu32 (inode->blocks.indir_block)) << log2_blksz, 0, blksz, indir)) return grub_errno; blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]); grub_free (indir); } /* Double indirect. */ else if (fileblock < (grub_disk_addr_t)(INDIRECT_BLOCKS + blksz / 4) \ * (grub_disk_addr_t)(blksz / 4 + 1)) { unsigned int perblock = blksz / 4; unsigned int rblock = fileblock - (INDIRECT_BLOCKS + blksz / 4); grub_uint32_t *indir; indir = grub_malloc (blksz); if (! indir) return grub_errno; if (grub_disk_read (data->disk, ((grub_disk_addr_t) grub_le_to_cpu32 (inode->blocks.double_indir_block)) << log2_blksz, 0, blksz, indir)) return grub_errno; if (grub_disk_read (data->disk, ((grub_disk_addr_t) grub_le_to_cpu32 (indir[rblock / perblock])) << log2_blksz, 0, blksz, indir)) return grub_errno; blknr = grub_le_to_cpu32 (indir[rblock % perblock]); grub_free (indir); } /* triple indirect. */ else { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ext2fs doesn't support triple indirect blocks"); } return blknr; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ /* {{{ php_parse_date: Backwards compatibility function */ PHPAPI signed long php_parse_date(char *string, signed long *now) { timelib_time *parsed_time; timelib_error_container *error = NULL; int error2; signed long retval; parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (error->error_count) { timelib_time_dtor(parsed_time); timelib_error_container_dtor(error); return -1; } timelib_error_container_dtor(error); timelib_update_ts(parsed_time, NULL); retval = timelib_date_to_int(parsed_time, &error2); timelib_time_dtor(parsed_time); if (error2) { return -1; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [MagickExport void DestroyModuleList(void) { /* Destroy magick modules. */ LockSemaphoreInfo(module_semaphore); #if defined(MAGICKCORE_MODULES_SUPPORT) if (module_list != (SplayTreeInfo *) NULL) module_list=DestroySplayTree(module_list); #endif UnlockSemaphoreInfo(module_semaphore); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int ioat3_dma_probe(struct ioatdma_device *device, int dca) { struct pci_dev *pdev = device->pdev; int dca_en = system_has_dca_enabled(pdev); struct dma_device *dma; struct dma_chan *c; struct ioat_chan_common *chan; bool is_raid_device = false; int err; device->enumerate_channels = ioat2_enumerate_channels; device->reset_hw = ioat3_reset_hw; device->self_test = ioat3_dma_self_test; device->intr_quirk = ioat3_intr_quirk; dma = &device->common; dma->device_prep_dma_memcpy = ioat2_dma_prep_memcpy_lock; dma->device_issue_pending = ioat2_issue_pending; dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; dma->device_free_chan_resources = ioat2_free_chan_resources; dma_cap_set(DMA_INTERRUPT, dma->cap_mask); dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock; device->cap = readl(device->reg_base + IOAT_DMA_CAP_OFFSET); if (is_xeon_cb32(pdev) || is_bwd_noraid(pdev)) device->cap &= ~(IOAT_CAP_XOR | IOAT_CAP_PQ | IOAT_CAP_RAID16SS); /* dca is incompatible with raid operations */ if (dca_en && (device->cap & (IOAT_CAP_XOR|IOAT_CAP_PQ))) device->cap &= ~(IOAT_CAP_XOR|IOAT_CAP_PQ); if (device->cap & IOAT_CAP_XOR) { is_raid_device = true; dma->max_xor = 8; dma_cap_set(DMA_XOR, dma->cap_mask); dma->device_prep_dma_xor = ioat3_prep_xor; dma_cap_set(DMA_XOR_VAL, dma->cap_mask); dma->device_prep_dma_xor_val = ioat3_prep_xor_val; } if (device->cap & IOAT_CAP_PQ) { is_raid_device = true; dma->device_prep_dma_pq = ioat3_prep_pq; dma->device_prep_dma_pq_val = ioat3_prep_pq_val; dma_cap_set(DMA_PQ, dma->cap_mask); dma_cap_set(DMA_PQ_VAL, dma->cap_mask); if (device->cap & IOAT_CAP_RAID16SS) { dma_set_maxpq(dma, 16, 0); } else { dma_set_maxpq(dma, 8, 0); } if (!(device->cap & IOAT_CAP_XOR)) { dma->device_prep_dma_xor = ioat3_prep_pqxor; dma->device_prep_dma_xor_val = ioat3_prep_pqxor_val; dma_cap_set(DMA_XOR, dma->cap_mask); dma_cap_set(DMA_XOR_VAL, dma->cap_mask); if (device->cap & IOAT_CAP_RAID16SS) { dma->max_xor = 16; } else { dma->max_xor = 8; } } } dma->device_tx_status = ioat3_tx_status; device->cleanup_fn = ioat3_cleanup_event; device->timer_fn = ioat3_timer_event; /* starting with CB3.3 super extended descriptors are supported */ if (device->cap & IOAT_CAP_RAID16SS) { char pool_name[14]; int i; for (i = 0; i < MAX_SED_POOLS; i++) { snprintf(pool_name, 14, "ioat_hw%d_sed", i); /* allocate SED DMA pool */ device->sed_hw_pool[i] = dmam_pool_create(pool_name, &pdev->dev, SED_SIZE * (i + 1), 64, 0); if (!device->sed_hw_pool[i]) return -ENOMEM; } } err = ioat_probe(device); if (err) return err; ioat_set_tcp_copy_break(262144); list_for_each_entry(c, &dma->channels, device_node) { chan = to_chan_common(c); writel(IOAT_DMA_DCA_ANY_CPU, chan->reg_base + IOAT_DCACTRL_OFFSET); } err = ioat_register(device); if (err) return err; ioat_kobject_add(device, &ioat2_ktype); if (dca) device->dca = ioat3_dca_init(pdev, device->reg_base); return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int cloop_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVCloopState *s = bs->opaque; uint32_t offsets_size, max_compressed_block_size = 1, i; int ret; bs->read_only = 1; /* read header */ ret = bdrv_pread(bs->file, 128, &s->block_size, 4); if (ret < 0) { return ret; } s->block_size = be32_to_cpu(s->block_size); ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4); if (ret < 0) { return ret; } s->n_blocks = be32_to_cpu(s->n_blocks); /* read offsets */ offsets_size = s->n_blocks * sizeof(uint64_t); s->offsets = g_malloc(offsets_size); ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size); if (ret < 0) { goto fail; } for(i=0;i<s->n_blocks;i++) { s->offsets[i] = be64_to_cpu(s->offsets[i]); if (i > 0) { uint32_t size = s->offsets[i] - s->offsets[i - 1]; if (size > max_compressed_block_size) { max_compressed_block_size = size; } } } /* initialize zlib engine */ s->compressed_block = g_malloc(max_compressed_block_size + 1); s->uncompressed_block = g_malloc(s->block_size); if (inflateInit(&s->zstream) != Z_OK) { ret = -EINVAL; goto fail; } s->current_block = s->n_blocks; s->sectors_per_block = s->block_size/512; bs->total_sectors = s->n_blocks * s->sectors_per_block; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->offsets); g_free(s->compressed_block); g_free(s->uncompressed_block); return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [isdn_net_getphones(isdn_net_ioctl_phone * phone, char __user *phones) { isdn_net_dev *p = isdn_net_findif(phone->name); int inout = phone->outgoing & 1; int more = 0; int count = 0; isdn_net_phone *n; if (!p) return -ENODEV; inout &= 1; for (n = p->local->phone[inout]; n; n = n->next) { if (more) { put_user(' ', phones++); count++; } if (copy_to_user(phones, n->num, strlen(n->num) + 1)) { return -EFAULT; } phones += strlen(n->num); count += strlen(n->num); more = 1; } put_user(0, phones); count++; return count; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int r_cmd_java_get_all_access_flags_value (const char *cmd) { RList *the_list = NULL; RListIter *iter = NULL; char *str = NULL; switch (*(cmd)) { case 'f': the_list = retrieve_all_field_access_string_and_value (); break; case 'm': the_list = retrieve_all_method_access_string_and_value (); break; case 'c': the_list = retrieve_all_class_access_string_and_value (); break; } if (!the_list) { eprintf ("[-] r_cmd_java: incorrect syntax for the flags calculation.\n"); r_cmd_java_print_cmd_help (JAVA_CMDS+CALC_FLAGS_IDX); return false; } switch (*(cmd)) { case 'f': r_cons_printf ("[=] Fields Access Flags List\n"); break; case 'm': r_cons_printf ("[=] Methods Access Flags List\n"); break; case 'c': r_cons_printf ("[=] Class Access Flags List\n");; break; } r_list_foreach (the_list, iter, str) { r_cons_println (str); } r_list_free (the_list); return true; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [TPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size) { TPM_RC rc = TPM_RC_SUCCESS; UINT32 i; if (rc == TPM_RC_SUCCESS) { rc = UINT32_Unmarshal(&target->count, buffer, size); } if (rc == TPM_RC_SUCCESS) { if (target->count > MAX_TAGGED_POLICIES) { rc = TPM_RC_SIZE; } } for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { rc = TPMS_TAGGED_POLICY_Unmarshal(&target->policies[i], buffer, size); } return rc; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ns__client_tcpconn(isc_nmhandle_t *handle, isc_result_t result, void *arg) { ns_interface_t *ifp = (ns_interface_t *)arg; dns_aclenv_t *env = ns_interfacemgr_getaclenv(ifp->mgr); ns_server_t *sctx = ns_interfacemgr_getserver(ifp->mgr); unsigned int tcpquota; isc_sockaddr_t peeraddr; isc_netaddr_t netaddr; int match; if (result != ISC_R_SUCCESS) { return (result); } if (handle != NULL) { peeraddr = isc_nmhandle_peeraddr(handle); isc_netaddr_fromsockaddr(&netaddr, &peeraddr); if (sctx->blackholeacl != NULL && (dns_acl_match(&netaddr, NULL, sctx->blackholeacl, env, &match, NULL) == ISC_R_SUCCESS) && match > 0) { return (ISC_R_CONNREFUSED); } } tcpquota = isc_quota_getused(&sctx->tcpquota); ns_stats_update_if_greater(sctx->nsstats, ns_statscounter_tcphighwater, tcpquota); return (ISC_R_SUCCESS); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int search_func(_UNUSED_ struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val val, void *state) { struct ldb_context *ldb; struct ldb_kv_context *ac; struct ldb_message *msg, *filtered_msg; int ret; bool matched; ac = talloc_get_type(state, struct ldb_kv_context); ldb = ldb_module_get_ctx(ac->module); /* * We want to skip @ records early in a search full scan * * @ records like @IDXLIST are only available via a base * search on the specific name but the method by which they * were excluded was expensive, after the unpack the DN is * exploded and ldb_match_msg_error() would reject it for * failing to match the scope. * * ldb_kv_key_is_normal_record() uses the fact that @ records * have the DN=@ prefix on their TDB/LMDB key to quickly * exclude them from consideration. * * (any other non-records are also excluded by the same key * match) */ if (ldb_kv_key_is_normal_record(key) == false) { return 0; } msg = ldb_msg_new(ac); if (!msg) { ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } /* unpack the record */ ret = ldb_unpack_data_flags(ldb, &val, msg, LDB_UNPACK_DATA_FLAG_NO_VALUES_ALLOC); if (ret == -1) { talloc_free(msg); ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } if (!msg->dn) { msg->dn = ldb_dn_new(msg, ldb, (char *)key.data + 3); if (msg->dn == NULL) { talloc_free(msg); ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } } /* see if it matches the given expression */ ret = ldb_match_msg_error(ldb, msg, ac->tree, ac->base, ac->scope, &matched); if (ret != LDB_SUCCESS) { talloc_free(msg); ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } if (!matched) { talloc_free(msg); return 0; } filtered_msg = ldb_msg_new(ac); if (filtered_msg == NULL) { TALLOC_FREE(msg); return LDB_ERR_OPERATIONS_ERROR; } filtered_msg->dn = talloc_steal(filtered_msg, msg->dn); /* filter the attributes that the user wants */ ret = ldb_kv_filter_attrs(ldb, msg, ac->attrs, filtered_msg); talloc_free(msg); if (ret == -1) { TALLOC_FREE(filtered_msg); ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } ret = ldb_module_send_entry(ac->req, filtered_msg, NULL); if (ret != LDB_SUCCESS) { ac->request_terminated = true; /* the callback failed, abort the operation */ ac->error = LDB_ERR_OPERATIONS_ERROR; return -1; } return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) { BUF_MEM *b; unsigned char *p; int i; size_t want = HEADER_SIZE; int eos = 0; size_t off = 0; size_t len = 0; const unsigned char *q; long slen; int inf, tag, xclass; b = BUF_MEM_new(); if (b == NULL) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); return -1; } ERR_clear_error(); for (;;) { if (want >= (len - off)) { want -= (len - off); if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } i = BIO_read(in, &(b->data[len]), want); if ((i < 0) && ((len - off) == 0)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_NOT_ENOUGH_DATA); goto err; } if (i > 0) { if (len + i < len) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } len += i; } } /* else data already loaded */ p = (unsigned char *)&(b->data[off]); q = p; inf = ASN1_get_object(&q, &slen, &tag, &xclass, len - off); if (inf & 0x80) { unsigned long e; e = ERR_GET_REASON(ERR_peek_error()); if (e != ASN1_R_TOO_LONG) goto err; else ERR_clear_error(); /* clear error */ } i = q - p; /* header length */ off += i; /* end of data */ if (inf & 1) { /* no data body so go round again */ eos++; if (eos < 0) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_HEADER_TOO_LONG); goto err; } want = HEADER_SIZE; } else if (eos && (slen == 0) && (tag == V_ASN1_EOC)) { /* eos value, so go back and read another header */ eos--; if (eos <= 0) break; else want = HEADER_SIZE; } else { /* suck in slen bytes of data */ want = slen; if (want > (len - off)) { want -= (len - off); if (want > INT_MAX /* BIO_read takes an int length */ || len + want < len) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } if (!BUF_MEM_grow_clean(b, len + want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } while (want > 0) { i = BIO_read(in, &(b->data[len]), want); if (i <= 0) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_NOT_ENOUGH_DATA); goto err; } /* * This can't overflow because |len+want| didn't * overflow. */ len += i; want -= i; } } if (off + slen < off) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } off += slen; if (eos <= 0) { break; } else want = HEADER_SIZE; } } if (off > INT_MAX) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } *pb = b; return off; err: BUF_MEM_free(b); return -1; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int mct_u232_port_probe(struct usb_serial_port *port) { struct mct_u232_private *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; /* Use second interrupt-in endpoint for reading. */ priv->read_urb = port->serial->port[1]->interrupt_in_urb; priv->read_urb->context = port; spin_lock_init(&priv->lock); usb_set_serial_port_data(port, priv); return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int spi_gpio_probe(struct platform_device *pdev) { int status; struct spi_master *master; struct spi_gpio *spi_gpio; struct device *dev = &pdev->dev; struct spi_bitbang *bb; const struct of_device_id *of_id; of_id = of_match_device(spi_gpio_dt_ids, &pdev->dev); master = spi_alloc_master(dev, sizeof(*spi_gpio)); if (!master) return -ENOMEM; status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master); if (status) return status; if (of_id) status = spi_gpio_probe_dt(pdev, master); else status = spi_gpio_probe_pdata(pdev, master); if (status) return status; spi_gpio = spi_master_get_devdata(master); status = spi_gpio_request(dev, spi_gpio); if (status) return status; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL | SPI_CS_HIGH; if (!spi_gpio->mosi) { /* HW configuration without MOSI pin * * No setting SPI_MASTER_NO_RX here - if there is only * a MOSI pin connected the host can still do RX by * changing the direction of the line. */ master->flags = SPI_MASTER_NO_TX; } master->bus_num = pdev->id; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup; bb = &spi_gpio->bitbang; bb->master = master; /* * There is some additional business, apart from driving the CS GPIO * line, that we need to do on selection. This makes the local * callback for chipselect always get called. */ master->flags |= SPI_MASTER_GPIO_SS; bb->chipselect = spi_gpio_chipselect; bb->set_line_direction = spi_gpio_set_direction; if (master->flags & SPI_MASTER_NO_TX) { bb->txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2; bb->txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3; } else { bb->txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0; bb->txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1; bb->txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2; bb->txrx_word[SPI_MODE_3] = spi_gpio_txrx_word_mode3; } bb->setup_transfer = spi_bitbang_setup_transfer; status = spi_bitbang_init(&spi_gpio->bitbang); if (status) return status; return devm_spi_register_master(&pdev->dev, spi_master_get(master)); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [DECODE_JSON(UInt16) { CHECK_TOKEN_BOUNDS; CHECK_PRIMITIVE; size_t tokenSize; char* tokenData; GET_TOKEN(tokenData, tokenSize); UA_UInt64 out = 0; UA_StatusCode s = parseUnsignedInteger(tokenData, tokenSize, &out); *dst = (UA_UInt16)out; if(moveToken) parseCtx->index++; return s; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct proc_dir_entry *pde = seq->private; struct neigh_table *tbl = pde->data; int cpu; for (cpu = *pos; cpu < NR_CPUS; ++cpu) { if (!cpu_possible(cpu)) continue; *pos = cpu+1; return per_cpu_ptr(tbl->stats, cpu); } return NULL; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int snd_seq_device_dev_free(struct snd_device *device) { struct snd_seq_device *dev = device->device_data; put_device(&dev->dev); return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static VirtioNetRscChain *virtio_net_rsc_lookup_chain(VirtIONet *n, NetClientState *nc, uint16_t proto) { VirtioNetRscChain *chain; if ((proto != (uint16_t)ETH_P_IP) && (proto != (uint16_t)ETH_P_IPV6)) { return NULL; } QTAILQ_FOREACH(chain, &n->rsc_chains, next) { if (chain->proto == proto) { return chain; } } chain = g_malloc(sizeof(*chain)); chain->n = n; chain->proto = proto; if (proto == (uint16_t)ETH_P_IP) { chain->max_payload = VIRTIO_NET_MAX_IP4_PAYLOAD; chain->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; } else { chain->max_payload = VIRTIO_NET_MAX_IP6_PAYLOAD; chain->gso_type = VIRTIO_NET_HDR_GSO_TCPV6; } chain->drain_timer = timer_new_ns(QEMU_CLOCK_HOST, virtio_net_rsc_purge, chain); memset(&chain->stat, 0, sizeof(chain->stat)); QTAILQ_INIT(&chain->buffers); QTAILQ_INSERT_TAIL(&n->rsc_chains, chain, next); return chain; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void CLASS adobe_dng_load_raw_nc() { ushort *pixel, *rp; unsigned row, col; pixel = (ushort *) calloc (raw_width * tiff_samples, sizeof *pixel); merror (pixel, "adobe_dng_load_raw_nc()"); for (row=0; row < raw_height; row++) { if (tiff_bps == 16) read_shorts (pixel, raw_width * tiff_samples); else { getbits(-1); for (col=0; col < raw_width * tiff_samples; col++) pixel[col] = getbits(tiff_bps); } for (rp=pixel, col=0; col < raw_width; col++) adobe_copy_pixel (row, col, &rp); } free (pixel); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ssize_t enc_untrusted_send(int sockfd, const void *buf, size_t len, int flags) { return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_sendto, sockfd, buf, len, flags, /*dest_addr=*/nullptr, /*addrlen=*/0); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, List<Item> &fields, List<Item> &all_fields, ORDER *order, bool from_window_spec) { SELECT_LEX *select = thd->lex->current_select; enum_parsing_place context_analysis_place= thd->lex->current_select->context_analysis_place; thd->where="order clause"; const bool for_union = select->master_unit()->is_union() && select == select->master_unit()->fake_select_lex; for (uint number = 1; order; order=order->next, number++) { if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, all_fields, false, true, from_window_spec)) return 1; if ((*order->item)->with_window_func && context_analysis_place != IN_ORDER_BY) { my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; } /* UNION queries cannot be used with an aggregate function in an ORDER BY clause */ if (for_union && (*order->item)->with_sum_func) { my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number); return 1; } if (from_window_spec && (*order->item)->with_sum_func && (*order->item)->type() != Item::SUM_FUNC_ITEM) (*order->item)->split_sum_func(thd, ref_pointer_array, all_fields, SPLIT_SUM_SELECT); } return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) { if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) return; time_for_testing = (time_t)tv_get_number(&argvars[0]); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void tipc_link_set_active(struct tipc_link *l, bool active) { l->active = active; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void vrend_set_viewport_states(struct vrend_context *ctx, uint32_t start_slot, uint32_t num_viewports, const struct pipe_viewport_state *state) { /* convert back to glViewport */ GLint x, y; GLsizei width, height; GLclampd near_val, far_val; bool viewport_is_negative = (state[0].scale[1] < 0) ? true : false; uint i, idx; if (num_viewports > PIPE_MAX_VIEWPORTS || start_slot > (PIPE_MAX_VIEWPORTS - num_viewports)) { vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, num_viewports); return; } for (i = 0; i < num_viewports; i++) { GLfloat abs_s1 = fabsf(state[i].scale[1]); idx = start_slot + i; width = state[i].scale[0] * 2.0f; height = abs_s1 * 2.0f; x = state[i].translate[0] - state[i].scale[0]; y = state[i].translate[1] - state[i].scale[1]; if (!ctx->sub->rs_state.clip_halfz) { near_val = state[i].translate[2] - state[i].scale[2]; far_val = near_val + (state[i].scale[2] * 2.0); } else { near_val = state[i].translate[2]; far_val = state[i].scale[2] + state[i].translate[2]; } if (ctx->sub->vps[idx].cur_x != x || ctx->sub->vps[idx].cur_y != y || ctx->sub->vps[idx].width != width || ctx->sub->vps[idx].height != height || ctx->sub->vps[idx].near_val != near_val || ctx->sub->vps[idx].far_val != far_val || (!(ctx->sub->viewport_state_initialized &= (1 << idx)))) { ctx->sub->vps[idx].cur_x = x; ctx->sub->vps[idx].cur_y = y; ctx->sub->vps[idx].width = width; ctx->sub->vps[idx].height = height; ctx->sub->vps[idx].near_val = near_val; ctx->sub->vps[idx].far_val = far_val; ctx->sub->viewport_state_dirty |= (1 << idx); } if (idx == 0) { if (ctx->sub->viewport_is_negative != viewport_is_negative) ctx->sub->viewport_is_negative = viewport_is_negative; } } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [main(int argc, char *argv[]) { int i, fd, swapped, pkthdrlen, ret, optct, backwards, caplentoobig; struct pcap_file_header pcap_fh; struct pcap_pkthdr pcap_ph; struct pcap_sf_patched_pkthdr pcap_patched_ph; /* Kuznetzov */ char buf[10000]; struct stat statinfo; uint64_t pktcnt; uint32_t readword; int32_t last_sec, last_usec, caplen; optct = optionProcess(&tcpcapinfoOptions, argc, argv); argc -= optct; argv += optct; #ifdef DEBUG if (HAVE_OPT(DBUG)) debug = OPT_VALUE_DBUG; #endif for (i = 0; i < argc; i++) { dbgx(1, "processing: %s\n", argv[i]); if ((fd = open(argv[i], O_RDONLY)) < 0) errx(-1, "Error opening file %s: %s", argv[i], strerror(errno)); if (fstat(fd, &statinfo) < 0) errx(-1, "Error getting file stat info %s: %s", argv[i], strerror(errno)); printf("file size = %"PRIu64" bytes\n", (uint64_t)statinfo.st_size); if ((ret = read(fd, &buf, sizeof(pcap_fh))) != sizeof(pcap_fh)) errx(-1, "File too small. Unable to read pcap_file_header from %s", argv[i]); dbgx(3, "Read %d bytes for file header", ret); swapped = 0; memcpy(&pcap_fh, &buf, sizeof(pcap_fh)); pkthdrlen = 16; /* pcap_pkthdr isn't the actual on-disk format for 64bit systems! */ switch (pcap_fh.magic) { case TCPDUMP_MAGIC: printf("magic = 0x%08"PRIx32" (tcpdump) (%s)\n", pcap_fh.magic, is_not_swapped); break; case SWAPLONG(TCPDUMP_MAGIC): printf("magic = 0x%08"PRIx32" (tcpdump/swapped) (%s)\n", pcap_fh.magic, is_swapped); swapped = 1; break; case KUZNETZOV_TCPDUMP_MAGIC: pkthdrlen = sizeof(pcap_patched_ph); printf("magic = 0x%08"PRIx32" (Kuznetzov) (%s)\n", pcap_fh.magic, is_not_swapped); break; case SWAPLONG(KUZNETZOV_TCPDUMP_MAGIC): pkthdrlen = sizeof(pcap_patched_ph); printf("magic = 0x%08"PRIx32" (Kuznetzov/swapped) (%s)\n", pcap_fh.magic, is_swapped); swapped = 1; break; case FMESQUITA_TCPDUMP_MAGIC: printf("magic = 0x%08"PRIx32" (Fmesquita) (%s)\n", pcap_fh.magic, is_not_swapped); break; case SWAPLONG(FMESQUITA_TCPDUMP_MAGIC): printf("magic = 0x%08"PRIx32" (Fmesquita) (%s)\n", pcap_fh.magic, is_swapped); swapped = 1; break; case NAVTEL_TCPDUMP_MAGIC: printf("magic = 0x%08"PRIx32" (Navtel) (%s)\n", pcap_fh.magic, is_not_swapped); break; case SWAPLONG(NAVTEL_TCPDUMP_MAGIC): printf("magic = 0x%08"PRIx32" (Navtel/swapped) (%s)\n", pcap_fh.magic, is_swapped); swapped = 1; break; case NSEC_TCPDUMP_MAGIC: printf("magic = 0x%08"PRIx32" (Nsec) (%s)\n", pcap_fh.magic, is_not_swapped); break; case SWAPLONG(NSEC_TCPDUMP_MAGIC): printf("magic = 0x%08"PRIx32" (Nsec/swapped) (%s)\n", pcap_fh.magic, is_swapped); swapped = 1; break; default: printf("magic = 0x%08"PRIx32" (unknown)\n", pcap_fh.magic); } if (swapped == 1) { pcap_fh.version_major = SWAPSHORT(pcap_fh.version_major); pcap_fh.version_minor = SWAPSHORT(pcap_fh.version_minor); pcap_fh.thiszone = SWAPLONG(pcap_fh.thiszone); pcap_fh.sigfigs = SWAPLONG(pcap_fh.sigfigs); pcap_fh.snaplen = SWAPLONG(pcap_fh.snaplen); pcap_fh.linktype = SWAPLONG(pcap_fh.linktype); } printf("version = %hu.%hu\n", pcap_fh.version_major, pcap_fh.version_minor); printf("thiszone = 0x%08"PRIx32"\n", pcap_fh.thiszone); printf("sigfigs = 0x%08"PRIx32"\n", pcap_fh.sigfigs); printf("snaplen = %"PRIu32"\n", pcap_fh.snaplen); printf("linktype = 0x%08"PRIx32"\n", pcap_fh.linktype); if (pcap_fh.version_major != 2 && pcap_fh.version_minor != 4) { printf("Sorry, we only support file format version 2.4\n"); close(fd); continue; } dbgx(5, "Packet header len: %d", pkthdrlen); if (pkthdrlen == 24) { printf("Packet\tOrigLen\t\tCaplen\t\tTimestamp\t\tIndex\tProto\tPktType\tPktCsum\tNote\n"); } else { printf("Packet\tOrigLen\t\tCaplen\t\tTimestamp\tCsum\tNote\n"); } pktcnt = 0; last_sec = 0; last_usec = 0; while ((ret = read(fd, &buf, pkthdrlen)) == pkthdrlen) { pktcnt ++; backwards = 0; caplentoobig = 0; dbgx(3, "Read %d bytes for packet %"PRIu64" header", ret, pktcnt); memset(&pcap_ph, 0, sizeof(pcap_ph)); /* see what packet header we're using */ if (pkthdrlen == sizeof(pcap_patched_ph)) { memcpy(&pcap_patched_ph, &buf, sizeof(pcap_patched_ph)); if (swapped == 1) { dbg(3, "Swapping packet header bytes..."); pcap_patched_ph.caplen = SWAPLONG(pcap_patched_ph.caplen); pcap_patched_ph.len = SWAPLONG(pcap_patched_ph.len); pcap_patched_ph.ts.tv_sec = SWAPLONG(pcap_patched_ph.ts.tv_sec); pcap_patched_ph.ts.tv_usec = SWAPLONG(pcap_patched_ph.ts.tv_usec); pcap_patched_ph.index = SWAPLONG(pcap_patched_ph.index); pcap_patched_ph.protocol = SWAPSHORT(pcap_patched_ph.protocol); } printf("%"PRIu64"\t%4"PRIu32"\t\t%4"PRIu32"\t\t%" PRIx32".%"PRIx32"\t\t%4"PRIu32"\t%4hu\t%4hhu", pktcnt, pcap_patched_ph.len, pcap_patched_ph.caplen, pcap_patched_ph.ts.tv_sec, pcap_patched_ph.ts.tv_usec, pcap_patched_ph.index, pcap_patched_ph.protocol, pcap_patched_ph.pkt_type); if (pcap_fh.snaplen < pcap_patched_ph.caplen) { caplentoobig = 1; } caplen = pcap_patched_ph.caplen; } else { /* manually map on-disk bytes to our memory structure */ memcpy(&readword, buf, 4); pcap_ph.ts.tv_sec = readword; memcpy(&readword, &buf[4], 4); pcap_ph.ts.tv_usec = readword; memcpy(&pcap_ph.caplen, &buf[8], 4); memcpy(&pcap_ph.len, &buf[12], 4); if (swapped == 1) { dbg(3, "Swapping packet header bytes..."); pcap_ph.caplen = SWAPLONG(pcap_ph.caplen); pcap_ph.len = SWAPLONG(pcap_ph.len); pcap_ph.ts.tv_sec = SWAPLONG(pcap_ph.ts.tv_sec); pcap_ph.ts.tv_usec = SWAPLONG(pcap_ph.ts.tv_usec); } printf("%"PRIu64"\t%4"PRIu32"\t\t%4"PRIu32"\t\t%" PRIx32".%"PRIx32, pktcnt, pcap_ph.len, pcap_ph.caplen, (unsigned int)pcap_ph.ts.tv_sec, (unsigned int)pcap_ph.ts.tv_usec); if (pcap_fh.snaplen < pcap_ph.caplen) { caplentoobig = 1; } caplen = pcap_ph.caplen; } /* check to make sure timestamps don't go backwards */ if (last_sec > 0 && last_usec > 0) { if ((pcap_ph.ts.tv_sec == last_sec) ? (pcap_ph.ts.tv_usec < last_usec) : (pcap_ph.ts.tv_sec < last_sec)) { backwards = 1; } } if (pkthdrlen == sizeof(pcap_patched_ph)) { last_sec = pcap_patched_ph.ts.tv_sec; last_usec = pcap_patched_ph.ts.tv_usec; } else { last_sec = pcap_ph.ts.tv_sec; last_usec = pcap_ph.ts.tv_usec; } /* read the frame */ if ((ret = read(fd, &buf, caplen)) != caplen) { if (ret < 0) { printf("Error reading file: %s: %s\n", argv[i], strerror(errno)); } else { printf("File truncated! Unable to jump to next packet.\n"); } close(fd); continue; } /* print the frame checksum */ printf("\t%x\t", do_checksum_math((u_int16_t *)buf, caplen)); /* print the Note */ if (! backwards && ! caplentoobig) { printf("OK\n"); } else if (backwards && ! caplentoobig) { printf("BAD_TS\n"); } else if (caplentoobig && ! backwards) { printf("TOOBIG\n"); } else if (backwards && caplentoobig) { printf("BAD_TS|TOOBIG"); } } } exit(0); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [compose_group16_knockout(uint16_t *tos_ptr, bool tos_isolated, int tos_planestride, int tos_rowstride, uint16_t alpha, uint16_t shape, gs_blend_mode_t blend_mode, bool tos_has_shape, int tos_shape_offset, int tos_alpha_g_offset, int tos_tag_offset, bool tos_has_tag, uint16_t *nos_ptr, bool nos_isolated, int nos_planestride, int nos_rowstride, uint16_t *nos_alpha_g_ptr, bool nos_knockout, int nos_shape_offset, int nos_tag_offset, uint16_t *mask_row_ptr, int has_mask, pdf14_buf *maskbuf, uint16_t mask_bg_alpha, const uint16_t *mask_tr_fn, uint16_t *backdrop_ptr, bool has_matte, int n_chan, bool additive, int num_spots, bool overprint, gx_color_index drawn_comps, int x0, int y0, int x1, int y1, const pdf14_nonseparable_blending_procs_t *pblend_procs, pdf14_device *pdev) { template_compose_group16(tos_ptr, tos_isolated, tos_planestride, tos_rowstride, alpha, shape, blend_mode, tos_has_shape, tos_shape_offset, tos_alpha_g_offset, tos_tag_offset, tos_has_tag, nos_ptr, nos_isolated, nos_planestride, nos_rowstride, nos_alpha_g_ptr, /* nos_knockout = */1, nos_shape_offset, nos_tag_offset, mask_row_ptr, has_mask, maskbuf, mask_bg_alpha, mask_tr_fn, backdrop_ptr, has_matte, n_chan, additive, num_spots, overprint, drawn_comps, x0, y0, x1, y1, pblend_procs, pdev, 1, 0); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { struct lg_drv_data *drv_data = hid_get_drvdata(hdev); struct usb_device_descriptor *udesc; __u16 bcdDevice, rev_maj, rev_min; if ((drv_data->quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 && rdesc[84] == 0x8c && rdesc[85] == 0x02) { hid_info(hdev, "fixing up Logitech keyboard report descriptor\n"); rdesc[84] = rdesc[89] = 0x4d; rdesc[85] = rdesc[90] = 0x10; } if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 50 && rdesc[32] == 0x81 && rdesc[33] == 0x06 && rdesc[49] == 0x81 && rdesc[50] == 0x06) { hid_info(hdev, "fixing up rel/abs in Logitech report descriptor\n"); rdesc[33] = rdesc[50] = 0x02; } switch (hdev->product) { /* Several wheels report as this id when operating in emulation mode. */ case USB_DEVICE_ID_LOGITECH_WHEEL: udesc = &(hid_to_usb_dev(hdev)->descriptor); if (!udesc) { hid_err(hdev, "NULL USB device descriptor\n"); break; } bcdDevice = le16_to_cpu(udesc->bcdDevice); rev_maj = bcdDevice >> 8; rev_min = bcdDevice & 0xff; /* Update the report descriptor for only the Driving Force wheel */ if (rev_maj == 1 && rev_min == 2 && *rsize == DF_RDESC_ORIG_SIZE) { hid_info(hdev, "fixing up Logitech Driving Force report descriptor\n"); rdesc = df_rdesc_fixed; *rsize = sizeof(df_rdesc_fixed); } break; case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL: if (*rsize == MOMO_RDESC_ORIG_SIZE) { hid_info(hdev, "fixing up Logitech Momo Force (Red) report descriptor\n"); rdesc = momo_rdesc_fixed; *rsize = sizeof(momo_rdesc_fixed); } break; case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2: if (*rsize == MOMO2_RDESC_ORIG_SIZE) { hid_info(hdev, "fixing up Logitech Momo Racing Force (Black) report descriptor\n"); rdesc = momo2_rdesc_fixed; *rsize = sizeof(momo2_rdesc_fixed); } break; case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL: if (*rsize == FV_RDESC_ORIG_SIZE) { hid_info(hdev, "fixing up Logitech Formula Vibration report descriptor\n"); rdesc = fv_rdesc_fixed; *rsize = sizeof(fv_rdesc_fixed); } break; case USB_DEVICE_ID_LOGITECH_DFP_WHEEL: if (*rsize == DFP_RDESC_ORIG_SIZE) { hid_info(hdev, "fixing up Logitech Driving Force Pro report descriptor\n"); rdesc = dfp_rdesc_fixed; *rsize = sizeof(dfp_rdesc_fixed); } break; case USB_DEVICE_ID_LOGITECH_WII_WHEEL: if (*rsize >= 101 && rdesc[41] == 0x95 && rdesc[42] == 0x0B && rdesc[47] == 0x05 && rdesc[48] == 0x09) { hid_info(hdev, "fixing up Logitech Speed Force Wireless report descriptor\n"); rdesc[41] = 0x05; rdesc[42] = 0x09; rdesc[47] = 0x95; rdesc[48] = 0x0B; } break; } return rdesc; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static long posix_cpu_nsleep_restart(struct restart_block *restart_block) { clockid_t which_clock = restart_block->nanosleep.clockid; struct timespec64 t; t = ns_to_timespec64(restart_block->nanosleep.expires); return do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [JPEGSetupEncode(TIFF* tif) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGSetupEncode"; #if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFInitJPEG) if( tif->tif_dir.td_bitspersample == 12 ) return TIFFReInitJPEG_12( tif, COMPRESSION_JPEG, 1 ); #endif JPEGInitializeLibJPEG( tif, FALSE ); assert(sp != NULL); assert(!sp->cinfo.comm.is_decompressor); sp->photometric = td->td_photometric; /* * Initialize all JPEG parameters to default values. * Note that jpeg_set_defaults needs legal values for * in_color_space and input_components. */ if (td->td_planarconfig == PLANARCONFIG_CONTIG) { sp->cinfo.c.input_components = td->td_samplesperpixel; if (sp->photometric == PHOTOMETRIC_YCBCR) { if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { sp->cinfo.c.in_color_space = JCS_RGB; } else { sp->cinfo.c.in_color_space = JCS_YCbCr; } } else { if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1) sp->cinfo.c.in_color_space = JCS_GRAYSCALE; else if (td->td_photometric == PHOTOMETRIC_RGB && td->td_samplesperpixel == 3) sp->cinfo.c.in_color_space = JCS_RGB; else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4) sp->cinfo.c.in_color_space = JCS_CMYK; else sp->cinfo.c.in_color_space = JCS_UNKNOWN; } } else { sp->cinfo.c.input_components = 1; sp->cinfo.c.in_color_space = JCS_UNKNOWN; } if (!TIFFjpeg_set_defaults(sp)) return (0); /* Set per-file parameters */ switch (sp->photometric) { case PHOTOMETRIC_YCBCR: sp->h_sampling = td->td_ycbcrsubsampling[0]; sp->v_sampling = td->td_ycbcrsubsampling[1]; if( sp->h_sampling == 0 || sp->v_sampling == 0 ) { TIFFErrorExt(tif->tif_clientdata, module, "Invalig horizontal/vertical sampling value"); return (0); } /* * A ReferenceBlackWhite field *must* be present since the * default value is inappropriate for YCbCr. Fill in the * proper value if application didn't set it. */ { float *ref; if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, &ref)) { float refbw[6]; long top = 1L << td->td_bitspersample; refbw[0] = 0; refbw[1] = (float)(top-1L); refbw[2] = (float)(top>>1); refbw[3] = refbw[1]; refbw[4] = refbw[2]; refbw[5] = refbw[1]; TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw); } } break; case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ case PHOTOMETRIC_MASK: TIFFErrorExt(tif->tif_clientdata, module, "PhotometricInterpretation %d not allowed for JPEG", (int) sp->photometric); return (0); default: /* TIFF 6.0 forbids subsampling of all other color spaces */ sp->h_sampling = 1; sp->v_sampling = 1; break; } /* Verify miscellaneous parameters */ /* * This would need work if libtiff ever supports different * depths for different components, or if libjpeg ever supports * run-time selection of depth. Neither is imminent. */ #ifdef JPEG_LIB_MK1 /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */ if (td->td_bitspersample != 8 && td->td_bitspersample != 12) #else if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif { TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", (int) td->td_bitspersample); return (0); } sp->cinfo.c.data_precision = td->td_bitspersample; #ifdef JPEG_LIB_MK1 sp->cinfo.c.bits_in_jsample = td->td_bitspersample; #endif if (isTiled(tif)) { if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, "JPEG tile height must be multiple of %d", sp->v_sampling * DCTSIZE); return (0); } if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, "JPEG tile width must be multiple of %d", sp->h_sampling * DCTSIZE); return (0); } } else { if (td->td_rowsperstrip < td->td_imagelength && (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, "RowsPerStrip must be multiple of %d for JPEG", sp->v_sampling * DCTSIZE); return (0); } } /* Create a JPEGTables field if appropriate */ if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { if( sp->jpegtables == NULL || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) { if (!prepare_JPEGTables(tif)) return (0); /* Mark the field present */ /* Can't use TIFFSetField since BEENWRITING is already set! */ tif->tif_flags |= TIFF_DIRTYDIRECT; TIFFSetFieldBit(tif, FIELD_JPEGTABLES); } } else { /* We do not support application-supplied JPEGTables, */ /* so mark the field not present */ TIFFClrFieldBit(tif, FIELD_JPEGTABLES); } /* Direct libjpeg output to libtiff's output buffer */ TIFFjpeg_data_dest(sp, tif); return (1); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [const Track* Tracks::GetTrackByIndex(uint32_t index) const { if (track_entries_ == NULL) return NULL; if (index >= track_entries_size_) return NULL; return track_entries_[index]; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [get_issuers_num (gnutls_session_t session, uint8_t * data, ssize_t data_size) { int issuers_dn_len = 0, result; unsigned size; /* Count the number of the given issuers; * This is used to allocate the issuers_dn without * using realloc(). */ if (data_size == 0 || data == NULL) return 0; if (data_size > 0) do { /* This works like DECR_LEN() */ result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; DECR_LENGTH_COM (data_size, 2, goto error); size = _gnutls_read_uint16 (data); result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; DECR_LENGTH_COM (data_size, size, goto error); data += 2; if (size > 0) { issuers_dn_len++; data += size; } if (data_size == 0) break; } while (1); return issuers_dn_len; error: return result; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) { struct hlist_head *hashent = ucounts_hashentry(ns, uid); struct ucounts *ucounts, *new; bool wrapped; spin_lock_irq(&ucounts_lock); ucounts = find_ucounts(ns, uid, hashent); if (!ucounts) { spin_unlock_irq(&ucounts_lock); new = kzalloc(sizeof(*new), GFP_KERNEL); if (!new) return NULL; new->ns = ns; new->uid = uid; atomic_set(&new->count, 1); spin_lock_irq(&ucounts_lock); ucounts = find_ucounts(ns, uid, hashent); if (ucounts) { kfree(new); } else { hlist_add_head(&new->node, hashent); spin_unlock_irq(&ucounts_lock); return new; } } wrapped = !get_ucounts_or_wrap(ucounts); spin_unlock_irq(&ucounts_lock); if (wrapped) { put_ucounts(ucounts); return NULL; } return ucounts; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) { struct address_space *swap_space; struct file *swap_storage; struct page *from_page; struct page *to_page; int i; int ret = -ENOMEM; BUG_ON(ttm->state != tt_unbound && ttm->state != tt_unpopulated); BUG_ON(ttm->caching_state != tt_cached); if (!persistent_swap_storage) { swap_storage = shmem_file_setup("ttm swap", ttm->num_pages << PAGE_SHIFT, 0); if (IS_ERR(swap_storage)) { pr_err("Failed allocating swap storage\n"); return PTR_ERR(swap_storage); } } else { swap_storage = persistent_swap_storage; } swap_space = swap_storage->f_mapping; for (i = 0; i < ttm->num_pages; ++i) { gfp_t gfp_mask = mapping_gfp_mask(swap_space); gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0); from_page = ttm->pages[i]; if (unlikely(from_page == NULL)) continue; to_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask); if (IS_ERR(to_page)) { ret = PTR_ERR(to_page); goto out_err; } copy_highpage(to_page, from_page); set_page_dirty(to_page); mark_page_accessed(to_page); put_page(to_page); } ttm_tt_unpopulate(ttm); ttm->swap_storage = swap_storage; ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED; if (persistent_swap_storage) ttm->page_flags |= TTM_PAGE_FLAG_PERSISTENT_SWAP; return 0; out_err: if (!persistent_swap_storage) fput(swap_storage); return ret; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void mspack_fmap_free(void *mem) { free(mem); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int cn_print_exe_file(struct core_name *cn) { struct file *exe_file; char *pathbuf, *path; int ret; exe_file = get_mm_exe_file(current->mm); if (!exe_file) { char *commstart = cn->corename + cn->used; ret = cn_printf(cn, "%s (path unknown)", current->comm); cn_escape(commstart); return ret; } pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); if (!pathbuf) { ret = -ENOMEM; goto put_exe_file; } path = d_path(&exe_file->f_path, pathbuf, PATH_MAX); if (IS_ERR(path)) { ret = PTR_ERR(path); goto free_buf; } cn_escape(path); ret = cn_printf(cn, "%s", path); free_buf: kfree(pathbuf); put_exe_file: fput(exe_file); return ret; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [CBINDInstallDlg::UpdateService(CString StartName) { SC_HANDLE hSCManager; SC_HANDLE hService; if(m_toolsOnly) return; SetCurrent(IDS_OPEN_SCM); hSCManager= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (!hSCManager) { MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage()); return; } DWORD dwStart = SERVICE_DEMAND_START; if (m_autoStart) dwStart = SERVICE_AUTO_START; DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS; CString namedLoc; namedLoc.Format("%s\\bin\\named.exe", m_targetDir); CStringA namedLocA(namedLoc); const char *str = (const char *) namedLocA; char pathBuffer[2 * MAX_PATH]; strncpy(pathBuffer, str, sizeof(pathBuffer) - 1); pathBuffer[sizeof(pathBuffer) - 1] = 0; PathQuoteSpaces(pathBuffer); SetCurrent(IDS_OPEN_SERVICE); hService = OpenService(hSCManager, BIND_SERVICE_NAME, SERVICE_CHANGE_CONFIG); if (!hService) { MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage()); if (hSCManager) CloseServiceHandle(hSCManager); return; } else { if (ChangeServiceConfig(hService, dwServiceType, dwStart, SERVICE_ERROR_NORMAL, pathBuffer, NULL, NULL, NULL, StartName, m_accountPassword, BIND_DISPLAY_NAME) != TRUE) { DWORD err = GetLastError(); MsgBox(IDS_ERR_UPDATE_SERVICE, GetErrMessage()); } } if (hService) CloseServiceHandle(hService); if (hSCManager) CloseServiceHandle(hSCManager); SetItemStatus(IDC_REG_SERVICE); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int SavePackageDescriptionToDebugDump(const char *dump_dir_name) { struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) return 1; char *analyzer = dd_load_text(dd, FILENAME_ANALYZER); if (!strcmp(analyzer, "Kerneloops")) { dd_save_text(dd, FILENAME_PACKAGE, "kernel"); dd_save_text(dd, FILENAME_COMPONENT, "kernel"); dd_close(dd); free(analyzer); return 0; } free(analyzer); char *cmdline = NULL; char *executable = NULL; char *rootdir = NULL; char *package_short_name = NULL; struct pkg_envra *pkg_name = NULL; char *component = NULL; int error = 1; /* note: "goto ret" statements below free all the above variables, * but they don't dd_close(dd) */ cmdline = dd_load_text_ext(dd, FILENAME_CMDLINE, DD_FAIL_QUIETLY_ENOENT); executable = dd_load_text(dd, FILENAME_EXECUTABLE); rootdir = dd_load_text_ext(dd, FILENAME_ROOTDIR, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); /* Close dd while we query package database. It can take some time, * don't want to keep dd locked longer than necessary */ dd_close(dd); if (is_path_blacklisted(executable)) { log("Blacklisted executable '%s'", executable); goto ret; /* return 1 (failure) */ } pkg_name = rpm_get_package_nvr(executable, rootdir); if (!pkg_name) { if (settings_bProcessUnpackaged) { log_info("Crash in unpackaged executable '%s', " "proceeding without packaging information", executable); goto ret0; /* no error */ } log("Executable '%s' doesn't belong to any package" " and ProcessUnpackaged is set to 'no'", executable ); goto ret; /* return 1 (failure) */ } /* Check well-known interpreter names */ const char *basename = strrchr(executable, '/'); if (basename) basename++; else basename = executable; /* if basename is known interpreter, we want to blame the running script * not the interpreter */ if (g_list_find_custom(settings_Interpreters, basename, (GCompareFunc)g_strcmp0)) { struct pkg_envra *script_pkg = get_script_name(cmdline, &executable); /* executable may have changed, check it again */ if (is_path_blacklisted(executable)) { log("Blacklisted executable '%s'", executable); goto ret; /* return 1 (failure) */ } if (!script_pkg) { /* Script name is not absolute, or it doesn't * belong to any installed package. */ if (!settings_bProcessUnpackaged) { log("Interpreter crashed, but no packaged script detected: '%s'", cmdline); goto ret; /* return 1 (failure) */ } /* Unpackaged script, but the settings says we want to keep it. * BZ plugin wont allow to report this anyway, because component * is missing, so there is no reason to mark it as not_reportable. * Someone might want to use abrt to report it using ftp. */ goto ret0; } free_pkg_envra(pkg_name); pkg_name = script_pkg; } package_short_name = xasprintf("%s", pkg_name->p_name); log_info("Package:'%s' short:'%s'", pkg_name->p_nvr, package_short_name); if (g_list_find_custom(settings_setBlackListedPkgs, package_short_name, (GCompareFunc)g_strcmp0)) { log("Blacklisted package '%s'", package_short_name); goto ret; /* return 1 (failure) */ } if (settings_bOpenGPGCheck) { if (!rpm_chk_fingerprint(package_short_name)) { log("Package '%s' isn't signed with proper key", package_short_name); goto ret; /* return 1 (failure) */ } /* We used to also check the integrity of the executable here: * if (!CheckHash(package_short_name.c_str(), executable)) BOOM(); * Checking the MD5 sum requires to run prelink to "un-prelink" the * binaries - this is considered potential security risk so we don't * do it now, until we find some non-intrusive way. */ } component = rpm_get_component(executable, rootdir); dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) goto ret; /* return 1 (failure) */ if (pkg_name) { dd_save_text(dd, FILENAME_PACKAGE, pkg_name->p_nvr); dd_save_text(dd, FILENAME_PKG_EPOCH, pkg_name->p_epoch); dd_save_text(dd, FILENAME_PKG_NAME, pkg_name->p_name); dd_save_text(dd, FILENAME_PKG_VERSION, pkg_name->p_version); dd_save_text(dd, FILENAME_PKG_RELEASE, pkg_name->p_release); dd_save_text(dd, FILENAME_PKG_ARCH, pkg_name->p_arch); } if (component) dd_save_text(dd, FILENAME_COMPONENT, component); dd_close(dd); ret0: error = 0; ret: free(cmdline); free(executable); free(rootdir); free(package_short_name); free_pkg_envra(pkg_name); free(component); return error; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void msf2_dma_tx(MSF2EmacState *s) { NetClientState *nc = qemu_get_queue(s->nic); hwaddr desc = s->regs[R_DMA_TX_DESC]; uint8_t buf[MAX_PKT_SIZE]; EmacDesc d; int size; uint8_t pktcnt; uint32_t status; if (!(s->regs[R_CFG1] & R_CFG1_TX_EN_MASK)) { return; } while (1) { emac_load_desc(s, &d, desc); if (d.pktsize & EMPTY_MASK) { break; } size = d.pktsize & PKT_SIZE; address_space_read(&s->dma_as, d.pktaddr, MEMTXATTRS_UNSPECIFIED, buf, size); /* * This is very basic way to send packets. Ideally there should be * a FIFO and packets should be sent out from FIFO only when * R_CFG1 bit 0 is set. */ if (s->regs[R_CFG1] & R_CFG1_LB_EN_MASK) { nc->info->receive(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } d.pktsize |= EMPTY_MASK; emac_store_desc(s, &d, desc); /* update sent packets count */ status = s->regs[R_DMA_TX_STATUS]; pktcnt = FIELD_EX32(status, DMA_TX_STATUS, PKTCNT); pktcnt++; s->regs[R_DMA_TX_STATUS] = FIELD_DP32(status, DMA_TX_STATUS, PKTCNT, pktcnt); s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_PKT_SENT_MASK; desc = d.next; } s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_UNDERRUN_MASK; s->regs[R_DMA_TX_CTL] &= ~R_DMA_TX_CTL_EN_MASK; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ ~my_var_user() { }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [readconf_readname(uschar *name, int len, uschar *s) { int p = 0; while (isspace(*s)) s++; if (isalpha(*s)) { while (isalnum(*s) || *s == '_') { if (p < len-1) name[p++] = *s; s++; } } name[p] = 0; while (isspace(*s)) s++; return s; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static inline void setup_pegasus_II(pegasus_t *pegasus) { __u8 data = 0xa5; set_register(pegasus, Reg1d, 0); set_register(pegasus, Reg7b, 1); mdelay(100); if ((pegasus->features & HAS_HOME_PNA) && mii_mode) set_register(pegasus, Reg7b, 0); else set_register(pegasus, Reg7b, 2); set_register(pegasus, 0x83, data); get_registers(pegasus, 0x83, 1, &data); if (data == 0xa5) pegasus->chip = 0x8513; else pegasus->chip = 0; set_register(pegasus, 0x80, 0xc0); set_register(pegasus, 0x83, 0xff); set_register(pegasus, 0x84, 0x01); if (pegasus->features & HAS_HOME_PNA && mii_mode) set_register(pegasus, Reg81, 6); else set_register(pegasus, Reg81, 2); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int decorated_text_output(gx_device_txtwrite_t *tdev) { int i; text_list_entry_t * x_entry, *next_x; char TextBuffer[512], Escaped[32]; float xpos; page_text_list_t *y_list; #ifdef TRACE_TXTWRITE text_list_entry_t *debug_x; #endif if (tdev->TextFormat == 0) { gp_fwrite("<page>\n", sizeof(unsigned char), 7, tdev->file); x_entry = tdev->PageData.unsorted_text_list; while (x_entry) { next_x = x_entry->next; gs_sprintf(TextBuffer, "<span bbox=\"%0.0f %0.0f %0.0f %0.0f\" font=\"%s\" size=\"%0.4f\">\n", x_entry->start.x, x_entry->start.y, x_entry->end.x, x_entry->end.y, x_entry->FontName,x_entry->size); gp_fwrite(TextBuffer, 1, strlen(TextBuffer), tdev->file); xpos = x_entry->start.x; for (i=0;i<x_entry->Unicode_Text_Size;i++) { escaped_Unicode(x_entry->Unicode_Text[i], (char *)&Escaped); gs_sprintf(TextBuffer, "<char bbox=\"%0.0f %0.0f %0.0f %0.0f\" c=\"%s\"/>\n", xpos, x_entry->start.y, xpos + x_entry->Widths[i], x_entry->end.y, Escaped); gp_fwrite(TextBuffer, 1, strlen(TextBuffer), tdev->file); xpos += x_entry->Widths[i]; } gp_fwrite("</span>\n", sizeof(unsigned char), 8, tdev->file); x_entry = next_x; } gp_fwrite("</page>\n", sizeof(unsigned char), 8, tdev->file); } else { merge_vertically(tdev); merge_horizontally(tdev); y_list = tdev->PageData.y_ordered_list; gp_fwrite("<page>\n", sizeof(unsigned char), 7, tdev->file); /* Walk the list looking for 'blocks' */ do { page_text_list_t *temp; page_text_t block; page_text_list_t *block_line; float BBox[4]; memset(&block, 0x00, sizeof(page_text_t)); memset(BBox, 0x00, sizeof(float) * 4); while (y_list) { if (block.y_ordered_list) { text_list_entry_t *x_entry = y_list->x_ordered_list; block_line = block.y_ordered_list; while (x_entry) { if (x_entry->start.x > BBox[2] || x_entry->end.x < BBox[0] || x_entry->start.y > (BBox[1] + (BBox[3] - BBox[1]))) { ; } else { block_line->next = (page_text_list_t *)gs_malloc(tdev->memory->stable_memory, 1, sizeof(page_text_list_t), "txtwrite alloc Y-list"); memset(block_line->next, 0x00, sizeof(page_text_list_t)); block_line = block_line->next; block_line->x_ordered_list = x_entry; if(x_entry->next) x_entry->next->previous = x_entry->previous; if (x_entry->previous) x_entry->previous->next = x_entry->next; else { if (x_entry->next == 0x00) { /* remove Y entry */ temp = y_list->next; if (y_list->previous) y_list->previous->next = y_list->next; if (y_list->next) y_list->next->previous = y_list->previous; else { if (y_list->previous == 0x00) { tdev->PageData.y_ordered_list = 0x00; } } gs_free(tdev->memory, y_list, 1, sizeof(page_text_list_t), "txtwrite free text list"); if (tdev->PageData.y_ordered_list == y_list) tdev->PageData.y_ordered_list = temp; y_list = temp; x_entry = x_entry->next; continue; } } if (block_line->x_ordered_list->start.x < BBox[0]) BBox[0] = block_line->x_ordered_list->start.x; if (block_line->x_ordered_list->start.y < BBox[1]) BBox[1] = block_line->x_ordered_list->start.y; if (block_line->x_ordered_list->end.x < BBox[2]) BBox[2] = block_line->x_ordered_list->end.x; if (block_line->x_ordered_list->end.y + block_line->x_ordered_list->FontBBox_topright.y < BBox[3]) BBox[3] = block_line->x_ordered_list->end.y + block_line->x_ordered_list->FontBBox_topright.y; } x_entry = x_entry->next; } } else { block.y_ordered_list = block_line = (page_text_list_t *)gs_malloc(tdev->memory->stable_memory, 1, sizeof(page_text_list_t), "txtwrite alloc Y-list"); memset(block_line, 0x00, sizeof(page_text_list_t)); block_line->x_ordered_list = y_list->x_ordered_list; y_list->x_ordered_list = y_list->x_ordered_list->next; if (y_list->x_ordered_list == 0x00) { temp = y_list->next; if (y_list->previous) y_list->previous->next = y_list->next; if (y_list->next) y_list->next->previous = y_list->previous; else { if (y_list->previous == 0x00) { tdev->PageData.y_ordered_list = 0x00; } } gs_free(tdev->memory, y_list, 1, sizeof(page_text_list_t), "txtwrite free text list"); if (tdev->PageData.y_ordered_list == y_list) tdev->PageData.y_ordered_list = temp; y_list = temp; continue; } block_line->x_ordered_list->next = block_line->x_ordered_list->previous = 0x00; BBox[0] = block_line->x_ordered_list->start.x; BBox[1] = block_line->x_ordered_list->start.y; BBox[2] = block_line->x_ordered_list->end.x; BBox[3] = block_line->x_ordered_list->end.y + block_line->x_ordered_list->FontBBox_topright.y; } if (y_list) y_list = y_list->next; } /* FIXME - need to free the used memory in here */ gp_fwrite("<block>\n", sizeof(unsigned char), 8, tdev->file); block_line = block.y_ordered_list; while (block_line) { gp_fwrite("<line>\n", sizeof(unsigned char), 7, tdev->file); x_entry = block_line->x_ordered_list; while(x_entry) { gs_sprintf(TextBuffer, "<span bbox=\"%0.0f %0.0f %0.0f %0.0f\" font=\"%s\" size=\"%0.4f\">\n", x_entry->start.x, x_entry->start.y, x_entry->end.x, x_entry->end.y, x_entry->FontName,x_entry->size); gp_fwrite(TextBuffer, 1, strlen(TextBuffer), tdev->file); xpos = x_entry->start.x; for (i=0;i<x_entry->Unicode_Text_Size;i++) { escaped_Unicode(x_entry->Unicode_Text[i], (char *)&Escaped); gs_sprintf(TextBuffer, "<char bbox=\"%0.0f %0.0f %0.0f %0.0f\" c=\"%s\"/>\n", xpos, x_entry->start.y, xpos + x_entry->Widths[i], x_entry->end.y, Escaped); gp_fwrite(TextBuffer, 1, strlen(TextBuffer), tdev->file); xpos += x_entry->Widths[i]; } gp_fwrite("</span>\n", sizeof(unsigned char), 8, tdev->file); x_entry = x_entry->next; } gp_fwrite("</line>\n", sizeof(unsigned char), 8, tdev->file); block_line = block_line->next; } gp_fwrite("</block>\n", sizeof(unsigned char), 9, tdev->file); y_list = tdev->PageData.y_ordered_list; } while (y_list); gp_fwrite("</page>\n", sizeof(unsigned char), 8, tdev->file); } return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) { struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); int ret; if (level != SOL_PACKET) return -ENOPROTOOPT; switch (optname) { case PACKET_ADD_MEMBERSHIP: case PACKET_DROP_MEMBERSHIP: { struct packet_mreq_max mreq; int len = optlen; memset(&mreq, 0, sizeof(mreq)); if (len < sizeof(struct packet_mreq)) return -EINVAL; if (len > sizeof(mreq)) len = sizeof(mreq); if (copy_from_user(&mreq, optval, len)) return -EFAULT; if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address))) return -EINVAL; if (optname == PACKET_ADD_MEMBERSHIP) ret = packet_mc_add(sk, &mreq); else ret = packet_mc_drop(sk, &mreq); return ret; } case PACKET_RX_RING: case PACKET_TX_RING: { union tpacket_req_u req_u; int len; switch (po->tp_version) { case TPACKET_V1: case TPACKET_V2: len = sizeof(req_u.req); break; case TPACKET_V3: default: len = sizeof(req_u.req3); break; } if (optlen < len) return -EINVAL; if (copy_from_user(&req_u.req, optval, len)) return -EFAULT; return packet_set_ring(sk, &req_u, 0, optname == PACKET_TX_RING); } case PACKET_COPY_THRESH: { int val; if (optlen != sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; pkt_sk(sk)->copy_thresh = val; return 0; } case PACKET_VERSION: { int val; if (optlen != sizeof(val)) return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; switch (val) { case TPACKET_V1: case TPACKET_V2: case TPACKET_V3: po->tp_version = val; return 0; default: return -EINVAL; } } case PACKET_RESERVE: { unsigned int val; if (optlen != sizeof(val)) return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->tp_reserve = val; return 0; } case PACKET_LOSS: { unsigned int val; if (optlen != sizeof(val)) return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->tp_loss = !!val; return 0; } case PACKET_AUXDATA: { int val; if (optlen < sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->auxdata = !!val; return 0; } case PACKET_ORIGDEV: { int val; if (optlen < sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->origdev = !!val; return 0; } case PACKET_VNET_HDR: { int val; if (sock->type != SOCK_RAW) return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY; if (optlen < sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->has_vnet_hdr = !!val; return 0; } case PACKET_TIMESTAMP: { int val; if (optlen != sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->tp_tstamp = val; return 0; } case PACKET_FANOUT: { int val; if (optlen != sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; return fanout_add(sk, val & 0xffff, val >> 16); } case PACKET_FANOUT_DATA: { if (!po->fanout) return -EINVAL; return fanout_set_data(po, optval, optlen); } case PACKET_TX_HAS_OFF: { unsigned int val; if (optlen != sizeof(val)) return -EINVAL; if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) return -EBUSY; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->tp_tx_has_off = !!val; return 0; } case PACKET_QDISC_BYPASS: { int val; if (optlen != sizeof(val)) return -EINVAL; if (copy_from_user(&val, optval, sizeof(val))) return -EFAULT; po->xmit = val ? packet_direct_xmit : dev_queue_xmit; return 0; } default: return -ENOPROTOOPT; } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int multiSelectValues( Parse *pParse, /* Parsing context */ Select *p, /* The right-most of SELECTs to be coded */ SelectDest *pDest /* What to do with query results */ ){ int nRow = 1; int rc = 0; int bShowAll = p->pLimit==0; assert( p->selFlags & SF_MultiValue ); do{ assert( p->selFlags & SF_Values ); assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr ); if( p->pWin ) return -1; if( p->pPrior==0 ) break; assert( p->pPrior->pNext==p ); p = p->pPrior; nRow += bShowAll; }while(1); ExplainQueryPlan((pParse, 0, "SCAN %d CONSTANT ROW%s", nRow, nRow==1 ? "" : "S")); while( p ){ selectInnerLoop(pParse, p, -1, 0, 0, pDest, 1, 1); if( !bShowAll ) break; p->nSelectRow = nRow; p = p->pNext; } return rc; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ArgParser::argOiMinArea(char* parameter) { o.oi_min_area = QUtil::string_to_int(parameter); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int picolcd_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *raw_data, int size) { struct picolcd_data *data = hid_get_drvdata(hdev); unsigned long flags; int ret = 0; if (!data) return 1; if (report->id == REPORT_KEY_STATE) { if (data->input_keys) ret = picolcd_raw_keypad(data, report, raw_data+1, size-1); } else if (report->id == REPORT_IR_DATA) { ret = picolcd_raw_cir(data, report, raw_data+1, size-1); } else { spin_lock_irqsave(&data->lock, flags); /* * We let the caller of picolcd_send_and_wait() check if the * report we got is one of the expected ones or not. */ if (data->pending) { memcpy(data->pending->raw_data, raw_data+1, size-1); data->pending->raw_size = size-1; data->pending->in_report = report; complete(&data->pending->ready); } spin_unlock_irqrestore(&data->lock, flags); } picolcd_debug_raw_event(data, hdev, report, raw_data, size); return 1; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [pci_bus_configured(int bus) { assert(bus >= 0 && bus < MAXBUSES); return (pci_businfo[bus] != NULL); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static s32 gf_media_vvc_read_vps_bs_internal(GF_BitStream *bs, VVCState *vvc, Bool stop_at_vps_ext) { u32 i, j; s32 vps_id; VVC_VPS *vps; Bool vps_default_ptl_dpb_hrd_max_tid_flag=0; //nalu header already parsed vps_id = gf_bs_read_int_log(bs, 4, "vps_id"); if (vps_id >= 16) return -1; if (!vps_id) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] VPS ID 0 is forbidden\n")); return -1; } vps = &vvc->vps[vps_id]; if (!vps->state) { vps->id = vps_id; vps->state = 1; } vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers"); if (vps->max_layers > MAX_LHVC_LAYERS) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS)); return -1; } vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1; if ((vps->max_layers>1) && (vps->max_sub_layers>1)) vps_default_ptl_dpb_hrd_max_tid_flag = gf_bs_read_int_log(bs, 1, "vps_default_ptl_dpb_hrd_max_tid_flag"); if (vps->max_layers>1) vps->all_layers_independent = gf_bs_read_int_log(bs, 1, "all_layers_independent"); for (i=0; i<vps->max_layers; i++) { u32 layer_id = gf_bs_read_int_log_idx(bs, 6, "layer_id", i); if (layer_id>vps->max_layer_id) vps->max_layer_id = layer_id; if (i && !vps->all_layers_independent) { Bool layer_indep = gf_bs_read_int_log_idx(bs, 1, "layer_independent", i); if (!layer_indep) { Bool vps_max_tid_ref_present_flag = gf_bs_read_int_log_idx(bs, 1, "vps_max_tid_ref_present_flag", i); for (j=0; j<i; j++) { Bool vps_direct_ref_layer_flag = gf_bs_read_int_log_idx2(bs, 1, "vps_direct_ref_layer_flag", i, j); if (vps_max_tid_ref_present_flag && vps_direct_ref_layer_flag) { gf_bs_read_int_log_idx2(bs, 3, "vps_max_tid_il_ref_pics_plus1", i, j); } } } } } vps->num_ptl = 1; if (vps->max_layers > 1) { if (vps->all_layers_independent) { vps->each_layer_is_ols = gf_bs_read_int_log(bs, 1, "each_layer_is_ols"); } if (!vps->each_layer_is_ols) { u32 vps_ols_mode_idc = 2; if (!vps->all_layers_independent) { vps_ols_mode_idc = gf_bs_read_int_log(bs, 2, "vps_ols_mode_idc"); } if (vps_ols_mode_idc==2) { u8 vps_num_output_layer_sets = 2 + gf_bs_read_int_log(bs, 8, "vps_num_output_layer_sets_minus2"); for (i=0; i<vps_num_output_layer_sets; i++) { for (j=0; j<vps->max_layers; j++) { gf_bs_read_int_log_idx2(bs, 1, "vps_ols_output_layer_flag", i, j); } } } } vps->num_ptl = 1 + gf_bs_read_int_log(bs, 8, "num_ptl_minus1"); } vps->ptl[0].pt_present = 1; for (i=0; i<vps->num_ptl; i++) { if (i) vps->ptl[i].pt_present = gf_bs_read_int_log_idx(bs, 1, "pt_present", i); if (!vps_default_ptl_dpb_hrd_max_tid_flag) vps->ptl[i].ptl_max_tid = gf_bs_read_int_log_idx(bs, 3, "ptl_max_tid", i); else vps->ptl[i].ptl_max_tid = vps->max_sub_layers - 1;; } //align gf_bs_align(bs); for (i=0; i<vps->num_ptl; i++) { vvc_profile_tier_level(bs, &vps->ptl[i], i); } //TODO, parse multilayer stuff return vps_id; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [u64 gf_isom_segment_get_fragment_size(GF_ISOFile *file, u32 moof_index, u32 *moof_size) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!file) return 0; u32 moof_sn=0; Bool moof_after_mdat = GF_FALSE; u64 size=0; u32 i, count = gf_list_count(file->TopBoxes); if (moof_size) *moof_size = 0; for (i=0; i<count; i++) { GF_Box *b = gf_list_get(file->TopBoxes, i); size += b->size; if (b->type == GF_ISOM_BOX_TYPE_MOOF) { if (!moof_after_mdat && (moof_sn == moof_index)) return size - b->size; if (moof_size) *moof_size = (u32) b->size; moof_sn++; if (moof_after_mdat && (moof_sn == moof_index)) return size; if (moof_after_mdat) size=0; if ((moof_sn>1) && !moof_after_mdat) size = b->size; } if (b->type == GF_ISOM_BOX_TYPE_MDAT) { if (!moof_sn) moof_after_mdat = GF_TRUE; } } return size; #endif return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [xmlAutomataIsDeterminist(xmlAutomataPtr am) { int ret; if (am == NULL) return(-1); ret = xmlFAComputesDeterminism(am); return(ret); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) { assign_eip_near(ctxt, ctxt->_eip + rel); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void session_init(tls_session_t *ssn) { ssn->ssl = NULL; ssn->into_ssl = ssn->from_ssl = NULL; record_init(&ssn->clean_in); record_init(&ssn->clean_out); record_init(&ssn->dirty_in); record_init(&ssn->dirty_out); memset(&ssn->info, 0, sizeof(ssn->info)); ssn->mtu = 0; ssn->fragment = false; ssn->tls_msg_len = 0; ssn->length_flag = false; ssn->opaque = NULL; ssn->free_opaque = NULL; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [bgp_capability_as4 (struct peer *peer, struct capability_header *hdr) { as_t as4 = stream_getl (BGP_INPUT(peer)); if (BGP_DEBUG (as4, AS4)) zlog_debug ("%s [AS4] about to set cap PEER_CAP_AS4_RCV, got as4 %u", peer->host, as4); SET_FLAG (peer->cap, PEER_CAP_AS4_RCV); return as4; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *value = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (i_zend_is_true(value)) { EX_T(opline->result.u.var).tmp_var = *value; zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_JMP(opline->op2.u.jmp_addr); } if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; ZEND_VM_NEXT_OPCODE(); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [GF_Err iods_box_size(GF_Box *s) { GF_ObjectDescriptorBox *ptr = (GF_ObjectDescriptorBox *)s; ptr->size += gf_odf_desc_size(ptr->descriptor); return GF_OK; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void sc_usage(void) { BIO_printf(bio_err,"usage: s_client args\n"); BIO_printf(bio_err,"\n"); BIO_printf(bio_err," -host host - use -connect instead\n"); BIO_printf(bio_err," -port port - use -connect instead\n"); BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR); BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n"); BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n"); BIO_printf(bio_err," -certform arg - certificate format (PEM or DER) PEM default\n"); BIO_printf(bio_err," -key arg - Private key file to use, in cert file if\n"); BIO_printf(bio_err," not specified but cert file is.\n"); BIO_printf(bio_err," -keyform arg - key format (PEM or DER) PEM default\n"); BIO_printf(bio_err," -pass arg - private key file pass phrase source\n"); BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n"); BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n"); BIO_printf(bio_err," -reconnect - Drop and re-make the connection with the same Session-ID\n"); BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n"); BIO_printf(bio_err," -showcerts - show all certificates in the chain\n"); BIO_printf(bio_err," -debug - extra output\n"); #ifdef WATT32 BIO_printf(bio_err," -wdebug - WATT-32 tcp debugging\n"); #endif BIO_printf(bio_err," -msg - Show protocol messages\n"); BIO_printf(bio_err," -nbio_test - more ssl protocol testing\n"); BIO_printf(bio_err," -state - print the 'ssl' states\n"); #ifdef FIONBIO BIO_printf(bio_err," -nbio - Run with non-blocking IO\n"); #endif BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n"); BIO_printf(bio_err," -quiet - no s_client output\n"); BIO_printf(bio_err," -ign_eof - ignore input eof (default when -quiet)\n"); BIO_printf(bio_err," -no_ign_eof - don't ignore input eof\n"); #ifndef OPENSSL_NO_PSK BIO_printf(bio_err," -psk_identity arg - PSK identity\n"); BIO_printf(bio_err," -psk arg - PSK in hex (without 0x)\n"); # ifndef OPENSSL_NO_JPAKE BIO_printf(bio_err," -jpake arg - JPAKE secret to use\n"); # endif #endif BIO_printf(bio_err," -ssl2 - just use SSLv2\n"); BIO_printf(bio_err," -ssl3 - just use SSLv3\n"); BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n"); BIO_printf(bio_err," -tls1 - just use TLSv1\n"); BIO_printf(bio_err," -dtls1 - just use DTLSv1\n"); BIO_printf(bio_err," -mtu - set the link layer MTU\n"); BIO_printf(bio_err," -no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n"); BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n"); BIO_printf(bio_err," -serverpref - Use server's cipher preferences (only SSLv2)\n"); BIO_printf(bio_err," -cipher - preferred cipher to use, use the 'openssl ciphers'\n"); BIO_printf(bio_err," command to see what is available\n"); BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n"); BIO_printf(bio_err," for those protocols that support it, where\n"); BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n"); BIO_printf(bio_err," only \"smtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n"); BIO_printf(bio_err," are supported.\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); #endif BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err," -sess_out arg - file to write SSL session to\n"); BIO_printf(bio_err," -sess_in arg - file to read SSL session from\n"); #ifndef OPENSSL_NO_TLSEXT BIO_printf(bio_err," -servername host - Set TLS extension servername in ClientHello\n"); BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n"); BIO_printf(bio_err," -status - request certificate status from server\n"); BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n"); # ifndef OPENSSL_NO_NEXTPROTONEG BIO_printf(bio_err," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n"); # endif #endif BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n"); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 addr, u32 *p, u32 cnt, enum mcp_area area) { int err = 0; u32 val; err = readx_poll_timeout_atomic(hw_atl_sem_ram_get, self, val, val == 1U, 10U, 100000U); if (err < 0) goto err_exit; if (ATL_HW_IS_CHIP_FEATURE(self, REVISION_B1)) err = hw_atl_utils_write_b1_mbox(self, addr, p, cnt, area); else err = hw_atl_utils_write_b0_mbox(self, addr, p, cnt); hw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM); if (err < 0) goto err_exit; err = aq_hw_err_from_flags(self); err_exit: return err; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static inline void call_glob_match(const char *name, int len, int from_glob, char *arg, int abpos, int fbpos) { char *use_buf; ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, abpos + len + 2); memcpy(glob.arg_buf + abpos, name, len); abpos += len; glob.arg_buf[abpos] = '\0'; if (fbpos >= 0) { ENSURE_MEMSPACE(glob.filt_buf, char, glob.fbsize, fbpos + len + 2); memcpy(glob.filt_buf + fbpos, name, len); fbpos += len; glob.filt_buf[fbpos] = '\0'; use_buf = glob.filt_buf; } else use_buf = glob.arg_buf; if (from_glob || (arg && len)) { STRUCT_STAT st; int is_dir; if (do_stat(glob.arg_buf, &st) != 0) return; is_dir = S_ISDIR(st.st_mode) != 0; if (arg && !is_dir) return; if (daemon_filter_list.head && check_filter(&daemon_filter_list, FLOG, use_buf, is_dir) < 0) return; } if (arg) { glob.arg_buf[abpos++] = '/'; glob.arg_buf[abpos] = '\0'; if (fbpos >= 0) { glob.filt_buf[fbpos++] = '/'; glob.filt_buf[fbpos] = '\0'; } glob_match(arg, abpos, fbpos); } else { ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, glob.argc + 1); if (!(glob.argv[glob.argc++] = strdup(glob.arg_buf))) out_of_memory("glob_match"); } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align) { unsigned long mask, offset, pfn, start = 0; unsigned long bitmap_maxno, bitmap_no, bitmap_count; struct page *page = NULL; int ret; if (!cma || !cma->count) return NULL; pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma, count, align); if (!count) return NULL; mask = cma_bitmap_aligned_mask(cma, align); offset = cma_bitmap_aligned_offset(cma, align); bitmap_maxno = cma_bitmap_maxno(cma); bitmap_count = cma_bitmap_pages_to_bits(cma, count); for (;;) { mutex_lock(&cma->lock); bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap, bitmap_maxno, start, bitmap_count, mask, offset); if (bitmap_no >= bitmap_maxno) { mutex_unlock(&cma->lock); break; } bitmap_set(cma->bitmap, bitmap_no, bitmap_count); /* * It's safe to drop the lock here. We've marked this region for * our exclusive use. If the migration fails we will take the * lock again and unmark it. */ mutex_unlock(&cma->lock); pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit); mutex_lock(&cma_mutex); ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA); mutex_unlock(&cma_mutex); if (ret == 0) { page = pfn_to_page(pfn); break; } cma_clear_bitmap(cma, pfn, count); if (ret != -EBUSY) break; pr_debug("%s(): memory range at %p is busy, retrying\n", __func__, pfn_to_page(pfn)); /* try again with a bit different memory target */ start = bitmap_no + mask + 1; } trace_cma_alloc(page ? pfn : -1UL, page, count, align); pr_debug("%s(): returned %p\n", __func__, page); return page; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void i8042_stop(struct serio *serio) { struct i8042_port *port = serio->port_data; port->exists = false; /* * We synchronize with both AUX and KBD IRQs because there is * a (very unlikely) chance that AUX IRQ is raised for KBD port * and vice versa. */ synchronize_irq(I8042_AUX_IRQ); synchronize_irq(I8042_KBD_IRQ); port->serio = NULL; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [httpSpecialClientSideHandler(int status, FdEventHandlerPtr event, StreamRequestPtr srequest) { HTTPConnectionPtr connection = srequest->data; HTTPRequestPtr request = connection->request; if(status) { connection->flags &= ~CONN_READER; if (request->chandler) { unregisterConditionHandler(request->chandler); request->chandler = NULL; } do_log(L_ERROR, "Incomplete client request.\n"); httpClientRawError(connection, 502, internAtom("Incomplete client request"), 1); return 1; } connection->reqlen = srequest->offset; return readFinished(connection); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [did_set_string_option( int opt_idx, // index in options[] table char_u **varp, // pointer to the option variable int new_value_alloced, // new value was allocated char_u *oldval, // previous value of the option char *errbuf, // buffer for errors, or NULL int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL int *value_checked) // value was checked to be save, no // need to set P_INSECURE { char *errmsg = NULL; char_u *s, *p; int did_chartab = FALSE; char_u **gvarp; long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED); #ifdef FEAT_GUI // set when changing an option that only requires a redraw in the GUI int redraw_gui_only = FALSE; #endif int value_changed = FALSE; #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) int did_swaptcap = FALSE; #endif // Get the global option to compare with, otherwise we would have to check // two values for all local options. gvarp = (char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL); // Disallow changing some options from secure mode if ((secure #ifdef HAVE_SANDBOX || sandbox != 0 #endif ) && (get_option_flags(opt_idx) & P_SECURE)) errmsg = e_secure; // Check for a "normal" directory or file name in some options. Disallow a // path separator (slash and/or backslash), wildcards and characters that // are often illegal in a file name. Be more permissive if "secure" is off. else if (((get_option_flags(opt_idx) & P_NFNAME) && vim_strpbrk(*varp, (char_u *)(secure ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL) || ((get_option_flags(opt_idx) & P_NDNAME) && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) errmsg = e_invarg; // 'term' else if (varp == &T_NAME) { if (T_NAME[0] == NUL) errmsg = N_("E529: Cannot set 'term' to empty string"); #ifdef FEAT_GUI else if (gui.in_use) errmsg = N_("E530: Cannot change term in GUI"); else if (term_is_gui(T_NAME)) errmsg = N_("E531: Use \":gui\" to start the GUI"); #endif else if (set_termname(T_NAME) == FAIL) errmsg = N_("E522: Not found in termcap"); else { // Screen colors may have changed. redraw_later_clear(); // Both 'term' and 'ttytype' point to T_NAME, only set the // P_ALLOCED flag on 'term'. opt_idx = findoption((char_u *)"term"); free_oldval = (get_option_flags(opt_idx) & P_ALLOCED); } } // 'backupcopy' else if (gvarp == &p_bkc) { char_u *bkc = p_bkc; unsigned int *flags = &bkc_flags; if (opt_flags & OPT_LOCAL) { bkc = curbuf->b_p_bkc; flags = &curbuf->b_bkc_flags; } if ((opt_flags & OPT_LOCAL) && *bkc == NUL) // make the local value empty: use the global value *flags = 0; else { if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK) errmsg = e_invarg; if ((((int)*flags & BKC_AUTO) != 0) + (((int)*flags & BKC_YES) != 0) + (((int)*flags & BKC_NO) != 0) != 1) { // Must have exactly one of "auto", "yes" and "no". (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE); errmsg = e_invarg; } } } // 'backupext' and 'patchmode' else if (varp == &p_bex || varp == &p_pm) { if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, *p_pm == '.' ? p_pm + 1 : p_pm) == 0) errmsg = N_("E589: 'backupext' and 'patchmode' are equal"); } #ifdef FEAT_LINEBREAK // 'breakindentopt' else if (varp == &curwin->w_p_briopt) { if (briopt_check(curwin) == FAIL) errmsg = e_invarg; } #endif // 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] // If the new option is invalid, use old value. 'lisp' option: refill // g_chartab[] for '-' char else if ( varp == &p_isi || varp == &(curbuf->b_p_isk) || varp == &p_isp || varp == &p_isf) { if (init_chartab() == FAIL) { did_chartab = TRUE; // need to restore it below errmsg = e_invarg; // error in value } } // 'helpfile' else if (varp == &p_hf) { // May compute new values for $VIM and $VIMRUNTIME if (didset_vim) { vim_setenv((char_u *)"VIM", (char_u *)""); didset_vim = FALSE; } if (didset_vimruntime) { vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); didset_vimruntime = FALSE; } } #ifdef FEAT_SYN_HL // 'cursorlineopt' else if (varp == &curwin->w_p_culopt || gvarp == &curwin->w_allbuf_opt.wo_culopt) { if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK) errmsg = e_invarg; } // 'colorcolumn' else if (varp == &curwin->w_p_cc) errmsg = check_colorcolumn(curwin); #endif #ifdef FEAT_MULTI_LANG // 'helplang' else if (varp == &p_hlg) { // Check for "", "ab", "ab,cd", etc. for (s = p_hlg; *s != NUL; s += 3) { if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { errmsg = e_invarg; break; } if (s[2] == NUL) break; } } #endif // 'highlight' else if (varp == &p_hl) { if (highlight_changed() == FAIL) errmsg = e_invarg; // invalid flags } // 'nrformats' else if (gvarp == &p_nf) { if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) errmsg = e_invarg; } #ifdef FEAT_SESSION // 'sessionoptions' else if (varp == &p_ssop) { if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) errmsg = e_invarg; if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) { // Don't allow both "sesdir" and "curdir". (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); errmsg = e_invarg; } } // 'viewoptions' else if (varp == &p_vop) { if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) errmsg = e_invarg; } #endif // 'scrollopt' else if (varp == &p_sbo) { if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) errmsg = e_invarg; } // 'ambiwidth' else if (varp == &p_ambw || varp == &p_emoji) { if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) errmsg = e_invarg; else if (set_chars_option(curwin, &p_fcs) != NULL) errmsg = _("E835: Conflicts with value of 'fillchars'"); else { tabpage_T *tp; win_T *wp; FOR_ALL_TAB_WINDOWS(tp, wp) { if (set_chars_option(wp, &wp->w_p_lcs) != NULL) { errmsg = _("E834: Conflicts with value of 'listchars'"); goto ambw_end; } } } ambw_end: {} } // 'background' else if (varp == &p_bg) { if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) { #ifdef FEAT_EVAL int dark = (*p_bg == 'd'); #endif init_highlight(FALSE, FALSE); #ifdef FEAT_EVAL if (dark != (*p_bg == 'd') && get_var_value((char_u *)"g:colors_name") != NULL) { // The color scheme must have set 'background' back to another // value, that's not what we want here. Disable the color // scheme and set the colors again. do_unlet((char_u *)"g:colors_name", TRUE); free_string_option(p_bg); p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); check_string_option(&p_bg); init_highlight(FALSE, FALSE); } #endif #ifdef FEAT_TERMINAL term_update_colors_all(); #endif } else errmsg = e_invarg; } // 'wildmode' else if (varp == &p_wim) { if (check_opt_wim() == FAIL) errmsg = e_invarg; } // 'wildoptions' else if (varp == &p_wop) { if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) errmsg = e_invarg; } #ifdef FEAT_WAK // 'winaltkeys' else if (varp == &p_wak) { if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) errmsg = e_invarg; # ifdef FEAT_MENU # ifdef FEAT_GUI_MOTIF else if (gui.in_use) gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); # else # ifdef FEAT_GUI_GTK else if (gui.in_use) gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); # endif # endif # endif } #endif // 'eventignore' else if (varp == &p_ei) { if (check_ei() == FAIL) errmsg = e_invarg; } // 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc || gvarp == &p_menc) { if (gvarp == &p_fenc) { if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) errmsg = e_cannot_make_changes_modifiable_is_off; else if (vim_strchr(*varp, ',') != NULL) // No comma allowed in 'fileencoding'; catches confusing it // with 'fileencodings'. errmsg = e_invarg; else { #ifdef FEAT_TITLE // May show a "+" in the title now. redraw_titles(); #endif // Add 'fileencoding' to the swap file. ml_setflags(curbuf); } } if (errmsg == NULL) { // canonize the value, so that STRCMP() can be used on it p = enc_canonize(*varp); if (p != NULL) { vim_free(*varp); *varp = p; } if (varp == &p_enc) { errmsg = mb_init(); #ifdef FEAT_TITLE redraw_titles(); #endif } } #if defined(FEAT_GUI_GTK) if (errmsg == NULL && varp == &p_tenc && gui.in_use) { // GTK+ 2 uses only a single encoding, and that is UTF-8. if (STRCMP(p_tenc, "utf-8") != 0) errmsg = N_("E617: Cannot be changed in the GTK+ 2 GUI"); } #endif if (errmsg == NULL) { #ifdef FEAT_KEYMAP // When 'keymap' is used and 'encoding' changes, reload the keymap // (with another encoding). if (varp == &p_enc && *curbuf->b_p_keymap != NUL) (void)keymap_init(); #endif // When 'termencoding' is not empty and 'encoding' changes or when // 'termencoding' changes, need to setup for keyboard input and // display output conversion. if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) { if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL || convert_setup(&output_conv, p_enc, p_tenc) == FAIL) { semsg(_("E950: Cannot convert between %s and %s"), p_tenc, p_enc); errmsg = e_invarg; } } #if defined(MSWIN) // $HOME may have characters in active code page. if (varp == &p_enc) init_homedir(); #endif } } #if defined(FEAT_POSTSCRIPT) else if (varp == &p_penc) { // Canonize printencoding if VIM standard one p = enc_canonize(p_penc); if (p != NULL) { vim_free(p_penc); p_penc = p; } else { // Ensure lower case and '-' for '_' for (s = p_penc; *s != NUL; s++) { if (*s == '_') *s = '-'; else *s = TOLOWER_ASC(*s); } } } #endif #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) else if (varp == &p_imak) { if (!im_xim_isvalid_imactivate()) errmsg = e_invarg; } #endif #ifdef FEAT_KEYMAP else if (varp == &curbuf->b_p_keymap) { if (!valid_filetype(*varp)) errmsg = e_invarg; else { int secure_save = secure; // Reset the secure flag, since the value of 'keymap' has // been checked to be safe. secure = 0; // load or unload key mapping tables errmsg = keymap_init(); secure = secure_save; // Since we check the value, there is no need to set P_INSECURE, // even when the value comes from a modeline. *value_checked = TRUE; } if (errmsg == NULL) { if (*curbuf->b_p_keymap != NUL) { // Installed a new keymap, switch on using it. curbuf->b_p_iminsert = B_IMODE_LMAP; if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) curbuf->b_p_imsearch = B_IMODE_LMAP; } else { // Cleared the keymap, may reset 'iminsert' and 'imsearch'. if (curbuf->b_p_iminsert == B_IMODE_LMAP) curbuf->b_p_iminsert = B_IMODE_NONE; if (curbuf->b_p_imsearch == B_IMODE_LMAP) curbuf->b_p_imsearch = B_IMODE_USE_INSERT; } if ((opt_flags & OPT_LOCAL) == 0) { set_iminsert_global(); set_imsearch_global(); } status_redraw_curbuf(); } } #endif // 'fileformat' else if (gvarp == &p_ff) { if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) errmsg = e_cannot_make_changes_modifiable_is_off; else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) errmsg = e_invarg; else { // may also change 'textmode' if (get_fileformat(curbuf) == EOL_DOS) curbuf->b_p_tx = TRUE; else curbuf->b_p_tx = FALSE; #ifdef FEAT_TITLE redraw_titles(); #endif // update flag in swap file ml_setflags(curbuf); // Redraw needed when switching to/from "mac": a CR in the text // will be displayed differently. if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') redraw_curbuf_later(NOT_VALID); } } // 'fileformats' else if (varp == &p_ffs) { if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) errmsg = e_invarg; else { // also change 'textauto' if (*p_ffs == NUL) p_ta = FALSE; else p_ta = TRUE; } } #if defined(FEAT_CRYPT) // 'cryptkey' else if (gvarp == &p_key) { // Make sure the ":set" command doesn't show the new value in the // history. remove_key_from_history(); if (STRCMP(curbuf->b_p_key, oldval) != 0) // Need to update the swapfile. { ml_set_crypt_key(curbuf, oldval, *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm); changed_internal(); } } else if (gvarp == &p_cm) { if (opt_flags & OPT_LOCAL) p = curbuf->b_p_cm; else p = p_cm; if (check_opt_strings(p, p_cm_values, TRUE) != OK) errmsg = e_invarg; else if (crypt_self_test() == FAIL) errmsg = e_invarg; else { // When setting the global value to empty, make it "zip". if (*p_cm == NUL) { if (new_value_alloced) free_string_option(p_cm); p_cm = vim_strsave((char_u *)"zip"); new_value_alloced = TRUE; } // When using ":set cm=name" the local value is going to be empty. // Do that here, otherwise the crypt functions will still use the // local value. if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) { free_string_option(curbuf->b_p_cm); curbuf->b_p_cm = empty_option; } // Need to update the swapfile when the effective method changed. // Set "s" to the effective old value, "p" to the effective new // method and compare. if ((opt_flags & OPT_LOCAL) && *oldval == NUL) s = p_cm; // was previously using the global value else s = oldval; if (*curbuf->b_p_cm == NUL) p = p_cm; // is now using the global value else p = curbuf->b_p_cm; if (STRCMP(s, p) != 0) ml_set_crypt_key(curbuf, curbuf->b_p_key, s); // If the global value changes need to update the swapfile for all // buffers using that value. if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0) { buf_T *buf; FOR_ALL_BUFFERS(buf) if (buf != curbuf && *buf->b_p_cm == NUL) ml_set_crypt_key(buf, buf->b_p_key, oldval); } } } #endif // 'matchpairs' else if (gvarp == &p_mps) { if (has_mbyte) { for (p = *varp; *p != NUL; ++p) { int x2 = -1; int x3 = -1; if (*p != NUL) p += mb_ptr2len(p); if (*p != NUL) x2 = *p++; if (*p != NUL) { x3 = mb_ptr2char(p); p += mb_ptr2len(p); } if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) { errmsg = e_invarg; break; } if (*p == NUL) break; } } else { // Check for "x:y,x:y" for (p = *varp; *p != NUL; p += 4) { if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) { errmsg = e_invarg; break; } if (p[3] == NUL) break; } } } // 'comments' else if (gvarp == &p_com) { for (s = *varp; *s; ) { while (*s && *s != ':') { if (vim_strchr((char_u *)COM_ALL, *s) == NULL && !VIM_ISDIGIT(*s) && *s != '-') { errmsg = illegal_char(errbuf, *s); break; } ++s; } if (*s++ == NUL) errmsg = N_("E524: Missing colon"); else if (*s == ',' || *s == NUL) errmsg = N_("E525: Zero length string"); if (errmsg != NULL) break; while (*s && *s != ',') { if (*s == '\\' && s[1] != NUL) ++s; ++s; } s = skip_to_option_part(s); } } // global 'listchars' else if (varp == &p_lcs) { errmsg = set_chars_option(curwin, varp); if (errmsg == NULL) { tabpage_T *tp; win_T *wp; // The current window is set to use the global 'listchars' value. // So clear the window-local value. if (!(opt_flags & OPT_GLOBAL)) clear_string_option(&curwin->w_p_lcs); FOR_ALL_TAB_WINDOWS(tp, wp) { errmsg = set_chars_option(wp, &wp->w_p_lcs); if (errmsg) break; } redraw_all_later(NOT_VALID); } } // local 'listchars' else if (varp == &curwin->w_p_lcs) errmsg = set_chars_option(curwin, varp); // 'fillchars' else if (varp == &p_fcs) { errmsg = set_chars_option(curwin, varp); } #ifdef FEAT_CMDWIN // 'cedit' else if (varp == &p_cedit) { errmsg = check_cedit(); } #endif // 'verbosefile' else if (varp == &p_vfile) { verbose_stop(); if (*p_vfile != NUL && verbose_open() == FAIL) errmsg = e_invarg; } #ifdef FEAT_VIMINFO // 'viminfo' else if (varp == &p_viminfo) { for (s = p_viminfo; *s;) { // Check it's a valid character if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) { errmsg = illegal_char(errbuf, *s); break; } if (*s == 'n') // name is always last one break; else if (*s == 'r') // skip until next ',' { while (*++s && *s != ',') ; } else if (*s == '%') { // optional number while (vim_isdigit(*++s)) ; } else if (*s == '!' || *s == 'h' || *s == 'c') ++s; // no extra chars else // must have a number { while (vim_isdigit(*++s)) ; if (!VIM_ISDIGIT(*(s - 1))) { if (errbuf != NULL) { sprintf(errbuf, _("E526: Missing number after <%s>"), transchar_byte(*(s - 1))); errmsg = errbuf; } else errmsg = ""; break; } } if (*s == ',') ++s; else if (*s) { if (errbuf != NULL) errmsg = N_("E527: Missing comma"); else errmsg = ""; break; } } if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) errmsg = N_("E528: Must specify a ' value"); } #endif // FEAT_VIMINFO // terminal options else if (istermoption_idx(opt_idx) && full_screen) { // ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" if (varp == &T_CCO) { int colors = atoi((char *)T_CCO); // Only reinitialize colors if t_Co value has really changed to // avoid expensive reload of colorscheme if t_Co is set to the // same value multiple times. if (colors != t_colors) { t_colors = colors; if (t_colors <= 1) { if (new_value_alloced) vim_free(T_CCO); T_CCO = empty_option; } #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) if (is_term_win32()) { swap_tcap(); did_swaptcap = TRUE; } #endif // We now have a different color setup, initialize it again. init_highlight(TRUE, FALSE); } } ttest(FALSE); if (varp == &T_ME) { out_str(T_ME); redraw_later(CLEAR); #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) // Since t_me has been set, this probably means that the user // wants to use this as default colors. Need to reset default // background/foreground colors. # ifdef VIMDLL if (!gui.in_use && !gui.starting) # endif mch_set_normal_colors(); #endif } if (varp == &T_BE && termcap_active) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; #endif if (*T_BE == NUL) // When clearing t_BE we assume the user no longer wants // bracketed paste, thus disable it by writing t_BD. out_str(T_BD); else out_str(T_BE); } } #ifdef FEAT_LINEBREAK // 'showbreak' else if (gvarp == &p_sbr) { for (s = *varp; *s; ) { if (ptr2cells(s) != 1) errmsg = N_("E595: 'showbreak' contains unprintable or wide character"); MB_PTR_ADV(s); } } #endif #ifdef FEAT_GUI // 'guifont' else if (varp == &p_guifont) { if (gui.in_use) { p = p_guifont; # if defined(FEAT_GUI_GTK) // Put up a font dialog and let the user select a new value. // If this is cancelled go back to the old value but don't // give an error message. if (STRCMP(p, "*") == 0) { p = gui_mch_font_dialog(oldval); if (new_value_alloced) free_string_option(p_guifont); p_guifont = (p != NULL) ? p : vim_strsave(oldval); new_value_alloced = TRUE; } # endif if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) { # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) if (STRCMP(p_guifont, "*") == 0) { // Dialog was cancelled: Keep the old value without giving // an error message. if (new_value_alloced) free_string_option(p_guifont); p_guifont = vim_strsave(oldval); new_value_alloced = TRUE; } else # endif errmsg = N_("E596: Invalid font(s)"); } } redraw_gui_only = TRUE; } # ifdef FEAT_XFONTSET else if (varp == &p_guifontset) { if (STRCMP(p_guifontset, "*") == 0) errmsg = N_("E597: can't select fontset"); else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) errmsg = N_("E598: Invalid fontset"); redraw_gui_only = TRUE; } # endif else if (varp == &p_guifontwide) { if (STRCMP(p_guifontwide, "*") == 0) errmsg = N_("E533: can't select wide font"); else if (gui_get_wide_font() == FAIL) errmsg = N_("E534: Invalid wide font"); redraw_gui_only = TRUE; } #endif #ifdef CURSOR_SHAPE // 'guicursor' else if (varp == &p_guicursor) errmsg = parse_shape_opt(SHAPE_CURSOR); #endif #ifdef FEAT_MOUSESHAPE // 'mouseshape' else if (varp == &p_mouseshape) { errmsg = parse_shape_opt(SHAPE_MOUSE); update_mouseshape(-1); } #endif #ifdef FEAT_PRINTER else if (varp == &p_popt) errmsg = parse_printoptions(); # if defined(FEAT_POSTSCRIPT) else if (varp == &p_pmfn) errmsg = parse_printmbfont(); # endif #endif #ifdef FEAT_LANGMAP // 'langmap' else if (varp == &p_langmap) langmap_set(); #endif #ifdef FEAT_LINEBREAK // 'breakat' else if (varp == &p_breakat) fill_breakat_flags(); #endif #ifdef FEAT_TITLE // 'titlestring' and 'iconstring' else if (varp == &p_titlestring || varp == &p_iconstring) { # ifdef FEAT_STL_OPT int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; // NULL => statusline syntax if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) stl_syntax |= flagval; else stl_syntax &= ~flagval; # endif did_set_title(); } #endif #ifdef FEAT_GUI // 'guioptions' else if (varp == &p_go) { gui_init_which_components(oldval); redraw_gui_only = TRUE; } #endif #if defined(FEAT_GUI_TABLINE) // 'guitablabel' else if (varp == &p_gtl) { redraw_tabline = TRUE; redraw_gui_only = TRUE; } // 'guitabtooltip' else if (varp == &p_gtt) { redraw_gui_only = TRUE; } #endif #if defined(UNIX) || defined(VMS) // 'ttymouse' else if (varp == &p_ttym) { // Switch the mouse off before changing the escape sequences used for // that. mch_setmouse(FALSE); if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) errmsg = e_invarg; else check_mouse_termcode(); if (termcap_active) setmouse(); // may switch it on again } #endif // 'selection' else if (varp == &p_sel) { if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) errmsg = e_invarg; } // 'selectmode' else if (varp == &p_slm) { if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) errmsg = e_invarg; } #ifdef FEAT_BROWSE // 'browsedir' else if (varp == &p_bsdir) { if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK && !mch_isdir(p_bsdir)) errmsg = e_invarg; } #endif // 'keymodel' else if (varp == &p_km) { if (check_opt_strings(p_km, p_km_values, TRUE) != OK) errmsg = e_invarg; else { km_stopsel = (vim_strchr(p_km, 'o') != NULL); km_startsel = (vim_strchr(p_km, 'a') != NULL); } } // 'mousemodel' else if (varp == &p_mousem) { if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) errmsg = e_invarg; #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) else if (*p_mousem != *oldval) // Changed from "extend" to "popup" or "popup_setpos" or vv: need // to create or delete the popup menus. gui_motif_update_mousemodel(root_menu); #endif } // 'switchbuf' else if (varp == &p_swb) { if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK) errmsg = e_invarg; } // 'debug' else if (varp == &p_debug) { if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK) errmsg = e_invarg; } // 'display' else if (varp == &p_dy) { if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) errmsg = e_invarg; else (void)init_chartab(); } // 'eadirection' else if (varp == &p_ead) { if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) errmsg = e_invarg; } #ifdef FEAT_CLIPBOARD // 'clipboard' else if (varp == &p_cb) errmsg = check_clipboard_option(); #endif #ifdef FEAT_SPELL // When 'spelllang' or 'spellfile' is set and there is a window for this // buffer in which 'spell' is set load the wordlists. else if (varp == &(curwin->w_s->b_p_spl) || varp == &(curwin->w_s->b_p_spf)) { int is_spellfile = varp == &(curwin->w_s->b_p_spf); if ((is_spellfile && !valid_spellfile(*varp)) || (!is_spellfile && !valid_spelllang(*varp))) errmsg = e_invarg; else errmsg = did_set_spell_option(is_spellfile); } // When 'spellcapcheck' is set compile the regexp program. else if (varp == &(curwin->w_s->b_p_spc)) { errmsg = compile_cap_prog(curwin->w_s); } // 'spelloptions' else if (varp == &(curwin->w_s->b_p_spo)) { if (**varp != NUL && STRCMP("camel", *varp) != 0) errmsg = e_invarg; } // 'spellsuggest' else if (varp == &p_sps) { if (spell_check_sps() != OK) errmsg = e_invarg; } // 'mkspellmem' else if (varp == &p_msm) { if (spell_check_msm() != OK) errmsg = e_invarg; } #endif // When 'bufhidden' is set, check for valid value. else if (gvarp == &p_bh) { if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) errmsg = e_invarg; } // When 'buftype' is set, check for valid value. else if (gvarp == &p_bt) { if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) errmsg = e_invarg; else { if (curwin->w_status_height) { curwin->w_redr_status = TRUE; redraw_later(VALID); } curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); #ifdef FEAT_TITLE redraw_titles(); #endif } } #ifdef FEAT_STL_OPT // 'statusline' or 'rulerformat' else if (gvarp == &p_stl || varp == &p_ruf) { int wid; if (varp == &p_ruf) // reset ru_wid first ru_wid = 0; s = *varp; if (varp == &p_ruf && *s == '%') { // set ru_wid if 'ruf' starts with "%99(" if (*++s == '-') // ignore a '-' s++; wid = getdigits(&s); if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) ru_wid = wid; else errmsg = check_stl_option(p_ruf); } // check 'statusline' only if it doesn't start with "%!" else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') errmsg = check_stl_option(s); if (varp == &p_ruf && errmsg == NULL) comp_col(); } #endif // check if it is a valid value for 'complete' -- Acevedo else if (gvarp == &p_cpt) { for (s = *varp; *s;) { while (*s == ',' || *s == ' ') s++; if (!*s) break; if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) { errmsg = illegal_char(errbuf, *s); break; } if (*++s != NUL && *s != ',' && *s != ' ') { if (s[-1] == 'k' || s[-1] == 's') { // skip optional filename after 'k' and 's' while (*s && *s != ',' && *s != ' ') { if (*s == '\\' && s[1] != NUL) ++s; ++s; } } else { if (errbuf != NULL) { sprintf((char *)errbuf, _("E535: Illegal character after <%c>"), *--s); errmsg = errbuf; } else errmsg = ""; break; } } } } // 'completeopt' else if (varp == &p_cot) { if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) errmsg = e_invarg; else completeopt_was_set(); } #ifdef BACKSLASH_IN_FILENAME // 'completeslash' else if (gvarp == &p_csl) { if (check_opt_strings(p_csl, p_csl_values, FALSE) != OK || check_opt_strings(curbuf->b_p_csl, p_csl_values, FALSE) != OK) errmsg = e_invarg; } #endif #ifdef FEAT_SIGNS // 'signcolumn' else if (varp == &curwin->w_p_scl) { if (check_opt_strings(*varp, p_scl_values, FALSE) != OK) errmsg = e_invarg; // When changing the 'signcolumn' to or from 'number', recompute the // width of the number column if 'number' or 'relativenumber' is set. if (((*oldval == 'n' && *(oldval + 1) == 'u') || (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) =='u')) && (curwin->w_p_nu || curwin->w_p_rnu)) curwin->w_nrwidth_line_count = 0; } #endif #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) // 'toolbar' else if (varp == &p_toolbar) { if (opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE) != OK) errmsg = e_invarg; else { out_flush(); gui_mch_show_toolbar((toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); } } #endif #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) // 'toolbariconsize': GTK+ 2 only else if (varp == &p_tbis) { if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) errmsg = e_invarg; else { out_flush(); gui_mch_show_toolbar((toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); } } #endif // 'pastetoggle': translate key codes like in a mapping else if (varp == &p_pt) { if (*p_pt) { (void)replace_termcodes(p_pt, &p, REPTERM_FROM_PART | REPTERM_DO_LT, NULL); if (p != NULL) { if (new_value_alloced) free_string_option(p_pt); p_pt = p; new_value_alloced = TRUE; } } } // 'backspace' else if (varp == &p_bs) { if (VIM_ISDIGIT(*p_bs)) { if (*p_bs > '3' || p_bs[1] != NUL) errmsg = e_invarg; } else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) errmsg = e_invarg; } else if (varp == &p_bo) { if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK) errmsg = e_invarg; } // 'tagcase' else if (gvarp == &p_tc) { unsigned int *flags; if (opt_flags & OPT_LOCAL) { p = curbuf->b_p_tc; flags = &curbuf->b_tc_flags; } else { p = p_tc; flags = &tc_flags; } if ((opt_flags & OPT_LOCAL) && *p == NUL) // make the local value empty: use the global value *flags = 0; else if (*p == NUL || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK) errmsg = e_invarg; } // 'casemap' else if (varp == &p_cmp) { if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) errmsg = e_invarg; } #ifdef FEAT_DIFF // 'diffopt' else if (varp == &p_dip) { if (diffopt_changed() == FAIL) errmsg = e_invarg; } #endif #ifdef FEAT_FOLDING // 'foldmethod' else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) { if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK || *curwin->w_p_fdm == NUL) errmsg = e_invarg; else { foldUpdateAll(curwin); if (foldmethodIsDiff(curwin)) newFoldLevel(); } } # ifdef FEAT_EVAL // 'foldexpr' else if (varp == &curwin->w_p_fde) { if (foldmethodIsExpr(curwin)) foldUpdateAll(curwin); } # endif // 'foldmarker' else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { p = vim_strchr(*varp, ','); if (p == NULL) errmsg = N_("E536: comma required"); else if (p == *varp || p[1] == NUL) errmsg = e_invarg; else if (foldmethodIsMarker(curwin)) foldUpdateAll(curwin); } // 'commentstring' else if (gvarp == &p_cms) { if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) errmsg = N_("E537: 'commentstring' must be empty or contain %s"); } // 'foldopen' else if (varp == &p_fdo) { if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) errmsg = e_invarg; } // 'foldclose' else if (varp == &p_fcl) { if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) errmsg = e_invarg; } // 'foldignore' else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) { if (foldmethodIsIndent(curwin)) foldUpdateAll(curwin); } #endif // 'virtualedit' else if (gvarp == &p_ve) { char_u *ve = p_ve; unsigned int *flags = &ve_flags; if (opt_flags & OPT_LOCAL) { ve = curwin->w_p_ve; flags = &curwin->w_ve_flags; } if ((opt_flags & OPT_LOCAL) && *ve == NUL) // make the local value empty: use the global value *flags = 0; else { if (opt_strings_flags(ve, p_ve_values, flags, TRUE) != OK) errmsg = e_invarg; else if (STRCMP(p_ve, oldval) != 0) { // Recompute cursor position in case the new 've' setting // changes something. validate_virtcol(); coladvance(curwin->w_virtcol); } } } #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) else if (varp == &p_csqf) { if (p_csqf != NULL) { p = p_csqf; while (*p != NUL) { if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL || p[1] == NUL || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL || (p[2] != NUL && p[2] != ',')) { errmsg = e_invarg; break; } else if (p[2] == NUL) break; else p += 3; } } } #endif #ifdef FEAT_CINDENT // 'cinoptions' else if (gvarp == &p_cino) { // TODO: recognize errors parse_cino(curbuf); } #endif #if defined(FEAT_RENDER_OPTIONS) // 'renderoptions' else if (varp == &p_rop) { if (!gui_mch_set_rendering_options(p_rop)) errmsg = e_invarg; } #endif else if (gvarp == &p_ft) { if (!valid_filetype(*varp)) errmsg = e_invarg; else { value_changed = STRCMP(oldval, *varp) != 0; // Since we check the value, there is no need to set P_INSECURE, // even when the value comes from a modeline. *value_checked = TRUE; } } #ifdef FEAT_SYN_HL else if (gvarp == &p_syn) { if (!valid_filetype(*varp)) errmsg = e_invarg; else { value_changed = STRCMP(oldval, *varp) != 0; // Since we check the value, there is no need to set P_INSECURE, // even when the value comes from a modeline. *value_checked = TRUE; } } #endif #ifdef FEAT_TERMINAL // 'termwinkey' else if (varp == &curwin->w_p_twk) { if (*curwin->w_p_twk != NUL && string_to_key(curwin->w_p_twk, TRUE) == 0) errmsg = e_invarg; } // 'termwinsize' else if (varp == &curwin->w_p_tws) { if (*curwin->w_p_tws != NUL) { p = skipdigits(curwin->w_p_tws); if (p == curwin->w_p_tws || (*p != 'x' && *p != '*') || *skipdigits(p + 1) != NUL) errmsg = e_invarg; } } // 'wincolor' else if (varp == &curwin->w_p_wcr) { if (curwin->w_buffer->b_term != NULL) term_update_colors(curwin->w_buffer->b_term); } # if defined(MSWIN) // 'termwintype' else if (varp == &p_twt) { if (check_opt_strings(*varp, p_twt_values, FALSE) != OK) errmsg = e_invarg; } # endif #endif #ifdef FEAT_VARTABS // 'varsofttabstop' else if (varp == &(curbuf->b_p_vsts)) { char_u *cp; if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1])) { if (curbuf->b_p_vsts_array) { vim_free(curbuf->b_p_vsts_array); curbuf->b_p_vsts_array = 0; } } else { for (cp = *varp; *cp; ++cp) { if (vim_isdigit(*cp)) continue; if (*cp == ',' && cp > *varp && *(cp-1) != ',') continue; errmsg = e_invarg; break; } if (errmsg == NULL) { int *oldarray = curbuf->b_p_vsts_array; if (tabstop_set(*varp, &(curbuf->b_p_vsts_array))) { if (oldarray) vim_free(oldarray); } else errmsg = e_invarg; } } } // 'vartabstop' else if (varp == &(curbuf->b_p_vts)) { char_u *cp; if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1])) { if (curbuf->b_p_vts_array) { vim_free(curbuf->b_p_vts_array); curbuf->b_p_vts_array = NULL; } } else { for (cp = *varp; *cp; ++cp) { if (vim_isdigit(*cp)) continue; if (*cp == ',' && cp > *varp && *(cp-1) != ',') continue; errmsg = e_invarg; break; } if (errmsg == NULL) { int *oldarray = curbuf->b_p_vts_array; if (tabstop_set(*varp, &(curbuf->b_p_vts_array))) { vim_free(oldarray); #ifdef FEAT_FOLDING if (foldmethodIsIndent(curwin)) foldUpdateAll(curwin); #endif } else errmsg = e_invarg; } } } #endif #ifdef FEAT_PROP_POPUP // 'previewpopup' else if (varp == &p_pvp) { if (parse_previewpopup(NULL) == FAIL) errmsg = e_invarg; } # ifdef FEAT_QUICKFIX // 'completepopup' else if (varp == &p_cpp) { if (parse_completepopup(NULL) == FAIL) errmsg = e_invarg; else popup_close_info(); } # endif #endif #ifdef FEAT_QUICKFIX else if (varp == &p_qftf) { if (qf_process_qftf_option() == FALSE) errmsg = e_invarg; } #endif // Options that are a list of flags. else { p = NULL; if (varp == &p_ww) // 'whichwrap' p = (char_u *)WW_ALL; if (varp == &p_shm) // 'shortmess' p = (char_u *)SHM_ALL; else if (varp == &(p_cpo)) // 'cpoptions' p = (char_u *)CPO_ALL; else if (varp == &(curbuf->b_p_fo)) // 'formatoptions' p = (char_u *)FO_ALL; #ifdef FEAT_CONCEAL else if (varp == &curwin->w_p_cocu) // 'concealcursor' p = (char_u *)COCU_ALL; #endif else if (varp == &p_mouse) // 'mouse' { p = (char_u *)MOUSE_ALL; } #if defined(FEAT_GUI) else if (varp == &p_go) // 'guioptions' p = (char_u *)GO_ALL; #endif if (p != NULL) { for (s = *varp; *s; ++s) if (vim_strchr(p, *s) == NULL) { errmsg = illegal_char(errbuf, *s); break; } } } // If error detected, restore the previous value. if (errmsg != NULL) { if (new_value_alloced) free_string_option(*varp); *varp = oldval; // When resetting some values, need to act on it. if (did_chartab) (void)init_chartab(); if (varp == &p_hl) (void)highlight_changed(); } else { #ifdef FEAT_EVAL // Remember where the option was set. set_option_sctx_idx(opt_idx, opt_flags, current_sctx); #endif // Free string options that are in allocated memory. // Use "free_oldval", because recursiveness may change the flags under // our fingers (esp. init_highlight()). if (free_oldval) free_string_option(oldval); if (new_value_alloced) set_option_flag(opt_idx, P_ALLOCED); else clear_option_flag(opt_idx, P_ALLOCED); if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 && is_global_local_option(opt_idx)) { // global option with local value set to use global value; free // the local value and make it empty p = get_option_varp_scope(opt_idx, OPT_LOCAL); free_string_option(*(char_u **)p); *(char_u **)p = empty_option; } // May set global value for local option. else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) set_string_option_global(opt_idx, varp); // Trigger the autocommand only after setting the flags. #ifdef FEAT_SYN_HL // When 'syntax' is set, load the syntax of that name if (varp == &(curbuf->b_p_syn)) { static int syn_recursive = 0; ++syn_recursive; // Only pass TRUE for "force" when the value changed or not used // recursively, to avoid endless recurrence. apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, value_changed || syn_recursive == 1, curbuf); curbuf->b_flags |= BF_SYN_SET; --syn_recursive; } #endif else if (varp == &(curbuf->b_p_ft)) { // 'filetype' is set, trigger the FileType autocommand. // Skip this when called from a modeline and the filetype was // already set to this value. if (!(opt_flags & OPT_MODELINE) || value_changed) { static int ft_recursive = 0; int secure_save = secure; // Reset the secure flag, since the value of 'filetype' has // been checked to be safe. secure = 0; ++ft_recursive; did_filetype = TRUE; // Only pass TRUE for "force" when the value changed or not // used recursively, to avoid endless recurrence. apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, value_changed || ft_recursive == 1, curbuf); --ft_recursive; // Just in case the old "curbuf" is now invalid. if (varp != &(curbuf->b_p_ft)) varp = NULL; secure = secure_save; } } #ifdef FEAT_SPELL if (varp == &(curwin->w_s->b_p_spl)) { char_u fname[200]; char_u *q = curwin->w_s->b_p_spl; // Skip the first name if it is "cjk". if (STRNCMP(q, "cjk,", 4) == 0) q += 4; // Source the spell/LANG.vim in 'runtimepath'. // They could set 'spellcapcheck' depending on the language. // Use the first name in 'spelllang' up to '_region' or // '.encoding'. for (p = q; *p != NUL; ++p) if (!ASCII_ISALNUM(*p) && *p != '-') break; if (p > q) { vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); source_runtime(fname, DIP_ALL); } } #endif } if (varp == &p_mouse) { if (*p_mouse == NUL) mch_setmouse(FALSE); // switch mouse off else setmouse(); // in case 'mouse' changed } #if defined(FEAT_LUA) || defined(PROTO) if (varp == &p_rtp) update_package_paths_in_lua(); #endif if (curwin->w_curswant != MAXCOL && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; if ((opt_flags & OPT_NO_REDRAW) == 0) { #ifdef FEAT_GUI // check redraw when it's not a GUI option or the GUI is active. if (!redraw_gui_only || gui.in_use) #endif check_redraw(get_option_flags(opt_idx)); } #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) if (did_swaptcap) { set_termname((char_u *)"win32"); init_highlight(TRUE, FALSE); } #endif return errmsg; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int compare_order_lists(SQL_I_List<ORDER> *part_list1, SQL_I_List<ORDER> *part_list2) { if (part_list1 == part_list2) return CMP_EQ; ORDER *elem1= part_list1->first; ORDER *elem2= part_list2->first; for ( ; elem1 && elem2; elem1= elem1->next, elem2= elem2->next) { int cmp; // remove all constants as we don't need them for comparision while(elem1 && ((*elem1->item)->real_item())->const_item()) { elem1= elem1->next; continue; } while(elem2 && ((*elem2->item)->real_item())->const_item()) { elem2= elem2->next; continue; } if (!elem1 || !elem2) break; if ((cmp= compare_order_elements(elem1, elem2))) return cmp; } if (elem1) return CMP_GT_C; if (elem2) return CMP_LT_C; return CMP_EQ; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [MagickPrivate void XFreeStandardColormap(Display *display, const XVisualInfo *visual_info,XStandardColormap *map_info,XPixelInfo *pixel) { /* Free colormap. */ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(display != (Display *) NULL); assert(visual_info != (XVisualInfo *) NULL); assert(map_info != (XStandardColormap *) NULL); (void) XFlush(display); if (map_info->colormap != (Colormap) NULL) { if (map_info->colormap != XDefaultColormap(display,visual_info->screen)) (void) XFreeColormap(display,map_info->colormap); else if (pixel != (XPixelInfo *) NULL) if ((visual_info->klass != TrueColor) && (visual_info->klass != DirectColor)) (void) XFreeColors(display,map_info->colormap,pixel->pixels, (int) pixel->colors,0); } map_info->colormap=(Colormap) NULL; if (pixel != (XPixelInfo *) NULL) { if (pixel->pixels != (unsigned long *) NULL) pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels); pixel->pixels=(unsigned long *) NULL; } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program) { AVStream *stream = ist->st; AVCodecParameters *par; AVCodecContext *dec_ctx; char val_str[128]; const char *s; AVRational sar, dar; AVBPrint pbuf; const AVCodecDescriptor *cd; int ret = 0; const char *profile = NULL; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM); print_int("index", stream->index); par = stream->codecpar; dec_ctx = ist->dec_ctx; if (cd = avcodec_descriptor_get(par->codec_id)) { print_str("codec_name", cd->name); if (!do_bitexact) { print_str("codec_long_name", cd->long_name ? cd->long_name : "unknown"); } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) { print_str_opt("codec_long_name", "unknown"); } } if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile))) print_str("profile", profile); else { if (par->profile != FF_PROFILE_UNKNOWN) { char profile_num[12]; snprintf(profile_num, sizeof(profile_num), "%d", par->profile); print_str("profile", profile_num); } else print_str_opt("profile", "unknown"); } s = av_get_media_type_string(par->codec_type); if (s) print_str ("codec_type", s); else print_str_opt("codec_type", "unknown"); #if FF_API_LAVF_AVCTX if (dec_ctx) print_q("codec_time_base", dec_ctx->time_base, '/'); #endif /* print AVI/FourCC tag */ print_str("codec_tag_string", av_fourcc2str(par->codec_tag)); print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag); switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", par->width); print_int("height", par->height); if (dec_ctx) { print_int("coded_width", dec_ctx->coded_width); print_int("coded_height", dec_ctx->coded_height); } print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); if (sar.den) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, par->height * sar.den, 1024*1024); print_q("display_aspect_ratio", dar, ':'); } else { print_str_opt("sample_aspect_ratio", "N/A"); print_str_opt("display_aspect_ratio", "N/A"); } s = av_get_pix_fmt_name(par->format); if (s) print_str ("pix_fmt", s); else print_str_opt("pix_fmt", "unknown"); print_int("level", par->level); if (par->color_range != AVCOL_RANGE_UNSPECIFIED) print_str ("color_range", av_color_range_name(par->color_range)); else print_str_opt("color_range", "N/A"); if (par->color_space != AVCOL_SPC_UNSPECIFIED) print_str("color_space", av_color_space_name(par->color_space)); else print_str_opt("color_space", av_color_space_name(par->color_space)); if (par->color_trc != AVCOL_TRC_UNSPECIFIED) print_str("color_transfer", av_color_transfer_name(par->color_trc)); else print_str_opt("color_transfer", av_color_transfer_name(par->color_trc)); if (par->color_primaries != AVCOL_PRI_UNSPECIFIED) print_str("color_primaries", av_color_primaries_name(par->color_primaries)); else print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries)); if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED) print_str("chroma_location", av_chroma_location_name(par->chroma_location)); else print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location)); if (par->field_order == AV_FIELD_PROGRESSIVE) print_str("field_order", "progressive"); else if (par->field_order == AV_FIELD_TT) print_str("field_order", "tt"); else if (par->field_order == AV_FIELD_BB) print_str("field_order", "bb"); else if (par->field_order == AV_FIELD_TB) print_str("field_order", "tb"); else if (par->field_order == AV_FIELD_BT) print_str("field_order", "bt"); else print_str_opt("field_order", "unknown"); #if FF_API_PRIVATE_OPT if (dec_ctx && dec_ctx->timecode_frame_start >= 0) { char tcbuf[AV_TIMECODE_STR_SIZE]; av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start); print_str("timecode", tcbuf); } else { print_str_opt("timecode", "N/A"); } #endif if (dec_ctx) print_int("refs", dec_ctx->refs); break; case AVMEDIA_TYPE_AUDIO: s = av_get_sample_fmt_name(par->format); if (s) print_str ("sample_fmt", s); else print_str_opt("sample_fmt", "unknown"); print_val("sample_rate", par->sample_rate, unit_hertz_str); print_int("channels", par->channels); if (par->channel_layout) { av_bprint_clear(&pbuf); av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout); print_str ("channel_layout", pbuf.str); } else { print_str_opt("channel_layout", "unknown"); } print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); break; case AVMEDIA_TYPE_SUBTITLE: if (par->width) print_int("width", par->width); else print_str_opt("width", "N/A"); if (par->height) print_int("height", par->height); else print_str_opt("height", "N/A"); break; } if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { const AVOption *opt = NULL; while (opt = av_opt_next(dec_ctx->priv_data,opt)) { uint8_t *str; if (opt->flags) continue; if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) { print_str(opt->name, str); av_free(str); } } } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id); else print_str_opt("id", "N/A"); print_q("r_frame_rate", stream->r_frame_rate, '/'); print_q("avg_frame_rate", stream->avg_frame_rate, '/'); print_q("time_base", stream->time_base, '/'); print_ts ("start_pts", stream->start_time); print_time("start_time", stream->start_time, &stream->time_base); print_ts ("duration_ts", stream->duration); print_time("duration", stream->duration, &stream->time_base); if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str); else print_str_opt("bit_rate", "N/A"); #if FF_API_LAVF_AVCTX if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str); else print_str_opt("max_bit_rate", "N/A"); #endif if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); else print_str_opt("bits_per_raw_sample", "N/A"); if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames); else print_str_opt("nb_frames", "N/A"); if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]); else print_str_opt("nb_read_frames", "N/A"); if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]); else print_str_opt("nb_read_packets", "N/A"); if (do_show_data) writer_print_data(w, "extradata", par->extradata, par->extradata_size); writer_print_data_hash(w, "extradata_hash", par->extradata, par->extradata_size); /* Print disposition information */ #define PRINT_DISPOSITION(flagname, name) do { \ print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \ } while (0) if (do_show_stream_disposition) { writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION); PRINT_DISPOSITION(DEFAULT, "default"); PRINT_DISPOSITION(DUB, "dub"); PRINT_DISPOSITION(ORIGINAL, "original"); PRINT_DISPOSITION(COMMENT, "comment"); PRINT_DISPOSITION(LYRICS, "lyrics"); PRINT_DISPOSITION(KARAOKE, "karaoke"); PRINT_DISPOSITION(FORCED, "forced"); PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired"); PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired"); PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects"); PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic"); PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails"); writer_print_section_footer(w); } if (do_show_stream_tags) ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS); if (stream->nb_side_data) { print_pkt_side_data(w, stream->codecpar, stream->side_data, stream->nb_side_data, SECTION_ID_STREAM_SIDE_DATA_LIST, SECTION_ID_STREAM_SIDE_DATA); } writer_print_section_footer(w); av_bprint_finalize(&pbuf, NULL); fflush(stdout); return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ldns_rr_rd_count(const ldns_rr *rr) { return rr->_rd_count; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [SetConstraintStateCreate(int numalloc) { SetConstraintState state; /* Behave sanely with numalloc == 0 */ if (numalloc <= 0) numalloc = 1; /* * We assume that zeroing will correctly initialize the state values. */ state = (SetConstraintState) MemoryContextAllocZero(TopTransactionContext, sizeof(SetConstraintStateData) + (numalloc - 1) *sizeof(SetConstraintTriggerData)); state->numalloc = numalloc; return state; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [local unsigned char *yank(char *name, boost::uint32_t *len) { boost::uint32_t size; unsigned char *buf; FILE *in; struct stat s; *len = 0; if (stat(name, &s)) return NULL; if ((s.st_mode & S_IFMT) != S_IFREG) return NULL; size = (boost::uint32_t)(s.st_size); if (size == 0 || (off_t)size != s.st_size) return NULL; in = fopen(name, "r"); if (in == NULL) return NULL; buf = malloc(size); if (buf != NULL && fread(buf, 1, size, in) != size) { free(buf); buf = NULL; } fclose(in); *len = size; return buf; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [rb_str_split_m(argc, argv, str) int argc; VALUE *argv; VALUE str; { VALUE spat; VALUE limit; int awk_split = Qfalse; long beg, end, i = 0; int lim = 0; VALUE result, tmp; if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) { lim = NUM2INT(limit); if (lim <= 0) limit = Qnil; else if (lim == 1) { if (RSTRING(str)->len == 0) return rb_ary_new2(0); return rb_ary_new3(1, str); } i = 1; } if (NIL_P(spat)) { if (!NIL_P(rb_fs)) { spat = rb_fs; goto fs_set; } awk_split = Qtrue; } else { fs_set: if (TYPE(spat) == T_STRING && RSTRING(spat)->len == 1) { if (RSTRING(spat)->ptr[0] == ' ') { awk_split = Qtrue; } else { spat = rb_reg_regcomp(rb_reg_quote(spat)); } } else { spat = get_pat(spat, 1); } } result = rb_ary_new(); beg = 0; if (awk_split) { char *ptr = RSTRING(str)->ptr; long len = RSTRING(str)->len; char *eptr = ptr + len; int skip = 1; for (end = beg = 0; ptr<eptr; ptr++) { if (skip) { if (ISSPACE(*ptr)) { beg++; } else { end = beg+1; skip = 0; if (!NIL_P(limit) && lim <= i) break; } } else { if (ISSPACE(*ptr)) { rb_ary_push(result, rb_str_substr(str, beg, end-beg)); skip = 1; beg = end + 1; if (!NIL_P(limit)) ++i; } else { end++; } } } } else { long start = beg; long idx; int last_null = 0; struct re_registers *regs; while ((end = rb_reg_search(spat, str, start, 0)) >= 0) { regs = RMATCH(rb_backref_get())->regs; if (start == end && BEG(0) == END(0)) { if (!RSTRING(str)->ptr) { rb_ary_push(result, rb_str_new("", 0)); break; } else if (last_null == 1) { rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat))); beg = start; } else { start += mbclen2(RSTRING(str)->ptr[start],spat); last_null = 1; continue; } } else { rb_ary_push(result, rb_str_substr(str, beg, end-beg)); beg = start = END(0); } last_null = 0; for (idx=1; idx < regs->num_regs; idx++) { if (BEG(idx) == -1) continue; if (BEG(idx) == END(idx)) tmp = rb_str_new5(str, 0, 0); else tmp = rb_str_substr(str, BEG(idx), END(idx)-BEG(idx)); rb_ary_push(result, tmp); } if (!NIL_P(limit) && lim <= ++i) break; } } if (RSTRING(str)->len > 0 && (!NIL_P(limit) || RSTRING(str)->len > beg || lim < 0)) { if (RSTRING(str)->len == beg) tmp = rb_str_new5(str, 0, 0); else tmp = rb_str_substr(str, beg, RSTRING(str)->len-beg); rb_ary_push(result, tmp); } if (NIL_P(limit) && lim == 0) { while (RARRAY(result)->len > 0 && RSTRING(RARRAY(result)->ptr[RARRAY(result)->len-1])->len == 0) rb_ary_pop(result); } return result; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [gdk_pixbuf__gif_image_load_increment (gpointer data, const guchar *buf, guint size, GError **error) { gint retval; GifContext *context = (GifContext *) data; context->error = error; if (context->amount_needed == 0) { /* we aren't looking for some bytes. */ /* we can use buf now, but we don't want to keep it around at all. * it will be gone by the end of the call. */ context->buf = (guchar*) buf; /* very dubious const cast */ context->ptr = 0; context->size = size; } else { /* we need some bytes */ if (size < context->amount_needed) { context->amount_needed -= size; /* copy it over and return */ memcpy (context->buf + context->size, buf, size); context->size += size; return TRUE; } else if (size == context->amount_needed) { memcpy (context->buf + context->size, buf, size); context->size += size; } else { context->buf = g_realloc (context->buf, context->size + size); memcpy (context->buf + context->size, buf, size); context->size += size; } } retval = gif_main_loop (context); if (retval == -2) return FALSE; if (retval == -1) { /* we didn't have enough memory */ /* prepare for the next image_load_increment */ if (context->buf == buf) { g_assert (context->size == size); context->buf = (guchar *)g_new (guchar, context->amount_needed + (context->size - context->ptr)); memcpy (context->buf, buf + context->ptr, context->size - context->ptr); } else { /* copy the left overs to the begining of the buffer */ /* and realloc the memory */ memmove (context->buf, context->buf + context->ptr, context->size - context->ptr); context->buf = g_realloc (context->buf, context->amount_needed + (context->size - context->ptr)); } context->size = context->size - context->ptr; context->ptr = 0; } else { /* we are prolly all done */ if (context->buf == buf) context->buf = NULL; } return TRUE; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [bool SNC_io_parser<EW>:: read_edge(Halfedge_handle eh) { bool OK = true; int index; #ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT typename K::RT hx,hy,hz,hw; #endif in >> index; OK = OK && test_string("{"); in >> index; eh->twin() = Edge_of[index]; OK = OK && test_string(","); in >> index; eh->center_vertex() = Vertex_of[index]; OK = OK && test_string(","); in >> index; if(index == 0) { in >> index; eh->out_sedge() = SEdge_of[index]; } else { in >> index; eh->incident_sface() = SFace_of[index]; } OK = OK && test_string("|"); #ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT in >> hx >> hy >> hz >> hw; eh->point() = Sphere_point(hx,hy,hz); #else eh->point() = Geometry_io<typename K::Kernel_tag, Kernel>::template read_point<Kernel,K>(in); #endif OK = OK && test_string("}"); in >> eh->mark(); return OK; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void force_metadata_allocation(struct btrfs_fs_info *info) { struct list_head *head = &info->space_info; struct btrfs_space_info *found; list_for_each_entry(found, head, list) { if (found->flags & BTRFS_BLOCK_GROUP_METADATA) found->force_alloc = CHUNK_ALLOC_FORCE; } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, struct scsi_cmnd *cmd) { char *buffer; unsigned short use_sg; int retvalue = 0, transfer_len = 0; unsigned long flags; struct CMD_MESSAGE_FIELD *pcmdmessagefld; uint32_t controlcode = (uint32_t)cmd->cmnd[5] << 24 | (uint32_t)cmd->cmnd[6] << 16 | (uint32_t)cmd->cmnd[7] << 8 | (uint32_t)cmd->cmnd[8]; struct scatterlist *sg; use_sg = scsi_sg_count(cmd); sg = scsi_sglist(cmd); buffer = kmap_atomic(sg_page(sg)) + sg->offset; if (use_sg > 1) { retvalue = ARCMSR_MESSAGE_FAIL; goto message_out; } transfer_len += sg->length; if (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) { retvalue = ARCMSR_MESSAGE_FAIL; pr_info("%s: ARCMSR_MESSAGE_FAIL!\n", __func__); goto message_out; } pcmdmessagefld = (struct CMD_MESSAGE_FIELD *)buffer; switch (controlcode) { case ARCMSR_MESSAGE_READ_RQBUFFER: { unsigned char *ver_addr; uint8_t *ptmpQbuffer; uint32_t allxfer_len = 0; ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC); if (!ver_addr) { retvalue = ARCMSR_MESSAGE_FAIL; pr_info("%s: memory not enough!\n", __func__); goto message_out; } ptmpQbuffer = ver_addr; spin_lock_irqsave(&acb->rqbuffer_lock, flags); if (acb->rqbuf_getIndex != acb->rqbuf_putIndex) { unsigned int tail = acb->rqbuf_getIndex; unsigned int head = acb->rqbuf_putIndex; unsigned int cnt_to_end = CIRC_CNT_TO_END(head, tail, ARCMSR_MAX_QBUFFER); allxfer_len = CIRC_CNT(head, tail, ARCMSR_MAX_QBUFFER); if (allxfer_len > ARCMSR_API_DATA_BUFLEN) allxfer_len = ARCMSR_API_DATA_BUFLEN; if (allxfer_len <= cnt_to_end) memcpy(ptmpQbuffer, acb->rqbuffer + tail, allxfer_len); else { memcpy(ptmpQbuffer, acb->rqbuffer + tail, cnt_to_end); memcpy(ptmpQbuffer + cnt_to_end, acb->rqbuffer, allxfer_len - cnt_to_end); } acb->rqbuf_getIndex = (acb->rqbuf_getIndex + allxfer_len) % ARCMSR_MAX_QBUFFER; } memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len); if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { struct QBUFFER __iomem *prbuffer; acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; prbuffer = arcmsr_get_iop_rqbuffer(acb); if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0) acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; } spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); kfree(ver_addr); pcmdmessagefld->cmdmessage.Length = allxfer_len; if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; break; } case ARCMSR_MESSAGE_WRITE_WQBUFFER: { unsigned char *ver_addr; int32_t user_len, cnt2end; uint8_t *pQbuffer, *ptmpuserbuffer; ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC); if (!ver_addr) { retvalue = ARCMSR_MESSAGE_FAIL; goto message_out; } ptmpuserbuffer = ver_addr; user_len = pcmdmessagefld->cmdmessage.Length; memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len); spin_lock_irqsave(&acb->wqbuffer_lock, flags); if (acb->wqbuf_putIndex != acb->wqbuf_getIndex) { struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)cmd->sense_buffer; arcmsr_write_ioctldata2iop(acb); /* has error report sensedata */ sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS; sensebuffer->SenseKey = ILLEGAL_REQUEST; sensebuffer->AdditionalSenseLength = 0x0A; sensebuffer->AdditionalSenseCode = 0x20; sensebuffer->Valid = 1; retvalue = ARCMSR_MESSAGE_FAIL; } else { pQbuffer = &acb->wqbuffer[acb->wqbuf_putIndex]; cnt2end = ARCMSR_MAX_QBUFFER - acb->wqbuf_putIndex; if (user_len > cnt2end) { memcpy(pQbuffer, ptmpuserbuffer, cnt2end); ptmpuserbuffer += cnt2end; user_len -= cnt2end; acb->wqbuf_putIndex = 0; pQbuffer = acb->wqbuffer; } memcpy(pQbuffer, ptmpuserbuffer, user_len); acb->wqbuf_putIndex += user_len; acb->wqbuf_putIndex %= ARCMSR_MAX_QBUFFER; if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) { acb->acb_flags &= ~ACB_F_MESSAGE_WQBUFFER_CLEARED; arcmsr_write_ioctldata2iop(acb); } } spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); kfree(ver_addr); if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; break; } case ARCMSR_MESSAGE_CLEAR_RQBUFFER: { uint8_t *pQbuffer = acb->rqbuffer; arcmsr_clear_iop2drv_rqueue_buffer(acb); spin_lock_irqsave(&acb->rqbuffer_lock, flags); acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED; acb->rqbuf_getIndex = 0; acb->rqbuf_putIndex = 0; memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER); spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; break; } case ARCMSR_MESSAGE_CLEAR_WQBUFFER: { uint8_t *pQbuffer = acb->wqbuffer; spin_lock_irqsave(&acb->wqbuffer_lock, flags); acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED | ACB_F_MESSAGE_WQBUFFER_READED); acb->wqbuf_getIndex = 0; acb->wqbuf_putIndex = 0; memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER); spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; break; } case ARCMSR_MESSAGE_CLEAR_ALLQBUFFER: { uint8_t *pQbuffer; arcmsr_clear_iop2drv_rqueue_buffer(acb); spin_lock_irqsave(&acb->rqbuffer_lock, flags); acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED; acb->rqbuf_getIndex = 0; acb->rqbuf_putIndex = 0; pQbuffer = acb->rqbuffer; memset(pQbuffer, 0, sizeof(struct QBUFFER)); spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); spin_lock_irqsave(&acb->wqbuffer_lock, flags); acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED | ACB_F_MESSAGE_WQBUFFER_READED); acb->wqbuf_getIndex = 0; acb->wqbuf_putIndex = 0; pQbuffer = acb->wqbuffer; memset(pQbuffer, 0, sizeof(struct QBUFFER)); spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; break; } case ARCMSR_MESSAGE_RETURN_CODE_3F: { if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_3F; break; } case ARCMSR_MESSAGE_SAY_HELLO: { int8_t *hello_string = "Hello! I am ARCMSR"; if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; memcpy(pcmdmessagefld->messagedatabuffer, hello_string, (int16_t)strlen(hello_string)); break; } case ARCMSR_MESSAGE_SAY_GOODBYE: { if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; arcmsr_iop_parking(acb); break; } case ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE: { if (acb->fw_flag == FW_DEADLOCK) pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON; else pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; arcmsr_flush_adapter_cache(acb); break; } default: retvalue = ARCMSR_MESSAGE_FAIL; pr_info("%s: unknown controlcode!\n", __func__); } message_out: if (use_sg) { struct scatterlist *sg = scsi_sglist(cmd); kunmap_atomic(buffer - sg->offset); } return retvalue; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [rsvg_state_finalize (RsvgState * state) { g_free (state->font_family); g_free (state->lang); rsvg_paint_server_unref (state->fill); rsvg_paint_server_unref (state->stroke); if (state->dash.n_dash != 0) g_free (state->dash.dash); if (state->styles) { g_hash_table_unref (state->styles); state->styles = NULL; } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int LibuvStreamWrap::DoWrite(WriteWrap* req_wrap, uv_buf_t* bufs, size_t count, uv_stream_t* send_handle) { LibuvWriteWrap* w = static_cast<LibuvWriteWrap*>(req_wrap); int r; if (send_handle == nullptr) { r = w->Dispatch(uv_write, stream(), bufs, count, AfterUvWrite); } else { r = w->Dispatch(uv_write2, stream(), bufs, count, send_handle, AfterUvWrite); } if (!r) { size_t bytes = 0; for (size_t i = 0; i < count; i++) bytes += bufs[i].len; if (stream()->type == UV_TCP) { NODE_COUNT_NET_BYTES_SENT(bytes); } else if (stream()->type == UV_NAMED_PIPE) { NODE_COUNT_PIPE_BYTES_SENT(bytes); } } return r; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [find_next_quote( char_u *line, int col, int quotechar, char_u *escape) // escape characters, can be NULL { int c; for (;;) { c = line[col]; if (c == NUL) return -1; else if (escape != NULL && vim_strchr(escape, c)) ++col; else if (c == quotechar) break; if (has_mbyte) col += (*mb_ptr2len)(line + col); else ++col; } return col; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void CLASS parse_exif(int base) { unsigned kodak, entries, tag, type, len, save, c; double expo, ape; kodak = !strncmp(make, "EASTMAN", 7) && tiff_nifds < 3; entries = get2(); if (!strncmp(make, "Hasselblad", 10) && (tiff_nifds > 3) && (entries > 512)) return; #ifdef LIBRAW_LIBRARY_BUILD INT64 fsize = ifp->size(); #endif while (entries--) { tiff_get(base, &tag, &type, &len, &save); #ifdef LIBRAW_LIBRARY_BUILD INT64 savepos = ftell(ifp); if (len > 8 && savepos + len > fsize * 2) continue; if (callbacks.exif_cb) { callbacks.exif_cb(callbacks.exifparser_data, tag, type, len, order, ifp); fseek(ifp, savepos, SEEK_SET); } #endif switch (tag) { #ifdef LIBRAW_LIBRARY_BUILD case 0xa405: // FocalLengthIn35mmFormat imgdata.lens.FocalLengthIn35mmFormat = get2(); break; case 0xa431: // BodySerialNumber stmread(imgdata.shootinginfo.BodySerial, len, ifp); break; case 0xa432: // LensInfo, 42034dec, Lens Specification per EXIF standard imgdata.lens.MinFocal = getreal(type); imgdata.lens.MaxFocal = getreal(type); imgdata.lens.MaxAp4MinFocal = getreal(type); imgdata.lens.MaxAp4MaxFocal = getreal(type); break; case 0xa435: // LensSerialNumber stmread(imgdata.lens.LensSerial, len, ifp); break; case 0xc630: // DNG LensInfo, Lens Specification per EXIF standard imgdata.lens.dng.MinFocal = getreal(type); imgdata.lens.dng.MaxFocal = getreal(type); imgdata.lens.dng.MaxAp4MinFocal = getreal(type); imgdata.lens.dng.MaxAp4MaxFocal = getreal(type); break; case 0xa433: // LensMake stmread(imgdata.lens.LensMake, len, ifp); break; case 0xa434: // LensModel stmread(imgdata.lens.Lens, len, ifp); if (!strncmp(imgdata.lens.Lens, "----", 4)) imgdata.lens.Lens[0] = 0; break; case 0x9205: imgdata.lens.EXIF_MaxAp = powf64(2.0f, (getreal(type) / 2.0f)); break; #endif case 33434: tiff_ifd[tiff_nifds - 1].t_shutter = shutter = getreal(type); break; case 33437: aperture = getreal(type); break; // 0x829d FNumber case 34855: iso_speed = get2(); break; case 34866: if (iso_speed == 0xffff && (!strncasecmp(make, "SONY", 4) || !strncasecmp(make, "CANON", 5))) iso_speed = getreal(type); break; case 36867: case 36868: get_timestamp(0); break; case 37377: if ((expo = -getreal(type)) < 128 && shutter == 0.) tiff_ifd[tiff_nifds - 1].t_shutter = shutter = powf64(2.0, expo); break; case 37378: // 0x9202 ApertureValue if ((fabs(ape = getreal(type)) < 256.0) && (!aperture)) aperture = powf64(2.0, ape / 2); break; case 37385: flash_used = getreal(type); break; case 37386: focal_len = getreal(type); break; case 37500: // tag 0x927c #ifdef LIBRAW_LIBRARY_BUILD if (((make[0] == '\0') && (!strncmp(model, "ov5647", 6))) || ((!strncmp(make, "RaspberryPi", 11)) && (!strncmp(model, "RP_OV5647", 9))) || ((!strncmp(make, "RaspberryPi", 11)) && (!strncmp(model, "RP_imx219", 9)))) { char mn_text[512]; char *pos; char ccms[512]; ushort l; float num; fgets(mn_text, len, ifp); pos = strstr(mn_text, "gain_r="); if (pos) cam_mul[0] = atof(pos + 7); pos = strstr(mn_text, "gain_b="); if (pos) cam_mul[2] = atof(pos + 7); if ((cam_mul[0] > 0.001f) && (cam_mul[2] > 0.001f)) cam_mul[1] = cam_mul[3] = 1.0f; else cam_mul[0] = cam_mul[2] = 0.0f; pos = strstr(mn_text, "ccm=") + 4; l = strstr(pos, " ") - pos; memcpy(ccms, pos, l); ccms[l] = '\0'; pos = strtok(ccms, ","); for (l = 0; l < 4; l++) { num = 0.0; for (c = 0; c < 3; c++) { imgdata.color.ccm[l][c] = (float)atoi(pos); num += imgdata.color.ccm[l][c]; pos = strtok(NULL, ","); } if (num > 0.01) FORC3 imgdata.color.ccm[l][c] = imgdata.color.ccm[l][c] / num; } } else #endif parse_makernote(base, 0); break; case 40962: if (kodak) raw_width = get4(); break; case 40963: if (kodak) raw_height = get4(); break; case 41730: if (get4() == 0x20002) for (exif_cfa = c = 0; c < 8; c += 2) exif_cfa |= fgetc(ifp) * 0x01010101 << c; } fseek(ifp, save, SEEK_SET); } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [jio_vsnprintf(char * str, int n, const char * format, va_list args) { int result; Trc_SC_vsnprintf_Entry(str, n, format); #if defined(WIN32) && !defined(WIN32_IBMC) result = _vsnprintf( str, n, format, args ); #else result = vsprintf( str, format, args ); #endif Trc_SC_vsnprintf_Exit(result); return result; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; if (!pi->first) { comp = &pi->comps[pi->compno]; goto LABEL_SKIP; } else { pi->first = 0; } for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) { int resno; comp = &pi->comps[pi->compno]; pi->dx = 0; pi->dy = 0; for (resno = 0; resno < comp->numresolutions; resno++) { int dx, dy; res = &comp->resolutions[resno]; dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno)); dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno)); pi->dx = !pi->dx ? dx : int_min(pi->dx, dx); pi->dy = !pi->dy ? dy : int_min(pi->dy, dy); } if (!pi->tp_on) { pi->poc.ty0 = pi->ty0; pi->poc.tx0 = pi->tx0; pi->poc.ty1 = pi->ty1; pi->poc.tx1 = pi->tx1; } for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) { for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) { for (pi->resno = pi->poc.resno0; pi->resno < int_min(pi->poc.resno1, comp->numresolutions); pi->resno++) { int levelno; int trx0, try0; int trx1, try1; int rpx, rpy; int prci, prcj; res = &comp->resolutions[pi->resno]; levelno = comp->numresolutions - 1 - pi->resno; trx0 = int_ceildiv(pi->tx0, comp->dx << levelno); try0 = int_ceildiv(pi->ty0, comp->dy << levelno); trx1 = int_ceildiv(pi->tx1, comp->dx << levelno); try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))) { continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))) { continue; } if ((res->pw == 0) || (res->ph == 0)) { continue; } if ((trx0 == trx1) || (try0 == try1)) { continue; } prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx) - int_floordivpow2(trx0, res->pdx); prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy) - int_floordivpow2(try0, res->pdy); pi->precno = prci + prcj * res->pw; for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; return OPJ_TRUE; } LABEL_SKIP: ; } } } } } return OPJ_FALSE; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) { Iterator i; Unit *u; const char *t; char **e; int r; assert(m); assert(f); assert(fds); m->n_reloading ++; fprintf(f, "current-job-id=%i\n", m->current_job_id); fprintf(f, "taint-usr=%s\n", yes_no(m->taint_usr)); fprintf(f, "n-installed-jobs=%u\n", m->n_installed_jobs); fprintf(f, "n-failed-jobs=%u\n", m->n_failed_jobs); dual_timestamp_serialize(f, "firmware-timestamp", &m->firmware_timestamp); dual_timestamp_serialize(f, "loader-timestamp", &m->loader_timestamp); dual_timestamp_serialize(f, "kernel-timestamp", &m->kernel_timestamp); dual_timestamp_serialize(f, "initrd-timestamp", &m->initrd_timestamp); if (!in_initrd()) { dual_timestamp_serialize(f, "userspace-timestamp", &m->userspace_timestamp); dual_timestamp_serialize(f, "finish-timestamp", &m->finish_timestamp); dual_timestamp_serialize(f, "security-start-timestamp", &m->security_start_timestamp); dual_timestamp_serialize(f, "security-finish-timestamp", &m->security_finish_timestamp); dual_timestamp_serialize(f, "generators-start-timestamp", &m->generators_start_timestamp); dual_timestamp_serialize(f, "generators-finish-timestamp", &m->generators_finish_timestamp); dual_timestamp_serialize(f, "units-load-start-timestamp", &m->units_load_start_timestamp); dual_timestamp_serialize(f, "units-load-finish-timestamp", &m->units_load_finish_timestamp); } if (!switching_root) { STRV_FOREACH(e, m->environment) { _cleanup_free_ char *ce; ce = cescape(*e); if (!ce) return -ENOMEM; fprintf(f, "env=%s\n", *e); } } if (m->notify_fd >= 0) { int copy; copy = fdset_put_dup(fds, m->notify_fd); if (copy < 0) return copy; fprintf(f, "notify-fd=%i\n", copy); fprintf(f, "notify-socket=%s\n", m->notify_socket); } if (m->kdbus_fd >= 0) { int copy; copy = fdset_put_dup(fds, m->kdbus_fd); if (copy < 0) return copy; fprintf(f, "kdbus-fd=%i\n", copy); } bus_serialize(m, f); fputc('\n', f); HASHMAP_FOREACH_KEY(u, t, m->units, i) { if (u->id != t) continue; if (!unit_can_serialize(u)) continue; /* Start marker */ fputs(u->id, f); fputc('\n', f); r = unit_serialize(u, f, fds, !switching_root); if (r < 0) { m->n_reloading --; return r; } } assert(m->n_reloading > 0); m->n_reloading --; if (ferror(f)) return -EIO; r = bus_fdset_add_all(m, fds); if (r < 0) return r; return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void luaV_execute (lua_State *L, CallInfo *ci) { LClosure *cl; TValue *k; StkId base; const Instruction *pc; int trap; #if LUA_USE_JUMPTABLE #include "ljumptab.h" #endif tailcall: trap = L->hookmask; cl = clLvalue(s2v(ci->func)); k = cl->p->k; pc = ci->u.l.savedpc; if (trap) { if (cl->p->is_vararg) trap = 0; /* hooks will start after VARARGPREP instruction */ else if (pc == cl->p->code) /* first instruction (not resuming)? */ luaD_hookcall(L, ci); ci->u.l.trap = 1; /* there may be other hooks */ } base = ci->func + 1; /* main loop of interpreter */ for (;;) { Instruction i; /* instruction being executed */ StkId ra; /* instruction's A register */ vmfetch(); lua_assert(base == ci->func + 1); lua_assert(base <= L->top && L->top < L->stack + L->stacksize); /* invalidate top for instructions not expecting it */ lua_assert(isIT(i) || (cast_void(L->top = base), 1)); vmdispatch (GET_OPCODE(i)) { vmcase(OP_MOVE) { setobjs2s(L, ra, RB(i)); vmbreak; } vmcase(OP_LOADI) { lua_Integer b = GETARG_sBx(i); setivalue(s2v(ra), b); vmbreak; } vmcase(OP_LOADF) { int b = GETARG_sBx(i); setfltvalue(s2v(ra), cast_num(b)); vmbreak; } vmcase(OP_LOADK) { TValue *rb = k + GETARG_Bx(i); setobj2s(L, ra, rb); vmbreak; } vmcase(OP_LOADKX) { TValue *rb; rb = k + GETARG_Ax(*pc); pc++; setobj2s(L, ra, rb); vmbreak; } vmcase(OP_LOADFALSE) { setbfvalue(s2v(ra)); vmbreak; } vmcase(OP_LFALSESKIP) { setbfvalue(s2v(ra)); pc++; /* skip next instruction */ vmbreak; } vmcase(OP_LOADTRUE) { setbtvalue(s2v(ra)); vmbreak; } vmcase(OP_LOADNIL) { int b = GETARG_B(i); do { setnilvalue(s2v(ra++)); } while (b--); vmbreak; } vmcase(OP_GETUPVAL) { int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); vmbreak; } vmcase(OP_SETUPVAL) { UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, s2v(ra)); luaC_barrier(L, uv, s2v(ra)); vmbreak; } vmcase(OP_GETTABUP) { const TValue *slot; TValue *upval = cl->upvals[GETARG_B(i)]->v; TValue *rc = KC(i); TString *key = tsvalue(rc); /* key must be a string */ if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { setobj2s(L, ra, slot); } else Protect(luaV_finishget(L, upval, rc, ra, slot)); vmbreak; } vmcase(OP_GETTABLE) { const TValue *slot; TValue *rb = vRB(i); TValue *rc = vRC(i); lua_Unsigned n; if (ttisinteger(rc) /* fast track for integers? */ ? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot)) : luaV_fastget(L, rb, rc, slot, luaH_get)) { setobj2s(L, ra, slot); } else Protect(luaV_finishget(L, rb, rc, ra, slot)); vmbreak; } vmcase(OP_GETI) { const TValue *slot; TValue *rb = vRB(i); int c = GETARG_C(i); if (luaV_fastgeti(L, rb, c, slot)) { setobj2s(L, ra, slot); } else { TValue key; setivalue(&key, c); Protect(luaV_finishget(L, rb, &key, ra, slot)); } vmbreak; } vmcase(OP_GETFIELD) { const TValue *slot; TValue *rb = vRB(i); TValue *rc = KC(i); TString *key = tsvalue(rc); /* key must be a string */ if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) { setobj2s(L, ra, slot); } else Protect(luaV_finishget(L, rb, rc, ra, slot)); vmbreak; } vmcase(OP_SETTABUP) { const TValue *slot; TValue *upval = cl->upvals[GETARG_A(i)]->v; TValue *rb = KB(i); TValue *rc = RKC(i); TString *key = tsvalue(rb); /* key must be a string */ if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { luaV_finishfastset(L, upval, slot, rc); } else Protect(luaV_finishset(L, upval, rb, rc, slot)); vmbreak; } vmcase(OP_SETTABLE) { const TValue *slot; TValue *rb = vRB(i); /* key (table is in 'ra') */ TValue *rc = RKC(i); /* value */ lua_Unsigned n; if (ttisinteger(rb) /* fast track for integers? */ ? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot)) : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) { luaV_finishfastset(L, s2v(ra), slot, rc); } else Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); vmbreak; } vmcase(OP_SETI) { const TValue *slot; int c = GETARG_B(i); TValue *rc = RKC(i); if (luaV_fastgeti(L, s2v(ra), c, slot)) { luaV_finishfastset(L, s2v(ra), slot, rc); } else { TValue key; setivalue(&key, c); Protect(luaV_finishset(L, s2v(ra), &key, rc, slot)); } vmbreak; } vmcase(OP_SETFIELD) { const TValue *slot; TValue *rb = KB(i); TValue *rc = RKC(i); TString *key = tsvalue(rb); /* key must be a string */ if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) { luaV_finishfastset(L, s2v(ra), slot, rc); } else Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); vmbreak; } vmcase(OP_NEWTABLE) { int b = GETARG_B(i); /* log2(hash size) + 1 */ int c = GETARG_C(i); /* array size */ Table *t; if (b > 0) b = 1 << (b - 1); /* size is 2^(b - 1) */ lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0)); if (TESTARG_k(i)) /* non-zero extra argument? */ c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */ pc++; /* skip extra argument */ L->top = ra + 1; /* correct top in case of emergency GC */ t = luaH_new(L); /* memory allocation */ sethvalue2s(L, ra, t); if (b != 0 || c != 0) luaH_resize(L, t, c, b); /* idem */ checkGC(L, ra + 1); vmbreak; } vmcase(OP_SELF) { const TValue *slot; TValue *rb = vRB(i); TValue *rc = RKC(i); TString *key = tsvalue(rc); /* key must be a string */ setobj2s(L, ra + 1, rb); if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { setobj2s(L, ra, slot); } else Protect(luaV_finishget(L, rb, rc, ra, slot)); vmbreak; } vmcase(OP_ADDI) { op_arithI(L, l_addi, luai_numadd); vmbreak; } vmcase(OP_ADDK) { op_arithK(L, l_addi, luai_numadd); vmbreak; } vmcase(OP_SUBK) { op_arithK(L, l_subi, luai_numsub); vmbreak; } vmcase(OP_MULK) { op_arithK(L, l_muli, luai_nummul); vmbreak; } vmcase(OP_MODK) { op_arithK(L, luaV_mod, luaV_modf); vmbreak; } vmcase(OP_POWK) { op_arithfK(L, luai_numpow); vmbreak; } vmcase(OP_DIVK) { op_arithfK(L, luai_numdiv); vmbreak; } vmcase(OP_IDIVK) { op_arithK(L, luaV_idiv, luai_numidiv); vmbreak; } vmcase(OP_BANDK) { op_bitwiseK(L, l_band); vmbreak; } vmcase(OP_BORK) { op_bitwiseK(L, l_bor); vmbreak; } vmcase(OP_BXORK) { op_bitwiseK(L, l_bxor); vmbreak; } vmcase(OP_SHRI) { TValue *rb = vRB(i); int ic = GETARG_sC(i); lua_Integer ib; if (tointegerns(rb, &ib)) { pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic)); } vmbreak; } vmcase(OP_SHLI) { TValue *rb = vRB(i); int ic = GETARG_sC(i); lua_Integer ib; if (tointegerns(rb, &ib)) { pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib)); } vmbreak; } vmcase(OP_ADD) { op_arith(L, l_addi, luai_numadd); vmbreak; } vmcase(OP_SUB) { op_arith(L, l_subi, luai_numsub); vmbreak; } vmcase(OP_MUL) { op_arith(L, l_muli, luai_nummul); vmbreak; } vmcase(OP_MOD) { op_arith(L, luaV_mod, luaV_modf); vmbreak; } vmcase(OP_POW) { op_arithf(L, luai_numpow); vmbreak; } vmcase(OP_DIV) { /* float division (always with floats) */ op_arithf(L, luai_numdiv); vmbreak; } vmcase(OP_IDIV) { /* floor division */ op_arith(L, luaV_idiv, luai_numidiv); vmbreak; } vmcase(OP_BAND) { op_bitwise(L, l_band); vmbreak; } vmcase(OP_BOR) { op_bitwise(L, l_bor); vmbreak; } vmcase(OP_BXOR) { op_bitwise(L, l_bxor); vmbreak; } vmcase(OP_SHR) { op_bitwise(L, luaV_shiftr); vmbreak; } vmcase(OP_SHL) { op_bitwise(L, luaV_shiftl); vmbreak; } vmcase(OP_MMBIN) { Instruction pi = *(pc - 2); /* original arith. expression */ TValue *rb = vRB(i); TMS tm = (TMS)GETARG_C(i); StkId result = RA(pi); lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR); Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm)); vmbreak; } vmcase(OP_MMBINI) { Instruction pi = *(pc - 2); /* original arith. expression */ int imm = GETARG_sB(i); TMS tm = (TMS)GETARG_C(i); int flip = GETARG_k(i); StkId result = RA(pi); Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm)); vmbreak; } vmcase(OP_MMBINK) { Instruction pi = *(pc - 2); /* original arith. expression */ TValue *imm = KB(i); TMS tm = (TMS)GETARG_C(i); int flip = GETARG_k(i); StkId result = RA(pi); Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm)); vmbreak; } vmcase(OP_UNM) { TValue *rb = vRB(i); lua_Number nb; if (ttisinteger(rb)) { lua_Integer ib = ivalue(rb); setivalue(s2v(ra), intop(-, 0, ib)); } else if (tonumberns(rb, nb)) { setfltvalue(s2v(ra), luai_numunm(L, nb)); } else Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); vmbreak; } vmcase(OP_BNOT) { TValue *rb = vRB(i); lua_Integer ib; if (tointegerns(rb, &ib)) { setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib)); } else Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); vmbreak; } vmcase(OP_NOT) { TValue *rb = vRB(i); if (l_isfalse(rb)) setbtvalue(s2v(ra)); else setbfvalue(s2v(ra)); vmbreak; } vmcase(OP_LEN) { Protect(luaV_objlen(L, ra, vRB(i))); vmbreak; } vmcase(OP_CONCAT) { int n = GETARG_B(i); /* number of elements to concatenate */ L->top = ra + n; /* mark the end of concat operands */ ProtectNT(luaV_concat(L, n)); checkGC(L, L->top); /* 'luaV_concat' ensures correct top */ vmbreak; } vmcase(OP_CLOSE) { Protect(luaF_close(L, ra, LUA_OK)); vmbreak; } vmcase(OP_TBC) { /* create new to-be-closed upvalue */ halfProtect(luaF_newtbcupval(L, ra)); vmbreak; } vmcase(OP_JMP) { dojump(ci, i, 0); vmbreak; } vmcase(OP_EQ) { int cond; TValue *rb = vRB(i); Protect(cond = luaV_equalobj(L, s2v(ra), rb)); docondjump(); vmbreak; } vmcase(OP_LT) { op_order(L, l_lti, LTnum, lessthanothers); vmbreak; } vmcase(OP_LE) { op_order(L, l_lei, LEnum, lessequalothers); vmbreak; } vmcase(OP_EQK) { TValue *rb = KB(i); /* basic types do not use '__eq'; we can use raw equality */ int cond = luaV_rawequalobj(s2v(ra), rb); docondjump(); vmbreak; } vmcase(OP_EQI) { int cond; int im = GETARG_sB(i); if (ttisinteger(s2v(ra))) cond = (ivalue(s2v(ra)) == im); else if (ttisfloat(s2v(ra))) cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im)); else cond = 0; /* other types cannot be equal to a number */ docondjump(); vmbreak; } vmcase(OP_LTI) { op_orderI(L, l_lti, luai_numlt, 0, TM_LT); vmbreak; } vmcase(OP_LEI) { op_orderI(L, l_lei, luai_numle, 0, TM_LE); vmbreak; } vmcase(OP_GTI) { op_orderI(L, l_gti, luai_numgt, 1, TM_LT); vmbreak; } vmcase(OP_GEI) { op_orderI(L, l_gei, luai_numge, 1, TM_LE); vmbreak; } vmcase(OP_TEST) { int cond = !l_isfalse(s2v(ra)); docondjump(); vmbreak; } vmcase(OP_TESTSET) { TValue *rb = vRB(i); if (l_isfalse(rb) == GETARG_k(i)) pc++; else { setobj2s(L, ra, rb); donextjump(ci); } vmbreak; } vmcase(OP_CALL) { int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; if (b != 0) /* fixed number of arguments? */ L->top = ra + b; /* top signals number of arguments */ /* else previous instruction set top */ ProtectNT(luaD_call(L, ra, nresults)); vmbreak; } vmcase(OP_TAILCALL) { int b = GETARG_B(i); /* number of arguments + 1 (function) */ int nparams1 = GETARG_C(i); /* delat is virtual 'func' - real 'func' (vararg functions) */ int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; if (b != 0) L->top = ra + b; else /* previous instruction set top */ b = cast_int(L->top - ra); savepc(ci); /* some calls here can raise errors */ if (TESTARG_k(i)) { /* close upvalues from current call; the compiler ensures that there are no to-be-closed variables here, so this call cannot change the stack */ luaF_close(L, base, NOCLOSINGMETH); lua_assert(base == ci->func + 1); } while (!ttisfunction(s2v(ra))) { /* not a function? */ luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ b++; /* there is now one extra argument */ checkstackp(L, 1, ra); } if (!ttisLclosure(s2v(ra))) { /* C function? */ luaD_call(L, ra, LUA_MULTRET); /* call it */ updatetrap(ci); updatestack(ci); /* stack may have been relocated */ ci->func -= delta; luaD_poscall(L, ci, cast_int(L->top - ra)); return; } ci->func -= delta; luaD_pretailcall(L, ci, ra, b); /* prepare call frame */ goto tailcall; } vmcase(OP_RETURN) { int n = GETARG_B(i) - 1; /* number of results */ int nparams1 = GETARG_C(i); if (n < 0) /* not fixed? */ n = cast_int(L->top - ra); /* get what is available */ savepc(ci); if (TESTARG_k(i)) { /* may there be open upvalues? */ if (L->top < ci->top) L->top = ci->top; luaF_close(L, base, LUA_OK); updatetrap(ci); updatestack(ci); } if (nparams1) /* vararg function? */ ci->func -= ci->u.l.nextraargs + nparams1; L->top = ra + n; /* set call for 'luaD_poscall' */ luaD_poscall(L, ci, n); return; } vmcase(OP_RETURN0) { if (L->hookmask) { L->top = ra; halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */ } else { /* do the 'poscall' here */ int nres = ci->nresults; L->ci = ci->previous; /* back to caller */ L->top = base - 1; while (nres-- > 0) setnilvalue(s2v(L->top++)); /* all results are nil */ } return; } vmcase(OP_RETURN1) { if (L->hookmask) { L->top = ra + 1; halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */ } else { /* do the 'poscall' here */ int nres = ci->nresults; L->ci = ci->previous; /* back to caller */ if (nres == 0) L->top = base - 1; /* asked for no results */ else { setobjs2s(L, base - 1, ra); /* at least this result */ L->top = base; while (--nres > 0) /* complete missing results */ setnilvalue(s2v(L->top++)); } } return; } vmcase(OP_FORLOOP) { if (ttisinteger(s2v(ra + 2))) { /* integer loop? */ lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1))); if (count > 0) { /* still more iterations? */ lua_Integer step = ivalue(s2v(ra + 2)); lua_Integer idx = ivalue(s2v(ra)); /* internal index */ chgivalue(s2v(ra + 1), count - 1); /* update counter */ idx = intop(+, idx, step); /* add step to index */ chgivalue(s2v(ra), idx); /* update internal index */ setivalue(s2v(ra + 3), idx); /* and control variable */ pc -= GETARG_Bx(i); /* jump back */ } } else if (floatforloop(ra)) /* float loop */ pc -= GETARG_Bx(i); /* jump back */ updatetrap(ci); /* allows a signal to break the loop */ vmbreak; } vmcase(OP_FORPREP) { savestate(L, ci); /* in case of errors */ if (forprep(L, ra)) pc += GETARG_Bx(i) + 1; /* skip the loop */ vmbreak; } vmcase(OP_TFORPREP) { /* create to-be-closed upvalue (if needed) */ halfProtect(luaF_newtbcupval(L, ra + 3)); pc += GETARG_Bx(i); i = *(pc++); /* go to next instruction */ lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i)); goto l_tforcall; } vmcase(OP_TFORCALL) { l_tforcall: /* 'ra' has the iterator function, 'ra + 1' has the state, 'ra + 2' has the control variable, and 'ra + 3' has the to-be-closed variable. The call will use the stack after these values (starting at 'ra + 4') */ /* push function, state, and control variable */ memcpy(ra + 4, ra, 3 * sizeof(*ra)); L->top = ra + 4 + 3; ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */ updatestack(ci); /* stack may have changed */ i = *(pc++); /* go to next instruction */ lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i)); goto l_tforloop; } vmcase(OP_TFORLOOP) { l_tforloop: if (!ttisnil(s2v(ra + 4))) { /* continue loop? */ setobjs2s(L, ra + 2, ra + 4); /* save control variable */ pc -= GETARG_Bx(i); /* jump back */ } vmbreak; } vmcase(OP_SETLIST) { int n = GETARG_B(i); unsigned int last = GETARG_C(i); Table *h = hvalue(s2v(ra)); if (n == 0) n = cast_int(L->top - ra) - 1; /* get up to the top */ else L->top = ci->top; /* correct top in case of emergency GC */ last += n; if (TESTARG_k(i)) { last += GETARG_Ax(*pc) * (MAXARG_C + 1); pc++; } if (last > luaH_realasize(h)) /* needs more space? */ luaH_resizearray(L, h, last); /* preallocate it at once */ for (; n > 0; n--) { TValue *val = s2v(ra + n); setobj2t(L, &h->array[last - 1], val); last--; luaC_barrierback(L, obj2gco(h), val); } vmbreak; } vmcase(OP_CLOSURE) { Proto *p = cl->p->p[GETARG_Bx(i)]; halfProtect(pushclosure(L, p, cl->upvals, base, ra)); checkGC(L, ra + 1); vmbreak; } vmcase(OP_VARARG) { int n = GETARG_C(i) - 1; /* required results */ Protect(luaT_getvarargs(L, ci, ra, n)); vmbreak; } vmcase(OP_VARARGPREP) { luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p); updatetrap(ci); if (trap) { luaD_hookcall(L, ci); L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */ } updatebase(ci); /* function has new base after adjustment */ vmbreak; } vmcase(OP_EXTRAARG) { lua_assert(0); vmbreak; } } } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [YR_OBJECT* yr_object_lookup_field( YR_OBJECT* object, const char* field_name) { YR_STRUCTURE_MEMBER* member; assert(object != NULL); assert(object->type == OBJECT_TYPE_STRUCTURE); member = object_as_structure(object)->members; while (member != NULL) { if (strcmp(member->object->identifier, field_name) == 0) return member->object; member = member->next; } return NULL; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [_equalRuleStmt(const RuleStmt *a, const RuleStmt *b) { COMPARE_NODE_FIELD(relation); COMPARE_STRING_FIELD(rulename); COMPARE_NODE_FIELD(whereClause); COMPARE_SCALAR_FIELD(event); COMPARE_SCALAR_FIELD(instead); COMPARE_NODE_FIELD(actions); COMPARE_SCALAR_FIELD(replace); return true; }] Response: 0