From: Willy Tarreau Date: Thu, 10 Mar 2016 15:53:03 +0000 (+0100) Subject: CLEANUP: payload: remove useless and confusing nullity checks for channel buffer X-Git-Tag: v1.7-dev2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4cefbc07529923d3d0e89fba52c2e037d70e664e;p=thirdparty%2Fhaproxy.git CLEANUP: payload: remove useless and confusing nullity checks for channel buffer The buffer could not be null by definition since we moved the stream out of the session. It's the stream which gained the ability to be NULL (hence the recent fix for this case). The checks in place are useless and make one think this situation can happen. --- diff --git a/src/payload.c b/src/payload.c index 620ebe4346..0cac555da0 100644 --- a/src/payload.c +++ b/src/payload.c @@ -50,9 +50,6 @@ smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void * return 0; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - return 0; - smp->data.type = SMP_T_SINT; smp->data.u.sint = chn->buf->i; smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE; @@ -75,9 +72,6 @@ smp_fetch_req_ssl_st_ext(const struct arg *args, struct sample *smp, const char goto not_ssl_hello; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - goto not_ssl_hello; - bleft = chn->buf->i; data = (unsigned char *)chn->buf->p; @@ -211,9 +205,6 @@ smp_fetch_req_ssl_ec_ext(const struct arg *args, struct sample *smp, const char goto not_ssl_hello; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - goto not_ssl_hello; - bleft = chn->buf->i; data = (unsigned char *)chn->buf->p; @@ -335,9 +326,6 @@ smp_fetch_ssl_hello_type(const struct arg *args, struct sample *smp, const char goto not_ssl_hello; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - goto not_ssl_hello; - bleft = chn->buf->i; data = (const unsigned char *)chn->buf->p; @@ -404,9 +392,6 @@ smp_fetch_req_ssl_ver(const struct arg *args, struct sample *smp, const char *kw return 0; req = &smp->strm->req; - if (!req->buf) - return 0; - msg_len = 0; bleft = req->buf->i; if (!bleft) @@ -547,9 +532,6 @@ smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char * goto not_ssl_hello; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - goto not_ssl_hello; - bleft = chn->buf->i; data = (unsigned char *)chn->buf->p; @@ -681,9 +663,6 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i int bleft; const unsigned char *data; - if (!s->req.buf) - return 0; - smp->flags = SMP_F_CONST; smp->data.type = SMP_T_STR; @@ -812,9 +791,6 @@ smp_fetch_payload_lv(const struct arg *arg_p, struct sample *smp, const char *kw return 0; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - return 0; - if (len_offset + len_size > chn->buf->i) goto too_short; @@ -865,9 +841,6 @@ smp_fetch_payload(const struct arg *arg_p, struct sample *smp, const char *kw, v return 0; chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req; - if (!chn->buf) - return 0; - if (!buf_size || buf_size > global.tune.bufsize || buf_offset + buf_size > global.tune.bufsize) { /* will never match */ smp->flags = 0;