diff options
author | Ludovic Courtès <ludo@gnu.org> | 2025-05-08 23:11:36 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-05-10 15:58:26 +0200 |
commit | 029ab7d7b38c76ba14c24fcbf526ccef29af9e88 (patch) | |
tree | 324a396caa436027292328e88d611002b3bfd866 | |
parent | 09b6cb6acf5b664c1eff805949446d4fcbc9d724 (diff) |
pflocal: Do not inherit PFLOCAL_SOCK_NONBLOCK across connect/accept.
Previously, ‘accept’ would return an O_NONBLOCK socket if the listening
socket was O_NONBLOCK at the time the connection was made. With this
change, ‘accept’ always returns a socket where O_NONBLOCK is cleared.
-rw-r--r-- | pflocal/sock.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pflocal/sock.c b/pflocal/sock.c index 90c618ec..6bc061d6 100644 --- a/pflocal/sock.c +++ b/pflocal/sock.c @@ -1,6 +1,6 @@ /* Sock functions - Copyright (C) 1995,96,2000,01,02, 2005 Free Software Foundation, Inc. + Copyright (C) 1995,96,2000,01,02, 2005, 2025 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.org> This program is free software; you can redistribute it and/or @@ -167,8 +167,11 @@ sock_clone (struct sock *template, struct sock **sock) if (err) return err; - /* Copy some properties from TEMPLATE. */ - (*sock)->flags = template->flags & ~PFLOCAL_SOCK_CONNECTED; + /* Copy some properties from TEMPLATE. Clear O_NONBLOCK because the socket + returned by 'accept' must not inherit O_NONBLOCK from the parent + socket. */ + (*sock)->flags = + template->flags & ~(PFLOCAL_SOCK_CONNECTED | PFLOCAL_SOCK_NONBLOCK); return 0; } |