[gtk-vnc] Avoid use of uninitialized variables in password echo prompt



commit 8fb15eb1a4b129c01ee10f2b10fcd5c984e6ce2c
Author: Daniel P. Berrange <berrange redhat com>
Date:   Fri Dec 7 15:45:32 2012 +0000

    Avoid use of uninitialized variables in password echo prompt

 tools/gvnccapture.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/tools/gvnccapture.c b/tools/gvnccapture.c
index 2e3f577..c830ca4 100644
--- a/tools/gvnccapture.c
+++ b/tools/gvnccapture.c
@@ -150,12 +150,14 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
     fflush(stdout);
 
     /* Turn echoing off and fail if we can't. */
-    if (!doecho && tcgetattr (fileno (stdin), &old) != 0)
-        return NULL;
-    new = old;
-    new.c_lflag &= ~ECHO;
-    if (!doecho && tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
-        return NULL;
+    if (!doecho) {
+        if (tcgetattr (fileno (stdin), &old) != 0)
+            return NULL;
+        new = old;
+        new.c_lflag &= ~ECHO;
+        if (tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
+            return NULL;
+    }
 
     /* Read the password. */
     if ((res = fgets(buf, n, stdin)) != NULL) {



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