Subject: bin/3517: tn3270 should use mkstemp()
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: netbsd-bugs
Date: 04/20/1997 00:36:22
>Number:         3517
>Category:       bin
>Synopsis:       shell() in tn3270, leaks memory and should use mkstemp()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 19 07:50:03 1997
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
Zen Programming...
>Release:        April 2
>Environment:
	
System: NetBSD zen.quick.com.au 1.2D NetBSD 1.2D (ZEN) #12: Sat Apr 5 18:39:29 EST 1997 root@zen.quick.com.au:/share/usr.src/sys/arch/i386/compile/ZEN i386


>Description:
	
shell() in tn3270/sys_curses/system.c uses mktemp() and leaks in the
process.
>How-To-Repeat:
	
>Fix:
	
*** tn3270/sys_curses/system.c    1997/02/08 12:26:26     1.2
--- tn3270/sys_curses/system.c    1997/04/19 04:04:21
***************
*** 659,666 ****
--- 659,671 ----
  
      /* First, create verification file. */
      do {
+ #if defined(BSD4_4) || defined(__svr4__) || defined(HAVE_MKSTEMP)
+           if ((fd = mkstemp(strcpy(sockNAME, "/tmp/apiXXXXXX"))) >= 0)
+                keyname = strdup(sockNAME);
+ #else
        keyname = mktemp(strdup("/tmp/apiXXXXXX"));
        fd = open(keyname, O_RDWR|O_CREAT|O_EXCL, IREAD|IWRITE);
+ #endif
      } while ((fd == -1) && (errno == EEXIST));
  
      if (fd == -1) {

>Audit-Trail:
>Unformatted: