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 integral2.. (unknown [125.160.108.65]) by gnuweeb.org (Postfix) with ESMTPSA id 7B6DA7F91E; Sun, 26 Jun 2022 02:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656211543; bh=n+H5MdKm0euCjLN4JZRPMPU3ZvcLRktbV8WqSjnKKp0=; h=From:To:Cc:Subject:Date:From; b=lPHK7oWxsJ6oSEH1iImhgr7hKTu8ARJPDM9uJjtfG5HS5RNi9Pgi3CorLp46Tu5uA EcficiBPUsoy+ykw9YRgvCxtvmdqT2KohzmY4K3IQKOkG1urkRJCU/miLMg4tingDF GSyeVJ2p/Sq7g96CTlhuP0mBzSN+LCcXbNLzaBPcJnlx/Y1LrYb9DJLRchrXI/f/Bx +UvANpY5VJUcohVeQKIyLKkplVSXVz1jYexN8GOJucik1HgYbG7k/VZ5A4gUz91gnE IDZJeBzRDFEoIlbs6jmdZLW215k318pAY5iEfHSh1NR+27wZ5QCCuksbQN4ukDMuPr IGs4w2oubAIOA== From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Yonle Subject: [PATCH gwhttpd 0/2] Two gwhttpd fixes Date: Sun, 26 Jun 2022 09:45:29 +0700 Message-Id: <20220626024531.657451-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 Signed-off-by: Ammar Faizi --- 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