public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH teavpn2 0/3] teavpn2 fixes
@ 2022-05-27  0:02 Alviro Iskandar Setiawan
  2022-05-27  0:02 ` [PATCH teavpn2 1/3] allocator: Fix `@errno` value when overflow Alviro Iskandar Setiawan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-05-27  0:02 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List,
	Tea Inside Mailing List, Ammar Faizi, Louvian Lyndal,
	Michael Arminto

Hi all,

I have a few TeaVPN2 fixes, please review. 3 patches below:

### Patch 1
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.

### Patch 2
The malloc() call in escapeshellarg() doesn't have a NULL check. This
results in a potential NULL pointer dereference. Fix this by checking
the return value of malloc(). Just return NULL directly if we hit the
ENOMEM case.

### Patch 3
The libc syscall wrappers mostly return -1 when they fail, then they
set the error code to the @errno variable. The current code seems to
be doing something wrong. We assume it errors when the return value
is negative. However, not all negative values are meant to be an
error indicator. On Linux, the only reserved error code is within
range [-4095, -1]. That means we still have a potential to get a
negative return value that is not an error.

I understand that most of them work fine here because of the nature
of the syscall itself that won't return a negative value upen
succcessful. But the above assumption about the negative value is
not correct.

Replace the error checking from (ret < 0) to (ret == -1) to reflect
the above fact.

Cc: Ammar Faizi <[email protected]>
Cc: Louvian Lyndal <[email protected]>
Cc: Michael Arminto <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>

---
Alviro Iskandar Setiawan (3):
  allocator: Fix `@errno` value when overflow
  net: iface: Fix a potential NULL pointer dereference
  arch/linux: syscall: Fix retval checking in libc syscall

 src/teavpn2/allocator.c          |  2 +-
 src/teavpn2/arch/generic/linux.h | 12 ++++++------
 src/teavpn2/net/linux/iface.c    |  7 +++++--
 3 files changed, 12 insertions(+), 9 deletions(-)


base-commit: 5e5223089d02c6fde68a0b567ca802317be59467
prerequisite-patch-id: b71545410b349281e6ead6ff1dcc1f71f8ab30a4
prerequisite-patch-id: 7fe15b03300490b8aa25cac4dd0be0bd3ce7a4bb
-- 
Alviro Iskandar Setiawan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-27  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-27  0:02 [PATCH teavpn2 0/3] teavpn2 fixes Alviro Iskandar Setiawan
2022-05-27  0:02 ` [PATCH teavpn2 1/3] allocator: Fix `@errno` value when overflow Alviro Iskandar Setiawan
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox