Files
uw-imap-2007f/patches/0003-Replace-gets-with-fgets.patch

45 lines
1.2 KiB
Diff
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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/5] 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