]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper: allow non-standard file description flags
authorEric Wong <e@80x24.org>
Mon, 4 Sep 2023 23:49:46 +0000 (23:49 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Sep 2023 03:01:45 +0000 (03:01 +0000)
pipe2(.., O_CLOEXEC) on NetBSD sets the O_CLOEXEC file description
flag along with the FD_CLOEXEC file descriptor flag, so we must
not attempt to do exact matches on the file description flags.

lib/PublicInbox/xap_helper.h

index 0f16d316fab0b09ff0e2dc5b0444448ed180dc9f..73590efd803551906973aaf8cefda58beaa1c1ee 100644 (file)
@@ -636,18 +636,17 @@ static bool recv_req(struct req *req, char *rbuf, size_t *len)
                        int fd = *fdp++;
                        const char *mode = NULL;
                        int fl = fd_ok ? fcntl(fd, F_GETFL) : 0;
-                       switch (fl) {
-                       case 0: break; // hit previous error
-                       case -1:
+                       if (fl == 0) {
+                               continue; // hit previous error
+                       } else if (fl == -1) {
                                warnx("invalid fd=%d", fd);
                                fd_ok = false;
-                               break;
-                       case O_WRONLY: mode = "w"; break;
-                       case O_RDWR:
+                       } else if (fl & O_WRONLY) {
+                               mode = "w";
+                       } else if (fl & O_RDWR) {
                                mode = "r+";
                                if (i == 0) req->has_input = true;
-                               break;
-                       default:
+                       } else {
                                warnx("invalid mode from F_GETFL: 0x%x", fl);
                                fd_ok = false;
                        }