public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: GNU/Weeb Mailing List <[email protected]>
Cc: Ammar Faizi <[email protected]>, Yonle <[email protected]>
Subject: [PATCH gwhttpd 0/2] Two gwhttpd fixes
Date: Sun, 26 Jun 2022 09:45:29 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

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


             reply	other threads:[~2022-06-26  2:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-26  2:45 Ammar Faizi [this message]
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

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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