[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] getpass echoes on many systems
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] getpass echoes on many systems |
Date: |
Wed, 1 Oct 2003 13:14:34 +0200 |
User-agent: |
KMail/1.5 |
Larry Jones wrote:
> We just had a bug report on the newly-released CVS 1.11.7 that passwords
> were getting echoed, not while entering them, but after hitting return.
> This is due to a bug in getpass.c. According to the C standard, input
> may not be followed by output on the same stream without an intervening
> call to a file positioning function. Here's a patch:
Thanks a lot. I've committed your fix, with an extended comment in the
source code.
> +#ifndef SEEK_CUR
> +#define SEEK_CUR 1
> +#endif
I've replaced this with #include <fcntl.h>, Should be sufficient for those
systems that don't define SEEK_CUR in <stdio.h>, I hope?
Bruno
*** getpass.c 9 Jul 2003 22:48:53 -0000 1.4
--- getpass.c 1 Oct 2003 11:11:02 -0000 1.5
***************
*** 1,4 ****
! /* Copyright (C) 1992,93,94,95,96,97,98,99,2000, 2001 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
--- 1,4 ----
! /* Copyright (C) 1992-2001, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
***************
*** 22,27 ****
--- 22,28 ----
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
+ #include <fcntl.h>
#include "getline.h"
#include "unlocked-io.h"
***************
*** 84,91 ****
/* Remove the newline. */
buf[nread - 1] = '\0';
if (tty_changed)
! /* Write the newline that was not echoed. */
! putc ('\n', out);
}
}
--- 85,102 ----
/* Remove the newline. */
buf[nread - 1] = '\0';
if (tty_changed)
! {
! /* Write the newline that was not echoed.
! But before doing that, do a no-op fseek. According to the C
! standard, input may not be followed by output on the same
! stream without an intervening call to a file positioning
! function. Without this fseek() call, on Solaris, HP-UX,
! AIX, OSF/1, the previous input gets echoed, whereas on IRIX,
! the following newline is not output as it should. */
! if (out == in)
! fseek (out, 0, SEEK_CUR);
! putc ('\n', out);
! }
}
}
- Re: [Bug-gnulib] getpass echoes on many systems,
Bruno Haible <=
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Bruno Haible, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Bruno Haible, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02