From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [138.197.159.143]) by gnuweeb.org (Postfix) with ESMTPSA id 591F97F71F; Fri, 27 May 2022 00:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1653609760; bh=aj88cbK45mPfYpbsEHWaRxMdphseNME1m9/eofpBsJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pt+/hwgAdM3axTUVFK9hbGF1VInCj5hzC5RuX2A9yLbYPJWzbul79tdGwLetrMAbB 5+xXXMKfvKso/sMC+t8qOulP43iN6LbVPz+ecFLXpdHRbqntZ7DmGJZOmhM3sWd7JO ZPxav8GEb5wrMYrNUA4oyVR/YFKy6Q002fxAEo80bcgAFoKiizhs1GDlVx8XJ/BitQ rrisLTyvvMA6HxfUbVnOVnofui3QGspBWc7p0uBqB1p1OrKJCxPt+mrgUfiYl+6IL1 DEW9ziPDQIbDqEbbMLjNGzHuFNuxbH6fVSkvZ21UW+LRFbvIrHeYq0clbXm+1ZwemN hPawpySwjFbrw== From: Alviro Iskandar Setiawan To: Ammar Faizi Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List , Tea Inside Mailing List , Ammar Faizi , Louvian Lyndal , Michael Arminto Subject: [PATCH teavpn2 1/3] allocator: Fix `@errno` value when overflow Date: Fri, 27 May 2022 00:02:25 +0000 Message-Id: <20220527000227.1253934-2-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220527000227.1253934-1-alviro.iskandar@gnuweeb.org> References: <20220527000227.1253934-1-alviro.iskandar@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The calloc() function from libc sets the @errno variable to ENOMEM when overflow, not to EOVERFLOW. Change it to ENOMEM to follow libc error code. Fixes: 44f2ca85b3b923b9405b9da89a1e76039b7bafa1 ("allocator: implement custom allocator to guarantee 64-byte alignment") Cc: Ammar Faizi Cc: Louvian Lyndal Cc: Michael Arminto Signed-off-by: Alviro Iskandar Setiawan --- src/teavpn2/allocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/teavpn2/allocator.c b/src/teavpn2/allocator.c index 5918009..8aeb2d8 100644 --- a/src/teavpn2/allocator.c +++ b/src/teavpn2/allocator.c @@ -32,7 +32,7 @@ noinline void *al64_calloc(size_t nmemb, size_t size) size_t real_size = 0; if (unlikely(__builtin_mul_overflow(nmemb, size, &real_size))) { - errno = EOVERFLOW; + errno = ENOMEM; return NULL; } -- Alviro Iskandar Setiawan