45 lines
1.2 KiB
Diff
45 lines
1.2 KiB
Diff
From 789c2d97f672fd25cb0f5495892f13eda9fef440 Mon Sep 17 00:00:00 2001
|
||
From: Christoph <ckubu@oopen.de>
|
||
Date: Sun, 14 Dec 2025 11:49:00 +0100
|
||
Subject: [PATCH 3/4] Replace gets() with fgets()
|
||
|
||
---
|
||
src/mtest/mtest.c | 7 +++++--
|
||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||
|
||
diff --git a/src/mtest/mtest.c b/src/mtest/mtest.c
|
||
index 69af568..c15a853 100644
|
||
--- a/src/mtest/mtest.c
|
||
+++ b/src/mtest/mtest.c
|
||
@@ -38,6 +38,7 @@
|
||
#include <signal.h>
|
||
#include "c-client.h"
|
||
#include "imap4r1.h"
|
||
+#include <string.h>
|
||
|
||
/* Excellent reasons to hate ifdefs, and why my real code never uses them */
|
||
|
||
@@ -595,7 +596,8 @@ void status (MAILSTREAM *stream)
|
||
void prompt (char *msg,char *txt)
|
||
{
|
||
printf ("%s",msg);
|
||
- gets (txt);
|
||
+ if (!fgets (txt, sizeof (txt), stdin)) txt[0] = '\0';
|
||
+ txt[strcspn (txt, "\r\n")] = '\0';
|
||
}
|
||
|
||
/* Interfaces to C-client */
|
||
@@ -779,7 +781,8 @@ void smtptest (long debug)
|
||
puts (" Msg (end with a line with only a '.'):");
|
||
body->type = TYPETEXT;
|
||
*text = '\0';
|
||
- while (gets (line)) {
|
||
+ while (fgets (line, sizeof (line), stdin)) {
|
||
+ line[strcspn (line, "\r\n")] = '\0';
|
||
if (line[0] == '.') {
|
||
if (line[1] == '\0') break;
|
||
else strcat (text,".");
|
||
--
|
||
2.47.3
|
||
|