use mkstemp() and plug memory leak; fixes PR bin/3517.
This commit is contained in:
parent
e98ae4a7d1
commit
75418659ae
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: system.c,v 1.4 1997/01/09 20:22:28 tls Exp $ */
|
||||
/* $NetBSD: system.c,v 1.5 1997/04/23 07:11:09 mikel Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988 The Regents of the University of California.
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)system.c 4.5 (Berkeley) 4/26/91";*/
|
||||
static char rcsid[] = "$NetBSD: system.c,v 1.4 1997/01/09 20:22:28 tls Exp $";
|
||||
static char rcsid[] = "$NetBSD: system.c,v 1.5 1997/04/23 07:11:09 mikel Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -620,7 +620,7 @@ child_died(code)
|
||||
|
||||
/*
|
||||
* Called from telnet.c to fork a lower command.com. We
|
||||
* use the spint... routines so that we can pick up
|
||||
* use the sprint... routines so that we can pick up
|
||||
* interrupts generated by application programs.
|
||||
*/
|
||||
|
||||
@ -638,14 +638,25 @@ char *argv[];
|
||||
struct timeval tv;
|
||||
long ikey;
|
||||
extern long random();
|
||||
#if !defined(BSD4_4)
|
||||
extern char *mktemp();
|
||||
#endif /* !defined(BSD4_4) */
|
||||
extern char *strcpy();
|
||||
|
||||
/* First, create verification file. */
|
||||
#if defined(BSD4_4)
|
||||
if (keyname != NULL)
|
||||
free(keyname);
|
||||
keyname = strdup("/tmp/apiXXXXXX");
|
||||
fd = mkstemp(keyname);
|
||||
#else
|
||||
do {
|
||||
if (keyname != NULL)
|
||||
free(keyname);
|
||||
keyname = mktemp(strdup("/tmp/apiXXXXXX"));
|
||||
fd = open(keyname, O_RDWR|O_CREAT|O_EXCL, IREAD|IWRITE);
|
||||
} while ((fd == -1) && (errno == EEXIST));
|
||||
#endif /* defined(BSD4_4) */
|
||||
|
||||
if (fd == -1) {
|
||||
perror("open");
|
||||
|
Loading…
Reference in New Issue
Block a user