mirror of git://sourceware.org/git/glibc.git
Use *stat64 instead of *stat in installed programs
This ensures reliable operation on file systems with inode numbers which do not fit into 32 bits.
This commit is contained in:
parent
a3375d2990
commit
4c0fe6fe42
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2013-05-10 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* elf/sprof.c (load_profdata): Use fstat64 instead of fstat.
|
||||||
|
* iconv/iconv_charmap.c (charmap_conversion): Likewise.
|
||||||
|
* iconv/iconv_prog.c (main): Likewise.
|
||||||
|
* locale/programs/charmap-dir.c (charmap_readdir)
|
||||||
|
(fopen_uncompressed): Likewise.
|
||||||
|
* locale/programs/locfile.c (siblings_uncached)
|
||||||
|
(write_locale_data): Use lstat64 instead of lstat.
|
||||||
|
* sunrpc/rpc_main.c (find_cpp, checkfiles): Use stat64 instead of
|
||||||
|
stat.
|
||||||
|
|
||||||
2013-05-10 Andreas Jaeger <aj@suse.de>
|
2013-05-10 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
[BZ #15395]
|
[BZ #15395]
|
||||||
|
|
|
@ -744,7 +744,7 @@ load_profdata (const char *name, struct shobj *shobj)
|
||||||
{
|
{
|
||||||
struct profdata *result;
|
struct profdata *result;
|
||||||
int fd;
|
int fd;
|
||||||
struct stat st;
|
struct stat64 st;
|
||||||
void *addr;
|
void *addr;
|
||||||
uint32_t *narcsp;
|
uint32_t *narcsp;
|
||||||
size_t fromlimit;
|
size_t fromlimit;
|
||||||
|
@ -783,7 +783,7 @@ load_profdata (const char *name, struct shobj *shobj)
|
||||||
|
|
||||||
/* We have found the file, now make sure it is the right one for the
|
/* We have found the file, now make sure it is the right one for the
|
||||||
data file. */
|
data file. */
|
||||||
if (fstat (fd, &st) < 0)
|
if (fstat64 (fd, &st) < 0)
|
||||||
{
|
{
|
||||||
error (0, errno, _("while stat'ing profiling data file"));
|
error (0, errno, _("while stat'ing profiling data file"));
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
|
@ -171,11 +171,11 @@ charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _POSIX_MAPPED_FILES
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
struct stat st;
|
struct stat64 st;
|
||||||
char *addr;
|
char *addr;
|
||||||
/* We have possibilities for reading the input file. First try
|
/* We have possibilities for reading the input file. First try
|
||||||
to mmap() it since this will provide the fastest solution. */
|
to mmap() it since this will provide the fastest solution. */
|
||||||
if (fstat (fd, &st) == 0
|
if (fstat64 (fd, &st) == 0
|
||||||
&& ((addr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE,
|
&& ((addr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE,
|
||||||
fd, 0)) != MAP_FAILED))
|
fd, 0)) != MAP_FAILED))
|
||||||
{
|
{
|
||||||
|
|
|
@ -275,7 +275,7 @@ conversions from `%s' and to `%s' are not supported"),
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef _POSIX_MAPPED_FILES
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
struct stat st;
|
struct stat64 st;
|
||||||
char *addr;
|
char *addr;
|
||||||
#endif
|
#endif
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
@ -300,7 +300,7 @@ conversions from `%s' and to `%s' are not supported"),
|
||||||
#ifdef _POSIX_MAPPED_FILES
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
/* We have possibilities for reading the input file. First try
|
/* We have possibilities for reading the input file. First try
|
||||||
to mmap() it since this will provide the fastest solution. */
|
to mmap() it since this will provide the fastest solution. */
|
||||||
if (fstat (fd, &st) == 0
|
if (fstat64 (fd, &st) == 0
|
||||||
&& ((addr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE,
|
&& ((addr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE,
|
||||||
fd, 0)) != MAP_FAILED))
|
fd, 0)) != MAP_FAILED))
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,9 +121,9 @@ charmap_readdir (CHARMAP_DIR *cdir)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat64 statbuf;
|
||||||
|
|
||||||
if (stat (cdir->pathname, &statbuf) < 0)
|
if (stat64 (cdir->pathname, &statbuf) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mode = statbuf.st_mode;
|
mode = statbuf.st_mode;
|
||||||
|
@ -167,10 +167,10 @@ fopen_uncompressed (const char *pathname, const char *compressor)
|
||||||
pfd = open (pathname, O_RDONLY);
|
pfd = open (pathname, O_RDONLY);
|
||||||
if (pfd >= 0)
|
if (pfd >= 0)
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat64 statbuf;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
|
|
||||||
if (fstat (pfd, &statbuf) >= 0
|
if (fstat64 (pfd, &statbuf) >= 0
|
||||||
&& S_ISREG (statbuf.st_mode)
|
&& S_ISREG (statbuf.st_mode)
|
||||||
&& pipe (fd) >= 0)
|
&& pipe (fd) >= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -355,7 +355,7 @@ siblings_uncached (const char *output_path)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char *base, *p;
|
char *base, *p;
|
||||||
struct stat output_stat;
|
struct stat64 output_stat;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int nelems;
|
int nelems;
|
||||||
const char **elems;
|
const char **elems;
|
||||||
|
@ -378,7 +378,7 @@ siblings_uncached (const char *output_path)
|
||||||
len = p - base;
|
len = p - base;
|
||||||
|
|
||||||
/* Get the properties of output_path. */
|
/* Get the properties of output_path. */
|
||||||
if (lstat (output_path, &output_stat) < 0 || !S_ISDIR (output_stat.st_mode))
|
if (lstat64 (output_path, &output_stat) < 0 || !S_ISDIR (output_stat.st_mode))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Iterate through the directories in base directory. */
|
/* Iterate through the directories in base directory. */
|
||||||
|
@ -392,7 +392,7 @@ siblings_uncached (const char *output_path)
|
||||||
struct dirent64 *other_dentry;
|
struct dirent64 *other_dentry;
|
||||||
const char *other_name;
|
const char *other_name;
|
||||||
char *other_path;
|
char *other_path;
|
||||||
struct stat other_stat;
|
struct stat64 other_stat;
|
||||||
|
|
||||||
other_dentry = readdir64 (dirp);
|
other_dentry = readdir64 (dirp);
|
||||||
if (other_dentry == NULL)
|
if (other_dentry == NULL)
|
||||||
|
@ -407,7 +407,7 @@ siblings_uncached (const char *output_path)
|
||||||
other_path[len] = '/';
|
other_path[len] = '/';
|
||||||
strcpy (other_path + len + 1, other_name);
|
strcpy (other_path + len + 1, other_name);
|
||||||
|
|
||||||
if (lstat (other_path, &other_stat) >= 0
|
if (lstat64 (other_path, &other_stat) >= 0
|
||||||
&& S_ISDIR (other_stat.st_mode)
|
&& S_ISDIR (other_stat.st_mode)
|
||||||
&& other_stat.st_uid == output_stat.st_uid
|
&& other_stat.st_uid == output_stat.st_uid
|
||||||
&& other_stat.st_gid == output_stat.st_gid
|
&& other_stat.st_gid == output_stat.st_gid
|
||||||
|
@ -580,9 +580,9 @@ write_locale_data (const char *output_path, int catidx, const char *category,
|
||||||
fd = -2;
|
fd = -2;
|
||||||
if (strcmp (category, "LC_MESSAGES") == 0)
|
if (strcmp (category, "LC_MESSAGES") == 0)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat64 st;
|
||||||
|
|
||||||
if (stat (fname, &st) < 0)
|
if (stat64 (fname, &st) < 0)
|
||||||
{
|
{
|
||||||
if (mkdir (fname, 0777) >= 0)
|
if (mkdir (fname, 0777) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -659,9 +659,9 @@ failure while writing data for category `%s'"), category));
|
||||||
other_paths = siblings (output_path);
|
other_paths = siblings (output_path);
|
||||||
if (other_paths != NULL)
|
if (other_paths != NULL)
|
||||||
{
|
{
|
||||||
struct stat fname_stat;
|
struct stat64 fname_stat;
|
||||||
|
|
||||||
if (lstat (fname, &fname_stat) >= 0
|
if (lstat64 (fname, &fname_stat) >= 0
|
||||||
&& S_ISREG (fname_stat.st_mode))
|
&& S_ISREG (fname_stat.st_mode))
|
||||||
{
|
{
|
||||||
const char *fname_tail = fname + strlen (output_path);
|
const char *fname_tail = fname + strlen (output_path);
|
||||||
|
@ -680,14 +680,14 @@ failure while writing data for category `%s'"), category));
|
||||||
const char *other_path = *other_p;
|
const char *other_path = *other_p;
|
||||||
size_t other_path_len = strlen (other_path);
|
size_t other_path_len = strlen (other_path);
|
||||||
char *other_fname;
|
char *other_fname;
|
||||||
struct stat other_fname_stat;
|
struct stat64 other_fname_stat;
|
||||||
|
|
||||||
other_fname =
|
other_fname =
|
||||||
(char *) xmalloc (other_path_len + strlen (fname_tail) + 1);
|
(char *) xmalloc (other_path_len + strlen (fname_tail) + 1);
|
||||||
memcpy (other_fname, other_path, other_path_len);
|
memcpy (other_fname, other_path, other_path_len);
|
||||||
strcpy (other_fname + other_path_len, fname_tail);
|
strcpy (other_fname + other_path_len, fname_tail);
|
||||||
|
|
||||||
if (lstat (other_fname, &other_fname_stat) >= 0
|
if (lstat64 (other_fname, &other_fname_stat) >= 0
|
||||||
&& S_ISREG (other_fname_stat.st_mode)
|
&& S_ISREG (other_fname_stat.st_mode)
|
||||||
/* Consider only files on the same device.
|
/* Consider only files on the same device.
|
||||||
Otherwise hard linking won't work anyway. */
|
Otherwise hard linking won't work anyway. */
|
||||||
|
|
|
@ -326,9 +326,9 @@ clear_args (void)
|
||||||
static void
|
static void
|
||||||
find_cpp (void)
|
find_cpp (void)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat64 buf;
|
||||||
|
|
||||||
if (stat (CPP, &buf) == 0)
|
if (stat64 (CPP, &buf) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cppDefined) /* user specified cpp but it does not exist */
|
if (cppDefined) /* user specified cpp but it does not exist */
|
||||||
|
@ -1114,17 +1114,17 @@ putarg (int whereto, const char *cp)
|
||||||
static void
|
static void
|
||||||
checkfiles (const char *infile, const char *outfile)
|
checkfiles (const char *infile, const char *outfile)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat64 buf;
|
||||||
|
|
||||||
if (infile) /* infile ! = NULL */
|
if (infile) /* infile ! = NULL */
|
||||||
if (stat (infile, &buf) < 0)
|
if (stat64 (infile, &buf) < 0)
|
||||||
{
|
{
|
||||||
perror (infile);
|
perror (infile);
|
||||||
crash ();
|
crash ();
|
||||||
}
|
}
|
||||||
if (outfile)
|
if (outfile)
|
||||||
{
|
{
|
||||||
if (stat (outfile, &buf) < 0)
|
if (stat64 (outfile, &buf) < 0)
|
||||||
return; /* file does not exist */
|
return; /* file does not exist */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue