From: Hugo Villeneuve Date: Sat, 14 Jan 2017 15:31:59 +0000 (-0500) Subject: Remove clear text password in debug mode X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=3aa4cc07fdae2face0697bdd5ec17de10f40d776;p=dockapps%2Fwmnotify.git Remove clear text password in debug mode --- diff --git a/src/imap.c b/src/imap.c index 29400dd..eae62ce 100644 --- a/src/imap.c +++ b/src/imap.c @@ -118,10 +118,7 @@ get_packet: } if (wmnotify_infos.debug) { - printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - printf("IMAP4 Server Response (size %d bytes):\n", len); printf("%s", rx_buffer); - printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); } /* @@ -245,6 +242,8 @@ static int IMAP4_SendCommand(int argc, char *argv[]) { int len; int i; + char debug_buffer[sizeof(tx_buffer)]; + int debug_len; /* Adding Transaction Label. */ tlabel++; @@ -253,16 +252,26 @@ static int IMAP4_SendCommand(int argc, char *argv[]) len += sprintf(tx_buffer + len, "%d", tlabel); tlabel_len = len; + debug_len = 0; + debug_len += sprintf(debug_buffer + debug_len, "%s", tx_buffer); + /* Adding command and it's arguments. */ - for (i = 0; i < argc; i++) + for (i = 0; i < argc; i++) { len += sprintf(tx_buffer + len, " %s", argv[i]); + if (STREQ(argv[0], IMAP4_CMD_LOGIN) && (i == 2)) { + debug_len += sprintf(debug_buffer + debug_len, + " XXXXXXXX"); + } + else { + debug_len += sprintf(debug_buffer + debug_len, + " %s", argv[i]); + } + } + if (wmnotify_infos.debug) { - tx_buffer[len] = '\0'; - printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); - printf("IMAP4 Client Command (size %d bytes):\n%s\n", len, - tx_buffer); - printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); + debug_buffer[debug_len] = '\0'; + printf("%s\n", debug_buffer); } /* Adding termination characters. */