CLEANUP: Apply ist.cocci

Make use of the new rules to use `istend()`.
This commit is contained in:
Tim Duesterhus 2021-11-06 15:14:44 +01:00 committed by Willy Tarreau
parent 958f50454a
commit 4c8f75fc31
6 changed files with 19 additions and 14 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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++;

View File

@ -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,9 @@ 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 +712,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 +919,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);

View File

@ -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;

View File

@ -1818,7 +1818,7 @@ 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;