public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH gwhttpd 0/2] Two gwhttpd fixes
@ 2022-06-26  2:45 Ammar Faizi
  2022-06-26  2:45 ` [PATCH gwhttpd 1/2] gwhttpd: Explicitly set sa_family before bind() Ammar Faizi
  2022-06-26  2:45 ` [PATCH gwhttpd 2/2] gwhttpd: Fix `EBADF` errors at destruction Ammar Faizi
  0 siblings, 2 replies; 3+ messages in thread
From: Ammar Faizi @ 2022-06-26  2:45 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Yonle

Hi,

This small series contains two fixes for gwhttpd.

## Patch 1
Yonle reported that he is getting an error on bind():

  Address family not supported by protocol

This doesn't mean that Yonle's device doesn't support IPv4, but it's
because we don't explicitly set the sa_family to AF_INET. This will
happen to work just fine only on a platform where `AF_INET == 0` since
we have a prior memset() call that zeroes the whole struct sockaddr_in.

On platforms that have `AF_INET != 0`, this will break. Fix this by
simply setting the `saddr.sa_family` to AF_INET at initialization.

## Patch 2
When Yonle reported an issue about error on bind(), he attached an
strace output and it has many EBADF errors like this:

  close(0) = 0
  close(0) = -1 EBADF (Bad file descriptor)
  close(0) = -1 EBADF (Bad file descriptor)
  close(0) = -1 EBADF (Bad file descriptor)
  close(0) = -1 EBADF (Bad file descriptor)
  close(0) = -1 EBADF (Bad file descriptor)
  ...

This happens because all sess[i].fd is set to 0 at initialization while
the destructor is supposed to close the file descriptor when it's not
equal to -1. Fix this by setting all file descriptor fields to -1 at
initialization.

Reported-by: Yonle <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---

Ammar Faizi (2):
  gwhttpd: Explicitly set sa_family before bind()
  gwhttpd: Fix `EBADF` errors at destruction

 gwhttpd.cpp | 2 ++
 1 file changed, 2 insertions(+)

base-commit: 864446870ed865423aadb4cb2c46e334010e72b4
-- 
Ammar Faizi


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

end of thread, other threads:[~2022-06-26  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-26  2:45 [PATCH gwhttpd 0/2] Two gwhttpd fixes Ammar Faizi
2022-06-26  2:45 ` [PATCH gwhttpd 1/2] gwhttpd: Explicitly set sa_family before bind() Ammar Faizi
2022-06-26  2:45 ` [PATCH gwhttpd 2/2] gwhttpd: Fix `EBADF` errors at destruction Ammar Faizi

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