From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
Tea Inside Mailing List <timl@vger.teainside.org>,
Ammar Faizi <ammarfaizi2@gmail.com>,
Louvian Lyndal <louvianlyndal@gmail.com>,
Michael Arminto <kohaku.mski@gmail.com>
Subject: [PATCH teavpn2 1/3] allocator: Fix `@errno` value when overflow
Date: Fri, 27 May 2022 00:02:25 +0000 [thread overview]
Message-ID: <20220527000227.1253934-2-alviro.iskandar@gnuweeb.org> (raw)
In-Reply-To: <20220527000227.1253934-1-alviro.iskandar@gnuweeb.org>
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 <ammarfaizi2@gmail.com>
Cc: Louvian Lyndal <louvianlyndal@gmail.com>
Cc: Michael Arminto <kohaku.mski@gmail.com>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
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
next prev parent reply other threads:[~2022-05-27 0:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 0:02 [PATCH teavpn2 0/3] teavpn2 fixes Alviro Iskandar Setiawan
2022-05-27 0:02 ` Alviro Iskandar Setiawan [this message]
2022-05-27 0:02 ` [PATCH teavpn2 2/3] net: iface: Fix a potential NULL pointer dereference Alviro Iskandar Setiawan
2022-05-27 0:02 ` [PATCH teavpn2 3/3] arch/linux: syscall: Fix retval checking in libc syscall Alviro Iskandar Setiawan
2022-05-27 0:14 ` [PATCH teavpn2 0/3] teavpn2 fixes Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220527000227.1253934-2-alviro.iskandar@gnuweeb.org \
--to=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gmail.com \
--cc=ammarfaizi2@gnuweeb.org \
--cc=gwml@vger.gnuweeb.org \
--cc=kohaku.mski@gmail.com \
--cc=louvianlyndal@gmail.com \
--cc=timl@vger.teainside.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox