Bug#983297: Substitute "mktemp" with "mkstemp"

2021-02-22 Thread Bjarni Ingi Gislason
>From 9e118ddc9b66faa71e517117d7dc4349d9e9466f Mon Sep 17 00:00:00 2001
>From: Bjarni Ingi Gislason 
>Date: Mon, 22 Feb 2021 22:51:39 +
>Subject: [PATCH] Remove declaration of "mkstemp"

  Warning from the compiler:

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 ,
see "man 3 mktemp".

contrib/rcmail.c: likewise

Signed-off-by: Bjarni Ingi Gislason 
---
 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 , 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;
 
-extern char*mkstemp();
+/* extern char*mkstemp(); defined in , see "man 3 mkstemp" */
 
 static FILE*nntp_in = NULL;/* fp for reading from server */
 static FILE*nntp_out = NULL;/* fp for writing to server */
-- 
2.30.0


-- 
Bjarni I. Gislason



Bug#983297: Substitute "mktemp" with "mkstemp"

2021-02-21 Thread Bjarni Ingi Gislason
Source: nn
Version: 6.7.3-14
Severity: normal
Tags: patch

Dear Maintainer,

>From 1da3e089210539ef445e6b32a393b9870f967df9 Mon Sep 17 00:00:00 2001
>From: Bjarni Ingi Gislason 
>Date: Mon, 22 Feb 2021 02:04:32 +
>Subject: [PATCH] Substitute "mktemp" with "mkstemp"

  Substitute "mktemp" with "mkstemp" in files "nntp.c" and
"contrib/recmail.c" as "mktemp" is unsafe,
see "man 3 mktemp".

Signed-off-by: Bjarni Ingi Gislason 
---
 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;
 
-extern char*mktemp();
+extern char*mkstemp();
 
 static FILE*nntp_in = NULL;/* fp for reading from server */
 static FILE*nntp_out = NULL;/* fp for writing to server */
@@ -996,7 +996,7 @@ nntp_get_active(void)
 if (!is_connected && connect_server() < 0)
return -1;
 
-new_name = mktemp(relative(db_directory, ".actXX"));
+new_name = mkstemp(relative(db_directory, ".actXX"));
 
 switch (n = ask_server("LIST")) {
case OK_GROUPS:
@@ -1053,7 +1053,7 @@ nntp_get_newsgroups(void)
 FILE   *new;
 int n;
 
-new_name = mktemp(relative(tmp_directory, "nngrXX"));
+new_name = mkstemp(relative(tmp_directory, "nngrXX"));
 new = open_file(new_name, OPEN_CREATE_RW | OPEN_UNLINK);
 if (new == NULL)
return NULL;
-- 
2.30.0



-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.9-1 (SMP w/2 CPU threads)
Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), 
LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

-- debconf information excluded

-- 
Bjarni I. Gislason