aboutsummaryrefslogtreecommitdiff
path: root/libpam_misc/misc_conv.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpam_misc/misc_conv.c')
-rw-r--r--libpam_misc/misc_conv.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c
index f6397af1..dbcd6aec 100644
--- a/libpam_misc/misc_conv.c
+++ b/libpam_misc/misc_conv.c
@@ -17,8 +17,9 @@
#include <security/pam_appl.h>
#include <security/pam_misc.h>
+#include "pam_inline.h"
-#define INPUTSIZE PAM_MAX_RESP_SIZE /* maximum length of input+1 */
+#define INPUTSIZE PAM_MISC_CONV_BUFSIZE /* maximum length of input+1 */
#define CONV_ECHO_ON 1 /* types of echo state */
#define CONV_ECHO_OFF 0
@@ -184,15 +185,17 @@ static int read_string(int echo, const char *prompt, char **retstr)
nc++) {
int rv;
if ((rv=read(STDIN_FILENO, line+nc, 1)) != 1) {
- if (rv < 0)
+ if (rv < 0) {
+ pam_overwrite_n(line, (unsigned int) nc);
nc = rv;
+ }
break;
}
}
if (have_term) {
(void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before);
if (!echo || expired) /* do we need a newline? */
- fprintf(stderr,"\n");
+ fprintf(stderr, "\n");
}
if ( delay > 0 ) {
reset_alarm(&old_sig);
@@ -202,7 +205,7 @@ static int read_string(int echo, const char *prompt, char **retstr)
} else if (nc > 0) { /* we got some user input */
D(("we got some user input"));
- if (nc > 0 && line[nc-1] == '\n') { /* <NUL> terminate */
+ if (line[nc-1] == '\n') { /* <NUL> terminate */
line[--nc] = '\0';
} else {
if (echo) {
@@ -211,7 +214,7 @@ static int read_string(int echo, const char *prompt, char **retstr)
line[nc] = '\0';
}
*retstr = strdup(line);
- _pam_overwrite(line);
+ pam_overwrite_array(line);
if (!*retstr) {
D(("no memory for response string"));
nc = -1;
@@ -244,13 +247,13 @@ static int read_string(int echo, const char *prompt, char **retstr)
D(("the timer appears to have expired"));
*retstr = NULL;
- _pam_overwrite(line);
+ pam_overwrite_array(line);
cleanexit:
if (have_term) {
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
- (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before);
+ (void) tcsetattr(STDIN_FILENO, TCSAFLUSH, &term_before);
}
return nc;
@@ -374,7 +377,7 @@ failed_conversation:
switch (msgm[count]->msg_style) {
case PAM_PROMPT_ECHO_ON:
case PAM_PROMPT_ECHO_OFF:
- _pam_overwrite(reply[count].resp);
+ pam_overwrite_string(reply[count].resp);
free(reply[count].resp);
break;
case PAM_BINARY_PROMPT: