plugins/passprompt: Fix potential out-of-bounds array reference
authorPaul Mackerras <paulus@samba.org>
Sun, 3 Feb 2013 10:44:11 +0000 (21:44 +1100)
committerPaul Mackerras <paulus@samba.org>
Sun, 3 Feb 2013 10:44:11 +0000 (21:44 +1100)
From Debian BTS, fix suggested by Timo Weingärtner.

Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd/plugins/passprompt.c

index 1d885fcea53ba53fa732381ad69be3737def9ad5..babb6dc31bab6f1d71d1cabedfd844ba2a4d5158 100644 (file)
@@ -82,7 +82,6 @@ static int promptpass(char *user, char *passwd)
        }
        readgood += red;
     } while (readgood < MAXSECRETLEN - 1);
-    passwd[readgood] = 0;
     close(p[0]);
 
     /* now wait for child to exit */
@@ -95,6 +94,7 @@ static int promptpass(char *user, char *passwd)
 
     if (readgood < 0)
        return 0;
+    passwd[readgood] = 0;
     if (!WIFEXITED(wstat))
        warn("%s terminated abnormally", promptprog);
     if (WEXITSTATUS(wstat))