if ( !sr_isError(fd) ) {
Int res = VG_(fstat)( sr_Res(fd), &stat_buf );
// Ignore if not owned by current user or world writeable (CVE-2008-4865)
- if (!res && stat_buf.st_uid == VG_(geteuid)()
- && (!(stat_buf.st_mode & VKI_S_IWOTH))) {
- if ( stat_buf.st_size > 0 ) {
- f_clo = VG_(malloc)("commandline.rdv.1", stat_buf.st_size+1);
+ if (!res && stat_buf.uid == VG_(geteuid)()
+ && (!(stat_buf.mode & VKI_S_IWOTH))) {
+ if ( stat_buf.size > 0 ) {
+ f_clo = VG_(malloc)("commandline.rdv.1", stat_buf.size+1);
vg_assert(f_clo);
- n = VG_(read)(sr_Res(fd), f_clo, stat_buf.st_size);
+ n = VG_(read)(sr_Res(fd), f_clo, stat_buf.size);
if (n == -1) n = 0;
- vg_assert(n >= 0 && n <= stat_buf.st_size+1);
+ vg_assert(n >= 0 && n <= stat_buf.size+1);
f_clo[n] = '\0';
}
}
/* stat dereferences symlinks, so we don't expect it to succeed and
yet produce something that is a symlink. */
- vg_assert(sr_isError(statres) || ! VKI_S_ISLNK(statbuf.st_mode));
+ vg_assert(sr_isError(statres) || ! VKI_S_ISLNK(statbuf.mode));
/* Don't let the stat call fail silently. Filter out some known
sources of noise before complaining, though. */
/* Finally, the point of all this stattery: if it's not a regular file,
don't try to read debug info from it. */
- if (! VKI_S_ISREG(statbuf.st_mode))
+ if (! VKI_S_ISREG(statbuf.mode))
return 0;
/* no uses of statbuf below here. */
if (r == -1)
goto out; /* stat failed ?! */
vg_assert(r == 0);
- obj_mtime = stat_buf.st_mtime;
+ obj_mtime = stat_buf.mtime;
/* and get its name into exename[]. */
vg_assert(VKI_PATH_MAX > 100); /* to ensure /proc/self/fd/%d is safe */
VG_(message)(Vg_UserMsg, "LOAD_PDB_DEBUGINFO: missing: %s", pdbname);
goto out;
}
- pdb_mtime = stat_buf.st_mtime;
+ pdb_mtime = stat_buf.mtime;
if (pdb_mtime < obj_mtime ) {
/* PDB file is older than PE file - ignore it or we will either
(a) print wrong stack traces or more likely (b) crash. */
/* Looks promising; go on to try and read stuff from it. */
fd_pdbimage = sr_Res(sres);
- n_pdbimage = stat_buf.st_size;
+ n_pdbimage = stat_buf.size;
sres = VG_(am_mmap_file_float_valgrind)( n_pdbimage, VKI_PROT_READ,
fd_pdbimage, 0 );
if (sr_isError(sres)) {
#define TRANSLATE_TO_vg_stat(_p_vgstat, _p_vkistat) \
do { \
- (_p_vgstat)->st_dev = (ULong)( (_p_vkistat)->st_dev ); \
- (_p_vgstat)->st_ino = (ULong)( (_p_vkistat)->st_ino ); \
- (_p_vgstat)->st_nlink = (ULong)( (_p_vkistat)->st_nlink ); \
- (_p_vgstat)->st_mode = (UInt) ( (_p_vkistat)->st_mode ); \
- (_p_vgstat)->st_uid = (UInt) ( (_p_vkistat)->st_uid ); \
- (_p_vgstat)->st_gid = (UInt) ( (_p_vkistat)->st_gid ); \
- (_p_vgstat)->st_rdev = (ULong)( (_p_vkistat)->st_rdev ); \
- (_p_vgstat)->st_size = (Long) ( (_p_vkistat)->st_size ); \
- (_p_vgstat)->st_blksize = (ULong)( (_p_vkistat)->st_blksize ); \
- (_p_vgstat)->st_blocks = (ULong)( (_p_vkistat)->st_blocks ); \
- (_p_vgstat)->st_atime = (ULong)( (_p_vkistat)->st_atime ); \
- (_p_vgstat)->st_atime_nsec = (ULong)( (_p_vkistat)->st_atime_nsec ); \
- (_p_vgstat)->st_mtime = (ULong)( (_p_vkistat)->st_mtime ); \
- (_p_vgstat)->st_mtime_nsec = (ULong)( (_p_vkistat)->st_mtime_nsec ); \
- (_p_vgstat)->st_ctime = (ULong)( (_p_vkistat)->st_ctime ); \
- (_p_vgstat)->st_ctime_nsec = (ULong)( (_p_vkistat)->st_ctime_nsec ); \
+ (_p_vgstat)->dev = (ULong)( (_p_vkistat)->st_dev ); \
+ (_p_vgstat)->ino = (ULong)( (_p_vkistat)->st_ino ); \
+ (_p_vgstat)->nlink = (ULong)( (_p_vkistat)->st_nlink ); \
+ (_p_vgstat)->mode = (UInt) ( (_p_vkistat)->st_mode ); \
+ (_p_vgstat)->uid = (UInt) ( (_p_vkistat)->st_uid ); \
+ (_p_vgstat)->gid = (UInt) ( (_p_vkistat)->st_gid ); \
+ (_p_vgstat)->rdev = (ULong)( (_p_vkistat)->st_rdev ); \
+ (_p_vgstat)->size = (Long) ( (_p_vkistat)->st_size ); \
+ (_p_vgstat)->blksize = (ULong)( (_p_vkistat)->st_blksize ); \
+ (_p_vgstat)->blocks = (ULong)( (_p_vkistat)->st_blocks ); \
+ (_p_vgstat)->atime = (ULong)( (_p_vkistat)->st_atime ); \
+ (_p_vgstat)->atime_nsec = (ULong)( (_p_vkistat)->st_atime_nsec ); \
+ (_p_vgstat)->mtime = (ULong)( (_p_vkistat)->st_mtime ); \
+ (_p_vgstat)->mtime_nsec = (ULong)( (_p_vkistat)->st_mtime_nsec ); \
+ (_p_vgstat)->ctime = (ULong)( (_p_vkistat)->st_ctime ); \
+ (_p_vgstat)->ctime_nsec = (ULong)( (_p_vkistat)->st_ctime_nsec ); \
} while (0)
SysRes VG_(stat) ( const Char* file_name, struct vg_stat* vgbuf )
VKI_STX_NORMAL);
if (!sr_isError(res)) {
VG_(memset)(vgbuf, 0, sizeof(*vgbuf));
- vgbuf->st_dev = (ULong)buf.st_dev;
- vgbuf->st_ino = (ULong)buf.st_ino;
- vgbuf->st_mode = (UInt)buf.st_mode;
- vgbuf->st_uid = (UInt)buf.st_uid;
- vgbuf->st_gid = (UInt)buf.st_gid;
- vgbuf->st_size = (Long)buf.st_size;
+ vgbuf->dev = (ULong)buf.st_dev;
+ vgbuf->ino = (ULong)buf.st_ino;
+ vgbuf->mode = (UInt)buf.st_mode;
+ vgbuf->uid = (UInt)buf.st_uid;
+ vgbuf->gid = (UInt)buf.st_gid;
+ vgbuf->size = (Long)buf.st_size;
}
return res;
}
{
struct vg_stat buf;
Int res = VG_(fstat)( fd, &buf );
- return (res == -1) ? (-1LL) : buf.st_size;
+ return (res == -1) ? (-1LL) : buf.size;
}
Bool VG_(is_dir) ( HChar* f )
struct vg_stat buf;
SysRes res = VG_(stat)(f, &buf);
return sr_isError(res) ? False
- : VKI_S_ISDIR(buf.st_mode) ? True : False;
+ : VKI_S_ISDIR(buf.mode) ? True : False;
}
SysRes VG_(dup) ( Int oldfd )
return sr_Err(res);
}
- if ( (st.st_mode & (VKI_S_ISUID | VKI_S_ISGID)) && !allow_setuid ) {
+ if ( (st.mode & (VKI_S_ISUID | VKI_S_ISGID)) && !allow_setuid ) {
if (is_setuid)
*is_setuid = True;
return VKI_EACCES;
}
- if (VG_(geteuid)() == st.st_uid) {
- if (!(st.st_mode & VKI_S_IXUSR))
+ if (VG_(geteuid)() == st.uid) {
+ if (!(st.mode & VKI_S_IXUSR))
return VKI_EACCES;
} else {
Int grpmatch = 0;
- if (VG_(getegid)() == st.st_gid)
+ if (VG_(getegid)() == st.gid)
grpmatch = 1;
else {
UInt groups[32];
Int i;
/* ngrp will be -1 if VG_(getgroups) failed. */
for (i = 0; i < ngrp; i++) {
- if (groups[i] == st.st_gid) {
+ if (groups[i] == st.gid) {
grpmatch = 1;
break;
}
}
if (grpmatch) {
- if (!(st.st_mode & VKI_S_IXGRP)) {
+ if (!(st.mode & VKI_S_IXGRP)) {
return VKI_EACCES;
}
- } else if (!(st.st_mode & VKI_S_IXOTH)) {
+ } else if (!(st.mode & VKI_S_IXOTH)) {
return VKI_EACCES;
}
}