static void rsem_AA2(void) { RSL(X1); WSL(X2); // this one should fail }
static void rsem_AA3(void) { WSL(X1); RSL(X2); // this one should fail }
static uint16_t http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, const struct http_conn *htc) { char *q, *r; txt t = htc->rxbuf; if (*p == '\r') p++; hp->nhd = HTTP_HDR_FIRST; hp->conds = 0; r = NULL; /* For FlexeLint */ for (; p < t.e; p = r) { /* Find end of next header */ q = r = p; while (r < t.e) { if (!vct_iscrlf(*r)) { r++; continue; } q = r; assert(r < t.e); r += vct_skipcrlf(r); if (r >= t.e) break; /* If line does not continue: got it. */ if (!vct_issp(*r)) break; /* Clear line continuation LWS to spaces */ while (vct_islws(*q)) *q++ = ' '; } if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } /* Empty header = end of headers */ if (p == q) break; if ((p[0] == 'i' || p[0] == 'I') && (p[1] == 'f' || p[1] == 'F') && p[2] == '-') hp->conds = 1; while (q > p && vct_issp(q[-1])) q--; *q = '\0'; if (hp->nhd < hp->shd) { hp->hdf[hp->nhd] = 0; hp->hd[hp->nhd].b = p; hp->hd[hp->nhd].e = q; WSLH(w, vsl_id, hp, hp->nhd); hp->nhd++; } else { VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } } return (0); }
unsigned WRW_Flush(struct worker *wrk) { ssize_t i; struct wrw *wrw; char cbuf[32]; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); wrw = &wrk->wrw; AN(wrw->wfd); /* For chunked, there must be one slot reserved for the chunked tail */ if (wrw->ciov < wrw->siov) assert(wrw->niov < wrw->siov); if (*wrw->wfd >= 0 && wrw->liov > 0 && wrw->werr == 0) { if (wrw->ciov < wrw->siov && wrw->cliov > 0) { /* Add chunk head & tail */ bprintf(cbuf, "00%zx\r\n", wrw->cliov); i = strlen(cbuf); wrw->iov[wrw->ciov].iov_base = cbuf; wrw->iov[wrw->ciov].iov_len = i; wrw->liov += i; wrw->iov[wrw->niov].iov_base = cbuf + i - 2; wrw->iov[wrw->niov++].iov_len = 2; wrw->liov += 2; } else if (wrw->ciov < wrw->siov) { wrw->iov[wrw->ciov].iov_base = cbuf; wrw->iov[wrw->ciov].iov_len = 0; } i = writev(*wrw->wfd, wrw->iov, wrw->niov); while (i != wrw->liov && i > 0) { /* Remove sent data from start of I/O vector, * then retry; we hit a timeout, but some data * was sent. * * XXX: Add a "minimum sent data per timeout * counter to prevent slowlaris attacks */ if (VTIM_real() - wrk->sp->req->t_resp > cache_param->send_timeout) { WSL(wrk, SLT_Debug, *wrw->wfd, "Hit total send timeout, " "wrote = %ld/%ld; not retrying", i, wrw->liov); i = -1; break; } WSL(wrk, SLT_Debug, *wrw->wfd, "Hit send timeout, wrote = %ld/%ld; retrying", i, wrw->liov); wrw_prune(wrw, i); i = writev(*wrw->wfd, wrw->iov, wrw->niov); } if (i <= 0) { wrw->werr++; WSL(wrk, SLT_Debug, *wrw->wfd, "Write error, retval = %zd, len = %zd, errno = %s", i, wrw->liov, strerror(errno)); } } wrw->liov = 0; wrw->cliov = 0; wrw->niov = 0; if (wrw->ciov < wrw->siov) wrw->ciov = wrw->niov++; return (wrw->werr); }
static int cnt_done(struct sess *sp) { double dh, dp, da; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); AZ(sp->vbe); sp->director = NULL; sp->restarts = 0; if (sp->vcl != NULL && sp->esis == 0) { if (sp->wrk->vcl != NULL) VCL_Rel(&sp->wrk->vcl); sp->wrk->vcl = sp->vcl; sp->vcl = NULL; } sp->t_end = TIM_real(); sp->wrk->lastused = sp->t_end; if (sp->xid == 0) { sp->t_req = sp->t_end; sp->t_resp = sp->t_end; } dp = sp->t_resp - sp->t_req; da = sp->t_end - sp->t_resp; dh = sp->t_req - sp->t_open; WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %.9f %.9f %.9f %.9f %.9f", sp->xid, sp->t_req, sp->t_end, dh, dp, da); sp->xid = 0; sp->t_open = sp->t_end; sp->t_resp = NAN; WSL_Flush(sp->wrk, 0); /* If we did an ESI include, don't mess up our state */ if (sp->esis > 0) return (1); sp->t_req = NAN; if (sp->fd >= 0 && sp->doclose != NULL) { /* * This is an orderly close of the connection; ditch nolinger * before we close, to get queued data transmitted. */ TCP_linger(sp->fd, 0); vca_close_session(sp, sp->doclose); } if (sp->fd < 0) { SES_Charge(sp); VSL_stats->sess_closed++; sp->wrk = NULL; SES_Delete(sp); return (1); } /* Reset the workspace to the session-watermark */ WS_Reset(sp->ws, sp->ws_ses); i = HTC_Reinit(sp->htc); if (i == 1) { VSL_stats->sess_pipeline++; sp->step = STP_START; return (0); } if (Tlen(sp->htc->rxbuf)) { VSL_stats->sess_readahead++; sp->step = STP_WAIT; return (0); } if (params->session_linger > 0) { VSL_stats->sess_linger++; sp->step = STP_WAIT; return (0); } VSL_stats->sess_herd++; SES_Charge(sp); sp->wrk = NULL; vca_return_session(sp); return (1); }
static void rsem_AA3(void) { WSL(X1); RSL(X2); }
static void rsem_AA2(void) { RSL(X1); WSL(X2); }
void VRT_acl_log(const struct sess *sp, const char *msg) { WSL(sp->wrk, SLT_VCL_acl, sp->fd, msg); }
int FetchBody(struct sess *sp) { int cls; struct storage *st; struct worker *w; int mklen; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(sp->obj->http, HTTP_MAGIC); if (w->vfp == NULL) w->vfp = &vfp_nop; AN(sp->director); AssertObjCorePassOrBusy(sp->obj->objcore); AZ(w->vgz_rx); AZ(VTAILQ_FIRST(&sp->obj->store)); switch (w->body_status) { case BS_NONE: cls = 0; mklen = 0; break; case BS_ZERO: cls = 0; mklen = 1; break; case BS_LENGTH: cls = fetch_straight(sp, w->htc, w->h_content_length); mklen = 1; XXXAZ(w->vfp->end(sp)); break; case BS_CHUNKED: cls = fetch_chunked(sp, w->htc); mklen = 1; XXXAZ(w->vfp->end(sp)); break; case BS_EOF: cls = fetch_eof(sp, w->htc); mklen = 1; XXXAZ(w->vfp->end(sp)); break; case BS_ERROR: cls = 1; mklen = 0; break; default: cls = 0; mklen = 0; INCOMPL(); } AZ(w->vgz_rx); /* * It is OK for ->end to just leave the last storage segment * sitting on w->storage, we will always call vfp_nop_end() * to get it trimmed or thrown out if empty. */ AZ(vfp_nop_end(sp)); WSL(w, SLT_Fetch_Body, sp->vbc->vsl_id, "%u(%s) cls %d mklen %u", w->body_status, body_status(w->body_status), cls, mklen); if (w->body_status == BS_ERROR) { VDI_CloseFd(sp); return (__LINE__); } if (cls < 0) { w->stats.fetch_failed++; /* XXX: Wouldn't this store automatically be released ? */ while (!VTAILQ_EMPTY(&sp->obj->store)) { st = VTAILQ_FIRST(&sp->obj->store); VTAILQ_REMOVE(&sp->obj->store, st, list); STV_free(st); } VDI_CloseFd(sp); sp->obj->len = 0; return (__LINE__); } if (cls == 0 && w->do_close) cls = 1; WSL(w, SLT_Length, sp->vbc->vsl_id, "%u", sp->obj->len); { /* Sanity check fetch methods accounting */ ssize_t uu; uu = 0; VTAILQ_FOREACH(st, &sp->obj->store, list) uu += st->len; if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS)) /* Streaming might have started freeing stuff */ assert (uu <= sp->obj->len); else assert(uu == sp->obj->len); } if (mklen > 0) { http_Unset(sp->obj->http, H_Content_Length); http_PrintfHeader(w, sp->vsl_id, sp->obj->http, "Content-Length: %jd", (intmax_t)sp->obj->len); } if (cls) VDI_CloseFd(sp); else VDI_RecycleFd(sp); return (0); }