mirror of git://sourceware.org/git/glibc.git
Use __fstat64_time64 in __fts64_children_time64 (bug 33653)
Make sure that fts_safe_changedir can handle a directory with a time stamp after y2038.
This commit is contained in:
parent
7f670284d8
commit
0df50640a4
|
|
@ -235,6 +235,7 @@ tests := \
|
|||
tests-time64 := \
|
||||
tst-fcntl-time64 \
|
||||
tst-fts-time64 \
|
||||
tst-fts-time64-y2038 \
|
||||
tst-futimens-time64 \
|
||||
tst-futimes-time64\
|
||||
tst-futimesat-time64 \
|
||||
|
|
|
|||
5
io/fts.c
5
io/fts.c
|
|
@ -85,6 +85,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
|
|||
# define STRUCT_STAT stat
|
||||
# define STAT __stat
|
||||
# define LSTAT __lstat
|
||||
# define FSTAT __fstat
|
||||
#endif
|
||||
|
||||
static FTSENTRY *fts_alloc (FTSOBJ *, const char *, size_t);
|
||||
|
|
@ -1111,14 +1112,14 @@ static int
|
|||
fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p, int fd, const char *path)
|
||||
{
|
||||
int ret, oerrno, newfd;
|
||||
struct stat64 sb;
|
||||
struct STRUCT_STAT sb;
|
||||
|
||||
newfd = fd;
|
||||
if (ISSET(FTS_NOCHDIR))
|
||||
return (0);
|
||||
if (fd < 0 && (newfd = __open(path, O_RDONLY, 0)) < 0)
|
||||
return (-1);
|
||||
if (__fstat64(newfd, &sb)) {
|
||||
if (FSTAT (newfd, &sb)) {
|
||||
ret = -1;
|
||||
goto bail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
# define STRUCT_STAT __stat64_t64
|
||||
# define STAT __stat64_time64
|
||||
# define LSTAT __lstat64_time64
|
||||
# define FSTAT __fstat64_time64
|
||||
|
||||
# include "fts.c"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,5 +27,6 @@
|
|||
#define STRUCT_STAT stat64
|
||||
#define STAT __stat64
|
||||
#define LSTAT __lstat64
|
||||
#define FSTAT __fstat64
|
||||
|
||||
#include "fts.c"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
/* Test for bug 33653 in fts_safe_changedir. */
|
||||
#define TST_FTS_Y2038
|
||||
#include "tst-fts.c"
|
||||
35
io/tst-fts.c
35
io/tst-fts.c
|
|
@ -26,6 +26,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
|
||||
static void prepare (void);
|
||||
static int do_test (void);
|
||||
|
|
@ -54,6 +55,28 @@ make_dir (const char *dirname)
|
|||
add_temp_file (name);
|
||||
}
|
||||
|
||||
#ifdef TST_FTS_Y2038
|
||||
static void
|
||||
set_time_y2038 (const char *dirname)
|
||||
{
|
||||
char *name;
|
||||
if (asprintf (&name, "%s/%s", fts_test_dir, dirname) < 0)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
struct utimbuf ut = { 0x100000000, 0x100000000 };
|
||||
if (utime (name, &ut) < 0)
|
||||
{
|
||||
printf ("cannot set time on dir \"%s\": %m\n", name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
free (name);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
make_file (const char *filename)
|
||||
{
|
||||
|
|
@ -108,6 +131,10 @@ prepare (void)
|
|||
make_file ("bbb/1234");
|
||||
make_file ("bbb/5678");
|
||||
make_file ("bbb/90ab");
|
||||
|
||||
#ifdef TST_FTS_Y2038
|
||||
set_time_y2038 ("bbb");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Largest name wins, otherwise strcmp. */
|
||||
|
|
@ -160,7 +187,13 @@ do_test (void)
|
|||
{
|
||||
char *paths[2] = { fts_test_dir, NULL };
|
||||
FTS *fts;
|
||||
fts = fts_open (paths, FTS_LOGICAL, &compare_ents);
|
||||
int flags = 0;
|
||||
/* FTS_LOGICAL implies FTS_NOCHDIR, thus when testing for bug 33653,
|
||||
don't use FTS_LOGICAL. */
|
||||
#ifndef TST_FTS_Y2038
|
||||
flags |= FTS_LOGICAL;
|
||||
#endif
|
||||
fts = fts_open (paths, flags, &compare_ents);
|
||||
if (fts == NULL)
|
||||
{
|
||||
printf ("FAIL: fts_open: %m\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue