bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] getpass echoes on many systems


From: Larry Jones
Subject: [Bug-gnulib] getpass echoes on many systems
Date: Tue, 30 Sep 2003 18:23:26 -0400 (EDT)

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:

Index: getpass.c
===================================================================
RCS file: /cvs/ccvs/lib/getpass.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- getpass.c   29 Jul 2003 13:37:37 -0000      1.1.2.1
+++ getpass.c   30 Sep 2003 22:11:51 -0000      1.1.2.2
@@ -20,6 +20,9 @@
 #endif
 
 #include <stdio.h>
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
 #include <termios.h>
 #include <unistd.h>
 #include "getline.h"
@@ -83,8 +86,11 @@
          /* Remove the newline.  */
          buf[nread - 1] = '\0';
          if (tty_changed)
-           /* Write the newline that was not echoed.  */
-           putc ('\n', out);
+           {
+             /* Write the newline that was not echoed.  */
+             if (out == in) fseek (out, 0, SEEK_CUR);
+             putc ('\n', out);
+           }
        }
     }
 
-Larry Jones

Well of course the zipper's going to get stuck if everyone
stands around WATCHING me! -- Calvin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]