aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>1999-04-04 20:28:04 +0000
committerWarner Losh <imp@FreeBSD.org>1999-04-04 20:28:04 +0000
commit06b6a8ab984a85ed8e3e53ee69fda2f86a8faf40 (patch)
tree6c1cfeedadb93c427ec3b0af02a04f2b1947ca53 /lib
parenta508801763cfa037b6f7d34bfa9b79a416d4cfba (diff)
downloadsrc-06b6a8ab984a85ed8e3e53ee69fda2f86a8faf40.tar.gz
src-06b6a8ab984a85ed8e3e53ee69fda2f86a8faf40.zip
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.
Notes
Notes: svn path=/head/; revision=45303
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 c2da533af8a0..0127bdba35df 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;