diff --git a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_balanced_10to1.jsonl b/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_balanced_10to1.jsonl deleted file mode 100644 index 4da84d6aba0efaa1224852f1e0a80e22879f46f8..0000000000000000000000000000000000000000 --- a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_balanced_10to1.jsonl +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8155abf7d071a59130ee1dff2cbb16881c2021421c6d641cd214e29328da5219 -size 80502687 diff --git a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_filtered_total_length.jsonl b/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_filtered_total_length.jsonl deleted file mode 100644 index bafcdfc68e14356c01fd6953df0e846131a803e1..0000000000000000000000000000000000000000 --- a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_filtered_total_length.jsonl +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd5259f21f09e2c83901a8d4163e02c4d260437660e202b55d1bfa223aa2ad66 -size 227618564 diff --git a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_mistral_formatted.jsonl b/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_mistral_formatted.jsonl deleted file mode 100644 index 0af77501787273d05636b03f98dc4bca61531205..0000000000000000000000000000000000000000 --- a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_train_mistral_formatted.jsonl +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2b7b605b9e65b88c4a7b792f3ef636591c801b6c4c38aa48b2ec447227f95003 -size 209731584 diff --git a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_valid_balanced_10to1.jsonl b/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_valid_balanced_10to1.jsonl deleted file mode 100644 index dc4167dcf63b64e43d53a65a9f5d47aa26f5a68a..0000000000000000000000000000000000000000 --- a/Primevul_categorized_&_processed_for_finetuning/4.primevul_train_mistral_formatted/primevul_valid_balanced_10to1.jsonl +++ /dev/null @@ -1,6523 +0,0 @@ -{"idx": 473438, "input": "int crypto_rsa_public_encrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* exponent, BYTE* output) { return crypto_rsa_public(input, length, key_length, modulus, exponent, output); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 394651, "input": "LJ_NOINLINE void LJ_FASTCALL lj_err_run(lua_State *L) { ptrdiff_t ef = finderrfunc(L); if (ef) { TValue *errfunc = restorestack(L, ef); TValue *top = L->top; lj_trace_abort(G(L)); if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); lj_err_throw(L, LUA_ERRERR); } L->status = LUA_ERRERR; copyTV(L, top, top-1); copyTV(L, top-1, errfunc); L->top = top+1; lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ } lj_err_throw(L, LUA_ERRRUN); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 349486, "input": "p11_rpc_buffer_get_byte_array_value (p11_buffer *buffer, size_t *offset, void *value, CK_ULONG *value_length) { const unsigned char *val; size_t len; if (!p11_rpc_buffer_get_byte_array (buffer, offset, &val, &len)) return false; if (val && value) memcpy (value, val, len); if (value_length) *value_length = len; return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354541, "input": "static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) { switch (arg) { case KVM_CAP_USER_MEMORY: case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS: case KVM_CAP_INTERNAL_ERROR_DATA: #ifdef CONFIG_HAVE_KVM_MSI case KVM_CAP_SIGNAL_MSI: #endif #ifdef CONFIG_HAVE_KVM_IRQFD case KVM_CAP_IRQFD: case KVM_CAP_IRQFD_RESAMPLE: #endif case KVM_CAP_IOEVENTFD_ANY_LENGTH: case KVM_CAP_CHECK_EXTENSION_VM: case KVM_CAP_ENABLE_CAP_VM: return 1; #ifdef CONFIG_KVM_MMIO case KVM_CAP_COALESCED_MMIO: return KVM_COALESCED_MMIO_PAGE_OFFSET; case KVM_CAP_COALESCED_PIO: return 1; #endif #ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT case KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2: return KVM_DIRTY_LOG_MANUAL_CAPS; #endif #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING case KVM_CAP_IRQ_ROUTING: return KVM_MAX_IRQ_ROUTES; #endif #if KVM_ADDRESS_SPACE_NUM > 1 case KVM_CAP_MULTI_ADDRESS_SPACE: return KVM_ADDRESS_SPACE_NUM; #endif case KVM_CAP_NR_MEMSLOTS: return KVM_USER_MEM_SLOTS; default: break; } return kvm_vm_ioctl_check_extension(kvm, arg); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 291401, "input": "static void php_openssl_csr_free(zend_resource *rsrc) { X509_REQ * csr = (X509_REQ*)rsrc->ptr; X509_REQ_free(csr); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 438546, "input": "MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class) { assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename); image->storage_class=storage_class; return(SyncImagePixelCache(image,&image->exception)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 254806, "input": "static void deletePortsStats(struct port_stats *stats) { struct port_stats *current_port, *tmp; HASH_ITER(hh, stats, current_port, tmp) { HASH_DEL(stats, current_port); freeIpTree(current_port->addr_tree); free(current_port); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 330515, "input": "ssize_t vnc_tls_push(const char *buf, size_t len, void *opaque) { VncState *vs = opaque; ssize_t ret; retry: ret = send(vs->csock, buf, len, 0); if (ret < 0) { if (errno == EINTR) { goto retry; } return -1; } return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431223, "input": "int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) { struct nfs4_exception exception = { .interruptible = true, }; int err; do { err = nfs4_handle_exception(server, _nfs4_server_capabilities(server, fhandle), &exception); } while (exception.retry); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416663, "input": "static enum_func_status php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len, char *error, int error_buf_len, unsigned int *error_no, char *sqlstate TSRMLS_DC) { zend_uchar *p = buf; int error_msg_len= 0; DBG_ENTER(\"php_mysqlnd_read_error_from_line\"); *error_no = CR_UNKNOWN_ERROR; memcpy(sqlstate, unknown_sqlstate, MYSQLND_SQLSTATE_LENGTH); if (buf_len > 2) { *error_no = uint2korr(p); p+= 2; /* sqlstate is following. No need to check for buf_left_len as we checked > 2 above, if it was >=2 then we would need a check */ if (*p == '#') { ++p; if ((buf_len - (p - buf)) >= MYSQLND_SQLSTATE_LENGTH) { memcpy(sqlstate, p, MYSQLND_SQLSTATE_LENGTH); p+= MYSQLND_SQLSTATE_LENGTH; } else { goto end; } } if ((buf_len - (p - buf)) > 0) { error_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1)); memcpy(error, p, error_msg_len); } } end: sqlstate[MYSQLND_SQLSTATE_LENGTH] = '\\0'; error[error_msg_len]= '\\0'; DBG_RETURN(FAIL);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 402396, "input": "HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob(\"HttpStateData\"), Client(theFwdState), lastChunk(0), httpChunkDecoder(NULL), payloadSeen(0), payloadTruncated(0), sawDateGoBack(false) { debugs(11,5,HERE << \"HttpStateData \" << this << \" created\"); ignoreCacheControl = false; surrogateNoStore = false; serverConnection = fwd->serverConnection(); if (fwd->serverConnection() != NULL) _peer = cbdataReference(fwd->serverConnection()->getPeer()); /* might be NULL */ if (_peer) { request->flags.proxying = true; /* * This NEIGHBOR_PROXY_ONLY check probably shouldn't be here. * We might end up getting the object from somewhere else if, * for example, the request to this neighbor fails. */ if (_peer->options.proxy_only) entry->releaseRequest(true); #if USE_DELAY_POOLS entry->setNoDelay(_peer->options.no_delay); #endif } /* * register the handler to free HTTP state data when the FD closes */ typedef CommCbMemFunT Dialer; closeHandler = JobCallback(9, 5, Dialer, this, HttpStateData::httpStateConnClosed); comm_add_close_handler(serverConnection->fd, closeHandler); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246842, "input": "GF_EXPORT GF_Err gf_isom_get_sample_cenc_info(GF_ISOFile *movie, u32 track, u32 sample_number, Bool *IsEncrypted, u8 *crypt_byte_block, u8 *skip_byte_block, const u8 **key_info, u32 *key_info_size) { GF_TrackBox *trak = gf_isom_get_track_from_file(movie, track); GF_SampleEncryptionBox *senc = trak->sample_encryption; return gf_isom_get_sample_cenc_info_internal(trak, NULL, senc, sample_number, IsEncrypted, crypt_byte_block, skip_byte_block, key_info, key_info_size);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334512, "input": "mono_method_get_token (MonoMethod *method) { return method->token; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 234088, "input": "int processCertificate(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { struct ndpi_packet_struct *packet = &flow->packet; int is_dtls = packet->udp ? 1 : 0; u_int32_t certificates_length, length = (packet->payload[1] << 16) + (packet->payload[2] << 8) + packet->payload[3]; u_int32_t certificates_offset = 7 + (is_dtls ? 8 : 0); u_int8_t num_certificates_found = 0; SHA1_CTX srv_cert_fingerprint_ctx ; #ifdef DEBUG_TLS printf(\"[TLS] %s() [payload_packet_len=%u][direction: %u][%02X %02X %02X %02X %02X %02X...]\\n\", __FUNCTION__, packet->payload_packet_len, packet->packet_direction, packet->payload[0], packet->payload[1], packet->payload[2], packet->payload[3], packet->payload[4], packet->payload[5]); #endif if((packet->payload_packet_len != (length + 4 + (is_dtls ? 8 : 0))) || (packet->payload[1] != 0x0)) { ndpi_set_risk(flow, NDPI_MALFORMED_PACKET); return(-1); /* Invalid length */ } certificates_length = (packet->payload[certificates_offset - 3] << 16) + (packet->payload[certificates_offset - 2] << 8) + packet->payload[certificates_offset - 1]; if((packet->payload[certificates_offset - 3] != 0x0) || ((certificates_length+3) != length)) { ndpi_set_risk(flow, NDPI_MALFORMED_PACKET); return(-2); /* Invalid length */ } /* Now let's process each individual certificates */ while(certificates_offset < certificates_length) { u_int32_t certificate_len = (packet->payload[certificates_offset] << 16) + (packet->payload[certificates_offset+1] << 8) + packet->payload[certificates_offset+2]; /* Invalid lenght */ if((certificate_len == 0) || (packet->payload[certificates_offset] != 0x0) || ((certificates_offset+certificate_len) > (4+certificates_length+(is_dtls ? 8 : 0)))) { #ifdef DEBUG_TLS printf(\"[TLS] Invalid length [certificate_len: %u][certificates_offset: %u][%u vs %u]\\n\", certificate_len, certificates_offset, (certificates_offset+certificate_len), certificates_length); #endif break; } certificates_offset += 3; #ifdef DEBUG_TLS printf(\"[TLS] Processing %u bytes certificate [%02X %02X %02X]\\n\", certificate_len, packet->payload[certificates_offset], packet->payload[certificates_offset+1], packet->payload[certificates_offset+2]); #endif if(num_certificates_found++ == 0) /* Dissect only the first certificate that is the one we care */ { /* For SHA-1 we take into account only the first certificate and not all of them */ SHA1Init(&srv_cert_fingerprint_ctx); #ifdef DEBUG_CERTIFICATE_HASH { int i; for(i=0;ipayload[certificates_offset+i]); printf(\"\\n\"); } #endif SHA1Update(&srv_cert_fingerprint_ctx, &packet->payload[certificates_offset], certificate_len); SHA1Final(flow->protos.tls_quic_stun.tls_quic.sha1_certificate_fingerprint, &srv_cert_fingerprint_ctx); flow->l4.tcp.tls.fingerprint_set = 1; uint8_t * sha1 = flow->protos.tls_quic_stun.tls_quic.sha1_certificate_fingerprint; const size_t sha1_siz = sizeof(flow->protos.tls_quic_stun.tls_quic.sha1_certificate_fingerprint); char sha1_str[20 /* sha1_siz */ * 2 + 1]; static const char hexalnum[] = \"0123456789ABCDEF\"; for (size_t i = 0; i < sha1_siz; ++i) { u_int8_t lower = (sha1[i] & 0x0F); u_int8_t upper = (sha1[i] & 0xF0) >> 4; sha1_str[i*2] = hexalnum[upper]; sha1_str[i*2 + 1] = hexalnum[lower]; } sha1_str[sha1_siz * 2] = '\\0'; #ifdef DEBUG_TLS printf(\"[TLS] SHA-1: %s\\n\", sha1_str); #endif if (ndpi_struct->malicious_sha1_automa.ac_automa != NULL) { u_int16_t rc1 = ndpi_match_string(ndpi_struct->malicious_sha1_automa.ac_automa, sha1_str); if(rc1 > 0) ndpi_set_risk(flow, NDPI_MALICIOUS_SHA1_CERTIFICATE); } processCertificateElements(ndpi_struct, flow, certificates_offset, certificate_len); } certificates_offset += certificate_len; } if((ndpi_struct->num_tls_blocks_to_follow != 0) && (flow->l4.tcp.tls.num_tls_blocks >= ndpi_struct->num_tls_blocks_to_follow)) { #ifdef DEBUG_TLS_BLOCKS printf(\"*** [TLS Block] Enough blocks dissected\\n\"); #endif flow->extra_packets_func = NULL; /* We're good now */ } return(1); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 338563, "input": "*/ static int io_timeout_remove(struct io_kiocb *req, unsigned int issue_flags) { struct io_timeout_rem *tr = &req->timeout_rem; struct io_ring_ctx *ctx = req->ctx; int ret; spin_lock_irq(&ctx->completion_lock); if (!(req->timeout_rem.flags & IORING_TIMEOUT_UPDATE)) ret = io_timeout_cancel(ctx, tr->addr); else ret = io_timeout_update(ctx, tr->addr, &tr->ts, io_translate_timeout_mode(tr->flags)); io_cqring_fill_event(ctx, req->user_data, ret, 0); io_commit_cqring(ctx); spin_unlock_irq(&ctx->completion_lock); io_cqring_ev_posted(ctx); if (ret < 0) req_set_fail_links(req); io_put_req(req); return 0;", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 489878, "input": "int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, ext4_fsblk_t n_blocks_count) { ext4_fsblk_t o_blocks_count; ext4_group_t o_groups_count; ext4_grpblk_t last; ext4_grpblk_t add; struct buffer_head *bh; handle_t *handle; int err; ext4_group_t group; /* We don't need to worry about locking wrt other resizers just * yet: we're going to revalidate es->s_blocks_count after * taking lock_super() below. */ o_blocks_count = ext4_blocks_count(es); o_groups_count = EXT4_SB(sb)->s_groups_count; if (test_opt(sb, DEBUG)) printk(KERN_DEBUG \"EXT4-fs: extending last group from %llu uto %llu blocks\\n\", o_blocks_count, n_blocks_count); if (n_blocks_count == 0 || n_blocks_count == o_blocks_count) return 0; if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { printk(KERN_ERR \"EXT4-fs: filesystem on %s:\" \" too large to resize to %llu blocks safely\\n\", sb->s_id, n_blocks_count); if (sizeof(sector_t) < 8) ext4_warning(sb, __func__, \"CONFIG_LBD not enabled\"); return -EINVAL; } if (n_blocks_count < o_blocks_count) { ext4_warning(sb, __func__, \"can't shrink FS - resize aborted\"); return -EBUSY; } /* Handle the remaining blocks in the last group only. */ ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last); if (last == 0) { ext4_warning(sb, __func__, \"need to use ext2online to resize further\"); return -EPERM; } add = EXT4_BLOCKS_PER_GROUP(sb) - last; if (o_blocks_count + add < o_blocks_count) { ext4_warning(sb, __func__, \"blocks_count overflow\"); return -EINVAL; } if (o_blocks_count + add > n_blocks_count) add = n_blocks_count - o_blocks_count; if (o_blocks_count + add < n_blocks_count) ext4_warning(sb, __func__, \"will only finish group (%llu\" \" blocks, %u new)\", o_blocks_count + add, add); /* See if the device is actually as big as what was requested */ bh = sb_bread(sb, o_blocks_count + add - 1); if (!bh) { ext4_warning(sb, __func__, \"can't read last block, resize aborted\"); return -ENOSPC; } brelse(bh); /* We will update the superblock, one block bitmap, and * one group descriptor via ext4_free_blocks(). */ handle = ext4_journal_start_sb(sb, 3); if (IS_ERR(handle)) { err = PTR_ERR(handle); ext4_warning(sb, __func__, \"error %d on journal start\", err); goto exit_put; } lock_super(sb); if (o_blocks_count != ext4_blocks_count(es)) { ext4_warning(sb, __func__, \"multiple resizers run on filesystem!\"); unlock_super(sb); ext4_journal_stop(handle); err = -EBUSY; goto exit_put; } if ((err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh))) { ext4_warning(sb, __func__, \"error %d on journal write access\", err); unlock_super(sb); ext4_journal_stop(handle); goto exit_put; } ext4_blocks_count_set(es, o_blocks_count + add); ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); sb->s_dirt = 1; unlock_super(sb); ext4_debug(\"freeing blocks %llu through %llu\\n\", o_blocks_count, o_blocks_count + add); /* We add the blocks to the bitmap and set the group need init bit */ ext4_add_groupblocks(handle, sb, o_blocks_count, add); ext4_debug(\"freed blocks %llu through %llu\\n\", o_blocks_count, o_blocks_count + add); if ((err = ext4_journal_stop(handle))) goto exit_put; if (test_opt(sb, DEBUG)) printk(KERN_DEBUG \"EXT4-fs: extended group to %llu blocks\\n\", ext4_blocks_count(es)); update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es, sizeof(struct ext4_super_block)); exit_put: return err; } /* ext4_group_extend */", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393621, "input": "lr_yum_repo_update(LrYumRepo *repo, const char *type, const char *path) { assert(repo); assert(type); assert(path); for (GSList *elem = repo->paths; elem; elem = g_slist_next(elem)) { LrYumRepoPath *yumrepopath = elem->data; assert(yumrepopath); if (!strcmp(yumrepopath->type, type)) { lr_free(yumrepopath->path); yumrepopath->path = g_strdup(path); return; } } lr_yum_repo_append(repo, type, path); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 469011, "input": "int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) { struct sk_buff_head *list = &sk->sk_receive_queue; int rmem, delta, amt, err = -ENOMEM; spinlock_t *busy = NULL; int size; /* try to avoid the costly atomic add/sub pair when the receive * queue is full; always allow at least a packet */ rmem = atomic_read(&sk->sk_rmem_alloc); if (rmem > sk->sk_rcvbuf) goto drop; /* Under mem pressure, it might be helpful to help udp_recvmsg() * having linear skbs : * - Reduce memory overhead and thus increase receive queue capacity * - Less cache line misses at copyout() time * - Less work at consume_skb() (less alien page frag freeing) */ if (rmem > (sk->sk_rcvbuf >> 1)) { skb_condense(skb); busy = busylock_acquire(sk); } size = skb->truesize; udp_set_dev_scratch(skb); /* we drop only if the receive buf is full and the receive * queue contains some other skb */ rmem = atomic_add_return(size, &sk->sk_rmem_alloc); if (rmem > (size + sk->sk_rcvbuf)) goto uncharge_drop; spin_lock(&list->lock); if (size >= sk->sk_forward_alloc) { amt = sk_mem_pages(size); delta = amt << SK_MEM_QUANTUM_SHIFT; if (!__sk_mem_raise_allocated(sk, delta, amt, SK_MEM_RECV)) { err = -ENOBUFS; spin_unlock(&list->lock); goto uncharge_drop; } sk->sk_forward_alloc += delta; } sk->sk_forward_alloc -= size; /* no need to setup a destructor, we will explicitly release the * forward allocated memory on dequeue */ sock_skb_set_dropcount(sk, skb); __skb_queue_tail(list, skb); spin_unlock(&list->lock); if (!sock_flag(sk, SOCK_DEAD)) sk->sk_data_ready(sk); busylock_release(busy); return 0; uncharge_drop: atomic_sub(skb->truesize, &sk->sk_rmem_alloc); drop: atomic_inc(&sk->sk_drops); busylock_release(busy); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 422639, "input": "TEST(InMatchExpression, MatchesNull) { BSONObj operand = BSON_ARRAY(BSONNULL); InMatchExpression in(\"a\"); std::vector equalities{operand.firstElement()}; ASSERT_OK(in.setEqualities(std::move(equalities))); ASSERT(in.matchesBSON(BSONObj(), NULL)); ASSERT(in.matchesBSON(BSON(\"a\" << BSONNULL), NULL)); ASSERT(!in.matchesBSON(BSON(\"a\" << 4), NULL)); // A non-existent field is treated same way as an empty bson object ASSERT(in.matchesBSON(BSON(\"b\" << 4), NULL)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432431, "input": "static void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr) { }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 376658, "input": "static int svm_check_nested_events(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); bool block_nested_events = kvm_event_needs_reinjection(vcpu) || svm->nested.nested_run_pending; struct kvm_lapic *apic = vcpu->arch.apic; if (lapic_in_kernel(vcpu) && test_bit(KVM_APIC_INIT, &apic->pending_events)) { if (block_nested_events) return -EBUSY; if (!nested_exit_on_init(svm)) return 0; nested_svm_init(svm); return 0; } if (vcpu->arch.exception.pending) { if (block_nested_events) return -EBUSY; if (!nested_exit_on_exception(svm)) return 0; nested_svm_inject_exception_vmexit(svm); return 0; } if (vcpu->arch.smi_pending && !svm_smi_blocked(vcpu)) { if (block_nested_events) return -EBUSY; if (!nested_exit_on_smi(svm)) return 0; nested_svm_smi(svm); return 0; } if (vcpu->arch.nmi_pending && !svm_nmi_blocked(vcpu)) { if (block_nested_events) return -EBUSY; if (!nested_exit_on_nmi(svm)) return 0; nested_svm_nmi(svm); return 0; } if (kvm_cpu_has_interrupt(vcpu) && !svm_interrupt_blocked(vcpu)) { if (block_nested_events) return -EBUSY; if (!nested_exit_on_intr(svm)) return 0; nested_svm_intr(svm); return 0; } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 490842, "input": "static unsigned int irda_poll(struct file * file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; struct irda_sock *self = irda_sk(sk); unsigned int mask; IRDA_DEBUG(4, \"%s()\\n\", __func__); poll_wait(file, sk->sk_sleep, wait); mask = 0; /* Exceptional events? */ if (sk->sk_err) mask |= POLLERR; if (sk->sk_shutdown & RCV_SHUTDOWN) { IRDA_DEBUG(0, \"%s(), POLLHUP\\n\", __func__); mask |= POLLHUP; } /* Readable? */ if (!skb_queue_empty(&sk->sk_receive_queue)) { IRDA_DEBUG(4, \"Socket is readable\\n\"); mask |= POLLIN | POLLRDNORM; } /* Connection-based need to check for termination and startup */ switch (sk->sk_type) { case SOCK_STREAM: if (sk->sk_state == TCP_CLOSE) { IRDA_DEBUG(0, \"%s(), POLLHUP\\n\", __func__); mask |= POLLHUP; } if (sk->sk_state == TCP_ESTABLISHED) { if ((self->tx_flow == FLOW_START) && sock_writeable(sk)) { mask |= POLLOUT | POLLWRNORM | POLLWRBAND; } } break; case SOCK_SEQPACKET: if ((self->tx_flow == FLOW_START) && sock_writeable(sk)) { mask |= POLLOUT | POLLWRNORM | POLLWRBAND; } break; case SOCK_DGRAM: if (sock_writeable(sk)) mask |= POLLOUT | POLLWRNORM | POLLWRBAND; break; default: break; } return mask; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232510, "input": "static int check_reg_arg(struct bpf_verifier_env *env, u32 regno, enum reg_arg_type t) { struct bpf_verifier_state *vstate = env->cur_state; struct bpf_func_state *state = vstate->frame[vstate->curframe]; struct bpf_insn *insn = env->prog->insnsi + env->insn_idx; struct bpf_reg_state *reg, *regs = state->regs; bool rw64; if (regno >= MAX_BPF_REG) { verbose(env, \"R%d is invalid\\n\", regno); return -EINVAL; } reg = ®s[regno]; rw64 = is_reg64(env, insn, regno, reg, t); if (t == SRC_OP) { /* check whether register used as source operand can be read */ if (reg->type == NOT_INIT) { verbose(env, \"R%d !read_ok\\n\", regno); return -EACCES; } /* We don't need to worry about FP liveness because it's read-only */ if (regno == BPF_REG_FP) return 0; if (rw64) mark_insn_zext(env, reg); return mark_reg_read(env, reg, reg->parent, rw64 ? REG_LIVE_READ64 : REG_LIVE_READ32); } else { /* check whether register used as dest operand can be written to */ if (regno == BPF_REG_FP) { verbose(env, \"frame pointer is read only\\n\"); return -EACCES; } reg->live |= REG_LIVE_WRITTEN; reg->subreg_def = rw64 ? DEF_NOT_SUBREG : env->insn_idx + 1; if (t == DST_OP) mark_reg_unknown(env, regs, regno); } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 449669, "input": "static pj_status_t process_answer(pj_pool_t *pool, pjmedia_sdp_session *local_offer, pjmedia_sdp_session *answer, pj_bool_t allow_asym, pjmedia_sdp_session **p_active) { unsigned omi = 0; /* Offer media index */ unsigned ami = 0; /* Answer media index */ pj_bool_t has_active = PJ_FALSE; pjmedia_sdp_session *offer; pj_status_t status; /* Check arguments. */ PJ_ASSERT_RETURN(pool && local_offer && answer && p_active, PJ_EINVAL); /* Duplicate local offer SDP. */ offer = pjmedia_sdp_session_clone(pool, local_offer); /* Check that media count match between offer and answer */ // Ticket #527, different media count is allowed for more interoperability, // however, the media order must be same between offer and answer. // if (offer->media_count != answer->media_count) // return PJMEDIA_SDPNEG_EMISMEDIA; /* Now update each media line in the offer with the answer. */ for (; omimedia_count; ++omi) { if (ami == answer->media_count) { /* The answer has less media than the offer */ pjmedia_sdp_media *am; /* Generate matching-but-disabled-media for the answer */ am = sdp_media_clone_deactivate(pool, offer->media[omi], offer->media[omi], offer); answer->media[answer->media_count++] = am; ++ami; /* Deactivate our media offer too */ pjmedia_sdp_media_deactivate(pool, offer->media[omi]); /* No answer media to be negotiated */ continue; } status = process_m_answer(pool, offer->media[omi], answer->media[ami], allow_asym); /* If media type is mismatched, just disable the media. */ if (status == PJMEDIA_SDPNEG_EINVANSMEDIA) { pjmedia_sdp_media_deactivate(pool, offer->media[omi]); continue; } /* No common format in the answer media. */ else if (status == PJMEDIA_SDPNEG_EANSNOMEDIA) { pjmedia_sdp_media_deactivate(pool, offer->media[omi]); pjmedia_sdp_media_deactivate(pool, answer->media[ami]); } /* Return the error code, for other errors. */ else if (status != PJ_SUCCESS) { return status; } if (offer->media[omi]->desc.port != 0) has_active = PJ_TRUE; ++ami; } *p_active = offer; return has_active ? PJ_SUCCESS : PJMEDIA_SDPNEG_ENOMEDIA; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416785, "input": "static inline void cil_reset_userlevel(struct cil_userlevel *userlevel) { if (userlevel->level_str == NULL) { cil_reset_level(userlevel->level); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508519, "input": "bool JOIN::get_best_combination() { uint tablenr; table_map used_tables; JOIN_TAB *j; KEYUSE *keyuse; DBUG_ENTER(\"get_best_combination\"); /* Additional plan nodes for postjoin tmp tables: 1? + // For GROUP BY 1? + // For DISTINCT 1? + // For aggregation functions aggregated in outer query // when used with distinct 1? + // For ORDER BY 1? // buffer result Up to 2 tmp tables are actually used, but it's hard to tell exact number at this stage. */ uint aggr_tables= (group_list ? 1 : 0) + (select_distinct ? (tmp_table_param.using_outer_summary_function ? 2 : 1) : 0) + (order ? 1 : 0) + (select_options & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) ? 1 : 0) ; if (aggr_tables == 0) aggr_tables= 1; /* For group by pushdown */ if (select_lex->window_specs.elements) aggr_tables++; if (aggr_tables > 2) aggr_tables= 2; if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)* (top_join_tab_count + aggr_tables)))) DBUG_RETURN(TRUE); full_join=0; hash_join= FALSE; fix_semijoin_strategies_for_picked_join_order(this); JOIN_TAB_RANGE *root_range; if (!(root_range= new (thd->mem_root) JOIN_TAB_RANGE)) DBUG_RETURN(TRUE); root_range->start= join_tab; /* root_range->end will be set later */ join_tab_ranges.empty(); if (join_tab_ranges.push_back(root_range, thd->mem_root)) DBUG_RETURN(TRUE); JOIN_TAB *sjm_nest_end= NULL; JOIN_TAB *sjm_nest_root= NULL; for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++) { TABLE *form; POSITION *cur_pos= &best_positions[tablenr]; if (cur_pos->sj_strategy == SJ_OPT_MATERIALIZE || cur_pos->sj_strategy == SJ_OPT_MATERIALIZE_SCAN) { /* Ok, we've entered an SJ-Materialization semi-join (note that this can't be done recursively, semi-joins are not allowed to be nested). 1. Put into main join order a JOIN_TAB that represents a lookup or scan in the temptable. */ bzero((void*)j, sizeof(JOIN_TAB)); j->join= this; j->table= NULL; //temporary way to tell SJM tables from others. j->ref.key = -1; j->on_expr_ref= (Item**) &null_ptr; j->keys= key_map(1); /* The unique index is always in 'possible keys' in EXPLAIN */ /* 2. Proceed with processing SJM nest's join tabs, putting them into the sub-order */ SJ_MATERIALIZATION_INFO *sjm= cur_pos->table->emb_sj_nest->sj_mat_info; j->records_read= (sjm->is_sj_scan? sjm->rows : 1); j->records= (ha_rows) j->records_read; j->cond_selectivity= 1.0; JOIN_TAB *jt; JOIN_TAB_RANGE *jt_range; if (!(jt= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) || !(jt_range= new JOIN_TAB_RANGE)) DBUG_RETURN(TRUE); jt_range->start= jt; jt_range->end= jt + sjm->tables; join_tab_ranges.push_back(jt_range, thd->mem_root); j->bush_children= jt_range; sjm_nest_end= jt + sjm->tables; sjm_nest_root= j; j= jt; } *j= *best_positions[tablenr].table; j->bush_root_tab= sjm_nest_root; form= table[tablenr]= j->table; form->reginfo.join_tab=j; DBUG_PRINT(\"info\",(\"type: %d\", j->type)); if (j->type == JT_CONST) goto loop_end; // Handled in make_join_stat.. j->loosescan_match_tab= NULL; //non-nulls will be set later j->inside_loosescan_range= FALSE; j->ref.key = -1; j->ref.key_parts=0; if (j->type == JT_SYSTEM) goto loop_end; if ( !(keyuse= best_positions[tablenr].key)) { j->type=JT_ALL; if (best_positions[tablenr].use_join_buffer && tablenr != const_tables) full_join= 1; } /*if (best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN) { DBUG_ASSERT(!keyuse || keyuse->key == best_positions[tablenr].loosescan_picker.loosescan_key); j->index= best_positions[tablenr].loosescan_picker.loosescan_key; }*/ if ((j->type == JT_REF || j->type == JT_EQ_REF) && is_hash_join_key_no(j->ref.key)) hash_join= TRUE; loop_end: /* Save records_read in JOIN_TAB so that select_describe()/etc don't have to access join->best_positions[]. */ j->records_read= best_positions[tablenr].records_read; j->cond_selectivity= best_positions[tablenr].cond_selectivity; map2table[j->table->tablenr]= j; /* If we've reached the end of sjm nest, switch back to main sequence */ if (j + 1 == sjm_nest_end) { j->last_leaf_in_bush= TRUE; j= sjm_nest_root; sjm_nest_root= NULL; sjm_nest_end= NULL; } } root_range->end= j; used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++) { if (j->bush_children) j= j->bush_children->start; used_tables|= j->table->map; if (j->type != JT_CONST && j->type != JT_SYSTEM) { if ((keyuse= best_positions[tablenr].key) && create_ref_for_key(this, j, keyuse, TRUE, used_tables)) DBUG_RETURN(TRUE); // Something went wrong } if (j->last_leaf_in_bush) j= j->bush_root_tab; } top_join_tab_count= (uint)(join_tab_ranges.head()->end - join_tab_ranges.head()->start); update_depend_map(this); DBUG_RETURN(0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 499667, "input": "tape_toss_input (int in_des, off_t num_bytes) { off_t bytes_left = num_bytes; /* Bytes needing to be copied. */ off_t space_left; /* Bytes to copy from input buffer. */ while (bytes_left > 0) { if (input_size == 0) tape_fill_input_buffer (in_des, io_block_size); if (bytes_left < input_size) space_left = bytes_left; else space_left = input_size; if (crc_i_flag && only_verify_crc_flag) { int k; for (k = 0; k < space_left; ++k) crc += in_buff[k] & 0xff; } in_buff += space_left; input_size -= space_left; bytes_left -= space_left; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 211977, "input": "void luaD_callnoyield (lua_State *L, StkId func, int nResults) { incXCcalls(L); if (getCcalls(L) <= CSTACKERR) /* possible stack overflow? */ luaE_freeCI(L); luaD_call(L, func, nResults); decXCcalls(L); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "Lua through 5.4.0 allows a stack redzone cross in luaO_pushvfstring because a protection mechanism wrongly calls luaD_callnoyield twice in a row.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2020-24342"}} -{"idx": 301522, "input": "static int zend_shared_alloc_try(const zend_shared_memory_handler_entry *he, size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, char **error_in) { int res; g_shared_alloc_handler = he->handler; g_shared_model = he->name; ZSMMG(shared_segments) = NULL; ZSMMG(shared_segments_count) = 0; res = S_H(create_segments)(requested_size, shared_segments_p, shared_segments_count, error_in); if (res) { /* this model works! */ return res; } if (*shared_segments_p) { int i; /* cleanup */ for (i = 0; i < *shared_segments_count; i++) { if ((*shared_segments_p)[i]->p && (*shared_segments_p)[i]->p != (void *)-1) { S_H(detach_segment)((*shared_segments_p)[i]); } } free(*shared_segments_p); *shared_segments_p = NULL; } g_shared_alloc_handler = NULL; return ALLOC_FAILURE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219673, "input": "Variant HHVM_FUNCTION(imagecolorsforindex, const Resource& image, int64_t index) { gdImagePtr im = get_valid_image_resource(image); if (!im) return false; if (index >= 0 && (gdImageTrueColor(im) || index < gdImageColorsTotal(im))) { return make_darray( s_red, gdImageRed(im,index), s_green, gdImageGreen(im,index), s_blue, gdImageBlue(im,index), s_alpha, gdImageAlpha(im,index) ); } raise_warning(\"Color index %\" PRId64 \" out of range\", index); return false; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 237550, "input": "GF_Box *m4ds_box_new() { GF_MPEG4ExtensionDescriptorsBox *tmp = (GF_MPEG4ExtensionDescriptorsBox *) gf_malloc(sizeof(GF_MPEG4ExtensionDescriptorsBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_MPEG4ExtensionDescriptorsBox)); tmp->type = GF_ISOM_BOX_TYPE_M4DS; tmp->descriptors = gf_list_new(); return (GF_Box *)tmp; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 497521, "input": "ms_escher_read_SpgrContainer (MSEscherState *state, MSEscherHeader *h) { return ms_escher_read_container (state, h, 0, FALSE); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 499655, "input": "tape_empty_output_buffer (int out_des) { int bytes_written; #ifdef BROKEN_LONG_TAPE_DRIVER static long output_bytes_before_lseek = 0; /* Some tape drivers seem to have a signed internal seek pointer and they lose if it overflows and becomes negative (e.g. when writing tapes > 2Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the seek pointer and prevent it from overflowing. */ if (output_is_special && ( (output_bytes_before_lseek += output_size) >= 1073741824L) ) { lseek(out_des, 0L, SEEK_SET); output_bytes_before_lseek = 0; } #endif bytes_written = rmtwrite (out_des, output_buffer, output_size); if (bytes_written != output_size) { int rest_bytes_written; int rest_output_size; if (output_is_special && (bytes_written >= 0 || (bytes_written < 0 && (errno == ENOSPC || errno == EIO || errno == ENXIO)))) { get_next_reel (out_des); if (bytes_written > 0) rest_output_size = output_size - bytes_written; else rest_output_size = output_size; rest_bytes_written = rmtwrite (out_des, output_buffer, rest_output_size); if (rest_bytes_written != rest_output_size) error (PAXEXIT_FAILURE, errno, _(\"write error\")); } else error (PAXEXIT_FAILURE, errno, _(\"write error\")); } output_bytes += output_size; out_buff = output_buffer; output_size = 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 269101, "input": "service_info *FindServiceControlURLPath( service_table *table, const char *controlURLPath) { service_info *finger = NULL; uri_type parsed_url; uri_type parsed_url_in; if (!table || !controlURLPath) { return NULL; } if (parse_uri(controlURLPath, strlen(controlURLPath), &parsed_url_in) == HTTP_SUCCESS) { finger = table->serviceList; while (finger) { if (finger->controlURL) { if (parse_uri(finger->controlURL, strlen(finger->controlURL), &parsed_url) == HTTP_SUCCESS) { if (!token_cmp(&parsed_url.pathquery, &parsed_url_in.pathquery)) { return finger; } } } finger = finger->next; } } return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 255798, "input": "const GF_FilterRegister *flac_dmx_register(GF_FilterSession *session) { return &FLACDmxRegister; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393061, "input": "TEST_F(QueryPlannerTest, NonPrefixRegexOrCovering) { addIndex(BSON(\"a\" << 1)); runQuerySortProj( fromjson(\"{$or: [{a: /0/}, {a: /1/}]}\"), BSONObj(), fromjson(\"{_id: 0, a: 1}\")); ASSERT_EQUALS(getNumSolutions(), 2U); assertSolutionExists( \"{proj: {spec: {_id: 0, a: 1}, node: \" \"{cscan: {dir: 1, filter: {$or: [{a: /0/}, {a: /1/}]}}}}}\"); assertSolutionExists( \"{proj: {spec: {_id: 0, a: 1}, node: \" \"{ixscan: {filter: {$or: [{a: /0/}, {a: /1/}]}, pattern: {a: 1}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 295153, "input": "int gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a) { int c; int ct = -1; int op = -1; long rd, gd, bd, ad, dist; long mindist = 4 * 255 * 255; /* init to max poss dist */ if (im->trueColor) { return gdTrueColorAlpha (r, g, b, a); } for (c = 0; c < im->colorsTotal; c++) { if (im->open[c]) { op = c; /* Save open slot */ continue; /* Color not in use */ } if (c == im->transparent) { /* don't ever resolve to the color that has * been designated as the transparent color */ continue; } rd = (long) (im->red[c] - r); gd = (long) (im->green[c] - g); bd = (long) (im->blue[c] - b); ad = (long) (im->alpha[c] - a); dist = rd * rd + gd * gd + bd * bd + ad * ad; if (dist < mindist) { if (dist == 0) { return c; /* Return exact match color */ } mindist = dist; ct = c; } } /* no exact match. We now know closest, but first try to allocate exact */ if (op == -1) { op = im->colorsTotal; if (op == gdMaxColors) { /* No room for more colors */ return ct; /* Return closest available color */ } im->colorsTotal++; } im->red[op] = r; im->green[op] = g; im->blue[op] = b; im->alpha[op] = a; im->open[op] = 0; return op; /* Return newly allocated color */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 196264, "input": "GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs) { GF_OperatingPointsInformation* ptr = (GF_OperatingPointsInformation *)entry; u32 i, j, count; if (!ptr) return GF_BAD_PARAM; ptr->scalability_mask = gf_bs_read_u16(bs); gf_bs_read_int(bs, 2);//reserved count = gf_bs_read_int(bs, 6); for (i = 0; i < count; i++) { LHEVC_ProfileTierLevel *ptl; GF_SAFEALLOC(ptl, LHEVC_ProfileTierLevel); if (!ptl) return GF_OUT_OF_MEM; ptl->general_profile_space = gf_bs_read_int(bs, 2); ptl->general_tier_flag= gf_bs_read_int(bs, 1); ptl->general_profile_idc = gf_bs_read_int(bs, 5); ptl->general_profile_compatibility_flags = gf_bs_read_u32(bs); ptl->general_constraint_indicator_flags = gf_bs_read_long_int(bs, 48); ptl->general_level_idc = gf_bs_read_u8(bs); gf_list_add(ptr->profile_tier_levels, ptl); } count = gf_bs_read_u16(bs); for (i = 0; i < count; i++) { LHEVC_OperatingPoint *op; GF_SAFEALLOC(op, LHEVC_OperatingPoint); if (!op) return GF_OUT_OF_MEM; op->output_layer_set_idx = gf_bs_read_u16(bs); op->max_temporal_id = gf_bs_read_u8(bs); op->layer_count = gf_bs_read_u8(bs); if (op->layer_count > GF_ARRAY_LENGTH(op->layers_info)) return GF_NON_COMPLIANT_BITSTREAM; for (j = 0; j < op->layer_count; j++) { op->layers_info[j].ptl_idx = gf_bs_read_u8(bs); op->layers_info[j].layer_id = gf_bs_read_int(bs, 6); op->layers_info[j].is_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE; op->layers_info[j].is_alternate_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE; } op->minPicWidth = gf_bs_read_u16(bs); op->minPicHeight = gf_bs_read_u16(bs); op->maxPicWidth = gf_bs_read_u16(bs); op->maxPicHeight = gf_bs_read_u16(bs); op->maxChromaFormat = gf_bs_read_int(bs, 2); op->maxBitDepth = gf_bs_read_int(bs, 3) + 8; gf_bs_read_int(bs, 1);//reserved op->frame_rate_info_flag = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE; op->bit_rate_info_flag = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE; if (op->frame_rate_info_flag) { op->avgFrameRate = gf_bs_read_u16(bs); gf_bs_read_int(bs, 6); //reserved op->constantFrameRate = gf_bs_read_int(bs, 2); } if (op->bit_rate_info_flag) { op->maxBitRate = gf_bs_read_u32(bs); op->avgBitRate = gf_bs_read_u32(bs); } gf_list_add(ptr->operating_points, op); } count = gf_bs_read_u8(bs); for (i = 0; i < count; i++) { LHEVC_DependentLayer *dep; GF_SAFEALLOC(dep, LHEVC_DependentLayer); if (!dep) return GF_OUT_OF_MEM; dep->dependent_layerID = gf_bs_read_u8(bs); dep->num_layers_dependent_on = gf_bs_read_u8(bs); if (dep->num_layers_dependent_on > GF_ARRAY_LENGTH(dep->dependent_on_layerID)) { gf_free(dep); return GF_NON_COMPLIANT_BITSTREAM; } for (j = 0; j < dep->num_layers_dependent_on; j++) dep->dependent_on_layerID[j] = gf_bs_read_u8(bs); for (j = 0; j < 16; j++) { if (ptr->scalability_mask & (1 << j)) dep->dimension_identifier[j] = gf_bs_read_u8(bs); } gf_list_add(ptr->dependency_layers, dep); } return GF_OK; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Missing Release of Memory after Effective Lifetime"], "explanation": "Memory leak in the gf_isom_oinf_read_entry function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.", "severity_level": "NoInfo", "cwe": "CWE-401", "cve": "CVE-2021-33366"}} -{"idx": 463023, "input": "static int sev_launch_secret(struct kvm *kvm, struct kvm_sev_cmd *argp) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_launch_secret *data; struct kvm_sev_launch_secret params; struct page **pages; void *blob, *hdr; unsigned long n; int ret, offset; if (!sev_guest(kvm)) return -ENOTTY; if (copy_from_user(¶ms, (void __user *)(uintptr_t)argp->data, sizeof(params))) return -EFAULT; pages = sev_pin_memory(kvm, params.guest_uaddr, params.guest_len, &n, 1); if (IS_ERR(pages)) return PTR_ERR(pages); /* * The secret must be copied into contiguous memory region, lets verify * that userspace memory pages are contiguous before we issue command. */ if (get_num_contig_pages(0, pages, n) != n) { ret = -EINVAL; goto e_unpin_memory; } ret = -ENOMEM; data = kzalloc(sizeof(*data), GFP_KERNEL_ACCOUNT); if (!data) goto e_unpin_memory; offset = params.guest_uaddr & (PAGE_SIZE - 1); data->guest_address = __sme_page_pa(pages[0]) + offset; data->guest_len = params.guest_len; blob = psp_copy_user_blob(params.trans_uaddr, params.trans_len); if (IS_ERR(blob)) { ret = PTR_ERR(blob); goto e_free; } data->trans_address = __psp_pa(blob); data->trans_len = params.trans_len; hdr = psp_copy_user_blob(params.hdr_uaddr, params.hdr_len); if (IS_ERR(hdr)) { ret = PTR_ERR(hdr); goto e_free_blob; } data->hdr_address = __psp_pa(hdr); data->hdr_len = params.hdr_len; data->handle = sev->handle; ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_SECRET, data, &argp->error); kfree(hdr); e_free_blob: kfree(blob); e_free: kfree(data); e_unpin_memory: sev_unpin_memory(kvm, pages, n); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409191, "input": "static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id) { struct uvc_streaming *stream; list_for_each_entry(stream, &dev->streams, list) { if (stream->header.bTerminalLink == id) return stream; } return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431609, "input": "static void nfs4_free_createdata(struct nfs4_createdata *data) { nfs4_label_free(data->label); kfree(data); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 328380, "input": "static void __nf_tables_commit_chain_free_rules_old(struct rcu_head *h) { struct nft_rules_old *o = container_of(h, struct nft_rules_old, h); kvfree(o->start); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 399272, "input": "void imap_get_parent_path(const char *path, char *buf, size_t buflen) { struct ImapAccountData *adata = NULL; struct ImapMboxData *mdata = NULL; char mbox[1024]; if (imap_adata_find(path, &adata, &mdata) < 0) { mutt_str_copy(buf, path, buflen); return; } /* Gets the parent mbox in mbox */ imap_get_parent(mdata->name, adata->delim, mbox, sizeof(mbox)); /* Returns a fully qualified IMAP url */ imap_qualify_path(buf, buflen, &adata->conn->account, mbox); imap_mdata_free((void *) &mdata); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334476, "input": "mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, gboolean *used_context) { MonoMethod *result; int table = mono_metadata_token_table (token); int idx = mono_metadata_token_index (token); MonoTableInfo *tables = image->tables; MonoGenericContainer *generic_container = NULL, *container = NULL; const char *sig = NULL; int size; guint32 cols [MONO_TYPEDEF_SIZE]; if (image->dynamic) { MonoClass *handle_class; result = mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context); // This checks the memberref type as well if (result && handle_class != mono_defaults.methodhandle_class) { mono_loader_set_error_bad_image (g_strdup_printf (\"Bad method token 0x%08x on image %s.\", token, image->name)); return NULL; } return result; } if (table != MONO_TABLE_METHOD) { if (table == MONO_TABLE_METHODSPEC) { if (used_context) *used_context = TRUE; return method_from_methodspec (image, context, idx); } if (table != MONO_TABLE_MEMBERREF) { g_warning (\"got wrong token: 0x%08x\\n\", token); mono_loader_set_error_bad_image (g_strdup_printf (\"Bad method token 0x%08x on image %s.\", token, image->name)); return NULL; } return method_from_memberref (image, idx, context, used_context); } if (used_context) *used_context = FALSE; if (idx > image->tables [MONO_TABLE_METHOD].rows) { mono_loader_set_error_bad_image (g_strdup_printf (\"Bad method token 0x%08x on image %s.\", token, image->name)); return NULL; } mono_metadata_decode_row (&image->tables [MONO_TABLE_METHOD], idx - 1, cols, 6); if ((cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke)); else result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod)); mono_stats.method_count ++; if (!klass) { /*FIXME put this before the image alloc*/ guint32 type = mono_metadata_typedef_from_method (image, token); if (!type) return NULL; klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | type); if (klass == NULL) return NULL; } result->slot = -1; result->klass = klass; result->flags = cols [2]; result->iflags = cols [1]; result->token = token; result->name = mono_metadata_string_heap (image, cols [3]); if (!sig) /* already taken from the methodref */ sig = mono_metadata_blob_heap (image, cols [4]); size = mono_metadata_decode_blob_size (sig, &sig); container = klass->generic_container; /* * load_generic_params does a binary search so only call it if the method * is generic. */ if (*sig & 0x10) generic_container = mono_metadata_load_generic_params (image, token, container); if (generic_container) { result->is_generic = TRUE; generic_container->owner.method = result; /*FIXME put this before the image alloc*/ if (!mono_metadata_load_generic_param_constraints_full (image, token, generic_container)) return NULL; container = generic_container; } if (cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) { if (result->klass == mono_defaults.string_class && !strcmp (result->name, \".ctor\")) result->string_ctor = 1; } else if (cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) { MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)result; #ifdef TARGET_WIN32 /* IJW is P/Invoke with a predefined function pointer. */ if (image->is_module_handle && (cols [1] & METHOD_IMPL_ATTRIBUTE_NATIVE)) { piinfo->addr = mono_image_rva_map (image, cols [0]); g_assert (piinfo->addr); } #endif piinfo->implmap_idx = mono_metadata_implmap_from_method (image, idx - 1); /* Native methods can have no map. */ if (piinfo->implmap_idx) piinfo->piflags = mono_metadata_decode_row_col (&tables [MONO_TABLE_IMPLMAP], piinfo->implmap_idx - 1, MONO_IMPLMAP_FLAGS); } if (generic_container) mono_method_set_generic_container (result, generic_container); return result; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219796, "input": "X509_REQ *csr() { return m_csr; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 202143, "input": "static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { struct sock *sk; struct packet_sock *po; struct sockaddr_ll *sll; union tpacket_uhdr h; u8 *skb_head = skb->data; int skb_len = skb->len; unsigned int snaplen, res; unsigned long status = TP_STATUS_USER; unsigned short macoff, netoff, hdrlen; struct sk_buff *copy_skb = NULL; struct timespec64 ts; __u32 ts_status; bool is_drop_n_account = false; unsigned int slot_id = 0; bool do_vnet = false; /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. * We may add members to them until current aligned size without forcing * userspace to call getsockopt(..., PACKET_HDRLEN, ...). */ BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); if (skb->pkt_type == PACKET_LOOPBACK) goto drop; sk = pt->af_packet_priv; po = pkt_sk(sk); if (!net_eq(dev_net(dev), sock_net(sk))) goto drop; if (dev->header_ops) { if (sk->sk_type != SOCK_DGRAM) skb_push(skb, skb->data - skb_mac_header(skb)); else if (skb->pkt_type == PACKET_OUTGOING) { /* Special case: outgoing packets have ll header at head */ skb_pull(skb, skb_network_offset(skb)); } } snaplen = skb->len; res = run_filter(skb, sk, snaplen); if (!res) goto drop_n_restore; /* If we are flooded, just give up */ if (__packet_rcv_has_room(po, skb) == ROOM_NONE) { atomic_inc(&po->tp_drops); goto drop_n_restore; } if (skb->ip_summed == CHECKSUM_PARTIAL) status |= TP_STATUS_CSUMNOTREADY; else if (skb->pkt_type != PACKET_OUTGOING && (skb->ip_summed == CHECKSUM_COMPLETE || skb_csum_unnecessary(skb))) status |= TP_STATUS_CSUM_VALID; if (snaplen > res) snaplen = res; if (sk->sk_type == SOCK_DGRAM) { macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 + po->tp_reserve; } else { unsigned int maclen = skb_network_offset(skb); netoff = TPACKET_ALIGN(po->tp_hdrlen + (maclen < 16 ? 16 : maclen)) + po->tp_reserve; if (po->has_vnet_hdr) { netoff += sizeof(struct virtio_net_hdr); do_vnet = true; } macoff = netoff - maclen; } if (po->tp_version <= TPACKET_V2) { if (macoff + snaplen > po->rx_ring.frame_size) { if (po->copy_thresh && atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { if (skb_shared(skb)) { copy_skb = skb_clone(skb, GFP_ATOMIC); } else { copy_skb = skb_get(skb); skb_head = skb->data; } if (copy_skb) skb_set_owner_r(copy_skb, sk); } snaplen = po->rx_ring.frame_size - macoff; if ((int)snaplen < 0) { snaplen = 0; do_vnet = false; } } } else if (unlikely(macoff + snaplen > GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) { u32 nval; nval = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len - macoff; pr_err_once(\"tpacket_rcv: packet too big, clamped from %u to %u. macoff=%u\\n\", snaplen, nval, macoff); snaplen = nval; if (unlikely((int)snaplen < 0)) { snaplen = 0; macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len; do_vnet = false; } } spin_lock(&sk->sk_receive_queue.lock); h.raw = packet_current_rx_frame(po, skb, TP_STATUS_KERNEL, (macoff+snaplen)); if (!h.raw) goto drop_n_account; if (po->tp_version <= TPACKET_V2) { slot_id = po->rx_ring.head; if (test_bit(slot_id, po->rx_ring.rx_owner_map)) goto drop_n_account; __set_bit(slot_id, po->rx_ring.rx_owner_map); } if (do_vnet && virtio_net_hdr_from_skb(skb, h.raw + macoff - sizeof(struct virtio_net_hdr), vio_le(), true, 0)) { if (po->tp_version == TPACKET_V3) prb_clear_blk_fill_status(&po->rx_ring); goto drop_n_account; } if (po->tp_version <= TPACKET_V2) { packet_increment_rx_head(po, &po->rx_ring); /* * LOSING will be reported till you read the stats, * because it's COR - Clear On Read. * Anyways, moving it for V1/V2 only as V3 doesn't need this * at packet level. */ if (atomic_read(&po->tp_drops)) status |= TP_STATUS_LOSING; } po->stats.stats1.tp_packets++; if (copy_skb) { status |= TP_STATUS_COPY; __skb_queue_tail(&sk->sk_receive_queue, copy_skb); } spin_unlock(&sk->sk_receive_queue.lock); skb_copy_bits(skb, 0, h.raw + macoff, snaplen); if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) ktime_get_real_ts64(&ts); status |= ts_status; switch (po->tp_version) { case TPACKET_V1: h.h1->tp_len = skb->len; h.h1->tp_snaplen = snaplen; h.h1->tp_mac = macoff; h.h1->tp_net = netoff; h.h1->tp_sec = ts.tv_sec; h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC; hdrlen = sizeof(*h.h1); break; case TPACKET_V2: h.h2->tp_len = skb->len; h.h2->tp_snaplen = snaplen; h.h2->tp_mac = macoff; h.h2->tp_net = netoff; h.h2->tp_sec = ts.tv_sec; h.h2->tp_nsec = ts.tv_nsec; if (skb_vlan_tag_present(skb)) { h.h2->tp_vlan_tci = skb_vlan_tag_get(skb); h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto); status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID; } else { h.h2->tp_vlan_tci = 0; h.h2->tp_vlan_tpid = 0; } memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding)); hdrlen = sizeof(*h.h2); break; case TPACKET_V3: /* tp_nxt_offset,vlan are already populated above. * So DONT clear those fields here */ h.h3->tp_status |= status; h.h3->tp_len = skb->len; h.h3->tp_snaplen = snaplen; h.h3->tp_mac = macoff; h.h3->tp_net = netoff; h.h3->tp_sec = ts.tv_sec; h.h3->tp_nsec = ts.tv_nsec; memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding)); hdrlen = sizeof(*h.h3); break; default: BUG(); } sll = h.raw + TPACKET_ALIGN(hdrlen); sll->sll_halen = dev_parse_header(skb, sll->sll_addr); sll->sll_family = AF_PACKET; sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; if (unlikely(po->origdev)) sll->sll_ifindex = orig_dev->ifindex; else sll->sll_ifindex = dev->ifindex; smp_mb(); #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 if (po->tp_version <= TPACKET_V2) { u8 *start, *end; end = (u8 *) PAGE_ALIGN((unsigned long) h.raw + macoff + snaplen); for (start = h.raw; start < end; start += PAGE_SIZE) flush_dcache_page(pgv_to_page(start)); } smp_wmb(); #endif if (po->tp_version <= TPACKET_V2) { spin_lock(&sk->sk_receive_queue.lock); __packet_set_status(po, h.raw, status); __clear_bit(slot_id, po->rx_ring.rx_owner_map); spin_unlock(&sk->sk_receive_queue.lock); sk->sk_data_ready(sk); } else if (po->tp_version == TPACKET_V3) { prb_clear_blk_fill_status(&po->rx_ring); } drop_n_restore: if (skb_head != skb->data && skb_shared(skb)) { skb->data = skb_head; skb->len = skb_len; } drop: if (!is_drop_n_account) consume_skb(skb); else kfree_skb(skb); return 0; drop_n_account: spin_unlock(&sk->sk_receive_queue.lock); atomic_inc(&po->tp_drops); is_drop_n_account = true; sk->sk_data_ready(sk); kfree_skb(copy_skb); goto drop_n_restore; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "A flaw was found in the Linux kernel before 5.9-rc4. Memory corruption can be exploited to gain root privileges from unprivileged processes. The highest threat from this vulnerability is to data confidentiality and integrity.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2020-14386"}} -{"idx": 249536, "input": "GF_Err dump_isom_scene(char *file, char *inName, Bool is_final_name, GF_SceneDumpFormat dump_mode, Bool do_log, Bool no_odf_conv) { GF_Err e; GF_SceneManager *ctx; GF_SceneGraph *sg; GF_SceneLoader load; GF_FileType ftype; gf_log_cbk prev_logs = NULL; FILE *logs = NULL; sg = gf_sg_new(); ctx = gf_sm_new(sg); memset(&load, 0, sizeof(GF_SceneLoader)); load.fileName = file; load.ctx = ctx; load.swf_import_flags = swf_flags; if (dump_mode == GF_SM_DUMP_SVG) { load.swf_import_flags |= GF_SM_SWF_USE_SVG; load.svgOutFile = inName; } load.swf_flatten_limit = swf_flatten_angle; ftype = get_file_type_by_ext(file); if (ftype == GF_FILE_TYPE_ISO_MEDIA) { load.isom = gf_isom_open(file, GF_ISOM_OPEN_READ, NULL); if (!load.isom) { e = gf_isom_last_error(NULL); fprintf(stderr, \"Error opening file: %s\\n\", gf_error_to_string(e)); gf_sm_del(ctx); gf_sg_del(sg); return e; } if (no_odf_conv) gf_isom_disable_odf_conversion(load.isom, GF_TRUE); } else if (ftype==GF_FILE_TYPE_LSR_SAF) { load.isom = gf_isom_open(\"saf_conv\", GF_ISOM_WRITE_EDIT, NULL); #ifndef GPAC_DISABLE_MEDIA_IMPORT if (load.isom) { GF_Fraction _frac = {0,0}; e = import_file(load.isom, file, 0, _frac, 0, NULL, NULL, 0); } else #else fprintf(stderr, \"Warning: GPAC was compiled without Media Import support\\n\"); #endif e = gf_isom_last_error(NULL); if (e) { fprintf(stderr, \"Error importing file: %s\\n\", gf_error_to_string(e)); gf_sm_del(ctx); gf_sg_del(sg); if (load.isom) gf_isom_delete(load.isom); return e; } } if (do_log) { char szLog[GF_MAX_PATH]; sprintf(szLog, \"%s_dec.logs\", inName); logs = gf_fopen(szLog, \"wt\"); gf_log_set_tool_level(GF_LOG_CODING, GF_LOG_DEBUG); prev_logs = gf_log_set_callback(logs, scene_coding_log); } e = gf_sm_load_init(&load); if (!e) e = gf_sm_load_run(&load); gf_sm_load_done(&load); if (logs) { gf_log_set_tool_level(GF_LOG_CODING, GF_LOG_ERROR); gf_log_set_callback(NULL, prev_logs); gf_fclose(logs); } if (!e && dump_mode != GF_SM_DUMP_SVG) { u32 count = gf_list_count(ctx->streams); if (count) fprintf(stderr, \"Scene loaded - dumping %d systems streams\\n\", count); else fprintf(stderr, \"Scene loaded - dumping root scene\\n\"); e = gf_sm_dump(ctx, inName, is_final_name, dump_mode); } gf_sm_del(ctx); gf_sg_del(sg); if (e) fprintf(stderr, \"Error loading scene: %s\\n\", gf_error_to_string(e)); if (load.isom) gf_isom_delete(load.isom); return e; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 244698, "input": "static int rar5_cleanup(struct archive_read *a) { struct rar5* rar = get_context(a); free(rar->cstate.window_buf); free(rar->cstate.filtered_buf); free(rar->vol.push_buf); free_filters(rar); cdeque_free(&rar->cstate.filters); free(rar); a->format->data = NULL; return ARCHIVE_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 234078, "input": "static void ndpi_int_netbios_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t sub_protocol) { char name[64]; u_int off = flow->packet.payload[12] == 0x20 ? 12 : 14; if((off < flow->packet.payload_packet_len) && ndpi_netbios_name_interpret((char*)&flow->packet.payload[off], flow->packet.payload_packet_len - off, name, sizeof(name)) > 0) { snprintf((char*)flow->host_server_name, sizeof(flow->host_server_name)-1, \"%s\", name); ndpi_check_dga_name(ndpi_struct, flow, (char*)flow->host_server_name, 1); } if(sub_protocol == NDPI_PROTOCOL_UNKNOWN) ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETBIOS, NDPI_PROTOCOL_UNKNOWN); else ndpi_set_detected_protocol(ndpi_struct, flow, sub_protocol, NDPI_PROTOCOL_NETBIOS); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232136, "input": "static int win_eprintf(const char *format, ...) { va_list ap; va_start (ap, format); r_cons_win_vhprintf (STD_ERROR_HANDLE, false, format, ap); va_end (ap); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 254703, "input": "static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *field) { #ifndef PB_ENABLE_MALLOC PB_UNUSED(wire_type); PB_UNUSED(field); PB_RETURN_ERROR(stream, \"no malloc support\"); #else switch (PB_HTYPE(field->type)) { case PB_HTYPE_REQUIRED: case PB_HTYPE_OPTIONAL: case PB_HTYPE_ONEOF: if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL) { /* Duplicate field, have to release the old allocation first. */ /* FIXME: Does this work correctly for oneofs? */ pb_release_single_field(field); } if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF) { *(pb_size_t*)field->pSize = field->tag; } if (PB_LTYPE(field->type) == PB_LTYPE_STRING || PB_LTYPE(field->type) == PB_LTYPE_BYTES) { /* pb_dec_string and pb_dec_bytes handle allocation themselves */ field->pData = field->pField; return decode_basic_field(stream, wire_type, field); } else { if (!allocate_field(stream, field->pField, field->data_size, 1)) return false; field->pData = *(void**)field->pField; initialize_pointer_field(field->pData, field); return decode_basic_field(stream, wire_type, field); } case PB_HTYPE_REPEATED: if (wire_type == PB_WT_STRING && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) { /* Packed array, multiple items come in at once. */ bool status = true; pb_size_t *size = (pb_size_t*)field->pSize; size_t allocated_size = *size; pb_istream_t substream; if (!pb_make_string_substream(stream, &substream)) return false; while (substream.bytes_left) { if (*size == PB_SIZE_MAX) { #ifndef PB_NO_ERRMSG stream->errmsg = \"too many array entries\"; #endif status = false; break; } if ((size_t)*size + 1 > allocated_size) { /* Allocate more storage. This tries to guess the * number of remaining entries. Round the division * upwards. */ size_t remain = (substream.bytes_left - 1) / field->data_size + 1; if (remain < PB_SIZE_MAX - allocated_size) allocated_size += remain; else allocated_size += 1; if (!allocate_field(&substream, field->pField, field->data_size, allocated_size)) { status = false; break; } } /* Decode the array entry */ field->pData = *(char**)field->pField + field->data_size * (*size); initialize_pointer_field(field->pData, field); if (!decode_basic_field(&substream, PB_WT_PACKED, field)) { status = false; break; } (*size)++; } if (!pb_close_string_substream(stream, &substream)) return false; return status; } else { /* Normal repeated field, i.e. only one item at a time. */ pb_size_t *size = (pb_size_t*)field->pSize; if (*size == PB_SIZE_MAX) PB_RETURN_ERROR(stream, \"too many array entries\"); if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1))) return false; field->pData = *(char**)field->pField + field->data_size * (*size); (*size)++; initialize_pointer_field(field->pData, field); return decode_basic_field(stream, wire_type, field); } default: PB_RETURN_ERROR(stream, \"invalid field type\"); } #endif }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 319432, "input": "void LibRaw::sony_arw_load_raw() { ushort huff[32770]; static const ushort tab[18] = {0xf11, 0xf10, 0xe0f, 0xd0e, 0xc0d, 0xb0c, 0xa0b, 0x90a, 0x809, 0x708, 0x607, 0x506, 0x405, 0x304, 0x303, 0x300, 0x202, 0x201}; int i, c, n, col, row, sum = 0; huff[0] = 15; for (n = i = 0; i < 18; i++) FORC(32768 >> (tab[i] >> 8)) huff[++n] = tab[i]; getbits(-1); for (col = raw_width; col--;) { checkCancel(); for (row = 0; row < raw_height + 1; row += 2) { if (row == raw_height) row = 1; if ((sum += ljpeg_diff(huff)) >> 12) derror(); if (row < height) RAW(row, col) = sum; } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198363, "input": "void Compute(OpKernelContext* ctx) override { const Tensor& handle = ctx->input(0); const string& name = handle.scalar()(); Tensor val; auto session_state = ctx->session_state(); OP_REQUIRES(ctx, session_state != nullptr, errors::FailedPrecondition( \"GetSessionTensor called on null session state\")); OP_REQUIRES_OK(ctx, session_state->GetTensor(name, &val)); ctx->set_output(0, val); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, the implementation of `tf.raw_ops.GetSessionTensor` does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2022-29191"}} -{"idx": 195486, "input": "bool handleBackslash(signed char& out) { char ch = *p++; switch (ch) { case 0: return false; case '\"': out = ch; return true; case '\\\\': out = ch; return true; case '/': out = ch; return true; case 'b': out = '\\b'; return true; case 'f': out = '\\f'; return true; case 'n': out = '\\n'; return true; case 'r': out = '\\r'; return true; case 't': out = '\\t'; return true; case 'u': { if (UNLIKELY(is_tsimplejson)) { auto const ch1 = *p++; auto const ch2 = *p++; auto const dch3 = dehexchar(*p++); auto const dch4 = dehexchar(*p++); if (UNLIKELY(ch1 != '0' || ch2 != '0' || dch3 < 0 || dch4 < 0)) { return false; } out = (dch3 << 4) | dch4; return true; } else { uint16_t u16cp = 0; for (int i = 0; i < 4; i++) { auto const hexv = dehexchar(*p++); if (hexv < 0) return false; // includes check for end of string u16cp <<= 4; u16cp |= hexv; } if (u16cp > 0x7f) { return false; } else { out = u16cp; return true; } } } default: return false; } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "Insufficient boundary checks when decoding JSON in handleBackslash reads out of bounds memory, potentially leading to DOS. This issue affects HHVM 4.45.0, 4.44.0, 4.43.0, 4.42.0, 4.41.0, 4.40.0, 4.39.0, versions between 4.33.0 and 4.38.0 (inclusive), versions between 4.9.0 and 4.32.0 (inclusive), and versions prior to 4.8.7.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-1888"}} -{"idx": 445645, "input": "void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { /* use static because iter can be a bit big for the stack */ static struct trace_iterator iter; static atomic_t dump_running; struct trace_array *tr = &global_trace; unsigned int old_userobj; unsigned long flags; int cnt = 0, cpu; /* Only allow one dump user at a time. */ if (atomic_inc_return(&dump_running) != 1) { atomic_dec(&dump_running); return; } /* * Always turn off tracing when we dump. * We don't need to show trace output of what happens * between multiple crashes. * * If the user does a sysrq-z, then they can re-enable * tracing with echo 1 > tracing_on. */ tracing_off(); local_irq_save(flags); /* Simulate the iterator */ trace_init_global_iter(&iter); for_each_tracing_cpu(cpu) { atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled); } old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ; /* don't look at user memory in panic mode */ tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ; switch (oops_dump_mode) { case DUMP_ALL: iter.cpu_file = RING_BUFFER_ALL_CPUS; break; case DUMP_ORIG: iter.cpu_file = raw_smp_processor_id(); break; case DUMP_NONE: goto out_enable; default: printk(KERN_TRACE \"Bad dumping mode, switching to all CPUs dump\\n\"); iter.cpu_file = RING_BUFFER_ALL_CPUS; } printk(KERN_TRACE \"Dumping ftrace buffer:\\n\"); /* Did function tracer already get disabled? */ if (ftrace_is_dead()) { printk(\"# WARNING: FUNCTION TRACING IS CORRUPTED\\n\"); printk(\"# MAY BE MISSING FUNCTION EVENTS\\n\"); } /* * We need to stop all tracing on all CPUS to read the * the next buffer. This is a bit expensive, but is * not done often. We fill all what we can read, * and then release the locks again. */ while (!trace_empty(&iter)) { if (!cnt) printk(KERN_TRACE \"---------------------------------\\n\"); cnt++; /* reset all but tr, trace, and overruns */ memset(&iter.seq, 0, sizeof(struct trace_iterator) - offsetof(struct trace_iterator, seq)); iter.iter_flags |= TRACE_FILE_LAT_FMT; iter.pos = -1; if (trace_find_next_entry_inc(&iter) != NULL) { int ret; ret = print_trace_line(&iter); if (ret != TRACE_TYPE_NO_CONSUME) trace_consume(&iter); } touch_nmi_watchdog(); trace_printk_seq(&iter.seq); } if (!cnt) printk(KERN_TRACE \" (ftrace buffer empty)\\n\"); else printk(KERN_TRACE \"---------------------------------\\n\"); out_enable: tr->trace_flags |= old_userobj; for_each_tracing_cpu(cpu) { atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled); } atomic_dec(&dump_running); local_irq_restore(flags); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 249544, "input": "void dump_isom_rtp(GF_ISOFile *file, char *inName, Bool is_final_name) { u32 i, j, size; FILE *dump; const char *sdp; if (inName) { char szBuf[1024]; strcpy(szBuf, inName); if (!is_final_name) strcat(szBuf, \"_rtp.xml\"); dump = gf_fopen(szBuf, \"wt\"); if (!dump) { fprintf(stderr, \"Failed to open %s\\n\", szBuf); return; } } else { dump = stdout; } fprintf(dump, \"\\n\"); fprintf(dump, \"\\n\"); fprintf(dump, \"\\n\"); for (i=0; i\\n\", gf_isom_get_track_id(file, i+1)); gf_isom_sdp_track_get(file, i+1, &sdp, &size); fprintf(dump, \"%s\", sdp); #ifndef GPAC_DISABLE_ISOM_HINTING for (j=0; j\\n\"); } fprintf(dump, \"\\n\"); if (inName) gf_fclose(dump); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417748, "input": "static OTLookup *CreateACLookup(SplineFont1 *sf,AnchorClass1 *ac) { OTLookup *otl = chunkalloc(sizeof(OTLookup)); otl->lookup_type = ac->ac.type == act_mark ? gpos_mark2base : ac->ac.type == act_mkmk ? gpos_mark2mark : ac->ac.type == act_curs ? gpos_cursive : ac->ac.type == act_mklg ? gpos_mark2ligature : ot_undef; if ( otl->lookup_type == ot_undef ) IError(\"Unknown AnchorClass type\"); otl->next = sf->sf.gpos_lookups; sf->sf.gpos_lookups = otl; otl->lookup_flags = ac->flags; otl->features = FeaturesFromTagSli(ac->feature_tag,ac->script_lang_index,sf); /* We will set the lookup_index after we've ordered the list */ /* We will set the lookup_name after we've assigned the index */ /* We will add one subtable soon */ return( otl ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506567, "input": "history_command() { #ifdef USE_READLINE c_token++; if (!END_OF_COMMAND && equals(c_token,\"?\")) { static char *search_str = NULL; /* string from command line to search for */ /* find and show the entries */ c_token++; m_capture(&search_str, c_token, c_token); /* reallocates memory */ printf (\"history ?%s\\n\", search_str); if (!history_find_all(search_str)) int_error(c_token,\"not in history\"); c_token++; } else if (!END_OF_COMMAND && equals(c_token,\"!\")) { const char *line_to_do = NULL; /* command returned by search */ c_token++; if (isanumber(c_token)) { int i = int_expression(); line_to_do = history_find_by_number(i); } else { char *search_str = NULL; /* string from command line to search for */ m_capture(&search_str, c_token, c_token); line_to_do = history_find(search_str); free(search_str); } if (line_to_do == NULL) int_error(c_token, \"not in history\"); /* Add the command to the history. Note that history commands themselves are no longer added to the history. */ add_history((char *) line_to_do); printf(\" Executing:\\n\\t%s\\n\", line_to_do); do_string(line_to_do); c_token++; } else { int n = 0; /* print only entries */ char *tmp; TBOOLEAN append = FALSE; /* rewrite output file or append it */ static char *name = NULL; /* name of the output file; NULL for stdout */ TBOOLEAN quiet = history_quiet; if (!END_OF_COMMAND && almost_equals(c_token,\"q$uiet\")) { /* option quiet to suppress history entry numbers */ quiet = TRUE; c_token++; } /* show history entries */ if (!END_OF_COMMAND && isanumber(c_token)) { n = int_expression(); } if ((tmp = try_to_get_string())) { free(name); name = tmp; if (!END_OF_COMMAND && almost_equals(c_token, \"ap$pend\")) { append = TRUE; c_token++; } } write_history_n(n, (quiet ? \"\" : name), (append ? \"a\" : \"w\")); } #else c_token++; int_warn(NO_CARET, \"This copy of gnuplot was built without support for command history.\"); #endif /* defined(USE_READLINE) */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198286, "input": "static GF_Err gf_isom_parse_movie_boxes_internal(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode) { GF_Box *a; u64 totSize, mdat_end=0; GF_Err e = GF_OK; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->single_moof_mode && mov->single_moof_state == 2) { return e; } /*restart from where we stopped last*/ totSize = mov->current_top_box_start; if (mov->bytes_removed) { assert(totSize >= mov->bytes_removed); totSize -= mov->bytes_removed; } gf_bs_seek(mov->movieFileMap->bs, totSize); #endif /*while we have some data, parse our boxes*/ while (gf_bs_available(mov->movieFileMap->bs)) { *bytesMissing = 0; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Parsing a top-level box at position %d\\n\", mov->current_top_box_start)); #endif e = gf_isom_parse_root_box(&a, mov->movieFileMap->bs, boxType, bytesMissing, progressive_mode); if (e >= 0) { } else if (e == GF_ISOM_INCOMPLETE_FILE) { /*our mdat is uncomplete, only valid for READ ONLY files...*/ if (mov->openMode != GF_ISOM_OPEN_READ) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete MDAT while file is not read-only\\n\")); return GF_ISOM_INVALID_FILE; } if ((mov->openMode == GF_ISOM_OPEN_READ) && !progressive_mode) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete file while reading for dump - aborting parsing\\n\")); break; } return e; } else { return e; } switch (a->type) { /*MOOV box*/ case GF_ISOM_BOX_TYPE_MOOV: if (mov->moov) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate MOOV detected!\\n\")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->moov = (GF_MovieBox *)a; mov->original_moov_offset = mov->current_top_box_start; /*set our pointer to the movie*/ mov->moov->mov = mov; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->moov->mvex) mov->moov->mvex->mov = mov; #ifdef GF_ENABLE_CTRN if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { gf_isom_setup_traf_inheritance(mov); } #endif #endif e = gf_list_add(mov->TopBoxes, a); if (e) return e; totSize += a->size; if (!mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MovieHeaderBox\\n\")); return GF_ISOM_INVALID_FILE; } if (mov->meta) { gf_isom_meta_restore_items_ref(mov, mov->meta); } //dump senc info in dump mode if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; for (k=0; kmoov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, trak, NULL, trak->sample_encryption); if (e) return e; } } } else { u32 k; for (k=0; kmoov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->Media->information->sampleTable->sampleGroups) { convert_compact_sample_groups(trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroups); } } } if (mdat_end && mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } break; /*META box*/ case GF_ISOM_BOX_TYPE_META: if (mov->meta) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate META detected!\\n\")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->meta = (GF_MetaBox *)a; mov->original_meta_offset = mov->current_top_box_start; e = gf_list_add(mov->TopBoxes, a); if (e) { return e; } totSize += a->size; if (mov->moov) { gf_isom_meta_restore_items_ref(mov, mov->meta); } break; /*we only keep the MDAT in READ for dump purposes*/ case GF_ISOM_BOX_TYPE_MDAT: if (!mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; if (mov->openMode == GF_ISOM_OPEN_READ) { if (!mov->mdat) { mov->mdat = (GF_MediaDataBox *) a; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS else if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) gf_list_add(mov->TopBoxes, a); #endif else gf_isom_box_del(a); //in other modes we don't care if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { mdat_end = gf_bs_get_position(mov->movieFileMap->bs); if (mov->moov) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } } } /*if we don't have any MDAT yet, create one (edit-write mode) We only work with one mdat, but we're puting it at the place of the first mdat found when opening a file for editing*/ else if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { gf_isom_box_del(a); mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_FTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->brand) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'ftyp' detected!\\n\")); return GF_ISOM_INVALID_FILE; } mov->brand = (GF_FileTypeBox *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; case GF_ISOM_BOX_TYPE_OTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->otyp) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'otyp' detected!\\n\")); return GF_ISOM_INVALID_FILE; } if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { mov->otyp = (GF_Box *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else { GF_FileTypeBox *brand = (GF_FileTypeBox *) gf_isom_box_find_child(a->child_boxes, GF_ISOM_BOX_TYPE_FTYP); if (brand) { s32 pos; gf_list_del_item(a->child_boxes, brand); pos = gf_list_del_item(mov->TopBoxes, mov->brand); gf_isom_box_del((GF_Box *) mov->brand); mov->brand = brand; if (pos<0) pos=0; gf_list_insert(mov->TopBoxes, brand, pos); } } break; case GF_ISOM_BOX_TYPE_PDIN: /*ONE AND ONLY ONE PDIN*/ if (mov->pdin) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'pdin'' detected!\\n\")); return GF_ISOM_INVALID_FILE; } mov->pdin = (GF_ProgressiveDownloadBox *) a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS case GF_ISOM_BOX_TYPE_STYP: { u32 brand = ((GF_FileTypeBox *)a)->majorBrand; switch (brand) { case GF_ISOM_BRAND_SISX: case GF_ISOM_BRAND_RISX: case GF_ISOM_BRAND_SSSS: mov->is_index_segment = GF_TRUE; break; default: break; } } /*fall-through*/ case GF_ISOM_BOX_TYPE_SIDX: case GF_ISOM_BOX_TYPE_SSIX: if (mov->moov && !mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) && (mov->openMode!=GF_ISOM_OPEN_KEEP_FRAGMENTS) ) { if (a->type==GF_ISOM_BOX_TYPE_SIDX) { if (mov->root_sidx) gf_isom_box_del( (GF_Box *) mov->root_sidx); mov->root_sidx = (GF_SegmentIndexBox *) a; mov->sidx_start_offset = mov->current_top_box_start; mov->sidx_end_offset = gf_bs_get_position(mov->movieFileMap->bs); } else if (a->type==GF_ISOM_BOX_TYPE_STYP) { mov->styp_start_offset = mov->current_top_box_start; if (mov->seg_styp) gf_isom_box_del(mov->seg_styp); mov->seg_styp = a; } else if (a->type==GF_ISOM_BOX_TYPE_SSIX) { if (mov->seg_ssix) gf_isom_box_del(mov->seg_ssix); mov->seg_ssix = a; } else { gf_isom_box_del(a); } gf_isom_push_mdat_end(mov, mov->current_top_box_start); } else if (!mov->NextMoofNumber && (a->type==GF_ISOM_BOX_TYPE_SIDX)) { if (mov->main_sidx) gf_isom_box_del( (GF_Box *) mov->main_sidx); mov->main_sidx = (GF_SegmentIndexBox *) a; mov->main_sidx_end_pos = mov->current_top_box_start + a->size; } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_MOOF: //no support for inplace rewrite for fragmented files gf_isom_disable_inplace_rewrite(mov); if (!mov->moov) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Movie fragment but no moov (yet) - possibly broken parsing!\\n\")); } if (mov->single_moof_mode) { mov->single_moof_state++; if (mov->single_moof_state > 1) { gf_isom_box_del(a); return GF_OK; } } ((GF_MovieFragmentBox *)a)->mov = mov; totSize += a->size; mov->moof = (GF_MovieFragmentBox *) a; /*some smooth streaming streams contain a SDTP under the TRAF: this is incorrect, convert it*/ FixTrackID(mov); if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { FixSDTPInTRAF(mov->moof); } else { u32 k; for (k=0; kmoof->TrackList); k++) { GF_TrackFragmentBox *traf = (GF_TrackFragmentBox *)gf_list_get(mov->moof->TrackList, k); if (traf->sampleGroups) { convert_compact_sample_groups(traf->child_boxes, traf->sampleGroups); } } } /*read & debug: store at root level*/ if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; gf_list_add(mov->TopBoxes, a); /*also update pointers to trex for debug*/ if (mov->moov) { for (k=0; kmoof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->tfhd && mov->moov->mvex && mov->moov->mvex->TrackExList) { GF_TrackBox *trak = gf_isom_get_track_from_id(mov->moov, traf->tfhd->trackID); u32 j=0; while ((traf->trex = (GF_TrackExtendsBox*)gf_list_enum(mov->moov->mvex->TrackExList, &j))) { if (traf->trex->trackID == traf->tfhd->trackID) { if (!traf->trex->track) traf->trex->track = trak; break; } traf->trex = NULL; } } //we should only parse senc/psec when no saiz/saio is present, otherwise we fetch the info directly if (traf->trex && traf->tfhd && traf->trex->track && traf->sample_encryption) { GF_TrackBox *trak = GetTrackbyID(mov->moov, traf->tfhd->trackID); trak->current_traf_stsd_idx = traf->tfhd->sample_desc_index ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index; e = senc_Parse(mov->movieFileMap->bs, trak, traf, traf->sample_encryption); if (e) return e; trak->current_traf_stsd_idx = 0; } } } else { for (k=0; kmoof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, NULL, traf, traf->sample_encryption); if (e) return e; } } } } else if (mov->openMode==GF_ISOM_OPEN_KEEP_FRAGMENTS) { mov->NextMoofNumber = mov->moof->mfhd->sequence_number+1; mov->moof = NULL; gf_isom_box_del(a); } else { /*merge all info*/ e = MergeFragment((GF_MovieFragmentBox *)a, mov); gf_isom_box_del(a); if (e) return e; } //done with moov if (mov->root_sidx) { gf_isom_box_del((GF_Box *) mov->root_sidx); mov->root_sidx = NULL; } if (mov->root_ssix) { gf_isom_box_del(mov->seg_ssix); mov->root_ssix = NULL; } if (mov->seg_styp) { gf_isom_box_del(mov->seg_styp); mov->seg_styp = NULL; } mov->sidx_start_offset = 0; mov->sidx_end_offset = 0; mov->styp_start_offset = 0; break; #endif case GF_ISOM_BOX_TYPE_UNKNOWN: { GF_UnknownBox *box = (GF_UnknownBox*)a; if (box->original_4cc == GF_ISOM_BOX_TYPE_JP) { u8 *c = (u8 *) box->data; if ((box->dataSize==4) && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A)) mov->is_jp2 = 1; gf_isom_box_del(a); } else { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } } break; case GF_ISOM_BOX_TYPE_PRFT: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { //keep the last one read if (mov->last_producer_ref_time) gf_isom_box_del(a); else mov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a; break; } #endif //fallthrough default: totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*remember where we left, in case we append an entire number of movie fragments*/ mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; #endif } /*we need at least moov or meta*/ if (!mov->moov && !mov->meta #ifndef GPAC_DISABLE_ISOM_FRAGMENTS && !mov->moof && !mov->is_index_segment #endif ) { return GF_ISOM_INCOMPLETE_FILE; } /*we MUST have movie header*/ if (!gf_opts_get_bool(\"core\", \"no-check\")) { if (mov->moov && !mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MVHD in MOOV!\\n\")); return GF_ISOM_INVALID_FILE; } /*we MUST have meta handler*/ if (mov->meta && !mov->meta->handler) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing handler in META!\\n\")); return GF_ISOM_INVALID_FILE; } } #ifndef GPAC_DISABLE_ISOM_WRITE if (mov->moov) { /*set the default interleaving time*/ mov->interleavingTime = mov->moov->mvhd->timeScale; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*in edit mode with successfully loaded fragments, delete all fragment signaling since file is no longer fragmented*/ if ((mov->openMode > GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS) && mov->moov->mvex) { gf_isom_box_del_parent(&mov->moov->child_boxes, (GF_Box *)mov->moov->mvex); mov->moov->mvex = NULL; } #endif } //create a default mdat if none was found if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) return e; } #endif /*GPAC_DISABLE_ISOM_WRITE*/ return GF_OK; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Missing Release of Memory after Effective Lifetime"], "explanation": "Memory leak in the def_parent_box_new function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.", "severity_level": "NoInfo", "cwe": "CWE-401", "cve": "CVE-2021-33364"}} -{"idx": 230196, "input": "HermesValue JSObject::_getOwnIndexedImpl(JSObject *, Runtime *, uint32_t) { return HermesValue::encodeEmptyValue(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 379530, "input": "restore_pipestatus_array (a) ARRAY *a; { SHELL_VAR *v; ARRAY *a2; v = find_variable (\"PIPESTATUS\"); /* XXX - should we still assign even if existing value is NULL? */ if (v == 0 || array_p (v) == 0 || array_cell (v) == 0) return; a2 = array_cell (v); var_setarray (v, a); array_dispose (a2); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 350339, "input": "fopenTiff(FILE *fp, const char *modestring) { PROCNAME(\"fopenTiff\"); if (!fp) return (TIFF *)ERROR_PTR(\"stream not opened\", procName, NULL); if (!modestring) return (TIFF *)ERROR_PTR(\"modestring not defined\", procName, NULL); TIFFSetWarningHandler(NULL); /* disable warnings */ TIFFSetErrorHandler(NULL); /* disable error messages */ fseek(fp, 0, SEEK_SET); return TIFFClientOpen(\"TIFFstream\", modestring, (thandle_t)fp, lept_read_proc, lept_write_proc, lept_seek_proc, lept_close_proc, lept_size_proc, NULL, NULL); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230205, "input": "TEST_P(JSITest, PropNameIDTest) { // This is a little weird to test, because it doesn't really exist // in JS yet. All I can do is create them, compare them, and // receive one as an argument to a HostObject. PropNameID quux = PropNameID::forAscii(rt, \"quux1\", 4); PropNameID movedQuux = std::move(quux); EXPECT_EQ(movedQuux.utf8(rt), \"quux\"); movedQuux = PropNameID::forAscii(rt, \"quux2\"); EXPECT_EQ(movedQuux.utf8(rt), \"quux2\"); PropNameID copiedQuux = PropNameID(rt, movedQuux); EXPECT_TRUE(PropNameID::compare(rt, movedQuux, copiedQuux)); EXPECT_TRUE(PropNameID::compare(rt, movedQuux, movedQuux)); EXPECT_TRUE(PropNameID::compare( rt, movedQuux, PropNameID::forAscii(rt, std::string(\"quux2\")))); EXPECT_FALSE(PropNameID::compare( rt, movedQuux, PropNameID::forAscii(rt, std::string(\"foo\")))); uint8_t utf8[] = {0xF0, 0x9F, 0x86, 0x97}; PropNameID utf8PropNameID = PropNameID::forUtf8(rt, utf8, sizeof(utf8)); EXPECT_EQ(utf8PropNameID.utf8(rt), u8\"\\U0001F197\"); EXPECT_TRUE(PropNameID::compare( rt, utf8PropNameID, PropNameID::forUtf8(rt, utf8, sizeof(utf8)))); PropNameID nonUtf8PropNameID = PropNameID::forUtf8(rt, \"meow\"); EXPECT_TRUE(PropNameID::compare( rt, nonUtf8PropNameID, PropNameID::forAscii(rt, \"meow\"))); EXPECT_EQ(nonUtf8PropNameID.utf8(rt), \"meow\"); PropNameID strPropNameID = PropNameID::forString(rt, String::createFromAscii(rt, \"meow\")); EXPECT_TRUE(PropNameID::compare(rt, nonUtf8PropNameID, strPropNameID)); auto names = PropNameID::names( rt, \"Ala\", std::string(\"ma\"), PropNameID::forAscii(rt, \"kota\")); EXPECT_EQ(names.size(), 3); EXPECT_TRUE( PropNameID::compare(rt, names[0], PropNameID::forAscii(rt, \"Ala\"))); EXPECT_TRUE( PropNameID::compare(rt, names[1], PropNameID::forAscii(rt, \"ma\"))); EXPECT_TRUE( PropNameID::compare(rt, names[2], PropNameID::forAscii(rt, \"kota\"))); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432563, "input": "static void svm_vcpu_init_msrpm(u32 *msrpm) { int i; memset(msrpm, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); for (i = 0; direct_access_msrs[i].index != MSR_INVALID; i++) { if (!direct_access_msrs[i].always) continue; set_msr_interception(msrpm, direct_access_msrs[i].index, 1, 1); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 208675, "input": "FastHufDecoder::FastHufDecoder (const char *&table, int numBytes, int minSymbol, int maxSymbol, int rleSymbol) : _rleSymbol (rleSymbol), _numSymbols (0), _minCodeLength (255), _maxCodeLength (0), _idToSymbol (0) { // // List of symbols that we find with non-zero code lengths // (listed in the order we find them). Store these in the // same format as the code book stores codes + lengths - // low 6 bits are the length, everything above that is // the symbol. // std::vector symbols; // // The 'base' table is the minimum code at each code length. base[i] // is the smallest code (numerically) of length i. // Int64 base[MAX_CODE_LEN + 1]; // // The 'offset' table is the position (in sorted order) of the first id // of a given code lenght. Array is indexed by code length, like base. // Int64 offset[MAX_CODE_LEN + 1]; // // Count of how many codes at each length there are. Array is // indexed by code length, like base and offset. // size_t codeCount[MAX_CODE_LEN + 1]; for (int i = 0; i <= MAX_CODE_LEN; ++i) { codeCount[i] = 0; base[i] = 0xffffffffffffffffULL; offset[i] = 0; } // // Count the number of codes, the min/max code lengths, the number of // codes with each length, and record symbols with non-zero code // length as we find them. // const char *currByte = table; Int64 currBits = 0; int currBitCount = 0; const int SHORT_ZEROCODE_RUN = 59; const int LONG_ZEROCODE_RUN = 63; const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; for (Int64 symbol = static_cast(minSymbol); symbol <= static_cast(maxSymbol); symbol++) { if (currByte - table > numBytes) { throw IEX_NAMESPACE::InputExc (\"Error decoding Huffman table \" \"(Truncated table data).\"); } // // Next code length - either: // 0-58 (literal code length) // 59-62 (various lengths runs of 0) // 63 (run of n 0's, with n is the next 8 bits) // Int64 codeLen = readBits (6, currBits, currBitCount, currByte); if (codeLen == (Int64) LONG_ZEROCODE_RUN) { if (currByte - table > numBytes) { throw IEX_NAMESPACE::InputExc (\"Error decoding Huffman table \" \"(Truncated table data).\"); } int runLen = readBits (8, currBits, currBitCount, currByte) + SHORTEST_LONG_RUN; if (symbol + runLen > static_cast(maxSymbol + 1)) { throw IEX_NAMESPACE::InputExc (\"Error decoding Huffman table \" \"(Run beyond end of table).\"); } symbol += runLen - 1; } else if (codeLen >= static_cast(SHORT_ZEROCODE_RUN)) { int runLen = codeLen - SHORT_ZEROCODE_RUN + 2; if (symbol + runLen > static_cast(maxSymbol + 1)) { throw IEX_NAMESPACE::InputExc (\"Error decoding Huffman table \" \"(Run beyond end of table).\"); } symbol += runLen - 1; } else if (codeLen != 0) { symbols.push_back ((symbol << 6) | (codeLen & 63)); if (codeLen < _minCodeLength) _minCodeLength = codeLen; if (codeLen > _maxCodeLength) _maxCodeLength = codeLen; codeCount[codeLen]++; } } for (int i = 0; i < MAX_CODE_LEN; ++i) _numSymbols += codeCount[i]; table = currByte; // // Compute base - once we have the code length counts, there // is a closed form solution for this // { double* countTmp = new double[_maxCodeLength+1]; for (int l = _minCodeLength; l <= _maxCodeLength; ++l) { countTmp[l] = (double)codeCount[l] * (double)(2 << (_maxCodeLength-l)); } for (int l = _minCodeLength; l <= _maxCodeLength; ++l) { double tmp = 0; for (int k =l + 1; k <= _maxCodeLength; ++k) tmp += countTmp[k]; tmp /= (double)(2 << (_maxCodeLength - l)); base[l] = (Int64)ceil (tmp); } delete [] countTmp; } // // Compute offset - these are the positions of the first // id (not symbol) that has length [i] // offset[_maxCodeLength] = 0; for (int i= _maxCodeLength - 1; i >= _minCodeLength; i--) offset[i] = offset[i + 1] + codeCount[i + 1]; // // Allocate and fill the symbol-to-id mapping. Smaller Ids should be // mapped to less-frequent symbols (which have longer codes). Use // the offset table to tell us where the id's for a given code // length start off. // _idToSymbol = new int[_numSymbols]; Int64 mapping[MAX_CODE_LEN + 1]; for (int i = 0; i < MAX_CODE_LEN + 1; ++i) mapping[i] = -1; for (int i = _minCodeLength; i <= _maxCodeLength; ++i) mapping[i] = offset[i]; for (std::vector::const_iterator i = symbols.begin(); i != symbols.end(); ++i) { int codeLen = *i & 63; int symbol = *i >> 6; if (mapping[codeLen] >= static_cast(_numSymbols)) { delete[] _idToSymbol; _idToSymbol = NULL; throw IEX_NAMESPACE::InputExc (\"Huffman decode error \" \"(Invalid symbol in header).\"); } _idToSymbol[mapping[codeLen]] = symbol; mapping[codeLen]++; } // // exceptions can be thrown whilst building tables. Delete // _idToSynmbol before re-throwing to prevent memory leak // try { buildTables(base, offset); }catch(...) { delete[] _idToSymbol; _idToSymbol = NULL; throw; } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Integer Overflow or Wraparound"], "explanation": "There's a flaw in OpenEXR in versions before 3.0.0-beta. A crafted input file that is processed by OpenEXR could cause a shift overflow in the FastHufDecoder, potentially leading to problems with application availability.", "severity_level": "NoInfo", "cwe": "CWE-190", "cve": "CVE-2021-3474"}} -{"idx": 380020, "input": "* stop work. But, in that case, it is guaranteed not to race with * iscsi_destroy by conn_mutex. */ static void iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag) { /* * It is important that this path doesn't rely on * rx_queue_mutex, otherwise, a thread doing allocation on a * start_session/start_connection could sleep waiting on a * writeback to a failed iscsi device, that cannot be recovered * because the lock is held. If we don't hold it here, the * kernel stop_conn_work_fn has a chance to stop the broken * session and resolve the allocation. * * Still, the user invoked .stop_conn() needs to be serialized * with stop_conn_work_fn by a private mutex. Not pretty, but * it works. */ mutex_lock(&conn_mutex); conn->transport->stop_conn(conn, flag);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 514752, "input": "address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr orig_addr, hwaddr *xlat, hwaddr *plen, MemTxAttrs attrs, int *prot) { MemoryRegionSection *section; IOMMUMemoryRegion *iommu_mr; IOMMUMemoryRegionClass *imrc; IOMMUTLBEntry iotlb; int iommu_idx; hwaddr addr = orig_addr; AddressSpaceDispatch *d = qatomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch); for (;;) { section = address_space_translate_internal(d, addr, &addr, plen, false); iommu_mr = memory_region_get_iommu(section->mr); if (!iommu_mr) { break; } imrc = memory_region_get_iommu_class_nocheck(iommu_mr); iommu_idx = imrc->attrs_to_index(iommu_mr, attrs); tcg_register_iommu_notifier(cpu, iommu_mr, iommu_idx); /* We need all the permissions, so pass IOMMU_NONE so the IOMMU * doesn't short-cut its translation table walk. */ iotlb = imrc->translate(iommu_mr, addr, IOMMU_NONE, iommu_idx); addr = ((iotlb.translated_addr & ~iotlb.addr_mask) | (addr & iotlb.addr_mask)); /* Update the caller's prot bits to remove permissions the IOMMU * is giving us a failure response for. If we get down to no * permissions left at all we can give up now. */ if (!(iotlb.perm & IOMMU_RO)) { *prot &= ~(PAGE_READ | PAGE_EXEC); } if (!(iotlb.perm & IOMMU_WO)) { *prot &= ~PAGE_WRITE; } if (!*prot) { goto translate_fail; } d = flatview_to_dispatch(address_space_to_flatview(iotlb.target_as)); } assert(!memory_region_is_iommu(section->mr)); *xlat = addr; return section; translate_fail: /* * We should be given a page-aligned address -- certainly * tlb_set_page_with_attrs() does so. The page offset of xlat * is used to index sections[], and PHYS_SECTION_UNASSIGNED = 0. * The page portion of xlat will be logged by memory_region_access_valid() * when this memory access is rejected, so use the original untranslated * physical address. */ assert((orig_addr & ~TARGET_PAGE_MASK) == 0); *xlat = orig_addr; return &d->map.sections[PHYS_SECTION_UNASSIGNED]; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 277654, "input": "precalculateTileInfo (const TileDescription& tileDesc, int minX, int maxX, int minY, int maxY, int *&numXTiles, int *&numYTiles, int &numXLevels, int &numYLevels) { numXLevels = calculateNumXLevels(tileDesc, minX, maxX, minY, maxY); numYLevels = calculateNumYLevels(tileDesc, minX, maxX, minY, maxY); numXTiles = new int[numXLevels]; numYTiles = new int[numYLevels]; calculateNumTiles (numXTiles, numXLevels, minX, maxX, tileDesc.xSize, tileDesc.roundingMode); calculateNumTiles (numYTiles, numYLevels, minY, maxY, tileDesc.ySize, tileDesc.roundingMode); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 238849, "input": "inline void RunIfBoxIndexIsValid( OpKernelContext* context, typename TTypes::ConstTensor box_index, int batch_size, const Callback& compute, const Callback& done) { const int num_boxes = box_index.dimension(0); for (int b = 0; b < num_boxes; ++b) { OP_REQUIRES_ASYNC( context, FastBoundsCheck(box_index(b), batch_size), errors::OutOfRange(\"box_index has values outside [0, batch_size)\"), done); } if (compute) { compute(); } if (done) { done(); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 497558, "input": "static void blowfish_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out, unsigned long len) { gcry_cipher_encrypt(cipher->key[0], out, len, in, len); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 271470, "input": "static Bool latm_dmx_sync_frame_bs(GF_BitStream *bs, GF_M4ADecSpecInfo *acfg, u32 *nb_bytes, u8 *buffer, u32 *nb_skipped) { u32 val, size; u64 pos, mux_size; if (nb_skipped) *nb_skipped = 0; if (!acfg) return 0; while (gf_bs_available(bs)>3) { val = gf_bs_read_u8(bs); if (val!=0x56) { if (nb_skipped) (*nb_skipped) ++; continue; } val = gf_bs_read_int(bs, 3); if (val != 0x07) { gf_bs_read_int(bs, 5); if (nb_skipped) (*nb_skipped) ++; continue; } mux_size = gf_bs_read_int(bs, 13); pos = gf_bs_get_position(bs); if (mux_size>gf_bs_available(bs) ) { gf_bs_seek(bs, pos-3); return GF_FALSE; } /*use same stream mux*/ if (!gf_bs_read_int(bs, 1)) { Bool amux_version, amux_versionA; amux_version = (Bool)gf_bs_read_int(bs, 1); amux_versionA = GF_FALSE; if (amux_version) amux_versionA = (Bool)gf_bs_read_int(bs, 1); if (!amux_versionA) { u32 i, allStreamsSameTimeFraming, numProgram; if (amux_version) gf_latm_get_value(bs); allStreamsSameTimeFraming = gf_bs_read_int(bs, 1); /*numSubFrames = */gf_bs_read_int(bs, 6); numProgram = gf_bs_read_int(bs, 4); for (i=0; i<=numProgram; i++) { u32 j, num_lay; num_lay = gf_bs_read_int(bs, 3); for (j=0; j<=num_lay; j++) { u32 frameLengthType; Bool same_cfg = GF_FALSE; if (i || j) same_cfg = (Bool)gf_bs_read_int(bs, 1); if (!same_cfg) { if (amux_version==1) gf_latm_get_value(bs); gf_m4a_parse_config(bs, acfg, GF_FALSE); } frameLengthType = gf_bs_read_int(bs, 3); if (!frameLengthType) { /*latmBufferFullness = */gf_bs_read_int(bs, 8); if (!allStreamsSameTimeFraming) { } } else { /*not supported*/ } } } /*other data present*/ if (gf_bs_read_int(bs, 1)) { // u32 k = 0; } /*CRCcheck present*/ if (gf_bs_read_int(bs, 1)) { } } } size = 0; while (1) { u32 tmp = gf_bs_read_int(bs, 8); size += tmp; if (tmp!=255) break; } if (gf_bs_available(bs) < size) { gf_bs_seek(bs, pos-3); return GF_FALSE; } if (nb_bytes) { *nb_bytes = (u32) size; } if (buffer) { gf_bs_read_data(bs, (char *) buffer, size); } else { while (size) { gf_bs_read_int(bs, 8); size--; } } /*parse amux*/ gf_bs_seek(bs, pos + mux_size); if ((gf_bs_available(bs)>2) && gf_bs_peek_bits(bs, 11, 0) != 0x2B7) { gf_bs_seek(bs, pos + 1); if (nb_skipped) (*nb_skipped) ++; continue; } return GF_TRUE; } return GF_FALSE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445664, "input": "static void add_tracer_options(struct trace_array *tr, struct tracer *t) { /* Only enable if the directory has been created already. */ if (!tr->dir) return; create_trace_option_files(tr, t); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 212350, "input": "ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t bytes) { UINT8 *ptr; int framesize; int c, chunks, advance; int l, lines; int i, j, x = 0, y, ymax; /* If not even the chunk size is present, we'd better leave */ if (bytes < 4) { return 0; } /* We don't decode anything unless we have a full chunk in the input buffer */ ptr = buf; framesize = I32(ptr); if (framesize < I32(ptr)) { return 0; } /* Make sure this is a frame chunk. The Python driver takes case of other chunk types. */ if (bytes < 8) { state->errcode = IMAGING_CODEC_OVERRUN; return -1; } if (I16(ptr + 4) != 0xF1FA) { state->errcode = IMAGING_CODEC_UNKNOWN; return -1; } chunks = I16(ptr + 6); ptr += 16; bytes -= 16; /* Process subchunks */ for (c = 0; c < chunks; c++) { UINT8 *data; if (bytes < 10) { state->errcode = IMAGING_CODEC_OVERRUN; return -1; } data = ptr + 6; switch (I16(ptr + 4)) { case 4: case 11: /* FLI COLOR chunk */ break; /* ignored; handled by Python code */ case 7: /* FLI SS2 chunk (word delta) */ /* OOB ok, we've got 4 bytes min on entry */ lines = I16(data); data += 2; for (l = y = 0; l < lines && y < state->ysize; l++, y++) { UINT8 *local_buf = (UINT8 *)im->image[y]; int p, packets; ERR_IF_DATA_OOB(2) packets = I16(data); data += 2; while (packets & 0x8000) { /* flag word */ if (packets & 0x4000) { y += 65536 - packets; /* skip lines */ if (y >= state->ysize) { state->errcode = IMAGING_CODEC_OVERRUN; return -1; } local_buf = (UINT8 *)im->image[y]; } else { /* store last byte (used if line width is odd) */ local_buf[state->xsize - 1] = (UINT8)packets; } ERR_IF_DATA_OOB(2) packets = I16(data); data += 2; } for (p = x = 0; p < packets; p++) { ERR_IF_DATA_OOB(2) x += data[0]; /* pixel skip */ if (data[1] >= 128) { ERR_IF_DATA_OOB(4) i = 256 - data[1]; /* run */ if (x + i + i > state->xsize) { break; } for (j = 0; j < i; j++) { local_buf[x++] = data[2]; local_buf[x++] = data[3]; } data += 2 + 2; } else { i = 2 * (int)data[1]; /* chunk */ if (x + i > state->xsize) { break; } ERR_IF_DATA_OOB(2 + i) memcpy(local_buf + x, data + 2, i); data += 2 + i; x += i; } } if (p < packets) { break; /* didn't process all packets */ } } if (l < lines) { /* didn't process all lines */ state->errcode = IMAGING_CODEC_OVERRUN; return -1; } break; case 12: /* FLI LC chunk (byte delta) */ /* OOB Check ok, we have 4 bytes min here */ y = I16(data); ymax = y + I16(data + 2); data += 4; for (; y < ymax && y < state->ysize; y++) { UINT8 *out = (UINT8 *)im->image[y]; ERR_IF_DATA_OOB(1) int p, packets = *data++; for (p = x = 0; p < packets; p++, x += i) { ERR_IF_DATA_OOB(2) x += data[0]; /* skip pixels */ if (data[1] & 0x80) { i = 256 - data[1]; /* run */ if (x + i > state->xsize) { break; } ERR_IF_DATA_OOB(3) memset(out + x, data[2], i); data += 3; } else { i = data[1]; /* chunk */ if (x + i > state->xsize) { break; } ERR_IF_DATA_OOB(2 + i) memcpy(out + x, data + 2, i); data += i + 2; } } if (p < packets) { break; /* didn't process all packets */ } } if (y < ymax) { /* didn't process all lines */ state->errcode = IMAGING_CODEC_OVERRUN; return -1; } break; case 13: /* FLI BLACK chunk */ for (y = 0; y < state->ysize; y++) { memset(im->image[y], 0, state->xsize); } break; case 15: /* FLI BRUN chunk */ /* OOB, ok, we've got 4 bytes min on entry */ for (y = 0; y < state->ysize; y++) { UINT8 *out = (UINT8 *)im->image[y]; data += 1; /* ignore packetcount byte */ for (x = 0; x < state->xsize; x += i) { ERR_IF_DATA_OOB(2) if (data[0] & 0x80) { i = 256 - data[0]; if (x + i > state->xsize) { break; /* safety first */ } ERR_IF_DATA_OOB(i + 1) memcpy(out + x, data + 1, i); data += i + 1; } else { i = data[0]; if (x + i > state->xsize) { break; /* safety first */ } memset(out + x, data[1], i); data += 2; } } if (x != state->xsize) { /* didn't unpack whole line */ state->errcode = IMAGING_CODEC_OVERRUN; return -1; } } break; case 16: /* COPY chunk */ if (state->xsize > bytes / state->ysize) { /* not enough data for frame */ return ptr - buf; /* bytes consumed */ } for (y = 0; y < state->ysize; y++) { UINT8 *local_buf = (UINT8 *)im->image[y]; memcpy(local_buf, data, state->xsize); data += state->xsize; } break; case 18: /* PSTAMP chunk */ break; /* ignored */ default: /* unknown chunk */ /* printf(\"unknown FLI/FLC chunk: %d\\n\", I16(ptr+4)); */ state->errcode = IMAGING_CODEC_UNKNOWN; return -1; } advance = I32(ptr); if (advance < 0 || advance > bytes) { state->errcode = IMAGING_CODEC_OVERRUN; return -1; } ptr += advance; bytes -= advance; } return -1; /* end of frame */ }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Loop with Unreachable Exit Condition ('Infinite Loop')"], "explanation": "An issue was discovered in Pillow before 8.2.0. For FLI data, FliDecode did not properly check that the block advance was non-zero, potentially leading to an infinite loop on load.", "severity_level": "NoInfo", "cwe": "CWE-835", "cve": "CVE-2021-28676"}} -{"idx": 89085, "input": "void WebGraphicsContext3DDefaultImpl::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset) { makeContextCurrent(); if (m_boundArrayBuffer <= 0) { return; } if (indx < NumTrackedPointerStates) { VertexAttribPointerState& state = m_vertexAttribPointerState[indx]; state.buffer = m_boundArrayBuffer; state.indx = indx; state.size = size; state.type = type; state.normalized = normalized; state.stride = stride; state.offset = offset; } glVertexAttribPointer(indx, size, type, normalized, stride, reinterpret_cast(static_cast(offset))); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 214405, "input": "static void host_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct host_query *hquery = (struct host_query*)arg; int addinfostatus = ARES_SUCCESS; hquery->timeouts += timeouts; hquery->remaining--; if (status == ARES_SUCCESS) { addinfostatus = ares__parse_into_addrinfo(abuf, alen, hquery->ai); } else if (status == ARES_EDESTRUCTION) { end_hquery(hquery, status); } if (!hquery->remaining) { if (addinfostatus != ARES_SUCCESS) { /* error in parsing result e.g. no memory */ end_hquery(hquery, addinfostatus); } else if (hquery->ai->nodes) { /* at least one query ended with ARES_SUCCESS */ end_hquery(hquery, ARES_SUCCESS); } else if (status == ARES_ENOTFOUND) { next_lookup(hquery, status); } else { end_hquery(hquery, status); } } /* at this point we keep on waiting for the next query to finish */ }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NVD-CWE-Other"], "explanation": "A possible use-after-free and double-free in c-ares lib version 1.16.0 if ares_destroy() is called prior to ares_getaddrinfo() completing. This flaw possibly allows an attacker to crash the service that uses c-ares lib. The highest threat from this vulnerability is to this service availability.", "severity_level": "NoInfo", "cwe": "CWE-310", "cve": "CVE-2020-14354"}} -{"idx": 520922, "input": "static Jsi_RC CDataEnumFieldConfCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this, Jsi_Value **ret, Jsi_Func *funcPtr) { Jsi_EnumSpec *ei, *sf; char *arg1 = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL); if (!(sf = jsi_csEnumGet(interp, arg1))) return Jsi_LogError(\"unknown enum item: %s\", arg1); ei = 0; char *arg2 = Jsi_ValueArrayIndexToStr(interp, args, 1, NULL); if (!(ei = jsi_csEnumGetItem(interp, arg2, sf))) return JSI_OK; return CDataOptionsConf(interp, EnumFieldOptions, args, ei, ret, 0, 2); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 343476, "input": "void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector) { struct kvm_vcpu_hv_synic *synic = to_hv_synic(vcpu); int i; trace_kvm_hv_synic_send_eoi(vcpu->vcpu_id, vector); for (i = 0; i < ARRAY_SIZE(synic->sint); i++) if (synic_get_sint_vector(synic_read_sint(synic, i)) == vector) kvm_hv_notify_acked_sint(vcpu, i); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280803, "input": "parse_encap_header(const char *hdr, ovs_be32 *packet_type) { if (strcmp(hdr, \"ethernet\") == 0) { *packet_type = htonl(PT_ETH); } else if (strcmp(hdr, \"nsh\") == 0) { *packet_type = htonl(PT_NSH); } else { return false; } return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 215830, "input": "grep (int fd, char const *file, struct stats *stats) { int nlines, i; int not_text; size_t residue, save; char oldc; char *beg; char *lim; char eol = eolbyte; if (!reset (fd, file, stats)) return 0; if (file && directories == RECURSE_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) { /* Close fd now, so that we don't open a lot of file descriptors when we recurse deeply. */ if (close (fd) != 0) suppressible_error (file, errno); return grepdir (file, stats) - 2; } totalcc = 0; lastout = 0; totalnl = 0; outleft = max_count; after_last_match = 0; pending = 0; nlines = 0; residue = 0; save = 0; if (! fillbuf (save, stats)) { suppressible_error (filename, errno); return 0; } not_text = (((binary_files == BINARY_BINARY_FILES && !out_quiet) || binary_files == WITHOUT_MATCH_BINARY_FILES) && memchr (bufbeg, eol ? '\\0' : '\\200', buflim - bufbeg)); if (not_text && binary_files == WITHOUT_MATCH_BINARY_FILES) return 0; done_on_match += not_text; out_quiet += not_text; for (;;) { lastnl = bufbeg; if (lastout) lastout = bufbeg; beg = bufbeg + save; /* no more data to scan (eof) except for maybe a residue -> break */ if (beg == buflim) break; /* Determine new residue (the length of an incomplete line at the end of the buffer, 0 means there is no incomplete last line). */ oldc = beg[-1]; beg[-1] = eol; for (lim = buflim; lim[-1] != eol; lim--) continue; beg[-1] = oldc; if (lim == beg) lim = beg - residue; beg -= residue; residue = buflim - lim; if (beg < lim) { if (outleft) nlines += grepbuf (beg, lim); if (pending) prpending (lim); if ((!outleft && !pending) || (nlines && done_on_match && !out_invert)) goto finish_grep; } /* The last OUT_BEFORE lines at the end of the buffer will be needed as leading context if there is a matching line at the begin of the next data. Make beg point to their begin. */ i = 0; beg = lim; while (i < out_before && beg > bufbeg && beg != lastout) { ++i; do --beg; while (beg[-1] != eol); } /* detect if leading context is discontinuous from last printed line. */ if (beg != lastout) lastout = 0; /* Handle some details and read more data to scan. */ save = residue + lim - beg; if (out_byte) totalcc = add_count (totalcc, buflim - bufbeg - save); if (out_line) nlscan (beg); if (! fillbuf (save, stats)) { suppressible_error (filename, errno); goto finish_grep; } } if (residue) { *buflim++ = eol; if (outleft) nlines += grepbuf (bufbeg + save - residue, buflim); if (pending) prpending (buflim); } finish_grep: done_on_match -= not_text; out_quiet -= not_text; if ((not_text & ~out_quiet) && nlines != 0) printf (_(\"Binary file %s matches\\n\"), filename); return nlines; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NVD-CWE-Other"], "explanation": "Multiple integer overflows in GNU Grep before 2.11 might allow context-dependent attackers to execute arbitrary code via vectors involving a long input line that triggers a heap-based buffer overflow.", "severity_level": "Medium", "cwe": "CWE-189", "cve": "CVE-2012-5667"}} -{"idx": 318226, "input": "int addattr16(struct nlmsghdr *n, int maxlen, int type, __u16 data) { return addattr_l(n, maxlen, type, &data, sizeof(__u16)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508754, "input": "add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field, uint key, uint part) { KEYUSE keyuse; Field *field= key_field->field; keyuse.table= field->table; keyuse.val= key_field->val; keyuse.key= key; if (!is_hash_join_key_no(key)) { keyuse.keypart=part; keyuse.keypart_map= (key_part_map) 1 << part; } else { keyuse.keypart= field->field_index; keyuse.keypart_map= (key_part_map) 0; } keyuse.used_tables= key_field->val->used_tables(); keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL; keyuse.ref_table_rows= 0; keyuse.null_rejecting= key_field->null_rejecting; keyuse.cond_guard= key_field->cond_guard; keyuse.sj_pred_no= key_field->sj_pred_no; keyuse.validity_ref= 0; return (insert_dynamic(keyuse_array,(uchar*) &keyuse)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 374454, "input": "void zend_register_default_exception(TSRMLS_D) /* {{{ */ { zend_class_entry ce; INIT_CLASS_ENTRY(ce, \"Exception\", default_exception_functions); default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC); default_exception_ce->create_object = zend_default_exception_new; memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); default_exception_handlers.clone_obj = NULL; zend_declare_property_string(default_exception_ce, \"message\", sizeof(\"message\")-1, \"\", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(default_exception_ce, \"string\", sizeof(\"string\")-1, \"\", ZEND_ACC_PRIVATE TSRMLS_CC); zend_declare_property_long(default_exception_ce, \"code\", sizeof(\"code\")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, \"file\", sizeof(\"file\")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, \"line\", sizeof(\"line\")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, \"trace\", sizeof(\"trace\")-1, ZEND_ACC_PRIVATE TSRMLS_CC); zend_declare_property_null(default_exception_ce, \"previous\", sizeof(\"previous\")-1, ZEND_ACC_PRIVATE TSRMLS_CC); INIT_CLASS_ENTRY(ce, \"ErrorException\", error_exception_functions); error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce, NULL TSRMLS_CC); error_exception_ce->create_object = zend_error_exception_new; zend_declare_property_long(error_exception_ce, \"severity\", sizeof(\"severity\")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 303120, "input": "void blosc_destroy(void) { /* Return if Blosc is not initialized */ if (!g_initlib) return; g_initlib = 0; release_threadpool(g_global_context); if (g_global_context->serial_context != NULL) { free_thread_context(g_global_context->serial_context); } my_free(g_global_context); pthread_mutex_destroy(&global_comp_mutex); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 224898, "input": "static u32 get_box_reg_idx(u32 boxCode, u32 parent_type) { u32 i=0, count = gf_isom_get_num_supported_boxes(); const char *parent_name = parent_type ? gf_4cc_to_str(parent_type) : NULL; for (i=1; ihdev; if (hdev->scanning_paused) { bt_dev_dbg(hdev, \"Scanning is paused for suspend\"); return; } if (use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && addr_resolv) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } /* Use ext scanning if set ext scan param and ext scan enable is * supported */ if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_params *ext_param_cp; struct hci_cp_le_set_ext_scan_enable ext_enable_cp; struct hci_cp_le_scan_phy_params *phy_params; u8 data[sizeof(*ext_param_cp) + sizeof(*phy_params) * 2]; u32 plen; ext_param_cp = (void *)data; phy_params = (void *)ext_param_cp->data; memset(ext_param_cp, 0, sizeof(*ext_param_cp)); ext_param_cp->own_addr_type = own_addr_type; ext_param_cp->filter_policy = filter_policy; plen = sizeof(*ext_param_cp); if (scan_1m(hdev) || scan_2m(hdev)) { ext_param_cp->scanning_phys |= LE_SCAN_PHY_1M; memset(phy_params, 0, sizeof(*phy_params)); phy_params->type = type; phy_params->interval = cpu_to_le16(interval); phy_params->window = cpu_to_le16(window); plen += sizeof(*phy_params); phy_params++; } if (scan_coded(hdev)) { ext_param_cp->scanning_phys |= LE_SCAN_PHY_CODED; memset(phy_params, 0, sizeof(*phy_params)); phy_params->type = type; phy_params->interval = cpu_to_le16(interval); phy_params->window = cpu_to_le16(window); plen += sizeof(*phy_params); phy_params++; } hci_req_add(req, HCI_OP_LE_SET_EXT_SCAN_PARAMS, plen, ext_param_cp); memset(&ext_enable_cp, 0, sizeof(ext_enable_cp)); ext_enable_cp.enable = LE_SCAN_ENABLE; ext_enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE; hci_req_add(req, HCI_OP_LE_SET_EXT_SCAN_ENABLE, sizeof(ext_enable_cp), &ext_enable_cp); } else { struct hci_cp_le_set_scan_param param_cp; struct hci_cp_le_set_scan_enable enable_cp; memset(¶m_cp, 0, sizeof(param_cp)); param_cp.type = type; param_cp.interval = cpu_to_le16(interval); param_cp.window = cpu_to_le16(window); param_cp.own_address_type = own_addr_type; param_cp.filter_policy = filter_policy; hci_req_add(req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp), ¶m_cp); memset(&enable_cp, 0, sizeof(enable_cp)); enable_cp.enable = LE_SCAN_ENABLE; enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp), &enable_cp); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 385614, "input": "void Utf8Decoder::Reset(const char* stream, unsigned length) { Utf8DecoderBase::Reset(buffer_, kBufferSize, reinterpret_cast(stream), length); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 400916, "input": "WriteToRFBServer(rfbClient* client, const char *buf, unsigned int n) { fd_set fds; int i = 0; int j; const char *obuf = buf; #ifdef LIBVNCSERVER_HAVE_SASL const char *output; unsigned int outputlen; int err; #endif /* LIBVNCSERVER_HAVE_SASL */ if (client->serverPort==-1) return TRUE; /* vncrec playing */ if (client->tlsSession) { /* WriteToTLS() will guarantee either everything is written, or error/eof returns */ i = WriteToTLS(client, buf, n); if (i <= 0) return FALSE; return TRUE; } #ifdef LIBVNCSERVER_HAVE_SASL if (client->saslconn) { err = sasl_encode(client->saslconn, buf, n, &output, &outputlen); if (err != SASL_OK) { rfbClientLog(\"Failed to encode SASL data %s\", sasl_errstring(err, NULL, NULL)); return FALSE; } obuf = output; n = outputlen; } #endif /* LIBVNCSERVER_HAVE_SASL */ while (i < n) { j = write(client->sock, obuf + i, (n - i)); if (j <= 0) { if (j < 0) { #ifdef WIN32 errno=WSAGetLastError(); #endif if (errno == EWOULDBLOCK || #ifdef LIBVNCSERVER_ENOENT_WORKAROUND errno == ENOENT || #endif errno == EAGAIN) { FD_ZERO(&fds); FD_SET(client->sock,&fds); if (select(client->sock+1, NULL, &fds, NULL, NULL) <= 0) { rfbClientErr(\"select\\n\"); return FALSE; } j = 0; } else { rfbClientErr(\"write\\n\"); return FALSE; } } else { rfbClientLog(\"write failed\\n\"); return FALSE; } } i += j; } return TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219586, "input": "uint32_t capacity() const { return m_px->capacity(); // intentionally skip nullptr check }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219067, "input": "explicit StrNR(StringData *sd) : m_px(sd) {}", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 207463, "input": "ipmi_get_session_info(struct ipmi_intf * intf, Ipmi_Session_Request_Type session_request_type, uint32_t id_or_handle) { int i, retval = 0; struct ipmi_rs * rsp; struct ipmi_rq req; uint8_t rqdata[5]; // max length of the variable length request struct get_session_info_rsp session_info; memset(&req, 0, sizeof(req)); memset(&session_info, 0, sizeof(session_info)); req.msg.netfn = IPMI_NETFN_APP; // 0x06 req.msg.cmd = IPMI_GET_SESSION_INFO; // 0x3D req.msg.data = rqdata; switch (session_request_type) { case IPMI_SESSION_REQUEST_CURRENT: case IPMI_SESSION_REQUEST_BY_ID: case IPMI_SESSION_REQUEST_BY_HANDLE: switch (session_request_type) { case IPMI_SESSION_REQUEST_CURRENT: rqdata[0] = 0x00; req.msg.data_len = 1; break; case IPMI_SESSION_REQUEST_BY_ID: rqdata[0] = 0xFF; rqdata[1] = id_or_handle & 0x000000FF; rqdata[2] = (id_or_handle >> 8) & 0x000000FF; rqdata[3] = (id_or_handle >> 16) & 0x000000FF; rqdata[4] = (id_or_handle >> 24) & 0x000000FF; req.msg.data_len = 5; break; case IPMI_SESSION_REQUEST_BY_HANDLE: rqdata[0] = 0xFE; rqdata[1] = (uint8_t)id_or_handle; req.msg.data_len = 2; break; case IPMI_SESSION_REQUEST_ALL: break; } rsp = intf->sendrecv(intf, &req); if (!rsp) { lprintf(LOG_ERR, \"Get Session Info command failed\"); retval = -1; } else if (rsp->ccode) { lprintf(LOG_ERR, \"Get Session Info command failed: %s\", val2str(rsp->ccode, completion_code_vals)); retval = -1; } if (retval < 0) { if ((session_request_type == IPMI_SESSION_REQUEST_CURRENT) && (strncmp(intf->name, \"lan\", 3) != 0)) lprintf(LOG_ERR, \"It is likely that the channel in use \" \"does not support sessions\"); } else { memcpy(&session_info, rsp->data, rsp->data_len); print_session_info(&session_info, rsp->data_len); } break; case IPMI_SESSION_REQUEST_ALL: req.msg.data_len = 1; i = 1; do { rqdata[0] = i++; rsp = intf->sendrecv(intf, &req); if (!rsp) { lprintf(LOG_ERR, \"Get Session Info command failed\"); retval = -1; break; } else if (rsp->ccode && rsp->ccode != 0xCC && rsp->ccode != 0xCB) { lprintf(LOG_ERR, \"Get Session Info command failed: %s\", val2str(rsp->ccode, completion_code_vals)); retval = -1; break; } else if (rsp->data_len < 3) { retval = -1; break; } memcpy(&session_info, rsp->data, rsp->data_len); print_session_info(&session_info, rsp->data_len); } while (i <= session_info.session_slot_count); break; } return retval; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')"], "explanation": "It's been found that multiple functions in ipmitool before 1.8.19 neglect proper checking of the data received from a remote LAN party, which may lead to buffer overflows and potentially to remote code execution on the ipmitool side. This is especially dangerous if ipmitool is run as a privileged user. This problem is fixed in version 1.8.19.", "severity_level": "NoInfo", "cwe": "CWE-120", "cve": "CVE-2020-5208"}} -{"idx": 448831, "input": "void RGWInfo_ObjStore_SWIFT::execute() { bool is_admin_info_enabled = false; const string& swiftinfo_sig = s->info.args.get(\"swiftinfo_sig\"); const string& swiftinfo_expires = s->info.args.get(\"swiftinfo_expires\"); if (!swiftinfo_sig.empty() && !swiftinfo_expires.empty() && !is_expired(swiftinfo_expires, s->cct)) { is_admin_info_enabled = true; } s->formatter->open_object_section(\"info\"); for (const auto& pair : swift_info) { if(!is_admin_info_enabled && pair.second.is_admin_info) continue; if (!pair.second.list_data) { s->formatter->open_object_section((pair.first).c_str()); s->formatter->close_section(); } else { pair.second.list_data(*(s->formatter), s->cct->_conf, *store); } } s->formatter->close_section(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 323567, "input": "static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { struct mmu_gather *tlb = walk->private; struct mm_struct *mm = tlb->mm; struct vm_area_struct *vma = walk->vma; spinlock_t *ptl; pte_t *orig_pte, *pte, ptent; struct page *page; int nr_swap = 0; unsigned long next; next = pmd_addr_end(addr, end); if (pmd_trans_huge(*pmd)) if (madvise_free_huge_pmd(tlb, vma, pmd, addr, next)) goto next; if (pmd_trans_unstable(pmd)) return 0; tlb_change_page_size(tlb, PAGE_SIZE); orig_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl); flush_tlb_batched_pending(mm); arch_enter_lazy_mmu_mode(); for (; addr != end; pte++, addr += PAGE_SIZE) { ptent = *pte; if (pte_none(ptent)) continue; /* * If the pte has swp_entry, just clear page table to * prevent swap-in which is more expensive rather than * (page allocation + zeroing). */ if (!pte_present(ptent)) { swp_entry_t entry; entry = pte_to_swp_entry(ptent); if (non_swap_entry(entry)) continue; nr_swap--; free_swap_and_cache(entry); pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); continue; } page = vm_normal_page(vma, addr, ptent); if (!page) continue; /* * If pmd isn't transhuge but the page is THP and * is owned by only this process, split it and * deactivate all pages. */ if (PageTransCompound(page)) { if (page_mapcount(page) != 1) goto out; get_page(page); if (!trylock_page(page)) { put_page(page); goto out; } pte_unmap_unlock(orig_pte, ptl); if (split_huge_page(page)) { unlock_page(page); put_page(page); pte_offset_map_lock(mm, pmd, addr, &ptl); goto out; } unlock_page(page); put_page(page); pte = pte_offset_map_lock(mm, pmd, addr, &ptl); pte--; addr -= PAGE_SIZE; continue; } VM_BUG_ON_PAGE(PageTransCompound(page), page); if (PageSwapCache(page) || PageDirty(page)) { if (!trylock_page(page)) continue; /* * If page is shared with others, we couldn't clear * PG_dirty of the page. */ if (page_mapcount(page) != 1) { unlock_page(page); continue; } if (PageSwapCache(page) && !try_to_free_swap(page)) { unlock_page(page); continue; } ClearPageDirty(page); unlock_page(page); } if (pte_young(ptent) || pte_dirty(ptent)) { /* * Some of architecture(ex, PPC) don't update TLB * with set_pte_at and tlb_remove_tlb_entry so for * the portability, remap the pte with old|clean * after pte clearing. */ ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); ptent = pte_mkold(ptent); ptent = pte_mkclean(ptent); set_pte_at(mm, addr, pte, ptent); tlb_remove_tlb_entry(tlb, pte, addr); } mark_page_lazyfree(page); } out: if (nr_swap) { if (current->mm == mm) sync_mm_rss(mm); add_mm_counter(mm, MM_SWAPENTS, nr_swap); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); cond_resched(); next: return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 468918, "input": "void __init ip_init(void) { ip_rt_init(); inet_initpeers(); #if defined(CONFIG_IP_MULTICAST) igmp_mc_init(); #endif }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432459, "input": "static inline void set_dr_intercepts(struct vcpu_svm *svm) { struct vmcb *vmcb = get_host_vmcb(svm); vmcb->control.intercept_dr = (1 << INTERCEPT_DR0_READ) | (1 << INTERCEPT_DR1_READ) | (1 << INTERCEPT_DR2_READ) | (1 << INTERCEPT_DR3_READ) | (1 << INTERCEPT_DR4_READ) | (1 << INTERCEPT_DR5_READ) | (1 << INTERCEPT_DR6_READ) | (1 << INTERCEPT_DR7_READ) | (1 << INTERCEPT_DR0_WRITE) | (1 << INTERCEPT_DR1_WRITE) | (1 << INTERCEPT_DR2_WRITE) | (1 << INTERCEPT_DR3_WRITE) | (1 << INTERCEPT_DR4_WRITE) | (1 << INTERCEPT_DR5_WRITE) | (1 << INTERCEPT_DR6_WRITE) | (1 << INTERCEPT_DR7_WRITE); recalc_intercepts(svm); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409895, "input": "static void tcp_ack_saw_tstamp(struct sock *sk, int flag) { /* RTTM Rule: A TSecr value received in a segment is used to * update the averaged RTT measurement only if the segment * acknowledges some new data, i.e., only if it advances the * left edge of the send window. * * See draft-ietf-tcplw-high-performance-00, section 3.3. * 1998/04/10 Andrey V. Savochkin * * Changed: reset backoff as soon as we see the first valid sample. * If we do not, we get strongly overestimated rto. With timestamps * samples are accepted even from very old segments: f.e., when rtt=1 * increases to 8, we retransmit 5 times and after 8 seconds delayed * answer arrives rto becomes 120 seconds! If at least one of segments * in window is lost... Voila. --ANK (010210) */ struct tcp_sock *tp = tcp_sk(sk); tcp_valid_rtt_meas(sk, tcp_time_stamp - tp->rx_opt.rcv_tsecr); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198440, "input": "scanner_scan_all (parser_context_t *context_p, /**< context */ const uint8_t *arg_list_p, /**< function argument list */ const uint8_t *arg_list_end_p, /**< end of argument list */ const uint8_t *source_p, /**< valid UTF-8 source code */ const uint8_t *source_end_p) /**< end of source code */ { scanner_context_t scanner_context; #if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) if (context_p->is_show_opcodes) { JERRY_DEBUG_MSG (\"\\n--- Scanning start ---\\n\\n\"); } #endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */ scanner_context.context_status_flags = context_p->status_flags; scanner_context.status_flags = SCANNER_CONTEXT_NO_FLAGS; #if ENABLED (JERRY_DEBUGGER) if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) { scanner_context.status_flags |= SCANNER_CONTEXT_DEBUGGER_ENABLED; } #endif /* ENABLED (JERRY_DEBUGGER) */ #if ENABLED (JERRY_ES2015) scanner_context.binding_type = SCANNER_BINDING_NONE; scanner_context.active_binding_list_p = NULL; #endif /* ENABLED (JERRY_ES2015) */ scanner_context.active_literal_pool_p = NULL; scanner_context.active_switch_statement.last_case_p = NULL; scanner_context.end_arguments_p = NULL; #if ENABLED (JERRY_ES2015) scanner_context.async_source_p = NULL; #endif /* ENABLED (JERRY_ES2015) */ /* This assignment must be here because of Apple compilers. */ context_p->u.scanner_context_p = &scanner_context; parser_stack_init (context_p); PARSER_TRY (context_p->try_buffer) { context_p->line = 1; context_p->column = 1; if (arg_list_p == NULL) { context_p->source_p = source_p; context_p->source_end_p = source_end_p; uint16_t status_flags = SCANNER_LITERAL_POOL_FUNCTION_WITHOUT_ARGUMENTS | SCANNER_LITERAL_POOL_CAN_EVAL; if (context_p->status_flags & PARSER_IS_STRICT) { status_flags |= SCANNER_LITERAL_POOL_IS_STRICT; } scanner_literal_pool_t *literal_pool_p = scanner_push_literal_pool (context_p, &scanner_context, status_flags); literal_pool_p->source_p = source_p; parser_stack_push_uint8 (context_p, SCAN_STACK_SCRIPT); lexer_next_token (context_p); scanner_check_directives (context_p, &scanner_context); } else { context_p->source_p = arg_list_p; context_p->source_end_p = arg_list_end_p; uint16_t status_flags = SCANNER_LITERAL_POOL_FUNCTION; if (context_p->status_flags & PARSER_IS_STRICT) { status_flags |= SCANNER_LITERAL_POOL_IS_STRICT; } #if ENABLED (JERRY_ES2015) if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION) { status_flags |= SCANNER_LITERAL_POOL_GENERATOR; } #endif /* ENABLED (JERRY_ES2015) */ scanner_push_literal_pool (context_p, &scanner_context, status_flags); scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS; parser_stack_push_uint8 (context_p, SCAN_STACK_SCRIPT_FUNCTION); /* Faking the first token. */ context_p->token.type = LEXER_LEFT_PAREN; } while (true) { lexer_token_type_t type = (lexer_token_type_t) context_p->token.type; scan_stack_modes_t stack_top = (scan_stack_modes_t) context_p->stack_top_uint8; switch (scanner_context.mode) { case SCAN_MODE_PRIMARY_EXPRESSION: { if (type == LEXER_ADD || type == LEXER_SUBTRACT || LEXER_IS_UNARY_OP_TOKEN (type)) { break; } /* FALLTHRU */ } case SCAN_MODE_PRIMARY_EXPRESSION_AFTER_NEW: { if (scanner_scan_primary_expression (context_p, &scanner_context, type, stack_top) != SCAN_NEXT_TOKEN) { continue; } break; } #if ENABLED (JERRY_ES2015) case SCAN_MODE_CLASS_DECLARATION: { if (context_p->token.type == LEXER_KEYW_EXTENDS) { parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_EXTENDS); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } else if (context_p->token.type != LEXER_LEFT_BRACE) { scanner_raise_error (context_p); } scanner_context.mode = SCAN_MODE_CLASS_METHOD; /* FALLTHRU */ } case SCAN_MODE_CLASS_METHOD: { JERRY_ASSERT (stack_top == SCAN_STACK_IMPLICIT_CLASS_CONSTRUCTOR || stack_top == SCAN_STACK_EXPLICIT_CLASS_CONSTRUCTOR); lexer_skip_empty_statements (context_p); lexer_scan_identifier (context_p); if (context_p->token.type == LEXER_RIGHT_BRACE) { scanner_source_start_t source_start; parser_stack_pop_uint8 (context_p); if (stack_top == SCAN_STACK_IMPLICIT_CLASS_CONSTRUCTOR) { parser_stack_pop (context_p, &source_start, sizeof (scanner_source_start_t)); } stack_top = context_p->stack_top_uint8; JERRY_ASSERT (stack_top == SCAN_STACK_CLASS_STATEMENT || stack_top == SCAN_STACK_CLASS_EXPRESSION); if (stack_top == SCAN_STACK_CLASS_STATEMENT) { /* The token is kept to disallow consuming a semicolon after it. */ scanner_context.mode = SCAN_MODE_STATEMENT_END; continue; } scanner_context.mode = SCAN_MODE_POST_PRIMARY_EXPRESSION; parser_stack_pop_uint8 (context_p); break; } if (context_p->token.type == LEXER_LITERAL && LEXER_IS_IDENT_OR_STRING (context_p->token.lit_location.type) && lexer_compare_literal_to_string (context_p, \"constructor\", 11)) { if (stack_top == SCAN_STACK_IMPLICIT_CLASS_CONSTRUCTOR) { scanner_source_start_t source_start; parser_stack_pop_uint8 (context_p); parser_stack_pop (context_p, &source_start, sizeof (scanner_source_start_t)); scanner_info_t *info_p = scanner_insert_info (context_p, source_start.source_p, sizeof (scanner_info_t)); info_p->type = SCANNER_TYPE_CLASS_CONSTRUCTOR; parser_stack_push_uint8 (context_p, SCAN_STACK_EXPLICIT_CLASS_CONSTRUCTOR); } } if (lexer_token_is_identifier (context_p, \"static\", 6)) { lexer_scan_identifier (context_p); } parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PROPERTY); scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS; uint16_t literal_pool_flags = SCANNER_LITERAL_POOL_FUNCTION; if (lexer_token_is_identifier (context_p, \"get\", 3) || lexer_token_is_identifier (context_p, \"set\", 3)) { lexer_scan_identifier (context_p); if (context_p->token.type == LEXER_LEFT_PAREN) { scanner_push_literal_pool (context_p, &scanner_context, SCANNER_LITERAL_POOL_FUNCTION); continue; } } else if (lexer_token_is_identifier (context_p, \"async\", 5)) { lexer_scan_identifier (context_p); if (context_p->token.type == LEXER_LEFT_PAREN) { scanner_push_literal_pool (context_p, &scanner_context, SCANNER_LITERAL_POOL_FUNCTION); continue; } literal_pool_flags |= SCANNER_LITERAL_POOL_ASYNC; if (context_p->token.type == LEXER_MULTIPLY) { lexer_scan_identifier (context_p); literal_pool_flags |= SCANNER_LITERAL_POOL_GENERATOR; } } else if (context_p->token.type == LEXER_MULTIPLY) { lexer_scan_identifier (context_p); literal_pool_flags |= SCANNER_LITERAL_POOL_GENERATOR; } if (context_p->token.type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCANNER_FROM_LITERAL_POOL_TO_COMPUTED (literal_pool_flags)); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } if (context_p->token.type != LEXER_LITERAL) { scanner_raise_error (context_p); } if (literal_pool_flags & SCANNER_LITERAL_POOL_GENERATOR) { context_p->status_flags |= PARSER_IS_GENERATOR_FUNCTION; } scanner_push_literal_pool (context_p, &scanner_context, literal_pool_flags); lexer_next_token (context_p); continue; } #endif /* ENABLED (JERRY_ES2015) */ case SCAN_MODE_POST_PRIMARY_EXPRESSION: { if (scanner_scan_post_primary_expression (context_p, &scanner_context, type, stack_top)) { break; } type = (lexer_token_type_t) context_p->token.type; /* FALLTHRU */ } case SCAN_MODE_PRIMARY_EXPRESSION_END: { if (scanner_scan_primary_expression_end (context_p, &scanner_context, type, stack_top) != SCAN_NEXT_TOKEN) { continue; } break; } case SCAN_MODE_STATEMENT_OR_TERMINATOR: { if (type == LEXER_RIGHT_BRACE || type == LEXER_EOS) { scanner_context.mode = SCAN_MODE_STATEMENT_END; continue; } /* FALLTHRU */ } case SCAN_MODE_STATEMENT: { if (scanner_scan_statement (context_p, &scanner_context, type, stack_top) != SCAN_NEXT_TOKEN) { continue; } break; } case SCAN_MODE_STATEMENT_END: { if (scanner_scan_statement_end (context_p, &scanner_context, type) != SCAN_NEXT_TOKEN) { continue; } if (context_p->token.type == LEXER_EOS) { goto scan_completed; } break; } case SCAN_MODE_VAR_STATEMENT: { #if ENABLED (JERRY_ES2015) if (type == LEXER_LEFT_SQUARE || type == LEXER_LEFT_BRACE) { uint8_t binding_type = SCANNER_BINDING_VAR; if (stack_top == SCAN_STACK_LET || stack_top == SCAN_STACK_FOR_LET_START) { binding_type = SCANNER_BINDING_LET; } else if (stack_top == SCAN_STACK_CONST || stack_top == SCAN_STACK_FOR_CONST_START) { binding_type = SCANNER_BINDING_CONST; } scanner_push_destructuring_pattern (context_p, &scanner_context, binding_type, false); if (type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCAN_STACK_ARRAY_LITERAL); scanner_context.mode = SCAN_MODE_BINDING; break; } parser_stack_push_uint8 (context_p, SCAN_STACK_OBJECT_LITERAL); scanner_context.mode = SCAN_MODE_PROPERTY_NAME; continue; } #endif /* ENABLED (JERRY_ES2015) */ if (type != LEXER_LITERAL || context_p->token.lit_location.type != LEXER_IDENT_LITERAL) { scanner_raise_error (context_p); } lexer_lit_location_t *literal_p = scanner_add_literal (context_p, &scanner_context); #if ENABLED (JERRY_ES2015) if (stack_top != SCAN_STACK_VAR && stack_top != SCAN_STACK_FOR_VAR_START) { scanner_detect_invalid_let (context_p, literal_p); if (stack_top == SCAN_STACK_LET || stack_top == SCAN_STACK_FOR_LET_START) { literal_p->type |= SCANNER_LITERAL_IS_LET; } else { JERRY_ASSERT (stack_top == SCAN_STACK_CONST || stack_top == SCAN_STACK_FOR_CONST_START); literal_p->type |= SCANNER_LITERAL_IS_CONST; } lexer_next_token (context_p); if (literal_p->type & SCANNER_LITERAL_IS_USED) { literal_p->type |= SCANNER_LITERAL_EARLY_CREATE; } else if (context_p->token.type == LEXER_ASSIGN) { scanner_binding_literal_t binding_literal; binding_literal.literal_p = literal_p; parser_stack_push (context_p, &binding_literal, sizeof (scanner_binding_literal_t)); parser_stack_push_uint8 (context_p, SCAN_STACK_BINDING_INIT); } } else { if (!(literal_p->type & SCANNER_LITERAL_IS_VAR)) { scanner_detect_invalid_var (context_p, &scanner_context, literal_p); literal_p->type |= SCANNER_LITERAL_IS_VAR; if (scanner_context.active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH) { literal_p->type |= SCANNER_LITERAL_NO_REG; } } lexer_next_token (context_p); } #else /* !ENABLED (JERRY_ES2015) */ literal_p->type |= SCANNER_LITERAL_IS_VAR; if (scanner_context.active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH) { literal_p->type |= SCANNER_LITERAL_NO_REG; } lexer_next_token (context_p); #endif /* ENABLED (JERRY_ES2015) */ #if ENABLED (JERRY_ES2015_MODULE_SYSTEM) if (scanner_context.active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_EXPORT) { literal_p->type |= SCANNER_LITERAL_NO_REG; } #endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ switch (context_p->token.type) { case LEXER_ASSIGN: { scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; /* FALLTHRU */ } case LEXER_COMMA: { lexer_next_token (context_p); continue; } } if (SCANNER_IS_FOR_START (stack_top)) { #if ENABLED (JERRY_ES2015_MODULE_SYSTEM) JERRY_ASSERT (!(scanner_context.active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_EXPORT)); #endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ if (context_p->token.type != LEXER_SEMICOLON && context_p->token.type != LEXER_KEYW_IN && !SCANNER_IDENTIFIER_IS_OF ()) { scanner_raise_error (context_p); } scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION_END; continue; } #if ENABLED (JERRY_ES2015) JERRY_ASSERT (stack_top == SCAN_STACK_VAR || stack_top == SCAN_STACK_LET || stack_top == SCAN_STACK_CONST); #else /* !ENABLED (JERRY_ES2015) */ JERRY_ASSERT (stack_top == SCAN_STACK_VAR); #endif /* ENABLED (JERRY_ES2015) */ #if ENABLED (JERRY_ES2015_MODULE_SYSTEM) scanner_context.active_literal_pool_p->status_flags &= (uint16_t) ~SCANNER_LITERAL_POOL_IN_EXPORT; #endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ scanner_context.mode = SCAN_MODE_STATEMENT_END; parser_stack_pop_uint8 (context_p); continue; } case SCAN_MODE_FUNCTION_ARGUMENTS: { JERRY_ASSERT (stack_top == SCAN_STACK_SCRIPT_FUNCTION || stack_top == SCAN_STACK_FUNCTION_STATEMENT || stack_top == SCAN_STACK_FUNCTION_EXPRESSION || stack_top == SCAN_STACK_FUNCTION_PROPERTY); scanner_literal_pool_t *literal_pool_p = scanner_context.active_literal_pool_p; JERRY_ASSERT (literal_pool_p != NULL && (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION)); literal_pool_p->source_p = context_p->source_p; #if ENABLED (JERRY_ES2015) if (JERRY_UNLIKELY (scanner_context.async_source_p != NULL)) { literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_ASYNC; literal_pool_p->source_p = scanner_context.async_source_p; scanner_context.async_source_p = NULL; } #endif /* ENABLED (JERRY_ES2015) */ if (type != LEXER_LEFT_PAREN) { scanner_raise_error (context_p); } lexer_next_token (context_p); #if ENABLED (JERRY_ES2015) /* FALLTHRU */ } case SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS: { #endif /* ENABLED (JERRY_ES2015) */ if (context_p->token.type != LEXER_RIGHT_PAREN && context_p->token.type != LEXER_EOS) { #if ENABLED (JERRY_ES2015) lexer_lit_location_t *argument_literal_p; #endif /* ENABLED (JERRY_ES2015) */ while (true) { #if ENABLED (JERRY_ES2015) if (context_p->token.type == LEXER_THREE_DOTS) { scanner_context.active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_ARGUMENTS_UNMAPPED; lexer_next_token (context_p); } if (context_p->token.type == LEXER_LEFT_SQUARE || context_p->token.type == LEXER_LEFT_BRACE) { argument_literal_p = NULL; break; } #endif /* ENABLED (JERRY_ES2015) */ if (context_p->token.type != LEXER_LITERAL || context_p->token.lit_location.type != LEXER_IDENT_LITERAL) { scanner_raise_error (context_p); } #if ENABLED (JERRY_ES2015) argument_literal_p = scanner_append_argument (context_p, &scanner_context); #else /* !ENABLED (JERRY_ES2015) */ scanner_append_argument (context_p, &scanner_context); #endif /* ENABLED (JERRY_ES2015) */ lexer_next_token (context_p); if (context_p->token.type != LEXER_COMMA) { break; } lexer_next_token (context_p); } #if ENABLED (JERRY_ES2015) if (argument_literal_p == NULL) { scanner_context.active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_ARGUMENTS_UNMAPPED; parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PARAMETERS); scanner_append_hole (context_p, &scanner_context); scanner_push_destructuring_pattern (context_p, &scanner_context, SCANNER_BINDING_ARG, false); if (context_p->token.type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCAN_STACK_ARRAY_LITERAL); scanner_context.mode = SCAN_MODE_BINDING; break; } parser_stack_push_uint8 (context_p, SCAN_STACK_OBJECT_LITERAL); scanner_context.mode = SCAN_MODE_PROPERTY_NAME; continue; } if (context_p->token.type == LEXER_ASSIGN) { scanner_context.active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_ARGUMENTS_UNMAPPED; parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PARAMETERS); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; if (argument_literal_p->type & SCANNER_LITERAL_IS_USED) { JERRY_ASSERT (argument_literal_p->type & SCANNER_LITERAL_EARLY_CREATE); break; } scanner_binding_literal_t binding_literal; binding_literal.literal_p = argument_literal_p; parser_stack_push (context_p, &binding_literal, sizeof (scanner_binding_literal_t)); parser_stack_push_uint8 (context_p, SCAN_STACK_BINDING_INIT); break; } #endif /* ENABLED (JERRY_ES2015) */ } if (context_p->token.type == LEXER_EOS && stack_top == SCAN_STACK_SCRIPT_FUNCTION) { /* End of argument parsing. */ scanner_info_t *scanner_info_p = (scanner_info_t *) scanner_malloc (context_p, sizeof (scanner_info_t)); scanner_info_p->next_p = context_p->next_scanner_info_p; scanner_info_p->source_p = NULL; scanner_info_p->type = SCANNER_TYPE_END_ARGUMENTS; scanner_context.end_arguments_p = scanner_info_p; context_p->next_scanner_info_p = scanner_info_p; context_p->source_p = source_p; context_p->source_end_p = source_end_p; context_p->line = 1; context_p->column = 1; scanner_filter_arguments (context_p, &scanner_context); lexer_next_token (context_p); scanner_check_directives (context_p, &scanner_context); continue; } if (context_p->token.type != LEXER_RIGHT_PAREN) { scanner_raise_error (context_p); } lexer_next_token (context_p); if (context_p->token.type != LEXER_LEFT_BRACE) { scanner_raise_error (context_p); } scanner_filter_arguments (context_p, &scanner_context); lexer_next_token (context_p); scanner_check_directives (context_p, &scanner_context); continue; } case SCAN_MODE_PROPERTY_NAME: { JERRY_ASSERT (stack_top == SCAN_STACK_OBJECT_LITERAL); if (lexer_scan_identifier (context_p)) { lexer_check_property_modifier (context_p); } #if ENABLED (JERRY_ES2015) if (context_p->token.type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } #endif /* ENABLED (JERRY_ES2015) */ if (context_p->token.type == LEXER_RIGHT_BRACE) { scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION_END; continue; } if (context_p->token.type == LEXER_PROPERTY_GETTER #if ENABLED (JERRY_ES2015) || context_p->token.type == LEXER_KEYW_ASYNC || context_p->token.type == LEXER_MULTIPLY #endif /* ENABLED (JERRY_ES2015) */ || context_p->token.type == LEXER_PROPERTY_SETTER) { uint16_t literal_pool_flags = SCANNER_LITERAL_POOL_FUNCTION; #if ENABLED (JERRY_ES2015) if (context_p->token.type == LEXER_MULTIPLY) { literal_pool_flags |= SCANNER_LITERAL_POOL_GENERATOR; } else if (context_p->token.type == LEXER_KEYW_ASYNC) { literal_pool_flags |= SCANNER_LITERAL_POOL_ASYNC; if (lexer_consume_generator (context_p)) { literal_pool_flags |= SCANNER_LITERAL_POOL_GENERATOR; } } #endif /* ENABLED (JERRY_ES2015) */ parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PROPERTY); lexer_scan_identifier (context_p); #if ENABLED (JERRY_ES2015) if (context_p->token.type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCANNER_FROM_LITERAL_POOL_TO_COMPUTED (literal_pool_flags)); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } #endif /* ENABLED (JERRY_ES2015) */ if (context_p->token.type != LEXER_LITERAL) { scanner_raise_error (context_p); } scanner_push_literal_pool (context_p, &scanner_context, literal_pool_flags); scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS; break; } if (context_p->token.type != LEXER_LITERAL) { scanner_raise_error (context_p); } #if ENABLED (JERRY_ES2015) parser_line_counter_t start_line = context_p->token.line; parser_line_counter_t start_column = context_p->token.column; bool is_ident = (context_p->token.lit_location.type == LEXER_IDENT_LITERAL); #endif /* ENABLED (JERRY_ES2015) */ lexer_next_token (context_p); #if ENABLED (JERRY_ES2015) if (context_p->token.type == LEXER_LEFT_PAREN) { scanner_push_literal_pool (context_p, &scanner_context, SCANNER_LITERAL_POOL_FUNCTION); parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PROPERTY); scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS; continue; } if (is_ident && (context_p->token.type == LEXER_COMMA || context_p->token.type == LEXER_RIGHT_BRACE || context_p->token.type == LEXER_ASSIGN)) { context_p->source_p = context_p->token.lit_location.char_p; context_p->line = start_line; context_p->column = start_column; lexer_next_token (context_p); JERRY_ASSERT (context_p->token.type != LEXER_LITERAL || context_p->token.lit_location.type == LEXER_IDENT_LITERAL); if (context_p->token.type != LEXER_LITERAL) { scanner_raise_error (context_p); } if (scanner_context.binding_type != SCANNER_BINDING_NONE) { scanner_context.mode = SCAN_MODE_BINDING; continue; } scanner_add_reference (context_p, &scanner_context); lexer_next_token (context_p); if (context_p->token.type == LEXER_ASSIGN) { scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION_END; continue; } #endif /* ENABLED (JERRY_ES2015) */ if (context_p->token.type != LEXER_COLON) { scanner_raise_error (context_p); } scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; #if ENABLED (JERRY_ES2015) if (scanner_context.binding_type != SCANNER_BINDING_NONE) { scanner_context.mode = SCAN_MODE_BINDING; } #endif /* ENABLED (JERRY_ES2015) */ break; } #if ENABLED (JERRY_ES2015) case SCAN_MODE_BINDING: { JERRY_ASSERT (scanner_context.binding_type == SCANNER_BINDING_VAR || scanner_context.binding_type == SCANNER_BINDING_LET || scanner_context.binding_type == SCANNER_BINDING_CATCH || scanner_context.binding_type == SCANNER_BINDING_CONST || scanner_context.binding_type == SCANNER_BINDING_ARG || scanner_context.binding_type == SCANNER_BINDING_ARROW_ARG); if (type == LEXER_THREE_DOTS) { lexer_next_token (context_p); type = (lexer_token_type_t) context_p->token.type; } if (type == LEXER_LEFT_SQUARE || type == LEXER_LEFT_BRACE) { scanner_push_destructuring_pattern (context_p, &scanner_context, scanner_context.binding_type, true); if (type == LEXER_LEFT_SQUARE) { parser_stack_push_uint8 (context_p, SCAN_STACK_ARRAY_LITERAL); break; } parser_stack_push_uint8 (context_p, SCAN_STACK_OBJECT_LITERAL); scanner_context.mode = SCAN_MODE_PROPERTY_NAME; continue; } if (type != LEXER_LITERAL || context_p->token.lit_location.type != LEXER_IDENT_LITERAL) { scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; continue; } lexer_lit_location_t *literal_p = scanner_add_literal (context_p, &scanner_context); scanner_context.mode = SCAN_MODE_POST_PRIMARY_EXPRESSION; if (scanner_context.binding_type == SCANNER_BINDING_VAR) { if (!(literal_p->type & SCANNER_LITERAL_IS_VAR)) { scanner_detect_invalid_var (context_p, &scanner_context, literal_p); literal_p->type |= SCANNER_LITERAL_IS_VAR; if (scanner_context.active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH) { literal_p->type |= SCANNER_LITERAL_NO_REG; } } break; } if (scanner_context.binding_type == SCANNER_BINDING_ARROW_ARG) { literal_p->type |= SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG; if (literal_p->type & SCANNER_LITERAL_IS_USED) { literal_p->type |= SCANNER_LITERAL_EARLY_CREATE; break; } } else { scanner_detect_invalid_let (context_p, literal_p); if (scanner_context.binding_type <= SCANNER_BINDING_CATCH) { JERRY_ASSERT ((scanner_context.binding_type == SCANNER_BINDING_LET) || (scanner_context.binding_type == SCANNER_BINDING_CATCH)); literal_p->type |= SCANNER_LITERAL_IS_LET; } else { literal_p->type |= SCANNER_LITERAL_IS_CONST; if (scanner_context.binding_type == SCANNER_BINDING_ARG) { literal_p->type |= SCANNER_LITERAL_IS_ARG; if (literal_p->type & SCANNER_LITERAL_IS_USED) { literal_p->type |= SCANNER_LITERAL_EARLY_CREATE; break; } } } if (literal_p->type & SCANNER_LITERAL_IS_USED) { literal_p->type |= SCANNER_LITERAL_EARLY_CREATE; break; } } scanner_binding_item_t *binding_item_p; binding_item_p = (scanner_binding_item_t *) scanner_malloc (context_p, sizeof (scanner_binding_item_t)); binding_item_p->next_p = scanner_context.active_binding_list_p->items_p; binding_item_p->literal_p = literal_p; scanner_context.active_binding_list_p->items_p = binding_item_p; lexer_next_token (context_p); if (context_p->token.type != LEXER_ASSIGN) { continue; } scanner_binding_literal_t binding_literal; binding_literal.literal_p = literal_p; parser_stack_push (context_p, &binding_literal, sizeof (scanner_binding_literal_t)); parser_stack_push_uint8 (context_p, SCAN_STACK_BINDING_INIT); scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION; break; } #endif /* ENABLED (JERRY_ES2015) */ } lexer_next_token (context_p); } scan_completed: if (context_p->stack_top_uint8 != SCAN_STACK_SCRIPT && context_p->stack_top_uint8 != SCAN_STACK_SCRIPT_FUNCTION) { scanner_raise_error (context_p); } scanner_pop_literal_pool (context_p, &scanner_context); #if ENABLED (JERRY_ES2015) JERRY_ASSERT (scanner_context.active_binding_list_p == NULL); #endif /* ENABLED (JERRY_ES2015) */ JERRY_ASSERT (scanner_context.active_literal_pool_p == NULL); #ifndef JERRY_NDEBUG scanner_context.context_status_flags |= PARSER_SCANNING_SUCCESSFUL; #endif /* !JERRY_NDEBUG */ } PARSER_CATCH { /* Ignore the errors thrown by the lexer. */ if (context_p->error != PARSER_ERR_OUT_OF_MEMORY) { context_p->error = PARSER_ERR_NO_ERROR; } #if ENABLED (JERRY_ES2015) while (scanner_context.active_binding_list_p != NULL) { scanner_pop_binding_list (&scanner_context); } #endif /* ENABLED (JERRY_ES2015) */ /* The following code may allocate memory, so it is enclosed in a try/catch. */ PARSER_TRY (context_p->try_buffer) { #if ENABLED (JERRY_ES2015) if (scanner_context.status_flags & SCANNER_CONTEXT_THROW_ERR_ASYNC_FUNCTION) { JERRY_ASSERT (scanner_context.async_source_p != NULL); scanner_info_t *info_p; info_p = scanner_insert_info (context_p, scanner_context.async_source_p, sizeof (scanner_info_t)); info_p->type = SCANNER_TYPE_ERR_ASYNC_FUNCTION; } #endif /* ENABLED (JERRY_ES2015) */ while (scanner_context.active_literal_pool_p != NULL) { scanner_pop_literal_pool (context_p, &scanner_context); } } PARSER_CATCH { JERRY_ASSERT (context_p->error == PARSER_ERR_NO_ERROR); while (scanner_context.active_literal_pool_p != NULL) { scanner_literal_pool_t *literal_pool_p = scanner_context.active_literal_pool_p; scanner_context.active_literal_pool_p = literal_pool_p->prev_p; parser_list_free (&literal_pool_p->literal_pool); scanner_free (literal_pool_p, sizeof (scanner_literal_pool_t)); } } PARSER_TRY_END #if ENABLED (JERRY_ES2015) context_p->status_flags &= (uint32_t) ~PARSER_IS_GENERATOR_FUNCTION; #endif /* ENABLED (JERRY_ES2015) */ } PARSER_TRY_END context_p->status_flags = scanner_context.context_status_flags; scanner_reverse_info_list (context_p); #if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) if (context_p->is_show_opcodes) { scanner_info_t *info_p = context_p->next_scanner_info_p; const uint8_t *source_start_p = (arg_list_p == NULL) ? source_p : arg_list_p; while (info_p->type != SCANNER_TYPE_END) { const char *name_p = NULL; bool print_location = false; switch (info_p->type) { case SCANNER_TYPE_END_ARGUMENTS: { JERRY_DEBUG_MSG (\" END_ARGUMENTS\\n\"); source_start_p = source_p; break; } case SCANNER_TYPE_FUNCTION: case SCANNER_TYPE_BLOCK: { const uint8_t *prev_source_p = info_p->source_p - 1; const uint8_t *data_p; if (info_p->type == SCANNER_TYPE_FUNCTION) { data_p = (const uint8_t *) (info_p + 1); JERRY_DEBUG_MSG (\" FUNCTION: flags: 0x%x declarations: %d\", (int) info_p->u8_arg, (int) info_p->u16_arg); } else { data_p = (const uint8_t *) (info_p + 1); JERRY_DEBUG_MSG (\" BLOCK:\"); } JERRY_DEBUG_MSG (\" source:%d\\n\", (int) (info_p->source_p - source_start_p)); while (data_p[0] != SCANNER_STREAM_TYPE_END) { switch (data_p[0] & SCANNER_STREAM_TYPE_MASK) { case SCANNER_STREAM_TYPE_VAR: { JERRY_DEBUG_MSG (\" VAR \"); break; } #if ENABLED (JERRY_ES2015) case SCANNER_STREAM_TYPE_LET: { JERRY_DEBUG_MSG (\" LET \"); break; } case SCANNER_STREAM_TYPE_CONST: { JERRY_DEBUG_MSG (\" CONST \"); break; } case SCANNER_STREAM_TYPE_LOCAL: { JERRY_DEBUG_MSG (\" LOCAL \"); break; } #endif /* ENABLED (JERRY_ES2015) */ #if ENABLED (JERRY_ES2015_MODULE_SYSTEM) case SCANNER_STREAM_TYPE_IMPORT: { JERRY_DEBUG_MSG (\" IMPORT \"); break; } #endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ case SCANNER_STREAM_TYPE_ARG: { JERRY_DEBUG_MSG (\" ARG \"); break; } #if ENABLED (JERRY_ES2015) case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG: { JERRY_DEBUG_MSG (\" DESTRUCTURED_ARG \"); break; } #endif /* ENABLED (JERRY_ES2015) */ case SCANNER_STREAM_TYPE_ARG_FUNC: { JERRY_DEBUG_MSG (\" ARG_FUNC \"); break; } #if ENABLED (JERRY_ES2015) case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC: { JERRY_DEBUG_MSG (\" DESTRUCTURED_ARG_FUNC \"); break; } #endif /* ENABLED (JERRY_ES2015) */ case SCANNER_STREAM_TYPE_FUNC: { JERRY_DEBUG_MSG (\" FUNC \"); break; } default: { JERRY_ASSERT ((data_p[0] & SCANNER_STREAM_TYPE_MASK) == SCANNER_STREAM_TYPE_HOLE); JERRY_DEBUG_MSG (\" HOLE\\n\"); data_p++; continue; } } size_t length; if (!(data_p[0] & SCANNER_STREAM_UINT16_DIFF)) { if (data_p[2] != 0) { prev_source_p += data_p[2]; length = 2 + 1; } else { memcpy (&prev_source_p, data_p + 2 + 1, sizeof (const uint8_t *)); length = 2 + 1 + sizeof (const uint8_t *); } } else { int32_t diff = ((int32_t) data_p[2]) | ((int32_t) data_p[3]) << 8; if (diff <= UINT8_MAX) { diff = -diff; } prev_source_p += diff; length = 2 + 2; } #if ENABLED (JERRY_ES2015) if (data_p[0] & SCANNER_STREAM_EARLY_CREATE) { JERRY_ASSERT (data_p[0] & SCANNER_STREAM_NO_REG); JERRY_DEBUG_MSG (\"*\"); } #endif /* ENABLED (JERRY_ES2015) */ if (data_p[0] & SCANNER_STREAM_NO_REG) { JERRY_DEBUG_MSG (\"* \"); } JERRY_DEBUG_MSG (\"'%.*s'\\n\", data_p[1], (char *) prev_source_p); prev_source_p += data_p[1]; data_p += length; } break; } case SCANNER_TYPE_WHILE: { name_p = \"WHILE\"; print_location = true; break; } case SCANNER_TYPE_FOR: { scanner_for_info_t *for_info_p = (scanner_for_info_t *) info_p; JERRY_DEBUG_MSG (\" FOR: source:%d expression:%d[%d:%d] end:%d[%d:%d]\\n\", (int) (for_info_p->info.source_p - source_start_p), (int) (for_info_p->expression_location.source_p - source_start_p), (int) for_info_p->expression_location.line, (int) for_info_p->expression_location.column, (int) (for_info_p->end_location.source_p - source_start_p), (int) for_info_p->end_location.line, (int) for_info_p->end_location.column); break; } case SCANNER_TYPE_FOR_IN: { name_p = \"FOR-IN\"; print_location = true; break; } #if ENABLED (JERRY_ES2015) case SCANNER_TYPE_FOR_OF: { name_p = \"FOR-OF\"; print_location = true; break; } #endif /* ENABLED (JERRY_ES2015) */ case SCANNER_TYPE_SWITCH: { JERRY_DEBUG_MSG (\" SWITCH: source:%d\\n\", (int) (info_p->source_p - source_start_p)); scanner_case_info_t *current_case_p = ((scanner_switch_info_t *) info_p)->case_p; while (current_case_p != NULL) { JERRY_DEBUG_MSG (\" CASE: location:%d[%d:%d]\\n\", (int) (current_case_p->location.source_p - source_start_p), (int) current_case_p->location.line, (int) current_case_p->location.column); current_case_p = current_case_p->next_p; } break; } case SCANNER_TYPE_CASE: { name_p = \"CASE\"; print_location = true; break; } #if ENABLED (JERRY_ES2015) case SCANNER_TYPE_INITIALIZER: { name_p = \"INITIALIZER\"; print_location = true; break; } case SCANNER_TYPE_CLASS_CONSTRUCTOR: { JERRY_DEBUG_MSG (\" CLASS-CONSTRUCTOR: source:%d\\n\", (int) (info_p->source_p - source_start_p)); print_location = false; break; } case SCANNER_TYPE_LET_EXPRESSION: { JERRY_DEBUG_MSG (\" LET_EXPRESSION: source:%d\\n\", (int) (info_p->source_p - source_start_p)); break; } case SCANNER_TYPE_ERR_REDECLARED: { JERRY_DEBUG_MSG (\" ERR_REDECLARED: source:%d\\n\", (int) (info_p->source_p - source_start_p)); break; } case SCANNER_TYPE_ERR_ASYNC_FUNCTION: { JERRY_DEBUG_MSG (\" ERR_ASYNC_FUNCTION: source:%d\\n\", (int) (info_p->source_p - source_start_p)); break; } #endif /* ENABLED (JERRY_ES2015) */ } if (print_location) { scanner_location_info_t *location_info_p = (scanner_location_info_t *) info_p; JERRY_DEBUG_MSG (\" %s: source:%d location:%d[%d:%d]\\n\", name_p, (int) (location_info_p->info.source_p - source_start_p), (int) (location_info_p->location.source_p - source_start_p), (int) location_info_p->location.line, (int) location_info_p->location.column); } info_p = info_p->next_p; } JERRY_DEBUG_MSG (\"\\n--- Scanning end ---\\n\\n\"); } #endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */ parser_stack_free (context_p); } /* scanner_scan_all */", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "parser/js/js-scanner.c in JerryScript 2.2.0 mishandles errors during certain out-of-memory conditions, as demonstrated by a scanner_reverse_info_list NULL pointer dereference and a scanner_scan_all assertion failure.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2020-13649"}} -{"idx": 291400, "input": "PHP_FUNCTION(openssl_pkcs7_sign) { zval * zcert, * zprivkey, * zheaders; zval * hval; X509 * cert = NULL; EVP_PKEY * privkey = NULL; zend_long flags = PKCS7_DETACHED; PKCS7 * p7 = NULL; BIO * infile = NULL, * outfile = NULL; STACK_OF(X509) *others = NULL; zend_resource *certresource = NULL, *keyresource = NULL; zend_string * strindex; char * infilename; size_t infilename_len; char * outfilename; size_t outfilename_len; char * extracertsfilename = NULL; size_t extracertsfilename_len; if (zend_parse_parameters(ZEND_NUM_ARGS(), \"ppzza!|lp!\", &infilename, &infilename_len, &outfilename, &outfilename_len, &zcert, &zprivkey, &zheaders, &flags, &extracertsfilename, &extracertsfilename_len) == FAILURE) { return; } RETVAL_FALSE; if (extracertsfilename) { others = php_openssl_load_all_certs_from_file(extracertsfilename); if (others == NULL) { goto clean_exit; } } privkey = php_openssl_evp_from_zval(zprivkey, 0, \"\", 0, 0, &keyresource); if (privkey == NULL) { php_error_docref(NULL, E_WARNING, \"error getting private key\"); goto clean_exit; } cert = php_openssl_x509_from_zval(zcert, 0, &certresource); if (cert == NULL) { php_error_docref(NULL, E_WARNING, \"error getting cert\"); goto clean_exit; } if (php_openssl_open_base_dir_chk(infilename) || php_openssl_open_base_dir_chk(outfilename)) { goto clean_exit; } infile = BIO_new_file(infilename, PHP_OPENSSL_BIO_MODE_R(flags)); if (infile == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, \"error opening input file %s!\", infilename); goto clean_exit; } outfile = BIO_new_file(outfilename, PHP_OPENSSL_BIO_MODE_W(PKCS7_BINARY)); if (outfile == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, \"error opening output file %s!\", outfilename); goto clean_exit; } p7 = PKCS7_sign(cert, privkey, others, infile, (int)flags); if (p7 == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, \"error creating PKCS7 structure!\"); goto clean_exit; } (void)BIO_reset(infile); /* tack on extra headers */ if (zheaders) { int ret; ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zheaders), strindex, hval) { convert_to_string_ex(hval); if (strindex) { ret = BIO_printf(outfile, \"%s: %s\\n\", ZSTR_VAL(strindex), Z_STRVAL_P(hval)); } else { ret = BIO_printf(outfile, \"%s\\n\", Z_STRVAL_P(hval)); } if (ret < 0) { php_openssl_store_errors(); } } ZEND_HASH_FOREACH_END(); } /* write the signed data */ if (!SMIME_write_PKCS7(outfile, p7, infile, (int)flags)) { php_openssl_store_errors(); goto clean_exit; } RETVAL_TRUE; clean_exit: PKCS7_free(p7); BIO_free(infile); BIO_free(outfile); if (others) { sk_X509_pop_free(others, X509_free); } if (privkey && keyresource == NULL) { EVP_PKEY_free(privkey); } if (cert && certresource == NULL) { X509_free(cert); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 366763, "input": "struct mempolicy *__get_vma_policy(struct vm_area_struct *vma, unsigned long addr) { struct mempolicy *pol = NULL; if (vma) { if (vma->vm_ops && vma->vm_ops->get_policy) { pol = vma->vm_ops->get_policy(vma, addr); } else if (vma->vm_policy) { pol = vma->vm_policy; /* * shmem_alloc_page() passes MPOL_F_SHARED policy with * a pseudo vma whose vma->vm_ops=NULL. Take a reference * count on these policies which will be dropped by * mpol_cond_put() later */ if (mpol_needs_cond_ref(pol)) mpol_get(pol); } } return pol; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 244386, "input": "int mp4boxMain(int argc, char **argv) { u32 i, j; const char *gpac_profile = \"0\"; GF_Err e = GF_OK; nb_tsel_acts = nb_add = nb_cat = nb_track_act = nb_sdp_ex = max_ptime = nb_meta_act = rtp_rate = major_brand = nb_alt_brand_add = nb_alt_brand_rem = car_dur = minor_version = 0; split_duration = 0.0; split_start = -1.0; interleaving_time = 0; dash_duration = dash_subduration = 0.0; import_fps.num = import_fps.den = 0; import_flags = 0; split_size = 0; movie_time = 0; dump_nal = dump_saps = dump_saps_mode = force_new = 0; FullInter = HintInter = encode = do_scene_log = old_interleave = do_saf = do_hash = verbose = do_mpd_rip = merge_vtt_cues = get_nb_tracks = GF_FALSE; #ifndef GPAC_DISABLE_SCENE_DUMP dump_mode = GF_SM_DUMP_NONE; #endif Frag = force_ocr = remove_sys_tracks = agg_samples = remove_hint = keep_sys_tracks = remove_root_od = single_group = clean_groups = compress_moov = GF_FALSE; conv_type = HintIt = needSave = print_sdp = regular_iod = dump_std = open_edit = dump_rtp = dump_cr = dump_srt = dump_ttxt = dump_m2ts = dump_cart = import_subtitle = force_cat = pack_wgt = dash_live = GF_FALSE; no_fragments_defaults = GF_FALSE; single_traf_per_moof = hls_clock = GF_FALSE; tfdt_per_traf = GF_FALSE; dump_nal_type = 0; dump_isom = 0; print_info = 0; /*align cat is the new default behaviour for -cat*/ align_cat = GF_TRUE; subsegs_per_sidx = 0; track_dump_type = 0; crypt = 0; time_shift_depth = 0; file = NULL; itunes_tags = pes_dump = NULL; seg_name = dash_ctx_file = NULL; compress_top_boxes = NULL; initial_moof_sn = 0; initial_tfdt = 0; #ifndef GPAC_DISABLE_SCENE_ENCODER memset(&smenc_opts, 0, sizeof(smenc_opts)); #endif trackID = stat_level = hint_flags = 0; program_number = 0; info_track_id = 0; do_flat = 0; inName = outName = mediaSource = input_ctx = output_ctx = drm_file = avi2raw = cprt = chap_file = pack_file = raw_cat = high_dynamc_range_filename = use_init_seg = box_patch_filename = NULL; #ifndef GPAC_DISABLE_SWF_IMPORT swf_flags = GF_SM_SWF_SPLIT_TIMELINE; #endif swf_flatten_angle = 0.0f; tmpdir = NULL; for (i = 1; i < (u32) argc ; i++) { if (!strcmp(argv[i], \"-mem-track\") || !strcmp(argv[i], \"-mem-track-stack\")) { #ifdef GPAC_MEMORY_TRACKING mem_track = !strcmp(argv[i], \"-mem-track-stack\") ? GF_MemTrackerBackTrace : GF_MemTrackerSimple; #else fprintf(stderr, \"WARNING - GPAC not compiled with Memory Tracker - ignoring \\\"%s\\\"\\n\", argv[i]); #endif break; } else if (!strcmp(argv[i], \"-p\")) { if (i+1<(u32) argc) gpac_profile = argv[i+1]; else { fprintf(stderr, \"Bad argument for -p, expecting profile name but no more args\\n\"); return 1; } } else if (!strncmp(argv[i], \"-p=\", 3)) gpac_profile = argv[i]+3; } #ifdef _TWO_DIGIT_EXPONENT _set_output_format(_TWO_DIGIT_EXPONENT); #endif /*init libgpac*/ gf_sys_init(mem_track, gpac_profile); if (argc < 2) { fprintf(stderr, \"Not enough arguments - check usage with -h\\n\" \"MP4Box - GPAC version %s\\n\" \"%s\\n\", gf_gpac_version(), gf_gpac_copyright()); gf_sys_close(); return 0; } helpout = stdout; i = mp4box_parse_args(argc, argv); if (i) { return mp4box_cleanup(i - 1); } if (!inName && dump_std) inName = \"std\"; if (!inName) { if (has_next_arg) { fprintf(stderr, \"Broken argument specifier or file name missing - check usage with -h\\n\"); } else { PrintUsage(); } return mp4box_cleanup(1); } if (!strcmp(inName, \"std\")) dump_std = 2; if (!strcmp(inName, \"stdb\")) { inName = \"std\"; dump_std = 1; } if (!interleaving_time) { /*by default use single fragment per dash segment*/ if (dash_duration) interleaving_time = dash_duration; else if (!do_flat) { interleaving_time = DEFAULT_INTERLEAVING_IN_SEC; } } if (dump_std) outName = \"std\"; if (dump_std==2) { #ifdef WIN32 if ( _setmode(_fileno(stdout), _O_BINARY) == -1 ) #else if ( freopen(NULL, \"wb\", stdout) == NULL) #endif { fprintf(stderr, \"Fatal error: cannot reopen stdout in binary mode.\\n\"); return mp4box_cleanup(1); } } #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG) if (live_scene) { int ret = live_session(argc, argv); return mp4box_cleanup(ret); } #endif GF_LOG_Level level = verbose ? GF_LOG_DEBUG : GF_LOG_INFO; gf_log_set_tool_level(GF_LOG_CONTAINER, level); gf_log_set_tool_level(GF_LOG_SCENE, level); gf_log_set_tool_level(GF_LOG_PARSER, level); gf_log_set_tool_level(GF_LOG_AUTHOR, level); gf_log_set_tool_level(GF_LOG_CODING, level); gf_log_set_tool_level(GF_LOG_DASH, level); #ifdef GPAC_MEMORY_TRACKING if (mem_track) gf_log_set_tool_level(GF_LOG_MEMORY, level); #endif e = gf_sys_set_args(argc, (const char **) argv); if (e) { fprintf(stderr, \"Error assigning libgpac arguments: %s\\n\", gf_error_to_string(e) ); return mp4box_cleanup(1); } if (raw_cat) { char chunk[4096]; FILE *fin, *fout; s64 to_copy, done; fin = gf_fopen(raw_cat, \"rb\"); if (!fin) return mp4box_cleanup(1); fout = gf_fopen(inName, \"a+b\"); if (!fout) { gf_fclose(fin); return mp4box_cleanup(1); } gf_fseek(fin, 0, SEEK_END); to_copy = gf_ftell(fin); gf_fseek(fin, 0, SEEK_SET); done = 0; while (1) { u32 nb_bytes = (u32) gf_fread(chunk, 4096, fin); gf_fwrite(chunk, nb_bytes, fout); done += nb_bytes; fprintf(stderr, \"Appending file %s - %02.2f done\\r\", raw_cat, 100.0*done/to_copy); if (done >= to_copy) break; } gf_fclose(fin); gf_fclose(fout); return mp4box_cleanup(0); } if (compress_top_boxes) { if (size_top_box) { u64 top_size = do_size_top_boxes(inName, compress_top_boxes, size_top_box); fprintf(stdout, LLU\"\\n\", top_size); return mp4box_cleanup(e ? 1 : 0); } else { e = do_compress_top_boxes(inName, outName, compress_top_boxes, comp_top_box_version, comp_lzma); return mp4box_cleanup(e ? 1 : 0); } } if (do_mpd_rip) { e = rip_mpd(inName, outName); return mp4box_cleanup(e ? 1 : 0); } #ifndef GPAC_DISABLE_CORE_TOOLS if (do_wget != NULL) { e = gf_dm_wget(do_wget, inName, 0, 0, NULL); if (e != GF_OK) { fprintf(stderr, \"Cannot retrieve %s: %s\\n\", do_wget, gf_error_to_string(e) ); return mp4box_cleanup(1); } return mp4box_cleanup(0); } #endif if (udp_dest) { GF_Socket *sock = gf_sk_new(GF_SOCK_TYPE_UDP); u16 port = 2345; char *sep = strrchr(udp_dest, ':'); if (sep) { sep[0] = 0; port = atoi(sep+1); } e = gf_sk_bind( sock, \"127.0.0.1\", 0, udp_dest, port, 0); if (sep) sep[0] = ':'; if (e) fprintf(stderr, \"Failed to bind socket to %s: %s\\n\", udp_dest, gf_error_to_string(e) ); else { e = gf_sk_send(sock, (u8 *) inName, (u32)strlen(inName)); if (e) fprintf(stderr, \"Failed to send datagram: %s\\n\", gf_error_to_string(e) ); } gf_sk_del(sock); return 0; } #ifndef GPAC_DISABLE_MPD if (do_mpd) { Bool remote = GF_FALSE; GF_MPD *mpd; char *mpd_base_url = NULL; if (!strnicmp(inName, \"http://\", 7) || !strnicmp(inName, \"https://\", 8)) { #if !defined(GPAC_DISABLE_CORE_TOOLS) e = gf_dm_wget(inName, \"tmp_main.m3u8\", 0, 0, &mpd_base_url); if (e != GF_OK) { fprintf(stderr, \"Cannot retrieve M3U8 (%s): %s\\n\", inName, gf_error_to_string(e)); if (mpd_base_url) gf_free(mpd_base_url); return mp4box_cleanup(1); } remote = GF_TRUE; #else gf_free(mpd_base_url); fprintf(stderr, \"HTTP Downloader disabled in this build\\n\"); return mp4box_cleanup(1); #endif if (outName) strcpy(outfile, outName); else { const char *sep = gf_file_basename(inName); char *ext = gf_file_ext_start(sep); if (ext) ext[0] = 0; sprintf(outfile, \"%s.mpd\", sep); if (ext) ext[0] = '.'; } } else { if (outName) strcpy(outfile, outName); else { char *dst = strdup(inName); char *ext = strstr(dst, \".m3u8\"); if (ext) ext[0] = 0; sprintf(outfile, \"%s.mpd\", dst); gf_free(dst); } } mpd = gf_mpd_new(); if (!mpd) { e = GF_OUT_OF_MEM; fprintf(stderr, \"[DASH] Error: MPD creation problem %s\\n\", gf_error_to_string(e)); mp4box_cleanup(1); } FILE *f = gf_fopen(remote ? \"tmp_main.m3u8\" : inName, \"r\"); u32 manif_type = 0; if (f) { char szDATA[1000]; s32 read; szDATA[999]=0; read = (s32) gf_fread(szDATA, 999, f); if (read<0) read = 0; szDATA[read]=0; gf_fclose(f); if (strstr(szDATA, \"SmoothStreamingMedia\")) manif_type = 2; else if (strstr(szDATA, \"#EXTM3U\")) manif_type = 1; } if (manif_type==1) { e = gf_m3u8_to_mpd(remote ? \"tmp_main.m3u8\" : inName, mpd_base_url ? mpd_base_url : inName, outfile, 0, \"video/mp2t\", GF_TRUE, use_url_template, segment_timeline, NULL, mpd, GF_TRUE, GF_TRUE); } else if (manif_type==2) { e = gf_mpd_smooth_to_mpd(remote ? \"tmp_main.m3u8\" : inName, mpd, mpd_base_url ? mpd_base_url : inName); } else { e = GF_NOT_SUPPORTED; } if (!e) gf_mpd_write_file(mpd, outfile); if (mpd) gf_mpd_del(mpd); if (mpd_base_url) gf_free(mpd_base_url); if (remote) { gf_file_delete(\"tmp_main.m3u8\"); } if (e != GF_OK) { fprintf(stderr, \"Error converting %s (%s) to MPD (%s): %s\\n\", (manif_type==1) ? \"HLS\" : \"Smooth\", inName, outfile, gf_error_to_string(e)); return mp4box_cleanup(1); } else { fprintf(stderr, \"Done converting %s (%s) to MPD (%s)\\n\", (manif_type==1) ? \"HLS\" : \"Smooth\", inName, outfile); return mp4box_cleanup(0); } } #endif if (dash_duration && !nb_dash_inputs) { dash_inputs = set_dash_input(dash_inputs, inName, &nb_dash_inputs); } if (do_saf && !encode) { switch (get_file_type_by_ext(inName)) { case GF_FILE_TYPE_BT_WRL_X3DV: case GF_FILE_TYPE_XMT_X3D: case GF_FILE_TYPE_SVG: encode = GF_TRUE; break; case GF_FILE_TYPE_NOT_SUPPORTED: case GF_FILE_TYPE_ISO_MEDIA: case GF_FILE_TYPE_SWF: case GF_FILE_TYPE_LSR_SAF: break; } } #ifndef GPAC_DISABLE_SCENE_DUMP if (dump_mode == GF_SM_DUMP_SVG) { if (strstr(inName, \".srt\") || strstr(inName, \".ttxt\")) import_subtitle = 2; } #endif if (import_subtitle && !trackID) { /* We import the subtitle file, i.e. we parse it and store the content as samples of a 3GPP Timed Text track in an ISO file, possibly for later export (e.g. when converting SRT to TTXT, ...) */ #ifndef GPAC_DISABLE_MEDIA_IMPORT GF_MediaImporter import; /* Prepare the importer */ file = gf_isom_open(\"ttxt_convert\", GF_ISOM_OPEN_WRITE, NULL); if (timescale && file) gf_isom_set_timescale(file, timescale); memset(&import, 0, sizeof(GF_MediaImporter)); import.dest = file; import.in_name = inName; /* Start the import */ e = gf_media_import(&import); if (e) { fprintf(stderr, \"Error importing %s: %s\\n\", inName, gf_error_to_string(e)); gf_isom_delete(file); gf_file_delete(\"ttxt_convert\"); return mp4box_cleanup(1); } /* Prepare the export */ strcpy(outfile, inName); if (strchr(outfile, '.')) { while (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0; outfile[strlen(outfile)-1] = 0; } #ifndef GPAC_DISABLE_ISOM_DUMP /* Start the export of the track #1, in the appropriate dump type, indicating it's a conversion */ dump_isom_timed_text(file, gf_isom_get_track_id(file, 1), dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, GF_TRUE, (import_subtitle==2) ? GF_TEXTDUMPTYPE_SVG : (dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT)); #endif /* Clean the importer */ gf_isom_delete(file); gf_file_delete(\"ttxt_convert\"); if (e) { fprintf(stderr, \"Error converting %s: %s\\n\", inName, gf_error_to_string(e)); return mp4box_cleanup(1); } return mp4box_cleanup(0); #else fprintf(stderr, \"Feature not supported\\n\"); return mp4box_cleanup(1); #endif } #if !defined(GPAC_DISABLE_MEDIA_IMPORT) && !defined(GPAC_DISABLE_ISOM_WRITE) if (nb_add || nb_cat) { u32 ipass, nb_pass = 1; char *mux_args=NULL; GF_FilterSession *fs = NULL; if (nb_add) { GF_ISOOpenMode open_mode = GF_ISOM_OPEN_EDIT; if (force_new) { open_mode = (do_flat || (force_new==2)) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT; } else { FILE *test = gf_fopen(inName, \"rb\"); if (!test) { open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT; if (!outName) outName = inName; } else { gf_fclose(test); if (! gf_isom_probe_file(inName) ) { open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT; if (!outName) outName = inName; } } } open_edit = do_flat ? GF_FALSE : GF_TRUE; file = gf_isom_open(inName, open_mode, tmpdir); if (!file) { fprintf(stderr, \"Cannot open destination file %s: %s\\n\", inName, gf_error_to_string(gf_isom_last_error(NULL)) ); return mp4box_cleanup(1); } if (freeze_box_order) gf_isom_freeze_order(file); } if (do_flat && interleaving_time) { char szSubArg[100]; gf_isom_set_storage_mode(file, GF_ISOM_STORE_FASTSTART); do_flat = 2; nb_pass = 2; fs = gf_fs_new_defaults(0); if (!fs) { fprintf(stderr, \"Error creating filter session\\n\"); gf_isom_delete(file); return mp4box_cleanup(1); } //mux args gf_dynstrcat(&mux_args, \"mp4mx:importer:store=fstart\", \":\"); sprintf(szSubArg, \"file=%p\", file); gf_dynstrcat(&mux_args, szSubArg, \":\"); sprintf(szSubArg, \"cdur=%g\", interleaving_time); gf_dynstrcat(&mux_args, szSubArg, \":\"); } for (ipass=0; ipass0) && (dash_duration > dash_subduration)) { fprintf(stderr, \"Warning: -subdur parameter (%g s) should be greater than segment duration (%g s), using segment duration instead\\n\", dash_subduration, dash_duration); dash_subduration = dash_duration; } if (dash_mode && dash_live) fprintf(stderr, \"Live DASH-ing - press 'q' to quit, 's' to save context and quit\\n\"); if (!dash_ctx_file && dash_live) { u32 r1; u64 add = (u64) (intptr_t) &dasher; add ^= gf_net_get_utc(); r1 = (u32) add ^ (u32) (add/0xFFFFFFFF); r1 ^= gf_rand(); sprintf(szStateFile, \"%s/dasher_%X.xml\", gf_get_default_cache_directory(), r1 ); dash_ctx_file = szStateFile; dyn_state_file = GF_TRUE; } else if (dash_ctx_file) { if (force_new) gf_file_delete(dash_ctx_file); } if (dash_profile==GF_DASH_PROFILE_AUTO) dash_profile = dash_mode ? GF_DASH_PROFILE_LIVE : GF_DASH_PROFILE_FULL; if (!dash_mode) { time_shift_depth = 0; mpd_update_time = 0; } else if ((dash_profile>=GF_DASH_PROFILE_MAIN) && !use_url_template && !mpd_update_time) { /*use a default MPD update of dash_duration sec*/ mpd_update_time = (Double) (dash_subduration ? dash_subduration : dash_duration); fprintf(stderr, \"Using default MPD refresh of %g seconds\\n\", mpd_update_time); } if (file && needSave) { gf_isom_close(file); file = NULL; del_file = GF_TRUE; } /*setup dash*/ dasher = gf_dasher_new(szMPD, dash_profile, tmpdir, dash_scale, dash_ctx_file); if (!dasher) { return mp4box_cleanup(1); } e = gf_dasher_set_info(dasher, dash_title, cprt, dash_more_info, dash_source, NULL); if (e) { fprintf(stderr, \"DASH Error: %s\\n\", gf_error_to_string(e)); gf_dasher_del(dasher); return mp4box_cleanup(1); } gf_dasher_set_start_date(dasher, dash_start_date); gf_dasher_set_location(dasher, dash_source); for (i=0; i < nb_mpd_base_urls; i++) { e = gf_dasher_add_base_url(dasher, mpd_base_urls[i]); if (e) { fprintf(stderr, \"DASH Error: %s\\n\", gf_error_to_string(e)); gf_dasher_del(dasher); return mp4box_cleanup(1); } } if (segment_timeline && !use_url_template) { fprintf(stderr, \"DASH Warning: using -segment-timeline with no -url-template. Forcing URL template.\\n\"); use_url_template = GF_TRUE; } e = gf_dasher_enable_url_template(dasher, (Bool) use_url_template, seg_name, seg_ext, init_seg_ext); if (!e) e = gf_dasher_enable_segment_timeline(dasher, segment_timeline); if (!e) e = gf_dasher_enable_single_segment(dasher, single_segment); if (!e) e = gf_dasher_enable_single_file(dasher, single_file); if (!e) e = gf_dasher_set_switch_mode(dasher, bitstream_switching_mode); if (!e) e = gf_dasher_set_durations(dasher, dash_duration, interleaving_time, dash_subduration); if (!e) e = gf_dasher_enable_rap_splitting(dasher, seg_at_rap, frag_at_rap); if (!e) e = gf_dasher_set_segment_marker(dasher, segment_marker); if (!e) e = gf_dasher_enable_sidx(dasher, (subsegs_per_sidx>=0) ? 1 : 0, (u32) subsegs_per_sidx, daisy_chain_sidx, use_ssix); if (!e) e = gf_dasher_set_dynamic_mode(dasher, dash_mode, mpd_update_time, time_shift_depth, mpd_live_duration); if (!e) e = gf_dasher_set_min_buffer(dasher, min_buffer); if (!e) e = gf_dasher_set_ast_offset(dasher, ast_offset_ms); if (!e) e = gf_dasher_enable_memory_fragmenting(dasher, memory_frags); if (!e) e = gf_dasher_set_initial_isobmf(dasher, initial_moof_sn, initial_tfdt); if (!e) e = gf_dasher_configure_isobmf_default(dasher, no_fragments_defaults, pssh_mode, samplegroups_in_traf, single_traf_per_moof, tfdt_per_traf, mvex_after_traks, sdtp_in_traf); if (!e) e = gf_dasher_enable_utc_ref(dasher, insert_utc); if (!e) e = gf_dasher_enable_real_time(dasher, frag_real_time); if (!e) e = gf_dasher_set_content_protection_location_mode(dasher, cp_location_mode); if (!e) e = gf_dasher_set_profile_extension(dasher, dash_profile_extension); if (!e) e = gf_dasher_enable_cached_inputs(dasher, no_cache); if (!e) e = gf_dasher_enable_loop_inputs(dasher, ! no_loop); if (!e) e = gf_dasher_set_split_mode(dasher, dash_split_mode); if (!e) e = gf_dasher_set_hls_clock(dasher, hls_clock); if (!e && dash_cues) e = gf_dasher_set_cues(dasher, dash_cues, strict_cues); if (!e && fs_dump_flags) e = gf_dasher_print_session_info(dasher, fs_dump_flags); for (i=0; i < nb_dash_inputs; i++) { if (!e) e = gf_dasher_add_input(dasher, &dash_inputs[i]); } if (e) { fprintf(stderr, \"DASH Setup Error: %s\\n\", gf_error_to_string(e)); gf_dasher_del(dasher); return mp4box_cleanup(1); } dash_cumulated_time=0; while (1) { if (run_for && (dash_cumulated_time >= run_for)) { fprintf(stderr, \"Done running, computing static MPD\\n\"); do_abort = 3; } dash_prev_time=gf_sys_clock(); if (do_abort>=2) { e = gf_dasher_set_dynamic_mode(dasher, GF_DASH_DYNAMIC_LAST, 0, time_shift_depth, mpd_live_duration); } if (!e) e = gf_dasher_process(dasher); if (!dash_live && (e==GF_EOS) ) { fprintf(stderr, \"Nothing to dash, too early ...\\n\"); e = GF_OK; } if (do_abort) break; //this happens when reading file while writing them (local playback of the live session ...) if (dash_live && (e==GF_IO_ERR) ) { fprintf(stderr, \"Error dashing file (%s) but continuing ...\\n\", gf_error_to_string(e) ); e = GF_OK; } if (e) break; if (dash_live) { u64 ms_in_session=0; u32 slept = gf_sys_clock(); u32 sleep_for = gf_dasher_next_update_time(dasher, &ms_in_session); fprintf(stderr, \"Next generation scheduled in %u ms (DASH time \"LLU\" ms)\\r\", sleep_for, ms_in_session); if (run_for && (ms_in_session>=run_for)) { dash_cumulated_time = 1+run_for; continue; } while (1) { if (gf_prompt_has_input()) { char c = (char) gf_prompt_get_char(); if (c=='X') { do_abort = 1; break; } if (c=='q') { do_abort = 2; break; } if (c=='s') { do_abort = 3; break; } } if (dash_mode == GF_DASH_DYNAMIC_DEBUG) { break; } if (!sleep_for) break; gf_sleep(sleep_for/10); sleep_for = gf_dasher_next_update_time(dasher, NULL); if (sleep_for<=1) { dash_now_time=gf_sys_clock(); dash_cumulated_time+=(dash_now_time-dash_prev_time); fprintf(stderr, \"Slept for %d ms before generation, dash cumulated time %d\\n\", dash_now_time - slept, dash_cumulated_time); break; } } } else { break; } } gf_dasher_del(dasher); if (!run_for && dash_ctx_file && (do_abort==3) && (dyn_state_file) && !gf_sys_is_test_mode() ) { char szName[1024]; fprintf(stderr, \"Enter file name to save dash context:\\n\"); if (scanf(\"%1023s\", szName) == 1) { gf_file_move(dash_ctx_file, szName); } } if (e) fprintf(stderr, \"Error DASHing file: %s\\n\", gf_error_to_string(e)); if (file) gf_isom_delete(file); if (del_file) gf_file_delete(inName); if (e) return mp4box_cleanup(1); goto exit; } else if (!file && !do_hash #ifndef GPAC_DISABLE_MEDIA_EXPORT && !(track_dump_type & GF_EXPORT_AVI_NATIVE) #endif ) { FILE *st = gf_fopen(inName, \"rb\"); Bool file_exists = 0; GF_ISOOpenMode omode; if (st) { file_exists = 1; gf_fclose(st); } switch (get_file_type_by_ext(inName)) { case 1: omode = (u8) (force_new ? GF_ISOM_WRITE_EDIT : (open_edit ? GF_ISOM_OPEN_EDIT : ( ((dump_isom>0) || print_info) ? GF_ISOM_OPEN_READ_DUMP : GF_ISOM_OPEN_READ) ) ); if (crypt) { //keep fragment signaling in moov omode = GF_ISOM_OPEN_READ; if (use_init_seg) file = gf_isom_open(use_init_seg, GF_ISOM_OPEN_READ, tmpdir); } if (!crypt && use_init_seg) { file = gf_isom_open(use_init_seg, GF_ISOM_OPEN_READ_DUMP, tmpdir); if (file) { e = gf_isom_open_segment(file, inName, 0, 0, 0); if (e) { fprintf(stderr, \"Error opening segment %s: %s\\n\", inName, gf_error_to_string(e) ); gf_isom_delete(file); file = NULL; } } } if (!file) file = gf_isom_open(inName, omode, tmpdir); if (!file && (gf_isom_last_error(NULL) == GF_ISOM_INCOMPLETE_FILE) && !open_edit) { u64 missing_bytes; e = gf_isom_open_progressive(inName, 0, 0, GF_FALSE, &file, &missing_bytes); fprintf(stderr, \"Truncated file - missing \"LLD\" bytes\\n\", missing_bytes); } if (!file) { if (open_edit && nb_meta_act) { file = gf_isom_open(inName, GF_ISOM_WRITE_EDIT, tmpdir); if (!outName && file) outName = inName; } if (!file) { fprintf(stderr, \"Error opening file %s: %s\\n\", inName, gf_error_to_string(gf_isom_last_error(NULL))); return mp4box_cleanup(1); } } if (freeze_box_order) gf_isom_freeze_order(file); break; /*allowed for bt<->xmt*/ case 2: case 3: /*allowed for svg->lsr**/ case 4: /*allowed for swf->bt, swf->xmt, swf->svg*/ case 5: break; /*used for .saf / .lsr dump*/ case 6: #ifndef GPAC_DISABLE_SCENE_DUMP if ((dump_mode==GF_SM_DUMP_LASER) || (dump_mode==GF_SM_DUMP_SVG)) { break; } #endif default: if (!open_edit && file_exists && !gf_isom_probe_file(inName) && track_dump_type) { } #ifndef GPAC_DISABLE_ISOM_WRITE else if (!open_edit && file_exists /* && !gf_isom_probe_file(inName) */ #ifndef GPAC_DISABLE_SCENE_DUMP && dump_mode == GF_SM_DUMP_NONE #endif //GPAC_DISABLE_SCENE_DUMP ) { /*************************************************************************************************/ #ifndef GPAC_DISABLE_MEDIA_IMPORT if(dvbhdemux) { GF_MediaImporter import; file = gf_isom_open(\"ttxt_convert\", GF_ISOM_OPEN_WRITE, NULL); memset(&import, 0, sizeof(GF_MediaImporter)); import.dest = file; import.in_name = inName; import.flags = GF_IMPORT_MPE_DEMUX; e = gf_media_import(&import); if (e) { fprintf(stderr, \"Error importing %s: %s\\n\", inName, gf_error_to_string(e)); gf_isom_delete(file); gf_file_delete(\"ttxt_convert\"); return mp4box_cleanup(1); } } #endif /*GPAC_DISABLE_MEDIA_IMPORT*/ if (dump_m2ts) { #ifndef GPAC_DISABLE_MPEG2TS dump_mpeg2_ts(inName, pes_dump, program_number); #endif } else if (dump_timestamps) { #ifndef GPAC_DISABLE_MPEG2TS dump_mpeg2_ts(inName, pes_dump, program_number); #endif #ifndef GPAC_DISABLE_CORE_TOOLS } else if (do_bin_xml) { xml_bs_to_bin(inName, outName, dump_std); #endif } else if (do_hash) { hash_file(inName, dump_std); } else if (print_info) { #ifndef GPAC_DISABLE_MEDIA_IMPORT convert_file_info(inName, info_track_id); #endif } else { fprintf(stderr, \"Input %s is not an MP4 file, operation not allowed\\n\", inName); return mp4box_cleanup(1); } goto exit; } #endif /*GPAC_DISABLE_ISOM_WRITE*/ else if (open_edit) { file = gf_isom_open(inName, GF_ISOM_WRITE_EDIT, tmpdir); if (!outName && file) outName = inName; } else if (!file_exists) { fprintf(stderr, \"Error creating file %s: %s\\n\", inName, gf_error_to_string(GF_URL_ERROR)); return mp4box_cleanup(1); } else { fprintf(stderr, \"Cannot open %s - extension not supported\\n\", inName); return mp4box_cleanup(1); } } } if (high_dynamc_range_filename) { e = parse_high_dynamc_range_xml_desc(file, high_dynamc_range_filename); if (e) goto err_exit; } if (file && keep_utc && open_edit) { gf_isom_keep_utc_times(file, 1); } strcpy(outfile, outName ? outName : inName); { char *szExt = gf_file_ext_start(outfile); if (szExt) { /*turn on 3GP saving*/ if (!stricmp(szExt, \".3gp\") || !stricmp(szExt, \".3gpp\") || !stricmp(szExt, \".3g2\")) conv_type = GF_ISOM_CONV_TYPE_3GPP; else if (!stricmp(szExt, \".m4a\") || !stricmp(szExt, \".m4v\")) conv_type = GF_ISOM_CONV_TYPE_IPOD; else if (!stricmp(szExt, \".psp\")) conv_type = GF_ISOM_CONV_TYPE_PSP; else if (!stricmp(szExt, \".mov\") || !stricmp(szExt, \".qt\")) conv_type = GF_ISOM_CONV_TYPE_MOV; //remove extension from outfile *szExt = 0; } } #ifndef GPAC_DISABLE_MEDIA_EXPORT if (track_dump_type & GF_EXPORT_AVI_NATIVE) { char szFile[GF_MAX_PATH+24]; GF_MediaExporter mdump; memset(&mdump, 0, sizeof(mdump)); mdump.in_name = inName; mdump.flags = GF_EXPORT_AVI_NATIVE; mdump.trackID = trackID; if (dump_std) { mdump.out_name = \"std\"; } else if (outName) { mdump.out_name = outName; } else if (trackID>2) { sprintf(szFile, \"%s_audio%d\", outfile, trackID-1); mdump.out_name = szFile; } else { sprintf(szFile, \"%s_%s\", outfile, (trackID==1) ? \"video\" : \"audio\"); mdump.out_name = szFile; } mdump.print_stats_graph = fs_dump_flags; e = gf_media_export(&mdump); if (e) goto err_exit; goto exit; } if (!open_edit && track_dump_type && !gf_isom_probe_file(inName)) { GF_MediaExporter mdump; char szFile[GF_MAX_PATH+24]; for (i=0; iact_type != TRAC_ACTION_RAW_EXTRACT) continue; memset(&mdump, 0, sizeof(mdump)); mdump.in_name = inName; mdump.flags = tka->dump_type; mdump.trackID = tka->trackID; mdump.sample_num = tka->sample_num; if (outName) { mdump.out_name = outName; mdump.flags |= GF_EXPORT_MERGE; } else if (nb_track_act>1) { sprintf(szFile, \"%s_track%d\", outfile, mdump.trackID); mdump.out_name = szFile; } else { mdump.out_name = outfile; } mdump.print_stats_graph = fs_dump_flags; e = gf_media_export(&mdump); if (e) goto err_exit; } goto exit; } #endif /*GPAC_DISABLE_MEDIA_EXPORT*/ #ifndef GPAC_DISABLE_SCENE_DUMP if (dump_mode != GF_SM_DUMP_NONE) { e = dump_isom_scene(inName, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_mode, do_scene_log, no_odf_conf); if (e) goto err_exit; } #endif #ifndef GPAC_DISABLE_SCENE_STATS if (stat_level) dump_isom_scene_stats(inName, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, stat_level); #endif #ifndef GPAC_DISABLE_ISOM_HINTING if (!HintIt && print_sdp) dump_isom_sdp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE); #endif if (get_nb_tracks) { fprintf(stdout, \"%d\\n\", gf_isom_get_track_count(file)); } if (print_info) { if (!file) { fprintf(stderr, \"Cannot print info on a non ISOM file (%s)\\n\", inName); } else { if (info_track_id) DumpTrackInfo(file, info_track_id, 1, (print_info==2) ? GF_TRUE : GF_FALSE); else DumpMovieInfo(file); } } #ifndef GPAC_DISABLE_ISOM_DUMP if (dump_isom) { e = dump_isom_xml(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, (dump_isom==2) ? GF_TRUE : GF_FALSE, merge_vtt_cues, use_init_seg ? GF_TRUE : GF_FALSE, (dump_isom==3) ? GF_TRUE : GF_FALSE); if (e) goto err_exit; } if (dump_cr) dump_isom_ismacryp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE); if ((dump_ttxt || dump_srt) && trackID) { if (trackID == (u32)-1) { for (j=0; jact_type != TRAC_ACTION_RAW_EXTRACT) continue; memset(&mdump, 0, sizeof(mdump)); mdump.file = file; mdump.flags = tka->dump_type; mdump.trackID = tka->trackID; mdump.sample_num = tka->sample_num; if (tka->out_name) { mdump.out_name = tka->out_name; } else if (outName) { mdump.out_name = outName; mdump.flags |= GF_EXPORT_MERGE; /*don't infer extension on user-given filename*/ mdump.flags |= GF_EXPORT_NO_FILE_EXT; } else if (mdump.trackID) { sprintf(szFile, \"%s_track%d\", outfile, mdump.trackID); mdump.out_name = szFile; } else { sprintf(szFile, \"%s_export\", outfile); mdump.out_name = szFile; } if (tka->trackID==(u32) -1) { for (j=0; jtrackID) tk = gf_isom_get_track_by_id(file, meta->trackID); switch (meta->act_type) { #ifndef GPAC_DISABLE_ISOM_WRITE case META_ACTION_SET_TYPE: /*note: we don't handle file brand modification, this is an author stuff and cannot be guessed from meta type*/ e = gf_isom_set_meta_type(file, meta->root_meta, tk, meta->meta_4cc); gf_isom_modify_alternate_brand(file, GF_ISOM_BRAND_ISO2, GF_TRUE); needSave = GF_TRUE; break; case META_ACTION_ADD_ITEM: self_ref = !stricmp(meta->szPath, \"NULL\") || !stricmp(meta->szPath, \"this\") || !stricmp(meta->szPath, \"self\"); e = gf_isom_add_meta_item(file, meta->root_meta, tk, self_ref, self_ref ? NULL : meta->szPath, meta->szName, meta->item_id, meta->item_type, meta->mime_type, meta->enc_type, meta->use_dref ? meta->szPath : NULL, NULL, meta->image_props); if (meta->ref_type) { e = gf_isom_meta_add_item_ref(file, meta->root_meta, tk, meta->item_id, meta->ref_item_id, meta->ref_type, NULL); } needSave = GF_TRUE; break; case META_ACTION_ADD_IMAGE_ITEM: { u32 old_tk_count = gf_isom_get_track_count(file); GF_Fraction _frac = {0,0}; e = import_file(file, meta->szPath, 0, _frac, 0, NULL, NULL, 0); if (e == GF_OK) { u32 meta_type = gf_isom_get_meta_type(file, meta->root_meta, tk); if (!meta_type) { e = gf_isom_set_meta_type(file, meta->root_meta, tk, GF_META_ITEM_TYPE_PICT); } else { if (meta_type != GF_META_ITEM_TYPE_PICT) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Warning: file already has a root 'meta' box of type %s\\n\", gf_4cc_to_str(meta_type))); e = GF_BAD_PARAM; } } if (e == GF_OK) { if (!meta->item_id) { e = gf_isom_meta_get_next_item_id(file, meta->root_meta, tk, &meta->item_id); } if (e == GF_OK) { e = gf_isom_iff_create_image_item_from_track(file, meta->root_meta, tk, 1, meta->szName, meta->item_id, meta->image_props, NULL); if (e == GF_OK && meta->primary) { e = gf_isom_set_meta_primary_item(file, meta->root_meta, tk, meta->item_id); } if (e == GF_OK && meta->ref_type) { e = gf_isom_meta_add_item_ref(file, meta->root_meta, tk, meta->item_id, meta->ref_item_id, meta->ref_type, NULL); } } } } gf_isom_remove_track(file, old_tk_count+1); needSave = GF_TRUE; } break; case META_ACTION_REM_ITEM: e = gf_isom_remove_meta_item(file, meta->root_meta, tk, meta->item_id); needSave = GF_TRUE; break; case META_ACTION_SET_PRIMARY_ITEM: e = gf_isom_set_meta_primary_item(file, meta->root_meta, tk, meta->item_id); needSave = GF_TRUE; break; case META_ACTION_SET_XML: case META_ACTION_SET_BINARY_XML: e = gf_isom_set_meta_xml(file, meta->root_meta, tk, meta->szPath, NULL, 0, (meta->act_type==META_ACTION_SET_BINARY_XML) ? 1 : 0); needSave = GF_TRUE; break; case META_ACTION_REM_XML: if (gf_isom_get_meta_item_count(file, meta->root_meta, tk)) { e = gf_isom_remove_meta_xml(file, meta->root_meta, tk); needSave = GF_TRUE; } else { fprintf(stderr, \"No meta box in input file\\n\"); } break; case META_ACTION_DUMP_ITEM: if (gf_isom_get_meta_item_count(file, meta->root_meta, tk)) { e = gf_isom_extract_meta_item(file, meta->root_meta, tk, meta->item_id, strlen(meta->szPath) ? meta->szPath : NULL); } else { fprintf(stderr, \"No meta box in input file\\n\"); } break; #endif // GPAC_DISABLE_ISOM_WRITE case META_ACTION_DUMP_XML: if (gf_isom_has_meta_xml(file, meta->root_meta, tk)) { e = gf_isom_extract_meta_xml(file, meta->root_meta, tk, meta->szPath, NULL); } else { fprintf(stderr, \"No meta box in input file\\n\"); } break; default: break; } if (meta->image_props) { gf_free(meta->image_props); meta->image_props = NULL; } if (e) goto err_exit; } if (!open_edit && !needSave) { if (file) gf_isom_delete(file); goto exit; } #ifndef GPAC_DISABLE_ISOM_WRITE if (clean_groups) { e = gf_isom_reset_switch_parameters(file); if (e) goto err_exit; needSave = GF_TRUE; } for (i=0; i0) { u32 tk, k; for (k=0; k<(u32) count; k++) { gf_isom_get_reference(file, j+1, GF_ISOM_REF_CHAP, k+1, &tk); if (tk==i+1) { is_chap = 1; break; } } if (is_chap) break; } if (is_chap) break; } /*this is a subtitle track*/ if (!is_chap) gf_isom_set_media_type(file, i+1, GF_ISOM_MEDIA_SUBT); } break; } } gf_isom_set_brand_info(file, ipod_major_brand, 1); gf_isom_modify_alternate_brand(file, GF_ISOM_BRAND_MP42, GF_TRUE); needSave = GF_TRUE; } } else if (outName) { strcpy(outfile, outName); } for (j=0; jtrackID ? gf_isom_get_track_by_id(file, tka->trackID) : 0; timescale = gf_isom_get_timescale(file); switch (tka->act_type) { case TRAC_ACTION_REM_TRACK: e = gf_isom_remove_track(file, track); if (e) { fprintf(stderr, \"Error Removing track ID %d: %s\\n\", tka->trackID, gf_error_to_string(e)); } else { fprintf(stderr, \"Removing track ID %d\\n\", tka->trackID); } needSave = GF_TRUE; break; case TRAC_ACTION_SET_LANGUAGE: for (i=0; ilang); if (e) goto err_exit; needSave = GF_TRUE; } needSave = GF_TRUE; break; case TRAC_ACTION_SET_KIND: for (i=0; ikind_scheme, tka->kind_value); if (e) goto err_exit; needSave = GF_TRUE; } needSave = GF_TRUE; break; case TRAC_ACTION_REM_KIND: for (i=0; ikind_scheme, tka->kind_value); if (e) goto err_exit; needSave = GF_TRUE; } needSave = GF_TRUE; break; case TRAC_ACTION_SET_DELAY: if (tka->delay_ms) { u64 tk_dur; gf_isom_remove_edits(file, track); tk_dur = gf_isom_get_track_duration(file, track); if (gf_isom_get_edits_count(file, track)) needSave = GF_TRUE; if (tka->delay_ms>0) { gf_isom_append_edit(file, track, (timescale*tka->delay_ms)/1000, 0, GF_ISOM_EDIT_EMPTY); gf_isom_append_edit(file, track, tk_dur, 0, GF_ISOM_EDIT_NORMAL); needSave = GF_TRUE; } else { u64 to_skip = (timescale*(-tka->delay_ms))/1000; if (to_skipdelay_ms)*gf_isom_get_media_timescale(file, track) / 1000; gf_isom_append_edit(file, track, tk_dur-to_skip, media_time, GF_ISOM_EDIT_NORMAL); needSave = GF_TRUE; } else { fprintf(stderr, \"Warning: request negative delay longer than track duration - ignoring\\n\"); } } } else if (gf_isom_get_edits_count(file, track)) { gf_isom_remove_edits(file, track); needSave = GF_TRUE; } break; case TRAC_ACTION_SET_KMS_URI: for (i=0; ikms); if (e) goto err_exit; needSave = GF_TRUE; } break; case TRAC_ACTION_SET_ID: if (!tka->trackID && (gf_isom_get_track_count(file) == 1)) { fprintf(stderr, \"Warning: track id is not specified, but file has only one track - assume that you want to change id for this track\\n\"); track = 1; } if (track) { u32 newTrack; newTrack = gf_isom_get_track_by_id(file, tka->newTrackID); if (newTrack != 0) { fprintf(stderr, \"Error: Cannot set track id with value %d because a track already exists - ignoring\", tka->newTrackID); } else { e = gf_isom_set_track_id(file, track, tka->newTrackID); needSave = GF_TRUE; } } else { fprintf(stderr, \"Error: Cannot change id for track %d because it does not exist - ignoring\", tka->trackID); } break; case TRAC_ACTION_SWAP_ID: if (track) { u32 tk1, tk2; tk1 = gf_isom_get_track_by_id(file, tka->trackID); tk2 = gf_isom_get_track_by_id(file, tka->newTrackID); if (!tk1 || !tk2) { fprintf(stderr, \"Error: Cannot swap track IDs because not existing - ignoring\"); } else { e = gf_isom_set_track_id(file, tk2, 0); if (!e) e = gf_isom_set_track_id(file, tk1, tka->newTrackID); if (!e) e = gf_isom_set_track_id(file, tk2, tka->trackID); needSave = GF_TRUE; } } else { fprintf(stderr, \"Error: Cannot change id for track %d because it does not exist - ignoring\", tka->trackID); } break; case TRAC_ACTION_SET_PAR: e = gf_media_change_par(file, track, tka->par_num, tka->par_den, tka->force_par, tka->rewrite_bs); needSave = GF_TRUE; break; case TRAC_ACTION_SET_CLAP: e = gf_isom_set_clean_aperture(file, track, 1, tka->clap_wnum, tka->clap_wden, tka->clap_hnum, tka->clap_hden, tka->clap_honum, tka->clap_hoden, tka->clap_vonum, tka->clap_voden); needSave = GF_TRUE; break; case TRAC_ACTION_SET_MX: e = gf_isom_set_track_matrix(file, track, tka->mx); needSave = GF_TRUE; break; case TRAC_ACTION_SET_HANDLER_NAME: e = gf_isom_set_handler_name(file, track, tka->hdl_name); needSave = GF_TRUE; break; case TRAC_ACTION_ENABLE: if (!gf_isom_is_track_enabled(file, track)) { e = gf_isom_set_track_enabled(file, track, GF_TRUE); needSave = GF_TRUE; } break; case TRAC_ACTION_DISABLE: if (gf_isom_is_track_enabled(file, track)) { e = gf_isom_set_track_enabled(file, track, GF_FALSE); needSave = GF_TRUE; } break; case TRAC_ACTION_REFERENCE: e = gf_isom_set_track_reference(file, track, GF_4CC(tka->lang[0], tka->lang[1], tka->lang[2], tka->lang[3]), (u32) tka->delay_ms); needSave = GF_TRUE; break; case TRAC_ACTION_REM_NON_RAP: fprintf(stderr, \"Removing non-rap samples from track %d\\n\", tka->trackID); e = gf_media_remove_non_rap(file, track, GF_FALSE); needSave = GF_TRUE; break; case TRAC_ACTION_REM_NON_REFS: fprintf(stderr, \"Removing non-reference samples from track %d\\n\", tka->trackID); e = gf_media_remove_non_rap(file, track, GF_TRUE); needSave = GF_TRUE; break; case TRAC_ACTION_SET_UDTA: fprintf(stderr, \"Assigning udta box\\n\"); e = set_file_udta(file, track, tka->udta_type, tka->src_name, tka->sample_num ? GF_TRUE : GF_FALSE); if (e) goto err_exit; needSave = GF_TRUE; break; default: break; } if (e) goto err_exit; } if (itunes_tags) { char *tags = itunes_tags; while (tags) { char *val; char *sep = gf_url_colon_suffix(tags); u32 tlen, itag = 0; if (sep) { while (sep) { for (itag=0; itag> 8; _t[5] = t; _t[4] = t >> 8; } else if (sscanf(val, \"%u\", &n) == 1) { _t[3] = n; _t[2] = n >> 8; } else tlen = 0; } if (!val || tlen) gf_isom_apple_set_tag(file, itag, val ? (u8 *)_t : NULL, tlen); } break; case GF_ISOM_ITUNE_GAPLESS: case GF_ISOM_ITUNE_COMPILATION: { u8 _t[1]; if (val && !stricmp(val, \"yes\")) _t[0] = 1; else _t[0] = 0; gf_isom_apple_set_tag(file, itag, _t, 1); } break; default: gf_isom_apple_set_tag(file, itag, (u8 *)val, tlen); break; } needSave = GF_TRUE; if (sep) { sep[0] = ':'; tags = sep+1; } else { tags = NULL; } } } if (movie_time) { gf_isom_set_creation_time(file, movie_time); for (i=0; idata, text->size); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409877, "input": "static int tcp_process_frto(struct sock *sk, int flag) { struct tcp_sock *tp = tcp_sk(sk); tcp_verify_left_out(tp); /* Duplicate the behavior from Loss state (fastretrans_alert) */ if (flag & FLAG_DATA_ACKED) inet_csk(sk)->icsk_retransmits = 0; if ((flag & FLAG_NONHEAD_RETRANS_ACKED) || ((tp->frto_counter >= 2) && (flag & FLAG_RETRANS_DATA_ACKED))) tp->undo_marker = 0; if (!before(tp->snd_una, tp->frto_highmark)) { tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 2 : 3), flag); return 1; } if (!tcp_is_sackfrto(tp)) { /* RFC4138 shortcoming in step 2; should also have case c): * ACK isn't duplicate nor advances window, e.g., opposite dir * data, winupdate */ if (!(flag & FLAG_ANY_PROGRESS) && (flag & FLAG_NOT_DUP)) return 1; if (!(flag & FLAG_DATA_ACKED)) { tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 0 : 3), flag); return 1; } } else { if (!(flag & FLAG_DATA_ACKED) && (tp->frto_counter == 1)) { /* Prevent sending of new data. */ tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)); return 1; } if ((tp->frto_counter >= 2) && (!(flag & FLAG_FORWARD_PROGRESS) || ((flag & FLAG_DATA_SACKED) && !(flag & FLAG_ONLY_ORIG_SACKED)))) { /* RFC4138 shortcoming (see comment above) */ if (!(flag & FLAG_FORWARD_PROGRESS) && (flag & FLAG_NOT_DUP)) return 1; tcp_enter_frto_loss(sk, 3, flag); return 1; } } if (tp->frto_counter == 1) { /* tcp_may_send_now needs to see updated state */ tp->snd_cwnd = tcp_packets_in_flight(tp) + 2; tp->frto_counter = 2; if (!tcp_may_send_now(sk)) tcp_enter_frto_loss(sk, 2, flag); return 1; } else { switch (sysctl_tcp_frto_response) { case 2: tcp_undo_spur_to_response(sk, flag); break; case 1: tcp_conservative_spur_to_response(tp); break; default: tcp_ratehalving_spur_to_response(sk); break; } tp->frto_counter = 0; tp->undo_marker = 0; NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSPURIOUSRTOS); } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 201788, "input": "unsigned long move_page_tables(struct vm_area_struct *vma, unsigned long old_addr, struct vm_area_struct *new_vma, unsigned long new_addr, unsigned long len, bool need_rmap_locks) { unsigned long extent, next, old_end; struct mmu_notifier_range range; pmd_t *old_pmd, *new_pmd; old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); mmu_notifier_range_init(&range, MMU_NOTIFY_UNMAP, 0, vma, vma->vm_mm, old_addr, old_end); mmu_notifier_invalidate_range_start(&range); for (; old_addr < old_end; old_addr += extent, new_addr += extent) { cond_resched(); next = (old_addr + PMD_SIZE) & PMD_MASK; /* even if next overflowed, extent below will be ok */ extent = next - old_addr; if (extent > old_end - old_addr) extent = old_end - old_addr; old_pmd = get_old_pmd(vma->vm_mm, old_addr); if (!old_pmd) continue; new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr); if (!new_pmd) break; if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) { if (extent == HPAGE_PMD_SIZE) { bool moved; /* See comment in move_ptes() */ if (need_rmap_locks) take_rmap_locks(vma); moved = move_huge_pmd(vma, old_addr, new_addr, old_end, old_pmd, new_pmd); if (need_rmap_locks) drop_rmap_locks(vma); if (moved) continue; } split_huge_pmd(vma, old_pmd, old_addr); if (pmd_trans_unstable(old_pmd)) continue; } else if (extent == PMD_SIZE) { #ifdef CONFIG_HAVE_MOVE_PMD /* * If the extent is PMD-sized, try to speed the move by * moving at the PMD level if possible. */ bool moved; if (need_rmap_locks) take_rmap_locks(vma); moved = move_normal_pmd(vma, old_addr, new_addr, old_end, old_pmd, new_pmd); if (need_rmap_locks) drop_rmap_locks(vma); if (moved) continue; #endif } if (pte_alloc(new_vma->vm_mm, new_pmd)) break; next = (new_addr + PMD_SIZE) & PMD_MASK; if (extent > next - new_addr) extent = next - new_addr; move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma, new_pmd, new_addr, need_rmap_locks); } mmu_notifier_invalidate_range_end(&range); return len + old_addr - old_end; /* how much done */ }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Restriction of Operations within the Bounds of a Memory Buffer"], "explanation": "A flaw was found in the Linux Kernel in versions after 4.5-rc1 in the way mremap handled DAX Huge Pages. This flaw allows a local attacker with access to a DAX enabled storage to escalate their privileges on the system.", "severity_level": "NoInfo", "cwe": "CWE-119", "cve": "CVE-2020-10757"}} -{"idx": 384512, "input": "int iwl_fw_dbg_error_collect(struct iwl_fw_runtime *fwrt, enum iwl_fw_dbg_trigger trig_type) { int ret; struct iwl_fw_dump_desc *iwl_dump_error_desc; if (!test_bit(STATUS_DEVICE_ENABLED, &fwrt->trans->status)) return -EIO; iwl_dump_error_desc = kmalloc(sizeof(*iwl_dump_error_desc), GFP_KERNEL); if (!iwl_dump_error_desc) return -ENOMEM; iwl_dump_error_desc->trig_desc.type = cpu_to_le32(trig_type); iwl_dump_error_desc->len = 0; ret = iwl_fw_dbg_collect_desc(fwrt, iwl_dump_error_desc, false, 0); if (ret) kfree(iwl_dump_error_desc); else iwl_trans_sync_nmi(fwrt->trans); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 223166, "input": "Status AttrValueHasType(const AttrValue& attr_value, StringPiece type) { int num_set = 0; #define VALIDATE_FIELD(name, type_string, oneof_case) \\ do { \\ if (attr_value.has_list()) { \\ if (attr_value.list().name##_size() > 0) { \\ if (type != \"list(\" type_string \")\") { \\ return errors::InvalidArgument( \\ \"AttrValue had value with type 'list(\" type_string \")' when '\", \\ type, \"' expected\"); \\ } \\ ++num_set; \\ } \\ } else if (attr_value.value_case() == AttrValue::oneof_case) { \\ if (type != type_string) { \\ return errors::InvalidArgument( \\ \"AttrValue had value with type '\" type_string \"' when '\", type, \\ \"' expected\"); \\ } \\ ++num_set; \\ } \\ } while (false) VALIDATE_FIELD(s, \"string\", kS); VALIDATE_FIELD(i, \"int\", kI); VALIDATE_FIELD(f, \"float\", kF); VALIDATE_FIELD(b, \"bool\", kB); VALIDATE_FIELD(type, \"type\", kType); VALIDATE_FIELD(shape, \"shape\", kShape); VALIDATE_FIELD(tensor, \"tensor\", kTensor); VALIDATE_FIELD(func, \"func\", kFunc); #undef VALIDATE_FIELD if (attr_value.value_case() == AttrValue::kPlaceholder) { return errors::InvalidArgument( \"AttrValue had value with unexpected type 'placeholder'\"); } // If the attr type is 'list', we expect attr_value.has_list() to be // true. However, proto3's attr_value.has_list() can be false when // set to an empty list for GraphDef versions <= 4. So we simply // check if has_list is false and some other field in attr_value is // set to flag the error. This test can be made more strict once // support for GraphDef versions <= 4 is dropped. if (absl::StartsWith(type, \"list(\") && !attr_value.has_list()) { if (num_set) { return errors::InvalidArgument( \"AttrValue missing value with expected type '\", type, \"'\"); } else { // Indicate that we have a list, but an empty one. ++num_set; } } // Okay to have an empty list, but not to be missing a non-list value. if (num_set == 0 && !absl::StartsWith(type, \"list(\")) { return errors::InvalidArgument( \"AttrValue missing value with expected type '\", type, \"'\"); } // Ref types and DT_INVALID are illegal, and DataTypes must // be a valid enum type. if (type == \"type\") { if (!DataType_IsValid(attr_value.type())) { return errors::InvalidArgument(\"AttrValue has invalid DataType enum: \", attr_value.type()); } if (IsRefType(attr_value.type())) { return errors::InvalidArgument( \"AttrValue must not have reference type value of \", DataTypeString(attr_value.type())); } if (attr_value.type() == DT_INVALID) { return errors::InvalidArgument(\"AttrValue has invalid DataType\"); } } else if (type == \"list(type)\") { for (auto as_int : attr_value.list().type()) { const DataType dtype = static_cast(as_int); if (!DataType_IsValid(dtype)) { return errors::InvalidArgument(\"AttrValue has invalid DataType enum: \", as_int); } if (IsRefType(dtype)) { return errors::InvalidArgument( \"AttrValue must not have reference type value of \", DataTypeString(dtype)); } if (dtype == DT_INVALID) { return errors::InvalidArgument(\"AttrValue contains invalid DataType\"); } } } return Status::OK(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432492, "input": "static void init_vmcb(struct vcpu_svm *svm) { struct vmcb_control_area *control = &svm->vmcb->control; struct vmcb_save_area *save = &svm->vmcb->save; svm->vcpu.arch.hflags = 0; set_cr_intercept(svm, INTERCEPT_CR0_READ); set_cr_intercept(svm, INTERCEPT_CR3_READ); set_cr_intercept(svm, INTERCEPT_CR4_READ); set_cr_intercept(svm, INTERCEPT_CR0_WRITE); set_cr_intercept(svm, INTERCEPT_CR3_WRITE); set_cr_intercept(svm, INTERCEPT_CR4_WRITE); if (!kvm_vcpu_apicv_active(&svm->vcpu)) set_cr_intercept(svm, INTERCEPT_CR8_WRITE); set_dr_intercepts(svm); set_exception_intercept(svm, PF_VECTOR); set_exception_intercept(svm, UD_VECTOR); set_exception_intercept(svm, MC_VECTOR); set_exception_intercept(svm, AC_VECTOR); set_exception_intercept(svm, DB_VECTOR); /* * Guest access to VMware backdoor ports could legitimately * trigger #GP because of TSS I/O permission bitmap. * We intercept those #GP and allow access to them anyway * as VMware does. */ if (enable_vmware_backdoor) set_exception_intercept(svm, GP_VECTOR); set_intercept(svm, INTERCEPT_INTR); set_intercept(svm, INTERCEPT_NMI); set_intercept(svm, INTERCEPT_SMI); set_intercept(svm, INTERCEPT_SELECTIVE_CR0); set_intercept(svm, INTERCEPT_RDPMC); set_intercept(svm, INTERCEPT_CPUID); set_intercept(svm, INTERCEPT_INVD); set_intercept(svm, INTERCEPT_INVLPG); set_intercept(svm, INTERCEPT_INVLPGA); set_intercept(svm, INTERCEPT_IOIO_PROT); set_intercept(svm, INTERCEPT_MSR_PROT); set_intercept(svm, INTERCEPT_TASK_SWITCH); set_intercept(svm, INTERCEPT_SHUTDOWN); set_intercept(svm, INTERCEPT_VMRUN); set_intercept(svm, INTERCEPT_VMMCALL); set_intercept(svm, INTERCEPT_VMLOAD); set_intercept(svm, INTERCEPT_VMSAVE); set_intercept(svm, INTERCEPT_STGI); set_intercept(svm, INTERCEPT_CLGI); set_intercept(svm, INTERCEPT_SKINIT); set_intercept(svm, INTERCEPT_WBINVD); set_intercept(svm, INTERCEPT_XSETBV); set_intercept(svm, INTERCEPT_RDPRU); set_intercept(svm, INTERCEPT_RSM); if (!kvm_mwait_in_guest(svm->vcpu.kvm)) { set_intercept(svm, INTERCEPT_MONITOR); set_intercept(svm, INTERCEPT_MWAIT); } if (!kvm_hlt_in_guest(svm->vcpu.kvm)) set_intercept(svm, INTERCEPT_HLT); control->iopm_base_pa = __sme_set(iopm_base); control->msrpm_base_pa = __sme_set(__pa(svm->msrpm)); control->int_ctl = V_INTR_MASKING_MASK; init_seg(&save->es); init_seg(&save->ss); init_seg(&save->ds); init_seg(&save->fs); init_seg(&save->gs); save->cs.selector = 0xf000; save->cs.base = 0xffff0000; /* Executable/Readable Code Segment */ save->cs.attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK; save->cs.limit = 0xffff; save->gdtr.limit = 0xffff; save->idtr.limit = 0xffff; init_sys_seg(&save->ldtr, SEG_TYPE_LDT); init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); svm_set_efer(&svm->vcpu, 0); save->dr6 = 0xffff0ff0; kvm_set_rflags(&svm->vcpu, 2); save->rip = 0x0000fff0; svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; /* * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0. * It also updates the guest-visible cr0 value. */ svm_set_cr0(&svm->vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); kvm_mmu_reset_context(&svm->vcpu); save->cr4 = X86_CR4_PAE; /* rdx = ?? */ if (npt_enabled) { /* Setup VMCB for Nested Paging */ control->nested_ctl |= SVM_NESTED_CTL_NP_ENABLE; clr_intercept(svm, INTERCEPT_INVLPG); clr_exception_intercept(svm, PF_VECTOR); clr_cr_intercept(svm, INTERCEPT_CR3_READ); clr_cr_intercept(svm, INTERCEPT_CR3_WRITE); save->g_pat = svm->vcpu.arch.pat; save->cr3 = 0; save->cr4 = 0; } svm->asid_generation = 0; svm->nested.vmcb = 0; svm->vcpu.arch.hflags = 0; if (pause_filter_count) { control->pause_filter_count = pause_filter_count; if (pause_filter_thresh) control->pause_filter_thresh = pause_filter_thresh; set_intercept(svm, INTERCEPT_PAUSE); } else { clr_intercept(svm, INTERCEPT_PAUSE); } if (kvm_vcpu_apicv_active(&svm->vcpu)) avic_init_vmcb(svm); /* * If hardware supports Virtual VMLOAD VMSAVE then enable it * in VMCB and clear intercepts to avoid #VMEXIT. */ if (vls) { clr_intercept(svm, INTERCEPT_VMLOAD); clr_intercept(svm, INTERCEPT_VMSAVE); svm->vmcb->control.virt_ext |= VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK; } if (vgif) { clr_intercept(svm, INTERCEPT_STGI); clr_intercept(svm, INTERCEPT_CLGI); svm->vmcb->control.int_ctl |= V_GIF_ENABLE_MASK; } if (sev_guest(svm->vcpu.kvm)) { svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ENABLE; clr_exception_intercept(svm, UD_VECTOR); } mark_all_dirty(svm->vmcb); enable_gif(svm); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246143, "input": "static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ Table *pTab; Expr *pExpr; assert( !p->pGroupBy ); if( p->pWhere || p->pEList->nExpr!=1 || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect ){ return 0; } pTab = p->pSrc->a[0].pTab; pExpr = p->pEList->a[0].pExpr; assert( pTab && !pTab->pSelect && pExpr ); if( IsVirtual(pTab) ) return 0; if( pExpr->op!=TK_AGG_FUNCTION ) return 0; if( NEVER(pAggInfo->nFunc==0) ) return 0; if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; return pTab; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 224817, "input": "static void pep_sock_close(struct sock *sk, long timeout) { struct pep_sock *pn = pep_sk(sk); int ifindex = 0; sock_hold(sk); /* keep a reference after sk_common_release() */ sk_common_release(sk); lock_sock(sk); if ((1 << sk->sk_state) & (TCPF_SYN_RECV|TCPF_ESTABLISHED)) { if (sk->sk_backlog_rcv == pipe_do_rcv) /* Forcefully remove dangling Phonet pipe */ pipe_do_remove(sk); else pipe_handler_request(sk, PNS_PEP_DISCONNECT_REQ, PAD, NULL, 0); } sk->sk_state = TCP_CLOSE; ifindex = pn->ifindex; pn->ifindex = 0; release_sock(sk); if (ifindex) gprs_detach(sk); sock_put(sk); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 410397, "input": "static int lookup_umount_fs_by_mountinfo(struct libmnt_context *cxt, const char *tgt) { struct libmnt_fs *fs = NULL; int rc; assert(cxt); assert(cxt->fs); DBG(CXT, ul_debugobj(cxt, \" lookup by mountinfo\")); /* search */ rc = __mtab_find_umount_fs(cxt, tgt, &fs); if (rc != 0) return rc; /* apply result */ if (fs != cxt->fs) { mnt_fs_set_source(cxt->fs, NULL); mnt_fs_set_target(cxt->fs, NULL); if (!mnt_copy_fs(cxt->fs, fs)) { DBG(CXT, ul_debugobj(cxt, \" failed to copy FS\")); return -errno; } DBG(CXT, ul_debugobj(cxt, \" mtab applied\")); } cxt->flags |= MNT_FL_TAB_APPLIED; return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 429712, "input": "ulong STDCALL mysql_get_client_version(void) { return MARIADB_VERSION_ID; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 221449, "input": "int mp4read_seek(int framenum) { if (framenum > mp4config.frame.ents) return ERR_FAIL; if (fseek(g_fin, mp4config.mdatofs + mp4config.frame.data[framenum], SEEK_SET)) return ERR_FAIL; mp4config.frame.current = framenum; return ERR_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 359166, "input": "void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final) { OPJ_UINT32 compno, resno, bandno, precno, cblkno; OPJ_INT32 value; /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */ OPJ_INT32 matrice[10][10][3]; OPJ_UINT32 i, j, k; opj_cp_t *cp = tcd->cp; opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles; opj_tcp_t *tcd_tcp = tcd->tcp; for (compno = 0; compno < tcd_tile->numcomps; compno++) { opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno]; for (i = 0; i < tcd_tcp->numlayers; i++) { for (j = 0; j < tilec->numresolutions; j++) { for (k = 0; k < 3; k++) { matrice[i][j][k] = (OPJ_INT32)((OPJ_FLOAT32)cp->m_specific_param.m_enc.m_matrice[i * tilec->numresolutions * 3 + j * 3 + k] * (OPJ_FLOAT32)(tcd->image->comps[compno].prec / 16.0)); } } } for (resno = 0; resno < tilec->numresolutions; resno++) { opj_tcd_resolution_t *res = &tilec->resolutions[resno]; for (bandno = 0; bandno < res->numbands; bandno++) { opj_tcd_band_t *band = &res->bands[bandno]; /* Skip empty bands */ if (opj_tcd_is_band_empty(band)) { continue; } for (precno = 0; precno < res->pw * res->ph; precno++) { opj_tcd_precinct_t *prc = &band->precincts[precno]; for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) { opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno]; opj_tcd_layer_t *layer = &cblk->layers[layno]; OPJ_UINT32 n; OPJ_INT32 imsb = (OPJ_INT32)(tcd->image->comps[compno].prec - cblk->numbps); /* number of bit-plan equal to zero */ /* Correction of the matrix of coefficient to include the IMSB information */ if (layno == 0) { value = matrice[layno][resno][bandno]; if (imsb >= value) { value = 0; } else { value -= imsb; } } else { value = matrice[layno][resno][bandno] - matrice[layno - 1][resno][bandno]; if (imsb >= matrice[layno - 1][resno][bandno]) { value -= (imsb - matrice[layno - 1][resno][bandno]); if (value < 0) { value = 0; } } } if (layno == 0) { cblk->numpassesinlayers = 0; } n = cblk->numpassesinlayers; if (cblk->numpassesinlayers == 0) { if (value != 0) { n = 3 * (OPJ_UINT32)value - 2 + cblk->numpassesinlayers; } else { n = cblk->numpassesinlayers; } } else { n = 3 * (OPJ_UINT32)value + cblk->numpassesinlayers; } layer->numpasses = n - cblk->numpassesinlayers; if (!layer->numpasses) { continue; } if (cblk->numpassesinlayers == 0) { layer->len = cblk->passes[n - 1].rate; layer->data = cblk->data; } else { layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate; layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate; } if (final) { cblk->numpassesinlayers = n; } } } } } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 490161, "input": "static int ecryptfs_read_headers_virt(char *page_virt, struct ecryptfs_crypt_stat *crypt_stat, struct dentry *ecryptfs_dentry, int validate_header_size) { int rc = 0; int offset; int bytes_read; ecryptfs_set_default_sizes(crypt_stat); crypt_stat->mount_crypt_stat = &ecryptfs_superblock_to_private( ecryptfs_dentry->d_sb)->mount_crypt_stat; offset = ECRYPTFS_FILE_SIZE_BYTES; rc = contains_ecryptfs_marker(page_virt + offset); if (rc == 0) { rc = -EINVAL; goto out; } offset += MAGIC_ECRYPTFS_MARKER_SIZE_BYTES; rc = ecryptfs_process_flags(crypt_stat, (page_virt + offset), &bytes_read); if (rc) { ecryptfs_printk(KERN_WARNING, \"Error processing flags\\n\"); goto out; } if (crypt_stat->file_version > ECRYPTFS_SUPPORTED_FILE_VERSION) { ecryptfs_printk(KERN_WARNING, \"File version is [%d]; only \" \"file version [%d] is supported by this \" \"version of eCryptfs\\n\", crypt_stat->file_version, ECRYPTFS_SUPPORTED_FILE_VERSION); rc = -EINVAL; goto out; } offset += bytes_read; if (crypt_stat->file_version >= 1) { rc = parse_header_metadata(crypt_stat, (page_virt + offset), &bytes_read, validate_header_size); if (rc) { ecryptfs_printk(KERN_WARNING, \"Error reading header \" \"metadata; rc = [%d]\\n\", rc); } offset += bytes_read; } else set_default_header_data(crypt_stat); rc = ecryptfs_parse_packet_set(crypt_stat, (page_virt + offset), ecryptfs_dentry); out: return rc; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416658, "input": "uint64_t php_mysqlnd_net_field_length_ll(zend_uchar **packet) { register zend_uchar *p= (zend_uchar *)*packet; if (*p < 251) { (*packet)++; return (uint64_t) *p; } switch (*p) { case 251: (*packet)++; return (uint64_t) MYSQLND_NULL_LENGTH; case 252: (*packet) += 3; return (uint64_t) uint2korr(p + 1); case 253: (*packet) += 4; return (uint64_t) uint3korr(p + 1); default: (*packet) += 9; return (uint64_t) uint8korr(p + 1); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445827, "input": "trace_process_export(struct trace_export *export, struct ring_buffer_event *event) { struct trace_entry *entry; unsigned int size = 0; entry = ring_buffer_event_data(event); size = ring_buffer_event_length(event); export->write(export, entry, size); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219642, "input": "bool operator()(const StringData *s1, const StringData *s2) const { return bstrcasecmp(s1->data(), s1->size(), s2->data(), s2->size()) < 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 378496, "input": "static int windowArgCount(Window *pWin){ ExprList *pList = pWin->pOwner->x.pList; return (pList ? pList->nExpr : 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 197987, "input": "inline size_t codepoint_length(const char *s8, size_t l) { if (l) { auto b = static_cast(s8[0]); if ((b & 0x80) == 0) { return 1; } else if ((b & 0xE0) == 0xC0) { return 2; } else if ((b & 0xF0) == 0xE0) { return 3; } else if ((b & 0xF8) == 0xF0) { return 4; } } return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "An issue was discovered in cpp-peglib through v0.1.12. peg::resolve_escape_sequence() in peglib.h has a heap-based buffer over-read.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-23915"}} -{"idx": 434143, "input": "int rdp_recv_autodetect_response_packet(rdpRdp* rdp, wStream* s) { AUTODETECT_RSP_PDU autodetectRspPdu; BOOL success = FALSE; if (Stream_GetRemainingLength(s) < 6) return -1; Stream_Read_UINT8(s, autodetectRspPdu.headerLength); /* headerLength (1 byte) */ Stream_Read_UINT8(s, autodetectRspPdu.headerTypeId); /* headerTypeId (1 byte) */ Stream_Read_UINT16(s, autodetectRspPdu.sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Read_UINT16(s, autodetectRspPdu.responseType); /* responseType (2 bytes) */ WLog_VRB(AUTODETECT_TAG, \"rdp_recv_autodetect_response_packet: headerLength=%\" PRIu8 \", headerTypeId=%\" PRIu8 \", sequenceNumber=%\" PRIu16 \", requestType=%04\" PRIx16 \"\", autodetectRspPdu.headerLength, autodetectRspPdu.headerTypeId, autodetectRspPdu.sequenceNumber, autodetectRspPdu.responseType); if (autodetectRspPdu.headerTypeId != TYPE_ID_AUTODETECT_RESPONSE) return -1; switch (autodetectRspPdu.responseType) { case RDP_RTT_RESPONSE_TYPE: /* RTT Measure Response (RDP_RTT_RESPONSE) - MS-RDPBCGR 2.2.14.2.1 */ success = autodetect_recv_rtt_measure_response(rdp, s, &autodetectRspPdu); break; case RDP_BW_RESULTS_RESPONSE_TYPE_CONNECTTIME: case RDP_BW_RESULTS_RESPONSE_TYPE_CONTINUOUS: /* Bandwidth Measure Results (RDP_BW_RESULTS) - MS-RDPBCGR 2.2.14.2.2 */ success = autodetect_recv_bandwidth_measure_results(rdp, s, &autodetectRspPdu); break; default: break; } return success ? 0 : -1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246195, "input": "static void havingToWhere(Parse *pParse, Select *p){ Walker sWalker; memset(&sWalker, 0, sizeof(sWalker)); sWalker.pParse = pParse; sWalker.xExprCallback = havingToWhereExprCb; sWalker.u.pSelect = p; sqlite3WalkExpr(&sWalker, p->pHaving); #if SELECTTRACE_ENABLED if( sWalker.eCode && (sqlite3SelectTrace & 0x100)!=0 ){ SELECTTRACE(0x100,pParse,p,(\"Move HAVING terms into WHERE:\\n\")); sqlite3TreeViewSelect(0, p, 0); } #endif }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 398306, "input": "static int mcba_net_get_berr_counter(const struct net_device *netdev, struct can_berr_counter *bec) { struct mcba_priv *priv = netdev_priv(netdev); bec->txerr = priv->bec.txerr; bec->rxerr = priv->bec.rxerr; return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 207859, "input": "int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req, unsigned long opt), unsigned long opt, u32 timeout, u8 *hci_status) { int ret; if (!test_bit(HCI_UP, &hdev->flags)) return -ENETDOWN; /* Serialize all requests */ hci_req_sync_lock(hdev); ret = __hci_req_sync(hdev, req, opt, timeout, hci_status); hci_req_sync_unlock(hdev); return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')"], "explanation": "net/bluetooth/hci_request.c in the Linux kernel through 5.12.2 has a race condition for removal of the HCI controller.", "severity_level": "NoInfo", "cwe": "CWE-362", "cve": "CVE-2021-32399"}} -{"idx": 230256, "input": "Object createObject(std::shared_ptr ho) { class DHO1 : public DecoratedHostObject { public: using DecoratedHostObject::DecoratedHostObject; Value get(Runtime& rt, const PropNameID& name) override { numGets++; return DecoratedHostObject::get(rt, name); } }; return Object::createFromHostObject( plain(), std::make_shared(*this, ho)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 325870, "input": "canonical_charset_name(const char *charset) { char cs[16]; char *p; const char *s; if (charset == NULL || charset[0] == '\\0' || strlen(charset) > 15) return (charset); /* Copy name to uppercase. */ p = cs; s = charset; while (*s) { char c = *s++; if (c >= 'a' && c <= 'z') c -= 'a' - 'A'; *p++ = c; } *p++ = '\\0'; if (strcmp(cs, \"UTF-8\") == 0 || strcmp(cs, \"UTF8\") == 0) return (\"UTF-8\"); if (strcmp(cs, \"UTF-16BE\") == 0 || strcmp(cs, \"UTF16BE\") == 0) return (\"UTF-16BE\"); if (strcmp(cs, \"UTF-16LE\") == 0 || strcmp(cs, \"UTF16LE\") == 0) return (\"UTF-16LE\"); if (strcmp(cs, \"CP932\") == 0) return (\"CP932\"); return (charset); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508526, "input": "join_read_prev(READ_RECORD *info) { int error; if (unlikely((error= info->table->file->ha_index_prev(info->record())))) return report_error(info->table, error); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 116227, "input": "void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance, ExceptionState& exceptionState) { if (!utterance) { exceptionState.throwTypeError(\"Invalid utterance argument\"); return; } m_utteranceQueue.append(utterance); if (m_utteranceQueue.size() == 1) startSpeakingImmediately(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 336902, "input": "rb_str_force_encoding(VALUE str, VALUE enc) { str_modifiable(str); rb_enc_associate(str, rb_to_encoding(enc)); ENC_CODERANGE_CLEAR(str); return str; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 353346, "input": "static void input_stop_autorepeat(struct input_dev *dev) { del_timer(&dev->timer); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445724, "input": "static int tracing_trace_options_open(struct inode *inode, struct file *file) { struct trace_array *tr = inode->i_private; int ret; if (tracing_disabled) return -ENODEV; if (trace_array_get(tr) < 0) return -ENODEV; ret = single_open(file, tracing_trace_options_show, inode->i_private); if (ret < 0) trace_array_put(tr); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354560, "input": "bool kvm_is_zone_device_pfn(kvm_pfn_t pfn) { /* * The metadata used by is_zone_device_page() to determine whether or * not a page is ZONE_DEVICE is guaranteed to be valid if and only if * the device has been pinned, e.g. by get_user_pages(). WARN if the * page_count() is zero to help detect bad usage of this helper. */ if (!pfn_valid(pfn) || WARN_ON_ONCE(!page_count(pfn_to_page(pfn)))) return false; return is_zone_device_page(pfn_to_page(pfn)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219199, "input": "static bool _php_image_output_ctx(const Resource& image, const String& filename, int quality, int basefilter, int image_type, char* /*tn*/, void (*func_p)()) { gdImagePtr im = get_valid_image_resource(image); if (!im) return false; req::ptr file; FILE *fp = nullptr; int q = quality, i; int f = basefilter; gdIOCtx *ctx; /* The third (quality) parameter for Wbmp stands for the threshold when called from image2wbmp(). The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called from imagey(). */ if (!filename.empty()) { file = php_open_plain_file(filename, \"wb\", &fp); if (!file) { raise_warning(\"Unable to open '%s' for writing\", filename.c_str()); return false; } ctx = gdNewFileCtx(fp); } else { ctx = (gdIOCtx *)IM_MALLOC(sizeof(gdIOCtx)); CHECK_ALLOC_R(ctx, sizeof(gdIOCtx), false); ctx->putC = _php_image_output_putc; ctx->putBuf = _php_image_output_putbuf; ctx->gd_free = _php_image_output_ctxfree; } switch(image_type) { case PHP_GDIMG_CONVERT_WBM: if (q<0||q>255) { raise_warning(\"Invalid threshold value '%d'. \" \"It must be between 0 and 255\", q); } case PHP_GDIMG_TYPE_JPG: ((void(*)(gdImagePtr, gdIOCtx *, int))(func_p))(im, ctx, q); break; case PHP_GDIMG_TYPE_PNG: ((void(*)(gdImagePtr, gdIOCtx *, int, int))(func_p))(im, ctx, q, f); break; case PHP_GDIMG_TYPE_WEBP: ((void(*)(gdImagePtr, gdIOCtx *, int64_t, int))(func_p))(im, ctx, q, f); break; case PHP_GDIMG_TYPE_XBM: case PHP_GDIMG_TYPE_WBM: if (q == -1) { // argc < 3 for(i=0; i < gdImageColorsTotal(im); i++) { if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) break; } q = i; } if (image_type == PHP_GDIMG_TYPE_XBM) { ((void(*)(gdImagePtr, char *, int, gdIOCtx *))(func_p)) (im, (char*)filename.c_str(), q, ctx); } else { ((void(*)(gdImagePtr, int, gdIOCtx *))(func_p))(im, q, ctx); } break; default: ((void(*)(gdImagePtr, gdIOCtx *))(func_p))(im, ctx); break; } ctx->gd_free(ctx); if (fp) { fflush(fp); file->close(); } return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 422578, "input": "TEST(GtOp, MatchesNull) { BSONObj operand = BSON(\"$gt\" << BSONNULL); GTMatchExpression gt(\"a\", operand[\"$gt\"]); ASSERT(!gt.matchesBSON(BSONObj(), NULL)); ASSERT(!gt.matchesBSON(BSON(\"a\" << BSONNULL), NULL)); ASSERT(!gt.matchesBSON(BSON(\"a\" << 4), NULL)); // A non-existent field is treated same way as an empty bson object ASSERT(!gt.matchesBSON(BSON(\"b\" << 4), NULL)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219086, "input": "bool HHVM_FUNCTION(imagecolordeallocate, const Resource& image, int64_t color) { gdImagePtr im = get_valid_image_resource(image); if (!im) return false; /* We can return right away for a truecolor image as deallocating colours is meaningless here */ if (gdImageTrueColor(im)) return true; if (color >= 0 && color < gdImageColorsTotal(im)) { gdImageColorDeallocate(im, color); return true; } else { raise_warning(\"Color index %\" PRId64 \" out of range\", color); return false; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 509168, "input": "virtual table_map all_used_tables() const { return used_tables(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 273244, "input": "void PushTargetUser(const User* targetuser) { if (targetuser->registered & REG_NICK) PushParamRef(targetuser->nick); else PushParam(\"*\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 451904, "input": "static int savemsg(message_data_t *m, FILE *f) { struct stat sbuf; const char **body, **groups; int r, i; time_t now = time(NULL); static int post_count = 0; FILE *stagef = NULL; const char *skipheaders[] = { \"Path\", /* need to prepend our servername */ \"Xref\", /* need to remove (generated on the fly) */ \"Reply-To\", /* need to add \"post\" email addresses */ NULL }; m->f = f; /* fill the cache */ r = spool_fill_hdrcache(nntp_in, f, m->hdrcache, skipheaders); if (r) { /* got a bad header */ /* flush the remaining output */ spool_copy_msg(nntp_in, NULL); return r; } /* now, using our header cache, fill in the data that we want */ /* get path */ if ((body = spool_getheader(m->hdrcache, \"path\")) != NULL) { /* prepend to the cached path */ m->path = strconcat(config_servername, \"!\", body[0], (char *)NULL); spool_replace_header(xstrdup(\"Path\"), xstrdup(m->path), m->hdrcache); } else { /* no path, create one */ m->path = strconcat(config_servername, \"!\", nntp_userid ? nntp_userid : \"anonymous\", (char *)NULL); spool_cache_header(xstrdup(\"Path\"), xstrdup(m->path), m->hdrcache); } fprintf(f, \"Path: %s\\r\\n\", m->path); /* get message-id */ if ((body = spool_getheader(m->hdrcache, \"message-id\")) != NULL) { m->id = xstrdup(body[0]); } else { /* no message-id, create one */ pid_t p = getpid(); m->id = xmalloc(40 + strlen(config_servername)); sprintf(m->id, \"\", p, (int) now, post_count++, config_servername); fprintf(f, \"Message-ID: %s\\r\\n\", m->id); spool_cache_header(xstrdup(\"Message-ID\"), xstrdup(m->id), m->hdrcache); } /* get date */ if ((body = spool_getheader(m->hdrcache, \"date\")) == NULL) { /* no date, create one */ char datestr[RFC822_DATETIME_MAX+1]; time_to_rfc822(now, datestr, sizeof(datestr)); m->date = xstrdup(datestr); fprintf(f, \"Date: %s\\r\\n\", datestr); spool_cache_header(xstrdup(\"Date\"), xstrdup(datestr), m->hdrcache); } else { m->date = xstrdup(body[0]); } /* get control */ if ((body = spool_getheader(m->hdrcache, \"control\")) != NULL) { size_t len; char *s; m->control = xstrdup(body[0]); /* create a recipient for the appropriate pseudo newsgroup */ len = strcspn(m->control, \" \\t\\r\\n\"); s = xmalloc(strlen(newsprefix) + 8 + len + 1); sprintf(s, \"%scontrol.%.*s\", newsprefix, (int) len, m->control); strarray_appendm(&m->rcpt, s); } else { m->control = NULL; /* no control */ /* get newsgroups */ if ((groups = spool_getheader(m->hdrcache, \"newsgroups\")) != NULL) { /* parse newsgroups and create recipients */ parse_groups(groups[0], m); if (!m->rcpt.count) { r = IMAP_MAILBOX_NONEXISTENT; /* no newsgroups that we serve */ } if (!r) { const char *newspostuser = config_getstring(IMAPOPT_NEWSPOSTUSER); /* get reply-to */ body = spool_getheader(m->hdrcache, \"reply-to\"); /* add Reply-To: header */ if (body || newspostuser) { const char **postto, *p; int fold = 0; const char *sep = \"\"; char *replyto; size_t n; struct buf buf = BUF_INITIALIZER; if (newspostuser) { /* add \"post\" email addresses based on newsgroup */ /* determine which groups header to use */ postto = spool_getheader(m->hdrcache, \"followup-to\"); if (!postto) postto = groups; if (body) { /* append to the cached header */ buf_appendcstr(&buf, body[0]); fold = buf.len+1; sep = \", \"; } for (p = postto[0];; p += n) { /* skip whitespace */ while (p && *p && (Uisspace(*p) || *p == ',')) p++; if (!p || !*p) break; /* find end of group name */ n = strcspn(p, \", \\t\"); /* add the post address */ buf_printf(&buf, \"%s%s+%.*s\", sep, newspostuser, (int) n, p); sep = \", \"; } replyto = buf_release(&buf); if (body) { /* replace the existing header */ spool_replace_header(xstrdup(\"Reply-To\"), replyto, m->hdrcache); } else { /* add the new header to the cache */ spool_cache_header(xstrdup(\"Reply-To\"), replyto, m->hdrcache); } } else { /* no newspostuser, use original replyto */ replyto = (char *) body[0]; } /* add the header to the file */ fprintf(f, \"Reply-To: \"); if (fold) fprintf(f, \"%.*s\\r\\n\\t\", fold, replyto); fprintf(f, \"%s\\r\\n\", replyto+fold); } } } else { r = NNTP_NO_NEWSGROUPS; /* no newsgroups header */ } if (r) { /* error getting newsgroups */ /* flush the remaining output */ spool_copy_msg(nntp_in, NULL); return r; } } fflush(f); if (ferror(f)) { return IMAP_IOERROR; } if (fstat(fileno(f), &sbuf) == -1) { return IMAP_IOERROR; } /* spool to the stage of one of the recipients */ for (i = 0; !stagef && (i < m->rcpt.count); i++) { stagef = append_newstage(m->rcpt.data[i], now, 0, &stage); } if (stagef) { const char *base = 0; unsigned long size = 0; int n; /* copy the header from our tmpfile to the stage */ map_refresh(fileno(f), 1, &base, &size, sbuf.st_size, \"tmp\", 0); n = retry_write(fileno(stagef), base, size); map_free(&base, &size); if (n == -1) { /* close and remove the stage */ fclose(stagef); append_removestage(stage); stage = NULL; return IMAP_IOERROR; } else { /* close the tmpfile and use the stage */ fclose(f); m->f = f = stagef; } } /* else this is probably a remote group, so use the tmpfile */ r = spool_copy_msg(nntp_in, f); if (r) return r; fflush(f); if (ferror(f)) { return IMAP_IOERROR; } if (fstat(fileno(f), &sbuf) == -1) { return IMAP_IOERROR; } m->size = sbuf.st_size; m->data = prot_new(fileno(f), 0); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232395, "input": "explicit QuantizedResizeBilinearOp(OpKernelConstruction* context) : OpKernel(context) { OP_REQUIRES_OK(context, context->GetAttr(\"align_corners\", &align_corners_)); OP_REQUIRES_OK( context, context->GetAttr(\"half_pixel_centers\", &half_pixel_centers_)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 255024, "input": "int ConvBackpropDimensions::SpatialPadding(const Padding& padding, int dim) const { return (padding == VALID) ? 0 : std::max( 0, static_cast((output_size(dim) - 1) * stride(dim) + (filter_size(dim) - 1) * dilation(dim) + 1 - input_size(dim))); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 209807, "input": "filter_session_io(struct io *io, int evt, void *arg) { struct filter_session *fs = arg; char *line = NULL; ssize_t len; log_trace(TRACE_IO, \"filter session: %p: %s %s\", fs, io_strevent(evt), io_strio(io)); switch (evt) { case IO_DATAIN: nextline: line = io_getline(fs->io, &len); /* No complete line received */ if (line == NULL) return; filter_data(fs->id, line); goto nextline; case IO_DISCONNECTED: io_free(fs->io); fs->io = NULL; break; } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "smtpd/lka_filter.c in OpenSMTPD before 6.8.0p1, in certain configurations, allows remote attackers to cause a denial of service (NULL pointer dereference and daemon crash) via a crafted pattern of client activity, because the filter state machine does not properly maintain the I/O channel between the SMTP engine and the filters layer.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2020-35680"}} -{"idx": 223142, "input": "void MoveAttrValue(std::vector&& value, AttrValue* out) { out->mutable_list()->Clear(); // Create list() even if value empty. for (auto& v : value) { out->mutable_list()->add_s(std::move(v)); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393618, "input": "hmfcb(void *clientp, const char *msg, const char *url) { CbData *data = clientp; if (data->hmfcb) return data->hmfcb(data->userdata, msg, url, data->metadata); return LR_CB_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 376779, "input": "static avifBool avifParsePixelInformationProperty(avifProperty * prop, const uint8_t * raw, size_t rawLen) { BEGIN_STREAM(s, raw, rawLen); CHECK(avifROStreamReadAndEnforceVersion(&s, 0)); avifPixelInformationProperty * pixi = &prop->u.pixi; CHECK(avifROStreamRead(&s, &pixi->planeCount, 1)); // unsigned int (8) num_channels; if (pixi->planeCount > MAX_PIXI_PLANE_DEPTHS) { return AVIF_FALSE; } for (uint8_t i = 0; i < pixi->planeCount; ++i) { CHECK(avifROStreamRead(&s, &pixi->planeDepths[i], 1)); // unsigned int (8) bits_per_channel; } return AVIF_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 462443, "input": "static void dw_spi_debugfs_remove(struct dw_spi *dws) { debugfs_remove_recursive(dws->debugfs); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 505391, "input": "static void patch_fn(struct cgit_context *ctx) { cgit_print_patch(ctx->qry.sha1); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280062, "input": "static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, void *obj) { if (unlikely(slab_want_init_on_free(s)) && obj) memset((void *)((char *)obj + s->offset), 0, sizeof(void *)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445585, "input": "static void __update_tracer_options(struct trace_array *tr) { struct tracer *t; for (t = trace_types; t; t = t->next) add_tracer_options(tr, t); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431524, "input": "nfs4_opendata_get_inode(struct nfs4_opendata *data) { struct inode *inode; switch (data->o_arg.claim) { case NFS4_OPEN_CLAIM_NULL: case NFS4_OPEN_CLAIM_DELEGATE_CUR: case NFS4_OPEN_CLAIM_DELEGATE_PREV: if (!(data->f_attr.valid & NFS_ATTR_FATTR)) return ERR_PTR(-EAGAIN); inode = nfs_fhget(data->dir->d_sb, &data->o_res.fh, &data->f_attr, data->f_label); break; default: inode = d_inode(data->dentry); ihold(inode); nfs_refresh_inode(inode, &data->f_attr); } return inode; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381978, "input": "int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser) { CServer *pThis = (CServer *)pUser; char aAddrStr[NETADDR_MAXSTRSIZE]; net_addr_str(pThis->m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true); char aBuf[256]; str_format(aBuf, sizeof(aBuf), \"client dropped. cid=%d addr=%s reason='%s'\", ClientID, aAddrStr, pReason); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, \"server\", aBuf); // notify the mod about the drop if(pThis->m_aClients[ClientID].m_State >= CClient::STATE_READY) { pThis->m_aClients[ClientID].m_Quitting = true; pThis->GameServer()->OnClientDrop(ClientID, pReason); } pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY; pThis->m_aClients[ClientID].m_aName[0] = 0; pThis->m_aClients[ClientID].m_aClan[0] = 0; pThis->m_aClients[ClientID].m_Country = -1; pThis->m_aClients[ClientID].m_Authed = AUTHED_NO; pThis->m_aClients[ClientID].m_AuthTries = 0; pThis->m_aClients[ClientID].m_pRconCmdToSend = 0; pThis->m_aClients[ClientID].m_pMapListEntryToSend = 0; pThis->m_aClients[ClientID].m_NoRconNote = false; pThis->m_aClients[ClientID].m_Quitting = false; pThis->m_aClients[ClientID].m_Snapshots.PurgeAll(); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 399280, "input": "int imap_adata_find(const char *path, struct ImapAccountData **adata, struct ImapMboxData **mdata) { struct ConnAccount cac = { { 0 } }; struct ImapAccountData *tmp_adata = NULL; char tmp[1024]; if (imap_parse_path(path, &cac, tmp, sizeof(tmp)) < 0) return -1; struct Account *np = NULL; TAILQ_FOREACH(np, &NeoMutt->accounts, entries) { if (np->type != MUTT_IMAP) continue; tmp_adata = np->adata; if (!tmp_adata) continue; if (imap_account_match(&tmp_adata->conn->account, &cac)) { *mdata = imap_mdata_new(tmp_adata, tmp); *adata = tmp_adata; return 0; } } mutt_debug(LL_DEBUG3, \"no ImapAccountData found\\n\"); return -1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417851, "input": "static struct ttf_table *SFDGetTtfTable(FILE *sfd, SplineFont *sf,struct ttf_table *lasttab[2]) { /* We've read the TtfTable token, it is followed by a tag and a byte count */ /* and then the instructions in enc85 format */ int i,len; int which; struct enc85 dec; struct ttf_table *tab = chunkalloc(sizeof(struct ttf_table)); memset(&dec,'\\0', sizeof(dec)); dec.pos = -1; dec.sfd = sfd; tab->tag = gettag(sfd); if ( tab->tag==CHR('f','p','g','m') || tab->tag==CHR('p','r','e','p') || tab->tag==CHR('c','v','t',' ') || tab->tag==CHR('m','a','x','p')) which = 0; else which = 1; getint(sfd,&len); tab->data = malloc(len); tab->len = len; for ( i=0; idata[i] = Dec85(&dec); if ( lasttab[which]!=NULL ) lasttab[which]->next = tab; else if ( which==0 ) sf->ttf_tables = tab; else sf->ttf_tab_saved = tab; lasttab[which] = tab; return( tab ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432462, "input": "static void svm_sync_dirty_debug_regs(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); get_debugreg(vcpu->arch.db[0], 0); get_debugreg(vcpu->arch.db[1], 1); get_debugreg(vcpu->arch.db[2], 2); get_debugreg(vcpu->arch.db[3], 3); vcpu->arch.dr6 = svm_get_dr6(vcpu); vcpu->arch.dr7 = svm->vmcb->save.dr7; vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_WONT_EXIT; set_dr_intercepts(svm); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 197477, "input": "export_desktop_file (const char *app, const char *branch, const char *arch, GKeyFile *metadata, const char * const *previous_ids, int parent_fd, const char *name, struct stat *stat_buf, char **target, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; glnx_autofd int desktop_fd = -1; g_autofree char *tmpfile_name = g_strdup_printf (\"export-desktop-XXXXXX\"); g_autoptr(GOutputStream) out_stream = NULL; g_autofree gchar *data = NULL; gsize data_len; g_autofree gchar *new_data = NULL; gsize new_data_len; g_autoptr(GKeyFile) keyfile = NULL; g_autofree gchar *old_exec = NULL; gint old_argc; g_auto(GStrv) old_argv = NULL; g_auto(GStrv) groups = NULL; GString *new_exec = NULL; g_autofree char *escaped_app = maybe_quote (app); g_autofree char *escaped_branch = maybe_quote (branch); g_autofree char *escaped_arch = maybe_quote (arch); int i; if (!flatpak_openat_noatime (parent_fd, name, &desktop_fd, cancellable, error)) goto out; if (!read_fd (desktop_fd, stat_buf, &data, &data_len, error)) goto out; keyfile = g_key_file_new (); if (!g_key_file_load_from_data (keyfile, data, data_len, G_KEY_FILE_KEEP_TRANSLATIONS, error)) goto out; if (g_str_has_suffix (name, \".service\")) { g_autofree gchar *dbus_name = NULL; g_autofree gchar *expected_dbus_name = g_strndup (name, strlen (name) - strlen (\".service\")); dbus_name = g_key_file_get_string (keyfile, \"D-BUS Service\", \"Name\", NULL); if (dbus_name == NULL || strcmp (dbus_name, expected_dbus_name) != 0) { return flatpak_fail_error (error, FLATPAK_ERROR_EXPORT_FAILED, _(\"D-Bus service file '%s' has wrong name\"), name); } } if (g_str_has_suffix (name, \".desktop\")) { gsize length; g_auto(GStrv) tags = g_key_file_get_string_list (metadata, \"Application\", \"tags\", &length, NULL); if (tags != NULL) { g_key_file_set_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP, \"X-Flatpak-Tags\", (const char * const *) tags, length); } /* Add a marker so consumers can easily find out that this launches a sandbox */ g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, \"X-Flatpak\", app); /* If the app has been renamed, add its old .desktop filename to * X-Flatpak-RenamedFrom in the new .desktop file, taking care not to * introduce duplicates. */ if (previous_ids != NULL) { const char *X_FLATPAK_RENAMED_FROM = \"X-Flatpak-RenamedFrom\"; g_auto(GStrv) renamed_from = g_key_file_get_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP, X_FLATPAK_RENAMED_FROM, NULL, NULL); g_autoptr(GPtrArray) merged = g_ptr_array_new_with_free_func (g_free); g_autoptr(GHashTable) seen = g_hash_table_new (g_str_hash, g_str_equal); const char *new_suffix; for (i = 0; renamed_from != NULL && renamed_from[i] != NULL; i++) { if (!g_hash_table_contains (seen, renamed_from[i])) { gchar *copy = g_strdup (renamed_from[i]); g_hash_table_insert (seen, copy, copy); g_ptr_array_add (merged, g_steal_pointer (©)); } } /* If an app was renamed from com.example.Foo to net.example.Bar, and * the new version exports net.example.Bar-suffix.desktop, we assume the * old version exported com.example.Foo-suffix.desktop. * * This assertion is true because * flatpak_name_matches_one_wildcard_prefix() is called on all * exported files before we get here. */ g_assert (g_str_has_prefix (name, app)); /* \".desktop\" for the \"main\" desktop file; something like * \"-suffix.desktop\" for extra ones. */ new_suffix = name + strlen (app); for (i = 0; previous_ids[i] != NULL; i++) { g_autofree gchar *previous_desktop = g_strconcat (previous_ids[i], new_suffix, NULL); if (!g_hash_table_contains (seen, previous_desktop)) { g_hash_table_insert (seen, previous_desktop, previous_desktop); g_ptr_array_add (merged, g_steal_pointer (&previous_desktop)); } } if (merged->len > 0) { g_ptr_array_add (merged, NULL); g_key_file_set_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP, X_FLATPAK_RENAMED_FROM, (const char * const *) merged->pdata, merged->len - 1); } } } groups = g_key_file_get_groups (keyfile, NULL); for (i = 0; groups[i] != NULL; i++) { g_auto(GStrv) flatpak_run_opts = g_key_file_get_string_list (keyfile, groups[i], \"X-Flatpak-RunOptions\", NULL, NULL); g_autofree char *flatpak_run_args = format_flatpak_run_args_from_run_opts (flatpak_run_opts); g_key_file_remove_key (keyfile, groups[i], \"X-Flatpak-RunOptions\", NULL); g_key_file_remove_key (keyfile, groups[i], \"TryExec\", NULL); /* Remove this to make sure nothing tries to execute it outside the sandbox*/ g_key_file_remove_key (keyfile, groups[i], \"X-GNOME-Bugzilla-ExtraInfoScript\", NULL); new_exec = g_string_new (\"\"); g_string_append_printf (new_exec, FLATPAK_BINDIR \"/flatpak run --branch=%s --arch=%s\", escaped_branch, escaped_arch); if (flatpak_run_args != NULL) g_string_append_printf (new_exec, \"%s\", flatpak_run_args); old_exec = g_key_file_get_string (keyfile, groups[i], \"Exec\", NULL); if (old_exec && g_shell_parse_argv (old_exec, &old_argc, &old_argv, NULL) && old_argc >= 1) { int j; g_autofree char *command = maybe_quote (old_argv[0]); g_string_append_printf (new_exec, \" --command=%s\", command); for (j = 1; j < old_argc; j++) { if (strcasecmp (old_argv[j], \"%f\") == 0 || strcasecmp (old_argv[j], \"%u\") == 0) { g_string_append (new_exec, \" --file-forwarding\"); break; } } g_string_append (new_exec, \" \"); g_string_append (new_exec, escaped_app); for (j = 1; j < old_argc; j++) { g_autofree char *arg = maybe_quote (old_argv[j]); if (strcasecmp (arg, \"%f\") == 0) g_string_append_printf (new_exec, \" @@ %s @@\", arg); else if (strcasecmp (arg, \"%u\") == 0) g_string_append_printf (new_exec, \" @@u %s @@\", arg); else if (strcmp (arg, \"@@\") == 0 || strcmp (arg, \"@@u\") == 0) g_print (_(\"Skipping invalid Exec argument %s\\n\"), arg); else g_string_append_printf (new_exec, \" %s\", arg); } } else { g_string_append (new_exec, \" \"); g_string_append (new_exec, escaped_app); } g_key_file_set_string (keyfile, groups[i], G_KEY_FILE_DESKTOP_KEY_EXEC, new_exec->str); } new_data = g_key_file_to_data (keyfile, &new_data_len, error); if (new_data == NULL) goto out; if (!flatpak_open_in_tmpdir_at (parent_fd, 0755, tmpfile_name, &out_stream, cancellable, error)) goto out; if (!g_output_stream_write_all (out_stream, new_data, new_data_len, NULL, cancellable, error)) goto out; if (!g_output_stream_close (out_stream, cancellable, error)) goto out; if (target) *target = g_steal_pointer (&tmpfile_name); ret = TRUE; out: if (new_exec != NULL) g_string_free (new_exec, TRUE); return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Control of Generation of Code ('Code Injection')"], "explanation": "Flatpak is a system for building, distributing, and running sandboxed desktop applications on Linux. In Flatpack since version 0.9.4 and before version 1.10.2 has a vulnerability in the \"file forwarding\" feature which can be used by an attacker to gain access to files that would not ordinarily be allowed by the app's permissions. By putting the special tokens `@@` and/or `@@u` in the Exec field of a Flatpak app's .desktop file, a malicious app publisher can trick flatpak into behaving as though the user had chosen to open a target file with their Flatpak app, which automatically makes that file available to the Flatpak app. This is fixed in version 1.10.2. A minimal solution is the first commit \"`Disallow @@ and @@U usage in desktop files`\". The follow-up commits \"`dir: Reserve the whole @@ prefix`\" and \"`dir: Refuse to export .desktop files with suspicious uses of @@ tokens`\" are recommended, but not strictly required. As a workaround, avoid installing Flatpak apps from untrusted sources, or check the contents of the exported `.desktop` files in `exports/share/applications/*.desktop` (typically `~/.local/share/flatpak/exports/share/applications/*.desktop` and `/var/lib/flatpak/exports/share/applications/*.desktop`) to make sure that literal filenames do not follow `@@` or `@@u`.", "severity_level": "NoInfo", "cwe": "CWE-94", "cve": "CVE-2021-21381"}} -{"idx": 204491, "input": "static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, char *name) { XImage *xim; static int reported_flip = 0; int db = 0; shm->shmid = -1; shm->shmaddr = (char *) -1; *ximg_ptr = NULL; if (nofb) { return 1; } X_LOCK; if (! using_shm || xform24to32 || raw_fb) { /* we only need the XImage created */ xim = XCreateImage_wr(dpy, default_visual, depth, ZPixmap, 0, NULL, w, h, raw_fb ? 32 : BitmapPad(dpy), 0); X_UNLOCK; if (xim == NULL) { rfbErr(\"XCreateImage(%s) failed.\\n\", name); if (quiet) { fprintf(stderr, \"XCreateImage(%s) failed.\\n\", name); } return 0; } if (db) fprintf(stderr, \"shm_create simple %d %d\\t%p %s\\n\", w, h, (void *)xim, name); xim->data = (char *) malloc(xim->bytes_per_line * xim->height); if (xim->data == NULL) { rfbErr(\"XCreateImage(%s) data malloc failed.\\n\", name); if (quiet) { fprintf(stderr, \"XCreateImage(%s) data malloc\" \" failed.\\n\", name); } return 0; } if (flip_byte_order) { char *order = flip_ximage_byte_order(xim); if (! reported_flip && ! quiet) { rfbLog(\"Changing XImage byte order\" \" to %s\\n\", order); reported_flip = 1; } } *ximg_ptr = xim; return 1; } if (! dpy) { X_UNLOCK; return 0; } xim = XShmCreateImage_wr(dpy, default_visual, depth, ZPixmap, NULL, shm, w, h); if (xim == NULL) { rfbErr(\"XShmCreateImage(%s) failed.\\n\", name); if (quiet) { fprintf(stderr, \"XShmCreateImage(%s) failed.\\n\", name); } X_UNLOCK; return 0; } *ximg_ptr = xim; #if HAVE_XSHM shm->shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height, IPC_CREAT | 0777); if (shm->shmid == -1) { rfbErr(\"shmget(%s) failed.\\n\", name); rfbLogPerror(\"shmget\"); XDestroyImage(xim); *ximg_ptr = NULL; X_UNLOCK; return 0; } shm->shmaddr = xim->data = (char *) shmat(shm->shmid, 0, 0); if (shm->shmaddr == (char *)-1) { rfbErr(\"shmat(%s) failed.\\n\", name); rfbLogPerror(\"shmat\"); XDestroyImage(xim); *ximg_ptr = NULL; shmctl(shm->shmid, IPC_RMID, 0); shm->shmid = -1; X_UNLOCK; return 0; } shm->readOnly = False; if (! XShmAttach_wr(dpy, shm)) { rfbErr(\"XShmAttach(%s) failed.\\n\", name); XDestroyImage(xim); *ximg_ptr = NULL; shmdt(shm->shmaddr); shm->shmaddr = (char *) -1; shmctl(shm->shmid, IPC_RMID, 0); shm->shmid = -1; X_UNLOCK; return 0; } #endif X_UNLOCK; return 1; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Access Control"], "explanation": "scan.c in x11vnc 0.9.16 uses IPC_CREAT|0777 in shmget calls, which allows access by actors other than the current user.", "severity_level": "NoInfo", "cwe": "CWE-284", "cve": "CVE-2020-29074"}} -{"idx": 281530, "input": "static void lrc_destroy_wa_ctx(struct intel_engine_cs *engine) { i915_vma_unpin_and_release(&engine->wa_ctx.vma, 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219321, "input": "Variant HHVM_FUNCTION(socket_select, Variant& read, Variant& write, Variant& except, const Variant& vtv_sec, int tv_usec /* = 0 */) { int count = 0; if (!read.isNull()) { if (!read.isArray()) { raise_warning(\"socket_select() expects parameter 1 to be array()\"); return init_null(); } count += read.asCArrRef().size(); } if (!write.isNull()) { if (!write.isArray()) { raise_warning(\"socket_select() expects parameter 2 to be array()\"); return init_null(); } count += write.asCArrRef().size(); } if (!except.isNull()) { if (!except.isArray()) { raise_warning(\"socket_select() expects parameter 3 to be array()\"); return init_null(); } count += except.asCArrRef().size(); } if (!count) { return false; } std::vector fds; fds.reserve(count); if (!read.isNull()) { sock_array_to_fd_set(read.asCArrRef(), fds, POLLIN); } if (!write.isNull()) { sock_array_to_fd_set(write.asCArrRef(), fds, POLLOUT); } if (!except.isNull()) { sock_array_to_fd_set(except.asCArrRef(), fds, POLLPRI); } if (fds.empty()) { raise_warning(\"no resource arrays were passed to select\"); return false; } IOStatusHelper io(\"socket_select\"); int timeout_ms = -1; if (!vtv_sec.isNull()) { timeout_ms = vtv_sec.toInt32() * 1000 + tv_usec / 1000; } /* slight hack to support buffered data; if there is data sitting in the * read buffer of any of the streams in the read array, let's pretend * that we selected, but return only the readable sockets */ if (!read.isNull()) { // sock_array_from_fd_set can set a sparsely indexed array, so // we use darray everywhere. auto hasData = Array::CreateDArray(); IterateVNoInc( read.asCArrRef().get(), [&](TypedValue v) { assertx(v.m_type == KindOfResource); auto file = static_cast(v.m_data.pres->data()); if (file->bufferedLen() > 0) { hasData.append(v); } } ); if (hasData.size() > 0) { write = empty_darray(); except = empty_darray(); read = hasData; return hasData.size(); } } int retval = poll(fds.data(), fds.size(), timeout_ms); if (retval == -1) { raise_warning(\"unable to select [%d]: %s\", errno, folly::errnoStr(errno).c_str()); return false; } count = 0; int nfds = 0; if (!read.isNull()) { sock_array_from_fd_set(read, fds, nfds, count, POLLIN|POLLERR|POLLHUP); } if (!write.isNull()) { sock_array_from_fd_set(write, fds, nfds, count, POLLOUT|POLLERR); } if (!except.isNull()) { sock_array_from_fd_set(except, fds, nfds, count, POLLPRI|POLLERR); } return count; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416786, "input": "static void cil_reset_classpermissionset(struct cil_classpermissionset *cps) { cil_reset_classperms_list(cps->classperms); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416766, "input": "static void cil_reset_user(struct cil_user *user) { /* reset the bounds to NULL during a re-resolve */ user->bounds = NULL; user->dftlevel = NULL; user->range = NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 195985, "input": "static GF_Err av1dmx_parse_flush_sample(GF_Filter *filter, GF_AV1DmxCtx *ctx) { u32 pck_size; GF_FilterPacket *pck; u8 *output; gf_bs_get_content_no_truncate(ctx->state.bs, &ctx->state.frame_obus, &pck_size, &ctx->state.frame_obus_alloc); if (!pck_size) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[AV1Dmx] no frame OBU, skipping OBU\\n\")); return GF_OK; } pck = gf_filter_pck_new_alloc(ctx->opid, pck_size, &output); if (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, pck); gf_filter_pck_set_cts(pck, ctx->cts); gf_filter_pck_set_sap(pck, ctx->state.frame_state.key_frame ? GF_FILTER_SAP_1 : 0); memcpy(output, ctx->state.frame_obus, pck_size); if (ctx->deps) { u8 flags = 0; //dependsOn flags = ( ctx->state.frame_state.key_frame) ? 2 : 1; flags <<= 2; //dependedOn flags |= ctx->state.frame_state.refresh_frame_flags ? 1 : 2; flags <<= 2; //hasRedundant //flags |= ctx->has_redundant ? 1 : 2; gf_filter_pck_set_dependency_flags(pck, flags); } gf_filter_pck_send(pck); av1dmx_update_cts(ctx); gf_av1_reset_state(&ctx->state, GF_FALSE); return GF_OK; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "There is a Null Pointer Dereference in function filter_core/filter_pck.c:gf_filter_pck_new_alloc_internal in GPAC 1.0.1. The pid comes from function av1dmx_parse_flush_sample, the ctx.opid maybe NULL. The result is a crash in gf_filter_pck_new_alloc_internal.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2021-30015"}} -{"idx": 431167, "input": "static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) { __be32 *p; int ret = 0; *type = 0; if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) return -EIO; if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { p = xdr_inline_decode(xdr, 4); if (unlikely(!p)) return -EIO; *type = be32_to_cpup(p); if (*type < NF4REG || *type > NF4NAMEDATTR) { dprintk(\"%s: bad type %d\\n\", __func__, *type); return -EIO; } bitmap[0] &= ~FATTR4_WORD0_TYPE; ret = NFS_ATTR_FATTR_TYPE; } dprintk(\"%s: type=0%o\\n\", __func__, nfs_type2fmt[*type]); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 301211, "input": "string_vformat(uschar *buffer, int buflen, char *format, va_list ap) { enum { L_NORMAL, L_SHORT, L_LONG, L_LONGLONG, L_LONGDOUBLE }; BOOL yield = TRUE; int width, precision; char *fp = format; /* Deliberately not unsigned */ uschar *p = buffer; uschar *last = buffer + buflen - 1; string_datestamp_offset = -1; /* Datestamp not inserted */ /* Scan the format and handle the insertions */ while (*fp != 0) { int length = L_NORMAL; int *nptr; int slen; char *null = \"NULL\"; /* ) These variables */ char *item_start, *s; /* ) are deliberately */ char newformat[16]; /* ) not unsigned */ /* Non-% characters just get copied verbatim */ if (*fp != '%') { if (p >= last) { yield = FALSE; break; } *p++ = (uschar)*fp++; continue; } /* Deal with % characters. Pick off the width and precision, for checking strings, skipping over the flag and modifier characters. */ item_start = fp; width = precision = -1; if (strchr(\"-+ #0\", *(++fp)) != NULL) { if (*fp == '#') null = \"\"; fp++; } if (isdigit((uschar)*fp)) { width = *fp++ - '0'; while (isdigit((uschar)*fp)) width = width * 10 + *fp++ - '0'; } else if (*fp == '*') { width = va_arg(ap, int); fp++; } if (*fp == '.') { if (*(++fp) == '*') { precision = va_arg(ap, int); fp++; } else { precision = 0; while (isdigit((uschar)*fp)) precision = precision*10 + *fp++ - '0'; } } /* Skip over 'h', 'L', 'l', and 'll', remembering the item length */ if (*fp == 'h') { fp++; length = L_SHORT; } else if (*fp == 'L') { fp++; length = L_LONGDOUBLE; } else if (*fp == 'l') { if (fp[1] == 'l') { fp += 2; length = L_LONGLONG; } else { fp++; length = L_LONG; } } /* Handle each specific format type. */ switch (*fp++) { case 'n': nptr = va_arg(ap, int *); *nptr = p - buffer; break; case 'd': case 'o': case 'u': case 'x': case 'X': if (p >= last - ((length > L_LONG)? 24 : 12)) { yield = FALSE; goto END_FORMAT; } strncpy(newformat, item_start, fp - item_start); newformat[fp - item_start] = 0; /* Short int is promoted to int when passing through ..., so we must use int for va_arg(). */ switch(length) { case L_SHORT: case L_NORMAL: sprintf(CS p, newformat, va_arg(ap, int)); break; case L_LONG: sprintf(CS p, newformat, va_arg(ap, long int)); break; case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, LONGLONG_T)); break; } while (*p) p++; break; case 'p': if (p >= last - 24) { yield = FALSE; goto END_FORMAT; } strncpy(newformat, item_start, fp - item_start); newformat[fp - item_start] = 0; sprintf(CS p, newformat, va_arg(ap, void *)); while (*p) p++; break; /* %f format is inherently insecure if the numbers that it may be handed are unknown (e.g. 1e300). However, in Exim, %f is used for printing load averages, and these are actually stored as integers (load average * 1000) so the size of the numbers is constrained. It is also used for formatting sending rates, where the simplicity of the format prevents overflow. */ case 'f': case 'e': case 'E': case 'g': case 'G': if (precision < 0) precision = 6; if (p >= last - precision - 8) { yield = FALSE; goto END_FORMAT; } strncpy(newformat, item_start, fp - item_start); newformat[fp-item_start] = 0; if (length == L_LONGDOUBLE) sprintf(CS p, newformat, va_arg(ap, long double)); else sprintf(CS p, newformat, va_arg(ap, double)); while (*p) p++; break; /* String types */ case '%': if (p >= last) { yield = FALSE; goto END_FORMAT; } *p++ = '%'; break; case 'c': if (p >= last) { yield = FALSE; goto END_FORMAT; } *p++ = va_arg(ap, int); break; case 'D': /* Insert datestamp for log file names */ s = CS tod_stamp(tod_log_datestamp); string_datestamp_offset = p - buffer; /* Passed back via global */ goto INSERT_STRING; case 's': case 'S': /* Forces *lower* case */ s = va_arg(ap, char *); INSERT_STRING: /* Come to from %D above */ if (s == NULL) s = null; slen = Ustrlen(s); /* If the width is specified, check that there is a precision set; if not, set it to the width to prevent overruns of long strings. */ if (width >= 0) { if (precision < 0) precision = width; } /* If a width is not specified and the precision is specified, set the width to the precision, or the string length if shorted. */ else if (precision >= 0) { width = (precision < slen)? precision : slen; } /* If neither are specified, set them both to the string length. */ else width = precision = slen; /* Check string space, and add the string to the buffer if ok. If not OK, add part of the string (debugging uses this to show as much as possible). */ if (p == last) { yield = FALSE; goto END_FORMAT; } if (p >= last - width) { yield = FALSE; width = precision = last - p - 1; if (width < 0) width = 0; if (precision < 0) precision = 0; } sprintf(CS p, \"%*.*s\", width, precision, s); if (fp[-1] == 'S') while (*p) { *p = tolower(*p); p++; } else while (*p) p++; if (!yield) goto END_FORMAT; break; /* Some things are never used in Exim; also catches junk. */ default: strncpy(newformat, item_start, fp - item_start); newformat[fp-item_start] = 0; log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"string_format: unsupported type \" \"in \\\"%s\\\" in \\\"%s\\\"\", newformat, format); break; } } /* Ensure string is complete; return TRUE if got to the end of the format */ END_FORMAT: *p = 0; return yield; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 269730, "input": "ElectronNavigationThrottle::WillStartRequest() { auto* handle = navigation_handle(); auto* contents = handle->GetWebContents(); if (!contents) { NOTREACHED(); return PROCEED; } v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); auto api_contents = electron::api::WebContents::From(isolate, contents); if (api_contents.IsEmpty()) { // No need to emit any event if the WebContents is not available in JS. return PROCEED; } if (handle->IsRendererInitiated() && handle->IsInMainFrame() && api_contents->EmitNavigationEvent(\"will-navigate\", handle)) { return CANCEL; } return PROCEED; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 376827, "input": "static avifBool avifParseItemPropertiesBox(avifMeta * meta, const uint8_t * raw, size_t rawLen) { BEGIN_STREAM(s, raw, rawLen); avifBoxHeader ipcoHeader; CHECK(avifROStreamReadBoxHeader(&s, &ipcoHeader)); if (memcmp(ipcoHeader.type, \"ipco\", 4) != 0) { return AVIF_FALSE; } // Read all item properties inside of ItemPropertyContainerBox CHECK(avifParseItemPropertyContainerBox(&meta->properties, avifROStreamCurrent(&s), ipcoHeader.size)); CHECK(avifROStreamSkip(&s, ipcoHeader.size)); // Now read all ItemPropertyAssociation until the end of the box, and make associations while (avifROStreamHasBytesLeft(&s, 1)) { avifBoxHeader ipmaHeader; CHECK(avifROStreamReadBoxHeader(&s, &ipmaHeader)); if (!memcmp(ipmaHeader.type, \"ipma\", 4)) { CHECK(avifParseItemPropertyAssociation(meta, avifROStreamCurrent(&s), ipmaHeader.size)); } else { // These must all be type ipma return AVIF_FALSE; } CHECK(avifROStreamSkip(&s, ipmaHeader.size)); } return AVIF_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 284254, "input": "static const char *h2_ss_str(h2_stream_state_t state) { switch (state) { case H2_SS_IDLE: return \"IDLE\"; case H2_SS_RSVD_L: return \"RESERVED_LOCAL\"; case H2_SS_RSVD_R: return \"RESERVED_REMOTE\"; case H2_SS_OPEN: return \"OPEN\"; case H2_SS_CLOSED_L: return \"HALF_CLOSED_LOCAL\"; case H2_SS_CLOSED_R: return \"HALF_CLOSED_REMOTE\"; case H2_SS_CLOSED: return \"CLOSED\"; case H2_SS_CLEANUP: return \"CLEANUP\"; default: return \"UNKNOWN\"; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393255, "input": "TEST_F(QueryPlannerTest, CompoundIndexBoundsEqualityThenIn) { addIndex(BSON(\"a\" << 1 << \"b\" << 1)); runQuery(fromjson(\"{a: 5, b: {$in: [2,6,11]}}\")); assertNumSolutions(2U); assertSolutionExists(\"{cscan: {dir: 1}}\"); assertSolutionExists( \"{fetch: {filter: null, node: {ixscan: {filter: null, pattern: \" \"{a: 1, b: 1}, bounds: {a: [[5,5,true,true]], \" \"b:[[2,2,true,true],[6,6,true,true],[11,11,true,true]]}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393176, "input": "TEST_F(QueryPlannerTest, SortSoftLimit) { runQuerySortProjSkipNToReturn(BSONObj(), fromjson(\"{a: 1}\"), BSONObj(), 0, 3); assertNumSolutions(1U); assertSolutionExists( \"{sort: {pattern: {a: 1}, limit: 3, node: {sortKeyGen: \" \"{node: {cscan: {dir: 1}}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 311105, "input": "DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp) { int pw, nc, retval=0; if(width<1 || subsamp<0 || subsamp>=TJ_NUMSAMP) _throw(\"tjPlaneWidth(): Invalid argument\"); nc=(subsamp==TJSAMP_GRAY? 1:3); if(componentID<0 || componentID>=nc) _throw(\"tjPlaneWidth(): Invalid argument\"); pw=PAD(width, tjMCUWidth[subsamp]/8); if(componentID==0) retval=pw; else retval=pw*8/tjMCUWidth[subsamp]; bailout: return retval; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198430, "input": "void Compute(OpKernelContext* context) override { const Tensor& image = context->input(0); OP_REQUIRES(context, image.dims() == 3, errors::InvalidArgument(\"image must be 3-dimensional\", image.shape().DebugString())); OP_REQUIRES( context, FastBoundsCheck(image.NumElements(), std::numeric_limits::max()), errors::InvalidArgument(\"image cannot have >= int32 max elements\")); const int32 height = static_cast(image.dim_size(0)); const int32 width = static_cast(image.dim_size(1)); const int32 channels = static_cast(image.dim_size(2)); // In some cases, we pass width*channels*2 to png. const int32 max_row_width = std::numeric_limits::max() / 2; OP_REQUIRES(context, FastBoundsCheck(width * channels, max_row_width), errors::InvalidArgument(\"image too wide to encode\")); OP_REQUIRES(context, channels >= 1 && channels <= 4, errors::InvalidArgument( \"image must have 1, 2, 3, or 4 channels, got \", channels)); // Encode image to png string Tensor* output = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({}), &output)); if (desired_channel_bits_ == 8) { OP_REQUIRES(context, png::WriteImageToBuffer( image.flat().data(), width, height, width * channels, channels, desired_channel_bits_, compression_, &output->scalar()(), nullptr), errors::Internal(\"PNG encoding failed\")); } else { OP_REQUIRES(context, png::WriteImageToBuffer( image.flat().data(), width, height, width * channels * 2, channels, desired_channel_bits_, compression_, &output->scalar()(), nullptr), errors::Internal(\"PNG encoding failed\")); } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a `CHECK` fail in PNG encoding by providing an empty input tensor as the pixel data. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/kernels/image/encode_png_op.cc#L57-L60) only validates that the total number of pixels in the image does not overflow. Thus, an attacker can send an empty matrix for encoding. However, if the tensor is empty, then the associated buffer is `nullptr`. Hence, when calling `png::WriteImageToBuffer`(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/kernels/image/encode_png_op.cc#L79-L93), the first argument (i.e., `image.flat().data()`) is `NULL`. This then triggers the `CHECK_NOTNULL` in the first line of `png::WriteImageToBuffer`(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/lib/png/png_io.cc#L345-L349). Since `image` is null, this results in `abort` being called after printing the stacktrace. Effectively, this allows an attacker to mount a denial of service attack. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2021-29531"}} -{"idx": 223156, "input": "void SetAttrValue(const TensorShapeProto& value, AttrValue* out) { *out->mutable_shape() = value; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 369440, "input": "static inline void ConvertDisplayP3ToXYZ(const double red,const double green, const double blue,double *X,double *Y,double *Z) { double b, g, r; /* Convert Display P3 to XYZ colorspace. */ assert(X != (double *) NULL); assert(Y != (double *) NULL); assert(Z != (double *) NULL); r=QuantumScale*DecodePixelGamma(red); g=QuantumScale*DecodePixelGamma(green); b=QuantumScale*DecodePixelGamma(blue); *X=0.4865709486482162*r+0.26566769316909306*g+0.1982172852343625*b; *Y=0.2289745640697488*r+0.69173852183650640*g+0.0792869140937450*b; *Z=0.0000000000000000*r+0.04511338185890264*g+1.0439443689009760*b; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 402387, "input": "varyEvaluateMatch(StoreEntry * entry, HttpRequest * request) { SBuf vary(request->vary_headers); int has_vary = entry->getReply()->header.has(Http::HdrType::VARY); #if X_ACCELERATOR_VARY has_vary |= entry->getReply()->header.has(Http::HdrType::HDR_X_ACCELERATOR_VARY); #endif if (!has_vary || entry->mem_obj->vary_headers.isEmpty()) { if (!vary.isEmpty()) { /* Oops... something odd is going on here.. */ debugs(33, DBG_IMPORTANT, \"varyEvaluateMatch: Oops. Not a Vary object on second attempt, '\" << entry->mem_obj->urlXXX() << \"' '\" << vary << \"'\"); request->vary_headers.clear(); return VARY_CANCEL; } if (!has_vary) { /* This is not a varying object */ return VARY_NONE; } /* virtual \"vary\" object found. Calculate the vary key and * continue the search */ vary = httpMakeVaryMark(request, entry->getReply()); if (!vary.isEmpty()) { request->vary_headers = vary; return VARY_OTHER; } else { /* Ouch.. we cannot handle this kind of variance */ /* XXX This cannot really happen, but just to be complete */ return VARY_CANCEL; } } else { if (vary.isEmpty()) { vary = httpMakeVaryMark(request, entry->getReply()); if (!vary.isEmpty()) request->vary_headers = vary; } if (vary.isEmpty()) { /* Ouch.. we cannot handle this kind of variance */ /* XXX This cannot really happen, but just to be complete */ return VARY_CANCEL; } else if (vary.cmp(entry->mem_obj->vary_headers) == 0) { return VARY_MATCH; } else { /* Oops.. we have already been here and still haven't * found the requested variant. Bail out */ debugs(33, DBG_IMPORTANT, \"varyEvaluateMatch: Oops. Not a Vary match on second attempt, '\" << entry->mem_obj->urlXXX() << \"' '\" << vary << \"'\"); return VARY_CANCEL; } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198240, "input": "GF_Err abst_box_read(GF_Box *s, GF_BitStream *bs) { GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s; int i; u32 tmp_strsize; char *tmp_str; GF_Err e; ISOM_DECREASE_SIZE(ptr, 25) ptr->bootstrapinfo_version = gf_bs_read_u32(bs); ptr->profile = gf_bs_read_int(bs, 2); ptr->live = gf_bs_read_int(bs, 1); ptr->update = gf_bs_read_int(bs, 1); ptr->reserved = gf_bs_read_int(bs, 4); ptr->time_scale = gf_bs_read_u32(bs); ptr->current_media_time = gf_bs_read_u64(bs); ptr->smpte_time_code_offset = gf_bs_read_u64(bs); i=0; if (ptr->size<8) return GF_ISOM_INVALID_FILE; tmp_strsize =(u32)ptr->size; tmp_str = gf_malloc(sizeof(char)*tmp_strsize); if (!tmp_str) return GF_OUT_OF_MEM; memset(tmp_str, 0, sizeof(char)*tmp_strsize); while (tmp_strsize) { ISOM_DECREASE_SIZE(ptr, 1) tmp_str[i] = gf_bs_read_u8(bs); tmp_strsize--; if (!tmp_str[i]) break; i++; } if (i) { ptr->movie_identifier = gf_strdup(tmp_str); } ISOM_DECREASE_SIZE(ptr, 1) ptr->server_entry_count = gf_bs_read_u8(bs); for (i=0; iserver_entry_count; i++) { int j=0; tmp_strsize=(u32)ptr->size; while (tmp_strsize) { ISOM_DECREASE_SIZE(ptr, 1) tmp_str[j] = gf_bs_read_u8(bs); tmp_strsize--; if (!tmp_str[j]) break; j++; } if (j) { gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i); } } ISOM_DECREASE_SIZE(ptr, 1) ptr->quality_entry_count = gf_bs_read_u8(bs); for (i=0; iquality_entry_count; i++) { int j=0; tmp_strsize=(u32)ptr->size; while (tmp_strsize) { ISOM_DECREASE_SIZE(ptr, 1) tmp_str[j] = gf_bs_read_u8(bs); tmp_strsize--; if (!tmp_str[j]) break; j++; } if (j) { gf_list_insert(ptr->quality_entry_table, gf_strdup(tmp_str), i); } } i=0; tmp_strsize=(u32)ptr->size; while (tmp_strsize) { ISOM_DECREASE_SIZE(ptr, 1) tmp_str[i] = gf_bs_read_u8(bs); tmp_strsize--; if (!tmp_str[i]) break; i++; } if (i) { ptr->drm_data = gf_strdup(tmp_str); } i=0; tmp_strsize=(u32)ptr->size; while (tmp_strsize) { ISOM_DECREASE_SIZE(ptr, 1) tmp_str[i] = gf_bs_read_u8(bs); tmp_strsize--; if (!tmp_str[i]) break; i++; } if (i) { ptr->meta_data = gf_strdup(tmp_str); } ISOM_DECREASE_SIZE(ptr, 1) ptr->segment_run_table_count = gf_bs_read_u8(bs); for (i=0; isegment_run_table_count; i++) { GF_AdobeSegmentRunTableBox *asrt = NULL; e = gf_isom_box_parse((GF_Box **)&asrt, bs); if (e) { if (asrt) gf_isom_box_del((GF_Box*)asrt); gf_free(tmp_str); return e; } gf_list_add(ptr->segment_run_table_entries, asrt); } ISOM_DECREASE_SIZE(ptr, 1) ptr->fragment_run_table_count = gf_bs_read_u8(bs); for (i=0; ifragment_run_table_count; i++) { GF_AdobeFragmentRunTableBox *afrt = NULL; e = gf_isom_box_parse((GF_Box **)&afrt, bs); if (e) { if (afrt) gf_isom_box_del((GF_Box*)afrt); gf_free(tmp_str); return e; } gf_list_add(ptr->fragment_run_table_entries, afrt); } gf_free(tmp_str); return GF_OK; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "Buffer overflow in the abst_box_read function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2021-31255"}} -{"idx": 336880, "input": "rb_str_subpat_set(VALUE str, VALUE re, VALUE backref, VALUE val) { int nth; VALUE match; long start, end, len; rb_encoding *enc; struct re_registers *regs; if (rb_reg_search(re, str, 0, 0) < 0) { rb_raise(rb_eIndexError, \"regexp not matched\"); } match = rb_backref_get(); nth = rb_reg_backref_number(match, backref); regs = RMATCH_REGS(match); if (nth >= regs->num_regs) { out_of_range: rb_raise(rb_eIndexError, \"index %d out of regexp\", nth); } if (nth < 0) { if (-nth >= regs->num_regs) { goto out_of_range; } nth += regs->num_regs; } start = BEG(nth); if (start == -1) { rb_raise(rb_eIndexError, \"regexp group %d not matched\", nth); } end = END(nth); len = end - start; StringValue(val); enc = rb_enc_check(str, val); rb_str_splice_0(str, start, len, val); rb_enc_associate(str, enc); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 272243, "input": "multi_client_disconnect_setenv(struct multi_instance *mi) { /* setenv client real IP address */ setenv_trusted(mi->context.c2.es, get_link_socket_info(&mi->context)); /* setenv stats */ setenv_stats(&mi->context); /* setenv connection duration */ setenv_long_long(mi->context.c2.es, \"time_duration\", now - mi->created); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381952, "input": "static apr_byte_t oidc_provider_static_config(request_rec *r, oidc_cfg *c, oidc_provider_t **provider) { json_t *j_provider = NULL; char *s_json = NULL; /* see if we should configure a static provider based on external (cached) metadata */ if ((c->metadata_dir != NULL) || (c->provider.metadata_url == NULL)) { *provider = &c->provider; return TRUE; } oidc_cache_get_provider(r, c->provider.metadata_url, &s_json); if (s_json == NULL) { if (oidc_metadata_provider_retrieve(r, c, NULL, c->provider.metadata_url, &j_provider, &s_json) == FALSE) { oidc_error(r, \"could not retrieve metadata from url: %s\", c->provider.metadata_url); return FALSE; } oidc_cache_set_provider(r, c->provider.metadata_url, s_json, apr_time_now() + (c->provider_metadata_refresh_interval <= 0 ? apr_time_from_sec( OIDC_CACHE_PROVIDER_METADATA_EXPIRY_DEFAULT) : c->provider_metadata_refresh_interval)); } else { oidc_util_decode_json_object(r, s_json, &j_provider); /* check to see if it is valid metadata */ if (oidc_metadata_provider_is_valid(r, c, j_provider, NULL) == FALSE) { oidc_error(r, \"cache corruption detected: invalid metadata from url: %s\", c->provider.metadata_url); return FALSE; } } *provider = apr_pcalloc(r->pool, sizeof(oidc_provider_t)); memcpy(*provider, &c->provider, sizeof(oidc_provider_t)); if (oidc_metadata_provider_parse(r, c, j_provider, *provider) == FALSE) { oidc_error(r, \"could not parse metadata from url: %s\", c->provider.metadata_url); if (j_provider) json_decref(j_provider); return FALSE; } json_decref(j_provider); return TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417907, "input": "static GuidelineSet *SFDReadGuideline(FILE *sfd, GuidelineSet **gll, GuidelineSet *lastgl) { GuidelineSet *gl = chunkalloc(sizeof(GuidelineSet)); gl->name = SFDReadUTF7Str(sfd); gl->identifier = SFDReadUTF7Str(sfd); getreal(sfd,&gl->point.x); getreal(sfd,&gl->point.y); getreal(sfd,&gl->angle); getint(sfd,&gl->color); getint(sfd,&gl->flags); if ( lastgl!=NULL ) lastgl->next = gl; else if (gll) *gll = gl; return( gl ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 359161, "input": "static void opj_tcd_code_block_dec_deallocate(opj_tcd_precinct_t * p_precinct) { OPJ_UINT32 cblkno, l_nb_code_blocks; opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec; if (l_code_block) { /*fprintf(stderr,\"deallocate codeblock:{\\n\");*/ /*fprintf(stderr,\"\\t x0=%d, y0=%d, x1=%d, y1=%d\\n\",l_code_block->x0, l_code_block->y0, l_code_block->x1, l_code_block->y1);*/ /*fprintf(stderr,\"\\t numbps=%d, numlenbits=%d, len=%d, numnewpasses=%d, real_num_segs=%d, m_current_max_segs=%d\\n \", l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/ l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof( opj_tcd_cblk_dec_t); /*fprintf(stderr,\"nb_code_blocks =%d\\t}\\n\", l_nb_code_blocks);*/ for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { if (l_code_block->segs) { opj_free(l_code_block->segs); l_code_block->segs = 00; } if (l_code_block->chunks) { opj_free(l_code_block->chunks); l_code_block->chunks = 00; } opj_aligned_free(l_code_block->decoded_data); l_code_block->decoded_data = NULL; ++l_code_block; } opj_free(p_precinct->cblks.dec); p_precinct->cblks.dec = 00; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 392956, "input": "TEST_F(QueryPlannerTest, MaxMinReverseIndexDir) { addIndex(BSON(\"a\" << -1)); // Because the index is descending, the min is numerically larger than the max. runQueryFull(BSONObj(), fromjson(\"{a: -1}\"), BSONObj(), 0, 0, BSONObj(), fromjson(\"{a: 8}\"), fromjson(\"{a: 2}\"), false); assertNumSolutions(1); assertSolutionExists(\"{fetch: {node: {ixscan: {filter: null, dir: 1, pattern: {a: -1}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 519056, "input": "void ocall_free(uint8_t *buf) { free(buf); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 402528, "input": "static void discoverable_update_work(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, discoverable_update); u8 status; hci_req_sync(hdev, discoverable_update, 0, HCI_CMD_TIMEOUT, &status); mgmt_set_discoverable_complete(hdev, status); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232638, "input": "static int bpf_adj_linfo_after_remove(struct bpf_verifier_env *env, u32 off, u32 cnt) { struct bpf_prog *prog = env->prog; u32 i, l_off, l_cnt, nr_linfo; struct bpf_line_info *linfo; nr_linfo = prog->aux->nr_linfo; if (!nr_linfo) return 0; linfo = prog->aux->linfo; /* find first line info to remove, count lines to be removed */ for (i = 0; i < nr_linfo; i++) if (linfo[i].insn_off >= off) break; l_off = i; l_cnt = 0; for (; i < nr_linfo; i++) if (linfo[i].insn_off < off + cnt) l_cnt++; else break; /* First live insn doesn't match first live linfo, it needs to \"inherit\" * last removed linfo. prog is already modified, so prog->len == off * means no live instructions after (tail of the program was removed). */ if (prog->len != off && l_cnt && (i == nr_linfo || linfo[i].insn_off != off + cnt)) { l_cnt--; linfo[--i].insn_off = off + cnt; } /* remove the line info which refer to the removed instructions */ if (l_cnt) { memmove(linfo + l_off, linfo + i, sizeof(*linfo) * (nr_linfo - i)); prog->aux->nr_linfo -= l_cnt; nr_linfo = prog->aux->nr_linfo; } /* pull all linfo[i].insn_off >= off + cnt in by cnt */ for (i = l_off; i < nr_linfo; i++) linfo[i].insn_off -= cnt; /* fix up all subprogs (incl. 'exit') which start >= off */ for (i = 0; i <= env->subprog_cnt; i++) if (env->subprog_info[i].linfo_idx > l_off) { /* program may have started in the removed region but * may not be fully removed */ if (env->subprog_info[i].linfo_idx >= l_off + l_cnt) env->subprog_info[i].linfo_idx -= l_cnt; else env->subprog_info[i].linfo_idx = l_off; } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431323, "input": "static void nfs_clear_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode) { clear_bit(NFS_O_RDWR_STATE, &state->flags); switch (fmode & (FMODE_READ|FMODE_WRITE)) { case FMODE_WRITE: clear_bit(NFS_O_RDONLY_STATE, &state->flags); break; case FMODE_READ: clear_bit(NFS_O_WRONLY_STATE, &state->flags); break; case 0: clear_bit(NFS_O_RDONLY_STATE, &state->flags); clear_bit(NFS_O_WRONLY_STATE, &state->flags); clear_bit(NFS_OPEN_STATE, &state->flags); } if (stateid == NULL) return; /* Handle OPEN+OPEN_DOWNGRADE races */ if (nfs4_stateid_match_other(stateid, &state->open_stateid) && !nfs4_stateid_is_newer(stateid, &state->open_stateid)) { nfs_resync_open_stateid_locked(state); goto out; } if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) nfs4_stateid_copy(&state->stateid, stateid); nfs4_stateid_copy(&state->open_stateid, stateid); trace_nfs4_open_stateid_update(state->inode, stateid, 0); out: nfs_state_log_update_open_stateid(state); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 497546, "input": "ms_escher_read_CalloutRule (MSEscherState *state, MSEscherHeader *h) { return FALSE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 423631, "input": "add_range(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, unsigned int out, int check_for_overlap, int many) { int current; cmap_splay *tree; if (low > high) { fz_warn(ctx, \"range limits out of range in cmap %s\", cmap->cmap_name); return; } tree = cmap->tree; if (cmap->tlen) { unsigned int move = cmap->ttop; unsigned int gt = EMPTY; unsigned int lt = EMPTY; if (check_for_overlap) { /* Check for collision with the current node */ do { current = move; /* Cases we might meet: * tree[i]: <-----> * case 0: <-> * case 1: <-------> * case 2: <-------------> * case 3: <-> * case 4: <-------> * case 5: <-> */ if (low <= tree[current].low && tree[current].low <= high) { /* case 1, reduces to case 0 */ /* or case 2, deleting the node */ tree[current].out += high + 1 - tree[current].low; tree[current].low = high + 1; if (tree[current].low > tree[current].high) { move = delete_node(cmap, current); current = EMPTY; continue; } } else if (low <= tree[current].high && tree[current].high <= high) { /* case 4, reduces to case 5 */ tree[current].high = low - 1; assert(tree[current].low <= tree[current].high); } else if (tree[current].low < low && high < tree[current].high) { /* case 3, reduces to case 5 */ int new_high = tree[current].high; tree[current].high = low-1; add_range(ctx, cmap, high+1, new_high, tree[current].out + high + 1 - tree[current].low, 0, tree[current].many); tree = cmap->tree; } /* Now look for where to move to next (left for case 0, right for case 5) */ if (tree[current].low > high) { move = tree[current].left; gt = current; } else { move = tree[current].right; lt = current; } } while (move != EMPTY); } else { do { current = move; if (tree[current].low > high) { move = tree[current].left; gt = current; } else { move = tree[current].right; lt = current; } } while (move != EMPTY); } /* current is now the node to which we would be adding the new node */ /* lt is the last node we traversed which is lt the new node. */ /* gt is the last node we traversed which is gt the new node. */ if (!many) { /* Check for the 'merge' cases. */ if (lt != EMPTY && !tree[lt].many && tree[lt].high == low-1 && tree[lt].out - tree[lt].low == out - low) { tree[lt].high = high; if (gt != EMPTY && !tree[gt].many && tree[gt].low == high+1 && tree[gt].out - tree[gt].low == out - low) { tree[lt].high = tree[gt].high; delete_node(cmap, gt); } goto exit; } if (gt != EMPTY && !tree[gt].many && tree[gt].low == high+1 && tree[gt].out - tree[gt].low == out - low) { tree[gt].low = low; tree[gt].out = out; goto exit; } } } else current = EMPTY; if (cmap->tlen == cmap->tcap) { int new_cap = cmap->tcap ? cmap->tcap * 2 : 256; tree = cmap->tree = fz_resize_array(ctx, cmap->tree, new_cap, sizeof *cmap->tree); cmap->tcap = new_cap; } tree[cmap->tlen].low = low; tree[cmap->tlen].high = high; tree[cmap->tlen].out = out; tree[cmap->tlen].parent = current; tree[cmap->tlen].left = EMPTY; tree[cmap->tlen].right = EMPTY; tree[cmap->tlen].many = many; cmap->tlen++; if (current == EMPTY) cmap->ttop = 0; else if (tree[current].low > high) tree[current].left = cmap->tlen-1; else { assert(tree[current].high < low); tree[current].right = cmap->tlen-1; } move_to_root(tree, cmap->tlen-1); cmap->ttop = cmap->tlen-1; exit: {} #ifdef CHECK_SPLAY check_splay(cmap->tree, cmap->ttop, 0); #endif #ifdef DUMP_SPLAY dump_splay(cmap->tree, cmap->ttop, 0, \"\"); #endif }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 345166, "input": "int ssh_buffer_get_u64(struct ssh_buffer_struct *buffer, uint64_t *data){ return ssh_buffer_get_data(buffer,data,sizeof(uint64_t)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 458406, "input": "static int mt_touch_input_configured(struct hid_device *hdev, struct hid_input *hi, struct mt_application *app) { struct mt_device *td = hid_get_drvdata(hdev); struct mt_class *cls = &td->mtclass; struct input_dev *input = hi->input; int ret; if (!td->maxcontacts) td->maxcontacts = MT_DEFAULT_MAXCONTACT; mt_post_parse(td, app); if (td->serial_maybe) mt_post_parse_default_settings(td, app); if (cls->is_indirect) app->mt_flags |= INPUT_MT_POINTER; if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) app->mt_flags |= INPUT_MT_DROP_UNUSED; /* check for clickpads */ if ((app->mt_flags & INPUT_MT_POINTER) && (app->buttons_count == 1)) td->is_buttonpad = true; if (td->is_buttonpad) __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); app->pending_palm_slots = devm_kcalloc(&hi->input->dev, BITS_TO_LONGS(td->maxcontacts), sizeof(long), GFP_KERNEL); if (!app->pending_palm_slots) return -ENOMEM; ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); if (ret) return ret; app->mt_flags = 0; return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 509441, "input": "Item_string_sys(THD *thd, const char *str): Item_string(thd, str, (uint) strlen(str), system_charset_info) { }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 520930, "input": "static Jsi_RC CDataTypeConfCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this, Jsi_Value **ret, Jsi_Func *funcPtr) { char *arg1 = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL); Jsi_OptionTypedef *nd = NULL; jsi_csInitType(interp); if (arg1) nd = (typeof(nd))Jsi_TypeLookup(interp, arg1); if (!nd) return Jsi_LogError(\"Unknown type: %s\", arg1); return CDataOptionsConf(interp, TypeOptions, args, nd, ret, 0, 1); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 330258, "input": "ex_redir(exarg_T *eap) { char *mode; char_u *fname; char_u *arg = eap->arg; #ifdef FEAT_EVAL if (redir_execute) { emsg(_(\"E930: Cannot use :redir inside execute()\")); return; } #endif if (STRICMP(eap->arg, \"END\") == 0) close_redir(); else { if (*arg == '>') { ++arg; if (*arg == '>') { ++arg; mode = \"a\"; } else mode = \"w\"; arg = skipwhite(arg); close_redir(); // Expand environment variables and \"~/\". fname = expand_env_save(arg); if (fname == NULL) return; #ifdef FEAT_BROWSE if (cmdmod.cmod_flags & CMOD_BROWSE) { char_u *browseFile; browseFile = do_browse(BROWSE_SAVE, (char_u *)_(\"Save Redirection\"), fname, NULL, NULL, (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); if (browseFile == NULL) return; // operation cancelled vim_free(fname); fname = browseFile; eap->forceit = TRUE; // since dialog already asked } #endif redir_fd = open_exfile(fname, eap->forceit, mode); vim_free(fname); } #ifdef FEAT_EVAL else if (*arg == '@') { // redirect to a register a-z (resp. A-Z for appending) close_redir(); ++arg; if (ASCII_ISALPHA(*arg) # ifdef FEAT_CLIPBOARD || *arg == '*' || *arg == '+' # endif || *arg == '\"') { redir_reg = *arg++; if (*arg == '>' && arg[1] == '>') // append arg += 2; else { // Can use both \"@a\" and \"@a>\". if (*arg == '>') arg++; // Make register empty when not using @A-@Z and the // command is valid. if (*arg == NUL && !isupper(redir_reg)) write_reg_contents(redir_reg, (char_u *)\"\", -1, FALSE); } } if (*arg != NUL) { redir_reg = 0; semsg(_(e_invarg2), eap->arg); } } else if (*arg == '=' && arg[1] == '>') { int append; // redirect to a variable close_redir(); arg += 2; if (*arg == '>') { ++arg; append = TRUE; } else append = FALSE; if (var_redir_start(skipwhite(arg), append) == OK) redir_vname = 1; } #endif // TODO: redirect to a buffer else semsg(_(e_invarg2), eap->arg); } // Make sure redirection is not off. Can happen for cmdline completion // that indirectly invokes a command to catch its output. if (redir_fd != NULL #ifdef FEAT_EVAL || redir_reg || redir_vname #endif ) redir_off = FALSE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 215446, "input": "static int svc_listen(struct socket *sock,int backlog) { DEFINE_WAIT(wait); struct sock *sk = sock->sk; struct atm_vcc *vcc = ATM_SD(sock); int error; pr_debug(\"svc_listen %p\\n\",vcc); lock_sock(sk); /* let server handle listen on unbound sockets */ if (test_bit(ATM_VF_SESSION,&vcc->flags)) { error = -EINVAL; goto out; } vcc_insert_socket(sk); set_bit(ATM_VF_WAITING, &vcc->flags); prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { schedule(); prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); } finish_wait(sk->sk_sleep, &wait); if (!sigd) { error = -EUNATCH; goto out; } set_bit(ATM_VF_LISTEN,&vcc->flags); sk->sk_max_ack_backlog = backlog > 0 ? backlog : ATM_BACKLOG_DEFAULT; error = -sk->sk_err; out: release_sock(sk); return error; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NVD-CWE-Other"], "explanation": "net/atm/svc.c in the ATM subsystem in the Linux kernel 2.6.27.8 and earlier allows local users to cause a denial of service (kernel infinite loop) by making two calls to svc_listen for the same socket, and then reading a /proc/net/atm/*vc file, related to corruption of the vcc table.", "severity_level": "Medium", "cwe": "CWE-399", "cve": "CVE-2008-5079"}} -{"idx": 281333, "input": "RGWOp *RGWHandler_REST_Bucket_S3::op_options() { return new RGWOptionsCORS_ObjStore_S3; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219491, "input": "inline static void appendsimplestring(char **buffer, int *pos, int *size, const char *add, int len) { int req_size = *pos + len; if (req_size > *size) { while (req_size > *size) { *size <<= 1; } *buffer = (char *)realloc(*buffer, *size); } memcpy(&(*buffer)[*pos], add, len); *pos += len; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354810, "input": "static int kvm_set_memslot(struct kvm *kvm, const struct kvm_userspace_memory_region *mem, struct kvm_memory_slot *old, struct kvm_memory_slot *new, int as_id, enum kvm_mr_change change) { struct kvm_memory_slot *slot; struct kvm_memslots *slots; int r; slots = kvm_dup_memslots(__kvm_memslots(kvm, as_id), change); if (!slots) return -ENOMEM; if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) { /* * Note, the INVALID flag needs to be in the appropriate entry * in the freshly allocated memslots, not in @old or @new. */ slot = id_to_memslot(slots, old->id); slot->flags |= KVM_MEMSLOT_INVALID; /* * We can re-use the old memslots, the only difference from the * newly installed memslots is the invalid flag, which will get * dropped by update_memslots anyway. We'll also revert to the * old memslots if preparing the new memory region fails. */ slots = install_new_memslots(kvm, as_id, slots); /* From this point no new shadow pages pointing to a deleted, * or moved, memslot will be created. * * validation of sp->gfn happens in: * - gfn_to_hva (kvm_read_guest, gfn_to_pfn) * - kvm_is_visible_gfn (mmu_check_root) */ kvm_arch_flush_shadow_memslot(kvm, slot); } r = kvm_arch_prepare_memory_region(kvm, new, mem, change); if (r) goto out_slots; update_memslots(slots, new, change); slots = install_new_memslots(kvm, as_id, slots); kvm_arch_commit_memory_region(kvm, mem, old, new, change); kvfree(slots); return 0; out_slots: if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) slots = install_new_memslots(kvm, as_id, slots); kvfree(slots); return r; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 275400, "input": "GF_Err gf_isom_ismacryp_sample_to_sample(const GF_ISMASample *s, GF_ISOSample *dest) { GF_BitStream *bs; if (!s || !dest) return GF_BAD_PARAM; bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); if (s->flags & GF_ISOM_ISMA_USE_SEL_ENC) { gf_bs_write_int(bs, (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) ? 1 : 0, 1); gf_bs_write_int(bs, 0, 7); } if (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) { if (s->IV_length) gf_bs_write_long_int(bs, (s64) s->IV, 8*s->IV_length); if (s->KI_length) gf_bs_write_data(bs, (char*)s->key_indicator, s->KI_length); } gf_bs_write_data(bs, s->data, s->dataLength); if (dest->data) gf_free(dest->data); dest->data = NULL; dest->dataLength = 0; gf_bs_get_content(bs, &dest->data, &dest->dataLength); gf_bs_del(bs); return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 437559, "input": "static int skinit_interception(struct vcpu_svm *svm) { trace_kvm_skinit(svm->vmcb->save.rip, svm->vcpu.arch.regs[VCPU_REGS_RAX]); kvm_queue_exception(&svm->vcpu, UD_VECTOR); return 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 370045, "input": "const char* ExpressionBinarySize::getOpName() const { return \"$binarySize\"; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508703, "input": "static int compare_fields_by_table_order(Item *field1, Item *field2, void *table_join_idx) { int cmp= 0; bool outer_ref= 0; Item *field1_real= field1->real_item(); Item *field2_real= field2->real_item(); if (field1->const_item() || field1_real->const_item()) return -1; if (field2->const_item() || field2_real->const_item()) return 1; Item_field *f1= (Item_field *) field1_real; Item_field *f2= (Item_field *) field2_real; if (f1->used_tables() & OUTER_REF_TABLE_BIT) { outer_ref= 1; cmp= -1; } if (f2->used_tables() & OUTER_REF_TABLE_BIT) { outer_ref= 1; cmp++; } if (outer_ref) return cmp; JOIN_TAB **idx= (JOIN_TAB **) table_join_idx; JOIN_TAB *tab1= idx[f1->field->table->tablenr]; JOIN_TAB *tab2= idx[f2->field->table->tablenr]; /* if one of the table is inside a merged SJM nest and another one isn't, compare SJM bush roots of the tables. */ if (tab1->bush_root_tab != tab2->bush_root_tab) { if (tab1->bush_root_tab) tab1= tab1->bush_root_tab; if (tab2->bush_root_tab) tab2= tab2->bush_root_tab; } cmp= (int)(tab1 - tab2); if (!cmp) { /* Fields f1, f2 belong to the same table */ JOIN_TAB *tab= idx[f1->field->table->tablenr]; uint keyno= MAX_KEY; if (tab->ref.key_parts) keyno= tab->ref.key; else if (tab->select && tab->select->quick) keyno = tab->select->quick->index; if (keyno != MAX_KEY) { if (f1->field->part_of_key.is_set(keyno)) cmp= -1; if (f2->field->part_of_key.is_set(keyno)) cmp++; /* Here: if both f1, f2 are components of the key tab->ref.key then cmp==0, if only f1 is a component of the key then cmp==-1 (f1 is better), if only f2 is a component of the key then cmp==1, (f2 is better), if none of f1,f1 is component of the key cmp==0. */ if (!cmp) { KEY *key_info= tab->table->key_info + keyno; for (uint i= 0; i < key_info->user_defined_key_parts; i++) { Field *fld= key_info->key_part[i].field; if (fld->eq(f1->field)) { cmp= -1; // f1 is better break; } if (fld->eq(f2->field)) { cmp= 1; // f2 is better break; } } } } if (!cmp) cmp= f1->field->field_index-f2->field->field_index; } return cmp < 0 ? -1 : (cmp ? 1 : 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 361277, "input": "void setnxCommand(client *c) { c->argv[2] = tryObjectEncoding(c->argv[2]); setGenericCommand(c,OBJ_SET_NX,c->argv[1],c->argv[2],NULL,0,shared.cone,shared.czero); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 429724, "input": "uint STDCALL mysql_errno(MYSQL *mysql) { return mysql ? mysql->net.last_errno : 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 269098, "input": "void freeServiceList(service_info *head) { service_info *next = NULL; while (head) { if (head->serviceType) ixmlFreeDOMString(head->serviceType); if (head->serviceId) ixmlFreeDOMString(head->serviceId); if (head->SCPDURL) free(head->SCPDURL); if (head->controlURL) free(head->controlURL); if (head->eventURL) free(head->eventURL); if (head->UDN) ixmlFreeDOMString(head->UDN); if (head->subscriptionList) freeSubscriptionList(head->subscriptionList); head->TotalSubscriptions = 0; next = head->next; free(head); head = next; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 336813, "input": "rb_str_append(VALUE str, VALUE str2) { rb_encoding *enc; int cr, cr2; StringValue(str2); if (RSTRING_LEN(str2) > 0 && STR_ASSOC_P(str)) { long len = RSTRING_LEN(str)+RSTRING_LEN(str2); enc = rb_enc_check(str, str2); cr = ENC_CODERANGE(str); if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2; rb_str_modify(str); REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1); memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len, RSTRING_PTR(str2), RSTRING_LEN(str2)+1); RSTRING(str)->as.heap.len = len; rb_enc_associate(str, enc); ENC_CODERANGE_SET(str, cr); OBJ_INFECT(str, str2); return str; } return rb_str_buf_append(str, str2); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393200, "input": "TEST_F(QueryPlannerTest, ExprEqCanUseHashedIndexWithRegex) { params.options &= ~QueryPlannerParams::INCLUDE_COLLSCAN; addIndex(BSON(\"a\" << \"hashed\")); runQuery(fromjson(\"{a: {$_internalExprEq: /abc/}}\")); ASSERT_EQUALS(getNumSolutions(), 1U); assertSolutionExists( \"{fetch: {filter: {a: {$_internalExprEq: /abc/}}, node: {ixscan: {filter: null, pattern: \" \"{a: 'hashed'}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 378590, "input": "static void checkActiveVdbeCnt(sqlite3 *db){ Vdbe *p; int cnt = 0; int nWrite = 0; int nRead = 0; p = db->pVdbe; while( p ){ if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){ cnt++; if( p->readOnly==0 ) nWrite++; if( p->bIsReader ) nRead++; } p = p->pNext; } assert( cnt==db->nVdbeActive ); assert( nWrite==db->nVdbeWrite ); assert( nRead==db->nVdbeRead ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 482976, "input": "struct mpc *dcn20_mpc_create(struct dc_context *ctx) { struct dcn20_mpc *mpc20 = kzalloc(sizeof(struct dcn20_mpc), GFP_KERNEL); if (!mpc20) return NULL; dcn20_mpc_construct(mpc20, ctx, &mpc_regs, &mpc_shift, &mpc_mask, 6); return &mpc20->base; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 328343, "input": "static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net, u32 portid, u32 seq, int event, u32 flags, int family, const struct nft_table *table, const struct nft_chain *chain, const struct nft_rule *rule, const struct nft_rule *prule) { struct nlmsghdr *nlh; const struct nft_expr *expr, *next; struct nlattr *list; u16 type = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, type, flags, family, NFNETLINK_V0, nft_base_seq(net)); if (!nlh) goto nla_put_failure; if (nla_put_string(skb, NFTA_RULE_TABLE, table->name)) goto nla_put_failure; if (nla_put_string(skb, NFTA_RULE_CHAIN, chain->name)) goto nla_put_failure; if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle), NFTA_RULE_PAD)) goto nla_put_failure; if (event != NFT_MSG_DELRULE && prule) { if (nla_put_be64(skb, NFTA_RULE_POSITION, cpu_to_be64(prule->handle), NFTA_RULE_PAD)) goto nla_put_failure; } if (chain->flags & NFT_CHAIN_HW_OFFLOAD) nft_flow_rule_stats(chain, rule); list = nla_nest_start_noflag(skb, NFTA_RULE_EXPRESSIONS); if (list == NULL) goto nla_put_failure; nft_rule_for_each_expr(expr, next, rule) { if (nft_expr_dump(skb, NFTA_LIST_ELEM, expr) < 0) goto nla_put_failure; } nla_nest_end(skb, list); if (rule->udata) { struct nft_userdata *udata = nft_userdata(rule); if (nla_put(skb, NFTA_RULE_USERDATA, udata->len + 1, udata->data) < 0) goto nla_put_failure; } nlmsg_end(skb, nlh); return 0; nla_put_failure: nlmsg_trim(skb, nlh); return -1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381442, "input": "static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { struct v4l2_format *p = arg; struct video_device *vfd = video_devdata(file); int ret = check_fmt(file, p->type); unsigned int i; if (ret) return ret; v4l_sanitize_format(p); switch (p->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (unlikely(!ops->vidioc_try_fmt_vid_cap)) break; CLEAR_AFTER_FIELD(p, fmt.pix); ret = ops->vidioc_try_fmt_vid_cap(file, fh, arg); /* just in case the driver zeroed it again */ p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; if (vfd->vfl_type == VFL_TYPE_TOUCH) v4l_pix_format_touch(&p->fmt.pix); return ret; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); return ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) break; CLEAR_AFTER_FIELD(p, fmt.win); return ops->vidioc_try_fmt_vid_overlay(file, fh, arg); case V4L2_BUF_TYPE_VBI_CAPTURE: if (unlikely(!ops->vidioc_try_fmt_vbi_cap)) break; CLEAR_AFTER_FIELD(p, fmt.vbi.flags); return ops->vidioc_try_fmt_vbi_cap(file, fh, arg); case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap)) break; CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); return ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OUTPUT: if (unlikely(!ops->vidioc_try_fmt_vid_out)) break; CLEAR_AFTER_FIELD(p, fmt.pix); ret = ops->vidioc_try_fmt_vid_out(file, fh, arg); /* just in case the driver zeroed it again */ p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; return ret; case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); return ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay)) break; CLEAR_AFTER_FIELD(p, fmt.win); return ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg); case V4L2_BUF_TYPE_VBI_OUTPUT: if (unlikely(!ops->vidioc_try_fmt_vbi_out)) break; CLEAR_AFTER_FIELD(p, fmt.vbi.flags); return ops->vidioc_try_fmt_vbi_out(file, fh, arg); case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out)) break; CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); case V4L2_BUF_TYPE_SDR_CAPTURE: if (unlikely(!ops->vidioc_try_fmt_sdr_cap)) break; CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); return ops->vidioc_try_fmt_sdr_cap(file, fh, arg); case V4L2_BUF_TYPE_SDR_OUTPUT: if (unlikely(!ops->vidioc_try_fmt_sdr_out)) break; CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); return ops->vidioc_try_fmt_sdr_out(file, fh, arg); case V4L2_BUF_TYPE_META_CAPTURE: if (unlikely(!ops->vidioc_try_fmt_meta_cap)) break; CLEAR_AFTER_FIELD(p, fmt.meta); return ops->vidioc_try_fmt_meta_cap(file, fh, arg); case V4L2_BUF_TYPE_META_OUTPUT: if (unlikely(!ops->vidioc_try_fmt_meta_out)) break; CLEAR_AFTER_FIELD(p, fmt.meta); return ops->vidioc_try_fmt_meta_out(file, fh, arg); } return -EINVAL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 336794, "input": "fill_yin_type(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, struct lys_type *type, int parenttype, struct unres_schema *unres) { const char *value, *name, *module_name = NULL; struct lys_node *siter; struct lyxml_elem *next, *next2, *node, *child, exts; struct lys_restr **restrs, *restr; struct lys_type_bit bit, *bits_sc = NULL; struct lys_type_enum *enms_sc = NULL; /* shortcut */ struct lys_type *dertype; struct ly_ctx *ctx = module->ctx; int rc, val_set, c_ftrs, c_ext = 0; unsigned int i, j; int ret = -1; int64_t v, v_ = 0; int64_t p, p_; size_t len; int in_grp = 0; char *buf, modifier; /* init */ memset(&exts, 0, sizeof exts); GETVAL(ctx, value, yin, \"name\"); value = transform_schema2json(module, value); if (!value) { goto error; } i = parse_identifier(value); if (i < 1) { LOGVAL(ctx, LYE_INCHAR, LY_VLOG_NONE, NULL, value[-i], &value[-i]); lydict_remove(ctx, value); goto error; } /* module name */ name = value; if (value[i]) { module_name = lydict_insert(ctx, value, i); name += i; if ((name[0] != ':') || (parse_identifier(name + 1) < 1)) { LOGVAL(ctx, LYE_INCHAR, LY_VLOG_NONE, NULL, name[0], name); lydict_remove(ctx, module_name); lydict_remove(ctx, value); goto error; } /* name is in dictionary, but moved */ ++name; } rc = resolve_superior_type(name, module_name, module, parent, &type->der); if (rc == -1) { LOGVAL(ctx, LYE_INMOD, LY_VLOG_NONE, NULL, module_name); lydict_remove(ctx, module_name); lydict_remove(ctx, value); goto error; /* the type could not be resolved or it was resolved to an unresolved typedef */ } else if (rc == EXIT_FAILURE) { LOGVAL(ctx, LYE_NORESOLV, LY_VLOG_NONE, NULL, \"type\", name); lydict_remove(ctx, module_name); lydict_remove(ctx, value); ret = EXIT_FAILURE; goto error; } lydict_remove(ctx, module_name); lydict_remove(ctx, value); if (type->value_flags & LY_VALUE_UNRESGRP) { /* resolved type in grouping, decrease the grouping's nacm number to indicate that one less * unresolved item left inside the grouping, LYTYPE_GRP used as a flag for types inside a grouping. */ for (siter = parent; siter && (siter->nodetype != LYS_GROUPING); siter = lys_parent(siter)); if (siter) { assert(((struct lys_node_grp *)siter)->unres_count); ((struct lys_node_grp *)siter)->unres_count--; } else { LOGINT(ctx); goto error; } type->value_flags &= ~LY_VALUE_UNRESGRP; } type->base = type->der->type.base; /* check status */ if (lyp_check_status(type->parent->flags, type->parent->module, type->parent->name, type->der->flags, type->der->module, type->der->name, parent)) { return -1; } /* parse extension instances */ LY_TREE_FOR_SAFE(yin->child, next, node) { if (!node->ns) { /* garbage */ lyxml_free(ctx, node); continue; } else if (!strcmp(node->ns->value, LY_NSYIN)) { /* YANG (YIN) statements - process later */ continue; } YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, type->ext_size, \"extensions\", \"type\", error); lyxml_unlink_elem(ctx, node, 2); lyxml_add_child(ctx, &exts, node); c_ext++; } if (c_ext) { type->ext = calloc(c_ext, sizeof *type->ext); LY_CHECK_ERR_GOTO(!type->ext, LOGMEM(ctx), error); LY_TREE_FOR_SAFE(exts.child, next, node) { rc = lyp_yin_fill_ext(type, LYEXT_PAR_TYPE, 0, 0, module, node, &type->ext, &type->ext_size, unres); if (rc) { goto error; } } lyp_reduce_ext_list(&type->ext, type->ext_size, c_ext + type->ext_size); } switch (type->base) { case LY_TYPE_BITS: /* RFC 6020 9.7.4 - bit */ /* get bit specifications, at least one must be present */ LY_TREE_FOR_SAFE(yin->child, next, node) { if (!strcmp(node->name, \"bit\")) { YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, type->info.bits.count, type->info.bits.count, \"bits\", \"type\", type->info.bits.count = 0; goto error); type->info.bits.count++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); type->info.bits.count = 0; goto error; } } dertype = &type->der->type; if (!dertype->der) { if (!type->info.bits.count) { /* type is derived directly from buit-in bits type and bit statement is required */ LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"bit\", \"type\"); goto error; } } else { for (; !dertype->info.enums.count; dertype = &dertype->der->type); if (module->version < 2 && type->info.bits.count) { /* type is not directly derived from buit-in bits type and bit statement is prohibited, * since YANG 1.1 the bit statements can be used to restrict the base bits type */ LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, \"bit\"); type->info.bits.count = 0; goto error; } } if (type->info.bits.count) { type->info.bits.bit = calloc(type->info.bits.count, sizeof *type->info.bits.bit); LY_CHECK_ERR_GOTO(!type->info.bits.bit, LOGMEM(ctx), error); } p = 0; i = 0; LY_TREE_FOR(yin->child, next) { c_ftrs = 0; GETVAL(ctx, value, next, \"name\"); if (lyp_check_identifier(ctx, value, LY_IDENT_SIMPLE, NULL, NULL)) { goto error; } type->info.bits.bit[i].name = lydict_insert(ctx, value, strlen(value)); if (read_yin_common(module, NULL, &type->info.bits.bit[i], LYEXT_PAR_TYPE_BIT, next, 0, unres)) { type->info.bits.count = i + 1; goto error; } if (!dertype->der) { /* directly derived type from bits built-in type */ /* check the name uniqueness */ for (j = 0; j < i; j++) { if (!strcmp(type->info.bits.bit[j].name, type->info.bits.bit[i].name)) { LOGVAL(ctx, LYE_BITS_DUPNAME, LY_VLOG_NONE, NULL, type->info.bits.bit[i].name); type->info.bits.count = i + 1; goto error; } } } else { /* restricted bits type - the name MUST be used in the base type */ bits_sc = dertype->info.bits.bit; for (j = 0; j < dertype->info.bits.count; j++) { if (ly_strequal(bits_sc[j].name, value, 1)) { break; } } if (j == dertype->info.bits.count) { LOGVAL(ctx, LYE_BITS_INNAME, LY_VLOG_NONE, NULL, value); type->info.bits.count = i + 1; goto error; } } p_ = -1; LY_TREE_FOR_SAFE(next->child, next2, node) { if (!node->ns) { /* garbage */ continue; } else if (strcmp(node->ns->value, LY_NSYIN)) { /* extension */ if (lyp_yin_parse_subnode_ext(module, &type->info.bits.bit[i], LYEXT_PAR_TYPE_BIT, node, LYEXT_SUBSTMT_SELF, 0, unres)) { goto error; } } else if (!strcmp(node->name, \"position\")) { if (p_ != -1) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name); type->info.bits.count = i + 1; goto error; } GETVAL(ctx, value, node, \"value\"); p_ = strtoll(value, NULL, 10); /* range check */ if (p_ < 0 || p_ > UINT32_MAX) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"bit/position\"); type->info.bits.count = i + 1; goto error; } type->info.bits.bit[i].pos = (uint32_t)p_; if (!dertype->der) { /* directly derived type from bits built-in type */ /* keep the highest enum value for automatic increment */ if (type->info.bits.bit[i].pos >= p) { p = type->info.bits.bit[i].pos; p++; } else { /* check that the value is unique */ for (j = 0; j < i; j++) { if (type->info.bits.bit[j].pos == type->info.bits.bit[i].pos) { LOGVAL(ctx, LYE_BITS_DUPVAL, LY_VLOG_NONE, NULL, type->info.bits.bit[i].pos, type->info.bits.bit[i].name, type->info.bits.bit[j].name); type->info.bits.count = i + 1; goto error; } } } } if (lyp_yin_parse_subnode_ext(module, &type->info.bits.bit[i], LYEXT_PAR_TYPE_BIT, node, LYEXT_SUBSTMT_POSITION, 0, unres)) { goto error; } for (j = 0; j < type->info.bits.bit[i].ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (type->info.bits.bit[i].ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } } else if ((module->version >= 2) && !strcmp(node->name, \"if-feature\")) { YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, type->info.bits.bit[i].iffeature_size, \"if-features\", \"bit\", error); c_ftrs++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } if (!dertype->der) { /* directly derived type from bits built-in type */ if (p_ == -1) { /* assign value automatically */ if (p > UINT32_MAX) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, \"4294967295\", \"bit/position\"); type->info.bits.count = i + 1; goto error; } type->info.bits.bit[i].pos = (uint32_t)p; type->info.bits.bit[i].flags |= LYS_AUTOASSIGNED; p++; } } else { /* restricted bits type */ if (p_ == -1) { /* automatically assign position from base type */ type->info.bits.bit[i].pos = bits_sc[j].pos; type->info.bits.bit[i].flags |= LYS_AUTOASSIGNED; } else { /* check that the assigned position corresponds to the original * position of the bit in the base type */ if (p_ != bits_sc[j].pos) { /* p_ - assigned position in restricted bits * bits_sc[j].pos - position assigned to the corresponding bit (detected above) in base type */ LOGVAL(ctx, LYE_BITS_INVAL, LY_VLOG_NONE, NULL, type->info.bits.bit[i].pos, type->info.bits.bit[i].name, bits_sc[j].pos); type->info.bits.count = i + 1; goto error; } } } /* if-features */ if (c_ftrs) { bits_sc = &type->info.bits.bit[i]; bits_sc->iffeature = calloc(c_ftrs, sizeof *bits_sc->iffeature); if (!bits_sc->iffeature) { LOGMEM(ctx); type->info.bits.count = i + 1; goto error; } LY_TREE_FOR(next->child, node) { if (!strcmp(node->name, \"if-feature\")) { rc = fill_yin_iffeature((struct lys_node *)type->parent, 0, node, &bits_sc->iffeature[bits_sc->iffeature_size], unres); bits_sc->iffeature_size++; if (rc) { type->info.bits.count = i + 1; goto error; } } } } /* keep them ordered by position */ j = i; while (j && type->info.bits.bit[j - 1].pos > type->info.bits.bit[j].pos) { /* switch them */ memcpy(&bit, &type->info.bits.bit[j], sizeof bit); memcpy(&type->info.bits.bit[j], &type->info.bits.bit[j - 1], sizeof bit); memcpy(&type->info.bits.bit[j - 1], &bit, sizeof bit); j--; } ++i; } break; case LY_TYPE_DEC64: /* RFC 6020 9.2.4 - range and 9.3.4 - fraction-digits */ LY_TREE_FOR(yin->child, node) { if (!strcmp(node->name, \"range\")) { if (type->info.dec64.range) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); type->info.dec64.range = calloc(1, sizeof *type->info.dec64.range); LY_CHECK_ERR_GOTO(!type->info.dec64.range, LOGMEM(ctx), error); type->info.dec64.range->expr = lydict_insert(ctx, value, 0); /* get possible substatements */ if (read_restr_substmt(module, type->info.dec64.range, node, unres)) { goto error; } for (j = 0; j < type->info.dec64.range->ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (type->info.dec64.range->ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } } else if (!strcmp(node->name, \"fraction-digits\")) { if (type->info.dec64.dig) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); v = strtol(value, NULL, 10); /* range check */ if (v < 1 || v > 18) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name); goto error; } type->info.dec64.dig = (uint8_t)v; type->info.dec64.div = 10; for (i = 1; i < v; i++) { type->info.dec64.div *= 10; } /* extensions */ if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_DIGITS, 0, unres)) { goto error; } } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } /* mandatory sub-statement(s) check */ if (!type->info.dec64.dig && !type->der->type.der) { /* decimal64 type directly derived from built-in type requires fraction-digits */ LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"fraction-digits\", \"type\"); goto error; } if (type->info.dec64.dig && type->der->type.der) { /* type is not directly derived from buit-in type and fraction-digits statement is prohibited */ LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, \"fraction-digits\"); goto error; } /* copy fraction-digits specification from parent type for easier internal use */ if (type->der->type.der) { type->info.dec64.dig = type->der->type.info.dec64.dig; type->info.dec64.div = type->der->type.info.dec64.div; } if (type->info.dec64.range && lyp_check_length_range(ctx, type->info.dec64.range->expr, type)) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"range\"); goto error; } break; case LY_TYPE_ENUM: /* RFC 6020 9.6 - enum */ /* get enum specifications, at least one must be present */ LY_TREE_FOR_SAFE(yin->child, next, node) { if (!strcmp(node->name, \"enum\")) { YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, type->info.enums.count, type->info.enums.count, \"enums\", \"type\", type->info.enums.count = 0; goto error); type->info.enums.count++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); type->info.enums.count = 0; goto error; } } dertype = &type->der->type; if (!dertype->der) { if (!type->info.enums.count) { /* type is derived directly from buit-in enumeartion type and enum statement is required */ LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"enum\", \"type\"); goto error; } } else { for (; !dertype->info.enums.count; dertype = &dertype->der->type); if (module->version < 2 && type->info.enums.count) { /* type is not directly derived from built-in enumeration type and enum statement is prohibited * in YANG 1.0, since YANG 1.1 enum statements can be used to restrict the base enumeration type */ LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, \"enum\"); type->info.enums.count = 0; goto error; } } if (type->info.enums.count) { type->info.enums.enm = calloc(type->info.enums.count, sizeof *type->info.enums.enm); LY_CHECK_ERR_GOTO(!type->info.enums.enm, LOGMEM(ctx), error); } v = 0; i = 0; LY_TREE_FOR(yin->child, next) { c_ftrs = 0; GETVAL(ctx, value, next, \"name\"); if (!value[0]) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"enum name\"); LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, \"Enum name must not be empty.\"); goto error; } type->info.enums.enm[i].name = lydict_insert(ctx, value, strlen(value)); if (read_yin_common(module, NULL, &type->info.enums.enm[i], LYEXT_PAR_TYPE_ENUM, next, 0, unres)) { type->info.enums.count = i + 1; goto error; } /* the assigned name MUST NOT have any leading or trailing whitespace characters */ value = type->info.enums.enm[i].name; if (isspace(value[0]) || isspace(value[strlen(value) - 1])) { LOGVAL(ctx, LYE_ENUM_WS, LY_VLOG_NONE, NULL, value); type->info.enums.count = i + 1; goto error; } if (!dertype->der) { /* directly derived type from enumeration built-in type */ /* check the name uniqueness */ for (j = 0; j < i; j++) { if (ly_strequal(type->info.enums.enm[j].name, value, 1)) { LOGVAL(ctx, LYE_ENUM_DUPNAME, LY_VLOG_NONE, NULL, value); type->info.enums.count = i + 1; goto error; } } } else { /* restricted enumeration type - the name MUST be used in the base type */ enms_sc = dertype->info.enums.enm; for (j = 0; j < dertype->info.enums.count; j++) { if (ly_strequal(enms_sc[j].name, value, 1)) { break; } } if (j == dertype->info.enums.count) { LOGVAL(ctx, LYE_ENUM_INNAME, LY_VLOG_NONE, NULL, value); type->info.enums.count = i + 1; goto error; } } val_set = 0; LY_TREE_FOR_SAFE(next->child, next2, node) { if (!node->ns) { /* garbage */ continue; } else if (strcmp(node->ns->value, LY_NSYIN)) { /* extensions */ if (lyp_yin_parse_subnode_ext(module, &type->info.enums.enm[i], LYEXT_PAR_TYPE_ENUM, node, LYEXT_SUBSTMT_SELF, 0, unres)) { goto error; } } else if (!strcmp(node->name, \"value\")) { if (val_set) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name); type->info.enums.count = i + 1; goto error; } GETVAL(ctx, value, node, \"value\"); v_ = strtoll(value, NULL, 10); /* range check */ if (v_ < INT32_MIN || v_ > INT32_MAX) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"enum/value\"); type->info.enums.count = i + 1; goto error; } type->info.enums.enm[i].value = v_; if (!dertype->der) { /* directly derived type from enumeration built-in type */ if (!i) { /* change value, which is assigned automatically, if first enum has value. */ v = type->info.enums.enm[i].value; v++; } else { /* keep the highest enum value for automatic increment */ if (type->info.enums.enm[i].value >= v) { v = type->info.enums.enm[i].value; v++; } else { /* check that the value is unique */ for (j = 0; j < i; j++) { if (type->info.enums.enm[j].value == type->info.enums.enm[i].value) { LOGVAL(ctx, LYE_ENUM_DUPVAL, LY_VLOG_NONE, NULL, type->info.enums.enm[i].value, type->info.enums.enm[i].name, type->info.enums.enm[j].name); type->info.enums.count = i + 1; goto error; } } } } } val_set = 1; if (lyp_yin_parse_subnode_ext(module, &type->info.enums.enm[i], LYEXT_PAR_TYPE_ENUM, node, LYEXT_SUBSTMT_VALUE, 0, unres)) { goto error; } for (j = 0; j < type->info.enums.enm[i].ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (type->info.enums.enm[i].ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } } else if ((module->version >= 2) && !strcmp(node->name, \"if-feature\")) { YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, type->info.enums.enm[i].iffeature_size, \"if-features\", \"enum\", error); c_ftrs++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } if (!dertype->der) { /* directly derived type from enumeration */ if (!val_set) { /* assign value automatically */ if (v > INT32_MAX) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, \"2147483648\", \"enum/value\"); type->info.enums.count = i + 1; goto error; } type->info.enums.enm[i].value = v; type->info.enums.enm[i].flags |= LYS_AUTOASSIGNED; v++; } } else { /* restricted enum type */ if (!val_set) { /* automatically assign value from base type */ type->info.enums.enm[i].value = enms_sc[j].value; type->info.enums.enm[i].flags |= LYS_AUTOASSIGNED; } else { /* check that the assigned value corresponds to the original * value of the enum in the base type */ if (v_ != enms_sc[j].value) { /* v_ - assigned value in restricted enum * enms_sc[j].value - value assigned to the corresponding enum (detected above) in base type */ LOGVAL(ctx, LYE_ENUM_INVAL, LY_VLOG_NONE, NULL, type->info.enums.enm[i].value, type->info.enums.enm[i].name, enms_sc[j].value); type->info.enums.count = i + 1; goto error; } } } /* if-features */ if (c_ftrs) { enms_sc = &type->info.enums.enm[i]; enms_sc->iffeature = calloc(c_ftrs, sizeof *enms_sc->iffeature); if (!enms_sc->iffeature) { LOGMEM(ctx); type->info.enums.count = i + 1; goto error; } LY_TREE_FOR(next->child, node) { if (!strcmp(node->name, \"if-feature\")) { rc = fill_yin_iffeature((struct lys_node *)type->parent, 0, node, &enms_sc->iffeature[enms_sc->iffeature_size], unres); enms_sc->iffeature_size++; if (rc) { type->info.enums.count = i + 1; goto error; } } } } ++i; } break; case LY_TYPE_IDENT: /* RFC 6020 9.10 - base */ /* get base specification, at least one must be present */ LY_TREE_FOR_SAFE(yin->child, next, node) { if (strcmp(node->name, \"base\")) { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } GETVAL(ctx, value, yin->child, \"name\"); /* store in the JSON format */ value = transform_schema2json(module, value); if (!value) { goto error; } rc = unres_schema_add_str(module, unres, type, UNRES_TYPE_IDENTREF, value); lydict_remove(ctx, value); if (rc == -1) { goto error; } if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_BASE, 0, unres)) { goto error; } } if (!yin->child) { if (type->der->type.der) { /* this is just a derived type with no base required */ break; } LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"base\", \"type\"); goto error; } else { if (type->der->type.der) { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, \"base\"); goto error; } } if (yin->child->next) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, yin->child->next->name, yin->name); goto error; } break; case LY_TYPE_INST: /* RFC 6020 9.13.2 - require-instance */ LY_TREE_FOR(yin->child, node) { if (!strcmp(node->name, \"require-instance\")) { if (type->info.inst.req) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); if (!strcmp(value, \"true\")) { type->info.inst.req = 1; } else if (!strcmp(value, \"false\")) { type->info.inst.req = -1; } else { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name); goto error; } /* extensions */ if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_REQINSTANCE, 0, unres)) { goto error; } } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } if (type->der->type.der && !type->info.inst.req) { /* inherit require-instance property */ type->info.inst.req = type->der->type.info.inst.req; } break; case LY_TYPE_BINARY: /* RFC 6020 9.8.1, 9.4.4 - length, number of octets it contains */ case LY_TYPE_INT8: case LY_TYPE_INT16: case LY_TYPE_INT32: case LY_TYPE_INT64: case LY_TYPE_UINT8: case LY_TYPE_UINT16: case LY_TYPE_UINT32: case LY_TYPE_UINT64: /* RFC 6020 9.2.4 - range */ /* length and range are actually the same restriction, so process * them by this common code, we just need to differ the name and * structure where the information will be stored */ if (type->base == LY_TYPE_BINARY) { restrs = &type->info.binary.length; name = \"length\"; } else { restrs = &type->info.num.range; name = \"range\"; } LY_TREE_FOR(yin->child, node) { if (!strcmp(node->name, name)) { if (*restrs) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); if (lyp_check_length_range(ctx, value, type)) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, name); goto error; } *restrs = calloc(1, sizeof **restrs); LY_CHECK_ERR_GOTO(!(*restrs), LOGMEM(ctx), error); (*restrs)->expr = lydict_insert(ctx, value, 0); /* get possible substatements */ if (read_restr_substmt(module, *restrs, node, unres)) { goto error; } for (j = 0; j < (*restrs)->ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if ((*restrs)->ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } break; case LY_TYPE_LEAFREF: /* flag resolving for later use */ if (!parenttype && lys_ingrouping(parent)) { /* just a flag - do not resolve */ parenttype = 1; } /* RFC 6020 9.9.2 - path */ LY_TREE_FOR(yin->child, node) { if (!strcmp(node->name, \"path\") && !type->der->type.der) { /* keep path for later */ } else if (module->version >= 2 && !strcmp(node->name, \"require-instance\")) { if (type->info.lref.req) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); if (!strcmp(value, \"true\")) { type->info.lref.req = 1; } else if (!strcmp(value, \"false\")) { type->info.lref.req = -1; } else { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name); goto error; } /* extensions */ if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_REQINSTANCE, 0, unres)) { goto error; } } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } /* now that require-instance is properly set, try to find and resolve path */ LY_TREE_FOR(yin->child, node) { if (!strcmp(node->name, \"path\") && !type->der->type.der) { if (type->info.lref.path) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); /* store in the JSON format */ type->info.lref.path = transform_schema2json(module, value); if (!type->info.lref.path) { goto error; } /* try to resolve leafref path only when this is instantiated * leaf, so it is not: * - typedef's type, * - in grouping definition, * - just instantiated in a grouping definition, * because in those cases the nodes referenced in path might not be present * and it is not a bug. */ if (!parenttype && unres_schema_add_node(module, unres, type, UNRES_TYPE_LEAFREF, parent) == -1) { goto error; } /* extensions */ if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_PATH, 0, unres)) { goto error; } break; } } if (!type->info.lref.path) { if (!type->der->type.der) { LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"path\", \"type\"); goto error; } else { /* copy leafref definition into the derived type */ type->info.lref.path = lydict_insert(ctx, type->der->type.info.lref.path, 0); if (!type->info.lref.req) { type->info.lref.req = type->der->type.info.lref.req; } /* and resolve the path at the place we are (if not in grouping/typedef) */ if (!parenttype && unres_schema_add_node(module, unres, type, UNRES_TYPE_LEAFREF, parent) == -1) { goto error; } } } break; case LY_TYPE_STRING: /* RFC 6020 9.4.4 - length */ /* RFC 6020 9.4.6 - pattern */ i = 0; LY_TREE_FOR_SAFE(yin->child, next, node) { if (!strcmp(node->name, \"length\")) { if (type->info.str.length) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name); goto error; } GETVAL(ctx, value, node, \"value\"); if (lyp_check_length_range(ctx, value, type)) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"length\"); goto error; } type->info.str.length = calloc(1, sizeof *type->info.str.length); LY_CHECK_ERR_GOTO(!type->info.str.length, LOGMEM(ctx), error); type->info.str.length->expr = lydict_insert(ctx, value, 0); /* get possible sub-statements */ if (read_restr_substmt(module, type->info.str.length, node, unres)) { goto error; } for (j = 0; j < type->info.str.length->ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (type->info.str.length->ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } lyxml_free(ctx, node); } else if (!strcmp(node->name, \"pattern\")) { YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, i, type->info.str.pat_count, \"patterns\", \"type\", error); i++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } /* store patterns in array */ if (i) { if (!parenttype && parent && lys_ingrouping(parent)) { in_grp = 1; } type->info.str.patterns = calloc(i, sizeof *type->info.str.patterns); LY_CHECK_ERR_GOTO(!type->info.str.patterns, LOGMEM(ctx), error); #ifdef LY_ENABLED_CACHE if (!in_grp) { /* do not compile patterns in groupings */ type->info.str.patterns_pcre = calloc(2 * i, sizeof *type->info.str.patterns_pcre); LY_CHECK_ERR_GOTO(!type->info.str.patterns_pcre, LOGMEM(ctx), error); } #endif LY_TREE_FOR(yin->child, node) { GETVAL(ctx, value, node, \"value\"); if (in_grp) { /* in grouping, just check the pattern syntax */ if (!(ctx->models.flags & LY_CTX_TRUSTED) && lyp_check_pattern(ctx, value, NULL)) { goto error; } } #ifdef LY_ENABLED_CACHE else { /* outside grouping, check syntax and precompile pattern for later use by libpcre */ if (lyp_precompile_pattern(ctx, value, (pcre **)&type->info.str.patterns_pcre[type->info.str.pat_count * 2], (pcre_extra **)&type->info.str.patterns_pcre[type->info.str.pat_count * 2 + 1])) { goto error; } } #endif restr = &type->info.str.patterns[type->info.str.pat_count]; /* shortcut */ type->info.str.pat_count++; modifier = 0x06; /* ACK */ name = NULL; if (module->version >= 2) { LY_TREE_FOR_SAFE(node->child, next2, child) { if (child->ns && !strcmp(child->ns->value, LY_NSYIN) && !strcmp(child->name, \"modifier\")) { if (name) { LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, \"modifier\", node->name); goto error; } GETVAL(ctx, name, child, \"value\"); if (!strcmp(name, \"invert-match\")) { modifier = 0x15; /* NACK */ } else { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, name, \"modifier\"); goto error; } /* get extensions of the modifier */ if (lyp_yin_parse_subnode_ext(module, restr, LYEXT_PAR_RESTR, child, LYEXT_SUBSTMT_MODIFIER, 0, unres)) { goto error; } lyxml_free(ctx, child); } } } len = strlen(value); buf = malloc((len + 2) * sizeof *buf); /* modifier byte + value + terminating NULL byte */ LY_CHECK_ERR_GOTO(!buf, LOGMEM(ctx), error); buf[0] = modifier; strcpy(&buf[1], value); restr->expr = lydict_insert_zc(ctx, buf); /* get possible sub-statements */ if (read_restr_substmt(module, restr, node, unres)) { goto error; } for (j = 0; j < restr->ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (restr->ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } } } break; case LY_TYPE_UNION: /* RFC 6020 7.4 - type */ /* count number of types in union */ i = 0; LY_TREE_FOR_SAFE(yin->child, next, node) { if (!strcmp(node->name, \"type\")) { if (type->der->type.der) { /* type can be a substatement only in \"union\" type, not in derived types */ LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, \"type\", \"derived type\"); goto error; } YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, i, type->info.uni.count, \"types\", \"type\", error); i++; } else { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name); goto error; } } if (!i && !type->der->type.der) { LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, \"type\", \"(union) type\"); goto error; } /* inherit instid presence information */ if ((type->der->type.base == LY_TYPE_UNION) && type->der->type.info.uni.has_ptr_type) { type->info.uni.has_ptr_type = 1; } /* allocate array for union's types ... */ if (i) { type->info.uni.types = calloc(i, sizeof *type->info.uni.types); LY_CHECK_ERR_GOTO(!type->info.uni.types, LOGMEM(ctx), error); } /* ... and fill the structures */ LY_TREE_FOR(yin->child, node) { type->info.uni.types[type->info.uni.count].parent = type->parent; rc = fill_yin_type(module, parent, node, &type->info.uni.types[type->info.uni.count], parenttype, unres); if (!rc) { type->info.uni.count++; if (module->version < 2) { /* union's type cannot be empty or leafref */ if (type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_EMPTY) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, \"empty\", node->name); rc = -1; } else if (type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_LEAFREF) { LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, \"leafref\", node->name); rc = -1; } } if ((type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_INST) || (type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_LEAFREF) || ((type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_UNION) && type->info.uni.types[type->info.uni.count - 1].info.uni.has_ptr_type)) { type->info.uni.has_ptr_type = 1; } } if (rc) { /* even if we got EXIT_FAILURE, throw it all away, too much trouble doing something else */ for (i = 0; i < type->info.uni.count; ++i) { lys_type_free(ctx, &type->info.uni.types[i], NULL); } free(type->info.uni.types); type->info.uni.types = NULL; type->info.uni.count = 0; type->info.uni.has_ptr_type = 0; type->der = NULL; type->base = LY_TYPE_DER; if (rc == EXIT_FAILURE) { ret = EXIT_FAILURE; } goto error; } } break; case LY_TYPE_BOOL: case LY_TYPE_EMPTY: /* no sub-statement allowed */ if (yin->child) { LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, yin->child->name); goto error; } break; default: LOGINT(ctx); goto error; } for(j = 0; j < type->ext_size; ++j) { /* set flag, which represent LYEXT_OPT_VALID */ if (type->ext[j]->flags & LYEXT_OPT_VALID) { type->parent->flags |= LYS_VALID_EXT; break; } } /* if derived type has extension, which need validate data */ dertype = &type->der->type; while (dertype->der) { if (dertype->parent->flags & LYS_VALID_EXT) { type->parent->flags |= LYS_VALID_EXT; } dertype = &dertype->der->type; } return EXIT_SUCCESS; error: lyxml_free_withsiblings(ctx, exts.child); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 375203, "input": "int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize) { sigset_t kmask; if (!umask) return 0; if (sigsetsize != sizeof(sigset_t)) return -EINVAL; if (copy_from_user(&kmask, umask, sizeof(sigset_t))) return -EFAULT; set_restore_sigmask(); current->saved_sigmask = current->blocked; set_current_blocked(&kmask); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 319452, "input": "void LibRaw::nikon_read_curve() { ushort ver0, ver1, vpred[2][2], hpred[2], csize; int i, step, max; fseek(ifp, meta_offset, SEEK_SET); ver0 = fgetc(ifp); ver1 = fgetc(ifp); if (ver0 == 0x49 || ver1 == 0x58) fseek(ifp, 2110, SEEK_CUR); read_shorts(vpred[0], 4); max = 1 << tiff_bps & 0x7fff; if ((csize = get2()) > 1) step = max / (csize - 1); if (ver0 == 0x44 && (ver1 == 0x20 || (ver1 == 0x40 && step > 3)) && step > 0) { if (ver1 == 0x40) { step /= 4; max /= 4; } for (i = 0; i < csize; i++) curve[i * step] = get2(); for (i = 0; i < max; i++) curve[i] = (curve[i - i % step] * (step - i % step) + curve[i - i % step + step] * (i % step)) / step; } else if (ver0 != 0x46 && csize <= 0x4001) read_shorts(curve, max = csize); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 496487, "input": "add_count (uintmax_t a, uintmax_t b) { uintmax_t sum = a + b; if (sum < a) error (EXIT_TROUBLE, 0, _(\"input is too large to count\")); return sum; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 224959, "input": "snmp_ber_encode_length(snmp_packet_t *snmp_packet, uint16_t length) { if(length > 0xFF) { if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = (uint8_t)length & 0xFF; snmp_packet->used++; if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = (uint8_t)(length >> 8) & 0xFF; snmp_packet->used++; if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = 0x82; snmp_packet->used++; } else if(length > 0x7F) { if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = (uint8_t)length & 0xFF; snmp_packet->used++; if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = 0x81; snmp_packet->used++; } else { if(snmp_packet->used == snmp_packet->max) { return 0; } *snmp_packet->out-- = (uint8_t)length & 0x7F; snmp_packet->used++; } return 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 199924, "input": "CallResult Interpreter::interpretFunction( Runtime *runtime, InterpreterState &state) { // The interepter is re-entrant and also saves/restores its IP via the runtime // whenever a call out is made (see the CAPTURE_IP_* macros). As such, failure // to preserve the IP across calls to interpeterFunction() disrupt interpreter // calls further up the C++ callstack. The RAII utility class below makes sure // we always do this correctly. // // TODO: The IPs stored in the C++ callstack via this holder will generally be // the same as in the JS stack frames via the Saved IP field. We can probably // get rid of one of these redundant stores. Doing this isn't completely // trivial as there are currently cases where we re-enter the interpreter // without calling Runtime::saveCallerIPInStackFrame(), and there are features // (I think mostly the debugger + stack traces) which implicitly rely on // this behavior. At least their tests break if this behavior is not // preserved. struct IPSaver { IPSaver(Runtime *runtime) : ip_(runtime->getCurrentIP()), runtime_(runtime) {} ~IPSaver() { runtime_->setCurrentIP(ip_); } private: const Inst *ip_; Runtime *runtime_; }; IPSaver ipSaver(runtime); #ifndef HERMES_ENABLE_DEBUGGER static_assert(!SingleStep, \"can't use single-step mode without the debugger\"); #endif // Make sure that the cache can use an optimization by avoiding a branch to // access the property storage. static_assert( HiddenClass::kDictionaryThreshold <= SegmentedArray::kValueToSegmentThreshold, \"Cannot avoid branches in cache check if the dictionary \" \"crossover point is larger than the inline storage\"); CodeBlock *curCodeBlock = state.codeBlock; const Inst *ip = nullptr; // Holds runtime->currentFrame_.ptr()-1 which is the first local // register. This eliminates the indirect load from Runtime and the -1 offset. PinnedHermesValue *frameRegs; // Strictness of current function. bool strictMode; // Default flags when accessing properties. PropOpFlags defaultPropOpFlags; // These CAPTURE_IP* macros should wrap around any major calls out of the // interpeter loop. They stash and retrieve the IP via the current Runtime // allowing the IP to be externally observed and even altered to change the flow // of execution. Explicitly saving AND restoring the IP from the Runtime in this // way means the C++ compiler will keep IP in a register within the rest of the // interpeter loop. // // When assertions are enabled we take the extra step of \"invalidating\" the IP // between captures so we can detect if it's erroneously accessed. // // In some cases we explicitly don't want to invalidate the IP and instead want // it to stay set. For this we use the *NO_INVALIDATE variants. This comes up // when we're performing a call operation which may re-enter the interpeter // loop, and so need the IP available for the saveCallerIPInStackFrame() call // when we next enter. #define CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr) \\ runtime->setCurrentIP(ip); \\ dst = expr; \\ ip = runtime->getCurrentIP(); #ifdef NDEBUG #define CAPTURE_IP(expr) \\ runtime->setCurrentIP(ip); \\ (void)expr; \\ ip = runtime->getCurrentIP(); #define CAPTURE_IP_ASSIGN(dst, expr) CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr) #else // !NDEBUG #define CAPTURE_IP(expr) \\ runtime->setCurrentIP(ip); \\ (void)expr; \\ ip = runtime->getCurrentIP(); \\ runtime->invalidateCurrentIP(); #define CAPTURE_IP_ASSIGN(dst, expr) \\ runtime->setCurrentIP(ip); \\ dst = expr; \\ ip = runtime->getCurrentIP(); \\ runtime->invalidateCurrentIP(); #endif // NDEBUG LLVM_DEBUG(dbgs() << \"interpretFunction() called\\n\"); ScopedNativeDepthTracker depthTracker{runtime}; if (LLVM_UNLIKELY(depthTracker.overflowed())) { return runtime->raiseStackOverflow(Runtime::StackOverflowKind::NativeStack); } if (!SingleStep) { if (auto jitPtr = runtime->jitContext_.compile(runtime, curCodeBlock)) { return (*jitPtr)(runtime); } } GCScope gcScope(runtime); // Avoid allocating a handle dynamically by reusing this one. MutableHandle<> tmpHandle(runtime); CallResult res{ExecutionStatus::EXCEPTION}; CallResult> resPH{ExecutionStatus::EXCEPTION}; CallResult> resArgs{ExecutionStatus::EXCEPTION}; CallResult boolRes{ExecutionStatus::EXCEPTION}; // Mark the gcScope so we can clear all allocated handles. // Remember how many handles the scope has so we can clear them in the loop. static constexpr unsigned KEEP_HANDLES = 1; assert( gcScope.getHandleCountDbg() == KEEP_HANDLES && \"scope has unexpected number of handles\"); INIT_OPCODE_PROFILER; #if !defined(HERMESVM_PROFILER_EXTERN) tailCall: #endif PROFILER_ENTER_FUNCTION(curCodeBlock); #ifdef HERMES_ENABLE_DEBUGGER runtime->getDebugger().willEnterCodeBlock(curCodeBlock); #endif runtime->getCodeCoverageProfiler().markExecuted(runtime, curCodeBlock); // Update function executionCount_ count curCodeBlock->incrementExecutionCount(); if (!SingleStep) { auto newFrame = runtime->setCurrentFrameToTopOfStack(); runtime->saveCallerIPInStackFrame(); #ifndef NDEBUG runtime->invalidateCurrentIP(); #endif // Point frameRegs to the first register in the new frame. Note that at this // moment technically it points above the top of the stack, but we are never // going to access it. frameRegs = &newFrame.getFirstLocalRef(); #ifndef NDEBUG LLVM_DEBUG( dbgs() << \"function entry: stackLevel=\" << runtime->getStackLevel() << \", argCount=\" << runtime->getCurrentFrame().getArgCount() << \", frameSize=\" << curCodeBlock->getFrameSize() << \"\\n\"); LLVM_DEBUG( dbgs() << \" callee \" << DumpHermesValue( runtime->getCurrentFrame().getCalleeClosureOrCBRef()) << \"\\n\"); LLVM_DEBUG( dbgs() << \" this \" << DumpHermesValue(runtime->getCurrentFrame().getThisArgRef()) << \"\\n\"); for (uint32_t i = 0; i != runtime->getCurrentFrame()->getArgCount(); ++i) { LLVM_DEBUG( dbgs() << \" \" << llvh::format_decimal(i, 4) << \" \" << DumpHermesValue(runtime->getCurrentFrame().getArgRef(i)) << \"\\n\"); } #endif // Allocate the registers for the new frame. if (LLVM_UNLIKELY(!runtime->checkAndAllocStack( curCodeBlock->getFrameSize() + StackFrameLayout::CalleeExtraRegistersAtStart, HermesValue::encodeUndefinedValue()))) goto stackOverflow; ip = (Inst const *)curCodeBlock->begin(); // Check for invalid invocation. if (LLVM_UNLIKELY(curCodeBlock->getHeaderFlags().isCallProhibited( newFrame.isConstructorCall()))) { if (!newFrame.isConstructorCall()) { CAPTURE_IP( runtime->raiseTypeError(\"Class constructor invoked without new\")); } else { CAPTURE_IP(runtime->raiseTypeError(\"Function is not a constructor\")); } goto handleExceptionInParent; } } else { // Point frameRegs to the first register in the frame. frameRegs = &runtime->getCurrentFrame().getFirstLocalRef(); ip = (Inst const *)(curCodeBlock->begin() + state.offset); } assert((const uint8_t *)ip < curCodeBlock->end() && \"CodeBlock is empty\"); INIT_STATE_FOR_CODEBLOCK(curCodeBlock); #define BEFORE_OP_CODE \\ { \\ UPDATE_OPCODE_TIME_SPENT; \\ HERMES_SLOW_ASSERT( \\ curCodeBlock->contains(ip) && \"curCodeBlock must contain ip\"); \\ HERMES_SLOW_ASSERT((printDebugInfo(curCodeBlock, frameRegs, ip), true)); \\ HERMES_SLOW_ASSERT( \\ gcScope.getHandleCountDbg() == KEEP_HANDLES && \\ \"unaccounted handles were created\"); \\ HERMES_SLOW_ASSERT(tmpHandle->isUndefined() && \"tmpHandle not cleared\"); \\ RECORD_OPCODE_START_TIME; \\ INC_OPCODE_COUNT; \\ } #ifdef HERMESVM_INDIRECT_THREADING static void *opcodeDispatch[] = { #define DEFINE_OPCODE(name) &&case_##name, #include \"hermes/BCGen/HBC/BytecodeList.def\" &&case__last}; #define CASE(name) case_##name: #define DISPATCH \\ BEFORE_OP_CODE; \\ if (SingleStep) { \\ state.codeBlock = curCodeBlock; \\ state.offset = CUROFFSET; \\ return HermesValue::encodeUndefinedValue(); \\ } \\ goto *opcodeDispatch[(unsigned)ip->opCode] #else // HERMESVM_INDIRECT_THREADING #define CASE(name) case OpCode::name: #define DISPATCH \\ if (SingleStep) { \\ state.codeBlock = curCodeBlock; \\ state.offset = CUROFFSET; \\ return HermesValue::encodeUndefinedValue(); \\ } \\ continue #endif // HERMESVM_INDIRECT_THREADING #define RUN_DEBUGGER_ASYNC_BREAK(flags) \\ do { \\ CAPTURE_IP_ASSIGN( \\ auto dRes, \\ runDebuggerUpdatingState( \\ (uint8_t)(flags) & \\ (uint8_t)Runtime::AsyncBreakReasonBits::DebuggerExplicit \\ ? Debugger::RunReason::AsyncBreakExplicit \\ : Debugger::RunReason::AsyncBreakImplicit, \\ runtime, \\ curCodeBlock, \\ ip, \\ frameRegs)); \\ if (dRes == ExecutionStatus::EXCEPTION) \\ goto exception; \\ } while (0) for (;;) { BEFORE_OP_CODE; #ifdef HERMESVM_INDIRECT_THREADING goto *opcodeDispatch[(unsigned)ip->opCode]; #else switch (ip->opCode) #endif { const Inst *nextIP; uint32_t idVal; bool tryProp; uint32_t callArgCount; // This is HermesValue::getRaw(), since HermesValue cannot be assigned // to. It is meant to be used only for very short durations, in the // dispatch of call instructions, when there is definitely no possibility // of a GC. HermesValue::RawType callNewTarget; /// Handle an opcode \\p name with an out-of-line implementation in a function /// ExecutionStatus caseName( /// Runtime *, /// PinnedHermesValue *frameRegs, /// Inst *ip) #define CASE_OUTOFLINE(name) \\ CASE(name) { \\ CAPTURE_IP_ASSIGN(auto res, case##name(runtime, frameRegs, ip)); \\ if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \\ goto exception; \\ } \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } /// Implement a binary arithmetic instruction with a fast path where both /// operands are numbers. /// \\param name the name of the instruction. The fast path case will have a /// \"n\" appended to the name. /// \\param oper the C++ operator to use to actually perform the arithmetic /// operation. #define BINOP(name, oper) \\ CASE(name) { \\ if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \\ /* Fast-path. */ \\ CASE(name##N) { \\ O1REG(name) = HermesValue::encodeDoubleValue( \\ oper(O2REG(name).getNumber(), O3REG(name).getNumber())); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } \\ } \\ CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) \\ goto exception; \\ double left = res->getDouble(); \\ CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) \\ goto exception; \\ O1REG(name) = \\ HermesValue::encodeDoubleValue(oper(left, res->getDouble())); \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } /// Implement a shift instruction with a fast path where both /// operands are numbers. /// \\param name the name of the instruction. /// \\param oper the C++ operator to use to actually perform the shift /// operation. /// \\param lConv the conversion function for the LHS of the expression. /// \\param lType the type of the LHS operand. /// \\param returnType the type of the return value. #define SHIFTOP(name, oper, lConv, lType, returnType) \\ CASE(name) { \\ if (LLVM_LIKELY( \\ O2REG(name).isNumber() && \\ O3REG(name).isNumber())) { /* Fast-path. */ \\ auto lnum = static_cast( \\ hermes::truncateToInt32(O2REG(name).getNumber())); \\ auto rnum = static_cast( \\ hermes::truncateToInt32(O3REG(name).getNumber())) & \\ 0x1f; \\ O1REG(name) = HermesValue::encodeDoubleValue( \\ static_cast(lnum oper rnum)); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } \\ CAPTURE_IP_ASSIGN(res, lConv(runtime, Handle<>(&O2REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) { \\ goto exception; \\ } \\ auto lnum = static_cast(res->getNumber()); \\ CAPTURE_IP_ASSIGN(res, toUInt32_RJS(runtime, Handle<>(&O3REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) { \\ goto exception; \\ } \\ auto rnum = static_cast(res->getNumber()) & 0x1f; \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ O1REG(name) = HermesValue::encodeDoubleValue( \\ static_cast(lnum oper rnum)); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } /// Implement a binary bitwise instruction with a fast path where both /// operands are numbers. /// \\param name the name of the instruction. /// \\param oper the C++ operator to use to actually perform the bitwise /// operation. #define BITWISEBINOP(name, oper) \\ CASE(name) { \\ if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \\ /* Fast-path. */ \\ O1REG(name) = HermesValue::encodeDoubleValue( \\ hermes::truncateToInt32(O2REG(name).getNumber()) \\ oper hermes::truncateToInt32(O3REG(name).getNumber())); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } \\ CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) { \\ goto exception; \\ } \\ int32_t left = res->getNumberAs(); \\ CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O3REG(name)))); \\ if (res == ExecutionStatus::EXCEPTION) { \\ goto exception; \\ } \\ O1REG(name) = \\ HermesValue::encodeNumberValue(left oper res->getNumberAs()); \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } /// Implement a comparison instruction. /// \\param name the name of the instruction. /// \\param oper the C++ operator to use to actually perform the fast arithmetic /// comparison. /// \\param operFuncName function to call for the slow-path comparison. #define CONDOP(name, oper, operFuncName) \\ CASE(name) { \\ if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \\ /* Fast-path. */ \\ O1REG(name) = HermesValue::encodeBoolValue( \\ O2REG(name).getNumber() oper O3REG(name).getNumber()); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } \\ CAPTURE_IP_ASSIGN( \\ boolRes, \\ operFuncName( \\ runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \\ if (boolRes == ExecutionStatus::EXCEPTION) \\ goto exception; \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ O1REG(name) = HermesValue::encodeBoolValue(boolRes.getValue()); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } /// Implement a comparison conditional jump with a fast path where both /// operands are numbers. /// \\param name the name of the instruction. The fast path case will have a /// \"N\" appended to the name. /// \\param suffix Optional suffix to be added to the end (e.g. Long) /// \\param oper the C++ operator to use to actually perform the fast arithmetic /// comparison. /// \\param operFuncName function to call for the slow-path comparison. /// \\param trueDest ip value if the conditional evaluates to true /// \\param falseDest ip value if the conditional evaluates to false #define JCOND_IMPL(name, suffix, oper, operFuncName, trueDest, falseDest) \\ CASE(name##suffix) { \\ if (LLVM_LIKELY( \\ O2REG(name##suffix).isNumber() && \\ O3REG(name##suffix).isNumber())) { \\ /* Fast-path. */ \\ CASE(name##N##suffix) { \\ if (O2REG(name##N##suffix) \\ .getNumber() oper O3REG(name##N##suffix) \\ .getNumber()) { \\ ip = trueDest; \\ DISPATCH; \\ } \\ ip = falseDest; \\ DISPATCH; \\ } \\ } \\ CAPTURE_IP_ASSIGN( \\ boolRes, \\ operFuncName( \\ runtime, \\ Handle<>(&O2REG(name##suffix)), \\ Handle<>(&O3REG(name##suffix)))); \\ if (boolRes == ExecutionStatus::EXCEPTION) \\ goto exception; \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ if (boolRes.getValue()) { \\ ip = trueDest; \\ DISPATCH; \\ } \\ ip = falseDest; \\ DISPATCH; \\ } /// Implement a strict equality conditional jump /// \\param name the name of the instruction. /// \\param suffix Optional suffix to be added to the end (e.g. Long) /// \\param trueDest ip value if the conditional evaluates to true /// \\param falseDest ip value if the conditional evaluates to false #define JCOND_STRICT_EQ_IMPL(name, suffix, trueDest, falseDest) \\ CASE(name##suffix) { \\ if (strictEqualityTest(O2REG(name##suffix), O3REG(name##suffix))) { \\ ip = trueDest; \\ DISPATCH; \\ } \\ ip = falseDest; \\ DISPATCH; \\ } /// Implement an equality conditional jump /// \\param name the name of the instruction. /// \\param suffix Optional suffix to be added to the end (e.g. Long) /// \\param trueDest ip value if the conditional evaluates to true /// \\param falseDest ip value if the conditional evaluates to false #define JCOND_EQ_IMPL(name, suffix, trueDest, falseDest) \\ CASE(name##suffix) { \\ CAPTURE_IP_ASSIGN( \\ res, \\ abstractEqualityTest_RJS( \\ runtime, \\ Handle<>(&O2REG(name##suffix)), \\ Handle<>(&O3REG(name##suffix)))); \\ if (res == ExecutionStatus::EXCEPTION) { \\ goto exception; \\ } \\ gcScope.flushToSmallCount(KEEP_HANDLES); \\ if (res->getBool()) { \\ ip = trueDest; \\ DISPATCH; \\ } \\ ip = falseDest; \\ DISPATCH; \\ } /// Implement the long and short forms of a conditional jump, and its negation. #define JCOND(name, oper, operFuncName) \\ JCOND_IMPL( \\ J##name, \\ , \\ oper, \\ operFuncName, \\ IPADD(ip->iJ##name.op1), \\ NEXTINST(J##name)); \\ JCOND_IMPL( \\ J##name, \\ Long, \\ oper, \\ operFuncName, \\ IPADD(ip->iJ##name##Long.op1), \\ NEXTINST(J##name##Long)); \\ JCOND_IMPL( \\ JNot##name, \\ , \\ oper, \\ operFuncName, \\ NEXTINST(JNot##name), \\ IPADD(ip->iJNot##name.op1)); \\ JCOND_IMPL( \\ JNot##name, \\ Long, \\ oper, \\ operFuncName, \\ NEXTINST(JNot##name##Long), \\ IPADD(ip->iJNot##name##Long.op1)); /// Load a constant. /// \\param value is the value to store in the output register. #define LOAD_CONST(name, value) \\ CASE(name) { \\ O1REG(name) = value; \\ ip = NEXTINST(name); \\ DISPATCH; \\ } #define LOAD_CONST_CAPTURE_IP(name, value) \\ CASE(name) { \\ CAPTURE_IP_ASSIGN(O1REG(name), value); \\ ip = NEXTINST(name); \\ DISPATCH; \\ } CASE(Mov) { O1REG(Mov) = O2REG(Mov); ip = NEXTINST(Mov); DISPATCH; } CASE(MovLong) { O1REG(MovLong) = O2REG(MovLong); ip = NEXTINST(MovLong); DISPATCH; } CASE(LoadParam) { if (LLVM_LIKELY(ip->iLoadParam.op2 <= FRAME.getArgCount())) { // index 0 must load 'this'. Index 1 the first argument, etc. O1REG(LoadParam) = FRAME.getArgRef((int32_t)ip->iLoadParam.op2 - 1); ip = NEXTINST(LoadParam); DISPATCH; } O1REG(LoadParam) = HermesValue::encodeUndefinedValue(); ip = NEXTINST(LoadParam); DISPATCH; } CASE(LoadParamLong) { if (LLVM_LIKELY(ip->iLoadParamLong.op2 <= FRAME.getArgCount())) { // index 0 must load 'this'. Index 1 the first argument, etc. O1REG(LoadParamLong) = FRAME.getArgRef((int32_t)ip->iLoadParamLong.op2 - 1); ip = NEXTINST(LoadParamLong); DISPATCH; } O1REG(LoadParamLong) = HermesValue::encodeUndefinedValue(); ip = NEXTINST(LoadParamLong); DISPATCH; } CASE(CoerceThisNS) { if (LLVM_LIKELY(O2REG(CoerceThisNS).isObject())) { O1REG(CoerceThisNS) = O2REG(CoerceThisNS); } else if ( O2REG(CoerceThisNS).isNull() || O2REG(CoerceThisNS).isUndefined()) { O1REG(CoerceThisNS) = runtime->global_; } else { tmpHandle = O2REG(CoerceThisNS); nextIP = NEXTINST(CoerceThisNS); goto coerceThisSlowPath; } ip = NEXTINST(CoerceThisNS); DISPATCH; } CASE(LoadThisNS) { if (LLVM_LIKELY(FRAME.getThisArgRef().isObject())) { O1REG(LoadThisNS) = FRAME.getThisArgRef(); } else if ( FRAME.getThisArgRef().isNull() || FRAME.getThisArgRef().isUndefined()) { O1REG(LoadThisNS) = runtime->global_; } else { tmpHandle = FRAME.getThisArgRef(); nextIP = NEXTINST(LoadThisNS); goto coerceThisSlowPath; } ip = NEXTINST(LoadThisNS); DISPATCH; } coerceThisSlowPath : { CAPTURE_IP_ASSIGN(res, toObject(runtime, tmpHandle)); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CoerceThisNS) = res.getValue(); tmpHandle.clear(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(ConstructLong) { callArgCount = (uint32_t)ip->iConstructLong.op3; nextIP = NEXTINST(ConstructLong); callNewTarget = O2REG(ConstructLong).getRaw(); goto doCall; } CASE(CallLong) { callArgCount = (uint32_t)ip->iCallLong.op3; nextIP = NEXTINST(CallLong); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); goto doCall; } // Note in Call1 through Call4, the first argument is 'this' which has // argument index -1. // Also note that we are writing to callNewTarget last, to avoid the // possibility of it being aliased by the arg writes. CASE(Call1) { callArgCount = 1; nextIP = NEXTINST(Call1); StackFramePtr fr{runtime->stackPointer_}; fr.getArgRefUnsafe(-1) = O3REG(Call1); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); goto doCall; } CASE(Call2) { callArgCount = 2; nextIP = NEXTINST(Call2); StackFramePtr fr{runtime->stackPointer_}; fr.getArgRefUnsafe(-1) = O3REG(Call2); fr.getArgRefUnsafe(0) = O4REG(Call2); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); goto doCall; } CASE(Call3) { callArgCount = 3; nextIP = NEXTINST(Call3); StackFramePtr fr{runtime->stackPointer_}; fr.getArgRefUnsafe(-1) = O3REG(Call3); fr.getArgRefUnsafe(0) = O4REG(Call3); fr.getArgRefUnsafe(1) = O5REG(Call3); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); goto doCall; } CASE(Call4) { callArgCount = 4; nextIP = NEXTINST(Call4); StackFramePtr fr{runtime->stackPointer_}; fr.getArgRefUnsafe(-1) = O3REG(Call4); fr.getArgRefUnsafe(0) = O4REG(Call4); fr.getArgRefUnsafe(1) = O5REG(Call4); fr.getArgRefUnsafe(2) = O6REG(Call4); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); goto doCall; } CASE(Construct) { callArgCount = (uint32_t)ip->iConstruct.op3; nextIP = NEXTINST(Construct); callNewTarget = O2REG(Construct).getRaw(); goto doCall; } CASE(Call) { callArgCount = (uint32_t)ip->iCall.op3; nextIP = NEXTINST(Call); callNewTarget = HermesValue::encodeUndefinedValue().getRaw(); // Fall through. } doCall : { #ifdef HERMES_ENABLE_DEBUGGER // Check for an async debugger request. if (uint8_t asyncFlags = runtime->testAndClearDebuggerAsyncBreakRequest()) { RUN_DEBUGGER_ASYNC_BREAK(asyncFlags); gcScope.flushToSmallCount(KEEP_HANDLES); DISPATCH; } #endif // Subtract 1 from callArgCount as 'this' is considered an argument in the // instruction, but not in the frame. CAPTURE_IP_ASSIGN_NO_INVALIDATE( auto newFrame, StackFramePtr::initFrame( runtime->stackPointer_, FRAME, ip, curCodeBlock, callArgCount - 1, O2REG(Call), HermesValue::fromRaw(callNewTarget))); (void)newFrame; SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame)); if (auto *func = dyn_vmcast(O2REG(Call))) { assert(!SingleStep && \"can't single-step a call\"); #ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES runtime->pushCallStack(curCodeBlock, ip); #endif CodeBlock *calleeBlock = func->getCodeBlock(); calleeBlock->lazyCompile(runtime); #if defined(HERMESVM_PROFILER_EXTERN) CAPTURE_IP_ASSIGN_NO_INVALIDATE( res, runtime->interpretFunction(calleeBlock)); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(Call) = *res; gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; #else if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) { res = (*jitPtr)(runtime); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) goto exception; O1REG(Call) = *res; SLOW_DEBUG( dbgs() << \"JIT return value r\" << (unsigned)ip->iCall.op1 << \"=\" << DumpHermesValue(O1REG(Call)) << \"\\n\"); gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } curCodeBlock = calleeBlock; goto tailCall; #endif } CAPTURE_IP_ASSIGN_NO_INVALIDATE( resPH, Interpreter::handleCallSlowPath(runtime, &O2REG(Call))); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(Call) = std::move(resPH->get()); SLOW_DEBUG( dbgs() << \"native return value r\" << (unsigned)ip->iCall.op1 << \"=\" << DumpHermesValue(O1REG(Call)) << \"\\n\"); gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(CallDirect) CASE(CallDirectLongIndex) { #ifdef HERMES_ENABLE_DEBUGGER // Check for an async debugger request. if (uint8_t asyncFlags = runtime->testAndClearDebuggerAsyncBreakRequest()) { RUN_DEBUGGER_ASYNC_BREAK(asyncFlags); gcScope.flushToSmallCount(KEEP_HANDLES); DISPATCH; } #endif CAPTURE_IP_ASSIGN( CodeBlock * calleeBlock, ip->opCode == OpCode::CallDirect ? curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate( ip->iCallDirect.op3) : curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate( ip->iCallDirectLongIndex.op3)); CAPTURE_IP_ASSIGN_NO_INVALIDATE( auto newFrame, StackFramePtr::initFrame( runtime->stackPointer_, FRAME, ip, curCodeBlock, (uint32_t)ip->iCallDirect.op2 - 1, HermesValue::encodeNativePointer(calleeBlock), HermesValue::encodeUndefinedValue())); (void)newFrame; LLVM_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame)); assert(!SingleStep && \"can't single-step a call\"); calleeBlock->lazyCompile(runtime); #if defined(HERMESVM_PROFILER_EXTERN) CAPTURE_IP_ASSIGN_NO_INVALIDATE( res, runtime->interpretFunction(calleeBlock)); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CallDirect) = *res; gcScope.flushToSmallCount(KEEP_HANDLES); ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect) : NEXTINST(CallDirectLongIndex); DISPATCH; #else if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) { res = (*jitPtr)(runtime); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) goto exception; O1REG(CallDirect) = *res; LLVM_DEBUG( dbgs() << \"JIT return value r\" << (unsigned)ip->iCallDirect.op1 << \"=\" << DumpHermesValue(O1REG(Call)) << \"\\n\"); gcScope.flushToSmallCount(KEEP_HANDLES); ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect) : NEXTINST(CallDirectLongIndex); DISPATCH; } curCodeBlock = calleeBlock; goto tailCall; #endif } CASE(CallBuiltin) { NativeFunction *nf = runtime->getBuiltinNativeFunction(ip->iCallBuiltin.op2); CAPTURE_IP_ASSIGN( auto newFrame, StackFramePtr::initFrame( runtime->stackPointer_, FRAME, ip, curCodeBlock, (uint32_t)ip->iCallBuiltin.op3 - 1, nf, false)); // \"thisArg\" is implicitly assumed to \"undefined\". newFrame.getThisArgRef() = HermesValue::encodeUndefinedValue(); SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame)); CAPTURE_IP_ASSIGN(resPH, NativeFunction::_nativeCall(nf, runtime)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) goto exception; O1REG(CallBuiltin) = std::move(resPH->get()); SLOW_DEBUG( dbgs() << \"native return value r\" << (unsigned)ip->iCallBuiltin.op1 << \"=\" << DumpHermesValue(O1REG(CallBuiltin)) << \"\\n\"); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CallBuiltin); DISPATCH; } CASE(CompleteGenerator) { auto *innerFn = vmcast( runtime->getCurrentFrame().getCalleeClosure()); innerFn->setState(GeneratorInnerFunction::State::Completed); ip = NEXTINST(CompleteGenerator); DISPATCH; } CASE(SaveGenerator) { nextIP = IPADD(ip->iSaveGenerator.op1); goto doSaveGen; } CASE(SaveGeneratorLong) { nextIP = IPADD(ip->iSaveGeneratorLong.op1); goto doSaveGen; } doSaveGen : { auto *innerFn = vmcast( runtime->getCurrentFrame().getCalleeClosure()); innerFn->saveStack(runtime); innerFn->setNextIP(nextIP); innerFn->setState(GeneratorInnerFunction::State::SuspendedYield); ip = NEXTINST(SaveGenerator); DISPATCH; } CASE(StartGenerator) { auto *innerFn = vmcast( runtime->getCurrentFrame().getCalleeClosure()); if (innerFn->getState() == GeneratorInnerFunction::State::SuspendedStart) { nextIP = NEXTINST(StartGenerator); } else { nextIP = innerFn->getNextIP(); innerFn->restoreStack(runtime); } innerFn->setState(GeneratorInnerFunction::State::Executing); ip = nextIP; DISPATCH; } CASE(ResumeGenerator) { auto *innerFn = vmcast( runtime->getCurrentFrame().getCalleeClosure()); O1REG(ResumeGenerator) = innerFn->getResult(); O2REG(ResumeGenerator) = HermesValue::encodeBoolValue( innerFn->getAction() == GeneratorInnerFunction::Action::Return); innerFn->clearResult(runtime); if (innerFn->getAction() == GeneratorInnerFunction::Action::Throw) { runtime->setThrownValue(O1REG(ResumeGenerator)); goto exception; } ip = NEXTINST(ResumeGenerator); DISPATCH; } CASE(Ret) { #ifdef HERMES_ENABLE_DEBUGGER // Check for an async debugger request. if (uint8_t asyncFlags = runtime->testAndClearDebuggerAsyncBreakRequest()) { RUN_DEBUGGER_ASYNC_BREAK(asyncFlags); gcScope.flushToSmallCount(KEEP_HANDLES); DISPATCH; } #endif PROFILER_EXIT_FUNCTION(curCodeBlock); #ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES runtime->popCallStack(); #endif // Store the return value. res = O1REG(Ret); ip = FRAME.getSavedIP(); curCodeBlock = FRAME.getSavedCodeBlock(); frameRegs = &runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef(); SLOW_DEBUG( dbgs() << \"function exit: restored stackLevel=\" << runtime->getStackLevel() << \"\\n\"); // Are we returning to native code? if (!curCodeBlock) { SLOW_DEBUG(dbgs() << \"function exit: returning to native code\\n\"); return res; } // Return because of recursive calling structure #if defined(HERMESVM_PROFILER_EXTERN) return res; #endif INIT_STATE_FOR_CODEBLOCK(curCodeBlock); O1REG(Call) = res.getValue(); ip = nextInstCall(ip); DISPATCH; } CASE(Catch) { assert(!runtime->thrownValue_.isEmpty() && \"Invalid thrown value\"); assert( !isUncatchableError(runtime->thrownValue_) && \"Uncatchable thrown value was caught\"); O1REG(Catch) = runtime->thrownValue_; runtime->clearThrownValue(); #ifdef HERMES_ENABLE_DEBUGGER // Signal to the debugger that we're done unwinding an exception, // and we can resume normal debugging flow. runtime->debugger_.finishedUnwindingException(); #endif ip = NEXTINST(Catch); DISPATCH; } CASE(Throw) { runtime->thrownValue_ = O1REG(Throw); SLOW_DEBUG( dbgs() << \"Exception thrown: \" << DumpHermesValue(runtime->thrownValue_) << \"\\n\"); goto exception; } CASE(ThrowIfUndefinedInst) { if (LLVM_UNLIKELY(O1REG(ThrowIfUndefinedInst).isUndefined())) { SLOW_DEBUG( dbgs() << \"Throwing ReferenceError for undefined variable\"); CAPTURE_IP(runtime->raiseReferenceError( \"accessing an uninitialized variable\")); goto exception; } ip = NEXTINST(ThrowIfUndefinedInst); DISPATCH; } CASE(Debugger) { SLOW_DEBUG(dbgs() << \"debugger statement executed\\n\"); #ifdef HERMES_ENABLE_DEBUGGER { if (!runtime->debugger_.isDebugging()) { // Only run the debugger if we're not already debugging. // Don't want to call it again and mess with its state. CAPTURE_IP_ASSIGN( auto res, runDebuggerUpdatingState( Debugger::RunReason::Opcode, runtime, curCodeBlock, ip, frameRegs)); if (res == ExecutionStatus::EXCEPTION) { // If one of the internal steps threw, // then handle that here by jumping to where we're supposed to go. // If we're in mid-step, the breakpoint at the catch point // will have been set by the debugger. // We don't want to execute this instruction because it's already // thrown. goto exception; } } auto breakpointOpt = runtime->debugger_.getBreakpointLocation(ip); if (breakpointOpt.hasValue()) { // We're on a breakpoint but we're supposed to continue. curCodeBlock->uninstallBreakpointAtOffset( CUROFFSET, breakpointOpt->opCode); if (ip->opCode == OpCode::Debugger) { // Breakpointed a debugger instruction, so move past it // since we've already called the debugger on this instruction. ip = NEXTINST(Debugger); } else { InterpreterState newState{curCodeBlock, (uint32_t)CUROFFSET}; CAPTURE_IP_ASSIGN( ExecutionStatus status, runtime->stepFunction(newState)); curCodeBlock->installBreakpointAtOffset(CUROFFSET); if (status == ExecutionStatus::EXCEPTION) { goto exception; } curCodeBlock = newState.codeBlock; ip = newState.codeBlock->getOffsetPtr(newState.offset); INIT_STATE_FOR_CODEBLOCK(curCodeBlock); // Single-stepping should handle call stack management for us. frameRegs = &runtime->getCurrentFrame().getFirstLocalRef(); } } else if (ip->opCode == OpCode::Debugger) { // No breakpoint here and we've already run the debugger, // just continue on. // If the current instruction is no longer a debugger instruction, // we're just going to keep executing from the current IP. ip = NEXTINST(Debugger); } gcScope.flushToSmallCount(KEEP_HANDLES); } DISPATCH; #else ip = NEXTINST(Debugger); DISPATCH; #endif } CASE(AsyncBreakCheck) { if (LLVM_UNLIKELY(runtime->hasAsyncBreak())) { #ifdef HERMES_ENABLE_DEBUGGER if (uint8_t asyncFlags = runtime->testAndClearDebuggerAsyncBreakRequest()) { RUN_DEBUGGER_ASYNC_BREAK(asyncFlags); } #endif if (runtime->testAndClearTimeoutAsyncBreakRequest()) { CAPTURE_IP_ASSIGN(auto nRes, runtime->notifyTimeout()); if (nRes == ExecutionStatus::EXCEPTION) { goto exception; } } } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(AsyncBreakCheck); DISPATCH; } CASE(ProfilePoint) { #ifdef HERMESVM_PROFILER_BB auto pointIndex = ip->iProfilePoint.op1; SLOW_DEBUG(llvh::dbgs() << \"ProfilePoint: \" << pointIndex << \"\\n\"); CAPTURE_IP(runtime->getBasicBlockExecutionInfo().executeBlock( curCodeBlock, pointIndex)); #endif ip = NEXTINST(ProfilePoint); DISPATCH; } CASE(Unreachable) { llvm_unreachable(\"Hermes bug: unreachable instruction\"); } CASE(CreateClosure) { idVal = ip->iCreateClosure.op3; nextIP = NEXTINST(CreateClosure); goto createClosure; } CASE(CreateClosureLongIndex) { idVal = ip->iCreateClosureLongIndex.op3; nextIP = NEXTINST(CreateClosureLongIndex); goto createClosure; } createClosure : { auto *runtimeModule = curCodeBlock->getRuntimeModule(); CAPTURE_IP_ASSIGN( O1REG(CreateClosure), JSFunction::create( runtime, runtimeModule->getDomain(runtime), Handle::vmcast(&runtime->functionPrototype), Handle::vmcast(&O2REG(CreateClosure)), runtimeModule->getCodeBlockMayAllocate(idVal)) .getHermesValue()); gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(CreateGeneratorClosure) { CAPTURE_IP_ASSIGN( auto res, createGeneratorClosure( runtime, curCodeBlock->getRuntimeModule(), ip->iCreateClosure.op3, Handle::vmcast(&O2REG(CreateGeneratorClosure)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CreateGeneratorClosure) = res->getHermesValue(); res->invalidate(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateGeneratorClosure); DISPATCH; } CASE(CreateGeneratorClosureLongIndex) { CAPTURE_IP_ASSIGN( auto res, createGeneratorClosure( runtime, curCodeBlock->getRuntimeModule(), ip->iCreateClosureLongIndex.op3, Handle::vmcast( &O2REG(CreateGeneratorClosureLongIndex)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CreateGeneratorClosureLongIndex) = res->getHermesValue(); res->invalidate(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateGeneratorClosureLongIndex); DISPATCH; } CASE(CreateGenerator) { CAPTURE_IP_ASSIGN( auto res, createGenerator_RJS( runtime, curCodeBlock->getRuntimeModule(), ip->iCreateGenerator.op3, Handle::vmcast(&O2REG(CreateGenerator)), FRAME.getNativeArgs())); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CreateGenerator) = res->getHermesValue(); res->invalidate(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateGenerator); DISPATCH; } CASE(CreateGeneratorLongIndex) { CAPTURE_IP_ASSIGN( auto res, createGenerator_RJS( runtime, curCodeBlock->getRuntimeModule(), ip->iCreateGeneratorLongIndex.op3, Handle::vmcast(&O2REG(CreateGeneratorLongIndex)), FRAME.getNativeArgs())); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(CreateGeneratorLongIndex) = res->getHermesValue(); res->invalidate(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateGeneratorLongIndex); DISPATCH; } CASE(GetEnvironment) { // The currently executing function must exist, so get the environment. Environment *curEnv = FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime); for (unsigned level = ip->iGetEnvironment.op2; level; --level) { assert(curEnv && \"invalid environment relative level\"); curEnv = curEnv->getParentEnvironment(runtime); } O1REG(GetEnvironment) = HermesValue::encodeObjectValue(curEnv); ip = NEXTINST(GetEnvironment); DISPATCH; } CASE(CreateEnvironment) { tmpHandle = HermesValue::encodeObjectValue( FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime)); CAPTURE_IP_ASSIGN( res, Environment::create( runtime, tmpHandle->getPointer() ? Handle::vmcast(tmpHandle) : Handle::vmcast_or_null( &runtime->nullPointer_), curCodeBlock->getEnvironmentSize())); if (res == ExecutionStatus::EXCEPTION) { goto exception; } O1REG(CreateEnvironment) = *res; #ifdef HERMES_ENABLE_DEBUGGER FRAME.getDebugEnvironmentRef() = *res; #endif tmpHandle = HermesValue::encodeUndefinedValue(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateEnvironment); DISPATCH; } CASE(StoreToEnvironment) { vmcast(O1REG(StoreToEnvironment)) ->slot(ip->iStoreToEnvironment.op2) .set(O3REG(StoreToEnvironment), &runtime->getHeap()); ip = NEXTINST(StoreToEnvironment); DISPATCH; } CASE(StoreToEnvironmentL) { vmcast(O1REG(StoreToEnvironmentL)) ->slot(ip->iStoreToEnvironmentL.op2) .set(O3REG(StoreToEnvironmentL), &runtime->getHeap()); ip = NEXTINST(StoreToEnvironmentL); DISPATCH; } CASE(StoreNPToEnvironment) { vmcast(O1REG(StoreNPToEnvironment)) ->slot(ip->iStoreNPToEnvironment.op2) .setNonPtr(O3REG(StoreNPToEnvironment), &runtime->getHeap()); ip = NEXTINST(StoreNPToEnvironment); DISPATCH; } CASE(StoreNPToEnvironmentL) { vmcast(O1REG(StoreNPToEnvironmentL)) ->slot(ip->iStoreNPToEnvironmentL.op2) .setNonPtr(O3REG(StoreNPToEnvironmentL), &runtime->getHeap()); ip = NEXTINST(StoreNPToEnvironmentL); DISPATCH; } CASE(LoadFromEnvironment) { O1REG(LoadFromEnvironment) = vmcast(O2REG(LoadFromEnvironment)) ->slot(ip->iLoadFromEnvironment.op3); ip = NEXTINST(LoadFromEnvironment); DISPATCH; } CASE(LoadFromEnvironmentL) { O1REG(LoadFromEnvironmentL) = vmcast(O2REG(LoadFromEnvironmentL)) ->slot(ip->iLoadFromEnvironmentL.op3); ip = NEXTINST(LoadFromEnvironmentL); DISPATCH; } CASE(GetGlobalObject) { O1REG(GetGlobalObject) = runtime->global_; ip = NEXTINST(GetGlobalObject); DISPATCH; } CASE(GetNewTarget) { O1REG(GetNewTarget) = FRAME.getNewTargetRef(); ip = NEXTINST(GetNewTarget); DISPATCH; } CASE(DeclareGlobalVar) { DefinePropertyFlags dpf = DefinePropertyFlags::getDefaultNewPropertyFlags(); dpf.configurable = 0; // Do not overwrite existing globals with undefined. dpf.setValue = 0; CAPTURE_IP_ASSIGN( auto res, JSObject::defineOwnProperty( runtime->getGlobal(), runtime, ID(ip->iDeclareGlobalVar.op1), dpf, Runtime::getUndefinedValue(), PropOpFlags().plusThrowOnError())); if (res == ExecutionStatus::EXCEPTION) { assert( !runtime->getGlobal()->isProxyObject() && \"global can't be a proxy object\"); // If the property already exists, this should be a noop. // Instead of incurring the cost to check every time, do it // only if an exception is thrown, and swallow the exception // if it exists, since we didn't want to make the call, // anyway. This most likely means the property is // non-configurable. NamedPropertyDescriptor desc; CAPTURE_IP_ASSIGN( auto res, JSObject::getOwnNamedDescriptor( runtime->getGlobal(), runtime, ID(ip->iDeclareGlobalVar.op1), desc)); if (!res) { goto exception; } else { runtime->clearThrownValue(); } // fall through } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(DeclareGlobalVar); DISPATCH; } CASE(TryGetByIdLong) { tryProp = true; idVal = ip->iTryGetByIdLong.op4; nextIP = NEXTINST(TryGetByIdLong); goto getById; } CASE(GetByIdLong) { tryProp = false; idVal = ip->iGetByIdLong.op4; nextIP = NEXTINST(GetByIdLong); goto getById; } CASE(GetByIdShort) { tryProp = false; idVal = ip->iGetByIdShort.op4; nextIP = NEXTINST(GetByIdShort); goto getById; } CASE(TryGetById) { tryProp = true; idVal = ip->iTryGetById.op4; nextIP = NEXTINST(TryGetById); goto getById; } CASE(GetById) { tryProp = false; idVal = ip->iGetById.op4; nextIP = NEXTINST(GetById); } getById : { ++NumGetById; // NOTE: it is safe to use OnREG(GetById) here because all instructions // have the same layout: opcode, registers, non-register operands, i.e. // they only differ in the width of the last \"identifier\" field. CallResult propRes{ExecutionStatus::EXCEPTION}; if (LLVM_LIKELY(O2REG(GetById).isObject())) { auto *obj = vmcast(O2REG(GetById)); auto cacheIdx = ip->iGetById.op3; auto *cacheEntry = curCodeBlock->getReadCacheEntry(cacheIdx); #ifdef HERMESVM_PROFILER_BB { HERMES_SLOW_ASSERT( gcScope.getHandleCountDbg() == KEEP_HANDLES && \"unaccounted handles were created\"); auto objHandle = runtime->makeHandle(obj); auto cacheHCPtr = vmcast_or_null(static_cast( cacheEntry->clazz.get(runtime, &runtime->getHeap()))); CAPTURE_IP(runtime->recordHiddenClass( curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr)); // obj may be moved by GC due to recordHiddenClass obj = objHandle.get(); } gcScope.flushToSmallCount(KEEP_HANDLES); #endif auto clazzGCPtr = obj->getClassGCPtr(); #ifndef NDEBUG if (clazzGCPtr.get(runtime)->isDictionary()) ++NumGetByIdDict; #else (void)NumGetByIdDict; #endif // If we have a cache hit, reuse the cached offset and immediately // return the property. if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) { ++NumGetByIdCacheHits; CAPTURE_IP_ASSIGN( O1REG(GetById), JSObject::getNamedSlotValue( obj, runtime, cacheEntry->slot)); ip = nextIP; DISPATCH; } auto id = ID(idVal); NamedPropertyDescriptor desc; CAPTURE_IP_ASSIGN( OptValue fastPathResult, JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc)); if (LLVM_LIKELY( fastPathResult.hasValue() && fastPathResult.getValue()) && !desc.flags.accessor) { ++NumGetByIdFastPaths; // cacheIdx == 0 indicates no caching so don't update the cache in // those cases. auto *clazz = clazzGCPtr.getNonNull(runtime); if (LLVM_LIKELY(!clazz->isDictionaryNoCache()) && LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) { #ifdef HERMES_SLOW_DEBUG if (cacheEntry->clazz && cacheEntry->clazz != clazzGCPtr.getStorageType()) ++NumGetByIdCacheEvicts; #else (void)NumGetByIdCacheEvicts; #endif // Cache the class, id and property slot. cacheEntry->clazz = clazzGCPtr.getStorageType(); cacheEntry->slot = desc.slot; } CAPTURE_IP_ASSIGN( O1REG(GetById), JSObject::getNamedSlotValue(obj, runtime, desc)); ip = nextIP; DISPATCH; } // The cache may also be populated via the prototype of the object. // This value is only reliable if the fast path was a definite // not-found. if (fastPathResult.hasValue() && !fastPathResult.getValue() && !obj->isProxyObject()) { CAPTURE_IP_ASSIGN(JSObject * parent, obj->getParent(runtime)); // TODO: This isLazy check is because a lazy object is reported as // having no properties and therefore cannot contain the property. // This check does not belong here, it should be merged into // tryGetOwnNamedDescriptorFast(). if (parent && cacheEntry->clazz == parent->getClassGCPtr().getStorageType() && LLVM_LIKELY(!obj->isLazy())) { ++NumGetByIdProtoHits; CAPTURE_IP_ASSIGN( O1REG(GetById), JSObject::getNamedSlotValue(parent, runtime, cacheEntry->slot)); ip = nextIP; DISPATCH; } } #ifdef HERMES_SLOW_DEBUG CAPTURE_IP_ASSIGN( JSObject * propObj, JSObject::getNamedDescriptor( Handle::vmcast(&O2REG(GetById)), runtime, id, desc)); if (propObj) { if (desc.flags.accessor) ++NumGetByIdAccessor; else if (propObj != vmcast(O2REG(GetById))) ++NumGetByIdProto; } else { ++NumGetByIdNotFound; } #else (void)NumGetByIdAccessor; (void)NumGetByIdProto; (void)NumGetByIdNotFound; #endif #ifdef HERMES_SLOW_DEBUG auto *savedClass = cacheIdx != hbc::PROPERTY_CACHING_DISABLED ? cacheEntry->clazz.get(runtime, &runtime->getHeap()) : nullptr; #endif ++NumGetByIdSlow; CAPTURE_IP_ASSIGN( resPH, JSObject::getNamed_RJS( Handle::vmcast(&O2REG(GetById)), runtime, id, !tryProp ? defaultPropOpFlags : defaultPropOpFlags.plusMustExist(), cacheIdx != hbc::PROPERTY_CACHING_DISABLED ? cacheEntry : nullptr)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } #ifdef HERMES_SLOW_DEBUG if (cacheIdx != hbc::PROPERTY_CACHING_DISABLED && savedClass && cacheEntry->clazz.get(runtime, &runtime->getHeap()) != savedClass) { ++NumGetByIdCacheEvicts; } #endif } else { ++NumGetByIdTransient; assert(!tryProp && \"TryGetById can only be used on the global object\"); /* Slow path. */ CAPTURE_IP_ASSIGN( resPH, Interpreter::getByIdTransient_RJS( runtime, Handle<>(&O2REG(GetById)), ID(idVal))); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } } O1REG(GetById) = resPH->get(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(TryPutByIdLong) { tryProp = true; idVal = ip->iTryPutByIdLong.op4; nextIP = NEXTINST(TryPutByIdLong); goto putById; } CASE(PutByIdLong) { tryProp = false; idVal = ip->iPutByIdLong.op4; nextIP = NEXTINST(PutByIdLong); goto putById; } CASE(TryPutById) { tryProp = true; idVal = ip->iTryPutById.op4; nextIP = NEXTINST(TryPutById); goto putById; } CASE(PutById) { tryProp = false; idVal = ip->iPutById.op4; nextIP = NEXTINST(PutById); } putById : { ++NumPutById; if (LLVM_LIKELY(O1REG(PutById).isObject())) { auto *obj = vmcast(O1REG(PutById)); auto cacheIdx = ip->iPutById.op3; auto *cacheEntry = curCodeBlock->getWriteCacheEntry(cacheIdx); #ifdef HERMESVM_PROFILER_BB { HERMES_SLOW_ASSERT( gcScope.getHandleCountDbg() == KEEP_HANDLES && \"unaccounted handles were created\"); auto objHandle = runtime->makeHandle(obj); auto cacheHCPtr = vmcast_or_null(static_cast( cacheEntry->clazz.get(runtime, &runtime->getHeap()))); CAPTURE_IP(runtime->recordHiddenClass( curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr)); // obj may be moved by GC due to recordHiddenClass obj = objHandle.get(); } gcScope.flushToSmallCount(KEEP_HANDLES); #endif auto clazzGCPtr = obj->getClassGCPtr(); // If we have a cache hit, reuse the cached offset and immediately // return the property. if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) { ++NumPutByIdCacheHits; CAPTURE_IP(JSObject::setNamedSlotValue( obj, runtime, cacheEntry->slot, O2REG(PutById))); ip = nextIP; DISPATCH; } auto id = ID(idVal); NamedPropertyDescriptor desc; CAPTURE_IP_ASSIGN( OptValue hasOwnProp, JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc)); if (LLVM_LIKELY(hasOwnProp.hasValue() && hasOwnProp.getValue()) && !desc.flags.accessor && desc.flags.writable && !desc.flags.internalSetter) { ++NumPutByIdFastPaths; // cacheIdx == 0 indicates no caching so don't update the cache in // those cases. auto *clazz = clazzGCPtr.getNonNull(runtime); if (LLVM_LIKELY(!clazz->isDictionary()) && LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) { #ifdef HERMES_SLOW_DEBUG if (cacheEntry->clazz && cacheEntry->clazz != clazzGCPtr.getStorageType()) ++NumPutByIdCacheEvicts; #else (void)NumPutByIdCacheEvicts; #endif // Cache the class and property slot. cacheEntry->clazz = clazzGCPtr.getStorageType(); cacheEntry->slot = desc.slot; } CAPTURE_IP(JSObject::setNamedSlotValue( obj, runtime, desc.slot, O2REG(PutById))); ip = nextIP; DISPATCH; } CAPTURE_IP_ASSIGN( auto putRes, JSObject::putNamed_RJS( Handle::vmcast(&O1REG(PutById)), runtime, id, Handle<>(&O2REG(PutById)), !tryProp ? defaultPropOpFlags : defaultPropOpFlags.plusMustExist())); if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) { goto exception; } } else { ++NumPutByIdTransient; assert(!tryProp && \"TryPutById can only be used on the global object\"); CAPTURE_IP_ASSIGN( auto retStatus, Interpreter::putByIdTransient_RJS( runtime, Handle<>(&O1REG(PutById)), ID(idVal), Handle<>(&O2REG(PutById)), strictMode)); if (retStatus == ExecutionStatus::EXCEPTION) { goto exception; } } gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(GetByVal) { CallResult propRes{ExecutionStatus::EXCEPTION}; if (LLVM_LIKELY(O2REG(GetByVal).isObject())) { CAPTURE_IP_ASSIGN( resPH, JSObject::getComputed_RJS( Handle::vmcast(&O2REG(GetByVal)), runtime, Handle<>(&O3REG(GetByVal)))); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } } else { // This is the \"slow path\". CAPTURE_IP_ASSIGN( resPH, Interpreter::getByValTransient_RJS( runtime, Handle<>(&O2REG(GetByVal)), Handle<>(&O3REG(GetByVal)))); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(GetByVal) = resPH->get(); ip = NEXTINST(GetByVal); DISPATCH; } CASE(PutByVal) { if (LLVM_LIKELY(O1REG(PutByVal).isObject())) { CAPTURE_IP_ASSIGN( auto putRes, JSObject::putComputed_RJS( Handle::vmcast(&O1REG(PutByVal)), runtime, Handle<>(&O2REG(PutByVal)), Handle<>(&O3REG(PutByVal)), defaultPropOpFlags)); if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) { goto exception; } } else { // This is the \"slow path\". CAPTURE_IP_ASSIGN( auto retStatus, Interpreter::putByValTransient_RJS( runtime, Handle<>(&O1REG(PutByVal)), Handle<>(&O2REG(PutByVal)), Handle<>(&O3REG(PutByVal)), strictMode)); if (LLVM_UNLIKELY(retStatus == ExecutionStatus::EXCEPTION)) { goto exception; } } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(PutByVal); DISPATCH; } CASE(PutOwnByIndexL) { nextIP = NEXTINST(PutOwnByIndexL); idVal = ip->iPutOwnByIndexL.op3; goto putOwnByIndex; } CASE(PutOwnByIndex) { nextIP = NEXTINST(PutOwnByIndex); idVal = ip->iPutOwnByIndex.op3; } putOwnByIndex : { tmpHandle = HermesValue::encodeDoubleValue(idVal); CAPTURE_IP(JSObject::defineOwnComputedPrimitive( Handle::vmcast(&O1REG(PutOwnByIndex)), runtime, tmpHandle, DefinePropertyFlags::getDefaultNewPropertyFlags(), Handle<>(&O2REG(PutOwnByIndex)))); gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); ip = nextIP; DISPATCH; } CASE(GetPNameList) { CAPTURE_IP_ASSIGN( auto pRes, handleGetPNameList(runtime, frameRegs, ip)); if (LLVM_UNLIKELY(pRes == ExecutionStatus::EXCEPTION)) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(GetPNameList); DISPATCH; } CASE(GetNextPName) { { assert( vmisa(O2REG(GetNextPName)) && \"GetNextPName's second op must be BigStorage\"); auto obj = Handle::vmcast(&O3REG(GetNextPName)); auto arr = Handle::vmcast(&O2REG(GetNextPName)); uint32_t idx = O4REG(GetNextPName).getNumber(); uint32_t size = O5REG(GetNextPName).getNumber(); MutableHandle propObj{runtime}; // Loop until we find a property which is present. while (idx < size) { tmpHandle = arr->at(idx); ComputedPropertyDescriptor desc; CAPTURE_IP(JSObject::getComputedPrimitiveDescriptor( obj, runtime, tmpHandle, propObj, desc)); if (LLVM_LIKELY(propObj)) break; ++idx; } if (idx < size) { // We must return the property as a string if (tmpHandle->isNumber()) { CAPTURE_IP_ASSIGN(auto status, toString_RJS(runtime, tmpHandle)); assert( status == ExecutionStatus::RETURNED && \"toString on number cannot fail\"); tmpHandle = status->getHermesValue(); } O1REG(GetNextPName) = tmpHandle.get(); O4REG(GetNextPName) = HermesValue::encodeNumberValue(idx + 1); } else { O1REG(GetNextPName) = HermesValue::encodeUndefinedValue(); } } gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); ip = NEXTINST(GetNextPName); DISPATCH; } CASE(ToNumber) { if (LLVM_LIKELY(O2REG(ToNumber).isNumber())) { O1REG(ToNumber) = O2REG(ToNumber); ip = NEXTINST(ToNumber); } else { CAPTURE_IP_ASSIGN( res, toNumber_RJS(runtime, Handle<>(&O2REG(ToNumber)))); if (res == ExecutionStatus::EXCEPTION) goto exception; gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(ToNumber) = res.getValue(); ip = NEXTINST(ToNumber); } DISPATCH; } CASE(ToInt32) { CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(ToInt32)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) goto exception; gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(ToInt32) = res.getValue(); ip = NEXTINST(ToInt32); DISPATCH; } CASE(AddEmptyString) { if (LLVM_LIKELY(O2REG(AddEmptyString).isString())) { O1REG(AddEmptyString) = O2REG(AddEmptyString); ip = NEXTINST(AddEmptyString); } else { CAPTURE_IP_ASSIGN( res, toPrimitive_RJS( runtime, Handle<>(&O2REG(AddEmptyString)), PreferredType::NONE)); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) goto exception; tmpHandle = res.getValue(); CAPTURE_IP_ASSIGN(auto strRes, toString_RJS(runtime, tmpHandle)); if (LLVM_UNLIKELY(strRes == ExecutionStatus::EXCEPTION)) goto exception; tmpHandle.clear(); gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(AddEmptyString) = strRes->getHermesValue(); ip = NEXTINST(AddEmptyString); } DISPATCH; } CASE(Jmp) { ip = IPADD(ip->iJmp.op1); DISPATCH; } CASE(JmpLong) { ip = IPADD(ip->iJmpLong.op1); DISPATCH; } CASE(JmpTrue) { if (toBoolean(O2REG(JmpTrue))) ip = IPADD(ip->iJmpTrue.op1); else ip = NEXTINST(JmpTrue); DISPATCH; } CASE(JmpTrueLong) { if (toBoolean(O2REG(JmpTrueLong))) ip = IPADD(ip->iJmpTrueLong.op1); else ip = NEXTINST(JmpTrueLong); DISPATCH; } CASE(JmpFalse) { if (!toBoolean(O2REG(JmpFalse))) ip = IPADD(ip->iJmpFalse.op1); else ip = NEXTINST(JmpFalse); DISPATCH; } CASE(JmpFalseLong) { if (!toBoolean(O2REG(JmpFalseLong))) ip = IPADD(ip->iJmpFalseLong.op1); else ip = NEXTINST(JmpFalseLong); DISPATCH; } CASE(JmpUndefined) { if (O2REG(JmpUndefined).isUndefined()) ip = IPADD(ip->iJmpUndefined.op1); else ip = NEXTINST(JmpUndefined); DISPATCH; } CASE(JmpUndefinedLong) { if (O2REG(JmpUndefinedLong).isUndefined()) ip = IPADD(ip->iJmpUndefinedLong.op1); else ip = NEXTINST(JmpUndefinedLong); DISPATCH; } CASE(Add) { if (LLVM_LIKELY( O2REG(Add).isNumber() && O3REG(Add).isNumber())) { /* Fast-path. */ CASE(AddN) { O1REG(Add) = HermesValue::encodeDoubleValue( O2REG(Add).getNumber() + O3REG(Add).getNumber()); ip = NEXTINST(Add); DISPATCH; } } CAPTURE_IP_ASSIGN( res, addOp_RJS(runtime, Handle<>(&O2REG(Add)), Handle<>(&O3REG(Add)))); if (res == ExecutionStatus::EXCEPTION) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(Add) = res.getValue(); ip = NEXTINST(Add); DISPATCH; } CASE(BitNot) { if (LLVM_LIKELY(O2REG(BitNot).isNumber())) { /* Fast-path. */ O1REG(BitNot) = HermesValue::encodeDoubleValue( ~hermes::truncateToInt32(O2REG(BitNot).getNumber())); ip = NEXTINST(BitNot); DISPATCH; } CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(BitNot)))); if (res == ExecutionStatus::EXCEPTION) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(BitNot) = HermesValue::encodeDoubleValue( ~static_cast(res->getNumber())); ip = NEXTINST(BitNot); DISPATCH; } CASE(GetArgumentsLength) { // If the arguments object hasn't been created yet. if (O2REG(GetArgumentsLength).isUndefined()) { O1REG(GetArgumentsLength) = HermesValue::encodeNumberValue(FRAME.getArgCount()); ip = NEXTINST(GetArgumentsLength); DISPATCH; } // The arguments object has been created, so this is a regular property // get. assert( O2REG(GetArgumentsLength).isObject() && \"arguments lazy register is not an object\"); CAPTURE_IP_ASSIGN( resPH, JSObject::getNamed_RJS( Handle::vmcast(&O2REG(GetArgumentsLength)), runtime, Predefined::getSymbolID(Predefined::length))); if (resPH == ExecutionStatus::EXCEPTION) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(GetArgumentsLength) = resPH->get(); ip = NEXTINST(GetArgumentsLength); DISPATCH; } CASE(GetArgumentsPropByVal) { // If the arguments object hasn't been created yet and we have a // valid integer index, we use the fast path. if (O3REG(GetArgumentsPropByVal).isUndefined()) { // If this is an integer index. if (auto index = toArrayIndexFastPath(O2REG(GetArgumentsPropByVal))) { // Is this an existing argument? if (*index < FRAME.getArgCount()) { O1REG(GetArgumentsPropByVal) = FRAME.getArgRef(*index); ip = NEXTINST(GetArgumentsPropByVal); DISPATCH; } } } // Slow path. CAPTURE_IP_ASSIGN( auto res, getArgumentsPropByValSlowPath_RJS( runtime, &O3REG(GetArgumentsPropByVal), &O2REG(GetArgumentsPropByVal), FRAME.getCalleeClosureHandleUnsafe(), strictMode)); if (res == ExecutionStatus::EXCEPTION) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(GetArgumentsPropByVal) = res->getHermesValue(); ip = NEXTINST(GetArgumentsPropByVal); DISPATCH; } CASE(ReifyArguments) { // If the arguments object was already created, do nothing. if (!O1REG(ReifyArguments).isUndefined()) { assert( O1REG(ReifyArguments).isObject() && \"arguments lazy register is not an object\"); ip = NEXTINST(ReifyArguments); DISPATCH; } CAPTURE_IP_ASSIGN( resArgs, reifyArgumentsSlowPath( runtime, FRAME.getCalleeClosureHandleUnsafe(), strictMode)); if (LLVM_UNLIKELY(resArgs == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(ReifyArguments) = resArgs->getHermesValue(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(ReifyArguments); DISPATCH; } CASE(NewObject) { // Create a new object using the built-in constructor. Note that the // built-in constructor is empty, so we don't actually need to call // it. CAPTURE_IP_ASSIGN( O1REG(NewObject), JSObject::create(runtime).getHermesValue()); assert( gcScope.getHandleCountDbg() == KEEP_HANDLES && \"Should not create handles.\"); ip = NEXTINST(NewObject); DISPATCH; } CASE(NewObjectWithParent) { CAPTURE_IP_ASSIGN( O1REG(NewObjectWithParent), JSObject::create( runtime, O2REG(NewObjectWithParent).isObject() ? Handle::vmcast(&O2REG(NewObjectWithParent)) : O2REG(NewObjectWithParent).isNull() ? Runtime::makeNullHandle() : Handle::vmcast(&runtime->objectPrototype)) .getHermesValue()); assert( gcScope.getHandleCountDbg() == KEEP_HANDLES && \"Should not create handles.\"); ip = NEXTINST(NewObjectWithParent); DISPATCH; } CASE(NewObjectWithBuffer) { CAPTURE_IP_ASSIGN( resPH, Interpreter::createObjectFromBuffer( runtime, curCodeBlock, ip->iNewObjectWithBuffer.op3, ip->iNewObjectWithBuffer.op4, ip->iNewObjectWithBuffer.op5)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(NewObjectWithBuffer) = resPH->get(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(NewObjectWithBuffer); DISPATCH; } CASE(NewObjectWithBufferLong) { CAPTURE_IP_ASSIGN( resPH, Interpreter::createObjectFromBuffer( runtime, curCodeBlock, ip->iNewObjectWithBufferLong.op3, ip->iNewObjectWithBufferLong.op4, ip->iNewObjectWithBufferLong.op5)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(NewObjectWithBufferLong) = resPH->get(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(NewObjectWithBufferLong); DISPATCH; } CASE(NewArray) { // Create a new array using the built-in constructor. Note that the // built-in constructor is empty, so we don't actually need to call // it. CAPTURE_IP_ASSIGN( auto createRes, JSArray::create(runtime, ip->iNewArray.op2, ip->iNewArray.op2)); if (createRes == ExecutionStatus::EXCEPTION) { goto exception; } O1REG(NewArray) = createRes->getHermesValue(); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(NewArray); DISPATCH; } CASE(NewArrayWithBuffer) { CAPTURE_IP_ASSIGN( resPH, Interpreter::createArrayFromBuffer( runtime, curCodeBlock, ip->iNewArrayWithBuffer.op2, ip->iNewArrayWithBuffer.op3, ip->iNewArrayWithBuffer.op4)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(NewArrayWithBuffer) = resPH->get(); gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); ip = NEXTINST(NewArrayWithBuffer); DISPATCH; } CASE(NewArrayWithBufferLong) { CAPTURE_IP_ASSIGN( resPH, Interpreter::createArrayFromBuffer( runtime, curCodeBlock, ip->iNewArrayWithBufferLong.op2, ip->iNewArrayWithBufferLong.op3, ip->iNewArrayWithBufferLong.op4)); if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(NewArrayWithBufferLong) = resPH->get(); gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); ip = NEXTINST(NewArrayWithBufferLong); DISPATCH; } CASE(CreateThis) { // Registers: output, prototype, closure. if (LLVM_UNLIKELY(!vmisa(O3REG(CreateThis)))) { CAPTURE_IP(runtime->raiseTypeError(\"constructor is not callable\")); goto exception; } CAPTURE_IP_ASSIGN( auto res, Callable::newObject( Handle::vmcast(&O3REG(CreateThis)), runtime, Handle::vmcast( O2REG(CreateThis).isObject() ? &O2REG(CreateThis) : &runtime->objectPrototype))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(CreateThis) = res->getHermesValue(); ip = NEXTINST(CreateThis); DISPATCH; } CASE(SelectObject) { // Registers: output, thisObject, constructorReturnValue. O1REG(SelectObject) = O3REG(SelectObject).isObject() ? O3REG(SelectObject) : O2REG(SelectObject); ip = NEXTINST(SelectObject); DISPATCH; } CASE(Eq) CASE(Neq) { CAPTURE_IP_ASSIGN( res, abstractEqualityTest_RJS( runtime, Handle<>(&O2REG(Eq)), Handle<>(&O3REG(Eq)))); if (res == ExecutionStatus::EXCEPTION) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(Eq) = ip->opCode == OpCode::Eq ? res.getValue() : HermesValue::encodeBoolValue(!res->getBool()); ip = NEXTINST(Eq); DISPATCH; } CASE(StrictEq) { O1REG(StrictEq) = HermesValue::encodeBoolValue( strictEqualityTest(O2REG(StrictEq), O3REG(StrictEq))); ip = NEXTINST(StrictEq); DISPATCH; } CASE(StrictNeq) { O1REG(StrictNeq) = HermesValue::encodeBoolValue( !strictEqualityTest(O2REG(StrictNeq), O3REG(StrictNeq))); ip = NEXTINST(StrictNeq); DISPATCH; } CASE(Not) { O1REG(Not) = HermesValue::encodeBoolValue(!toBoolean(O2REG(Not))); ip = NEXTINST(Not); DISPATCH; } CASE(Negate) { if (LLVM_LIKELY(O2REG(Negate).isNumber())) { O1REG(Negate) = HermesValue::encodeDoubleValue(-O2REG(Negate).getNumber()); } else { CAPTURE_IP_ASSIGN( res, toNumber_RJS(runtime, Handle<>(&O2REG(Negate)))); if (res == ExecutionStatus::EXCEPTION) goto exception; gcScope.flushToSmallCount(KEEP_HANDLES); O1REG(Negate) = HermesValue::encodeDoubleValue(-res->getNumber()); } ip = NEXTINST(Negate); DISPATCH; } CASE(TypeOf) { CAPTURE_IP_ASSIGN( O1REG(TypeOf), typeOf(runtime, Handle<>(&O2REG(TypeOf)))); ip = NEXTINST(TypeOf); DISPATCH; } CASE(Mod) { // We use fmod here for simplicity. Theoretically fmod behaves slightly // differently than the ECMAScript Spec. fmod applies round-towards-zero // for the remainder when it's not representable by a double; while the // spec requires round-to-nearest. As an example, 5 % 0.7 will give // 0.10000000000000031 using fmod, but using the rounding style // described // by the spec, the output should really be 0.10000000000000053. // Such difference can be ignored in practice. if (LLVM_LIKELY(O2REG(Mod).isNumber() && O3REG(Mod).isNumber())) { /* Fast-path. */ O1REG(Mod) = HermesValue::encodeDoubleValue( std::fmod(O2REG(Mod).getNumber(), O3REG(Mod).getNumber())); ip = NEXTINST(Mod); DISPATCH; } CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(Mod)))); if (res == ExecutionStatus::EXCEPTION) goto exception; double left = res->getDouble(); CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(Mod)))); if (res == ExecutionStatus::EXCEPTION) goto exception; O1REG(Mod) = HermesValue::encodeDoubleValue(std::fmod(left, res->getDouble())); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(Mod); DISPATCH; } CASE(InstanceOf) { CAPTURE_IP_ASSIGN( auto result, instanceOfOperator_RJS( runtime, Handle<>(&O2REG(InstanceOf)), Handle<>(&O3REG(InstanceOf)))); if (LLVM_UNLIKELY(result == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(InstanceOf) = HermesValue::encodeBoolValue(*result); gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(InstanceOf); DISPATCH; } CASE(IsIn) { { if (LLVM_UNLIKELY(!O3REG(IsIn).isObject())) { CAPTURE_IP(runtime->raiseTypeError( \"right operand of 'in' is not an object\")); goto exception; } CAPTURE_IP_ASSIGN( auto cr, JSObject::hasComputed( Handle::vmcast(&O3REG(IsIn)), runtime, Handle<>(&O2REG(IsIn)))); if (cr == ExecutionStatus::EXCEPTION) { goto exception; } O1REG(IsIn) = HermesValue::encodeBoolValue(*cr); } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(IsIn); DISPATCH; } CASE(PutNewOwnByIdShort) { nextIP = NEXTINST(PutNewOwnByIdShort); idVal = ip->iPutNewOwnByIdShort.op3; goto putOwnById; } CASE(PutNewOwnNEByIdLong) CASE(PutNewOwnByIdLong) { nextIP = NEXTINST(PutNewOwnByIdLong); idVal = ip->iPutNewOwnByIdLong.op3; goto putOwnById; } CASE(PutNewOwnNEById) CASE(PutNewOwnById) { nextIP = NEXTINST(PutNewOwnById); idVal = ip->iPutNewOwnById.op3; } putOwnById : { assert( O1REG(PutNewOwnById).isObject() && \"Object argument of PutNewOwnById must be an object\"); CAPTURE_IP_ASSIGN( auto res, JSObject::defineNewOwnProperty( Handle::vmcast(&O1REG(PutNewOwnById)), runtime, ID(idVal), ip->opCode <= OpCode::PutNewOwnByIdLong ? PropertyFlags::defaultNewNamedPropertyFlags() : PropertyFlags::nonEnumerablePropertyFlags(), Handle<>(&O2REG(PutNewOwnById)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(DelByIdLong) { idVal = ip->iDelByIdLong.op3; nextIP = NEXTINST(DelByIdLong); goto DelById; } CASE(DelById) { idVal = ip->iDelById.op3; nextIP = NEXTINST(DelById); } DelById : { if (LLVM_LIKELY(O2REG(DelById).isObject())) { CAPTURE_IP_ASSIGN( auto status, JSObject::deleteNamed( Handle::vmcast(&O2REG(DelById)), runtime, ID(idVal), defaultPropOpFlags)); if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue()); } else { // This is the \"slow path\". CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelById)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { // If an exception is thrown, likely we are trying to convert // undefined/null to an object. Passing over the name of the property // so that we could emit more meaningful error messages. CAPTURE_IP(amendPropAccessErrorMsgWithPropName( runtime, Handle<>(&O2REG(DelById)), \"delete\", ID(idVal))); goto exception; } tmpHandle = res.getValue(); CAPTURE_IP_ASSIGN( auto status, JSObject::deleteNamed( Handle::vmcast(tmpHandle), runtime, ID(idVal), defaultPropOpFlags)); if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue()); tmpHandle.clear(); } gcScope.flushToSmallCount(KEEP_HANDLES); ip = nextIP; DISPATCH; } CASE(DelByVal) { if (LLVM_LIKELY(O2REG(DelByVal).isObject())) { CAPTURE_IP_ASSIGN( auto status, JSObject::deleteComputed( Handle::vmcast(&O2REG(DelByVal)), runtime, Handle<>(&O3REG(DelByVal)), defaultPropOpFlags)); if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue()); } else { // This is the \"slow path\". CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelByVal)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception; } tmpHandle = res.getValue(); CAPTURE_IP_ASSIGN( auto status, JSObject::deleteComputed( Handle::vmcast(tmpHandle), runtime, Handle<>(&O3REG(DelByVal)), defaultPropOpFlags)); if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) { goto exception; } O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue()); } gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); ip = NEXTINST(DelByVal); DISPATCH; } CASE(CreateRegExp) { { // Create the RegExp object. CAPTURE_IP_ASSIGN(auto re, JSRegExp::create(runtime)); // Initialize the regexp. CAPTURE_IP_ASSIGN( auto pattern, runtime->makeHandle(curCodeBlock->getRuntimeModule() ->getStringPrimFromStringIDMayAllocate( ip->iCreateRegExp.op2))); CAPTURE_IP_ASSIGN( auto flags, runtime->makeHandle(curCodeBlock->getRuntimeModule() ->getStringPrimFromStringIDMayAllocate( ip->iCreateRegExp.op3))); CAPTURE_IP_ASSIGN( auto bytecode, curCodeBlock->getRuntimeModule()->getRegExpBytecodeFromRegExpID( ip->iCreateRegExp.op4)); CAPTURE_IP_ASSIGN( auto initRes, JSRegExp::initialize(re, runtime, pattern, flags, bytecode)); if (LLVM_UNLIKELY(initRes == ExecutionStatus::EXCEPTION)) { goto exception; } // Done, return the new object. O1REG(CreateRegExp) = re.getHermesValue(); } gcScope.flushToSmallCount(KEEP_HANDLES); ip = NEXTINST(CreateRegExp); DISPATCH; } CASE(SwitchImm) { if (LLVM_LIKELY(O1REG(SwitchImm).isNumber())) { double numVal = O1REG(SwitchImm).getNumber(); uint32_t uintVal = (uint32_t)numVal; if (LLVM_LIKELY(numVal == uintVal) && // Only integers. LLVM_LIKELY(uintVal >= ip->iSwitchImm.op4) && // Bounds checking. LLVM_LIKELY(uintVal <= ip->iSwitchImm.op5)) // Bounds checking. { // Calculate the offset into the bytecode where the jump table for // this SwitchImm starts. const uint8_t *tablestart = (const uint8_t *)llvh::alignAddr( (const uint8_t *)ip + ip->iSwitchImm.op2, sizeof(uint32_t)); // Read the offset from the table. // Must be signed to account for backwards branching. const int32_t *loc = (const int32_t *)tablestart + uintVal - ip->iSwitchImm.op4; ip = IPADD(*loc); DISPATCH; } } // Wrong type or out of range, jump to default. ip = IPADD(ip->iSwitchImm.op3); DISPATCH; } LOAD_CONST( LoadConstUInt8, HermesValue::encodeDoubleValue(ip->iLoadConstUInt8.op2)); LOAD_CONST( LoadConstInt, HermesValue::encodeDoubleValue(ip->iLoadConstInt.op2)); LOAD_CONST( LoadConstDouble, HermesValue::encodeDoubleValue(ip->iLoadConstDouble.op2)); LOAD_CONST_CAPTURE_IP( LoadConstString, HermesValue::encodeStringValue( curCodeBlock->getRuntimeModule() ->getStringPrimFromStringIDMayAllocate( ip->iLoadConstString.op2))); LOAD_CONST_CAPTURE_IP( LoadConstStringLongIndex, HermesValue::encodeStringValue( curCodeBlock->getRuntimeModule() ->getStringPrimFromStringIDMayAllocate( ip->iLoadConstStringLongIndex.op2))); LOAD_CONST(LoadConstUndefined, HermesValue::encodeUndefinedValue()); LOAD_CONST(LoadConstNull, HermesValue::encodeNullValue()); LOAD_CONST(LoadConstTrue, HermesValue::encodeBoolValue(true)); LOAD_CONST(LoadConstFalse, HermesValue::encodeBoolValue(false)); LOAD_CONST(LoadConstZero, HermesValue::encodeDoubleValue(0)); BINOP(Sub, doSub); BINOP(Mul, doMult); BINOP(Div, doDiv); BITWISEBINOP(BitAnd, &); BITWISEBINOP(BitOr, |); BITWISEBINOP(BitXor, ^); // For LShift, we need to use toUInt32 first because lshift on negative // numbers is undefined behavior in theory. SHIFTOP(LShift, <<, toUInt32_RJS, uint32_t, int32_t); SHIFTOP(RShift, >>, toInt32_RJS, int32_t, int32_t); SHIFTOP(URshift, >>, toUInt32_RJS, uint32_t, uint32_t); CONDOP(Less, <, lessOp_RJS); CONDOP(LessEq, <=, lessEqualOp_RJS); CONDOP(Greater, >, greaterOp_RJS); CONDOP(GreaterEq, >=, greaterEqualOp_RJS); JCOND(Less, <, lessOp_RJS); JCOND(LessEqual, <=, lessEqualOp_RJS); JCOND(Greater, >, greaterOp_RJS); JCOND(GreaterEqual, >=, greaterEqualOp_RJS); JCOND_STRICT_EQ_IMPL( JStrictEqual, , IPADD(ip->iJStrictEqual.op1), NEXTINST(JStrictEqual)); JCOND_STRICT_EQ_IMPL( JStrictEqual, Long, IPADD(ip->iJStrictEqualLong.op1), NEXTINST(JStrictEqualLong)); JCOND_STRICT_EQ_IMPL( JStrictNotEqual, , NEXTINST(JStrictNotEqual), IPADD(ip->iJStrictNotEqual.op1)); JCOND_STRICT_EQ_IMPL( JStrictNotEqual, Long, NEXTINST(JStrictNotEqualLong), IPADD(ip->iJStrictNotEqualLong.op1)); JCOND_EQ_IMPL(JEqual, , IPADD(ip->iJEqual.op1), NEXTINST(JEqual)); JCOND_EQ_IMPL( JEqual, Long, IPADD(ip->iJEqualLong.op1), NEXTINST(JEqualLong)); JCOND_EQ_IMPL( JNotEqual, , NEXTINST(JNotEqual), IPADD(ip->iJNotEqual.op1)); JCOND_EQ_IMPL( JNotEqual, Long, NEXTINST(JNotEqualLong), IPADD(ip->iJNotEqualLong.op1)); CASE_OUTOFLINE(PutOwnByVal); CASE_OUTOFLINE(PutOwnGetterSetterByVal); CASE_OUTOFLINE(DirectEval); CASE_OUTOFLINE(IteratorBegin); CASE_OUTOFLINE(IteratorNext); CASE(IteratorClose) { if (LLVM_UNLIKELY(O1REG(IteratorClose).isObject())) { // The iterator must be closed if it's still an object. // That means it was never an index and is not done iterating (a state // which is indicated by `undefined`). CAPTURE_IP_ASSIGN( auto res, iteratorClose( runtime, Handle::vmcast(&O1REG(IteratorClose)), Runtime::getEmptyValue())); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { if (ip->iIteratorClose.op2 && !isUncatchableError(runtime->thrownValue_)) { // Ignore inner exception. runtime->clearThrownValue(); } else { goto exception; } } gcScope.flushToSmallCount(KEEP_HANDLES); } ip = NEXTINST(IteratorClose); DISPATCH; } CASE(_last) { llvm_unreachable(\"Invalid opcode _last\"); } } llvm_unreachable(\"unreachable\"); // We arrive here if we couldn't allocate the registers for the current frame. stackOverflow: CAPTURE_IP(runtime->raiseStackOverflow( Runtime::StackOverflowKind::JSRegisterStack)); // We arrive here when we raised an exception in a callee, but we don't want // the callee to be able to handle it. handleExceptionInParent: // Restore the caller code block and IP. curCodeBlock = FRAME.getSavedCodeBlock(); ip = FRAME.getSavedIP(); // Pop to the previous frame where technically the error happened. frameRegs = &runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef(); // If we are coming from native code, return. if (!curCodeBlock) return ExecutionStatus::EXCEPTION; // Return because of recursive calling structure #ifdef HERMESVM_PROFILER_EXTERN return ExecutionStatus::EXCEPTION; #endif // Handle the exception. exception: UPDATE_OPCODE_TIME_SPENT; assert( !runtime->thrownValue_.isEmpty() && \"thrownValue unavailable at exception\"); bool catchable = true; // If this is an Error object that was thrown internally, it didn't have // access to the current codeblock and IP, so collect the stack trace here. if (auto *jsError = dyn_vmcast(runtime->thrownValue_)) { catchable = jsError->catchable(); if (!jsError->getStackTrace()) { // Temporarily clear the thrown value for following operations. CAPTURE_IP_ASSIGN( auto errorHandle, runtime->makeHandle(vmcast(runtime->thrownValue_))); runtime->clearThrownValue(); CAPTURE_IP(JSError::recordStackTrace( errorHandle, runtime, false, curCodeBlock, ip)); // Restore the thrown value. runtime->setThrownValue(errorHandle.getHermesValue()); } } gcScope.flushToSmallCount(KEEP_HANDLES); tmpHandle.clear(); #ifdef HERMES_ENABLE_DEBUGGER if (SingleStep) { // If we're single stepping, don't bother with any more checks, // and simply signal that we should continue execution with an exception. state.codeBlock = curCodeBlock; state.offset = CUROFFSET; return ExecutionStatus::EXCEPTION; } using PauseOnThrowMode = facebook::hermes::debugger::PauseOnThrowMode; auto mode = runtime->debugger_.getPauseOnThrowMode(); if (mode != PauseOnThrowMode::None) { if (!runtime->debugger_.isDebugging()) { // Determine whether the PauseOnThrowMode requires us to stop here. bool caught = runtime->debugger_ .findCatchTarget(InterpreterState(curCodeBlock, CUROFFSET)) .hasValue(); bool shouldStop = mode == PauseOnThrowMode::All || (mode == PauseOnThrowMode::Uncaught && !caught); if (shouldStop) { // When runDebugger is invoked after an exception, // stepping should never happen internally. // Any step is a step to an exception handler, which we do // directly here in the interpreter. // Thus, the result state should be the same as the input state. InterpreterState tmpState{curCodeBlock, (uint32_t)CUROFFSET}; CAPTURE_IP_ASSIGN( ExecutionStatus resultStatus, runtime->debugger_.runDebugger( Debugger::RunReason::Exception, tmpState)); (void)resultStatus; assert( tmpState == InterpreterState(curCodeBlock, CUROFFSET) && \"not allowed to step internally in a pauseOnThrow\"); gcScope.flushToSmallCount(KEEP_HANDLES); } } } #endif int32_t handlerOffset = 0; // If the exception is not catchable, skip found catch blocks. while (((handlerOffset = curCodeBlock->findCatchTargetOffset(CUROFFSET)) == -1) || !catchable) { PROFILER_EXIT_FUNCTION(curCodeBlock); #ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES runtime->popCallStack(); #endif // Restore the code block and IP. curCodeBlock = FRAME.getSavedCodeBlock(); ip = FRAME.getSavedIP(); // Pop a stack frame. frameRegs = &runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef(); SLOW_DEBUG( dbgs() << \"function exit with exception: restored stackLevel=\" << runtime->getStackLevel() << \"\\n\"); // Are we returning to native code? if (!curCodeBlock) { SLOW_DEBUG( dbgs() << \"function exit with exception: returning to native code\\n\"); return ExecutionStatus::EXCEPTION; } assert( isCallType(ip->opCode) && \"return address is not Call-type instruction\"); // Return because of recursive calling structure #ifdef HERMESVM_PROFILER_EXTERN return ExecutionStatus::EXCEPTION; #endif } INIT_STATE_FOR_CODEBLOCK(curCodeBlock); ip = IPADD(handlerOffset - CUROFFSET); } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "A logic vulnerability when handling the SaveGeneratorLong instruction in Facebook Hermes prior to commit b2021df620824627f5a8c96615edbd1eb7fdddfc allows attackers to potentially read out of bounds or theoretically execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2020-1914"}} -{"idx": 198112, "input": "rdpBitmapCache* bitmap_cache_new(rdpSettings* settings) { int i; rdpBitmapCache* bitmapCache; bitmapCache = (rdpBitmapCache*)calloc(1, sizeof(rdpBitmapCache)); if (!bitmapCache) return NULL; bitmapCache->settings = settings; bitmapCache->update = ((freerdp*)settings->instance)->update; bitmapCache->context = bitmapCache->update->context; bitmapCache->maxCells = settings->BitmapCacheV2NumCells; bitmapCache->cells = (BITMAP_V2_CELL*)calloc(bitmapCache->maxCells, sizeof(BITMAP_V2_CELL)); if (!bitmapCache->cells) goto fail; for (i = 0; i < (int)bitmapCache->maxCells; i++) { bitmapCache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries; /* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */ bitmapCache->cells[i].entries = (rdpBitmap**)calloc((bitmapCache->cells[i].number + 1), sizeof(rdpBitmap*)); if (!bitmapCache->cells[i].entries) goto fail; } return bitmapCache; fail: if (bitmapCache->cells) { for (i = 0; i < (int)bitmapCache->maxCells; i++) free(bitmapCache->cells[i].entries); } free(bitmapCache); return NULL; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "libfreerdp/cache/bitmap.c in FreeRDP versions > 1.0 through 2.0.0-rc4 has an Out of bounds read.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-11525"}} -{"idx": 284243, "input": "static apr_status_t setup_input(h2_stream *stream) { if (stream->input == NULL) { int empty = (stream->input_eof && (!stream->in_buffer || APR_BRIGADE_EMPTY(stream->in_buffer))); if (!empty) { h2_beam_create(&stream->input, stream->pool, stream->id, \"input\", H2_BEAM_OWNER_SEND, 0, stream->session->s->timeout); h2_beam_send_from(stream->input, stream->pool); } } return APR_SUCCESS; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 302154, "input": "xmlFreeEntity(xmlEntityPtr entity) { xmlDictPtr dict = NULL; if (entity == NULL) return; if (entity->doc != NULL) dict = entity->doc->dict; if ((entity->children) && (entity->owner == 1) && (entity == (xmlEntityPtr) entity->children->parent)) xmlFreeNodeList(entity->children); if (dict != NULL) { if ((entity->name != NULL) && (!xmlDictOwns(dict, entity->name))) xmlFree((char *) entity->name); if ((entity->ExternalID != NULL) && (!xmlDictOwns(dict, entity->ExternalID))) xmlFree((char *) entity->ExternalID); if ((entity->SystemID != NULL) && (!xmlDictOwns(dict, entity->SystemID))) xmlFree((char *) entity->SystemID); if ((entity->URI != NULL) && (!xmlDictOwns(dict, entity->URI))) xmlFree((char *) entity->URI); if ((entity->content != NULL) && (!xmlDictOwns(dict, entity->content))) xmlFree((char *) entity->content); if ((entity->orig != NULL) && (!xmlDictOwns(dict, entity->orig))) xmlFree((char *) entity->orig); } else { if (entity->name != NULL) xmlFree((char *) entity->name); if (entity->ExternalID != NULL) xmlFree((char *) entity->ExternalID); if (entity->SystemID != NULL) xmlFree((char *) entity->SystemID); if (entity->URI != NULL) xmlFree((char *) entity->URI); if (entity->content != NULL) xmlFree((char *) entity->content); if (entity->orig != NULL) xmlFree((char *) entity->orig); } xmlFree(entity); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 199976, "input": "pixFewColorsOctcubeQuantMixed(PIX *pixs, l_int32 level, l_int32 darkthresh, l_int32 lightthresh, l_int32 diffthresh, l_float32 minfract, l_int32 maxspan) { l_int32 i, j, w, h, wplc, wplm, wpld, ncolors, index; l_int32 rval, gval, bval, val, minval, maxval; l_int32 *lut; l_uint32 *datac, *datam, *datad, *linec, *linem, *lined; PIX *pixc, *pixm, *pixg, *pixd; PIXCMAP *cmap, *cmapd; PROCNAME(\"pixFewColorsOctcubeQuantMixed\"); if (!pixs || pixGetDepth(pixs) != 32) return (PIX *)ERROR_PTR(\"pixs undefined or not 32 bpp\", procName, NULL); if (level <= 0) level = 3; if (level > 6) return (PIX *)ERROR_PTR(\"invalid level\", procName, NULL); if (darkthresh <= 0) darkthresh = 20; if (lightthresh <= 0) lightthresh = 244; if (diffthresh <= 0) diffthresh = 20; if (minfract <= 0.0) minfract = 0.05; if (maxspan <= 2) maxspan = 15; /* Start with a simple fixed octcube quantizer. */ if ((pixc = pixFewColorsOctcubeQuant1(pixs, level)) == NULL) return (PIX *)ERROR_PTR(\"too many colors\", procName, NULL); /* Identify and save color entries in the colormap. Set up a LUT * that returns -1 for any gray pixel. */ cmap = pixGetColormap(pixc); ncolors = pixcmapGetCount(cmap); cmapd = pixcmapCreate(8); lut = (l_int32 *)LEPT_CALLOC(256, sizeof(l_int32)); for (i = 0; i < 256; i++) lut[i] = -1; for (i = 0, index = 0; i < ncolors; i++) { pixcmapGetColor(cmap, i, &rval, &gval, &bval); minval = L_MIN(rval, gval); minval = L_MIN(minval, bval); if (minval > lightthresh) /* near white */ continue; maxval = L_MAX(rval, gval); maxval = L_MAX(maxval, bval); if (maxval < darkthresh) /* near black */ continue; /* Use the max diff between components to test for color */ if (maxval - minval >= diffthresh) { pixcmapAddColor(cmapd, rval, gval, bval); lut[i] = index; index++; } } /* Generate dest pix with just the color pixels set to their * colormap indices. At the same time, make a 1 bpp mask * of the non-color pixels */ pixGetDimensions(pixs, &w, &h, NULL); pixd = pixCreate(w, h, 8); pixSetColormap(pixd, cmapd); pixm = pixCreate(w, h, 1); datac = pixGetData(pixc); datam = pixGetData(pixm); datad = pixGetData(pixd); wplc = pixGetWpl(pixc); wplm = pixGetWpl(pixm); wpld = pixGetWpl(pixd); for (i = 0; i < h; i++) { linec = datac + i * wplc; linem = datam + i * wplm; lined = datad + i * wpld; for (j = 0; j < w; j++) { val = GET_DATA_BYTE(linec, j); if (lut[val] == -1) SET_DATA_BIT(linem, j); else SET_DATA_BYTE(lined, j, lut[val]); } } /* Fill in the gray values. Use a grayscale version of pixs * as input, along with the mask over the actual gray pixels. */ pixg = pixConvertTo8(pixs, 0); pixGrayQuantFromHisto(pixd, pixg, pixm, minfract, maxspan); LEPT_FREE(lut); pixDestroy(&pixc); pixDestroy(&pixm); pixDestroy(&pixg); return pixd; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "Leptonica before 1.80.0 allows a heap-based buffer over-read in pixFewColorsOctcubeQuantMixed in colorquant1.c.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-36281"}} -{"idx": 499996, "input": "acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end) { struct acpi_table_ioapic *ioapic = NULL; ioapic = (struct acpi_table_ioapic *)header; if (BAD_MADT_ENTRY(ioapic, end)) return -EINVAL; acpi_table_print_madt_entry(header); mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219069, "input": "void clear() { wall_time = cpu = memory = peak_memory = 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 402166, "input": "int bcf_hdr_add_hrec(bcf_hdr_t *hdr, bcf_hrec_t *hrec) { int res; if ( !hrec ) return 0; hrec->type = BCF_HL_GEN; res = bcf_hdr_register_hrec(hdr,hrec); if (res < 0) return -1; if ( !res ) { // If one of the hashed field, then it is already present if ( hrec->type != BCF_HL_GEN ) { bcf_hrec_destroy(hrec); return 0; } // Is one of the generic fields and already present? int i; for (i=0; inhrec; i++) { if ( hdr->hrec[i]->type!=BCF_HL_GEN ) continue; if ( !strcmp(hdr->hrec[i]->key,hrec->key) && !strcmp(hrec->key,\"fileformat\") ) break; if ( !strcmp(hdr->hrec[i]->key,hrec->key) && !strcmp(hdr->hrec[i]->value,hrec->value) ) break; } if ( inhrec ) { bcf_hrec_destroy(hrec); return 0; } } // New record, needs to be added int n = hdr->nhrec + 1; bcf_hrec_t **new_hrec = realloc(hdr->hrec, n*sizeof(bcf_hrec_t*)); if (!new_hrec) return -1; hdr->hrec = new_hrec; hdr->hrec[hdr->nhrec] = hrec; hdr->dirty = 1; hdr->nhrec = n; return hrec->type==BCF_HL_GEN ? 0 : 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416682, "input": "static enum_func_status php_mysqlnd_auth_response_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) { zend_uchar local_buf[AUTH_RESP_BUFFER_SIZE]; size_t buf_len = conn->net->cmd_buffer.buffer? conn->net->cmd_buffer.length: AUTH_RESP_BUFFER_SIZE; zend_uchar *buf = conn->net->cmd_buffer.buffer? (zend_uchar *) conn->net->cmd_buffer.buffer : local_buf; zend_uchar *p = buf; zend_uchar *begin = buf; unsigned long i; register MYSQLND_PACKET_AUTH_RESPONSE * packet= (MYSQLND_PACKET_AUTH_RESPONSE *) _packet; DBG_ENTER(\"php_mysqlnd_auth_response_read\"); /* leave space for terminating safety \\0 */ buf_len--; PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, \"OK\", PROT_OK_PACKET); BAIL_IF_NO_MORE_DATA; /* zero-terminate the buffer for safety. We are sure there is place for the \\0 because buf_len is -1 the size of the buffer pointed */ buf[packet->header.size] = '\\0'; /* Should be always 0x0 or ERROR_MARKER for error */ packet->response_code = uint1korr(p); p++; BAIL_IF_NO_MORE_DATA; if (ERROR_MARKER == packet->response_code) { php_mysqlnd_read_error_from_line(p, packet->header.size - 1, packet->error, sizeof(packet->error), &packet->error_no, packet->sqlstate TSRMLS_CC); DBG_RETURN(PASS); } if (0xFE == packet->response_code) { /* Authentication Switch Response */ if (packet->header.size > (size_t) (p - buf)) { packet->new_auth_protocol = mnd_pestrdup((char *)p, FALSE); packet->new_auth_protocol_len = strlen(packet->new_auth_protocol); p+= packet->new_auth_protocol_len + 1; /* +1 for the \\0 */ packet->new_auth_protocol_data_len = packet->header.size - (size_t) (p - buf); if (packet->new_auth_protocol_data_len) { packet->new_auth_protocol_data = mnd_emalloc(packet->new_auth_protocol_data_len); memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len); } DBG_INF_FMT(\"The server requested switching auth plugin to : %s\", packet->new_auth_protocol); DBG_INF_FMT(\"Server salt : [%d][%.*s]\", packet->new_auth_protocol_data_len, packet->new_auth_protocol_data_len, packet->new_auth_protocol_data); } } else { /* Everything was fine! */ packet->affected_rows = php_mysqlnd_net_field_length_ll(&p); BAIL_IF_NO_MORE_DATA; packet->last_insert_id = php_mysqlnd_net_field_length_ll(&p); BAIL_IF_NO_MORE_DATA; packet->server_status = uint2korr(p); p+= 2; BAIL_IF_NO_MORE_DATA; packet->warning_count = uint2korr(p); p+= 2; BAIL_IF_NO_MORE_DATA; /* There is a message */ if (packet->header.size > (size_t) (p - buf) && (i = php_mysqlnd_net_field_length(&p))) { packet->message_len = MIN(i, buf_len - (p - begin)); packet->message = mnd_pestrndup((char *)p, packet->message_len, FALSE); } else { packet->message = NULL; packet->message_len = 0; } DBG_INF_FMT(\"OK packet: aff_rows=%lld last_ins_id=%ld server_status=%u warnings=%u\", packet->affected_rows, packet->last_insert_id, packet->server_status, packet->warning_count); } DBG_RETURN(PASS); premature_end: DBG_ERR_FMT(\"OK packet %d bytes shorter than expected\", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, \"AUTH_RESPONSE packet \"MYSQLND_SZ_T_SPEC\" bytes shorter than expected\", p - begin - packet->header.size); DBG_RETURN(FAIL);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409602, "input": "static BOOL rdp_write_rfx_client_capability_container(wStream* s, const rdpSettings* settings) { UINT32 captureFlags; BYTE codecMode; if (!Stream_EnsureRemainingCapacity(s, 64)) return FALSE; captureFlags = settings->RemoteFxOnly ? 0 : CARDP_CAPS_CAPTURE_NON_CAC; codecMode = settings->RemoteFxCodecMode; Stream_Write_UINT16(s, 49); /* codecPropertiesLength */ /* TS_RFX_CLNT_CAPS_CONTAINER */ Stream_Write_UINT32(s, 49); /* length */ Stream_Write_UINT32(s, captureFlags); /* captureFlags */ Stream_Write_UINT32(s, 37); /* capsLength */ /* TS_RFX_CAPS */ Stream_Write_UINT16(s, CBY_CAPS); /* blockType */ Stream_Write_UINT32(s, 8); /* blockLen */ Stream_Write_UINT16(s, 1); /* numCapsets */ /* TS_RFX_CAPSET */ Stream_Write_UINT16(s, CBY_CAPSET); /* blockType */ Stream_Write_UINT32(s, 29); /* blockLen */ Stream_Write_UINT8(s, 0x01); /* codecId (MUST be set to 0x01) */ Stream_Write_UINT16(s, CLY_CAPSET); /* capsetType */ Stream_Write_UINT16(s, 2); /* numIcaps */ Stream_Write_UINT16(s, 8); /* icapLen */ /* TS_RFX_ICAP (RLGR1) */ Stream_Write_UINT16(s, CLW_VERSION_1_0); /* version */ Stream_Write_UINT16(s, CT_TILE_64x64); /* tileSize */ Stream_Write_UINT8(s, codecMode); /* flags */ Stream_Write_UINT8(s, CLW_COL_CONV_ICT); /* colConvBits */ Stream_Write_UINT8(s, CLW_XFORM_DWT_53_A); /* transformBits */ Stream_Write_UINT8(s, CLW_ENTROPY_RLGR1); /* entropyBits */ /* TS_RFX_ICAP (RLGR3) */ Stream_Write_UINT16(s, CLW_VERSION_1_0); /* version */ Stream_Write_UINT16(s, CT_TILE_64x64); /* tileSize */ Stream_Write_UINT8(s, codecMode); /* flags */ Stream_Write_UINT8(s, CLW_COL_CONV_ICT); /* colConvBits */ Stream_Write_UINT8(s, CLW_XFORM_DWT_53_A); /* transformBits */ Stream_Write_UINT8(s, CLW_ENTROPY_RLGR3); /* entropyBits */ return TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 294205, "input": "UINT rdpgfx_write_header(wStream* s, const RDPGFX_HEADER* header) { Stream_Write_UINT16(s, header->cmdId); /* cmdId (2 bytes) */ Stream_Write_UINT16(s, header->flags); /* flags (2 bytes) */ Stream_Write_UINT32(s, header->pduLength); /* pduLength (4 bytes) */ return CHANNEL_RC_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445539, "input": "void tracing_record_taskinfo_sched_switch(struct task_struct *prev, struct task_struct *next, int flags) { bool done; if (tracing_record_taskinfo_skip(flags)) return; /* * Record as much task information as possible. If some fail, continue * to try to record the others. */ done = !(flags & TRACE_RECORD_CMDLINE) || trace_save_cmdline(prev); done &= !(flags & TRACE_RECORD_CMDLINE) || trace_save_cmdline(next); done &= !(flags & TRACE_RECORD_TGID) || trace_save_tgid(prev); done &= !(flags & TRACE_RECORD_TGID) || trace_save_tgid(next); /* If recording any information failed, retry again soon. */ if (!done) return; __this_cpu_write(trace_taskinfo_save, false); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230091, "input": "int64 FeatureCount(int64 batch) const override { return row_splits_(batch + 1) - row_splits_(batch); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232518, "input": "static int check_map_access(struct bpf_verifier_env *env, u32 regno, int off, int size, bool zero_size_allowed) { struct bpf_verifier_state *vstate = env->cur_state; struct bpf_func_state *state = vstate->frame[vstate->curframe]; struct bpf_reg_state *reg = &state->regs[regno]; int err; /* We may have adjusted the register to this map value, so we * need to try adding each of min_value and max_value to off * to make sure our theoretical access will be safe. */ if (env->log.level & BPF_LOG_LEVEL) print_verifier_state(env, state); /* The minimum value is only important with signed * comparisons where we can't assume the floor of a * value is 0. If we are using signed variables for our * index'es we need to make sure that whatever we use * will have a set floor within our range. */ if (reg->smin_value < 0 && (reg->smin_value == S64_MIN || (off + reg->smin_value != (s64)(s32)(off + reg->smin_value)) || reg->smin_value + off < 0)) { verbose(env, \"R%d min value is negative, either use unsigned index or do a if (index >=0) check.\\n\", regno); return -EACCES; } err = __check_map_access(env, regno, reg->smin_value + off, size, zero_size_allowed); if (err) { verbose(env, \"R%d min value is outside of the array range\\n\", regno); return err; } /* If we haven't set a max value then we need to bail since we can't be * sure we won't do bad things. * If reg->umax_value + off could overflow, treat that as unbounded too. */ if (reg->umax_value >= BPF_MAX_VAR_OFF) { verbose(env, \"R%d unbounded memory access, make sure to bounds check any array access into a map\\n\", regno); return -EACCES; } err = __check_map_access(env, regno, reg->umax_value + off, size, zero_size_allowed); if (err) verbose(env, \"R%d max value is outside of the array range\\n\", regno); if (map_value_has_spin_lock(reg->map_ptr)) { u32 lock = reg->map_ptr->spin_lock_off; /* if any part of struct bpf_spin_lock can be touched by * load/store reject this program. * To check that [x1, x2) overlaps with [y1, y2) * it is sufficient to check x1 < y2 && y1 < x2. */ if (reg->smin_value + off < lock + sizeof(struct bpf_spin_lock) && lock < reg->umax_value + off + size) { verbose(env, \"bpf_spin_lock cannot be accessed directly by load/store\\n\"); return -EACCES; } } return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198174, "input": "Status KernelAndDeviceOp::Run( ScopedStepContainer* step_container, const EagerKernelArgs& inputs, std::vector* outputs, CancellationManager* cancellation_manager, const absl::optional& remote_func_params) { OpKernelContext::Params params; params.device = device_; params.frame_iter = FrameAndIter(0, 0); params.inputs = inputs.GetTensorValues(); params.op_kernel = kernel_.get(); params.resource_manager = device_->resource_manager(); params.input_alloc_attrs = &input_alloc_attrs_; params.output_attr_array = output_alloc_attrs_.data(); params.function_library = flr_; params.slice_reader_cache = &slice_reader_cache_; params.rendezvous = rendezvous_; OpExecutionState* op_execution_state = nullptr; CancellationManager default_cancellation_manager; if (cancellation_manager) { params.cancellation_manager = cancellation_manager; } else if (kernel_->is_deferred()) { op_execution_state = new OpExecutionState; params.cancellation_manager = &op_execution_state->cancellation_manager; params.inc_num_deferred_ops_function = [op_execution_state]() { op_execution_state->Ref(); }; params.dec_num_deferred_ops_function = [op_execution_state]() { op_execution_state->Unref(); }; } else { params.cancellation_manager = &default_cancellation_manager; } params.log_memory = log_memory_; params.runner = get_runner(); params.step_container = step_container == nullptr ? &step_container_ : step_container; auto step_container_cleanup = gtl::MakeCleanup([step_container, this] { if (step_container == nullptr) { this->step_container_.CleanUp(); } }); params.collective_executor = collective_executor_ ? collective_executor_->get() : nullptr; OpKernelContext context(¶ms); { port::ScopedFlushDenormal flush; port::ScopedSetRound round(FE_TONEAREST); // 'AnnotatedTraceMe' will trace both scheduling time on host and execution // time on device of the OpKernel. profiler::AnnotatedTraceMe activity( [&] { return kernel_->TraceString(context, /*verbose=*/false); }, profiler::TraceMeLevel::kInfo); device_->Compute(kernel_.get(), &context); } // Clean up execution op_execution_state if deferred ops aren't running. if (op_execution_state != nullptr) { op_execution_state->Unref(); } if (!context.status().ok()) return context.status(); if (outputs != nullptr) { outputs->clear(); for (int i = 0; i < context.num_outputs(); ++i) { outputs->push_back(Tensor(*context.mutable_output(i))); } } return Status::OK(); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Divide By Zero"], "explanation": "In Tensorflow before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1 and 2.3.1, the `tf.raw_ops.Switch` operation takes as input a tensor and a boolean and outputs two tensors. Depending on the boolean value, one of the tensors is exactly the input tensor whereas the other one should be an empty tensor. However, the eager runtime traverses all tensors in the output. Since only one of the tensors is defined, the other one is `nullptr`, hence we are binding a reference to `nullptr`. This is undefined behavior and reported as an error if compiling with `-fsanitize=null`. In this case, this results in a segmentation fault The issue is patched in commit da8558533d925694483d2c136a9220d6d49d843c, and is released in TensorFlow versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, or 2.3.1.", "severity_level": "NoInfo", "cwe": "CWE-369", "cve": "CVE-2020-15190"}} -{"idx": 378551, "input": "SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){ int c; int n1 = pB1->n; int n2 = pB2->n; /* It is possible to have a Blob value that has some non-zero content ** followed by zero content. But that only comes up for Blobs formed ** by the OP_MakeRecord opcode, and such Blobs never get passed into ** sqlite3MemCompare(). */ assert( (pB1->flags & MEM_Zero)==0 || n1==0 ); assert( (pB2->flags & MEM_Zero)==0 || n2==0 ); if( (pB1->flags|pB2->flags) & MEM_Zero ){ if( pB1->flags & pB2->flags & MEM_Zero ){ return pB1->u.nZero - pB2->u.nZero; }else if( pB1->flags & MEM_Zero ){ if( !isAllZero(pB2->z, pB2->n) ) return -1; return pB1->u.nZero - n2; }else{ if( !isAllZero(pB1->z, pB1->n) ) return +1; return n1 - pB2->u.nZero; } } c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1); if( c ) return c; return n1 - n2; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 379951, "input": "} static int iscsi_unicast_skb(struct sk_buff *skb, u32 portid)", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 408807, "input": "static void ca8210_unregister_ext_clock(struct spi_device *spi) { struct ca8210_priv *priv = spi_get_drvdata(spi); if (!priv->clk) return of_clk_del_provider(spi->dev.of_node); clk_unregister(priv->clk); dev_info(&spi->dev, \"External clock unregistered\\n\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381524, "input": "static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 357401, "input": "static OPJ_BOOL opj_j2k_post_write_tile(opj_j2k_t * p_j2k, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager) { OPJ_UINT32 l_nb_bytes_written; OPJ_BYTE * l_current_data = 00; OPJ_UINT32 l_tile_size = 0; OPJ_UINT32 l_available_data; /* preconditions */ assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data); l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size; l_available_data = l_tile_size; l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data; l_nb_bytes_written = 0; if (! opj_j2k_write_first_tile_part(p_j2k, l_current_data, &l_nb_bytes_written, l_available_data, p_stream, p_manager)) { return OPJ_FALSE; } l_current_data += l_nb_bytes_written; l_available_data -= l_nb_bytes_written; l_nb_bytes_written = 0; if (! opj_j2k_write_all_tile_parts(p_j2k, l_current_data, &l_nb_bytes_written, l_available_data, p_stream, p_manager)) { return OPJ_FALSE; } l_available_data -= l_nb_bytes_written; l_nb_bytes_written = l_tile_size - l_available_data; if (opj_stream_write_data(p_stream, p_j2k->m_specific_param.m_encoder.m_encoded_tile_data, l_nb_bytes_written, p_manager) != l_nb_bytes_written) { return OPJ_FALSE; } ++p_j2k->m_current_tile_number; return OPJ_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 267336, "input": "GF_Err gf_isom_force_64bit_chunk_offset(GF_ISOFile *file, Bool set_on) { if (!file) return GF_BAD_PARAM; file->force_co64 = set_on; return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 455268, "input": "RefreshTimeOutProcess ( IN EFI_EVENT Event, IN VOID *Context ) { WARNING_IF_CONTEXT *EventInfo; CHAR16 TimeOutString[MAX_TIME_OUT_LEN]; EventInfo = (WARNING_IF_CONTEXT *) Context; if (*(EventInfo->TimeOut) == 0) { gBS->CloseEvent (Event); gBS->SignalEvent (EventInfo->SyncEvent); return; } UnicodeSPrint(TimeOutString, MAX_TIME_OUT_LEN, L\"%d\", *(EventInfo->TimeOut)); CreateDialog (NULL, gEmptyString, EventInfo->ErrorInfo, gPressEnter, gEmptyString, TimeOutString, NULL); *(EventInfo->TimeOut) -= 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354720, "input": "static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu) { retry: kvm_s390_vcpu_request_handled(vcpu); if (!kvm_request_pending(vcpu)) return 0; /* * We use MMU_RELOAD just to re-arm the ipte notifier for the * guest prefix page. gmap_mprotect_notify will wait on the ptl lock. * This ensures that the ipte instruction for this request has * already finished. We might race against a second unmapper that * wants to set the blocking bit. Lets just retry the request loop. */ if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu)) { int rc; rc = gmap_mprotect_notify(vcpu->arch.gmap, kvm_s390_get_prefix(vcpu), PAGE_SIZE * 2, PROT_WRITE); if (rc) { kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu); return rc; } goto retry; } if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) { vcpu->arch.sie_block->ihcpu = 0xffff; goto retry; } if (kvm_check_request(KVM_REQ_ENABLE_IBS, vcpu)) { if (!ibs_enabled(vcpu)) { trace_kvm_s390_enable_disable_ibs(vcpu->vcpu_id, 1); kvm_s390_set_cpuflags(vcpu, CPUSTAT_IBS); } goto retry; } if (kvm_check_request(KVM_REQ_DISABLE_IBS, vcpu)) { if (ibs_enabled(vcpu)) { trace_kvm_s390_enable_disable_ibs(vcpu->vcpu_id, 0); kvm_s390_clear_cpuflags(vcpu, CPUSTAT_IBS); } goto retry; } if (kvm_check_request(KVM_REQ_ICPT_OPEREXC, vcpu)) { vcpu->arch.sie_block->ictl |= ICTL_OPEREXC; goto retry; } if (kvm_check_request(KVM_REQ_START_MIGRATION, vcpu)) { /* * Disable CMM virtualization; we will emulate the ESSA * instruction manually, in order to provide additional * functionalities needed for live migration. */ vcpu->arch.sie_block->ecb2 &= ~ECB2_CMMA; goto retry; } if (kvm_check_request(KVM_REQ_STOP_MIGRATION, vcpu)) { /* * Re-enable CMM virtualization if CMMA is available and * CMM has been used. */ if ((vcpu->kvm->arch.use_cmma) && (vcpu->kvm->mm->context.uses_cmm)) vcpu->arch.sie_block->ecb2 |= ECB2_CMMA; goto retry; } /* nothing to do, just clear the request */ kvm_clear_request(KVM_REQ_UNHALT, vcpu); /* we left the vsie handler, nothing to do, just clear the request */ kvm_clear_request(KVM_REQ_VSIE_RESTART, vcpu); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 422665, "input": "TEST_F(QueryPlannerTest, ElemMatchValueNegationInArray) { addIndex(BSON(\"i\" << 1)); runQuery(fromjson(\"{i: {$elemMatch: {$not: {$in: [[1]]}}}}\")); assertHasOnlyCollscan(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280063, "input": "static __always_inline void *slab_alloc(struct kmem_cache *s, gfp_t gfpflags, unsigned long addr) { return slab_alloc_node(s, gfpflags, NUMA_NO_NODE, addr); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 341895, "input": "void fuse_invalidate_atime(struct inode *inode) { if (!IS_RDONLY(inode)) fuse_invalidate_attr_mask(inode, STATX_ATIME); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432445, "input": "static bool svm_xsaves_supported(void) { return boot_cpu_has(X86_FEATURE_XSAVES); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 227308, "input": "void skipSpace() { while (isSpace(*p)) p++; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 453319, "input": "static bool bfq_allow_bio_merge(struct request_queue *q, struct request *rq, struct bio *bio) { struct bfq_data *bfqd = q->elevator->elevator_data; bool is_sync = op_is_sync(bio->bi_opf); struct bfq_queue *bfqq = bfqd->bio_bfqq, *new_bfqq; /* * Disallow merge of a sync bio into an async request. */ if (is_sync && !rq_is_sync(rq)) return false; /* * Lookup the bfqq that this bio will be queued with. Allow * merge only if rq is queued there. */ if (!bfqq) return false; /* * We take advantage of this function to perform an early merge * of the queues of possible cooperating processes. */ new_bfqq = bfq_setup_cooperator(bfqd, bfqq, bio, false); if (new_bfqq) { /* * bic still points to bfqq, then it has not yet been * redirected to some other bfq_queue, and a queue * merge between bfqq and new_bfqq can be safely * fulfilled, i.e., bic can be redirected to new_bfqq * and bfqq can be put. */ bfq_merge_bfqqs(bfqd, bfqd->bio_bic, bfqq, new_bfqq); /* * If we get here, bio will be queued into new_queue, * so use new_bfqq to decide whether bio and rq can be * merged. */ bfqq = new_bfqq; /* * Change also bqfd->bio_bfqq, as * bfqd->bio_bic now points to new_bfqq, and * this function may be invoked again (and then may * use again bqfd->bio_bfqq). */ bfqd->bio_bfqq = bfqq; } return bfqq == RQ_BFQQ(rq);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 293642, "input": "static void copy_oom_score_adj(u64 clone_flags, struct task_struct *tsk) { /* Skip if kernel thread */ if (!tsk->mm) return; /* Skip if spawning a thread or using vfork */ if ((clone_flags & (CLONE_VM | CLONE_THREAD | CLONE_VFORK)) != CLONE_VM) return; /* We need to synchronize with __set_oom_adj */ mutex_lock(&oom_adj_mutex); set_bit(MMF_MULTIPROCESS, &tsk->mm->flags); /* Update the values in case they were changed after copy_signal */ tsk->signal->oom_score_adj = current->signal->oom_score_adj; tsk->signal->oom_score_adj_min = current->signal->oom_score_adj_min; mutex_unlock(&oom_adj_mutex); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354592, "input": "static int kvm_s390_set_processor_feat(struct kvm *kvm, struct kvm_device_attr *attr) { struct kvm_s390_vm_cpu_feat data; if (copy_from_user(&data, (void __user *)attr->addr, sizeof(data))) return -EFAULT; if (!bitmap_subset((unsigned long *) data.feat, kvm_s390_available_cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS)) return -EINVAL; mutex_lock(&kvm->lock); if (kvm->created_vcpus) { mutex_unlock(&kvm->lock); return -EBUSY; } bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat, KVM_S390_VM_CPU_FEAT_NR_BITS); mutex_unlock(&kvm->lock); VM_EVENT(kvm, 3, \"SET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx\", data.feat[0], data.feat[1], data.feat[2]); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 200622, "input": "static void ov518_mode_init_regs(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int hsegs, vsegs, packet_size; struct usb_host_interface *alt; struct usb_interface *intf; intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); if (!alt) { gspca_err(gspca_dev, \"Couldn't get altsetting\\n\"); sd->gspca_dev.usb_err = -EIO; return; } packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2); /******** Set the mode ********/ reg_w(sd, 0x2b, 0); reg_w(sd, 0x2c, 0); reg_w(sd, 0x2d, 0); reg_w(sd, 0x2e, 0); reg_w(sd, 0x3b, 0); reg_w(sd, 0x3c, 0); reg_w(sd, 0x3d, 0); reg_w(sd, 0x3e, 0); if (sd->bridge == BRIDGE_OV518) { /* Set 8-bit (YVYU) input format */ reg_w_mask(sd, 0x20, 0x08, 0x08); /* Set 12-bit (4:2:0) output format */ reg_w_mask(sd, 0x28, 0x80, 0xf0); reg_w_mask(sd, 0x38, 0x80, 0xf0); } else { reg_w(sd, 0x28, 0x80); reg_w(sd, 0x38, 0x80); } hsegs = sd->gspca_dev.pixfmt.width / 16; vsegs = sd->gspca_dev.pixfmt.height / 4; reg_w(sd, 0x29, hsegs); reg_w(sd, 0x2a, vsegs); reg_w(sd, 0x39, hsegs); reg_w(sd, 0x3a, vsegs); /* Windows driver does this here; who knows why */ reg_w(sd, 0x2f, 0x80); /******** Set the framerate ********/ if (sd->bridge == BRIDGE_OV518PLUS && sd->revision == 0 && sd->sensor == SEN_OV7620AE) sd->clockdiv = 0; else sd->clockdiv = 1; /* Mode independent, but framerate dependent, regs */ /* 0x51: Clock divider; Only works on some cams which use 2 crystals */ reg_w(sd, 0x51, 0x04); reg_w(sd, 0x22, 0x18); reg_w(sd, 0x23, 0xff); if (sd->bridge == BRIDGE_OV518PLUS) { switch (sd->sensor) { case SEN_OV7620AE: /* * HdG: 640x480 needs special handling on device * revision 2, we check for device revision > 0 to * avoid regressions, as we don't know the correct * thing todo for revision 1. * * Also this likely means we don't need to * differentiate between the OV7620 and OV7620AE, * earlier testing hitting this same problem likely * happened to be with revision < 2 cams using an * OV7620 and revision 2 cams using an OV7620AE. */ if (sd->revision > 0 && sd->gspca_dev.pixfmt.width == 640) { reg_w(sd, 0x20, 0x60); reg_w(sd, 0x21, 0x1f); } else { reg_w(sd, 0x20, 0x00); reg_w(sd, 0x21, 0x19); } break; case SEN_OV7620: reg_w(sd, 0x20, 0x00); reg_w(sd, 0x21, 0x19); break; default: reg_w(sd, 0x21, 0x19); } } else reg_w(sd, 0x71, 0x17); /* Compression-related? */ /* FIXME: Sensor-specific */ /* Bit 5 is what matters here. Of course, it is \"reserved\" */ i2c_w(sd, 0x54, 0x23); reg_w(sd, 0x2f, 0x80); if (sd->bridge == BRIDGE_OV518PLUS) { reg_w(sd, 0x24, 0x94); reg_w(sd, 0x25, 0x90); ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */ ov518_reg_w32(sd, 0xc6, 540, 2); /* 21ch */ ov518_reg_w32(sd, 0xc7, 540, 2); /* 21ch */ ov518_reg_w32(sd, 0xc8, 108, 2); /* 6ch */ ov518_reg_w32(sd, 0xca, 131098, 3); /* 2001ah */ ov518_reg_w32(sd, 0xcb, 532, 2); /* 214h */ ov518_reg_w32(sd, 0xcc, 2400, 2); /* 960h */ ov518_reg_w32(sd, 0xcd, 32, 2); /* 20h */ ov518_reg_w32(sd, 0xce, 608, 2); /* 260h */ } else { reg_w(sd, 0x24, 0x9f); reg_w(sd, 0x25, 0x90); ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */ ov518_reg_w32(sd, 0xc6, 381, 2); /* 17dh */ ov518_reg_w32(sd, 0xc7, 381, 2); /* 17dh */ ov518_reg_w32(sd, 0xc8, 128, 2); /* 80h */ ov518_reg_w32(sd, 0xca, 183331, 3); /* 2cc23h */ ov518_reg_w32(sd, 0xcb, 746, 2); /* 2eah */ ov518_reg_w32(sd, 0xcc, 1750, 2); /* 6d6h */ ov518_reg_w32(sd, 0xcd, 45, 2); /* 2dh */ ov518_reg_w32(sd, 0xce, 851, 2); /* 353h */ } reg_w(sd, 0x2f, 0x80); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "An issue was discovered in the Linux kernel before 5.6.1. drivers/media/usb/gspca/ov519.c allows NULL pointer dereferences in ov511_mode_init_regs and ov518_mode_init_regs when there are zero endpoints, aka CID-998912346c0d.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2020-11608"}} -{"idx": 385173, "input": "gchar* tcp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port) { const gchar *ip_version = src_addr->type == AT_IPv6 ? \"v6\" : \"\"; gchar src_addr_str[WS_INET6_ADDRSTRLEN]; gchar dst_addr_str[WS_INET6_ADDRSTRLEN]; address_to_str_buf(src_addr, src_addr_str, sizeof(src_addr_str)); address_to_str_buf(dst_addr, dst_addr_str, sizeof(dst_addr_str)); return g_strdup_printf(\"((ip%s.src eq %s and tcp.srcport eq %d) and \" \"(ip%s.dst eq %s and tcp.dstport eq %d))\" \" or \" \"((ip%s.src eq %s and tcp.srcport eq %d) and \" \"(ip%s.dst eq %s and tcp.dstport eq %d))\", ip_version, src_addr_str, src_port, ip_version, dst_addr_str, dst_port, ip_version, dst_addr_str, dst_port, ip_version, src_addr_str, src_port); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 215213, "input": "static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_len, char *offset_base, size_t IFDlength, size_t displacement TSRMLS_DC) { int de, i=0, section_index = SECTION_MAKERNOTE; int NumDirEntries, old_motorola_intel, offset_diff; const maker_note_type *maker_note; char *dir_start; for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) { if (i==sizeof(maker_note_array)/sizeof(maker_note_type)) { #ifdef EXIF_DEBUG exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"No maker note data found. Detected maker: %s (length = %d)\", ImageInfo->make, strlen(ImageInfo->make)); #endif /* unknown manufacturer, not an error, use it as a string */ return TRUE; } maker_note = maker_note_array+i; /*exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"check (%s,%s)\", maker_note->make?maker_note->make:\"\", maker_note->model?maker_note->model:\"\");*/ if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make))) continue; if (maker_note->model && (!ImageInfo->model || strcmp(maker_note->model, ImageInfo->model))) continue; if (maker_note->id_string && strncmp(maker_note->id_string, value_ptr, maker_note->id_string_len)) continue; break; } if (maker_note->offset >= value_len) { /* Do not go past the value end */ exif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"IFD data too short: 0x%04X offset 0x%04X\", value_len, maker_note->offset); return FALSE; } dir_start = value_ptr + maker_note->offset; #ifdef EXIF_DEBUG exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Process %s @x%04X + 0x%04X=%d: %s\", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement)); #endif ImageInfo->sections_found |= FOUND_MAKERNOTE; old_motorola_intel = ImageInfo->motorola_intel; switch (maker_note->byte_order) { case MN_ORDER_INTEL: ImageInfo->motorola_intel = 0; break; case MN_ORDER_MOTOROLA: ImageInfo->motorola_intel = 1; break; default: case MN_ORDER_NORMAL: break; } NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); switch (maker_note->offset_mode) { case MN_OFFSET_MAKER: offset_base = value_ptr; break; case MN_OFFSET_GUESS: if (maker_note->offset + 10 + 4 >= value_len) { /* Can not read dir_start+10 since it's beyond value end */ exif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"IFD data too short: 0x%04X\", value_len); return FALSE; } offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel); #ifdef EXIF_DEBUG exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Using automatic offset correction: 0x%04X\", ((int)dir_start-(int)offset_base+maker_note->offset+displacement) + offset_diff); #endif if (offset_diff < 0 || offset_diff >= value_len ) { exif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"IFD data bad offset: 0x%04X length 0x%04X\", offset_diff, value_len); return FALSE; } offset_base = value_ptr + offset_diff; break; default: case MN_OFFSET_NORMAL: break; } if ((2+NumDirEntries*12) > value_len) { exif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Illegal IFD size: 2 + 0x%04X*12 = 0x%04X > 0x%04X\", NumDirEntries, 2+NumDirEntries*12, value_len); return FALSE; } for (de=0;detag_table TSRMLS_CC)) { return FALSE; } } ImageInfo->motorola_intel = old_motorola_intel; /* NextDirOffset (must be NULL) = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel);*/ #ifdef EXIF_DEBUG exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Subsection %s done\", exif_get_sectionname(SECTION_MAKERNOTE)); #endif return TRUE; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "exif_process_IFD_in_MAKERNOTE in ext/exif/exif.c in PHP before 5.6.37, 7.0.x before 7.0.31, 7.1.x before 7.1.20, and 7.2.x before 7.2.8 allows remote attackers to cause a denial of service (out-of-bounds read and application crash) via a crafted JPEG file.", "severity_level": "Medium", "cwe": "CWE-125", "cve": "CVE-2018-14851"}} -{"idx": 198315, "input": "multi_process_incoming_link(struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags) { struct gc_arena gc = gc_new(); struct context *c; struct mroute_addr src, dest; unsigned int mroute_flags; struct multi_instance *mi; bool ret = true; bool floated = false; if (m->pending) { return true; } if (!instance) { #ifdef MULTI_DEBUG_EVENT_LOOP printf(\"TCP/UDP -> TUN [%d]\\n\", BLEN(&m->top.c2.buf)); #endif multi_set_pending(m, multi_get_create_instance_udp(m, &floated)); } else { multi_set_pending(m, instance); } if (m->pending) { set_prefix(m->pending); /* get instance context */ c = &m->pending->context; if (!instance) { /* transfer packet pointer from top-level context buffer to instance */ c->c2.buf = m->top.c2.buf; /* transfer from-addr from top-level context buffer to instance */ if (!floated) { c->c2.from = m->top.c2.from; } } if (BLEN(&c->c2.buf) > 0) { struct link_socket_info *lsi; const uint8_t *orig_buf; /* decrypt in instance context */ perf_push(PERF_PROC_IN_LINK); lsi = get_link_socket_info(c); orig_buf = c->c2.buf.data; if (process_incoming_link_part1(c, lsi, floated)) { if (floated) { multi_process_float(m, m->pending); } process_incoming_link_part2(c, lsi, orig_buf); } perf_pop(); if (TUNNEL_TYPE(m->top.c1.tuntap) == DEV_TYPE_TUN) { /* extract packet source and dest addresses */ mroute_flags = mroute_extract_addr_from_packet(&src, &dest, NULL, NULL, 0, &c->c2.to_tun, DEV_TYPE_TUN); /* drop packet if extract failed */ if (!(mroute_flags & MROUTE_EXTRACT_SUCCEEDED)) { c->c2.to_tun.len = 0; } /* make sure that source address is associated with this client */ else if (multi_get_instance_by_virtual_addr(m, &src, true) != m->pending) { /* IPv6 link-local address (fe80::xxx)? */ if ( (src.type & MR_ADDR_MASK) == MR_ADDR_IPV6 && IN6_IS_ADDR_LINKLOCAL(&src.v6.addr) ) { /* do nothing, for now. TODO: add address learning */ } else { msg(D_MULTI_DROPPED, \"MULTI: bad source address from client [%s], packet dropped\", mroute_addr_print(&src, &gc)); } c->c2.to_tun.len = 0; } /* client-to-client communication enabled? */ else if (m->enable_c2c) { /* multicast? */ if (mroute_flags & MROUTE_EXTRACT_MCAST) { /* for now, treat multicast as broadcast */ multi_bcast(m, &c->c2.to_tun, m->pending, NULL, 0); } else /* possible client to client routing */ { ASSERT(!(mroute_flags & MROUTE_EXTRACT_BCAST)); mi = multi_get_instance_by_virtual_addr(m, &dest, true); /* if dest addr is a known client, route to it */ if (mi) { #ifdef ENABLE_PF if (!pf_c2c_test(&c->c2.pf, c->c2.tls_multi, &mi->context.c2.pf, mi->context.c2.tls_multi, \"tun_c2c\")) { msg(D_PF_DROPPED, \"PF: client -> client[%s] packet dropped by TUN packet filter\", mi_prefix(mi)); } else #endif { multi_unicast(m, &c->c2.to_tun, mi); register_activity(c, BLEN(&c->c2.to_tun)); } c->c2.to_tun.len = 0; } } } #ifdef ENABLE_PF if (c->c2.to_tun.len && !pf_addr_test(&c->c2.pf, c, &dest, \"tun_dest_addr\")) { msg(D_PF_DROPPED, \"PF: client -> addr[%s] packet dropped by TUN packet filter\", mroute_addr_print_ex(&dest, MAPF_SHOW_ARP, &gc)); c->c2.to_tun.len = 0; } #endif } else if (TUNNEL_TYPE(m->top.c1.tuntap) == DEV_TYPE_TAP) { uint16_t vid = 0; #ifdef ENABLE_PF struct mroute_addr edest; mroute_addr_reset(&edest); #endif if (m->top.options.vlan_tagging) { if (vlan_is_tagged(&c->c2.to_tun)) { /* Drop VLAN-tagged frame. */ msg(D_VLAN_DEBUG, \"dropping incoming VLAN-tagged frame\"); c->c2.to_tun.len = 0; } else { vid = c->options.vlan_pvid; } } /* extract packet source and dest addresses */ mroute_flags = mroute_extract_addr_from_packet(&src, &dest, NULL, #ifdef ENABLE_PF &edest, #else NULL, #endif vid, &c->c2.to_tun, DEV_TYPE_TAP); if (mroute_flags & MROUTE_EXTRACT_SUCCEEDED) { if (multi_learn_addr(m, m->pending, &src, 0) == m->pending) { /* check for broadcast */ if (m->enable_c2c) { if (mroute_flags & (MROUTE_EXTRACT_BCAST|MROUTE_EXTRACT_MCAST)) { multi_bcast(m, &c->c2.to_tun, m->pending, NULL, vid); } else /* try client-to-client routing */ { mi = multi_get_instance_by_virtual_addr(m, &dest, false); /* if dest addr is a known client, route to it */ if (mi) { #ifdef ENABLE_PF if (!pf_c2c_test(&c->c2.pf, c->c2.tls_multi, &mi->context.c2.pf, mi->context.c2.tls_multi, \"tap_c2c\")) { msg(D_PF_DROPPED, \"PF: client -> client[%s] packet dropped by TAP packet filter\", mi_prefix(mi)); } else #endif { multi_unicast(m, &c->c2.to_tun, mi); register_activity(c, BLEN(&c->c2.to_tun)); } c->c2.to_tun.len = 0; } } } #ifdef ENABLE_PF if (c->c2.to_tun.len && !pf_addr_test(&c->c2.pf, c, &edest, \"tap_dest_addr\")) { msg(D_PF_DROPPED, \"PF: client -> addr[%s] packet dropped by TAP packet filter\", mroute_addr_print_ex(&edest, MAPF_SHOW_ARP, &gc)); c->c2.to_tun.len = 0; } #endif } else { msg(D_MULTI_DROPPED, \"MULTI: bad source address from client [%s], packet dropped\", mroute_addr_print(&src, &gc)); c->c2.to_tun.len = 0; } } else { c->c2.to_tun.len = 0; } } } /* postprocess and set wakeup */ ret = multi_process_post(m, m->pending, mpp_flags); clear_prefix(); } gc_free(&gc); return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "An issue was discovered in OpenVPN 2.4.x before 2.4.9. An attacker can inject a data channel v2 (P_DATA_V2) packet using a victim's peer-id. Normally such packets are dropped, but if this packet arrives before the data channel crypto parameters have been initialized, the victim's connection will be dropped. This requires careful timing due to the small time window (usually within a few seconds) between the victim client connection starting and the server PUSH_REPLY response back to the client. This attack will only work if Negotiable Cipher Parameters (NCP) is in use.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2020-11810"}} -{"idx": 281492, "input": "static void init_wa_bb_reg_state(u32 * const regs, const struct intel_engine_cs *engine, u32 pos_bb_per_ctx) { const struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx; if (wa_ctx->per_ctx.size) { const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma); regs[pos_bb_per_ctx] = (ggtt_offset + wa_ctx->per_ctx.offset) | 0x01; } if (wa_ctx->indirect_ctx.size) { const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma); regs[pos_bb_per_ctx + 2] = (ggtt_offset + wa_ctx->indirect_ctx.offset) | (wa_ctx->indirect_ctx.size / CACHELINE_BYTES); regs[pos_bb_per_ctx + 4] = intel_lr_indirect_ctx_offset(engine) << 6; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 398207, "input": "static void sctp_for_each_tx_datachunk(struct sctp_association *asoc, bool clear, void (*cb)(struct sctp_chunk *)) { struct sctp_datamsg *msg, *prev_msg = NULL; struct sctp_outq *q = &asoc->outqueue; struct sctp_chunk *chunk, *c; struct sctp_transport *t; list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) list_for_each_entry(chunk, &t->transmitted, transmitted_list) traverse_and_process(); list_for_each_entry(chunk, &q->retransmit, transmitted_list) traverse_and_process(); list_for_each_entry(chunk, &q->sacked, transmitted_list) traverse_and_process(); list_for_each_entry(chunk, &q->abandoned, transmitted_list) traverse_and_process(); list_for_each_entry(chunk, &q->out_chunk_list, list) traverse_and_process(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 378556, "input": "static void selectWindowRewriteEList( Parse *pParse, Window *pWin, SrcList *pSrc, ExprList *pEList, /* Rewrite expressions in this list */ Table *pTab, ExprList **ppSub /* IN/OUT: Sub-select expression-list */ ){ Walker sWalker; WindowRewrite sRewrite; assert( pWin!=0 ); memset(&sWalker, 0, sizeof(Walker)); memset(&sRewrite, 0, sizeof(WindowRewrite)); sRewrite.pSub = *ppSub; sRewrite.pWin = pWin; sRewrite.pSrc = pSrc; sRewrite.pTab = pTab; sWalker.pParse = pParse; sWalker.xExprCallback = selectWindowRewriteExprCb; sWalker.xSelectCallback = selectWindowRewriteSelectCb; sWalker.u.pRewrite = &sRewrite; (void)sqlite3WalkExprList(&sWalker, pEList); *ppSub = sRewrite.pSub; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508488, "input": "add_key_field(JOIN *join, KEY_FIELD **key_fields,uint and_level, Item_bool_func *cond, Field *field, bool eq_func, Item **value, uint num_values, table_map usable_tables, SARGABLE_PARAM **sargables, uint row_col_no= 0) { uint optimize= 0; if (eq_func && ((join->is_allowed_hash_join_access() && field->hash_join_is_possible() && !(field->table->pos_in_table_list->is_materialized_derived() && field->table->is_created())) || (field->table->pos_in_table_list->is_materialized_derived() && !field->table->is_created() && !(field->flags & BLOB_FLAG)))) { optimize= KEY_OPTIMIZE_EQ; } else if (!(field->flags & PART_KEY_FLAG)) { // Don't remove column IS NULL on a LEFT JOIN table if (eq_func && (*value)->type() == Item::NULL_ITEM && field->table->maybe_null && !field->null_ptr) { optimize= KEY_OPTIMIZE_EXISTS; DBUG_ASSERT(num_values == 1); } } if (optimize != KEY_OPTIMIZE_EXISTS) { table_map used_tables=0; bool optimizable=0; for (uint i=0; ireal_item()->type() == Item::ROW_ITEM) { Item_row *value_tuple= (Item_row *) (value[i]->real_item()); curr_val= value_tuple->element_index(row_col_no - 1); } else curr_val= value[i]; table_map value_used_tables= curr_val->used_tables(); used_tables|= value_used_tables; if (!(value_used_tables & (field->table->map | RAND_TABLE_BIT))) optimizable=1; } if (!optimizable) return; if (!(usable_tables & field->table->map)) { if (!eq_func || (*value)->type() != Item::NULL_ITEM || !field->table->maybe_null || field->null_ptr) return; // Can't use left join optimize optimize= KEY_OPTIMIZE_EXISTS; } else { JOIN_TAB *stat=field->table->reginfo.join_tab; key_map possible_keys=field->get_possible_keys(); possible_keys.intersect(field->table->keys_in_use_for_query); stat[0].keys.merge(possible_keys); // Add possible keys /* Save the following cases: Field op constant Field LIKE constant where constant doesn't start with a wildcard Field = field2 where field2 is in a different table Field op formula Field IS NULL Field IS NOT NULL Field BETWEEN ... Field IN ... */ if (field->flags & PART_KEY_FLAG) stat[0].key_dependent|=used_tables; bool is_const=1; for (uint i=0; ireal_item()->type() == Item::ROW_ITEM) { Item_row *value_tuple= (Item_row *) (value[i]->real_item()); curr_val= value_tuple->element_index(row_col_no - 1); } else curr_val= value[i]; if (!(is_const&= curr_val->const_item())) break; } if (is_const) { stat[0].const_keys.merge(possible_keys); bitmap_set_bit(&field->table->cond_set, field->field_index); } else if (!eq_func) { /* Save info to be able check whether this predicate can be considered as sargable for range analisis after reading const tables. We do not save info about equalities as update_const_equal_items will take care of updating info on keys from sargable equalities. */ (*sargables)--; (*sargables)->field= field; (*sargables)->arg_value= value; (*sargables)->num_values= num_values; } if (!eq_func) // eq_func is NEVER true when num_values > 1 return; } } /* For the moment eq_func is always true. This slot is reserved for future extensions where we want to remembers other things than just eq comparisons */ DBUG_ASSERT(eq_func); /* Store possible eq field */ (*key_fields)->field= field; (*key_fields)->eq_func= eq_func; (*key_fields)->val= *value; (*key_fields)->cond= cond; (*key_fields)->level= and_level; (*key_fields)->optimize= optimize; /* If the condition we are analyzing is NULL-rejecting and at least one side of the equalities is NULLable, mark the KEY_FIELD object as null-rejecting. This property is used by: - add_not_null_conds() to add \"column IS NOT NULL\" conditions - best_access_path() to produce better estimates for NULL-able unique keys. */ { if ((cond->functype() == Item_func::EQ_FUNC || cond->functype() == Item_func::MULT_EQUAL_FUNC) && ((*value)->maybe_null || field->real_maybe_null())) (*key_fields)->null_rejecting= true; else (*key_fields)->null_rejecting= false; } (*key_fields)->cond_guard= NULL; (*key_fields)->sj_pred_no= get_semi_join_select_list_index(field); (*key_fields)++; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 429673, "input": "mysql_select_db(MYSQL *mysql, const char *db) { int error; if (!db) return 1; if ((error=ma_simple_command(mysql, COM_INIT_DB, db, (uint) strlen(db),0,0))) return(error); free(mysql->db); mysql->db=strdup(db); return(0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 262857, "input": "static void dmar_disable_translation(struct dmar_drhd_rt *dmar_unit) { uint32_t status; spinlock_obtain(&(dmar_unit->lock)); if ((dmar_unit->gcmd & DMA_GCMD_TE) != 0U) { dmar_unit->gcmd &= ~DMA_GCMD_TE; iommu_write32(dmar_unit, DMAR_GCMD_REG, dmar_unit->gcmd); /* 32-bit register */ dmar_wait_completion(dmar_unit, DMAR_GSTS_REG, DMA_GSTS_TES, DMA_GSTS_TES, &status); } spinlock_release(&(dmar_unit->lock)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232995, "input": "virtio_set_io_bar(struct virtio_base *base, int barnum) { size_t size; /* * ??? should we use VIRTIO_PCI_CONFIG_OFF(0) if MSI-X * is disabled? Existing code did not... */ size = VIRTIO_PCI_CONFIG_OFF(1) + base->vops->cfgsize; pci_emul_alloc_bar(base->dev, barnum, PCIBAR_IO, size); base->legacy_pio_bar_idx = barnum; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 462456, "input": "void dw_spi_remove_host(struct dw_spi *dws) { dw_spi_debugfs_remove(dws); if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws); spi_shutdown_chip(dws); free_irq(dws->irq, dws->master); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 295409, "input": "static int pick_link(struct nameidata *nd, struct path *link, struct inode *inode, unsigned seq) { int error; struct saved *last; if (unlikely(nd->total_link_count++ >= MAXSYMLINKS)) { path_to_nameidata(link, nd); return -ELOOP; } if (!(nd->flags & LOOKUP_RCU)) { if (link->mnt == nd->path.mnt) mntget(link->mnt); } error = nd_alloc_stack(nd); if (unlikely(error)) { if (error == -ECHILD) { if (unlikely(!legitimize_path(nd, link, seq))) { drop_links(nd); nd->depth = 0; nd->flags &= ~LOOKUP_RCU; nd->path.mnt = NULL; nd->path.dentry = NULL; rcu_read_unlock(); } else if (likely(unlazy_walk(nd)) == 0) error = nd_alloc_stack(nd); } if (error) { path_put(link); return error; } } last = nd->stack + nd->depth++; last->link = *link; clear_delayed_call(&last->done); nd->link_inode = inode; last->seq = seq; return 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 349469, "input": "p11_rpc_message_write_attribute_buffer (p11_rpc_message *msg, CK_ATTRIBUTE_PTR arr, CK_ULONG num) { CK_ATTRIBUTE_PTR attr; CK_ULONG i; assert (num == 0 || arr != NULL); assert (msg != NULL); assert (msg->output != NULL); /* Make sure this is in the right order */ assert (!msg->signature || p11_rpc_message_verify_part (msg, \"fA\")); /* Write the number of items */ p11_rpc_buffer_add_uint32 (msg->output, num); for (i = 0; i < num; ++i) { attr = &(arr[i]); /* The attribute type */ p11_rpc_buffer_add_uint32 (msg->output, attr->type); /* And the attribute buffer length */ p11_rpc_buffer_add_uint32 (msg->output, attr->pValue ? attr->ulValueLen : 0); } return !p11_buffer_failed (msg->output); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 361272, "input": "static int checkStringLength(client *c, long long size) { if (!(c->flags & CLIENT_MASTER) && size > server.proto_max_bulk_len) { addReplyError(c,\"string exceeds maximum allowed size (proto-max-bulk-len)\"); return C_ERR; } return C_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 399270, "input": "void imap_qualify_path(char *buf, size_t buflen, struct ConnAccount *cac, char *path) { struct Url url = { 0 }; mutt_account_tourl(cac, &url); url.path = path; url_tostring(&url, buf, buflen, U_NO_FLAGS); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 318238, "input": "int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) { return parse_rtattr_flags(tb, max, rta, len, 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 231546, "input": "unsigned int CClient::PutStatus(const CTable& table) { unsigned int idx = 0; CString sLine; while (table.GetLine(idx++, sLine)) PutStatus(sLine); return idx - 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 492793, "input": "long keyctl_keyring_search(key_serial_t ringid, const char __user *_type, const char __user *_description, key_serial_t destringid) { struct key_type *ktype; key_ref_t keyring_ref, key_ref, dest_ref; char type[32], *description; long ret; /* pull the type and description into kernel space */ ret = key_get_type_from_user(type, _type, sizeof(type)); if (ret < 0) goto error; description = strndup_user(_description, PAGE_SIZE); if (IS_ERR(description)) { ret = PTR_ERR(description); goto error; } /* get the keyring at which to begin the search */ keyring_ref = lookup_user_key(ringid, 0, KEY_SEARCH); if (IS_ERR(keyring_ref)) { ret = PTR_ERR(keyring_ref); goto error2; } /* get the destination keyring if specified */ dest_ref = NULL; if (destringid) { dest_ref = lookup_user_key(destringid, KEY_LOOKUP_CREATE, KEY_WRITE); if (IS_ERR(dest_ref)) { ret = PTR_ERR(dest_ref); goto error3; } } /* find the key type */ ktype = key_type_lookup(type); if (IS_ERR(ktype)) { ret = PTR_ERR(ktype); goto error4; } /* do the search */ key_ref = keyring_search(keyring_ref, ktype, description); if (IS_ERR(key_ref)) { ret = PTR_ERR(key_ref); /* treat lack or presence of a negative key the same */ if (ret == -EAGAIN) ret = -ENOKEY; goto error5; } /* link the resulting key to the destination keyring if we can */ if (dest_ref) { ret = key_permission(key_ref, KEY_LINK); if (ret < 0) goto error6; ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref)); if (ret < 0) goto error6; } ret = key_ref_to_ptr(key_ref)->serial; error6: key_ref_put(key_ref); error5: key_type_put(ktype); error4: key_ref_put(dest_ref); error3: key_ref_put(keyring_ref); error2: kfree(description); error: return ret; } /* end keyctl_keyring_search() */", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432409, "input": "static int ud_interception(struct vcpu_svm *svm) { return handle_ud(&svm->vcpu); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 385314, "input": "xmlChar * xmlXPathParseName(xmlXPathParserContextPtr ctxt) { const xmlChar *in; xmlChar *ret; size_t count = 0; if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL); /* * Accelerator for simple ASCII names */ in = ctxt->cur; if (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || (*in == '_') || (*in == ':')) { in++; while (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || ((*in >= 0x30) && (*in <= 0x39)) || (*in == '_') || (*in == '-') || (*in == ':') || (*in == '.')) in++; if ((*in > 0) && (*in < 0x80)) { count = in - ctxt->cur; if (count > XML_MAX_NAME_LENGTH) { ctxt->cur = in; XP_ERRORNULL(XPATH_EXPR_ERROR); } ret = xmlStrndup(ctxt->cur, count); ctxt->cur = in; return(ret); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 330541, "input": "static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) { char buf[1024]; VncShareMode mode; int size; mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE; switch (vs->vd->share_policy) { case VNC_SHARE_POLICY_IGNORE: /* * Ignore the shared flag. Nothing to do here. * * Doesn't conform to the rfb spec but is traditional qemu * behavior, thus left here as option for compatibility * reasons. */ break; case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE: /* * Policy: Allow clients ask for exclusive access. * * Implementation: When a client asks for exclusive access, * disconnect all others. Shared connects are allowed as long * as no exclusive connection exists. * * This is how the rfb spec suggests to handle the shared flag. */ if (mode == VNC_SHARE_MODE_EXCLUSIVE) { VncState *client; QTAILQ_FOREACH(client, &vs->vd->clients, next) { if (vs == client) { continue; } if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE && client->share_mode != VNC_SHARE_MODE_SHARED) { continue; } vnc_disconnect_start(client); } } if (mode == VNC_SHARE_MODE_SHARED) { if (vs->vd->num_exclusive > 0) { vnc_disconnect_start(vs); return 0; } } break; case VNC_SHARE_POLICY_FORCE_SHARED: /* * Policy: Shared connects only. * Implementation: Disallow clients asking for exclusive access. * * Useful for shared desktop sessions where you don't want * someone forgetting to say -shared when running the vnc * client disconnect everybody else. */ if (mode == VNC_SHARE_MODE_EXCLUSIVE) { vnc_disconnect_start(vs); return 0; } break; } vnc_set_share_mode(vs, mode); if (vs->vd->num_shared > vs->vd->connections_limit) { vnc_disconnect_start(vs); return 0; } vs->client_width = pixman_image_get_width(vs->vd->server); vs->client_height = pixman_image_get_height(vs->vd->server); vnc_write_u16(vs, vs->client_width); vnc_write_u16(vs, vs->client_height); pixel_format_message(vs); if (qemu_name) size = snprintf(buf, sizeof(buf), \"QEMU (%s)\", qemu_name); else size = snprintf(buf, sizeof(buf), \"QEMU\"); vnc_write_u32(vs, size); vnc_write(vs, buf, size); vnc_flush(vs); vnc_client_cache_auth(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED); vnc_read_when(vs, protocol_client_msg, 1); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 216983, "input": "address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, hwaddr *xlat, hwaddr *plen, MemTxAttrs attrs, int *prot) { MemoryRegionSection *section; IOMMUMemoryRegion *iommu_mr; IOMMUMemoryRegionClass *imrc; IOMMUTLBEntry iotlb; int iommu_idx; AddressSpaceDispatch *d = qatomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch); for (;;) { section = address_space_translate_internal(d, addr, &addr, plen, false); iommu_mr = memory_region_get_iommu(section->mr); if (!iommu_mr) { break; } imrc = memory_region_get_iommu_class_nocheck(iommu_mr); iommu_idx = imrc->attrs_to_index(iommu_mr, attrs); tcg_register_iommu_notifier(cpu, iommu_mr, iommu_idx); /* We need all the permissions, so pass IOMMU_NONE so the IOMMU * doesn't short-cut its translation table walk. */ iotlb = imrc->translate(iommu_mr, addr, IOMMU_NONE, iommu_idx); addr = ((iotlb.translated_addr & ~iotlb.addr_mask) | (addr & iotlb.addr_mask)); /* Update the caller's prot bits to remove permissions the IOMMU * is giving us a failure response for. If we get down to no * permissions left at all we can give up now. */ if (!(iotlb.perm & IOMMU_RO)) { *prot &= ~(PAGE_READ | PAGE_EXEC); } if (!(iotlb.perm & IOMMU_WO)) { *prot &= ~PAGE_WRITE; } if (!*prot) { goto translate_fail; } d = flatview_to_dispatch(address_space_to_flatview(iotlb.target_as)); } assert(!memory_region_is_iommu(section->mr)); *xlat = addr; return section; translate_fail: return &d->map.sections[PHYS_SECTION_UNASSIGNED]; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Use of Uninitialized Resource"], "explanation": "softmmu/physmem.c in QEMU through 7.0.0 can perform an uninitialized read on the translate_fail path, leading to an io_readx or io_writex crash. NOTE: a third party states that the Non-virtualization Use Case in the qemu.org reference applies here, i.e., \"Bugs affecting the non-virtualization use case are not considered security bugs at this time.", "severity_level": "NoInfo", "cwe": "CWE-908", "cve": "CVE-2022-35414"}} -{"idx": 508525, "input": "Item_equal::add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, table_map usable_tables, SARGABLE_PARAM **sargables) { Item *const_item2= get_const(); Item_equal_fields_iterator it(*this); if (const_item2) { /* For each field field1 from item_equal consider the equality field1=const_item as a condition allowing an index access of the table with field1 by the keys value of field1. */ while (it++) { Field *equal_field= it.get_curr_field(); add_key_field(join, key_fields, *and_level, this, equal_field, TRUE, &const_item2, 1, usable_tables, sargables); } } else { /* Consider all pairs of different fields included into item_equal. For each of them (field1, field1) consider the equality field1=field2 as a condition allowing an index access of the table with field1 by the keys value of field2. */ Item_equal_fields_iterator fi(*this); while (fi++) { Field *field= fi.get_curr_field(); Item *item; while ((item= it++)) { Field *equal_field= it.get_curr_field(); if (!field->eq(equal_field)) { add_key_field(join, key_fields, *and_level, this, field, TRUE, &item, 1, usable_tables, sargables); } } it.rewind(); } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416793, "input": "static inline void cil_reset_cats(struct cil_cats *cats) { if (cats != NULL) { cats->evaluated = CIL_FALSE; cil_list_destroy(&cats->datum_expr, CIL_FALSE); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 325877, "input": "combine_surrogate_pair(uint32_t uc, uint32_t uc2) { uc -= 0xD800; uc *= 0x400; uc += uc2 - 0xDC00; uc += 0x10000; return (uc); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 429627, "input": "mysql_get_parameters(void) { return &mariadb_internal_parameters; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 212365, "input": "int vt_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct vc_data *vc = tty->driver_data; struct console_font_op op; /* used in multiple places here */ unsigned int console; unsigned char ucval; unsigned int uival; void __user *up = (void __user *)arg; int i, perm; int ret = 0; console = vc->vc_num; if (!vc_cons_allocated(console)) { /* impossible? */ ret = -ENOIOCTLCMD; goto out; } /* * To have permissions to do most of the vt ioctls, we either have * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. */ perm = 0; if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) perm = 1; switch (cmd) { case TIOCLINUX: ret = tioclinux(tty, arg); break; case KIOCSOUND: if (!perm) return -EPERM; /* * The use of PIT_TICK_RATE is historic, it used to be * the platform-dependent CLOCK_TICK_RATE between 2.6.12 * and 2.6.36, which was a minor but unfortunate ABI * change. kd_mksound is locked by the input layer. */ if (arg) arg = PIT_TICK_RATE / arg; kd_mksound(arg, 0); break; case KDMKTONE: if (!perm) return -EPERM; { unsigned int ticks, count; /* * Generate the tone for the appropriate number of ticks. * If the time is zero, turn off sound ourselves. */ ticks = msecs_to_jiffies((arg >> 16) & 0xffff); count = ticks ? (arg & 0xffff) : 0; if (count) count = PIT_TICK_RATE / count; kd_mksound(count, ticks); break; } case KDGKBTYPE: /* * this is na\u00efve. */ ucval = KB_101; ret = put_user(ucval, (char __user *)arg); break; /* * These cannot be implemented on any machine that implements * ioperm() in user level (such as Alpha PCs) or not at all. * * XXX: you should never use these, just call ioperm directly.. */ #ifdef CONFIG_X86 case KDADDIO: case KDDELIO: /* * KDADDIO and KDDELIO may be able to add ports beyond what * we reject here, but to be safe... * * These are locked internally via sys_ioperm */ if (arg < GPFIRST || arg > GPLAST) { ret = -EINVAL; break; } ret = ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0; break; case KDENABIO: case KDDISABIO: ret = ksys_ioperm(GPFIRST, GPNUM, (cmd == KDENABIO)) ? -ENXIO : 0; break; #endif /* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */ case KDKBDREP: { struct kbd_repeat kbrep; if (!capable(CAP_SYS_TTY_CONFIG)) return -EPERM; if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat))) { ret = -EFAULT; break; } ret = kbd_rate(&kbrep); if (ret) break; if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat))) ret = -EFAULT; break; } case KDSETMODE: /* * currently, setting the mode from KD_TEXT to KD_GRAPHICS * doesn't do a whole lot. i'm not sure if it should do any * restoration of modes or what... * * XXX It should at least call into the driver, fbdev's definitely * need to restore their engine state. --BenH */ if (!perm) return -EPERM; switch (arg) { case KD_GRAPHICS: break; case KD_TEXT0: case KD_TEXT1: arg = KD_TEXT; case KD_TEXT: break; default: ret = -EINVAL; goto out; } /* FIXME: this needs the console lock extending */ if (vc->vc_mode == (unsigned char) arg) break; vc->vc_mode = (unsigned char) arg; if (console != fg_console) break; /* * explicitly blank/unblank the screen if switching modes */ console_lock(); if (arg == KD_TEXT) do_unblank_screen(1); else do_blank_screen(1); console_unlock(); break; case KDGETMODE: uival = vc->vc_mode; goto setint; case KDMAPDISP: case KDUNMAPDISP: /* * these work like a combination of mmap and KDENABIO. * this could be easily finished. */ ret = -EINVAL; break; case KDSKBMODE: if (!perm) return -EPERM; ret = vt_do_kdskbmode(console, arg); if (ret == 0) tty_ldisc_flush(tty); break; case KDGKBMODE: uival = vt_do_kdgkbmode(console); ret = put_user(uival, (int __user *)arg); break; /* this could be folded into KDSKBMODE, but for compatibility reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */ case KDSKBMETA: ret = vt_do_kdskbmeta(console, arg); break; case KDGKBMETA: /* FIXME: should review whether this is worth locking */ uival = vt_do_kdgkbmeta(console); setint: ret = put_user(uival, (int __user *)arg); break; case KDGETKEYCODE: case KDSETKEYCODE: if(!capable(CAP_SYS_TTY_CONFIG)) perm = 0; ret = vt_do_kbkeycode_ioctl(cmd, up, perm); break; case KDGKBENT: case KDSKBENT: ret = vt_do_kdsk_ioctl(cmd, up, perm, console); break; case KDGKBSENT: case KDSKBSENT: ret = vt_do_kdgkb_ioctl(cmd, up, perm); break; /* Diacritical processing. Handled in keyboard.c as it has to operate on the keyboard locks and structures */ case KDGKBDIACR: case KDGKBDIACRUC: case KDSKBDIACR: case KDSKBDIACRUC: ret = vt_do_diacrit(cmd, up, perm); break; /* the ioctls below read/set the flags usually shown in the leds */ /* don't use them - they will go away without warning */ case KDGKBLED: case KDSKBLED: case KDGETLED: case KDSETLED: ret = vt_do_kdskled(console, cmd, arg, perm); break; /* * A process can indicate its willingness to accept signals * generated by pressing an appropriate key combination. * Thus, one can have a daemon that e.g. spawns a new console * upon a keypress and then changes to it. * See also the kbrequest field of inittab(5). */ case KDSIGACCEPT: { if (!perm || !capable(CAP_KILL)) return -EPERM; if (!valid_signal(arg) || arg < 1 || arg == SIGKILL) ret = -EINVAL; else { spin_lock_irq(&vt_spawn_con.lock); put_pid(vt_spawn_con.pid); vt_spawn_con.pid = get_pid(task_pid(current)); vt_spawn_con.sig = arg; spin_unlock_irq(&vt_spawn_con.lock); } break; } case VT_SETMODE: { struct vt_mode tmp; if (!perm) return -EPERM; if (copy_from_user(&tmp, up, sizeof(struct vt_mode))) { ret = -EFAULT; goto out; } if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) { ret = -EINVAL; goto out; } console_lock(); vc->vt_mode = tmp; /* the frsig is ignored, so we set it to 0 */ vc->vt_mode.frsig = 0; put_pid(vc->vt_pid); vc->vt_pid = get_pid(task_pid(current)); /* no switch is required -- saw@shade.msu.ru */ vc->vt_newvt = -1; console_unlock(); break; } case VT_GETMODE: { struct vt_mode tmp; int rc; console_lock(); memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); console_unlock(); rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); if (rc) ret = -EFAULT; break; } /* * Returns global vt state. Note that VT 0 is always open, since * it's an alias for the current VT, and people can't use it here. * We cannot return state for more than 16 VTs, since v_state is short. */ case VT_GETSTATE: { struct vt_stat __user *vtstat = up; unsigned short state, mask; /* Review: FIXME: Console lock ? */ if (put_user(fg_console + 1, &vtstat->v_active)) ret = -EFAULT; else { state = 1; /* /dev/tty0 is always open */ for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask; ++i, mask <<= 1) if (VT_IS_IN_USE(i)) state |= mask; ret = put_user(state, &vtstat->v_state); } break; } /* * Returns the first available (non-opened) console. */ case VT_OPENQRY: /* FIXME: locking ? - but then this is a stupid API */ for (i = 0; i < MAX_NR_CONSOLES; ++i) if (! VT_IS_IN_USE(i)) break; uival = i < MAX_NR_CONSOLES ? (i+1) : -1; goto setint; /* * ioctl(fd, VT_ACTIVATE, num) will cause us to switch to vt # num, * with num >= 1 (switches to vt 0, our console, are not allowed, just * to preserve sanity). */ case VT_ACTIVATE: if (!perm) return -EPERM; if (arg == 0 || arg > MAX_NR_CONSOLES) ret = -ENXIO; else { arg--; console_lock(); ret = vc_allocate(arg); console_unlock(); if (ret) break; set_console(arg); } break; case VT_SETACTIVATE: { struct vt_setactivate vsa; if (!perm) return -EPERM; if (copy_from_user(&vsa, (struct vt_setactivate __user *)arg, sizeof(struct vt_setactivate))) { ret = -EFAULT; goto out; } if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES) ret = -ENXIO; else { vsa.console = array_index_nospec(vsa.console, MAX_NR_CONSOLES + 1); vsa.console--; console_lock(); ret = vc_allocate(vsa.console); if (ret == 0) { struct vc_data *nvc; /* This is safe providing we don't drop the console sem between vc_allocate and finishing referencing nvc */ nvc = vc_cons[vsa.console].d; nvc->vt_mode = vsa.mode; nvc->vt_mode.frsig = 0; put_pid(nvc->vt_pid); nvc->vt_pid = get_pid(task_pid(current)); } console_unlock(); if (ret) break; /* Commence switch and lock */ /* Review set_console locks */ set_console(vsa.console); } break; } /* * wait until the specified VT has been activated */ case VT_WAITACTIVE: if (!perm) return -EPERM; if (arg == 0 || arg > MAX_NR_CONSOLES) ret = -ENXIO; else ret = vt_waitactive(arg); break; /* * If a vt is under process control, the kernel will not switch to it * immediately, but postpone the operation until the process calls this * ioctl, allowing the switch to complete. * * According to the X sources this is the behavior: * 0: pending switch-from not OK * 1: pending switch-from OK * 2: completed switch-to OK */ case VT_RELDISP: if (!perm) return -EPERM; console_lock(); if (vc->vt_mode.mode != VT_PROCESS) { console_unlock(); ret = -EINVAL; break; } /* * Switching-from response */ if (vc->vt_newvt >= 0) { if (arg == 0) /* * Switch disallowed, so forget we were trying * to do it. */ vc->vt_newvt = -1; else { /* * The current vt has been released, so * complete the switch. */ int newvt; newvt = vc->vt_newvt; vc->vt_newvt = -1; ret = vc_allocate(newvt); if (ret) { console_unlock(); break; } /* * When we actually do the console switch, * make sure we are atomic with respect to * other console switches.. */ complete_change_console(vc_cons[newvt].d); } } else { /* * Switched-to response */ /* * If it's just an ACK, ignore it */ if (arg != VT_ACKACQ) ret = -EINVAL; } console_unlock(); break; /* * Disallocate memory associated to VT (but leave VT1) */ case VT_DISALLOCATE: if (arg > MAX_NR_CONSOLES) { ret = -ENXIO; break; } if (arg == 0) vt_disallocate_all(); else ret = vt_disallocate(--arg); break; case VT_RESIZE: { struct vt_sizes __user *vtsizes = up; struct vc_data *vc; ushort ll,cc; if (!perm) return -EPERM; if (get_user(ll, &vtsizes->v_rows) || get_user(cc, &vtsizes->v_cols)) ret = -EFAULT; else { console_lock(); for (i = 0; i < MAX_NR_CONSOLES; i++) { vc = vc_cons[i].d; if (vc) { vc->vc_resize_user = 1; /* FIXME: review v tty lock */ vc_resize(vc_cons[i].d, cc, ll); } } console_unlock(); } break; } case VT_RESIZEX: { struct vt_consize v; if (!perm) return -EPERM; if (copy_from_user(&v, up, sizeof(struct vt_consize))) return -EFAULT; /* FIXME: Should check the copies properly */ if (!v.v_vlin) v.v_vlin = vc->vc_scan_lines; if (v.v_clin) { int rows = v.v_vlin/v.v_clin; if (v.v_rows != rows) { if (v.v_rows) /* Parameters don't add up */ return -EINVAL; v.v_rows = rows; } } if (v.v_vcol && v.v_ccol) { int cols = v.v_vcol/v.v_ccol; if (v.v_cols != cols) { if (v.v_cols) return -EINVAL; v.v_cols = cols; } } if (v.v_clin > 32) return -EINVAL; for (i = 0; i < MAX_NR_CONSOLES; i++) { if (!vc_cons[i].d) continue; console_lock(); if (v.v_vlin) vc_cons[i].d->vc_scan_lines = v.v_vlin; if (v.v_clin) vc_cons[i].d->vc_font.height = v.v_clin; vc_cons[i].d->vc_resize_user = 1; vc_resize(vc_cons[i].d, v.v_cols, v.v_rows); console_unlock(); } break; } case PIO_FONT: { if (!perm) return -EPERM; op.op = KD_FONT_OP_SET; op.flags = KD_FONT_FLAG_OLD | KD_FONT_FLAG_DONT_RECALC; /* Compatibility */ op.width = 8; op.height = 0; op.charcount = 256; op.data = up; ret = con_font_op(vc_cons[fg_console].d, &op); break; } case GIO_FONT: { op.op = KD_FONT_OP_GET; op.flags = KD_FONT_FLAG_OLD; op.width = 8; op.height = 32; op.charcount = 256; op.data = up; ret = con_font_op(vc_cons[fg_console].d, &op); break; } case PIO_CMAP: if (!perm) ret = -EPERM; else ret = con_set_cmap(up); break; case GIO_CMAP: ret = con_get_cmap(up); break; case PIO_FONTX: case GIO_FONTX: ret = do_fontx_ioctl(cmd, up, perm, &op); break; case PIO_FONTRESET: { if (!perm) return -EPERM; #ifdef BROKEN_GRAPHICS_PROGRAMS /* With BROKEN_GRAPHICS_PROGRAMS defined, the default font is not saved. */ ret = -ENOSYS; break; #else { op.op = KD_FONT_OP_SET_DEFAULT; op.data = NULL; ret = con_font_op(vc_cons[fg_console].d, &op); if (ret) break; console_lock(); con_set_default_unimap(vc_cons[fg_console].d); console_unlock(); break; } #endif } case KDFONTOP: { if (copy_from_user(&op, up, sizeof(op))) { ret = -EFAULT; break; } if (!perm && op.op != KD_FONT_OP_GET) return -EPERM; ret = con_font_op(vc, &op); if (ret) break; if (copy_to_user(up, &op, sizeof(op))) ret = -EFAULT; break; } case PIO_SCRNMAP: if (!perm) ret = -EPERM; else ret = con_set_trans_old(up); break; case GIO_SCRNMAP: ret = con_get_trans_old(up); break; case PIO_UNISCRNMAP: if (!perm) ret = -EPERM; else ret = con_set_trans_new(up); break; case GIO_UNISCRNMAP: ret = con_get_trans_new(up); break; case PIO_UNIMAPCLR: if (!perm) return -EPERM; con_clear_unimap(vc); break; case PIO_UNIMAP: case GIO_UNIMAP: ret = do_unimap_ioctl(cmd, up, perm, vc); break; case VT_LOCKSWITCH: if (!capable(CAP_SYS_TTY_CONFIG)) return -EPERM; vt_dont_switch = 1; break; case VT_UNLOCKSWITCH: if (!capable(CAP_SYS_TTY_CONFIG)) return -EPERM; vt_dont_switch = 0; break; case VT_GETHIFONTMASK: ret = put_user(vc->vc_hi_font_mask, (unsigned short __user *)arg); break; case VT_WAITEVENT: ret = vt_event_wait_ioctl((struct vt_event __user *)arg); break; default: ret = -ENOIOCTLCMD; } out: return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "A race condition in the Linux kernel before 5.5.7 involving VT_RESIZEX could lead to a NULL pointer dereference and general protection fault.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2020-36558"}} -{"idx": 409953, "input": "static void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp, struct sk_buff *skb) { tcp_verify_retransmit_hint(tp, skb); if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_LOST|TCPCB_SACKED_ACKED))) { tp->lost_out += tcp_skb_pcount(skb); TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506526, "input": "restore_prompt() { if (interactive) { #if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDITLINE) # if !defined(MISSING_RL_FORCED_UPDATE_DISPLAY) rl_forced_update_display(); # else rl_redisplay(); # endif #else fputs(PROMPT, stderr); fflush(stderr); #endif } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 360750, "input": "void rotate_coords_inverse(int x, int y, int *xo, int *yo, int dxi, int dyi) { int xi = x, yi = y; int Dx, Dy; if (dxi >= 0) { Dx = dxi; Dy = dyi; } else if (scaling) { Dx = scaled_x; Dy = scaled_y; } else { Dx = dpy_x; Dy = dpy_y; } if (! rotating_same) { int t = Dx; Dx = Dy; Dy = t; } if (rotating == ROTATE_NONE) { *xo = xi; *yo = yi; } else if (rotating == ROTATE_X) { *xo = Dx - xi - 1; *yo = yi; } else if (rotating == ROTATE_Y) { *xo = xi; *yo = Dy - yi - 1; } else if (rotating == ROTATE_XY) { *xo = Dx - xi - 1; *yo = Dy - yi - 1; } else if (rotating == ROTATE_90) { *xo = yi; *yo = Dx - xi - 1; } else if (rotating == ROTATE_90X) { *xo = yi; *yo = xi; } else if (rotating == ROTATE_90Y) { *xo = Dy - yi - 1; *yo = Dx - xi - 1; } else if (rotating == ROTATE_270) { *xo = Dy - yi - 1; *yo = xi; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 521653, "input": "bool is_pkcs7_sig_format(const void *data) { const struct efi_variable_authentication_2 *auth = data; uuid_t pkcs7_guid = EFI_CERT_TYPE_PKCS7_GUID; return !memcmp(&auth->auth_info.cert_type, &pkcs7_guid, 16); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417763, "input": "static struct Base *SFDParseBase(FILE *sfd) { struct Base *base = chunkalloc(sizeof(struct Base)); int i; getint(sfd,&base->baseline_cnt); if ( base->baseline_cnt!=0 ) { base->baseline_tags = malloc(base->baseline_cnt*sizeof(uint32)); for ( i=0; ibaseline_cnt; ++i ) base->baseline_tags[i] = gettag(sfd); } return( base ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246265, "input": "AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root) { core_request_config *conf = ap_get_core_module_config(r->request_config); conf->document_root = document_root; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 439512, "input": "bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) { struct bfad_itnim_data_s *itnim_data = rport->dd_data; struct bfad_itnim_s *itnim = itnim_data->itnim; struct bfad_s *bfad = itnim->im->bfad; uint16_t path_tov = bfa_fcpim_path_tov_get(&bfad->bfa); rport->dev_loss_tmo = timeout; if (timeout < path_tov) rport->dev_loss_tmo = path_tov + 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 299147, "input": "yaffsfs_jopen(TSK_FS_INFO * /*info*/, TSK_INUM_T /*inum*/) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_UNSUPFUNC); tsk_error_set_errstr(\"Journal support for YAFFS is not implemented\"); return 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393274, "input": "TEST_F(QueryPlannerTest, ContainedOrPredicateIsLeadingFieldForOneOrBranch) { addIndex(BSON(\"a\" << 1 << \"b\" << 1)); addIndex(BSON(\"c\" << 1)); runQuery(fromjson(\"{$and: [{a: 5}, {$or: [{b: 6}, {c: 7}]}]}\")); assertNumSolutions(3); assertSolutionExists( \"{fetch: {filter: {a: 5}, node: {or: {nodes: [\" \"{ixscan: {pattern: {a: 1, b: 1}, bounds: {a: [[5, 5, true, true]], b: [[6, 6, true, \" \"true]]}}},\" \"{ixscan: {pattern: {c: 1}, bounds: {c: [[7, 7, true, true]]}}}\" \"]}}}}\"); assertSolutionExists( \"{fetch: {filter: {$or: [{b: 6}, {c: 7}]}, node: \" \"{ixscan: {pattern: {a: 1, b: 1}, bounds: {a: [[5, 5, true, true]], b: [['MinKey', \" \"'MaxKey', true, true]]}}}\" \"}}\"); assertSolutionExists(\"{cscan: {dir: 1}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 338668, "input": "static bool __io_file_supports_async(struct file *file, int rw) { umode_t mode = file_inode(file)->i_mode; if (S_ISBLK(mode)) { if (IS_ENABLED(CONFIG_BLOCK) && io_bdev_nowait(I_BDEV(file->f_mapping->host))) return true; return false; } if (S_ISCHR(mode) || S_ISSOCK(mode)) return true; if (S_ISREG(mode)) { if (IS_ENABLED(CONFIG_BLOCK) && io_bdev_nowait(file->f_inode->i_sb->s_bdev) && file->f_op != &io_uring_fops) return true; return false; } /* any ->read/write should understand O_NONBLOCK */ if (file->f_flags & O_NONBLOCK) return true; if (!(file->f_mode & FMODE_NOWAIT)) return false; if (rw == READ) return file->f_op->read_iter != NULL; return file->f_op->write_iter != NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280035, "input": "static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) { int objects = 0; int pages = 0; int cpu; int len; for_each_online_cpu(cpu) { struct page *page; page = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu)); if (page) { pages += page->pages; objects += page->pobjects; } } len = sprintf(buf, \"%d(%d)\", objects, pages); #ifdef CONFIG_SMP for_each_online_cpu(cpu) { struct page *page; page = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu)); if (page && len < PAGE_SIZE - 20) len += sprintf(buf + len, \" C%d=%d(%d)\", cpu, page->pobjects, page->pages); } #endif return len + sprintf(buf + len, \"\\n\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 268940, "input": "R_API char *r_str_newf(const char *fmt, ...) { va_list ap, ap2; va_start (ap, fmt); if (!strchr (fmt, '%')) { va_end (ap); return strdup (fmt); } va_copy (ap2, ap); int ret = vsnprintf (NULL, 0, fmt, ap2); ret++; char *p = calloc (1, ret); if (p) { (void)vsnprintf (p, ret, fmt, ap); } va_end (ap2); va_end (ap); return p; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 394645, "input": "static TValue *debug_localname(lua_State *L, const lua_Debug *ar, const char **name, BCReg slot1) { uint32_t offset = (uint32_t)ar->i_ci & 0xffff; uint32_t size = (uint32_t)ar->i_ci >> 16; TValue *frame = tvref(L->stack) + offset; TValue *nextframe = size ? frame + size : NULL; GCfunc *fn = frame_func(frame); BCPos pc = debug_framepc(L, fn, nextframe); if (!nextframe) nextframe = L->top; if ((int)slot1 < 0) { /* Negative slot number is for varargs. */ if (pc != NO_BCPOS) { GCproto *pt = funcproto(fn); if ((pt->flags & PROTO_VARARG)) { slot1 = pt->numparams + (BCReg)(-(int)slot1); if (frame_isvarg(frame)) { /* Vararg frame has been set up? (pc!=0) */ nextframe = frame; frame = frame_prevd(frame); } if (frame + slot1 < nextframe) { *name = \"(*vararg)\"; return frame+slot1; } } } return NULL; } if (pc != NO_BCPOS && (*name = debug_varname(funcproto(fn), pc, slot1-1)) != NULL) ; else if (slot1 > 0 && frame + slot1 < nextframe) *name = \"(*temporary)\"; return frame+slot1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 95576, "input": "void BlobURLRequestJob::Seek(int64 offset) { for (item_index_ = 0; item_index_ < blob_data_->items().size() && offset >= item_length_list_[item_index_]; ++item_index_) { offset -= item_length_list_[item_index_]; } current_item_offset_ = offset; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 488928, "input": "append_frame_to_pkt( struct net_device *dev, unsigned framelen, u32 crc ) { struct net_local *nl = (struct net_local *) dev->priv; u8 *p; if( nl->inppos + framelen > ETHER_MAX_LEN ) return 0; if( !nl->rx_buf_p && !(nl->rx_buf_p = get_rx_buf( dev )) ) return 0; p = nl->rx_buf_p->data + nl->inppos; insb( dev->base_addr + DAT, p, framelen ); if( calc_crc32( crc, p, framelen ) != CRC32_REMAINDER ) return 0; nl->inppos += framelen - 4; if( --nl->wait_frameno == 0 ) /* last frame received */ indicate_pkt( dev ); return 1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 520873, "input": "Jsi_Value *jsi_ObjArrayLookup(Jsi_Interp *interp, Jsi_Obj *obj, const char *key) { if (!obj->arr || !key || !isdigit(*key)) return NULL; char *ep = NULL; int n = (int)strtol(key, &ep, 0); if (n<0 || n >= (int)obj->arrCnt) return NULL; Jsi_Value *v = obj->arr[n]; return v; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 430996, "input": "nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) { return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506418, "input": "static unsigned int append_string(buffer_t *buf, const char *str, bool ucase, bool unicode) { unsigned int length = 0; for ( ; *str != '\\0'; str++) { buffer_append_c(buf, ucase ? i_toupper(*str) : *str); if (unicode) { buffer_append_c(buf, 0); length++; } length++; } return length; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 379932, "input": "{ISCSI_DISC_PARENT_ISNS, \"isns\" }, }; char *iscsi_get_discovery_parent_name(int parent_type) { int i; char *state = \"Unknown!\"; for (i = 0; i < ARRAY_SIZE(iscsi_discovery_parent_names); i++) { if (iscsi_discovery_parent_names[i].value & parent_type) { state = iscsi_discovery_parent_names[i].name; break; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381491, "input": "static void v4l_print_frmivalenum(const void *arg, bool write_only) { const struct v4l2_frmivalenum *p = arg; pr_cont(\"index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u\", p->index, (p->pixel_format & 0xff), (p->pixel_format >> 8) & 0xff, (p->pixel_format >> 16) & 0xff, (p->pixel_format >> 24) & 0xff, p->width, p->height, p->type); switch (p->type) { case V4L2_FRMIVAL_TYPE_DISCRETE: pr_cont(\", fps=%d/%d\\n\", p->discrete.numerator, p->discrete.denominator); break; case V4L2_FRMIVAL_TYPE_STEPWISE: pr_cont(\", min=%d/%d, max=%d/%d, step=%d/%d\\n\", p->stepwise.min.numerator, p->stepwise.min.denominator, p->stepwise.max.numerator, p->stepwise.max.denominator, p->stepwise.step.numerator, p->stepwise.step.denominator); break; case V4L2_FRMIVAL_TYPE_CONTINUOUS: default: pr_cont(\"\\n\"); break; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 95565, "input": "bool BlobURLRequestJob::DispatchReadFile(const BlobData::Item& item) { if (stream_ != NULL) return ReadFile(item); base::FileUtilProxy::CreateOrOpen( file_thread_proxy_, item.file_path(), kFileOpenFlags, callback_factory_.NewCallback(&BlobURLRequestJob::DidOpen)); SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); return false; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 455376, "input": "int getGenericCommand(client *c) { robj *o; if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp])) == NULL) return C_OK; if (checkType(c,o,OBJ_STRING)) { return C_ERR; } addReplyBulk(c,o); return C_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 330262, "input": "static inline void HatTransform(const float *magick_restrict pixels, const size_t stride,const size_t extent,const size_t scale,float *kernel) { const float *magick_restrict p, *magick_restrict q, *magick_restrict r; ssize_t i; p=pixels; q=pixels+scale*stride; r=pixels+scale*stride; for (i=0; i < (ssize_t) scale; i++) { kernel[i]=0.25f*(*p+(*p)+(*q)+(*r)); p+=stride; q-=stride; r+=stride; } for ( ; i < (ssize_t) (extent-scale); i++) { kernel[i]=0.25f*(2.0f*(*p)+*(p-scale*stride)+*(p+scale*stride)); p+=stride; } q=p-scale*stride; r=pixels+stride*(extent-2); for ( ; i < (ssize_t) extent; i++) { kernel[i]=0.25f*(*p+(*p)+(*q)+(*r)); p+=stride; q+=stride; r-=stride; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432392, "input": "static int rdpmc_interception(struct vcpu_svm *svm) { int err; if (!nrips) return emulate_on_interception(svm); err = kvm_rdpmc(&svm->vcpu); return kvm_complete_insn_gp(&svm->vcpu, err); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409839, "input": "static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, u32 prior_snd_una) { struct tcp_sock *tp = tcp_sk(sk); const struct inet_connection_sock *icsk = inet_csk(sk); struct sk_buff *skb; u32 now = tcp_time_stamp; int fully_acked = 1; int flag = 0; u32 pkts_acked = 0; u32 reord = tp->packets_out; u32 prior_sacked = tp->sacked_out; s32 seq_rtt = -1; s32 ca_seq_rtt = -1; ktime_t last_ackt = net_invalid_timestamp(); while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { struct tcp_skb_cb *scb = TCP_SKB_CB(skb); u32 acked_pcount; u8 sacked = scb->sacked; /* Determine how many packets and what bytes were acked, tso and else */ if (after(scb->end_seq, tp->snd_una)) { if (tcp_skb_pcount(skb) == 1 || !after(tp->snd_una, scb->seq)) break; acked_pcount = tcp_tso_acked(sk, skb); if (!acked_pcount) break; fully_acked = 0; } else { acked_pcount = tcp_skb_pcount(skb); } if (sacked & TCPCB_RETRANS) { if (sacked & TCPCB_SACKED_RETRANS) tp->retrans_out -= acked_pcount; flag |= FLAG_RETRANS_DATA_ACKED; ca_seq_rtt = -1; seq_rtt = -1; if ((flag & FLAG_DATA_ACKED) || (acked_pcount > 1)) flag |= FLAG_NONHEAD_RETRANS_ACKED; } else { ca_seq_rtt = now - scb->when; last_ackt = skb->tstamp; if (seq_rtt < 0) { seq_rtt = ca_seq_rtt; } if (!(sacked & TCPCB_SACKED_ACKED)) reord = min(pkts_acked, reord); } if (sacked & TCPCB_SACKED_ACKED) tp->sacked_out -= acked_pcount; if (sacked & TCPCB_LOST) tp->lost_out -= acked_pcount; tp->packets_out -= acked_pcount; pkts_acked += acked_pcount; /* Initial outgoing SYN's get put onto the write_queue * just like anything else we transmit. It is not * true data, and if we misinform our callers that * this ACK acks real data, we will erroneously exit * connection startup slow start one packet too * quickly. This is severely frowned upon behavior. */ if (!(scb->tcp_flags & TCPHDR_SYN)) { flag |= FLAG_DATA_ACKED; } else { flag |= FLAG_SYN_ACKED; tp->retrans_stamp = 0; } if (!fully_acked) break; tcp_unlink_write_queue(skb, sk); sk_wmem_free_skb(sk, skb); tp->scoreboard_skb_hint = NULL; if (skb == tp->retransmit_skb_hint) tp->retransmit_skb_hint = NULL; if (skb == tp->lost_skb_hint) tp->lost_skb_hint = NULL; } if (likely(between(tp->snd_up, prior_snd_una, tp->snd_una))) tp->snd_up = tp->snd_una; if (skb && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) flag |= FLAG_SACK_RENEGING; if (flag & FLAG_ACKED) { const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; if (unlikely(icsk->icsk_mtup.probe_size && !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) { tcp_mtup_probe_success(sk); } tcp_ack_update_rtt(sk, flag, seq_rtt); tcp_rearm_rto(sk); if (tcp_is_reno(tp)) { tcp_remove_reno_sacks(sk, pkts_acked); } else { int delta; /* Non-retransmitted hole got filled? That's reordering */ if (reord < prior_fackets) tcp_update_reordering(sk, tp->fackets_out - reord, 0); delta = tcp_is_fack(tp) ? pkts_acked : prior_sacked - tp->sacked_out; tp->lost_cnt_hint -= min(tp->lost_cnt_hint, delta); } tp->fackets_out -= min(pkts_acked, tp->fackets_out); if (ca_ops->pkts_acked) { s32 rtt_us = -1; /* Is the ACK triggering packet unambiguous? */ if (!(flag & FLAG_RETRANS_DATA_ACKED)) { /* High resolution needed and available? */ if (ca_ops->flags & TCP_CONG_RTT_STAMP && !ktime_equal(last_ackt, net_invalid_timestamp())) rtt_us = ktime_us_delta(ktime_get_real(), last_ackt); else if (ca_seq_rtt >= 0) rtt_us = jiffies_to_usecs(ca_seq_rtt); } ca_ops->pkts_acked(sk, pkts_acked, rtt_us); } } #if FASTRETRANS_DEBUG > 0 WARN_ON((int)tp->sacked_out < 0); WARN_ON((int)tp->lost_out < 0); WARN_ON((int)tp->retrans_out < 0); if (!tp->packets_out && tcp_is_sack(tp)) { icsk = inet_csk(sk); if (tp->lost_out) { printk(KERN_DEBUG \"Leak l=%u %d\\n\", tp->lost_out, icsk->icsk_ca_state); tp->lost_out = 0; } if (tp->sacked_out) { printk(KERN_DEBUG \"Leak s=%u %d\\n\", tp->sacked_out, icsk->icsk_ca_state); tp->sacked_out = 0; } if (tp->retrans_out) { printk(KERN_DEBUG \"Leak r=%u %d\\n\", tp->retrans_out, icsk->icsk_ca_state); tp->retrans_out = 0; } } #endif return flag; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219307, "input": "Variant sockopen_impl(const HostURL &hosturl, Variant& errnum, Variant& errstr, double timeout, bool persistent, const Variant& context) { errnum = 0; errstr = empty_string(); std::string key; if (persistent) { key = hosturl.getHostURL() + \":\" + folly::to(hosturl.getPort()); // Check our persistent storage and determine if it's an SSLSocket // or just a regular socket. auto sockItr = s_sockets->find(key); if (sockItr != s_sockets->end()) { req::ptr sock; if (auto sslSocketData = std::dynamic_pointer_cast(sockItr->second)) { sock = req::make(sslSocketData); } else { sock = req::make(sockItr->second); } if (sock->getError() == 0 && sock->checkLiveness()) { return Variant(sock); } // socket had an error earlier, we need to close it, remove it from // persistent storage, and create a new one (in that order) sock->close(); s_sockets->erase(sockItr); } } if (timeout < 0) { timeout = RequestInfo::s_requestInfo.getNoCheck()-> m_reqInjectionData.getSocketDefaultTimeout(); } req::ptr streamctx; if (context.isResource()) { streamctx = cast(context.toResource()); } auto socket = new_socket_connect(hosturl, timeout, streamctx, errnum, errstr); if (!socket.isResource()) { return false; } if (persistent) { assertx(!key.empty()); (*s_sockets)[key] = cast(socket)->getData(); assertx((*s_sockets)[key]); } return socket; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230154, "input": "TEST_P(JSITest, HostObjectTest) { class ConstantHostObject : public HostObject { Value get(Runtime&, const PropNameID& sym) override { return 9000; } void set(Runtime&, const PropNameID&, const Value&) override {} }; Object cho = Object::createFromHostObject(rt, std::make_shared()); EXPECT_TRUE(function(\"function (obj) { return obj.someRandomProp == 9000; }\") .call(rt, cho) .getBool()); EXPECT_TRUE(cho.isHostObject(rt)); EXPECT_TRUE(cho.getHostObject(rt).get() != nullptr); struct SameRuntimeHostObject : HostObject { SameRuntimeHostObject(Runtime& rt) : rt_(rt){}; Value get(Runtime& rt, const PropNameID& sym) override { EXPECT_EQ(&rt, &rt_); return Value(); } void set(Runtime& rt, const PropNameID& name, const Value& value) override { EXPECT_EQ(&rt, &rt_); } std::vector getPropertyNames(Runtime& rt) override { EXPECT_EQ(&rt, &rt_); return {}; } Runtime& rt_; }; Object srho = Object::createFromHostObject( rt, std::make_shared(rt)); // Test get's Runtime is as expected function(\"function (obj) { return obj.isSame; }\").call(rt, srho); // ... and set function(\"function (obj) { obj['k'] = 'v'; }\").call(rt, srho); // ... and getPropertyNames function(\"function (obj) { for (k in obj) {} }\").call(rt, srho); class TwiceHostObject : public HostObject { Value get(Runtime& rt, const PropNameID& sym) override { return String::createFromUtf8(rt, sym.utf8(rt) + sym.utf8(rt)); } void set(Runtime&, const PropNameID&, const Value&) override {} }; Object tho = Object::createFromHostObject(rt, std::make_shared()); EXPECT_TRUE(function(\"function (obj) { return obj.abc == 'abcabc'; }\") .call(rt, tho) .getBool()); EXPECT_TRUE(function(\"function (obj) { return obj['def'] == 'defdef'; }\") .call(rt, tho) .getBool()); EXPECT_TRUE(function(\"function (obj) { return obj[12] === '1212'; }\") .call(rt, tho) .getBool()); EXPECT_TRUE(tho.isHostObject(rt)); EXPECT_TRUE( std::dynamic_pointer_cast(tho.getHostObject(rt)) == nullptr); EXPECT_TRUE(tho.getHostObject(rt).get() != nullptr); class PropNameIDHostObject : public HostObject { Value get(Runtime& rt, const PropNameID& sym) override { if (PropNameID::compare(rt, sym, PropNameID::forAscii(rt, \"undef\"))) { return Value::undefined(); } else { return PropNameID::compare( rt, sym, PropNameID::forAscii(rt, \"somesymbol\")); } } void set(Runtime&, const PropNameID&, const Value&) override {} }; Object sho = Object::createFromHostObject( rt, std::make_shared()); EXPECT_TRUE(sho.isHostObject(rt)); EXPECT_TRUE(function(\"function (obj) { return obj.undef; }\") .call(rt, sho) .isUndefined()); EXPECT_TRUE(function(\"function (obj) { return obj.somesymbol; }\") .call(rt, sho) .getBool()); EXPECT_FALSE(function(\"function (obj) { return obj.notsomuch; }\") .call(rt, sho) .getBool()); class BagHostObject : public HostObject { public: const std::string& getThing() { return bag_[\"thing\"]; } private: Value get(Runtime& rt, const PropNameID& sym) override { if (sym.utf8(rt) == \"thing\") { return String::createFromUtf8(rt, bag_[sym.utf8(rt)]); } return Value::undefined(); } void set(Runtime& rt, const PropNameID& sym, const Value& val) override { std::string key(sym.utf8(rt)); if (key == \"thing\") { bag_[key] = val.toString(rt).utf8(rt); } } std::unordered_map bag_; }; std::shared_ptr shbho = std::make_shared(); Object bho = Object::createFromHostObject(rt, shbho); EXPECT_TRUE(bho.isHostObject(rt)); EXPECT_TRUE(function(\"function (obj) { return obj.undef; }\") .call(rt, bho) .isUndefined()); EXPECT_EQ( function(\"function (obj) { obj.thing = 'hello'; return obj.thing; }\") .call(rt, bho) .toString(rt) .utf8(rt), \"hello\"); EXPECT_EQ(shbho->getThing(), \"hello\"); class ThrowingHostObject : public HostObject { Value get(Runtime& rt, const PropNameID& sym) override { throw std::runtime_error(\"Cannot get\"); } void set(Runtime& rt, const PropNameID& sym, const Value& val) override { throw std::runtime_error(\"Cannot set\"); } }; Object thro = Object::createFromHostObject(rt, std::make_shared()); EXPECT_TRUE(thro.isHostObject(rt)); std::string exc; try { function(\"function (obj) { return obj.thing; }\").call(rt, thro); } catch (const JSError& ex) { exc = ex.what(); } EXPECT_NE(exc.find(\"Cannot get\"), std::string::npos); exc = \"\"; try { function(\"function (obj) { obj.thing = 'hello'; }\").call(rt, thro); } catch (const JSError& ex) { exc = ex.what(); } EXPECT_NE(exc.find(\"Cannot set\"), std::string::npos); class NopHostObject : public HostObject {}; Object nopHo = Object::createFromHostObject(rt, std::make_shared()); EXPECT_TRUE(nopHo.isHostObject(rt)); EXPECT_TRUE(function(\"function (obj) { return obj.thing; }\") .call(rt, nopHo) .isUndefined()); std::string nopExc; try { function(\"function (obj) { obj.thing = 'pika'; }\").call(rt, nopHo); } catch (const JSError& ex) { nopExc = ex.what(); } EXPECT_NE(nopExc.find(\"TypeError: \"), std::string::npos); class HostObjectWithPropertyNames : public HostObject { std::vector getPropertyNames(Runtime& rt) override { return PropNameID::names( rt, \"a_prop\", \"1\", \"false\", \"a_prop\", \"3\", \"c_prop\"); } }; Object howpn = Object::createFromHostObject( rt, std::make_shared()); EXPECT_TRUE( function( \"function (o) { return Object.getOwnPropertyNames(o).length == 5 }\") .call(rt, howpn) .getBool()); auto hasOwnPropertyName = function( \"function (o, p) {\" \" return Object.getOwnPropertyNames(o).indexOf(p) >= 0\" \"}\"); EXPECT_TRUE( hasOwnPropertyName.call(rt, howpn, String::createFromAscii(rt, \"a_prop\")) .getBool()); EXPECT_TRUE( hasOwnPropertyName.call(rt, howpn, String::createFromAscii(rt, \"1\")) .getBool()); EXPECT_TRUE( hasOwnPropertyName.call(rt, howpn, String::createFromAscii(rt, \"false\")) .getBool()); EXPECT_TRUE( hasOwnPropertyName.call(rt, howpn, String::createFromAscii(rt, \"3\")) .getBool()); EXPECT_TRUE( hasOwnPropertyName.call(rt, howpn, String::createFromAscii(rt, \"c_prop\")) .getBool()); EXPECT_FALSE(hasOwnPropertyName .call(rt, howpn, String::createFromAscii(rt, \"not_existing\")) .getBool()); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 209045, "input": "int flb_gzip_compress(void *in_data, size_t in_len, void **out_data, size_t *out_len) { int flush; int status; int footer_start; uint8_t *pb; size_t out_size; void *out_buf; z_stream strm; mz_ulong crc; out_size = in_len + 32; out_buf = flb_malloc(out_size); if (!out_buf) { flb_errno(); flb_error(\"[gzip] could not allocate outgoing buffer\"); return -1; } /* Initialize streaming buffer context */ memset(&strm, '\\0', sizeof(strm)); strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = in_data; strm.avail_in = in_len; strm.total_out = 0; /* Deflate mode */ deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -Z_DEFAULT_WINDOW_BITS, 9, Z_DEFAULT_STRATEGY); /* * Miniz don't support GZip format directly, instead we will: * * - append manual GZip magic bytes * - deflate raw content * - append manual CRC32 data */ gzip_header(out_buf); /* Header offset */ pb = (uint8_t *) out_buf + FLB_GZIP_HEADER_OFFSET; flush = Z_NO_FLUSH; while (1) { strm.next_out = pb + strm.total_out; strm.avail_out = out_size - (pb - (uint8_t *) out_buf); if (strm.avail_in == 0) { flush = Z_FINISH; } status = deflate(&strm, flush); if (status == Z_STREAM_END) { break; } else if (status != Z_OK) { deflateEnd(&strm); return -1; } } if (deflateEnd(&strm) != Z_OK) { flb_free(out_buf); return -1; } *out_len = strm.total_out; /* Construct the gzip checksum (CRC32 footer) */ footer_start = FLB_GZIP_HEADER_OFFSET + *out_len; pb = (uint8_t *) out_buf + footer_start; crc = mz_crc32(MZ_CRC32_INIT, in_data, in_len); *pb++ = crc & 0xFF; *pb++ = (crc >> 8) & 0xFF; *pb++ = (crc >> 16) & 0xFF; *pb++ = (crc >> 24) & 0xFF; *pb++ = in_len & 0xFF; *pb++ = (in_len >> 8) & 0xFF; *pb++ = (in_len >> 16) & 0xFF; *pb++ = (in_len >> 24) & 0xFF; /* Set the real buffer size for the caller */ *out_len += FLB_GZIP_HEADER_OFFSET + 8; *out_data = out_buf; return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "flb_gzip_compress in flb_gzip.c in Fluent Bit before 1.6.4 has an out-of-bounds write because it does not use the correct calculation of the maximum gzip data-size expansion.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2020-35963"}} -{"idx": 394643, "input": "static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) { const uint8_t *p = proto_varinfo(pt); if (p) { BCPos lastpc = 0; for (;;) { const char *name = (const char *)p; uint32_t vn = *p++; BCPos startpc, endpc; if (vn < VARNAME__MAX) { if (vn == VARNAME_END) break; /* End of varinfo. */ } else { while (*p++) ; /* Skip over variable name string. */ } lastpc = startpc = lastpc + debug_read_uleb128(&p); if (startpc > pc) break; endpc = startpc + debug_read_uleb128(&p); if (pc < endpc && slot-- == 0) { if (vn < VARNAME__MAX) { #define VARNAMESTR(name, str) str \"\\0\" name = VARNAMEDEF(VARNAMESTR); #undef VARNAMESTR if (--vn) while (*name++ || --vn) ; } return name; } } } return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354446, "input": "void kvm_release_pfn(kvm_pfn_t pfn, bool dirty, struct gfn_to_pfn_cache *cache) { if (pfn == 0) return; if (cache) cache->pfn = cache->gfn = 0; if (dirty) kvm_release_pfn_dirty(pfn); else kvm_release_pfn_clean(pfn); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 394618, "input": "void lj_trace_reenableproto(GCproto *pt) { if ((pt->flags & PROTO_ILOOP)) { BCIns *bc = proto_bc(pt); BCPos i, sizebc = pt->sizebc;; pt->flags &= ~PROTO_ILOOP; if (bc_op(bc[0]) == BC_IFUNCF) setbc_op(&bc[0], BC_FUNCF); for (i = 1; i < sizebc; i++) { BCOp op = bc_op(bc[i]); if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP) setbc_op(&bc[i], (int)op+(int)BC_LOOP-(int)BC_ILOOP); } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 234473, "input": "ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req, bool strict_iomode) { pnfs_put_lseg(pgio->pg_lseg); pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), req_offset(req), req->wb_bytes, IOMODE_READ, strict_iomode, GFP_KERNEL); if (IS_ERR(pgio->pg_lseg)) { pgio->pg_error = PTR_ERR(pgio->pg_lseg); pgio->pg_lseg = NULL; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416780, "input": "static void cil_reset_constrain(struct cil_constrain *con) { cil_reset_classperms_list(con->classperms); cil_list_destroy(&con->datum_expr, CIL_FALSE); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 505198, "input": "int auth_server_connection_connect(struct auth_server_connection *conn) { const char *handshake; int fd; i_assert(!conn->connected); i_assert(conn->fd == -1); conn->last_connect = ioloop_time; timeout_remove(&conn->to); /* max. 1 second wait here. */ fd = net_connect_unix_with_retries(conn->client->auth_socket_path, 1000); if (fd == -1) { if (errno == EACCES) { i_error(\"auth: %s\", eacces_error_get(\"connect\", conn->client->auth_socket_path)); } else { i_error(\"auth: connect(%s) failed: %m\", conn->client->auth_socket_path); } return -1; } conn->fd = fd; conn->io = io_add(fd, IO_READ, auth_server_connection_input, conn); conn->input = i_stream_create_fd(fd, AUTH_SERVER_CONN_MAX_LINE_LENGTH); conn->output = o_stream_create_fd(fd, (size_t)-1); conn->connected = TRUE; handshake = t_strdup_printf(\"VERSION\\t%u\\t%u\\nCPID\\t%u\\n\", AUTH_CLIENT_PROTOCOL_MAJOR_VERSION, AUTH_CLIENT_PROTOCOL_MINOR_VERSION, conn->client->client_pid); if (o_stream_send_str(conn->output, handshake) < 0) { i_warning(\"Error sending handshake to auth server: %s\", o_stream_get_error(conn->output)); auth_server_connection_disconnect(conn, o_stream_get_error(conn->output)); return -1; } conn->to = timeout_add(AUTH_HANDSHAKE_TIMEOUT, auth_client_handshake_timeout, conn); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 462781, "input": "static void preinit_thread (lua_State *L, global_State *g) { G(L) = g; L->stack = NULL; L->ci = NULL; L->nci = 0; L->stacksize = 0; L->twups = L; /* thread has no upvalues */ L->errorJmp = NULL; L->hook = NULL; L->hookmask = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; L->status = LUA_OK; L->errfunc = 0; L->oldpc = 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 398065, "input": "static int sctp_disconnect(struct sock *sk, int flags) { return -EOPNOTSUPP; /* STUB */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281472, "input": "static void virtual_engine_initial_hint(struct virtual_engine *ve) { int swp; /* * Pick a random sibling on starting to help spread the load around. * * New contexts are typically created with exactly the same order * of siblings, and often started in batches. Due to the way we iterate * the array of sibling when submitting requests, sibling[0] is * prioritised for dequeuing. If we make sure that sibling[0] is fairly * randomised across the system, we also help spread the load by the * first engine we inspect being different each time. * * NB This does not force us to execute on this engine, it will just * typically be the first we inspect for submission. */ swp = prandom_u32_max(ve->num_siblings); if (!swp) return; swap(ve->siblings[swp], ve->siblings[0]); if (!intel_engine_has_relative_mmio(ve->siblings[0])) virtual_update_register_offsets(ve->context.lrc_reg_state, ve->siblings[0]); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 394167, "input": "ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) { unsigned int flags = cb->data ? NLM_F_DUMP_FILTERED : 0; struct net *net = sock_net(skb->sk); struct nf_conn *ct, *last; struct nf_conntrack_tuple_hash *h; struct hlist_nulls_node *n; struct nf_conn *nf_ct_evict[8]; int res, i; spinlock_t *lockp; last = (struct nf_conn *)cb->args[1]; i = 0; local_bh_disable(); for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) { restart: while (i) { i--; if (nf_ct_should_gc(nf_ct_evict[i])) nf_ct_kill(nf_ct_evict[i]); nf_ct_put(nf_ct_evict[i]); } lockp = &nf_conntrack_locks[cb->args[0] % CONNTRACK_LOCKS]; nf_conntrack_lock(lockp); if (cb->args[0] >= nf_conntrack_htable_size) { spin_unlock(lockp); goto out; } hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[cb->args[0]], hnnode) { if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) continue; ct = nf_ct_tuplehash_to_ctrack(h); if (nf_ct_is_expired(ct)) { if (i < ARRAY_SIZE(nf_ct_evict) && atomic_inc_not_zero(&ct->ct_general.use)) nf_ct_evict[i++] = ct; continue; } if (!net_eq(net, nf_ct_net(ct))) continue; if (cb->args[1]) { if (ct != last) continue; cb->args[1] = 0; } if (!ctnetlink_filter_match(ct, cb->data)) continue; res = ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NFNL_MSG_TYPE(cb->nlh->nlmsg_type), ct, true, flags); if (res < 0) { nf_conntrack_get(&ct->ct_general); cb->args[1] = (unsigned long)ct; spin_unlock(lockp); goto out; } } spin_unlock(lockp); if (cb->args[1]) { cb->args[1] = 0; goto restart; } } out: local_bh_enable(); if (last) { /* nf ct hash resize happened, now clear the leftover. */ if ((struct nf_conn *)cb->args[1] == last) cb->args[1] = 0; nf_ct_put(last); } while (i) { i--; if (nf_ct_should_gc(nf_ct_evict[i])) nf_ct_kill(nf_ct_evict[i]); nf_ct_put(nf_ct_evict[i]); } return skb->len; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219468, "input": "TypedValue HHVM_FUNCTION(strpbrk, const String& haystack, const String& char_list) { return tvReturn(strpbrk_impl(haystack, char_list)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508995, "input": "bool has_no_value() const { return state == NO_VALUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 212388, "input": "ec_p_init (mpi_ec_t ctx, enum gcry_mpi_ec_models model, enum ecc_dialects dialect, int flags, gcry_mpi_t p, gcry_mpi_t a, gcry_mpi_t b) { int i; static int use_barrett; if (!use_barrett) { if (getenv (\"GCRYPT_BARRETT\")) use_barrett = 1; else use_barrett = -1; } /* Fixme: Do we want to check some constraints? e.g. a < p */ ctx->model = model; ctx->dialect = dialect; ctx->flags = flags; if (dialect == ECC_DIALECT_ED25519) ctx->nbits = 256; else ctx->nbits = mpi_get_nbits (p); ctx->p = mpi_copy (p); ctx->a = mpi_copy (a); ctx->b = mpi_copy (b); ctx->t.p_barrett = use_barrett > 0? _gcry_mpi_barrett_init (ctx->p, 0):NULL; _gcry_mpi_ec_get_reset (ctx); /* Allocate scratch variables. */ for (i=0; i< DIM(ctx->t.scratch); i++) ctx->t.scratch[i] = mpi_alloc_like (ctx->p); /* Prepare for fast reduction. */ /* FIXME: need a test for NIST values. However it does not gain us any real advantage, for 384 bits it is actually slower than using mpi_mulm. */ /* ctx->nist_nbits = mpi_get_nbits (ctx->p); */ /* if (ctx->nist_nbits == 192) */ /* { */ /* for (i=0; i < 4; i++) */ /* ctx->s[i] = mpi_new (192); */ /* ctx->c = mpi_new (192*2); */ /* } */ /* else if (ctx->nist_nbits == 384) */ /* { */ /* for (i=0; i < 10; i++) */ /* ctx->s[i] = mpi_new (384); */ /* ctx->c = mpi_new (384*2); */ /* } */ }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "Libgcrypt before 1.8.1 does not properly consider Curve25519 side-channel attacks, which makes it easier for attackers to discover a secret key, related to cipher/ecc.c and mpi/ec.c.", "severity_level": "Medium", "cwe": "CWE-200", "cve": "CVE-2017-0379"}} -{"idx": 269138, "input": "inline void SetActivationParams(float min, float max, P* params) { params->float_activation_min = min; params->float_activation_max = max; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 497476, "input": "translate_axes (ClutterInputDevice *device, gdouble x, gdouble y, ClutterStageX11 *stage_x11, XIValuatorState *valuators) { guint n_axes = clutter_input_device_get_n_axes (device); guint i; gdouble *retval; double *values; retval = g_new0 (gdouble, n_axes); values = valuators->values; for (i = 0; i < valuators->mask_len * 8; i++) { ClutterInputAxis axis; gdouble val; if (!XIMaskIsSet (valuators->mask, i)) continue; axis = clutter_input_device_get_axis (device, i); val = *values++; switch (axis) { case CLUTTER_INPUT_AXIS_X: retval[i] = x; break; case CLUTTER_INPUT_AXIS_Y: retval[i] = y; break; default: _clutter_input_device_translate_axis (device, i, val, &retval[i]); break; } } return retval; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 206616, "input": "start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo) { gif_source_ptr source = (gif_source_ptr)sinfo; U_CHAR hdrbuf[10]; /* workspace for reading control blocks */ unsigned int width, height; /* image dimensions */ int colormaplen, aspectRatio; int c; /* Read and verify GIF Header */ if (!ReadOK(source->pub.input_file, hdrbuf, 6)) ERREXIT(cinfo, JERR_GIF_NOT); if (hdrbuf[0] != 'G' || hdrbuf[1] != 'I' || hdrbuf[2] != 'F') ERREXIT(cinfo, JERR_GIF_NOT); /* Check for expected version numbers. * If unknown version, give warning and try to process anyway; * this is per recommendation in GIF89a standard. */ if ((hdrbuf[3] != '8' || hdrbuf[4] != '7' || hdrbuf[5] != 'a') && (hdrbuf[3] != '8' || hdrbuf[4] != '9' || hdrbuf[5] != 'a')) TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]); /* Read and decipher Logical Screen Descriptor */ if (!ReadOK(source->pub.input_file, hdrbuf, 7)) ERREXIT(cinfo, JERR_INPUT_EOF); width = LM_to_uint(hdrbuf, 0); height = LM_to_uint(hdrbuf, 2); /* we ignore the color resolution, sort flag, and background color index */ aspectRatio = UCH(hdrbuf[6]); if (aspectRatio != 0 && aspectRatio != 49) TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE); /* Allocate space to store the colormap */ source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)MAXCOLORMAPSIZE, (JDIMENSION)NUMCOLORS); colormaplen = 0; /* indicate initialization */ /* Read global colormap if header indicates it is present */ if (BitSet(hdrbuf[4], COLORMAPFLAG)) { colormaplen = 2 << (hdrbuf[4] & 0x07); ReadColorMap(source, colormaplen, source->colormap); } /* Scan until we reach start of desired image. * We don't currently support skipping images, but could add it easily. */ for (;;) { c = ReadByte(source); if (c == ';') /* GIF terminator?? */ ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND); if (c == '!') { /* Extension */ DoExtension(source); continue; } if (c != ',') { /* Not an image separator? */ WARNMS1(cinfo, JWRN_GIF_CHAR, c); continue; } /* Read and decipher Local Image Descriptor */ if (!ReadOK(source->pub.input_file, hdrbuf, 9)) ERREXIT(cinfo, JERR_INPUT_EOF); /* we ignore top/left position info, also sort flag */ width = LM_to_uint(hdrbuf, 4); height = LM_to_uint(hdrbuf, 6); source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0); /* Read local colormap if header indicates it is present */ /* Note: if we wanted to support skipping images, */ /* we'd need to skip rather than read colormap for ignored images */ if (BitSet(hdrbuf[8], COLORMAPFLAG)) { colormaplen = 2 << (hdrbuf[8] & 0x07); ReadColorMap(source, colormaplen, source->colormap); } source->input_code_size = ReadByte(source); /* get min-code-size byte */ if (source->input_code_size < 2 || source->input_code_size > 8) ERREXIT1(cinfo, JERR_GIF_CODESIZE, source->input_code_size); /* Reached desired image, so break out of loop */ /* If we wanted to skip this image, */ /* we'd call SkipDataBlocks and then continue the loop */ break; } /* Prepare to read selected image: first initialize LZW decompressor */ source->symbol_head = (UINT16 *) (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * sizeof(UINT16)); source->symbol_tail = (UINT8 *) (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * sizeof(UINT8)); source->symbol_stack = (UINT8 *) (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * sizeof(UINT8)); InitLZWCode(source); /* * If image is interlaced, we read it into a full-size sample array, * decompressing as we go; then get_interlaced_row selects rows from the * sample array in the proper order. */ if (source->is_interlaced) { /* We request the virtual array now, but can't access it until virtual * arrays have been allocated. Hence, the actual work of reading the * image is postponed until the first call to get_pixel_rows. */ source->interlaced_image = (*cinfo->mem->request_virt_sarray) ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, (JDIMENSION)width, (JDIMENSION)height, (JDIMENSION)1); if (cinfo->progress != NULL) { cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress; progress->total_extra_passes++; /* count file input as separate pass */ } source->pub.get_pixel_rows = load_interlaced_image; } else { source->pub.get_pixel_rows = get_pixel_rows; } /* Create compressor input buffer. */ source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)width * NUMCOLORS, (JDIMENSION)1); source->pub.buffer_height = 1; /* Pad colormap for safety. */ for (c = colormaplen; c < source->clear_code; c++) { source->colormap[CM_RED][c] = source->colormap[CM_GREEN][c] = source->colormap[CM_BLUE][c] = CENTERJSAMPLE; } /* Return info about the image. */ cinfo->in_color_space = JCS_RGB; cinfo->input_components = NUMCOLORS; cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ cinfo->image_width = width; cinfo->image_height = height; TRACEMS3(cinfo, 1, JTRC_GIF, width, height, colormaplen); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Divide By Zero"], "explanation": "Libjpeg-turbo versions 2.0.91 and 2.0.90 is vulnerable to a denial of service vulnerability caused by a divide by zero when processing a crafted GIF image.", "severity_level": "NoInfo", "cwe": "CWE-369", "cve": "CVE-2021-20205"}} -{"idx": 337027, "input": "rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag) { rb_encoding *enc; VALUE w; long width, len, flen = 1, fclen = 1; VALUE res; char *p; const char *f = \" \"; long n, size, llen, rlen, llen2 = 0, rlen2 = 0; volatile VALUE pad; int singlebyte = 1, cr; rb_scan_args(argc, argv, \"11\", &w, &pad); enc = STR_ENC_GET(str); width = NUM2LONG(w); if (argc == 2) { StringValue(pad); enc = rb_enc_check(str, pad); f = RSTRING_PTR(pad); flen = RSTRING_LEN(pad); fclen = str_strlen(pad, enc); singlebyte = single_byte_optimizable(pad); if (flen == 0 || fclen == 0) { rb_raise(rb_eArgError, \"zero width padding\"); } } len = str_strlen(str, enc); if (width < 0 || len >= width) return rb_str_dup(str); n = width - len; llen = (jflag == 'l') ? 0 : ((jflag == 'r') ? n : n/2); rlen = n - llen; cr = ENC_CODERANGE(str); if (flen > 1) { llen2 = str_offset(f, f + flen, llen % fclen, enc, singlebyte); rlen2 = str_offset(f, f + flen, rlen % fclen, enc, singlebyte); } size = RSTRING_LEN(str); if ((len = llen / fclen + rlen / fclen) >= LONG_MAX / flen || (len *= flen) >= LONG_MAX - llen2 - rlen2 || (len += llen2 + rlen2) >= LONG_MAX - size) { rb_raise(rb_eArgError, \"argument too big\"); } len += size; res = rb_str_new5(str, 0, len); p = RSTRING_PTR(res); if (flen <= 1) { memset(p, *f, llen); p += llen; } else { while (llen > fclen) { memcpy(p,f,flen); p += flen; llen -= fclen; } if (llen > 0) { memcpy(p, f, llen2); p += llen2; } } memcpy(p, RSTRING_PTR(str), size); p += size; if (flen <= 1) { memset(p, *f, rlen); p += rlen; } else { while (rlen > fclen) { memcpy(p,f,flen); p += flen; rlen -= fclen; } if (rlen > 0) { memcpy(p, f, rlen2); p += rlen2; } } *p = '\\0'; STR_SET_LEN(res, p-RSTRING_PTR(res)); OBJ_INFECT(res, str); if (!NIL_P(pad)) OBJ_INFECT(res, pad); rb_enc_associate(res, enc); if (argc == 2) cr = ENC_CODERANGE_AND(cr, ENC_CODERANGE(pad)); if (cr != ENC_CODERANGE_BROKEN) ENC_CODERANGE_SET(res, cr); return res; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 299177, "input": "xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) { const char *errmsg; if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; switch (error) { case XML_ERR_INVALID_HEX_CHARREF: errmsg = \"CharRef: invalid hexadecimal value\"; break; case XML_ERR_INVALID_DEC_CHARREF: errmsg = \"CharRef: invalid decimal value\"; break; case XML_ERR_INVALID_CHARREF: errmsg = \"CharRef: invalid value\"; break; case XML_ERR_INTERNAL_ERROR: errmsg = \"internal error\"; break; case XML_ERR_PEREF_AT_EOF: errmsg = \"PEReference at end of document\"; break; case XML_ERR_PEREF_IN_PROLOG: errmsg = \"PEReference in prolog\"; break; case XML_ERR_PEREF_IN_EPILOG: errmsg = \"PEReference in epilog\"; break; case XML_ERR_PEREF_NO_NAME: errmsg = \"PEReference: no name\"; break; case XML_ERR_PEREF_SEMICOL_MISSING: errmsg = \"PEReference: expecting ';'\"; break; case XML_ERR_ENTITY_LOOP: errmsg = \"Detected an entity reference loop\"; break; case XML_ERR_ENTITY_NOT_STARTED: errmsg = \"EntityValue: \\\" or ' expected\"; break; case XML_ERR_ENTITY_PE_INTERNAL: errmsg = \"PEReferences forbidden in internal subset\"; break; case XML_ERR_ENTITY_NOT_FINISHED: errmsg = \"EntityValue: \\\" or ' expected\"; break; case XML_ERR_ATTRIBUTE_NOT_STARTED: errmsg = \"AttValue: \\\" or ' expected\"; break; case XML_ERR_LT_IN_ATTRIBUTE: errmsg = \"Unescaped '<' not allowed in attributes values\"; break; case XML_ERR_LITERAL_NOT_STARTED: errmsg = \"SystemLiteral \\\" or ' expected\"; break; case XML_ERR_LITERAL_NOT_FINISHED: errmsg = \"Unfinished System or Public ID \\\" or ' expected\"; break; case XML_ERR_MISPLACED_CDATA_END: errmsg = \"Sequence ']]>' not allowed in content\"; break; case XML_ERR_URI_REQUIRED: errmsg = \"SYSTEM or PUBLIC, the URI is missing\"; break; case XML_ERR_PUBID_REQUIRED: errmsg = \"PUBLIC, the Public Identifier is missing\"; break; case XML_ERR_HYPHEN_IN_COMMENT: errmsg = \"Comment must not contain '--' (double-hyphen)\"; break; case XML_ERR_PI_NOT_STARTED: errmsg = \"xmlParsePI : no target name\"; break; case XML_ERR_RESERVED_XML_NAME: errmsg = \"Invalid PI name\"; break; case XML_ERR_NOTATION_NOT_STARTED: errmsg = \"NOTATION: Name expected here\"; break; case XML_ERR_NOTATION_NOT_FINISHED: errmsg = \"'>' required to close NOTATION declaration\"; break; case XML_ERR_VALUE_REQUIRED: errmsg = \"Entity value required\"; break; case XML_ERR_URI_FRAGMENT: errmsg = \"Fragment not allowed\"; break; case XML_ERR_ATTLIST_NOT_STARTED: errmsg = \"'(' required to start ATTLIST enumeration\"; break; case XML_ERR_NMTOKEN_REQUIRED: errmsg = \"NmToken expected in ATTLIST enumeration\"; break; case XML_ERR_ATTLIST_NOT_FINISHED: errmsg = \"')' required to finish ATTLIST enumeration\"; break; case XML_ERR_MIXED_NOT_STARTED: errmsg = \"MixedContentDecl : '|' or ')*' expected\"; break; case XML_ERR_PCDATA_REQUIRED: errmsg = \"MixedContentDecl : '#PCDATA' expected\"; break; case XML_ERR_ELEMCONTENT_NOT_STARTED: errmsg = \"ContentDecl : Name or '(' expected\"; break; case XML_ERR_ELEMCONTENT_NOT_FINISHED: errmsg = \"ContentDecl : ',' '|' or ')' expected\"; break; case XML_ERR_PEREF_IN_INT_SUBSET: errmsg = \"PEReference: forbidden within markup decl in internal subset\"; break; case XML_ERR_GT_REQUIRED: errmsg = \"expected '>'\"; break; case XML_ERR_CONDSEC_INVALID: errmsg = \"XML conditional section '[' expected\"; break; case XML_ERR_EXT_SUBSET_NOT_FINISHED: errmsg = \"Content error in the external subset\"; break; case XML_ERR_CONDSEC_INVALID_KEYWORD: errmsg = \"conditional section INCLUDE or IGNORE keyword expected\"; break; case XML_ERR_CONDSEC_NOT_FINISHED: errmsg = \"XML conditional section not closed\"; break; case XML_ERR_XMLDECL_NOT_STARTED: errmsg = \"Text declaration '' expected\"; break; case XML_ERR_EXT_ENTITY_STANDALONE: errmsg = \"external parsed entities cannot be standalone\"; break; case XML_ERR_ENTITYREF_SEMICOL_MISSING: errmsg = \"EntityRef: expecting ';'\"; break; case XML_ERR_DOCTYPE_NOT_FINISHED: errmsg = \"DOCTYPE improperly terminated\"; break; case XML_ERR_LTSLASH_REQUIRED: errmsg = \"EndTag: 'errNo = error; if (info == NULL) { __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, \"%s\\n\", errmsg); } else { __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, \"%s: %s\\n\", errmsg, info); } if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 373772, "input": "static inline qDeqID getNextDeqID(qqueue_t *pQueue) { ISOBJ_TYPE_assert(pQueue, qqueue); return pQueue->deqIDAdd++; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 318153, "input": "static inline unsigned int alignDiff(rpm_tagtype_t type, unsigned int alignsize) { int typesize = typeSizes[type]; if (typesize > 1) { unsigned int diff = typesize - (alignsize % typesize); if (diff != typesize) return diff; } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 265768, "input": "CWebAuth::CWebAuth(CWebSock* pWebSock, const CString& sUsername, const CString& sPassword, bool bBasic) : CAuthBase(sUsername, sPassword, pWebSock), m_pWebSock(pWebSock), m_bBasic(bBasic) {}", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 211908, "input": "int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ssize_t bytes) { TIFFSTATE *clientstate = (TIFFSTATE *)state->context; char *filename = \"tempfile.tif\"; char *mode = \"r\"; TIFF *tiff; /* buffer is the encoded file, bytes is the length of the encoded file */ /* it all ends up in state->buffer, which is a uint8* from Imaging.h */ TRACE((\"in decoder: bytes %d\\n\", bytes)); TRACE((\"State: count %d, state %d, x %d, y %d, ystep %d\\n\", state->count, state->state, state->x, state->y, state->ystep)); TRACE((\"State: xsize %d, ysize %d, xoff %d, yoff %d \\n\", state->xsize, state->ysize, state->xoff, state->yoff)); TRACE((\"State: bits %d, bytes %d \\n\", state->bits, state->bytes)); TRACE((\"Buffer: %p: %c%c%c%c\\n\", buffer, (char)buffer[0], (char)buffer[1],(char)buffer[2], (char)buffer[3])); TRACE((\"State->Buffer: %c%c%c%c\\n\", (char)state->buffer[0], (char)state->buffer[1],(char)state->buffer[2], (char)state->buffer[3])); TRACE((\"Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \\n\", im->mode, im->type, im->bands, im->xsize, im->ysize)); TRACE((\"Image: image8 %p, image32 %p, image %p, block %p \\n\", im->image8, im->image32, im->image, im->block)); TRACE((\"Image: pixelsize: %d, linesize %d \\n\", im->pixelsize, im->linesize)); dump_state(clientstate); clientstate->size = bytes; clientstate->eof = clientstate->size; clientstate->loc = 0; clientstate->data = (tdata_t)buffer; clientstate->flrealloc = 0; dump_state(clientstate); TIFFSetWarningHandler(NULL); TIFFSetWarningHandlerExt(NULL); if (clientstate->fp) { TRACE((\"Opening using fd: %d\\n\",clientstate->fp)); lseek(clientstate->fp,0,SEEK_SET); // Sometimes, I get it set to the end. tiff = TIFFFdOpen(clientstate->fp, filename, mode); } else { TRACE((\"Opening from string\\n\")); tiff = TIFFClientOpen(filename, mode, (thandle_t) clientstate, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); } if (!tiff){ TRACE((\"Error, didn't get the tiff\\n\")); state->errcode = IMAGING_CODEC_BROKEN; return -1; } if (clientstate->ifd){ int rv; uint32 ifdoffset = clientstate->ifd; TRACE((\"reading tiff ifd %u\\n\", ifdoffset)); rv = TIFFSetSubDirectory(tiff, ifdoffset); if (!rv){ TRACE((\"error in TIFFSetSubDirectory\")); return -1; } } if (TIFFIsTiled(tiff)) { UINT32 x, y, tile_y, row_byte_size; UINT32 tile_width, tile_length, current_tile_width; UINT8 *new_data; TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_width); TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_length); // We could use TIFFTileSize, but for YCbCr data it returns subsampled data size row_byte_size = (tile_width * state->bits + 7) / 8; state->bytes = row_byte_size * tile_length; /* overflow check for malloc */ if (state->bytes > INT_MAX - 1) { state->errcode = IMAGING_CODEC_MEMORY; TIFFClose(tiff); return -1; } /* realloc to fit whole tile */ new_data = realloc (state->buffer, state->bytes); if (!new_data) { state->errcode = IMAGING_CODEC_MEMORY; TIFFClose(tiff); return -1; } state->buffer = new_data; TRACE((\"TIFFTileSize: %d\\n\", state->bytes)); for (y = state->yoff; y < state->ysize; y += tile_length) { for (x = state->xoff; x < state->xsize; x += tile_width) { if (ReadTile(tiff, x, y, (UINT32*) state->buffer) == -1) { TRACE((\"Decode Error, Tile at %dx%d\\n\", x, y)); state->errcode = IMAGING_CODEC_BROKEN; TIFFClose(tiff); return -1; } TRACE((\"Read tile at %dx%d; \\n\\n\", x, y)); current_tile_width = min(tile_width, state->xsize - x); // iterate over each line in the tile and stuff data into image for (tile_y = 0; tile_y < min(tile_length, state->ysize - y); tile_y++) { TRACE((\"Writing tile data at %dx%d using tile_width: %d; \\n\", tile_y + y, x, current_tile_width)); // UINT8 * bbb = state->buffer + tile_y * row_byte_size; // TRACE((\"chars: %x%x%x%x\\n\", ((UINT8 *)bbb)[0], ((UINT8 *)bbb)[1], ((UINT8 *)bbb)[2], ((UINT8 *)bbb)[3])); state->shuffle((UINT8*) im->image[tile_y + y] + x * im->pixelsize, state->buffer + tile_y * row_byte_size, current_tile_width ); } } } } else { UINT32 strip_row, row_byte_size; UINT8 *new_data; UINT32 rows_per_strip; int ret; ret = TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip); if (ret != 1) { rows_per_strip = state->ysize; } TRACE((\"RowsPerStrip: %u \\n\", rows_per_strip)); // We could use TIFFStripSize, but for YCbCr data it returns subsampled data size row_byte_size = (state->xsize * state->bits + 7) / 8; state->bytes = rows_per_strip * row_byte_size; TRACE((\"StripSize: %d \\n\", state->bytes)); /* realloc to fit whole strip */ new_data = realloc (state->buffer, state->bytes); if (!new_data) { state->errcode = IMAGING_CODEC_MEMORY; TIFFClose(tiff); return -1; } state->buffer = new_data; for (; state->y < state->ysize; state->y += rows_per_strip) { if (ReadStrip(tiff, state->y, (UINT32 *)state->buffer) == -1) { TRACE((\"Decode Error, strip %d\\n\", TIFFComputeStrip(tiff, state->y, 0))); state->errcode = IMAGING_CODEC_BROKEN; TIFFClose(tiff); return -1; } TRACE((\"Decoded strip for row %d \\n\", state->y)); // iterate over each row in the strip and stuff data into image for (strip_row = 0; strip_row < min(rows_per_strip, state->ysize - state->y); strip_row++) { TRACE((\"Writing data into line %d ; \\n\", state->y + strip_row)); // UINT8 * bbb = state->buffer + strip_row * (state->bytes / rows_per_strip); // TRACE((\"chars: %x %x %x %x\\n\", ((UINT8 *)bbb)[0], ((UINT8 *)bbb)[1], ((UINT8 *)bbb)[2], ((UINT8 *)bbb)[3])); state->shuffle((UINT8*) im->image[state->y + state->yoff + strip_row] + state->xoff * im->pixelsize, state->buffer + strip_row * row_byte_size, state->xsize); } } } TIFFClose(tiff); TRACE((\"Done Decoding, Returning \\n\")); // Returning -1 here to force ImageFile.load to break, rather than // even think about looping back around. return -1; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "libImaging/TiffDecode.c in Pillow before 6.2.2 has a TIFF decoding integer overflow, related to realloc.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2020-5310"}} -{"idx": 263101, "input": "iasecc_keyset_change(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left) { struct sc_context *ctx = card->ctx; struct iasecc_sdo_update update; struct iasecc_sdo sdo; unsigned scb; int rv; LOG_FUNC_CALLED(ctx); sc_log(ctx, \"Change keyset(ref:%i,lengths:%i)\", data->pin_reference, data->pin2.len); if (!data->pin2.data || data->pin2.len < 32) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, \"Needs at least 32 bytes for a new keyset value\"); memset(&sdo, 0, sizeof(sdo)); sdo.sdo_class = IASECC_SDO_CLASS_KEYSET; sdo.sdo_ref = data->pin_reference; rv = iasecc_sdo_get_data(card, &sdo); LOG_TEST_RET(ctx, rv, \"Cannot get keyset data\"); if (sdo.docp.acls_contact.size == 0) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, \"Bewildered ... there are no ACLs\"); scb = sdo.docp.scbs[IASECC_ACLS_KEYSET_PUT_DATA]; iasecc_sdo_free_fields(card, &sdo); sc_log(ctx, \"SCB:0x%X\", scb); if (!(scb & IASECC_SCB_METHOD_SM)) LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, \"Other then protected by SM, the keyset change is not supported\"); memset(&update, 0, sizeof(update)); update.magic = SC_CARDCTL_IASECC_SDO_MAGIC_PUT_DATA; update.sdo_class = sdo.sdo_class; update.sdo_ref = sdo.sdo_ref; update.fields[0].parent_tag = IASECC_SDO_KEYSET_TAG; update.fields[0].tag = IASECC_SDO_KEYSET_TAG_MAC; /* FIXME is it safe to modify the const value here? */ update.fields[0].value = (unsigned char *) data->pin2.data; update.fields[0].size = 16; update.fields[1].parent_tag = IASECC_SDO_KEYSET_TAG; update.fields[1].tag = IASECC_SDO_KEYSET_TAG_ENC; /* FIXME is it safe to modify the const value here? */ update.fields[1].value = (unsigned char *) data->pin2.data + 16; update.fields[1].size = 16; rv = iasecc_sm_sdo_update(card, (scb & IASECC_SCB_METHOD_MASK_REF), &update); LOG_FUNC_RETURN(ctx, rv); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 229856, "input": "packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, unsigned long datalen, packet_queue_listener_state_t *listen_state) { /* * Look for a matching listener */ /* 17 = packet_type(1) + channel(4) + reason(4) + descr(4) + lang(4) */ unsigned long packet_len = 17 + (sizeof(FwdNotReq) - 1); unsigned char *p; LIBSSH2_LISTENER *listn = _libssh2_list_first(&session->listeners); char failure_code = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED; int rc; (void) datalen; if(listen_state->state == libssh2_NB_state_idle) { unsigned char *s = data + (sizeof(\"forwarded-tcpip\") - 1) + 5; listen_state->sender_channel = _libssh2_ntohu32(s); s += 4; listen_state->initial_window_size = _libssh2_ntohu32(s); s += 4; listen_state->packet_size = _libssh2_ntohu32(s); s += 4; listen_state->host_len = _libssh2_ntohu32(s); s += 4; listen_state->host = s; s += listen_state->host_len; listen_state->port = _libssh2_ntohu32(s); s += 4; listen_state->shost_len = _libssh2_ntohu32(s); s += 4; listen_state->shost = s; s += listen_state->shost_len; listen_state->sport = _libssh2_ntohu32(s); _libssh2_debug(session, LIBSSH2_TRACE_CONN, \"Remote received connection from %s:%ld to %s:%ld\", listen_state->shost, listen_state->sport, listen_state->host, listen_state->port); listen_state->state = libssh2_NB_state_allocated; } if(listen_state->state != libssh2_NB_state_sent) { while(listn) { if((listn->port == (int) listen_state->port) && (strlen(listn->host) == listen_state->host_len) && (memcmp (listn->host, listen_state->host, listen_state->host_len) == 0)) { /* This is our listener */ LIBSSH2_CHANNEL *channel = NULL; listen_state->channel = NULL; if(listen_state->state == libssh2_NB_state_allocated) { if(listn->queue_maxsize && (listn->queue_maxsize <= listn->queue_size)) { /* Queue is full */ failure_code = SSH_OPEN_RESOURCE_SHORTAGE; _libssh2_debug(session, LIBSSH2_TRACE_CONN, \"Listener queue full, ignoring\"); listen_state->state = libssh2_NB_state_sent; break; } channel = LIBSSH2_CALLOC(session, sizeof(LIBSSH2_CHANNEL)); if(!channel) { _libssh2_error(session, LIBSSH2_ERROR_ALLOC, \"Unable to allocate a channel for \" \"new connection\"); failure_code = SSH_OPEN_RESOURCE_SHORTAGE; listen_state->state = libssh2_NB_state_sent; break; } listen_state->channel = channel; channel->session = session; channel->channel_type_len = sizeof(\"forwarded-tcpip\") - 1; channel->channel_type = LIBSSH2_ALLOC(session, channel-> channel_type_len + 1); if(!channel->channel_type) { _libssh2_error(session, LIBSSH2_ERROR_ALLOC, \"Unable to allocate a channel for new\" \" connection\"); LIBSSH2_FREE(session, channel); failure_code = SSH_OPEN_RESOURCE_SHORTAGE; listen_state->state = libssh2_NB_state_sent; break; } memcpy(channel->channel_type, \"forwarded-tcpip\", channel->channel_type_len + 1); channel->remote.id = listen_state->sender_channel; channel->remote.window_size_initial = LIBSSH2_CHANNEL_WINDOW_DEFAULT; channel->remote.window_size = LIBSSH2_CHANNEL_WINDOW_DEFAULT; channel->remote.packet_size = LIBSSH2_CHANNEL_PACKET_DEFAULT; channel->local.id = _libssh2_channel_nextid(session); channel->local.window_size_initial = listen_state->initial_window_size; channel->local.window_size = listen_state->initial_window_size; channel->local.packet_size = listen_state->packet_size; _libssh2_debug(session, LIBSSH2_TRACE_CONN, \"Connection queued: channel %lu/%lu \" \"win %lu/%lu packet %lu/%lu\", channel->local.id, channel->remote.id, channel->local.window_size, channel->remote.window_size, channel->local.packet_size, channel->remote.packet_size); p = listen_state->packet; *(p++) = SSH_MSG_CHANNEL_OPEN_CONFIRMATION; _libssh2_store_u32(&p, channel->remote.id); _libssh2_store_u32(&p, channel->local.id); _libssh2_store_u32(&p, channel->remote.window_size_initial); _libssh2_store_u32(&p, channel->remote.packet_size); listen_state->state = libssh2_NB_state_created; } if(listen_state->state == libssh2_NB_state_created) { rc = _libssh2_transport_send(session, listen_state->packet, 17, NULL, 0); if(rc == LIBSSH2_ERROR_EAGAIN) return rc; else if(rc) { listen_state->state = libssh2_NB_state_idle; return _libssh2_error(session, rc, \"Unable to send channel \" \"open confirmation\"); } /* Link the channel into the end of the queue list */ if(listen_state->channel) { _libssh2_list_add(&listn->queue, &listen_state->channel->node); listn->queue_size++; } listen_state->state = libssh2_NB_state_idle; return 0; } } listn = _libssh2_list_next(&listn->node); } listen_state->state = libssh2_NB_state_sent; } /* We're not listening to you */ p = listen_state->packet; *(p++) = SSH_MSG_CHANNEL_OPEN_FAILURE; _libssh2_store_u32(&p, listen_state->sender_channel); _libssh2_store_u32(&p, failure_code); _libssh2_store_str(&p, FwdNotReq, sizeof(FwdNotReq) - 1); _libssh2_htonu32(p, 0); rc = _libssh2_transport_send(session, listen_state->packet, packet_len, NULL, 0); if(rc == LIBSSH2_ERROR_EAGAIN) { return rc; } else if(rc) { listen_state->state = libssh2_NB_state_idle; return _libssh2_error(session, rc, \"Unable to send open failure\"); } listen_state->state = libssh2_NB_state_idle; return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 378683, "input": "void sqlite3VdbePrintSql(Vdbe *p){ const char *z = 0; if( p->zSql ){ z = p->zSql; }else if( p->nOp>=1 ){ const VdbeOp *pOp = &p->aOp[0]; if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){ z = pOp->p4.z; while( sqlite3Isspace(*z) ) z++; } } if( z ) printf(\"SQL: [%s]\\n\", z); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381422, "input": "static void v4l_print_audioout(const void *arg, bool write_only) { const struct v4l2_audioout *p = arg; if (write_only) pr_cont(\"index=%u\\n\", p->index); else pr_cont(\"index=%u, name=%.*s, capability=0x%x, mode=0x%x\\n\", p->index, (int)sizeof(p->name), p->name, p->capability, p->mode); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393224, "input": "TEST_F(QueryPlannerTest, InBasicOrEquivalent) { addIndex(fromjson(\"{a: 1}\")); runQuery(fromjson(\"{$or: [{a: 1}, {a: 2}]}\")); assertNumSolutions(2U); assertSolutionExists(\"{cscan: {dir: 1, filter: {$or: [{a: 1}, {a: 2}]}}}\"); assertSolutionExists( \"{fetch: {filter: null, \" \"node: {ixscan: {pattern: {a: 1}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 238827, "input": "void TranslateCodepoints(icu::UnicodeString* s, bool* found_any_format_error, UChar32 ch, int src_bytes, bool format_error) { if (ShouldHandleFormatError(error_options_, ch, format_error)) { *found_any_format_error = true; if (error_options_.elide_replacement) { return; } else { ch = error_options_.subst; } } s->append(ch); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 429661, "input": "mysql_data_seek(MYSQL_RES *result, unsigned long long row) { MYSQL_ROWS *tmp=0; if (result->data) for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; result->current_row=0; result->data_cursor = tmp; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230259, "input": "CallResult> JSObject::getComputedPropertyValue_RJS( Handle selfHandle, Runtime *runtime, Handle propObj, ComputedPropertyDescriptor desc, Handle<> nameValHandle) { if (!propObj) { return createPseudoHandle(HermesValue::encodeEmptyValue()); } if (LLVM_LIKELY(!desc.flags.proxyObject)) { return JSObject::getComputedPropertyValue_RJS( selfHandle, runtime, propObj, desc); } CallResult> keyRes = toPropertyKey(runtime, nameValHandle); if (LLVM_UNLIKELY(keyRes == ExecutionStatus::EXCEPTION)) { return ExecutionStatus::EXCEPTION; } CallResult hasRes = JSProxy::hasComputed(propObj, runtime, *keyRes); if (LLVM_UNLIKELY(hasRes == ExecutionStatus::EXCEPTION)) { return ExecutionStatus::EXCEPTION; } if (!*hasRes) { return createPseudoHandle(HermesValue::encodeEmptyValue()); } return JSProxy::getComputed(propObj, runtime, *keyRes, selfHandle); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 293146, "input": "static u32 zipfileGetTime(sqlite3_value *pVal){ if( pVal==0 || sqlite3_value_type(pVal)==SQLITE_NULL ){ return zipfileTime(); } return (u32)sqlite3_value_int64(pVal); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 379907, "input": "} EXPORT_SYMBOL_GPL(iscsi_unblock_session); static void __iscsi_block_session(struct work_struct *work) { struct iscsi_cls_session *session = container_of(work, struct iscsi_cls_session, block_work); unsigned long flags; ISCSI_DBG_TRANS_SESSION(session, \"Blocking session\\n\"); spin_lock_irqsave(&session->lock, flags); session->state = ISCSI_SESSION_FAILED; spin_unlock_irqrestore(&session->lock, flags); scsi_target_block(&session->dev); ISCSI_DBG_TRANS_SESSION(session, \"Completed SCSI target blocking\\n\"); if (session->recovery_tmo >= 0) queue_delayed_work(iscsi_eh_timer_workq,", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219148, "input": "static bool string_substr_check(int len, int& f, int& l) { assertx(len >= 0); if (l < 0 && -l > len) { return false; } if (f >= len) { return false; } if (l > len) { l = len; } if (f < 0 && -f > len) { f = 0; if (len == 0) { return false; } } if (l < 0 && l + len < f) { return false; } // If \"from\" position is negative, count start position from the end. if (f < 0) { f += len; } assertx(f >= 0); // If \"length\" position is negative, set it to the length needed to stop that // many chars from the end of the string. if (l < 0) { l += len - f; if (l < 0) { l = 0; } } assertx(l >= 0); return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 267907, "input": "GF_Err stbl_AppendCTSOffset(GF_SampleTableBox *stbl, s32 offset) { GF_CompositionOffsetBox *ctts; if (!stbl->CompositionOffset) { stbl->CompositionOffset = (GF_CompositionOffsetBox *) gf_isom_box_new_parent(&stbl->child_boxes, GF_ISOM_BOX_TYPE_CTTS); if (!stbl->CompositionOffset) return GF_OUT_OF_MEM; } ctts = stbl->CompositionOffset; ctts->w_LastSampleNumber ++; if (!ctts->unpack_mode && ctts->nb_entries && (ctts->entries[ctts->nb_entries-1].decodingOffset == offset) ) { ctts->entries[ctts->nb_entries-1].sampleCount++; return GF_OK; } if (ctts->nb_entries==ctts->alloc_size) { ALLOC_INC(ctts->alloc_size); ctts->entries = gf_realloc(ctts->entries, sizeof(GF_DttsEntry)*ctts->alloc_size); if (!ctts->entries) return GF_OUT_OF_MEM; memset(&ctts->entries[ctts->nb_entries], 0, sizeof(GF_DttsEntry)*(ctts->alloc_size-ctts->nb_entries) ); } ctts->entries[ctts->nb_entries].decodingOffset = offset; ctts->entries[ctts->nb_entries].sampleCount = 1; ctts->nb_entries++; if (offset<0) ctts->version=1; if (ABS(offset) > ctts->max_ts_delta) ctts->max_ts_delta = ABS(offset); return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 519155, "input": "static bool MR_primality_test(UnsignedBigInteger n, const Vector& tests) { // Written using Wikipedia: // https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test ASSERT(!(n < 4)); auto predecessor = n.minus({ 1 }); auto d = predecessor; size_t r = 0; { auto div_result = d.divided_by(2); while (div_result.remainder == 0) { d = div_result.quotient; div_result = d.divided_by(2); ++r; } } if (r == 0) { // n - 1 is odd, so n was even. But there is only one even prime: return n == 2; } for (auto& a : tests) { // Technically: ASSERT(2 <= a && a <= n - 2) ASSERT(a < n); auto x = ModularPower(a, d, n); if (x == 1 || x == predecessor) continue; bool skip_this_witness = false; // r \u2212 1 iterations. for (size_t i = 0; i < r - 1; ++i) { x = ModularPower(x, 2, n); if (x == predecessor) { skip_this_witness = true; break; } } if (skip_this_witness) continue; return false; // \"composite\" } return true; // \"probably prime\" }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280103, "input": "static int slab_memory_callback(struct notifier_block *self, unsigned long action, void *arg) { int ret = 0; switch (action) { case MEM_GOING_ONLINE: ret = slab_mem_going_online_callback(arg); break; case MEM_GOING_OFFLINE: ret = slab_mem_going_offline_callback(arg); break; case MEM_OFFLINE: case MEM_CANCEL_ONLINE: slab_mem_offline_callback(arg); break; case MEM_ONLINE: case MEM_CANCEL_OFFLINE: break; } if (ret) ret = notifier_from_errno(ret); else ret = NOTIFY_OK; return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 212945, "input": "static int calcstepsizes(uint_fast16_t refstepsize, int numrlvls, uint_fast16_t *stepsizes) { int bandno; int numbands; uint_fast16_t expn; uint_fast16_t mant; expn = JPC_QCX_GETEXPN(refstepsize); mant = JPC_QCX_GETMANT(refstepsize); numbands = 3 * numrlvls - 2; for (bandno = 0; bandno < numbands; ++bandno) { //jas_eprintf(\"DEBUG %d %d %d %d %d\\n\", bandno, expn, numrlvls, bandno, ((numrlvls - 1) - (numrlvls - 1 - ((bandno > 0) ? ((bandno + 2) / 3) : (0))))); stepsizes[bandno] = JPC_QCX_MANT(mant) | JPC_QCX_EXPN(expn + (bandno + 2) / 3); } return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Reachable Assertion"], "explanation": "The calcstepsizes function in jpc_dec.c in JasPer 1.900.22 allows remote attackers to cause a denial of service (assertion failure) via unspecified vectors.", "severity_level": "NoInfo", "cwe": "CWE-617", "cve": "CVE-2016-9399"}} -{"idx": 219418, "input": "bool HHVM_FUNCTION(imagepolygon, const Resource& image, const Array& points, int64_t num_points, int64_t color) { return php_imagepolygon(image, points, num_points, color, 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 430787, "input": "UnicodeStringAppendable::appendCodePoint(UChar32 c) { UChar buffer[U16_MAX_LENGTH]; int32_t cLength = 0; UBool isError = FALSE; U16_APPEND(buffer, cLength, U16_MAX_LENGTH, c, isError); return !isError && str.doAppend(buffer, 0, cLength).isWritable(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431966, "input": "static void hci_cc_le_set_ext_scan_param(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_cp_le_set_ext_scan_params *cp; __u8 status = *((__u8 *) skb->data); struct hci_cp_le_scan_phy_params *phy_param; BT_DBG(\"%s status 0x%2.2x\", hdev->name, status); if (status) return; cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS); if (!cp) return; phy_param = (void *)cp->data; hci_dev_lock(hdev); hdev->le_scan_type = phy_param->type; hci_dev_unlock(hdev); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 267223, "input": "GF_Err gf_isom_remove_track_references(GF_ISOFile *the_file, u32 trackNumber) { GF_TrackBox *trak; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; if (trak->References) { gf_isom_box_del_parent(&trak->child_boxes, (GF_Box *)trak->References); trak->References = NULL; } return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 474553, "input": "ReadFromTLS(rfbClient* client, char *out, unsigned int n) { ssize_t ret; ret = SSL_read (client->tlsSession, out, n); if (ret >= 0) return ret; else { errno = ssl_errno (client->tlsSession, ret); if (errno != EAGAIN) { rfbClientLog(\"Error reading from TLS: -.\\n\"); } } return -1; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381932, "input": "static int oidc_handle_refresh_token_request(request_rec *r, oidc_cfg *c, oidc_session_t *session) { char *return_to = NULL; char *r_access_token = NULL; char *error_code = NULL; char *error_str = NULL; char *error_description = NULL; apr_byte_t needs_save = TRUE; /* get the command passed to the session management handler */ oidc_util_get_request_parameter(r, OIDC_REDIRECT_URI_REQUEST_REFRESH, &return_to); oidc_util_get_request_parameter(r, OIDC_PROTO_ACCESS_TOKEN, &r_access_token); /* check the input parameters */ if (return_to == NULL) { oidc_error(r, \"refresh token request handler called with no URL to return to\"); return HTTP_INTERNAL_SERVER_ERROR; } /* do input validation on the return to parameter value */ if (oidc_validate_redirect_url(r, c, return_to, TRUE, &error_str, &error_description) == FALSE) { oidc_error(r, \"return_to URL validation failed: %s: %s\", error_str, error_description); return HTTP_INTERNAL_SERVER_ERROR; } if (r_access_token == NULL) { oidc_error(r, \"refresh token request handler called with no access_token parameter\"); error_code = \"no_access_token\"; goto end; } const char *s_access_token = oidc_session_get_access_token(r, session); if (s_access_token == NULL) { oidc_error(r, \"no existing access_token found in the session, nothing to refresh\"); error_code = \"no_access_token_exists\"; goto end; } /* compare the access_token parameter used for XSRF protection */ if (apr_strnatcmp(s_access_token, r_access_token) != 0) { oidc_error(r, \"access_token passed in refresh request does not match the one stored in the session\"); error_code = \"no_access_token_match\"; goto end; } /* get a handle to the provider configuration */ oidc_provider_t *provider = NULL; if (oidc_get_provider_from_session(r, c, session, &provider) == FALSE) { error_code = \"session_corruption\"; goto end; } /* execute the actual refresh grant */ if (oidc_refresh_access_token(r, c, session, provider, NULL) == FALSE) { oidc_error(r, \"access_token could not be refreshed\"); error_code = \"refresh_failed\"; goto end; } /* pass the tokens to the application, possibly updating the expiry */ if (oidc_session_pass_tokens(r, c, session, &needs_save) == FALSE) { error_code = \"session_corruption\"; goto end; } if (oidc_session_save(r, session, FALSE) == FALSE) { error_code = \"error saving session\"; goto end; } end: /* pass optional error message to the return URL */ if (error_code != NULL) return_to = apr_psprintf(r->pool, \"%s%serror_code=%s\", return_to, strchr(return_to ? return_to : \"\", OIDC_CHAR_QUERY) ? OIDC_STR_AMP : OIDC_STR_QUERY, oidc_util_escape_string(r, error_code)); /* add the redirect location header */ oidc_util_hdr_out_location_set(r, return_to); return HTTP_MOVED_TEMPORARILY; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 318242, "input": "struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type, const void *data, int len) { struct rtattr *start = NLMSG_TAIL(n); addattr_l(n, maxlen, type, data, len); addattr_nest(n, maxlen, type); return start; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 478532, "input": "static int slcan_open(struct tty_struct *tty) { struct slcan *sl; int err; if (!capable(CAP_NET_ADMIN)) return -EPERM; if (tty->ops->write == NULL) return -EOPNOTSUPP; /* RTnetlink lock is misused here to serialize concurrent opens of slcan channels. There are better ways, but it is the simplest one. */ rtnl_lock(); /* Collect hanged up channels. */ slc_sync(); sl = tty->disc_data; err = -EEXIST; /* First make sure we're not already connected. */ if (sl && sl->magic == SLCAN_MAGIC) goto err_exit; /* OK. Find a free SLCAN channel to use. */ err = -ENFILE; sl = slc_alloc(); if (sl == NULL) goto err_exit; sl->tty = tty; tty->disc_data = sl; if (!test_bit(SLF_INUSE, &sl->flags)) { /* Perform the low-level SLCAN initialization. */ sl->rcount = 0; sl->xleft = 0; set_bit(SLF_INUSE, &sl->flags); err = register_netdevice(sl->dev); if (err) goto err_free_chan; } /* Done. We have linked the TTY line to a channel. */ rtnl_unlock(); tty->receive_room = 65536; /* We don't flow control */ /* TTY layer expects 0 on success */ return 0; err_free_chan: sl->tty = NULL; tty->disc_data = NULL; clear_bit(SLF_INUSE, &sl->flags); slc_free_netdev(sl->dev); /* do not call free_netdev before rtnl_unlock */ rtnl_unlock(); free_netdev(sl->dev); return err; err_exit: rtnl_unlock(); /* Count references from TTY module */ return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 453321, "input": "static ssize_t bfq_max_budget_store(struct elevator_queue *e, const char *page, size_t count) { struct bfq_data *bfqd = e->elevator_data; unsigned long __data; int ret; ret = bfq_var_store(&__data, (page)); if (ret) return ret; if (__data == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); else { if (__data > INT_MAX) __data = INT_MAX; bfqd->bfq_max_budget = __data; } bfqd->bfq_user_max_budget = __data; return count;", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 325994, "input": "static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, struct file *file, int idx) { struct tty_struct *tty; if (driver->ops->lookup) if (!file) tty = ERR_PTR(-EIO); else tty = driver->ops->lookup(driver, file, idx); else tty = driver->ttys[idx]; if (!IS_ERR(tty)) tty_kref_get(tty); return tty; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 319439, "input": "void LibRaw::lossless_jpeg_load_raw() { int jwide, jhigh, jrow, jcol, val, jidx, i, j, row = 0, col = 0; struct jhead jh; ushort *rp; if (!ljpeg_start(&jh, 0)) return; if (jh.wide < 1 || jh.high < 1 || jh.clrs < 1 || jh.bits < 1) throw LIBRAW_EXCEPTION_IO_CORRUPT; jwide = jh.wide * jh.clrs; jhigh = jh.high; if (jh.clrs == 4 && jwide >= raw_width * 2) jhigh *= 2; try { for (jrow = 0; jrow < jh.high; jrow++) { checkCancel(); rp = ljpeg_row(jrow, &jh); if (load_flags & 1) row = jrow & 1 ? height - 1 - jrow / 2 : jrow / 2; for (jcol = 0; jcol < jwide; jcol++) { val = curve[*rp++]; if (cr2_slice[0]) { jidx = jrow * jwide + jcol; i = jidx / (cr2_slice[1] * raw_height); if ((j = i >= cr2_slice[0])) i = cr2_slice[0]; jidx -= i * (cr2_slice[1] * raw_height); row = jidx / cr2_slice[1 + j]; col = jidx % cr2_slice[1 + j] + i * cr2_slice[1]; } if (raw_width == 3984 && (col -= 2) < 0) col += (row--, raw_width); if (row > raw_height) throw LIBRAW_EXCEPTION_IO_CORRUPT; if ((unsigned)row < raw_height) RAW(row, col) = val; if (++col >= raw_width) col = (row++, 0); } } } catch (...) { ljpeg_end(&jh); throw; } ljpeg_end(&jh); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 326068, "input": "static int __tty_fasync(int fd, struct file *filp, int on) { struct tty_struct *tty = file_tty(filp); unsigned long flags; int retval = 0; if (tty_paranoia_check(tty, file_inode(filp), \"tty_fasync\")) goto out; retval = fasync_helper(fd, filp, on, &tty->fasync); if (retval <= 0) goto out; if (on) { enum pid_type type; struct pid *pid; spin_lock_irqsave(&tty->ctrl_lock, flags); if (tty->pgrp) { pid = tty->pgrp; type = PIDTYPE_PGID; } else { pid = task_pid(current); type = PIDTYPE_TGID; } get_pid(pid); spin_unlock_irqrestore(&tty->ctrl_lock, flags); __f_setown(filp, pid, type, 0); put_pid(pid); retval = 0; } out: return retval; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 124855, "input": "void MediaElementAudioSourceNode::unlock() { m_processLock.unlock(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 206300, "input": "static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa) { struct property *prop; char *name; char *value; prop = kzalloc(sizeof(*prop), GFP_KERNEL); if (!prop) return NULL; name = (char *)ccwa + be32_to_cpu(ccwa->name_offset); prop->name = kstrdup(name, GFP_KERNEL); prop->length = be32_to_cpu(ccwa->prop_length); value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset); prop->value = kmemdup(value, prop->length, GFP_KERNEL); if (!prop->value) { dlpar_free_cc_property(prop); return NULL; } return prop; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "An issue was discovered in dlpar_parse_cc_property in arch/powerpc/platforms/pseries/dlpar.c in the Linux kernel through 5.1.6. There is an unchecked kstrdup of prop->name, which might allow an attacker to cause a denial of service (NULL pointer dereference and system crash).", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2019-12614"}} -{"idx": 509338, "input": "virtual bool collect_item_field_processor(void *arg) { return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 384548, "input": "auto make_stack_allocator() { return boost::context::protected_fixedsize_stack{512*1024}; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 453397, "input": "static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, struct bfq_group *bfqg, int ioprio_class, int ioprio) { switch (ioprio_class) { case IOPRIO_CLASS_RT: return &bfqg->async_bfqq[0][ioprio]; case IOPRIO_CLASS_NONE: ioprio = IOPRIO_NORM; /* fall through */ case IOPRIO_CLASS_BE: return &bfqg->async_bfqq[1][ioprio]; case IOPRIO_CLASS_IDLE: return &bfqg->async_idle_bfqq; default: return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 376800, "input": "static void avifDecoderCleanup(avifDecoder * decoder) { if (decoder->data) { avifDecoderDataDestroy(decoder->data); decoder->data = NULL; } if (decoder->image) { avifImageDestroy(decoder->image); decoder->image = NULL; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 343498, "input": "static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config, bool host) { union hv_stimer_config new_config = {.as_uint64 = config}, old_config = {.as_uint64 = stimer->config.as_uint64}; struct kvm_vcpu *vcpu = hv_stimer_to_vcpu(stimer); struct kvm_vcpu_hv_synic *synic = to_hv_synic(vcpu); if (!synic->active && !host) return 1; trace_kvm_hv_stimer_set_config(hv_stimer_to_vcpu(stimer)->vcpu_id, stimer->index, config, host); stimer_cleanup(stimer); if (old_config.enable && !new_config.direct_mode && new_config.sintx == 0) new_config.enable = 0; stimer->config.as_uint64 = new_config.as_uint64; if (stimer->config.enable) stimer_mark_pending(stimer, false); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381479, "input": "static void v4l_print_dbg_chip_info(const void *arg, bool write_only) { const struct v4l2_dbg_chip_info *p = arg; pr_cont(\"type=%u, \", p->match.type); if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) pr_cont(\"name=%.*s, \", (int)sizeof(p->match.name), p->match.name); else pr_cont(\"addr=%u, \", p->match.addr); pr_cont(\"name=%.*s\\n\", (int)sizeof(p->name), p->name); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 243191, "input": "void mp4box_log(const char *fmt, ...) { va_list vl; va_start(vl, fmt); vfprintf(stderr, fmt, vlist); fflush(stderr); va_end(vl); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334482, "input": "mono_loader_get_last_error (void) { return (MonoLoaderError*)TlsGetValue (loader_error_thread_id); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 267343, "input": "GF_Err gf_isom_set_y3d_info(GF_ISOFile *movie, u32 trackNumber, u32 sampleDescriptionIndex, GF_ISOM_Y3D_Info *info) { GF_Err e; u32 proj_type; GF_SampleEntryBox *ent; GF_TrackBox *trak; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !info) return GF_BAD_PARAM; ent = gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, sampleDescriptionIndex-1); if (!ent) return GF_BAD_PARAM; if (info->projection_type > GF_PROJ360_EQR) return GF_NOT_SUPPORTED; GF_Stereo3DBox *st3d = (GF_Stereo3DBox *) gf_isom_box_find_child(ent->child_boxes, GF_ISOM_BOX_TYPE_ST3D); if (st3d) { if (info->stereo_type) { st3d->stereo_type = info->stereo_type; } else { gf_isom_box_del_parent(&ent->child_boxes, (GF_Box *) st3d); } } else if (info->stereo_type) { st3d = (GF_Stereo3DBox *) gf_isom_box_new_parent(&ent->child_boxes, GF_ISOM_BOX_TYPE_ST3D); if (!st3d) return GF_OUT_OF_MEM; st3d->stereo_type = info->stereo_type; } GF_Box *sv3d = gf_isom_box_find_child(ent->child_boxes, GF_ISOM_BOX_TYPE_SV3D); if (sv3d && !info->projection_type) { gf_isom_box_del_parent(&ent->child_boxes, sv3d); return GF_OK; } if (!sv3d && !info->projection_type) { return GF_OK; } if (!sv3d) { sv3d = gf_isom_box_new_parent(&ent->child_boxes, GF_ISOM_BOX_TYPE_SV3D); if (!sv3d) return GF_OUT_OF_MEM; } //svhd mandatory GF_SphericalVideoInfoBox *svhd = (GF_SphericalVideoInfoBox *) gf_isom_box_find_child(sv3d->child_boxes, GF_ISOM_BOX_TYPE_SVHD); if (svhd) { if (svhd->string) gf_free(svhd->string); } else { svhd = (GF_SphericalVideoInfoBox *) gf_isom_box_new_parent(&sv3d->child_boxes, GF_ISOM_BOX_TYPE_SVHD); if (!svhd) return GF_OUT_OF_MEM; } svhd->string = gf_strdup(info->meta_data ? info->meta_data : \"\"); //proj mandatory GF_Box *proj = gf_isom_box_find_child(sv3d->child_boxes, GF_ISOM_BOX_TYPE_PROJ); if (!proj) { proj = (GF_Box *) gf_isom_box_new_parent(&sv3d->child_boxes, GF_ISOM_BOX_TYPE_PROJ); if (!proj) return GF_OUT_OF_MEM; } GF_ProjectionHeaderBox *projh = (GF_ProjectionHeaderBox *) gf_isom_box_find_child(proj->child_boxes, GF_ISOM_BOX_TYPE_PRHD); //prj header mandatory if (!projh) { projh = (GF_ProjectionHeaderBox *) gf_isom_box_new_parent(&proj->child_boxes, GF_ISOM_BOX_TYPE_PRHD); if (!projh) return GF_OUT_OF_MEM; } projh->yaw = info->yaw; projh->pitch = info->pitch; projh->roll = info->roll; proj_type = (info->projection_type==GF_PROJ360_CUBE_MAP) ? GF_ISOM_BOX_TYPE_CBMP : GF_ISOM_BOX_TYPE_EQUI; GF_ProjectionTypeBox *projt = (GF_ProjectionTypeBox *) gf_isom_box_find_child(proj->child_boxes, proj_type); if (!projt) { projt = (GF_ProjectionTypeBox *) gf_isom_box_new_parent(&proj->child_boxes, proj_type); if (!projt) return GF_OUT_OF_MEM; } if (info->projection_type==GF_PROJ360_CUBE_MAP) { projt->layout = info->layout; projt->padding = info->padding; } else { projt->bounds_top = info->top; projt->bounds_bottom = info->bottom; projt->bounds_left = info->left; projt->bounds_right = info->right; } //remove other ones GF_Box *b = gf_isom_box_new_parent(&proj->child_boxes, GF_ISOM_BOX_TYPE_MSHP); if (b) gf_isom_box_del_parent(&proj->child_boxes, b); if (info->projection_type==GF_PROJ360_CUBE_MAP) { b = gf_isom_box_new_parent(&proj->child_boxes, GF_ISOM_BOX_TYPE_EQUI); if (b) gf_isom_box_del_parent(&proj->child_boxes, b); } else { b = gf_isom_box_new_parent(&proj->child_boxes, GF_ISOM_BOX_TYPE_EQUI); if (b) gf_isom_box_del_parent(&proj->child_boxes, b); } return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431416, "input": "static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) { struct nfs_writeverf *verf = res->verf; int status; status = decode_op_hdr(xdr, OP_COMMIT); if (!status) status = decode_write_verifier(xdr, &verf->verifier); if (!status) verf->committed = NFS_FILE_SYNC; return status; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409184, "input": "static int uvc_parse_control(struct uvc_device *dev) { struct usb_host_interface *alts = dev->intf->cur_altsetting; unsigned char *buffer = alts->extra; int buflen = alts->extralen; int ret; /* Parse the default alternate setting only, as the UVC specification * defines a single alternate setting, the default alternate setting * zero. */ while (buflen > 2) { if (uvc_parse_vendor_control(dev, buffer, buflen) || buffer[1] != USB_DT_CS_INTERFACE) goto next_descriptor; if ((ret = uvc_parse_standard_control(dev, buffer, buflen)) < 0) return ret; next_descriptor: buflen -= buffer[0]; buffer += buffer[0]; } /* Check if the optional status endpoint is present. Built-in iSight * webcams have an interrupt endpoint but spit proprietary data that * don't conform to the UVC status endpoint messages. Don't try to * handle the interrupt endpoint for those cameras. */ if (alts->desc.bNumEndpoints == 1 && !(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)) { struct usb_host_endpoint *ep = &alts->endpoint[0]; struct usb_endpoint_descriptor *desc = &ep->desc; if (usb_endpoint_is_int_in(desc) && le16_to_cpu(desc->wMaxPacketSize) >= 8 && desc->bInterval != 0) { uvc_trace(UVC_TRACE_DESCR, \"Found a Status endpoint \" \"(addr %02x).\\n\", desc->bEndpointAddress); dev->int_ep = ep; } } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280634, "input": "parse_DEC_MPLS_TTL(char *arg OVS_UNUSED, const struct ofpact_parse_params *pp) { ofpact_put_DEC_MPLS_TTL(pp->ofpacts); return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246401, "input": "static const char *set_document_root(cmd_parms *cmd, void *dummy, const char *arg) { void *sconf = cmd->server->module_config; core_server_config *conf = ap_get_core_module_config(sconf); const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE); if (err != NULL) { return err; } /* When ap_document_root_check is false; skip all the stuff below */ if (!ap_document_root_check) { conf->ap_document_root = arg; return NULL; } /* Make it absolute, relative to ServerRoot */ arg = ap_server_root_relative(cmd->pool, arg); if (arg == NULL) { return \"DocumentRoot must be a directory\"; } if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg, APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS || !ap_is_directory(cmd->temp_pool, arg)) { if (cmd->server->is_virtual) { ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, cmd->pool, APLOGNO(00112) \"Warning: DocumentRoot [%s] does not exist\", arg); conf->ap_document_root = arg; } else { return apr_psprintf(cmd->pool, \"DocumentRoot '%s' is not a directory, or is not readable\", arg); } } return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280760, "input": "parse_EXIT(char *arg OVS_UNUSED, const struct ofpact_parse_params *pp) { ofpact_put_EXIT(pp->ofpacts); return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393008, "input": "TEST_F(QueryPlannerTest, IndexBoundsOrOfNegations) { addIndex(BSON(\"a\" << 1)); runQuery(fromjson(\"{$or: [{a: {$ne: 3}}, {a: {$ne: 4}}]}\")); assertNumSolutions(2U); assertSolutionExists(\"{cscan: {dir: 1}}\"); assertSolutionExists( \"{fetch: {filter: null, node: {ixscan: {pattern: {a:1}, \" \"bounds: {a: [['MinKey','MaxKey',true,true]]}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 195564, "input": "static bool TryParse(const char* inp, int length, TypedValue* buf, Variant& out, JSONContainerType container_type, bool is_tsimplejson) { SimpleParser parser(inp, length, buf, container_type, is_tsimplejson); bool ok = parser.parseValue(); parser.skipSpace(); if (!ok || parser.p != inp + length) { // Unsupported, malformed, or trailing garbage. Release entire stack. tvDecRefRange(buf, parser.top); return false; } out = Variant::attach(*--parser.top); return true; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "Insufficient boundary checks when decoding JSON in TryParse reads out of bounds memory, potentially leading to DOS. This issue affects HHVM 4.45.0, 4.44.0, 4.43.0, 4.42.0, 4.41.0, 4.40.0, 4.39.0, versions between 4.33.0 and 4.38.0 (inclusive), versions between 4.9.0 and 4.32.0 (inclusive), and versions prior to 4.8.7.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-1893"}} -{"idx": 398316, "input": "static u32 convert_can2host_bitrate(struct mcba_usb_msg_ka_can *msg) { const u32 bitrate = get_unaligned_be16(&msg->can_bitrate); if ((bitrate == 33) || (bitrate == 83)) return bitrate * 1000 + 333; else return bitrate * 1000; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281258, "input": "RGWOp *RGWHandler_REST_Bucket_S3::op_delete() { if (is_cors_op()) { return new RGWDeleteCORS_ObjStore_S3; } else if(is_lc_op()) { return new RGWDeleteLC_ObjStore_S3; } else if(is_policy_op()) { return new RGWDeleteBucketPolicy; } if (s->info.args.sub_resource_exists(\"website\")) { if (!s->cct->_conf->rgw_enable_static_website) { return NULL; } return new RGWDeleteBucketWebsite_ObjStore_S3; } if (s->info.args.exists(\"mdsearch\")) { return new RGWDelBucketMetaSearch_ObjStore_S3; } return new RGWDeleteBucket_ObjStore_S3; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232609, "input": "static int fixup_call_args(struct bpf_verifier_env *env) { #ifndef CONFIG_BPF_JIT_ALWAYS_ON struct bpf_prog *prog = env->prog; struct bpf_insn *insn = prog->insnsi; int i, depth; #endif int err = 0; if (env->prog->jit_requested && !bpf_prog_is_dev_bound(env->prog->aux)) { err = jit_subprogs(env); if (err == 0) return 0; if (err == -EFAULT) return err; } #ifndef CONFIG_BPF_JIT_ALWAYS_ON for (i = 0; i < prog->len; i++, insn++) { if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) continue; depth = get_callee_stack_depth(env, insn, i); if (depth < 0) return depth; bpf_patch_call_args(insn, depth); } err = 0; #endif return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 338559, "input": "static void io_poll_remove_double(struct io_kiocb *req) __must_hold(&req->ctx->completion_lock) { struct io_poll_iocb *poll = io_poll_get_double(req); lockdep_assert_held(&req->ctx->completion_lock); if (poll && poll->head) { struct wait_queue_head *head = poll->head; spin_lock(&head->lock); list_del_init(&poll->wait.entry); if (poll->wait.private) req_ref_put(req); poll->head = NULL; spin_unlock(&head->lock); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 295308, "input": "long do_mknodat(int dfd, const char __user *filename, umode_t mode, unsigned int dev) { struct dentry *dentry; struct path path; int error; unsigned int lookup_flags = 0; error = may_mknod(mode); if (error) return error; retry: dentry = user_path_create(dfd, filename, &path, lookup_flags); if (IS_ERR(dentry)) return PTR_ERR(dentry); if (!IS_POSIXACL(path.dentry->d_inode)) mode &= ~current_umask(); error = security_path_mknod(&path, dentry, mode, dev); if (error) goto out; switch (mode & S_IFMT) { case 0: case S_IFREG: error = vfs_create(path.dentry->d_inode,dentry,mode,true); if (!error) ima_post_path_mknod(dentry); break; case S_IFCHR: case S_IFBLK: error = vfs_mknod(path.dentry->d_inode,dentry,mode, new_decode_dev(dev)); break; case S_IFIFO: case S_IFSOCK: error = vfs_mknod(path.dentry->d_inode,dentry,mode,0); break; } out: done_path_create(&path, dentry); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; goto retry; } return error; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 387905, "input": "void get_cmdln_options(int argc, char *argv[]) { int o; #if CONFIG_FILE && HAVE_GETPWUID static struct passwd *pwd_entry; char *str; #endif #ifdef LONG_OPTIONS int option_index = 0; static struct option long_options[] = { {\"timeout\", 1, 0, 't'}, #ifdef PROC_NET_DEV {\"procfile\",1,0,'f'}, #endif #ifdef PROC_DISKSTATS {\"diskstatsfile\",1,0,1000}, {\"partitionsfile\",1,0,1001}, #endif #if NETSTAT && ALLOW_NETSTATPATH {\"netstat\",1,0,'n'}, #endif #if IOSERVICE_IN {\"longdisknames\",0,0,1002}, #endif {\"input\",1,0,'i'}, {\"dynamic\",1,0,'d'}, {\"help\", 0, 0, 'h'}, {\"version\",0,0,'V'}, {\"allif\",1,0,'a'}, {\"unit\",1,0,'u'}, {\"ansiout\",0,0,'N'}, #if EXTENDED_STATS {\"type\",1,0,'T'}, {\"avglength\",1,0,'A'}, #endif {\"interfaces\",1,0,'I'}, {\"sumhidden\",1,0,'S'}, {\"output\",1,0,'o'}, #ifdef CSV {\"csvchar\",1,0,'C'}, {\"csvfile\",1,0,'F'}, #endif {\"count\",1,0,'c'}, {\"daemon\",1,0,'D'}, #ifdef HTML {\"htmlrefresh\",1,0,'R'}, {\"htmlheader\",1,0,'H'}, #endif {0,0,0,0} }; #endif #ifdef CONFIG_FILE /* loop till first non option argument */ opterr=0; while (1) { #ifdef LONG_OPTIONS o=getopt_long (argc,argv,SHORT_OPTIONS,long_options, &option_index); #else o=getopt (argc,argv,SHORT_OPTIONS); #endif if (o==-1) break; } opterr=1; if (optind < argc) { read_config(argv[optind]); } else { read_config(\"/etc/bwm-ng.conf\"); #ifdef HAVE_GETPWUID pwd_entry=getpwuid(getuid()); if (pwd_entry!=NULL) { str=(char*)malloc(strlen(pwd_entry->pw_dir)+14); if(!str) { printf(\"Fatal: failed to allocate %zu bytes.\\n\", strlen(pwd_entry->pw_dir)+14); exit(EXIT_FAILURE); } snprintf(str,strlen(pwd_entry->pw_dir)+14,\"%s/.bwm-ng.conf\",pwd_entry->pw_dir); read_config(str); free(str); } #endif } /* reset getopt again */ optind=1; #endif /* get command line arguments, kinda ugly, wanna rewrite it? */ while (1) { #ifdef LONG_OPTIONS o=getopt_long (argc,argv,SHORT_OPTIONS,long_options, &option_index); #else o=getopt (argc,argv,SHORT_OPTIONS); #endif if (o==-1) break; switch (o) { case '?': printf(\"unknown option: %s\\n\",argv[optind-1]); exit(EXIT_FAILURE); break; /* ugly workaround to handle optional arguments for all platforms */ case ':': if (!strcmp(argv[optind-1],\"-a\") || !strcasecmp(argv[optind-1],\"--allif\")) show_all_if=1; else if (!strcmp(argv[optind-1],\"-d\") || !strcasecmp(argv[optind-1],\"--dynamic\")) dynamic=1; else if (!strcmp(argv[optind-1],\"-D\") || !strcasecmp(argv[optind-1],\"--daemon\")) daemonize=1; #ifdef HTML else if (!strcmp(argv[optind-1],\"-H\") || !strcasecmp(argv[optind-1],\"--htmlheader\")) html_header=1; #endif else if (!strcmp(argv[optind-1],\"-S\") || !strcasecmp(argv[optind-1],\"--sumhidden\")) sumhidden=1; else { printf(\"%s requires an argument!\\n\",argv[optind-1]); exit(EXIT_FAILURE); } break; #ifdef PROC_DISKSTATS case 1000: if (strlen(optarg)0) { html_refresh=atol(optarg); } break; case 'H': if (optarg) html_header=atoi(optarg); break; #endif case 'c': if (optarg) output_count=atol(optarg); break; #if CSV || HTML case 'F': if (optarg) { if (out_file) fclose(out_file); out_file=fopen(optarg,\"a\"); if (!out_file) deinit(1, \"failed to open outfile\\n\"); if (out_file_path) free(out_file_path); out_file_path=(char *)strdup(optarg); } break; #endif #ifdef CSV case 'C': if (optarg) csv_char=optarg[0]; break; #endif case 'h': cmdln_printhelp(); break; #ifdef PROC_NET_DEV case 'f': if (optarg && (strlen(optarg)0) { delay=atol(optarg); } break; #if EXTENDED_STATS case 'T': output_type=str2output_type(optarg); break; case 'A': if (optarg) avg_length=atoi(optarg)*1000; break; #endif case 'd': if (optarg) dynamic=atoi(optarg); break; case 'u': output_unit=str2output_unit(optarg); break; #if NETSTAT && ALLOW_NETSTATPATH case 'n': if (optarg && (strlen(optarg)=avg_length) deinit(1, \"avglength needs to be a least twice the value of timeout\\n\"); #endif if ((output_unit==ERRORS_OUT && !net_input_method(input_method)) || (output_unit==PACKETS_OUT && input_method==LIBSTATDISK_IN)) output_unit=BYTES_OUT; return; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 398090, "input": "static int sctp_connect(struct sock *sk, struct sockaddr *addr, int addr_len, int flags) { struct sctp_af *af; int err = -EINVAL; lock_sock(sk); pr_debug(\"%s: sk:%p, sockaddr:%p, addr_len:%d\\n\", __func__, sk, addr, addr_len); /* Validate addr_len before calling common connect/connectx routine. */ af = sctp_get_af_specific(addr->sa_family); if (af && addr_len >= af->sockaddr_len) err = __sctp_connect(sk, addr, af->sockaddr_len, flags, NULL); release_sock(sk); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 209042, "input": "bool SFD_GetFontMetaData( FILE *sfd, char *tok, SplineFont *sf, SFD_GetFontMetaDataData* d ) { int ch; int i; KernClass* kc = 0; int old; char val[2000]; // This allows us to assume we can dereference d // at all times static SFD_GetFontMetaDataData my_static_d; static int my_static_d_is_virgin = 1; if( !d ) { if( my_static_d_is_virgin ) { my_static_d_is_virgin = 0; SFD_GetFontMetaDataData_Init( &my_static_d ); } d = &my_static_d; } if ( strmatch(tok,\"FontName:\")==0 ) { geteol(sfd,val); sf->fontname = copy(val); } else if ( strmatch(tok,\"FullName:\")==0 ) { geteol(sfd,val); sf->fullname = copy(val); } else if ( strmatch(tok,\"FamilyName:\")==0 ) { geteol(sfd,val); sf->familyname = copy(val); } else if ( strmatch(tok,\"DefaultBaseFilename:\")==0 ) { geteol(sfd,val); sf->defbasefilename = copy(val); } else if ( strmatch(tok,\"Weight:\")==0 ) { getprotectedname(sfd,val); sf->weight = copy(val); } else if ( strmatch(tok,\"Copyright:\")==0 ) { sf->copyright = getquotedeol(sfd); } else if ( strmatch(tok,\"Comments:\")==0 ) { char *temp = getquotedeol(sfd); sf->comments = latin1_2_utf8_copy(temp); free(temp); } else if ( strmatch(tok,\"UComments:\")==0 ) { sf->comments = SFDReadUTF7Str(sfd); } else if ( strmatch(tok,\"FontLog:\")==0 ) { sf->fontlog = SFDReadUTF7Str(sfd); } else if ( strmatch(tok,\"Version:\")==0 ) { geteol(sfd,val); sf->version = copy(val); } else if ( strmatch(tok,\"StyleMapFamilyName:\")==0 ) { sf->styleMapFamilyName = SFDReadUTF7Str(sfd); } /* Legacy attribute for StyleMapFamilyName. Deprecated. */ else if ( strmatch(tok,\"OS2FamilyName:\")==0 ) { if (sf->styleMapFamilyName == NULL) sf->styleMapFamilyName = SFDReadUTF7Str(sfd); } else if ( strmatch(tok,\"FONDName:\")==0 ) { geteol(sfd,val); sf->fondname = copy(val); } else if ( strmatch(tok,\"ItalicAngle:\")==0 ) { getreal(sfd,&sf->italicangle); } else if ( strmatch(tok,\"StrokeWidth:\")==0 ) { getreal(sfd,&sf->strokewidth); } else if ( strmatch(tok,\"UnderlinePosition:\")==0 ) { getreal(sfd,&sf->upos); } else if ( strmatch(tok,\"UnderlineWidth:\")==0 ) { getreal(sfd,&sf->uwidth); } else if ( strmatch(tok,\"ModificationTime:\")==0 ) { getlonglong(sfd,&sf->modificationtime); } else if ( strmatch(tok,\"CreationTime:\")==0 ) { getlonglong(sfd,&sf->creationtime); d->hadtimes = true; } else if ( strmatch(tok,\"PfmFamily:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.pfmfamily = temp; sf->pfminfo.pfmset = true; } else if ( strmatch(tok,\"LangName:\")==0 ) { sf->names = SFDGetLangName(sfd,sf->names); } else if ( strmatch(tok,\"GaspTable:\")==0 ) { SFDGetGasp(sfd,sf); } else if ( strmatch(tok,\"DesignSize:\")==0 ) { SFDGetDesignSize(sfd,sf); } else if ( strmatch(tok,\"OtfFeatName:\")==0 ) { SFDGetOtfFeatName(sfd,sf); } else if ( strmatch(tok,\"PfmWeight:\")==0 || strmatch(tok,\"TTFWeight:\")==0 ) { getsint(sfd,&sf->pfminfo.weight); sf->pfminfo.pfmset = true; } else if ( strmatch(tok,\"TTFWidth:\")==0 ) { getsint(sfd,&sf->pfminfo.width); sf->pfminfo.pfmset = true; } else if ( strmatch(tok,\"Panose:\")==0 ) { int temp,i; for ( i=0; i<10; ++i ) { getint(sfd,&temp); sf->pfminfo.panose[i] = temp; } sf->pfminfo.panose_set = true; } else if ( strmatch(tok,\"LineGap:\")==0 ) { getsint(sfd,&sf->pfminfo.linegap); sf->pfminfo.pfmset = true; } else if ( strmatch(tok,\"VLineGap:\")==0 ) { getsint(sfd,&sf->pfminfo.vlinegap); sf->pfminfo.pfmset = true; } else if ( strmatch(tok,\"HheadAscent:\")==0 ) { getsint(sfd,&sf->pfminfo.hhead_ascent); } else if ( strmatch(tok,\"HheadAOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.hheadascent_add = temp; } else if ( strmatch(tok,\"HheadDescent:\")==0 ) { getsint(sfd,&sf->pfminfo.hhead_descent); } else if ( strmatch(tok,\"HheadDOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.hheaddescent_add = temp; } else if ( strmatch(tok,\"OS2TypoLinegap:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_typolinegap); } else if ( strmatch(tok,\"OS2TypoAscent:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_typoascent); } else if ( strmatch(tok,\"OS2TypoAOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.typoascent_add = temp; } else if ( strmatch(tok,\"OS2TypoDescent:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_typodescent); } else if ( strmatch(tok,\"OS2TypoDOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.typodescent_add = temp; } else if ( strmatch(tok,\"OS2WinAscent:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_winascent); } else if ( strmatch(tok,\"OS2WinDescent:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_windescent); } else if ( strmatch(tok,\"OS2WinAOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.winascent_add = temp; } else if ( strmatch(tok,\"OS2WinDOffset:\")==0 ) { int temp; getint(sfd,&temp); sf->pfminfo.windescent_add = temp; } else if ( strmatch(tok,\"HHeadAscent:\")==0 ) { // DUPLICATE OF ABOVE getsint(sfd,&sf->pfminfo.hhead_ascent); } else if ( strmatch(tok,\"HHeadDescent:\")==0 ) { // DUPLICATE OF ABOVE getsint(sfd,&sf->pfminfo.hhead_descent); } else if ( strmatch(tok,\"HHeadAOffset:\")==0 ) { // DUPLICATE OF ABOVE int temp; getint(sfd,&temp); sf->pfminfo.hheadascent_add = temp; } else if ( strmatch(tok,\"HHeadDOffset:\")==0 ) { // DUPLICATE OF ABOVE int temp; getint(sfd,&temp); sf->pfminfo.hheaddescent_add = temp; } else if ( strmatch(tok,\"MacStyle:\")==0 ) { getsint(sfd,&sf->macstyle); } else if ( strmatch(tok,\"OS2SubXSize:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_subxsize); sf->pfminfo.subsuper_set = true; } else if ( strmatch(tok,\"OS2SubYSize:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_subysize); } else if ( strmatch(tok,\"OS2SubXOff:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_subxoff); } else if ( strmatch(tok,\"OS2SubYOff:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_subyoff); } else if ( strmatch(tok,\"OS2SupXSize:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_supxsize); } else if ( strmatch(tok,\"OS2SupYSize:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_supysize); } else if ( strmatch(tok,\"OS2SupXOff:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_supxoff); } else if ( strmatch(tok,\"OS2SupYOff:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_supyoff); } else if ( strmatch(tok,\"OS2StrikeYSize:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_strikeysize); } else if ( strmatch(tok,\"OS2StrikeYPos:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_strikeypos); } else if ( strmatch(tok,\"OS2CapHeight:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_capheight); } else if ( strmatch(tok,\"OS2XHeight:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_xheight); } else if ( strmatch(tok,\"OS2FamilyClass:\")==0 ) { getsint(sfd,&sf->pfminfo.os2_family_class); } else if ( strmatch(tok,\"OS2Vendor:\")==0 ) { while ( isspace(nlgetc(sfd))); sf->pfminfo.os2_vendor[0] = nlgetc(sfd); sf->pfminfo.os2_vendor[1] = nlgetc(sfd); sf->pfminfo.os2_vendor[2] = nlgetc(sfd); sf->pfminfo.os2_vendor[3] = nlgetc(sfd); (void) nlgetc(sfd); } else if ( strmatch(tok,\"OS2CodePages:\")==0 ) { gethexints(sfd,sf->pfminfo.codepages,2); sf->pfminfo.hascodepages = true; } else if ( strmatch(tok,\"OS2UnicodeRanges:\")==0 ) { gethexints(sfd,sf->pfminfo.unicoderanges,4); sf->pfminfo.hasunicoderanges = true; } else if ( strmatch(tok,\"TopEncoding:\")==0 ) { /* Obsolete */ getint(sfd,&sf->top_enc); } else if ( strmatch(tok,\"Ascent:\")==0 ) { getint(sfd,&sf->ascent); } else if ( strmatch(tok,\"Descent:\")==0 ) { getint(sfd,&sf->descent); } else if ( strmatch(tok,\"InvalidEm:\")==0 ) { getint(sfd,&sf->invalidem); } else if ( strmatch(tok,\"woffMajor:\")==0 ) { getint(sfd,&sf->woffMajor); } else if ( strmatch(tok,\"woffMinor:\")==0 ) { getint(sfd,&sf->woffMinor); } else if ( strmatch(tok,\"woffMetadata:\")==0 ) { sf->woffMetadata = SFDReadUTF7Str(sfd); } else if ( strmatch(tok,\"UFOAscent:\")==0 ) { getreal(sfd,&sf->ufo_ascent); } else if ( strmatch(tok,\"UFODescent:\")==0 ) { getreal(sfd,&sf->ufo_descent); } else if ( strmatch(tok,\"sfntRevision:\")==0 ) { gethex(sfd,(uint32 *)&sf->sfntRevision); } else if ( strmatch(tok,\"LayerCount:\")==0 ) { d->had_layer_cnt = true; getint(sfd,&sf->layer_cnt); if ( sf->layer_cnt>2 ) { sf->layers = realloc(sf->layers,sf->layer_cnt*sizeof(LayerInfo)); memset(sf->layers+2,0,(sf->layer_cnt-2)*sizeof(LayerInfo)); } } else if ( strmatch(tok,\"Layer:\")==0 ) { // TODO: Read the U. F. O. path. int layer, o2, bk; getint(sfd,&layer); if ( layer>=sf->layer_cnt ) { sf->layers = realloc(sf->layers,(layer+1)*sizeof(LayerInfo)); memset(sf->layers+sf->layer_cnt,0,((layer+1)-sf->layer_cnt)*sizeof(LayerInfo)); sf->layer_cnt = layer+1; } getint(sfd,&o2); sf->layers[layer].order2 = o2; sf->layers[layer].background = layer==ly_back; /* Used briefly, now background is after layer name */ while ( (ch=nlgetc(sfd))==' ' ); ungetc(ch,sfd); if ( ch!='\"' ) { getint(sfd,&bk); sf->layers[layer].background = bk; } /* end of section for obsolete format */ sf->layers[layer].name = SFDReadUTF7Str(sfd); while ( (ch=nlgetc(sfd))==' ' ); ungetc(ch,sfd); if ( ch!='\\n' ) { getint(sfd,&bk); sf->layers[layer].background = bk; } while ( (ch=nlgetc(sfd))==' ' ); ungetc(ch,sfd); if ( ch!='\\n' ) { sf->layers[layer].ufo_path = SFDReadUTF7Str(sfd); } } else if ( strmatch(tok,\"PreferredKerning:\")==0 ) { int temp; getint(sfd,&temp); sf->preferred_kerning = temp; } else if ( strmatch(tok,\"StrokedFont:\")==0 ) { int temp; getint(sfd,&temp); sf->strokedfont = temp; } else if ( strmatch(tok,\"MultiLayer:\")==0 ) { int temp; getint(sfd,&temp); sf->multilayer = temp; } else if ( strmatch(tok,\"NeedsXUIDChange:\")==0 ) { int temp; getint(sfd,&temp); sf->changed_since_xuidchanged = temp; } else if ( strmatch(tok,\"VerticalOrigin:\")==0 ) { // this doesn't seem to be written ever. int temp; getint(sfd,&temp); sf->hasvmetrics = true; } else if ( strmatch(tok,\"HasVMetrics:\")==0 ) { int temp; getint(sfd,&temp); sf->hasvmetrics = temp; } else if ( strmatch(tok,\"Justify:\")==0 ) { SFDParseJustify(sfd,sf,tok); } else if ( strmatch(tok,\"BaseHoriz:\")==0 ) { sf->horiz_base = SFDParseBase(sfd); d->last_base = sf->horiz_base; d->last_base_script = NULL; } else if ( strmatch(tok,\"BaseVert:\")==0 ) { sf->vert_base = SFDParseBase(sfd); d->last_base = sf->vert_base; d->last_base_script = NULL; } else if ( strmatch(tok,\"BaseScript:\")==0 ) { struct basescript *bs = SFDParseBaseScript(sfd,d->last_base); if ( d->last_base==NULL ) { BaseScriptFree(bs); bs = NULL; } else if ( d->last_base_script!=NULL ) d->last_base_script->next = bs; else d->last_base->scripts = bs; d->last_base_script = bs; } else if ( strmatch(tok,\"StyleMap:\")==0 ) { gethex(sfd,(uint32 *)&sf->pfminfo.stylemap); } /* Legacy attribute for StyleMap. Deprecated. */ else if ( strmatch(tok,\"OS2StyleName:\")==0 ) { char* sname = SFDReadUTF7Str(sfd); if (sf->pfminfo.stylemap == -1) { if (strcmp(sname,\"bold italic\")==0) sf->pfminfo.stylemap = 0x21; else if (strcmp(sname,\"bold\")==0) sf->pfminfo.stylemap = 0x20; else if (strcmp(sname,\"italic\")==0) sf->pfminfo.stylemap = 0x01; else if (strcmp(sname,\"regular\")==0) sf->pfminfo.stylemap = 0x40; } free(sname); } else if ( strmatch(tok,\"FSType:\")==0 ) { getsint(sfd,&sf->pfminfo.fstype); } else if ( strmatch(tok,\"OS2Version:\")==0 ) { getsint(sfd,&sf->os2_version); } else if ( strmatch(tok,\"OS2_WeightWidthSlopeOnly:\")==0 ) { int temp; getint(sfd,&temp); sf->weight_width_slope_only = temp; } else if ( strmatch(tok,\"OS2_UseTypoMetrics:\")==0 ) { int temp; getint(sfd,&temp); sf->use_typo_metrics = temp; } else if ( strmatch(tok,\"UseUniqueID:\")==0 ) { int temp; getint(sfd,&temp); sf->use_uniqueid = temp; } else if ( strmatch(tok,\"UseXUID:\")==0 ) { int temp; getint(sfd,&temp); sf->use_xuid = temp; } else if ( strmatch(tok,\"UniqueID:\")==0 ) { getint(sfd,&sf->uniqueid); } else if ( strmatch(tok,\"XUID:\")==0 ) { geteol(sfd,tok); sf->xuid = copy(tok); } else if ( strmatch(tok,\"Lookup:\")==0 ) { OTLookup *otl; int temp; if ( sf->sfd_version<2 ) { IError( \"Lookups should not happen in version 1 sfd files.\" ); exit(1); } otl = chunkalloc(sizeof(OTLookup)); getint(sfd,&temp); otl->lookup_type = temp; getint(sfd,&temp); otl->lookup_flags = temp; getint(sfd,&temp); otl->store_in_afm = temp; otl->lookup_name = SFDReadUTF7Str(sfd); if ( otl->lookup_typelastsotl==NULL ) sf->gsub_lookups = otl; else d->lastsotl->next = otl; d->lastsotl = otl; } else { if ( d->lastpotl==NULL ) sf->gpos_lookups = otl; else d->lastpotl->next = otl; d->lastpotl = otl; } SFDParseLookup(sfd,otl); } else if ( strmatch(tok,\"MarkAttachClasses:\")==0 ) { getint(sfd,&sf->mark_class_cnt); sf->mark_classes = malloc(sf->mark_class_cnt*sizeof(char *)); sf->mark_class_names = malloc(sf->mark_class_cnt*sizeof(char *)); sf->mark_classes[0] = NULL; sf->mark_class_names[0] = NULL; for ( i=1; imark_class_cnt; ++i ) { /* Class 0 is unused */ int temp; while ( (temp=nlgetc(sfd))=='\\n' || temp=='\\r' ); ungetc(temp,sfd); sf->mark_class_names[i] = SFDReadUTF7Str(sfd); getint(sfd,&temp); sf->mark_classes[i] = malloc(temp+1); sf->mark_classes[i][temp] = '\\0'; nlgetc(sfd); /* skip space */ fread(sf->mark_classes[i],1,temp,sfd); } } else if ( strmatch(tok,\"MarkAttachSets:\")==0 ) { getint(sfd,&sf->mark_set_cnt); sf->mark_sets = malloc(sf->mark_set_cnt*sizeof(char *)); sf->mark_set_names = malloc(sf->mark_set_cnt*sizeof(char *)); for ( i=0; imark_set_cnt; ++i ) { /* Set 0 is used */ int temp; while ( (temp=nlgetc(sfd))=='\\n' || temp=='\\r' ); ungetc(temp,sfd); sf->mark_set_names[i] = SFDReadUTF7Str(sfd); getint(sfd,&temp); sf->mark_sets[i] = malloc(temp+1); sf->mark_sets[i][temp] = '\\0'; nlgetc(sfd); /* skip space */ fread(sf->mark_sets[i],1,temp,sfd); } } else if ( strmatch(tok,\"KernClass2:\")==0 || strmatch(tok,\"VKernClass2:\")==0 || strmatch(tok,\"KernClass:\")==0 || strmatch(tok,\"VKernClass:\")==0 || strmatch(tok,\"KernClass3:\")==0 || strmatch(tok,\"VKernClass3:\")==0 ) { int kernclassversion = 0; int isv = tok[0]=='V'; int kcvoffset = (isv ? 10 : 9); //Offset to read kerning class version if (isdigit(tok[kcvoffset])) kernclassversion = tok[kcvoffset] - '0'; int temp, classstart=1; int old = (kernclassversion == 0); if ( (sf->sfd_version<2)!=old ) { IError( \"Version mixup in Kerning Classes of sfd file.\" ); exit(1); } kc = chunkalloc(old ? sizeof(KernClass1) : sizeof(KernClass)); getint(sfd,&kc->first_cnt); ch=nlgetc(sfd); if ( ch=='+' ) classstart = 0; else ungetc(ch,sfd); getint(sfd,&kc->second_cnt); if ( old ) { getint(sfd,&temp); ((KernClass1 *) kc)->sli = temp; getint(sfd,&temp); ((KernClass1 *) kc)->flags = temp; } else { kc->subtable = SFFindLookupSubtableAndFreeName(sf,SFDReadUTF7Str(sfd)); if ( kc->subtable!=NULL && kc->subtable->kc==NULL ) kc->subtable->kc = kc; else { if ( kc->subtable==NULL ) LogError(_(\"Bad SFD file, missing subtable in kernclass defn.\\n\") ); else LogError(_(\"Bad SFD file, two kerning classes assigned to the same subtable: %s\\n\"), kc->subtable->subtable_name ); kc->subtable = NULL; } } kc->firsts = calloc(kc->first_cnt,sizeof(char *)); kc->seconds = calloc(kc->second_cnt,sizeof(char *)); kc->offsets = calloc(kc->first_cnt*kc->second_cnt,sizeof(int16)); kc->adjusts = calloc(kc->first_cnt*kc->second_cnt,sizeof(DeviceTable)); if (kernclassversion >= 3) { kc->firsts_flags = calloc(kc->first_cnt, sizeof(int)); kc->seconds_flags = calloc(kc->second_cnt, sizeof(int)); kc->offsets_flags = calloc(kc->first_cnt*kc->second_cnt, sizeof(int)); kc->firsts_names = calloc(kc->first_cnt, sizeof(char*)); kc->seconds_names = calloc(kc->second_cnt, sizeof(char*)); } kc->firsts[0] = NULL; for ( i=classstart; ifirst_cnt; ++i ) { if (kernclassversion < 3) { getint(sfd,&temp); kc->firsts[i] = malloc(temp+1); kc->firsts[i][temp] = '\\0'; nlgetc(sfd); /* skip space */ fread(kc->firsts[i],1,temp,sfd); } else { getint(sfd,&kc->firsts_flags[i]); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\\n' || ch == EOF) continue; kc->firsts_names[i] = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\\n' || ch == EOF) continue; kc->firsts[i] = SFDReadUTF7Str(sfd); if (kc->firsts[i] == NULL) kc->firsts[i] = copy(\"\"); // In certain places, this must be defined. while ((ch=nlgetc(sfd)) == ' ' || ch == '\\n'); ungetc(ch, sfd); } } kc->seconds[0] = NULL; for ( i=1; isecond_cnt; ++i ) { if (kernclassversion < 3) { getint(sfd,&temp); kc->seconds[i] = malloc(temp+1); kc->seconds[i][temp] = '\\0'; nlgetc(sfd); /* skip space */ fread(kc->seconds[i],1,temp,sfd); } else { getint(sfd,&temp); kc->seconds_flags[i] = temp; while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\\n' || ch == EOF) continue; kc->seconds_names[i] = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\\n' || ch == EOF) continue; kc->seconds[i] = SFDReadUTF7Str(sfd); if (kc->seconds[i] == NULL) kc->seconds[i] = copy(\"\"); // In certain places, this must be defined. while ((ch=nlgetc(sfd)) == ' ' || ch == '\\n'); ungetc(ch, sfd); } } for ( i=0; ifirst_cnt*kc->second_cnt; ++i ) { if (kernclassversion >= 3) { getint(sfd,&temp); kc->offsets_flags[i] = temp; } getint(sfd,&temp); kc->offsets[i] = temp; SFDReadDeviceTable(sfd,&kc->adjusts[i]); } if ( !old && kc->subtable == NULL ) { /* Error. Ignore it. Free it. Whatever */; } else if ( !isv ) { if ( d->lastkc==NULL ) sf->kerns = kc; else d->lastkc->next = kc; d->lastkc = kc; } else { if ( d->lastvkc==NULL ) sf->vkerns = kc; else d->lastvkc->next = kc; d->lastvkc = kc; } } else if ( strmatch(tok,\"ContextPos2:\")==0 || strmatch(tok,\"ContextSub2:\")==0 || strmatch(tok,\"ChainPos2:\")==0 || strmatch(tok,\"ChainSub2:\")==0 || strmatch(tok,\"ReverseChain2:\")==0 || strmatch(tok,\"ContextPos:\")==0 || strmatch(tok,\"ContextSub:\")==0 || strmatch(tok,\"ChainPos:\")==0 || strmatch(tok,\"ChainSub:\")==0 || strmatch(tok,\"ReverseChain:\")==0 ) { FPST *fpst; int old; if ( strchr(tok,'2')!=NULL ) { old = false; fpst = chunkalloc(sizeof(FPST)); } else { old = true; fpst = chunkalloc(sizeof(FPST1)); } if ( (sf->sfd_version<2)!=old ) { IError( \"Version mixup in FPST of sfd file.\" ); exit(1); } if ( d->lastfp==NULL ) sf->possub = fpst; else d->lastfp->next = fpst; d->lastfp = fpst; SFDParseChainContext(sfd,sf,fpst,tok,old); } else if ( strmatch(tok,\"Group:\")==0 ) { struct ff_glyphclasses *grouptmp = calloc(1, sizeof(struct ff_glyphclasses)); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); grouptmp->classname = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); grouptmp->glyphs = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' ' || ch == '\\n'); ungetc(ch, sfd); if (d->lastgroup != NULL) d->lastgroup->next = grouptmp; else sf->groups = grouptmp; d->lastgroup = grouptmp; } else if ( strmatch(tok,\"GroupKern:\")==0 ) { int temp = 0; struct ff_rawoffsets *kerntmp = calloc(1, sizeof(struct ff_rawoffsets)); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); kerntmp->left = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); kerntmp->right = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); getint(sfd,&temp); kerntmp->offset = temp; while ((ch=nlgetc(sfd)) == ' ' || ch == '\\n'); ungetc(ch, sfd); if (d->lastgroupkern != NULL) d->lastgroupkern->next = kerntmp; else sf->groupkerns = kerntmp; d->lastgroupkern = kerntmp; } else if ( strmatch(tok,\"GroupVKern:\")==0 ) { int temp = 0; struct ff_rawoffsets *kerntmp = calloc(1, sizeof(struct ff_rawoffsets)); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); kerntmp->left = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); kerntmp->right = SFDReadUTF7Str(sfd); while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); getint(sfd,&temp); kerntmp->offset = temp; while ((ch=nlgetc(sfd)) == ' ' || ch == '\\n'); ungetc(ch, sfd); if (d->lastgroupvkern != NULL) d->lastgroupvkern->next = kerntmp; else sf->groupvkerns = kerntmp; d->lastgroupvkern = kerntmp; } else if ( strmatch(tok,\"MacIndic2:\")==0 || strmatch(tok,\"MacContext2:\")==0 || strmatch(tok,\"MacLigature2:\")==0 || strmatch(tok,\"MacSimple2:\")==0 || strmatch(tok,\"MacKern2:\")==0 || strmatch(tok,\"MacInsert2:\")==0 || strmatch(tok,\"MacIndic:\")==0 || strmatch(tok,\"MacContext:\")==0 || strmatch(tok,\"MacLigature:\")==0 || strmatch(tok,\"MacSimple:\")==0 || strmatch(tok,\"MacKern:\")==0 || strmatch(tok,\"MacInsert:\")==0 ) { ASM *sm; if ( strchr(tok,'2')!=NULL ) { old = false; sm = chunkalloc(sizeof(ASM)); } else { old = true; sm = chunkalloc(sizeof(ASM1)); } if ( (sf->sfd_version<2)!=old ) { IError( \"Version mixup in state machine of sfd file.\" ); exit(1); } if ( d->lastsm==NULL ) sf->sm = sm; else d->lastsm->next = sm; d->lastsm = sm; SFDParseStateMachine(sfd,sf,sm,tok,old); } else if ( strmatch(tok,\"MacFeat:\")==0 ) { sf->features = SFDParseMacFeatures(sfd,tok); } else if ( strmatch(tok,\"TtfTable:\")==0 ) { /* Old, binary format */ /* still used for maxp and unknown tables */ SFDGetTtfTable(sfd,sf,d->lastttf); } else if ( strmatch(tok,\"TtTable:\")==0 ) { /* text instruction format */ SFDGetTtTable(sfd,sf,d->lastttf); } /////////////////// else if ( strmatch(tok,\"ShortTable:\")==0 ) { // only read, not written. /* text number format */ SFDGetShortTable(sfd,sf,d->lastttf); } else { // // We didn't have a match ourselves. // return false; } return true; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Use After Free"], "explanation": "FontForge 20190801 has a use-after-free in SFD_GetFontMetaData in sfd.c.", "severity_level": "NoInfo", "cwe": "CWE-416", "cve": "CVE-2020-5395"}} -{"idx": 208176, "input": "convert( Imaging imOut, Imaging imIn, const char *mode, ImagingPalette palette, int dither) { ImagingSectionCookie cookie; ImagingShuffler convert; int y; if (!imIn) { return (Imaging)ImagingError_ModeError(); } if (!mode) { /* Map palette image to full depth */ if (!imIn->palette) { return (Imaging)ImagingError_ModeError(); } mode = imIn->palette->mode; } else { /* Same mode? */ if (!strcmp(imIn->mode, mode)) { return ImagingCopy2(imOut, imIn); } } /* test for special conversions */ if (strcmp(imIn->mode, \"P\") == 0 || strcmp(imIn->mode, \"PA\") == 0) { return frompalette(imOut, imIn, mode); } if (strcmp(mode, \"P\") == 0 || strcmp(mode, \"PA\") == 0) { return topalette(imOut, imIn, mode, palette, dither); } if (dither && strcmp(mode, \"1\") == 0) { return tobilevel(imOut, imIn, dither); } /* standard conversion machinery */ convert = NULL; for (y = 0; converters[y].from; y++) { if (!strcmp(imIn->mode, converters[y].from) && !strcmp(mode, converters[y].to)) { convert = converters[y].convert; break; } } if (!convert) { #ifdef notdef return (Imaging)ImagingError_ValueError(\"conversion not supported\"); #else static char buf[100]; sprintf(buf, \"conversion from %.10s to %.10s not supported\", imIn->mode, mode); return (Imaging)ImagingError_ValueError(buf); #endif } imOut = ImagingNew2Dirty(mode, imOut, imIn); if (!imOut) { return NULL; } ImagingSectionEnter(&cookie); for (y = 0; y < imIn->ysize; y++) { (*convert)((UINT8 *)imOut->image[y], (UINT8 *)imIn->image[y], imIn->xsize); } ImagingSectionLeave(&cookie); return imOut; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')"], "explanation": "Pillow through 8.2.0 and PIL (aka Python Imaging Library) through 1.1.7 allow an attacker to pass controlled parameters directly into a convert function to trigger a buffer overflow in Convert.c.", "severity_level": "NoInfo", "cwe": "CWE-120", "cve": "CVE-2021-34552"}} -{"idx": 336927, "input": "rb_enc_cr_str_exact_copy(VALUE dest, VALUE src) { str_enc_copy(dest, src); ENC_CODERANGE_SET(dest, ENC_CODERANGE(src)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230538, "input": "bool CLua::is_path_safe(string s, bool trusted) { lowercase(s); return s.find(\"..\") == string::npos && shell_safe(s.c_str()) // loading dlua stuff would spew tons of error messages && (trusted || s.find(\"dlua\") != 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 284264, "input": "void h2_stream_set_monitor(h2_stream *stream, h2_stream_monitor *monitor) { stream->monitor = monitor; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508573, "input": "Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, Field **default_field, bool group, bool modify_item, bool table_cant_handle_bit_fields, bool make_copy_field) { Field *result; Item::Type orig_type= type; Item *orig_item= 0; DBUG_ASSERT(thd == table->in_use); if (type != Item::FIELD_ITEM && item->real_item()->type() == Item::FIELD_ITEM) { orig_item= item; item= item->real_item(); type= Item::FIELD_ITEM; } switch (type) { case Item::TYPE_HOLDER: case Item::SUM_FUNC_ITEM: { result= item->create_tmp_field(group, table); if (!result) my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); return result; } case Item::DEFAULT_VALUE_ITEM: { Field *field= ((Item_default_value*) item)->field; if (field->default_value && (field->flags & BLOB_FLAG)) { /* We have to use a copy function when using a blob with default value as the we have to calcuate the default value before we can use it. */ return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 : copy_func), modify_item); } } /* Fall through */ case Item::FIELD_ITEM: case Item::CONTEXTUALLY_TYPED_VALUE_ITEM: case Item::INSERT_VALUE_ITEM: case Item::TRIGGER_FIELD_ITEM: { Item_field *field= (Item_field*) item; bool orig_modify= modify_item; if (orig_type == Item::REF_ITEM) modify_item= 0; /* If item have to be able to store NULLs but underlaid field can't do it, create_tmp_field_from_field() can't be used for tmp field creation. */ if (((field->maybe_null && field->in_rollup) || (thd->create_tmp_table_for_derived && /* for mat. view/dt */ orig_item && orig_item->maybe_null)) && !field->field->maybe_null()) { bool save_maybe_null= FALSE; /* The item the ref points to may have maybe_null flag set while the ref doesn't have it. This may happen for outer fields when the outer query decided at some point after name resolution phase that this field might be null. Take this into account here. */ if (orig_item) { save_maybe_null= item->maybe_null; item->maybe_null= orig_item->maybe_null; } result= create_tmp_field_from_item(thd, item, table, NULL, modify_item); *from_field= field->field; if (result && modify_item) field->result_field= result; if (orig_item) { item->maybe_null= save_maybe_null; result->field_name= orig_item->name; } } else if (table_cant_handle_bit_fields && field->field->type() == MYSQL_TYPE_BIT) { const Type_handler *handler= item->type_handler_long_or_longlong(); *from_field= field->field; if ((result= handler->make_and_init_table_field(&item->name, Record_addr(item->maybe_null), *item, table))) create_tmp_field_from_item_finalize(thd, result, item, copy_func, modify_item); if (result && modify_item) field->result_field= result; } else { LEX_CSTRING *tmp= orig_item ? &orig_item->name : &item->name; result= create_tmp_field_from_field(thd, (*from_field= field->field), tmp, table, modify_item ? field : NULL); } if (orig_type == Item::REF_ITEM && orig_modify) ((Item_ref*)orig_item)->set_result_field(result); /* Fields that are used as arguments to the DEFAULT() function already have their data pointers set to the default value during name resolution. See Item_default_value::fix_fields. */ if (orig_type != Item::DEFAULT_VALUE_ITEM && field->field->eq_def(result)) *default_field= field->field; return result; } /* Fall through */ case Item::FUNC_ITEM: if (((Item_func *) item)->functype() == Item_func::FUNC_SP) { Item_func_sp *item_func_sp= (Item_func_sp *) item; Field *sp_result_field= item_func_sp->get_sp_result_field(); if (make_copy_field) { DBUG_ASSERT(item_func_sp->result_field); *from_field= item_func_sp->result_field; } else { *((*copy_func)++)= item; } Field *result_field= create_tmp_field_from_field(thd, sp_result_field, &item_func_sp->name, table, NULL); if (modify_item) item->set_result_field(result_field); return result_field; } /* Fall through */ case Item::COND_ITEM: case Item::SUBSELECT_ITEM: case Item::REF_ITEM: case Item::EXPR_CACHE_ITEM: if (make_copy_field) { DBUG_ASSERT(((Item_result_field*)item)->result_field); *from_field= ((Item_result_field*)item)->result_field; } /* Fall through */ case Item::FIELD_AVG_ITEM: case Item::FIELD_STD_ITEM: case Item::PROC_ITEM: case Item::INT_ITEM: case Item::REAL_ITEM: case Item::DECIMAL_ITEM: case Item::STRING_ITEM: case Item::DATE_ITEM: case Item::NULL_ITEM: case Item::VARBIN_ITEM: case Item::CACHE_ITEM: case Item::WINDOW_FUNC_ITEM: // psergey-winfunc: case Item::PARAM_ITEM: return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 : copy_func), modify_item); default: // Dosen't have to be stored return 0; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354816, "input": "static inline bool kvm_dirty_log_manual_protect_and_init_set(struct kvm *kvm) { return !!(kvm->manual_dirty_log_protect & KVM_DIRTY_LOG_INITIALLY_SET); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232423, "input": "static u64 gen_hi_min(struct tnum var) { return var.value & ~0xffffffffULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 385203, "input": "tcp_sequence_number_analysis_print_zero_window(packet_info * pinfo, proto_item * flags_item, struct tcp_acked *ta ) { /* TCP Zero Window Probe */ if (ta->flags & TCP_A_ZERO_WINDOW_PROBE) { expert_add_info(pinfo, flags_item, &ei_tcp_analysis_zero_window_probe); col_prepend_fence_fstr(pinfo->cinfo, COL_INFO, \"[TCP ZeroWindowProbe] \"); } /* TCP Zero Window */ if (ta->flags&TCP_A_ZERO_WINDOW) { expert_add_info(pinfo, flags_item, &ei_tcp_analysis_zero_window); col_prepend_fence_fstr(pinfo->cinfo, COL_INFO, \"[TCP ZeroWindow] \"); } /* TCP Zero Window Probe Ack */ if (ta->flags & TCP_A_ZERO_WINDOW_PROBE_ACK) { expert_add_info(pinfo, flags_item, &ei_tcp_analysis_zero_window_probe_ack); col_prepend_fence_fstr(pinfo->cinfo, COL_INFO, \"[TCP ZeroWindowProbeAck] \"); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 211591, "input": "PJ_DEF(pj_status_t) pjmedia_sdp_neg_modify_local_offer2( pj_pool_t *pool, pjmedia_sdp_neg *neg, unsigned flags, const pjmedia_sdp_session *local) { pjmedia_sdp_session *new_offer; pjmedia_sdp_session *old_offer; char media_used[PJMEDIA_MAX_SDP_MEDIA]; unsigned oi; /* old offer media index */ pj_status_t status; /* Check arguments are valid. */ PJ_ASSERT_RETURN(pool && neg && local, PJ_EINVAL); /* Can only do this in STATE_DONE. */ PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_DONE, PJMEDIA_SDPNEG_EINSTATE); /* Validate the new offer */ status = pjmedia_sdp_validate(local); if (status != PJ_SUCCESS) return status; /* Change state to STATE_LOCAL_OFFER */ neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER; /* Init vars */ pj_bzero(media_used, sizeof(media_used)); old_offer = neg->active_local_sdp; new_offer = pjmedia_sdp_session_clone(pool, local); /* RFC 3264 Section 8: When issuing an offer that modifies the session, * the \"o=\" line of the new SDP MUST be identical to that in the * previous SDP, except that the version in the origin field MUST * increment by one from the previous SDP. */ pj_strdup(pool, &new_offer->origin.user, &old_offer->origin.user); new_offer->origin.id = old_offer->origin.id; pj_strdup(pool, &new_offer->origin.net_type, &old_offer->origin.net_type); pj_strdup(pool, &new_offer->origin.addr_type,&old_offer->origin.addr_type); pj_strdup(pool, &new_offer->origin.addr, &old_offer->origin.addr); if ((flags & PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE) == 0) { /* Generating the new offer, in the case media lines doesn't match the * active SDP (e.g. current/active SDP's have m=audio and m=video lines, * and the new offer only has m=audio line), the negotiator will fix * the new offer by reordering and adding the missing media line with * port number set to zero. */ for (oi = 0; oi < old_offer->media_count; ++oi) { pjmedia_sdp_media *om; pjmedia_sdp_media *nm; unsigned ni; /* new offer media index */ pj_bool_t found = PJ_FALSE; om = old_offer->media[oi]; for (ni = oi; ni < new_offer->media_count; ++ni) { nm = new_offer->media[ni]; if (pj_strcmp(&nm->desc.media, &om->desc.media) == 0) { if (ni != oi) { /* The same media found but the position unmatched to * the old offer, so let's put this media in the right * place, and keep the order of the rest. */ pj_array_insert( new_offer->media, /* array */ sizeof(new_offer->media[0]), /* elmt size*/ ni, /* count */ oi, /* pos */ &nm); /* new elmt */ } found = PJ_TRUE; break; } } if (!found) { pjmedia_sdp_media *m; m = sdp_media_clone_deactivate(pool, om, om, local); pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), new_offer->media_count++, oi, &m); } } } else { /* If media type change is allowed, the negotiator only needs to fix * the new offer by adding the missing media line(s) with port number * set to zero. */ for (oi = new_offer->media_count; oi < old_offer->media_count; ++oi) { pjmedia_sdp_media *m; m = sdp_media_clone_deactivate(pool, old_offer->media[oi], old_offer->media[oi], local); pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), new_offer->media_count++, oi, &m); } } /* New_offer fixed */ #if PJMEDIA_SDP_NEG_COMPARE_BEFORE_INC_VERSION new_offer->origin.version = old_offer->origin.version; if (pjmedia_sdp_session_cmp(new_offer, neg->initial_sdp, 0) != PJ_SUCCESS) { ++new_offer->origin.version; } #else new_offer->origin.version = old_offer->origin.version + 1; #endif neg->initial_sdp_tmp = neg->initial_sdp; neg->initial_sdp = new_offer; neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, new_offer); return PJ_SUCCESS; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In PJSIP version 2.10 and earlier, after an initial INVITE has been sent, when two 183 responses are received, with the first one causing negotiation failure, a crash will occur. This results in a denial of service.", "severity_level": "NoInfo", "cwe": "CWE-200", "cve": "CVE-2021-21375"}} -{"idx": 197832, "input": "void *UntrustedCacheMalloc::GetBuffer() { void **buffers = nullptr; void *buffer; bool is_pool_empty; { LockGuard spin_lock(&lock_); is_pool_empty = buffer_pool_.empty(); if (is_pool_empty) { buffers = primitives::AllocateUntrustedBuffers(kPoolIncrement, kPoolEntrySize); for (int i = 0; i < kPoolIncrement; i++) { if (!buffers[i] || !TrustedPrimitives::IsOutsideEnclave(buffers[i], kPoolEntrySize)) { abort(); } buffer_pool_.push(buffers[i]); } } buffer = buffer_pool_.top(); buffer_pool_.pop(); busy_buffers_.insert(buffer); } if (is_pool_empty) { // Free memory held by the array of buffer pointers returned by // AllocateUntrustedBuffers. Free(buffers); } return buffer; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "An attacker can modify the pointers in enclave memory to overwrite arbitrary memory addresses within the secure enclave. It is recommended to update past 0.6.3 or git commit https://github.com/google/asylo/commit/a47ef55db2337d29de19c50cd29b0deb2871d31c", "severity_level": "NoInfo", "cwe": "CWE-200", "cve": "CVE-2021-22550"}} -{"idx": 306287, "input": "static void i2c_w_mask(struct sd *sd, u8 reg, u8 value, u8 mask) { int rc; u8 oldval; value &= mask; /* Enforce mask on value */ rc = i2c_r(sd, reg); if (rc < 0) return; oldval = rc & ~mask; /* Clear the masked bits */ value |= oldval; /* Set the desired bits */ i2c_w(sd, reg, value); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 116225, "input": "void SpeechSynthesis::resume() { if (!currentSpeechUtterance()) return; m_platformSpeechSynthesizer->resume(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 491968, "input": "void apply_mask(char *perm, const char *mask) { while (*perm) { if (*mask == '-' && *perm >= 'a' && *perm <= 'z') *perm = *perm - 'a' + 'A'; perm++; if (*mask) mask++; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334466, "input": "find_method_in_class (MonoClass *klass, const char *name, const char *qname, const char *fqname, MonoMethodSignature *sig, MonoClass *from_class) { int i; /* Search directly in the metadata to avoid calling setup_methods () */ /* FIXME: !from_class->generic_class condition causes test failures. */ if (klass->type_token && !klass->image->dynamic && !klass->methods && !klass->rank && klass == from_class && !from_class->generic_class) { for (i = 0; i < klass->method.count; ++i) { guint32 cols [MONO_METHOD_SIZE]; MonoMethod *method; const char *m_name; MonoMethodSignature *other_sig; mono_metadata_decode_table_row (klass->image, MONO_TABLE_METHOD, klass->method.first + i, cols, MONO_METHOD_SIZE); m_name = mono_metadata_string_heap (klass->image, cols [MONO_METHOD_NAME]); if (!((fqname && !strcmp (m_name, fqname)) || (qname && !strcmp (m_name, qname)) || (name && !strcmp (m_name, name)))) continue; method = mono_get_method (klass->image, MONO_TOKEN_METHOD_DEF | (klass->method.first + i + 1), klass); other_sig = mono_method_signature (method); if (method && other_sig && (sig->call_convention != MONO_CALL_VARARG) && mono_metadata_signature_equal (sig, other_sig)) return method; } } mono_class_setup_methods (klass); /* We can't fail lookup of methods otherwise the runtime will fail with MissingMethodException instead of TypeLoadException. See mono/tests/generic-type-load-exception.2.il FIXME we should better report this error to the caller */ if (!klass->methods) return NULL; for (i = 0; i < klass->method.count; ++i) { MonoMethod *m = klass->methods [i]; MonoMethodSignature *msig; if (!((fqname && !strcmp (m->name, fqname)) || (qname && !strcmp (m->name, qname)) || (name && !strcmp (m->name, name)))) continue; msig = mono_method_signature (m); if (!msig) continue; if (sig->call_convention == MONO_CALL_VARARG) { if (mono_metadata_signature_vararg_match (sig, msig)) break; } else { if (mono_metadata_signature_equal (sig, msig)) break; } } if (i < klass->method.count) return mono_class_get_method_by_index (from_class, i); return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 90056, "input": "std::unique_ptr ClipboardReader::Create( const String& mime_type) { if (mime_type == kMimeTypeImagePng) return std::make_unique(); if (mime_type == kMimeTypeTextPlain) return std::make_unique(); return nullptr; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 408521, "input": "static void msf2_emac_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = msf2_emac_realize; dc->reset = msf2_emac_reset; dc->vmsd = &vmstate_msf2_emac; device_class_set_props(dc, msf2_emac_properties); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 498303, "input": "url_unescape (char *s) { url_unescape_1 (s, 0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506598, "input": "parse_term_size( float *xsize, float *ysize, size_units default_units ) { size_units units = default_units; if (END_OF_COMMAND) int_error(c_token, \"size requires two numbers: xsize, ysize\"); *xsize = real_expression(); if (almost_equals(c_token,\"in$ches\")) { c_token++; units = INCHES; } else if (equals(c_token,\"cm\")) { c_token++; units = CM; } switch (units) { case INCHES: *xsize *= gp_resolution; break; case CM: *xsize *= (float)gp_resolution / 2.54; break; case PIXELS: default: break; } if (!equals(c_token++,\",\")) int_error(c_token, \"size requires two numbers: xsize, ysize\"); *ysize = real_expression(); if (almost_equals(c_token,\"in$ches\")) { c_token++; units = INCHES; } else if (equals(c_token,\"cm\")) { c_token++; units = CM; } switch (units) { case INCHES: *ysize *= gp_resolution; break; case CM: *ysize *= (float)gp_resolution / 2.54; break; case PIXELS: default: break; } if (*xsize < 1 || *ysize < 1) int_error(c_token, \"size: out of range\"); return units; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508945, "input": "virtual bool exists2in_processor(void *arg) { return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281256, "input": "static void dump_usage_categories_info(Formatter *formatter, const rgw_usage_log_entry& entry, map *categories) { formatter->open_array_section(\"categories\"); map::const_iterator uiter; for (uiter = entry.usage_map.begin(); uiter != entry.usage_map.end(); ++uiter) { if (categories && !categories->empty() && !categories->count(uiter->first)) continue; const rgw_usage_data& usage = uiter->second; formatter->open_object_section(\"Entry\"); formatter->dump_string(\"Category\", uiter->first); formatter->dump_int(\"BytesSent\", usage.bytes_sent); formatter->dump_int(\"BytesReceived\", usage.bytes_received); formatter->dump_int(\"Ops\", usage.ops); formatter->dump_int(\"SuccessfulOps\", usage.successful_ops); formatter->close_section(); // Entry } formatter->close_section(); // Category }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431905, "input": "static void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_remote_features *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG(\"%s status 0x%2.2x\", hdev->name, ev->status); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); if (!conn) goto unlock; if (!ev->status) memcpy(conn->features[0], ev->features, 8); if (conn->state != BT_CONFIG) goto unlock; if (!ev->status && lmp_ext_feat_capable(hdev) && lmp_ext_feat_capable(conn)) { struct hci_cp_read_remote_ext_features cp; cp.handle = ev->handle; cp.page = 0x01; hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES, sizeof(cp), &cp); goto unlock; } if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { struct hci_cp_remote_name_req cp; memset(&cp, 0, sizeof(cp)); bacpy(&cp.bdaddr, &conn->dst); cp.pscan_rep_mode = 0x02; hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, conn, 0, NULL, 0); if (!hci_outgoing_auth_needed(hdev, conn)) { conn->state = BT_CONNECTED; hci_connect_cfm(conn, ev->status); hci_conn_drop(conn); } unlock: hci_dev_unlock(hdev); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 201363, "input": "rpmRC hdrblobInit(const void *uh, size_t uc, rpmTagVal regionTag, int exact_size, struct hdrblob_s *blob, char **emsg) { rpmRC rc = RPMRC_FAIL; memset(blob, 0, sizeof(*blob)); blob->ei = (int32_t *) uh; /* discards const */ blob->il = ntohl(blob->ei[0]); blob->dl = ntohl(blob->ei[1]); blob->pe = (entryInfo) &(blob->ei[2]); blob->pvlen = sizeof(blob->il) + sizeof(blob->dl) + (blob->il * sizeof(*blob->pe)) + blob->dl; blob->dataStart = (uint8_t *) (blob->pe + blob->il); blob->dataEnd = blob->dataStart + blob->dl; /* Is the blob the right size? */ if (blob->pvlen >= headerMaxbytes || (uc && blob->pvlen != uc)) { rasprintf(emsg, _(\"blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\"), blob->pvlen, blob->il, blob->dl); goto exit; } if (hdrblobVerifyRegion(regionTag, exact_size, blob, emsg) == RPMRC_FAIL) goto exit; /* Sanity check the rest of the header structure. */ if (hdrblobVerifyInfo(blob, emsg)) goto exit; rc = RPMRC_OK; exit: return rc; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "A flaw was found in RPM's hdrblobInit() in lib/header.c. This flaw allows an attacker who can modify the rpmdb to cause an out-of-bounds read. The highest threat from this vulnerability is to system availability.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2021-20266"}} -{"idx": 404068, "input": "void kvm_vcpu_block(struct kvm_vcpu *vcpu) { ktime_t start, cur, poll_end; bool waited = false; u64 block_ns; kvm_arch_vcpu_blocking(vcpu); start = cur = poll_end = ktime_get(); if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) { ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); ++vcpu->stat.halt_attempted_poll; do { /* * This sets KVM_REQ_UNHALT if an interrupt * arrives. */ if (kvm_vcpu_check_block(vcpu) < 0) { ++vcpu->stat.halt_successful_poll; if (!vcpu_valid_wakeup(vcpu)) ++vcpu->stat.halt_poll_invalid; goto out; } poll_end = cur = ktime_get(); } while (kvm_vcpu_can_poll(cur, stop)); } prepare_to_rcuwait(&vcpu->wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (kvm_vcpu_check_block(vcpu) < 0) break; waited = true; schedule(); } finish_rcuwait(&vcpu->wait); cur = ktime_get(); out: kvm_arch_vcpu_unblocking(vcpu); block_ns = ktime_to_ns(cur) - ktime_to_ns(start); update_halt_poll_stats( vcpu, ktime_to_ns(ktime_sub(poll_end, start)), waited); if (!kvm_arch_no_poll(vcpu)) { if (!vcpu_valid_wakeup(vcpu)) { shrink_halt_poll_ns(vcpu); } else if (vcpu->kvm->max_halt_poll_ns) { if (block_ns <= vcpu->halt_poll_ns) ; /* we had a long block, shrink polling */ else if (vcpu->halt_poll_ns && block_ns > vcpu->kvm->max_halt_poll_ns) shrink_halt_poll_ns(vcpu); /* we had a short halt and our poll time is too small */ else if (vcpu->halt_poll_ns < vcpu->kvm->max_halt_poll_ns && block_ns < vcpu->kvm->max_halt_poll_ns) grow_halt_poll_ns(vcpu); } else { vcpu->halt_poll_ns = 0; } } trace_kvm_vcpu_wakeup(block_ns, waited, vcpu_valid_wakeup(vcpu)); kvm_arch_vcpu_block_finish(vcpu); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 373810, "input": "DequeueConsumableElements(qqueue_t *pThis, wti_t *pWti, int *piRemainingQueueSize) { int nDequeued; int nDiscarded; int nDeleted; int iQueueSize; void *pUsr; rsRetVal localRet; DEFiRet; nDeleted = pWti->batch.nElemDeq; DeleteProcessedBatch(pThis, &pWti->batch); nDequeued = nDiscarded = 0; while((iQueueSize = getLogicalQueueSize(pThis)) > 0 && nDequeued < pThis->iDeqBatchSize) { CHKiRet(qqueueDeq(pThis, &pUsr)); /* check if we should discard this element */ localRet = qqueueChkDiscardMsg(pThis, pThis->iQueueSize, pUsr); if(localRet == RS_RET_QUEUE_FULL) { ++nDiscarded; continue; } else if(localRet != RS_RET_OK) { ABORT_FINALIZE(localRet); } /* all well, use this element */ pWti->batch.pElem[nDequeued].pUsrp = pUsr; pWti->batch.pElem[nDequeued].state = BATCH_STATE_RDY; pWti->batch.pElem[nDequeued].bFilterOK = 1; // TODO: think again if we can handle that with more performance ++nDequeued; } /* it is sufficient to persist only when the bulk of work is done */ qqueueChkPersist(pThis, nDequeued+nDiscarded+nDeleted); pWti->batch.nElem = nDequeued; pWti->batch.nElemDeq = nDequeued + nDiscarded; pWti->batch.deqID = getNextDeqID(pThis); *piRemainingQueueSize = iQueueSize; finalize_it: RETiRet; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 318254, "input": "int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, struct nlmsghdr **answer) { return __rtnl_talk(rtnl, n, answer, true, NULL); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 267187, "input": "GF_Err gf_isom_change_generic_sample_description(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, GF_GenericSampleDescription *udesc) { GF_TrackBox *trak; GF_Err e; GF_GenericVisualSampleEntryBox *entry; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !StreamDescriptionIndex) return GF_BAD_PARAM; entry = (GF_GenericVisualSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, StreamDescriptionIndex-1); if (!entry) return GF_BAD_PARAM; if (entry->type == GF_ISOM_BOX_TYPE_GNRV) { entry->vendor = udesc->vendor_code; entry->version = udesc->version; entry->revision = udesc->revision; entry->temporal_quality = udesc->temporal_quality; entry->spatial_quality = udesc->spatial_quality; entry->Width = udesc->width; entry->Height = udesc->height; strcpy(entry->compressor_name, udesc->compressor_name); entry->color_table_index = -1; entry->frames_per_sample = 1; entry->horiz_res = udesc->h_res ? udesc->h_res : 0x00480000; entry->vert_res = udesc->v_res ? udesc->v_res : 0x00480000; entry->bit_depth = udesc->depth ? udesc->depth : 0x18; if (entry->data) gf_free(entry->data); entry->data = NULL; entry->data_size = 0; if (udesc->extension_buf && udesc->extension_buf_size) { entry->data = (char*)gf_malloc(sizeof(char) * udesc->extension_buf_size); if (!entry->data) { gf_isom_box_del((GF_Box *) entry); return GF_OUT_OF_MEM; } memcpy(entry->data, udesc->extension_buf, udesc->extension_buf_size); entry->data_size = udesc->extension_buf_size; } return GF_OK; } else if (entry->type == GF_ISOM_BOX_TYPE_GNRA) { GF_GenericAudioSampleEntryBox *gena = (GF_GenericAudioSampleEntryBox *)entry; gena->vendor = udesc->vendor_code; gena->version = udesc->version; gena->revision = udesc->revision; gena->bitspersample = udesc->bits_per_sample ? udesc->bits_per_sample : 16; gena->channel_count = udesc->nb_channels ? udesc->nb_channels : 2; gena->samplerate_hi = udesc->samplerate; gena->samplerate_lo = 0; if (gena->data) gf_free(gena->data); gena->data = NULL; gena->data_size = 0; if (udesc->extension_buf && udesc->extension_buf_size) { gena->data = (char*)gf_malloc(sizeof(char) * udesc->extension_buf_size); if (!gena->data) { gf_isom_box_del((GF_Box *) gena); return GF_OUT_OF_MEM; } memcpy(gena->data, udesc->extension_buf, udesc->extension_buf_size); gena->data_size = udesc->extension_buf_size; } return GF_OK; } else if (entry->type == GF_ISOM_BOX_TYPE_GNRM) { GF_GenericSampleEntryBox *genm = (GF_GenericSampleEntryBox *)entry; if (genm->data) gf_free(genm->data); genm->data = NULL; genm->data_size = 0; if (udesc->extension_buf && udesc->extension_buf_size) { genm->data = (char*)gf_malloc(sizeof(char) * udesc->extension_buf_size); if (!genm->data) { gf_isom_box_del((GF_Box *) genm); return GF_OUT_OF_MEM; } memcpy(genm->data, udesc->extension_buf, udesc->extension_buf_size); genm->data_size = udesc->extension_buf_size; } return GF_OK; } return GF_BAD_PARAM; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 378527, "input": "int sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){ VdbeCursor *p = *pp; assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO ); if( p->deferredMoveto ){ int iMap; if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 ){ *pp = p->pAltCursor; *piCol = iMap - 1; return SQLITE_OK; } return handleDeferredMoveto(p); } if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){ return handleMovedCursor(p); } return SQLITE_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 380803, "input": "static void vgacon_clear(struct vc_data *vc, int sy, int sx, int height, int width) { }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 364169, "input": "static unsigned long deferred_split_scan(struct shrinker *shrink, struct shrink_control *sc) { struct pglist_data *pgdata = NODE_DATA(sc->nid); struct deferred_split *ds_queue = &pgdata->deferred_split_queue; unsigned long flags; LIST_HEAD(list), *pos, *next; struct page *page; int split = 0; #ifdef CONFIG_MEMCG if (sc->memcg) ds_queue = &sc->memcg->deferred_split_queue; #endif spin_lock_irqsave(&ds_queue->split_queue_lock, flags); /* Take pin on all head pages to avoid freeing them under us */ list_for_each_safe(pos, next, &ds_queue->split_queue) { page = list_entry((void *)pos, struct page, mapping); page = compound_head(page); if (get_page_unless_zero(page)) { list_move(page_deferred_list(page), &list); } else { /* We lost race with put_compound_page() */ list_del_init(page_deferred_list(page)); ds_queue->split_queue_len--; } if (!--sc->nr_to_scan) break; } spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); list_for_each_safe(pos, next, &list) { page = list_entry((void *)pos, struct page, mapping); if (!trylock_page(page)) goto next; /* split_huge_page() removes page from list on success */ if (!split_huge_page(page)) split++; unlock_page(page); next: put_page(page); } spin_lock_irqsave(&ds_queue->split_queue_lock, flags); list_splice_tail(&list, &ds_queue->split_queue); spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); /* * Stop shrinker if we didn't split any page, but the queue is empty. * This can happen if pages were freed under us. */ if (!split && list_empty(&ds_queue->split_queue)) return SHRINK_STOP; return split; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 299204, "input": "xmlParseContent(xmlParserCtxtPtr ctxt) { GROW; while ((RAW != 0) && ((RAW != '<') || (NXT(1) != '/')) && (ctxt->instate != XML_PARSER_EOF)) { const xmlChar *test = CUR_PTR; unsigned int cons = ctxt->input->consumed; const xmlChar *cur = ctxt->input->cur; /* * First case : a Processing Instruction. */ if ((*cur == '<') && (cur[1] == '?')) { xmlParsePI(ctxt); } /* * Second case : a CDSection */ /* 2.6.0 test was *cur not RAW */ else if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) { xmlParseCDSect(ctxt); } /* * Third case : a comment */ else if ((*cur == '<') && (NXT(1) == '!') && (NXT(2) == '-') && (NXT(3) == '-')) { xmlParseComment(ctxt); ctxt->instate = XML_PARSER_CONTENT; } /* * Fourth case : a sub-element. */ else if (*cur == '<') { xmlParseElement(ctxt); } /* * Fifth case : a reference. If if has not been resolved, * parsing returns it's Name, create the node */ else if (*cur == '&') { xmlParseReference(ctxt); } /* * Last case, text. Note that References are handled directly. */ else { xmlParseCharData(ctxt, 0); } GROW; SHRINK; if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) { xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, \"detected an error in element content\\n\"); xmlHaltParser(ctxt); break; } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 212892, "input": "int luaG_traceexec (lua_State *L, const Instruction *pc) { CallInfo *ci = L->ci; lu_byte mask = L->hookmask; int counthook; if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) { /* no hooks? */ ci->u.l.trap = 0; /* don't need to stop again */ return 0; /* turn off 'trap' */ } pc++; /* reference is always next instruction */ ci->u.l.savedpc = pc; /* save 'pc' */ counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT)); if (counthook) resethookcount(L); /* reset count */ else if (!(mask & LUA_MASKLINE)) return 1; /* no line hook and count != 0; nothing to be done now */ if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ return 1; /* do not call hook again (VM yielded, so it did not move) */ } if (!isIT(*(ci->u.l.savedpc - 1))) L->top = ci->top; /* prepare top */ if (counthook) luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ if (mask & LUA_MASKLINE) { const Proto *p = ci_func(ci)->p; int npci = pcRel(pc, p); if (npci == 0 || /* call linehook when enter a new function, */ pc <= L->oldpc || /* when jump back (loop), or when */ changedline(p, pcRel(L->oldpc, p), npci)) { /* enter new line */ int newline = luaG_getfuncline(p, npci); luaD_hook(L, LUA_HOOKLINE, newline, 0, 0); /* call line hook */ } L->oldpc = pc; /* 'pc' of last call to line hook */ } if (L->status == LUA_YIELD) { /* did hook yield? */ if (counthook) L->hookcount = 1; /* undo decrement to zero */ ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ luaD_throw(L, LUA_YIELD); } return 1; /* keep 'trap' on */ }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "Lua through 5.4.0 has a segmentation fault in changedline in ldebug.c (e.g., when called by luaG_traceexec) because it incorrectly expects that an oldpc value is always updated upon a return of the flow of control to a function.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2020-15945"}} -{"idx": 381904, "input": "static int oidc_authorization_response_error(request_rec *r, oidc_cfg *c, oidc_proto_state_t *proto_state, const char *error, const char *error_description) { const char *prompt = oidc_proto_state_get_prompt(proto_state); if (prompt != NULL) prompt = apr_pstrdup(r->pool, prompt); oidc_proto_state_destroy(proto_state); if ((prompt != NULL) && (apr_strnatcmp(prompt, OIDC_PROTO_PROMPT_NONE) == 0)) { return oidc_session_redirect_parent_window_to_logout(r, c); } return oidc_util_html_send_error(r, c->error_template, apr_psprintf(r->pool, \"OpenID Connect Provider error: %s\", error), error_description, OK); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 199916, "input": "static int may_create_in_sticky(struct dentry * const dir, struct inode * const inode) { if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) || (!sysctl_protected_regular && S_ISREG(inode->i_mode)) || likely(!(dir->d_inode->i_mode & S_ISVTX)) || uid_eq(inode->i_uid, dir->d_inode->i_uid) || uid_eq(current_fsuid(), inode->i_uid)) return 0; if (likely(dir->d_inode->i_mode & 0002) || (dir->d_inode->i_mode & 0020 && ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) || (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) { const char *operation = S_ISFIFO(inode->i_mode) ? \"sticky_create_fifo\" : \"sticky_create_regular\"; audit_log_path_denied(AUDIT_ANOM_CREAT, operation); return -EACCES; } return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Access Control"], "explanation": "fs/namei.c in the Linux kernel before 5.5 has a may_create_in_sticky use-after-free, which allows local users to cause a denial of service (OOPS) or possibly obtain sensitive information from kernel memory, aka CID-d0cb50185ae9. One attack vector may be an open system call for a UNIX domain socket, if the socket is being moved to a new parent directory and its old parent directory is being removed.", "severity_level": "NoInfo", "cwe": "CWE-284", "cve": "CVE-2020-8428"}} -{"idx": 341935, "input": "static inline int register_fuseblk(void) { return register_filesystem(&fuseblk_fs_type); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 410413, "input": "int mnt_optstr_get_option(const char *optstr, const char *name, char **value, size_t *valsz) { struct libmnt_optloc ol = MNT_INIT_OPTLOC; int rc; if (!optstr || !name) return -EINVAL; rc = mnt_optstr_locate_option((char *) optstr, name, &ol); if (!rc) { if (value) *value = ol.value; if (valsz) *valsz = ol.valsz; } return rc; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417887, "input": "static struct ttflangname *SFDGetLangName(FILE *sfd,struct ttflangname *old) { struct ttflangname *cur = chunkalloc(sizeof(struct ttflangname)), *prev; int i; getint(sfd,&cur->lang); for ( i=0; inames[i] = SFDReadUTF7Str(sfd); if ( old==NULL ) return( cur ); for ( prev = old; prev->next !=NULL; prev = prev->next ); prev->next = cur; return( old ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 277992, "input": "ins_compl_add_list(list_T *list) { listitem_T *li; int dir = compl_direction; // Go through the List with matches and add each of them. CHECK_LIST_MATERIALIZE(list); FOR_ALL_LIST_ITEMS(list, li) { if (ins_compl_add_tv(&li->li_tv, dir, TRUE) == OK) // if dir was BACKWARD then honor it just once dir = FORWARD; else if (did_emsg) break; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 389363, "input": "printer_req_alloc(struct usb_ep *ep, unsigned len, gfp_t gfp_flags) { struct usb_request *req; req = usb_ep_alloc_request(ep, gfp_flags); if (req != NULL) { req->length = len; req->buf = kmalloc(len, gfp_flags); if (req->buf == NULL) { usb_ep_free_request(ep, req); return NULL; } } return req; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280525, "input": "parse_SET_IP_TTL(char *arg, const struct ofpact_parse_params *pp) { uint8_t ttl; char *error; error = str_to_u8(arg, \"TTL\", &ttl); if (error) { return error; } ofpact_put_SET_IP_TTL(pp->ofpacts)->ttl = ttl; return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246794, "input": "GF_EXPORT Bool gf_isom_is_smooth_streaming_moov(GF_ISOFile *the_file) { return the_file ? the_file->is_smooth : GF_FALSE;", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 357390, "input": "static OPJ_BOOL opj_j2k_read_coc(opj_j2k_t *p_j2k, OPJ_BYTE * p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t * p_manager ) { opj_cp_t *l_cp = NULL; opj_tcp_t *l_tcp = NULL; opj_image_t *l_image = NULL; OPJ_UINT32 l_comp_room; OPJ_UINT32 l_comp_no; /* preconditions */ assert(p_header_data != 00); assert(p_j2k != 00); assert(p_manager != 00); l_cp = &(p_j2k->m_cp); l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp; l_image = p_j2k->m_private_image; l_comp_room = l_image->numcomps <= 256 ? 1 : 2; /* make sure room is sufficient*/ if (p_header_size < l_comp_room + 1) { opj_event_msg(p_manager, EVT_ERROR, \"Error reading COC marker\\n\"); return OPJ_FALSE; } p_header_size -= l_comp_room + 1; opj_read_bytes(p_header_data, &l_comp_no, l_comp_room); /* Ccoc */ p_header_data += l_comp_room; if (l_comp_no >= l_image->numcomps) { opj_event_msg(p_manager, EVT_ERROR, \"Error reading COC marker (bad number of components)\\n\"); return OPJ_FALSE; } opj_read_bytes(p_header_data, &l_tcp->tccps[l_comp_no].csty, 1); /* Scoc */ ++p_header_data ; if (! opj_j2k_read_SPCod_SPCoc(p_j2k, l_comp_no, p_header_data, &p_header_size, p_manager)) { opj_event_msg(p_manager, EVT_ERROR, \"Error reading COC marker\\n\"); return OPJ_FALSE; } if (p_header_size != 0) { opj_event_msg(p_manager, EVT_ERROR, \"Error reading COC marker\\n\"); return OPJ_FALSE; } return OPJ_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431016, "input": "static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, struct file_lock *fl, int err) { switch (err) { default: printk(KERN_ERR \"NFS: %s: unhandled error \" \"%d.\\n\", __func__, err); case 0: case -ENOENT: case -EAGAIN: case -ESTALE: case -ETIMEDOUT: break; case -NFS4ERR_BADSESSION: case -NFS4ERR_BADSLOT: case -NFS4ERR_BAD_HIGH_SLOT: case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: case -NFS4ERR_DEADSESSION: return -EAGAIN; case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_STALE_STATEID: /* Don't recall a delegation if it was lost */ nfs4_schedule_lease_recovery(server->nfs_client); return -EAGAIN; case -NFS4ERR_MOVED: nfs4_schedule_migration_recovery(server); return -EAGAIN; case -NFS4ERR_LEASE_MOVED: nfs4_schedule_lease_moved_recovery(server->nfs_client); return -EAGAIN; case -NFS4ERR_DELEG_REVOKED: case -NFS4ERR_ADMIN_REVOKED: case -NFS4ERR_EXPIRED: case -NFS4ERR_BAD_STATEID: case -NFS4ERR_OPENMODE: nfs_inode_find_state_and_recover(state->inode, stateid); nfs4_schedule_stateid_recovery(server, state); return -EAGAIN; case -NFS4ERR_DELAY: case -NFS4ERR_GRACE: ssleep(1); return -EAGAIN; case -ENOMEM: case -NFS4ERR_DENIED: if (fl) { struct nfs4_lock_state *lsp = fl->fl_u.nfs4_fl.owner; if (lsp) set_bit(NFS_LOCK_LOST, &lsp->ls_flags); } return 0; } return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 214425, "input": "static void slc_bump(struct slcan *sl) { struct sk_buff *skb; struct can_frame cf; int i, tmp; u32 tmpid; char *cmd = sl->rbuff; cf.can_id = 0; switch (*cmd) { case 'r': cf.can_id = CAN_RTR_FLAG; /* fallthrough */ case 't': /* store dlc ASCII value and terminate SFF CAN ID string */ cf.can_dlc = sl->rbuff[SLC_CMD_LEN + SLC_SFF_ID_LEN]; sl->rbuff[SLC_CMD_LEN + SLC_SFF_ID_LEN] = 0; /* point to payload data behind the dlc */ cmd += SLC_CMD_LEN + SLC_SFF_ID_LEN + 1; break; case 'R': cf.can_id = CAN_RTR_FLAG; /* fallthrough */ case 'T': cf.can_id |= CAN_EFF_FLAG; /* store dlc ASCII value and terminate EFF CAN ID string */ cf.can_dlc = sl->rbuff[SLC_CMD_LEN + SLC_EFF_ID_LEN]; sl->rbuff[SLC_CMD_LEN + SLC_EFF_ID_LEN] = 0; /* point to payload data behind the dlc */ cmd += SLC_CMD_LEN + SLC_EFF_ID_LEN + 1; break; default: return; } if (kstrtou32(sl->rbuff + SLC_CMD_LEN, 16, &tmpid)) return; cf.can_id |= tmpid; /* get can_dlc from sanitized ASCII value */ if (cf.can_dlc >= '0' && cf.can_dlc < '9') cf.can_dlc -= '0'; else return; *(u64 *) (&cf.data) = 0; /* clear payload */ /* RTR frames may have a dlc > 0 but they never have any data bytes */ if (!(cf.can_id & CAN_RTR_FLAG)) { for (i = 0; i < cf.can_dlc; i++) { tmp = hex_to_bin(*cmd++); if (tmp < 0) return; cf.data[i] = (tmp << 4); tmp = hex_to_bin(*cmd++); if (tmp < 0) return; cf.data[i] |= tmp; } } skb = dev_alloc_skb(sizeof(struct can_frame) + sizeof(struct can_skb_priv)); if (!skb) return; skb->dev = sl->dev; skb->protocol = htons(ETH_P_CAN); skb->pkt_type = PACKET_BROADCAST; skb->ip_summed = CHECKSUM_UNNECESSARY; can_skb_reserve(skb); can_skb_prv(skb)->ifindex = sl->dev->ifindex; can_skb_prv(skb)->skbcnt = 0; skb_put_data(skb, &cf, sizeof(struct can_frame)); sl->dev->stats.rx_packets++; sl->dev->stats.rx_bytes += cf.can_dlc; netif_rx_ni(skb); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "An issue was discovered in slc_bump in drivers/net/can/slcan.c in the Linux kernel 3.16 through 5.6.2. It allows attackers to read uninitialized can_frame data, potentially containing sensitive information from kernel stack memory, if the configuration lacks CONFIG_INIT_STACK_ALL, aka CID-b9258a2cece4.", "severity_level": "NoInfo", "cwe": "CWE-200", "cve": "CVE-2020-11494"}} -{"idx": 431348, "input": "static void nfs40_call_sync_done(struct rpc_task *task, void *calldata) { struct nfs4_call_sync_data *data = calldata; nfs4_sequence_done(task, data->seq_res); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 364115, "input": "static int xdp_umem_pin_pages(struct xdp_umem *umem) { unsigned int gup_flags = FOLL_WRITE; long npgs; int err; umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs), GFP_KERNEL | __GFP_NOWARN); if (!umem->pgs) return -ENOMEM; down_read(¤t->mm->mmap_sem); npgs = pin_user_pages(umem->address, umem->npgs, gup_flags | FOLL_LONGTERM, &umem->pgs[0], NULL); up_read(¤t->mm->mmap_sem); if (npgs != umem->npgs) { if (npgs >= 0) { umem->npgs = npgs; err = -ENOMEM; goto out_pin; } err = npgs; goto out_pgs; } return 0; out_pin: xdp_umem_unpin_pages(umem); out_pgs: kfree(umem->pgs); umem->pgs = NULL; return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381957, "input": "static int oidc_handle_unauthenticated_user(request_rec *r, oidc_cfg *c) { /* see if we've configured OIDCUnAuthAction for this path */ switch (oidc_dir_cfg_unauth_action(r)) { case OIDC_UNAUTH_RETURN410: return HTTP_GONE; case OIDC_UNAUTH_RETURN407: return HTTP_PROXY_AUTHENTICATION_REQUIRED; case OIDC_UNAUTH_RETURN401: return HTTP_UNAUTHORIZED; case OIDC_UNAUTH_PASS: r->user = \"\"; /* * we're not going to pass information about an authenticated user to the application, * but we do need to scrub the headers that mod_auth_openidc would set for security reasons */ oidc_scrub_headers(r); return OK; case OIDC_UNAUTH_AUTHENTICATE: /* * exception handling: if this looks like a XMLHttpRequest call we * won't redirect the user and thus avoid creating a state cookie * for a non-browser (= Javascript) call that will never return from the OP */ if ((oidc_dir_cfg_unauth_expr_is_set(r) == FALSE) && (oidc_is_xml_http_request(r) == TRUE)) return HTTP_UNAUTHORIZED; } /* * else: no session (regardless of whether it is main or sub-request), * and we need to authenticate the user */ return oidc_authenticate_user(r, c, NULL, oidc_get_current_url(r), NULL, NULL, NULL, oidc_dir_cfg_path_auth_request_params(r), oidc_dir_cfg_path_scope(r)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219329, "input": "static int* create_offset_array(const pcre_cache_entry* pce, int& size_offsets) { /* Allocate memory for the offsets array */ size_offsets = pce->num_subpats * 3; return (int *)req::malloc_noptrs(size_offsets * sizeof(int)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219592, "input": "int64_t HHVM_FUNCTION(crc32, StringArg str) { return (uint32_t)string_crc32(str.get()->data(), str.get()->size()); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508632, "input": "AGGR_OP::end_send() { enum_nested_loop_state rc= NESTED_LOOP_OK; TABLE *table= join_tab->table; JOIN *join= join_tab->join; // All records were stored, send them further int tmp, new_errno= 0; if ((rc= put_record(true)) < NESTED_LOOP_OK) return rc; if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) { DBUG_PRINT(\"error\",(\"extra(HA_EXTRA_NO_CACHE) failed\")); new_errno= tmp; } if ((tmp= table->file->ha_index_or_rnd_end())) { DBUG_PRINT(\"error\",(\"ha_index_or_rnd_end() failed\")); new_errno= tmp; } if (new_errno) { table->file->print_error(new_errno,MYF(0)); return NESTED_LOOP_ERROR; } // Update ref array join_tab->join->set_items_ref_array(*join_tab->ref_array); bool keep_last_filesort_result = join_tab->filesort ? false : true; if (join_tab->window_funcs_step) { if (join_tab->window_funcs_step->exec(join, keep_last_filesort_result)) return NESTED_LOOP_ERROR; } table->reginfo.lock_type= TL_UNLOCK; bool in_first_read= true; while (rc == NESTED_LOOP_OK) { int error; if (in_first_read) { in_first_read= false; error= join_init_read_record(join_tab); } else error= join_tab->read_record.read_record(); if (unlikely(error > 0 || (join->thd->is_error()))) // Fatal error rc= NESTED_LOOP_ERROR; else if (error < 0) break; else if (unlikely(join->thd->killed)) // Aborted by user { join->thd->send_kill_message(); rc= NESTED_LOOP_KILLED; } else { rc= evaluate_join_record(join, join_tab, 0); } } if (keep_last_filesort_result) { delete join_tab->filesort_result; join_tab->filesort_result= NULL; } // Finish rnd scn after sending records if (join_tab->table->file->inited) join_tab->table->file->ha_rnd_end(); return rc; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 293667, "input": "static inline void init_task_pid_links(struct task_struct *task) { enum pid_type type; for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) { INIT_HLIST_NODE(&task->pid_links[type]); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431467, "input": "static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_pgio_res *res) { __be32 *p; uint32_t count, eof, recvd; int status; status = decode_op_hdr(xdr, OP_READ); if (status) return status; p = xdr_inline_decode(xdr, 8); if (unlikely(!p)) return -EIO; eof = be32_to_cpup(p++); count = be32_to_cpup(p); recvd = xdr_read_pages(xdr, count); if (count > recvd) { dprintk(\"NFS: server cheating in read reply: \" \"count %u > recvd %u\\n\", count, recvd); count = recvd; eof = 0; } res->eof = eof; res->count = count; return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 200525, "input": "gdImagePtr gdImageCreateFromXpm (char *filename) { XpmInfo info; XpmImage image; int i, j, k, number; char buf[5]; gdImagePtr im = 0; int *pointer; int red = 0, green = 0, blue = 0; int *colors; int ret; ret = XpmReadFileToXpmImage(filename, &image, &info); if (ret != XpmSuccess) { return 0; } if (!(im = gdImageCreate(image.width, image.height))) { goto done; } number = image.ncolors; colors = (int *) safe_emalloc(number, sizeof(int), 0); for (i = 0; i < number; i++) { switch (strlen (image.colorTable[i].c_color)) { case 4: buf[1] = '\\0'; buf[0] = image.colorTable[i].c_color[1]; red = strtol(buf, NULL, 16); buf[0] = image.colorTable[i].c_color[2]; green = strtol(buf, NULL, 16); buf[0] = image.colorTable[i].c_color[3]; blue = strtol(buf, NULL, 16); break; case 7: buf[2] = '\\0'; buf[0] = image.colorTable[i].c_color[1]; buf[1] = image.colorTable[i].c_color[2]; red = strtol(buf, NULL, 16); buf[0] = image.colorTable[i].c_color[3]; buf[1] = image.colorTable[i].c_color[4]; green = strtol(buf, NULL, 16); buf[0] = image.colorTable[i].c_color[5]; buf[1] = image.colorTable[i].c_color[6]; blue = strtol(buf, NULL, 16); break; case 10: buf[3] = '\\0'; buf[0] = image.colorTable[i].c_color[1]; buf[1] = image.colorTable[i].c_color[2]; buf[2] = image.colorTable[i].c_color[3]; red = strtol(buf, NULL, 16); red /= 64; buf[0] = image.colorTable[i].c_color[4]; buf[1] = image.colorTable[i].c_color[5]; buf[2] = image.colorTable[i].c_color[6]; green = strtol(buf, NULL, 16); green /= 64; buf[0] = image.colorTable[i].c_color[7]; buf[1] = image.colorTable[i].c_color[8]; buf[2] = image.colorTable[i].c_color[9]; blue = strtol(buf, NULL, 16); blue /= 64; break; case 13: buf[4] = '\\0'; buf[0] = image.colorTable[i].c_color[1]; buf[1] = image.colorTable[i].c_color[2]; buf[2] = image.colorTable[i].c_color[3]; buf[3] = image.colorTable[i].c_color[4]; red = strtol(buf, NULL, 16); red /= 256; buf[0] = image.colorTable[i].c_color[5]; buf[1] = image.colorTable[i].c_color[6]; buf[2] = image.colorTable[i].c_color[7]; buf[3] = image.colorTable[i].c_color[8]; green = strtol(buf, NULL, 16); green /= 256; buf[0] = image.colorTable[i].c_color[9]; buf[1] = image.colorTable[i].c_color[10]; buf[2] = image.colorTable[i].c_color[11]; buf[3] = image.colorTable[i].c_color[12]; blue = strtol(buf, NULL, 16); blue /= 256; break; } colors[i] = gdImageColorResolve(im, red, green, blue); } pointer = (int *) image.data; for (i = 0; i < image.height; i++) { for (j = 0; j < image.width; j++) { k = *pointer++; gdImageSetPixel(im, j, i, colors[k]); } } gdFree(colors); done: XpmFreeXpmImage(&image); XpmFreeXpmInfo(&info); return im; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "The gdImageCreateFromXpm function in gdxpm.c in libgd, as used in PHP 5.4.26 and earlier, allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted color table in an XPM file.", "severity_level": "Medium", "cwe": "CWE-476", "cve": "CVE-2014-2497"}} -{"idx": 378585, "input": "void sqlite3VdbeReusable(Vdbe *p){ p->runOnlyOnce = 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 293150, "input": "static int zipfileSerializeCDS(ZipfileEntry *pEntry, u8 *aBuf){ u8 *a = aBuf; ZipfileCDS *pCDS = &pEntry->cds; if( pEntry->aExtra==0 ){ pCDS->nExtra = 9; } zipfileWrite32(a, ZIPFILE_SIGNATURE_CDS); zipfileWrite16(a, pCDS->iVersionMadeBy); zipfileWrite16(a, pCDS->iVersionExtract); zipfileWrite16(a, pCDS->flags); zipfileWrite16(a, pCDS->iCompression); zipfileWrite16(a, pCDS->mTime); zipfileWrite16(a, pCDS->mDate); zipfileWrite32(a, pCDS->crc32); zipfileWrite32(a, pCDS->szCompressed); zipfileWrite32(a, pCDS->szUncompressed); assert( a==&aBuf[ZIPFILE_CDS_NFILE_OFF] ); zipfileWrite16(a, pCDS->nFile); zipfileWrite16(a, pCDS->nExtra); zipfileWrite16(a, pCDS->nComment); zipfileWrite16(a, pCDS->iDiskStart); zipfileWrite16(a, pCDS->iInternalAttr); zipfileWrite32(a, pCDS->iExternalAttr); zipfileWrite32(a, pCDS->iOffset); memcpy(a, pCDS->zFile, pCDS->nFile); a += pCDS->nFile; if( pEntry->aExtra ){ int n = (int)pCDS->nExtra + (int)pCDS->nComment; memcpy(a, pEntry->aExtra, n); a += n; }else{ assert( pCDS->nExtra==9 ); zipfileWrite16(a, ZIPFILE_EXTRA_TIMESTAMP); zipfileWrite16(a, 5); *a++ = 0x01; zipfileWrite32(a, pEntry->mUnixTime); } return a-aBuf; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 509072, "input": "void used_tables_and_const_cache_update_and_join(Item *item) { item->update_used_tables(); used_tables_and_const_cache_join(item); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 357437, "input": "static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd, opj_image_t* p_output_image) { OPJ_UINT32 i, j; OPJ_UINT32 l_width_src, l_height_src; OPJ_UINT32 l_width_dest, l_height_dest; OPJ_INT32 l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src; OPJ_SIZE_T l_start_offset_src; OPJ_UINT32 l_start_x_dest, l_start_y_dest; OPJ_UINT32 l_x0_dest, l_y0_dest, l_x1_dest, l_y1_dest; OPJ_SIZE_T l_start_offset_dest; opj_image_comp_t * l_img_comp_src = 00; opj_image_comp_t * l_img_comp_dest = 00; opj_tcd_tilecomp_t * l_tilec = 00; opj_image_t * l_image_src = 00; OPJ_INT32 * l_dest_ptr; l_tilec = p_tcd->tcd_image->tiles->comps; l_image_src = p_tcd->image; l_img_comp_src = l_image_src->comps; l_img_comp_dest = p_output_image->comps; for (i = 0; i < l_image_src->numcomps; i++, ++l_img_comp_dest, ++l_img_comp_src, ++l_tilec) { OPJ_INT32 res_x0, res_x1, res_y0, res_y1; OPJ_UINT32 src_data_stride; const OPJ_INT32* p_src_data; /* Copy info from decoded comp image to output image */ l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded; if (p_tcd->whole_tile_decoding) { opj_tcd_resolution_t* l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded; res_x0 = l_res->x0; res_y0 = l_res->y0; res_x1 = l_res->x1; res_y1 = l_res->y1; src_data_stride = (OPJ_UINT32)( l_tilec->resolutions[l_tilec->minimum_num_resolutions - 1].x1 - l_tilec->resolutions[l_tilec->minimum_num_resolutions - 1].x0); p_src_data = l_tilec->data; } else { opj_tcd_resolution_t* l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded; res_x0 = (OPJ_INT32)l_res->win_x0; res_y0 = (OPJ_INT32)l_res->win_y0; res_x1 = (OPJ_INT32)l_res->win_x1; res_y1 = (OPJ_INT32)l_res->win_y1; src_data_stride = l_res->win_x1 - l_res->win_x0; p_src_data = l_tilec->data_win; } if (p_src_data == NULL) { /* Happens for partial component decoding */ continue; } l_width_src = (OPJ_UINT32)(res_x1 - res_x0); l_height_src = (OPJ_UINT32)(res_y1 - res_y0); /* Current tile component size*/ /*if (i == 0) { fprintf(stdout, \"SRC: l_res_x0=%d, l_res_x1=%d, l_res_y0=%d, l_res_y1=%d\\n\", res_x0, res_x1, res_y0, res_y1); }*/ /* Border of the current output component*/ l_x0_dest = opj_uint_ceildivpow2(l_img_comp_dest->x0, l_img_comp_dest->factor); l_y0_dest = opj_uint_ceildivpow2(l_img_comp_dest->y0, l_img_comp_dest->factor); l_x1_dest = l_x0_dest + l_img_comp_dest->w; /* can't overflow given that image->x1 is uint32 */ l_y1_dest = l_y0_dest + l_img_comp_dest->h; /*if (i == 0) { fprintf(stdout, \"DEST: l_x0_dest=%d, l_x1_dest=%d, l_y0_dest=%d, l_y1_dest=%d (%d)\\n\", l_x0_dest, l_x1_dest, l_y0_dest, l_y1_dest, l_img_comp_dest->factor ); }*/ /*-----*/ /* Compute the area (l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src) * of the input buffer (decoded tile component) which will be move * in the output buffer. Compute the area of the output buffer (l_start_x_dest, * l_start_y_dest, l_width_dest, l_height_dest) which will be modified * by this input area. * */ assert(res_x0 >= 0); assert(res_x1 >= 0); if (l_x0_dest < (OPJ_UINT32)res_x0) { l_start_x_dest = (OPJ_UINT32)res_x0 - l_x0_dest; l_offset_x0_src = 0; if (l_x1_dest >= (OPJ_UINT32)res_x1) { l_width_dest = l_width_src; l_offset_x1_src = 0; } else { l_width_dest = l_x1_dest - (OPJ_UINT32)res_x0 ; l_offset_x1_src = (OPJ_INT32)(l_width_src - l_width_dest); } } else { l_start_x_dest = 0U; l_offset_x0_src = (OPJ_INT32)l_x0_dest - res_x0; if (l_x1_dest >= (OPJ_UINT32)res_x1) { l_width_dest = l_width_src - (OPJ_UINT32)l_offset_x0_src; l_offset_x1_src = 0; } else { l_width_dest = l_img_comp_dest->w ; l_offset_x1_src = res_x1 - (OPJ_INT32)l_x1_dest; } } if (l_y0_dest < (OPJ_UINT32)res_y0) { l_start_y_dest = (OPJ_UINT32)res_y0 - l_y0_dest; l_offset_y0_src = 0; if (l_y1_dest >= (OPJ_UINT32)res_y1) { l_height_dest = l_height_src; l_offset_y1_src = 0; } else { l_height_dest = l_y1_dest - (OPJ_UINT32)res_y0 ; l_offset_y1_src = (OPJ_INT32)(l_height_src - l_height_dest); } } else { l_start_y_dest = 0U; l_offset_y0_src = (OPJ_INT32)l_y0_dest - res_y0; if (l_y1_dest >= (OPJ_UINT32)res_y1) { l_height_dest = l_height_src - (OPJ_UINT32)l_offset_y0_src; l_offset_y1_src = 0; } else { l_height_dest = l_img_comp_dest->h ; l_offset_y1_src = res_y1 - (OPJ_INT32)l_y1_dest; } } if ((l_offset_x0_src < 0) || (l_offset_y0_src < 0) || (l_offset_x1_src < 0) || (l_offset_y1_src < 0)) { return OPJ_FALSE; } /* testcase 2977.pdf.asan.67.2198 */ if ((OPJ_INT32)l_width_dest < 0 || (OPJ_INT32)l_height_dest < 0) { return OPJ_FALSE; } /*-----*/ /* Compute the input buffer offset */ l_start_offset_src = (OPJ_SIZE_T)l_offset_x0_src + (OPJ_SIZE_T)l_offset_y0_src * (OPJ_SIZE_T)src_data_stride; /* Compute the output buffer offset */ l_start_offset_dest = (OPJ_SIZE_T)l_start_x_dest + (OPJ_SIZE_T)l_start_y_dest * (OPJ_SIZE_T)l_img_comp_dest->w; /* Allocate output component buffer if necessary */ if (l_img_comp_dest->data == NULL && l_start_offset_src == 0 && l_start_offset_dest == 0 && src_data_stride == l_img_comp_dest->w && l_width_dest == l_img_comp_dest->w && l_height_dest == l_img_comp_dest->h) { /* If the final image matches the tile buffer, then borrow it */ /* directly to save a copy */ if (p_tcd->whole_tile_decoding) { l_img_comp_dest->data = l_tilec->data; l_tilec->data = NULL; } else { l_img_comp_dest->data = l_tilec->data_win; l_tilec->data_win = NULL; } continue; } else if (l_img_comp_dest->data == NULL) { OPJ_SIZE_T l_width = l_img_comp_dest->w; OPJ_SIZE_T l_height = l_img_comp_dest->h; if ((l_height == 0U) || (l_width > (SIZE_MAX / l_height)) || l_width * l_height > SIZE_MAX / sizeof(OPJ_INT32)) { /* would overflow */ return OPJ_FALSE; } l_img_comp_dest->data = (OPJ_INT32*) opj_image_data_alloc(l_width * l_height * sizeof(OPJ_INT32)); if (! l_img_comp_dest->data) { return OPJ_FALSE; } if (l_img_comp_dest->w != l_width_dest || l_img_comp_dest->h != l_height_dest) { memset(l_img_comp_dest->data, 0, (OPJ_SIZE_T)l_img_comp_dest->w * l_img_comp_dest->h * sizeof(OPJ_INT32)); } } /* Move the output buffer to the first place where we will write*/ l_dest_ptr = l_img_comp_dest->data + l_start_offset_dest; { const OPJ_INT32 * l_src_ptr = p_src_data; l_src_ptr += l_start_offset_src; for (j = 0; j < l_height_dest; ++j) { memcpy(l_dest_ptr, l_src_ptr, l_width_dest * sizeof(OPJ_INT32)); l_dest_ptr += l_img_comp_dest->w; l_src_ptr += src_data_stride; } } } return OPJ_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 206866, "input": "static ssize_t acpi_table_aml_write(struct config_item *cfg, const void *data, size_t size) { const struct acpi_table_header *header = data; struct acpi_table *table; int ret; table = container_of(cfg, struct acpi_table, cfg); if (table->header) { pr_err(\"table already loaded\\n\"); return -EBUSY; } if (header->length != size) { pr_err(\"invalid table length\\n\"); return -EINVAL; } if (memcmp(header->signature, ACPI_SIG_SSDT, 4)) { pr_err(\"invalid table signature\\n\"); return -EINVAL; } table = container_of(cfg, struct acpi_table, cfg); table->header = kmemdup(header, header->length, GFP_KERNEL); if (!table->header) return -ENOMEM; ret = acpi_load_table(table->header, &table->index); if (ret) { kfree(table->header); table->header = NULL; } return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Missing Authorization"], "explanation": "An issue was discovered in drivers/acpi/acpi_configfs.c in the Linux kernel before 5.7.7. Injection of malicious ACPI tables via configfs could be used by attackers to bypass lockdown and secure boot restrictions, aka CID-75b0cea7bf30.", "severity_level": "NoInfo", "cwe": "CWE-862", "cve": "CVE-2020-15780"}} -{"idx": 214025, "input": "open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS, rfbCredential *cred) { SSL_CTX *ssl_ctx = NULL; SSL *ssl = NULL; int n, finished = 0; X509_VERIFY_PARAM *param; uint8_t verify_crls = cred->x509Credential.x509CrlVerifyMode; if (!(ssl_ctx = SSL_CTX_new(SSLv23_client_method()))) { rfbClientLog(\"Could not create new SSL context.\\n\"); return NULL; } param = X509_VERIFY_PARAM_new(); /* Setup verification if not anonymous */ if (!anonTLS) { if (cred->x509Credential.x509CACertFile) { if (!SSL_CTX_load_verify_locations(ssl_ctx, cred->x509Credential.x509CACertFile, NULL)) { rfbClientLog(\"Failed to load CA certificate from %s.\\n\", cred->x509Credential.x509CACertFile); goto error_free_ctx; } } else { rfbClientLog(\"Using default paths for certificate verification.\\n\"); SSL_CTX_set_default_verify_paths (ssl_ctx); } if (cred->x509Credential.x509CACrlFile) { if (!load_crls_from_file(cred->x509Credential.x509CACrlFile, ssl_ctx)) { rfbClientLog(\"CRLs could not be loaded.\\n\"); goto error_free_ctx; } if (verify_crls == rfbX509CrlVerifyNone) verify_crls = rfbX509CrlVerifyAll; } if (cred->x509Credential.x509ClientCertFile && cred->x509Credential.x509ClientKeyFile) { if (SSL_CTX_use_certificate_chain_file(ssl_ctx, cred->x509Credential.x509ClientCertFile) != 1) { rfbClientLog(\"Client certificate could not be loaded.\\n\"); goto error_free_ctx; } if (SSL_CTX_use_PrivateKey_file(ssl_ctx, cred->x509Credential.x509ClientKeyFile, SSL_FILETYPE_PEM) != 1) { rfbClientLog(\"Client private key could not be loaded.\\n\"); goto error_free_ctx; } if (SSL_CTX_check_private_key(ssl_ctx) == 0) { rfbClientLog(\"Client certificate and private key do not match.\\n\"); goto error_free_ctx; } } SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); if (verify_crls == rfbX509CrlVerifyClient) X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK); else if (verify_crls == rfbX509CrlVerifyAll) X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); if(!X509_VERIFY_PARAM_set1_host(param, client->serverHost, strlen(client->serverHost))) { rfbClientLog(\"Could not set server name for verification.\\n\"); goto error_free_ctx; } SSL_CTX_set1_param(ssl_ctx, param); } if (!(ssl = SSL_new (ssl_ctx))) { rfbClientLog(\"Could not create a new SSL session.\\n\"); goto error_free_ctx; } /* TODO: finetune this list, take into account anonTLS bool */ SSL_set_cipher_list(ssl, \"ALL\"); SSL_set_fd (ssl, sockfd); SSL_CTX_set_app_data (ssl_ctx, client); do { n = SSL_connect(ssl); if (n != 1) { if (wait_for_data(ssl, n, 1) != 1) { finished = 1; SSL_shutdown(ssl); goto error_free_ssl; } } } while( n != 1 && finished != 1 ); X509_VERIFY_PARAM_free(param); return ssl; error_free_ssl: SSL_free(ssl); error_free_ctx: X509_VERIFY_PARAM_free(param); SSL_CTX_free(ssl_ctx); return NULL; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "An issue was discovered in LibVNCServer before 0.9.13. libvncclient/tls_openssl.c has a NULL pointer dereference.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2020-14396"}} -{"idx": 285530, "input": "calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) { reg_errcode_t err; Idx i; re_node_set eclosure; bool ok; bool incomplete = false; err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); if (BE (err != REG_NOERROR, 0)) return err; /* This indicates that we are calculating this node now. We reference this value to avoid infinite loop. */ dfa->eclosures[node].nelem = REG_MISSING; /* If the current node has constraints, duplicate all nodes since they must inherit the constraints. */ if (dfa->nodes[node].constraint && dfa->edests[node].nelem && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) { err = duplicate_node_closure (dfa, node, node, node, dfa->nodes[node].constraint); if (BE (err != REG_NOERROR, 0)) return err; } /* Expand each epsilon destination nodes. */ if (IS_EPSILON_NODE(dfa->nodes[node].type)) for (i = 0; i < dfa->edests[node].nelem; ++i) { re_node_set eclosure_elem; Idx edest = dfa->edests[node].elems[i]; /* If calculating the epsilon closure of 'edest' is in progress, return intermediate result. */ if (dfa->eclosures[edest].nelem == REG_MISSING) { incomplete = true; continue; } /* If we haven't calculated the epsilon closure of 'edest' yet, calculate now. Otherwise use calculated epsilon closure. */ if (dfa->eclosures[edest].nelem == 0) { err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); if (BE (err != REG_NOERROR, 0)) return err; } else eclosure_elem = dfa->eclosures[edest]; /* Merge the epsilon closure of 'edest'. */ err = re_node_set_merge (&eclosure, &eclosure_elem); if (BE (err != REG_NOERROR, 0)) return err; /* If the epsilon closure of 'edest' is incomplete, the epsilon closure of this node is also incomplete. */ if (dfa->eclosures[edest].nelem == 0) { incomplete = true; re_node_set_free (&eclosure_elem); } } /* An epsilon closure includes itself. */ ok = re_node_set_insert (&eclosure, node); if (BE (! ok, 0)) return REG_ESPACE; if (incomplete && !root) dfa->eclosures[node].nelem = 0; else dfa->eclosures[node] = eclosure; *new_set = eclosure; return REG_NOERROR; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 336279, "input": "static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head, void *priv) { struct epitem *epi, *tmp; poll_table pt; int depth = *(int *)priv; init_poll_funcptr(&pt, NULL); depth++; list_for_each_entry_safe(epi, tmp, head, rdllink) { if (ep_item_poll(epi, &pt, depth)) { return EPOLLIN | EPOLLRDNORM; } else { /* * Item has been dropped into the ready list by the poll * callback, but it's not actually ready, as far as * caller requested events goes. We can remove it here. */ __pm_relax(ep_wakeup_source(epi)); list_del_init(&epi->rdllink); } } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 237545, "input": "GF_Err SmDm_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_SMPTE2086MasteringDisplayMetadataBox *p = (GF_SMPTE2086MasteringDisplayMetadataBox*)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u16(bs, p->primaryRChromaticity_x); gf_bs_write_u16(bs, p->primaryRChromaticity_y); gf_bs_write_u16(bs, p->primaryGChromaticity_x); gf_bs_write_u16(bs, p->primaryGChromaticity_y); gf_bs_write_u16(bs, p->primaryBChromaticity_x); gf_bs_write_u16(bs, p->primaryBChromaticity_y); gf_bs_write_u16(bs, p->whitePointChromaticity_x); gf_bs_write_u16(bs, p->whitePointChromaticity_y); gf_bs_write_u32(bs, p->luminanceMax); gf_bs_write_u32(bs, p->luminanceMin); return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 349488, "input": "p11_rpc_buffer_add_byte_array (p11_buffer *buffer, const unsigned char *data, size_t length) { if (data == NULL) { p11_rpc_buffer_add_uint32 (buffer, 0xffffffff); return; } else if (length >= 0x7fffffff) { p11_buffer_fail (buffer); return; } p11_rpc_buffer_add_uint32 (buffer, length); p11_buffer_add (buffer, data, length); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 421815, "input": "ipmi_lan_print(struct ipmi_intf * intf, uint8_t chan) { struct lan_param * p; if (chan < 1 || chan > IPMI_CHANNEL_NUMBER_MAX) { lprintf(LOG_ERR, \"Invalid Channel %d\", chan); return -1; } /* find type of channel and only accept 802.3 LAN */ if (!is_lan_channel(intf, chan)) { lprintf(LOG_ERR, \"Channel %d is not a LAN channel\", chan); return -1; } p = get_lan_param(intf, chan, IPMI_LANP_SET_IN_PROGRESS); if (!p) return -1; if (p->data) { printf(\"%-24s: \", p->desc); p->data[0] &= 3; switch (p->data[0]) { case 0: printf(\"Set Complete\\n\"); break; case 1: printf(\"Set In Progress\\n\"); break; case 2: printf(\"Commit Write\\n\"); break; case 3: printf(\"Reserved\\n\"); break; default: printf(\"Unknown\\n\"); } } p = get_lan_param(intf, chan, IPMI_LANP_AUTH_TYPE); if (!p) return -1; if (p->data) { printf(\"%-24s: %s%s%s%s%s\\n\", p->desc, (p->data[0] & 1<data[0] & 1<data[0] & 1<data[0] & 1<data[0] & 1<data) { printf(\"%-24s: Callback : %s%s%s%s%s\\n\", p->desc, (p->data[0] & 1<data[0] & 1<data[0] & 1<data[0] & 1<data[0] & 1<data[1] & 1<data[1] & 1<data[1] & 1<data[1] & 1<data[1] & 1<data[2] & 1<data[2] & 1<data[2] & 1<data[2] & 1<data[2] & 1<data[3] & 1<data[3] & 1<data[3] & 1<data[3] & 1<data[3] & 1<data[4] & 1<data[4] & 1<data[4] & 1<data[4] & 1<data[4] & 1<data) { printf(\"%-24s: \", p->desc); p->data[0] &= 0xf; switch (p->data[0]) { case 0: printf(\"Unspecified\\n\"); break; case 1: printf(\"Static Address\\n\"); break; case 2: printf(\"DHCP Address\\n\"); break; case 3: printf(\"BIOS Assigned Address\\n\"); break; default: printf(\"Other\\n\"); break; } } p = get_lan_param(intf, chan, IPMI_LANP_IP_ADDR); if (!p) return -1; if (p->data) printf(\"%-24s: %d.%d.%d.%d\\n\", p->desc, p->data[0], p->data[1], p->data[2], p->data[3]); p = get_lan_param(intf, chan, IPMI_LANP_SUBNET_MASK); if (!p) return -1; if (p->data) printf(\"%-24s: %d.%d.%d.%d\\n\", p->desc, p->data[0], p->data[1], p->data[2], p->data[3]); p = get_lan_param(intf, chan, IPMI_LANP_MAC_ADDR); if (!p) return -1; if (p->data) printf(\"%-24s: %s\\n\", p->desc, mac2str(p->data)); p = get_lan_param(intf, chan, IPMI_LANP_SNMP_STRING); if (!p) return -1; if (p->data) printf(\"%-24s: %s\\n\", p->desc, p->data); p = get_lan_param(intf, chan, IPMI_LANP_IP_HEADER); if (!p) return -1; if (p->data) printf(\"%-24s: TTL=0x%02x Flags=0x%02x Precedence=0x%02x TOS=0x%02x\\n\", p->desc, p->data[0], p->data[1] & 0xe0, p->data[2] & 0xe0, p->data[2] & 0x1e); p = get_lan_param(intf, chan, IPMI_LANP_BMC_ARP); if (!p) return -1; if (p->data) printf(\"%-24s: ARP Responses %sabled, Gratuitous ARP %sabled\\n\", p->desc, (p->data[0] & 2) ? \"En\" : \"Dis\", (p->data[0] & 1) ? \"En\" : \"Dis\"); p = get_lan_param(intf, chan, IPMI_LANP_GRAT_ARP); if (!p) return -1; if (p->data) printf(\"%-24s: %.1f seconds\\n\", p->desc, (float)((p->data[0] + 1) / 2)); p = get_lan_param(intf, chan, IPMI_LANP_DEF_GATEWAY_IP); if (!p) return -1; if (p->data) printf(\"%-24s: %d.%d.%d.%d\\n\", p->desc, p->data[0], p->data[1], p->data[2], p->data[3]); p = get_lan_param(intf, chan, IPMI_LANP_DEF_GATEWAY_MAC); if (!p) return -1; if (p->data) printf(\"%-24s: %s\\n\", p->desc, mac2str(p->data)); p = get_lan_param(intf, chan, IPMI_LANP_BAK_GATEWAY_IP); if (!p) return -1; if (p->data) printf(\"%-24s: %d.%d.%d.%d\\n\", p->desc, p->data[0], p->data[1], p->data[2], p->data[3]); p = get_lan_param(intf, chan, IPMI_LANP_BAK_GATEWAY_MAC); if (!p) return -1; if (p->data) printf(\"%-24s: %s\\n\", p->desc, mac2str(p->data)); p = get_lan_param(intf, chan, IPMI_LANP_VLAN_ID); if (p && p->data) { int id = ((p->data[1] & 0x0f) << 8) + p->data[0]; if (p->data[1] & 0x80) printf(\"%-24s: %d\\n\", p->desc, id); else printf(\"%-24s: Disabled\\n\", p->desc); } p = get_lan_param(intf, chan, IPMI_LANP_VLAN_PRIORITY); if (p && p->data) printf(\"%-24s: %d\\n\", p->desc, p->data[0] & 0x07); /* Determine supported Cipher Suites -- Requires two calls */ p = get_lan_param(intf, chan, IPMI_LANP_RMCP_CIPHER_SUPPORT); if (!p) return -1; else if (p->data) { unsigned char cipher_suite_count = p->data[0]; p = get_lan_param(intf, chan, IPMI_LANP_RMCP_CIPHERS); if (!p) return -1; printf(\"%-24s: \", p->desc); /* Now we're dangerous. There are only 15 fixed cipher suite IDs, but the spec allows for 16 in the return data.*/ if (p->data && p->data_len <= 17) { unsigned int i; for (i = 0; (i < 16) && (i < cipher_suite_count); ++i) { printf(\"%s%d\", (i > 0? \",\": \"\"), p->data[i + 1]); } printf(\"\\n\"); } else { printf(\"None\\n\"); } } /* RMCP+ Messaging Cipher Suite Privilege Levels */ /* These are the privilege levels for the 15 fixed cipher suites */ p = get_lan_param(intf, chan, IPMI_LANP_RMCP_PRIV_LEVELS); if (!p) return -1; if (p->data && 9 == p->data_len) { printf(\"%-24s: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\\n\", p->desc, priv_level_to_char(p->data[1] & 0x0F), priv_level_to_char(p->data[1] >> 4), priv_level_to_char(p->data[2] & 0x0F), priv_level_to_char(p->data[2] >> 4), priv_level_to_char(p->data[3] & 0x0F), priv_level_to_char(p->data[3] >> 4), priv_level_to_char(p->data[4] & 0x0F), priv_level_to_char(p->data[4] >> 4), priv_level_to_char(p->data[5] & 0x0F), priv_level_to_char(p->data[5] >> 4), priv_level_to_char(p->data[6] & 0x0F), priv_level_to_char(p->data[6] >> 4), priv_level_to_char(p->data[7] & 0x0F), priv_level_to_char(p->data[7] >> 4), priv_level_to_char(p->data[8] & 0x0F)); /* Now print a legend */ printf(\"%-24s: %s\\n\", \"\", \" X=Cipher Suite Unused\"); printf(\"%-24s: %s\\n\", \"\", \" c=CALLBACK\"); printf(\"%-24s: %s\\n\", \"\", \" u=USER\"); printf(\"%-24s: %s\\n\", \"\", \" o=OPERATOR\"); printf(\"%-24s: %s\\n\", \"\", \" a=ADMIN\"); printf(\"%-24s: %s\\n\", \"\", \" O=OEM\"); } else printf(\"%-24s: Not Available\\n\", p->desc); /* Bad Password Threshold */ p = get_lan_param(intf, chan, IPMI_LANP_BAD_PASS_THRESH); if (!p) return -1; if (p->data && 6 == p->data_len) { int tmp; printf(\"%-24s: %d\\n\", p->desc, p->data[1]); printf(\"%-24s: %s\\n\", \"Invalid password disable\", p->data[0] & 1 ? \"yes\" : \"no\" ); tmp = p->data[2] + (p->data[3] << 8); printf(\"%-24s: %d\\n\", \"Attempt Count Reset Int.\", tmp * 10); tmp = p->data[4] + (p->data[5] << 8); printf(\"%-24s: %d\\n\", \"User Lockout Interval\", tmp * 10); } else { printf(\"%-24s: Not Available\\n\", p->desc); } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 497513, "input": "ms_escher_read_Dgg (MSEscherState *state, MSEscherHeader *h) { #if 0 typedef struct { guint32 max_spid; guint32 num_id_clust; guint32 num_shapes_saved; /* Includes deleted shapes if undo saved */ guint32 num_drawings_saved; GArray *id_clusts; } FDGG; typedef struct { guint32 DG_owning_spids; guint32 spids_used_so_far; } ID_CLUST; FDGG fd; guint32 lp; guint8 const *data = h->data + COMMON_HEADER_LEN; fd.id_clusts = g_array_new (1, 1, sizeof(ID_CLUST)); fd.max_spid = GSF_LE_GET_GUINT32(data+ 0); fd.num_id_clust = GSF_LE_GET_GUINT32(data+ 4); fd.num_shapes_saved = GSF_LE_GET_GUINT32(data+ 8); fd.num_drawings_saved = GSF_LE_GET_GUINT32(data+12); g_printerr (\"maxspid 0x%x clusts 0x%x shapes 0x%x drawings x%x\\n\", fd.max_spid, fd.num_id_clust, fd.num_shapes_saved, fd.num_drawings_saved); data+=16; for (lp = 0; lp < fd.num_id_clust; lp++) { ID_CLUST cl; cl.DG_owning_spids = GSF_LE_GET_GUINT32(data+0); cl.spids_used_so_far = GSF_LE_GET_GUINT32(data+4); g_array_append_val (fd.id_clusts, cl); } #endif return FALSE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 308336, "input": "doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, const char *end, const char **nextPtr, XML_Bool haveMore) { const char *s = *startPtr; const char **eventPP; const char **eventEndPP; if (enc == encoding) { eventPP = &eventPtr; *eventPP = s; eventEndPP = &eventEndPtr; } else { eventPP = &(openInternalEntities->internalEventPtr); eventEndPP = &(openInternalEntities->internalEventEndPtr); } *eventPP = s; *startPtr = NULL; for (;;) { const char *next; int tok = XmlCdataSectionTok(enc, s, end, &next); *eventEndPP = next; switch (tok) { case XML_TOK_CDATA_SECT_CLOSE: if (endCdataSectionHandler) endCdataSectionHandler(handlerArg); #if 0 /* see comment under XML_TOK_CDATA_SECT_OPEN */ else if (characterDataHandler) characterDataHandler(handlerArg, dataBuf, 0); #endif else if (defaultHandler) reportDefault(parser, enc, s, next); *startPtr = next; *nextPtr = next; if (ps_parsing == XML_FINISHED) return XML_ERROR_ABORTED; else return XML_ERROR_NONE; case XML_TOK_DATA_NEWLINE: if (characterDataHandler) { XML_Char c = 0xA; characterDataHandler(handlerArg, &c, 1); } else if (defaultHandler) reportDefault(parser, enc, s, next); break; case XML_TOK_DATA_CHARS: { XML_CharacterDataHandler charDataHandler = characterDataHandler; if (charDataHandler) { if (MUST_CONVERT(enc, s)) { for (;;) { ICHAR *dataPtr = (ICHAR *)dataBuf; const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); *eventEndPP = next; charDataHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) break; *eventPP = s; } } else charDataHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)next - (XML_Char *)s)); } else if (defaultHandler) reportDefault(parser, enc, s, next); } break; case XML_TOK_INVALID: *eventPP = next; return XML_ERROR_INVALID_TOKEN; case XML_TOK_PARTIAL_CHAR: if (haveMore) { *nextPtr = s; return XML_ERROR_NONE; } return XML_ERROR_PARTIAL_CHAR; case XML_TOK_PARTIAL: case XML_TOK_NONE: if (haveMore) { *nextPtr = s; return XML_ERROR_NONE; } return XML_ERROR_UNCLOSED_CDATA_SECTION; default: *eventPP = next; return XML_ERROR_UNEXPECTED_STATE; } *eventPP = s = next; switch (ps_parsing) { case XML_SUSPENDED: *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; default: ; } } /* not reached */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 264814, "input": "GF_Err mdia_on_child_box(GF_Box *s, GF_Box *a) { GF_MediaBox *ptr = (GF_MediaBox *)s; switch(a->type) { case GF_ISOM_BOX_TYPE_MDHD: if (ptr->mediaHeader) ERROR_ON_DUPLICATED_BOX(a, ptr) ptr->mediaHeader = (GF_MediaHeaderBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_HDLR: if (ptr->handler) ERROR_ON_DUPLICATED_BOX(a, ptr) ptr->handler = (GF_HandlerBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_MINF: if (ptr->information) ERROR_ON_DUPLICATED_BOX(a, ptr) ptr->information = (GF_MediaInformationBox *)a; return GF_OK; } return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 273981, "input": "mrb_alloca(mrb_state *mrb, size_t size) { struct RString *s; s = (struct RString*)mrb_obj_alloc(mrb, MRB_TT_STRING, mrb->string_class); return s->as.heap.ptr = (char*)mrb_malloc(mrb, size); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 410745, "input": "static inline bool tcp_stream_is_thin(struct tcp_sock *tp) { return tp->packets_out < 4 && !tcp_in_initial_slowstart(tp); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 200413, "input": "sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Cookie *cookie) { int rc; BerElement *ber; struct berval *bvp; char *uuid; Slapi_Attr *attr; Slapi_Value *val; if (type == LDAP_SYNC_NONE || ctrlp == NULL || (ber = der_alloc()) == NULL) { return (LDAP_OPERATIONS_ERROR); } *ctrlp = NULL; slapi_entry_attr_find(e, SLAPI_ATTR_UNIQUEID, &attr); slapi_attr_first_value(attr, &val); uuid = sync_nsuniqueid2uuid(slapi_value_get_string(val)); if ((rc = ber_printf(ber, \"{eo\", type, uuid, 16)) != -1) { if (cookie) { char *cookiestr = sync_cookie2str(cookie); rc = ber_printf(ber, \"s}\", cookiestr); slapi_ch_free((void **)&cookiestr); } else { rc = ber_printf(ber, \"}\"); } } if (rc != -1) { rc = ber_flatten(ber, &bvp); } ber_free(ber, 1); slapi_ch_free((void **)&uuid); if (rc == -1) { return (LDAP_OPERATIONS_ERROR); } *ctrlp = (LDAPControl *)slapi_ch_malloc(sizeof(LDAPControl)); (*ctrlp)->ldctl_iscritical = 0; (*ctrlp)->ldctl_oid = slapi_ch_strdup(LDAP_CONTROL_SYNC_STATE); (*ctrlp)->ldctl_value = *bvp; /* struct copy */ bvp->bv_val = NULL; ber_bvfree(bvp); return (LDAP_SUCCESS); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "When using a sync_repl client in 389-ds-base, an authenticated attacker can cause a NULL pointer dereference using a specially crafted query, causing a crash.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2021-3514"}} -{"idx": 461583, "input": "static bool is_ereg(u32 reg) { return (1 << reg) & (BIT(BPF_REG_5) | BIT(AUX_REG) | BIT(BPF_REG_7) | BIT(BPF_REG_8) | BIT(BPF_REG_9) | BIT(X86_REG_R9) | BIT(BPF_REG_AX)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 196632, "input": "void Compute(OpKernelContext* context) override { const Tensor& input_sizes = context->input(0); const Tensor& filter = context->input(1); const Tensor& out_backprop = context->input(2); TensorShape input_shape; OP_REQUIRES_OK(context, Conv2DBackpropComputeInputShape(input_sizes, filter.shape(), out_backprop.shape(), data_format_, &input_shape)); ConvBackpropDimensions dims; OP_REQUIRES_OK(context, ConvBackpropComputeDimensionsV2( \"Conv2DCustomBackpropInput\", /*num_spatial_dims=*/2, input_shape, filter.shape(), out_backprop.shape(), /*dilations=*/{1, 1, 1, 1}, strides_, padding_, explicit_paddings_, data_format_, &dims)); OP_REQUIRES(context, dims.in_depth == filter.shape().dim_size(2), errors::InvalidArgument(\"Computed input depth \", dims.in_depth, \" doesn't match filter input depth \", filter.shape().dim_size(2))); OP_REQUIRES( context, dims.out_depth == filter.shape().dim_size(3), errors::InvalidArgument(\"Computed output depth \", dims.out_depth, \" doesn't match filter output depth \", filter.shape().dim_size(3))); Tensor* in_backprop = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &in_backprop)); // If there is nothing to compute, return. if (input_shape.num_elements() == 0) { return; } // TODO(ezhulenev): Remove custom kernel and move XSMM support to // LaunchConv2DBackpropInputOp functor. #if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \\ defined TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS int64 pad_top, pad_bottom; int64 pad_left, pad_right; OP_REQUIRES_OK( context, GetWindowedOutputSizeVerbose( dims.spatial_dims[0].input_size, dims.spatial_dims[0].filter_size, dims.spatial_dims[0].stride, padding_, &dims.spatial_dims[0].output_size, &pad_top, &pad_bottom)); OP_REQUIRES_OK( context, GetWindowedOutputSizeVerbose( dims.spatial_dims[1].input_size, dims.spatial_dims[1].filter_size, dims.spatial_dims[1].stride, padding_, &dims.spatial_dims[1].output_size, &pad_left, &pad_right)); if (pad_left == pad_right && pad_top == pad_bottom) { if (LaunchXsmmBackwardInputConvolution()( context, context->eigen_device(), in_backprop->tensor(), filter.tensor(), out_backprop.tensor(), dims.spatial_dims[0].input_size, dims.spatial_dims[1].input_size, static_cast(dims.spatial_dims[0].stride), static_cast(dims.spatial_dims[1].stride), static_cast(pad_top), static_cast(pad_left), data_format_)) { return; } } #else int64 pad_top, pad_bottom; int64 pad_left, pad_right; #endif if (padding_ == Padding::EXPLICIT) { pad_top = explicit_paddings_[2]; pad_bottom = explicit_paddings_[3]; pad_left = explicit_paddings_[4]; pad_right = explicit_paddings_[5]; } OP_REQUIRES_OK( context, GetWindowedOutputSizeVerbose( dims.spatial_dims[0].input_size, dims.spatial_dims[0].filter_size, dims.spatial_dims[0].stride, padding_, &dims.spatial_dims[0].output_size, &pad_top, &pad_bottom)); OP_REQUIRES_OK( context, GetWindowedOutputSizeVerbose( dims.spatial_dims[1].input_size, dims.spatial_dims[1].filter_size, dims.spatial_dims[1].stride, padding_, &dims.spatial_dims[1].output_size, &pad_left, &pad_right)); // The total dimension size of each kernel. const int filter_total_size = dims.spatial_dims[0].filter_size * dims.spatial_dims[1].filter_size * dims.in_depth; // The output image size is the spatial size of the output. const int output_image_size = dims.spatial_dims[0].output_size * dims.spatial_dims[1].output_size; // TODO(andydavis) Get L2/L3 cache sizes from device. const size_t l2_cache_size = 256LL << 10; const size_t l3_cache_size = 30LL << 20; // Use L3 cache size as target working set size. const size_t target_working_set_size = l3_cache_size / sizeof(T); // Calculate size of matrices involved in MatMul: C = A x B. const size_t size_A = output_image_size * dims.out_depth; const size_t size_B = filter_total_size * dims.out_depth; const size_t size_C = output_image_size * filter_total_size; const size_t work_unit_size = size_A + size_B + size_C; auto worker_threads = *(context->device()->tensorflow_cpu_worker_threads()); // Calculate per-thread work unit size. const size_t thread_work_unit_size = work_unit_size / worker_threads.num_threads; // Set minimum per-thread work unit size to size of L2 cache. const size_t min_thread_work_unit_size = l2_cache_size / sizeof(T); // Use parallel tensor contractions if there is no batching, or if the // minimum per-thread work unit size threshold has been exceeded. // Otherwise, revert to multiple single-threaded matmul ops running in // parallel to keep all threads busy. // TODO(andydavis) Explore alternatives to branching the code in this way // (i.e. run multiple, parallel tensor contractions in another thread pool). const bool use_parallel_contraction = dims.batch_size == 1 || thread_work_unit_size >= min_thread_work_unit_size; const size_t shard_size = use_parallel_contraction ? 1 : (target_working_set_size + work_unit_size - 1) / work_unit_size; Tensor col_buffer; OP_REQUIRES_OK(context, context->allocate_temp( DataTypeToEnum::value, TensorShape({static_cast(shard_size), static_cast(output_image_size), static_cast(filter_total_size)}), &col_buffer)); // The input offset corresponding to a single input image. const int input_offset = dims.spatial_dims[0].input_size * dims.spatial_dims[1].input_size * dims.in_depth; // The output offset corresponding to a single output image. const int output_offset = dims.spatial_dims[0].output_size * dims.spatial_dims[1].output_size * dims.out_depth; const T* filter_data = filter.template flat().data(); T* col_buffer_data = col_buffer.template flat().data(); const T* out_backprop_data = out_backprop.template flat().data(); auto in_backprop_flat = in_backprop->template flat(); T* input_backprop_data = in_backprop_flat.data(); in_backprop_flat.device(context->eigen_device()) = in_backprop_flat.constant(T(0)); if (use_parallel_contraction) { typedef Eigen::TensorMap, Eigen::Unaligned> TensorMap; typedef Eigen::TensorMap, Eigen::Unaligned> ConstTensorMap; // Initialize contraction dims (we need to transpose 'B' below). Eigen::array, 1> contract_dims; contract_dims[0].first = 1; contract_dims[0].second = 1; for (int image_id = 0; image_id < dims.batch_size; ++image_id) { // Compute gradient into col_buffer. TensorMap C(col_buffer_data, output_image_size, filter_total_size); ConstTensorMap A(out_backprop_data + output_offset * image_id, output_image_size, dims.out_depth); ConstTensorMap B(filter_data, filter_total_size, dims.out_depth); C.device(context->eigen_cpu_device()) = A.contract(B, contract_dims); Col2im( col_buffer_data, dims.in_depth, dims.spatial_dims[0].input_size, dims.spatial_dims[1].input_size, dims.spatial_dims[0].filter_size, dims.spatial_dims[1].filter_size, pad_top, pad_left, pad_bottom, pad_right, dims.spatial_dims[0].stride, dims.spatial_dims[1].stride, input_backprop_data); input_backprop_data += input_offset; } } else { for (int image_id = 0; image_id < dims.batch_size; image_id += shard_size) { const int shard_limit = std::min(static_cast(shard_size), static_cast(dims.batch_size) - image_id); auto shard = [&context, &dims, &pad_top, &pad_left, &pad_bottom, &pad_right, &output_image_size, &filter_total_size, &input_backprop_data, &col_buffer_data, &out_backprop_data, &filter_data, &input_offset, &output_offset, &size_C](int64 start, int64 limit) { for (int shard_id = start; shard_id < limit; ++shard_id) { T* im2col_buf = col_buffer_data + shard_id * size_C; T* input_data = input_backprop_data + shard_id * input_offset; const T* out_data = out_backprop_data + shard_id * output_offset; Conv2DCustomBackpropInputMatMulFunctor()( context, out_data, filter_data, filter_total_size, output_image_size, dims.out_depth, im2col_buf); Col2im(im2col_buf, dims.in_depth, dims.spatial_dims[0].input_size, dims.spatial_dims[1].input_size, dims.spatial_dims[0].filter_size, dims.spatial_dims[1].filter_size, pad_top, pad_left, pad_bottom, pad_right, dims.spatial_dims[0].stride, dims.spatial_dims[1].stride, input_data); } }; Shard(worker_threads.num_threads, worker_threads.workers, shard_limit, work_unit_size, shard); input_backprop_data += input_offset * shard_limit; out_backprop_data += output_offset * shard_limit; } } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Divide By Zero"], "explanation": "TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a division by 0 in `tf.raw_ops.Conv2DBackpropInput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/b40060c9f697b044e3107917c797ba052f4506ab/tensorflow/core/kernels/conv_grad_input_ops.h#L625-L655) does a division by a quantity that is controlled by the caller. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.", "severity_level": "NoInfo", "cwe": "CWE-369", "cve": "CVE-2021-29525"}} -{"idx": 487411, "input": "isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev) { struct ethhdr *eth; unsigned char *rawp; skb_reset_mac_header(skb); skb_pull(skb, ETH_HLEN); eth = eth_hdr(skb); if (*eth->h_dest & 1) { if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0) skb->pkt_type = PACKET_BROADCAST; else skb->pkt_type = PACKET_MULTICAST; } /* * This ALLMULTI check should be redundant by 1.4 * so don't forget to remove it. */ else if (dev->flags & (IFF_PROMISC /*| IFF_ALLMULTI*/)) { if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN)) skb->pkt_type = PACKET_OTHERHOST; } if (ntohs(eth->h_proto) >= 1536) return eth->h_proto; rawp = skb->data; /* * This is a magic hack to spot IPX packets. Older Novell breaks * the protocol design and runs IPX over 802.3 without an 802.2 LLC * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This * won't work for fault tolerant netware but does for the rest. */ if (*(unsigned short *) rawp == 0xFFFF) return htons(ETH_P_802_3); /* * Real 802.2 LLC */ return htons(ETH_P_802_2); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 375318, "input": "static inline bool sig_handler_ignored(void __user *handler, int sig) { /* Is it explicitly or implicitly ignored? */ return handler == SIG_IGN || (handler == SIG_DFL && sig_kernel_ignore(sig)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 438554, "input": "MagickExport MagickBooleanType SetImageBackgroundColor(Image *image) { CacheView *image_view; ExceptionInfo *exception; IndexPacket index; MagickBooleanType status; MagickPixelPacket background; PixelPacket pixel; ssize_t y; assert(image != (Image *) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\"); assert(image->signature == MagickCoreSignature); if (SetImageStorageClass(image,DirectClass) == MagickFalse) return(MagickFalse); if ((IsPixelGray(&image->background_color) == MagickFalse) && (IsGrayColorspace(image->colorspace) != MagickFalse)) (void) TransformImageColorspace(image,RGBColorspace); if ((image->background_color.opacity != OpaqueOpacity) && (image->matte == MagickFalse)) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel); GetMagickPixelPacket(image,&background); SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *) NULL,&background); if (image->colorspace == CMYKColorspace) ConvertRGBToCMYK(&background); index=0; pixel.opacity=OpaqueOpacity; SetPixelPacket(image,&background,&pixel,&index); /* Set image background color. */ status=MagickTrue; exception=(&image->exception); image_view=AcquireAuthenticCacheView(image,exception); for (y=0; y < (ssize_t) image->rows; y++) { register PixelPacket *magick_restrict q; register ssize_t x; if (status == MagickFalse) continue; q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } for (x=0; x < (ssize_t) image->columns; x++) *q++=pixel; if (image->colorspace == CMYKColorspace) { register IndexPacket *magick_restrict indexes; indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) SetPixelIndex(indexes+x,index); } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; } image_view=DestroyCacheView(image_view); return(status); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409222, "input": "static const char *uvc_print_chain(struct uvc_video_chain *chain) { static char buffer[43]; char *p = buffer; p += uvc_print_terms(&chain->entities, UVC_TERM_INPUT, p); p += sprintf(p, \" -> \"); uvc_print_terms(&chain->entities, UVC_TERM_OUTPUT, p); return buffer; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 303121, "input": "int blosc_set_nthreads(int nthreads_new) { int ret = g_nthreads; /* the previous number of threads */ /* Check whether the library should be initialized */ if (!g_initlib) blosc_init(); if (nthreads_new != ret) { g_nthreads = nthreads_new; g_global_context->new_nthreads = nthreads_new; check_nthreads(g_global_context); } return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 421574, "input": "lka_report_smtp_tx_envelope(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, uint64_t evpid) { report_smtp_broadcast(reqid, direction, tv, \"tx-envelope\", \"%08x|%016\"PRIx64\"\\n\", msgid, evpid); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432502, "input": "static inline void avic_post_state_restore(struct kvm_vcpu *vcpu) { if (avic_handle_apic_id_update(vcpu) != 0) return; avic_handle_dfr_update(vcpu); avic_handle_ldr_update(vcpu); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 208276, "input": "static int flattenSubquery( Parse *pParse, /* Parsing context */ Select *p, /* The parent or outer SELECT statement */ int iFrom, /* Index in p->pSrc->a[] of the inner subquery */ int isAgg /* True if outer SELECT uses aggregate functions */ ){ const char *zSavedAuthContext = pParse->zAuthContext; Select *pParent; /* Current UNION ALL term of the other query */ Select *pSub; /* The inner query or \"subquery\" */ Select *pSub1; /* Pointer to the rightmost select in sub-query */ SrcList *pSrc; /* The FROM clause of the outer query */ SrcList *pSubSrc; /* The FROM clause of the subquery */ int iParent; /* VDBE cursor number of the pSub result set temp table */ int iNewParent = -1;/* Replacement table for iParent */ int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ int i; /* Loop counter */ Expr *pWhere; /* The WHERE clause */ struct SrcList_item *pSubitem; /* The subquery */ sqlite3 *db = pParse->db; /* Check to see if flattening is permitted. Return 0 if not. */ assert( p!=0 ); assert( p->pPrior==0 ); if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0; pSrc = p->pSrc; assert( pSrc && iFrom>=0 && iFromnSrc ); pSubitem = &pSrc->a[iFrom]; iParent = pSubitem->iCursor; pSub = pSubitem->pSelect; assert( pSub!=0 ); #ifndef SQLITE_OMIT_WINDOWFUNC if( p->pWin || pSub->pWin ) return 0; /* Restriction (25) */ #endif pSubSrc = pSub->pSrc; assert( pSubSrc ); /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET ** because they could be computed at compile-time. But when LIMIT and OFFSET ** became arbitrary expressions, we were forced to add restrictions (13) ** and (14). */ if( pSub->pLimit && p->pLimit ) return 0; /* Restriction (13) */ if( pSub->pLimit && pSub->pLimit->pRight ) return 0; /* Restriction (14) */ if( (p->selFlags & SF_Compound)!=0 && pSub->pLimit ){ return 0; /* Restriction (15) */ } if( pSubSrc->nSrc==0 ) return 0; /* Restriction (7) */ if( pSub->selFlags & SF_Distinct ) return 0; /* Restriction (4) */ if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){ return 0; /* Restrictions (8)(9) */ } if( p->pOrderBy && pSub->pOrderBy ){ return 0; /* Restriction (11) */ } if( isAgg && pSub->pOrderBy ) return 0; /* Restriction (16) */ if( pSub->pLimit && p->pWhere ) return 0; /* Restriction (19) */ if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){ return 0; /* Restriction (21) */ } if( pSub->selFlags & (SF_Recursive) ){ return 0; /* Restrictions (22) */ } /* ** If the subquery is the right operand of a LEFT JOIN, then the ** subquery may not be a join itself (3a). Example of why this is not ** allowed: ** ** t1 LEFT OUTER JOIN (t2 JOIN t3) ** ** If we flatten the above, we would get ** ** (t1 LEFT OUTER JOIN t2) JOIN t3 ** ** which is not at all the same thing. ** ** If the subquery is the right operand of a LEFT JOIN, then the outer ** query cannot be an aggregate. (3c) This is an artifact of the way ** aggregates are processed - there is no mechanism to determine if ** the LEFT JOIN table should be all-NULL. ** ** See also tickets #306, #350, and #3300. */ if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ isLeftJoin = 1; if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){ /* (3a) (3c) (3b) */ return 0; } } #ifdef SQLITE_EXTRA_IFNULLROW else if( iFrom>0 && !isAgg ){ /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for ** every reference to any result column from subquery in a join, even ** though they are not necessary. This will stress-test the OP_IfNullRow ** opcode. */ isLeftJoin = -1; } #endif /* Restriction (17): If the sub-query is a compound SELECT, then it must ** use only the UNION ALL operator. And none of the simple select queries ** that make up the compound SELECT are allowed to be aggregate or distinct ** queries. */ if( pSub->pPrior ){ if( pSub->pOrderBy ){ return 0; /* Restriction (20) */ } if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){ return 0; /* (17d1), (17d2), or (17d3) */ } for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){ testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct ); testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate ); assert( pSub->pSrc!=0 ); assert( pSub->pEList->nExpr==pSub1->pEList->nExpr ); if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 /* (17b) */ || (pSub1->pPrior && pSub1->op!=TK_ALL) /* (17a) */ || pSub1->pSrc->nSrc<1 /* (17c) */ ){ return 0; } testcase( pSub1->pSrc->nSrc>1 ); } /* Restriction (18). */ if( p->pOrderBy ){ int ii; for(ii=0; iipOrderBy->nExpr; ii++){ if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0; } } } /* Ex-restriction (23): ** The only way that the recursive part of a CTE can contain a compound ** subquery is for the subquery to be one term of a join. But if the ** subquery is a join, then the flattening has already been stopped by ** restriction (17d3) */ assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 ); /***** If we reach this point, flattening is permitted. *****/ SELECTTRACE(1,pParse,p,(\"flatten %u.%p from term %d\\n\", pSub->selId, pSub, iFrom)); /* Authorize the subquery */ pParse->zAuthContext = pSubitem->zName; TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0); testcase( i==SQLITE_DENY ); pParse->zAuthContext = zSavedAuthContext; /* If the sub-query is a compound SELECT statement, then (by restrictions ** 17 and 18 above) it must be a UNION ALL and the parent query must ** be of the form: ** ** SELECT FROM () ** ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or ** OFFSET clauses and joins them to the left-hand-side of the original ** using UNION ALL operators. In this case N is the number of simple ** select statements in the compound sub-query. ** ** Example: ** ** SELECT a+1 FROM ( ** SELECT x FROM tab ** UNION ALL ** SELECT y FROM tab ** UNION ALL ** SELECT abs(z*2) FROM tab2 ** ) WHERE a!=5 ORDER BY 1 ** ** Transformed into: ** ** SELECT x+1 FROM tab WHERE x+1!=5 ** UNION ALL ** SELECT y+1 FROM tab WHERE y+1!=5 ** UNION ALL ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 ** ORDER BY 1 ** ** We call this the \"compound-subquery flattening\". */ for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){ Select *pNew; ExprList *pOrderBy = p->pOrderBy; Expr *pLimit = p->pLimit; Select *pPrior = p->pPrior; p->pOrderBy = 0; p->pSrc = 0; p->pPrior = 0; p->pLimit = 0; pNew = sqlite3SelectDup(db, p, 0); p->pLimit = pLimit; p->pOrderBy = pOrderBy; p->pSrc = pSrc; p->op = TK_ALL; if( pNew==0 ){ p->pPrior = pPrior; }else{ pNew->pPrior = pPrior; if( pPrior ) pPrior->pNext = pNew; pNew->pNext = p; p->pPrior = pNew; SELECTTRACE(2,pParse,p,(\"compound-subquery flattener\" \" creates %u as peer\\n\",pNew->selId)); } if( db->mallocFailed ) return 1; } /* Begin flattening the iFrom-th entry of the FROM clause ** in the outer query. */ pSub = pSub1 = pSubitem->pSelect; /* Delete the transient table structure associated with the ** subquery */ sqlite3DbFree(db, pSubitem->zDatabase); sqlite3DbFree(db, pSubitem->zName); sqlite3DbFree(db, pSubitem->zAlias); pSubitem->zDatabase = 0; pSubitem->zName = 0; pSubitem->zAlias = 0; pSubitem->pSelect = 0; /* Defer deleting the Table object associated with the ** subquery until code generation is ** complete, since there may still exist Expr.pTab entries that ** refer to the subquery even after flattening. Ticket #3346. ** ** pSubitem->pTab is always non-NULL by test restrictions and tests above. */ if( ALWAYS(pSubitem->pTab!=0) ){ Table *pTabToDel = pSubitem->pTab; if( pTabToDel->nTabRef==1 ){ Parse *pToplevel = sqlite3ParseToplevel(pParse); pTabToDel->pNextZombie = pToplevel->pZombieTab; pToplevel->pZombieTab = pTabToDel; }else{ pTabToDel->nTabRef--; } pSubitem->pTab = 0; } /* The following loop runs once for each term in a compound-subquery ** flattening (as described above). If we are doing a different kind ** of flattening - a flattening other than a compound-subquery flattening - ** then this loop only runs once. ** ** This loop moves all of the FROM elements of the subquery into the ** the FROM clause of the outer query. Before doing this, remember ** the cursor number for the original outer query FROM element in ** iParent. The iParent cursor will never be used. Subsequent code ** will scan expressions looking for iParent references and replace ** those references with expressions that resolve to the subquery FROM ** elements we are now copying in. */ for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){ int nSubSrc; u8 jointype = 0; assert( pSub!=0 ); pSubSrc = pSub->pSrc; /* FROM clause of subquery */ nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */ pSrc = pParent->pSrc; /* FROM clause of the outer query */ if( pSrc ){ assert( pParent==p ); /* First time through the loop */ jointype = pSubitem->fg.jointype; }else{ assert( pParent!=p ); /* 2nd and subsequent times through the loop */ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); if( pSrc==0 ) break; pParent->pSrc = pSrc; } /* The subquery uses a single slot of the FROM clause of the outer ** query. If the subquery has more than one element in its FROM clause, ** then expand the outer query to make space for it to hold all elements ** of the subquery. ** ** Example: ** ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; ** ** The outer query has 3 slots in its FROM clause. One slot of the ** outer query (the middle slot) is used by the subquery. The next ** block of code will expand the outer query FROM clause to 4 slots. ** The middle slot is expanded to two slots in order to make space ** for the two elements in the FROM clause of the subquery. */ if( nSubSrc>1 ){ pSrc = sqlite3SrcListEnlarge(pParse, pSrc, nSubSrc-1,iFrom+1); if( pSrc==0 ) break; pParent->pSrc = pSrc; } /* Transfer the FROM clause terms from the subquery into the ** outer query. */ for(i=0; ia[i+iFrom].pUsing); assert( pSrc->a[i+iFrom].fg.isTabFunc==0 ); pSrc->a[i+iFrom] = pSubSrc->a[i]; iNewParent = pSubSrc->a[i].iCursor; memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); } pSrc->a[iFrom].fg.jointype = jointype; /* Now begin substituting subquery result set expressions for ** references to the iParent in the outer query. ** ** Example: ** ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; ** \\ \\_____________ subquery __________/ / ** \\_____________________ outer query ______________________________/ ** ** We look at every expression in the outer query and every place we see ** \"a\" we substitute \"x*3\" and every place we see \"b\" we substitute \"y+10\". */ if( pSub->pOrderBy ){ /* At this point, any non-zero iOrderByCol values indicate that the ** ORDER BY column expression is identical to the iOrderByCol'th ** expression returned by SELECT statement pSub. Since these values ** do not necessarily correspond to columns in SELECT statement pParent, ** zero them before transfering the ORDER BY clause. ** ** Not doing this may cause an error if a subsequent call to this ** function attempts to flatten a compound sub-query into pParent ** (the only way this can happen is if the compound sub-query is ** currently part of pSub->pSrc). See ticket [d11a6e908f]. */ ExprList *pOrderBy = pSub->pOrderBy; for(i=0; inExpr; i++){ pOrderBy->a[i].u.x.iOrderByCol = 0; } assert( pParent->pOrderBy==0 ); pParent->pOrderBy = pOrderBy; pSub->pOrderBy = 0; } pWhere = pSub->pWhere; pSub->pWhere = 0; if( isLeftJoin>0 ){ sqlite3SetJoinExpr(pWhere, iNewParent); } pParent->pWhere = sqlite3ExprAnd(pParse, pWhere, pParent->pWhere); if( db->mallocFailed==0 ){ SubstContext x; x.pParse = pParse; x.iTable = iParent; x.iNewTable = iNewParent; x.isLeftJoin = isLeftJoin; x.pEList = pSub->pEList; substSelect(&x, pParent, 0); } /* The flattened query is a compound if either the inner or the ** outer query is a compound. */ pParent->selFlags |= pSub->selFlags & SF_Compound; assert( (pSub->selFlags & SF_Distinct)==0 ); /* restriction (17b) */ /* ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; ** ** One is tempted to try to add a and b to combine the limits. But this ** does not work if either limit is negative. */ if( pSub->pLimit ){ pParent->pLimit = pSub->pLimit; pSub->pLimit = 0; } } /* Finially, delete what is left of the subquery and return ** success. */ sqlite3SelectDelete(db, pSub1); #if SELECTTRACE_ENABLED if( sqlite3SelectTrace & 0x100 ){ SELECTTRACE(0x100,pParse,p,(\"After flattening:\\n\")); sqlite3TreeViewSelect(0, p, 0); } #endif return 1; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "flattenSubquery in select.c in SQLite 3.30.1 mishandles certain uses of SELECT DISTINCT involving a LEFT JOIN in which the right-hand side is a view. This can cause a NULL pointer dereference (or incorrect results).", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2019-19923"}} -{"idx": 499680, "input": "get_inode_and_dev (struct cpio_file_stat *hdr, struct stat *st) { if (renumber_inodes_option) { if (st->st_nlink > 1) { struct inode_val *ival = find_inode_val (st->st_ino, major (st->st_dev), minor (st->st_dev)); if (!ival) ival = add_inode (st->st_ino, NULL, major (st->st_dev), minor (st->st_dev)); hdr->c_ino = ival->trans_inode; } else hdr->c_ino = next_inode++; } else hdr->c_ino = st->st_ino; if (ignore_devno_option) { hdr->c_dev_maj = 0; hdr->c_dev_min = 0; } else { hdr->c_dev_maj = major (st->st_dev); hdr->c_dev_min = minor (st->st_dev); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 509325, "input": "Item_func_or_sum(THD *thd, Item *a, Item *b, Item *c): Item_result_field(thd), Item_args(thd, a, b, c) { }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 357333, "input": "static OPJ_BOOL opj_j2k_read_rgn(opj_j2k_t *p_j2k, OPJ_BYTE * p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t * p_manager ) { OPJ_UINT32 l_nb_comp; opj_image_t * l_image = 00; opj_cp_t *l_cp = 00; opj_tcp_t *l_tcp = 00; OPJ_UINT32 l_comp_room, l_comp_no, l_roi_sty; /* preconditions*/ assert(p_header_data != 00); assert(p_j2k != 00); assert(p_manager != 00); l_image = p_j2k->m_private_image; l_nb_comp = l_image->numcomps; if (l_nb_comp <= 256) { l_comp_room = 1; } else { l_comp_room = 2; } if (p_header_size != 2 + l_comp_room) { opj_event_msg(p_manager, EVT_ERROR, \"Error reading RGN marker\\n\"); return OPJ_FALSE; } l_cp = &(p_j2k->m_cp); l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp; opj_read_bytes(p_header_data, &l_comp_no, l_comp_room); /* Crgn */ p_header_data += l_comp_room; opj_read_bytes(p_header_data, &l_roi_sty, 1); /* Srgn */ ++p_header_data; #ifdef USE_JPWL if (l_cp->correct) { /* totlen is negative or larger than the bytes left!!! */ if (l_comp_room >= l_nb_comp) { opj_event_msg(p_manager, EVT_ERROR, \"JPWL: bad component number in RGN (%d when there are only %d)\\n\", l_comp_room, l_nb_comp); if (!JPWL_ASSUME) { opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\"); return OPJ_FALSE; } } }; #endif /* USE_JPWL */ /* testcase 3635.pdf.asan.77.2930 */ if (l_comp_no >= l_nb_comp) { opj_event_msg(p_manager, EVT_ERROR, \"bad component number in RGN (%d when there are only %d)\\n\", l_comp_no, l_nb_comp); return OPJ_FALSE; } opj_read_bytes(p_header_data, (OPJ_UINT32 *)(&(l_tcp->tccps[l_comp_no].roishift)), 1); /* SPrgn */ ++p_header_data; return OPJ_TRUE; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198111, "input": "inline int MatchingDim(const RuntimeShape& shape1, int index1, const RuntimeShape& shape2, int index2) { TFLITE_DCHECK_EQ(shape1.Dims(index1), shape2.Dims(index2)); return shape1.Dims(index1); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "In tensorflow-lite before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1 and 2.3.1, when determining the common dimension size of two tensors, TFLite uses a `DCHECK` which is no-op outside of debug compilation modes. Since the function always returns the dimension of the first tensor, malicious attackers can craft cases where this is larger than that of the second tensor. In turn, this would result in reads/writes outside of bounds since the interpreter will wrongly assume that there is enough data in both tensors. The issue is patched in commit 8ee24e7949a203d234489f9da2c5bf45a7d5157d, and is released in TensorFlow versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, or 2.3.1.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-15208"}} -{"idx": 364103, "input": "static void xdp_clear_umem_at_qid(struct net_device *dev, u16 queue_id) { if (queue_id < dev->real_num_rx_queues) dev->_rx[queue_id].umem = NULL; if (queue_id < dev->real_num_tx_queues) dev->_tx[queue_id].umem = NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 341908, "input": "int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid, loff_t offset, loff_t len) { struct fuse_inode *fi; struct inode *inode; pgoff_t pg_start; pgoff_t pg_end; inode = fuse_ilookup(fc, nodeid, NULL); if (!inode) return -ENOENT; fi = get_fuse_inode(inode); spin_lock(&fi->lock); fi->attr_version = atomic64_inc_return(&fc->attr_version); spin_unlock(&fi->lock); fuse_invalidate_attr(inode); forget_all_cached_acls(inode); if (offset >= 0) { pg_start = offset >> PAGE_SHIFT; if (len <= 0) pg_end = -1; else pg_end = (offset + len - 1) >> PAGE_SHIFT; invalidate_inode_pages2_range(inode->i_mapping, pg_start, pg_end); } iput(inode); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219404, "input": "bool HHVM_FUNCTION(imageellipse, const Resource& image, int64_t cx, int64_t cy, int64_t width, int64_t height, int64_t color) { gdImagePtr im = get_valid_image_resource(image); if (!im) return false; color = SetupAntiAliasedColor(im, color); gdImageArc(im, cx, cy, width, height, 0, 360, color); return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 243212, "input": "void dump_isom_timed_text(GF_ISOFile *file, GF_ISOTrackID trackID, char *inName, Bool is_final_name, Bool is_convert, GF_TextDumpType dump_type) { FILE *dump; GF_Err e; u32 track; track = gf_isom_get_track_by_id(file, trackID); if (!track) { M4_LOG(GF_LOG_ERROR, (\"Cannot find track ID %d\\n\", trackID)); return; } switch (gf_isom_get_media_type(file, track)) { case GF_ISOM_MEDIA_TEXT: case GF_ISOM_MEDIA_SUBT: break; default: M4_LOG(GF_LOG_ERROR, (\"Track ID %d is not a 3GPP text track\\n\", trackID)); return; } if (inName) { char szBuf[1024]; char *ext; ext = ((dump_type==GF_TEXTDUMPTYPE_SVG) ? \"svg\" : ((dump_type==GF_TEXTDUMPTYPE_SRT) ? \"srt\" : \"ttxt\")); if (is_final_name) { strcpy(szBuf, inName) ; } else if (is_convert) sprintf(szBuf, \"%s.%s\", inName, ext) ; else sprintf(szBuf, \"%s_%d_text.%s\", inName, trackID, ext); dump = gf_fopen(szBuf, \"wt\"); if (!dump) { M4_LOG(GF_LOG_ERROR, (\"Failed to open %s for dumping\\n\", szBuf)); return; } } else { dump = stdout; } e = gf_isom_text_dump(file, track, dump, dump_type); if (inName) gf_fclose(dump); if (e) { M4_LOG(GF_LOG_ERROR, (\"Conversion failed (%s)\\n\", gf_error_to_string(e))); } else { fprintf(stderr, \"Conversion done\\n\");", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 404418, "input": "static SVGInfo *DestroySVGInfo(SVGInfo *svg_info) { if (svg_info->size != (char *) NULL) svg_info->size=DestroyString(svg_info->size); if (svg_info->text != (char *) NULL) svg_info->text=DestroyString(svg_info->text); if (svg_info->scale != (double *) NULL) svg_info->scale=(double *) RelinquishMagickMemory(svg_info->scale); if (svg_info->title != (char *) NULL) svg_info->title=DestroyString(svg_info->title); if (svg_info->comment != (char *) NULL) svg_info->comment=DestroyString(svg_info->comment); return((SVGInfo *) RelinquishMagickMemory(svg_info)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393298, "input": "TEST_F(QueryPlannerTest, ContainedOrPredicateIsLeadingFieldMoveToAnd) { addIndex(BSON(\"a\" << 1 << \"b\" << 1 << \"c\" << 1)); addIndex(BSON(\"a\" << 1 << \"d\" << 1)); runQuery(fromjson(\"{$and: [{a: 5}, {$or: [{$and: [{b: 6}, {c: 7}]}, {d: 8}]}]}\")); assertNumSolutions(4); assertSolutionExists( \"{fetch: {filter: null, node: {or: {nodes: [\" \"{ixscan: {pattern: {a: 1, b: 1, c: 1}, bounds: {a: [[5, 5, true, true]], b: [[6, 6, true, \" \"true]], c: [[7, 7, true, true]]}}},\" \"{ixscan: {pattern: {a: 1, d: 1}, bounds: {a: [[5, 5, true, true]], d: [[8, 8, true, \" \"true]]}}}\" \"]}}}}\"); assertSolutionExists( \"{fetch: {filter: {$or: [{$and: [{b: 6}, {c: 7}]}, {d: 8}]}, node: \" \"{ixscan: {pattern: {a: 1, b: 1, c: 1}, bounds: {a: [[5, 5, true, true]], b: [['MinKey', \" \"'MaxKey', true, true]], c: [['MinKey', 'MaxKey', true, true]]}}}\" \"}}\"); assertSolutionExists( \"{fetch: {filter: {$or: [{$and: [{b: 6}, {c: 7}]}, {d: 8}]}, node: \" \"{ixscan: {pattern: {a: 1, d: 1}, bounds: {a: [[5, 5, true, true]], d: [['MinKey', \" \"'MaxKey', true, true]]}}}\" \"}}\"); assertSolutionExists(\"{cscan: {dir: 1}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 468907, "input": "table_close_all(struct smtpd *conf) { struct table *t; void *iter; iter = NULL; while (dict_iter(conf->sc_tables_dict, &iter, NULL, (void **)&t)) table_close(t); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 445831, "input": "static inline void ftrace_exports_disable(void) { static_branch_disable(&ftrace_exports_enabled); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 453396, "input": "*/ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq) { struct bfq_queue *bfqq = RQ_BFQQ(rq); /* * For consistency, the next instruction should have been * executed after removing the request from the queue and * dispatching it. We execute instead this instruction before * bfq_remove_request() (and hence introduce a temporary * inconsistency), for efficiency. In fact, should this * dispatch occur for a non in-service bfqq, this anticipated * increment prevents two counters related to bfqq->dispatched * from risking to be, first, uselessly decremented, and then * incremented again when the (new) value of bfqq->dispatched * happens to be taken into account. */ bfqq->dispatched++; bfq_update_peak_rate(q->elevator->elevator_data, rq); bfq_remove_request(q, rq);", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280110, "input": "static inline unsigned int oo_order(struct kmem_cache_order_objects x) { return x.x >> OO_SHIFT; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 102018, "input": "void ContentSettingsStore::NotifyOfContentSettingChanged( const std::string& extension_id, bool incognito) { FOR_EACH_OBSERVER( ContentSettingsStore::Observer, observers_, OnContentSettingChanged(extension_id, incognito)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 374738, "input": "void perf_event_print_debug(void) { unsigned long sdar, sier, flags; u32 pmcs[MAX_HWEVENTS]; int i; if (!ppmu) { pr_info(\"Performance monitor hardware not registered.\\n\"); return; } if (!ppmu->n_counter) return; local_irq_save(flags); pr_info(\"CPU: %d PMU registers, ppmu = %s n_counters = %d\", smp_processor_id(), ppmu->name, ppmu->n_counter); for (i = 0; i < ppmu->n_counter; i++) pmcs[i] = read_pmc(i + 1); for (; i < MAX_HWEVENTS; i++) pmcs[i] = 0xdeadbeef; pr_info(\"PMC1: %08x PMC2: %08x PMC3: %08x PMC4: %08x\\n\", pmcs[0], pmcs[1], pmcs[2], pmcs[3]); if (ppmu->n_counter > 4) pr_info(\"PMC5: %08x PMC6: %08x PMC7: %08x PMC8: %08x\\n\", pmcs[4], pmcs[5], pmcs[6], pmcs[7]); pr_info(\"MMCR0: %016lx MMCR1: %016lx MMCRA: %016lx\\n\", mfspr(SPRN_MMCR0), mfspr(SPRN_MMCR1), mfspr(SPRN_MMCRA)); sdar = sier = 0; #ifdef CONFIG_PPC64 sdar = mfspr(SPRN_SDAR); if (ppmu->flags & PPMU_HAS_SIER) sier = mfspr(SPRN_SIER); if (ppmu->flags & PPMU_ARCH_207S) { pr_info(\"MMCR2: %016lx EBBHR: %016lx\\n\", mfspr(SPRN_MMCR2), mfspr(SPRN_EBBHR)); pr_info(\"EBBRR: %016lx BESCR: %016lx\\n\", mfspr(SPRN_EBBRR), mfspr(SPRN_BESCR)); } if (ppmu->flags & PPMU_ARCH_31) { pr_info(\"MMCR3: %016lx SIER2: %016lx SIER3: %016lx\\n\", mfspr(SPRN_MMCR3), mfspr(SPRN_SIER2), mfspr(SPRN_SIER3)); } #endif pr_info(\"SIAR: %016lx SDAR: %016lx SIER: %016lx\\n\", mfspr(SPRN_SIAR), sdar, sier); local_irq_restore(flags); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 308294, "input": "XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end) { if (parser == NULL) return; startDoctypeDeclHandler = start; endDoctypeDeclHandler = end; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 509406, "input": "void save_val(Field *to) { if (check_null_ref()) to->set_null(); else Item_direct_ref::save_val(to); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 234394, "input": "static int ff_layout_async_handle_error_v3(struct rpc_task *task, struct pnfs_layout_segment *lseg, u32 idx) { struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx); switch (task->tk_status) { /* File access problems. Don't mark the device as unavailable */ case -EACCES: case -ESTALE: case -EISDIR: case -EBADHANDLE: case -ELOOP: case -ENOSPC: break; case -EJUKEBOX: nfs_inc_stats(lseg->pls_layout->plh_inode, NFSIOS_DELAY); goto out_retry; default: dprintk(\"%s DS connection error %d\\n\", __func__, task->tk_status); nfs4_delete_deviceid(devid->ld, devid->nfs_client, &devid->deviceid); } /* FIXME: Need to prevent infinite looping here. */ return -NFS4ERR_RESET_TO_PNFS; out_retry: task->tk_status = 0; rpc_restart_call_prepare(task); rpc_delay(task, NFS_JUKEBOX_RETRY_TIME); return -EAGAIN; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 244779, "input": "static void* cdeque_filter(struct filter_info* f) { return (void**) (size_t) f; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219441, "input": "const char *data() const { return m_str ? m_str->data() : \"\"; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 207262, "input": "LJ_NOINLINE void lj_err_run(lua_State *L) { ptrdiff_t ef = finderrfunc(L); if (ef) { TValue *errfunc = restorestack(L, ef); TValue *top = L->top; lj_trace_abort(G(L)); if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); lj_err_throw(L, LUA_ERRERR); } L->status = LUA_ERRERR; copyTV(L, top, top-1); copyTV(L, top-1, errfunc); L->top = top+1; lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ } lj_err_throw(L, LUA_ERRRUN); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Read"], "explanation": "LuaJIT through 2.1.0-beta3 has an out-of-bounds read in lj_err_run in lj_err.c.", "severity_level": "NoInfo", "cwe": "CWE-125", "cve": "CVE-2020-24372"}} -{"idx": 509436, "input": "Item_func_or_sum(THD *thd): Item_result_field(thd), Item_args() {}", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431024, "input": "static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type) { __be32 *p; p = reserve_space(xdr, 4); *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); encode_delegation_type(xdr, type); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 430852, "input": "UnicodeString::UnicodeString(UnicodeString &&src) U_NOEXCEPT { copyFieldsFrom(src, TRUE); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 371763, "input": "MagickExport size_t GetOptimalKernelWidth2D(const double radius, const double sigma) { double alpha, beta, gamma, normalize, value; size_t width; ssize_t j, u, v; (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\"); if (radius > MagickEpsilon) return((size_t) (2.0*ceil(radius)+1.0)); gamma=fabs(sigma); if (gamma <= MagickEpsilon) return(3UL); alpha=PerceptibleReciprocal(2.0*gamma*gamma); beta=(double) PerceptibleReciprocal((double) Magick2PI*gamma*gamma); for (width=5; ; ) { normalize=0.0; j=(ssize_t) (width-1)/2; for (v=(-j); v <= j; v++) for (u=(-j); u <= j; u++) normalize+=exp(-((double) (u*u+v*v))*alpha)*beta; value=exp(-((double) (j*j))*alpha)*beta/normalize; if ((value < QuantumScale) || (value < MagickEpsilon)) break; width+=2; } return((size_t) (width-2)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281295, "input": "void RGWPutObjTags_ObjStore_S3::send_response() { if (op_ret) set_req_state_err(s, op_ret); dump_errno(s); end_header(s, this, \"application/xml\"); dump_start(s); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 303056, "input": "static int parallel_blosc(blosc2_context* context) { #ifdef BLOSC_POSIX_BARRIERS int rc; #endif /* Set sentinels */ context->thread_giveup_code = 1; context->thread_nblock = -1; if (threads_callback) { threads_callback(threads_callback_data, t_blosc_do_job, context->nthreads, sizeof(struct thread_context), (void*) context->thread_contexts); } else { /* Synchronization point for all threads (wait for initialization) */ WAIT_INIT(-1, context); /* Synchronization point for all threads (wait for finalization) */ WAIT_FINISH(-1, context); } if (context->thread_giveup_code <= 0) { /* Compression/decompression gave up. Return error code. */ return context->thread_giveup_code; } /* Return the total bytes (de-)compressed in threads */ return (int)context->output_bytes; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431915, "input": "static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_le_conn_update_complete *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG(\"%s status 0x%2.2x\", hdev->name, ev->status); if (ev->status) return; hci_dev_lock(hdev); conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); if (conn) { conn->le_conn_interval = le16_to_cpu(ev->interval); conn->le_conn_latency = le16_to_cpu(ev->latency); conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); } hci_dev_unlock(hdev); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219438, "input": "PregWithErrorGuard::~PregWithErrorGuard() { if (*rl_last_error_code == PHP_PCRE_NO_ERROR) { error.setNull(); } else { error = *rl_last_error_code; } *rl_last_error_code = prior_error; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 330231, "input": "ex_redraw(exarg_T *eap) { int r = RedrawingDisabled; int p = p_lz; RedrawingDisabled = 0; p_lz = FALSE; validate_cursor(); update_topline(); update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); #ifdef FEAT_TITLE if (need_maketitle) maketitle(); #endif #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) # ifdef VIMDLL if (!gui.in_use) # endif resize_console_buf(); #endif RedrawingDisabled = r; p_lz = p; // Reset msg_didout, so that a message that's there is overwritten. msg_didout = FALSE; msg_col = 0; // No need to wait after an intentional redraw. need_wait_return = FALSE; out_flush(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 196791, "input": "void Compute(OpKernelContext* context) override { // Get inputs const Tensor& input_tensor = context->input(0); const auto input_tensor_flat = input_tensor.flat(); const Tensor& input_splits = context->input(1); const auto input_splits_flat = input_splits.flat(); // Since we limit to a 2-D input (flat_values of rank 1 and a single splits // tensor), our output dimension will be 1 with it's size equal to the // number of splits (outer dimension or ragged tensor). TensorShape output_shape({input_splits.dim_size(0) - 1}); Tensor* output_tensor; OP_REQUIRES_OK(context, context->allocate_output(\"output\", output_shape, &output_tensor)); auto output_tensor_flat = output_tensor->flat(); // Use a single index over the flattened input values tensor. int idx = 0; // Loop through our split dimension to create a new string at each split. for (int i = 1; i < input_splits_flat.size(); ++i) { icu::UnicodeString unicode_string; icu::UnicodeStringAppendable appendable_unicode_string(unicode_string); for (; idx < input_splits_flat(i); ++idx) { int32 code_point = input_tensor_flat(idx); // Check for invalid code point if (!U_IS_UNICODE_CHAR(code_point)) { if (error_options_.error_on_malformatting) { context->CtxFailure(errors::InvalidArgument( \"Code point is out of range for Unicode, or a noncharacter.\")); return; } else if (!error_options_.elide_replacement) { code_point = error_options_.subst; } } appendable_unicode_string.appendCodePoint(code_point); } // Encode our string and save in the output. tstring result; Encode(encoding_, unicode_string, &result); output_tensor_flat(i - 1) = std::move(result); } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "TensorFlow is an end-to-end open source platform for machine learning. An attacker can access data outside of bounds of heap allocated array in `tf.raw_ops.UnicodeEncode`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/472c1f12ad9063405737679d4f6bd43094e1d36d/tensorflow/core/kernels/unicode_ops.cc) assumes that the `input_value`/`input_splits` pair specify a valid sparse tensor. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2021-29559"}} -{"idx": 431555, "input": "static int nfs4_proc_rmdir(struct inode *dir, const struct qstr *name) { struct nfs4_exception exception = { .interruptible = true, }; int err; do { err = _nfs4_proc_remove(dir, name, NF4DIR); trace_nfs4_remove(dir, name, err); err = nfs4_handle_exception(NFS_SERVER(dir), err, &exception); } while (exception.retry); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232622, "input": "static void opt_hard_wire_dead_code_branches(struct bpf_verifier_env *env) { struct bpf_insn_aux_data *aux_data = env->insn_aux_data; struct bpf_insn ja = BPF_JMP_IMM(BPF_JA, 0, 0, 0); struct bpf_insn *insn = env->prog->insnsi; const int insn_cnt = env->prog->len; int i; for (i = 0; i < insn_cnt; i++, insn++) { if (!insn_is_cond_jump(insn->code)) continue; if (!aux_data[i + 1].seen) ja.off = insn->off; else if (!aux_data[i + 1 + insn->off].seen) ja.off = 0; else continue; if (bpf_prog_is_dev_bound(env->prog->aux)) bpf_prog_offload_replace_insn(env, i, &ja); memcpy(insn, &ja, sizeof(ja)); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 336863, "input": "str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte) { const char *pp = str_nth(p, e, nth, enc, singlebyte); if (!pp) return e - p; return pp - p; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393194, "input": "TEST_F(QueryPlannerTest, NegationCantUseSparseIndex2) { // false means not multikey, true means sparse addIndex(BSON(\"i\" << 1 << \"j\" << 1), false, true); runQuery(fromjson(\"{i: 4, j: {$ne: 5}}\")); assertNumSolutions(2U); assertSolutionExists(\"{cscan: {dir: 1}}\"); assertSolutionExists( \"{fetch: {node: {ixscan: {pattern: {i:1,j:1}, bounds: \" \"{i: [[4,4,true,true]], j: [['MinKey','MaxKey',true,true]]}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 461601, "input": "static void emit_bpf_tail_call_direct(struct bpf_jit_poke_descriptor *poke, u8 **pprog, int addr, u8 *image, bool *callee_regs_used, u32 stack_depth) { int tcc_off = -4 - round_up(stack_depth, 8); u8 *prog = *pprog; int pop_bytes = 0; int off1 = 20; int poke_off; int cnt = 0; /* count the additional bytes used for popping callee regs to stack * that need to be taken into account for jump offset that is used for * bailing out from of the tail call when limit is reached */ pop_bytes = get_pop_bytes(callee_regs_used); off1 += pop_bytes; /* * total bytes for: * - nop5/ jmpq $off * - pop callee regs * - sub rsp, $val if depth > 0 * - pop rax */ poke_off = X86_PATCH_SIZE + pop_bytes + 1; if (stack_depth) { poke_off += 7; off1 += 7; } /* * if (tail_call_cnt > MAX_TAIL_CALL_CNT) * goto out; */ EMIT2_off32(0x8B, 0x85, tcc_off); /* mov eax, dword ptr [rbp - tcc_off] */ EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ EMIT2(X86_JA, off1); /* ja out */ EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ EMIT2_off32(0x89, 0x85, tcc_off); /* mov dword ptr [rbp - tcc_off], eax */ poke->tailcall_bypass = image + (addr - poke_off - X86_PATCH_SIZE); poke->adj_off = X86_TAIL_CALL_OFFSET; poke->tailcall_target = image + (addr - X86_PATCH_SIZE); poke->bypass_addr = (u8 *)poke->tailcall_target + X86_PATCH_SIZE; emit_jump(&prog, (u8 *)poke->tailcall_target + X86_PATCH_SIZE, poke->tailcall_bypass); *pprog = prog; pop_callee_regs(pprog, callee_regs_used); prog = *pprog; EMIT1(0x58); /* pop rax */ if (stack_depth) EMIT3_off32(0x48, 0x81, 0xC4, round_up(stack_depth, 8)); memcpy(prog, ideal_nops[NOP_ATOMIC5], X86_PATCH_SIZE); prog += X86_PATCH_SIZE; /* out: */ *pprog = prog; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431296, "input": "static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen) { struct nfs4_exception exception = { }; int err; do { err = __nfs4_proc_set_acl(inode, buf, buflen); trace_nfs4_set_acl(inode, err); err = nfs4_handle_exception(NFS_SERVER(inode), err, &exception); } while (exception.retry); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198944, "input": "xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) { xmlParserCtxtPtr ctxt = NULL; xmlDocPtr ret; /* xmlInitParser(); */ ctxt = xmlCreateMemoryParserCtxt(buf, buf_size); if (ctxt) { zend_bool old; ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; ctxt->sax->error = NULL; /*ctxt->sax->fatalError = NULL;*/ #if LIBXML_VERSION >= 20703 ctxt->options |= XML_PARSE_HUGE; #endif old = php_libxml_disable_entity_loader(1); xmlParseDocument(ctxt); php_libxml_disable_entity_loader(old); if (ctxt->wellFormed) { ret = ctxt->myDoc; if (ret->URL == NULL && ctxt->directory != NULL) { ret->URL = xmlCharStrdup(ctxt->directory); } } else { ret = NULL; xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL; } xmlFreeParserCtxt(ctxt); } else { ret = NULL; } /* xmlCleanupParser(); */ /* if (ret) { cleanup_xml_node((xmlNodePtr)ret); } */ return ret; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "The SOAP parser in PHP before 5.3.23 and 5.4.x before 5.4.13 allows remote attackers to read arbitrary files via a SOAP WSDL file containing an XML external entity declaration in conjunction with an entity reference, related to an XML External Entity (XXE) issue in the soap_xmlParseFile and soap_xmlParseMemory functions. NOTE: this vulnerability exists because of an incorrect fix for CVE-2013-1824.", "severity_level": "Medium", "cwe": "CWE-200", "cve": "CVE-2013-1643"}} -{"idx": 476898, "input": "static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(\">>> Tracing basic block at 0x%\"PRIx64 \", block size = 0x%x\\n\", address, size); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 376820, "input": "avifDecoder * avifDecoderCreate(void) { avifDecoder * decoder = (avifDecoder *)avifAlloc(sizeof(avifDecoder)); memset(decoder, 0, sizeof(avifDecoder)); return decoder; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432008, "input": "static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_keypress_notify *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG(\"%s\", hdev->name); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (!conn) return; switch (ev->type) { case HCI_KEYPRESS_STARTED: conn->passkey_entered = 0; return; case HCI_KEYPRESS_ENTERED: conn->passkey_entered++; break; case HCI_KEYPRESS_ERASED: conn->passkey_entered--; break; case HCI_KEYPRESS_CLEARED: conn->passkey_entered = 0; break; case HCI_KEYPRESS_COMPLETED: return; } if (hci_dev_test_flag(hdev, HCI_MGMT)) mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, conn->dst_type, conn->passkey_notify, conn->passkey_entered); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 258437, "input": "static int on_ppp_if_up(struct tunnel *tunnel) { log_info(\"Interface %s is UP.\\n\", tunnel->ppp_iface); if (tunnel->config->set_routes) { int ret; log_info(\"Setting new routes...\\n\"); ret = ipv4_set_tunnel_routes(tunnel); if (ret != 0) log_warn(\"Adding route table is incomplete. Please check route table.\\n\"); } if (tunnel->config->set_dns) { log_info(\"Adding VPN nameservers...\\n\"); ipv4_add_nameservers_to_resolv_conf(tunnel); } log_info(\"Tunnel is up and running.\\n\"); #if HAVE_SYSTEMD sd_notify(0, \"READY=1\"); #endif return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 481504, "input": "void rec_wont(struct Curl_easy *data, int option) { struct TELNET *tn = data->req.p.telnet; switch(tn->him[option]) { case CURL_NO: /* Already disabled */ break; case CURL_YES: tn->him[option] = CURL_NO; send_negotiation(data, CURL_DONT, option); break; case CURL_WANTNO: switch(tn->himq[option]) { case CURL_EMPTY: tn->him[option] = CURL_NO; break; case CURL_OPPOSITE: tn->him[option] = CURL_WANTYES; tn->himq[option] = CURL_EMPTY; send_negotiation(data, CURL_DO, option); break; } break; case CURL_WANTYES: switch(tn->himq[option]) { case CURL_EMPTY: tn->him[option] = CURL_NO; break; case CURL_OPPOSITE: tn->him[option] = CURL_NO; tn->himq[option] = CURL_EMPTY; break; } break; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 318156, "input": "static rpmRC hdrblobVerifyLengths(rpmTagVal regionTag, uint32_t il, uint32_t dl, char **emsg) { uint32_t il_max = HEADER_TAGS_MAX; uint32_t dl_max = HEADER_DATA_MAX; if (regionTag == RPMTAG_HEADERSIGNATURES) { il_max = 32; dl_max = 64 * 1024 * 1024; } if (hdrchkRange(il_max, il)) { rasprintf(emsg, _(\"hdr tags: BAD, no. of tags(%\" PRIu32 \") out of range\"), il); return RPMRC_FAIL; } if (hdrchkRange(dl_max, dl)) { rasprintf(emsg, _(\"hdr data: BAD, no. of bytes(%\" PRIu32 \") out of range\"), dl); return RPMRC_FAIL; } return RPMRC_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508735, "input": "free_tmp_table(THD *thd, TABLE *entry) { MEM_ROOT own_root= entry->mem_root; const char *save_proc_info; DBUG_ENTER(\"free_tmp_table\"); DBUG_PRINT(\"enter\",(\"table: %s alias: %s\",entry->s->table_name.str, entry->alias.c_ptr())); save_proc_info=thd->proc_info; THD_STAGE_INFO(thd, stage_removing_tmp_table); if (entry->file && entry->is_created()) { entry->file->ha_index_or_rnd_end(); if (entry->db_stat) { entry->file->info(HA_STATUS_VARIABLE); thd->tmp_tables_size+= (entry->file->stats.data_file_length + entry->file->stats.index_file_length); entry->file->ha_drop_table(entry->s->path.str); } else entry->file->ha_delete_table(entry->s->path.str); delete entry->file; } /* free blobs */ for (Field **ptr=entry->field ; *ptr ; ptr++) (*ptr)->free(); if (entry->temp_pool_slot != MY_BIT_NONE) bitmap_lock_clear_bit(&temp_pool, entry->temp_pool_slot); plugin_unlock(0, entry->s->db_plugin); entry->alias.free(); if (entry->pos_in_table_list && entry->pos_in_table_list->table) { DBUG_ASSERT(entry->pos_in_table_list->table == entry); entry->pos_in_table_list->table= NULL; } free_root(&own_root, MYF(0)); /* the table is allocated in its own root */ thd_proc_info(thd, save_proc_info); DBUG_VOID_RETURN; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431127, "input": "int nfs4_proc_destroy_session(struct nfs4_session *session, const struct cred *cred) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION], .rpc_argp = session, .rpc_cred = cred, }; int status = 0; dprintk(\"--> nfs4_proc_destroy_session\\n\"); /* session is still being setup */ if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state)) return 0; status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN); trace_nfs4_destroy_session(session->clp, status); if (status) dprintk(\"NFS: Got error %d from the server on DESTROY_SESSION. \" \"Session has been destroyed regardless...\\n\", status); dprintk(\"<-- nfs4_proc_destroy_session\\n\"); return status; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 306339, "input": "static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int ret; if (sd->gspca_dev.usb_err < 0) return; *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); /* Avoid things going to fast for the bridge with a xhci host */ udelay(150); ret = usb_control_msg(sd->gspca_dev.dev, usb_sndctrlpipe(sd->gspca_dev.dev, 0), 1 /* REG_IO */, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, index, sd->gspca_dev.usb_buf, n, 500); if (ret < 0) { gspca_err(gspca_dev, \"reg_w32 %02x failed %d\\n\", index, ret); sd->gspca_dev.usb_err = ret; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381984, "input": "const char *CServer::ClientClan(int ClientID) const { if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State == CServer::CClient::STATE_EMPTY) return \"\"; if(m_aClients[ClientID].m_State == CServer::CClient::STATE_INGAME) return m_aClients[ClientID].m_aClan; else return \"\"; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 316690, "input": "static double GetOpacityPixel(PolygonInfo *polygon_info,const double mid, const MagickBooleanType fill,const FillRule fill_rule,const ssize_t x, const ssize_t y,double *stroke_opacity) { double alpha, beta, distance, subpath_opacity; PointInfo delta; EdgeInfo *p; const PointInfo *q; ssize_t i; ssize_t j, winding_number; /* Compute fill & stroke opacity for this (x,y) point. */ *stroke_opacity=0.0; subpath_opacity=0.0; p=polygon_info->edges; for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) { if ((double) y <= (p->bounds.y1-mid-0.5)) break; if ((double) y > (p->bounds.y2+mid+0.5)) { (void) DestroyEdge(polygon_info,j); continue; } if (((double) x <= (p->bounds.x1-mid-0.5)) || ((double) x > (p->bounds.x2+mid+0.5))) continue; i=(ssize_t) MagickMax((double) p->highwater,1.0); for ( ; i < (ssize_t) p->number_points; i++) { if ((double) y <= (p->points[i-1].y-mid-0.5)) break; if ((double) y > (p->points[i].y+mid+0.5)) continue; if (p->scanline != (double) y) { p->scanline=(double) y; p->highwater=(size_t) i; } /* Compute distance between a point and an edge. */ q=p->points+i-1; delta.x=(q+1)->x-q->x; delta.y=(q+1)->y-q->y; beta=delta.x*(x-q->x)+delta.y*(y-q->y); if (beta <= 0.0) { delta.x=(double) x-q->x; delta.y=(double) y-q->y; distance=delta.x*delta.x+delta.y*delta.y; } else { alpha=delta.x*delta.x+delta.y*delta.y; if (beta >= alpha) { delta.x=(double) x-(q+1)->x; delta.y=(double) y-(q+1)->y; distance=delta.x*delta.x+delta.y*delta.y; } else { alpha=PerceptibleReciprocal(alpha); beta=delta.x*(y-q->y)-delta.y*(x-q->x)+MagickEpsilon; distance=alpha*beta*beta; } } /* Compute stroke & subpath opacity. */ beta=0.0; if (p->ghostline == MagickFalse) { alpha=mid+0.5; if ((*stroke_opacity < 1.0) && (distance <= ((alpha+0.25)*(alpha+0.25)))) { alpha=mid-0.5; if (distance <= ((alpha+0.25)*(alpha+0.25))) *stroke_opacity=1.0; else { beta=1.0; if (fabs(distance-1.0) >= MagickEpsilon) beta=sqrt((double) distance); alpha=beta-mid-0.5; if (*stroke_opacity < ((alpha-0.25)*(alpha-0.25))) *stroke_opacity=(alpha-0.25)*(alpha-0.25); } } } if ((fill == MagickFalse) || (distance > 1.0) || (subpath_opacity >= 1.0)) continue; if (distance <= 0.0) { subpath_opacity=1.0; continue; } if (distance > 1.0) continue; if (fabs(beta) < MagickEpsilon) { beta=1.0; if (fabs(distance-1.0) >= MagickEpsilon) beta=sqrt(distance); } alpha=beta-1.0; if (subpath_opacity < (alpha*alpha)) subpath_opacity=alpha*alpha; } } /* Compute fill opacity. */ if (fill == MagickFalse) return(0.0); if (subpath_opacity >= 1.0) return(1.0); /* Determine winding number. */ winding_number=0; p=polygon_info->edges; for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) { if ((double) y <= p->bounds.y1) break; if (((double) y > p->bounds.y2) || ((double) x <= p->bounds.x1)) continue; if ((double) x > p->bounds.x2) { winding_number+=p->direction ? 1 : -1; continue; } i=(ssize_t) MagickMax((double) p->highwater,1.0); for ( ; i < (ssize_t) (p->number_points-1); i++) if ((double) y <= p->points[i].y) break; q=p->points+i-1; if ((((q+1)->x-q->x)*(y-q->y)) <= (((q+1)->y-q->y)*(x-q->x))) winding_number+=p->direction ? 1 : -1; } if (fill_rule != NonZeroRule) { if ((MagickAbsoluteValue(winding_number) & 0x01) != 0) return(1.0); } else if (MagickAbsoluteValue(winding_number) != 0) return(1.0); return(subpath_opacity); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 380782, "input": "static void vgacon_invert_region(struct vc_data *c, u16 * p, int count) { const bool col = vga_can_do_color; while (count--) { u16 a = scr_readw(p); if (col) a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4); else a ^= ((a & 0x0700) == 0x0100) ? 0x7000 : 0x7700; scr_writew(a, p++); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 437616, "input": "static int nested_svm_exit_handled_msr(struct vcpu_svm *svm) { u32 offset, msr, value; int write, mask; if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT))) return NESTED_EXIT_HOST; msr = svm->vcpu.arch.regs[VCPU_REGS_RCX]; offset = svm_msrpm_offset(msr); write = svm->vmcb->control.exit_info_1 & 1; mask = 1 << ((2 * (msr & 0xf)) + write); if (offset == MSR_INVALID) return NESTED_EXIT_DONE; /* Offset is in 32 bit units but need in 8 bit units */ offset *= 4; if (kvm_read_guest(svm->vcpu.kvm, svm->nested.vmcb_msrpm + offset, &value, 4)) return NESTED_EXIT_DONE; return (value & mask) ? NESTED_EXIT_DONE : NESTED_EXIT_HOST; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281349, "input": "int RGWPostObj_ObjStore_S3::complete_get_params() { bool done; do { struct post_form_part part; int r = read_form_part_header(&part, done); if (r < 0) { return r; } ceph::bufferlist part_data; bool boundary; uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size; r = read_data(part.data, chunk_size, boundary, done); if (r < 0 || !boundary) { return -EINVAL; } /* Just reading the data but not storing any results of that. */ } while (!done); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 409576, "input": "static void rdp_write_gdiplus_cache_chunk_size(wStream* s, UINT16 gccs, UINT16 obccs, UINT16 opccs, UINT16 oiaccs) { Stream_Write_UINT16(s, gccs); /* gdipGraphicsCacheChunkSize (2 bytes) */ Stream_Write_UINT16(s, obccs); /* gdipObjectBrushCacheChunkSize (2 bytes) */ Stream_Write_UINT16(s, opccs); /* gdipObjectPenCacheChunkSize (2 bytes) */ Stream_Write_UINT16(s, oiaccs); /* gdipObjectImageAttributesCacheChunkSize (2 bytes) */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 379594, "input": "export_environment_candidate (var) SHELL_VAR *var; { return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var))); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219412, "input": "Variant HHVM_FUNCTION(mcrypt_enc_get_algorithms_name, const Resource& td) { auto pm = get_valid_mcrypt_resource(td); if (!pm) { return false; } char *name = mcrypt_enc_get_algorithms_name(pm->m_td); String ret(name, CopyString); mcrypt_free(name); return ret; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 346307, "input": "static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *prod_name) { int fd = -1, ret; USBHostDevice *dev = NULL; struct usbdevfs_connectinfo ci; char buf[1024]; dev = qemu_mallocz(sizeof(USBHostDevice)); dev->bus_num = bus_num; dev->addr = addr; printf(\"husb: open device %d.%d\\n\", bus_num, addr); if (!usb_host_device_path) { perror(\"husb: USB Host Device Path not set\"); goto fail; } snprintf(buf, sizeof(buf), \"%s/%03d/%03d\", usb_host_device_path, bus_num, addr); fd = open(buf, O_RDWR | O_NONBLOCK); if (fd < 0) { perror(buf); goto fail; } dprintf(\"husb: opened %s\\n\", buf); /* read the device description */ dev->descr_len = read(fd, dev->descr, sizeof(dev->descr)); if (dev->descr_len <= 0) { perror(\"husb: reading device data failed\"); goto fail; } #ifdef DEBUG { int x; printf(\"=== begin dumping device descriptor data ===\\n\"); for (x = 0; x < dev->descr_len; x++) printf(\"%02x \", dev->descr[x]); printf(\"\\n=== end dumping device descriptor data ===\\n\"); } #endif dev->fd = fd; /* * Initial configuration is -1 which makes us claim first * available config. We used to start with 1, which does not * always work. I've seen devices where first config starts * with 2. */ if (!usb_host_claim_interfaces(dev, -1)) goto fail; ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci); if (ret < 0) { perror(\"usb_host_device_open: USBDEVFS_CONNECTINFO\"); goto fail; } printf(\"husb: grabbed usb device %d.%d\\n\", bus_num, addr); ret = usb_linux_update_endp_table(dev); if (ret) goto fail; if (ci.slow) dev->dev.speed = USB_SPEED_LOW; else dev->dev.speed = USB_SPEED_HIGH; dev->dev.handle_packet = usb_host_handle_packet; dev->dev.handle_reset = usb_host_handle_reset; dev->dev.handle_destroy = usb_host_handle_destroy; if (!prod_name || prod_name[0] == '\\0') snprintf(dev->dev.devname, sizeof(dev->dev.devname), \"host:%d.%d\", bus_num, addr); else pstrcpy(dev->dev.devname, sizeof(dev->dev.devname), prod_name); /* USB devio uses 'write' flag to check for async completions */ qemu_set_fd_handler(dev->fd, NULL, async_complete, dev); hostdev_link(dev); return (USBDevice *) dev; fail: if (dev) qemu_free(dev); close(fd); return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 279706, "input": "void notify_callback(struct smbd_server_connection *sconn, void *private_data, struct timespec when, const struct notify_event *e) { struct notify_fsp_state state = { .notified_fsp = private_data, .when = when, .e = e }; files_forall(sconn, notify_fsp_cb, &state); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 269024, "input": "R_API void r_sys_set_environ (char **e) { env = e; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 381530, "input": "static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { struct video_device *vfd = video_devdata(file); struct v4l2_ext_controls *p = arg; struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL; p->error_idx = p->count; if (vfh && vfh->ctrl_handler) return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, vfd, vfd->v4l2_dev->mdev, p); if (vfd->ctrl_handler) return v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, vfd, vfd->v4l2_dev->mdev, p); if (ops->vidioc_s_ext_ctrls == NULL) return -ENOTTY; return check_ext_ctrls(p, 0) ? ops->vidioc_s_ext_ctrls(file, fh, p) : -EINVAL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 246366, "input": "AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf, void *url_config) { void **new_space; if (!conf->sec_file) conf->sec_file = apr_array_make(p, 2, sizeof(ap_conf_vector_t *)); new_space = (void **)apr_array_push(conf->sec_file); *new_space = url_config; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 399928, "input": "vhost_shadow_dequeue_single_packed_inorder(struct vhost_virtqueue *vq, uint16_t buf_id, uint16_t count) { uint16_t flags; vq->shadow_used_packed[0].id = buf_id; flags = vq->desc_packed[vq->last_used_idx].flags; if (vq->used_wrap_counter) { flags |= VRING_DESC_F_USED; flags |= VRING_DESC_F_AVAIL; } else { flags &= ~VRING_DESC_F_USED; flags &= ~VRING_DESC_F_AVAIL; } if (!vq->shadow_used_idx) { vq->shadow_last_used_idx = vq->last_used_idx; vq->shadow_used_packed[0].len = 0; vq->shadow_used_packed[0].flags = flags; vq->shadow_used_idx++; } vq_inc_last_used_packed(vq, count); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432436, "input": "static int nested_svm_exit_handled_msr(struct vcpu_svm *svm) { u32 offset, msr, value; int write, mask; if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT))) return NESTED_EXIT_HOST; msr = svm->vcpu.arch.regs[VCPU_REGS_RCX]; offset = svm_msrpm_offset(msr); write = svm->vmcb->control.exit_info_1 & 1; mask = 1 << ((2 * (msr & 0xf)) + write); if (offset == MSR_INVALID) return NESTED_EXIT_DONE; /* Offset is in 32 bit units but need in 8 bit units */ offset *= 4; if (kvm_vcpu_read_guest(&svm->vcpu, svm->nested.vmcb_msrpm + offset, &value, 4)) return NESTED_EXIT_DONE; return (value & mask) ? NESTED_EXIT_DONE : NESTED_EXIT_HOST; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 386076, "input": "static int rtsx_usb_ms_runtime_resume(struct device *dev) { struct rtsx_usb_ms *host = dev_get_drvdata(dev); if (host->system_suspending) return 0; memstick_detect_change(host->msh); return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 417762, "input": "static int SFDCloseCheck(SplinePointList *spl,int order2) { if ( spl->first!=spl->last && RealNear(spl->first->me.x,spl->last->me.x) && RealNear(spl->first->me.y,spl->last->me.y)) { SplinePoint *oldlast = spl->last; spl->first->prevcp = oldlast->prevcp; spl->first->noprevcp = oldlast->noprevcp; oldlast->prev->from->next = NULL; spl->last = oldlast->prev->from; chunkfree(oldlast->prev,sizeof(*oldlast)); chunkfree(oldlast->hintmask,sizeof(HintMask)); chunkfree(oldlast,sizeof(*oldlast)); SplineMake(spl->last,spl->first,order2); spl->last = spl->first; return( true ); } return( false ); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230527, "input": "lua_State *CLua::state() { if (!_state) init_lua(); return _state; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232660, "input": "Status NdarrayToTensor(PyObject* obj, Tensor* ret) { Safe_TF_TensorPtr tf_tensor = make_safe(static_cast(nullptr)); Status s = NdarrayToTensor(nullptr /*ctx*/, obj, &tf_tensor); if (!s.ok()) { return s; } return TF_TensorToTensor(tf_tensor.get(), ret); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 383915, "input": "finish_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo) { /* no work */ }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 410720, "input": "static inline int tcp_skb_mss(const struct sk_buff *skb) { return TCP_SKB_CB(skb)->tcp_gso_size; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 519170, "input": "Latin1Decoder& latin1_decoder() { static Latin1Decoder* decoder; if (!decoder) decoder = new Latin1Decoder; return *decoder; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 431003, "input": "nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp) { struct nfs_release_lockowner_data *data; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER], }; if (server->nfs_client->cl_mvops->minor_version != 0) return; data = kmalloc(sizeof(*data), GFP_NOFS); if (!data) return; data->lsp = lsp; data->server = server; data->args.lock_owner.clientid = server->nfs_client->cl_clientid; data->args.lock_owner.id = lsp->ls_seqid.owner_id; data->args.lock_owner.s_dev = server->s_dev; msg.rpc_argp = &data->args; msg.rpc_resp = &data->res; nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0); rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 306300, "input": "static int ov518_i2c_r(struct sd *sd, u8 reg) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int value; /* Select camera register */ reg_w(sd, R51x_I2C_SADDR_2, reg); /* Initiate 2-byte write cycle */ reg_w(sd, R518_I2C_CTL, 0x03); reg_r8(sd, R518_I2C_CTL); /* Initiate 2-byte read cycle */ reg_w(sd, R518_I2C_CTL, 0x05); reg_r8(sd, R518_I2C_CTL); value = reg_r(sd, R51x_I2C_DATA); gspca_dbg(gspca_dev, D_USBI, \"ov518_i2c_r %02x %02x\\n\", reg, value); return value; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 196589, "input": "int flb_parser_json_do(struct flb_parser *parser, const char *in_buf, size_t in_size, void **out_buf, size_t *out_size, struct flb_time *out_time) { int i; int skip; int ret; int slen; int root_type; int records; double tmfrac = 0; char *mp_buf = NULL; char *time_key; char *tmp_out_buf = NULL; char tmp[255]; size_t tmp_out_size = 0; size_t off = 0; size_t map_size; size_t mp_size; size_t len; msgpack_sbuffer mp_sbuf; msgpack_packer mp_pck; msgpack_unpacked result; msgpack_object map; msgpack_object *k = NULL; msgpack_object *v = NULL; time_t time_lookup; struct tm tm = {0}; struct flb_time *t; /* Convert incoming in_buf JSON message to message pack format */ ret = flb_pack_json_recs(in_buf, in_size, &mp_buf, &mp_size, &root_type, &records); if (ret != 0) { return -1; } if (records != 1) { flb_free(mp_buf); return -1; } /* Make sure object is a map */ msgpack_unpacked_init(&result); if (msgpack_unpack_next(&result, mp_buf, mp_size, &off) == MSGPACK_UNPACK_SUCCESS) { map = result.data; if (map.type != MSGPACK_OBJECT_MAP) { flb_free(mp_buf); msgpack_unpacked_destroy(&result); return -1; } } else { if (mp_size > 0) { flb_free(mp_buf); } msgpack_unpacked_destroy(&result); return -1; } /* Export results (might change later) */ tmp_out_buf = mp_buf; tmp_out_size = mp_size; /* Do we have some decoders set ? */ if (parser->decoders) { ret = flb_parser_decoder_do(parser->decoders, mp_buf, mp_size, &tmp_out_buf, &tmp_out_size); if (ret == 0) { /* re-process the unpack context */ off = 0; msgpack_unpacked_destroy(&result); msgpack_unpacked_init(&result); msgpack_unpack_next(&result, tmp_out_buf, tmp_out_size, &off); map = result.data; } } /* Set the possible outgoing buffer */ *out_buf = tmp_out_buf; *out_size = tmp_out_size; if (mp_buf != tmp_out_buf) { flb_free(mp_buf); } /* Do time resolution ? */ if (!parser->time_fmt) { msgpack_unpacked_destroy(&result); return *out_size; } if (parser->time_key) { time_key = parser->time_key; } else { time_key = \"time\"; } slen = strlen(time_key); /* Lookup time field */ map_size = map.via.map.size; skip = map_size; for (i = 0; i < map_size; i++) { k = &map.via.map.ptr[i].key; v = &map.via.map.ptr[i].val; if (k->via.str.size != slen) { continue; } /* Ensure the pointer we are about to read is not NULL */ if (k->via.str.ptr == NULL) { flb_free(mp_buf); *out_buf = NULL; msgpack_unpacked_destroy(&result); return -1; } if (strncmp(k->via.str.ptr, time_key, k->via.str.size) == 0) { /* We found the key, break the loop and keep the index */ if (parser->time_keep == FLB_FALSE) { skip = i; break; } else { skip = -1; } break; } k = NULL; v = NULL; } /* No time_key field found */ if (i >= map_size || !k || !v) { msgpack_unpacked_destroy(&result); return *out_size; } /* Ensure we have an accurate type */ if (v->type != MSGPACK_OBJECT_STR) { msgpack_unpacked_destroy(&result); return *out_size; } /* Lookup time */ ret = flb_parser_time_lookup(v->via.str.ptr, v->via.str.size, 0, parser, &tm, &tmfrac); if (ret == -1) { len = v->via.str.size; if (len > sizeof(tmp) - 1) { len = sizeof(tmp) - 1; } memcpy(tmp, v->via.str.ptr, len); tmp[len] = '\\0'; flb_warn(\"[parser:%s] invalid time format %s for '%s'\", parser->name, parser->time_fmt_full, tmp); time_lookup = 0; } else { time_lookup = flb_parser_tm2time(&tm); } /* Compose a new map without the time_key field */ msgpack_sbuffer_init(&mp_sbuf); msgpack_packer_init(&mp_pck, &mp_sbuf, msgpack_sbuffer_write); if (parser->time_keep == FLB_FALSE) { msgpack_pack_map(&mp_pck, map_size - 1); } else { msgpack_pack_map(&mp_pck, map_size); } for (i = 0; i < map_size; i++) { if (i == skip) { continue; } msgpack_pack_object(&mp_pck, map.via.map.ptr[i].key); msgpack_pack_object(&mp_pck, map.via.map.ptr[i].val); } /* Export the proper buffer */ flb_free(tmp_out_buf); *out_buf = mp_sbuf.data; *out_size = mp_sbuf.size; t = out_time; t->tm.tv_sec = time_lookup; t->tm.tv_nsec = (tmfrac * 1000000000); msgpack_unpacked_destroy(&result); return *out_size; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Double Free"], "explanation": "Fluent Bit (aka fluent-bit) 1.7.0 through 1.7,4 has a double free in flb_free (called from flb_parser_json_do and flb_parser_do).", "severity_level": "NoInfo", "cwe": "CWE-415", "cve": "CVE-2021-36088"}} -{"idx": 367055, "input": "size_t RemoteIo::read(byte* buf, size_t rcount) { assert(p_->isMalloced_); if (p_->eof_) return 0; p_->totalRead_ += (uint32_t)rcount; size_t allow = std::min(rcount, p_->size_ - p_->idx_); size_t lowBlock = p_->idx_ /p_->blockSize_; size_t highBlock = (p_->idx_ + allow)/p_->blockSize_; // connect to the remote machine & populate the blocks just in time. p_->populateBlocks(lowBlock, highBlock); byte* fakeData = (byte*) std::calloc(p_->blockSize_, sizeof(byte)); if (!fakeData) { throw Error(kerErrorMessage, \"Unable to allocate data\"); } size_t iBlock = lowBlock; size_t startPos = p_->idx_ - lowBlock*p_->blockSize_; size_t totalRead = 0; do { byte* data = p_->blocksMap_[iBlock++].getData(); if (data == nullptr) data = fakeData; size_t blockR = std::min(allow, p_->blockSize_ - startPos); std::memcpy(&buf[totalRead], &data[startPos], blockR); totalRead += blockR; startPos = 0; allow -= blockR; } while(allow); if (fakeData) std::free(fakeData); p_->idx_ += (long)totalRead; p_->eof_ = (p_->idx_ == p_->size_); return totalRead; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 259372, "input": "CallResult JSObject::defineOwnPropertyInternal( Handle selfHandle, Runtime *runtime, SymbolID name, DefinePropertyFlags dpFlags, Handle<> valueOrAccessor, PropOpFlags opFlags) { assert( !opFlags.getMustExist() && \"cannot use mustExist with defineOwnProperty\"); assert( !(dpFlags.setValue && dpFlags.isAccessor()) && \"Cannot set both value and accessor\"); assert( (dpFlags.setValue || dpFlags.isAccessor() || valueOrAccessor.get().isUndefined()) && \"value must be undefined when all of setValue/setSetter/setGetter are \" \"false\"); #ifndef NDEBUG if (dpFlags.isAccessor()) { assert(valueOrAccessor.get().isPointer() && \"accessor must be non-empty\"); assert( !dpFlags.setWritable && !dpFlags.writable && \"writable must not be set with accessors\"); } #endif // Is it an existing property. NamedPropertyDescriptor desc; auto pos = findProperty(selfHandle, runtime, name, desc); if (pos) { return updateOwnProperty( selfHandle, runtime, name, *pos, desc, dpFlags, valueOrAccessor, opFlags); } if (LLVM_UNLIKELY( selfHandle->flags_.lazyObject || selfHandle->flags_.proxyObject)) { if (selfHandle->flags_.proxyObject) { return JSProxy::defineOwnProperty( selfHandle, runtime, name.isUniqued() ? runtime->makeHandle(HermesValue::encodeStringValue( runtime->getStringPrimFromSymbolID(name))) : runtime->makeHandle(name), dpFlags, valueOrAccessor, opFlags); } assert(selfHandle->flags_.lazyObject && \"descriptor flags are impossible\"); // if the property was not found and the object is lazy we need to // initialize it and try again. JSObject::initializeLazyObject(runtime, selfHandle); return defineOwnPropertyInternal( selfHandle, runtime, name, dpFlags, valueOrAccessor, opFlags); } return addOwnProperty( selfHandle, runtime, name, dpFlags, valueOrAccessor, opFlags); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 374476, "input": "static zend_object_value zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { return zend_default_exception_new_ex(class_type, 0 TSRMLS_CC); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 242179, "input": "show_entry_xml (ExifEntry *e, void *data) { unsigned char *ids = data; char v[TAG_VALUE_BUF], t[TAG_VALUE_BUF]; if (*ids) { fprintf (stdout, \"\", e->tag); fprintf (stdout, \"%s\", escape_xml(exif_entry_get_value (e, v, sizeof (v)))); fprintf (stdout, \"\", e->tag); } else { strncpy (t, exif_tag_get_title_in_ifd(e->tag, exif_entry_get_ifd(e)), sizeof (t)); t[sizeof(t)-1] = 0; /* Remove invalid characters from tag eg. (, ), space */ remove_bad_chars(t); fprintf (stdout, \"\\t<%s>\", t); fprintf (stdout, \"%s\", escape_xml(exif_entry_get_value (e, v, sizeof (v)))); fprintf (stdout, \"\\n\", t); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198559, "input": "file_continue(i_ctx_t *i_ctx_p) { os_ptr op = osp; es_ptr pscratch = esp - 2; file_enum *pfen = r_ptr(esp - 1, file_enum); int devlen = esp[-3].value.intval; gx_io_device *iodev = r_ptr(esp - 4, gx_io_device); uint len = r_size(pscratch); uint code; if (len < devlen) return_error(gs_error_rangecheck); /* not even room for device len */ memcpy((char *)pscratch->value.bytes, iodev->dname, devlen); code = iodev->procs.enumerate_next(pfen, (char *)pscratch->value.bytes + devlen, len - devlen); if (code == ~(uint) 0) { /* all done */ esp -= 5; /* pop proc, pfen, devlen, iodev , mark */ return o_pop_estack; } else if (code > len) /* overran string */ return_error(gs_error_rangecheck); else { push(1); ref_assign(op, pscratch); r_set_size(op, code + devlen); push_op_estack(file_continue); /* come again */ *++esp = pscratch[2]; /* proc */ return o_push_estack; } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Exposure of Sensitive Information to an Unauthorized Actor"], "explanation": "The getenv and filenameforall functions in Ghostscript 9.10 ignore the \"-dSAFER\" argument, which allows remote attackers to read data via a crafted postscript file.", "severity_level": "Medium", "cwe": "CWE-200", "cve": "CVE-2013-5653"}} -{"idx": 293576, "input": "free_regexps (void) { pcre_free (re_fedora); pcre_free (re_rhel_old); pcre_free (re_rhel); pcre_free (re_rhel_no_minor); pcre_free (re_centos_old); pcre_free (re_centos); pcre_free (re_centos_no_minor); pcre_free (re_scientific_linux_old); pcre_free (re_scientific_linux); pcre_free (re_scientific_linux_no_minor); pcre_free (re_major_minor); pcre_free (re_xdev); pcre_free (re_cciss); pcre_free (re_mdN); pcre_free (re_freebsd); pcre_free (re_diskbyid); pcre_free (re_netbsd); pcre_free (re_opensuse); pcre_free (re_sles); pcre_free (re_nld); pcre_free (re_opensuse_version); pcre_free (re_sles_version); pcre_free (re_sles_patchlevel); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 231626, "input": "GF_Err Media_GetSampleDesc(GF_MediaBox *mdia, u32 SampleDescIndex, GF_SampleEntryBox **out_entry, u32 *dataRefIndex) { GF_SampleDescriptionBox *stsd; GF_SampleEntryBox *entry = NULL; if (!mdia) return GF_ISOM_INVALID_FILE; stsd = mdia->information->sampleTable->SampleDescription; if (!stsd) return GF_ISOM_INVALID_FILE; if (!SampleDescIndex || (SampleDescIndex > gf_list_count(stsd->child_boxes)) ) return GF_BAD_PARAM; entry = (GF_SampleEntryBox*)gf_list_get(stsd->child_boxes, SampleDescIndex - 1); if (!entry) return GF_ISOM_INVALID_FILE; if (out_entry) *out_entry = entry; if (dataRefIndex) *dataRefIndex = entry->dataReferenceIndex; return GF_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 281452, "input": "static void set_timeslice(struct intel_engine_cs *engine) { if (!intel_engine_has_timeslices(engine)) return; set_timer_ms(&engine->execlists.timer, active_timeslice(engine)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 268084, "input": "static int pfkey_add(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr, void * const *ext_hdrs) { struct net *net = sock_net(sk); struct xfrm_state *x; int err; struct km_event c; x = pfkey_msg2xfrm_state(net, hdr, ext_hdrs); if (IS_ERR(x)) return PTR_ERR(x); xfrm_state_hold(x); if (hdr->sadb_msg_type == SADB_ADD) err = xfrm_state_add(x); else err = xfrm_state_update(x); xfrm_audit_state_add(x, err ? 0 : 1, true); if (err < 0) { x->km.state = XFRM_STATE_DEAD; __xfrm_state_put(x); goto out; } if (hdr->sadb_msg_type == SADB_ADD) c.event = XFRM_MSG_NEWSA; else c.event = XFRM_MSG_UPDSA; c.seq = hdr->sadb_msg_seq; c.portid = hdr->sadb_msg_pid; km_state_notify(x, &c); out: xfrm_state_put(x); return err; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 481073, "input": "static bool xdr_set_next_buffer(struct xdr_stream *xdr) { if (xdr->page_ptr != NULL) xdr_set_next_page(xdr); else if (xdr->iov == xdr->buf->head) xdr_set_page(xdr, 0, xdr_stream_remaining(xdr)); return xdr->p != xdr->end; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 206517, "input": "int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) { CNetChunk Packet; if(!pMsg) return -1; // drop packet to dummy client if(0 <= ClientID && ClientID < MAX_CLIENTS && GameServer()->IsClientBot(ClientID)) return 0; mem_zero(&Packet, sizeof(CNetChunk)); Packet.m_ClientID = ClientID; Packet.m_pData = pMsg->Data(); Packet.m_DataSize = pMsg->Size(); if(Flags&MSGFLAG_VITAL) Packet.m_Flags |= NETSENDFLAG_VITAL; if(Flags&MSGFLAG_FLUSH) Packet.m_Flags |= NETSENDFLAG_FLUSH; // write message to demo recorder if(!(Flags&MSGFLAG_NORECORD)) m_DemoRecorder.RecordMessage(pMsg->Data(), pMsg->Size()); if(!(Flags&MSGFLAG_NOSEND)) { if(ClientID == -1) { // broadcast int i; for(i = 0; i < MAX_CLIENTS; i++) if(m_aClients[i].m_State == CClient::STATE_INGAME && !m_aClients[i].m_Quitting) { Packet.m_ClientID = i; m_NetServer.Send(&Packet); } } else m_NetServer.Send(&Packet); } return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Check or Handling of Exceptional Conditions"], "explanation": "CServer::SendMsg in engine/server/server.cpp in Teeworlds 0.7.x before 0.7.5 allows remote attackers to shut down the server.", "severity_level": "NoInfo", "cwe": "CWE-703", "cve": "CVE-2020-12066"}} -{"idx": 484350, "input": "static void gch_transpose(struct SYMBOL *s) { int in_ch = 0; int i2 = curvoice->ckey.sf - curvoice->okey.sf; char *o = s->text, *p = o; // search the chord symbols for (;;) { if (in_ch || !strchr(\"^_<>@\", *p)) { gch_tr1(s, p - s->text, i2); p = s->text + (p - o); o = s->text; for (p++; *p; p++) { if (strchr(\"\\t;\\n\", *p)) break; } if (!*p) break; switch (*p) { case '\\t': in_ch = 1; break; case ';': in_ch = !strchr(\"^_<>@\", p[1]); break; default: in_ch = 0; break; } } else { p = strchr(p, '\\n'); if (!p) break; } p++; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416761, "input": "static void cil_reset_rangetransition(struct cil_rangetransition *rangetrans) { if (rangetrans->range_str == NULL) { cil_reset_levelrange(rangetrans->range); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393242, "input": "TEST_F(QueryPlannerTest, SplitLimitedSort) { params.options = QueryPlannerParams::NO_TABLE_SCAN; params.options |= QueryPlannerParams::SPLIT_LIMITED_SORT; addIndex(BSON(\"a\" << 1)); addIndex(BSON(\"b\" << 1)); runQuerySortProjSkipNToReturn(fromjson(\"{a: 1}\"), fromjson(\"{b: 1}\"), BSONObj(), 0, 3); assertNumSolutions(2U); // First solution has no blocking stage; no need to split. assertSolutionExists( \"{fetch: {filter: {a:1}, node: \" \"{ixscan: {filter: null, pattern: {b: 1}}}}}\"); // Second solution has a blocking sort with a limit: it gets split and // joined with an OR stage. assertSolutionExists( \"{ensureSorted: {pattern: {b: 1}, node: \" \"{or: {nodes: [\" \"{sort: {pattern: {b: 1}, limit: 3, node: {sortKeyGen: {node: \" \"{fetch: {node: {ixscan: {pattern: {a: 1}}}}}}}}}, \" \"{sort: {pattern: {b: 1}, limit: 0, node: {sortKeyGen: {node: \" \"{fetch: {node: {ixscan: {pattern: {a: 1}}}}}}}}}]}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 207646, "input": "virtio_dev_rx_batch_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, struct rte_mbuf **pkts) { bool wrap_counter = vq->avail_wrap_counter; struct vring_packed_desc *descs = vq->desc_packed; uint16_t avail_idx = vq->last_avail_idx; uint64_t desc_addrs[PACKED_BATCH_SIZE]; struct virtio_net_hdr_mrg_rxbuf *hdrs[PACKED_BATCH_SIZE]; uint32_t buf_offset = dev->vhost_hlen; uint64_t lens[PACKED_BATCH_SIZE]; uint16_t ids[PACKED_BATCH_SIZE]; uint16_t i; if (unlikely(avail_idx & PACKED_BATCH_MASK)) return -1; if (unlikely((avail_idx + PACKED_BATCH_SIZE) > vq->size)) return -1; vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { if (unlikely(pkts[i]->next != NULL)) return -1; if (unlikely(!desc_is_avail(&descs[avail_idx + i], wrap_counter))) return -1; } rte_smp_rmb(); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) lens[i] = descs[avail_idx + i].len; vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { if (unlikely(pkts[i]->pkt_len > (lens[i] - buf_offset))) return -1; } vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) desc_addrs[i] = vhost_iova_to_vva(dev, vq, descs[avail_idx + i].addr, &lens[i], VHOST_ACCESS_RW); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { if (unlikely(lens[i] != descs[avail_idx + i].len)) return -1; } vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { rte_prefetch0((void *)(uintptr_t)desc_addrs[i]); hdrs[i] = (struct virtio_net_hdr_mrg_rxbuf *) (uintptr_t)desc_addrs[i]; lens[i] = pkts[i]->pkt_len + dev->vhost_hlen; } vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) virtio_enqueue_offload(pkts[i], &hdrs[i]->hdr); vq_inc_last_avail_packed(vq, PACKED_BATCH_SIZE); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { rte_memcpy((void *)(uintptr_t)(desc_addrs[i] + buf_offset), rte_pktmbuf_mtod_offset(pkts[i], void *, 0), pkts[i]->pkt_len); } vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) vhost_log_cache_write_iova(dev, vq, descs[avail_idx + i].addr, lens[i]); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) ids[i] = descs[avail_idx + i].id; vhost_flush_enqueue_batch_packed(dev, vq, lens, ids); return 0; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Improper Initialization"], "explanation": "A flaw was found in DPDK version 19.11 and above that allows a malicious guest to cause a segmentation fault of the vhost-user backend application running on the host, which could result in a loss of connectivity for the other guests running on that host. This is caused by a missing validity check of the descriptor address in the function `virtio_dev_rx_batch_packed()`.", "severity_level": "NoInfo", "cwe": "CWE-665", "cve": "CVE-2020-10725"}} -{"idx": 375180, "input": "static bool kill_ok_by_cred(struct task_struct *t) { const struct cred *cred = current_cred(); const struct cred *tcred = __task_cred(t); return uid_eq(cred->euid, tcred->suid) || uid_eq(cred->euid, tcred->uid) || uid_eq(cred->uid, tcred->suid) || uid_eq(cred->uid, tcred->uid) || ns_capable(tcred->user_ns, CAP_KILL); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 230176, "input": "ExecutionStatus JSObject::defineNewOwnProperty( Handle selfHandle, Runtime *runtime, SymbolID name, PropertyFlags propertyFlags, Handle<> valueOrAccessor) { assert( !selfHandle->flags_.proxyObject && \"definedNewOwnProperty cannot be used with proxy objects\"); assert( !(propertyFlags.accessor && !valueOrAccessor.get().isPointer()) && \"accessor must be non-empty\"); assert( !(propertyFlags.accessor && propertyFlags.writable) && \"writable must not be set with accessors\"); assert( !HiddenClass::debugIsPropertyDefined( selfHandle->clazz_.get(runtime), runtime, name) && \"new property is already defined\"); return addOwnPropertyImpl( selfHandle, runtime, name, propertyFlags, valueOrAccessor); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334507, "input": "mono_loader_lock (void) { mono_locks_acquire (&loader_mutex, LoaderLock); if (G_UNLIKELY (loader_lock_track_ownership)) { TlsSetValue (loader_lock_nest_id, GUINT_TO_POINTER (GPOINTER_TO_UINT (TlsGetValue (loader_lock_nest_id)) + 1)); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508445, "input": "static void choose_initial_table_order(JOIN *join) { TABLE_LIST *emb_subq; JOIN_TAB **tab= join->best_ref + join->const_tables; JOIN_TAB **tabs_end= tab + join->table_count - join->const_tables; DBUG_ENTER(\"choose_initial_table_order\"); /* Find where the top-level JOIN_TABs end and subquery JOIN_TABs start */ for (; tab != tabs_end; tab++) { if ((emb_subq= get_emb_subq(*tab))) break; } uint n_subquery_tabs= (uint)(tabs_end - tab); if (!n_subquery_tabs) DBUG_VOID_RETURN; /* Copy the subquery JOIN_TABs to a separate array */ JOIN_TAB *subquery_tabs[MAX_TABLES]; memcpy(subquery_tabs, tab, sizeof(JOIN_TAB*) * n_subquery_tabs); JOIN_TAB **last_top_level_tab= tab; JOIN_TAB **subq_tab= subquery_tabs; JOIN_TAB **subq_tabs_end= subquery_tabs + n_subquery_tabs; TABLE_LIST *cur_subq_nest= NULL; for (; subq_tab < subq_tabs_end; subq_tab++) { if (get_emb_subq(*subq_tab)!= cur_subq_nest) { /* Reached the part of subquery_tabs that covers tables in some subquery. */ cur_subq_nest= get_emb_subq(*subq_tab); /* Determine how many tables the subquery has */ JOIN_TAB **last_tab_for_subq; for (last_tab_for_subq= subq_tab; last_tab_for_subq < subq_tabs_end && get_emb_subq(*last_tab_for_subq) == cur_subq_nest; last_tab_for_subq++) {} uint n_subquery_tables= (uint)(last_tab_for_subq - subq_tab); /* Walk the original array and find where this subquery would have been attached to */ table_map need_tables= cur_subq_nest->original_subq_pred_used_tables; need_tables &= ~(join->const_table_map | PSEUDO_TABLE_BITS); for (JOIN_TAB **top_level_tab= join->best_ref + join->const_tables; top_level_tab < last_top_level_tab; //top_level_tab < join->best_ref + join->table_count; top_level_tab++) { need_tables &= ~(*top_level_tab)->table->map; /* Check if this is the place where subquery should be attached */ if (!need_tables) { /* Move away the top-level tables that are after top_level_tab */ size_t top_tail_len= last_top_level_tab - top_level_tab - 1; memmove(top_level_tab + 1 + n_subquery_tables, top_level_tab + 1, sizeof(JOIN_TAB*)*top_tail_len); last_top_level_tab += n_subquery_tables; memcpy(top_level_tab + 1, subq_tab, sizeof(JOIN_TAB*)*n_subquery_tables); break; } } DBUG_ASSERT(!need_tables); subq_tab += n_subquery_tables - 1; } } DBUG_VOID_RETURN; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 334459, "input": "mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass, MonoGenericContext *context) { MonoClass *k; guint32 type; MonoClassField *field; if (image->dynamic) { MonoClassField *result; MonoClass *handle_class; *retklass = NULL; result = mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context); // This checks the memberref type as well if (!result || handle_class != mono_defaults.fieldhandle_class) { mono_loader_set_error_bad_image (g_strdup_printf (\"Bad field token 0x%08x on image %s.\", token, image->name)); return NULL; } *retklass = result->parent; return result; } mono_loader_lock (); if ((field = g_hash_table_lookup (image->field_cache, GUINT_TO_POINTER (token)))) { *retklass = field->parent; mono_loader_unlock (); return field; } mono_loader_unlock (); if (mono_metadata_token_table (token) == MONO_TABLE_MEMBERREF) field = field_from_memberref (image, token, retklass, context); else { type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token)); if (!type) return NULL; k = mono_class_get (image, MONO_TOKEN_TYPE_DEF | type); if (!k) return NULL; mono_class_init (k); if (retklass) *retklass = k; field = mono_class_get_field (k, token); } mono_loader_lock (); if (field && field->parent && !field->parent->generic_class && !field->parent->generic_container) g_hash_table_insert (image->field_cache, GUINT_TO_POINTER (token), field); mono_loader_unlock (); return field; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 370190, "input": "static MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_new() { return (MSUSB_INTERFACE_DESCRIPTOR*)calloc(1, sizeof(MSUSB_INTERFACE_DESCRIPTOR)); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 499717, "input": "delay_set_stat (char const *file_name, struct stat *st, mode_t invert_permissions) { struct cpio_file_stat fs; stat_to_cpio (&fs, st); fs.c_name = (char*) file_name; delay_cpio_set_stat (&fs, invert_permissions); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 279694, "input": "NTSTATUS change_notify_add_request(struct smb_request *req, uint32_t max_param, uint32_t filter, bool recursive, struct files_struct *fsp, void (*reply_fn)(struct smb_request *req, NTSTATUS error_code, uint8_t *buf, size_t len)) { struct notify_change_request *request = NULL; struct notify_mid_map *map = NULL; struct smbd_server_connection *sconn = req->sconn; DEBUG(10, (\"change_notify_add_request: Adding request for %s: \" \"max_param = %d\\n\", fsp_str_dbg(fsp), (int)max_param)); if (!(request = talloc(NULL, struct notify_change_request)) || !(map = talloc(request, struct notify_mid_map))) { TALLOC_FREE(request); return NT_STATUS_NO_MEMORY; } request->mid_map = map; map->req = request; request->req = talloc_move(request, &req); request->max_param = max_param; request->filter = filter; request->fsp = fsp; request->reply_fn = reply_fn; request->backend_data = NULL; DLIST_ADD_END(fsp->notify->requests, request); map->mid = request->req->mid; DLIST_ADD(sconn->smb1.notify_mid_maps, map); return NT_STATUS_OK; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 277040, "input": "file_close(ref * pfile) { stream *s; if (file_is_valid(s, pfile)) { /* closing a closed file is a no-op */ if (sclose(s)) return_error(gs_error_ioerror); } return 0; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 514749, "input": "bool ram_block_discard_is_disabled(void) { return qatomic_read(&ram_block_discard_disabled_cnt) || qatomic_read(&ram_block_uncoordinated_discard_disabled_cnt); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 197757, "input": "bool FromkLinuxSockAddr(const struct klinux_sockaddr *input, socklen_t input_len, struct sockaddr *output, socklen_t *output_len, void (*abort_handler)(const char *)) { if (!input || !output || !output_len || input_len == 0) { output = nullptr; return false; } int16_t klinux_family = input->klinux_sa_family; if (klinux_family == kLinux_AF_UNIX) { struct klinux_sockaddr_un *klinux_sockaddr_un_in = const_cast( reinterpret_cast(input)); struct sockaddr_un sockaddr_un_out; sockaddr_un_out.sun_family = AF_UNIX; InitializeToZeroArray(sockaddr_un_out.sun_path); ReinterpretCopyArray( sockaddr_un_out.sun_path, klinux_sockaddr_un_in->klinux_sun_path, std::min(sizeof(sockaddr_un_out.sun_path), sizeof(klinux_sockaddr_un_in->klinux_sun_path))); CopySockaddr(&sockaddr_un_out, sizeof(sockaddr_un_out), output, output_len); } else if (klinux_family == kLinux_AF_INET) { struct klinux_sockaddr_in *klinux_sockaddr_in_in = const_cast( reinterpret_cast(input)); struct sockaddr_in sockaddr_in_out; sockaddr_in_out.sin_family = AF_INET; sockaddr_in_out.sin_port = klinux_sockaddr_in_in->klinux_sin_port; InitializeToZeroSingle(&sockaddr_in_out.sin_addr); ReinterpretCopySingle(&sockaddr_in_out.sin_addr, &klinux_sockaddr_in_in->klinux_sin_addr); InitializeToZeroArray(sockaddr_in_out.sin_zero); ReinterpretCopyArray(sockaddr_in_out.sin_zero, klinux_sockaddr_in_in->klinux_sin_zero); CopySockaddr(&sockaddr_in_out, sizeof(sockaddr_in_out), output, output_len); } else if (klinux_family == kLinux_AF_INET6) { struct klinux_sockaddr_in6 *klinux_sockaddr_in6_in = const_cast( reinterpret_cast(input)); struct sockaddr_in6 sockaddr_in6_out; sockaddr_in6_out.sin6_family = AF_INET6; sockaddr_in6_out.sin6_port = klinux_sockaddr_in6_in->klinux_sin6_port; sockaddr_in6_out.sin6_flowinfo = klinux_sockaddr_in6_in->klinux_sin6_flowinfo; sockaddr_in6_out.sin6_scope_id = klinux_sockaddr_in6_in->klinux_sin6_scope_id; InitializeToZeroSingle(&sockaddr_in6_out.sin6_addr); ReinterpretCopySingle(&sockaddr_in6_out.sin6_addr, &klinux_sockaddr_in6_in->klinux_sin6_addr); CopySockaddr(&sockaddr_in6_out, sizeof(sockaddr_in6_out), output, output_len); } else if (klinux_family == kLinux_AF_UNSPEC) { output = nullptr; *output_len = 0; } else { if (abort_handler != nullptr) { std::string message = absl::StrCat( \"Type conversion error - Unsupported AF family: \", klinux_family); abort_handler(message.c_str()); } else { abort(); } } return true; }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Out-of-bounds Write"], "explanation": "An arbitrary memory overwrite vulnerability in Asylo versions up to 0.6.0 allows an attacker to make a host call to FromkLinuxSockAddr with attacker controlled content and size of klinux_addr which allows an attacker to write memory values from within the enclave. We recommend upgrading past commit a37fb6a0e7daf30134dbbf357c9a518a1026aa02", "severity_level": "NoInfo", "cwe": "CWE-787", "cve": "CVE-2020-8938"}} -{"idx": 409946, "input": "static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); /* Check #1 */ if (tp->rcv_ssthresh < tp->window_clamp && (int)tp->rcv_ssthresh < tcp_space(sk) && !tcp_memory_pressure) { int incr; /* Check #2. Increase window, if skb with such overhead * will fit to rcvbuf in future. */ if (tcp_win_from_space(skb->truesize) <= skb->len) incr = 2 * tp->advmss; else incr = __tcp_grow_window(sk, skb); if (incr) { tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, tp->window_clamp); inet_csk(sk)->icsk_ack.quick |= 1; } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 349458, "input": "p11_rpc_message_parse (p11_rpc_message *msg, p11_rpc_message_type type) { const unsigned char *val; size_t len; uint32_t call_id; assert (msg != NULL); assert (msg->input != NULL); msg->parsed = 0; /* Pull out the call identifier */ if (!p11_rpc_buffer_get_uint32 (msg->input, &msg->parsed, &call_id)) { p11_message (\"invalid message: couldn't read call identifier\"); return false; } msg->signature = msg->sigverify = NULL; /* The call id and signature */ if (call_id >= P11_RPC_CALL_MAX || (type == P11_RPC_REQUEST && call_id == P11_RPC_CALL_ERROR)) { p11_message (\"invalid message: bad call id: %d\", call_id); return false; } if (type == P11_RPC_REQUEST) msg->signature = p11_rpc_calls[call_id].request; else if (type == P11_RPC_RESPONSE) msg->signature = p11_rpc_calls[call_id].response; else assert_not_reached (); assert (msg->signature != NULL); msg->call_id = call_id; msg->call_type = type; msg->sigverify = msg->signature; /* Verify the incoming signature */ if (!p11_rpc_buffer_get_byte_array (msg->input, &msg->parsed, &val, &len) || /* This can happen if the length header == 0xffffffff */ val == NULL) { p11_message (\"invalid message: couldn't read signature\"); return false; } if ((strlen (msg->signature) != len) || (memcmp (val, msg->signature, len) != 0)) { p11_message (\"invalid message: signature doesn't match\"); return false; } return true; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 393095, "input": "TEST_F(QueryPlannerTest, EqualityIndexScanWithTrailingFields) { addIndex(BSON(\"x\" << 1 << \"y\" << 1)); runQuery(BSON(\"x\" << 5)); ASSERT_EQUALS(getNumSolutions(), 2U); assertSolutionExists(\"{cscan: {dir: 1, filter: {x: 5}}}\"); assertSolutionExists(\"{fetch: {filter: null, node: {ixscan: {pattern: {x: 1, y: 1}}}}}\"); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 498277, "input": "url_escape (const char *s) { return url_escape_1 (s, urlchr_unsafe, false); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508475, "input": "void JOIN::cache_const_exprs() { bool cache_flag= FALSE; bool *analyzer_arg= &cache_flag; /* No need in cache if all tables are constant. */ if (const_tables == table_count) return; if (conds) conds->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); cache_flag= FALSE; if (having) having->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); for (JOIN_TAB *tab= first_depth_first_tab(this); tab; tab= next_depth_first_tab(this, tab)) { if (*tab->on_expr_ref) { cache_flag= FALSE; (*tab->on_expr_ref)->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); } } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 333177, "input": "repodata_extend(Repodata *data, Id p) { if (data->start == data->end) data->start = data->end = p; if (p >= data->end) { int old = data->end - data->start; int new = p - data->end + 1; if (data->attrs) { data->attrs = solv_extend(data->attrs, old, new, sizeof(Id *), REPODATA_BLOCK); memset(data->attrs + old, 0, new * sizeof(Id *)); } data->incoreoffset = solv_extend(data->incoreoffset, old, new, sizeof(Id), REPODATA_BLOCK); memset(data->incoreoffset + old, 0, new * sizeof(Id)); data->end = p + 1; } if (p < data->start) { int old = data->end - data->start; int new = data->start - p; if (data->attrs) { data->attrs = solv_extend_resize(data->attrs, old + new, sizeof(Id *), REPODATA_BLOCK); memmove(data->attrs + new, data->attrs, old * sizeof(Id *)); memset(data->attrs, 0, new * sizeof(Id *)); } data->incoreoffset = solv_extend_resize(data->incoreoffset, old + new, sizeof(Id), REPODATA_BLOCK); memmove(data->incoreoffset + new, data->incoreoffset, old * sizeof(Id)); memset(data->incoreoffset, 0, new * sizeof(Id)); data->start = p; } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 214193, "input": "static void dp8393x_do_transmit_packets(dp8393xState *s) { NetClientState *nc = qemu_get_queue(s->nic); int width, size; int tx_len, len; uint16_t i; width = (s->regs[SONIC_DCR] & SONIC_DCR_DW) ? 2 : 1; while (1) { /* Read memory */ size = sizeof(uint16_t) * 6 * width; s->regs[SONIC_TTDA] = s->regs[SONIC_CTDA]; DPRINTF(\"Transmit packet at %08x\\n\", dp8393x_ttda(s)); address_space_read(&s->as, dp8393x_ttda(s) + sizeof(uint16_t) * width, MEMTXATTRS_UNSPECIFIED, s->data, size); tx_len = 0; /* Update registers */ s->regs[SONIC_TCR] = dp8393x_get(s, width, 0) & 0xf000; s->regs[SONIC_TPS] = dp8393x_get(s, width, 1); s->regs[SONIC_TFC] = dp8393x_get(s, width, 2); s->regs[SONIC_TSA0] = dp8393x_get(s, width, 3); s->regs[SONIC_TSA1] = dp8393x_get(s, width, 4); s->regs[SONIC_TFS] = dp8393x_get(s, width, 5); /* Handle programmable interrupt */ if (s->regs[SONIC_TCR] & SONIC_TCR_PINT) { s->regs[SONIC_ISR] |= SONIC_ISR_PINT; } else { s->regs[SONIC_ISR] &= ~SONIC_ISR_PINT; } for (i = 0; i < s->regs[SONIC_TFC]; ) { /* Append fragment */ len = s->regs[SONIC_TFS]; if (tx_len + len > sizeof(s->tx_buffer)) { len = sizeof(s->tx_buffer) - tx_len; } address_space_read(&s->as, dp8393x_tsa(s), MEMTXATTRS_UNSPECIFIED, &s->tx_buffer[tx_len], len); tx_len += len; i++; if (i != s->regs[SONIC_TFC]) { /* Read next fragment details */ size = sizeof(uint16_t) * 3 * width; address_space_read(&s->as, dp8393x_ttda(s) + sizeof(uint16_t) * width * (4 + 3 * i), MEMTXATTRS_UNSPECIFIED, s->data, size); s->regs[SONIC_TSA0] = dp8393x_get(s, width, 0); s->regs[SONIC_TSA1] = dp8393x_get(s, width, 1); s->regs[SONIC_TFS] = dp8393x_get(s, width, 2); } } /* Handle Ethernet checksum */ if (!(s->regs[SONIC_TCR] & SONIC_TCR_CRCI)) { /* Don't append FCS there, to look like slirp packets * which don't have one */ } else { /* Remove existing FCS */ tx_len -= 4; if (tx_len < 0) { SONIC_ERROR(\"tx_len is %d\\n\", tx_len); break; } } if (s->regs[SONIC_RCR] & (SONIC_RCR_LB1 | SONIC_RCR_LB0)) { /* Loopback */ s->regs[SONIC_TCR] |= SONIC_TCR_CRSL; if (nc->info->can_receive(nc)) { s->loopback_packet = 1; nc->info->receive(nc, s->tx_buffer, tx_len); } } else { /* Transmit packet */ qemu_send_packet(nc, s->tx_buffer, tx_len); } s->regs[SONIC_TCR] |= SONIC_TCR_PTX; /* Write status */ dp8393x_put(s, width, 0, s->regs[SONIC_TCR] & 0x0fff); /* status */ size = sizeof(uint16_t) * width; address_space_write(&s->as, dp8393x_ttda(s), MEMTXATTRS_UNSPECIFIED, s->data, size); if (!(s->regs[SONIC_CR] & SONIC_CR_HTX)) { /* Read footer of packet */ size = sizeof(uint16_t) * width; address_space_read(&s->as, dp8393x_ttda(s) + sizeof(uint16_t) * width * (4 + 3 * s->regs[SONIC_TFC]), MEMTXATTRS_UNSPECIFIED, s->data, size); s->regs[SONIC_CTDA] = dp8393x_get(s, width, 0); if (s->regs[SONIC_CTDA] & SONIC_DESC_EOL) { /* EOL detected */ break; } } } /* Done */ s->regs[SONIC_CR] &= ~SONIC_CR_TXP; s->regs[SONIC_ISR] |= SONIC_ISR_TXDN; dp8393x_update_irq(s); }", "output": {"is_vulnerable": "True", "vulnerability_types": ["Loop with Unreachable Exit Condition ('Infinite Loop')"], "explanation": "A potential stack overflow via infinite loop issue was found in various NIC emulators of QEMU in versions up to and including 5.2.0. The issue occurs in loopback mode of a NIC wherein reentrant DMA checks get bypassed. A guest user/process may use this flaw to consume CPU cycles or crash the QEMU process on the host resulting in DoS scenario.", "severity_level": "NoInfo", "cwe": "CWE-835", "cve": "CVE-2021-3416"}} -{"idx": 342112, "input": "static inline struct fuse_inode *get_fuse_inode(struct inode *inode) { return container_of(inode, struct fuse_inode, inode); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 234403, "input": "ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg, u32 start_idx, u32 *best_idx, bool check_device) { struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); struct nfs4_ff_layout_mirror *mirror; struct nfs4_pnfs_ds *ds; u32 idx; /* mirrors are initially sorted by efficiency */ for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { mirror = FF_LAYOUT_COMP(lseg, idx); ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false); if (!ds) continue; if (check_device && nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node)) continue; *best_idx = idx; return ds; } return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 255346, "input": "static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest) { uint32_t size; size_t alloc_size; bool status; if (!pb_decode_varint32(stream, &size)) return false; /* Space for null terminator */ alloc_size = size + 1; if (alloc_size < size) PB_RETURN_ERROR(stream, \"size too large\"); if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) { #ifndef PB_ENABLE_MALLOC PB_RETURN_ERROR(stream, \"no malloc support\"); #else if (!allocate_field(stream, dest, alloc_size, 1)) return false; dest = *(void**)dest; #endif } else { if (alloc_size > field->data_size) PB_RETURN_ERROR(stream, \"string overflow\"); } status = pb_read(stream, (uint8_t*)dest, size); *((uint8_t*)dest + size) = 0; return status; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506571, "input": "com_line() { #ifdef OS2_IPC static char *input_line_SharedMem = NULL; if (input_line_SharedMem == NULL) { /* get shared mem only once */ if (DosGetNamedSharedMem((PVOID) &input_line_SharedMem, mouseSharedMemName, PAG_WRITE | PAG_READ)) fputs(\"readline.c: DosGetNamedSharedMem ERROR\\n\", stderr); else *input_line_SharedMem = 0; } #endif /* OS2_IPC */ if (multiplot) { /* calls int_error() if it is not happy */ term_check_multiplot_okay(interactive); if (read_line(\"multiplot> \", 0)) return (1); } else { #if defined(OS2_IPC) && defined(USE_MOUSE) ULONG u; if (thread_rl_Running == 0) { int res = _beginthread(thread_read_line,NULL,32768,NULL); if (res == -1) fputs(\"error command.c could not begin thread\\n\",stderr); } /* wait until a line is read or gnupmdrv makes shared mem available */ DosWaitEventSem(semInputReady,SEM_INDEFINITE_WAIT); DosResetEventSem(semInputReady,&u); if (thread_rl_Running) { if (input_line_SharedMem == NULL || !*input_line_SharedMem) return (0); if (*input_line_SharedMem=='%') { do_event( (struct gp_event_t*)(input_line_SharedMem+1) ); /* pass terminal's event */ input_line_SharedMem[0] = 0; /* discard the whole command line */ thread_rl_RetCode = 0; return (0); } if (*input_line_SharedMem && strstr(input_line_SharedMem,\"plot\") != NULL && (strcmp(term->name,\"pm\") && strcmp(term->name,\"x11\"))) { /* avoid plotting if terminal is not PM or X11 */ fprintf(stderr,\"\\n\\tCommand(s) ignored for other than PM and X11 terminals\\a\\n\"); if (interactive) fputs(PROMPT,stderr); input_line_SharedMem[0] = 0; /* discard the whole command line */ return (0); } strcpy(gp_input_line, input_line_SharedMem); input_line_SharedMem[0] = 0; thread_rl_RetCode = 0; } if (thread_rl_RetCode) return (1); #else /* The normal case */ if (read_line(PROMPT, 0)) return (1); #endif /* defined(OS2_IPC) && defined(USE_MOUSE) */ } /* So we can flag any new output: if false at time of error, * we reprint the command line before printing caret. * TRUE for interactive terminals, since the command line is typed. * FALSE for non-terminal stdin, so command line is printed anyway. * (DFK 11/89) */ screen_ok = interactive; if (do_line()) return (1); else return (0); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 477404, "input": "iasecc_init_gemalto(struct sc_card *card) { struct sc_context *ctx = card->ctx; struct sc_path path; unsigned int flags; int rv = 0; LOG_FUNC_CALLED(ctx); flags = IASECC_CARD_DEFAULT_FLAGS; _sc_card_add_rsa_alg(card, 1024, flags, 0x10001); _sc_card_add_rsa_alg(card, 2048, flags, 0x10001); card->caps = SC_CARD_CAP_RNG; card->caps |= SC_CARD_CAP_APDU_EXT; card->caps |= SC_CARD_CAP_USE_FCI_AC; sc_format_path(\"3F00\", &path); rv = sc_select_file(card, &path, NULL); /* Result ignored*/ rv = iasecc_parse_ef_atr(card); sc_log(ctx, \"rv %i\", rv); if (rv == SC_ERROR_FILE_NOT_FOUND) { sc_log(ctx, \"Select MF\"); rv = iasecc_select_mf(card, NULL); sc_log(ctx, \"rv %i\", rv); LOG_TEST_RET(ctx, rv, \"MF selection error\"); rv = iasecc_parse_ef_atr(card); sc_log(ctx, \"rv %i\", rv); } sc_log(ctx, \"rv %i\", rv); LOG_TEST_RET(ctx, rv, \"Cannot read/parse EF.ATR\"); LOG_FUNC_RETURN(ctx, SC_SUCCESS); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 402233, "input": "static const char *get_type_name(int type) { const char *types[9] = { \"null\", \"int (8-bit)\", \"int (16 bit)\", \"int (32 bit)\", \"unknown\", \"float\", \"unknown\", \"char\", \"unknown\" }; int t = (type >= 0 && type < 8) ? type : 8; return types[t]; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232428, "input": "static bool is_ctx_reg(struct bpf_verifier_env *env, int regno) { const struct bpf_reg_state *reg = reg_state(env, regno); return reg->type == PTR_TO_CTX; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432504, "input": "static void svm_set_idt(struct kvm_vcpu *vcpu, struct desc_ptr *dt) { struct vcpu_svm *svm = to_svm(vcpu); svm->vmcb->save.idtr.limit = dt->size; svm->vmcb->save.idtr.base = dt->address ; mark_dirty(svm->vmcb, VMCB_DT); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 437039, "input": "void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) { char buf[8]; sprintf(buf, \"\\033[M%c%c%c\", (char)(' ' + butt), (char)('!' + mrx), (char)('!' + mry)); respond_string(buf, tty->port); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 198837, "input": "static void set_error_response(h2_stream *stream, int http_status) { if (!h2_stream_is_ready(stream)) { stream->rtmp->http_status = http_status; } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "Apache HTTP Server protocol handler for the HTTP/2 protocol checks received request headers against the size limitations as configured for the server and used for the HTTP/1 protocol as well. On violation of these restrictions and HTTP response is sent to the client with a status code indicating why the request was rejected. This rejection response was not fully initialised in the HTTP/2 protocol handler if the offending header was the very first one received or appeared in a a footer. This led to a NULL pointer dereference on initialised memory, crashing reliably the child process. Since such a triggering HTTP/2 request is easy to craft and submit, this can be exploited to DoS the server. This issue affected mod_http2 1.15.17 and Apache HTTP Server version 2.4.47 only. Apache HTTP Server 2.4.47 was never released.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2021-31618"}} -{"idx": 430989, "input": "static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir, const struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) { int status = -ENOMEM; struct page *page = NULL; struct nfs4_fs_locations *locations = NULL; page = alloc_page(GFP_KERNEL); if (page == NULL) goto out; locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); if (locations == NULL) goto out; status = nfs4_proc_fs_locations(client, dir, name, locations, page); if (status != 0) goto out; /* * If the fsid didn't change, this is a migration event, not a * referral. Cause us to drop into the exception handler, which * will kick off migration recovery. */ if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) { dprintk(\"%s: server did not return a different fsid for\" \" a referral at %s\\n\", __func__, name->name); status = -NFS4ERR_MOVED; goto out; } /* Fixup attributes for the nfs_lookup() call to nfs_fhget() */ nfs_fixup_referral_attributes(&locations->fattr); /* replace the lookup nfs_fattr with the locations nfs_fattr */ memcpy(fattr, &locations->fattr, sizeof(struct nfs_fattr)); memset(fhandle, 0, sizeof(struct nfs_fh)); out: if (page) __free_page(page); kfree(locations); return status; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 366737, "input": "COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len, compat_ulong_t, mode, compat_ulong_t __user *, nmask, compat_ulong_t, maxnode, compat_ulong_t, flags) { unsigned long __user *nm = NULL; unsigned long nr_bits, alloc_size; nodemask_t bm; nr_bits = min_t(unsigned long, maxnode-1, MAX_NUMNODES); alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; if (nmask) { if (compat_get_bitmap(nodes_addr(bm), nmask, nr_bits)) return -EFAULT; nm = compat_alloc_user_space(alloc_size); if (copy_to_user(nm, nodes_addr(bm), alloc_size)) return -EFAULT; } return kernel_mbind(start, len, mode, nm, nr_bits+1, flags); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 506597, "input": "estimate_strlen(const char *text, double *height) { int len; char *s; double estimated_fontheight = 1.0; if ((term->flags & TERM_IS_LATEX)) return strlen_tex(text); #ifdef GP_ENH_EST if (strchr(text,'\\n') || (term->flags & TERM_ENHANCED_TEXT)) { struct termentry *tsave = term; term = &ENHest; term->put_text(0,0,text); len = term->xmax; estimated_fontheight = term->ymax / 10.; term = tsave; /* Assume that unicode escape sequences \\U+xxxx will generate a single character */ /* ENHest_plaintext is filled in by the put_text() call to estimate.trm */ s = ENHest_plaintext; while ((s = contains_unicode(s)) != NULL) { len -= 6; s += 6; } FPRINTF((stderr,\"Estimating length %d height %g for enhanced text \\\"%s\\\"\", len, estimated_fontheight, text)); FPRINTF((stderr,\" plain text \\\"%s\\\"\\n\", ENHest_plaintext)); } else if (encoding == S_ENC_UTF8) len = strwidth_utf8(text); else #endif len = strlen(text); if (height) *height = estimated_fontheight; return len; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 432432, "input": "static void svm_vcpu_put(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); int i; avic_vcpu_put(vcpu); ++vcpu->stat.host_state_reload; kvm_load_ldt(svm->host.ldt); #ifdef CONFIG_X86_64 loadsegment(fs, svm->host.fs); wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gsbase); load_gs_index(svm->host.gs); #else #ifdef CONFIG_X86_32_LAZY_GS loadsegment(gs, svm->host.gs); #endif #endif for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++) wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 416665, "input": "PHPAPI void mysqlnd_protocol_free(MYSQLND_PROTOCOL * const protocol TSRMLS_DC) { DBG_ENTER(\"mysqlnd_protocol_free\"); if (protocol) { zend_bool pers = protocol->persistent; mnd_pefree(protocol, pers); } DBG_VOID_RETURN;", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 227311, "input": "void pushStringData(StringData* data) { auto const tv = top++; tv->m_type = KindOfString; tv->m_data.pstr = data; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 368601, "input": "_hivex_get_iconv (hive_h *h, recode_type t) { gl_lock_lock (h->iconv_cache[t].mutex); if (h->iconv_cache[t].handle == NULL) { if (t == utf8_to_latin1) h->iconv_cache[t].handle = iconv_open (\"LATIN1\", \"UTF-8\"); else if (t == latin1_to_utf8) h->iconv_cache[t].handle = iconv_open (\"UTF-8\", \"LATIN1\"); else if (t == utf8_to_utf16le) h->iconv_cache[t].handle = iconv_open (\"UTF-16LE\", \"UTF-8\"); else if (t == utf16le_to_utf8) h->iconv_cache[t].handle = iconv_open (\"UTF-8\", \"UTF-16LE\"); } else { /* reinitialize iconv context */ iconv (h->iconv_cache[t].handle, NULL, 0, NULL, 0); } return h->iconv_cache[t].handle; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 219147, "input": "Variant HHVM_FUNCTION(socket_get_option, const Resource& socket, int level, int optname) { auto sock = cast(socket); socklen_t optlen; switch (optname) { case SO_LINGER: { struct linger linger_val; optlen = sizeof(linger_val); if (getsockopt(sock->fd(), level, optname, (char*)&linger_val, &optlen) != 0) { SOCKET_ERROR(sock, \"unable to retrieve socket option\", errno); return false; } return make_darray( s_l_onoff, linger_val.l_onoff, s_l_linger, linger_val.l_linger ); } break; case SO_RCVTIMEO: case SO_SNDTIMEO: { struct timeval tv; optlen = sizeof(tv); if (getsockopt(sock->fd(), level, optname, (char*)&tv, &optlen) != 0) { SOCKET_ERROR(sock, \"unable to retrieve socket option\", errno); return false; } return make_darray( s_sec, (int)tv.tv_sec, s_usec, (int)tv.tv_usec ); } break; default: { int other_val; optlen = sizeof(other_val); if (getsockopt(sock->fd(), level, optname, (char*)&other_val, &optlen)) { SOCKET_ERROR(sock, \"unable to retrieve socket option\", errno); return false; } return other_val; } } not_reached(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 280854, "input": "parse_PUSH_VLAN(char *arg, const struct ofpact_parse_params *pp) { struct ofpact_push_vlan *push_vlan; uint16_t ethertype; char *error; *pp->usable_protocols &= OFPUTIL_P_OF11_UP; error = str_to_u16(arg, \"ethertype\", ðertype); if (error) { return error; } if (!eth_type_vlan(htons(ethertype))) { return xasprintf(\"%s: not a valid VLAN ethertype\", arg); } push_vlan = ofpact_put_PUSH_VLAN(pp->ofpacts); push_vlan->ethertype = htons(ethertype); return NULL; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 354825, "input": "void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty) { __kvm_unmap_gfn(kvm_vcpu_gfn_to_memslot(vcpu, map->gfn), map, NULL, dirty, false); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 109031, "input": "ServiceWorkerScriptContext::~ServiceWorkerScriptContext() {}", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 508511, "input": "Item_cond_and::add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, table_map usable_tables, SARGABLE_PARAM **sargables) { List_iterator_fast li(*argument_list()); KEY_FIELD *org_key_fields= *key_fields; Item *item; while ((item=li++)) item->add_key_fields(join, key_fields, and_level, usable_tables, sargables); for (; org_key_fields != *key_fields ; org_key_fields++) org_key_fields->level= *and_level; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 232414, "input": "static bool is_flow_key_reg(struct bpf_verifier_env *env, int regno) { const struct bpf_reg_state *reg = reg_state(env, regno); /* Separate to is_ctx_reg() since we still want to allow BPF_ST here. */ return reg->type == PTR_TO_FLOW_KEYS; }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 197715, "input": "void ValidateInputs(OpKernelContext* ctx, const CSRSparseMatrix& sparse_matrix, const Tensor& permutation_indices, int* batch_size, int64* num_rows) { OP_REQUIRES(ctx, sparse_matrix.dtype() == DataTypeToEnum::value, errors::InvalidArgument( \"Asked for a CSRSparseMatrix of type \", DataTypeString(DataTypeToEnum::value), \" but saw dtype: \", DataTypeString(sparse_matrix.dtype()))); const Tensor& dense_shape = sparse_matrix.dense_shape(); const int rank = dense_shape.dim_size(0); OP_REQUIRES(ctx, rank == 2 || rank == 3, errors::InvalidArgument(\"sparse matrix must have rank 2 or 3; \", \"but dense_shape has size \", rank)); const int row_dim = (rank == 2) ? 0 : 1; auto dense_shape_vec = dense_shape.vec(); *num_rows = dense_shape_vec(row_dim); const int64 num_cols = dense_shape_vec(row_dim + 1); OP_REQUIRES(ctx, *num_rows == num_cols, errors::InvalidArgument(\"sparse matrix must be square; got: \", *num_rows, \" != \", num_cols)); const TensorShape& perm_shape = permutation_indices.shape(); OP_REQUIRES( ctx, perm_shape.dims() + 1 == rank, errors::InvalidArgument( \"sparse matrix must have the same rank as permutation; got: \", rank, \" != \", perm_shape.dims(), \" + 1.\")); OP_REQUIRES( ctx, perm_shape.dim_size(rank - 2) == *num_rows, errors::InvalidArgument( \"permutation must have the same number of elements in each batch \" \"as the number of rows in sparse matrix; got: \", perm_shape.dim_size(rank - 2), \" != \", *num_rows)); *batch_size = sparse_matrix.batch_size(); if (*batch_size > 1) { OP_REQUIRES( ctx, perm_shape.dim_size(0) == *batch_size, errors::InvalidArgument(\"permutation must have the same batch size \" \"as sparse matrix; got: \", perm_shape.dim_size(0), \" != \", *batch_size)); } }", "output": {"is_vulnerable": "True", "vulnerability_types": ["NULL Pointer Dereference"], "explanation": "TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a null pointer dereference by providing an invalid `permutation` to `tf.raw_ops.SparseMatrixSparseCholesky`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/080f1d9e257589f78b3ffb75debf584168aa6062/tensorflow/core/kernels/sparse/sparse_cholesky_op.cc#L85-L86) fails to properly validate the input arguments. Although `ValidateInputs` is called and there are checks in the body of this function, the code proceeds to the next line in `ValidateInputs` since `OP_REQUIRES`(https://github.com/tensorflow/tensorflow/blob/080f1d9e257589f78b3ffb75debf584168aa6062/tensorflow/core/framework/op_requires.h#L41-L48) is a macro that only exits the current function. Thus, the first validation condition that fails in `ValidateInputs` will cause an early return from that function. However, the caller will continue execution from the next line. The fix is to either explicitly check `context->status()` or to convert `ValidateInputs` to return a `Status`. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.", "severity_level": "NoInfo", "cwe": "CWE-476", "cve": "CVE-2021-29530"}} -{"idx": 256387, "input": "Status SparseTensorToCSRSparseMatrixCPUFunctor::operator()( const int64 batch_size, const int num_rows, TTypes::ConstMatrix indices, TTypes::Vec batch_ptr, TTypes::Vec csr_row_ptr, TTypes::Vec csr_col_ind) { // Validate inputs. if (batch_ptr.size() != batch_size + 1) { return errors::InvalidArgument( \"Expected batch_ptr.size() == batch_size + 1. Got: \", batch_ptr.size(), \" vs. \", batch_size + 1); } if (csr_row_ptr.size() != batch_size * (num_rows + 1)) { return errors::InvalidArgument( \"Expected csr_row_ptr.size() == batch_size * (num_rows + 1). Got: \", csr_row_ptr.size(), \" vs. \", batch_size * (num_rows + 1)); } const int64 total_nnz = indices.dimension(0); const int rank = indices.dimension(1); if (rank == 2 && batch_size != 1) { return errors::InvalidArgument( \"Expected batch_size == 1 when rank is 2. Got batch_size: \", batch_size); } if (csr_col_ind.size() != total_nnz) { return errors::InvalidArgument( \"Expected csr_col_ind.size() == total_nnz. Got: \", csr_col_ind.size(), \" vs. \", total_nnz); } int prev_batch = -1; if (rank == 2) { // For a single batch, the batch_ptrs are {0, total_nnz}. batch_ptr(0) = 0; ++prev_batch; for (int64 i = 0; i < total_nnz; ++i) { // For now, the rows pointers store the corresponding row counts. int64 ix = indices(i, 0) + 1; if (ix >= csr_row_ptr.size()) { return errors::InvalidArgument(\"Got an index \", ix, \" that is outside of csr_row_ptr\"); } csr_row_ptr(indices(i, 0) + 1) += 1; csr_col_ind(i) = indices(i, 1); } } else { // rank == 3 for (int64 i = 0; i < total_nnz; ++i) { const int cur_batch = indices(i, 0); // For now, the rows pointers store the corresponding row counts. csr_row_ptr(cur_batch * (num_rows + 1) + indices(i, 1) + 1) += 1; csr_col_ind(i) = indices(i, 2); // We're at a new batch and might have skipped over empty batches. while (prev_batch < cur_batch) { // The previous batch ends at position i. batch_ptr(prev_batch + 1) = i; ++prev_batch; } } } // Set the last element of batch_ptr and account for trailing empty batches. while (prev_batch < batch_size) { batch_ptr(prev_batch + 1) = total_nnz; ++prev_batch; } // Compute the cumulative row counts for each batch. for (int batch_idx = 0; batch_idx < batch_size; ++batch_idx) { auto* row_ptr_batch = csr_row_ptr.data() + batch_idx * (num_rows + 1); std::partial_sum(row_ptr_batch, row_ptr_batch + num_rows + 1, row_ptr_batch); } return Status::OK(); }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 238842, "input": "~WrappedConverter() { if (converter_) { ucnv_close(converter_); } }", "output": {"is_vulnerable": "False", "vulnerability_types": "None", "explanation": "This function is not vulnerable.", "severity_level": "NotVulnerable", "cwe": "None", "cve": "None"}} -{"idx": 208547, "input": "HRESULT Http::HrReadHeaders() { HRESULT hr; std::string strBuffer; ULONG n = 0; std::map::iterator iHeader = mapHeaders.end(); ec_log_debug(\"Receiving headers:\"); do { hr = m_lpChannel->HrReadLine(strBuffer); if (hr != hrSuccess) return hr; if (strBuffer.empty()) break; if (n == 0) { m_strAction = strBuffer; } else { auto pos = strBuffer.find(':'); size_t start = 0; if (strBuffer[0] == ' ' || strBuffer[0] == '\\t') { if (iHeader == mapHeaders.end()) continue; // continue header while (strBuffer[start] == ' ' || strBuffer[start] == '\\t') ++start; iHeader->second += strBuffer.substr(start); } else { // new header auto r = mapHeaders.emplace(strBuffer.substr(0, pos), strBuffer.substr(pos + 2)); iHeader = r.first; } } if (strBuffer.find(\"Authorization\") != std::string::npos) ec_log_debug(\"< Authorization: