#983297 Substitute "mktemp" with "mkstemp"

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-02-22 23:27:02 UTC
Severity:
normal
Tags:
#983297#5
Date:
2021-02-22 02:13:19 UTC
From:
To:
Dear Maintainer,
"contrib/recmail.c" as "mktemp" is unsafe,
see "man 3 mktemp".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 contrib/recmail.c | 4 ++--
 nntp.c            | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/recmail.c b/contrib/recmail.c
index 78670d9..25e5f45 100644
--- a/contrib/recmail.c
+++ b/contrib/recmail.c
@@ -48,7 +48,7 @@
 extern char *getlogin();
 extern char *getenv();
 extern char *malloc();
-extern char *mktemp();
+extern char *mkstemp();
 extern struct passwd *getpwnam();
 void get_host_name();

@@ -89,7 +89,7 @@ char **argv;
 /*  FIX  this could be much better */
 	*tolist++ = MAILER;
 	*tolist++ = "-f";
-	*tolist++ = mktemp(strcpy(mail_spool, mail_template));
+	*tolist++ = mkstemp(strcpy(mail_spool, mail_template));
 	*tolist = pbuff;

 	if ((sfd = fopen(mail_spool, "w")) == NULL){
diff --git a/nntp.c b/nntp.c
index 0ba296f..c1bee4c 100644
--- a/nntp.c
+++ b/nntp.c
@@ -120,7 +120,7 @@ int             nntp_debug = 0;
 extern char    *home_directory;
 extern int      silent;

#983297#10
Date:
2021-02-22 23:17:13 UTC
From:
To:
cc -Iconf -Wall   -c -o nntp.o nntp.c
nntp.c:123:17: error: conflicting types for 'mkstemp'
  123 | extern char    *mkstemp();
      |                 ^~~~~~~
In file included from nntp.c:17:
/usr/include/stdlib.h:688:12: note: previous declaration of 'mkstemp'
was here
  688 | extern int mkstemp (char *__template) __nonnull ((1)) __wur;
      |            ^~~~~~~


nntp.c:  Remove declaration of "mkstemp" as it is defined in <stdlib.h>,
see "man 3 mktemp".

contrib/rcmail.c: likewise

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 contrib/recmail.c | 2 +-
 nntp.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/recmail.c b/contrib/recmail.c
index 25e5f45..40dfe1f 100644
--- a/contrib/recmail.c
+++ b/contrib/recmail.c
@@ -48,7 +48,7 @@
 extern char *getlogin();
 extern char *getenv();
 extern char *malloc();
-extern char *mkstemp();
+/* extern char *mkstemp(); defined in <stdlib.h>, see "man 3 mkstemp" */
 extern struct passwd *getpwnam();
 void get_host_name();

diff --git a/nntp.c b/nntp.c
index c1bee4c..11327a4 100644
--- a/nntp.c
+++ b/nntp.c
@@ -120,7 +120,7 @@ int             nntp_debug = 0;
 extern char    *home_directory;
 extern int      silent;