34 #include <sys/param.h>
70 char *tempname = NULL;
74 const int maxretry = 10;
77 for (i = 0; i < maxretry; i++) {
78 tempname = tempnam(dir, pfx);
86 LOG(
llevError,
"Created file detected in tempnam_secure. Someone hoping for a race condition?\n");
93 file = fdopen(fd,
"w+");
95 LOG(
llevError,
"fdopen() failed in tempnam_secure()!\n");
129 if (de->d_name[0] ==
'.')
135 status = stat(de->d_name, &statbuf);
136 if ((
status != -1) && (S_ISDIR(statbuf.st_mode))) {
137 snprintf(
buf,
sizeof(
buf),
"%s/%s",
path, de->d_name);
141 snprintf(
buf,
sizeof(
buf),
"%s/%s",
path, de->d_name);
170 while ((cp = strchr(cp+1, (
int)
'/'))) {
172 if (stat(
buf, &statbuf) || !S_ISDIR(statbuf.st_mode)) {
201 assert(curlen != NULL);
202 assert(*curlen < maxlen);
204 *curlen = strlcat(
dest, orig, maxlen);
206 if (*curlen == (maxlen-1))
208 strncpy(
dest+*curlen, orig, maxlen-*curlen-1);
210 *curlen += strlen(orig);
212 if (*curlen > (maxlen-1))
220 size_t strlcpy(
char *dst,
const char *src,
size_t size) {
221 strncpy(dst, src, size - 1);
222 dst[size - 1] =
'\0';
230 const char *
strcasestr(
const char *s,
const char *find)
235 if ((
c = *find++) != 0) {
240 if ((sc = *s++) == 0)
243 while ((
char)
tolower((
unsigned char) sc) !=
c);
245 while (strncasecmp(s, find, len) != 0);