|
10 | 10 | */
|
11 | 11 |
|
12 | 12 | #define _ISOC99_SOURCE
|
13 |
| -#define _BSD_SOURCE /* for d_type constants */ |
| 13 | +#define _DEFAULT_SOURCE /* for d_type constants */ |
14 | 14 | #define _XOPEN_SOURCE
|
15 | 15 |
|
16 | 16 | #include <stdio.h>
|
@@ -191,7 +191,7 @@ struct node *__build_tree(char *dir, struct node ***leaves, unsigned *size,
|
191 | 191 | DIR *d;
|
192 | 192 | struct dirent *ent;
|
193 | 193 | struct node *root = NULL, *node;
|
194 |
| - char path[PATH_MAX]; |
| 194 | + char path[PATH_MAX + 2]; |
195 | 195 |
|
196 | 196 | if (args && args->recursive && args->depth > 0)
|
197 | 197 | if (depth > args->depth)
|
@@ -234,7 +234,7 @@ struct node *__build_tree(char *dir, struct node ***leaves, unsigned *size,
|
234 | 234 | if (strcmp(ent->d_name, "..") == 0 || strcmp(ent->d_name, ".") == 0)
|
235 | 235 | continue;
|
236 | 236 |
|
237 |
| - snprintf(path, NAME_MAX, "%s/%s", dir, ent->d_name); |
| 237 | + snprintf(path, NAME_MAX + 2, "%s/%s", dir, ent->d_name); |
238 | 238 | if (is_dir(ent, path)) {
|
239 | 239 | if (!args->recursive)
|
240 | 240 | continue;
|
@@ -345,7 +345,7 @@ int copy_random(struct node **list, unsigned length, const char *src,
|
345 | 345 | {
|
346 | 346 | unsigned int i = 0, n = 0, num = args->limit;
|
347 | 347 | struct timeval tv;
|
348 |
| - char path[PATH_MAX], dpath[PATH_MAX], spath[PATH_MAX]; |
| 348 | + char path[PATH_MAX], dpath[PATH_MAX], spath[PATH_MAX + 1]; |
349 | 349 |
|
350 | 350 | gettimeofday(&tv, NULL);
|
351 | 351 | srand(tv.tv_usec);
|
|
0 commit comments