diff --git "a/train_data.csv" "b/train_data.csv" new file mode 100644--- /dev/null +++ "b/train_data.csv" @@ -0,0 +1,185079 @@ +func +"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 get_object3dtoCImg3d(const bool full_check=true) const { + CImgList opacities, colors; + CImgList 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; itail_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; iin_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(); + 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::ConstTensor stats_summary = + stats_summary_t->tensor(); + 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()(); + 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()(); + 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()(); + + 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()(); + + std::vector output_node_ids; + std::vector output_gains; + std::vector output_feature_dimensions; + std::vector output_thresholds; + std::vector output_left_node_contribs; + std::vector output_right_node_contribs; + std::vector 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::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::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(); + + // 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(); + + // 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(); + + // 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(); + + // 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(); + + // 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(); + + // 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(); + + // 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(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& 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()(); + + std::vector scores_data(num_boxes); + std::copy_n(scores.flat().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, 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(0.0); + bool is_soft_nms = soft_nms_sigma > static_cast(0.0); + if (is_soft_nms) { + scale = static_cast(-0.5) / soft_nms_sigma; + } + + auto suppress_weight = [similarity_threshold, scale, + is_soft_nms](const T sim) { + const T weight = Eigen::numext::exp(scale * sim * sim); + return is_soft_nms || sim <= similarity_threshold ? weight + : static_cast(0.0); + }; + + std::vector selected; + std::vector 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(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(similarity)); + + // First decide whether to perform hard suppression + if (!is_soft_nms && static_cast(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(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(selected.size())}); + OP_REQUIRES_OK(context, + context->allocate_output(0, output_shape, &output_indices)); + TTypes::Tensor output_indices_data = output_indices->tensor(); + 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::Tensor output_scores_data = + output_scores->tensor(); + 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
[...] */ + /* SEND
0 (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" +"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* context) override { + // Input tensor is of the following dimensions: + // [ batch, in_rows, in_cols, in_depth ] + const Tensor& input = context->input(0); + + // Input filter is of the following dimensions: + // [ filter_rows, filter_cols, in_depth, out_depth] + const Tensor& filter = context->input(1); + + // For 2D convolution, there should be 4 dimensions. + OP_REQUIRES(context, input.dims() == 4, + errors::InvalidArgument(""input must be 4-dimensional"", + input.shape().DebugString())); + OP_REQUIRES(context, filter.dims() == 4, + errors::InvalidArgument(""filter must be 4-dimensional: "", + filter.shape().DebugString())); + + const float min_input = context->input(2).flat()(0); + const float max_input = context->input(3).flat()(0); + const float min_filter = context->input(4).flat()(0); + const float max_filter = context->input(5).flat()(0); + const int32_t offset_input = + FloatToQuantizedUnclamped(0.0f, min_input, max_input); + const int32_t offset_filter = + FloatToQuantizedUnclamped(0.0f, min_filter, max_filter); + const int32_t offset_output = 0; + const int32_t mult_output = 1; + const int32_t shift_output = 0; + + // The last dimension for input is in_depth. It must be the same as the + // filter's in_depth. + const int64_t in_depth = input.dim_size(3); + OP_REQUIRES(context, in_depth == filter.dim_size(2), + errors::InvalidArgument( + ""input and filter must have the same depth: "", in_depth, + "" vs "", filter.dim_size(2))); + + // The last dimension for filter is out_depth. + const int64_t out_depth = filter.dim_size(3); + + // The second dimension for input is rows/height. + // The first dimension for filter is rows/height. + const int64_t input_rows = input.dim_size(1); + const int64_t filter_rows = filter.dim_size(0); + + // The third dimension for input is columns/width. + // The second dimension for filter is columns/width. + const int64_t input_cols = input.dim_size(2); + const int64_t filter_cols = filter.dim_size(1); + + // The first dimension for input is batch. + const int64_t batch = input.dim_size(0); + + // For now we take the stride from the second dimension only (we + // assume row = col stride, and do not support striding on the + // batch or depth dimension). + const int stride = strides_[1]; + + int64_t out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0; + OP_REQUIRES_OK(context, + GetWindowedOutputSize(input_rows, filter_rows, stride, + padding_, &out_rows, &pad_rows)); + OP_REQUIRES_OK(context, + GetWindowedOutputSize(input_cols, filter_cols, stride, + padding_, &out_cols, &pad_cols)); + CHECK_GT(batch, 0); + CHECK_GT(out_rows, 0); + CHECK_GT(out_cols, 0); + CHECK_GT(out_depth, 0); + TensorShape out_shape({batch, out_rows, out_cols, out_depth}); + + // Output tensor is of the following dimensions: + // [ in_batch, out_rows, out_cols, out_depth ] + Tensor* output = nullptr; + OP_REQUIRES_OK(context, context->allocate_output(0, out_shape, &output)); + + // This will call different implementations (e.g. reference or optimized) + // depending on the template parameter. + ConvFunctor conv_functor; + conv_functor(context, input.flat().data(), batch, input_rows, + input_cols, in_depth, offset_input, filter.flat().data(), + filter_rows, filter_cols, out_depth, offset_filter, stride, + padding_, output->flat().data(), out_rows, out_cols, + shift_output, offset_output, mult_output); + + float min_output_value; + float max_output_value; + QuantizationRangeForMultiplication( + min_input, max_input, min_filter, max_filter, &min_output_value, + &max_output_value); + + Tensor* output_min = nullptr; + OP_REQUIRES_OK(context, context->allocate_output(1, {}, &output_min)); + output_min->flat()(0) = min_output_value; + + Tensor* output_max = nullptr; + OP_REQUIRES_OK(context, context->allocate_output(2, {}, &output_max)); + output_max->flat()(0) = max_output_value; + }] + +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 mysql_prune_stmt_list(MYSQL *mysql) +{ + LIST *element= mysql->stmts; + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + stmt->last_errno= CR_SERVER_LOST; + strmov(stmt->last_error, ER(CR_SERVER_LOST)); + strmov(stmt->sqlstate, unknown_sqlstate); + mysql->stmts= list_delete(mysql->stmts, element); + } + } +}] + +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. + [cdp_decode(struct lldpd *cfg, char *frame, int s, + struct lldpd_hardware *hardware, + struct lldpd_chassis **newchassis, struct lldpd_port **newport) +{ + struct lldpd_chassis *chassis; + struct lldpd_port *port; + struct lldpd_mgmt *mgmt; + struct in_addr addr; +#if 0 + u_int16_t cksum; +#endif + u_int8_t *software = NULL, *platform = NULL; + int software_len = 0, platform_len = 0, proto, version, nb, caps; + const unsigned char cdpaddr[] = CDP_MULTICAST_ADDR; +#ifdef ENABLE_FDP + const unsigned char fdpaddr[] = CDP_MULTICAST_ADDR; + int fdp = 0; +#endif + u_int8_t *pos, *tlv, *pos_address, *pos_next_address; + int length, len_eth, tlv_type, tlv_len, addresses_len, address_len; +#ifdef ENABLE_DOT1 + struct lldpd_vlan *vlan; +#endif + + log_debug(""cdp"", ""decode CDP frame received on %s"", + hardware->h_ifname); + + if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) { + log_warn(""cdp"", ""failed to allocate remote chassis""); + return -1; + } + TAILQ_INIT(&chassis->c_mgmt); + if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) { + log_warn(""cdp"", ""failed to allocate remote port""); + free(chassis); + return -1; + } +#ifdef ENABLE_DOT1 + TAILQ_INIT(&port->p_vlans); +#endif + + length = s; + pos = (u_int8_t*)frame; + + if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t) /* Ethernet */ + + 8 /* LLC */ + 4 /* CDP header */) { + log_warn(""cdp"", ""too short CDP/FDP frame received on %s"", hardware->h_ifname); + goto malformed; + } + + if (PEEK_CMP(cdpaddr, sizeof(cdpaddr)) != 0) { +#ifdef ENABLE_FDP + PEEK_RESTORE((u_int8_t*)frame); + if (PEEK_CMP(fdpaddr, sizeof(fdpaddr)) != 0) + fdp = 1; + else { +#endif + log_info(""cdp"", ""frame not targeted at CDP/FDP multicast address received on %s"", + hardware->h_ifname); + goto malformed; +#ifdef ENABLE_FDP + } +#endif + } + PEEK_DISCARD(ETHER_ADDR_LEN); /* Don't care of source address */ + len_eth = PEEK_UINT16; + if (len_eth > length) { + log_warnx(""cdp"", ""incorrect 802.3 frame size reported on %s"", + hardware->h_ifname); + goto malformed; + } + PEEK_DISCARD(6); /* Skip beginning of LLC */ + proto = PEEK_UINT16; + if (proto != LLC_PID_CDP) { + if ((proto != LLC_PID_DRIP) && + (proto != LLC_PID_PAGP) && + (proto != LLC_PID_PVSTP) && + (proto != LLC_PID_UDLD) && + (proto != LLC_PID_VTP) && + (proto != LLC_PID_DTP) && + (proto != LLC_PID_STP)) + log_debug(""cdp"", ""incorrect LLC protocol ID received on %s"", + hardware->h_ifname); + goto malformed; + } + +#if 0 + /* Check checksum */ + cksum = frame_checksum(pos, len_eth - 8, +#ifdef ENABLE_FDP + !fdp /* fdp = 0 -> cisco checksum */ +#else + 1 /* cisco checksum */ +#endif + ); + if (cksum != 0) { + log_info(""cdp"", ""incorrect CDP/FDP checksum for frame received on %s (%d)"", + hardware->h_ifname, cksum); + goto malformed; + } +#endif + + /* Check version */ + version = PEEK_UINT8; + if ((version != 1) && (version != 2)) { + log_warnx(""cdp"", ""incorrect CDP/FDP version (%d) for frame received on %s"", + version, hardware->h_ifname); + goto malformed; + } + chassis->c_ttl = PEEK_UINT8; /* TTL */ + PEEK_DISCARD_UINT16; /* Checksum, already checked */ + + while (length) { + if (length < 4) { + log_warnx(""cdp"", ""CDP/FDP TLV header is too large for "" + ""frame received on %s"", + hardware->h_ifname); + goto malformed; + } + tlv_type = PEEK_UINT16; + tlv_len = PEEK_UINT16 - 4; + (void)PEEK_SAVE(tlv); + if ((tlv_len < 0) || (length < tlv_len)) { + log_warnx(""cdp"", ""incorrect size in CDP/FDP TLV header for frame "" + ""received on %s"", + hardware->h_ifname); + goto malformed; + } + switch (tlv_type) { + case CDP_TLV_CHASSIS: + if ((chassis->c_name = (char *)calloc(1, tlv_len + 1)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for chassis name""); + goto malformed; + } + PEEK_BYTES(chassis->c_name, tlv_len); + chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL; + if ((chassis->c_id = (char *)malloc(tlv_len)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for chassis ID""); + goto malformed; + } + memcpy(chassis->c_id, chassis->c_name, tlv_len); + chassis->c_id_len = tlv_len; + break; + case CDP_TLV_ADDRESSES: + CHECK_TLV_SIZE(4, ""Address""); + addresses_len = tlv_len - 4; + for (nb = PEEK_UINT32; nb > 0; nb--) { + (void)PEEK_SAVE(pos_address); + /* We first try to get the real length of the packet */ + if (addresses_len < 2) { + log_warn(""cdp"", ""too short address subframe "" + ""received on %s"", + hardware->h_ifname); + goto malformed; + } + PEEK_DISCARD_UINT8; addresses_len--; + address_len = PEEK_UINT8; addresses_len--; + if (addresses_len < address_len + 2) { + log_warn(""cdp"", ""too short address subframe "" + ""received on %s"", + hardware->h_ifname); + goto malformed; + } + PEEK_DISCARD(address_len); + addresses_len -= address_len; + address_len = PEEK_UINT16; addresses_len -= 2; + if (addresses_len < address_len) { + log_warn(""cdp"", ""too short address subframe "" + ""received on %s"", + hardware->h_ifname); + goto malformed; + } + PEEK_DISCARD(address_len); + (void)PEEK_SAVE(pos_next_address); + /* Next, we go back and try to extract + IPv4 address */ + PEEK_RESTORE(pos_address); + if ((PEEK_UINT8 == 1) && (PEEK_UINT8 == 1) && + (PEEK_UINT8 == CDP_ADDRESS_PROTO_IP) && + (PEEK_UINT16 == sizeof(struct in_addr))) { + PEEK_BYTES(&addr, sizeof(struct in_addr)); + mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4, &addr, + sizeof(struct in_addr), 0); + if (mgmt == NULL) { + assert(errno == ENOMEM); + log_warn(""cdp"", ""unable to allocate memory for management address""); + goto malformed; + } + TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries); + } + /* Go to the end of the address */ + PEEK_RESTORE(pos_next_address); + } + break; + case CDP_TLV_PORT: + if (tlv_len == 0) { + log_warn(""cdp"", ""too short port description received""); + goto malformed; + } + if ((port->p_descr = (char *)calloc(1, tlv_len + 1)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for port description""); + goto malformed; + } + PEEK_BYTES(port->p_descr, tlv_len); + port->p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME; + if ((port->p_id = (char *)calloc(1, tlv_len)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for port ID""); + goto malformed; + } + memcpy(port->p_id, port->p_descr, tlv_len); + port->p_id_len = tlv_len; + break; + case CDP_TLV_CAPABILITIES: +#ifdef ENABLE_FDP + if (fdp) { + /* Capabilities are string with FDP */ + if (!strncmp(""Router"", (char*)pos, tlv_len)) + chassis->c_cap_enabled = LLDP_CAP_ROUTER; + else if (!strncmp(""Switch"", (char*)pos, tlv_len)) + chassis->c_cap_enabled = LLDP_CAP_BRIDGE; + else if (!strncmp(""Bridge"", (char*)pos, tlv_len)) + chassis->c_cap_enabled = LLDP_CAP_REPEATER; + else + chassis->c_cap_enabled = LLDP_CAP_STATION; + chassis->c_cap_available = chassis->c_cap_enabled; + break; + } +#endif + CHECK_TLV_SIZE(4, ""Capabilities""); + caps = PEEK_UINT32; + if (caps & CDP_CAP_ROUTER) + chassis->c_cap_enabled |= LLDP_CAP_ROUTER; + if (caps & 0x0e) + chassis->c_cap_enabled |= LLDP_CAP_BRIDGE; + if (chassis->c_cap_enabled == 0) + chassis->c_cap_enabled = LLDP_CAP_STATION; + chassis->c_cap_available = chassis->c_cap_enabled; + break; + case CDP_TLV_SOFTWARE: + software_len = tlv_len; + (void)PEEK_SAVE(software); + break; + case CDP_TLV_PLATFORM: + platform_len = tlv_len; + (void)PEEK_SAVE(platform); + break; +#ifdef ENABLE_DOT1 + case CDP_TLV_NATIVEVLAN: + CHECK_TLV_SIZE(2, ""Native VLAN""); + if ((vlan = (struct lldpd_vlan *)calloc(1, + sizeof(struct lldpd_vlan))) == NULL) { + log_warn(""cdp"", ""unable to alloc vlan "" + ""structure for "" + ""tlv received on %s"", + hardware->h_ifname); + goto malformed; + } + vlan->v_vid = port->p_pvid = PEEK_UINT16; + if (asprintf(&vlan->v_name, ""VLAN #%d"", vlan->v_vid) == -1) { + log_warn(""cdp"", ""unable to alloc VLAN name for "" + ""TLV received on %s"", + hardware->h_ifname); + free(vlan); + goto malformed; + } + TAILQ_INSERT_TAIL(&port->p_vlans, + vlan, v_entries); + break; +#endif + default: + log_debug(""cdp"", ""unknown CDP/FDP TLV type (%d) received on %s"", + ntohs(tlv_type), hardware->h_ifname); + hardware->h_rx_unrecognized_cnt++; + } + PEEK_DISCARD(tlv + tlv_len - pos); + } + if (!software && platform) { + if ((chassis->c_descr = (char *)calloc(1, + platform_len + 1)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for chassis description""); + goto malformed; + } + memcpy(chassis->c_descr, platform, platform_len); + } else if (software && !platform) { + if ((chassis->c_descr = (char *)calloc(1, + software_len + 1)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for chassis description""); + goto malformed; + } + memcpy(chassis->c_descr, software, software_len); + } else if (software && platform) { +#define CONCAT_PLATFORM "" running on\n"" + if ((chassis->c_descr = (char *)calloc(1, + software_len + platform_len + + strlen(CONCAT_PLATFORM) + 1)) == NULL) { + log_warn(""cdp"", ""unable to allocate memory for chassis description""); + goto malformed; + } + memcpy(chassis->c_descr, platform, platform_len); + memcpy(chassis->c_descr + platform_len, + CONCAT_PLATFORM, strlen(CONCAT_PLATFORM)); + memcpy(chassis->c_descr + platform_len + strlen(CONCAT_PLATFORM), + software, software_len); + } + if ((chassis->c_id == NULL) || + (port->p_id == NULL) || + (chassis->c_name == NULL) || + (chassis->c_descr == NULL) || + (port->p_descr == NULL) || + (chassis->c_ttl == 0) || + (chassis->c_cap_enabled == 0)) { + log_warnx(""cdp"", ""some mandatory CDP/FDP tlv are missing for frame received on %s"", + hardware->h_ifname); + goto malformed; + } + *newchassis = chassis; + *newport = port; + return 1; + +malformed: + lldpd_chassis_cleanup(chassis, 1); + lldpd_port_cleanup(port, 1); + free(port); + 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. + [ofputil_pull_ofp14_port(struct ofputil_phy_port *pp, struct ofpbuf *msg) +{ + struct ofp14_port *op = ofpbuf_try_pull(msg, sizeof *op); + if (!op) { + return OFPERR_OFPBRC_BAD_LEN; + } + + size_t len = ntohs(op->length); + if (len < sizeof *op || len - sizeof *op > msg->size) { + return OFPERR_OFPBRC_BAD_LEN; + } + len -= sizeof *op; + + enum ofperr error = ofputil_port_from_ofp11(op->port_no, &pp->port_no); + if (error) { + return error; + } + pp->hw_addr = op->hw_addr; + ovs_strlcpy(pp->name, op->name, OFP_MAX_PORT_NAME_LEN); + + pp->config = ntohl(op->config) & OFPPC11_ALL; + pp->state = ntohl(op->state) & OFPPS11_ALL; + + struct ofpbuf properties = ofpbuf_const_initializer(ofpbuf_pull(msg, len), + len); + while (properties.size > 0) { + struct ofpbuf payload; + enum ofperr error; + uint64_t type; + + error = ofpprop_pull(&properties, &payload, &type); + if (error) { + return error; + } + + switch (type) { + case OFPPDPT14_ETHERNET: + error = parse_ofp14_port_ethernet_property(&payload, pp); + break; + + default: + error = OFPPROP_UNKNOWN(true, ""port"", type); + break; + } + + if (error) { + return error; + } + } + + 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 ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat) +{ + struct file *file = kiocb->ki_filp; + ssize_t ret = 0; + + switch (kiocb->ki_opcode) { + case IOCB_CMD_PREAD: + ret = -EBADF; + if (unlikely(!(file->f_mode & FMODE_READ))) + break; + ret = -EFAULT; + if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf, + kiocb->ki_left))) + break; + ret = security_file_permission(file, MAY_READ); + if (unlikely(ret)) + break; + ret = aio_setup_single_vector(kiocb); + if (ret) + break; + ret = -EINVAL; + if (file->f_op->aio_read) + kiocb->ki_retry = aio_rw_vect_retry; + break; + case IOCB_CMD_PWRITE: + ret = -EBADF; + if (unlikely(!(file->f_mode & FMODE_WRITE))) + break; + ret = -EFAULT; + if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf, + kiocb->ki_left))) + break; + ret = security_file_permission(file, MAY_WRITE); + if (unlikely(ret)) + break; + ret = aio_setup_single_vector(kiocb); + if (ret) + break; + ret = -EINVAL; + if (file->f_op->aio_write) + kiocb->ki_retry = aio_rw_vect_retry; + break; + case IOCB_CMD_PREADV: + ret = -EBADF; + if (unlikely(!(file->f_mode & FMODE_READ))) + break; + ret = security_file_permission(file, MAY_READ); + if (unlikely(ret)) + break; + ret = aio_setup_vectored_rw(READ, kiocb, compat); + if (ret) + break; + ret = -EINVAL; + if (file->f_op->aio_read) + kiocb->ki_retry = aio_rw_vect_retry; + break; + case IOCB_CMD_PWRITEV: + ret = -EBADF; + if (unlikely(!(file->f_mode & FMODE_WRITE))) + break; + ret = security_file_permission(file, MAY_WRITE); + if (unlikely(ret)) + break; + ret = aio_setup_vectored_rw(WRITE, kiocb, compat); + if (ret) + break; + ret = -EINVAL; + if (file->f_op->aio_write) + kiocb->ki_retry = aio_rw_vect_retry; + break; + case IOCB_CMD_FDSYNC: + ret = -EINVAL; + if (file->f_op->aio_fsync) + kiocb->ki_retry = aio_fdsync; + break; + case IOCB_CMD_FSYNC: + ret = -EINVAL; + if (file->f_op->aio_fsync) + kiocb->ki_retry = aio_fsync; + break; + default: + dprintk(""EINVAL: io_submit: no operation provided\n""); + ret = -EINVAL; + } + + if (!kiocb->ki_retry) + return ret; + + 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. + [int check_hex(char *str, int len) { + int i; + for (i = 0; i < len; i++) { + if ((str[i] < '0' && str[i] > '9') && (str[i] < 'a' && str[i] > 'f') && (str[i] < 'A' && str[i] > 'F') + ) { + return 0; + } + } + + return 1; + +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static int decode_avp(struct l2tp_avp_t *avp, const struct l2tp_attr_t *RV, + const char *secret, size_t secret_len) +{ + MD5_CTX md5_ctx; + uint8_t md5[MD5_DIGEST_LENGTH]; + uint8_t p1[MD5_DIGEST_LENGTH]; + uint8_t *prev_block = NULL; + uint16_t attr_len; + uint16_t orig_attr_len; + uint16_t bytes_left; + uint16_t blocks_left; + uint16_t last_block_len; + + if (avp->length < sizeof(struct l2tp_avp_t) + 2) { + /* Hidden AVPs must contain at least two bytes + for storing original attribute length */ + log_warn(""l2tp: incorrect hidden avp received (type %hu):"" + "" length too small (%hu bytes)\n"", + ntohs(avp->type), avp->length); + return -1; + } + attr_len = avp->length - sizeof(struct l2tp_avp_t); + + /* Decode first block */ + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, &avp->type, sizeof(avp->type)); + MD5_Update(&md5_ctx, secret, secret_len); + MD5_Update(&md5_ctx, RV->val.octets, RV->length); + MD5_Final(p1, &md5_ctx); + + if (attr_len <= MD5_DIGEST_LENGTH) { + memxor(avp->val, p1, attr_len); + return 0; + } + + memxor(p1, avp->val, MD5_DIGEST_LENGTH); + orig_attr_len = ntohs(*(uint16_t *)p1); + + if (orig_attr_len <= MD5_DIGEST_LENGTH - 2) { + /* Enough bytes decoded already, no need to decode padding */ + memcpy(avp->val, p1, MD5_DIGEST_LENGTH); + return 0; + } + + if (orig_attr_len > attr_len - 2) { + log_warn(""l2tp: incorrect hidden avp received (type %hu):"" + "" original attribute length too big (ciphered"" + "" attribute length: %hu bytes, advertised original"" + "" attribute length: %hu bytes)\n"", + ntohs(avp->type), attr_len, orig_attr_len); + return -1; + } + + /* Decode remaining blocks. Start from the last block as + preceding blocks must be kept hidden for computing MD5s */ + bytes_left = orig_attr_len + 2 - MD5_DIGEST_LENGTH; + last_block_len = bytes_left % MD5_DIGEST_LENGTH; + blocks_left = bytes_left / MD5_DIGEST_LENGTH; + if (last_block_len) { + prev_block = avp->val + blocks_left * MD5_DIGEST_LENGTH; + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, secret, secret_len); + MD5_Update(&md5_ctx, prev_block, MD5_DIGEST_LENGTH); + MD5_Final(md5, &md5_ctx); + memxor(prev_block + MD5_DIGEST_LENGTH, md5, last_block_len); + prev_block -= MD5_DIGEST_LENGTH; + } else + prev_block = avp->val + (blocks_left - 1) * MD5_DIGEST_LENGTH; + + while (prev_block >= avp->val) { + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, secret, secret_len); + MD5_Update(&md5_ctx, prev_block, MD5_DIGEST_LENGTH); + MD5_Final(md5, &md5_ctx); + memxor(prev_block + MD5_DIGEST_LENGTH, md5, MD5_DIGEST_LENGTH); + prev_block -= MD5_DIGEST_LENGTH; + } + memcpy(avp->val, p1, MD5_DIGEST_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. + [TEST_F(ServerSelectorTestFixture, ShouldReturnNoneIfTopologyUnknown) { + auto topologyDescription = std::make_shared(sdamConfiguration); + ASSERT_EQ(TopologyType::kUnknown, topologyDescription->getType()); + ASSERT_EQ(boost::none, selector.selectServers(topologyDescription, ReadPreferenceSetting())); +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len) +{ + size_t siz = (size_t)off + len; + + if ((off_t)(off + len) != (off_t)siz) { + errno = EINVAL; + return -1; + } + + if (info->i_buf != NULL && info->i_len >= siz) { + (void)memcpy(buf, &info->i_buf[off], len); + return (ssize_t)len; + } + + if (info->i_fd == -1) + return -1; + + if (lseek(info->i_fd, off, SEEK_SET) == (off_t)-1) + return -1; + + if (read(info->i_fd, buf, len) != (ssize_t)len) + return -1; + + return (ssize_t)len; +}] + +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 ClientHandler::start_immediate_shutdown() { + ev_timer_start(conn_.loop, &reneg_shutdown_timer_); +}] + +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 prvInitialiseNewQueue( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + const uint8_t ucQueueType, + Queue_t * pxNewQueue ) +{ + /* Remove compiler warnings about unused parameters should + * configUSE_TRACE_FACILITY not be set to 1. */ + ( void ) ucQueueType; + + if( uxItemSize == ( UBaseType_t ) 0 ) + { + /* No RAM was allocated for the queue storage area, but PC head cannot + * be set to NULL because NULL is used as a key to say the queue is used as + * a mutex. Therefore just set pcHead to point to the queue as a benign + * value that is known to be within the memory map. */ + pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; + } + else + { + /* Set the head to the start of the queue storage area. */ + pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage; + } + + /* Initialise the queue members as described where the queue type is + * defined. */ + pxNewQueue->uxLength = uxQueueLength; + pxNewQueue->uxItemSize = uxItemSize; + ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); + + #if ( configUSE_TRACE_FACILITY == 1 ) + { + pxNewQueue->ucQueueType = ucQueueType; + } + #endif /* configUSE_TRACE_FACILITY */ + + #if ( configUSE_QUEUE_SETS == 1 ) + { + pxNewQueue->pxQueueSetContainer = NULL; + } + #endif /* configUSE_QUEUE_SETS */ + + traceQUEUE_CREATE( pxNewQueue ); +} ] + +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. + [display_set_color_format(gx_device_display *ddev, int nFormat) +{ + gx_device * pdev = (gx_device *) ddev; + gx_device_color_info dci = ddev->color_info; + int bpc; /* bits per component */ + int bpp; /* bits per pixel */ + int maxvalue; + int align; + + switch (nFormat & DISPLAY_DEPTH_MASK) { + case DISPLAY_DEPTH_1: + bpc = 1; + break; + case DISPLAY_DEPTH_2: + bpc = 2; + break; + case DISPLAY_DEPTH_4: + bpc = 4; + break; + case DISPLAY_DEPTH_8: + bpc = 8; + break; + case DISPLAY_DEPTH_12: + bpc = 12; + break; + case DISPLAY_DEPTH_16: + bpc = 16; + break; + default: + return_error(gs_error_rangecheck); + } + maxvalue = (1 << bpc) - 1; + ddev->devn_params.bitspercomponent = bpc; + + switch (ddev->nFormat & DISPLAY_ROW_ALIGN_MASK) { + case DISPLAY_ROW_ALIGN_DEFAULT: + align = ARCH_ALIGN_PTR_MOD; + break; + case DISPLAY_ROW_ALIGN_4: + align = 4; + break; + case DISPLAY_ROW_ALIGN_8: + align = 8; + break; + case DISPLAY_ROW_ALIGN_16: + align = 16; + break; + case DISPLAY_ROW_ALIGN_32: + align = 32; + break; + case DISPLAY_ROW_ALIGN_64: + align = 64; + break; + default: + align = 0; /* not permitted */ + } + if (align < ARCH_ALIGN_PTR_MOD) + return_error(gs_error_rangecheck); + + switch (ddev->nFormat & DISPLAY_ALPHA_MASK) { + case DISPLAY_ALPHA_FIRST: + case DISPLAY_ALPHA_LAST: + /* Not implemented and unlikely to ever be implemented + * because they would interact with linear_and_separable + */ + return_error(gs_error_rangecheck); + } + + switch (nFormat & DISPLAY_COLORS_MASK) { + case DISPLAY_COLORS_NATIVE: + switch (nFormat & DISPLAY_DEPTH_MASK) { + case DISPLAY_DEPTH_1: + /* 1bit/pixel, black is 1, white is 0 */ + set_color_info(&dci, DISPLAY_MODEL_GRAY, 1, 1, 1, 0); + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; + set_gray_color_procs(pdev, gx_b_w_gray_encode, + gx_default_b_w_map_color_rgb); + break; + case DISPLAY_DEPTH_4: + /* 4bit/pixel VGA color */ + set_color_info(&dci, DISPLAY_MODEL_RGB, 3, 4, 3, 2); + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; + set_rgb_color_procs(pdev, display_map_rgb_color_device4, + display_map_color_rgb_device4); + break; + case DISPLAY_DEPTH_8: + /* 8bit/pixel 96 color palette */ + set_color_info(&dci, DISPLAY_MODEL_RGBK, 4, 8, 31, 3); + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; + set_rgbk_color_procs(pdev, display_encode_color_device8, + display_decode_color_device8); + break; + case DISPLAY_DEPTH_16: + /* Windows 16-bit display */ + /* Is maxgray = maxcolor = 63 correct? */ + if ((ddev->nFormat & DISPLAY_555_MASK) + == DISPLAY_NATIVE_555) + set_color_info(&dci, DISPLAY_MODEL_RGB, 3, 16, 31, 31); + else + set_color_info(&dci, DISPLAY_MODEL_RGB, 3, 16, 63, 63); + set_rgb_color_procs(pdev, display_map_rgb_color_device16, + display_map_color_rgb_device16); + break; + default: + return_error(gs_error_rangecheck); + } + dci.gray_index = GX_CINFO_COMP_NO_INDEX; + break; + case DISPLAY_COLORS_GRAY: + set_color_info(&dci, DISPLAY_MODEL_GRAY, 1, bpc, maxvalue, 0); + if (bpc == 1) + set_gray_color_procs(pdev, gx_default_gray_encode, + gx_default_w_b_map_color_rgb); + else + set_gray_color_procs(pdev, gx_default_gray_encode, + gx_default_gray_map_color_rgb); + break; + case DISPLAY_COLORS_RGB: + if ((nFormat & DISPLAY_ALPHA_MASK) == DISPLAY_ALPHA_NONE) + bpp = bpc * 3; + else + bpp = bpc * 4; + set_color_info(&dci, DISPLAY_MODEL_RGB, 3, bpp, maxvalue, maxvalue); + if (((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_8) && + ((nFormat & DISPLAY_ALPHA_MASK) == DISPLAY_ALPHA_NONE)) { + if ((nFormat & DISPLAY_ENDIAN_MASK) == DISPLAY_BIGENDIAN) + set_rgb_color_procs(pdev, gx_default_rgb_map_rgb_color, + gx_default_rgb_map_color_rgb); + else + set_rgb_color_procs(pdev, display_map_rgb_color_bgr24, + display_map_color_rgb_bgr24); + } + else { + /* slower flexible functions for alpha/unused component */ + set_rgb_color_procs(pdev, display_map_rgb_color_rgb, + display_map_color_rgb_rgb); + } + break; + case DISPLAY_COLORS_CMYK: + bpp = bpc * 4; + set_color_info(&dci, DISPLAY_MODEL_CMYK, 4, bpp, maxvalue, maxvalue); + if ((nFormat & DISPLAY_ALPHA_MASK) != DISPLAY_ALPHA_NONE) + return_error(gs_error_rangecheck); + if ((nFormat & DISPLAY_ENDIAN_MASK) != DISPLAY_BIGENDIAN) + return_error(gs_error_rangecheck); + + if ((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_1) + set_cmyk_color_procs(pdev, cmyk_1bit_map_cmyk_color, + cmyk_1bit_map_color_cmyk); + else if ((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_8) + set_cmyk_color_procs(pdev, cmyk_8bit_map_cmyk_color, + cmyk_8bit_map_color_cmyk); + else + return_error(gs_error_rangecheck); + break; + case DISPLAY_COLORS_SEPARATION: + if ((nFormat & DISPLAY_ENDIAN_MASK) != DISPLAY_BIGENDIAN) + return_error(gs_error_rangecheck); + bpp = ARCH_SIZEOF_COLOR_INDEX * 8; + set_color_info(&dci, DISPLAY_MODEL_SEP, bpp/bpc, bpp, + maxvalue, maxvalue); + if ((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_8) { + ddev->devn_params.bitspercomponent = bpc; + set_color_procs(pdev, + display_separation_encode_color, + display_separation_decode_color, + display_separation_get_color_mapping_procs, + display_separation_get_color_comp_index); + } + else + return_error(gs_error_rangecheck); + break; + default: + return_error(gs_error_rangecheck); + } + + /* restore old anti_alias info */ + dci.anti_alias = ddev->color_info.anti_alias; + ddev->color_info = dci; + check_device_separable(pdev); + switch (nFormat & DISPLAY_COLORS_MASK) { + case DISPLAY_COLORS_NATIVE: + ddev->color_info.gray_index = GX_CINFO_COMP_NO_INDEX; + if ((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_1) + ddev->color_info.gray_index = 0; + else if ((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_8) + ddev->color_info.gray_index = 3; + break; + case DISPLAY_COLORS_RGB: + ddev->color_info.gray_index = GX_CINFO_COMP_NO_INDEX; + break; + case DISPLAY_COLORS_GRAY: + ddev->color_info.gray_index = 0; + break; + case DISPLAY_COLORS_CMYK: + ddev->color_info.gray_index = 3; + break; + case DISPLAY_COLORS_SEPARATION: + ddev->color_info.gray_index = GX_CINFO_COMP_NO_INDEX; + break; + } + ddev->nFormat = nFormat; + + 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 cslg_Size(GF_Box *s) +{ + GF_CompositionToDecodeBox *ptr = (GF_CompositionToDecodeBox *)s; + + ptr->size += 20; + return GF_OK; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static int perf_event_read_group(struct perf_event *event, + u64 read_format, char __user *buf) +{ + struct perf_event *leader = event->group_leader, *sub; + int n = 0, size = 0, ret = -EFAULT; + struct perf_event_context *ctx = leader->ctx; + u64 values[5]; + u64 count, enabled, running; + + mutex_lock(&ctx->mutex); + count = perf_event_read_value(leader, &enabled, &running); + + values[n++] = 1 + leader->nr_siblings; + if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) + values[n++] = enabled; + if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) + values[n++] = running; + values[n++] = count; + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(leader); + + size = n * sizeof(u64); + + if (copy_to_user(buf, values, size)) + goto unlock; + + ret = size; + + list_for_each_entry(sub, &leader->sibling_list, group_entry) { + n = 0; + + values[n++] = perf_event_read_value(sub, &enabled, &running); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(sub); + + size = n * sizeof(u64); + + if (copy_to_user(buf + ret, values, size)) { + ret = -EFAULT; + goto unlock; + } + + ret += size; + } +unlock: + mutex_unlock(&ctx->mutex); + + 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. + [int SafeMulDims(const matvar_t *matvar, size_t* nelems) +{ + int i; + + for ( i = 0; i < matvar->rank; i++ ) { + if ( !psnip_safe_size_mul(nelems, *nelems, matvar->dims[i]) ) { + *nelems = 0; + return 1; + } + } + + return 0; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void *bson_realloc( void *ptr, int size ) { + void *p; + p = bson_realloc_func( ptr, size ); + bson_fatal_msg( !!p, ""realloc() failed"" ); + return 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. + [int ha_partition::disable_indexes(uint mode) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->ha_disable_indexes(mode))) + break; + } + return error; +}] + +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 rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td, + size_t max_data_size, + const __be32 **_xdr, + unsigned int *_toklen) +{ + const __be32 *xdr = *_xdr; + unsigned int toklen = *_toklen, len; + + /* there must be at least one tag and one length word */ + if (toklen <= 8) + return -EINVAL; + + _enter("",%zu,{%x,%x},%u"", + max_data_size, ntohl(xdr[0]), ntohl(xdr[1]), toklen); + + td->tag = ntohl(*xdr++); + len = ntohl(*xdr++); + toklen -= 8; + if (len > max_data_size) + return -EINVAL; + td->data_len = len; + + if (len > 0) { + td->data = kmemdup(xdr, len, GFP_KERNEL); + if (!td->data) + return -ENOMEM; + len = (len + 3) & ~3; + toklen -= len; + xdr += len >> 2; + } + + _debug(""tag %x len %x"", td->tag, td->data_len); + + *_xdr = xdr; + *_toklen = toklen; + _leave("" = 0 [toklen=%u]"", toklen); + 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 netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct bonding *bond = netdev_priv(dev); + netdev_tx_t ret = NETDEV_TX_OK; + + /* If we risk deadlock from transmitting this in the + * netpoll path, tell netpoll to queue the frame for later tx + */ + if (unlikely(is_netpoll_tx_blocked(dev))) + return NETDEV_TX_BUSY; + + rcu_read_lock(); + if (bond_has_slaves(bond)) + ret = __bond_start_xmit(skb, dev); + else + ret = bond_tx_drop(dev, skb); + rcu_read_unlock(); + + 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. + [ecma_op_internal_buffer_update (ecma_value_t *entry_p, /**< entry pointer */ + ecma_value_t value_arg, /**< value argument */ + lit_magic_string_id_t lit_id) /**< class id */ +{ + JERRY_ASSERT (entry_p != NULL); + + if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_MAP_UL) + { + ecma_free_value_if_not_object (((ecma_container_pair_t *) entry_p)->value); + + ((ecma_container_pair_t *) entry_p)->value = ecma_copy_value_if_not_object (value_arg); + } +} /* ecma_op_internal_buffer_update */] + +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. + [ CImg& fillZ(const unsigned int x, const unsigned int y, const unsigned int c, const int a0, ...) { + const ulongT wh = (ulongT)_width*_height; + if (x<_width && y<_height && c<_spectrum) _cimg_fill1(x,y,0,c,wh,_depth,int); + return *this; + }] + +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 dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len) +{ + int i, offset; + + if (dn_len < str_len + 1) + return -1; + + /* First byte of dn will be used to store the length of the first + * label */ + offset = 0; + for (i = 0; i < str_len; ++i) { + if (str[i] == '.') { + /* 2 or more consecutive dots is invalid */ + if (i == offset) + return -1; + + dn[offset] = (i - offset); + offset = i+1; + continue; + } + dn[i+1] = str[i]; + } + dn[offset] = (i - offset - 1); + dn[i] = '\0'; + return i; +}] + +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. + [TEST_F(HttpConnectionManagerConfigTest, NormalizePathTrue) { + const std::string yaml_string = R""EOF( + stat_prefix: ingress_http + route_config: + name: local_route + normalize_path: true + http_filters: + - name: envoy.filters.http.router + )EOF""; + + EXPECT_CALL(context_.runtime_loader_.snapshot_, + featureEnabled(""http_connection_manager.normalize_path"", An())) + .Times(0); + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, + scoped_routes_config_provider_manager_, http_tracer_manager_, + filter_config_provider_manager_); + EXPECT_TRUE(config.shouldNormalizePath()); +}] + +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 bool create_db_dir(char *fnam) +{ + int ret; + char *p; + + p = alloca(strlen(fnam) + 1); + strcpy(p, fnam); + fnam = p; + p = p + 1; + +again: + while (*p && *p != '/') + p++; + if (!*p) + return true; + + *p = '\0'; + + ret = mkdir(fnam, 0755); + if (ret < 0 && errno != EEXIST) { + usernic_error(""Failed to create %s: %s\n"", fnam, + strerror(errno)); + *p = '/'; + return false; + } + *(p++) = '/'; + + goto again; +}] + +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. + [message_send_groupchat_subject(const char *const roomjid, const char *const subject) +{ + xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_stanza_t *message = stanza_create_room_subject_message(ctx, roomjid, subject); + + _send_message_stanza(message); + xmpp_stanza_release(message); +}] + +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. + [hstore_from_record(PG_FUNCTION_ARGS) +{ + HeapTupleHeader rec; + int32 buflen; + HStore *out; + Pairs *pairs; + Oid tupType; + int32 tupTypmod; + TupleDesc tupdesc; + HeapTupleData tuple; + RecordIOData *my_extra; + int ncolumns; + int i, + j; + Datum *values; + bool *nulls; + + if (PG_ARGISNULL(0)) + { + Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); + + /* + * have no tuple to look at, so the only source of type info is the + * argtype. The lookup_rowtype_tupdesc call below will error out if we + * don't have a known composite type oid here. + */ + tupType = argtype; + tupTypmod = -1; + + rec = NULL; + } + else + { + rec = PG_GETARG_HEAPTUPLEHEADER(0); + + /* Extract type info from the tuple itself */ + tupType = HeapTupleHeaderGetTypeId(rec); + tupTypmod = HeapTupleHeaderGetTypMod(rec); + } + + tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + ncolumns = tupdesc->natts; + + /* + * We arrange to look up the needed I/O info just once per series of + * calls, assuming the record type doesn't change underneath us. + */ + my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; + if (my_extra == NULL || + my_extra->ncolumns != ncolumns) + { + fcinfo->flinfo->fn_extra = + MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, + sizeof(RecordIOData) - sizeof(ColumnIOData) + + ncolumns * sizeof(ColumnIOData)); + my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; + my_extra->record_type = InvalidOid; + my_extra->record_typmod = 0; + } + + if (my_extra->record_type != tupType || + my_extra->record_typmod != tupTypmod) + { + MemSet(my_extra, 0, + sizeof(RecordIOData) - sizeof(ColumnIOData) + + ncolumns * sizeof(ColumnIOData)); + my_extra->record_type = tupType; + my_extra->record_typmod = tupTypmod; + my_extra->ncolumns = ncolumns; + } + + pairs = palloc(ncolumns * sizeof(Pairs)); + + if (rec) + { + /* Build a temporary HeapTuple control structure */ + tuple.t_len = HeapTupleHeaderGetDatumLength(rec); + ItemPointerSetInvalid(&(tuple.t_self)); + tuple.t_tableOid = InvalidOid; + tuple.t_data = rec; + + values = (Datum *) palloc(ncolumns * sizeof(Datum)); + nulls = (bool *) palloc(ncolumns * sizeof(bool)); + + /* Break down the tuple into fields */ + heap_deform_tuple(&tuple, tupdesc, values, nulls); + } + else + { + values = NULL; + nulls = NULL; + } + + for (i = 0, j = 0; i < ncolumns; ++i) + { + ColumnIOData *column_info = &my_extra->columns[i]; + Oid column_type = tupdesc->attrs[i]->atttypid; + char *value; + + /* Ignore dropped columns in datatype */ + if (tupdesc->attrs[i]->attisdropped) + continue; + + pairs[j].key = NameStr(tupdesc->attrs[i]->attname); + pairs[j].keylen = hstoreCheckKeyLen(strlen(NameStr(tupdesc->attrs[i]->attname))); + + if (!nulls || nulls[i]) + { + pairs[j].val = NULL; + pairs[j].vallen = 4; + pairs[j].isnull = true; + pairs[j].needfree = false; + ++j; + continue; + } + + /* + * Convert the column value to text + */ + if (column_info->column_type != column_type) + { + bool typIsVarlena; + + getTypeOutputInfo(column_type, + &column_info->typiofunc, + &typIsVarlena); + fmgr_info_cxt(column_info->typiofunc, &column_info->proc, + fcinfo->flinfo->fn_mcxt); + column_info->column_type = column_type; + } + + value = OutputFunctionCall(&column_info->proc, values[i]); + + pairs[j].val = value; + pairs[j].vallen = hstoreCheckValLen(strlen(value)); + pairs[j].isnull = false; + pairs[j].needfree = false; + ++j; + } + + ncolumns = hstoreUniquePairs(pairs, j, &buflen); + + out = hstorePairs(pairs, ncolumns, buflen); + + ReleaseTupleDesc(tupdesc); + + PG_RETURN_POINTER(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. + [int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + qtest_add_func(""fuzz/lsi53c895a/lsi_do_dma_empty_queue"", + test_lsi_do_dma_empty_queue); + + return g_test_run(); +}] + +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 cine_read_packet(AVFormatContext *avctx, AVPacket *pkt) +{ + CineDemuxContext *cine = avctx->priv_data; + AVStream *st = avctx->streams[0]; + AVIOContext *pb = avctx->pb; + int n, size, ret; + + if (cine->pts >= st->duration) + return AVERROR_EOF; + + avio_seek(pb, st->index_entries[cine->pts].pos, SEEK_SET); + n = avio_rl32(pb); + if (n < 8) + return AVERROR_INVALIDDATA; + avio_skip(pb, n - 8); + size = avio_rl32(pb); + + ret = av_get_packet(pb, pkt, size); + if (ret < 0) + return ret; + + pkt->pts = cine->pts++; + pkt->stream_index = 0; + pkt->flags |= AV_PKT_FLAG_KEY; + 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 int qcow2_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVQcowState *s = bs->opaque; + int len, i, ret = 0; + QCowHeader header; + QemuOpts *opts; + Error *local_err = NULL; + uint64_t ext_end; + uint64_t l1_vm_state_index; + const char *opt_overlap_check; + int overlap_check_template = 0; + + ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not read qcow2 header""); + goto fail; + } + be32_to_cpus(&header.magic); + be32_to_cpus(&header.version); + be64_to_cpus(&header.backing_file_offset); + be32_to_cpus(&header.backing_file_size); + be64_to_cpus(&header.size); + be32_to_cpus(&header.cluster_bits); + be32_to_cpus(&header.crypt_method); + be64_to_cpus(&header.l1_table_offset); + be32_to_cpus(&header.l1_size); + be64_to_cpus(&header.refcount_table_offset); + be32_to_cpus(&header.refcount_table_clusters); + be64_to_cpus(&header.snapshots_offset); + be32_to_cpus(&header.nb_snapshots); + + if (header.magic != QCOW_MAGIC) { + error_setg(errp, ""Image is not in qcow2 format""); + ret = -EINVAL; + goto fail; + } + if (header.version < 2 || header.version > 3) { + report_unsupported(bs, errp, ""QCOW version %d"", header.version); + ret = -ENOTSUP; + goto fail; + } + + s->qcow_version = header.version; + + /* Initialise cluster size */ + if (header.cluster_bits < MIN_CLUSTER_BITS || + header.cluster_bits > MAX_CLUSTER_BITS) { + error_setg(errp, ""Unsupported cluster size: 2^%i"", header.cluster_bits); + ret = -EINVAL; + goto fail; + } + + s->cluster_bits = header.cluster_bits; + s->cluster_size = 1 << s->cluster_bits; + s->cluster_sectors = 1 << (s->cluster_bits - 9); + + /* Initialise version 3 header fields */ + if (header.version == 2) { + header.incompatible_features = 0; + header.compatible_features = 0; + header.autoclear_features = 0; + header.refcount_order = 4; + header.header_length = 72; + } else { + be64_to_cpus(&header.incompatible_features); + be64_to_cpus(&header.compatible_features); + be64_to_cpus(&header.autoclear_features); + be32_to_cpus(&header.refcount_order); + be32_to_cpus(&header.header_length); + + if (header.header_length < 104) { + error_setg(errp, ""qcow2 header too short""); + ret = -EINVAL; + goto fail; + } + } + + if (header.header_length > s->cluster_size) { + error_setg(errp, ""qcow2 header exceeds cluster size""); + ret = -EINVAL; + goto fail; + } + + if (header.header_length > sizeof(header)) { + s->unknown_header_fields_size = header.header_length - sizeof(header); + s->unknown_header_fields = g_malloc(s->unknown_header_fields_size); + ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields, + s->unknown_header_fields_size); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not read unknown qcow2 header "" + ""fields""); + goto fail; + } + } + + if (header.backing_file_offset > s->cluster_size) { + error_setg(errp, ""Invalid backing file offset""); + ret = -EINVAL; + goto fail; + } + + if (header.backing_file_offset) { + ext_end = header.backing_file_offset; + } else { + ext_end = 1 << header.cluster_bits; + } + + /* Handle feature bits */ + s->incompatible_features = header.incompatible_features; + s->compatible_features = header.compatible_features; + s->autoclear_features = header.autoclear_features; + + if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) { + void *feature_table = NULL; + qcow2_read_extensions(bs, header.header_length, ext_end, + &feature_table, NULL); + report_unsupported_feature(bs, errp, feature_table, + s->incompatible_features & + ~QCOW2_INCOMPAT_MASK); + ret = -ENOTSUP; + g_free(feature_table); + goto fail; + } + + if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { + /* Corrupt images may not be written to unless they are being repaired + */ + if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) { + error_setg(errp, ""qcow2: Image is corrupt; cannot be opened "" + ""read/write""); + ret = -EACCES; + goto fail; + } + } + + /* Check support for various header values */ + if (header.refcount_order != 4) { + report_unsupported(bs, errp, ""%d bit reference counts"", + 1 << header.refcount_order); + ret = -ENOTSUP; + goto fail; + } + s->refcount_order = header.refcount_order; + + if (header.crypt_method > QCOW_CRYPT_AES) { + error_setg(errp, ""Unsupported encryption method: %i"", + header.crypt_method); + ret = -EINVAL; + goto fail; + } + s->crypt_method_header = header.crypt_method; + if (s->crypt_method_header) { + bs->encrypted = 1; + } + + s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */ + s->l2_size = 1 << s->l2_bits; + bs->total_sectors = header.size / 512; + s->csize_shift = (62 - (s->cluster_bits - 8)); + s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; + s->cluster_offset_mask = (1LL << s->csize_shift) - 1; + s->refcount_table_offset = header.refcount_table_offset; + s->refcount_table_size = + header.refcount_table_clusters << (s->cluster_bits - 3); + + s->snapshots_offset = header.snapshots_offset; + s->nb_snapshots = header.nb_snapshots; + + /* read the level 1 table */ + s->l1_size = header.l1_size; + + l1_vm_state_index = size_to_l1(s, header.size); + if (l1_vm_state_index > INT_MAX) { + error_setg(errp, ""Image is too big""); + ret = -EFBIG; + goto fail; + } + s->l1_vm_state_index = l1_vm_state_index; + + /* the L1 table must contain at least enough entries to put + header.size bytes */ + if (s->l1_size < s->l1_vm_state_index) { + error_setg(errp, ""L1 table is too small""); + ret = -EINVAL; + goto fail; + } + s->l1_table_offset = header.l1_table_offset; + if (s->l1_size > 0) { + s->l1_table = g_malloc0( + align_offset(s->l1_size * sizeof(uint64_t), 512)); + ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, + s->l1_size * sizeof(uint64_t)); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not read L1 table""); + goto fail; + } + for(i = 0;i < s->l1_size; i++) { + be64_to_cpus(&s->l1_table[i]); + } + } + + /* alloc L2 table/refcount block cache */ + s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE); + s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE); + + s->cluster_cache = g_malloc(s->cluster_size); + /* one more sector for decompressed data alignment */ + s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + + 512); + s->cluster_cache_offset = -1; + s->flags = flags; + + ret = qcow2_refcount_init(bs); + if (ret != 0) { + error_setg_errno(errp, -ret, ""Could not initialize refcount handling""); + goto fail; + } + + QLIST_INIT(&s->cluster_allocs); + QTAILQ_INIT(&s->discards); + + /* read qcow2 extensions */ + if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL, + &local_err)) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + /* read the backing file name */ + if (header.backing_file_offset != 0) { + len = header.backing_file_size; + if (len > 1023) { + len = 1023; + } + ret = bdrv_pread(bs->file, header.backing_file_offset, + bs->backing_file, len); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not read backing file name""); + goto fail; + } + bs->backing_file[len] = '\0'; + } + + ret = qcow2_read_snapshots(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not read snapshots""); + goto fail; + } + + /* Clear unknown autoclear feature bits */ + if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) { + s->autoclear_features = 0; + ret = qcow2_update_header(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not update qcow2 header""); + goto fail; + } + } + + /* Initialise locks */ + qemu_co_mutex_init(&s->lock); + + /* Repair image if dirty */ + if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only && + (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { + BdrvCheckResult result = {0}; + + ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS); + if (ret < 0) { + error_setg_errno(errp, -ret, ""Could not repair dirty image""); + goto fail; + } + } + + /* Enable lazy_refcounts according to image and command line options */ + opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + opt_overlap_check = qemu_opt_get(opts, ""overlap-check"") ?: ""cached""; + if (!strcmp(opt_overlap_check, ""none"")) { + overlap_check_template = 0; + } else if (!strcmp(opt_overlap_check, ""constant"")) { + overlap_check_template = QCOW2_OL_CONSTANT; + } else if (!strcmp(opt_overlap_check, ""cached"")) { + overlap_check_template = QCOW2_OL_CACHED; + } else if (!strcmp(opt_overlap_check, ""all"")) { + overlap_check_template = QCOW2_OL_ALL; + } else { + error_setg(errp, ""Unsupported value '%s' for qcow2 option "" + ""'overlap-check'. Allowed are either of the following: "" + ""none, constant, cached, all"", opt_overlap_check); + qemu_opts_del(opts); + ret = -EINVAL; + goto fail; + } + + s->overlap_check = 0; + for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { + /* overlap-check defines a template bitmask, but every flag may be + * overwritten through the associated boolean option */ + s->overlap_check |= + qemu_opt_get_bool(opts, overlap_bool_option_names[i], + overlap_check_template & (1 << i)) << i; + } + + qemu_opts_del(opts); + + if (s->use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, ""Lazy refcounts require a qcow2 image with at least "" + ""qemu 1.1 compatibility level""); + ret = -EINVAL; + goto fail; + } + +#ifdef DEBUG_ALLOC + { + BdrvCheckResult result = {0}; + qcow2_check_refcounts(bs, &result, 0); + } +#endif + return ret; + + fail: + g_free(s->unknown_header_fields); + cleanup_unknown_header_ext(bs); + qcow2_free_snapshots(bs); + qcow2_refcount_close(bs); + g_free(s->l1_table); + /* else pre-write overlap checks in cache_destroy may crash */ + s->l1_table = NULL; + if (s->l2_table_cache) { + qcow2_cache_destroy(bs, s->l2_table_cache); + } + if (s->refcount_block_cache) { + qcow2_cache_destroy(bs, s->refcount_block_cache); + } + g_free(s->cluster_cache); + qemu_vfree(s->cluster_data); + 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 int i740fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) +{ + switch (var->bits_per_pixel) { + case 8: + var->red.offset = var->green.offset = var->blue.offset = 0; + var->red.length = var->green.length = var->blue.length = 8; + break; + case 16: + switch (var->green.length) { + default: + case 5: + var->red.offset = 10; + var->green.offset = 5; + var->blue.offset = 0; + var->red.length = 5; + var->green.length = 5; + var->blue.length = 5; + break; + case 6: + var->red.offset = 11; + var->green.offset = 5; + var->blue.offset = 0; + var->red.length = var->blue.length = 5; + break; + } + break; + case 24: + var->red.offset = 16; + var->green.offset = 8; + var->blue.offset = 0; + var->red.length = var->green.length = var->blue.length = 8; + break; + case 32: + var->transp.offset = 24; + var->red.offset = 16; + var->green.offset = 8; + var->blue.offset = 0; + var->transp.length = 8; + var->red.length = var->green.length = var->blue.length = 8; + break; + default: + return -EINVAL; + } + + if (var->xres > var->xres_virtual) + var->xres_virtual = var->xres; + + if (var->yres > var->yres_virtual) + var->yres_virtual = var->yres; + + if (info->monspecs.hfmax && info->monspecs.vfmax && + info->monspecs.dclkmax && fb_validate_mode(var, info) < 0) + return -EINVAL; + + 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. + [ Event_creation_ctx(CHARSET_INFO *client_cs, + CHARSET_INFO *connection_cl, + CHARSET_INFO *db_cl) + : Stored_program_creation_ctx(client_cs, connection_cl, db_cl) + { }] + +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. + [ip_do_one_event(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return lib_do_one_event_core(argc, argv, self, 0); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) { + URI_FUNC(FreeUriMembersMm)(uri, 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. + [SetWALFileNameForCleanup(void) +{ + uint32 tli = 1, + log = 0, + seg = 0; + uint32 log_diff = 0, + seg_diff = 0; + bool cleanup = false; + + if (restartWALFileName) + { + /* + * Don't do cleanup if the restartWALFileName provided is later than + * the xlog file requested. This is an error and we must not remove + * these files from archive. This shouldn't happen, but better safe + * than sorry. + */ + if (strcmp(restartWALFileName, nextWALFileName) > 0) + return false; + + strcpy(exclusiveCleanupFileName, restartWALFileName); + return true; + } + + if (keepfiles > 0) + { + sscanf(nextWALFileName, ""%08X%08X%08X"", &tli, &log, &seg); + if (tli > 0 && seg > 0) + { + log_diff = keepfiles / MaxSegmentsPerLogFile; + seg_diff = keepfiles % MaxSegmentsPerLogFile; + if (seg_diff > seg) + { + log_diff++; + seg = MaxSegmentsPerLogFile - (seg_diff - seg); + } + else + seg -= seg_diff; + + if (log >= log_diff) + { + log -= log_diff; + cleanup = true; + } + else + { + log = 0; + seg = 0; + } + } + } + + XLogFileName(exclusiveCleanupFileName, tli, log, seg); + + return cleanup; +}] + +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. + [ //! Erode the image by a square structuring element of specified size \newinstance. + CImg get_erode(const unsigned int s) const { + return (+*this).erode(s);] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static void cirrus_bitblt_rop_nop(CirrusVGAState *s, + uint32_t dstaddr, const uint8_t *src, + int dstpitch,int srcpitch, + int bltwidth,int bltheight) +{ +}] + +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_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in) +{ + jpc_ppm_t *ppm = &ms->parms.ppm; + + /* Eliminate compiler warning about unused variables. */ + cstate = 0; + + ppm->data = 0; + + if (ms->len < 1) { + goto error; + } + if (jpc_getuint8(in, &ppm->ind)) { + goto error; + } + + ppm->len = ms->len - 1; + if (ppm->len > 0) { + if (!(ppm->data = jas_malloc(ppm->len))) { + goto error; + } + if (JAS_CAST(jas_uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) { + goto error; + } + } else { + ppm->data = 0; + } + return 0; + +error: + jpc_ppm_destroyparms(ms); + return -1; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [TEST_P(ProxyProtocolTest, V2Fragmented3Error) { + // A well-formed ipv4/tcp header, delivering all of the signature +1, w/ an error + // simulated in recv() on the +1 + constexpr uint8_t buffer[] = {0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, + 0x54, 0x0a, 0x21, 0x11, 0x00, 0x0c, 0x01, 0x02, 0x03, 0x04, + 0x00, 0x01, 0x01, 0x02, 0x03, 0x05, 0x00, 0x02, 'm', 'o', + 'r', 'e', ' ', 'd', 'a', 't', 'a'}; + + Api::MockOsSysCalls os_sys_calls; + TestThreadsafeSingletonInjector os_calls(&os_sys_calls); + + EXPECT_CALL(os_sys_calls, recv(_, _, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke([this](os_fd_t fd, void* buf, size_t len, int flags) { + return os_sys_calls_actual_.recv(fd, buf, len, flags); + })); + EXPECT_CALL(os_sys_calls, recv(_, _, 1, _)) + .Times(AnyNumber()) + .WillOnce(Return(Api::SysCallSizeResult{-1, 0})); + EXPECT_CALL(os_sys_calls, connect(_, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke([this](os_fd_t sockfd, const sockaddr* addr, socklen_t addrlen) { + return os_sys_calls_actual_.connect(sockfd, addr, addrlen); + })); + EXPECT_CALL(os_sys_calls, ioctl(_, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke([this](os_fd_t fd, unsigned long int request, void* argp) { + return os_sys_calls_actual_.ioctl(fd, request, argp); + })); + EXPECT_CALL(os_sys_calls, writev(_, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke([this](os_fd_t fd, const iovec* iov, int iovcnt) { + return os_sys_calls_actual_.writev(fd, iov, iovcnt); + })); + EXPECT_CALL(os_sys_calls, readv(_, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke([this](os_fd_t fd, const iovec* iov, int iovcnt) { + return os_sys_calls_actual_.readv(fd, iov, iovcnt); + })); + EXPECT_CALL(os_sys_calls, getsockopt_(_, _, _, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke( + [this](os_fd_t sockfd, int level, int optname, void* optval, socklen_t* optlen) -> int { + return os_sys_calls_actual_.getsockopt(sockfd, level, optname, optval, optlen).rc_; + })); + EXPECT_CALL(os_sys_calls, getsockname(_, _, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke( + [this](os_fd_t sockfd, sockaddr* name, socklen_t* namelen) -> Api::SysCallIntResult { + return os_sys_calls_actual_.getsockname(sockfd, name, namelen); + })); + EXPECT_CALL(os_sys_calls, shutdown(_, _)) + .Times(AnyNumber()) + .WillRepeatedly(Invoke( + [this](os_fd_t sockfd, int how) { return os_sys_calls_actual_.shutdown(sockfd, how); })); + EXPECT_CALL(os_sys_calls, close(_)).Times(AnyNumber()).WillRepeatedly(Invoke([this](os_fd_t fd) { + return os_sys_calls_actual_.close(fd); + })); + connect(false); + write(buffer, 17); + + expectProxyProtoError(); +}] + +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 send_client_reply_packet(MCPVIO_EXT *mpvio, + const uchar *data, int data_len) +{ + MYSQL *mysql= mpvio->mysql; + NET *net= &mysql->net; + char *buff, *end; + size_t buff_size; + size_t connect_attrs_len= + (mysql->server_capabilities & CLIENT_CONNECT_ATTRS && + mysql->options.extension) ? + mysql->options.extension->connection_attributes_length : 0; + + DBUG_ASSERT(connect_attrs_len < MAX_CONNECTION_ATTR_STORAGE_LENGTH); + + + /* + see end= buff+32 below, fixed size of the packet is 32 bytes. + +9 because data is a length encoded binary where meta data size is max 9. + */ + buff_size= 33 + USERNAME_LENGTH + data_len + 9 + NAME_LEN + NAME_LEN + connect_attrs_len + 9; + buff= my_alloca(buff_size); + + mysql->client_flag|= mysql->options.client_flag; + mysql->client_flag|= CLIENT_CAPABILITIES; + + if (mysql->client_flag & CLIENT_MULTI_STATEMENTS) + mysql->client_flag|= CLIENT_MULTI_RESULTS; + +#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) + if (mysql->options.ssl_key || mysql->options.ssl_cert || + mysql->options.ssl_ca || mysql->options.ssl_capath || + mysql->options.ssl_cipher || + (mysql->options.extension && mysql->options.extension->ssl_crl) || + (mysql->options.extension && mysql->options.extension->ssl_crlpath)) + mysql->options.use_ssl= 1; + if (mysql->options.use_ssl) + mysql->client_flag|= CLIENT_SSL; +#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY*/ + if (mpvio->db) + mysql->client_flag|= CLIENT_CONNECT_WITH_DB; + else + mysql->client_flag&= ~CLIENT_CONNECT_WITH_DB; + + /* Remove options that server doesn't support */ + mysql->client_flag= mysql->client_flag & + (~(CLIENT_COMPRESS | CLIENT_SSL | CLIENT_PROTOCOL_41) + | mysql->server_capabilities); + +#ifndef HAVE_COMPRESS + mysql->client_flag&= ~CLIENT_COMPRESS; +#endif + + if (mysql->client_flag & CLIENT_PROTOCOL_41) + { + /* 4.1 server and 4.1 client has a 32 byte option flag */ + int4store(buff,mysql->client_flag); + int4store(buff+4, net->max_packet_size); + buff[8]= (char) mysql->charset->number; + memset(buff+9, 0, 32-9); + end= buff+32; + } + else + { + int2store(buff, mysql->client_flag); + int3store(buff+2, net->max_packet_size); + end= buff+5; + } +#ifdef HAVE_OPENSSL + if (mysql->client_flag & CLIENT_SSL) + { + /* Do the SSL layering. */ + struct st_mysql_options *options= &mysql->options; + struct st_VioSSLFd *ssl_fd; + enum enum_ssl_init_error ssl_init_error; + const char *cert_error; + unsigned long ssl_error; + + /* + Send mysql->client_flag, max_packet_size - unencrypted otherwise + the server does not know we want to do SSL + */ + if (my_net_write(net, (uchar*)buff, (size_t) (end-buff)) || net_flush(net)) + { + set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate, + ER(CR_SERVER_LOST_EXTENDED), + ""sending connection information to server"", + errno); + goto error; + } + + /* Create the VioSSLConnectorFd - init SSL and load certs */ + if (!(ssl_fd= new_VioSSLConnectorFd(options->ssl_key, + options->ssl_cert, + options->ssl_ca, + options->ssl_capath, + options->ssl_cipher, + &ssl_init_error, + options->extension ? + options->extension->ssl_crl : NULL, + options->extension ? + options->extension->ssl_crlpath : NULL))) + { + set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate, + ER(CR_SSL_CONNECTION_ERROR), sslGetErrString(ssl_init_error)); + goto error; + } + mysql->connector_fd= (unsigned char *) ssl_fd; + + /* Connect to the server */ + DBUG_PRINT(""info"", (""IO layer change in progress..."")); + if (sslconnect(ssl_fd, net->vio, + (long) (mysql->options.connect_timeout), &ssl_error)) + { + char buf[512]; + ERR_error_string_n(ssl_error, buf, 512); + buf[511]= 0; + set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate, + ER(CR_SSL_CONNECTION_ERROR), + buf); + goto error; + } + DBUG_PRINT(""info"", (""IO layer change done!"")); + + /* Verify server cert */ + if ((mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) && + ssl_verify_server_cert(net->vio, mysql->host, &cert_error)) + { + set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate, + ER(CR_SSL_CONNECTION_ERROR), cert_error); + goto error; + } + } +#endif /* HAVE_OPENSSL */ + + DBUG_PRINT(""info"",(""Server version = '%s' capabilites: %lu status: %u client_flag: %lu"", + mysql->server_version, mysql->server_capabilities, + mysql->server_status, mysql->client_flag)); + + compile_time_assert(MYSQL_USERNAME_LENGTH == USERNAME_LENGTH); + + /* This needs to be changed as it's not useful with big packets */ + if (mysql->user[0]) + strmake(end, mysql->user, USERNAME_LENGTH); + else + read_user_name(end); + + /* We have to handle different version of handshake here */ + DBUG_PRINT(""info"",(""user: %s"",end)); + end= strend(end) + 1; + if (data_len) + { + if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + /* + Since the older versions of server do not have + CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA capability, + a check is performed on this before sending auth data. + If lenenc support is not available, the data is sent + in the format of first byte representing the length of + the string followed by the actual string. + */ + if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA) + end= write_length_encoded_string4(end, (char *)(buff + buff_size), + (char *) data, + (char *)(data + data_len)); + else + end= write_string(end, (char *)(buff + buff_size), + (char *) data, + (char *)(data + data_len)); + if (end == NULL) + goto error; + } + else + { + DBUG_ASSERT(data_len == SCRAMBLE_LENGTH_323 + 1); /* incl. \0 at the end */ + memcpy(end, data, data_len); + end+= data_len; + } + } + else + *end++= 0; + + /* Add database if needed */ + if (mpvio->db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) + { + end= strmake(end, mpvio->db, NAME_LEN) + 1; + mysql->db= my_strdup(mpvio->db, MYF(MY_WME)); + } + + if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH) + end= strmake(end, mpvio->plugin->name, NAME_LEN) + 1; + + end= (char *) send_client_connect_attrs(mysql, (uchar *) end); + + /* Write authentication package */ + if (my_net_write(net, (uchar*) buff, (size_t) (end-buff)) || net_flush(net)) + { + set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate, + ER(CR_SERVER_LOST_EXTENDED), + ""sending authentication information"", + errno); + goto error; + } + my_afree(buff); + return 0; + +error: + my_afree(buff); + 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 cil_print_recursive_blockinherit(struct cil_tree_node *bi_node, struct cil_tree_node *terminating_node) +{ + struct cil_list *trace = NULL; + struct cil_list_item *item = NULL; + struct cil_tree_node *curr = NULL; + + cil_list_init(&trace, CIL_NODE); + + for (curr = bi_node; curr != terminating_node; curr = curr->parent) { + if (curr->flavor == CIL_BLOCK) { + cil_list_prepend(trace, CIL_NODE, curr); + } else if (curr->flavor == CIL_BLOCKINHERIT) { + if (curr != bi_node) { + cil_list_prepend(trace, CIL_NODE, NODE(((struct cil_blockinherit *)curr->data)->block)); + } + cil_list_prepend(trace, CIL_NODE, curr); + } else { + cil_list_prepend(trace, CIL_NODE, curr); + } + } + cil_list_prepend(trace, CIL_NODE, terminating_node); + + cil_list_for_each(item, trace) { + curr = item->data; + if (curr->flavor == CIL_BLOCK) { + cil_tree_log(curr, CIL_ERR, ""block %s"", DATUM(curr->data)->name); + } else if (curr->flavor == CIL_BLOCKINHERIT) { + cil_tree_log(curr, CIL_ERR, ""blockinherit %s"", ((struct cil_blockinherit *)curr->data)->block_str); + } else if (curr->flavor == CIL_OPTIONAL) { + cil_tree_log(curr, CIL_ERR, ""optional %s"", DATUM(curr->data)->name); + } else { + cil_tree_log(curr, CIL_ERR, ""%s"", cil_node_to_string(curr)); + } + } + + cil_list_destroy(&trace, CIL_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 inline __u32 inotify_arg_to_mask(u32 arg) +{ + __u32 mask; + + /* + * everything should accept their own ignored, cares about children, + * and should receive events when the inode is unmounted + */ + mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD | FS_UNMOUNT); + + /* mask off the flags used to open the fd */ + mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK)); + + return mask; +}] + +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. + [png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, + png_uint_32 num_pal) +{ + png_uint_32 i; + png_const_colorp pal_ptr; + png_byte buf[3]; + + png_debug(1, ""in png_write_PLTE""); + + if (( +#ifdef PNG_MNG_FEATURES_SUPPORTED + (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 && +#endif + num_pal == 0) || num_pal > 256) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, ""Invalid number of colors in palette""); + } + + else + { + png_warning(png_ptr, ""Invalid number of colors in palette""); + return; + } + } + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) + { + png_warning(png_ptr, + ""Ignoring request to write a PLTE chunk in grayscale PNG""); + + return; + } + + png_ptr->num_palette = (png_uint_16)num_pal; + png_debug1(3, ""num_palette = %d"", png_ptr->num_palette); + + png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); +#ifdef PNG_POINTER_INDEXING_SUPPORTED + + for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) + { + buf[0] = pal_ptr->red; + buf[1] = pal_ptr->green; + buf[2] = pal_ptr->blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } + +#else + /* This is a little slower but some buggy compilers need to do this + * instead + */ + pal_ptr=palette; + + for (i = 0; i < num_pal; i++) + { + buf[0] = pal_ptr[i].red; + buf[1] = pal_ptr[i].green; + buf[2] = pal_ptr[i].blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } + +#endif + png_write_chunk_end(png_ptr); + png_ptr->mode |= PNG_HAVE_PLTE; +}] + +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 rtecp_logout(sc_card_t *card) +{ + sc_apdu_t apdu; + int r; + + assert(card && card->ctx); + sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x40, 0, 0); + apdu.cla = 0x80; + r = sc_transmit_apdu(card, &apdu); + SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""APDU transmit failed""); + r = sc_check_sw(card, apdu.sw1, apdu.sw2); + SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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. + [void rundebug() + { + }] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void CLASS bad_pixels (const char *cfname) +{ + FILE *fp=NULL; +#ifndef LIBRAW_LIBRARY_BUILD + char *fname, *cp, line[128]; + int len, time, row, col, r, c, rad, tot, n, fixed=0; +#else + char *cp, line[128]; + int time, row, col, r, c, rad, tot, n; +#ifdef DCRAW_VERBOSE + int fixed = 0; +#endif +#endif + + if (!filters) return; +#ifdef LIBRAW_LIBRARY_BUILD + RUN_CALLBACK(LIBRAW_PROGRESS_BAD_PIXELS,0,2); +#endif + if (cfname) + fp = fopen (cfname, ""r""); +#line 4151 ""dcraw/dcraw.c"" + if (!fp) + { +#ifdef LIBRAW_LIBRARY_BUILD + imgdata.process_warnings |= LIBRAW_WARN_NO_BADPIXELMAP; +#endif + return; + } + while (fgets (line, 128, fp)) { + cp = strchr (line, '#'); + if (cp) *cp = 0; + if (sscanf (line, ""%d %d %d"", &col, &row, &time) != 3) continue; + if ((unsigned) col >= width || (unsigned) row >= height) continue; + if (time > timestamp) continue; + for (tot=n=0, rad=1; rad < 3 && n==0; rad++) + for (r = row-rad; r <= row+rad; r++) + for (c = col-rad; c <= col+rad; c++) + if ((unsigned) r < height && (unsigned) c < width && + (r != row || c != col) && fcol(r,c) == fcol(row,col)) { + tot += BAYER2(r,c); + n++; + } + BAYER2(row,col) = tot/n; +#ifdef DCRAW_VERBOSE + if (verbose) { + if (!fixed++) + fprintf (stderr,_(""Fixed dead pixels at:"")); + fprintf (stderr, "" %d,%d"", col, row); + } +#endif + } +#ifdef DCRAW_VERBOSE + if (fixed) fputc ('\n', stderr); +#endif + fclose (fp); +#ifdef LIBRAW_LIBRARY_BUILD + RUN_CALLBACK(LIBRAW_PROGRESS_BAD_PIXELS,1,2); +#endif +}] + +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 uint32_t _ring_fwd_done(pmixp_coll_ring_ctx_t *coll_ctx) +{ + return !(coll_ctx->coll->peers_cnt - coll_ctx->forward_cnt - 1); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void Transform::interpolate_nearestneighbour( RawTile& in, unsigned int resampled_width, unsigned int resampled_height ){ + + // Pointer to input buffer + unsigned char *input = (unsigned char*) in.data; + + int channels = in.channels; + unsigned int width = in.width; + unsigned int height = in.height; + + // Pointer to output buffer + unsigned char *output; + + // Create new buffer if size is larger than input size + bool new_buffer = false; + if( resampled_width*resampled_height > in.width*in.height ){ + new_buffer = true; + output = new unsigned char[(unsigned long long)resampled_width*resampled_height*in.channels]; + } + else output = (unsigned char*) in.data; + + // Calculate our scale + float xscale = (float)width / (float)resampled_width; + float yscale = (float)height / (float)resampled_height; + + for( unsigned int j=0; jstream) { + g_fprintf(so->stream, ""? %s\n"", 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. + [void exit_thread(void) +{ + discard_lazy_cpu_state(); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource, + struct rlimit __user *, rlim) +{ + struct rlimit x; + if (resource >= RLIM_NLIMITS) + return -EINVAL; + + task_lock(current->group_leader); + x = current->signal->rlim[resource]; + task_unlock(current->group_leader); + if (x.rlim_cur > 0x7FFFFFFF) + x.rlim_cur = 0x7FFFFFFF; + if (x.rlim_max > 0x7FFFFFFF) + x.rlim_max = 0x7FFFFFFF; + return copy_to_user(rlim, &x, sizeof(x))?-EFAULT: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. + [ absl::string_view pathAndQueryParams() const { return path_and_query_params_; }] + +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(imagefill) +{ + zval *IM; + long x, y, col; + gdImagePtr im; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""rlll"", &IM, &x, &y, &col) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, ""Image"", le_gd); + gdImageFill(im, x, y, col); + RETURN_TRUE; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out) +{ + char *s, *t; + size_t l; + + if (!in || !out || !(in->data)) { + return -1; + } + + out->data = (uint8_t *)ldb_casefold(ldb, mem_ctx, (const char *)(in->data), in->length); + if (out->data == NULL) { + ldb_debug(ldb, LDB_DEBUG_ERROR, ""ldb_handler_fold: unable to casefold string [%.*s]"", (int)in->length, (const char *)in->data); + return -1; + } + + s = (char *)(out->data); + + /* remove trailing spaces if any */ + l = strlen(s); + while (l > 0 && s[l - 1] == ' ') l--; + s[l] = '\0'; + + /* remove leading spaces if any */ + if (*s == ' ') { + for (t = s; *s == ' '; s++) ; + + /* remove leading spaces by moving down the string */ + memmove(t, s, l); + + s = t; + } + + /* check middle spaces */ + while ((t = strchr(s, ' ')) != NULL) { + for (s = t; *s == ' '; s++) ; + + if ((s - t) > 1) { + l = strlen(s); + + /* remove all spaces but one by moving down the string */ + memmove(t + 1, s, l); + } + } + + out->length = strlen((char *)out->data); + 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. + [TEST_F(RouterTest, AppendCluster1) { + testAppendCluster(absl::make_optional(Http::LowerCaseString(""x-custom-cluster""))); +}] + +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 RGWListBucket::parse_max_keys() +{ + // Bound max value of max-keys to configured value for security + // Bound min value of max-keys to '0' + // Some S3 clients explicitly send max-keys=0 to detect if the bucket is + // empty without listing any items. + op_ret = parse_value_and_bound(max_keys, &max, 0, g_conf()->rgw_max_listing_results, default_max); +}] + +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 __netdev_adjacent_dev_unlink(struct net_device *dev, + struct net_device *upper_dev) +{ + __netdev_adjacent_dev_unlink_lists(dev, upper_dev, + &dev->all_adj_list.upper, + &upper_dev->all_adj_list.lower);] + +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. + [ std::uint32_t calculate_segment_size(std::uint32_t size) override + { + return size; + }] + +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 X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) + { + if (!alg) + return 0; + if (ptype != V_ASN1_UNDEF) + { + if (alg->parameter == NULL) + alg->parameter = ASN1_TYPE_new(); + if (alg->parameter == NULL) + return 0; + } + if (alg) + { + if (alg->algorithm) + ASN1_OBJECT_free(alg->algorithm); + alg->algorithm = aobj; + } + if (ptype == 0) + return 1; + if (ptype == V_ASN1_UNDEF) + { + if (alg->parameter) + { + ASN1_TYPE_free(alg->parameter); + alg->parameter = NULL; + } + } + else + ASN1_TYPE_set(alg->parameter, ptype, pval); + return 1; + }] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int sqfs_size(const char *filename, loff_t *size) +{ + struct squashfs_super_block *sblk = ctxt.sblk; + struct squashfs_symlink_inode *symlink; + struct fs_dir_stream *dirsp = NULL; + struct squashfs_base_inode *base; + struct squashfs_dir_stream *dirs; + struct squashfs_lreg_inode *lreg; + struct squashfs_reg_inode *reg; + char *dir, *file, *resolved; + struct fs_dirent *dent; + unsigned char *ipos; + int ret, i_number; + + sqfs_split_path(&file, &dir, filename); + /* + * sqfs_opendir will uncompress inode and directory tables, and will + * return a pointer to the directory that contains the requested file. + */ + ret = sqfs_opendir(dir, &dirsp); + if (ret) { + ret = -EINVAL; + goto free_strings; + } + + dirs = (struct squashfs_dir_stream *)dirsp; + + while (!sqfs_readdir(dirsp, &dent)) { + ret = strcmp(dent->name, file); + if (!ret) + break; + free(dirs->entry); + dirs->entry = NULL; + } + + if (ret) { + printf(""File not found.\n""); + *size = 0; + ret = -EINVAL; + goto free_strings; + } + + i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset; + ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes, + sblk->block_size); + free(dirs->entry); + dirs->entry = NULL; + + base = (struct squashfs_base_inode *)ipos; + switch (get_unaligned_le16(&base->inode_type)) { + case SQFS_REG_TYPE: + reg = (struct squashfs_reg_inode *)ipos; + *size = get_unaligned_le32(®->file_size); + break; + case SQFS_LREG_TYPE: + lreg = (struct squashfs_lreg_inode *)ipos; + *size = get_unaligned_le64(&lreg->file_size); + break; + case SQFS_SYMLINK_TYPE: + case SQFS_LSYMLINK_TYPE: + symlink = (struct squashfs_symlink_inode *)ipos; + resolved = sqfs_resolve_symlink(symlink, filename); + ret = sqfs_size(resolved, size); + free(resolved); + break; + case SQFS_BLKDEV_TYPE: + case SQFS_CHRDEV_TYPE: + case SQFS_LBLKDEV_TYPE: + case SQFS_LCHRDEV_TYPE: + case SQFS_FIFO_TYPE: + case SQFS_SOCKET_TYPE: + case SQFS_LFIFO_TYPE: + case SQFS_LSOCKET_TYPE: + default: + printf(""Unable to recover entry's size.\n""); + *size = 0; + ret = -EINVAL; + break; + } + +free_strings: + free(dir); + free(file); + + sqfs_closedir(dirsp); + + 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. + [rfbTightExtensionClientClose(rfbClientPtr cl, void* data) { + + if(data != NULL) + free(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. + [_PUBLIC_ enum ndr_err_code ndr_pull_dns_txt_record(struct ndr_pull *ndr, int ndr_flags, struct dns_txt_record *r) +{ + NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + if (ndr_flags & NDR_SCALARS) { + enum ndr_err_code ndr_err; + uint32_t data_size = ndr->data_size; + uint32_t record_size = 0; + ndr_err = ndr_token_retrieve(&ndr->array_size_list, r, + &record_size); + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + NDR_PULL_NEED_BYTES(ndr, record_size); + ndr->data_size = ndr->offset + record_size; + } + NDR_CHECK(ndr_pull_align(ndr, 1)); + NDR_CHECK(ndr_pull_dnsp_string_list(ndr, NDR_SCALARS, &r->txt)); + NDR_CHECK(ndr_pull_trailer_align(ndr, 1)); + ndr->data_size = data_size; + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + u32 ar; + + if (vmx->rmode.vm86_active && seg != VCPU_SREG_LDTR) { + *var = vmx->rmode.segs[seg]; + if (seg == VCPU_SREG_TR + || var->selector == vmx_read_guest_seg_selector(vmx, seg)) + return; + var->base = vmx_read_guest_seg_base(vmx, seg); + var->selector = vmx_read_guest_seg_selector(vmx, seg); + return; + } + var->base = vmx_read_guest_seg_base(vmx, seg); + var->limit = vmx_read_guest_seg_limit(vmx, seg); + var->selector = vmx_read_guest_seg_selector(vmx, seg); + ar = vmx_read_guest_seg_ar(vmx, seg); + var->unusable = (ar >> 16) & 1; + var->type = ar & 15; + var->s = (ar >> 4) & 1; + var->dpl = (ar >> 5) & 3; + /* + * Some userspaces do not preserve unusable property. Since usable + * segment has to be present according to VMX spec we can use present + * property to amend userspace bug by making unusable segment always + * nonpresent. vmx_segment_access_rights() already marks nonpresent + * segment as unusable. + */ + var->present = !var->unusable; + var->avl = (ar >> 12) & 1; + var->l = (ar >> 13) & 1; + var->db = (ar >> 14) & 1; + var->g = (ar >> 15) & 1; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [cookedprint( + int datatype, + int length, + const char *data, + int status, + int quiet, + FILE *fp + ) +{ + char *name; + char *value; + char output_raw; + int fmt; + l_fp lfp; + sockaddr_u hval; + u_long uval; + int narr; + size_t len; + l_fp lfparr[8]; + char b[12]; + char bn[2 * MAXVARLEN]; + char bv[2 * MAXVALLEN]; + + UNUSED_ARG(datatype); + + if (!quiet) + fprintf(fp, ""status=%04x %s,\n"", status, + statustoa(datatype, status)); + + startoutput(); + while (nextvar(&length, &data, &name, &value)) { + fmt = varfmt(name); + output_raw = 0; + switch (fmt) { + + case PADDING: + output_raw = '*'; + break; + + case TS: + if (!decodets(value, &lfp)) + output_raw = '?'; + else + output(fp, name, prettydate(&lfp)); + break; + + case HA: /* fallthru */ + case NA: + if (!decodenetnum(value, &hval)) { + output_raw = '?'; + } else if (fmt == HA){ + output(fp, name, nntohost(&hval)); + } else { + output(fp, name, stoa(&hval)); + } + break; + + case RF: + if (decodenetnum(value, &hval)) { + if (ISREFCLOCKADR(&hval)) + output(fp, name, + refnumtoa(&hval)); + else + output(fp, name, stoa(&hval)); + } else if (strlen(value) <= 4) { + output(fp, name, value); + } else { + output_raw = '?'; + } + break; + + case LP: + if (!decodeuint(value, &uval) || uval > 3) { + output_raw = '?'; + } else { + b[0] = (0x2 & uval) + ? '1' + : '0'; + b[1] = (0x1 & uval) + ? '1' + : '0'; + b[2] = '\0'; + output(fp, name, b); + } + break; + + case OC: + if (!decodeuint(value, &uval)) { + output_raw = '?'; + } else { + snprintf(b, sizeof(b), ""%03lo"", uval); + output(fp, name, b); + } + break; + + case AR: + if (!decodearr(value, &narr, lfparr)) + output_raw = '?'; + else + outputarr(fp, name, narr, lfparr); + break; + + case FX: + if (!decodeuint(value, &uval)) + output_raw = '?'; + else + output(fp, name, tstflags(uval)); + break; + + default: + fprintf(stderr, ""Internal error in cookedprint, %s=%s, fmt %d\n"", + name, value, fmt); + output_raw = '?'; + break; + } + + if (output_raw != 0) { + atoascii(name, MAXVARLEN, bn, sizeof(bn)); + atoascii(value, MAXVALLEN, bv, sizeof(bv)); + if (output_raw != '*') { + len = strlen(bv); + bv[len] = output_raw; + bv[len+1] = '\0'; + } + output(fp, bn, bv); + } + } + endoutput(fp); +}] + +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 Image *ReadICONImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + IconFile + icon_file; + + IconInfo + icon_info; + + Image + *image; + + MagickBooleanType + status; + + register ssize_t + i, + x; + + register Quantum + *q; + + register unsigned char + *p; + + size_t + bit, + byte, + bytes_per_line, + one, + scanline_pad; + + ssize_t + count, + offset, + y; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%s"",image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + icon_file.reserved=(short) ReadBlobLSBShort(image); + icon_file.resource_type=(short) ReadBlobLSBShort(image); + icon_file.count=(short) ReadBlobLSBShort(image); + if ((icon_file.reserved != 0) || + ((icon_file.resource_type != 1) && (icon_file.resource_type != 2)) || + (icon_file.count > MaxIcons)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + for (i=0; i < icon_file.count; i++) + { + icon_file.directory[i].width=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].height=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].colors=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].reserved=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].planes=(unsigned short) ReadBlobLSBShort(image); + icon_file.directory[i].bits_per_pixel=(unsigned short) + ReadBlobLSBShort(image); + icon_file.directory[i].size=ReadBlobLSBLong(image); + icon_file.directory[i].offset=ReadBlobLSBLong(image); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + } + one=1; + for (i=0; i < icon_file.count; i++) + { + /* + Verify Icon identifier. + */ + offset=(ssize_t) SeekBlob(image,(MagickOffsetType) + icon_file.directory[i].offset,SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.size=ReadBlobLSBLong(image); + icon_info.width=(unsigned char) ((int) ReadBlobLSBLong(image)); + icon_info.height=(unsigned char) ((int) ReadBlobLSBLong(image)/2); + icon_info.planes=ReadBlobLSBShort(image); + icon_info.bits_per_pixel=ReadBlobLSBShort(image); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + if (((icon_info.planes == 18505) && (icon_info.bits_per_pixel == 21060)) || + (icon_info.size == 0x474e5089)) + { + Image + *icon_image; + + ImageInfo + *read_info; + + size_t + length; + + unsigned char + *png; + + /* + Icon image encoded as a compressed PNG image. + */ + length=icon_file.directory[i].size; + png=(unsigned char *) AcquireQuantumMemory(length+16,sizeof(*png)); + if (png == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + (void) CopyMagickMemory(png,""\211PNG\r\n\032\n\000\000\000\015"",12); + png[12]=(unsigned char) icon_info.planes; + png[13]=(unsigned char) (icon_info.planes >> 8); + png[14]=(unsigned char) icon_info.bits_per_pixel; + png[15]=(unsigned char) (icon_info.bits_per_pixel >> 8); + count=ReadBlob(image,length-16,png+16); + icon_image=(Image *) NULL; + if (count > 0) + { + read_info=CloneImageInfo(image_info); + (void) CopyMagickString(read_info->magick,""PNG"",MagickPathExtent); + icon_image=BlobToImage(read_info,png,length+16,exception); + read_info=DestroyImageInfo(read_info); + } + png=(unsigned char *) RelinquishMagickMemory(png); + if (icon_image == (Image *) NULL) + { + if (count != (ssize_t) (length-16)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + image=DestroyImageList(image); + return((Image *) NULL); + } + DestroyBlob(icon_image); + icon_image->blob=ReferenceBlob(image->blob); + ReplaceImageInList(&image,icon_image); + } + else + { + if (icon_info.bits_per_pixel > 32) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.compression=ReadBlobLSBLong(image); + icon_info.image_size=ReadBlobLSBLong(image); + icon_info.x_pixels=ReadBlobLSBLong(image); + icon_info.y_pixels=ReadBlobLSBLong(image); + icon_info.number_colors=ReadBlobLSBLong(image); + icon_info.colors_important=ReadBlobLSBLong(image); + image->alpha_trait=BlendPixelTrait; + image->columns=(size_t) icon_file.directory[i].width; + if ((ssize_t) image->columns > icon_info.width) + image->columns=(size_t) icon_info.width; + if (image->columns == 0) + image->columns=256; + image->rows=(size_t) icon_file.directory[i].height; + if ((ssize_t) image->rows > icon_info.height) + image->rows=(size_t) icon_info.height; + if (image->rows == 0) + image->rows=256; + image->depth=icon_info.bits_per_pixel; + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" scene = %.20g"",(double) i); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" size = %.20g"",(double) icon_info.size); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" width = %.20g"",(double) icon_file.directory[i].width); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" height = %.20g"",(double) icon_file.directory[i].height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" colors = %.20g"",(double ) icon_info.number_colors); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" planes = %.20g"",(double) icon_info.planes); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" bpp = %.20g"",(double) icon_info.bits_per_pixel); + } + if ((icon_info.number_colors != 0) || (icon_info.bits_per_pixel <= 16U)) + { + image->storage_class=PseudoClass; + image->colors=icon_info.number_colors; + if (image->colors == 0) + image->colors=one << icon_info.bits_per_pixel; + } + if (image->storage_class == PseudoClass) + { + register ssize_t + i; + + unsigned char + *icon_colormap; + + /* + Read Icon raster colormap. + */ + if (AcquireImageColormap(image,image->colors,exception) == + MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t) + image->colors,4UL*sizeof(*icon_colormap)); + if (icon_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,(size_t) (4*image->colors),icon_colormap); + if (count != (ssize_t) (4*image->colors)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + p=icon_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].blue=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].green=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].red=(Quantum) ScaleCharToQuantum(*p++); + p++; + } + icon_colormap=(unsigned char *) RelinquishMagickMemory(icon_colormap); + } + /* + Convert Icon raster image to pixel packets. + */ + if ((image_info->ping != MagickFalse) && + (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + bytes_per_line=(((image->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + (void) bytes_per_line; + scanline_pad=((((image->columns*icon_info.bits_per_pixel)+31) & ~31)- + (image->columns*icon_info.bits_per_pixel)) >> 3; + switch (icon_info.bits_per_pixel) + { + case 1: + { + /* + Convert bitmap scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) (image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + { + SetPixelIndex(image,((byte & (0x80 >> bit)) != 0 ? 0x01 : + 0x00),q); + q+=GetPixelChannels(image); + } + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + { + SetPixelIndex(image,((byte & (0x80 >> bit)) != 0 ? 0x01 : + 0x00),q); + q+=GetPixelChannels(image); + } + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 4: + { + /* + Read 4-bit Icon scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-1); x+=2) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(image,((byte >> 4) & 0xf),q); + q+=GetPixelChannels(image); + SetPixelIndex(image,((byte) & 0xf),q); + q+=GetPixelChannels(image); + } + if ((image->columns % 2) != 0) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(image,((byte >> 4) & 0xf),q); + q+=GetPixelChannels(image); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 8: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(image,byte,q); + q+=GetPixelChannels(image); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 16: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + byte|=(size_t) (ReadBlobByte(image) << 8); + SetPixelIndex(image,byte,q); + q+=GetPixelChannels(image); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 24: + case 32: + { + /* + Convert DirectColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelBlue(image,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)),q); + SetPixelGreen(image,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)),q); + SetPixelRed(image,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)),q); + if (icon_info.bits_per_pixel == 32) + SetPixelAlpha(image,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)),q); + q+=GetPixelChannels(image); + } + if (icon_info.bits_per_pixel == 24) + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + default: + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (image_info->ping == MagickFalse) + (void) SyncImage(image,exception); + if (icon_info.bits_per_pixel != 32) + { + /* + Read the ICON alpha mask. + */ + image->storage_class=DirectClass; + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + { + SetPixelAlpha(image,(((byte & (0x80 >> bit)) != 0) ? + TransparentAlpha : OpaqueAlpha),q); + q+=GetPixelChannels(image); + } + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + { + SetPixelAlpha(image,(((byte & (0x80 >> bit)) != 0) ? + TransparentAlpha : OpaqueAlpha),q); + q+=GetPixelChannels(image); + } + } + if ((image->columns % 32) != 0) + for (x=0; x < (ssize_t) ((32-(image->columns % 32))/8); x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + } + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + break; + } + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if (i < (ssize_t) (icon_file.count-1)) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image,exception); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +}] + +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 packet_release(struct socket *sock) +{ + struct sock *sk = sock->sk; + struct packet_sock *po; + struct net *net; + union tpacket_req_u req_u; + + if (!sk) + return 0; + + net = sock_net(sk); + po = pkt_sk(sk); + + mutex_lock(&net->packet.sklist_lock); + sk_del_node_init_rcu(sk); + mutex_unlock(&net->packet.sklist_lock); + + preempt_disable(); + sock_prot_inuse_add(net, sk->sk_prot, -1); + preempt_enable(); + + spin_lock(&po->bind_lock); + unregister_prot_hook(sk, false); + packet_cached_dev_reset(po); + + if (po->prot_hook.dev) { + dev_put(po->prot_hook.dev); + po->prot_hook.dev = NULL; + } + spin_unlock(&po->bind_lock); + + packet_flush_mclist(sk); + + if (po->rx_ring.pg_vec) { + memset(&req_u, 0, sizeof(req_u)); + packet_set_ring(sk, &req_u, 1, 0); + } + + if (po->tx_ring.pg_vec) { + memset(&req_u, 0, sizeof(req_u)); + packet_set_ring(sk, &req_u, 1, 1); + } + + fanout_release(sk); + + synchronize_net(); + /* + * Now the socket is dead. No more input will appear. + */ + sock_orphan(sk); + sock->sk = NULL; + + /* Purge queues */ + + skb_queue_purge(&sk->sk_receive_queue); + packet_free_pending(po); + sk_refcnt_debug_release(sk); + + sock_put(sk); + 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 u32 apic_get_tmcct(struct kvm_lapic *apic) +{ + ktime_t remaining; + s64 ns; + u32 tmcct; + + ASSERT(apic != NULL); + + /* if initial count is 0, current count should also be 0 */ + if (kvm_apic_get_reg(apic, APIC_TMICT) == 0) + return 0; + + remaining = hrtimer_get_remaining(&apic->lapic_timer.timer); + if (ktime_to_ns(remaining) < 0) + remaining = ktime_set(0, 0); + + ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period); + tmcct = div64_u64(ns, + (APIC_BUS_CYCLE_NS * apic->divide_count)); + + return tmcct; +}] + +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 sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){ +#ifndef SQLITE_OMIT_SUBQUERY + if( pExpr->flags & EP_xIsSelect ){ + sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1); + }else +#endif + { + sqlite3ErrorMsg(pParse, ""row value misused""); + } +}] + +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 close_cached_tables(THD *thd, TABLE_LIST *tables, + bool wait_for_refresh, ulong timeout) +{ + bool result= FALSE; + struct timespec abstime; + tdc_version_t refresh_version; + DBUG_ENTER(""close_cached_tables""); + DBUG_ASSERT(thd || (!wait_for_refresh && !tables)); + + refresh_version= tdc_increment_refresh_version(); + + if (!tables) + { + /* + Force close of all open tables. + + Note that code in TABLE_SHARE::wait_for_old_version() assumes that + incrementing of refresh_version is followed by purge of unused table + shares. + */ + kill_delayed_threads(); + /* + Get rid of all unused TABLE and TABLE_SHARE instances. By doing + this we automatically close all tables which were marked as ""old"". + */ + tc_purge(true); + /* Free table shares which were not freed implicitly by loop above. */ + tdc_purge(true); + } + else + { + bool found=0; + for (TABLE_LIST *table= tables; table; table= table->next_local) + { + /* tdc_remove_table() also sets TABLE_SHARE::version to 0. */ + found|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->db.str, + table->table_name.str, TRUE); + } + if (!found) + wait_for_refresh=0; // Nothing to wait for + } + + DBUG_PRINT(""info"", (""open table definitions: %d"", + (int) tdc_records())); + + if (!wait_for_refresh) + DBUG_RETURN(result); + + if (thd->locked_tables_mode) + { + /* + If we are under LOCK TABLES, we need to reopen the tables without + opening a door for any concurrent threads to sneak in and get + lock on our tables. To achieve this we use exclusive metadata + locks. + */ + TABLE_LIST *tables_to_reopen= (tables ? tables : + thd->locked_tables_list.locked_tables()); + + /* Close open HANDLER instances to avoid self-deadlock. */ + mysql_ha_flush_tables(thd, tables_to_reopen); + + for (TABLE_LIST *table_list= tables_to_reopen; table_list; + table_list= table_list->next_global) + { + int err; + /* A check that the table was locked for write is done by the caller. */ + TABLE *table= find_table_for_mdl_upgrade(thd, table_list->db.str, + table_list->table_name.str, &err); + + /* May return NULL if this table has already been closed via an alias. */ + if (! table) + continue; + + if (wait_while_table_is_used(thd, table, + HA_EXTRA_PREPARE_FOR_FORCED_CLOSE)) + { + result= TRUE; + goto err_with_reopen; + } + close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); + } + } + + /* Wait until all threads have closed all the tables we are flushing. */ + DBUG_PRINT(""info"", (""Waiting for other threads to close their open tables"")); + + /* + To a self-deadlock or deadlocks with other FLUSH threads + waiting on our open HANDLERs, we have to flush them. + */ + mysql_ha_flush(thd); + DEBUG_SYNC(thd, ""after_flush_unlock""); + + if (!tables) + { + int r= 0; + close_cached_tables_arg argument; + argument.refresh_version= refresh_version; + set_timespec(abstime, timeout); + + while (!thd->killed && + (r= tdc_iterate(thd, + (my_hash_walk_action) close_cached_tables_callback, + &argument)) == 1 && + !argument.element->share->wait_for_old_version(thd, &abstime, + MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL)) + /* no-op */; + + if (r) + result= TRUE; + } + else + { + for (TABLE_LIST *table= tables; table; table= table->next_local) + { + if (thd->killed) + break; + if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str, timeout, + MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL, + refresh_version)) + { + result= TRUE; + break; + } + } + } + +err_with_reopen: + if (thd->locked_tables_mode) + { + /* + No other thread has the locked tables open; reopen them and get the + old locks. This should always succeed (unless some external process + has removed the tables) + */ + if (thd->locked_tables_list.reopen_tables(thd, false)) + result= true; + /* + Since downgrade_lock() won't do anything with shared + metadata lock it is much simpler to go through all open tables rather + than picking only those tables that were flushed. + */ + for (TABLE *tab= thd->open_tables; tab; tab= tab->next) + tab->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + } + DBUG_RETURN(result); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [R_API RBinJavaAttrInfo *r_bin_java_default_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) { + // NOTE: this function receives the buffer offset in the original buffer, + // but the buffer is already point to that particular offset. + // XXX - all the code that relies on this function should probably be modified + // so that the original buffer pointer is passed in and then the buffer+buf_offset + // points to the correct location. + RBinJavaAttrInfo *attr = R_NEW0 (RBinJavaAttrInfo); + if (!attr) { + return NULL; + } + RBinJavaAttrMetas *type_info = NULL; + attr->metas = R_NEW0 (RBinJavaMetaInfo); + if (attr->metas == NULL) { + free (attr); + return NULL; + } + attr->is_attr_in_old_format = r_bin_java_is_old_format(bin); + attr->file_offset = buf_offset; + attr->name_idx = R_BIN_JAVA_USHORT (buffer, 0); + attr->length = R_BIN_JAVA_UINT (buffer, 2); + attr->size = R_BIN_JAVA_UINT (buffer, 2) + 6; + attr->name = r_bin_java_get_utf8_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, attr->name_idx); + if (attr->name == NULL) { + // Something bad has happened + attr->name = r_str_dup (NULL, ""NULL""); + eprintf (""r_bin_java_default_attr_new: Unable to find the name for %d index.\n"", attr->name_idx); + } + type_info = r_bin_java_get_attr_type_by_name (attr->name); + attr->metas->ord = (R_BIN_JAVA_GLOBAL_BIN->attr_idx++); + attr->metas->type_info = (void *) type_info; + // IFDBG eprintf ("" Addrs for type_info [tag=%d]: 0x%08""PFMT64x""\n"", type_val, &attr->metas->type_info); + return attr; +}] + +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. + [uint ha_partition::count_query_cache_dependant_tables(uint8 *tables_type) +{ + DBUG_ENTER(""ha_partition::count_query_cache_dependant_tables""); + /* Here we rely on the fact that all tables are of the same type */ + uint8 type= m_file[0]->table_cache_type(); + (*tables_type)|= type; + DBUG_PRINT(""info"", (""cnt: %u"", (uint)m_tot_parts)); + /* + We need save underlying tables only for HA_CACHE_TBL_ASKTRANSACT: + HA_CACHE_TBL_NONTRANSACT - because all changes goes through partition table + HA_CACHE_TBL_NOCACHE - because will not be cached + HA_CACHE_TBL_TRANSACT - QC need to know that such type present + */ + DBUG_RETURN(type == HA_CACHE_TBL_ASKTRANSACT ? m_tot_parts : 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. + [ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_, + const struct isakmp_gen *ext, u_int oprop_length, + const u_char *ep, int depth) +{ + const struct ikev2_p *p; + struct ikev2_p prop; + u_int prop_length; + const u_char *cp; + int i; + int tcount; + u_char np; + struct isakmp_gen e; + u_int item_len; + + p = (const struct ikev2_p *)ext; + ND_TCHECK(*p); + UNALIGNED_MEMCPY(&prop, ext, sizeof(prop)); + + ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical); + + /* + * ikev2_sa_print() guarantees that this is >= 4. + */ + prop_length = oprop_length - 4; + ND_PRINT((ndo,"" #%u protoid=%s transform=%d len=%u"", + prop.p_no, PROTOIDSTR(prop.prot_id), + prop.num_t, oprop_length)); + cp = (const u_char *)(p + 1); + + if (prop.spi_size) { + if (prop_length < prop.spi_size) + goto toolong; + ND_PRINT((ndo,"" spi="")); + if (!rawprint(ndo, (const uint8_t *)cp, prop.spi_size)) + goto trunc; + cp += prop.spi_size; + prop_length -= prop.spi_size; + } + + /* + * Print the transforms. + */ + tcount = 0; + for (np = ISAKMP_NPTYPE_T; np != 0; np = e.np) { + tcount++; + ext = (const struct isakmp_gen *)cp; + if (prop_length < sizeof(*ext)) + goto toolong; + ND_TCHECK(*ext); + + UNALIGNED_MEMCPY(&e, ext, sizeof(e)); + + /* + * Since we can't have a payload length of less than 4 bytes, + * we need to bail out here if the generic header is nonsensical + * or truncated, otherwise we could loop forever processing + * zero-length items or otherwise misdissect the packet. + */ + item_len = ntohs(e.len); + if (item_len <= 4) + goto trunc; + + if (prop_length < item_len) + goto toolong; + ND_TCHECK2(*cp, item_len); + + depth++; + ND_PRINT((ndo,""\n"")); + for (i = 0; i < depth; i++) + ND_PRINT((ndo,"" "")); + ND_PRINT((ndo,""("")); + if (np == ISAKMP_NPTYPE_T) { + cp = ikev2_t_print(ndo, tcount, ext, item_len, ep); + if (cp == NULL) { + /* error, already reported */ + return NULL; + } + } else { + ND_PRINT((ndo, ""%s"", NPSTR(np))); + cp += item_len; + } + ND_PRINT((ndo,"")"")); + depth--; + prop_length -= item_len; + } + return cp; +toolong: + /* + * Skip the rest of the proposal. + */ + cp += prop_length; + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_P))); + return cp; +trunc: + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_P))); + return NULL; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int ssl3_get_server_hello(SSL *s) + { + STACK_OF(SSL_CIPHER) *sk; + SSL_CIPHER *c; + unsigned char *p,*d; + int i,al,ok; + unsigned int j; + long n; +#ifndef OPENSSL_NO_COMP + SSL_COMP *comp; +#endif + + n=s->method->ssl_get_message(s, + SSL3_ST_CR_SRVR_HELLO_A, + SSL3_ST_CR_SRVR_HELLO_B, + -1, + 20000, /* ?? */ + &ok); + + if (!ok) return((int)n); + + if ( SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) + { + if ( s->s3->tmp.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST) + { + if ( s->d1->send_cookie == 0) + { + s->s3->tmp.reuse_message = 1; + return 1; + } + else /* already sent a cookie */ + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE); + goto f_err; + } + } + } + + if ( s->s3->tmp.message_type != SSL3_MT_SERVER_HELLO) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE); + goto f_err; + } + + d=p=(unsigned char *)s->init_msg; + + if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) + { + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION); + s->version=(s->version&0xff00)|p[1]; + al=SSL_AD_PROTOCOL_VERSION; + goto f_err; + } + p+=2; + + /* load the server hello data */ + /* load the server random */ + memcpy(s->s3->server_random,p,SSL3_RANDOM_SIZE); + p+=SSL3_RANDOM_SIZE; + + /* get the session-id */ + j= *(p++); + + if ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE)) + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_LONG); + goto f_err; + } + + if (j != 0 && j == s->session->session_id_length + && memcmp(p,s->session->session_id,j) == 0) + { + if(s->sid_ctx_length != s->session->sid_ctx_length + || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length)) + { + /* actually a client application bug */ + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); + goto f_err; + } + s->s3->flags |= SSL3_FLAGS_CCS_OK; + s->hit=1; + } + else /* a miss or crap from the other end */ + { + /* If we were trying for session-id reuse, make a new + * SSL_SESSION so we don't stuff up other people */ + s->hit=0; + if (s->session->session_id_length > 0) + { + if (!ssl_get_new_session(s,0)) + { + al=SSL_AD_INTERNAL_ERROR; + goto f_err; + } + } + s->session->session_id_length=j; + memcpy(s->session->session_id,p,j); /* j could be 0 */ + } + p+=j; + c=ssl_get_cipher_by_char(s,p); + if (c == NULL) + { + /* unknown cipher */ + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNKNOWN_CIPHER_RETURNED); + goto f_err; + } + p+=ssl_put_cipher_by_char(s,NULL,NULL); + + sk=ssl_get_ciphers_by_id(s); + i=sk_SSL_CIPHER_find(sk,c); + if (i < 0) + { + /* we did not say we would use this cipher */ + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED); + goto f_err; + } + + /* Depending on the session caching (internal/external), the cipher + and/or cipher_id values may not be set. Make sure that + cipher_id is set and use it for comparison. */ + if (s->session->cipher) + s->session->cipher_id = s->session->cipher->id; + if (s->hit && (s->session->cipher_id != c->id)) + { +/* Workaround is now obsolete */ +#if 0 + if (!(s->options & + SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)) +#endif + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); + goto f_err; + } + } + s->s3->tmp.new_cipher=c; + + /* lets get the compression algorithm */ + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + if (*(p++) != 0) + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + goto f_err; + } +#else + j= *(p++); + if (j == 0) + comp=NULL; + else + comp=ssl3_comp_find(s->ctx->comp_methods,j); + + if ((j != 0) && (comp == NULL)) + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + goto f_err; + } + else + { + s->s3->tmp.new_compression=comp; + } +#endif +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions*/ + if (s->version >= SSL3_VERSION) + { + if (!ssl_parse_serverhello_tlsext(s,&p,d,n, &al)) + { + /* 'al' set by ssl_parse_serverhello_tlsext */ + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_PARSE_TLSEXT); + goto f_err; + } + if (ssl_check_serverhello_tlsext(s) <= 0) + { + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SERVERHELLO_TLSEXT); + goto err; + } + } +#endif + + + if (p != (d+n)) + { + /* wrong packet length */ + al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_PACKET_LENGTH); + goto f_err; + } + + return(1); +f_err: + ssl3_send_alert(s,SSL3_AL_FATAL,al); +#ifndef OPENSSL_NO_TLSEXT +err: +#endif + return(-1); + }] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void __init sev_set_cpu_caps(void) +{ + if (!sev_enabled) + kvm_cpu_cap_clear(X86_FEATURE_SEV); + if (!sev_es_enabled) + kvm_cpu_cap_clear(X86_FEATURE_SEV_ES); +}] + +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* context) override { + const Tensor& input_sizes = context->input(0); + const Tensor& filter = context->input(1); + OP_REQUIRES( + context, TensorShapeUtils::IsVector(input_sizes.shape()), + errors::InvalidArgument( + ""Conv2DBackpropInput: input_sizes input must be 1-dim, not "", + input_sizes.dims())); + TensorShape input_shape; + const int32* in_sizes_data = input_sizes.template flat().data(); + + for (int i = 0; i < input_sizes.NumElements(); ++i) { + OP_REQUIRES(context, in_sizes_data[i] >= 0, + errors::InvalidArgument(""Dimension "", i, + "" of input_sizes must be >= 0"")); + input_shape.AddDim(in_sizes_data[i]); + } + const TensorShape& filter_shape = filter.shape(); + EXTRACT_AND_VERIFY_DIMENSIONS(""DepthwiseConv2DBackpropInput""); + + Tensor* in_backprop = nullptr; + OP_REQUIRES_OK(context, context->forward_input_or_allocate_output( + {0}, 0, input_shape, &in_backprop)); + + // If there is nothing to compute, return. + if (input_shape.num_elements() == 0) { + return; + } + + // If in_depth==1, this operation is just a standard convolution. + // Depthwise convolution is a special case of cuDNN's grouped convolution. + bool use_cudnn = std::is_same::value && + (in_depth == 1 || + (use_cudnn_grouped_conv_ && + IsCudnnSupportedFilterSize(/*filter_rows=*/filter_rows, + /*filter_cols=*/filter_cols, + /*in_depth=*/in_depth, + /*out_depth=*/out_depth))); + + VLOG(2) << ""DepthwiseConv2dNativeBackpropInput: "" + << "" Input: ["" << batch << "", "" << input_rows << "", "" << input_cols + << "", "" << in_depth << ""]; Filter: ["" << filter_rows << "", "" + << filter_cols << "", "" << in_depth << "", "" << depth_multiplier + << ""]; Output: ["" << batch << "", "" << out_rows << "", "" << out_cols + << "", "" << out_depth << ""], stride = "" << stride_ + << "", pad_rows = "" << pad_top << "", pad_cols = "" << pad_left + << "", Use cuDNN: "" << use_cudnn; + + if (use_cudnn) { + // Reshape from TF depthwise filter to cuDNN grouped convolution filter: + // + // | TensorFlow | cuDNN + // -------------------------------------------------------------------- + // filter_out_depth | depth_multiplier | depth_multiplier * group_count + // filter_in_depth | in_depth | in_depth / group_count + // + // For depthwise convolution, we have group_count == in_depth. + int32_t filter_in_depth = 1; + TensorShape shape = + TensorShape{filter_rows, filter_cols, filter_in_depth, out_depth}; + Tensor reshaped_filter(/*type=*/dtype_); + OP_REQUIRES( + context, reshaped_filter.CopyFrom(filter, shape), + errors::Internal( + ""Failed to reshape filter tensor for grouped convolution."")); + // TODO(yangzihao): Send in arbitrary dilation rates after the dilated + // conv is supported. + launcher_(context, /*use_cudnn=*/true, cudnn_use_autotune_, out_backprop, + reshaped_filter, /*row_dilation=*/1, /*col_dilation=*/1, + stride_, stride_, padding_, explicit_paddings_, in_backprop, + data_format_); + return; + } + + auto out_backprop_ptr = out_backprop.template flat().data(); + auto filter_ptr = filter.template flat().data(); + auto in_backprop_ptr = in_backprop->template flat().data(); + LaunchDepthwiseConvBackpropInputOp()( + context, args, out_backprop_ptr, filter_ptr, in_backprop_ptr, + data_format_); + }] + +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. + [netsnmp_init_mib(void) +{ + const char *prefix; + char *env_var, *entry; + PrefixListPtr pp = &mib_prefixes[0]; + char *st = NULL; + + if (Mib) + return; + netsnmp_init_mib_internals(); + + /* + * Initialise the MIB directory/ies + */ + netsnmp_fixup_mib_directory(); + env_var = strdup(netsnmp_get_mib_directory()); + if (!env_var) + return; + + DEBUGMSGTL((""init_mib"", + ""Seen MIBDIRS: Looking in '%s' for mib dirs ...\n"", + env_var)); + + entry = strtok_r(env_var, ENV_SEPARATOR, &st); + while (entry) { + add_mibdir(entry); + entry = strtok_r(NULL, ENV_SEPARATOR, &st); + } + SNMP_FREE(env_var); + + env_var = netsnmp_getenv(""MIBFILES""); + if (env_var != NULL) { + if (*env_var == '+') + entry = strtok_r(env_var+1, ENV_SEPARATOR, &st); + else + entry = strtok_r(env_var, ENV_SEPARATOR, &st); + while (entry) { + add_mibfile(entry, NULL); + entry = strtok_r(NULL, ENV_SEPARATOR, &st); + } + } + + netsnmp_init_mib_internals(); + + /* + * Read in any modules or mibs requested + */ + + env_var = netsnmp_getenv(""MIBS""); + if (env_var == NULL) { + if (confmibs != NULL) + env_var = strdup(confmibs); + else + env_var = strdup(NETSNMP_DEFAULT_MIBS); + } else { + env_var = strdup(env_var); + } + if (env_var && ((*env_var == '+') || (*env_var == '-'))) { + entry = + (char *) malloc(strlen(NETSNMP_DEFAULT_MIBS) + strlen(env_var) + 2); + if (!entry) { + DEBUGMSGTL((""init_mib"", ""env mibs malloc failed"")); + SNMP_FREE(env_var); + return; + } else { + if (*env_var == '+') + sprintf(entry, ""%s%c%s"", NETSNMP_DEFAULT_MIBS, ENV_SEPARATOR_CHAR, + env_var+1); + else + sprintf(entry, ""%s%c%s"", env_var+1, ENV_SEPARATOR_CHAR, + NETSNMP_DEFAULT_MIBS ); + } + SNMP_FREE(env_var); + env_var = entry; + } + + DEBUGMSGTL((""init_mib"", + ""Seen MIBS: Looking in '%s' for mib files ...\n"", + env_var)); + entry = strtok_r(env_var, ENV_SEPARATOR, &st); + while (entry) { + if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) { + read_all_mibs(); + } else if (strstr(entry, ""/"") != NULL) { + read_mib(entry); + } else { + netsnmp_read_module(entry); + } + entry = strtok_r(NULL, ENV_SEPARATOR, &st); + } + adopt_orphans(); + SNMP_FREE(env_var); + + env_var = netsnmp_getenv(""MIBFILES""); + if (env_var != NULL) { + if ((*env_var == '+') || (*env_var == '-')) { +#ifdef NETSNMP_DEFAULT_MIBFILES + entry = + (char *) malloc(strlen(NETSNMP_DEFAULT_MIBFILES) + + strlen(env_var) + 2); + if (!entry) { + DEBUGMSGTL((""init_mib"", ""env mibfiles malloc failed"")); + } else { + if (*env_var++ == '+') + sprintf(entry, ""%s%c%s"", NETSNMP_DEFAULT_MIBFILES, ENV_SEPARATOR_CHAR, + env_var ); + else + sprintf(entry, ""%s%c%s"", env_var, ENV_SEPARATOR_CHAR, + NETSNMP_DEFAULT_MIBFILES ); + } + SNMP_FREE(env_var); + env_var = entry; +#else + env_var = strdup(env_var + 1); +#endif + } else { + env_var = strdup(env_var); + } + } else { +#ifdef NETSNMP_DEFAULT_MIBFILES + env_var = strdup(NETSNMP_DEFAULT_MIBFILES); +#endif + } + + if (env_var != NULL) { + DEBUGMSGTL((""init_mib"", + ""Seen MIBFILES: Looking in '%s' for mib files ...\n"", + env_var)); + entry = strtok_r(env_var, ENV_SEPARATOR, &st); + while (entry) { + read_mib(entry); + entry = strtok_r(NULL, ENV_SEPARATOR, &st); + } + SNMP_FREE(env_var); + } + + prefix = netsnmp_getenv(""PREFIX""); + + if (!prefix) + prefix = Standard_Prefix; + + Prefix = (char *) malloc(strlen(prefix) + 2); + if (!Prefix) + DEBUGMSGTL((""init_mib"", ""Prefix malloc failed"")); + else + strcpy(Prefix, prefix); + + DEBUGMSGTL((""init_mib"", + ""Seen PREFIX: Looking in '%s' for prefix ...\n"", Prefix)); + + /* + * remove trailing dot + */ + if (Prefix) { + env_var = &Prefix[strlen(Prefix) - 1]; + if (*env_var == '.') + *env_var = '\0'; + } + + pp->str = Prefix; /* fixup first mib_prefix entry */ + /* + * now that the list of prefixes is built, save each string length. + */ + while (pp->str) { + pp->len = strlen(pp->str); + pp++; + } + + Mib = tree_head; /* Backwards compatibility */ + tree_top = (struct tree *) calloc(1, sizeof(struct tree)); + /* + * XX error check ? + */ + if (tree_top) { + tree_top->label = strdup(""(top)""); + tree_top->child_list = tree_head; + } +}] + +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 RList *carve_kexts(RKernelCacheObj *obj, RBinFile *bf) { + struct section_t *sections = NULL; + if (!(sections = MACH0_(get_sections) (obj->mach0))) { + return NULL; + } + + ut64 pa2va_exec = 0; + ut64 pa2va_data = 0; + ut64 kmod_start = 0, kmod_end = 0; + ut64 kmod_info = 0, kmod_info_end = 0; + int incomplete = 4; + RKmodInfo *all_infos = NULL; + + int i = 0; + for (; !sections[i].last && incomplete > 0; i++) { + if (strstr (sections[i].name, ""__TEXT_EXEC.__text"")) { + pa2va_exec = sections[i].addr - sections[i].offset; + incomplete--; + } + if (strstr (sections[i].name, ""__DATA.__data"")) { + pa2va_data = sections[i].addr - sections[i].offset; + incomplete--; + } + if (strstr (sections[i].name, ""__PRELINK_INFO.__kmod_start"")) { + kmod_start = sections[i].offset; + kmod_end = kmod_start + sections[i].size; + incomplete--; + } + if (strstr (sections[i].name, ""__PRELINK_INFO.__kmod_info"")) { + kmod_info = sections[i].offset; + kmod_info_end = kmod_info + sections[i].size; + incomplete--; + } + } + + R_FREE (sections); + + if (incomplete) { + return NULL; + } + + RList *kexts = r_list_newf ((RListFree) &r_kext_free); + if (!kexts) { + return NULL; + } + + int n_kmod_info = (kmod_info_end - kmod_info) / 8; + if (n_kmod_info == 0) { + goto beach; + } + + all_infos = R_NEWS0 (RKmodInfo, n_kmod_info); + if (!all_infos) { + goto beach; + } + + ut8 bytes[8]; + int j = 0; + for (; j < n_kmod_info; j++) { + ut64 entry_offset = j * 8 + kmod_info; + + if (r_buf_read_at (obj->cache_buf, entry_offset, bytes, 8) < 8) { + goto beach; + } + + ut64 kmod_info_paddr = K_RPTR (bytes) - pa2va_data; + + ut64 field_name = kmod_info_paddr + 0x10; + ut64 field_start = kmod_info_paddr + 0xb4; + + if (r_buf_read_at (obj->cache_buf, field_start, bytes, 8) < 8) { + goto beach; + } + + all_infos[j].start = K_RPTR (bytes); + + if (r_buf_read_at (obj->cache_buf, field_name, (ut8 *) all_infos[j].name, 0x40) < 0x40) { + goto beach; + } + + all_infos[j].name[0x40] = 0; + } + + ut64 cursor = kmod_start; + for(; cursor < kmod_end; cursor += 8) { + ut8 bytes[8]; + if (r_buf_read_at (obj->cache_buf, cursor, bytes, 8) < 8) { + goto beach; + } + + RKext *kext = R_NEW0 (RKext); + if (!kext) { + goto beach; + } + + kext->vaddr = K_RPTR (bytes); + kext->range.offset = kext->vaddr - pa2va_exec; + + kext->mach0 = create_kext_mach0 (obj, kext, bf); + if (!kext->mach0) { + r_kext_free (kext); + continue; + } + + r_kext_fill_text_range (kext); + kext->vaddr = K_PPTR (kext->vaddr); + kext->pa2va_exec = pa2va_exec; + kext->pa2va_data = pa2va_data; + + ut64 text_start = kext->vaddr; + ut64 text_end = text_start + kext->text_range.size; + + if (text_start == text_end) { + r_kext_free (kext); + continue; + } + + for (j = 0; j < n_kmod_info; j++) { + if (text_start > all_infos[j].start || all_infos[j].start >= text_end) { + continue; + } + + kext->name = strdup (all_infos[j].name); + kext->own_name = true; + break; + } + + if (!kext->name) { + r_kext_free (kext); + continue; + } + + r_list_push (kexts, kext); + } + + R_FREE (all_infos); + return kexts; + +beach: + r_list_free (kexts); + R_FREE (all_infos); + 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. + [mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, + const void *pBuf, size_t buf_size, + mz_uint level_and_flags) { + return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, + level_and_flags, 0, 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. + [ Http2CodecImplTestFixture(Http2SettingsTuple client_settings, Http2SettingsTuple server_settings) + : client_settings_(client_settings), server_settings_(server_settings) {}] + +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 __dvb_frontend_free(struct dvb_frontend *fe) +{ + struct dvb_frontend_private *fepriv = fe->frontend_priv; + + if (fepriv) + dvb_free_device(fepriv->dvbdev); + + dvb_frontend_invoke_release(fe, fe->ops.release); + + if (!fepriv) + return; + + kfree(fepriv); + fe->frontend_priv = NULL; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int compare_order_elements(ORDER *ord1, ORDER *ord2) +{ + if (*ord1->item == *ord2->item && ord1->direction == ord2->direction) + return CMP_EQ; + Item *item1= (*ord1->item)->real_item(); + Item *item2= (*ord2->item)->real_item(); + DBUG_ASSERT(item1->type() == Item::FIELD_ITEM && + item2->type() == Item::FIELD_ITEM); + ptrdiff_t cmp= ((Item_field *) item1)->field - ((Item_field *) item2)->field; + if (cmp == 0) + { + if (ord1->direction == ord2->direction) + return CMP_EQ; + return ord1->direction > ord2->direction ? CMP_GT : CMP_LT; + } + else + return cmp > 0 ? CMP_GT : CMP_LT; +}] + +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. + [SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) + { + SSL_CTX *ret=NULL; + + if (meth == NULL) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_NULL_SSL_METHOD_PASSED); + return(NULL); + } + + if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); + goto err; + } + ret=(SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX)); + if (ret == NULL) + goto err; + + memset(ret,0,sizeof(SSL_CTX)); + + ret->method=meth; + + ret->cert_store=NULL; + ret->session_cache_mode=SSL_SESS_CACHE_SERVER; + ret->session_cache_size=SSL_SESSION_CACHE_MAX_SIZE_DEFAULT; + ret->session_cache_head=NULL; + ret->session_cache_tail=NULL; + + /* We take the system default */ + ret->session_timeout=meth->get_timeout(); + + ret->new_session_cb=0; + ret->remove_session_cb=0; + ret->get_session_cb=0; + ret->generate_session_id=0; + + memset((char *)&ret->stats,0,sizeof(ret->stats)); + + ret->references=1; + ret->quiet_shutdown=0; + +/* ret->cipher=NULL;*/ +/* ret->s2->challenge=NULL; + ret->master_key=NULL; + ret->key_arg=NULL; + ret->s2->conn_id=NULL; */ + + ret->info_callback=NULL; + + ret->app_verify_callback=0; + ret->app_verify_arg=NULL; + + ret->max_cert_list=SSL_MAX_CERT_LIST_DEFAULT; + ret->read_ahead=0; + ret->msg_callback=0; + ret->msg_callback_arg=NULL; + ret->verify_mode=SSL_VERIFY_NONE; +#if 0 + ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ +#endif + ret->sid_ctx_length=0; + ret->default_verify_callback=NULL; + if ((ret->cert=ssl_cert_new()) == NULL) + goto err; + + ret->default_passwd_callback=0; + ret->default_passwd_callback_userdata=NULL; + ret->client_cert_cb=0; + ret->app_gen_cookie_cb=0; + ret->app_verify_cookie_cb=0; + + ret->sessions=lh_SSL_SESSION_new(); + if (ret->sessions == NULL) goto err; + ret->cert_store=X509_STORE_new(); + if (ret->cert_store == NULL) goto err; + + ssl_create_cipher_list(ret->method, + &ret->cipher_list,&ret->cipher_list_by_id, + meth->version == SSL2_VERSION ? ""SSLv2"" : SSL_DEFAULT_CIPHER_LIST); + if (ret->cipher_list == NULL + || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_LIBRARY_HAS_NO_CIPHERS); + goto err2; + } + + ret->param = X509_VERIFY_PARAM_new(); + if (!ret->param) + goto err; + + if ((ret->rsa_md5=EVP_get_digestbyname(""ssl2-md5"")) == NULL) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); + goto err2; + } + if ((ret->md5=EVP_get_digestbyname(""ssl3-md5"")) == NULL) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES); + goto err2; + } + if ((ret->sha1=EVP_get_digestbyname(""ssl3-sha1"")) == NULL) + { + SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES); + goto err2; + } + + if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL) + goto err; + + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data); + + ret->extra_certs=NULL; + ret->comp_methods=SSL_COMP_get_compression_methods(); + + ret->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH; + +#ifndef OPENSSL_NO_TLSEXT + ret->tlsext_servername_callback = 0; + ret->tlsext_servername_arg = NULL; + /* Setup RFC4507 ticket keys */ + if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0) + || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0) + || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0)) + ret->options |= SSL_OP_NO_TICKET; + + ret->tlsext_status_cb = 0; + ret->tlsext_status_arg = NULL; + +#endif +#ifndef OPENSSL_NO_PSK + ret->psk_identity_hint=NULL; + ret->psk_client_callback=NULL; + ret->psk_server_callback=NULL; +#endif +#ifndef OPENSSL_NO_BUF_FREELISTS + ret->freelist_max_len = SSL_MAX_BUF_FREELIST_LEN_DEFAULT; + ret->rbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST)); + if (!ret->rbuf_freelist) + goto err; + ret->rbuf_freelist->chunklen = 0; + ret->rbuf_freelist->len = 0; + ret->rbuf_freelist->head = NULL; + ret->wbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST)); + if (!ret->wbuf_freelist) + { + OPENSSL_free(ret->rbuf_freelist); + goto err; + } + ret->wbuf_freelist->chunklen = 0; + ret->wbuf_freelist->len = 0; + ret->wbuf_freelist->head = NULL; +#endif +#ifndef OPENSSL_NO_ENGINE + ret->client_cert_engine = NULL; +#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO +#define eng_strx(x) #x +#define eng_str(x) eng_strx(x) + /* Use specific client engine automatically... ignore errors */ + { + ENGINE *eng; + eng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO)); + if (!eng) + { + ERR_clear_error(); + ENGINE_load_builtin_engines(); + eng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO)); + } + if (!eng || !SSL_CTX_set_client_cert_engine(ret, eng)) + ERR_clear_error(); + } +#endif +#endif + /* Default is to connect to non-RI servers. When RI is more widely + * deployed might change this. + */ + ret->options |= SSL_OP_LEGACY_SERVER_CONNECT; + + return(ret); +err: + SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); +err2: + if (ret != NULL) SSL_CTX_free(ret); + return(NULL); + }] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static void temac_start_xmit_done(struct net_device *ndev) +{ + struct temac_local *lp = netdev_priv(ndev); + struct cdmac_bd *cur_p; + unsigned int stat = 0; + struct sk_buff *skb; + + cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; + stat = be32_to_cpu(cur_p->app0); + + while (stat & STS_CTRL_APP0_CMPLT) { + /* Make sure that the other fields are read after bd is + * released by dma + */ + rmb(); + dma_unmap_single(ndev->dev.parent, be32_to_cpu(cur_p->phys), + be32_to_cpu(cur_p->len), DMA_TO_DEVICE); + skb = (struct sk_buff *)ptr_from_txbd(cur_p); + if (skb) + dev_consume_skb_irq(skb); + cur_p->app1 = 0; + cur_p->app2 = 0; + cur_p->app3 = 0; + cur_p->app4 = 0; + + ndev->stats.tx_packets++; + ndev->stats.tx_bytes += be32_to_cpu(cur_p->len); + + /* app0 must be visible last, as it is used to flag + * availability of the bd + */ + smp_mb(); + cur_p->app0 = 0; + + lp->tx_bd_ci++; + if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci = 0; + + cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; + stat = be32_to_cpu(cur_p->app0); + } + + /* Matches barrier in temac_start_xmit */ + smp_mb(); + + netif_wake_queue(ndev); +}] + +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 jmapquery(void *sc, void *mc, const char *json) +{ + script_data_t *sd = (script_data_t *) sc; + message_data_t *md = ((deliver_data_t *) mc)->m; + struct buf msg = BUF_INITIALIZER; + const char *userid = mbname_userid(sd->mbname); + json_error_t jerr; + json_t *jfilter, *err = NULL; + int r; + + /* Create filter from json */ + jfilter = json_loads(json, 0, &jerr); + if (!jfilter) return 0; + + /* mmap the staged message file */ + buf_refresh_mmap(&msg, 1, fileno(md->f), md->id, md->size, NULL); + + /* Run query */ + r = jmap_email_matchmime(&msg, jfilter, userid, time(NULL), &err); + + if (err) { + char *errstr = json_dumps(err, JSON_COMPACT); + syslog(LOG_ERR, ""sieve: jmapquery error: %s"", errstr); + free(errstr); + r = SIEVE_RUN_ERROR; + } + + json_decref(jfilter); + buf_free(&msg); + + 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. + [static inline int l2cap_config_rsp(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, + u8 *data) +{ + struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; + u16 scid, flags, result; + struct l2cap_chan *chan; + int len = cmd_len - sizeof(*rsp); + int err = 0; + + if (cmd_len < sizeof(*rsp)) + return -EPROTO; + + scid = __le16_to_cpu(rsp->scid); + flags = __le16_to_cpu(rsp->flags); + result = __le16_to_cpu(rsp->result); + + BT_DBG(""scid 0x%4.4x flags 0x%2.2x result 0x%2.2x len %d"", scid, flags, + result, len); + + chan = l2cap_get_chan_by_scid(conn, scid); + if (!chan) + return 0; + + switch (result) { + case L2CAP_CONF_SUCCESS: + l2cap_conf_rfc_get(chan, rsp->data, len); + clear_bit(CONF_REM_CONF_PEND, &chan->conf_state); + break; + + case L2CAP_CONF_PENDING: + set_bit(CONF_REM_CONF_PEND, &chan->conf_state); + + if (test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { + char buf[64]; + + len = l2cap_parse_conf_rsp(chan, rsp->data, len, + buf, sizeof(buf), &result); + if (len < 0) { + l2cap_send_disconn_req(chan, ECONNRESET); + goto done; + } + + if (!chan->hs_hcon) { + l2cap_send_efs_conf_rsp(chan, buf, cmd->ident, + 0); + } else { + if (l2cap_check_efs(chan)) { + amp_create_logical_link(chan); + chan->ident = cmd->ident; + } + } + } + goto done; + + case L2CAP_CONF_UNACCEPT: + if (chan->num_conf_rsp <= L2CAP_CONF_MAX_CONF_RSP) { + char req[64]; + + if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { + l2cap_send_disconn_req(chan, ECONNRESET); + goto done; + } + + /* throw out any old stored conf requests */ + result = L2CAP_CONF_SUCCESS; + len = l2cap_parse_conf_rsp(chan, rsp->data, len, + req, sizeof(req), &result); + if (len < 0) { + l2cap_send_disconn_req(chan, ECONNRESET); + goto done; + } + + l2cap_send_cmd(conn, l2cap_get_ident(conn), + L2CAP_CONF_REQ, len, req); + chan->num_conf_req++; + if (result != L2CAP_CONF_SUCCESS) + goto done; + break; + } + + default: + l2cap_chan_set_err(chan, ECONNRESET); + + __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); + l2cap_send_disconn_req(chan, ECONNRESET); + goto done; + } + + if (flags & L2CAP_CONF_FLAG_CONTINUATION) + goto done; + + set_bit(CONF_INPUT_DONE, &chan->conf_state); + + if (test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) { + set_default_fcs(chan); + + if (chan->mode == L2CAP_MODE_ERTM || + chan->mode == L2CAP_MODE_STREAMING) + err = l2cap_ertm_init(chan); + + if (err < 0) + l2cap_send_disconn_req(chan, -err); + else + l2cap_chan_ready(chan); + } + +done: + l2cap_chan_unlock(chan); + return err; +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [ void parseTest(fs::path testFilePath) { + _testFilePath = testFilePath.string(); + LOGV2(4333507, ""### Parsing Test ###"", ""testFilePath""_attr = testFilePath.string()); + { + std::ifstream testFile(_testFilePath); + std::ostringstream json; + json << testFile.rdbuf(); + _jsonTest = fromjson(json.str()); + } + + // Do this first to save the state + if (_jsonTest.hasField(""error"")) { + LOGV2(5017004, ""Expecting test case to generate an error.""); + _errorExpected = _jsonTest.getBoolField(""error""); + } + + // The json tests pass in capitalized keywords for mode, but the server only accepts + // lowercased keywords. Also, change the key ""tags_set"" to ""tags"". + // This can throw for test cases that have invalid read preferences. + auto readPrefObj = _jsonTest.getObjectField(""read_preference""); + std::string mode = readPrefObj.getStringField(""mode""); + mode[0] = std::tolower(mode[0]); + auto tagSetsObj = readPrefObj[""tag_sets""]; + auto tags = tagSetsObj ? BSONArray(readPrefObj[""tag_sets""].Obj()) : BSONArray(); + + + auto topologyDescriptionObj = _jsonTest.getObjectField(""topology_description""); + TopologyType initType = + uassertStatusOK(parseTopologyType(topologyDescriptionObj.getStringField(""type""))); + boost::optional setName = boost::none; + if (initType == TopologyType::kReplicaSetNoPrimary || initType == TopologyType::kSingle) + setName = ""replset""; + + int maxStalenessSeconds = 0; + if (readPrefObj.hasField(""maxStalenessSeconds"")) { + maxStalenessSeconds = readPrefObj.getIntField(""maxStalenessSeconds""); + } + + BSONObj readPref = + BSON(""mode"" << mode << ""tags"" << tags << ""maxStalenessSeconds"" << maxStalenessSeconds); + auto stalenessParseResult = ReadPreferenceSetting::fromInnerBSON(readPref); + if (!_errorExpected && + stalenessParseResult.getStatus().code() == ErrorCodes::MaxStalenessOutOfRange && + (initType == TopologyType::kUnknown || initType == TopologyType::kSingle || + initType == TopologyType::kSharded)) { + // Drivers tests expect no error for invalid maxStaleness values for Unknown, Single, + // and Sharded topology types. The server code doesn't allow read preferences to be + // created for invalid values for maxStaleness, so ignore it. + readPref = BSON(""mode"" << mode << ""tags"" << tags << ""maxStalenessSeconds"" << 0); + stalenessParseResult = ReadPreferenceSetting::fromInnerBSON(readPref); + } else if (_errorExpected && maxStalenessSeconds == 0 && + readPrefObj.hasField(""maxStalenessSeconds"")) { + // Generate an error to pass test cases that set max staleness to zero since the server + // interprets this as no maxStaleness is specified. + uassert(ErrorCodes::MaxStalenessOutOfRange, ""max staleness should be >= 0"", false); + } + _readPreference = uassertStatusOK(stalenessParseResult); + LOGV2(5017007, ""Read Preference"", ""value""_attr = _readPreference); + + if (_jsonTest.hasField(""heartbeatFrequencyMS"")) { + sdamHeartBeatFrequencyMs = _jsonTest.getIntField(""heartbeatFrequencyMS""); + LOGV2(5017003, ""Set heartbeatFrequencyMs"", ""value""_attr = sdamHeartBeatFrequencyMs); + } + + std::vector serverDescriptions; + std::vector serverAddresses; + const std::vector& bsonServers = topologyDescriptionObj[""servers""].Array(); + + for (auto bsonServer : bsonServers) { + auto server = bsonServer.Obj(); + + int maxWireVersion = 9; + if (server.hasField(""maxWireVersion"")) { + maxWireVersion = server[""maxWireVersion""].numberInt(); + } + + auto serverType = uassertStatusOK(parseServerType(server.getStringField(""type""))); + auto serverDescription = ServerDescriptionBuilder() + .withAddress(HostAndPort(server.getStringField(""address""))) + .withType(serverType) + .withRtt(Milliseconds(server[""avg_rtt_ms""].numberInt())) + .withMinWireVersion(5) + .withMaxWireVersion(maxWireVersion); + + if (server.hasField(""lastWrite"")) { + auto lastWriteDate = + server.getObjectField(""lastWrite"").getIntField(""lastWriteDate""); + serverDescription.withLastWriteDate(Date_t::fromMillisSinceEpoch(lastWriteDate)); + } + + if (server.hasField(""lastUpdateTime"")) { + auto lastUpdateTime = server.getIntField(""lastUpdateTime""); + serverDescription.withLastUpdateTime(Date_t::fromMillisSinceEpoch(lastUpdateTime)); + } + + auto tagsObj = server.getObjectField(""tags""); + const auto keys = tagsObj.getFieldNames>(); + for (const auto key : keys) { + serverDescription.withTag(key, tagsObj.getStringField(key)); + } + + serverDescriptions.push_back(serverDescription.instance()); + LOGV2(5017002, + ""Server Description"", + ""description""_attr = serverDescriptions.back()->toBson()); + serverAddresses.push_back(HostAndPort(server.getStringField(""address""))); + } + + + boost::optional> seedList = boost::none; + if (serverAddresses.size() > 0) + seedList = serverAddresses; + + auto config = SdamConfiguration(seedList, + initType, + Milliseconds{sdamHeartBeatFrequencyMs}, + Milliseconds{sdamConnectTimeoutMs}, + Milliseconds{sdamLocalThreshholdMs}, + setName); + _topologyDescription = std::make_shared(config); + + if (_jsonTest.hasField(""in_latency_window"")) { + const std::vector& bsonLatencyWindow = + _jsonTest[""in_latency_window""].Array(); + for (const auto& serverDescription : serverDescriptions) { + _topologyDescription->installServerDescription(serverDescription); + + for (auto bsonServer : bsonLatencyWindow) { + auto server = bsonServer.Obj(); + if (serverDescription->getAddress() == + HostAndPort(server.getStringField(""address""))) { + _inLatencyWindow.push_back(serverDescription); + } + } + } + } + }] + +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. + [ecma_bigint_to_number (ecma_value_t value) /**< BigInt value */ +{ + JERRY_ASSERT (ecma_is_value_bigint (value)); + + if (value == ECMA_BIGINT_ZERO) + { + return ecma_make_integer_value (0); + } + + ecma_extended_primitive_t *value_p = ecma_get_extended_primitive_from_value (value); + uint32_t size = ECMA_BIGINT_GET_SIZE (value_p); + ecma_bigint_digit_t *digits_p = ECMA_BIGINT_GET_DIGITS (value_p, size); + + if (size == sizeof (ecma_bigint_digit_t)) + { + if (!(value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)) + { + if (digits_p[-1] <= ECMA_INTEGER_NUMBER_MAX) + { + return ecma_make_integer_value ((ecma_integer_value_t) digits_p[-1]); + } + } + else if (digits_p[-1] <= -ECMA_INTEGER_NUMBER_MIN) + { + return ecma_make_integer_value (-(ecma_integer_value_t) digits_p[-1]); + } + } + + uint64_t fraction = 0; + ecma_bigint_digit_t shift_left; + + if (digits_p[-1] == 1) + { + JERRY_ASSERT (size > sizeof (ecma_bigint_digit_t)); + + fraction = ((uint64_t) digits_p[-2]) << (8 * sizeof (ecma_bigint_digit_t)); + shift_left = (uint32_t) (8 * sizeof (ecma_bigint_digit_t)); + + if (size >= 3 * sizeof (ecma_bigint_digit_t)) + { + fraction |= (uint64_t) digits_p[-3]; + } + } + else + { + shift_left = ecma_big_uint_count_leading_zero (digits_p[-1]) + 1; + + fraction = ((uint64_t) digits_p[-1]) << (8 * sizeof (ecma_bigint_digit_t) + shift_left); + + if (size >= 2 * sizeof (ecma_bigint_digit_t)) + { + fraction |= ((uint64_t) digits_p[-2]) << shift_left; + } + + if (size >= 3 * sizeof (ecma_bigint_digit_t)) + { + fraction |= ((uint64_t) digits_p[-3]) >> (8 * sizeof (ecma_bigint_digit_t) - shift_left); + } + } + + uint32_t biased_exp = (uint32_t) (((1 << (ECMA_NUMBER_BIASED_EXP_WIDTH - 1)) - 1) + (size * 8 - shift_left)); + + /* Rounding result. */ + const uint64_t rounding_bit = (((uint64_t) 1) << (8 * sizeof (uint64_t) - ECMA_NUMBER_FRACTION_WIDTH - 1)); + bool round_up = false; + + if (fraction & rounding_bit) + { + round_up = true; + + /* IEEE_754 roundTiesToEven mode: when rounding_bit is set, and all the remaining bits + * are zero, the number needs to be rounded down the bit before rounding_bit is zero. */ + if ((fraction & ((rounding_bit << 2) - 1)) == rounding_bit) + { + round_up = false; + + if ((size >= (3 * sizeof (ecma_bigint_digit_t))) + && (shift_left == (8 * sizeof (ecma_bigint_digit_t)) + || (digits_p[-3] & ((((ecma_bigint_digit_t) 1) << shift_left) - 1)) == 0)) + { + ecma_bigint_digit_t *digits_start_p = ECMA_BIGINT_GET_DIGITS (value_p, 0); + + digits_p -= 3; + + while (digits_p > digits_start_p) + { + if (digits_p[-1] != 0) + { + round_up = true; + break; + } + digits_p--; + } + } + } + } + + if (round_up) + { + fraction += rounding_bit; + fraction >>= (8 * sizeof (uint64_t) - ECMA_NUMBER_FRACTION_WIDTH); + + if (fraction == 0) + { + biased_exp++; + } + } + else + { + fraction >>= (8 * sizeof (uint64_t) - ECMA_NUMBER_FRACTION_WIDTH); + } + + bool sign = (value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN); + ecma_number_t result; + + if (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) + { + result = ecma_number_pack (sign, biased_exp, fraction); + } + else + { + result = ecma_number_make_infinity (sign); + } + + return ecma_make_number_value (result); +} /* ecma_bigint_to_number */] + +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 enum_func_status +php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len, + char *error, int error_buf_len, + unsigned int *error_no, char *sqlstate TSRMLS_DC) +{ + zend_uchar *p = buf; + int error_msg_len= 0; + + DBG_ENTER(""php_mysqlnd_read_error_from_line""); + + *error_no = CR_UNKNOWN_ERROR; + memcpy(sqlstate, unknown_sqlstate, MYSQLND_SQLSTATE_LENGTH); + + if (buf_len > 2) { + *error_no = uint2korr(p); + p+= 2; + /* + sqlstate is following. No need to check for buf_left_len as we checked > 2 above, + if it was >=2 then we would need a check + */ + if (*p == '#') { + ++p; + if ((buf_len - (p - buf)) >= MYSQLND_SQLSTATE_LENGTH) { + memcpy(sqlstate, p, MYSQLND_SQLSTATE_LENGTH); + p+= MYSQLND_SQLSTATE_LENGTH; + } else { + goto end; + } + } + if ((buf_len - (p - buf)) > 0) { + error_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1)); + memcpy(error, p, error_msg_len); + } + } +end: + sqlstate[MYSQLND_SQLSTATE_LENGTH] = '\0'; + error[error_msg_len]= '\0'; + + DBG_RETURN(FAIL);] + +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 test_http_server(void) { + struct mg_mgr mgr; + const char *url = ""http://127.0.0.1:12346""; + char buf[FETCH_BUF_SIZE]; + + mg_mgr_init(&mgr); + mg_http_listen(&mgr, url, eh1, NULL); + + ASSERT(fetch(&mgr, buf, url, ""GET /a.txt HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hello\n"") == 0); + + ASSERT(fetch(&mgr, buf, url, ""GET /%%61.txt HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hello\n"") == 0); + + // Responses with missing reason phrase must also work + ASSERT(fetch(&mgr, buf, url, ""GET /no_reason HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""ok"") == 0); + + // Fetch file with unicode chars in filename + ASSERT(fetch(&mgr, buf, url, ""GET /київ.txt HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""є\n"") == 0); + + ASSERT(fetch(&mgr, buf, url, ""GET /../fuzz.c HTTP/1.0\n\n"") == 404); + ASSERT(fetch(&mgr, buf, url, ""GET /.%%2e/fuzz.c HTTP/1.0\n\n"") == 404); + ASSERT(fetch(&mgr, buf, url, ""GET /.%%2e%%2ffuzz.c HTTP/1.0\n\n"") == 404); + ASSERT(fetch(&mgr, buf, url, ""GET /..%%2f%%20fuzz.c HTTP/1.0\n\n"") == 404); + ASSERT(fetch(&mgr, buf, url, ""GET /..%%2ffuzz.c%%20 HTTP/1.0\n\n"") == 404); + + ASSERT(fetch(&mgr, buf, url, ""GET /dredir HTTP/1.0\n\n"") == 301); + ASSERT(cmpheader(buf, ""Location"", ""/dredir/"")); + + ASSERT(fetch(&mgr, buf, url, ""GET /dredir/ HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hi\n"") == 0); + + ASSERT(fetch(&mgr, buf, url, ""GET /..ddot HTTP/1.0\n\n"") == 301); + ASSERT(fetch(&mgr, buf, url, ""GET /..ddot/ HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hi\n"") == 0); + + { + extern char *mg_http_etag(char *, size_t, size_t, time_t); + char etag[100]; + size_t size = 0; + time_t mtime = 0; + ASSERT(mg_fs_posix.stat(""./test/data/a.txt"", &size, &mtime) != 0); + ASSERT(mg_http_etag(etag, sizeof(etag), size, mtime) == etag); + ASSERT(fetch(&mgr, buf, url, ""GET /a.txt HTTP/1.0\nIf-None-Match: %s\n\n"", + etag) == 304); + } + + // Text mime type override + ASSERT(fetch(&mgr, buf, url, ""GET /servefile HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hello\n"") == 0); + { + struct mg_http_message hm; + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_http_get_header(&hm, ""Content-Type"") != NULL); + ASSERT(mg_strcmp(*mg_http_get_header(&hm, ""Content-Type""), mg_str(""c/d"")) == + 0); + } + + ASSERT(fetch(&mgr, buf, url, ""GET /foo/1 HTTP/1.0\r\n\n"") == 200); + // LOG(LL_INFO, (""%d %.*s"", (int) hm.len, (int) hm.len, hm.buf)); + ASSERT(cmpbody(buf, ""uri: 1"") == 0); + + ASSERT(fetch(&mgr, buf, url, ""%s"", + ""POST /body HTTP/1.1\r\n"" + ""Content-Length: 4\r\n\r\nkuku"") == 200); + ASSERT(cmpbody(buf, ""kuku"") == 0); + + ASSERT(fetch(&mgr, buf, url, ""GET /ssi HTTP/1.1\r\n\r\n"") == 301); + ASSERT(fetch(&mgr, buf, url, ""GET /ssi/ HTTP/1.1\r\n\r\n"") == 200); + ASSERT(cmpbody(buf, + ""this is index\n"" + ""this is nested\n\n"" + ""this is f1\n\n\n\n"" + ""recurse\n\n"" + ""recurse\n\n"" + ""recurse\n\n"" + ""recurse\n\n"" + ""recurse\n\n"") == 0); + { + struct mg_http_message hm; + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_http_get_header(&hm, ""Content-Length"") != NULL); + ASSERT(mg_http_get_header(&hm, ""Content-Type"") != NULL); + ASSERT(mg_strcmp(*mg_http_get_header(&hm, ""Content-Type""), + mg_str(""text/html; charset=utf-8"")) == 0); + } + + ASSERT(fetch(&mgr, buf, url, ""GET /badroot HTTP/1.0\r\n\n"") == 400); + ASSERT(cmpbody(buf, ""Invalid web root [/BAAADDD!]\n"") == 0); + + { + char *data = mg_file_read(""./test/data/ca.pem"", NULL); + ASSERT(fetch(&mgr, buf, url, ""GET /ca.pem HTTP/1.0\r\n\n"") == 200); + ASSERT(cmpbody(buf, data) == 0); + free(data); + } + + { + // Test mime type + struct mg_http_message hm; + ASSERT(fetch(&mgr, buf, url, ""GET /empty.js HTTP/1.0\r\n\n"") == 200); + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_http_get_header(&hm, ""Content-Type"") != NULL); + ASSERT(mg_strcmp(*mg_http_get_header(&hm, ""Content-Type""), + mg_str(""text/javascript; charset=utf-8"")) == 0); + } + + { + // Test connection refused + int i, errored = 0; + mg_connect(&mgr, ""tcp://127.0.0.1:55117"", eh9, &errored); + for (i = 0; i < 10 && errored == 0; i++) mg_mgr_poll(&mgr, 1); + ASSERT(errored == 7); + } + + // Directory listing + fetch(&mgr, buf, url, ""GET /test/ HTTP/1.0\n\n""); + ASSERT(fetch(&mgr, buf, url, ""GET /test/ HTTP/1.0\n\n"") == 200); + ASSERT(mg_strstr(mg_str(buf), mg_str("">Index of /test/<"")) != NULL); + ASSERT(mg_strstr(mg_str(buf), mg_str("">fuzz.c<"")) != NULL); + + { + // Credentials + struct mg_http_message hm; + ASSERT(fetch(&mgr, buf, url, ""%s"", + ""GET /creds?access_token=x HTTP/1.0\r\n\r\n"") == 200); + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_strcmp(hm.body, mg_str(""[]:[x]"")) == 0); + + ASSERT(fetch(&mgr, buf, url, ""%s"", + ""GET /creds HTTP/1.0\r\n"" + ""Authorization: Bearer x\r\n\r\n"") == 200); + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_strcmp(hm.body, mg_str(""[]:[x]"")) == 0); + + ASSERT(fetch(&mgr, buf, url, ""%s"", + ""GET /creds HTTP/1.0\r\n"" + ""Authorization: Basic Zm9vOmJhcg==\r\n\r\n"") == 200); + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_strcmp(hm.body, mg_str(""[foo]:[bar]"")) == 0); + + ASSERT(fetch(&mgr, buf, url, ""%s"", + ""GET /creds HTTP/1.0\r\n"" + ""Cookie: blah; access_token=hello\r\n\r\n"") == 200); + mg_http_parse(buf, strlen(buf), &hm); + ASSERT(mg_strcmp(hm.body, mg_str(""[]:[hello]"")) == 0); + } + + { + // Test upload + char *p; + remove(""uploaded.txt""); + ASSERT((p = mg_file_read(""uploaded.txt"", NULL)) == NULL); + + ASSERT(fetch(&mgr, buf, url, + ""POST /upload HTTP/1.0\n"" + ""Content-Length: 1\n\nx"") == 400); + + ASSERT(fetch(&mgr, buf, url, + ""POST /upload?name=uploaded.txt HTTP/1.0\r\n"" + ""Content-Length: 5\r\n"" + ""\r\nhello"") == 200); + ASSERT(fetch(&mgr, buf, url, + ""POST /upload?name=uploaded.txt&offset=5 HTTP/1.0\r\n"" + ""Content-Length: 6\r\n"" + ""\r\n\nworld"") == 200); + ASSERT((p = mg_file_read(""uploaded.txt"", NULL)) != NULL); + ASSERT(strcmp(p, ""hello\nworld"") == 0); + free(p); + remove(""uploaded.txt""); + } + + // HEAD request + ASSERT(fetch(&mgr, buf, url, ""GET /a.txt HTTP/1.0\n\n"") == 200); + ASSERT(fetch(&mgr, buf, url, ""HEAD /a.txt HTTP/1.0\n\n"") == 200); + +#if MG_ENABLE_IPV6 + { + const char *url6 = ""http://[::1]:12346""; + ASSERT(mg_http_listen(&mgr, url6, eh1, NULL) != NULL); + ASSERT(fetch(&mgr, buf, url6, ""GET /a.txt HTTP/1.0\n\n"") == 200); + ASSERT(cmpbody(buf, ""hello\n"") == 0); + } +#endif + + mg_mgr_free(&mgr); + ASSERT(mgr.conns == NULL); +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, + bgp_size_t size, struct bgp_nlri *mp_update, + struct bgp_nlri *mp_withdraw) +{ + bgp_attr_parse_ret_t ret; + uint8_t flag = 0; + uint8_t type = 0; + bgp_size_t length; + uint8_t *startp, *endp; + uint8_t *attr_endp; + uint8_t seen[BGP_ATTR_BITMAP_SIZE]; + /* we need the as4_path only until we have synthesized the as_path with + * it */ + /* same goes for as4_aggregator */ + struct aspath *as4_path = NULL; + as_t as4_aggregator = 0; + struct in_addr as4_aggregator_addr = {.s_addr = 0}; + + /* Initialize bitmap. */ + memset(seen, 0, BGP_ATTR_BITMAP_SIZE); + + /* End pointer of BGP attribute. */ + endp = BGP_INPUT_PNT(peer) + size; + + /* Get attributes to the end of attribute length. */ + while (BGP_INPUT_PNT(peer) < endp) { + /* Check remaining length check.*/ + if (endp - BGP_INPUT_PNT(peer) < BGP_ATTR_MIN_LEN) { + /* XXX warning: long int format, int arg (arg 5) */ + flog_warn( + EC_BGP_ATTRIBUTE_TOO_SMALL, + ""%s: error BGP attribute length %lu is smaller than min len"", + peer->host, + (unsigned long)(endp + - stream_pnt(BGP_INPUT(peer)))); + + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); + return BGP_ATTR_PARSE_ERROR; + } + + /* Fetch attribute flag and type. */ + startp = BGP_INPUT_PNT(peer); + /* ""The lower-order four bits of the Attribute Flags octet are + unused. They MUST be zero when sent and MUST be ignored when + received."" */ + flag = 0xF0 & stream_getc(BGP_INPUT(peer)); + type = stream_getc(BGP_INPUT(peer)); + + /* Check whether Extended-Length applies and is in bounds */ + if (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) + && ((endp - startp) < (BGP_ATTR_MIN_LEN + 1))) { + flog_warn( + EC_BGP_EXT_ATTRIBUTE_TOO_SMALL, + ""%s: Extended length set, but just %lu bytes of attr header"", + peer->host, + (unsigned long)(endp + - stream_pnt(BGP_INPUT(peer)))); + + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); + return BGP_ATTR_PARSE_ERROR; + } + + /* Check extended attribue length bit. */ + if (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN)) + length = stream_getw(BGP_INPUT(peer)); + else + length = stream_getc(BGP_INPUT(peer)); + + /* If any attribute appears more than once in the UPDATE + message, then the Error Subcode is set to Malformed Attribute + List. */ + + if (CHECK_BITMAP(seen, type)) { + flog_warn( + EC_BGP_ATTRIBUTE_REPEATED, + ""%s: error BGP attribute type %d appears twice in a message"", + peer->host, type); + + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_MAL_ATTR); + return BGP_ATTR_PARSE_ERROR; + } + + /* Set type to bitmap to check duplicate attribute. `type' is + unsigned char so it never overflow bitmap range. */ + + SET_BITMAP(seen, type); + + /* Overflow check. */ + attr_endp = BGP_INPUT_PNT(peer) + length; + + if (attr_endp > endp) { + flog_warn( + EC_BGP_ATTRIBUTE_TOO_LARGE, + ""%s: BGP type %d length %d is too large, attribute total length is %d. attr_endp is %p. endp is %p"", + peer->host, type, length, size, attr_endp, + endp); + /* + * RFC 4271 6.3 + * If any recognized attribute has an Attribute + * Length that conflicts with the expected length + * (based on the attribute type code), then the + * Error Subcode MUST be set to Attribute Length + * Error. The Data field MUST contain the erroneous + * attribute (type, length, and value). + * ---------- + * We do not currently have a good way to determine the + * length of the attribute independent of the length + * received in the message. Instead we send the + * minimum between the amount of data we have and the + * amount specified by the attribute length field. + * + * Instead of directly passing in the packet buffer and + * offset we use the stream_get* functions to read into + * a stack buffer, since they perform bounds checking + * and we are working with untrusted data. + */ + unsigned char ndata[BGP_MAX_PACKET_SIZE]; + memset(ndata, 0x00, sizeof(ndata)); + size_t lfl = + CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) ? 2 : 1; + /* Rewind to end of flag field */ + stream_forward_getp(BGP_INPUT(peer), -(1 + lfl)); + /* Type */ + stream_get(&ndata[0], BGP_INPUT(peer), 1); + /* Length */ + stream_get(&ndata[1], BGP_INPUT(peer), lfl); + /* Value */ + size_t atl = attr_endp - startp; + size_t ndl = MIN(atl, STREAM_READABLE(BGP_INPUT(peer))); + stream_get(&ndata[lfl + 1], BGP_INPUT(peer), ndl); + + bgp_notify_send_with_data( + peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, ndata, + ndl + lfl + 1); + + return BGP_ATTR_PARSE_ERROR; + } + + struct bgp_attr_parser_args attr_args = { + .peer = peer, + .length = length, + .attr = attr, + .type = type, + .flags = flag, + .startp = startp, + .total = attr_endp - startp, + }; + + + /* If any recognized attribute has Attribute Flags that conflict + with the Attribute Type Code, then the Error Subcode is set + to + Attribute Flags Error. The Data field contains the erroneous + attribute (type, length and value). */ + if (bgp_attr_flag_invalid(&attr_args)) { + ret = bgp_attr_malformed( + &attr_args, BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, + attr_args.total); + if (ret == BGP_ATTR_PARSE_PROCEED) + continue; + return ret; + } + + /* OK check attribute and store it's value. */ + switch (type) { + case BGP_ATTR_ORIGIN: + ret = bgp_attr_origin(&attr_args); + break; + case BGP_ATTR_AS_PATH: + ret = bgp_attr_aspath(&attr_args); + break; + case BGP_ATTR_AS4_PATH: + ret = bgp_attr_as4_path(&attr_args, &as4_path); + break; + case BGP_ATTR_NEXT_HOP: + ret = bgp_attr_nexthop(&attr_args); + break; + case BGP_ATTR_MULTI_EXIT_DISC: + ret = bgp_attr_med(&attr_args); + break; + case BGP_ATTR_LOCAL_PREF: + ret = bgp_attr_local_pref(&attr_args); + break; + case BGP_ATTR_ATOMIC_AGGREGATE: + ret = bgp_attr_atomic(&attr_args); + break; + case BGP_ATTR_AGGREGATOR: + ret = bgp_attr_aggregator(&attr_args); + break; + case BGP_ATTR_AS4_AGGREGATOR: + ret = bgp_attr_as4_aggregator(&attr_args, + &as4_aggregator, + &as4_aggregator_addr); + break; + case BGP_ATTR_COMMUNITIES: + ret = bgp_attr_community(&attr_args); + break; + case BGP_ATTR_LARGE_COMMUNITIES: + ret = bgp_attr_large_community(&attr_args); + break; + case BGP_ATTR_ORIGINATOR_ID: + ret = bgp_attr_originator_id(&attr_args); + break; + case BGP_ATTR_CLUSTER_LIST: + ret = bgp_attr_cluster_list(&attr_args); + break; + case BGP_ATTR_MP_REACH_NLRI: + ret = bgp_mp_reach_parse(&attr_args, mp_update); + break; + case BGP_ATTR_MP_UNREACH_NLRI: + ret = bgp_mp_unreach_parse(&attr_args, mp_withdraw); + break; + case BGP_ATTR_EXT_COMMUNITIES: + ret = bgp_attr_ext_communities(&attr_args); + break; +#if ENABLE_BGP_VNC + case BGP_ATTR_VNC: +#endif + case BGP_ATTR_ENCAP: + ret = bgp_attr_encap(type, peer, length, attr, flag, + startp); + break; + case BGP_ATTR_PREFIX_SID: + ret = bgp_attr_prefix_sid(length, + &attr_args, mp_update); + break; + case BGP_ATTR_PMSI_TUNNEL: + ret = bgp_attr_pmsi_tunnel(&attr_args); + break; + default: + ret = bgp_attr_unknown(&attr_args); + break; + } + + if (ret == BGP_ATTR_PARSE_ERROR_NOTIFYPLS) { + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_MAL_ATTR); + ret = BGP_ATTR_PARSE_ERROR; + } + + if (ret == BGP_ATTR_PARSE_EOR) { + if (as4_path) + aspath_unintern(&as4_path); + return ret; + } + + /* If hard error occurred immediately return to the caller. */ + if (ret == BGP_ATTR_PARSE_ERROR) { + flog_warn(EC_BGP_ATTRIBUTE_PARSE_ERROR, + ""%s: Attribute %s, parse error"", peer->host, + lookup_msg(attr_str, type, NULL)); + if (as4_path) + aspath_unintern(&as4_path); + return ret; + } + if (ret == BGP_ATTR_PARSE_WITHDRAW) { + + flog_warn( + EC_BGP_ATTRIBUTE_PARSE_WITHDRAW, + ""%s: Attribute %s, parse error - treating as withdrawal"", + peer->host, lookup_msg(attr_str, type, NULL)); + if (as4_path) + aspath_unintern(&as4_path); + return ret; + } + + /* Check the fetched length. */ + if (BGP_INPUT_PNT(peer) != attr_endp) { + flog_warn(EC_BGP_ATTRIBUTE_FETCH_ERROR, + ""%s: BGP attribute %s, fetch error"", + peer->host, lookup_msg(attr_str, type, NULL)); + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); + if (as4_path) + aspath_unintern(&as4_path); + return BGP_ATTR_PARSE_ERROR; + } + } + + /* Check final read pointer is same as end pointer. */ + if (BGP_INPUT_PNT(peer) != endp) { + flog_warn(EC_BGP_ATTRIBUTES_MISMATCH, + ""%s: BGP attribute %s, length mismatch"", peer->host, + lookup_msg(attr_str, type, NULL)); + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); + if (as4_path) + aspath_unintern(&as4_path); + return BGP_ATTR_PARSE_ERROR; + } + + /* Check all mandatory well-known attributes are present */ + if ((ret = bgp_attr_check(peer, attr)) < 0) { + if (as4_path) + aspath_unintern(&as4_path); + return ret; + } + + /* + * At this place we can see whether we got AS4_PATH and/or + * AS4_AGGREGATOR from a 16Bit peer and act accordingly. + * We can not do this before we've read all attributes because + * the as4 handling does not say whether AS4_PATH has to be sent + * after AS_PATH or not - and when AS4_AGGREGATOR will be send + * in relationship to AGGREGATOR. + * So, to be defensive, we are not relying on any order and read + * all attributes first, including these 32bit ones, and now, + * afterwards, we look what and if something is to be done for as4. + * + * It is possible to not have AS_PATH, e.g. GR EoR and sole + * MP_UNREACH_NLRI. + */ + /* actually... this doesn't ever return failure currently, but + * better safe than sorry */ + if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH)) + && bgp_attr_munge_as4_attrs(peer, attr, as4_path, as4_aggregator, + &as4_aggregator_addr)) { + bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_MAL_ATTR); + if (as4_path) + aspath_unintern(&as4_path); + return BGP_ATTR_PARSE_ERROR; + } + + /* At this stage, we have done all fiddling with as4, and the + * resulting info is in attr->aggregator resp. attr->aspath + * so we can chuck as4_aggregator and as4_path alltogether in + * order to save memory + */ + if (as4_path) { + aspath_unintern(&as4_path); /* unintern - it is in the hash */ + /* The flag that we got this is still there, but that does not + * do any trouble + */ + } + /* + * The ""rest"" of the code does nothing with as4_aggregator. + * there is no memory attached specifically which is not part + * of the attr. + * so ignoring just means do nothing. + */ + /* + * Finally do the checks on the aspath we did not do yet + * because we waited for a potentially synthesized aspath. + */ + if (attr->flag & (ATTR_FLAG_BIT(BGP_ATTR_AS_PATH))) { + ret = bgp_attr_aspath_check(peer, attr); + if (ret != BGP_ATTR_PARSE_PROCEED) + return ret; + } + /* Finally intern unknown attribute. */ + if (attr->transit) + attr->transit = transit_intern(attr->transit); + if (attr->encap_subtlvs) + attr->encap_subtlvs = + encap_intern(attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); +#if ENABLE_BGP_VNC + if (attr->vnc_subtlvs) + attr->vnc_subtlvs = + encap_intern(attr->vnc_subtlvs, VNC_SUBTLV_TYPE); +#endif + + return BGP_ATTR_PARSE_PROCEED; +}] + +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 vmx_update_msr_bitmap_x2apic(struct kvm_vcpu *vcpu, u8 mode) +{ + if (!cpu_has_vmx_msr_bitmap()) + return; + + vmx_reset_x2apic_msrs(vcpu, mode); + + /* + * TPR reads and writes can be virtualized even if virtual interrupt + * delivery is not in use. + */ + vmx_set_intercept_for_msr(vcpu, X2APIC_MSR(APIC_TASKPRI), MSR_TYPE_RW, + !(mode & MSR_BITMAP_MODE_X2APIC)); + + if (mode & MSR_BITMAP_MODE_X2APIC_APICV) { + vmx_enable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_TMCCT), MSR_TYPE_RW); + vmx_disable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_EOI), MSR_TYPE_W); + vmx_disable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_SELF_IPI), MSR_TYPE_W); + } +}] + +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. + [u64 vmx_get_l2_tsc_offset(struct kvm_vcpu *vcpu) +{ + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + + if (nested_cpu_has(vmcs12, CPU_BASED_USE_TSC_OFFSETTING)) + return vmcs12->tsc_offset; + + 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. + [const char *nghttp2_strerror(int error_code) { + switch (error_code) { + case 0: + return ""Success""; + case NGHTTP2_ERR_INVALID_ARGUMENT: + return ""Invalid argument""; + case NGHTTP2_ERR_BUFFER_ERROR: + return ""Out of buffer space""; + case NGHTTP2_ERR_UNSUPPORTED_VERSION: + return ""Unsupported SPDY version""; + case NGHTTP2_ERR_WOULDBLOCK: + return ""Operation would block""; + case NGHTTP2_ERR_PROTO: + return ""Protocol error""; + case NGHTTP2_ERR_INVALID_FRAME: + return ""Invalid frame octets""; + case NGHTTP2_ERR_EOF: + return ""EOF""; + case NGHTTP2_ERR_DEFERRED: + return ""Data transfer deferred""; + case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE: + return ""No more Stream ID available""; + case NGHTTP2_ERR_STREAM_CLOSED: + return ""Stream was already closed or invalid""; + case NGHTTP2_ERR_STREAM_CLOSING: + return ""Stream is closing""; + case NGHTTP2_ERR_STREAM_SHUT_WR: + return ""The transmission is not allowed for this stream""; + case NGHTTP2_ERR_INVALID_STREAM_ID: + return ""Stream ID is invalid""; + case NGHTTP2_ERR_INVALID_STREAM_STATE: + return ""Invalid stream state""; + case NGHTTP2_ERR_DEFERRED_DATA_EXIST: + return ""Another DATA frame has already been deferred""; + case NGHTTP2_ERR_START_STREAM_NOT_ALLOWED: + return ""request HEADERS is not allowed""; + case NGHTTP2_ERR_GOAWAY_ALREADY_SENT: + return ""GOAWAY has already been sent""; + case NGHTTP2_ERR_INVALID_HEADER_BLOCK: + return ""Invalid header block""; + case NGHTTP2_ERR_INVALID_STATE: + return ""Invalid state""; + case NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE: + return ""The user callback function failed due to the temporal error""; + case NGHTTP2_ERR_FRAME_SIZE_ERROR: + return ""The length of the frame is invalid""; + case NGHTTP2_ERR_HEADER_COMP: + return ""Header compression/decompression error""; + case NGHTTP2_ERR_FLOW_CONTROL: + return ""Flow control error""; + case NGHTTP2_ERR_INSUFF_BUFSIZE: + return ""Insufficient buffer size given to function""; + case NGHTTP2_ERR_PAUSE: + return ""Callback was paused by the application""; + case NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS: + return ""Too many inflight SETTINGS""; + case NGHTTP2_ERR_PUSH_DISABLED: + return ""Server push is disabled by peer""; + case NGHTTP2_ERR_DATA_EXIST: + return ""DATA or HEADERS frame has already been submitted for the stream""; + case NGHTTP2_ERR_SESSION_CLOSING: + return ""The current session is closing""; + case NGHTTP2_ERR_HTTP_HEADER: + return ""Invalid HTTP header field was received""; + case NGHTTP2_ERR_HTTP_MESSAGING: + return ""Violation in HTTP messaging rule""; + case NGHTTP2_ERR_REFUSED_STREAM: + return ""Stream was refused""; + case NGHTTP2_ERR_INTERNAL: + return ""Internal error""; + case NGHTTP2_ERR_CANCEL: + return ""Cancel""; + case NGHTTP2_ERR_SETTINGS_EXPECTED: + return ""When a local endpoint expects to receive SETTINGS frame, it "" + ""receives an other type of frame""; + case NGHTTP2_ERR_NOMEM: + return ""Out of memory""; + case NGHTTP2_ERR_CALLBACK_FAILURE: + return ""The user callback function failed""; + case NGHTTP2_ERR_BAD_CLIENT_MAGIC: + return ""Received bad client magic byte string""; + case NGHTTP2_ERR_FLOODED: + return ""Flooding was detected in this HTTP/2 session, and it must be "" + ""closed""; + default: + return ""Unknown error code""; + } +}] + +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 connection_handle_write(request_st * const r, connection * const con) { + /*assert(!chunkqueue_is_empty(cq));*//* checked by callers */ + + if (con->is_writable <= 0) return CON_STATE_WRITE; + int rc = connection_write_chunkqueue(con, con->write_queue, MAX_WRITE_LIMIT); + switch (rc) { + case 0: + if (r->resp_body_finished) { + connection_set_state(r, CON_STATE_RESPONSE_END); + return CON_STATE_RESPONSE_END; + } + break; + case -1: /* error on our side */ + log_error(r->conf.errh, __FILE__, __LINE__, + ""connection closed: write failed on fd %d"", con->fd); + connection_set_state_error(r, CON_STATE_ERROR); + return CON_STATE_ERROR; + case -2: /* remote close */ + connection_set_state_error(r, CON_STATE_ERROR); + return CON_STATE_ERROR; + case 1: + /* do not spin trying to send HTTP/2 server Connection Preface + * while waiting for TLS negotiation to complete */ + if (con->write_queue->bytes_out) + con->is_writable = 0; + + /* not finished yet -> WRITE */ + break; + } + + return CON_STATE_WRITE; /*(state did not change)*/ +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [ void startPreloader() { + TRACE_POINT(); + this_thread::disable_interruption di; + this_thread::disable_syscall_interruption dsi; + assert(!preloaderStarted()); + checkChrootDirectories(options); + + shared_array args; + vector command = createRealPreloaderCommand(options, args); + SpawnPreparationInfo preparation = prepareSpawn(options); + SocketPair adminSocket = createUnixSocketPair(); + Pipe errorPipe = createPipe(); + DebugDirPtr debugDir = make_shared(preparation.uid, preparation.gid); + pid_t pid; + + pid = syscalls::fork(); + if (pid == 0) { + setenv(""PASSENGER_DEBUG_DIR"", debugDir->getPath().c_str(), 1); + purgeStdio(stdout); + purgeStdio(stderr); + resetSignalHandlersAndMask(); + disableMallocDebugging(); + int adminSocketCopy = dup2(adminSocket.first, 3); + int errorPipeCopy = dup2(errorPipe.second, 4); + dup2(adminSocketCopy, 0); + dup2(adminSocketCopy, 1); + dup2(errorPipeCopy, 2); + closeAllFileDescriptors(2); + setChroot(preparation); + switchUser(preparation); + setWorkingDirectory(preparation); + execvp(command[0].c_str(), (char * const *) args.get()); + + int e = errno; + printf(""!> Error\n""); + printf(""!> \n""); + printf(""Cannot execute \""%s\"": %s (errno=%d)\n"", command[0].c_str(), + strerror(e), e); + fprintf(stderr, ""Cannot execute \""%s\"": %s (errno=%d)\n"", + command[0].c_str(), strerror(e), e); + fflush(stdout); + fflush(stderr); + _exit(1); + + } else if (pid == -1) { + int e = errno; + throw SystemException(""Cannot fork a new process"", e); + + } else { + ScopeGuard guard(boost::bind(nonInterruptableKillAndWaitpid, pid)); + adminSocket.first.close(); + errorPipe.second.close(); + + StartupDetails details; + details.adminSocket = adminSocket.second; + details.io = BufferedIO(adminSocket.second); + details.stderrCapturer = + make_shared( + errorPipe.first, + config->forwardStderr ? config->forwardStderrTo : -1); + details.stderrCapturer->start(); + details.debugDir = debugDir; + details.options = &options; + details.timeout = options.startTimeout * 1000; + details.forwardStderr = config->forwardStderr; + details.forwardStderrTo = config->forwardStderrTo; + + { + this_thread::restore_interruption ri(di); + this_thread::restore_syscall_interruption rsi(dsi); + socketAddress = negotiatePreloaderStartup(details); + } + this->adminSocket = adminSocket.second; + { + lock_guard l(simpleFieldSyncher); + this->pid = pid; + } + preloaderOutputWatcher.set(adminSocket.second, ev::READ); + libev->start(preloaderOutputWatcher); + setNonBlocking(errorPipe.first); + preloaderErrorWatcher = make_shared(libev, + errorPipe.first, + config->forwardStderr ? config->forwardStderrTo : -1); + preloaderErrorWatcher->start(); + preloaderAnnotations = debugDir->readAll(); + P_DEBUG(""Preloader for "" << options.appRoot << + "" started on PID "" << pid << + "", listening on "" << socketAddress); + guard.clear(); + } + }] + +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. + [ +uint8_t escaped_char_value( + char* text) +{ + char hex[3]; + int result; + + assert(text[0] == '\\'); + + switch(text[1]) + { + case 'x': + hex[0] = text[2]; + hex[1] = text[3]; + hex[2] = '\0'; + sscanf(hex, ""%x"", &result); + break; + + case 'n': + result = '\n'; + break; + + case 't': + result = '\t'; + break; + + case 'r': + result = '\r'; + break; + + case 'f': + result = '\f'; + break; + + case 'a': + result = '\a'; + break; + + default: + result = text[1]; + } + + return result;] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [set_ref_in_functions(int copyID) +{ + int todo; + hashitem_T *hi = NULL; + ufunc_T *fp; + + todo = (int)func_hashtab.ht_used; + for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi) + { + if (!HASHITEM_EMPTY(hi)) + { + --todo; + fp = HI2UF(hi); + if (!func_name_refcount(fp->uf_name) + && set_ref_in_func(NULL, fp, copyID)) + return TRUE; + } + } + 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. + [int ssh_scp_init(ssh_scp scp) +{ + int rc; + char execbuffer[1024] = {0}; + + if (scp == NULL) { + return SSH_ERROR; + } + + if (scp->state != SSH_SCP_NEW) { + ssh_set_error(scp->session, SSH_FATAL, + ""ssh_scp_init called under invalid state""); + return SSH_ERROR; + } + + SSH_LOG(SSH_LOG_PROTOCOL, + ""Initializing scp session %s %son location '%s'"", + scp->mode == SSH_SCP_WRITE?""write"":""read"", + scp->recursive?""recursive "":"""", + scp->location); + + scp->channel = ssh_channel_new(scp->session); + if (scp->channel == NULL) { + scp->state = SSH_SCP_ERROR; + return SSH_ERROR; + } + + rc = ssh_channel_open_session(scp->channel); + if (rc == SSH_ERROR) { + scp->state = SSH_SCP_ERROR; + return SSH_ERROR; + } + + if (scp->mode == SSH_SCP_WRITE) { + snprintf(execbuffer, sizeof(execbuffer), ""scp -t %s %s"", + scp->recursive ? ""-r"":"""", scp->location); + } else { + snprintf(execbuffer, sizeof(execbuffer), ""scp -f %s %s"", + scp->recursive ? ""-r"":"""", scp->location); + } + + if (ssh_channel_request_exec(scp->channel, execbuffer) == SSH_ERROR) { + scp->state = SSH_SCP_ERROR; + return SSH_ERROR; + } + + if (scp->mode == SSH_SCP_WRITE) { + rc = ssh_scp_response(scp, NULL); + if (rc != 0) { + return SSH_ERROR; + } + } else { + ssh_channel_write(scp->channel, """", 1); + } + + if (scp->mode == SSH_SCP_WRITE) { + scp->state = SSH_SCP_WRITE_INITED; + } else { + scp->state = SSH_SCP_READ_INITED; + } + + return SSH_OK; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static void ssdp_recv(int sd) +{ + ssize_t len; + struct sockaddr sa; + socklen_t salen; + char buf[MAX_PKT_SIZE]; + + memset(buf, 0, sizeof(buf)); + len = recvfrom(sd, buf, sizeof(buf), MSG_DONTWAIT, &sa, &salen); + if (len > 0) { + buf[len] = 0; + + if (sa.sa_family != AF_INET) + return; + + if (strstr(buf, ""M-SEARCH *"")) { + size_t i; + char *ptr, *type; + struct ifsock *ifs; + struct sockaddr_in *sin = (struct sockaddr_in *)&sa; + + ifs = find_outbound(&sa); + if (!ifs) { + logit(LOG_DEBUG, ""No matching socket for client %s"", inet_ntoa(sin->sin_addr)); + return; + } + logit(LOG_DEBUG, ""Matching socket for client %s"", inet_ntoa(sin->sin_addr)); + + type = strcasestr(buf, ""\r\nST:""); + if (!type) { + logit(LOG_DEBUG, ""No Search Type (ST:) found in M-SEARCH *, assuming "" SSDP_ST_ALL); + type = SSDP_ST_ALL; + send_message(ifs, type, &sa); + return; + } + + type = strchr(type, ':'); + if (!type) + return; + type++; + while (isspace(*type)) + type++; + + ptr = strstr(type, ""\r\n""); + if (!ptr) + return; + *ptr = 0; + + for (i = 0; supported_types[i]; i++) { + if (!strcmp(supported_types[i], type)) { + logit(LOG_DEBUG, ""M-SEARCH * ST: %s from %s port %d"", type, + inet_ntoa(sin->sin_addr), ntohs(sin->sin_port)); + send_message(ifs, type, &sa); + return; + } + } + + logit(LOG_DEBUG, ""M-SEARCH * for unsupported ST: %s from %s"", type, + inet_ntoa(sin->sin_addr)); + } + } +}] + +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 DoRealForwardFFT(OpKernelContext* ctx, uint64* fft_shape, + const Tensor& in, Tensor* out) { + // Create the axes (which are always trailing). + const auto axes = Eigen::ArrayXi::LinSpaced(FFTRank, 1, FFTRank); + auto device = ctx->eigen_device(); + auto input = Tensor(in).flat_inner_dims(); + const auto input_dims = input.dimensions(); + + // Slice input to fft_shape on its inner-most dimensions. + Eigen::DSizes input_slice_sizes; + input_slice_sizes[0] = input_dims[0]; + TensorShape temp_shape{input_dims[0]}; + for (int i = 1; i <= FFTRank; ++i) { + input_slice_sizes[i] = fft_shape[i - 1]; + temp_shape.AddDim(fft_shape[i - 1]); + } + OP_REQUIRES(ctx, temp_shape.num_elements() > 0, + errors::InvalidArgument(""Obtained a FFT shape of 0 elements: "", + temp_shape.DebugString())); + + auto output = out->flat_inner_dims(); + const Eigen::DSizes zero_start_indices; + + // Compute the full FFT using a temporary tensor. + Tensor temp; + OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum::v(), + temp_shape, &temp)); + auto full_fft = temp.flat_inner_dims(); + full_fft.device(device) = + input.slice(zero_start_indices, input_slice_sizes) + .template fft(axes); + + // Slice away the negative frequency components. + output.device(device) = + full_fft.slice(zero_start_indices, output.dimensions()); + }] + +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. + [MYSQL_FIELD * +unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, + my_bool default_value, uint server_capabilities) +{ + MYSQL_ROWS *row; + MYSQL_FIELD *field,*result; + ulong lengths[9]; /* Max of fields */ + DBUG_ENTER(""unpack_fields""); + + field= result= (MYSQL_FIELD*) alloc_root(alloc, + (uint) sizeof(*field)*fields); + if (!result) + { + free_rows(data); /* Free old data */ + set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); + DBUG_RETURN(0); + } + bzero((char*) field, (uint) sizeof(MYSQL_FIELD)*fields); + if (server_capabilities & CLIENT_PROTOCOL_41) + { + /* server is 4.1, and returns the new field result format */ + for (row=data->data; row ; row = row->next,field++) + { + uchar *pos; + /* fields count may be wrong */ + DBUG_ASSERT((uint) (field - result) < fields); + cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); + field->catalog= strmake_root(alloc,(char*) row->data[0], lengths[0]); + field->db= strmake_root(alloc,(char*) row->data[1], lengths[1]); + field->table= strmake_root(alloc,(char*) row->data[2], lengths[2]); + field->org_table= strmake_root(alloc,(char*) row->data[3], lengths[3]); + field->name= strmake_root(alloc,(char*) row->data[4], lengths[4]); + field->org_name= strmake_root(alloc,(char*) row->data[5], lengths[5]); + + field->catalog_length= lengths[0]; + field->db_length= lengths[1]; + field->table_length= lengths[2]; + field->org_table_length= lengths[3]; + field->name_length= lengths[4]; + field->org_name_length= lengths[5]; + + /* Unpack fixed length parts */ + if (lengths[6] != 12) + { + /* malformed packet. signal an error. */ + free_rows(data); /* Free old data */ + set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); + DBUG_RETURN(0); + } + + pos= (uchar*) row->data[6]; + field->charsetnr= uint2korr(pos); + field->length= (uint) uint4korr(pos+2); + field->type= (enum enum_field_types) pos[6]; + field->flags= uint2korr(pos+7); + field->decimals= (uint) pos[9]; + + if (IS_NUM(field->type)) + field->flags|= NUM_FLAG; + if (default_value && row->data[7]) + { + field->def=strmake_root(alloc,(char*) row->data[7], lengths[7]); + field->def_length= lengths[7]; + } + else + field->def=0; + field->max_length= 0; + } + } +#ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL + else + { + /* old protocol, for backward compatibility */ + for (row=data->data; row ; row = row->next,field++) + { + cli_fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5); + field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]); + field->name= strdup_root(alloc,(char*) row->data[1]); + field->length= (uint) uint3korr(row->data[2]); + field->type= (enum enum_field_types) (uchar) row->data[3][0]; + + field->catalog=(char*) """"; + field->db= (char*) """"; + field->catalog_length= 0; + field->db_length= 0; + field->org_table_length= field->table_length= lengths[0]; + field->name_length= lengths[1]; + + if (server_capabilities & CLIENT_LONG_FLAG) + { + field->flags= uint2korr(row->data[4]); + field->decimals=(uint) (uchar) row->data[4][2]; + } + else + { + field->flags= (uint) (uchar) row->data[4][0]; + field->decimals=(uint) (uchar) row->data[4][1]; + } + if (IS_NUM(field->type)) + field->flags|= NUM_FLAG; + if (default_value && row->data[5]) + { + field->def=strdup_root(alloc,(char*) row->data[5]); + field->def_length= lengths[5]; + } + else + field->def=0; + field->max_length= 0; + } + } +#endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */ + free_rows(data); /* Free old data */ + DBUG_RETURN(result);] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int main(int argc, char **argv) { + swaylock_log_init(LOG_ERROR); + initialize_pw_backend(argc, argv); + srand(time(NULL)); + + enum line_mode line_mode = LM_LINE; + state.failed_attempts = 0; + state.args = (struct swaylock_args){ + .mode = BACKGROUND_MODE_FILL, + .font = strdup(""sans-serif""), + .font_size = 0, + .radius = 50, + .thickness = 10, + .indicator_x_position = 0, + .indicator_y_position = 0, + .override_indicator_x_position = false, + .override_indicator_y_position = false, + .ignore_empty = false, + .show_indicator = true, + .show_caps_lock_indicator = false, + .show_caps_lock_text = true, + .show_keyboard_layout = false, + .hide_keyboard_layout = false, + .show_failed_attempts = false, + .indicator_idle_visible = false + }; + wl_list_init(&state.images); + set_default_colors(&state.args.colors); + + char *config_path = NULL; + int result = parse_options(argc, argv, NULL, NULL, &config_path); + if (result != 0) { + free(config_path); + return result; + } + if (!config_path) { + config_path = get_config_path(); + } + + if (config_path) { + swaylock_log(LOG_DEBUG, ""Found config at %s"", config_path); + int config_status = load_config(config_path, &state, &line_mode); + free(config_path); + if (config_status != 0) { + free(state.args.font); + return config_status; + } + } + + if (argc > 1) { + swaylock_log(LOG_DEBUG, ""Parsing CLI Args""); + int result = parse_options(argc, argv, &state, &line_mode, NULL); + if (result != 0) { + free(state.args.font); + return result; + } + } + + if (line_mode == LM_INSIDE) { + state.args.colors.line = state.args.colors.inside; + } else if (line_mode == LM_RING) { + state.args.colors.line = state.args.colors.ring; + } + +#ifdef __linux__ + // Most non-linux platforms require root to mlock() + if (mlock(state.password.buffer, sizeof(state.password.buffer)) != 0) { + swaylock_log(LOG_ERROR, ""Unable to mlock() password memory.""); + return EXIT_FAILURE; + } +#endif + + wl_list_init(&state.surfaces); + state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + state.display = wl_display_connect(NULL); + if (!state.display) { + free(state.args.font); + swaylock_log(LOG_ERROR, ""Unable to connect to the compositor. "" + ""If your compositor is running, check or set the "" + ""WAYLAND_DISPLAY environment variable.""); + return EXIT_FAILURE; + } + + struct wl_registry *registry = wl_display_get_registry(state.display); + wl_registry_add_listener(registry, ®istry_listener, &state); + wl_display_roundtrip(state.display); + assert(state.compositor && state.layer_shell && state.shm); + if (!state.input_inhibit_manager) { + free(state.args.font); + swaylock_log(LOG_ERROR, ""Compositor does not support the input "" + ""inhibitor protocol, refusing to run insecurely""); + return 1; + } + + zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager); + if (wl_display_roundtrip(state.display) == -1) { + free(state.args.font); + swaylock_log(LOG_ERROR, ""Exiting - failed to inhibit input:"" + "" is another lockscreen already running?""); + return 2; + } + + if (state.zxdg_output_manager) { + struct swaylock_surface *surface; + wl_list_for_each(surface, &state.surfaces, link) { + surface->xdg_output = zxdg_output_manager_v1_get_xdg_output( + state.zxdg_output_manager, surface->output); + zxdg_output_v1_add_listener( + surface->xdg_output, &_xdg_output_listener, surface); + } + wl_display_roundtrip(state.display); + } else { + swaylock_log(LOG_INFO, ""Compositor does not support zxdg output "" + ""manager, images assigned to named outputs will not work""); + } + + struct swaylock_surface *surface; + wl_list_for_each(surface, &state.surfaces, link) { + create_layer_surface(surface); + } + + if (state.args.daemonize) { + wl_display_roundtrip(state.display); + daemonize(); + } + + state.eventloop = loop_create(); + loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLLIN, + display_in, NULL); + + loop_add_fd(state.eventloop, get_comm_reply_fd(), POLLIN, comm_in, NULL); + + state.run_display = true; + while (state.run_display) { + errno = 0; + if (wl_display_flush(state.display) == -1 && errno != EAGAIN) { + break; + } + loop_poll(state.eventloop); + } + + free(state.args.font); + 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. + [ecma_stringbuilder_create_from (ecma_string_t *string_p) /**< ecma string */ +{ + const lit_utf8_size_t string_size = ecma_string_get_size (string_p); + const lit_utf8_size_t initial_size = string_size + ECMA_ASCII_STRING_HEADER_SIZE; + + ecma_stringbuilder_header_t *header_p = (ecma_stringbuilder_header_t *) jmem_heap_alloc_block (initial_size); + header_p->current_size = initial_size; +#if JERRY_MEM_STATS + jmem_stats_allocate_string_bytes (initial_size); +#endif /* JERRY_MEM_STATS */ + + size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, + ECMA_STRINGBUILDER_STRING_PTR (header_p), + string_size); + JERRY_ASSERT (copied_size == string_size); + + ecma_stringbuilder_t ret = {.header_p = header_p}; + return ret; +} /* ecma_stringbuilder_create_from */] + +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. + [ UnknownRecordContent(const string& zone) : DNSRecordContent(0) + { + d_record.insert(d_record.end(), zone.begin(), zone.end()); + }] + +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. + [lseg_recv(PG_FUNCTION_ARGS) +{ + StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + LSEG *lseg; + + lseg = (LSEG *) palloc(sizeof(LSEG)); + + lseg->p[0].x = pq_getmsgfloat8(buf); + lseg->p[0].y = pq_getmsgfloat8(buf); + lseg->p[1].x = pq_getmsgfloat8(buf); + lseg->p[1].y = pq_getmsgfloat8(buf); + +#ifdef NOT_USED + lseg->m = point_sl(&lseg->p[0], &lseg->p[1]); +#endif + + PG_RETURN_LSEG_P(lseg); +}] + +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 jpc_dec_process_sot(jpc_dec_t *dec, jpc_ms_t *ms) +{ + jpc_dec_tile_t *tile; + jpc_sot_t *sot = &ms->parms.sot; + jas_image_cmptparm_t *compinfos; + jas_image_cmptparm_t *compinfo; + jpc_dec_cmpt_t *cmpt; + int cmptno; + + if (dec->state == JPC_MH) { + + compinfos = jas_malloc(dec->numcomps * sizeof(jas_image_cmptparm_t)); + assert(compinfos); + for (cmptno = 0, cmpt = dec->cmpts, compinfo = compinfos; + cmptno < dec->numcomps; ++cmptno, ++cmpt, ++compinfo) { + compinfo->tlx = 0; + compinfo->tly = 0; + compinfo->prec = cmpt->prec; + compinfo->sgnd = cmpt->sgnd; + compinfo->width = cmpt->width; + compinfo->height = cmpt->height; + compinfo->hstep = cmpt->hstep; + compinfo->vstep = cmpt->vstep; + } + + if (!(dec->image = jas_image_create(dec->numcomps, compinfos, + JAS_CLRSPC_UNKNOWN))) { + return -1; + } + jas_free(compinfos); + + /* Is the packet header information stored in PPM marker segments in + the main header? */ + if (dec->ppmstab) { + /* Convert the PPM marker segment data into a collection of streams + (one stream per tile-part). */ + if (!(dec->pkthdrstreams = jpc_ppmstabtostreams(dec->ppmstab))) { + abort(); + } + jpc_ppxstab_destroy(dec->ppmstab); + dec->ppmstab = 0; + } + } + + if (sot->len > 0) { + dec->curtileendoff = jas_stream_getrwcount(dec->in) - ms->len - + 4 + sot->len; + } else { + dec->curtileendoff = 0; + } + + if (JAS_CAST(int, sot->tileno) >= dec->numtiles) { + jas_eprintf(""invalid tile number in SOT marker segment\n""); + return -1; + } + /* Set the current tile. */ + dec->curtile = &dec->tiles[sot->tileno]; + tile = dec->curtile; + /* Ensure that this is the expected part number. */ + if (sot->partno != tile->partno) { + return -1; + } + if (tile->numparts > 0 && sot->partno >= tile->numparts) { + return -1; + } + if (!tile->numparts && sot->numparts > 0) { + tile->numparts = sot->numparts; + } + + tile->pptstab = 0; + + switch (tile->state) { + case JPC_TILE_INIT: + /* This is the first tile-part for this tile. */ + tile->state = JPC_TILE_ACTIVE; + assert(!tile->cp); + if (!(tile->cp = jpc_dec_cp_copy(dec->cp))) { + return -1; + } + jpc_dec_cp_resetflags(dec->cp); + break; + default: + if (sot->numparts == sot->partno - 1) { + tile->state = JPC_TILE_ACTIVELAST; + } + break; + } + + /* Note: We do not increment the expected tile-part number until + all processing for this tile-part is complete. */ + + /* We should expect to encounter other tile-part header marker + segments next. */ + dec->state = JPC_TPH; + + 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. + [hivex_open (const char *filename, int flags) +{ + hive_h *h = NULL; + + assert (sizeof (struct ntreg_header) == 0x1000); + assert (offsetof (struct ntreg_header, csum) == 0x1fc); + + h = calloc (1, sizeof *h); + if (h == NULL) + goto error; + + h->msglvl = flags & HIVEX_OPEN_MSGLVL_MASK; + + const char *debug = getenv (""HIVEX_DEBUG""); + if (debug && STREQ (debug, ""1"")) + h->msglvl = 2; + + DEBUG (2, ""created handle %p"", h); + + h->writable = !!(flags & HIVEX_OPEN_WRITE); + h->unsafe = !!(flags & HIVEX_OPEN_UNSAFE); + h->filename = strdup (filename); + if (h->filename == NULL) + goto error; + +#ifdef O_CLOEXEC + h->fd = open (filename, O_RDONLY | O_CLOEXEC | O_BINARY); +#else + h->fd = open (filename, O_RDONLY | O_BINARY); +#endif + if (h->fd == -1) + goto error; +#ifndef O_CLOEXEC + fcntl (h->fd, F_SETFD, FD_CLOEXEC); +#endif + + struct stat statbuf; + if (fstat (h->fd, &statbuf) == -1) + goto error; + + h->size = statbuf.st_size; + + if (h->size < 0x2000) { + SET_ERRNO (EINVAL, + ""%s: file is too small to be a Windows NT Registry hive file"", + filename); + goto error; + } + + if (!h->writable) { + h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0); + if (h->addr == MAP_FAILED) + goto error; + + DEBUG (2, ""mapped file at %p"", h->addr); + } else { + h->addr = malloc (h->size); + if (h->addr == NULL) + goto error; + + if (full_read (h->fd, h->addr, h->size) < h->size) + goto error; + + /* We don't need the file descriptor along this path, since we + * have read all the data. + */ + if (close (h->fd) == -1) + goto error; + h->fd = -1; + } + + /* Check header. */ + if (h->hdr->magic[0] != 'r' || + h->hdr->magic[1] != 'e' || + h->hdr->magic[2] != 'g' || + h->hdr->magic[3] != 'f') { + SET_ERRNO (ENOTSUP, + ""%s: not a Windows NT Registry hive file"", filename); + goto error; + } + + /* Check major version. */ + uint32_t major_ver = le32toh (h->hdr->major_ver); + if (major_ver != 1) { + SET_ERRNO (ENOTSUP, + ""%s: hive file major version %"" PRIu32 "" (expected 1)"", + filename, major_ver); + goto error; + } + + h->bitmap = calloc (1 + h->size / 32, 1); + if (h->bitmap == NULL) + goto error; + + /* Header checksum. */ + uint32_t sum = header_checksum (h); + if (sum != le32toh (h->hdr->csum)) { + SET_ERRNO (EINVAL, ""%s: bad checksum in hive header"", filename); + goto error; + } + + for (int t=0; ticonv_cache[t].mutex); + h->iconv_cache[t].handle = NULL; + } + + /* Last modified time. */ + h->last_modified = le64toh ((int64_t) h->hdr->last_modified); + + if (h->msglvl >= 2) { + char *name = _hivex_recode (h, utf16le_to_utf8, + h->hdr->name, 64, NULL); + + fprintf (stderr, + ""hivex_open: header fields:\n"" + "" file version %"" PRIu32 "".%"" PRIu32 ""\n"" + "" sequence nos %"" PRIu32 "" %"" PRIu32 ""\n"" + "" (sequences nos should match if hive was synched at shutdown)\n"" + "" last modified %"" PRIi64 ""\n"" + "" (Windows filetime, x 100 ns since 1601-01-01)\n"" + "" original file name %s\n"" + "" (only 32 chars are stored, name is probably truncated)\n"" + "" root offset 0x%x + 0x1000\n"" + "" end of last page 0x%x + 0x1000 (total file size 0x%zx)\n"" + "" checksum 0x%x (calculated 0x%x)\n"", + major_ver, le32toh (h->hdr->minor_ver), + le32toh (h->hdr->sequence1), le32toh (h->hdr->sequence2), + h->last_modified, + name ? name : ""(conversion failed)"", + le32toh (h->hdr->offset), + le32toh (h->hdr->blocks), h->size, + le32toh (h->hdr->csum), sum); + free (name); + } + + h->rootoffs = le32toh (h->hdr->offset) + 0x1000; + h->endpages = le32toh (h->hdr->blocks) + 0x1000; + + DEBUG (2, ""root offset = 0x%zx"", h->rootoffs); + + /* We'll set this flag when we see a block with the root offset (ie. + * the root block). + */ + int seen_root_block = 0, bad_root_block = 0; + + /* Collect some stats. */ + size_t pages = 0; /* Number of hbin pages read. */ + size_t smallest_page = SIZE_MAX, largest_page = 0; + size_t blocks = 0; /* Total number of blocks found. */ + size_t smallest_block = SIZE_MAX, largest_block = 0, blocks_bytes = 0; + size_t used_blocks = 0; /* Total number of used blocks found. */ + size_t used_size = 0; /* Total size (bytes) of used blocks. */ + + /* Read the pages and blocks. The aim here is to be robust against + * corrupt or malicious registries. So we make sure the loops + * always make forward progress. We add the address of each block + * we read to a hash table so pointers will only reference the start + * of valid blocks. + */ + size_t off; + struct ntreg_hbin_page *page; + for (off = 0x1000; off < h->size; off += le32toh (page->page_size)) { + if (off >= h->endpages) + break; + + page = (struct ntreg_hbin_page *) ((char *) h->addr + off); + if (page->magic[0] != 'h' || + page->magic[1] != 'b' || + page->magic[2] != 'i' || + page->magic[3] != 'n') { + + if (!h->unsafe) { + SET_ERRNO (ENOTSUP, + ""%s: trailing garbage at end of file "" + ""(at 0x%zx, after %zu pages)"", + filename, off, pages); + goto error; + } + + DEBUG (2, + ""page not found at expected offset 0x%zx, "" + ""seeking until one is found or EOF is reached"", + off); + + int found = 0; + while (off < h->size) { + off += 0x1000; + + if (off >= h->endpages) + break; + + page = (struct ntreg_hbin_page *) ((char *) h->addr + off); + if (page->magic[0] == 'h' && + page->magic[1] == 'b' && + page->magic[2] == 'i' && + page->magic[3] == 'n') { + DEBUG (2, ""found next page by seeking at 0x%zx"", off); + found = 1; + break; + } + } + + if (!found) { + DEBUG (2, ""page not found and end of pages section reached""); + break; + } + } + + size_t page_size = le32toh (page->page_size); + DEBUG (2, ""page at 0x%zx, size %zu"", off, page_size); + pages++; + if (page_size < smallest_page) smallest_page = page_size; + if (page_size > largest_page) largest_page = page_size; + + if (page_size <= sizeof (struct ntreg_hbin_page) || + (page_size & 0x0fff) != 0) { + SET_ERRNO (ENOTSUP, + ""%s: page size %zu at 0x%zx, bad registry"", + filename, page_size, off); + goto error; + } + + if (off + page_size > h->size) { + SET_ERRNO (ENOTSUP, + ""%s: page size %zu at 0x%zx extends beyond end of file, bad registry"", + filename, page_size, off); + goto error; + } + + size_t page_offset = le32toh(page->offset_first) + 0x1000; + + if (page_offset != off) { + SET_ERRNO (ENOTSUP, + ""%s: declared page offset (0x%zx) does not match computed "" + ""offset (0x%zx), bad registry"", + filename, page_offset, off); + goto error; + } + + /* Read the blocks in this page. */ + size_t blkoff; + struct ntreg_hbin_block *block; + size_t seg_len; + for (blkoff = off + 0x20; + blkoff < off + page_size; + blkoff += seg_len) { + blocks++; + + int is_root = blkoff == h->rootoffs; + if (is_root) + seen_root_block = 1; + + block = (struct ntreg_hbin_block *) ((char *) h->addr + blkoff); + int used; + seg_len = block_len (h, blkoff, &used); +/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78665 */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored ""-Wstrict-overflow"" + if (seg_len <= 4 || (seg_len & 3) != 0) { +#pragma GCC diagnostic pop + if (is_root || !h->unsafe) { + SET_ERRNO (ENOTSUP, + ""%s, the block at 0x%zx has invalid size %"" PRIu32 + "", bad registry"", + filename, blkoff, le32toh (block->seg_len)); + goto error; + } else { + DEBUG (2, + ""%s: block at 0x%zx has invalid size %"" PRIu32 "", skipping"", + filename, blkoff, le32toh (block->seg_len)); + break; + } + } + + if (h->msglvl >= 2) { + unsigned char *id = (unsigned char *) block->id; + int id0 = id[0], id1 = id[1]; + + fprintf (stderr, ""%s: %s: "" + ""%s block id %d,%d (%c%c) at 0x%zx size %zu%s\n"", + ""hivex"", __func__, + used ? ""used"" : ""free"", + id0, id1, + c_isprint (id0) ? id0 : '.', + c_isprint (id1) ? id1 : '.', + blkoff, + seg_len, is_root ? "" (root)"" : """"); + } + + blocks_bytes += seg_len; + if (seg_len < smallest_block) smallest_block = seg_len; + if (seg_len > largest_block) largest_block = seg_len; + + if (is_root && !used) + bad_root_block = 1; + + if (used) { + used_blocks++; + used_size += seg_len; + + /* Root block must be an nk-block. */ + if (is_root && (block->id[0] != 'n' || block->id[1] != 'k')) + bad_root_block = 1; + + /* Note this blkoff is a valid address. */ + BITMAP_SET (h->bitmap, blkoff); + } + } + } + + if (!seen_root_block) { + SET_ERRNO (ENOTSUP, ""%s: no root block found"", filename); + goto error; + } + + if (bad_root_block) { + SET_ERRNO (ENOTSUP, ""%s: bad root block (free or not nk)"", filename); + goto error; + } + + DEBUG (1, ""successfully read Windows Registry hive file:\n"" + "" pages: %zu [sml: %zu, lge: %zu]\n"" + "" blocks: %zu [sml: %zu, avg: %zu, lge: %zu]\n"" + "" blocks used: %zu\n"" + "" bytes used: %zu"", + pages, smallest_page, largest_page, + blocks, smallest_block, blocks_bytes / blocks, largest_block, + used_blocks, used_size); + + return h; + + error:; + int err = errno; + if (h) { + free (h->bitmap); + if (h->addr && h->size && h->addr != MAP_FAILED) { + if (!h->writable) + munmap (h->addr, h->size); + else + free (h->addr); + } + if (h->fd >= 0) + close (h->fd); + free (h->filename); + free (h); + } + errno = err; + return NULL; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [void address_space_stl_le(AddressSpace *as, hwaddr addr, uint32_t val, + MemTxAttrs attrs, MemTxResult *result) +{ + address_space_stl_internal(as, addr, val, attrs, result, + DEVICE_LITTLE_ENDIAN); +}] + +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 tls1_cbc_remove_padding(const SSL* s, + SSL3_RECORD *rec, + unsigned block_size, + unsigned mac_size) + { + unsigned padding_length, good, to_check, i; + const char has_explicit_iv = + s->version >= TLS1_1_VERSION || s->version == DTLS1_VERSION; + const unsigned overhead = 1 /* padding length byte */ + + mac_size + + (has_explicit_iv ? block_size : 0); + + /* These lengths are all public so we can test them in non-constant + * time. */ + if (overhead > rec->length) + return 0; + + /* We can always safely skip the explicit IV. We check at the beginning + * of this function that the record has at least enough space for the + * IV, MAC and padding length byte. (These can be checked in + * non-constant time because it's all public information.) So, if the + * padding was invalid, then we didn't change |rec->length| and this is + * safe. If the padding was valid then we know that we have at least + * overhead+padding_length bytes of space and so this is still safe + * because overhead accounts for the explicit IV. */ + if (has_explicit_iv) + { + rec->data += block_size; + rec->input += block_size; + rec->length -= block_size; + } + + padding_length = rec->data[rec->length-1]; + + /* NB: if compression is in operation the first packet may not be of + * even length so the padding bug check cannot be performed. This bug + * workaround has been around since SSLeay so hopefully it is either + * fixed now or no buggy implementation supports compression [steve] + */ + if ( (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG) && !s->expand) + { + /* First packet is even in size, so check */ + if ((memcmp(s->s3->read_sequence, ""\0\0\0\0\0\0\0\0"",8) == 0) && + !(padding_length & 1)) + { + s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG; + } + if ((s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) && + padding_length > 0) + { + padding_length--; + } + } + + if (EVP_CIPHER_flags(s->enc_read_ctx->cipher)&EVP_CIPH_FLAG_AEAD_CIPHER) + { + /* padding is already verified */ + rec->length -= padding_length; + return 1; + } + + good = constant_time_ge(rec->length, overhead+padding_length); + /* The padding consists of a length byte at the end of the record and + * then that many bytes of padding, all with the same value as the + * length byte. Thus, with the length byte included, there are i+1 + * bytes of padding. + * + * We can't check just |padding_length+1| bytes because that leaks + * decrypted information. Therefore we always have to check the maximum + * amount of padding possible. (Again, the length of the record is + * public information so we can use it.) */ + to_check = 255; /* maximum amount of padding. */ + if (to_check > rec->length-1) + to_check = rec->length-1; + + for (i = 0; i < to_check; i++) + { + unsigned char mask = constant_time_ge(padding_length, i); + unsigned char b = rec->data[rec->length-1-i]; + /* The final |padding_length+1| bytes should all have the value + * |padding_length|. Therefore the XOR should be zero. */ + good &= ~(mask&(padding_length ^ b)); + } + + /* If any of the final |padding_length+1| bytes had the wrong value, + * one or more of the lower eight bits of |good| will be cleared. We + * AND the bottom 8 bits together and duplicate the result to all the + * bits. */ + good &= good >> 4; + good &= good >> 2; + good &= good >> 1; + good <<= sizeof(good)*8-1; + good = DUPLICATE_MSB_TO_ALL(good); + + padding_length = good & (padding_length+1); + rec->length -= padding_length; + rec->type |= padding_length<<8; /* kludge: pass padding length */ + + return (int)((good & 1) | (~good & -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. + [archive_string_normalize_C(struct archive_string *as, const void *_p, + size_t len, struct archive_string_conv *sc) +{ + const char *s = (const char *)_p; + char *p, *endp; + uint32_t uc, uc2; + size_t w; + int always_replace, n, n2, ret = 0, spair, ts, tm; + int (*parse)(uint32_t *, const char *, size_t); + size_t (*unparse)(char *, size_t, uint32_t); + + always_replace = 1; + ts = 1;/* text size. */ + if (sc->flag & SCONV_TO_UTF16BE) { + unparse = unicode_to_utf16be; + ts = 2; + if (sc->flag & SCONV_FROM_UTF16BE) + always_replace = 0; + } else if (sc->flag & SCONV_TO_UTF16LE) { + unparse = unicode_to_utf16le; + ts = 2; + if (sc->flag & SCONV_FROM_UTF16LE) + always_replace = 0; + } else if (sc->flag & SCONV_TO_UTF8) { + unparse = unicode_to_utf8; + if (sc->flag & SCONV_FROM_UTF8) + always_replace = 0; + } else { + /* + * This case is going to be converted to another + * character-set through iconv. + */ + always_replace = 0; + if (sc->flag & SCONV_FROM_UTF16BE) { + unparse = unicode_to_utf16be; + ts = 2; + } else if (sc->flag & SCONV_FROM_UTF16LE) { + unparse = unicode_to_utf16le; + ts = 2; + } else { + unparse = unicode_to_utf8; + } + } + + if (sc->flag & SCONV_FROM_UTF16BE) { + parse = utf16be_to_unicode; + tm = 1; + spair = 4;/* surrogate pair size in UTF-16. */ + } else if (sc->flag & SCONV_FROM_UTF16LE) { + parse = utf16le_to_unicode; + tm = 1; + spair = 4;/* surrogate pair size in UTF-16. */ + } else { + parse = cesu8_to_unicode; + tm = ts; + spair = 6;/* surrogate pair size in UTF-8. */ + } + + if (archive_string_ensure(as, as->length + len * tm + ts) == NULL) + return (-1); + + p = as->s + as->length; + endp = as->s + as->buffer_length - ts; + while ((n = parse(&uc, s, len)) != 0) { + const char *ucptr, *uc2ptr; + + if (n < 0) { + /* Use a replaced unicode character. */ + UNPARSE(p, endp, uc); + s += n*-1; + len -= n*-1; + ret = -1; + continue; + } else if (n == spair || always_replace) + /* uc is converted from a surrogate pair. + * this should be treated as a changed code. */ + ucptr = NULL; + else + ucptr = s; + s += n; + len -= n; + + /* Read second code point. */ + while ((n2 = parse(&uc2, s, len)) > 0) { + uint32_t ucx[FDC_MAX]; + int ccx[FDC_MAX]; + int cl, cx, i, nx, ucx_size; + int LIndex,SIndex; + uint32_t nfc; + + if (n2 == spair || always_replace) + /* uc2 is converted from a surrogate pair. + * this should be treated as a changed code. */ + uc2ptr = NULL; + else + uc2ptr = s; + s += n2; + len -= n2; + + /* + * If current second code point is out of decomposable + * code points, finding compositions is unneeded. + */ + if (!IS_DECOMPOSABLE_BLOCK(uc2)) { + WRITE_UC(); + REPLACE_UC_WITH_UC2(); + continue; + } + + /* + * Try to combine current code points. + */ + /* + * We have to combine Hangul characters according to + * http://uniicode.org/reports/tr15/#Hangul + */ + if (0 <= (LIndex = uc - HC_LBASE) && + LIndex < HC_LCOUNT) { + /* + * Hangul Composition. + * 1. Two current code points are L and V. + */ + int VIndex = uc2 - HC_VBASE; + if (0 <= VIndex && VIndex < HC_VCOUNT) { + /* Make syllable of form LV. */ + UPDATE_UC(HC_SBASE + + (LIndex * HC_VCOUNT + VIndex) * + HC_TCOUNT); + } else { + WRITE_UC(); + REPLACE_UC_WITH_UC2(); + } + continue; + } else if (0 <= (SIndex = uc - HC_SBASE) && + SIndex < HC_SCOUNT && (SIndex % HC_TCOUNT) == 0) { + /* + * Hangul Composition. + * 2. Two current code points are LV and T. + */ + int TIndex = uc2 - HC_TBASE; + if (0 < TIndex && TIndex < HC_TCOUNT) { + /* Make syllable of form LVT. */ + UPDATE_UC(uc + TIndex); + } else { + WRITE_UC(); + REPLACE_UC_WITH_UC2(); + } + continue; + } else if ((nfc = get_nfc(uc, uc2)) != 0) { + /* A composition to current code points + * is found. */ + UPDATE_UC(nfc); + continue; + } else if ((cl = CCC(uc2)) == 0) { + /* Clearly 'uc2' the second code point is not + * a decomposable code. */ + WRITE_UC(); + REPLACE_UC_WITH_UC2(); + continue; + } + + /* + * Collect following decomposable code points. + */ + cx = 0; + ucx[0] = uc2; + ccx[0] = cl; + COLLECT_CPS(1); + + /* + * Find a composed code in the collected code points. + */ + i = 1; + while (i < ucx_size) { + int j; + + if ((nfc = get_nfc(uc, ucx[i])) == 0) { + i++; + continue; + } + + /* + * nfc is composed of uc and ucx[i]. + */ + UPDATE_UC(nfc); + + /* + * Remove ucx[i] by shifting + * following code points. + */ + for (j = i; j+1 < ucx_size; j++) { + ucx[j] = ucx[j+1]; + ccx[j] = ccx[j+1]; + } + ucx_size --; + + /* + * Collect following code points blocked + * by ucx[i] the removed code point. + */ + if (ucx_size > 0 && i == ucx_size && + nx > 0 && cx == cl) { + cl = ccx[ucx_size-1]; + COLLECT_CPS(ucx_size); + } + /* + * Restart finding a composed code with + * the updated uc from the top of the + * collected code points. + */ + i = 0; + } + + /* + * Apparently the current code points are not + * decomposed characters or already composed. + */ + WRITE_UC(); + for (i = 0; i < ucx_size; i++) + UNPARSE(p, endp, ucx[i]); + + /* + * Flush out remaining canonical combining characters. + */ + if (nx > 0 && cx == cl && len > 0) { + while ((nx = parse(&ucx[0], s, len)) + > 0) { + cx = CCC(ucx[0]); + if (cl > cx) + break; + s += nx; + len -= nx; + cl = cx; + UNPARSE(p, endp, ucx[0]); + } + } + break; + } + if (n2 < 0) { + WRITE_UC(); + /* Use a replaced unicode character. */ + UNPARSE(p, endp, uc2); + s += n2*-1; + len -= n2*-1; + ret = -1; + continue; + } else if (n2 == 0) { + WRITE_UC(); + break; + } + } + as->length = p - as->s; + as->s[as->length] = '\0'; + if (ts == 2) + as->s[as->length+1] = '\0'; + return (ret); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static GF_Err ttml_embed_data(GF_XMLNode *node, u8 *aux_data, u32 aux_data_size, u8 *subs_data, u32 subs_data_size) +{ + u32 i=0; + GF_XMLNode *child; + u32 subs_idx=0; + GF_XMLAttribute *att; + Bool is_source = GF_FALSE; + Bool has_src_att = GF_FALSE; + if (!node || node->type) return GF_BAD_PARAM; + + if (!strcmp(node->name, ""source"")) { + is_source = GF_TRUE; + } + + while ((att = gf_list_enum(node->attributes, &i))) { + char *sep, *fext; + if (strcmp(att->name, ""src"")) continue; + has_src_att = GF_TRUE; + if (strncmp(att->value, ""urn:"", 4)) continue; + sep = strrchr(att->value, ':'); + if (!sep) continue; + sep++; + fext = gf_file_ext_start(sep); + if (fext) fext[0] = 0; + subs_idx = atoi(sep); + if (fext) fext[0] = '.'; + if (!subs_idx || ((subs_idx-1) * 14 > subs_data_size)) { + subs_idx = 0; + continue; + } + break; + } + if (subs_idx) { + GF_XMLNode *data; + u32 subs_offset = 0; + u32 subs_size = 0; + u32 idx = 1; + //fetch subsample info + for (i=0; i aux_data_size)) { + if (!subs_size) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (""No subsample with index %u in sample\n"", subs_idx)); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (""Corrupted subsample %u info, size %u offset %u but sample size %u\n"", subs_idx, subs_size, subs_offset, aux_data_size)); + } + return GF_NON_COMPLIANT_BITSTREAM; + } + + //remove src attribute + gf_list_del_item(node->attributes, att); + if (att->name) gf_free(att->name); + if (att->value) gf_free(att->value); + gf_free(att); + + //create a source node + if (!is_source) { + GF_XMLNode *s; + GF_SAFEALLOC(s, GF_XMLNode); + if (!s) return GF_OUT_OF_MEM; + s->attributes = gf_list_new(); + s->content = gf_list_new(); + s->name = gf_strdup(""source""); + gf_list_add(node->content, s); + if (!s->name || !s->content || !s->attributes) return GF_OUT_OF_MEM; + //move @type to source + att = ttml_get_attr(node, ""type""); + if (att) { + gf_list_del_item(node->attributes, att); + gf_list_add(s->attributes, att); + } + node = s; + } + + //create a data node + GF_SAFEALLOC(data, GF_XMLNode); + if (!data) return GF_OUT_OF_MEM; + data->attributes = gf_list_new(); + data->content = gf_list_new(); + data->name = gf_strdup(""data""); + gf_list_add(node->content, data); + if (!data->name || !data->content || !data->attributes) return GF_OUT_OF_MEM; + //move @type to data + att = ttml_get_attr(node, ""type""); + if (att) { + gf_list_del_item(node->attributes, att); + gf_list_add(data->attributes, att); + } + //base64 encode in a child + GF_SAFEALLOC(node, GF_XMLNode) + if (!node) return GF_OUT_OF_MEM; + node->type = GF_XML_TEXT_TYPE; + node->name = gf_malloc(sizeof(u8) * subs_size * 2); + if (!node->name) { + gf_free(node); + return GF_OUT_OF_MEM; + } + subs_size = gf_base64_encode(aux_data + subs_offset, subs_size, (u8*) node->name, subs_size * 2); + node->name[subs_size] = 0; + return gf_list_add(data->content, node); + } + //src was present but not an embedded data, do not recurse + if (has_src_att) return GF_OK; + + i=0; + while ((child = gf_list_enum(node->content, &i))) { + if (child->type) continue; + ttml_embed_data(child, aux_data, aux_data_size, subs_data, subs_data_size); + } + return GF_OK; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) +{ + int r; + sigset_t sigsaved; + + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { + kvm_vcpu_block(vcpu); + clear_bit(KVM_REQ_UNHALT, &vcpu->requests); + r = -EAGAIN; + goto out; + } + + if (vcpu->mmio_needed) { + memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); + kvm_set_mmio_data(vcpu); + vcpu->mmio_read_completed = 1; + vcpu->mmio_needed = 0; + } + r = __vcpu_run(vcpu, kvm_run); +out: + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &sigsaved, NULL); + + return r; +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static int fcn_print_legacy(RCore *core, RAnalFunction *fcn) { + RListIter *iter; + RAnalRef *refi; + RList *refs, *xrefs; + int ebbs = 0; + char *name = r_core_anal_fcn_name (core, fcn); + + r_cons_printf (""#\noffset: 0x%08""PFMT64x""\nname: %s\nsize: %""PFMT64u, + fcn->addr, name, r_anal_function_linear_size (fcn)); + r_cons_printf (""\nis-pure: %s"", r_str_bool (r_anal_function_purity (fcn))); + r_cons_printf (""\nrealsz: %"" PFMT64d, r_anal_function_realsize (fcn)); + r_cons_printf (""\nstackframe: %d"", fcn->maxstack); + if (fcn->cc) { + r_cons_printf (""\ncall-convention: %s"", fcn->cc); + } + r_cons_printf (""\ncyclomatic-cost: %d"", r_anal_function_cost (fcn)); + r_cons_printf (""\ncyclomatic-complexity: %d"", r_anal_function_complexity (fcn)); + r_cons_printf (""\nbits: %d"", fcn->bits); + r_cons_printf (""\ntype: %s"", r_anal_functiontype_tostring (fcn->type)); + if (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) { + r_cons_printf ("" [%s]"", + fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?""MATCH"": + fcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?""UNMATCH"":""NEW""); + } + r_cons_printf (""\nnum-bbs: %d"", r_list_length (fcn->bbs)); + r_cons_printf (""\nedges: %d"", r_anal_function_count_edges (fcn, &ebbs)); + r_cons_printf (""\nend-bbs: %d"", ebbs); + r_cons_printf (""\ncall-refs:""); + int outdegree = 0; + refs = r_anal_function_get_refs (fcn); + r_list_foreach (refs, iter, refi) { + if (refi->type == R_ANAL_REF_TYPE_CALL) { + outdegree++; + } + if (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) { + r_cons_printf ("" 0x%08""PFMT64x"" %c"", refi->addr, + refi->type == R_ANAL_REF_TYPE_CALL?'C':'J'); + } + } + r_cons_printf (""\ndata-refs:""); + r_list_foreach (refs, iter, refi) { + // global or local? + if (refi->type == R_ANAL_REF_TYPE_DATA) { + r_cons_printf ("" 0x%08""PFMT64x, refi->addr); + } + } + r_list_free (refs); + + int indegree = 0; + r_cons_printf (""\ncode-xrefs:""); + xrefs = r_anal_function_get_xrefs (fcn); + r_list_foreach (xrefs, iter, refi) { + if (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) { + indegree++; + r_cons_printf ("" 0x%08""PFMT64x"" %c"", refi->addr, + refi->type == R_ANAL_REF_TYPE_CALL?'C':'J'); + } + } + r_cons_printf (""\nnoreturn: %s"", r_str_bool (fcn->is_noreturn)); + r_cons_printf (""\nin-degree: %d"", indegree); + r_cons_printf (""\nout-degree: %d"", outdegree); + r_cons_printf (""\ndata-xrefs:""); + r_list_foreach (xrefs, iter, refi) { + if (refi->type == R_ANAL_REF_TYPE_DATA) { + r_cons_printf ("" 0x%08""PFMT64x, refi->addr); + } + } + r_list_free (xrefs); + + if (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) { + int args_count = r_anal_var_count_args (fcn); + int var_count = r_anal_var_count_locals (fcn); + + r_cons_printf (""\nlocals: %d\nargs: %d\n"", var_count, args_count); + r_anal_var_list_show (core->anal, fcn, 'b', 0, NULL); + r_anal_var_list_show (core->anal, fcn, 's', 0, NULL); + r_anal_var_list_show (core->anal, fcn, 'r', 0, NULL); + r_cons_printf (""diff: type: %s"", + fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?""match"": + fcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?""unmatch"":""new""); + if (fcn->diff->addr != -1) { + r_cons_printf (""addr: 0x%""PFMT64x, fcn->diff->addr); + } + if (fcn->diff->name) { + r_cons_printf (""function: %s"", fcn->diff->name); + } + } + free (name); + + // traced + if (core->dbg->trace->enabled) { + is_fcn_traced (core->dbg->trace, fcn); + } + 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. + [term_is_gui(char_u *name) +{ + return (STRCMP(name, ""builtin_gui"") == 0 || STRCMP(name, ""gui"") == 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 llparse_state_t llhttp__internal__run( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + int match; + switch ((llparse_state_t) (intptr_t) state->_current) { + case s_n_llhttp__internal__n_invoke_llhttp__after_message_complete: + s_n_llhttp__internal__n_invoke_llhttp__after_message_complete: { + switch (llhttp__after_message_complete(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_finish_1; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_pause_1: + s_n_llhttp__internal__n_pause_1: { + state->error = 0x16; + state->reason = ""Pause on CONNECT/Upgrade""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_llhttp__after_message_complete; + return s_error; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_is_equal_upgrade: + s_n_llhttp__internal__n_invoke_is_equal_upgrade: { + switch (llhttp__internal__c_is_equal_upgrade(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_llhttp__after_message_complete; + default: + goto s_n_llhttp__internal__n_pause_1; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2: + s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2: { + switch (llhttp__on_message_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_is_equal_upgrade; + case 21: + goto s_n_llhttp__internal__n_pause_5; + default: + goto s_n_llhttp__internal__n_error_10; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_data_almost_done_skip: + s_n_llhttp__internal__n_chunk_data_almost_done_skip: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_data_almost_done_skip; + } + p++; + goto s_n_llhttp__internal__n_invoke_llhttp__on_chunk_complete; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_data_almost_done: + s_n_llhttp__internal__n_chunk_data_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_data_almost_done; + } + p++; + goto s_n_llhttp__internal__n_chunk_data_almost_done_skip; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_consume_content_length: + s_n_llhttp__internal__n_consume_content_length: { + size_t avail; + uint64_t need; + + avail = endp - p; + need = state->content_length; + if (avail >= need) { + p += need; + state->content_length = 0; + goto s_n_llhttp__internal__n_span_end_llhttp__on_body; + } + + state->content_length -= avail; + return s_n_llhttp__internal__n_consume_content_length; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_body: + s_n_llhttp__internal__n_span_start_llhttp__on_body: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_body; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_body; + goto s_n_llhttp__internal__n_consume_content_length; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_is_equal_content_length: + s_n_llhttp__internal__n_invoke_is_equal_content_length: { + switch (llhttp__internal__c_is_equal_content_length(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_span_start_llhttp__on_body; + default: + goto s_n_llhttp__internal__n_invoke_or_flags; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_size_almost_done: + s_n_llhttp__internal__n_chunk_size_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_size_almost_done; + } + p++; + goto s_n_llhttp__internal__n_invoke_llhttp__on_chunk_header; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_parameters: + s_n_llhttp__internal__n_chunk_parameters: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_chunk_parameters; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_chunk_parameters; + } + case 2: { + p++; + goto s_n_llhttp__internal__n_chunk_size_almost_done; + } + default: { + goto s_n_llhttp__internal__n_error_6; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_size_otherwise: + s_n_llhttp__internal__n_chunk_size_otherwise: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_size_otherwise; + } + switch (*p) { + case 13: { + p++; + goto s_n_llhttp__internal__n_chunk_size_almost_done; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_chunk_parameters; + } + case ';': { + p++; + goto s_n_llhttp__internal__n_chunk_parameters; + } + default: { + goto s_n_llhttp__internal__n_error_7; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_size: + s_n_llhttp__internal__n_chunk_size: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_size; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'A': { + p++; + match = 10; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'B': { + p++; + match = 11; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'C': { + p++; + match = 12; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'D': { + p++; + match = 13; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'E': { + p++; + match = 14; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'F': { + p++; + match = 15; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'a': { + p++; + match = 10; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'b': { + p++; + match = 11; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'c': { + p++; + match = 12; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'd': { + p++; + match = 13; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'e': { + p++; + match = 14; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'f': { + p++; + match = 15; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + default: { + goto s_n_llhttp__internal__n_chunk_size_otherwise; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_chunk_size_digit: + s_n_llhttp__internal__n_chunk_size_digit: { + if (p == endp) { + return s_n_llhttp__internal__n_chunk_size_digit; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'A': { + p++; + match = 10; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'B': { + p++; + match = 11; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'C': { + p++; + match = 12; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'D': { + p++; + match = 13; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'E': { + p++; + match = 14; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'F': { + p++; + match = 15; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'a': { + p++; + match = 10; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'b': { + p++; + match = 11; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'c': { + p++; + match = 12; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'd': { + p++; + match = 13; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'e': { + p++; + match = 14; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + case 'f': { + p++; + match = 15; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length; + } + default: { + goto s_n_llhttp__internal__n_error_9; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_update_content_length: + s_n_llhttp__internal__n_invoke_update_content_length: { + switch (llhttp__internal__c_update_content_length(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_chunk_size_digit; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_consume_content_length_1: + s_n_llhttp__internal__n_consume_content_length_1: { + size_t avail; + uint64_t need; + + avail = endp - p; + need = state->content_length; + if (avail >= need) { + p += need; + state->content_length = 0; + goto s_n_llhttp__internal__n_span_end_llhttp__on_body_1; + } + + state->content_length -= avail; + return s_n_llhttp__internal__n_consume_content_length_1; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_body_1: + s_n_llhttp__internal__n_span_start_llhttp__on_body_1: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_body_1; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_body; + goto s_n_llhttp__internal__n_consume_content_length_1; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_eof: + s_n_llhttp__internal__n_eof: { + if (p == endp) { + return s_n_llhttp__internal__n_eof; + } + p++; + goto s_n_llhttp__internal__n_eof; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_body_2: + s_n_llhttp__internal__n_span_start_llhttp__on_body_2: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_body_2; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_body; + goto s_n_llhttp__internal__n_eof; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete: + s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete: { + switch (llhttp__after_headers_complete(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_1; + case 2: + goto s_n_llhttp__internal__n_invoke_update_content_length; + case 3: + goto s_n_llhttp__internal__n_span_start_llhttp__on_body_1; + case 4: + goto s_n_llhttp__internal__n_invoke_update_finish_2; + case 5: + goto s_n_llhttp__internal__n_error_11; + default: + goto s_n_llhttp__internal__n_invoke_llhttp__on_message_complete; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_headers_almost_done: + s_n_llhttp__internal__n_headers_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_headers_almost_done; + } + p++; + goto s_n_llhttp__internal__n_invoke_test_flags; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_colon_discard_ws: + s_n_llhttp__internal__n_header_field_colon_discard_ws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field_colon_discard_ws; + } + switch (*p) { + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_field_colon_discard_ws; + } + default: { + goto s_n_llhttp__internal__n_header_field_colon; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_error_15: + s_n_llhttp__internal__n_error_15: { + state->error = 0xa; + state->reason = ""Invalid header field char""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_header_value: + s_n_llhttp__internal__n_span_start_llhttp__on_header_value: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_header_value; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_header_value; + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_discard_lws: + s_n_llhttp__internal__n_header_value_discard_lws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_discard_lws; + } + switch (*p) { + case 9: { + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + } + default: { + goto s_n_llhttp__internal__n_invoke_load_header_state; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_discard_ws_almost_done: + s_n_llhttp__internal__n_header_value_discard_ws_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_discard_ws_almost_done; + } + p++; + goto s_n_llhttp__internal__n_header_value_discard_lws; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_lws: + s_n_llhttp__internal__n_header_value_lws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_lws; + } + switch (*p) { + case 9: { + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1; + } + case ' ': { + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1; + } + default: { + goto s_n_llhttp__internal__n_invoke_load_header_state_3; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_almost_done: + s_n_llhttp__internal__n_header_value_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_almost_done; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_header_value_lws; + } + default: { + goto s_n_llhttp__internal__n_error_17; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_lenient: + s_n_llhttp__internal__n_header_value_lenient: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_lenient; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_1; + } + case 13: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_3; + } + default: { + p++; + goto s_n_llhttp__internal__n_header_value_lenient; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_otherwise: + s_n_llhttp__internal__n_header_value_otherwise: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_otherwise; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_1; + } + case 13: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2; + } + default: { + goto s_n_llhttp__internal__n_invoke_test_flags_5; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection_token: + s_n_llhttp__internal__n_header_value_connection_token: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection_token; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_header_value_connection_token; + } + case 2: { + p++; + goto s_n_llhttp__internal__n_header_value_connection; + } + default: { + goto s_n_llhttp__internal__n_header_value_otherwise; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection_ws: + s_n_llhttp__internal__n_header_value_connection_ws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection_ws; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_header_value_otherwise; + } + case 13: { + goto s_n_llhttp__internal__n_header_value_otherwise; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_connection_ws; + } + case ',': { + p++; + goto s_n_llhttp__internal__n_invoke_load_header_state_4; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_header_state_4; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection_1: + s_n_llhttp__internal__n_header_value_connection_1: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection_1; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob4, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_update_header_state_2; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_value_connection_1; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_header_value_connection_token; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection_2: + s_n_llhttp__internal__n_header_value_connection_2: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection_2; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob5, 9); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_update_header_state_5; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_value_connection_2; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_header_value_connection_token; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection_3: + s_n_llhttp__internal__n_header_value_connection_3: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection_3; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob6, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_update_header_state_6; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_value_connection_3; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_header_value_connection_token; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_connection: + s_n_llhttp__internal__n_header_value_connection: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_connection; + } + switch (((*p) >= 'A' && (*p) <= 'Z' ? (*p | 0x20) : (*p))) { + case 9: { + p++; + goto s_n_llhttp__internal__n_header_value_connection; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_connection; + } + case 'c': { + p++; + goto s_n_llhttp__internal__n_header_value_connection_1; + } + case 'k': { + p++; + goto s_n_llhttp__internal__n_header_value_connection_2; + } + case 'u': { + p++; + goto s_n_llhttp__internal__n_header_value_connection_3; + } + default: { + goto s_n_llhttp__internal__n_header_value_connection_token; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_error_20: + s_n_llhttp__internal__n_error_20: { + state->error = 0xb; + state->reason = ""Content-Length overflow""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_error_21: + s_n_llhttp__internal__n_error_21: { + state->error = 0xb; + state->reason = ""Invalid character in Content-Length""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_content_length_ws: + s_n_llhttp__internal__n_header_value_content_length_ws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_content_length_ws; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_invoke_or_flags_15; + } + case 13: { + goto s_n_llhttp__internal__n_invoke_or_flags_15; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_content_length_ws; + } + default: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_5; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_content_length: + s_n_llhttp__internal__n_header_value_content_length: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_content_length; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_mul_add_content_length_1; + } + default: { + goto s_n_llhttp__internal__n_header_value_content_length_ws; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_te_chunked_last: + s_n_llhttp__internal__n_header_value_te_chunked_last: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_te_chunked_last; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_invoke_update_header_state_7; + } + case 13: { + goto s_n_llhttp__internal__n_invoke_update_header_state_7; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_te_chunked_last; + } + default: { + goto s_n_llhttp__internal__n_header_value_te_chunked; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_te_token_ows: + s_n_llhttp__internal__n_header_value_te_token_ows: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_te_token_ows; + } + switch (*p) { + case 9: { + p++; + goto s_n_llhttp__internal__n_header_value_te_token_ows; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_te_token_ows; + } + default: { + goto s_n_llhttp__internal__n_header_value_te_chunked; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value: + s_n_llhttp__internal__n_header_value: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_header_value; + } + #ifdef __SSE4_2__ + if (endp - p >= 16) { + __m128i ranges; + __m128i input; + int avail; + int match_len; + + /* Load input */ + input = _mm_loadu_si128((__m128i const*) p); + ranges = _mm_loadu_si128((__m128i const*) llparse_blob8); + + /* Find first character that does not match `ranges` */ + match_len = _mm_cmpestri(ranges, 6, + input, 16, + _SIDD_UBYTE_OPS | _SIDD_CMP_RANGES | + _SIDD_NEGATIVE_POLARITY); + + if (match_len != 0) { + p += match_len; + goto s_n_llhttp__internal__n_header_value; + } + goto s_n_llhttp__internal__n_header_value_otherwise; + } + #endif /* __SSE4_2__ */ + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_header_value; + } + default: { + goto s_n_llhttp__internal__n_header_value_otherwise; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_te_token: + s_n_llhttp__internal__n_header_value_te_token: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_header_value_te_token; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_header_value_te_token; + } + case 2: { + p++; + goto s_n_llhttp__internal__n_header_value_te_token_ows; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_header_state_8; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_te_chunked: + s_n_llhttp__internal__n_header_value_te_chunked: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_value_te_chunked; + } + match_seq = llparse__match_sequence_to_lower_unsafe(state, p, endp, llparse_blob7, 7); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_header_value_te_chunked_last; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_value_te_chunked; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_header_value_te_token; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1: + s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_header_value; + goto s_n_llhttp__internal__n_invoke_load_header_state_2; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_value_discard_ws: + s_n_llhttp__internal__n_header_value_discard_ws: { + if (p == endp) { + return s_n_llhttp__internal__n_header_value_discard_ws; + } + switch (*p) { + case 9: { + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + } + case 10: { + p++; + goto s_n_llhttp__internal__n_header_value_discard_lws; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws_almost_done; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + } + default: { + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value_1; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_general_otherwise: + s_n_llhttp__internal__n_header_field_general_otherwise: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field_general_otherwise; + } + switch (*p) { + case ':': { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_field_2; + } + default: { + goto s_n_llhttp__internal__n_error_22; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_general: + s_n_llhttp__internal__n_header_field_general: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llhttp__internal__n_header_field_general; + } + #ifdef __SSE4_2__ + if (endp - p >= 16) { + __m128i ranges; + __m128i input; + int avail; + int match_len; + + /* Load input */ + input = _mm_loadu_si128((__m128i const*) p); + ranges = _mm_loadu_si128((__m128i const*) llparse_blob9); + + /* Find first character that does not match `ranges` */ + match_len = _mm_cmpestri(ranges, 16, + input, 16, + _SIDD_UBYTE_OPS | _SIDD_CMP_RANGES | + _SIDD_NEGATIVE_POLARITY); + + if (match_len != 0) { + p += match_len; + goto s_n_llhttp__internal__n_header_field_general; + } + ranges = _mm_loadu_si128((__m128i const*) llparse_blob10); + + /* Find first character that does not match `ranges` */ + match_len = _mm_cmpestri(ranges, 2, + input, 16, + _SIDD_UBYTE_OPS | _SIDD_CMP_RANGES | + _SIDD_NEGATIVE_POLARITY); + + if (match_len != 0) { + p += match_len; + goto s_n_llhttp__internal__n_header_field_general; + } + goto s_n_llhttp__internal__n_header_field_general_otherwise; + } + #endif /* __SSE4_2__ */ + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_header_field_general; + } + default: { + goto s_n_llhttp__internal__n_header_field_general_otherwise; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_colon: + s_n_llhttp__internal__n_header_field_colon: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field_colon; + } + switch (*p) { + case ' ': { + goto s_n_llhttp__internal__n_invoke_test_flags_4; + } + case ':': { + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_field_1; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_header_state_9; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_3: + s_n_llhttp__internal__n_header_field_3: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_3; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob3, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_header_state; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_3; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_4: + s_n_llhttp__internal__n_header_field_4: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_4; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob11, 10); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_header_state; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_4; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_2: + s_n_llhttp__internal__n_header_field_2: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field_2; + } + switch (((*p) >= 'A' && (*p) <= 'Z' ? (*p | 0x20) : (*p))) { + case 'n': { + p++; + goto s_n_llhttp__internal__n_header_field_3; + } + case 't': { + p++; + goto s_n_llhttp__internal__n_header_field_4; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_1: + s_n_llhttp__internal__n_header_field_1: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_1; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob2, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_header_field_2; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_1; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_5: + s_n_llhttp__internal__n_header_field_5: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_5; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob12, 15); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_header_state; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_5; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_6: + s_n_llhttp__internal__n_header_field_6: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_6; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob13, 16); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_header_state; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_6; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_7: + s_n_llhttp__internal__n_header_field_7: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_header_field_7; + } + match_seq = llparse__match_sequence_to_lower(state, p, endp, llparse_blob14, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_header_state; + } + case kMatchPause: { + return s_n_llhttp__internal__n_header_field_7; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field: + s_n_llhttp__internal__n_header_field: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field; + } + switch (((*p) >= 'A' && (*p) <= 'Z' ? (*p | 0x20) : (*p))) { + case 'c': { + p++; + goto s_n_llhttp__internal__n_header_field_1; + } + case 'p': { + p++; + goto s_n_llhttp__internal__n_header_field_5; + } + case 't': { + p++; + goto s_n_llhttp__internal__n_header_field_6; + } + case 'u': { + p++; + goto s_n_llhttp__internal__n_header_field_7; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_header_state_10; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_header_field: + s_n_llhttp__internal__n_span_start_llhttp__on_header_field: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_header_field; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_header_field; + goto s_n_llhttp__internal__n_header_field; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_header_field_start: + s_n_llhttp__internal__n_header_field_start: { + if (p == endp) { + return s_n_llhttp__internal__n_header_field_start; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_headers_almost_done; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_headers_almost_done; + } + default: { + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_field; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_skip_to_http09: + s_n_llhttp__internal__n_url_skip_to_http09: { + if (p == endp) { + return s_n_llhttp__internal__n_url_skip_to_http09; + } + p++; + goto s_n_llhttp__internal__n_invoke_update_http_major; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_skip_lf_to_http09: + s_n_llhttp__internal__n_url_skip_lf_to_http09: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_url_skip_lf_to_http09; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob15, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_update_http_major; + } + case kMatchPause: { + return s_n_llhttp__internal__n_url_skip_lf_to_http09; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_23; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_end_1: + s_n_llhttp__internal__n_req_http_end_1: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_end_1; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_header_field_start; + } + default: { + goto s_n_llhttp__internal__n_error_24; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_end: + s_n_llhttp__internal__n_req_http_end: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_end; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_header_field_start; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_req_http_end_1; + } + default: { + goto s_n_llhttp__internal__n_error_24; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_minor: + s_n_llhttp__internal__n_req_http_minor: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_minor; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_store_http_minor; + } + default: { + goto s_n_llhttp__internal__n_error_25; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_dot: + s_n_llhttp__internal__n_req_http_dot: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_dot; + } + switch (*p) { + case '.': { + p++; + goto s_n_llhttp__internal__n_req_http_minor; + } + default: { + goto s_n_llhttp__internal__n_error_26; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_major: + s_n_llhttp__internal__n_req_http_major: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_major; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_store_http_major; + } + default: { + goto s_n_llhttp__internal__n_error_27; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_start_1: + s_n_llhttp__internal__n_req_http_start_1: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_req_http_start_1; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob16, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_req_http_major; + } + case kMatchPause: { + return s_n_llhttp__internal__n_req_http_start_1; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_29; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_start_2: + s_n_llhttp__internal__n_req_http_start_2: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_req_http_start_2; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob17, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_is_equal_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_req_http_start_2; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_29; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_http_start: + s_n_llhttp__internal__n_req_http_start: { + if (p == endp) { + return s_n_llhttp__internal__n_req_http_start; + } + switch (*p) { + case ' ': { + p++; + goto s_n_llhttp__internal__n_req_http_start; + } + case 'H': { + p++; + goto s_n_llhttp__internal__n_req_http_start_1; + } + case 'I': { + p++; + goto s_n_llhttp__internal__n_req_http_start_2; + } + default: { + goto s_n_llhttp__internal__n_error_29; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_skip_to_http: + s_n_llhttp__internal__n_url_skip_to_http: { + if (p == endp) { + return s_n_llhttp__internal__n_url_skip_to_http; + } + p++; + goto s_n_llhttp__internal__n_req_http_start; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_fragment: + s_n_llhttp__internal__n_url_fragment: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_fragment; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_url_fragment; + } + case 2: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_6; + } + case 3: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_7; + } + case 4: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_8; + } + default: { + goto s_n_llhttp__internal__n_error_30; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_end_stub_query_3: + s_n_llhttp__internal__n_span_end_stub_query_3: { + if (p == endp) { + return s_n_llhttp__internal__n_span_end_stub_query_3; + } + p++; + goto s_n_llhttp__internal__n_url_fragment; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_query: + s_n_llhttp__internal__n_url_query: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_query; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_url_query; + } + case 2: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_9; + } + case 3: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_10; + } + case 4: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_11; + } + case 5: { + goto s_n_llhttp__internal__n_span_end_stub_query_3; + } + default: { + goto s_n_llhttp__internal__n_error_31; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_query_or_fragment: + s_n_llhttp__internal__n_url_query_or_fragment: { + if (p == endp) { + return s_n_llhttp__internal__n_url_query_or_fragment; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_3; + } + case 13: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_4; + } + case ' ': { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_5; + } + case '#': { + p++; + goto s_n_llhttp__internal__n_url_fragment; + } + case '?': { + p++; + goto s_n_llhttp__internal__n_url_query; + } + default: { + goto s_n_llhttp__internal__n_error_32; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_path: + s_n_llhttp__internal__n_url_path: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_path; + } + #ifdef __SSE4_2__ + if (endp - p >= 16) { + __m128i ranges; + __m128i input; + int avail; + int match_len; + + /* Load input */ + input = _mm_loadu_si128((__m128i const*) p); + ranges = _mm_loadu_si128((__m128i const*) llparse_blob1); + + /* Find first character that does not match `ranges` */ + match_len = _mm_cmpestri(ranges, 12, + input, 16, + _SIDD_UBYTE_OPS | _SIDD_CMP_RANGES | + _SIDD_NEGATIVE_POLARITY); + + if (match_len != 0) { + p += match_len; + goto s_n_llhttp__internal__n_url_path; + } + goto s_n_llhttp__internal__n_url_query_or_fragment; + } + #endif /* __SSE4_2__ */ + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_url_path; + } + default: { + goto s_n_llhttp__internal__n_url_query_or_fragment; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_stub_path_2: + s_n_llhttp__internal__n_span_start_stub_path_2: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_stub_path_2; + } + p++; + goto s_n_llhttp__internal__n_url_path; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_stub_path: + s_n_llhttp__internal__n_span_start_stub_path: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_stub_path; + } + p++; + goto s_n_llhttp__internal__n_url_path; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_stub_path_1: + s_n_llhttp__internal__n_span_start_stub_path_1: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_stub_path_1; + } + p++; + goto s_n_llhttp__internal__n_url_path; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_server_with_at: + s_n_llhttp__internal__n_url_server_with_at: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 6, + 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 4, + 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_server_with_at; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_12; + } + case 2: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_13; + } + case 3: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_14; + } + case 4: { + p++; + goto s_n_llhttp__internal__n_url_server; + } + case 5: { + goto s_n_llhttp__internal__n_span_start_stub_path_1; + } + case 6: { + p++; + goto s_n_llhttp__internal__n_url_query; + } + case 7: { + p++; + goto s_n_llhttp__internal__n_error_33; + } + default: { + goto s_n_llhttp__internal__n_error_34; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_server: + s_n_llhttp__internal__n_url_server: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 6, + 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 4, + 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_server; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url; + } + case 2: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_1; + } + case 3: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_url_2; + } + case 4: { + p++; + goto s_n_llhttp__internal__n_url_server; + } + case 5: { + goto s_n_llhttp__internal__n_span_start_stub_path; + } + case 6: { + p++; + goto s_n_llhttp__internal__n_url_query; + } + case 7: { + p++; + goto s_n_llhttp__internal__n_url_server_with_at; + } + default: { + goto s_n_llhttp__internal__n_error_35; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_schema_delim_1: + s_n_llhttp__internal__n_url_schema_delim_1: { + if (p == endp) { + return s_n_llhttp__internal__n_url_schema_delim_1; + } + switch (*p) { + case '/': { + p++; + goto s_n_llhttp__internal__n_url_server; + } + default: { + goto s_n_llhttp__internal__n_error_37; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_schema_delim: + s_n_llhttp__internal__n_url_schema_delim: { + if (p == endp) { + return s_n_llhttp__internal__n_url_schema_delim; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_error_36; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_error_36; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_error_36; + } + case '/': { + p++; + goto s_n_llhttp__internal__n_url_schema_delim_1; + } + default: { + goto s_n_llhttp__internal__n_error_37; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_end_stub_schema: + s_n_llhttp__internal__n_span_end_stub_schema: { + if (p == endp) { + return s_n_llhttp__internal__n_span_end_stub_schema; + } + p++; + goto s_n_llhttp__internal__n_url_schema_delim; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_schema: + s_n_llhttp__internal__n_url_schema: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_schema; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_error_36; + } + case 2: { + goto s_n_llhttp__internal__n_span_end_stub_schema; + } + case 3: { + p++; + goto s_n_llhttp__internal__n_url_schema; + } + default: { + goto s_n_llhttp__internal__n_error_38; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_url_start: + s_n_llhttp__internal__n_url_start: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llhttp__internal__n_url_start; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llhttp__internal__n_error_36; + } + case 2: { + goto s_n_llhttp__internal__n_span_start_stub_path_2; + } + case 3: { + goto s_n_llhttp__internal__n_url_schema; + } + default: { + goto s_n_llhttp__internal__n_error_39; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_url_1: + s_n_llhttp__internal__n_span_start_llhttp__on_url_1: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_url_1; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_url; + goto s_n_llhttp__internal__n_url_start; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_url: + s_n_llhttp__internal__n_span_start_llhttp__on_url: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_url; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_url; + goto s_n_llhttp__internal__n_url_server; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_spaces_before_url: + s_n_llhttp__internal__n_req_spaces_before_url: { + if (p == endp) { + return s_n_llhttp__internal__n_req_spaces_before_url; + } + switch (*p) { + case ' ': { + p++; + goto s_n_llhttp__internal__n_req_spaces_before_url; + } + default: { + goto s_n_llhttp__internal__n_invoke_is_equal_method; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_first_space_before_url: + s_n_llhttp__internal__n_req_first_space_before_url: { + if (p == endp) { + return s_n_llhttp__internal__n_req_first_space_before_url; + } + switch (*p) { + case ' ': { + p++; + goto s_n_llhttp__internal__n_req_spaces_before_url; + } + default: { + goto s_n_llhttp__internal__n_error_40; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_1: + s_n_llhttp__internal__n_start_req_1: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_1; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob0, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 19; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_1; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_2: + s_n_llhttp__internal__n_start_req_2: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_2; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob18, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 16; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_2; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_4: + s_n_llhttp__internal__n_start_req_4: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_4; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob19, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 22; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_4; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_6: + s_n_llhttp__internal__n_start_req_6: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_6; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob20, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_6; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_7: + s_n_llhttp__internal__n_start_req_7: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_7; + } + switch (*p) { + case 'Y': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_5: + s_n_llhttp__internal__n_start_req_5: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_5; + } + switch (*p) { + case 'N': { + p++; + goto s_n_llhttp__internal__n_start_req_6; + } + case 'P': { + p++; + goto s_n_llhttp__internal__n_start_req_7; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_3: + s_n_llhttp__internal__n_start_req_3: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_3; + } + switch (*p) { + case 'H': { + p++; + goto s_n_llhttp__internal__n_start_req_4; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_5; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_8: + s_n_llhttp__internal__n_start_req_8: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_8; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob21, 5); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_8; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_9: + s_n_llhttp__internal__n_start_req_9: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_9; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob22, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_9; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_10: + s_n_llhttp__internal__n_start_req_10: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_10; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob23, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_10; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_12: + s_n_llhttp__internal__n_start_req_12: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_12; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob24, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 31; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_12; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_13: + s_n_llhttp__internal__n_start_req_13: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_13; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob25, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_13; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_11: + s_n_llhttp__internal__n_start_req_11: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_11; + } + switch (*p) { + case 'I': { + p++; + goto s_n_llhttp__internal__n_start_req_12; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_13; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_15: + s_n_llhttp__internal__n_start_req_15: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_15; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob26, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 24; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_15; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_16: + s_n_llhttp__internal__n_start_req_16: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_16; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob27, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 23; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_16; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_18: + s_n_llhttp__internal__n_start_req_18: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_18; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob28, 7); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 21; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_18; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_20: + s_n_llhttp__internal__n_start_req_20: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_20; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob29, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 30; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_20; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_21: + s_n_llhttp__internal__n_start_req_21: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_21; + } + switch (*p) { + case 'L': { + p++; + match = 10; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_19: + s_n_llhttp__internal__n_start_req_19: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_19; + } + switch (*p) { + case 'A': { + p++; + goto s_n_llhttp__internal__n_start_req_20; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_21; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_17: + s_n_llhttp__internal__n_start_req_17: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_17; + } + switch (*p) { + case 'A': { + p++; + goto s_n_llhttp__internal__n_start_req_18; + } + case 'C': { + p++; + goto s_n_llhttp__internal__n_start_req_19; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_22: + s_n_llhttp__internal__n_start_req_22: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_22; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob30, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 11; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_22; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_14: + s_n_llhttp__internal__n_start_req_14: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_14; + } + switch (*p) { + case '-': { + p++; + goto s_n_llhttp__internal__n_start_req_15; + } + case 'E': { + p++; + goto s_n_llhttp__internal__n_start_req_16; + } + case 'K': { + p++; + goto s_n_llhttp__internal__n_start_req_17; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_22; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_23: + s_n_llhttp__internal__n_start_req_23: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_23; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob31, 5); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 25; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_23; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_24: + s_n_llhttp__internal__n_start_req_24: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_24; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob32, 6); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_24; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_26: + s_n_llhttp__internal__n_start_req_26: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_26; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob33, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 28; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_26; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_27: + s_n_llhttp__internal__n_start_req_27: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_27; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob34, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_27; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_31: + s_n_llhttp__internal__n_start_req_31: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_31; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob35, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 12; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_31; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_32: + s_n_llhttp__internal__n_start_req_32: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_32; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob36, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 13; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_32; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_30: + s_n_llhttp__internal__n_start_req_30: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_30; + } + switch (*p) { + case 'F': { + p++; + goto s_n_llhttp__internal__n_start_req_31; + } + case 'P': { + p++; + goto s_n_llhttp__internal__n_start_req_32; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_29: + s_n_llhttp__internal__n_start_req_29: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_29; + } + switch (*p) { + case 'P': { + p++; + goto s_n_llhttp__internal__n_start_req_30; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_28: + s_n_llhttp__internal__n_start_req_28: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_28; + } + switch (*p) { + case 'I': { + p++; + match = 34; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_29; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_34: + s_n_llhttp__internal__n_start_req_34: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_34; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob37, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 29; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_34; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_33: + s_n_llhttp__internal__n_start_req_33: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_33; + } + switch (*p) { + case 'R': { + p++; + goto s_n_llhttp__internal__n_start_req_34; + } + case 'T': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_25: + s_n_llhttp__internal__n_start_req_25: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_25; + } + switch (*p) { + case 'A': { + p++; + goto s_n_llhttp__internal__n_start_req_26; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_27; + } + case 'R': { + p++; + goto s_n_llhttp__internal__n_start_req_28; + } + case 'U': { + p++; + goto s_n_llhttp__internal__n_start_req_33; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_37: + s_n_llhttp__internal__n_start_req_37: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_37; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob38, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 17; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_37; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_38: + s_n_llhttp__internal__n_start_req_38: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_38; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob39, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 20; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_38; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_36: + s_n_llhttp__internal__n_start_req_36: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_36; + } + switch (*p) { + case 'B': { + p++; + goto s_n_llhttp__internal__n_start_req_37; + } + case 'P': { + p++; + goto s_n_llhttp__internal__n_start_req_38; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_35: + s_n_llhttp__internal__n_start_req_35: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_35; + } + switch (*p) { + case 'E': { + p++; + goto s_n_llhttp__internal__n_start_req_36; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_40: + s_n_llhttp__internal__n_start_req_40: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_40; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob40, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 14; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_40; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_41: + s_n_llhttp__internal__n_start_req_41: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_41; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob41, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 33; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_41; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_42: + s_n_llhttp__internal__n_start_req_42: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_42; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob42, 7); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 26; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_42; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_39: + s_n_llhttp__internal__n_start_req_39: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_39; + } + switch (*p) { + case 'E': { + p++; + goto s_n_llhttp__internal__n_start_req_40; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_41; + } + case 'U': { + p++; + goto s_n_llhttp__internal__n_start_req_42; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_43: + s_n_llhttp__internal__n_start_req_43: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_43; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob43, 4); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_43; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_46: + s_n_llhttp__internal__n_start_req_46: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_46; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob44, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 18; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_46; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_48: + s_n_llhttp__internal__n_start_req_48: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_48; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob45, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 32; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_48; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_49: + s_n_llhttp__internal__n_start_req_49: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_49; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob46, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 15; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_49; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_47: + s_n_llhttp__internal__n_start_req_47: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_47; + } + switch (*p) { + case 'I': { + p++; + goto s_n_llhttp__internal__n_start_req_48; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_49; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_50: + s_n_llhttp__internal__n_start_req_50: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_req_50; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob47, 8); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 27; + goto s_n_llhttp__internal__n_invoke_store_method_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_req_50; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_45: + s_n_llhttp__internal__n_start_req_45: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_45; + } + switch (*p) { + case 'B': { + p++; + goto s_n_llhttp__internal__n_start_req_46; + } + case 'L': { + p++; + goto s_n_llhttp__internal__n_start_req_47; + } + case 'S': { + p++; + goto s_n_llhttp__internal__n_start_req_50; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_44: + s_n_llhttp__internal__n_start_req_44: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_44; + } + switch (*p) { + case 'N': { + p++; + goto s_n_llhttp__internal__n_start_req_45; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req: + s_n_llhttp__internal__n_start_req: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req; + } + switch (*p) { + case 'A': { + p++; + goto s_n_llhttp__internal__n_start_req_1; + } + case 'B': { + p++; + goto s_n_llhttp__internal__n_start_req_2; + } + case 'C': { + p++; + goto s_n_llhttp__internal__n_start_req_3; + } + case 'D': { + p++; + goto s_n_llhttp__internal__n_start_req_8; + } + case 'G': { + p++; + goto s_n_llhttp__internal__n_start_req_9; + } + case 'H': { + p++; + goto s_n_llhttp__internal__n_start_req_10; + } + case 'L': { + p++; + goto s_n_llhttp__internal__n_start_req_11; + } + case 'M': { + p++; + goto s_n_llhttp__internal__n_start_req_14; + } + case 'N': { + p++; + goto s_n_llhttp__internal__n_start_req_23; + } + case 'O': { + p++; + goto s_n_llhttp__internal__n_start_req_24; + } + case 'P': { + p++; + goto s_n_llhttp__internal__n_start_req_25; + } + case 'R': { + p++; + goto s_n_llhttp__internal__n_start_req_35; + } + case 'S': { + p++; + goto s_n_llhttp__internal__n_start_req_39; + } + case 'T': { + p++; + goto s_n_llhttp__internal__n_start_req_43; + } + case 'U': { + p++; + goto s_n_llhttp__internal__n_start_req_44; + } + default: { + goto s_n_llhttp__internal__n_error_48; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_line_almost_done: + s_n_llhttp__internal__n_res_line_almost_done: { + if (p == endp) { + return s_n_llhttp__internal__n_res_line_almost_done; + } + p++; + goto s_n_llhttp__internal__n_header_field_start; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_status: + s_n_llhttp__internal__n_res_status: { + if (p == endp) { + return s_n_llhttp__internal__n_res_status; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_status; + } + case 13: { + goto s_n_llhttp__internal__n_span_end_llhttp__on_status_1; + } + default: { + p++; + goto s_n_llhttp__internal__n_res_status; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_span_start_llhttp__on_status: + s_n_llhttp__internal__n_span_start_llhttp__on_status: { + if (p == endp) { + return s_n_llhttp__internal__n_span_start_llhttp__on_status; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llhttp__on_status; + goto s_n_llhttp__internal__n_res_status; + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_status_start: + s_n_llhttp__internal__n_res_status_start: { + if (p == endp) { + return s_n_llhttp__internal__n_res_status_start; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_header_field_start; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_res_line_almost_done; + } + default: { + goto s_n_llhttp__internal__n_span_start_llhttp__on_status; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_status_code_otherwise: + s_n_llhttp__internal__n_res_status_code_otherwise: { + if (p == endp) { + return s_n_llhttp__internal__n_res_status_code_otherwise; + } + switch (*p) { + case 10: { + goto s_n_llhttp__internal__n_res_status_start; + } + case 13: { + goto s_n_llhttp__internal__n_res_status_start; + } + case ' ': { + p++; + goto s_n_llhttp__internal__n_res_status_start; + } + default: { + goto s_n_llhttp__internal__n_error_42; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_status_code: + s_n_llhttp__internal__n_res_status_code: { + if (p == endp) { + return s_n_llhttp__internal__n_res_status_code; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_mul_add_status_code; + } + default: { + goto s_n_llhttp__internal__n_res_status_code_otherwise; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_http_end: + s_n_llhttp__internal__n_res_http_end: { + if (p == endp) { + return s_n_llhttp__internal__n_res_http_end; + } + switch (*p) { + case ' ': { + p++; + goto s_n_llhttp__internal__n_invoke_update_status_code; + } + default: { + goto s_n_llhttp__internal__n_error_43; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_http_minor: + s_n_llhttp__internal__n_res_http_minor: { + if (p == endp) { + return s_n_llhttp__internal__n_res_http_minor; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_store_http_minor_1; + } + default: { + goto s_n_llhttp__internal__n_error_44; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_http_dot: + s_n_llhttp__internal__n_res_http_dot: { + if (p == endp) { + return s_n_llhttp__internal__n_res_http_dot; + } + switch (*p) { + case '.': { + p++; + goto s_n_llhttp__internal__n_res_http_minor; + } + default: { + goto s_n_llhttp__internal__n_error_45; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_res_http_major: + s_n_llhttp__internal__n_res_http_major: { + if (p == endp) { + return s_n_llhttp__internal__n_res_http_major; + } + switch (*p) { + case '0': { + p++; + match = 0; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '1': { + p++; + match = 1; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '2': { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '3': { + p++; + match = 3; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '4': { + p++; + match = 4; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '5': { + p++; + match = 5; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '6': { + p++; + match = 6; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '7': { + p++; + match = 7; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '8': { + p++; + match = 8; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + case '9': { + p++; + match = 9; + goto s_n_llhttp__internal__n_invoke_store_http_major_1; + } + default: { + goto s_n_llhttp__internal__n_error_46; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_res: + s_n_llhttp__internal__n_start_res: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_start_res; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob48, 5); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_res_http_major; + } + case kMatchPause: { + return s_n_llhttp__internal__n_start_res; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_49; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_or_res_method_2: + s_n_llhttp__internal__n_req_or_res_method_2: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_req_or_res_method_2; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob49, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + match = 2; + goto s_n_llhttp__internal__n_invoke_store_method; + } + case kMatchPause: { + return s_n_llhttp__internal__n_req_or_res_method_2; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_47; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_or_res_method_3: + s_n_llhttp__internal__n_req_or_res_method_3: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llhttp__internal__n_req_or_res_method_3; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob50, 3); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llhttp__internal__n_invoke_update_type_1; + } + case kMatchPause: { + return s_n_llhttp__internal__n_req_or_res_method_3; + } + case kMatchMismatch: { + goto s_n_llhttp__internal__n_error_47; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_or_res_method_1: + s_n_llhttp__internal__n_req_or_res_method_1: { + if (p == endp) { + return s_n_llhttp__internal__n_req_or_res_method_1; + } + switch (*p) { + case 'E': { + p++; + goto s_n_llhttp__internal__n_req_or_res_method_2; + } + case 'T': { + p++; + goto s_n_llhttp__internal__n_req_or_res_method_3; + } + default: { + goto s_n_llhttp__internal__n_error_47; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_req_or_res_method: + s_n_llhttp__internal__n_req_or_res_method: { + if (p == endp) { + return s_n_llhttp__internal__n_req_or_res_method; + } + switch (*p) { + case 'H': { + p++; + goto s_n_llhttp__internal__n_req_or_res_method_1; + } + default: { + goto s_n_llhttp__internal__n_error_47; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start_req_or_res: + s_n_llhttp__internal__n_start_req_or_res: { + if (p == endp) { + return s_n_llhttp__internal__n_start_req_or_res; + } + switch (*p) { + case 'H': { + goto s_n_llhttp__internal__n_req_or_res_method; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_type_2; + } + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_invoke_load_type: + s_n_llhttp__internal__n_invoke_load_type: { + switch (llhttp__internal__c_load_type(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_start_req; + case 2: + goto s_n_llhttp__internal__n_start_res; + default: + goto s_n_llhttp__internal__n_start_req_or_res; + } + /* UNREACHABLE */; + abort(); + } + case s_n_llhttp__internal__n_start: + s_n_llhttp__internal__n_start: { + if (p == endp) { + return s_n_llhttp__internal__n_start; + } + switch (*p) { + case 10: { + p++; + goto s_n_llhttp__internal__n_start; + } + case 13: { + p++; + goto s_n_llhttp__internal__n_start; + } + default: { + goto s_n_llhttp__internal__n_invoke_update_finish; + } + } + /* UNREACHABLE */; + abort(); + } + default: + /* UNREACHABLE */ + abort(); + } + s_n_llhttp__internal__n_error_36: { + state->error = 0x7; + state->reason = ""Invalid characters in url""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_finish_1: { + switch (llhttp__internal__c_update_finish_1(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_5: { + state->error = 0x15; + state->reason = ""on_message_complete pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_is_equal_upgrade; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_10: { + state->error = 0x12; + state->reason = ""`on_message_complete` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_7: { + state->error = 0x15; + state->reason = ""on_chunk_complete pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_14: { + state->error = 0x14; + state->reason = ""`on_chunk_complete` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_chunk_complete_1: { + switch (llhttp__on_chunk_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2; + case 21: + goto s_n_llhttp__internal__n_pause_7; + default: + goto s_n_llhttp__internal__n_error_14; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_12: { + state->error = 0x4; + state->reason = ""Content-Length can't be present with Transfer-Encoding""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_13: { + state->error = 0x4; + state->reason = ""Content-Length can't be present with chunked encoding""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_2: { + state->error = 0x15; + state->reason = ""on_message_complete pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_pause_1; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_3: { + state->error = 0x12; + state->reason = ""`on_message_complete` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_1: { + switch (llhttp__on_message_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_pause_1; + case 21: + goto s_n_llhttp__internal__n_pause_2; + default: + goto s_n_llhttp__internal__n_error_3; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_8: { + state->error = 0xc; + state->reason = ""Chunk size overflow""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_3: { + state->error = 0x15; + state->reason = ""on_chunk_complete pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_update_content_length; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_5: { + state->error = 0x14; + state->reason = ""`on_chunk_complete` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_chunk_complete: { + switch (llhttp__on_chunk_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_update_content_length; + case 21: + goto s_n_llhttp__internal__n_pause_3; + default: + goto s_n_llhttp__internal__n_error_5; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_body: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_body(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_chunk_data_almost_done; + return s_error; + } + goto s_n_llhttp__internal__n_chunk_data_almost_done; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags: { + switch (llhttp__internal__c_or_flags(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_4: { + state->error = 0x15; + state->reason = ""on_chunk_header pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_is_equal_content_length; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_4: { + state->error = 0x13; + state->reason = ""`on_chunk_header` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_chunk_header: { + switch (llhttp__on_chunk_header(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_is_equal_content_length; + case 21: + goto s_n_llhttp__internal__n_pause_4; + default: + goto s_n_llhttp__internal__n_error_4; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_6: { + state->error = 0x2; + state->reason = ""Invalid character in chunk parameters""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_7: { + state->error = 0xc; + state->reason = ""Invalid character in chunk size""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_mul_add_content_length: { + switch (llhttp__internal__c_mul_add_content_length(state, p, endp, match)) { + case 1: + goto s_n_llhttp__internal__n_error_8; + default: + goto s_n_llhttp__internal__n_chunk_size; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_9: { + state->error = 0xc; + state->reason = ""Invalid character in chunk size""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_body_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_body(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2; + return s_error; + } + goto s_n_llhttp__internal__n_invoke_llhttp__on_message_complete_2; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_finish_2: { + switch (llhttp__internal__c_update_finish_2(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_span_start_llhttp__on_body_2; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_11: { + state->error = 0xf; + state->reason = ""Request has invalid `Transfer-Encoding`""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause: { + state->error = 0x15; + state->reason = ""on_message_complete pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_llhttp__after_message_complete; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_2: { + state->error = 0x12; + state->reason = ""`on_message_complete` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_message_complete: { + switch (llhttp__on_message_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_llhttp__after_message_complete; + case 21: + goto s_n_llhttp__internal__n_pause; + default: + goto s_n_llhttp__internal__n_error_2; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_1: { + switch (llhttp__internal__c_or_flags_1(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_2: { + switch (llhttp__internal__c_or_flags_1(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_upgrade: { + switch (llhttp__internal__c_update_upgrade(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_or_flags_2; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_6: { + state->error = 0x15; + state->reason = ""Paused by on_headers_complete""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_1: { + state->error = 0x11; + state->reason = ""User callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_headers_complete: { + switch (llhttp__on_headers_complete(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_llhttp__after_headers_complete; + case 1: + goto s_n_llhttp__internal__n_invoke_or_flags_1; + case 2: + goto s_n_llhttp__internal__n_invoke_update_upgrade; + case 21: + goto s_n_llhttp__internal__n_pause_6; + default: + goto s_n_llhttp__internal__n_error_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete: { + switch (llhttp__before_headers_complete(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_llhttp__on_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_3: { + switch (llhttp__internal__c_test_flags_3(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_error_13; + default: + goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_2: { + switch (llhttp__internal__c_test_flags_2(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_error_12; + case 1: + goto s_n_llhttp__internal__n_invoke_test_flags_3; + default: + goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_1: { + switch (llhttp__internal__c_test_flags_1(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_invoke_test_flags_2; + default: + goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags: { + switch (llhttp__internal__c_test_flags(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_invoke_llhttp__on_chunk_complete_1; + default: + goto s_n_llhttp__internal__n_invoke_test_flags_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_field: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_field(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_error_15; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_error_15; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_4: { + switch (llhttp__internal__c_test_flags_2(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_header_field_colon_discard_ws; + default: + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_field; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_16: { + state->error = 0xb; + state->reason = ""Empty Content-Length""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_field_start; + return s_error; + } + goto s_n_llhttp__internal__n_header_field_start; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state: { + switch (llhttp__internal__c_update_header_state(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_3: { + switch (llhttp__internal__c_or_flags_3(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_4: { + switch (llhttp__internal__c_or_flags_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_5: { + switch (llhttp__internal__c_or_flags_5(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_6: { + switch (llhttp__internal__c_or_flags_6(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_header_state_1: { + switch (llhttp__internal__c_load_header_state(state, p, endp)) { + case 5: + goto s_n_llhttp__internal__n_invoke_or_flags_3; + case 6: + goto s_n_llhttp__internal__n_invoke_or_flags_4; + case 7: + goto s_n_llhttp__internal__n_invoke_or_flags_5; + case 8: + goto s_n_llhttp__internal__n_invoke_or_flags_6; + default: + goto s_n_llhttp__internal__n_span_start_llhttp__on_header_value; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_header_state: { + switch (llhttp__internal__c_load_header_state(state, p, endp)) { + case 2: + goto s_n_llhttp__internal__n_error_16; + default: + goto s_n_llhttp__internal__n_invoke_load_header_state_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_1: { + switch (llhttp__internal__c_update_header_state(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_7: { + switch (llhttp__internal__c_or_flags_3(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_8: { + switch (llhttp__internal__c_or_flags_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_9: { + switch (llhttp__internal__c_or_flags_5(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_10: { + switch (llhttp__internal__c_or_flags_6(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_header_state_3: { + switch (llhttp__internal__c_load_header_state(state, p, endp)) { + case 5: + goto s_n_llhttp__internal__n_invoke_or_flags_7; + case 6: + goto s_n_llhttp__internal__n_invoke_or_flags_8; + case 7: + goto s_n_llhttp__internal__n_invoke_or_flags_9; + case 8: + goto s_n_llhttp__internal__n_invoke_or_flags_10; + default: + goto s_n_llhttp__internal__n_header_field_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_17: { + state->error = 0x3; + state->reason = ""Missing expected LF after header value""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_value_almost_done; + return s_error; + } + goto s_n_llhttp__internal__n_header_value_almost_done; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_value_almost_done; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_header_value_almost_done; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value_3: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_value_almost_done; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_header_value_almost_done; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_18: { + state->error = 0xa; + state->reason = ""Invalid header value char""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_5: { + switch (llhttp__internal__c_test_flags_2(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_header_value_lenient; + default: + goto s_n_llhttp__internal__n_error_18; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_3: { + switch (llhttp__internal__c_update_header_state(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_11: { + switch (llhttp__internal__c_or_flags_3(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_3; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_12: { + switch (llhttp__internal__c_or_flags_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_3; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_13: { + switch (llhttp__internal__c_or_flags_5(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_3; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_14: { + switch (llhttp__internal__c_or_flags_6(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_header_state_4: { + switch (llhttp__internal__c_load_header_state(state, p, endp)) { + case 5: + goto s_n_llhttp__internal__n_invoke_or_flags_11; + case 6: + goto s_n_llhttp__internal__n_invoke_or_flags_12; + case 7: + goto s_n_llhttp__internal__n_invoke_or_flags_13; + case 8: + goto s_n_llhttp__internal__n_invoke_or_flags_14; + default: + goto s_n_llhttp__internal__n_header_value_connection; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_4: { + switch (llhttp__internal__c_update_header_state_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection_token; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_2: { + switch (llhttp__internal__c_update_header_state_2(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection_ws; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_5: { + switch (llhttp__internal__c_update_header_state_5(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection_ws; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_6: { + switch (llhttp__internal__c_update_header_state_6(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_connection_ws; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value_4: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_error_20; + return s_error; + } + goto s_n_llhttp__internal__n_error_20; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_mul_add_content_length_1: { + switch (llhttp__internal__c_mul_add_content_length_1(state, p, endp, match)) { + case 1: + goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_4; + default: + goto s_n_llhttp__internal__n_header_value_content_length; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_15: { + switch (llhttp__internal__c_or_flags_15(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_otherwise; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_value_5: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_value(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_error_21; + return s_error; + } + goto s_n_llhttp__internal__n_error_21; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_19: { + state->error = 0x4; + state->reason = ""Duplicate Content-Length""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_flags_6: { + switch (llhttp__internal__c_test_flags_6(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_header_value_content_length; + default: + goto s_n_llhttp__internal__n_error_19; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_7: { + switch (llhttp__internal__c_update_header_state_7(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_otherwise; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_8: { + switch (llhttp__internal__c_update_header_state_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_and_flags: { + switch (llhttp__internal__c_and_flags(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_value_te_chunked; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_16: { + switch (llhttp__internal__c_or_flags_16(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_and_flags; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_or_flags_17: { + switch (llhttp__internal__c_or_flags_17(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_header_state_8; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_header_state_2: { + switch (llhttp__internal__c_load_header_state(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_header_value_connection; + case 2: + goto s_n_llhttp__internal__n_invoke_test_flags_6; + case 3: + goto s_n_llhttp__internal__n_invoke_or_flags_16; + case 4: + goto s_n_llhttp__internal__n_invoke_or_flags_17; + default: + goto s_n_llhttp__internal__n_header_value; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_field_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_field(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_value_discard_ws; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_header_field_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_header_field(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_value_discard_ws; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_header_value_discard_ws; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_22: { + state->error = 0xa; + state->reason = ""Invalid header token""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_9: { + switch (llhttp__internal__c_update_header_state_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_general; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_header_state: { + switch (llhttp__internal__c_store_header_state(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_header_field_colon; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_header_state_10: { + switch (llhttp__internal__c_update_header_state_4(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_general; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_http_minor: { + switch (llhttp__internal__c_update_http_minor(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_header_field_start; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_http_major: { + switch (llhttp__internal__c_update_http_major(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_update_http_minor; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_3: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_23: { + state->error = 0x7; + state->reason = ""Expected CRLF""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_4: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_lf_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_lf_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_24: { + state->error = 0x9; + state->reason = ""Expected CRLF after version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_req_http_end; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_25: { + state->error = 0x9; + state->reason = ""Invalid minor version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_26: { + state->error = 0x9; + state->reason = ""Expected dot""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_major: { + switch (llhttp__internal__c_store_http_major(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_req_http_dot; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_27: { + state->error = 0x9; + state->reason = ""Invalid major version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_29: { + state->error = 0x8; + state->reason = ""Expected HTTP/""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_28: { + state->error = 0x8; + state->reason = ""Expected SOURCE method for ICE/x.x request""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_is_equal_method_1: { + switch (llhttp__internal__c_is_equal_method_1(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_error_28; + default: + goto s_n_llhttp__internal__n_req_http_major; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_5: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_6: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_7: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_lf_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_lf_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_8: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_30: { + state->error = 0x7; + state->reason = ""Invalid char in url fragment start""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_9: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_10: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_lf_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_lf_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_11: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_31: { + state->error = 0x7; + state->reason = ""Invalid char in url query""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_32: { + state->error = 0x7; + state->reason = ""Invalid char in url path""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_lf_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_lf_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_12: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_13: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_lf_to_http09; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_lf_to_http09; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_url_14: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_url(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_url_skip_to_http; + return s_error; + } + goto s_n_llhttp__internal__n_url_skip_to_http; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_33: { + state->error = 0x7; + state->reason = ""Double @ in url""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_34: { + state->error = 0x7; + state->reason = ""Unexpected char in url server""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_35: { + state->error = 0x7; + state->reason = ""Unexpected char in url server""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_37: { + state->error = 0x7; + state->reason = ""Unexpected char in url schema""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_38: { + state->error = 0x7; + state->reason = ""Unexpected char in url schema""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_39: { + state->error = 0x7; + state->reason = ""Unexpected start char in url""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_is_equal_method: { + switch (llhttp__internal__c_is_equal_method(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_span_start_llhttp__on_url_1; + default: + goto s_n_llhttp__internal__n_span_start_llhttp__on_url; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_40: { + state->error = 0x6; + state->reason = ""Expected space after method""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_method_1: { + switch (llhttp__internal__c_store_method(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_req_first_space_before_url; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_48: { + state->error = 0x6; + state->reason = ""Invalid method encountered""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_41: { + state->error = 0xd; + state->reason = ""Response overflow""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_mul_add_status_code: { + switch (llhttp__internal__c_mul_add_status_code(state, p, endp, match)) { + case 1: + goto s_n_llhttp__internal__n_error_41; + default: + goto s_n_llhttp__internal__n_res_status_code; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_status: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_status(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_header_field_start; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_header_field_start; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_span_end_llhttp__on_status_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llhttp__on_status(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_res_line_almost_done; + return s_error; + } + p++; + goto s_n_llhttp__internal__n_res_line_almost_done; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_42: { + state->error = 0xd; + state->reason = ""Invalid response status""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_status_code: { + switch (llhttp__internal__c_update_status_code(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_res_status_code; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_43: { + state->error = 0x9; + state->reason = ""Expected space after version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor_1: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_res_http_end; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_44: { + state->error = 0x9; + state->reason = ""Invalid minor version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_45: { + state->error = 0x9; + state->reason = ""Expected dot""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_major_1: { + switch (llhttp__internal__c_store_http_major(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_res_http_dot; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_46: { + state->error = 0x9; + state->reason = ""Invalid major version""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_49: { + state->error = 0x8; + state->reason = ""Expected HTTP/""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_type: { + switch (llhttp__internal__c_update_type(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_req_first_space_before_url; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_method: { + switch (llhttp__internal__c_store_method(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_invoke_update_type; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_47: { + state->error = 0x8; + state->reason = ""Invalid word encountered""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_type_1: { + switch (llhttp__internal__c_update_type_1(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_res_http_major; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_type_2: { + switch (llhttp__internal__c_update_type(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_start_req; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_pause_8: { + state->error = 0x15; + state->reason = ""on_message_begin pause""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_invoke_load_type; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error: { + state->error = 0x10; + state->reason = ""`on_message_begin` callback error""; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_llhttp__on_message_begin: { + switch (llhttp__on_message_begin(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_type; + case 21: + goto s_n_llhttp__internal__n_pause_8; + default: + goto s_n_llhttp__internal__n_error; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_update_finish: { + switch (llhttp__internal__c_update_finish(state, p, endp)) { + default: + goto s_n_llhttp__internal__n_invoke_llhttp__on_message_begin; + } + /* UNREACHABLE */; + abort(); + } +}] + +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 save_key_to(const char *algo, const char *name, const char *keydata) +{ + const char *error; + struct dict_transaction_context *ctx = + dict_transaction_begin(keys_dict); + + dict_set(ctx, t_strconcat(DICT_PATH_SHARED, ""default/"", algo, ""/"", + name, NULL), + keydata); + if (dict_transaction_commit(&ctx, &error) < 0) + i_error(""dict_set(%s) failed: %s"", name, error); +}] + +Response: +1" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + zend_op *opline = EX(opline); + zend_free_op free_op1; + zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; + zval *expr_ptr; + zval *offset=NULL; + +#if 0 || IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV + zval **expr_ptr_ptr = NULL; + + if (opline->extended_value) { + expr_ptr_ptr=NULL; + expr_ptr = *expr_ptr_ptr; + } else { + expr_ptr=_get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + } +#else + expr_ptr=_get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); +#endif + + if (1) { /* temporary variable */ + zval *new_expr; + + ALLOC_ZVAL(new_expr); + INIT_PZVAL_COPY(new_expr, expr_ptr); + expr_ptr = new_expr; + } else { +#if 0 || IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV + if (opline->extended_value) { + SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); + expr_ptr = *expr_ptr_ptr; + Z_ADDREF_P(expr_ptr); + } else +#endif + if (IS_TMP_VAR == IS_CONST || PZVAL_IS_REF(expr_ptr)) { + zval *new_expr; + + ALLOC_ZVAL(new_expr); + INIT_PZVAL_COPY(new_expr, expr_ptr); + expr_ptr = new_expr; + zendi_zval_copy_ctor(*expr_ptr); + } else { + Z_ADDREF_P(expr_ptr); + } + } + if (offset) { + switch (Z_TYPE_P(offset)) { + case IS_DOUBLE: + zend_hash_index_update(Z_ARRVAL_P(array_ptr), zend_dval_to_lval(Z_DVAL_P(offset)), &expr_ptr, sizeof(zval *), NULL); + break; + case IS_LONG: + case IS_BOOL: + zend_hash_index_update(Z_ARRVAL_P(array_ptr), Z_LVAL_P(offset), &expr_ptr, sizeof(zval *), NULL); + break; + case IS_STRING: + zend_symtable_update(Z_ARRVAL_P(array_ptr), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, &expr_ptr, sizeof(zval *), NULL); + break; + case IS_NULL: + zend_hash_update(Z_ARRVAL_P(array_ptr), """", sizeof(""""), &expr_ptr, sizeof(zval *), NULL); + break; + default: + zend_error(E_WARNING, ""Illegal offset type""); + zval_ptr_dtor(&expr_ptr); + /* do nothing */ + break; + } + + } else { + zend_hash_next_index_insert(Z_ARRVAL_P(array_ptr), &expr_ptr, sizeof(zval *), NULL); + } + if (opline->extended_value) { + + } else { + + } + ZEND_VM_NEXT_OPCODE(); +}] + +Response: +0" +"Instruction: +Analyze the code of the program enclosed in square brackets, + determine if it has vulnerability, or not, and return the answer as + the corresponding target label ""1"" or ""0"" respectively. + [static int fuse_rename2(struct inode *olddir, struct dentry *oldent, + struct inode *newdir, struct dentry *newent, + unsigned int flags) +{ + struct fuse_conn *fc = get_fuse_conn(olddir); + int err; + + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) + return -EINVAL; + + if (flags) { + if (fc->no_rename2 || fc->minor < 23) + return -EINVAL; + + err = fuse_rename_common(olddir, oldent, newdir, newent, flags, + FUSE_RENAME2, + sizeof(struct fuse_rename2_in)); + if (err == -ENOSYS) { + fc->no_rename2 = 1; + err = -EINVAL; + } + } else { + err = fuse_rename_common(olddir, oldent, newdir, newent, 0, + FUSE_RENAME, + sizeof(struct fuse_rename_in)); + } + + 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 tx3g_dump_style_nobox(FILE * trace, GF_StyleRecord *rec, u32 *shift_offset, u32 so_count) +{ + gf_fprintf(trace, ""