From 30a979ab1460a57d466a6a5cc6adb96eac452ce4 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 6 Oct 2013 23:58:51 -0600 Subject: * new version 2.11.8 * Fix in configure script for recognition of SSL files in Ubuntu 12.04 * Alpine does not attempt to automatically reopen a collection that was not opened due to cancellation by the user. Instead, the user must try to open it explicitly. * few improvements on new /tls1, /tls1_1, etc. options. --- imap/src/mtest/mtest.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'imap/src/mtest/mtest.c') diff --git a/imap/src/mtest/mtest.c b/imap/src/mtest/mtest.c index 69af568b..12a05e33 100644 --- a/imap/src/mtest/mtest.c +++ b/imap/src/mtest/mtest.c @@ -81,7 +81,7 @@ void overview_header (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov, void header (MAILSTREAM *stream,long msgno); void display_body (BODY *body,char *pfx,long i); void status (MAILSTREAM *stream); -void prompt (char *msg,char *txt); +void prompt (char *msg,char *txt, int buflen); void smtptest (long debug); /* Main program - initialization */ @@ -118,13 +118,13 @@ int main () #endif curhst = cpystr (mylocalhost ()); puts ("MTest -- C client test program"); - if (!*personalname) prompt ("Personal name: ",personalname); + if (!*personalname) prompt ("Personal name: ",personalname, sizeof(personalname)); /* user wants protocol telemetry? */ - prompt ("Debug protocol (y/n)?",tmp); + prompt ("Debug protocol (y/n)?",tmp, sizeof(tmp)); ucase (tmp); debug = (tmp[0] == 'Y') ? T : NIL; do { - prompt ("Mailbox ('?' for help): ",tmp); + prompt ("Mailbox ('?' for help): ",tmp, sizeof(tmp)); if (!strcmp (tmp,"?")) { puts ("Enter INBOX, mailbox name, or IMAP mailbox as {host}mailbox"); puts ("Known local mailboxes:"); @@ -154,13 +154,13 @@ void mm (MAILSTREAM *stream,long debug) { void *sdb = NIL; char cmd[MAILTMPLEN]; - char *s,*arg; + char *s, *arg; unsigned long i; unsigned long last = 0; BODY *body; status (stream); /* first report message status */ while (stream) { - prompt ("MTest>",cmd); /* prompt user, get command */ + prompt ("MTest> ",cmd, sizeof(cmd)); /* prompt user, get command */ /* get argument */ if (arg = strchr (cmd,' ')) *arg++ = '\0'; switch (*ucase (cmd)) { /* dispatch based on command */ @@ -255,7 +255,7 @@ void mm (MAILSTREAM *stream,long debug) } /* get the new mailbox */ while (!(stream = mail_open (stream,arg,debug))) { - prompt ("Mailbox: ",arg); + prompt ("Mailbox: ",arg, sizeof(arg)); if (!arg[0]) break; } last = 0; @@ -592,10 +592,14 @@ void status (MAILSTREAM *stream) * pointer to input buffer */ -void prompt (char *msg,char *txt) +void prompt (char *msg,char *txt, int buflen) { printf ("%s",msg); - gets (txt); + fgets (txt, buflen-1, stdin); + if(txt[strlen(txt)-1] == '\012') + txt[strlen(txt)-1] = '\0'; + if(txt[strlen(txt)-1] == '\015') + txt[strlen(txt)-1] = '\0'; } /* Interfaces to C-client */ @@ -758,14 +762,14 @@ void smtptest (long debug) msg->return_path = mail_newaddr (); msg->return_path->mailbox = cpystr (curusr); msg->return_path->host = cpystr (curhst); - prompt ("To: ",line); + prompt ("To: ",line, sizeof(line)); rfc822_parse_adrlist (&msg->to,line,curhst); if (msg->to) { - prompt ("cc: ",line); + prompt ("cc: ",line, sizeof(line)); rfc822_parse_adrlist (&msg->cc,line,curhst); } else { - prompt ("Newsgroups: ",line); + prompt ("Newsgroups: ",line, sizeof(line)); if (*line) msg->newsgroups = cpystr (line); else { mail_free_body (&body); @@ -774,12 +778,16 @@ void smtptest (long debug) return; } } - prompt ("Subject: ",line); + prompt ("Subject: ",line, sizeof(line)); msg->subject = cpystr (line); puts (" Msg (end with a line with only a '.'):"); body->type = TYPETEXT; *text = '\0'; - while (gets (line)) { + while (fgets(line, sizeof(line)-1, stdin)){ + if(line[strlen(line)-1] == '\012') + line[strlen(line)-1] = '\0'; + if(line[strlen(line)-1] == '\015') + line[strlen(line)-1] = '\0'; if (line[0] == '.') { if (line[1] == '\0') break; else strcat (text,"."); -- cgit v1.2.3-70-g09d2