This reapplies the xalloc_size.cocci patch across the whole `src/` tree.

see 16cc16dd8235e7eb6c38b7abd210bd1e1d96b1d9
see 63ee0e4c01b94aee5fc6c6dd98cfc4480ae5ea46
see 9fb57e8c175a0b852b06a0780f48eb8eaf321a47
---
 src/log.c        | 3 ++-
 src/proto_quic.c | 2 +-
 src/server.c     | 4 ++--
 src/tcpcheck.c   | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/log.c b/src/log.c
index 8ada05089..3458f93f9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -895,7 +895,8 @@ static int postcheck_log_backend(struct proxy *be)
        /* alloc srv array (it will be used for active and backup server lists 
in turn,
         * so we ensure that the longest list will fit
         */
-       be->lbprm.log.srv = calloc(MAX(be->srv_act, be->srv_bck), sizeof(struct 
server *));
+       be->lbprm.log.srv = calloc(MAX(be->srv_act, be->srv_bck),
+                                  sizeof(*be->lbprm.log.srv));
 
        if (!be->lbprm.log.srv ) {
                memprintf(&msg, "memory error when allocating server array (%d 
entries)",
diff --git a/src/proto_quic.c b/src/proto_quic.c
index 701dcb295..899cffebf 100644
--- a/src/proto_quic.c
+++ b/src/proto_quic.c
@@ -760,7 +760,7 @@ static int quic_alloc_dghdlrs(void)
                MT_LIST_INIT(&dghdlr->dgrams);
        }
 
-       quic_cid_trees = calloc(QUIC_CID_TREES_CNT, sizeof(struct 
quic_cid_tree));
+       quic_cid_trees = calloc(QUIC_CID_TREES_CNT, sizeof(*quic_cid_trees));
        if (!quic_cid_trees) {
                ha_alert("Failed to allocate global CIDs trees.\n");
                return 0;
diff --git a/src/server.c b/src/server.c
index 6e9e19564..ca48f2875 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1363,7 +1363,7 @@ static int srv_parse_set_proxy_v2_tlv_fmt(char **args, 
int *cur_arg,
                }
        }
 
-       srv_tlv = malloc(sizeof(struct srv_pp_tlv_list));
+       srv_tlv = malloc(sizeof(*srv_tlv));
        if (unlikely(!srv_tlv)) {
                memprintf(err, "'%s' : failed to parse allocate TLV entry", 
args[*cur_arg]);
                goto fail;
@@ -2516,7 +2516,7 @@ void srv_settings_cpy(struct server *srv, const struct 
server *src, int srv_tmpl
        list_for_each_entry(srv_tlv, &src->pp_tlvs, list) {
                if (srv_tlv == NULL)
                        break;
-               new_srv_tlv = malloc(sizeof(struct srv_pp_tlv_list));
+               new_srv_tlv = malloc(sizeof(*new_srv_tlv));
                if (unlikely(!new_srv_tlv)) {
                        break;
                }
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index c36b9d9a6..c00c47fed 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -4270,7 +4270,7 @@ int proxy_parse_smtpchk_opt(char **args, int cur_arg, 
struct proxy *curpx, const
            (strcmp(args[cur_arg], "EHLO") == 0 || strcmp(args[cur_arg], 
"HELO") == 0)) {
                /* <EHLO|HELO> + space (1) + <host> + null byte (1) */
                size_t len = strlen(args[cur_arg]) + 1 + 
strlen(args[cur_arg+1]) + 1;
-               cmd = calloc(len, 1);
+               cmd = calloc(1, len);
                if (cmd)
                        snprintf(cmd, len, "%s %s", args[cur_arg], 
args[cur_arg+1]);
        }
-- 
2.42.0


Reply via email to