[hurd,commited] hurd TIOCFLUSH: Cope BSD 4.1 semantic

Message ID 20210201184434.654055-1-samuel.thibault@ens-lyon.org
State Committed, archived
Headers
Series [hurd,commited] hurd TIOCFLUSH: Cope BSD 4.1 semantic |

Commit Message

Samuel Thibault Feb. 1, 2021, 6:44 p.m. UTC
  BSD 4.1 did not have an argument for TIOCFLUSH, BSD 4.2 added it. There
are still a lot of applications out there that pass a NULL argument to
TIOCFLUSH, so we should rather cope with it.
---
 sysdeps/mach/hurd/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Andreas Schwab Feb. 1, 2021, 6:55 p.m. UTC | #1
On Feb 01 2021, Samuel Thibault wrote:

> BSD 4.1 did not have an argument for TIOCFLUSH, BSD 4.2 added it. There
> are still a lot of applications out there that pass a NULL argument to
> TIOCFLUSH, so we should rather cope with it.
> ---
>  sysdeps/mach/hurd/ioctl.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
> index 662e8ee919..0d5bc176d1 100644
> --- a/sysdeps/mach/hurd/ioctl.c
> +++ b/sysdeps/mach/hurd/ioctl.c
> @@ -113,6 +113,10 @@ __ioctl (int fd, unsigned long int request, ...)
>  	  /* We don't want to advance ARG since it will be used to copy out
>  	     too if IOC_OUT is also set.  */
>  	  void *argptr = arg;
> +	  int zero = 0;
> +
> +	  if (request == TIOCFLUSH && !arg)
> +	    arg = &zero;

s/arg/argptr/.

Andreas.
  
Samuel Thibault Feb. 1, 2021, 7:03 p.m. UTC | #2
Andreas Schwab, le lun. 01 févr. 2021 19:55:05 +0100, a ecrit:
> On Feb 01 2021, Samuel Thibault wrote:
> 
> > BSD 4.1 did not have an argument for TIOCFLUSH, BSD 4.2 added it. There
> > are still a lot of applications out there that pass a NULL argument to
> > TIOCFLUSH, so we should rather cope with it.
> > ---
> >  sysdeps/mach/hurd/ioctl.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
> > index 662e8ee919..0d5bc176d1 100644
> > --- a/sysdeps/mach/hurd/ioctl.c
> > +++ b/sysdeps/mach/hurd/ioctl.c
> > @@ -113,6 +113,10 @@ __ioctl (int fd, unsigned long int request, ...)
> >  	  /* We don't want to advance ARG since it will be used to copy out
> >  	     too if IOC_OUT is also set.  */
> >  	  void *argptr = arg;
> > +	  int zero = 0;
> > +
> > +	  if (request == TIOCFLUSH && !arg)
> > +	    arg = &zero;
> 
> s/arg/argptr/.

Argl, yes, that was so in my actual test tree (that can actually be
tested within an actual distribution), and not backported to my commit
tree.

Fixed so, thanks for proofreading.

Samuel
  

Patch

diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
index 662e8ee919..0d5bc176d1 100644
--- a/sysdeps/mach/hurd/ioctl.c
+++ b/sysdeps/mach/hurd/ioctl.c
@@ -113,6 +113,10 @@  __ioctl (int fd, unsigned long int request, ...)
 	  /* We don't want to advance ARG since it will be used to copy out
 	     too if IOC_OUT is also set.  */
 	  void *argptr = arg;
+	  int zero = 0;
+
+	  if (request == TIOCFLUSH && !arg)
+	    arg = &zero;
 
 	  /* Pack an argument into the message buffer.  */
 	  void in (unsigned int count, enum __ioctl_datum type)