mktemp.c (249808) | mktemp.c (249810) |
---|---|
1/* 2 * Copyright (c) 1987, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1987, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/lib/libc/stdio/mktemp.c 249808 2013-04-23 13:33:13Z emaste $"); | 34__FBSDID("$FreeBSD: head/lib/libc/stdio/mktemp.c 249810 2013-04-23 14:36:44Z emaste $"); |
35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/stat.h> 39#include <fcntl.h> 40#include <errno.h> 41#include <stdio.h> 42#include <stdlib.h> --- 5 unchanged lines hidden (view full) --- 48char *_mktemp(char *); 49 50static int _gettemp(char *, int *, int, int); 51 52static const unsigned char padchar[] = 53"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 54 55int | 35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/stat.h> 39#include <fcntl.h> 40#include <errno.h> 41#include <stdio.h> 42#include <stdlib.h> --- 5 unchanged lines hidden (view full) --- 48char *_mktemp(char *); 49 50static int _gettemp(char *, int *, int, int); 51 52static const unsigned char padchar[] = 53"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 54 55int |
56mkstemps(path, slen) 57 char *path; 58 int slen; | 56mkstemps(char *path, int slen) |
59{ 60 int fd; 61 62 return (_gettemp(path, &fd, 0, slen) ? fd : -1); 63} 64 65int | 57{ 58 int fd; 59 60 return (_gettemp(path, &fd, 0, slen) ? fd : -1); 61} 62 63int |
66mkstemp(path) 67 char *path; | 64mkstemp(char *path) |
68{ 69 int fd; 70 71 return (_gettemp(path, &fd, 0, 0) ? fd : -1); 72} 73 74char * | 65{ 66 int fd; 67 68 return (_gettemp(path, &fd, 0, 0) ? fd : -1); 69} 70 71char * |
75mkdtemp(path) 76 char *path; | 72mkdtemp(char *path) |
77{ 78 return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL); 79} 80 81char * | 73{ 74 return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL); 75} 76 77char * |
82_mktemp(path) 83 char *path; | 78_mktemp(char *path) |
84{ 85 return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL); 86} 87 88__warn_references(mktemp, 89 "warning: mktemp() possibly used unsafely; consider using mkstemp()"); 90 91char * | 79{ 80 return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL); 81} 82 83__warn_references(mktemp, 84 "warning: mktemp() possibly used unsafely; consider using mkstemp()"); 85 86char * |
92mktemp(path) 93 char *path; | 87mktemp(char *path) |
94{ 95 return (_mktemp(path)); 96} 97 98static int | 88{ 89 return (_mktemp(path)); 90} 91 92static int |
99_gettemp(path, doopen, domkdir, slen) 100 char *path; 101 int *doopen; 102 int domkdir; 103 int slen; | 93_gettemp(char *path, int *doopen, int domkdir, int slen) |
104{ 105 char *start, *trv, *suffp, *carryp; 106 char *pad; 107 struct stat sbuf; 108 int rval; 109 uint32_t rand; 110 char carrybuf[MAXPATHLEN]; 111 --- 90 unchanged lines hidden --- | 94{ 95 char *start, *trv, *suffp, *carryp; 96 char *pad; 97 struct stat sbuf; 98 int rval; 99 uint32_t rand; 100 char carrybuf[MAXPATHLEN]; 101 --- 90 unchanged lines hidden --- |