From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 50F5E1F567 for ; Sun, 24 Sep 2023 21:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1695589704; bh=hW371ecBziYWuHqWXRgA4hJfgBCdIxsr65viWfz8O24=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cZwEAuJExN82V0Y5DiPaDgjxrEgt7oEfpk9oAVDBc2c64Bsv0+ZJv6D2PL1qGwrBl WCglXhgW9iAW08XTZDMibnNto2Ph0C4Wqzk5S53t0C5oqf/alCN42uGmhwrleT3I0u vuKzEy7mVhy0veCSu3K/LmsJcxpKg55tSBvhubZI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] xap_helper.h: add missing headers and avoid reallocarray Date: Sun, 24 Sep 2023 21:08:22 +0000 Message-Id: <20230924210822.2771981-5-e@80x24.org> In-Reply-To: <20230924210822.2771981-1-e@80x24.org> References: <20230924210822.2771981-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: These changes are necessary with glibc 2.17 and g++ 4.8.5 on CentOS 7.x. We don't have to worry about overflow with realloc(3) here since WORKER_MAX is only USHRT_MAX and sizeof(pid_t) is 4 bytes on every platform I've encountered. --- lib/PublicInbox/xap_helper.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index 377ff45a..5f04316c 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -35,7 +35,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -1084,9 +1087,9 @@ static void do_sigttin(void) warnx("workers cannot exceed %zu", (size_t)WORKER_MAX); return; } - void *p = reallocarray(worker_pids, nworker + 1, sizeof(pid_t)); + void *p = realloc(worker_pids, (nworker + 1) * sizeof(pid_t)); if (!p) { - warn("reallocarray"); + warn("realloc worker_pids"); } else { worker_pids = (pid_t *)p; worker_pids[nworker++] = 0;