[BUG] Fix NULL pointer dereference in stats_check_uri_auth(), v2
Recent "struct chunk rework" introduced a NULL pointer dereference
and now haproxy segfaults if auth is required for stats but not found.
The reason is that size_t cannot store negative values, but current
code assumes that "len < 0" == uninitialized.
This patch fixes it.
diff --git a/src/proto_http.c b/src/proto_http.c
index 4638d09..8698594 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -4596,8 +4596,7 @@
int len = txn->hdr_idx.v[cur_idx].len;
if (len > 14 &&
!strncasecmp("Authorization:", h, 14)) {
- txn->auth_hdr.str = h;
- txn->auth_hdr.len = len;
+ chunk_initlen(&txn->auth_hdr, h, 0, len);
break;
}
h += len + txn->hdr_idx.v[cur_idx].cr + 1;