]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: fcgi: Replace memcpy() on ist by istcat()
authorTim Duesterhus <tim@bastelstu.be>
Fri, 4 Mar 2022 23:52:44 +0000 (00:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Mar 2022 06:51:27 +0000 (07:51 +0100)
This is a little cleaner, because the length of the resulting string does not
need to be calculated manually.

src/mux_fcgi.c

index a22bc9391f4ddfb3feb1fc15069a5a91d6ed3876..0a8679019a255b7e8ef3ce6d6421b498d2f81dbb 100644 (file)
@@ -2030,6 +2030,8 @@ static size_t fcgi_strm_send_params(struct fcgi_conn *fconn, struct fcgi_strm *f
                                else if (isteq(p.n, ist("content-type")))
                                        p.n = ist("CONTENT_TYPE");
                                else {
+                                       struct ist n;
+
                                        if (isteq(p.n, ist("host")))
                                                params.srv_name = p.v;
                                        else if (isteq(p.n, ist("te"))) {
@@ -2046,9 +2048,10 @@ static size_t fcgi_strm_send_params(struct fcgi_conn *fconn, struct fcgi_strm *f
                                        if (isttest(fconn->proxy->server_id_hdr_name) && isteq(p.n, fconn->proxy->server_id_hdr_name))
                                                break;
 
-                                       memcpy(trash.area, "http_", 5);
-                                       memcpy(trash.area+5, p.n.ptr, p.n.len);
-                                       p.n = ist2(trash.area, p.n.len+5);
+                                       n = ist2(trash.area, 0);
+                                       istcat(&n, ist("http_"), trash.size);
+                                       istcat(&n, p.n, trash.size);
+                                       p.n = n;
                                }
 
                                if (!fcgi_encode_param(&outbuf, &p)) {