From e9187f8263ec1aa93379479c0454981746a543a8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 14 Apr 2014 15:27:14 +0200 Subject: [PATCH] BUILD/MEDIUM: http: remove calls to sprintf() OpenBSD complains about this use of sprintf() : src/proto_http.o(.text+0xb0e6): In function `http_process_request': src/proto_http.c:4127: warning: sprintf() is often misused, please use snprintf() Here there's no risk as the strings are way shorter than the buffer size but let's fix it anyway. --- src/proto_http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index c23fa541f3..1a8a6d92ff 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -4053,7 +4053,7 @@ int http_process_request(struct session *s, struct channel *req, int an_bit) len = s->fe->fwdfor_hdr_len; memcpy(trash.str, s->fe->fwdfor_hdr_name, len); } - len += sprintf(trash.str + len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); + len += snprintf(trash.str + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0)) goto return_bad_req; @@ -4081,7 +4081,7 @@ int http_process_request(struct session *s, struct channel *req, int an_bit) len = s->fe->fwdfor_hdr_len; memcpy(trash.str, s->fe->fwdfor_hdr_name, len); } - len += sprintf(trash.str + len, ": %s", pn); + len += snprintf(trash.str + len, trash.size - len, ": %s", pn); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0)) goto return_bad_req; @@ -4124,7 +4124,7 @@ int http_process_request(struct session *s, struct channel *req, int an_bit) len = s->fe->orgto_hdr_len; memcpy(trash.str, s->fe->orgto_hdr_name, len); } - len += sprintf(trash.str + len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); + len += snprintf(trash.str + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0)) goto return_bad_req; -- 2.47.3