func
stringlengths
269
194k
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [qemuProcessHandleReset(qemuMonitorPtr mon G_GNUC_UNUSED, virDomainObjPtr vm, void *opaque) { virQEMUDriverPtr driver = opaque; virObjectEventPtr event; qemuDomainObjPrivatePtr priv; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); int ret = -1; virObjectLock(vm); event = virDomainEventRebootNewFromObj(vm); priv = vm->privateData; if (priv->agent) qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_RESET); if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); if (vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) { if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { VIR_DEBUG("Ignoring RESET event from inactive domain %s", vm->def->name); goto endjob; } qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, QEMU_ASYNC_JOB_NONE, 0); virDomainAuditStop(vm, "destroyed"); qemuDomainRemoveInactive(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); } ret = 0; cleanup: virObjectUnlock(vm); virObjectEventStateQueue(driver->domainEventState, event); return ret; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [read_layer_block (PSDimage *img_a, FILE *f, GError **error) { PSDlayer **lyr_a; guint32 block_len; guint32 block_end; guint32 block_rem; gint32 read_len; gint32 write_len; gint lidx; /* Layer index */ gint cidx; /* Channel index */ if (fread (&block_len, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); img_a->num_layers = -1; return NULL; } img_a->mask_layer_len = GUINT32_FROM_BE (block_len); IFDBG(1) g_debug ("Layer and mask block size = %d", img_a->mask_layer_len); img_a->transparency = FALSE; img_a->layer_data_len = 0; if (!img_a->mask_layer_len) { img_a->num_layers = 0; return NULL; } else { img_a->mask_layer_start = ftell (f); block_end = img_a->mask_layer_start + img_a->mask_layer_len; /* Get number of layers */ if (fread (&block_len, 4, 1, f) < 1 || fread (&img_a->num_layers, 2, 1, f) < 1) { psd_set_error (feof (f), errno, error); img_a->num_layers = -1; return NULL; } img_a->num_layers = GINT16_FROM_BE (img_a->num_layers); IFDBG(2) g_debug ("Number of layers: %d", img_a->num_layers); if (img_a->num_layers < 0) { img_a->transparency = TRUE; img_a->num_layers = -img_a->num_layers; } if (img_a->num_layers) { /* Read layer records */ PSDlayerres res_a; /* Create pointer array for the layer records */ lyr_a = g_new (PSDlayer *, img_a->num_layers); for (lidx = 0; lidx < img_a->num_layers; ++lidx) { /* Allocate layer record */ lyr_a[lidx] = (PSDlayer *) g_malloc (sizeof (PSDlayer) ); /* Initialise record */ lyr_a[lidx]->drop = FALSE; lyr_a[lidx]->id = 0; if (fread (&lyr_a[lidx]->top, 4, 1, f) < 1 || fread (&lyr_a[lidx]->left, 4, 1, f) < 1 || fread (&lyr_a[lidx]->bottom, 4, 1, f) < 1 || fread (&lyr_a[lidx]->right, 4, 1, f) < 1 || fread (&lyr_a[lidx]->num_channels, 2, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } lyr_a[lidx]->top = GINT32_FROM_BE (lyr_a[lidx]->top); lyr_a[lidx]->left = GINT32_FROM_BE (lyr_a[lidx]->left); lyr_a[lidx]->bottom = GINT32_FROM_BE (lyr_a[lidx]->bottom); lyr_a[lidx]->right = GINT32_FROM_BE (lyr_a[lidx]->right); lyr_a[lidx]->num_channels = GUINT16_FROM_BE (lyr_a[lidx]->num_channels); if (lyr_a[lidx]->num_channels > MAX_CHANNELS) { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Too many channels in layer: %d"), lyr_a[lidx]->num_channels); return NULL; } if (lyr_a[lidx]->bottom - lyr_a[lidx]->top > GIMP_MAX_IMAGE_SIZE) { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Unsupported or invalid layer height: %d"), lyr_a[lidx]->bottom - lyr_a[lidx]->top); return NULL; } if (lyr_a[lidx]->right - lyr_a[lidx]->left > GIMP_MAX_IMAGE_SIZE) { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Unsupported or invalid layer width: %d"), lyr_a[lidx]->right - lyr_a[lidx]->left); return NULL; } IFDBG(2) g_debug ("Layer %d, Coords %d %d %d %d, channels %d, ", lidx, lyr_a[lidx]->left, lyr_a[lidx]->top, lyr_a[lidx]->right, lyr_a[lidx]->bottom, lyr_a[lidx]->num_channels); lyr_a[lidx]->chn_info = g_new (ChannelLengthInfo, lyr_a[lidx]->num_channels); for (cidx = 0; cidx < lyr_a[lidx]->num_channels; ++cidx) { if (fread (&lyr_a[lidx]->chn_info[cidx].channel_id, 2, 1, f) < 1 || fread (&lyr_a[lidx]->chn_info[cidx].data_len, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } lyr_a[lidx]->chn_info[cidx].channel_id = GINT16_FROM_BE (lyr_a[lidx]->chn_info[cidx].channel_id); lyr_a[lidx]->chn_info[cidx].data_len = GUINT32_FROM_BE (lyr_a[lidx]->chn_info[cidx].data_len); img_a->layer_data_len += lyr_a[lidx]->chn_info[cidx].data_len; IFDBG(3) g_debug ("Channel ID %d, data len %d", lyr_a[lidx]->chn_info[cidx].channel_id, lyr_a[lidx]->chn_info[cidx].data_len); } if (fread (lyr_a[lidx]->mode_key, 4, 1, f) < 1 || fread (lyr_a[lidx]->blend_mode, 4, 1, f) < 1 || fread (&lyr_a[lidx]->opacity, 1, 1, f) < 1 || fread (&lyr_a[lidx]->clipping, 1, 1, f) < 1 || fread (&lyr_a[lidx]->flags, 1, 1, f) < 1 || fread (&lyr_a[lidx]->filler, 1, 1, f) < 1 || fread (&lyr_a[lidx]->extra_len, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } if (memcmp (lyr_a[lidx]->mode_key, "8BIM", 4) != 0) { IFDBG(1) g_debug ("Incorrect layer mode signature %.4s", lyr_a[lidx]->mode_key); g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("The file is corrupt!")); return NULL; } lyr_a[lidx]->layer_flags.trans_prot = lyr_a[lidx]->flags & 1 ? TRUE : FALSE; lyr_a[lidx]->layer_flags.visible = lyr_a[lidx]->flags & 2 ? FALSE : TRUE; if (lyr_a[lidx]->flags & 8) lyr_a[lidx]->layer_flags.irrelevant = lyr_a[lidx]->flags & 16 ? TRUE : FALSE; else lyr_a[lidx]->layer_flags.irrelevant = FALSE; lyr_a[lidx]->extra_len = GUINT32_FROM_BE (lyr_a[lidx]->extra_len); block_rem = lyr_a[lidx]->extra_len; IFDBG(2) g_debug ("\n\tLayer mode sig: %.4s\n\tBlend mode: %.4s\n\t" "Opacity: %d\n\tClipping: %d\n\tExtra data len: %d\n\t" "Alpha lock: %d\n\tVisible: %d\n\tIrrelevant: %d", lyr_a[lidx]->mode_key, lyr_a[lidx]->blend_mode, lyr_a[lidx]->opacity, lyr_a[lidx]->clipping, lyr_a[lidx]->extra_len, lyr_a[lidx]->layer_flags.trans_prot, lyr_a[lidx]->layer_flags.visible, lyr_a[lidx]->layer_flags.irrelevant); IFDBG(3) g_debug ("Remaining length %d", block_rem); /* Layer mask data */ if (fread (&block_len, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } block_len = GUINT32_FROM_BE (block_len); block_rem -= (block_len + 4); IFDBG(3) g_debug ("Remaining length %d", block_rem); lyr_a[lidx]->layer_mask_extra.top = 0; lyr_a[lidx]->layer_mask_extra.left = 0; lyr_a[lidx]->layer_mask_extra.bottom = 0; lyr_a[lidx]->layer_mask_extra.right = 0; lyr_a[lidx]->layer_mask.top = 0; lyr_a[lidx]->layer_mask.left = 0; lyr_a[lidx]->layer_mask.bottom = 0; lyr_a[lidx]->layer_mask.right = 0; lyr_a[lidx]->layer_mask.def_color = 0; lyr_a[lidx]->layer_mask.extra_def_color = 0; lyr_a[lidx]->layer_mask.mask_flags.relative_pos = FALSE; lyr_a[lidx]->layer_mask.mask_flags.disabled = FALSE; lyr_a[lidx]->layer_mask.mask_flags.invert = FALSE; switch (block_len) { case 0: break; case 20: if (fread (&lyr_a[lidx]->layer_mask.top, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.left, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.bottom, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.right, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.def_color, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.flags, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.extra_def_color, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.extra_flags, 1, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } lyr_a[lidx]->layer_mask.top = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.top); lyr_a[lidx]->layer_mask.left = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.left); lyr_a[lidx]->layer_mask.bottom = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.bottom); lyr_a[lidx]->layer_mask.right = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.right); lyr_a[lidx]->layer_mask.mask_flags.relative_pos = lyr_a[lidx]->layer_mask.flags & 1 ? TRUE : FALSE; lyr_a[lidx]->layer_mask.mask_flags.disabled = lyr_a[lidx]->layer_mask.flags & 2 ? TRUE : FALSE; lyr_a[lidx]->layer_mask.mask_flags.invert = lyr_a[lidx]->layer_mask.flags & 4 ? TRUE : FALSE; break; case 36: /* If we have a 36 byte mask record assume second data set is correct */ if (fread (&lyr_a[lidx]->layer_mask_extra.top, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask_extra.left, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask_extra.bottom, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask_extra.right, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.extra_def_color, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.extra_flags, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.def_color, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.flags, 1, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.top, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.left, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.bottom, 4, 1, f) < 1 || fread (&lyr_a[lidx]->layer_mask.right, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } lyr_a[lidx]->layer_mask_extra.top = GINT32_FROM_BE (lyr_a[lidx]->layer_mask_extra.top); lyr_a[lidx]->layer_mask_extra.left = GINT32_FROM_BE (lyr_a[lidx]->layer_mask_extra.left); lyr_a[lidx]->layer_mask_extra.bottom = GINT32_FROM_BE (lyr_a[lidx]->layer_mask_extra.bottom); lyr_a[lidx]->layer_mask_extra.right = GINT32_FROM_BE (lyr_a[lidx]->layer_mask_extra.right); lyr_a[lidx]->layer_mask.top = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.top); lyr_a[lidx]->layer_mask.left = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.left); lyr_a[lidx]->layer_mask.bottom = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.bottom); lyr_a[lidx]->layer_mask.right = GINT32_FROM_BE (lyr_a[lidx]->layer_mask.right); lyr_a[lidx]->layer_mask.mask_flags.relative_pos = lyr_a[lidx]->layer_mask.flags & 1 ? TRUE : FALSE; lyr_a[lidx]->layer_mask.mask_flags.disabled = lyr_a[lidx]->layer_mask.flags & 2 ? TRUE : FALSE; lyr_a[lidx]->layer_mask.mask_flags.invert = lyr_a[lidx]->layer_mask.flags & 4 ? TRUE : FALSE; break; default: IFDBG(1) g_debug ("Unknown layer mask record size ... skipping"); if (fseek (f, block_len, SEEK_CUR) < 0) { psd_set_error (feof (f), errno, error); return NULL; } } IFDBG(2) g_debug ("Layer mask coords %d %d %d %d, Rel pos %d", lyr_a[lidx]->layer_mask.left, lyr_a[lidx]->layer_mask.top, lyr_a[lidx]->layer_mask.right, lyr_a[lidx]->layer_mask.bottom, lyr_a[lidx]->layer_mask.mask_flags.relative_pos); IFDBG(3) g_debug ("Default mask color, %d, %d", lyr_a[lidx]->layer_mask.def_color, lyr_a[lidx]->layer_mask.extra_def_color); /* Layer blending ranges */ /* FIXME */ if (fread (&block_len, 4, 1, f) < 1) { psd_set_error (feof (f), errno, error); return NULL; } block_len = GUINT32_FROM_BE (block_len); block_rem -= (block_len + 4); IFDBG(3) g_debug ("Remaining length %d", block_rem); if (block_len > 0) { if (fseek (f, block_len, SEEK_CUR) < 0) { psd_set_error (feof (f), errno, error); return NULL; } } lyr_a[lidx]->name = fread_pascal_string (&read_len, &write_len, 4, f, error); if (*error) return NULL; block_rem -= read_len; IFDBG(3) g_debug ("Remaining length %d", block_rem); /* Adjustment layer info */ /* FIXME */ while (block_rem > 7) { if (get_layer_resource_header (&res_a, f, error) < 0) return NULL; block_rem -= 12; if (res_a.data_len > block_rem) { IFDBG(1) g_debug ("Unexpected end of layer resource data"); g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("The file is corrupt!")); return NULL; } if (load_layer_resource (&res_a, lyr_a[lidx], f, error) < 0) return NULL; block_rem -= res_a.data_len; } if (block_rem > 0) { if (fseek (f, block_rem, SEEK_CUR) < 0) { psd_set_error (feof (f), errno, error); return NULL; } } } img_a->layer_data_start = ftell(f); if (fseek (f, img_a->layer_data_len, SEEK_CUR) < 0) { psd_set_error (feof (f), errno, error); return NULL; } IFDBG(1) g_debug ("Layer image data block size %d", img_a->layer_data_len); } else lyr_a = NULL; /* Read global layer mask record */ /* FIXME */ /* Skip to end of block */ if (fseek (f, block_end, SEEK_SET) < 0) { psd_set_error (feof (f), errno, error); return NULL; } } return lyr_a; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void CLASS imacon_full_load_raw() { int row, col; for (row=0; row < height; row++) for (col=0; col < width; col++) read_shorts (image[row*width+col], 3); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int path_found_entry(void *payload, git_buf *path) { GIT_UNUSED(payload); return !git_path_is_dot_or_dotdot(path->ptr); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) { int length; if(!ber_read_universal_tag(s, BER_TAG_ENUMERATED, FALSE) || !ber_read_length(s, &length)) return FALSE; if (length != 1 || Stream_GetRemainingLength(s) < 1) return FALSE; Stream_Read_UINT8(s, *enumerated); /* check that enumerated value falls within expected range */ if (*enumerated + 1 > count) return FALSE; return TRUE; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [PHP_FUNCTION(acosh) { double num; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) { return; } RETURN_DOUBLE(php_acosh(num)); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [NOEXPORT int verify_callback(int preverify_ok, X509_STORE_CTX *callback_ctx) { /* our verify callback function */ SSL *ssl; CLI *c; /* retrieve application specific data */ ssl=X509_STORE_CTX_get_ex_data(callback_ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); c=SSL_get_ex_data(ssl, index_ssl_cli); if(!c->opt->option.verify_chain && !c->opt->option.verify_peer) { s_log(LOG_INFO, "Certificate verification disabled"); return 1; /* accept */ } if(verify_checks(c, preverify_ok, callback_ctx)) { SSL_SESSION *sess=SSL_get1_session(c->ssl); if(sess) { int ok=SSL_SESSION_set_ex_data(sess, index_session_authenticated, (void *)(-1)); SSL_SESSION_free(sess); if(!ok) { sslerror("SSL_SESSION_set_ex_data"); return 0; /* reject */ } } return 1; /* accept */ } if(c->opt->option.client || c->opt->protocol) return 0; /* reject */ if(c->opt->redirect_addr.names) return 1; /* accept */ return 0; /* reject */ }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int dmg_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVDMGState *s = bs->opaque; uint64_t info_begin, info_end, last_in_offset, last_out_offset; uint32_t count, tmp; uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i; int64_t offset; int ret; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; /* read offset of info blocks */ offset = bdrv_getlength(bs->file); if (offset < 0) { ret = offset; goto fail; } offset -= 0x1d8; ret = read_uint64(bs, offset, &info_begin); if (ret < 0) { goto fail; } else if (info_begin == 0) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin, &tmp); if (ret < 0) { goto fail; } else if (tmp != 0x100) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin + 4, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; /* read offsets */ last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; ret = read_uint32(bs, offset, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } offset += 4; ret = read_uint32(bs, offset, &type); if (ret < 0) { goto fail; } if (type == 0x6d697368 && count >= 244) { size_t new_size; uint32_t chunk_count; offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { ret = read_uint32(bs, offset, &s->types[i]); if (ret < 0) { goto fail; } offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; ret = read_uint64(bs, offset, &s->sectors[i]); if (ret < 0) { goto fail; } s->sectors[i] += last_out_offset; offset += 8; ret = read_uint64(bs, offset, &s->sectorcounts[i]); if (ret < 0) { goto fail; } offset += 8; ret = read_uint64(bs, offset, &s->offsets[i]); if (ret < 0) { goto fail; } s->offsets[i] += last_in_offset; offset += 8; ret = read_uint64(bs, offset, &s->lengths[i]); if (ret < 0) { goto fail; } offset += 8; if (s->lengths[i] > max_compressed_size) { max_compressed_size = s->lengths[i]; } if (s->sectorcounts[i] > max_sectors_per_chunk) { max_sectors_per_chunk = s->sectorcounts[i]; } } s->n_chunks += chunk_count; } } /* initialize zlib engine */ s->compressed_chunk = g_malloc(max_compressed_size + 1); s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk); if (inflateInit(&s->zstream) != Z_OK) { ret = -EINVAL; goto fail; } s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); g_free(s->compressed_chunk); g_free(s->uncompressed_chunk); return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [spnego_gss_unwrap_aead(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_buffer_t input_message_buffer, gss_buffer_t input_assoc_buffer, gss_buffer_t output_payload_buffer, int *conf_state, gss_qop_t *qop_state) { OM_uint32 ret; ret = gss_unwrap_aead(minor_status, context_handle, input_message_buffer, input_assoc_buffer, output_payload_buffer, conf_state, qop_state); return (ret); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static PyObject *Input_iternext(InputObject *self) { PyObject *line = NULL; PyObject *rlargs = NULL; if (!self->r) { PyErr_SetString(PyExc_RuntimeError, "request object has expired"); return NULL; } rlargs = PyTuple_New(0); if (!rlargs) return NULL; line = Input_readline(self, rlargs); Py_DECREF(rlargs); if (!line) return NULL; if (PyString_GET_SIZE(line) == 0) { PyErr_SetObject(PyExc_StopIteration, Py_None); Py_DECREF(line); return NULL; } return line; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [evbuffer_expand(struct evbuffer *buf, size_t datlen) { size_t need = buf->misalign + buf->off + datlen; /* If we can fit all the data, then we don't have to do anything */ if (buf->totallen >= need) return (0); /* * If the misalignment fulfills our data needs, we just force an * alignment to happen. Afterwards, we have enough space. */ if (buf->misalign >= datlen) { evbuffer_align(buf); } else { void *newbuf; size_t length = buf->totallen; if (length < 256) length = 256; while (length < need) length <<= 1; if (buf->orig_buffer != buf->buffer) evbuffer_align(buf); if ((newbuf = realloc(buf->buffer, length)) == NULL) return (-1); buf->orig_buffer = buf->buffer = newbuf; buf->totallen = length; } return (0); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ bool empty() const { return ordered_.empty(); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ //! Convert 3d object into a CImg3d representation \overloading. CImg<floatT> get_object3dtoCImg3d(const bool full_check=true) const { CImgList<T> opacities, colors; CImgList<uintT> primitives(width(),1,1,1,1); cimglist_for(primitives,p) primitives(p,0) = p; return get_object3dtoCImg3d(primitives,colors,opacities,full_check);] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [dtls1_heartbeat(SSL *s) { unsigned char *buf, *p; int ret; unsigned int payload = 18; /* Sequence number + random bytes */ unsigned int padding = 16; /* Use minimum padding */ /* Only send if peer supports and accepts HB requests... */ if (!(s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) || s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_SEND_REQUESTS) { SSLerr(SSL_F_DTLS1_HEARTBEAT,SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT); return -1; } /* ...and there is none in flight yet... */ if (s->tlsext_hb_pending) { SSLerr(SSL_F_DTLS1_HEARTBEAT,SSL_R_TLS_HEARTBEAT_PENDING); return -1; } /* ...and no handshake in progress. */ if (SSL_in_init(s) || s->in_handshake) { SSLerr(SSL_F_DTLS1_HEARTBEAT,SSL_R_UNEXPECTED_MESSAGE); return -1; } /* Check if padding is too long, payload and padding * must not exceed 2^14 - 3 = 16381 bytes in total. */ OPENSSL_assert(payload + padding <= 16381); /* Create HeartBeat message, we just use a sequence number * as payload to distuingish different messages and add * some random stuff. * - Message Type, 1 byte * - Payload Length, 2 bytes (unsigned int) * - Payload, the sequence number (2 bytes uint) * - Payload, random bytes (16 bytes uint) * - Padding */ buf = OPENSSL_malloc(1 + 2 + payload + padding); p = buf; /* Message Type */ *p++ = TLS1_HB_REQUEST; /* Payload length (18 bytes here) */ s2n(payload, p); /* Sequence number */ s2n(s->tlsext_hb_seq, p); /* 16 random bytes */ RAND_pseudo_bytes(p, 16); p += 16; /* Random padding */ RAND_pseudo_bytes(p, padding); ret = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buf, 3 + payload + padding); if (ret >= 0) { if (s->msg_callback) s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, buf, 3 + payload + padding, s, s->msg_callback_arg); dtls1_start_timer(s); s->tlsext_hb_pending = 1; } OPENSSL_free(buf); return ret; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [GF_Err databox_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_DataBox *ptr = (GF_DataBox *) s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_int(bs, ptr->reserved, 32); if(ptr->data != NULL && ptr->dataSize > 0) { gf_bs_write_data(bs, ptr->data, ptr->dataSize); } return GF_OK; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [BOOL update_recv(rdpUpdate* update, wStream* s) { BOOL rc = FALSE; UINT16 updateType; rdpContext* context = update->context; if (Stream_GetRemainingLength(s) < 2) { WLog_ERR(TAG, "Stream_GetRemainingLength(s) < 2"); return FALSE; } Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ WLog_Print(update->log, WLOG_TRACE, "%s Update Data PDU", UPDATE_TYPE_STRINGS[updateType]); if (!update_begin_paint(update)) goto fail; switch (updateType) { case UPDATE_TYPE_ORDERS: rc = update_recv_orders(update, s); break; case UPDATE_TYPE_BITMAP: { BITMAP_UPDATE* bitmap_update = update_read_bitmap_update(update, s); if (!bitmap_update) { WLog_ERR(TAG, "UPDATE_TYPE_BITMAP - update_read_bitmap_update() failed"); goto fail; } rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update); free_bitmap_update(update->context, bitmap_update); } break; case UPDATE_TYPE_PALETTE: { PALETTE_UPDATE* palette_update = update_read_palette(update, s); if (!palette_update) { WLog_ERR(TAG, "UPDATE_TYPE_PALETTE - update_read_palette() failed"); goto fail; } rc = IFCALLRESULT(FALSE, update->Palette, context, palette_update); free_palette_update(context, palette_update); } break; case UPDATE_TYPE_SYNCHRONIZE: update_read_synchronize(update, s); rc = IFCALLRESULT(TRUE, update->Synchronize, context); break; default: break; } fail: if (!update_end_paint(update)) rc = FALSE; if (!rc) { WLog_ERR(TAG, "UPDATE_TYPE %s [%" PRIu16 "] failed", update_type_to_string(updateType), updateType); return FALSE; } return TRUE; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void PrintBuiltInNodes(u32 graph_type, Bool dump_nodes) { #if !defined(GPAC_DISABLE_VRML) && !defined(GPAC_DISABLE_X3D) && !defined(GPAC_DISABLE_SVG) GF_SceneGraph *sg; u32 i, nb_in, nb_not_in, start_tag, end_tag; if (graph_type==1) { #if !defined(GPAC_DISABLE_VRML) && !defined(GPAC_DISABLE_X3D) start_tag = GF_NODE_RANGE_FIRST_X3D; end_tag = TAG_LastImplementedX3D; #else fprintf(stderr, "X3D scene graph disabled in this build of GPAC\n"); return; #endif } else if (graph_type==2) { #ifdef GPAC_DISABLE_SVG fprintf(stderr, "SVG scene graph disabled in this build of GPAC\n"); return; #else start_tag = GF_NODE_RANGE_FIRST_SVG; end_tag = GF_NODE_RANGE_LAST_SVG; #endif } else { #ifdef GPAC_DISABLE_VRML fprintf(stderr, "VRML/MPEG-4 scene graph disabled in this build of GPAC\n"); return; #else start_tag = GF_NODE_RANGE_FIRST_MPEG4; end_tag = TAG_LastImplementedMPEG4; #endif } nb_in = nb_not_in = 0; sg = gf_sg_new(); if (graph_type==1) { fprintf(stderr, "Available X3D nodes in this build (dumping):\n"); } else if (graph_type==2) { fprintf(stderr, "Available SVG nodes in this build (dumping and LASeR coding):\n"); } else { fprintf(stderr, "Available MPEG-4 nodes in this build (encoding/decoding/dumping):\n"); } for (i=start_tag; i<end_tag; i++) { GF_Node *node = gf_node_new(sg, i); if (node) { gf_node_register(node, NULL); if (dump_nodes) { do_print_node(node, sg, gf_node_get_class_name(node), graph_type, GF_FALSE, GF_TRUE); } else { fprintf(stderr, " %s\n", gf_node_get_class_name(node)); } gf_node_unregister(node, NULL); nb_in++; } else { if (graph_type==2) break; nb_not_in++; } } gf_sg_del(sg); if (graph_type==2) { fprintf(stderr, "\n%d nodes supported\n", nb_in); } else { fprintf(stderr, "\n%d nodes supported - %d nodes not supported\n", nb_in, nb_not_in); } //coverage if (dump_nodes) { for (i=GF_SG_VRML_SFBOOL; i<GF_SG_VRML_SCRIPT_FUNCTION; i++) { void *fp = gf_sg_vrml_field_pointer_new(i); if (fp) gf_sg_vrml_field_pointer_del(fp, i); } } #else fprintf(stderr, "\nNo scene graph enabled in this MP4Box build\n"); #endif }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void sdma_sw_clean_up_task(unsigned long opaque) { struct sdma_engine *sde = (struct sdma_engine *)opaque; unsigned long flags; spin_lock_irqsave(&sde->tail_lock, flags); write_seqlock(&sde->head_lock); /* * At this point, the following should always be true: * - We are halted, so no more descriptors are getting retired. * - We are not running, so no one is submitting new work. * - Only we can send the e40_sw_cleaned, so we can't start * running again until we say so. So, the active list and * descq are ours to play with. */ /* * In the error clean up sequence, software clean must be called * before the hardware clean so we can use the hardware head in * the progress routine. A hardware clean or SPC unfreeze will * reset the hardware head. * * Process all retired requests. The progress routine will use the * latest physical hardware head - we are not running so speed does * not matter. */ sdma_make_progress(sde, 0); sdma_flush(sde); /* * Reset our notion of head and tail. * Note that the HW registers have been reset via an earlier * clean up. */ sde->descq_tail = 0; sde->descq_head = 0; sde->desc_avail = sdma_descq_freecnt(sde); *sde->head_dma = 0; __sdma_process_event(sde, sdma_event_e40_sw_cleaned); write_sequnlock(&sde->head_lock); spin_unlock_irqrestore(&sde->tail_lock, flags); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int tun_attach_filter(struct tun_struct *tun) { int i, ret = 0; struct tun_file *tfile; for (i = 0; i < tun->numqueues; i++) { tfile = rtnl_dereference(tun->tfiles[i]); lock_sock(tfile->socket.sk); ret = sk_attach_filter(&tun->fprog, tfile->socket.sk); release_sock(tfile->socket.sk); if (ret) { tun_detach_filter(tun, i); return ret; } } tun->filter_attached = true; return ret; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [String *Item_sum_udf_decimal::val_str(String *str) { return val_string_from_decimal(str); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [char *FLTGetIsLikeComparisonCommonExpression(FilterEncodingNode *psFilterNode) { const size_t bufferSize = 1024; char szBuffer[1024]; char szTmp[256]; char *pszValue = NULL; const char *pszWild = NULL; const char *pszSingle = NULL; const char *pszEscape = NULL; int bCaseInsensitive = 0; FEPropertyIsLike* propIsLike; int nLength=0, i=0, iTmp=0; if (!psFilterNode || !psFilterNode->pOther || !psFilterNode->psLeftNode || !psFilterNode->psRightNode || !psFilterNode->psRightNode->pszValue) return NULL; propIsLike = (FEPropertyIsLike *)psFilterNode->pOther; pszWild = propIsLike->pszWildCard; pszSingle = propIsLike->pszSingleChar; pszEscape = propIsLike->pszEscapeChar; bCaseInsensitive = propIsLike->bCaseInsensitive; if (!pszWild || strlen(pszWild) == 0 || !pszSingle || strlen(pszSingle) == 0 || !pszEscape || strlen(pszEscape) == 0) return NULL; /* -------------------------------------------------------------------- */ /* Use operand with regular expressions. */ /* -------------------------------------------------------------------- */ szBuffer[0] = '\0'; sprintf(szTmp, "%s", "(\"["); szTmp[4] = '\0'; strlcat(szBuffer, szTmp, bufferSize); /* attribute */ strlcat(szBuffer, psFilterNode->psLeftNode->pszValue, bufferSize); szBuffer[strlen(szBuffer)] = '\0'; /* #3521 */ if (bCaseInsensitive == 1) sprintf(szTmp, "%s", "]\" ~* \""); else sprintf(szTmp, "%s", "]\" ~ \""); szTmp[7] = '\0'; strlcat(szBuffer, szTmp, bufferSize); szBuffer[strlen(szBuffer)] = '\0'; pszValue = psFilterNode->psRightNode->pszValue; nLength = strlen(pszValue); iTmp =0; if (nLength > 0 && pszValue[0] != pszWild[0] && pszValue[0] != pszSingle[0] && pszValue[0] != pszEscape[0]) { szTmp[iTmp]= '^'; iTmp++; } for (i=0; i<nLength; i++) { if (pszValue[i] != pszWild[0] && pszValue[i] != pszSingle[0] && pszValue[i] != pszEscape[0]) { szTmp[iTmp] = pszValue[i]; iTmp++; szTmp[iTmp] = '\0'; } else if (pszValue[i] == pszSingle[0]) { szTmp[iTmp] = '.'; iTmp++; szTmp[iTmp] = '\0'; } else if (pszValue[i] == pszEscape[0]) { szTmp[iTmp] = '\\'; iTmp++; szTmp[iTmp] = '\0'; } else if (pszValue[i] == pszWild[0]) { szTmp[iTmp++] = '.'; szTmp[iTmp++] = '*'; szTmp[iTmp] = '\0'; } } szTmp[iTmp] = '"'; szTmp[++iTmp] = '\0'; strlcat(szBuffer, szTmp, bufferSize); strlcat(szBuffer, ")", bufferSize); return msStrdup(szBuffer); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int __ipmi_bmc_register(struct ipmi_smi *intf, struct ipmi_device_id *id, bool guid_set, guid_t *guid, int intf_num) { int rv; struct bmc_device *bmc; struct bmc_device *old_bmc; /* * platform_device_register() can cause bmc_reg_mutex to * be claimed because of the is_visible functions of * the attributes. Eliminate possible recursion and * release the lock. */ intf->in_bmc_register = true; mutex_unlock(&intf->bmc_reg_mutex); /* * Try to find if there is an bmc_device struct * representing the interfaced BMC already */ mutex_lock(&ipmidriver_mutex); if (guid_set) old_bmc = ipmi_find_bmc_guid(&ipmidriver.driver, guid); else old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver.driver, id->product_id, id->device_id); /* * If there is already an bmc_device, free the new one, * otherwise register the new BMC device */ if (old_bmc) { bmc = old_bmc; /* * Note: old_bmc already has usecount incremented by * the BMC find functions. */ intf->bmc = old_bmc; mutex_lock(&bmc->dyn_mutex); list_add_tail(&intf->bmc_link, &bmc->intfs); mutex_unlock(&bmc->dyn_mutex); dev_info(intf->si_dev, "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", bmc->id.manufacturer_id, bmc->id.product_id, bmc->id.device_id); } else { bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); if (!bmc) { rv = -ENOMEM; goto out; } INIT_LIST_HEAD(&bmc->intfs); mutex_init(&bmc->dyn_mutex); INIT_WORK(&bmc->remove_work, cleanup_bmc_work); bmc->id = *id; bmc->dyn_id_set = 1; bmc->dyn_guid_set = guid_set; bmc->guid = *guid; bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; bmc->pdev.name = "ipmi_bmc"; rv = ida_simple_get(&ipmi_bmc_ida, 0, 0, GFP_KERNEL); if (rv < 0) goto out; bmc->pdev.dev.driver = &ipmidriver.driver; bmc->pdev.id = rv; bmc->pdev.dev.release = release_bmc_device; bmc->pdev.dev.type = &bmc_device_type; kref_init(&bmc->usecount); intf->bmc = bmc; mutex_lock(&bmc->dyn_mutex); list_add_tail(&intf->bmc_link, &bmc->intfs); mutex_unlock(&bmc->dyn_mutex); rv = platform_device_register(&bmc->pdev); if (rv) { dev_err(intf->si_dev, "Unable to register bmc device: %d\n", rv); goto out_list_del; } dev_info(intf->si_dev, "Found new BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", bmc->id.manufacturer_id, bmc->id.product_id, bmc->id.device_id); } /* * create symlink from system interface device to bmc device * and back. */ rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); if (rv) { dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv); goto out_put_bmc; } if (intf_num == -1) intf_num = intf->intf_num; intf->my_dev_name = kasprintf(GFP_KERNEL, "ipmi%d", intf_num); if (!intf->my_dev_name) { rv = -ENOMEM; dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n", rv); goto out_unlink1; } rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, intf->my_dev_name); if (rv) { kfree(intf->my_dev_name); intf->my_dev_name = NULL; dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n", rv); goto out_free_my_dev_name; } intf->bmc_registered = true; out: mutex_unlock(&ipmidriver_mutex); mutex_lock(&intf->bmc_reg_mutex); intf->in_bmc_register = false; return rv; out_free_my_dev_name: kfree(intf->my_dev_name); intf->my_dev_name = NULL; out_unlink1: sysfs_remove_link(&intf->si_dev->kobj, "bmc"); out_put_bmc: mutex_lock(&bmc->dyn_mutex); list_del(&intf->bmc_link); mutex_unlock(&bmc->dyn_mutex); intf->bmc = &intf->tmp_bmc; kref_put(&bmc->usecount, cleanup_bmc_device); goto out; out_list_del: mutex_lock(&bmc->dyn_mutex); list_del(&intf->bmc_link); mutex_unlock(&bmc->dyn_mutex); intf->bmc = &intf->tmp_bmc; put_device(&bmc->pdev.dev); goto out; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [QPDF::trim_user_password(std::string& user_password) { // Although unnecessary, this routine trims the padding string // from the end of a user password. Its only purpose is for // recovery of user passwords which is done in the test suite. char const* cstr = user_password.c_str(); size_t len = user_password.length(); if (len < key_bytes) { return; } char const* p1 = cstr; char const* p2 = 0; while ((p2 = strchr(p1, '\x28')) != 0) { if (memcmp(p2, padding_string, len - (p2 - cstr)) == 0) { user_password = user_password.substr(0, p2 - cstr); return; } else { QTC::TC("qpdf", "QPDF_encryption skip 0x28"); p1 = p2 + 1; } } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void RegexMatchExpression::_init() { uassert( ErrorCodes::BadValue, "Regular expression is too long", _regex.size() <= kMaxPatternSize); uassert(ErrorCodes::BadValue, "Regular expression cannot contain an embedded null byte", _regex.find('\0') == std::string::npos); uassert(ErrorCodes::BadValue, "Regular expression options string cannot contain an embedded null byte", _flags.find('\0') == std::string::npos); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [R_API char *r_bin_java_get_this_class_name(RBinJavaObj *bin) { return (bin->cf2.this_class_name ? strdup (bin->cf2.this_class_name) : strdup ("unknown")); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [bool PackLinuxElf32::calls_crt1(Elf32_Rel const *rel, int sz) { if (!dynsym || !dynstr) { return false; } for (unsigned relnum= 0; 0 < sz; (sz -= sizeof(Elf32_Rel)), ++rel, ++relnum) { unsigned const symnum = get_te32(&rel->r_info) >> 8; char const *const symnam = get_dynsym_name(symnum, relnum); if (0==strcmp(symnam, "__libc_start_main") // glibc || 0==strcmp(symnam, "__libc_init") // Android || 0==strcmp(symnam, "__uClibc_main") || 0==strcmp(symnam, "__uClibc_start_main")) return true; } return false; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [R_API void U(r_bin_java_free_const_value)(ConstJavaValue * cp_value) { char first_char = cp_value && cp_value->type ? *cp_value->type : 0, second_char = cp_value && cp_value->type ? *(cp_value->type + 1) : 0; switch (first_char) { case 'r': if (cp_value && cp_value->value._ref) { free (cp_value->value._ref->class_name); free (cp_value->value._ref->name); free (cp_value->value._ref->desc); } break; case 's': if (second_char == 't' && cp_value->value._str) { free (cp_value->value._str->str); } break; } free (cp_value); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int ssl3_get_client_key_exchange(SSL *s) { int i,al,ok; long n; unsigned long alg_k; unsigned char *p; #ifndef OPENSSL_NO_RSA RSA *rsa=NULL; EVP_PKEY *pkey=NULL; #endif #ifndef OPENSSL_NO_DH BIGNUM *pub=NULL; DH *dh_srvr; #endif #ifndef OPENSSL_NO_KRB5 KSSL_ERR kssl_err; #endif /* OPENSSL_NO_KRB5 */ #ifndef OPENSSL_NO_ECDH EC_KEY *srvr_ecdh = NULL; EVP_PKEY *clnt_pub_pkey = NULL; EC_POINT *clnt_ecpoint = NULL; BN_CTX *bn_ctx = NULL; #endif n=s->method->ssl_get_message(s, SSL3_ST_SR_KEY_EXCH_A, SSL3_ST_SR_KEY_EXCH_B, SSL3_MT_CLIENT_KEY_EXCHANGE, 2048, /* ??? */ &ok); if (!ok) return((int)n); p=(unsigned char *)s->init_msg; alg_k=s->s3->tmp.new_cipher->algorithm_mkey; #ifndef OPENSSL_NO_RSA if (alg_k & SSL_kRSA) { /* FIX THIS UP EAY EAY EAY EAY */ if (s->s3->tmp.use_rsa_tmp) { if ((s->cert != NULL) && (s->cert->rsa_tmp != NULL)) rsa=s->cert->rsa_tmp; /* Don't do a callback because rsa_tmp should * be sent already */ if (rsa == NULL) { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_MISSING_TMP_RSA_PKEY); goto f_err; } } else { pkey=s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey; if ( (pkey == NULL) || (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_MISSING_RSA_CERTIFICATE); goto f_err; } rsa=pkey->pkey.rsa; } /* TLS and [incidentally] DTLS{0xFEFF} */ if (s->version > SSL3_VERSION && s->version != DTLS1_BAD_VER) { n2s(p,i); if (n != i+2) { if (!(s->options & SSL_OP_TLS_D5_BUG)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG); goto err; } else p-=2; } else n=i; } i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); al = -1; if (i != SSL_MAX_MASTER_KEY_LENGTH) { al=SSL_AD_DECODE_ERROR; /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); */ } if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) { /* The premaster secret must contain the same version number as the * ClientHello to detect version rollback attacks (strangely, the * protocol does not offer such protection for DH ciphersuites). * However, buggy clients exist that send the negotiated protocol * version instead if the server does not support the requested * protocol version. * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such clients. */ if (!((s->options & SSL_OP_TLS_ROLLBACK_BUG) && (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) { al=SSL_AD_DECODE_ERROR; /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ /* The Klima-Pokorny-Rosa extension of Bleichenbacher's attack * (http://eprint.iacr.org/2003/052/) exploits the version * number check as a "bad version oracle" -- an alert would * reveal that the plaintext corresponding to some ciphertext * made up by the adversary is properly formatted except * that the version number is wrong. To avoid such attacks, * we should treat this just like any other decryption error. */ } } if (al != -1) { /* Some decryption failure -- use random value instead as countermeasure * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding * (see RFC 2246, section 7.4.7.1). */ ERR_clear_error(); i = SSL_MAX_MASTER_KEY_LENGTH; p[0] = s->client_version >> 8; p[1] = s->client_version & 0xff; if (RAND_pseudo_bytes(p+2, i-2) <= 0) /* should be RAND_bytes, but we cannot work around a failure */ goto err; } s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, p,i); OPENSSL_cleanse(p,i); } else #endif #ifndef OPENSSL_NO_DH if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) { n2s(p,i); if (n != i+2) { if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); goto err; } else { p-=2; i=(int)n; } } if (n == 0L) /* the parameters are in the cert */ { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_UNABLE_TO_DECODE_DH_CERTS); goto f_err; } else { if (s->s3->tmp.dh == NULL) { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY); goto f_err; } else dh_srvr=s->s3->tmp.dh; } pub=BN_bin2bn(p,i,NULL); if (pub == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BN_LIB); goto err; } i=DH_compute_key(p,pub,dh_srvr); if (i <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB); goto err; } DH_free(s->s3->tmp.dh); s->s3->tmp.dh=NULL; BN_clear_free(pub); pub=NULL; s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key,p,i); OPENSSL_cleanse(p,i); } else #endif #ifndef OPENSSL_NO_KRB5 if (alg_k & SSL_kKRB5) { krb5_error_code krb5rc; krb5_data enc_ticket; krb5_data authenticator; krb5_data enc_pms; KSSL_CTX *kssl_ctx = s->kssl_ctx; EVP_CIPHER_CTX ciph_ctx; const EVP_CIPHER *enc = NULL; unsigned char iv[EVP_MAX_IV_LENGTH]; unsigned char pms[SSL_MAX_MASTER_KEY_LENGTH + EVP_MAX_BLOCK_LENGTH]; int padl, outl; krb5_timestamp authtime = 0; krb5_ticket_times ttimes; EVP_CIPHER_CTX_init(&ciph_ctx); if (!kssl_ctx) kssl_ctx = kssl_ctx_new(); n2s(p,i); enc_ticket.length = i; if (n < (long)(enc_ticket.length + 6)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } enc_ticket.data = (char *)p; p+=enc_ticket.length; n2s(p,i); authenticator.length = i; if (n < (long)(enc_ticket.length + authenticator.length + 6)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } authenticator.data = (char *)p; p+=authenticator.length; n2s(p,i); enc_pms.length = i; enc_pms.data = (char *)p; p+=enc_pms.length; /* Note that the length is checked again below, ** after decryption */ if(enc_pms.length > sizeof pms) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } if (n != (long)(enc_ticket.length + authenticator.length + enc_pms.length + 6)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } if ((krb5rc = kssl_sget_tkt(kssl_ctx, &enc_ticket, &ttimes, &kssl_err)) != 0) { #ifdef KSSL_DEBUG printf("kssl_sget_tkt rtn %d [%d]\n", krb5rc, kssl_err.reason); if (kssl_err.text) printf("kssl_err text= %s\n", kssl_err.text); #endif /* KSSL_DEBUG */ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, kssl_err.reason); goto err; } /* Note: no authenticator is not considered an error, ** but will return authtime == 0. */ if ((krb5rc = kssl_check_authent(kssl_ctx, &authenticator, &authtime, &kssl_err)) != 0) { #ifdef KSSL_DEBUG printf("kssl_check_authent rtn %d [%d]\n", krb5rc, kssl_err.reason); if (kssl_err.text) printf("kssl_err text= %s\n", kssl_err.text); #endif /* KSSL_DEBUG */ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, kssl_err.reason); goto err; } if ((krb5rc = kssl_validate_times(authtime, &ttimes)) != 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, krb5rc); goto err; } #ifdef KSSL_DEBUG kssl_ctx_show(kssl_ctx); #endif /* KSSL_DEBUG */ enc = kssl_map_enc(kssl_ctx->enctype); if (enc == NULL) goto err; memset(iv, 0, sizeof iv); /* per RFC 1510 */ if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DECRYPTION_FAILED); goto err; } if (!EVP_DecryptUpdate(&ciph_ctx, pms,&outl, (unsigned char *)enc_pms.data, enc_pms.length)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DECRYPTION_FAILED); goto err; } if (outl > SSL_MAX_MASTER_KEY_LENGTH) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } if (!EVP_DecryptFinal_ex(&ciph_ctx,&(pms[outl]),&padl)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DECRYPTION_FAILED); goto err; } outl += padl; if (outl > SSL_MAX_MASTER_KEY_LENGTH) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } if (!((pms[0] == (s->client_version>>8)) && (pms[1] == (s->client_version & 0xff)))) { /* The premaster secret must contain the same version number as the * ClientHello to detect version rollback attacks (strangely, the * protocol does not offer such protection for DH ciphersuites). * However, buggy clients exist that send random bytes instead of * the protocol version. * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such clients. * (Perhaps we should have a separate BUG value for the Kerberos cipher) */ if (!(s->options & SSL_OP_TLS_ROLLBACK_BUG)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_AD_DECODE_ERROR); goto err; } } EVP_CIPHER_CTX_cleanup(&ciph_ctx); s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, pms, outl); if (kssl_ctx->client_princ) { size_t len = strlen(kssl_ctx->client_princ); if ( len < SSL_MAX_KRB5_PRINCIPAL_LENGTH ) { s->session->krb5_client_princ_len = len; memcpy(s->session->krb5_client_princ,kssl_ctx->client_princ,len); } } /* Was doing kssl_ctx_free() here, ** but it caused problems for apache. ** kssl_ctx = kssl_ctx_free(kssl_ctx); ** if (s->kssl_ctx) s->kssl_ctx = NULL; */ } else #endif /* OPENSSL_NO_KRB5 */ #ifndef OPENSSL_NO_ECDH if (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) { int ret = 1; int field_size = 0; const EC_KEY *tkey; const EC_GROUP *group; const BIGNUM *priv_key; /* initialize structures for server's ECDH key pair */ if ((srvr_ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Let's get server private key and group information */ if (alg_k & (SSL_kECDHr|SSL_kECDHe)) { /* use the certificate */ tkey = s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec; } else { /* use the ephermeral values we saved when * generating the ServerKeyExchange msg. */ tkey = s->s3->tmp.ecdh; } group = EC_KEY_get0_group(tkey); priv_key = EC_KEY_get0_private_key(tkey); if (!EC_KEY_set_group(srvr_ecdh, group) || !EC_KEY_set_private_key(srvr_ecdh, priv_key)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } /* Let's get client's public key */ if ((clnt_ecpoint = EC_POINT_new(group)) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (n == 0L) { /* Client Publickey was in Client Certificate */ if (alg_k & SSL_kEECDH) { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_MISSING_TMP_ECDH_KEY); goto f_err; } if (((clnt_pub_pkey=X509_get_pubkey(s->session->peer)) == NULL) || (clnt_pub_pkey->type != EVP_PKEY_EC)) { /* XXX: For now, we do not support client * authentication using ECDH certificates * so this branch (n == 0L) of the code is * never executed. When that support is * added, we ought to ensure the key * received in the certificate is * authorized for key agreement. * ECDH_compute_key implicitly checks that * the two ECDH shares are for the same * group. */ al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNABLE_TO_DECODE_ECDH_CERTS); goto f_err; } if (EC_POINT_copy(clnt_ecpoint, EC_KEY_get0_public_key(clnt_pub_pkey->pkey.ec)) == 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } ret = 2; /* Skip certificate verify processing */ } else { /* Get client's public key from encoded point * in the ClientKeyExchange message. */ if ((bn_ctx = BN_CTX_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Get encoded point length */ i = *p; p += 1; if (EC_POINT_oct2point(group, clnt_ecpoint, p, i, bn_ctx) == 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } /* p is pointing to somewhere in the buffer * currently, so set it to the start */ p=(unsigned char *)s->init_buf->data; } /* Compute the shared pre-master secret */ field_size = EC_GROUP_get_degree(group); if (field_size <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } i = ECDH_compute_key(p, (field_size+7)/8, clnt_ecpoint, srvr_ecdh, NULL); if (i <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } EVP_PKEY_free(clnt_pub_pkey); EC_POINT_free(clnt_ecpoint); EC_KEY_free(srvr_ecdh); BN_CTX_free(bn_ctx); EC_KEY_free(s->s3->tmp.ecdh); s->s3->tmp.ecdh = NULL; /* Compute the master secret */ s->session->master_key_length = s->method->ssl3_enc-> \ generate_master_secret(s, s->session->master_key, p, i); OPENSSL_cleanse(p, i); return (ret); } else #endif #ifndef OPENSSL_NO_PSK if (alg_k & SSL_kPSK) { unsigned char *t = NULL; unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2+4]; unsigned int pre_ms_len = 0, psk_len = 0; int psk_err = 1; char tmp_id[PSK_MAX_IDENTITY_LEN+1]; al=SSL_AD_HANDSHAKE_FAILURE; n2s(p,i); if (n != i+2) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto psk_err; } if (i > PSK_MAX_IDENTITY_LEN) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto psk_err; } if (s->psk_server_callback == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_PSK_NO_SERVER_CB); goto psk_err; } /* Create guaranteed NULL-terminated identity * string for the callback */ memcpy(tmp_id, p, i); memset(tmp_id+i, 0, PSK_MAX_IDENTITY_LEN+1-i); psk_len = s->psk_server_callback(s, tmp_id, psk_or_pre_ms, sizeof(psk_or_pre_ms)); OPENSSL_cleanse(tmp_id, PSK_MAX_IDENTITY_LEN+1); if (psk_len > PSK_MAX_PSK_LEN) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto psk_err; } else if (psk_len == 0) { /* PSK related to the given identity not found */ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_PSK_IDENTITY_NOT_FOUND); al=SSL_AD_UNKNOWN_PSK_IDENTITY; goto psk_err; } /* create PSK pre_master_secret */ pre_ms_len=2+psk_len+2+psk_len; t = psk_or_pre_ms; memmove(psk_or_pre_ms+psk_len+4, psk_or_pre_ms, psk_len); s2n(psk_len, t); memset(t, 0, psk_len); t+=psk_len; s2n(psk_len, t); if (s->session->psk_identity != NULL) OPENSSL_free(s->session->psk_identity); s->session->psk_identity = BUF_strdup((char *)p); if (s->session->psk_identity == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto psk_err; } if (s->session->psk_identity_hint != NULL) OPENSSL_free(s->session->psk_identity_hint); s->session->psk_identity_hint = BUF_strdup(s->ctx->psk_identity_hint); if (s->ctx->psk_identity_hint != NULL && s->session->psk_identity_hint == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto psk_err; } s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, psk_or_pre_ms, pre_ms_len); psk_err = 0; psk_err: OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); if (psk_err != 0) goto f_err; } else #endif if (alg_k & SSL_kGOST) { int ret = 0; EVP_PKEY_CTX *pkey_ctx; EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; unsigned char premaster_secret[32], *start; size_t outlen=32, inlen; unsigned long alg_a; /* Get our certificate private key*/ alg_a = s->s3->tmp.new_cipher->algorithm_auth; if (alg_a & SSL_aGOST94) pk = s->cert->pkeys[SSL_PKEY_GOST94].privatekey; else if (alg_a & SSL_aGOST01) pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; pkey_ctx = EVP_PKEY_CTX_new(pk,NULL); EVP_PKEY_decrypt_init(pkey_ctx); /* If client certificate is present and is of the same type, maybe * use it for key exchange. Don't mind errors from * EVP_PKEY_derive_set_peer, because it is completely valid to use * a client certificate for authorization only. */ client_pub_pkey = X509_get_pubkey(s->session->peer); if (client_pub_pkey) { if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) ERR_clear_error(); } /* Decrypt session key */ if ((*p!=( V_ASN1_SEQUENCE| V_ASN1_CONSTRUCTED))) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED); goto gerr; } if (p[1] == 0x81) { start = p+3; inlen = p[2]; } else if (p[1] < 0x80) { start = p+2; inlen = p[1]; } else { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED); goto gerr; } if (EVP_PKEY_decrypt(pkey_ctx,premaster_secret,&outlen,start,inlen) <=0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED); goto gerr; } /* Generate master secret */ s->session->master_key_length= s->method->ssl3_enc->generate_master_secret(s, s->session->master_key,premaster_secret,32); /* Check if pubkey from client certificate was used */ if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) ret = 2; else ret = 1; gerr: EVP_PKEY_free(client_pub_pkey); EVP_PKEY_CTX_free(pkey_ctx); if (ret) return ret; else goto err; } else { al=SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNKNOWN_CIPHER_TYPE); goto f_err; } return(1); f_err: ssl3_send_alert(s,SSL3_AL_FATAL,al); #if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_ECDH) err: #endif #ifndef OPENSSL_NO_ECDH EVP_PKEY_free(clnt_pub_pkey); EC_POINT_free(clnt_ecpoint); if (srvr_ecdh != NULL) EC_KEY_free(srvr_ecdh); BN_CTX_free(bn_ctx); #endif return(-1); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t size, int flags) { struct sock *sk = sock->sk; struct sk_buff *skb; int copied; int err = 0; lock_sock(sk); /* * This works for seqpacket too. The receiver has ordered the * queue for us! We do one quick check first though */ if (sk->sk_type == SOCK_SEQPACKET && sk->sk_state != TCP_ESTABLISHED) { err = -ENOTCONN; goto out; } /* Now we can treat all alike */ skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &err); if (skb == NULL) goto out; if (!ax25_sk(sk)->pidincl) skb_pull(skb, 1); /* Remove PID */ skb_reset_transport_header(skb); copied = skb->len; if (copied > size) { copied = size; msg->msg_flags |= MSG_TRUNC; } skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); if (msg->msg_namelen != 0) { struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name; ax25_digi digi; ax25_address src; const unsigned char *mac = skb_mac_header(skb); ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL, &digi, NULL, NULL); sax->sax25_family = AF_AX25; /* We set this correctly, even though we may not let the application know the digi calls further down (because it did NOT ask to know them). This could get political... **/ sax->sax25_ndigis = digi.ndigi; sax->sax25_call = src; if (sax->sax25_ndigis != 0) { int ct; struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)sax; for (ct = 0; ct < digi.ndigi; ct++) fsa->fsa_digipeater[ct] = digi.calls[ct]; } msg->msg_namelen = sizeof(struct full_sockaddr_ax25); } skb_free_datagram(sk, skb); err = copied; out: release_sock(sk); return err; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void _int_free (mstate av, mchunkptr p, int have_lock) { INTERNAL_SIZE_T size; /* its size */ mfastbinptr *fb; /* associated fastbin */ mchunkptr nextchunk; /* next contiguous chunk */ INTERNAL_SIZE_T nextsize; /* its size */ int nextinuse; /* true if nextchunk is used */ INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */ mchunkptr bck; /* misc temp for linking */ mchunkptr fwd; /* misc temp for linking */ size = chunksize (p); /* Little security check which won't hurt performance: the allocator never wrapps around at the end of the address space. Therefore we can exclude some size values which might appear here by accident or by "design" from some intruder. */ if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) || __builtin_expect (misaligned_chunk (p), 0)) malloc_printerr ("free(): invalid pointer"); /* We know that each chunk is at least MINSIZE bytes in size or a multiple of MALLOC_ALIGNMENT. */ if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) malloc_printerr ("free(): invalid size"); check_inuse_chunk(av, p); #if USE_TCACHE { size_t tc_idx = csize2tidx (size); if (tcache && tc_idx < mp_.tcache_bins && tcache->counts[tc_idx] < mp_.tcache_count) { tcache_put (p, tc_idx); return; } } #endif /* If eligible, place chunk on a fastbin so it can be found and used quickly in malloc. */ if ((unsigned long)(size) <= (unsigned long)(get_max_fast ()) #if TRIM_FASTBINS /* If TRIM_FASTBINS set, don't place chunks bordering top into fastbins */ && (chunk_at_offset(p, size) != av->top) #endif ) { if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ, 0) || __builtin_expect (chunksize (chunk_at_offset (p, size)) >= av->system_mem, 0)) { bool fail = true; /* We might not have a lock at this point and concurrent modifications of system_mem might result in a false positive. Redo the test after getting the lock. */ if (!have_lock) { __libc_lock_lock (av->mutex); fail = (chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ || chunksize (chunk_at_offset (p, size)) >= av->system_mem); __libc_lock_unlock (av->mutex); } if (fail) malloc_printerr ("free(): invalid next size (fast)"); } free_perturb (chunk2mem(p), size - 2 * SIZE_SZ); atomic_store_relaxed (&av->have_fastchunks, true); unsigned int idx = fastbin_index(size); fb = &fastbin (av, idx); /* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ mchunkptr old = *fb, old2; if (SINGLE_THREAD_P) { /* Check that the top of the bin is not the record we are going to add (i.e., double free). */ if (__builtin_expect (old == p, 0)) malloc_printerr ("double free or corruption (fasttop)"); p->fd = old; *fb = p; } else do { /* Check that the top of the bin is not the record we are going to add (i.e., double free). */ if (__builtin_expect (old == p, 0)) malloc_printerr ("double free or corruption (fasttop)"); p->fd = old2 = old; } while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) != old2); /* Check that size of fastbin chunk at the top is the same as size of the chunk that we are adding. We can dereference OLD only if we have the lock, otherwise it might have already been allocated again. */ if (have_lock && old != NULL && __builtin_expect (fastbin_index (chunksize (old)) != idx, 0)) malloc_printerr ("invalid fastbin entry (free)"); } /* Consolidate other non-mmapped chunks as they arrive. */ else if (!chunk_is_mmapped(p)) { /* If we're single-threaded, don't lock the arena. */ if (SINGLE_THREAD_P) have_lock = true; if (!have_lock) __libc_lock_lock (av->mutex); nextchunk = chunk_at_offset(p, size); /* Lightweight tests: check whether the block is already the top block. */ if (__glibc_unlikely (p == av->top)) malloc_printerr ("double free or corruption (top)"); /* Or whether the next chunk is beyond the boundaries of the arena. */ if (__builtin_expect (contiguous (av) && (char *) nextchunk >= ((char *) av->top + chunksize(av->top)), 0)) malloc_printerr ("double free or corruption (out)"); /* Or whether the block is actually not marked used. */ if (__glibc_unlikely (!prev_inuse(nextchunk))) malloc_printerr ("double free or corruption (!prev)"); nextsize = chunksize(nextchunk); if (__builtin_expect (chunksize_nomask (nextchunk) <= 2 * SIZE_SZ, 0) || __builtin_expect (nextsize >= av->system_mem, 0)) malloc_printerr ("free(): invalid next size (normal)"); free_perturb (chunk2mem(p), size - 2 * SIZE_SZ); /* consolidate backward */ if (!prev_inuse(p)) { prevsize = prev_size (p); size += prevsize; p = chunk_at_offset(p, -((long) prevsize)); unlink(av, p, bck, fwd); } if (nextchunk != av->top) { /* get and clear inuse bit */ nextinuse = inuse_bit_at_offset(nextchunk, nextsize); /* consolidate forward */ if (!nextinuse) { unlink(av, nextchunk, bck, fwd); size += nextsize; } else clear_inuse_bit_at_offset(nextchunk, 0); /* Place the chunk in unsorted chunk list. Chunks are not placed into regular bins until after they have been given one chance to be used in malloc. */ bck = unsorted_chunks(av); fwd = bck->fd; if (__glibc_unlikely (fwd->bk != bck)) malloc_printerr ("free(): corrupted unsorted chunks"); p->fd = fwd; p->bk = bck; if (!in_smallbin_range(size)) { p->fd_nextsize = NULL; p->bk_nextsize = NULL; } bck->fd = p; fwd->bk = p; set_head(p, size | PREV_INUSE); set_foot(p, size); check_free_chunk(av, p); } /* If the chunk borders the current high end of memory, consolidate into top */ else { size += nextsize; set_head(p, size | PREV_INUSE); av->top = p; check_chunk(av, p); } /* If freeing a large space, consolidate possibly-surrounding chunks. Then, if the total unused topmost memory exceeds trim threshold, ask malloc_trim to reduce top. Unless max_fast is 0, we don't know if there are fastbins bordering top, so we cannot tell for sure whether threshold has been reached unless fastbins are consolidated. But we don't want to consolidate on each free. As a compromise, consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */ if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { if (atomic_load_relaxed (&av->have_fastchunks)) malloc_consolidate(av); if (av == &main_arena) { #ifndef MORECORE_CANNOT_TRIM if ((unsigned long)(chunksize(av->top)) >= (unsigned long)(mp_.trim_threshold)) systrim(mp_.top_pad, av); #endif } else { /* Always try heap_trim(), even if the top chunk is not large, because the corresponding heap might go away. */ heap_info *heap = heap_for_ptr(top(av)); assert(heap->ar_ptr == av); heap_trim(heap, mp_.top_pad); } } if (!have_lock) __libc_lock_unlock (av->mutex); } /* If the chunk was allocated via mmap, release via munmap(). */ else { munmap_chunk (p); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void handle_PORT(ctrl_t *ctrl, char *str) { int a, b, c, d, e, f; char addr[INET_ADDRSTRLEN]; struct sockaddr_in sin; if (ctrl->data_sd > 0) { uev_io_stop(&ctrl->data_watcher); close(ctrl->data_sd); ctrl->data_sd = -1; } /* Convert PORT command's argument to IP address + port */ sscanf(str, "%d,%d,%d,%d,%d,%d", &a, &b, &c, &d, &e, &f); sprintf(addr, "%d.%d.%d.%d", a, b, c, d); /* Check IPv4 address using inet_aton(), throw away converted result */ if (!inet_aton(addr, &(sin.sin_addr))) { ERR(0, "Invalid address '%s' given to PORT command", addr); send_msg(ctrl->sd, "500 Illegal PORT command.\r\n"); return; } strlcpy(ctrl->data_address, addr, sizeof(ctrl->data_address)); ctrl->data_port = e * 256 + f; DBG("Client PORT command accepted for %s:%d", ctrl->data_address, ctrl->data_port); send_msg(ctrl->sd, "200 PORT command successful.\r\n"); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ bool useRetryBudget() const { return runtime_.snapshot().get(budget_percent_key_).has_value() || runtime_.snapshot().get(min_retry_concurrency_key_).has_value() || budget_percent_ || min_retry_concurrency_; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term) { int protocol = state->mixer->protocol; int err; void *p1; memset(term, 0, sizeof(*term)); while ((p1 = find_audio_control_unit(state, id)) != NULL) { unsigned char *hdr = p1; term->id = id; if (protocol == UAC_VERSION_1 || protocol == UAC_VERSION_2) { switch (hdr[2]) { case UAC_INPUT_TERMINAL: if (protocol == UAC_VERSION_1) { struct uac_input_terminal_descriptor *d = p1; term->type = le16_to_cpu(d->wTerminalType); term->channels = d->bNrChannels; term->chconfig = le16_to_cpu(d->wChannelConfig); term->name = d->iTerminal; } else { /* UAC_VERSION_2 */ struct uac2_input_terminal_descriptor *d = p1; /* call recursively to verify that the * referenced clock entity is valid */ err = check_input_term(state, d->bCSourceID, term); if (err < 0) return err; /* save input term properties after recursion, * to ensure they are not overriden by the * recursion calls */ term->id = id; term->type = le16_to_cpu(d->wTerminalType); term->channels = d->bNrChannels; term->chconfig = le32_to_cpu(d->bmChannelConfig); term->name = d->iTerminal; } return 0; case UAC_FEATURE_UNIT: { /* the header is the same for v1 and v2 */ struct uac_feature_unit_descriptor *d = p1; id = d->bSourceID; break; /* continue to parse */ } case UAC_MIXER_UNIT: { struct uac_mixer_unit_descriptor *d = p1; term->type = UAC3_MIXER_UNIT << 16; /* virtual type */ term->channels = uac_mixer_unit_bNrChannels(d); term->chconfig = uac_mixer_unit_wChannelConfig(d, protocol); term->name = uac_mixer_unit_iMixer(d); return 0; } case UAC_SELECTOR_UNIT: case UAC2_CLOCK_SELECTOR: { struct uac_selector_unit_descriptor *d = p1; /* call recursively to retrieve the channel info */ err = check_input_term(state, d->baSourceID[0], term); if (err < 0) return err; term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */ term->id = id; term->name = uac_selector_unit_iSelector(d); return 0; } case UAC1_PROCESSING_UNIT: /* UAC2_EFFECT_UNIT */ if (protocol == UAC_VERSION_1) term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ else /* UAC_VERSION_2 */ term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */ /* fall through */ case UAC1_EXTENSION_UNIT: /* UAC2_PROCESSING_UNIT_V2 */ if (protocol == UAC_VERSION_1 && !term->type) term->type = UAC3_EXTENSION_UNIT << 16; /* virtual type */ else if (protocol == UAC_VERSION_2 && !term->type) term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ /* fall through */ case UAC2_EXTENSION_UNIT_V2: { struct uac_processing_unit_descriptor *d = p1; if (protocol == UAC_VERSION_2 && hdr[2] == UAC2_EFFECT_UNIT) { /* UAC2/UAC1 unit IDs overlap here in an * uncompatible way. Ignore this unit for now. */ return 0; } if (d->bNrInPins) { id = d->baSourceID[0]; break; /* continue to parse */ } if (!term->type) term->type = UAC3_EXTENSION_UNIT << 16; /* virtual type */ term->channels = uac_processing_unit_bNrChannels(d); term->chconfig = uac_processing_unit_wChannelConfig(d, protocol); term->name = uac_processing_unit_iProcessing(d, protocol); return 0; } case UAC2_CLOCK_SOURCE: { struct uac_clock_source_descriptor *d = p1; term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ term->id = id; term->name = d->iClockSource; return 0; } default: return -ENODEV; } } else { /* UAC_VERSION_3 */ switch (hdr[2]) { case UAC_INPUT_TERMINAL: { struct uac3_input_terminal_descriptor *d = p1; /* call recursively to verify that the * referenced clock entity is valid */ err = check_input_term(state, d->bCSourceID, term); if (err < 0) return err; /* save input term properties after recursion, * to ensure they are not overriden by the * recursion calls */ term->id = id; term->type = le16_to_cpu(d->wTerminalType); err = get_cluster_channels_v3(state, le16_to_cpu(d->wClusterDescrID)); if (err < 0) return err; term->channels = err; /* REVISIT: UAC3 IT doesn't have channels cfg */ term->chconfig = 0; term->name = le16_to_cpu(d->wTerminalDescrStr); return 0; } case UAC3_FEATURE_UNIT: { struct uac3_feature_unit_descriptor *d = p1; id = d->bSourceID; break; /* continue to parse */ } case UAC3_CLOCK_SOURCE: { struct uac3_clock_source_descriptor *d = p1; term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ term->id = id; term->name = le16_to_cpu(d->wClockSourceStr); return 0; } case UAC3_MIXER_UNIT: { struct uac_mixer_unit_descriptor *d = p1; err = uac_mixer_unit_get_channels(state, d); if (err <= 0) return err; term->channels = err; term->type = UAC3_MIXER_UNIT << 16; /* virtual type */ return 0; } case UAC3_SELECTOR_UNIT: case UAC3_CLOCK_SELECTOR: { struct uac_selector_unit_descriptor *d = p1; /* call recursively to retrieve the channel info */ err = check_input_term(state, d->baSourceID[0], term); if (err < 0) return err; term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */ term->id = id; term->name = 0; /* TODO: UAC3 Class-specific strings */ return 0; } case UAC3_PROCESSING_UNIT: { struct uac_processing_unit_descriptor *d = p1; if (!d->bNrInPins) return -EINVAL; /* call recursively to retrieve the channel info */ err = check_input_term(state, d->baSourceID[0], term); if (err < 0) return err; term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ term->id = id; term->name = 0; /* TODO: UAC3 Class-specific strings */ return 0; } default: return -ENODEV; } } } return -ENODEV; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { int err = -1; int dirfd; dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); if (dirfd == -1) { return -1; } if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { err = mknodat(dirfd, name, SM_LOCAL_MODE_BITS | S_IFREG, 0); if (err == -1) { goto out; } if (fs_ctx->export_flags & V9FS_SM_MAPPED) { err = local_set_xattrat(dirfd, name, credp); } else { err = local_set_mapped_file_attrat(dirfd, name, credp); } if (err == -1) { goto err_end; } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err == -1) { goto err_end; } } goto out; err_end: unlinkat_preserve_errno(dirfd, name, 0); out: close_preserve_errno(dirfd); return err; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ void __io_uring_free(struct task_struct *tsk) { struct io_uring_task *tctx = tsk->io_uring; WARN_ON_ONCE(!xa_empty(&tctx->xa)); WARN_ON_ONCE(tctx->io_wq); WARN_ON_ONCE(tctx->cached_refs); kfree(tctx->registered_rings); percpu_counter_destroy(&tctx->inflight); kfree(tctx); tsk->io_uring = NULL;] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ void Compute(OpKernelContext* const context) override { // node_id_range const Tensor* node_id_range_t; OP_REQUIRES_OK(context, context->input("node_id_range", &node_id_range_t)); OP_REQUIRES( context, node_id_range_t->NumElements() == 2, errors::InvalidArgument("node_id_range argument must have shape [2]")); const auto node_id_range = node_id_range_t->vec<int32>(); const int32_t node_id_first = node_id_range(0); // inclusive const int32_t node_id_last = node_id_range(1); // exclusive const Tensor* stats_summary_t; OP_REQUIRES_OK(context, context->input("stats_summary", &stats_summary_t)); OP_REQUIRES( context, stats_summary_t->shape().dims() == 4, errors::InvalidArgument("stats_summary argument must have rank 4")); TTypes<float, 4>::ConstTensor stats_summary = stats_summary_t->tensor<float, 4>(); const int32_t feature_dims = stats_summary_t->dim_size(1); // The last bucket is for default/missing value. const int32_t num_buckets = stats_summary_t->dim_size(2) - 1; const int32_t logits_dim = logits_dim_; const int32_t hessian_dim = stats_summary_t->dim_size(3) - logits_dim; DCHECK_GT(hessian_dim, 0); DCHECK_LE(hessian_dim, logits_dim * logits_dim); const Tensor* l1_t; OP_REQUIRES_OK(context, context->input("l1", &l1_t)); OP_REQUIRES(context, l1_t->NumElements() == 1, errors::InvalidArgument("l1 argument must be a scalar")); const auto l1 = l1_t->scalar<float>()(); DCHECK_GE(l1, 0); if (logits_dim_ > 1) { // Multi-class L1 regularization not supported yet. DCHECK_EQ(l1, 0); } const Tensor* l2_t; OP_REQUIRES_OK(context, context->input("l2", &l2_t)); OP_REQUIRES(context, l2_t->NumElements() == 1, errors::InvalidArgument("l2 argument must be a scalar")); const auto l2 = l2_t->scalar<float>()(); DCHECK_GE(l2, 0); const Tensor* tree_complexity_t; OP_REQUIRES_OK(context, context->input("tree_complexity", &tree_complexity_t)); OP_REQUIRES( context, tree_complexity_t->NumElements() == 1, errors::InvalidArgument("tree_complexity argument must be a scalar")); const auto tree_complexity = tree_complexity_t->scalar<float>()(); const Tensor* min_node_weight_t; OP_REQUIRES_OK(context, context->input("min_node_weight", &min_node_weight_t)); OP_REQUIRES( context, min_node_weight_t->NumElements() == 1, errors::InvalidArgument("min_node_weight argument must be a scalar")); const auto min_node_weight = min_node_weight_t->scalar<float>()(); std::vector<int32> output_node_ids; std::vector<float> output_gains; std::vector<int32> output_feature_dimensions; std::vector<int32> output_thresholds; std::vector<Eigen::VectorXf> output_left_node_contribs; std::vector<Eigen::VectorXf> output_right_node_contribs; std::vector<std::string> output_split_types; // TODO(tanzheny) parallelize the computation. // Iterate each node and find the best gain per node. for (int32_t node_id = node_id_first; node_id < node_id_last; ++node_id) { float best_gain = std::numeric_limits<float>::lowest(); int32_t best_bucket = 0; int32_t best_f_dim = 0; string best_split_type; Eigen::VectorXf best_contrib_for_left(logits_dim); Eigen::VectorXf best_contrib_for_right(logits_dim); float parent_gain; // Including default bucket. ConstMatrixMap stats_mat(&stats_summary(node_id, 0, 0, 0), num_buckets + 1, logits_dim + hessian_dim); const Eigen::VectorXf total_grad = stats_mat.leftCols(logits_dim).colwise().sum(); const Eigen::VectorXf total_hess = stats_mat.rightCols(hessian_dim).colwise().sum(); if (total_hess.norm() < min_node_weight) { continue; } Eigen::VectorXf parent_weight(logits_dim); CalculateWeightsAndGains(total_grad, total_hess, l1, l2, &parent_weight, &parent_gain); if (split_type_ == "inequality") { CalculateBestInequalitySplit( stats_summary, node_id, feature_dims, logits_dim, hessian_dim, num_buckets, min_node_weight, l1, l2, &best_gain, &best_bucket, &best_f_dim, &best_split_type, &best_contrib_for_left, &best_contrib_for_right); } else { CalculateBestEqualitySplit( stats_summary, total_grad, total_hess, node_id, feature_dims, logits_dim, hessian_dim, num_buckets, l1, l2, &best_gain, &best_bucket, &best_f_dim, &best_split_type, &best_contrib_for_left, &best_contrib_for_right); } if (best_gain == std::numeric_limits<float>::lowest()) { // Do not add the node if not split if found. continue; } output_node_ids.push_back(node_id); // Remove the parent gain for the parent node. output_gains.push_back(best_gain - parent_gain); output_feature_dimensions.push_back(best_f_dim); // default direction is fixed for dense splits. // TODO(tanzheny) account for default values. output_split_types.push_back(best_split_type); output_thresholds.push_back(best_bucket); output_left_node_contribs.push_back(best_contrib_for_left); output_right_node_contribs.push_back(best_contrib_for_right); } // for node id const int num_nodes = output_node_ids.size(); // output_node_ids Tensor* output_node_ids_t = nullptr; OP_REQUIRES_OK(context, context->allocate_output("node_ids", {num_nodes}, &output_node_ids_t)); auto output_node_ids_vec = output_node_ids_t->vec<int32>(); // output_gains Tensor* output_gains_t; OP_REQUIRES_OK(context, context->allocate_output("gains", {num_nodes}, &output_gains_t)); auto output_gains_vec = output_gains_t->vec<float>(); // output_feature_dimensions Tensor* output_feature_dimension_t; OP_REQUIRES_OK(context, context->allocate_output("feature_dimensions", {num_nodes}, &output_feature_dimension_t)); auto output_feature_dimensions_vec = output_feature_dimension_t->vec<int32>(); // output_thresholds Tensor* output_thresholds_t; OP_REQUIRES_OK(context, context->allocate_output("thresholds", {num_nodes}, &output_thresholds_t)); auto output_thresholds_vec = output_thresholds_t->vec<int32>(); // output_left_node_contribs Tensor* output_left_node_contribs_t; OP_REQUIRES_OK(context, context->allocate_output( "left_node_contribs", {num_nodes, logits_dim}, &output_left_node_contribs_t)); auto output_left_node_contribs_matrix = output_left_node_contribs_t->matrix<float>(); // output_right_node_contribs Tensor* output_right_node_contribs_t; OP_REQUIRES_OK(context, context->allocate_output( "right_node_contribs", {num_nodes, logits_dim}, &output_right_node_contribs_t)); auto output_right_node_contribs_matrix = output_right_node_contribs_t->matrix<float>(); // split type Tensor* output_split_types_t; OP_REQUIRES_OK( context, context->allocate_output("split_with_default_directions", {num_nodes}, &output_split_types_t)); auto output_split_types_vec = output_split_types_t->vec<tstring>(); // Sets output tensors from vectors. for (int i = 0; i < num_nodes; ++i) { output_node_ids_vec(i) = output_node_ids[i]; // Adjust the gains to penalize by tree complexity. output_gains_vec(i) = output_gains[i] - tree_complexity; output_feature_dimensions_vec(i) = output_feature_dimensions[i]; output_thresholds_vec(i) = output_thresholds[i]; for (int j = 0; j < logits_dim; ++j) { output_left_node_contribs_matrix(i, j) = output_left_node_contribs[i][j]; output_right_node_contribs_matrix(i, j) = output_right_node_contribs[i][j]; } output_split_types_vec(i) = output_split_types[i]; } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static struct tcf_proto *tcf_chain_tp_insert_unique(struct tcf_chain *chain, struct tcf_proto *tp_new, u32 protocol, u32 prio, bool rtnl_held) { struct tcf_chain_info chain_info; struct tcf_proto *tp; int err = 0; mutex_lock(&chain->filter_chain_lock); if (tcf_proto_exists_destroying(chain, tp_new)) { mutex_unlock(&chain->filter_chain_lock); tcf_proto_destroy(tp_new, rtnl_held, false, NULL); return ERR_PTR(-EAGAIN); } tp = tcf_chain_tp_find(chain, &chain_info, protocol, prio, false); if (!tp) err = tcf_chain_tp_insert(chain, &chain_info, tp_new); mutex_unlock(&chain->filter_chain_lock); if (tp) { tcf_proto_destroy(tp_new, rtnl_held, false, NULL); tp_new = tp; } else if (err) { tcf_proto_destroy(tp_new, rtnl_held, false, NULL); tp_new = ERR_PTR(err); } return tp_new; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ztype(i_ctx_t *i_ctx_p) { os_ptr op = osp; ref tnref; int code = array_get(imemory, op, (long)r_btype(op - 1), &tnref); if (code < 0) return code; if (!r_has_type(&tnref, t_name)) { /* Must be either a stack underflow or a t_[a]struct. */ check_op(2); { /* Get the type name from the structure. */ if (op[-1].value.pstruct != 0x00) { const char *sname = gs_struct_type_name_string(gs_object_type(imemory, op[-1].value.pstruct)); int code = name_ref(imemory, (const byte *)sname, strlen(sname), (ref *) (op - 1), 0); if (code < 0) return code; } else return_error(gs_error_stackunderflow); } r_set_attrs(op - 1, a_executable); } else { ref_assign(op - 1, &tnref); } pop(1); return 0; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int jpc_calcssexp(jpc_fix_t stepsize) { return jpc_firstone(stepsize) - JPC_FIX_FRACBITS; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static plist_t parse_array_node(struct bplist_data *bplist, const char** bnode, uint64_t size) { uint64_t j; uint32_t str_j = 0; uint32_t index1; plist_data_t data = plist_new_plist_data(); data->type = PLIST_ARRAY; data->length = size; plist_t node = node_create(NULL, data); for (j = 0; j < data->length; j++) { str_j = j * bplist->ref_size; index1 = UINT_TO_HOST((*bnode) + str_j, bplist->ref_size); if (index1 >= bplist->num_objects) { plist_free(node); return NULL; } /* process value node */ plist_t val = parse_bin_node_at_index(bplist, index1); if (!val) { plist_free(node); return NULL; } node_attach(node, val); } return node; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int ossl_rsaz_mod_exp_avx512_x2(BN_ULONG *res1, const BN_ULONG *base1, const BN_ULONG *exp1, const BN_ULONG *m1, const BN_ULONG *rr1, BN_ULONG k0_1, BN_ULONG *res2, const BN_ULONG *base2, const BN_ULONG *exp2, const BN_ULONG *m2, const BN_ULONG *rr2, BN_ULONG k0_2, int factor_size) { int ret = 0; /* * Number of word-size (BN_ULONG) digits to store exponent in redundant * representation. */ int exp_digits = number_of_digits(factor_size + 2, DIGIT_SIZE); int coeff_pow = 4 * (DIGIT_SIZE * exp_digits - factor_size); BN_ULONG *base1_red, *m1_red, *rr1_red; BN_ULONG *base2_red, *m2_red, *rr2_red; BN_ULONG *coeff_red; BN_ULONG *storage = NULL; BN_ULONG *storage_aligned = NULL; BN_ULONG storage_len_bytes = 7 * exp_digits * sizeof(BN_ULONG); /* AMM = Almost Montgomery Multiplication */ AMM52 amm = NULL; /* Dual (2-exps in parallel) exponentiation */ EXP52_x2 exp_x2 = NULL; const BN_ULONG *exp[2] = {0}; BN_ULONG k0[2] = {0}; /* Only 1024-bit factor size is supported now */ switch (factor_size) { case 1024: amm = ossl_rsaz_amm52x20_x1_256; exp_x2 = RSAZ_exp52x20_x2_256; break; default: goto err; } storage = (BN_ULONG *)OPENSSL_malloc(storage_len_bytes + 64); if (storage == NULL) goto err; storage_aligned = (BN_ULONG *)ALIGN_OF(storage, 64); /* Memory layout for red(undant) representations */ base1_red = storage_aligned; base2_red = storage_aligned + 1 * exp_digits; m1_red = storage_aligned + 2 * exp_digits; m2_red = storage_aligned + 3 * exp_digits; rr1_red = storage_aligned + 4 * exp_digits; rr2_red = storage_aligned + 5 * exp_digits; coeff_red = storage_aligned + 6 * exp_digits; /* Convert base_i, m_i, rr_i, from regular to 52-bit radix */ to_words52(base1_red, exp_digits, base1, factor_size); to_words52(base2_red, exp_digits, base2, factor_size); to_words52(m1_red, exp_digits, m1, factor_size); to_words52(m2_red, exp_digits, m2, factor_size); to_words52(rr1_red, exp_digits, rr1, factor_size); to_words52(rr2_red, exp_digits, rr2, factor_size); /* * Compute target domain Montgomery converters RR' for each modulus * based on precomputed original domain's RR. * * RR -> RR' transformation steps: * (1) coeff = 2^k * (2) t = AMM(RR,RR) = RR^2 / R' mod m * (3) RR' = AMM(t, coeff) = RR^2 * 2^k / R'^2 mod m * where * k = 4 * (52 * digits52 - modlen) * R = 2^(64 * ceil(modlen/64)) mod m * RR = R^2 mod M * R' = 2^(52 * ceil(modlen/52)) mod m * * modlen = 1024: k = 64, RR = 2^2048 mod m, RR' = 2^2080 mod m */ memset(coeff_red, 0, exp_digits * sizeof(BN_ULONG)); /* (1) in reduced domain representation */ set_bit(coeff_red, 64 * (int)(coeff_pow / 52) + coeff_pow % 52); amm(rr1_red, rr1_red, rr1_red, m1_red, k0_1); /* (2) for m1 */ amm(rr1_red, rr1_red, coeff_red, m1_red, k0_1); /* (3) for m1 */ amm(rr2_red, rr2_red, rr2_red, m2_red, k0_2); /* (2) for m2 */ amm(rr2_red, rr2_red, coeff_red, m2_red, k0_2); /* (3) for m2 */ exp[0] = exp1; exp[1] = exp2; k0[0] = k0_1; k0[1] = k0_2; exp_x2(rr1_red, base1_red, exp, m1_red, rr1_red, k0); /* Convert rr_i back to regular radix */ from_words52(res1, factor_size, rr1_red); from_words52(res2, factor_size, rr2_red); bn_reduce_once_in_place(res1, /*carry=*/0, m1, storage, factor_size); bn_reduce_once_in_place(res2, /*carry=*/0, m2, storage, factor_size); ret = 1; err: if (storage != NULL) { OPENSSL_cleanse(storage, storage_len_bytes); OPENSSL_free(storage); } return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [add_opcode_rel_addr(regex_t* reg, int opcode, int addr) { int r; r = add_opcode(reg, opcode); if (r) return r; r = add_rel_addr(reg, addr); return r; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ebt_do_watcher(const struct ebt_entry_watcher *w, struct sk_buff *skb, struct xt_action_param *par) { par->target = w->u.watcher; par->targinfo = w->data; w->u.watcher->target(skb, par); /* watchers don't give a verdict */ return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void create_le_conn_complete(struct hci_dev *hdev, u8 status, u16 opcode) { struct hci_conn *conn; hci_dev_lock(hdev); conn = hci_lookup_le_connect(hdev); if (!status) { hci_connect_le_scan_cleanup(conn); goto done; } bt_dev_err(hdev, "request failed to create LE connection: " "status 0x%2.2x", status); if (!conn) goto done; hci_le_conn_failed(conn, status); done: hci_dev_unlock(hdev); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [Pl_LZWDecoder::addToTable(unsigned char next) { unsigned int last_size = 0; unsigned char const* last_data = 0; unsigned char tmp[1]; if (this->last_code < 256) { tmp[0] = static_cast<unsigned char>(this->last_code); last_data = tmp; last_size = 1; } else if (this->last_code > 257) { unsigned int idx = this->last_code - 258; if (idx >= table.size()) { throw std::logic_error( "Pl_LZWDecoder::addToTable: table overflow"); } Buffer& b = table.at(idx); last_data = b.getBuffer(); last_size = QIntC::to_uint(b.getSize()); } else { throw std::logic_error( "Pl_LZWDecoder::addToTable called with invalid code (" + QUtil::int_to_string(this->last_code) + ")"); } Buffer entry(1 + last_size); unsigned char* new_data = entry.getBuffer(); memcpy(new_data, last_data, last_size); new_data[last_size] = next; this->table.push_back(entry); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int chip_write_masked(struct CHIPSTATE *chip, int subaddr, int val, int mask) { if (mask != 0) { if (-1 == subaddr) { val = (chip->shadow.bytes[1] & ~mask) | (val & mask); } else { val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); } } return chip_write(chip, subaddr, val); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int is_partially_overlapping(const void *ptr1, const void *ptr2, int len) { PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2; /* * Check for partially overlapping buffers. [Binary logical * operations are used instead of boolean to minimize number * of conditional branches.] */ int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) | (diff > (0 - (PTRDIFF_T)len))); return overlapped; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ Pong(const std::string& cookie, const std::string& server = "") : ClientProtocol::Message("PONG", ServerInstance->Config->GetServerName()) { PushParamRef(ServerInstance->Config->GetServerName()); if (!server.empty()) PushParamRef(server); PushParamRef(cookie); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static inline void clear_unsync_child_bit(struct kvm_mmu_page *sp, int idx) { --sp->unsync_children; WARN_ON((int)sp->unsync_children < 0); __clear_bit(idx, sp->unsync_child_bitmap); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [int x9_62_test_internal(BIO *out, int nid, const char *r_in, const char *s_in) { int ret = 0; const char message[] = "abc"; unsigned char digest[20]; unsigned int dgst_len = 0; EVP_MD_CTX md_ctx; EC_KEY *key = NULL; ECDSA_SIG *signature = NULL; BIGNUM *r = NULL, *s = NULL; EVP_MD_CTX_init(&md_ctx); /* get the message digest */ EVP_DigestInit(&md_ctx, EVP_ecdsa()); EVP_DigestUpdate(&md_ctx, (const void *)message, 3); EVP_DigestFinal(&md_ctx, digest, &dgst_len); BIO_printf(out, "testing %s: ", OBJ_nid2sn(nid)); /* create the key */ if ((key = EC_KEY_new_by_curve_name(nid)) == NULL) goto x962_int_err; if (!EC_KEY_generate_key(key)) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* create the signature */ signature = ECDSA_do_sign(digest, 20, key); if (signature == NULL) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* compare the created signature with the expected signature */ if ((r = BN_new()) == NULL || (s = BN_new()) == NULL) goto x962_int_err; if (!BN_dec2bn(&r, r_in) || !BN_dec2bn(&s, s_in)) goto x962_int_err; if (BN_cmp(signature->r, r) || BN_cmp(signature->s, s)) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* verify the signature */ if (ECDSA_do_verify(digest, 20, signature, key) != 1) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); BIO_printf(out, " ok\n"); ret = 1; x962_int_err: if (!ret) BIO_printf(out, " failed\n"); if (key) EC_KEY_free(key); if (signature) ECDSA_SIG_free(signature); if (r) BN_free(r); if (s) BN_free(s); EVP_MD_CTX_cleanup(&md_ctx); return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [SYSCALL_DEFINE1(brk, unsigned long, brk) { unsigned long retval; unsigned long newbrk, oldbrk, origbrk; struct mm_struct *mm = current->mm; struct vm_area_struct *next; unsigned long min_brk; bool populate; bool downgraded = false; LIST_HEAD(uf); if (down_write_killable(&mm->mmap_sem)) return -EINTR; origbrk = mm->brk; #ifdef CONFIG_COMPAT_BRK /* * CONFIG_COMPAT_BRK can still be overridden by setting * randomize_va_space to 2, which will still cause mm->start_brk * to be arbitrarily shifted */ if (current->brk_randomized) min_brk = mm->start_brk; else min_brk = mm->end_data; #else min_brk = mm->start_brk; #endif if (brk < min_brk) goto out; /* * Check against rlimit here. If this check is done later after the test * of oldbrk with newbrk then it can escape the test and let the data * segment grow beyond its set limit the in case where the limit is * not page aligned -Ram Gupta */ if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk, mm->end_data, mm->start_data)) goto out; newbrk = PAGE_ALIGN(brk); oldbrk = PAGE_ALIGN(mm->brk); if (oldbrk == newbrk) { mm->brk = brk; goto success; } /* * Always allow shrinking brk. * __do_munmap() may downgrade mmap_sem to read. */ if (brk <= mm->brk) { int ret; /* * mm->brk must to be protected by write mmap_sem so update it * before downgrading mmap_sem. When __do_munmap() fails, * mm->brk will be restored from origbrk. */ mm->brk = brk; ret = __do_munmap(mm, newbrk, oldbrk-newbrk, &uf, true); if (ret < 0) { mm->brk = origbrk; goto out; } else if (ret == 1) { downgraded = true; } goto success; } /* Check against existing mmap mappings. */ next = find_vma(mm, oldbrk); if (next && newbrk + PAGE_SIZE > vm_start_gap(next)) goto out; /* Ok, looks good - let it rip. */ if (do_brk_flags(oldbrk, newbrk-oldbrk, 0, &uf) < 0) goto out; mm->brk = brk; success: populate = newbrk > oldbrk && (mm->def_flags & VM_LOCKED) != 0; if (downgraded) up_read(&mm->mmap_sem); else up_write(&mm->mmap_sem); userfaultfd_unmap_complete(mm, &uf); if (populate) mm_populate(oldbrk, newbrk - oldbrk); return brk; out: retval = origbrk; up_write(&mm->mmap_sem); return retval; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [_gnutls13_recv_async_handshake(gnutls_session_t session) { int ret; handshake_buffer_st hsk; recv_state_t next_state = RECV_STATE_0; /* The following messages are expected asynchronously after * the handshake process is complete */ if (unlikely(session->internals.handshake_in_progress)) return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET); do { /* the received handshake message has already been pushed into * handshake buffers. As we do not need to use the handshake hash * buffers we call the lower level receive functions */ ret = _gnutls_handshake_io_recv_int(session, GNUTLS_HANDSHAKE_ANY, &hsk, 0); if (ret < 0) { gnutls_assert(); goto cleanup; } session->internals.last_handshake_in = hsk.htype; ret = _gnutls_call_hook_func(session, hsk.htype, GNUTLS_HOOK_PRE, 1, hsk.data.data, hsk.data.length); if (ret < 0) { gnutls_assert(); goto cleanup; } switch(hsk.htype) { case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: if (!(session->security_parameters.entity == GNUTLS_CLIENT) || !(session->internals.flags & GNUTLS_POST_HANDSHAKE_AUTH)) { ret = gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET); goto cleanup; } _gnutls_buffer_reset(&session->internals.reauth_buffer); /* include the handshake headers in reauth buffer */ ret = _gnutls_buffer_append_data(&session->internals.reauth_buffer, hsk.header, hsk.header_size); if (ret < 0) { gnutls_assert(); goto cleanup; } ret = _gnutls_buffer_append_data(&session->internals.reauth_buffer, hsk.data.data, hsk.data.length); if (ret < 0) { gnutls_assert(); goto cleanup; } if (session->internals.flags & GNUTLS_AUTO_REAUTH) { ret = gnutls_reauth(session, 0); if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) { next_state = RECV_STATE_REAUTH; } else if (ret < 0) { gnutls_assert(); goto cleanup; } } else { /* Application is expected to handle re-authentication * explicitly. */ ret = GNUTLS_E_REAUTH_REQUEST; } goto cleanup; case GNUTLS_HANDSHAKE_KEY_UPDATE: ret = _gnutls13_recv_key_update(session, &hsk.data); if (ret < 0) { gnutls_assert(); goto cleanup; } /* Handshake messages MUST NOT span key changes, i.e., we * should not have any other pending handshake messages from * the same record. */ if (session->internals.handshake_recv_buffer_size != 0) { ret = gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET); goto cleanup; } break; case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: if (session->security_parameters.entity != GNUTLS_CLIENT) { ret = gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET); goto cleanup; } ret = _gnutls13_recv_session_ticket(session, &hsk.data); if (ret < 0) { gnutls_assert(); goto cleanup; } memcpy(session->internals.tls13_ticket.resumption_master_secret, session->key.proto.tls13.ap_rms, session->key.proto.tls13.temp_secret_size); session->internals.tls13_ticket.prf = session->security_parameters.prf; session->internals.hsk_flags |= HSK_TICKET_RECEIVED; break; default: gnutls_assert(); ret = GNUTLS_E_UNEXPECTED_PACKET; goto cleanup; } ret = _gnutls_call_hook_func(session, hsk.htype, GNUTLS_HOOK_POST, 1, hsk.data.data, hsk.data.length); if (ret < 0) { gnutls_assert(); goto cleanup; } _gnutls_handshake_buffer_clear(&hsk); } while (_gnutls_record_buffer_get_size(session) > 0); session->internals.recv_state = next_state; return 0; cleanup: /* if we have pending/partial handshake data in buffers, ensure that * next read will read handshake data */ if (_gnutls_record_buffer_get_size(session) > 0) session->internals.recv_state = RECV_STATE_ASYNC_HANDSHAKE; else session->internals.recv_state = next_state; _gnutls_handshake_buffer_clear(&hsk); return ret; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void Magick::Image::stegano(const Image &watermark_) { MagickCore::Image *newImage; GetPPException; newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo); replaceImage(newImage); ThrowImageException; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void print_binder_proc(struct seq_file *m, struct binder_proc *proc, int print_all) { struct binder_work *w; struct rb_node *n; size_t start_pos = m->count; size_t header_pos; struct binder_node *last_node = NULL; seq_printf(m, "proc %d\n", proc->pid); seq_printf(m, "context %s\n", proc->context->name); header_pos = m->count; binder_inner_proc_lock(proc); for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) print_binder_thread_ilocked(m, rb_entry(n, struct binder_thread, rb_node), print_all); for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { struct binder_node *node = rb_entry(n, struct binder_node, rb_node); /* * take a temporary reference on the node so it * survives and isn't removed from the tree * while we print it. */ binder_inc_node_tmpref_ilocked(node); /* Need to drop inner lock to take node lock */ binder_inner_proc_unlock(proc); if (last_node) binder_put_node(last_node); binder_node_inner_lock(node); print_binder_node_nilocked(m, node); binder_node_inner_unlock(node); last_node = node; binder_inner_proc_lock(proc); } binder_inner_proc_unlock(proc); if (last_node) binder_put_node(last_node); if (print_all) { binder_proc_lock(proc); for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) print_binder_ref_olocked(m, rb_entry(n, struct binder_ref, rb_node_desc)); binder_proc_unlock(proc); } binder_alloc_print_allocated(m, &proc->alloc); binder_inner_proc_lock(proc); list_for_each_entry(w, &proc->todo, entry) print_binder_work_ilocked(m, proc, " ", " pending transaction", w); list_for_each_entry(w, &proc->delivered_death, entry) { seq_puts(m, " has delivered dead binder\n"); break; } binder_inner_proc_unlock(proc); if (!print_all && m->count == header_pos) m->count = start_pos; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [synth_cname(uint8_t* qname, size_t qnamelen, struct rrset_parse* dname_rrset, uint8_t* alias, size_t* aliaslen, sldns_buffer* pkt) { /* we already know that sname is a strict subdomain of DNAME owner */ uint8_t* dtarg = NULL; size_t dtarglen; if(!parse_get_cname_target(dname_rrset, &dtarg, &dtarglen)) return 0; if(qnamelen <= dname_rrset->dname_len) return 0; if(qnamelen == 0) return 0; log_assert(qnamelen > dname_rrset->dname_len); /* DNAME from com. to net. with qname example.com. -> example.net. */ /* so: \3com\0 to \3net\0 and qname \7example\3com\0 */ *aliaslen = qnamelen + dtarglen - dname_rrset->dname_len; if(*aliaslen > LDNS_MAX_DOMAINLEN) return 0; /* should have been RCODE YXDOMAIN */ /* decompress dnames into buffer, we know it fits */ dname_pkt_copy(pkt, alias, qname); dname_pkt_copy(pkt, alias+(qnamelen-dname_rrset->dname_len), dtarg); return 1; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void gf_isom_box_array_del_parent(GF_List **child_boxes, GF_List *boxlist) { if (!boxlist) return; gf_isom_box_array_reset_parent(child_boxes, boxlist); gf_list_del(boxlist); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void virtio_gpu_set_scanout(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; pixman_format_code_t format; uint32_t offset; int bpp; struct virtio_gpu_set_scanout ss; VIRTIO_GPU_FILL_CMD(ss); trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss.r.y); if (ss.scanout_id >= g->conf.max_outputs) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d", __func__, ss.scanout_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; return; } g->enable = 1; if (ss.resource_id == 0) { scanout = &g->scanout[ss.scanout_id]; if (scanout->resource_id) { res = virtio_gpu_find_resource(g, scanout->resource_id); if (res) { res->scanout_bitmask &= ~(1 << ss.scanout_id); } } if (ss.scanout_id == 0) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d", __func__, ss.scanout_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; return; } dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL); scanout->ds = NULL; scanout->width = 0; scanout->height = 0; return; } /* create a surface for this scanout */ res = virtio_gpu_find_resource(g, ss.resource_id); if (!res) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal resource specified %d\n", __func__, ss.resource_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } if (ss.r.x > res->width || ss.r.y > res->height || ss.r.width > res->width || ss.r.height > res->height || ss.r.x + ss.r.width > res->width || ss.r.y + ss.r.height > res->height) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout %d bounds for" " resource %d, (%d,%d)+%d,%d vs %d %d\n", __func__, ss.scanout_id, ss.resource_id, ss.r.x, ss.r.y, ss.r.width, ss.r.height, res->width, res->height); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; return; } scanout = &g->scanout[ss.scanout_id]; format = pixman_image_get_format(res->image); bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8; offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image); if (!scanout->ds || surface_data(scanout->ds) != ((uint8_t *)pixman_image_get_data(res->image) + offset) || scanout->width != ss.r.width || scanout->height != ss.r.height) { pixman_image_t *rect; void *ptr = (uint8_t *)pixman_image_get_data(res->image) + offset; rect = pixman_image_create_bits(format, ss.r.width, ss.r.height, ptr, pixman_image_get_stride(res->image)); pixman_image_ref(res->image); pixman_image_set_destroy_function(rect, virtio_unref_resource, res->image); /* realloc the surface ptr */ scanout->ds = qemu_create_displaysurface_pixman(rect); if (!scanout->ds) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; return; } dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, scanout->ds); } res->scanout_bitmask |= (1 << ss.scanout_id); scanout->resource_id = ss.resource_id; scanout->x = ss.r.x; scanout->y = ss.r.y; scanout->width = ss.r.width; scanout->height = ss.r.height; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int emsff_play(struct input_dev *dev, void *data, struct ff_effect *effect) { struct hid_device *hid = input_get_drvdata(dev); struct emsff_device *emsff = data; int weak, strong; weak = effect->u.rumble.weak_magnitude; strong = effect->u.rumble.strong_magnitude; dbg_hid("called with 0x%04x 0x%04x\n", strong, weak); weak = weak * 0xff / 0xffff; strong = strong * 0xff / 0xffff; emsff->report->field[0]->value[1] = weak; emsff->report->field[0]->value[2] = strong; dbg_hid("running with 0x%02x 0x%02x\n", strong, weak); hid_hw_request(hid, emsff->report, HID_REQ_SET_REPORT); return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [SPL_METHOD(SplDoublyLinkedList, current) { spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC); spl_ptr_llist_element *element = intern->traverse_pointer; if (zend_parse_parameters_none() == FAILURE) { return; } if (element == NULL || element->data == NULL) { RETURN_NULL(); } else { zval *data = (zval *)element->data; RETURN_ZVAL(data, 1, 0); } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [FreeWild(int count, char_u **files) { if (count <= 0 || files == NULL) return; while (count--) vim_free(files[count]); vim_free(files); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *filp = iocb->ki_filp; struct rpmsg_eptdev *eptdev = filp->private_data; size_t len = iov_iter_count(from); void *kbuf; int ret; kbuf = kzalloc(len, GFP_KERNEL); if (!kbuf) return -ENOMEM; if (!copy_from_iter_full(kbuf, len, from)) return -EFAULT; if (mutex_lock_interruptible(&eptdev->ept_lock)) { ret = -ERESTARTSYS; goto free_kbuf; } if (!eptdev->ept) { ret = -EPIPE; goto unlock_eptdev; } if (filp->f_flags & O_NONBLOCK) ret = rpmsg_trysend(eptdev->ept, kbuf, len); else ret = rpmsg_send(eptdev->ept, kbuf, len); unlock_eptdev: mutex_unlock(&eptdev->ept_lock); free_kbuf: kfree(kbuf); return ret < 0 ? ret : len; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [void DoNonMaxSuppressionOp(OpKernelContext* context, const Tensor& scores, int num_boxes, const Tensor& max_output_size, const T similarity_threshold, const T score_threshold, const T soft_nms_sigma, const std::function<float(int, int)>& similarity_fn, bool return_scores_tensor = false, bool pad_to_max_output_size = false, int* ptr_num_valid_outputs = nullptr) { const int output_size = max_output_size.scalar<int>()(); std::vector<T> scores_data(num_boxes); std::copy_n(scores.flat<T>().data(), num_boxes, scores_data.begin()); // Data structure for a selection candidate in NMS. struct Candidate { int box_index; T score; int suppress_begin_index; }; auto cmp = [](const Candidate bs_i, const Candidate bs_j) { return ((bs_i.score == bs_j.score) && (bs_i.box_index > bs_j.box_index)) || bs_i.score < bs_j.score; }; std::priority_queue<Candidate, std::deque<Candidate>, decltype(cmp)> candidate_priority_queue(cmp); for (int i = 0; i < scores_data.size(); ++i) { if (scores_data[i] > score_threshold) { candidate_priority_queue.emplace(Candidate({i, scores_data[i], 0})); } } T scale = static_cast<T>(0.0); bool is_soft_nms = soft_nms_sigma > static_cast<T>(0.0); if (is_soft_nms) { scale = static_cast<T>(-0.5) / soft_nms_sigma; } auto suppress_weight = [similarity_threshold, scale, is_soft_nms](const T sim) { const T weight = Eigen::numext::exp<T>(scale * sim * sim); return is_soft_nms || sim <= similarity_threshold ? weight : static_cast<T>(0.0); }; std::vector<int> selected; std::vector<T> selected_scores; float similarity; T original_score; Candidate next_candidate; while (selected.size() < output_size && !candidate_priority_queue.empty()) { next_candidate = candidate_priority_queue.top(); original_score = next_candidate.score; candidate_priority_queue.pop(); // Overlapping boxes are likely to have similar scores, therefore we // iterate through the previously selected boxes backwards in order to // see if `next_candidate` should be suppressed. We also enforce a property // that a candidate can be suppressed by another candidate no more than // once via `suppress_begin_index` which tracks which previously selected // boxes have already been compared against next_candidate prior to a given // iteration. These previous selected boxes are then skipped over in the // following loop. bool should_hard_suppress = false; for (int j = static_cast<int>(selected.size()) - 1; j >= next_candidate.suppress_begin_index; --j) { similarity = similarity_fn(next_candidate.box_index, selected[j]); next_candidate.score *= suppress_weight(static_cast<T>(similarity)); // First decide whether to perform hard suppression if (!is_soft_nms && static_cast<T>(similarity) > similarity_threshold) { should_hard_suppress = true; break; } // If next_candidate survives hard suppression, apply soft suppression if (next_candidate.score <= score_threshold) break; } // If `next_candidate.score` has not dropped below `score_threshold` // by this point, then we know that we went through all of the previous // selections and can safely update `suppress_begin_index` to // `selected.size()`. If on the other hand `next_candidate.score` // *has* dropped below the score threshold, then since `suppress_weight` // always returns values in [0, 1], further suppression by items that were // not covered in the above for loop would not have caused the algorithm // to select this item. We thus do the same update to // `suppress_begin_index`, but really, this element will not be added back // into the priority queue in the following. next_candidate.suppress_begin_index = selected.size(); if (!should_hard_suppress) { if (next_candidate.score == original_score) { // Suppression has not occurred, so select next_candidate selected.push_back(next_candidate.box_index); selected_scores.push_back(next_candidate.score); continue; } if (next_candidate.score > score_threshold) { // Soft suppression has occurred and current score is still greater than // score_threshold; add next_candidate back onto priority queue. candidate_priority_queue.push(next_candidate); } } } int num_valid_outputs = selected.size(); if (pad_to_max_output_size) { selected.resize(output_size, 0); selected_scores.resize(output_size, static_cast<T>(0)); } if (ptr_num_valid_outputs) { *ptr_num_valid_outputs = num_valid_outputs; } // Allocate output tensors Tensor* output_indices = nullptr; TensorShape output_shape({static_cast<int>(selected.size())}); OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output_indices)); TTypes<int, 1>::Tensor output_indices_data = output_indices->tensor<int, 1>(); std::copy_n(selected.begin(), selected.size(), output_indices_data.data()); if (return_scores_tensor) { Tensor* output_scores = nullptr; OP_REQUIRES_OK(context, context->allocate_output(1, output_shape, &output_scores)); typename TTypes<T, 1>::Tensor output_scores_data = output_scores->tensor<T, 1>(); std::copy_n(selected_scores.begin(), selected_scores.size(), output_scores_data.data()); } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [string_iconv (int from_utf8, const char *from_code, const char *to_code, const char *string) { char *outbuf; #ifdef HAVE_ICONV iconv_t cd; char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char; char *ptr_inbuf_shift; int done; size_t err, inbytesleft, outbytesleft; if (from_code && from_code[0] && to_code && to_code[0] && (string_strcasecmp(from_code, to_code) != 0)) { cd = iconv_open (to_code, from_code); if (cd == (iconv_t)(-1)) outbuf = strdup (string); else { inbuf = strdup (string); if (!inbuf) return NULL; ptr_inbuf = inbuf; inbytesleft = strlen (inbuf); outbytesleft = inbytesleft * 4; outbuf = malloc (outbytesleft + 2); if (!outbuf) return inbuf; ptr_outbuf = outbuf; ptr_inbuf_shift = NULL; done = 0; while (!done) { err = iconv (cd, (ICONV_CONST char **)(&ptr_inbuf), &inbytesleft, &ptr_outbuf, &outbytesleft); if (err == (size_t)(-1)) { switch (errno) { case EINVAL: done = 1; break; case E2BIG: done = 1; break; case EILSEQ: if (from_utf8) { next_char = utf8_next_char (ptr_inbuf); if (next_char) { inbytesleft -= next_char - ptr_inbuf; ptr_inbuf = next_char; } else { inbytesleft--; ptr_inbuf++; } } else { ptr_inbuf++; inbytesleft--; } ptr_outbuf[0] = '?'; ptr_outbuf++; outbytesleft--; break; } } else { if (!ptr_inbuf_shift) { ptr_inbuf_shift = ptr_inbuf; ptr_inbuf = NULL; inbytesleft = 0; } else done = 1; } } if (ptr_inbuf_shift) ptr_inbuf = ptr_inbuf_shift; ptr_outbuf[0] = '\0'; free (inbuf); iconv_close (cd); } } else outbuf = strdup (string); #else /* make C compiler happy */ (void) from_utf8; (void) from_code; (void) to_code; outbuf = strdup (string); #endif /* HAVE_ICONV */ return outbuf; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [source_to_string(SRC_Instance inst) { switch (inst->type) { case SRC_NTP: return UTI_IPToString(inst->ip_addr); case SRC_REFCLOCK: return UTI_RefidToString(inst->ref_id); default: assert(0); } return NULL; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void nbd_eject_notifier(Notifier *n, void *data) { NBDExport *exp = container_of(n, NBDExport, eject_notifier); nbd_export_close(exp); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target, CHAT_DCC_REC *chat) { GET_DCC_REC *dcc; SEND_DCC_REC *temp_dcc; IPADDR ip; char *address, **params, *fname; int paramcount, fileparams; int port, len, quoted = FALSE; uoff_t size; int p_id = -1; int passive = FALSE; if (addr == NULL) addr = ""; if (nick == NULL) nick = ""; /* SEND <file name> <address> <port> <size> [...] */ /* SEND <file name> <address> 0 <size> <id> (DCC SEND passive protocol) */ params = g_strsplit(data, " ", -1); paramcount = g_strv_length(params); if (paramcount < 4) { signal_emit("dcc error ctcp", 5, "SEND", data, nick, addr, target); g_strfreev(params); return; } fileparams = get_file_params_count(params, paramcount); address = g_strdup(params[fileparams]); dcc_str2ip(address, &ip); port = atoi(params[fileparams+1]); size = str_to_uofft(params[fileparams+2]); /* If this DCC uses passive protocol then store the id for later use. */ if (paramcount == fileparams + 4) { p_id = atoi(params[fileparams+3]); passive = TRUE; } fname = get_file_name(params, fileparams); g_strfreev(params); len = strlen(fname); if (len > 1 && *fname == '"' && fname[len-1] == '"') { /* "file name" - MIRC sends filenames with spaces like this */ fname[len-1] = '\0'; g_memmove(fname, fname+1, len); quoted = TRUE; } if (passive && port != 0) { /* This is NOT a DCC SEND request! This is a reply to our passive request. We MUST check the IDs and then connect to the remote host. */ temp_dcc = DCC_SEND(dcc_find_request(DCC_SEND_TYPE, nick, fname)); if (temp_dcc != NULL && p_id == temp_dcc->pasv_id) { temp_dcc->target = g_strdup(target); temp_dcc->port = port; temp_dcc->size = size; temp_dcc->file_quoted = quoted; memcpy(&temp_dcc->addr, &ip, sizeof(IPADDR)); if (temp_dcc->addr.family == AF_INET) net_ip2host(&temp_dcc->addr, temp_dcc->addrstr); else { /* with IPv6, show it to us as it was sent */ g_strlcpy(temp_dcc->addrstr, address, sizeof(temp_dcc->addrstr)); } /* This new signal is added to let us invoke dcc_send_connect() which is found in dcc-send.c */ signal_emit("dcc reply send pasv", 1, temp_dcc); g_free(address); g_free(fname); return; } else if (temp_dcc != NULL && p_id != temp_dcc->pasv_id) { /* IDs don't match... remove the old DCC SEND and return */ dcc_destroy(DCC(temp_dcc)); g_free(address); g_free(fname); return; } } dcc = DCC_GET(dcc_find_request(DCC_GET_TYPE, nick, fname)); if (dcc != NULL) dcc_destroy(DCC(dcc)); /* remove the old DCC */ dcc = dcc_get_create(server, chat, nick, fname); if (dcc == NULL) { g_free(address); g_free(fname); g_warn_if_reached(); return; } dcc->target = g_strdup(target); if (passive && port == 0) dcc->pasv_id = p_id; /* Assign the ID to the DCC */ memcpy(&dcc->addr, &ip, sizeof(ip)); if (dcc->addr.family == AF_INET) net_ip2host(&dcc->addr, dcc->addrstr); else { /* with IPv6, show it to us as it was sent */ g_strlcpy(dcc->addrstr, address, sizeof(dcc->addrstr)); } dcc->port = port; dcc->size = size; dcc->file_quoted = quoted; signal_emit("dcc request", 2, dcc, addr); g_free(address); g_free(fname); }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [f_synID(typval_T *argvars UNUSED, typval_T *rettv) { int id = 0; #ifdef FEAT_SYN_HL linenr_T lnum; colnr_T col; int trans; int transerr = FALSE; lnum = tv_get_lnum(argvars); /* -1 on type error */ col = (linenr_T)tv_get_number(&argvars[1]) - 1; /* -1 on type error */ trans = (int)tv_get_number_chk(&argvars[2], &transerr); if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col < (long)STRLEN(ml_get(lnum))) id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE); #endif rettv->vval.v_number = id; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [merge_selfsigs_main (KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo) { PKT_public_key *pk = NULL; KBNODE k; u32 kid[2]; u32 sigdate, uiddate, uiddate2; KBNODE signode, uidnode, uidnode2; u32 curtime = make_timestamp (); unsigned int key_usage = 0; u32 keytimestamp = 0; u32 key_expire = 0; int key_expire_seen = 0; byte sigversion = 0; *r_revoked = 0; memset (rinfo, 0, sizeof (*rinfo)); if (keyblock->pkt->pkttype != PKT_PUBLIC_KEY) BUG (); pk = keyblock->pkt->pkt.public_key; keytimestamp = pk->timestamp; keyid_from_pk (pk, kid); pk->main_keyid[0] = kid[0]; pk->main_keyid[1] = kid[1]; if (pk->version < 4) { /* Before v4 the key packet itself contains the expiration date * and there was no way to change it, so we start with the one * from the key packet. */ key_expire = pk->max_expiredate; key_expire_seen = 1; } /* First pass: Find the latest direct key self-signature. We assume * that the newest one overrides all others. */ /* In case this key was already merged. */ xfree (pk->revkey); pk->revkey = NULL; pk->numrevkeys = 0; signode = NULL; sigdate = 0; /* Helper variable to find the latest signature. */ for (k = keyblock; k && k->pkt->pkttype != PKT_USER_ID; k = k->next) { if (k->pkt->pkttype == PKT_SIGNATURE) { PKT_signature *sig = k->pkt->pkt.signature; if (sig->keyid[0] == kid[0] && sig->keyid[1] == kid[1]) { if (check_key_signature (keyblock, k, NULL)) ; /* Signature did not verify. */ else if (IS_KEY_REV (sig)) { /* Key has been revoked - there is no way to * override such a revocation, so we theoretically * can stop now. We should not cope with expiration * times for revocations here because we have to * assume that an attacker can generate all kinds of * signatures. However due to the fact that the key * has been revoked it does not harm either and by * continuing we gather some more info on that * key. */ *r_revoked = 1; sig_to_revoke_info (sig, rinfo); } else if (IS_KEY_SIG (sig)) { /* Add any revocation keys onto the pk. This is particularly interesting since we normally only get data from the most recent 1F signature, but you need multiple 1F sigs to properly handle revocation keys (PGP does it this way, and a revocation key could be sensitive and hence in a different signature). */ if (sig->revkey) { int i; pk->revkey = xrealloc (pk->revkey, sizeof (struct revocation_key) * (pk->numrevkeys + sig->numrevkeys)); for (i = 0; i < sig->numrevkeys; i++) memcpy (&pk->revkey[pk->numrevkeys++], sig->revkey[i], sizeof (struct revocation_key)); } if (sig->timestamp >= sigdate) { if (sig->flags.expired) ; /* Signature has expired - ignore it. */ else { sigdate = sig->timestamp; signode = k; if (sig->version > sigversion) sigversion = sig->version; } } } } } } /* Remove dupes from the revocation keys. */ if (pk->revkey) { int i, j, x, changed = 0; for (i = 0; i < pk->numrevkeys; i++) { for (j = i + 1; j < pk->numrevkeys; j++) { if (memcmp (&pk->revkey[i], &pk->revkey[j], sizeof (struct revocation_key)) == 0) { /* remove j */ for (x = j; x < pk->numrevkeys - 1; x++) pk->revkey[x] = pk->revkey[x + 1]; pk->numrevkeys--; j--; changed = 1; } } } if (changed) pk->revkey = xrealloc (pk->revkey, pk->numrevkeys * sizeof (struct revocation_key)); } if (signode) { /* Some information from a direct key signature take precedence * over the same information given in UID sigs. */ PKT_signature *sig = signode->pkt->pkt.signature; const byte *p; key_usage = parse_key_usage (sig); p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE, NULL); if (p && buf32_to_u32 (p)) { key_expire = keytimestamp + buf32_to_u32 (p); key_expire_seen = 1; } /* Mark that key as valid: One direct key signature should * render a key as valid. */ pk->flags.valid = 1; } /* Pass 1.5: Look for key revocation signatures that were not made by the key (i.e. did a revocation key issue a revocation for us?). Only bother to do this if there is a revocation key in the first place and we're not revoked already. */ if (!*r_revoked && pk->revkey) for (k = keyblock; k && k->pkt->pkttype != PKT_USER_ID; k = k->next) { if (k->pkt->pkttype == PKT_SIGNATURE) { PKT_signature *sig = k->pkt->pkt.signature; if (IS_KEY_REV (sig) && (sig->keyid[0] != kid[0] || sig->keyid[1] != kid[1])) { int rc = check_revocation_keys (pk, sig); if (rc == 0) { *r_revoked = 2; sig_to_revoke_info (sig, rinfo); /* Don't continue checking since we can't be any more revoked than this. */ break; } else if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY) pk->flags.maybe_revoked = 1; /* A failure here means the sig did not verify, was not issued by a revocation key, or a revocation key loop was broken. If a revocation key isn't findable, however, the key might be revoked and we don't know it. */ /* TODO: In the future handle subkey and cert revocations? PGP doesn't, but it's in 2440. */ } } } /* Second pass: Look at the self-signature of all user IDs. */ signode = uidnode = NULL; sigdate = 0; /* Helper variable to find the latest signature in one UID. */ for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID) { if (uidnode && signode) { fixup_uidnode (uidnode, signode, keytimestamp); pk->flags.valid = 1; } uidnode = k; signode = NULL; sigdate = 0; } else if (k->pkt->pkttype == PKT_SIGNATURE && uidnode) { PKT_signature *sig = k->pkt->pkt.signature; if (sig->keyid[0] == kid[0] && sig->keyid[1] == kid[1]) { if (check_key_signature (keyblock, k, NULL)) ; /* signature did not verify */ else if ((IS_UID_SIG (sig) || IS_UID_REV (sig)) && sig->timestamp >= sigdate) { /* Note: we allow to invalidate cert revocations * by a newer signature. An attacker can't use this * because a key should be revoced with a key revocation. * The reason why we have to allow for that is that at * one time an email address may become invalid but later * the same email address may become valid again (hired, * fired, hired again). */ sigdate = sig->timestamp; signode = k; signode->pkt->pkt.signature->flags.chosen_selfsig = 0; if (sig->version > sigversion) sigversion = sig->version; } } } } if (uidnode && signode) { fixup_uidnode (uidnode, signode, keytimestamp); pk->flags.valid = 1; } /* If the key isn't valid yet, and we have --allow-non-selfsigned-uid set, then force it valid. */ if (!pk->flags.valid && opt.allow_non_selfsigned_uid) { if (opt.verbose) log_info (_("Invalid key %s made valid by" " --allow-non-selfsigned-uid\n"), keystr_from_pk (pk)); pk->flags.valid = 1; } /* The key STILL isn't valid, so try and find an ultimately trusted signature. */ if (!pk->flags.valid) { uidnode = NULL; for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID) uidnode = k; else if (k->pkt->pkttype == PKT_SIGNATURE && uidnode) { PKT_signature *sig = k->pkt->pkt.signature; if (sig->keyid[0] != kid[0] || sig->keyid[1] != kid[1]) { PKT_public_key *ultimate_pk; ultimate_pk = xmalloc_clear (sizeof (*ultimate_pk)); /* We don't want to use the full get_pubkey to avoid infinite recursion in certain cases. There is no reason to check that an ultimately trusted key is still valid - if it has been revoked or the user should also renmove the ultimate trust flag. */ if (get_pubkey_fast (ultimate_pk, sig->keyid) == 0 && check_key_signature2 (keyblock, k, ultimate_pk, NULL, NULL, NULL, NULL) == 0 && get_ownertrust (ultimate_pk) == TRUST_ULTIMATE) { free_public_key (ultimate_pk); pk->flags.valid = 1; break; } free_public_key (ultimate_pk); } } } } /* Record the highest selfsig version so we know if this is a v3 key through and through, or a v3 key with a v4 selfsig somewhere. This is useful in a few places to know if the key must be treated as PGP2-style or OpenPGP-style. Note that a selfsig revocation with a higher version number will also raise this value. This is okay since such a revocation must be issued by the user (i.e. it cannot be issued by someone else to modify the key behavior.) */ pk->selfsigversion = sigversion; /* Now that we had a look at all user IDs we can now get some information * from those user IDs. */ if (!key_usage) { /* Find the latest user ID with key flags set. */ uiddate = 0; /* Helper to find the latest user ID. */ for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID) { PKT_user_id *uid = k->pkt->pkt.user_id; if (uid->help_key_usage && uid->created > uiddate) { key_usage = uid->help_key_usage; uiddate = uid->created; } } } } if (!key_usage) { /* No key flags at all: get it from the algo. */ key_usage = openpgp_pk_algo_usage (pk->pubkey_algo); } else { /* Check that the usage matches the usage as given by the algo. */ int x = openpgp_pk_algo_usage (pk->pubkey_algo); if (x) /* Mask it down to the actual allowed usage. */ key_usage &= x; } /* Whatever happens, it's a primary key, so it can certify. */ pk->pubkey_usage = key_usage | PUBKEY_USAGE_CERT; if (!key_expire_seen) { /* Find the latest valid user ID with a key expiration set * Note, that this may be a different one from the above because * some user IDs may have no expiration date set. */ uiddate = 0; for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID) { PKT_user_id *uid = k->pkt->pkt.user_id; if (uid->help_key_expire && uid->created > uiddate) { key_expire = uid->help_key_expire; uiddate = uid->created; } } } } /* Currently only v3 keys have a maximum expiration date, but I'll bet v5 keys get this feature again. */ if (key_expire == 0 || (pk->max_expiredate && key_expire > pk->max_expiredate)) key_expire = pk->max_expiredate; pk->has_expired = key_expire >= curtime ? 0 : key_expire; pk->expiredate = key_expire; /* Fixme: we should see how to get rid of the expiretime fields but * this needs changes at other places too. */ /* And now find the real primary user ID and delete all others. */ uiddate = uiddate2 = 0; uidnode = uidnode2 = NULL; for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID && !k->pkt->pkt.user_id->attrib_data) { PKT_user_id *uid = k->pkt->pkt.user_id; if (uid->is_primary) { if (uid->created > uiddate) { uiddate = uid->created; uidnode = k; } else if (uid->created == uiddate && uidnode) { /* The dates are equal, so we need to do a different (and arbitrary) comparison. This should rarely, if ever, happen. It's good to try and guarantee that two different GnuPG users with two different keyrings at least pick the same primary. */ if (cmp_user_ids (uid, uidnode->pkt->pkt.user_id) > 0) uidnode = k; } } else { if (uid->created > uiddate2) { uiddate2 = uid->created; uidnode2 = k; } else if (uid->created == uiddate2 && uidnode2) { if (cmp_user_ids (uid, uidnode2->pkt->pkt.user_id) > 0) uidnode2 = k; } } } } if (uidnode) { for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID && !k->pkt->pkt.user_id->attrib_data) { PKT_user_id *uid = k->pkt->pkt.user_id; if (k != uidnode) uid->is_primary = 0; } } } else if (uidnode2) { /* None is flagged primary - use the latest user ID we have, and disambiguate with the arbitrary packet comparison. */ uidnode2->pkt->pkt.user_id->is_primary = 1; } else { /* None of our uids were self-signed, so pick the one that sorts first to be the primary. This is the best we can do here since there are no self sigs to date the uids. */ uidnode = NULL; for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) { if (k->pkt->pkttype == PKT_USER_ID && !k->pkt->pkt.user_id->attrib_data) { if (!uidnode) { uidnode = k; uidnode->pkt->pkt.user_id->is_primary = 1; continue; } else { if (cmp_user_ids (k->pkt->pkt.user_id, uidnode->pkt->pkt.user_id) > 0) { uidnode->pkt->pkt.user_id->is_primary = 0; uidnode = k; uidnode->pkt->pkt.user_id->is_primary = 1; } else k->pkt->pkt.user_id->is_primary = 0; /* just to be safe */ } } } } }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [char ssl3_cbc_record_digest_supported(const EVP_MD *digest) { #ifdef OPENSSL_FIPS if (FIPS_mode()) return 0; #endif switch (digest->type) { case NID_md5: case NID_sha1: case NID_sha224: case NID_sha256: case NID_sha384: case NID_sha512: return 1; default: return 0; } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [GF_Err gf_m4a_write_config_bs(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg) { if (!cfg->base_sr_index) { if (!cfg->base_sr) return GF_BAD_PARAM; while (GF_M4ASampleRates[cfg->base_sr_index]) { if (GF_M4ASampleRates[cfg->base_sr_index] == cfg->base_sr) break; cfg->base_sr_index++; } } if (cfg->sbr_sr && !cfg->sbr_sr_index) { while (GF_M4ASampleRates[cfg->sbr_sr_index]) { if (GF_M4ASampleRates[cfg->sbr_sr_index] == cfg->sbr_sr) break; cfg->sbr_sr_index++; } } /*extended object type*/ if (cfg->base_object_type >= 32) { gf_bs_write_int(bs, 31, 5); gf_bs_write_int(bs, cfg->base_object_type - 32, 6); } else { gf_bs_write_int(bs, cfg->base_object_type, 5); } gf_bs_write_int(bs, cfg->base_sr_index, 4); if (cfg->base_sr_index == 0x0F) { gf_bs_write_int(bs, cfg->base_sr, 24); } if (cfg->program_config_element_present) { gf_bs_write_int(bs, 0, 4); } else { cfg->chan_cfg = gf_m4a_get_channel_cfg(cfg->nb_chan); if (!cfg->chan_cfg) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[AAC] Cannot write decoder config, ProgramConfigElement is missing and channel configuration is not a predefined one !\n")); return GF_BAD_PARAM; } gf_bs_write_int(bs, cfg->chan_cfg, 4); } if (cfg->base_object_type == 5 || cfg->base_object_type == 29) { if (cfg->base_object_type == 29) { cfg->has_ps = 1; cfg->nb_chan = 1; } cfg->has_sbr = 1; gf_bs_write_int(bs, cfg->sbr_sr_index, 4); if (cfg->sbr_sr_index == 0x0F) { gf_bs_write_int(bs, cfg->sbr_sr, 24); } gf_bs_write_int(bs, cfg->sbr_object_type, 5); } /*object cfg*/ switch (cfg->base_object_type) { case 1: case 2: case 3: case 4: case 6: case 7: case 17: case 19: case 20: case 21: case 22: case 23: case 42: { /*frame length flag*/ gf_bs_write_int(bs, 0, 1); /*depends on core coder*/ gf_bs_write_int(bs, 0, 1); /*ext flag*/ gf_bs_write_int(bs, 0, 1); if (cfg->program_config_element_present) { gf_m4a_write_program_config_element_bs(bs, cfg); } if ((cfg->base_object_type == 6) || (cfg->base_object_type == 20)) { gf_bs_write_int(bs, 0, 3); } } break; } /*ER cfg - not supported*/ /*implicit sbr/ps signaling not written here, cf reframe_adts*/ return GF_OK; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [ if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) { WLOG(WS_LOG_SFTP, "Error with file handle size"); res = err; type = WOLFSSH_FTP_FAILURE; ret = WS_BAD_FILE_E; }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [startElementHandler(void *userData, const char *name, const char **atts) { int pos; userdata_t *ud = (userdata_t *) userData; Agraph_t *g = NULL; if (strcmp(name, "graphml") == 0) { /* do nothing */ } else if (strcmp(name, "graph") == 0) { const char *edgeMode = ""; const char *id; Agdesc_t dir; char buf[NAMEBUF]; /* holds % + number */ Current_class = TAG_GRAPH; if (ud->closedElementType == TAG_GRAPH) { fprintf(stderr, "Warning: Node contains more than one graph.\n"); } pos = get_xml_attr("id", atts); if (pos > 0) { id = atts[pos]; } else id = ud->gname; pos = get_xml_attr("edgedefault", atts); if (pos > 0) { edgeMode = atts[pos]; } if (GSP == 0) { if (strcmp(edgeMode, "directed") == 0) { dir = Agdirected; } else if (strcmp(edgeMode, "undirected") == 0) { dir = Agundirected; } else { if (Verbose) { fprintf(stderr, "Warning: graph has no edgedefault attribute - assume directed\n"); } dir = Agdirected; } g = agopen((char *) id, dir, &AgDefaultDisc); push_subg(g); } else { Agraph_t *subg; if (isAnonGraph((char *) id)) { static int anon_id = 1; sprintf(buf, "%%%d", anon_id++); id = buf; } subg = agsubg(G, (char *) id, 1); push_subg(subg); } pushString(&ud->elements, id); } else if (strcmp(name, "node") == 0) { Current_class = TAG_NODE; pos = get_xml_attr("id", atts); if (pos > 0) { const char *attrname; attrname = atts[pos]; bind_node(attrname); pushString(&ud->elements, attrname); } } else if (strcmp(name, "edge") == 0) { const char *head = "", *tail = ""; char *tname; Agnode_t *t; Current_class = TAG_EDGE; pos = get_xml_attr("source", atts); if (pos > 0) tail = atts[pos]; pos = get_xml_attr("target", atts); if (pos > 0) head = atts[pos]; tname = mapLookup(ud->nameMap, (char *) tail); if (tname) tail = tname; tname = mapLookup(ud->nameMap, (char *) head); if (tname) head = tname; bind_edge(tail, head); t = AGTAIL(E); tname = agnameof(t); if (strcmp(tname, tail) == 0) { ud->edgeinverted = FALSE; } else if (strcmp(tname, head) == 0) { ud->edgeinverted = TRUE; } pos = get_xml_attr("id", atts); if (pos > 0) { setEdgeAttr(E, GRAPHML_ID, (char *) atts[pos], ud); } } else { /* must be some extension */ fprintf(stderr, "Unknown node %s - ignoring.\n", name); } }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static gboolean avrcp_search_rsp(struct avctp *conn, uint8_t *operands, size_t operand_count, void *user_data) { struct avrcp_browsing_header *pdu = (void *) operands; struct avrcp *session = (void *) user_data; struct avrcp_player *player = session->controller->player; struct media_player *mp = player->user_data; int ret; if (pdu == NULL) { ret = -ETIMEDOUT; goto done; } if (pdu->params[0] != AVRCP_STATUS_SUCCESS || operand_count < 7) { ret = -EINVAL; goto done; } player->uid_counter = get_be16(&pdu->params[1]); ret = get_be32(&pdu->params[3]); done: media_player_search_complete(mp, ret); return FALSE; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { EC_KEY *ec = ctx->pkey->pkey.ec; SM2_PKEY_CTX *dctx = ctx->data; const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { if (!sm2_plaintext_size(ec, md, inlen, outlen)) return -1; else return 1; } return sm2_decrypt(ec, md, in, inlen, out, outlen); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [static int netbk_set_skb_gso(struct xenvif *vif, struct sk_buff *skb, struct xen_netif_extra_info *gso) { if (!gso->u.gso.size) { netdev_err(vif->dev, "GSO size must not be zero.\n"); netbk_fatal_tx_err(vif); return -EINVAL; } /* Currently only TCPv4 S.O. is supported. */ if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) { netdev_err(vif->dev, "Bad GSO type %d.\n", gso->u.gso.type); netbk_fatal_tx_err(vif); return -EINVAL; } skb_shinfo(skb)->gso_size = gso->u.gso.size; skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; /* Header must be checked, and gso_segs computed. */ skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; skb_shinfo(skb)->gso_segs = 0; return 0; }] Response: 0
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [copy_move_file (CopyMoveJob *copy_job, GFile *src, GFile *dest_dir, gboolean same_fs, gboolean unique_names, char **dest_fs_type, SourceInfo *source_info, TransferInfo *transfer_info, GHashTable *debuting_files, GdkPoint *position, gboolean overwrite, gboolean *skipped_file, gboolean readonly_source_fs) { GFile *dest, *new_dest; GError *error; GFileCopyFlags flags; char *primary, *secondary, *details; int response; ProgressData pdata; gboolean would_recurse, is_merge; CommonJob *job; gboolean res; int unique_name_nr; gboolean handled_invalid_filename; job = (CommonJob *)copy_job; if (should_skip_file (job, src)) { *skipped_file = TRUE; return; } unique_name_nr = 1; /* another file in the same directory might have handled the invalid * filename condition for us */ handled_invalid_filename = *dest_fs_type != NULL; if (unique_names) { dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr++); } else { dest = get_target_file (src, dest_dir, *dest_fs_type, same_fs); } /* Don't allow recursive move/copy into itself. * (We would get a file system error if we proceeded but it is nicer to * detect and report it at this level) */ if (test_dir_is_parent (dest_dir, src)) { if (job->skip_all_error) { g_error_free (error); goto out; } /* the run_warning() frees all strings passed in automatically */ primary = copy_job->is_move ? g_strdup (_("You cannot move a folder into itself.")) : g_strdup (_("You cannot copy a folder into itself.")); secondary = g_strdup (_("The destination folder is inside the source folder.")); response = run_warning (job, primary, secondary, NULL, (source_info->num_files - transfer_info->num_files) > 1, GTK_STOCK_CANCEL, SKIP_ALL, SKIP, NULL); if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) { abort_job (job); } else if (response == 1) { /* skip all */ job->skip_all_error = TRUE; } else if (response == 2) { /* skip */ /* do nothing */ } else { g_assert_not_reached (); } goto out; } /* Don't allow copying over the source or one of the parents of the source. */ if (test_dir_is_parent (src, dest)) { if (job->skip_all_error) { g_error_free (error); goto out; } /* the run_warning() frees all strings passed in automatically */ primary = copy_job->is_move ? g_strdup (_("You cannot move a file over itself.")) : g_strdup (_("You cannot copy a file over itself.")); secondary = g_strdup (_("The source file would be overwritten by the destination.")); response = run_warning (job, primary, secondary, NULL, (source_info->num_files - transfer_info->num_files) > 1, GTK_STOCK_CANCEL, SKIP_ALL, SKIP, NULL); if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) { abort_job (job); } else if (response == 1) { /* skip all */ job->skip_all_error = TRUE; } else if (response == 2) { /* skip */ /* do nothing */ } else { g_assert_not_reached (); } goto out; } retry: error = NULL; flags = G_FILE_COPY_NOFOLLOW_SYMLINKS; if (overwrite) { flags |= G_FILE_COPY_OVERWRITE; } if (readonly_source_fs) { flags |= G_FILE_COPY_TARGET_DEFAULT_PERMS; } pdata.job = copy_job; pdata.last_size = 0; pdata.source_info = source_info; pdata.transfer_info = transfer_info; if (copy_job->is_move) { res = g_file_move (src, dest, flags, job->cancellable, copy_file_progress_callback, &pdata, &error); } else { res = g_file_copy (src, dest, flags, job->cancellable, copy_file_progress_callback, &pdata, &error); } if (res) { transfer_info->num_files ++; report_copy_progress (copy_job, source_info, transfer_info); if (debuting_files) { if (copy_job->is_move) { nautilus_file_changes_queue_schedule_metadata_move (src, dest); } else { nautilus_file_changes_queue_schedule_metadata_copy (src, dest); } if (position) { nautilus_file_changes_queue_schedule_position_set (dest, *position, job->screen_num); } else { nautilus_file_changes_queue_schedule_position_remove (dest); } g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (TRUE)); } if (copy_job->is_move) { nautilus_file_changes_queue_file_moved (src, dest); } else { nautilus_file_changes_queue_file_added (dest); } g_object_unref (dest); return; } if (!handled_invalid_filename && IS_IO_ERROR (error, INVALID_FILENAME)) { handled_invalid_filename = TRUE; g_assert (*dest_fs_type == NULL); *dest_fs_type = query_fs_type (dest_dir, job->cancellable); if (unique_names) { new_dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr); } else { new_dest = get_target_file (src, dest_dir, *dest_fs_type, same_fs); } if (!g_file_equal (dest, new_dest)) { g_object_unref (dest); dest = new_dest; g_error_free (error); goto retry; } else { g_object_unref (new_dest); } } /* Conflict */ if (!overwrite && IS_IO_ERROR (error, EXISTS)) { gboolean is_merge; if (unique_names) { g_object_unref (dest); dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr++); g_error_free (error); goto retry; } is_merge = FALSE; if (is_dir (dest)) { if (is_dir (src)) { is_merge = TRUE; primary = f (_("A folder named \"%B\" already exists. Do you want to merge the source folder?"), dest); secondary = f (_("The source folder already exists in \"%B\". " "Merging will ask for confirmation before replacing any files in the folder that conflict with the files being copied."), dest_dir); } else { primary = f (_("A folder named \"%B\" already exists. Do you want to replace it?"), dest); secondary = f (_("The folder already exists in \"%F\". " "Replacing it will remove all files in the folder."), dest_dir); } } else { primary = f (_("A file named \"%B\" already exists. Do you want to replace it?"), dest); secondary = f (_("The file already exists in \"%F\". " "Replacing it will overwrite its content."), dest_dir); } if ((is_merge && job->merge_all) || (!is_merge && job->replace_all)) { g_free (primary); g_free (secondary); g_error_free (error); overwrite = TRUE; goto retry; } if (job->skip_all_conflict) { g_free (primary); g_free (secondary); g_error_free (error); goto out; } response = run_warning (job, primary, secondary, NULL, (source_info->num_files - transfer_info->num_files) > 1, GTK_STOCK_CANCEL, SKIP_ALL, is_merge?MERGE_ALL:REPLACE_ALL, SKIP, is_merge?MERGE:REPLACE, NULL); g_error_free (error); if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) { abort_job (job); } else if (response == 1 || response == 3) { /* skip all / skip */ if (response == 1) { job->skip_all_conflict = TRUE; } } else if (response == 2 || response == 4) { /* merge/replace all / merge/replace*/ if (response == 2) { if (is_merge) { job->merge_all = TRUE; } else { job->replace_all = TRUE; } } overwrite = TRUE; goto retry; } else { g_assert_not_reached (); } } else if (overwrite && IS_IO_ERROR (error, IS_DIRECTORY)) { g_error_free (error); if (remove_target_recursively (job, src, dest, dest)) { goto retry; } } /* Needs to recurse */ else if (IS_IO_ERROR (error, WOULD_RECURSE) || IS_IO_ERROR (error, WOULD_MERGE)) { is_merge = error->code == G_IO_ERROR_WOULD_MERGE; would_recurse = error->code == G_IO_ERROR_WOULD_RECURSE; g_error_free (error); if (overwrite && would_recurse) { error = NULL; /* Copying a dir onto file, first remove the file */ if (!g_file_delete (dest, job->cancellable, &error) && !IS_IO_ERROR (error, NOT_FOUND)) { if (job->skip_all_error) { g_error_free (error); goto out; } if (copy_job->is_move) { primary = f (_("Error while moving \"%B\"."), src); } else { primary = f (_("Error while copying \"%B\"."), src); } secondary = f (_("Could not remove the already existing file with the same name in %F."), dest_dir); details = error->message; /* setting TRUE on show_all here, as we could have * another error on the same file later. */ response = run_warning (job, primary, secondary, details, TRUE, GTK_STOCK_CANCEL, SKIP_ALL, SKIP, NULL); g_error_free (error); if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) { abort_job (job); } else if (response == 1) { /* skip all */ job->skip_all_error = TRUE; } else if (response == 2) { /* skip */ /* do nothing */ } else { g_assert_not_reached (); } goto out; } if (error) { g_error_free (error); error = NULL; } if (debuting_files) { /* Only remove metadata for toplevel items */ nautilus_file_changes_queue_schedule_metadata_remove (dest); } nautilus_file_changes_queue_file_removed (dest); } if (is_merge) { /* On merge we now write in the target directory, which may not be in the same directory as the source, even if the parent is (if the merged directory is a mountpoint). This could cause problems as we then don't transcode filenames. We just set same_fs to FALSE which is safe but a bit slower. */ same_fs = FALSE; } if (!copy_move_directory (copy_job, src, &dest, same_fs, would_recurse, dest_fs_type, source_info, transfer_info, debuting_files, skipped_file, readonly_source_fs)) { /* destination changed, since it was an invalid file name */ g_assert (*dest_fs_type != NULL); handled_invalid_filename = TRUE; goto retry; } g_object_unref (dest); return; } else if (IS_IO_ERROR (error, CANCELLED)) { g_error_free (error); } /* Other error */ else { if (job->skip_all_error) { g_error_free (error); goto out; } primary = f (_("Error while copying \"%B\"."), src); secondary = f (_("There was an error copying the file into %F."), dest_dir); details = error->message; response = run_warning (job, primary, secondary, details, (source_info->num_files - transfer_info->num_files) > 1, GTK_STOCK_CANCEL, SKIP_ALL, SKIP, NULL); g_error_free (error); if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) { abort_job (job); } else if (response == 1) { /* skip all */ job->skip_all_error = TRUE; } else if (response == 2) { /* skip */ /* do nothing */ } else { g_assert_not_reached (); } } out: *skipped_file = TRUE; /* Or aborted, but same-same */ g_object_unref (dest); }] Response: 1
Instruction: Analyze the code of the program enclosed in square brackets, determine if it has vulnerability, or not, and return the answer as the corresponding target label "1" or "0" respectively. [tparm_proto(const char *string, TPARM_ARG a1, TPARM_ARG a2, TPARM_ARG a3, TPARM_ARG a4, TPARM_ARG a5, TPARM_ARG a6, TPARM_ARG a7, TPARM_ARG a8, TPARM_ARG a9) { return tparm_varargs(string, a1, a2, a3, a4, a5, a6, a7, a8, a9); }] Response: 1

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
5
Add dataset card