Make use of the new rules to use `istend()`. --- src/h1.c | 4 ++-- src/h2.c | 2 +- src/hlua.c | 2 +- src/http_htx.c | 11 ++++++----- src/htx.c | 11 +++++++---- src/tcpcheck.c | 3 ++- 6 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/src/h1.c b/src/h1.c index e0ba8d768..99b9c2993 100644 --- a/src/h1.c +++ b/src/h1.c @@ -110,7 +110,7 @@ int h1_parse_xfer_enc_header(struct h1m *h1m, struct ist value) h1m->flags |= H1_MF_XFER_ENC; word.ptr = value.ptr - 1; // -1 for next loop's pre-increment - e = value.ptr + value.len; + e = istend(value); while (++word.ptr < e) { /* skip leading delimiter and blanks */ @@ -229,7 +229,7 @@ void h1_parse_upgrade_header(struct h1m *h1m, struct ist value) h1m->flags &= ~H1_MF_UPG_WEBSOCKET; word.ptr = value.ptr - 1; // -1 for next loop's pre-increment - e = value.ptr + value.len; + e = istend(value); while (++word.ptr < e) { /* skip leading delimiter and blanks */ diff --git a/src/h2.c b/src/h2.c index dd1f7d9b6..49a1252e9 100644 --- a/src/h2.c +++ b/src/h2.c @@ -62,7 +62,7 @@ static int has_forbidden_char(const struct ist ist, const char *start) (1U << (uint8_t)*start) & ((1<<13) | (1<<10) | (1<<0))) return 1; start++; - } while (start < ist.ptr + ist.len); + } while (start < istend(ist)); return 0; } diff --git a/src/hlua.c b/src/hlua.c index e9d4391f7..086a8e0be 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -4750,7 +4750,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx) char *p, *q, *end; p = path.ptr; - end = path.ptr + path.len; + end = istend(path); q = p; while (q < end && *q != '?') q++; diff --git a/src/http_htx.c b/src/http_htx.c index 8028cfc99..d93cc3797 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -195,7 +195,8 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct if (istlen(n) < istlen(name)) goto next_blk; - n = ist2(istptr(n) + istlen(n) - istlen(name), istlen(name)); + n = ist2(istend(n) - istlen(name), + istlen(name)); if (!isteqi(n, name)) goto next_blk; break; @@ -219,8 +220,8 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct ctx->lws_before++; } if (!(flags & HTTP_FIND_FL_FULL)) - v.len = http_find_hdr_value_end(v.ptr, v.ptr + v.len) - v.ptr; - while (v.len && HTTP_IS_LWS(*(v.ptr + v.len - 1))) { + v.len = http_find_hdr_value_end(v.ptr, istend(v)) - v.ptr; + while (v.len && HTTP_IS_LWS(*(istend(v) - 1))) { v.len--; ctx->lws_after++; } @@ -710,7 +711,7 @@ int http_update_authority(struct htx *htx, struct htx_sl *sl, const struct ist h chunk_memcat(temp, uri.ptr, authority.ptr - uri.ptr); chunk_memcat(temp, host.ptr, host.len); - chunk_memcat(temp, authority.ptr + authority.len, uri.ptr + uri.len - (authority.ptr + authority.len)); + chunk_memcat(temp, istend(authority), istend(uri) - istend(authority)); uri = ist2(temp->area + meth.len + vsn.len, host.len + uri.len - authority.len); /* uri */ return http_replace_stline(htx, meth, uri, vsn); @@ -917,7 +918,7 @@ int http_str_to_htx(struct buffer *buf, struct ist raw, char **errmsg) h1m_init_res(&h1m); h1m.flags |= H1_MF_NO_PHDR; - ret = h1_headers_to_hdr_list(raw.ptr, raw.ptr + raw.len, + ret = h1_headers_to_hdr_list(raw.ptr, istend(raw), hdrs, sizeof(hdrs)/sizeof(hdrs[0]), &h1m, &h1sl); if (ret <= 0) { memprintf(errmsg, "unabled to parse headers (error offset: %d)", h1m.err_pos); diff --git a/src/htx.c b/src/htx.c index 8c6e368e7..940989c50 100644 --- a/src/htx.c +++ b/src/htx.c @@ -601,11 +601,13 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk, if (delta <= 0) { /* compression: copy new data first then move the end */ memcpy(old.ptr, new.ptr, new.len); - memmove(old.ptr + new.len, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len)); + memmove(old.ptr + new.len, istend(old), + istend(v) - istend(old)); } else { /* expansion: move the end first then copy new data */ - memmove(old.ptr + new.len, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len)); + memmove(old.ptr + new.len, istend(old), + istend(v) - istend(old)); memcpy(old.ptr, new.ptr, new.len); } @@ -629,7 +631,7 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk, ptr += new.len; /* Copy value after old part, if any */ - memcpy(ptr, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len)); + memcpy(ptr, istend(old), istend(v) - istend(old)); /* set the new block size and update HTX message */ htx_set_blk_value_len(blk, v.len + delta); @@ -654,7 +656,8 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk, /* move the end first and copy new data */ - memmove(old.ptr + offset + new.len, old.ptr + offset + old.len, (v.ptr + v.len) - (old.ptr + old.len)); + memmove(old.ptr + offset + new.len, old.ptr + offset + old.len, + istend(v) - istend(old)); memcpy(old.ptr + offset, new.ptr, new.len); } return blk; diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 14f83eae0..30e83de7d 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -1818,7 +1818,8 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, struct tcp case TCPCHK_EXPT_FL_HTTP_HVAL_END: if (istlen(value) < istlen(vpat)) break; - value = ist2(istptr(value) + istlen(value) - istlen(vpat), istlen(vpat)); + value = ist2(istend(value) - istlen(vpat), + istlen(vpat)); if (isteq(value, vpat)) { match = 1; goto end_of_match; -- 2.33.1