Skip to content

Commit 69c8514

Browse files
committed
fix some overflow warnings
Signed-off-by: Santosh Sivaraj <[email protected]>
1 parent b33c9e5 commit 69c8514

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

randcp.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
#define _ISOC99_SOURCE
13-
#define _BSD_SOURCE /* for d_type constants */
13+
#define _DEFAULT_SOURCE /* for d_type constants */
1414
#define _XOPEN_SOURCE
1515

1616
#include <stdio.h>
@@ -191,7 +191,7 @@ struct node *__build_tree(char *dir, struct node ***leaves, unsigned *size,
191191
DIR *d;
192192
struct dirent *ent;
193193
struct node *root = NULL, *node;
194-
char path[PATH_MAX];
194+
char path[PATH_MAX + 2];
195195

196196
if (args && args->recursive && args->depth > 0)
197197
if (depth > args->depth)
@@ -234,7 +234,7 @@ struct node *__build_tree(char *dir, struct node ***leaves, unsigned *size,
234234
if (strcmp(ent->d_name, "..") == 0 || strcmp(ent->d_name, ".") == 0)
235235
continue;
236236

237-
snprintf(path, NAME_MAX, "%s/%s", dir, ent->d_name);
237+
snprintf(path, NAME_MAX + 2, "%s/%s", dir, ent->d_name);
238238
if (is_dir(ent, path)) {
239239
if (!args->recursive)
240240
continue;
@@ -345,7 +345,7 @@ int copy_random(struct node **list, unsigned length, const char *src,
345345
{
346346
unsigned int i = 0, n = 0, num = args->limit;
347347
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];
349349

350350
gettimeofday(&tv, NULL);
351351
srand(tv.tv_usec);

0 commit comments

Comments
 (0)