summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-04-04 20:28:04 +0000
committerimp <imp@FreeBSD.org>1999-04-04 20:28:04 +0000
commit58c4e53b49467c7d4352c83412642f2eb125dece (patch)
treedd9e7690c5dda04f2b0af8b7fcf1dfc601c31f67 /lib
parent95a470c499918a30df1311cc8ed59f2fc0245ee3 (diff)
downloadFreeBSD-src-58c4e53b49467c7d4352c83412642f2eb125dece.zip
FreeBSD-src-58c4e53b49467c7d4352c83412642f2eb125dece.tar.gz
Add mkstemps from OpenBSD. This has been in my tree for months and
hasn't caused any problems until the egcs import. This fix breaks the world build, but my very next commit will remove mkstemps from the egcs build.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/mktemp.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index c2da533..0127bdb 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$Id: mktemp.c,v 1.11 1998/10/20 12:36:36 peter Exp $";
+ "$Id: mktemp.c,v 1.12 1998/10/20 15:33:21 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -50,7 +50,17 @@ static const char rcsid[] =
char *_mktemp __P((char *));
-static int _gettemp __P((char *, int *, int));
+static int _gettemp __P((char *, int *, int, int));
+
+int
+mkstemps(path, slen)
+ char *path;
+ int slen;
+{
+ int fd;
+
+ return (_gettemp(path, &fd, 0, slen) ? fd : -1);
+}
int
mkstemp(path)
@@ -58,21 +68,21 @@ mkstemp(path)
{
int fd;
- return (_gettemp(path, &fd, 0) ? fd : -1);
+ return (_gettemp(path, &fd, 0, 0) ? fd : -1);
}
char *
mkdtemp(path)
char *path;
{
- return(_gettemp(path, (int *)NULL, 1) ? path : (char *)NULL);
+ return(_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
}
char *
_mktemp(path)
char *path;
{
- return(_gettemp(path, (int *)NULL, 0) ? path : (char *)NULL);
+ return(_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
}
#ifdef UNSAFE_WARN
@@ -88,12 +98,13 @@ mktemp(path)
}
static int
-_gettemp(path, doopen, domkdir)
+_gettemp(path, doopen, domkdir, slen)
char *path;
register int *doopen;
int domkdir;
+ int slen;
{
- register char *start, *trv;
+ register char *start, *trv, *suffp;
struct stat sbuf;
int pid, rval;
@@ -105,7 +116,13 @@ _gettemp(path, doopen, domkdir)
pid = getpid();
for (trv = path; *trv; ++trv)
;
+ trv -= slen;
+ suffp = trv;
--trv;
+ if (trv < path) {
+ errno = EINVAL;
+ return (0);
+ }
while (*trv == 'X' && pid != 0) {
*trv-- = (pid % 10) + '0';
pid /= 10;
OpenPOWER on IntegriCloud