BUG/MEDIUM: httpclient: limit transfers to the maximum available room
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Feb 2022 16:28:25 +0000 (17:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Feb 2022 16:36:31 +0000 (17:36 +0100)
commiteeb4d850eac9ac05c1500444dc5dd506e4a07b22
tree68c81c109c51f58e7ecfc58931a3edcf45762d8d
parent597e436053258d71e57381e14e1fae10220630bc
BUG/MEDIUM: httpclient: limit transfers to the maximum available room

A bug was uncovered by commit fc5912914 ("MINOR: httpclient: Don't limit
data transfer to 1024 bytes"), it happens that callers of b_xfer() and
b_force_xfer() are expected to check for available room in the target
buffer. Previously it was unlikely to be full but now with full buffer-
sized transfers, it happens more often and in practice it is possible
to crash the process with the debug command "httpclient" on the CLI by
going beyond a the max buffer size. Other call places ought to be
rechecked by now and it might be time to rethink this API if it tends
to generalize.

This must be backported to 2.5.

(cherry picked from commit 11adb1d8fcab29ef8b12c93e3b036bb3dcf1607b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/http_client.c