Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 584930
Collapse All | Expand All

(-)sandbox-2.10.orig/libsandbox/canonicalize.c (-3 / +3 lines)
Lines 100-113 Link Here
100
		 * If not, try a little harder to consume this path in
100
		 * If not, try a little harder to consume this path in
101
		 * case it has symlinks out into a better world ...
101
		 * case it has symlinks out into a better world ...
102
		 */
102
		 */
103
		struct stat st;
103
		struct stat64 st;
104
		if (lstat(rpath, &st) == -1 && errno == EACCES) {
104
		if (lstat64(rpath, &st) == -1 && errno == EACCES) {
105
			char *p = rpath;
105
			char *p = rpath;
106
			strcpy(rpath, name);
106
			strcpy(rpath, name);
107
			do {
107
			do {
108
				p = strchr(p, '/');
108
				p = strchr(p, '/');
109
				if (p) *p = '\0';
109
				if (p) *p = '\0';
110
				if (lstat(rpath, &st))
110
				if (lstat64(rpath, &st))
111
					break;
111
					break;
112
				if (S_ISLNK(st.st_mode)) {
112
				if (S_ISLNK(st.st_mode)) {
113
					ssize_t cnt = readlink(rpath, rpath, path_max);
113
					ssize_t cnt = readlink(rpath, rpath, path_max);
(-)sandbox-2.10.orig/libsandbox/libsandbox.c (-6 / +6 lines)
Lines 318-324 Link Here
318
318
319
char *egetcwd(char *buf, size_t size)
319
char *egetcwd(char *buf, size_t size)
320
{
320
{
321
	struct stat st;
321
	struct stat64 st;
322
	char *tmpbuf;
322
	char *tmpbuf;
323
323
324
	/* We can't let the C lib allocate memory for us since we have our
324
	/* We can't let the C lib allocate memory for us since we have our
Lines 361-367 Link Here
361
	 */
361
	 */
362
	if ((tmpbuf) && (errno == 0)) {
362
	if ((tmpbuf) && (errno == 0)) {
363
		save_errno();
363
		save_errno();
364
		if (!lstat(buf, &st))
364
		if (!lstat64(buf, &st))
365
			/* errno is set only on failure */
365
			/* errno is set only on failure */
366
			errno = 0;
366
			errno = 0;
367
367
Lines 420-431 Link Here
420
static bool write_logfile(const char *logfile, const char *func, const char *path,
420
static bool write_logfile(const char *logfile, const char *func, const char *path,
421
                          const char *apath, const char *rpath, bool access)
421
                          const char *apath, const char *rpath, bool access)
422
{
422
{
423
	struct stat log_stat;
423
	struct stat64 log_stat;
424
	int stat_ret;
424
	int stat_ret;
425
	int logfd;
425
	int logfd;
426
	bool ret = false;
426
	bool ret = false;
427
427
428
	stat_ret = lstat(logfile, &log_stat);
428
	stat_ret = lstat64(logfile, &log_stat);
429
	/* Do not care about failure */
429
	/* Do not care about failure */
430
	errno = 0;
430
	errno = 0;
431
	if (stat_ret == 0 && S_ISREG(log_stat.st_mode) == 0)
431
	if (stat_ret == 0 && S_ISREG(log_stat.st_mode) == 0)
Lines 642-648 Link Here
642
/* Is this a func that works on symlinks, and is the file a symlink ? */
642
/* Is this a func that works on symlinks, and is the file a symlink ? */
643
static bool symlink_func(int sb_nr, int flags, const char *abs_path)
643
static bool symlink_func(int sb_nr, int flags, const char *abs_path)
644
{
644
{
645
	struct stat st;
645
	struct stat64 st;
646
646
647
	/* These funcs always operate on symlinks */
647
	/* These funcs always operate on symlinks */
648
	if (!(sb_nr == SB_NR_UNLINK   ||
648
	if (!(sb_nr == SB_NR_UNLINK   ||
Lines 661-667 Link Here
661
			return false;
661
			return false;
662
	}
662
	}
663
663
664
	if (-1 != lstat(abs_path, &st) && S_ISLNK(st.st_mode))
664
	if (-1 != lstat64(abs_path, &st) && S_ISLNK(st.st_mode))
665
		return true;
665
		return true;
666
	else
666
	else
667
		return false;
667
		return false;
(-)sandbox-2.10.orig/libsandbox/wrapper-funcs/fopen_pre_check.c (-2 / +2 lines)
Lines 11-18 Link Here
11
		save_errno();
11
		save_errno();
12
12
13
		/* If we're trying to read, fail normally if file does not stat */
13
		/* If we're trying to read, fail normally if file does not stat */
14
		struct stat st;
14
		struct stat64 st;
15
		if (-1 == stat(pathname, &st)) {
15
		if (-1 == stat64(pathname, &st)) {
16
			sb_debug_dyn("EARLY FAIL: %s(%s): %s\n",
16
			sb_debug_dyn("EARLY FAIL: %s(%s): %s\n",
17
				func, pathname, strerror(errno));
17
				func, pathname, strerror(errno));
18
			return false;
18
			return false;
(-)sandbox-2.10.orig/libsandbox/wrapper-funcs/mkdirat_pre_check.c (-3 / +3 lines)
Lines 31-38 Link Here
31
	 * not want to pass this attempt up to the higher levels as those
31
	 * not want to pass this attempt up to the higher levels as those
32
	 * will trigger a sandbox violation.
32
	 * will trigger a sandbox violation.
33
	 */
33
	 */
34
	struct stat st;
34
	struct stat64 st;
35
	if (0 == lstat(canonic, &st)) {
35
	if (0 == lstat64(canonic, &st)) {
36
		int new_errno;
36
		int new_errno;
37
		sb_debug_dyn("EARLY FAIL: %s(%s[%s]) @ lstat: %s\n",
37
		sb_debug_dyn("EARLY FAIL: %s(%s[%s]) @ lstat: %s\n",
38
			func, pathname, canonic, strerror(errno));
38
			func, pathname, canonic, strerror(errno));
Lines 40-46 Link Here
40
		new_errno = EEXIST;
40
		new_errno = EEXIST;
41
41
42
		/* Hmm, is this a broken symlink we're trying to extend ? */
42
		/* Hmm, is this a broken symlink we're trying to extend ? */
43
		if (S_ISLNK(st.st_mode) && stat(pathname, &st) != 0) {
43
		if (S_ISLNK(st.st_mode) && stat64(pathname, &st) != 0) {
44
			/* XXX: This awful hack should probably be turned into a
44
			/* XXX: This awful hack should probably be turned into a
45
			 * common func that does a better job.  For now, we have
45
			 * common func that does a better job.  For now, we have
46
			 * enough crap to catch gnulib tests #297026.
46
			 * enough crap to catch gnulib tests #297026.
(-)sandbox-2.10.orig/libsandbox/wrapper-funcs/openat_pre_check.c (-2 / +2 lines)
Lines 21-28 Link Here
21
		return false;
21
		return false;
22
22
23
	/* Doesn't exist -> skip permission checks */
23
	/* Doesn't exist -> skip permission checks */
24
	struct stat st;
24
	struct stat64 st;
25
	if (((flags & O_NOFOLLOW) ? lstat(pathname, &st) : stat(pathname, &st)) == -1) {
25
	if (((flags & O_NOFOLLOW) ? lstat64(pathname, &st) : stat64(pathname, &st)) == -1) {
26
		sb_debug_dyn("EARLY FAIL: %s(%s): %s\n",
26
		sb_debug_dyn("EARLY FAIL: %s(%s): %s\n",
27
			func, pathname, strerror(errno));
27
			func, pathname, strerror(errno));
28
		return false;
28
		return false;
(-)sandbox-2.10.orig/libsandbox/wrapper-funcs/__wrapper_exec.c (-2 / +2 lines)
Lines 25-37 Link Here
25
{
25
{
26
	int fd;
26
	int fd;
27
	unsigned char *elf;
27
	unsigned char *elf;
28
	struct stat st;
28
	struct stat64 st;
29
	bool do_trace = false;
29
	bool do_trace = false;
30
30
31
	fd = open(filename, O_RDONLY|O_CLOEXEC);
31
	fd = open(filename, O_RDONLY|O_CLOEXEC);
32
	if (fd == -1)
32
	if (fd == -1)
33
		return;
33
		return;
34
	if (fstat(fd, &st))
34
	if (fstat64(fd, &st))
35
		goto out_fd;
35
		goto out_fd;
36
	if (st.st_size < sizeof(Elf64_Ehdr))
36
	if (st.st_size < sizeof(Elf64_Ehdr))
37
		goto out_fd;
37
		goto out_fd;
(-)sandbox-2.10.orig/libsbutil/gnulib/canonicalize.c (-3 / +3 lines)
Lines 67-73 Link Here
67
/* Return true if we've already seen the triple, <FILENAME, dev, ino>.
67
/* Return true if we've already seen the triple, <FILENAME, dev, ino>.
68
   If *HT is not initialized, initialize it.  */
68
   If *HT is not initialized, initialize it.  */
69
static bool
69
static bool
70
seen_triple (Hash_table **ht, char const *filename, struct stat const *st)
70
seen_triple (Hash_table **ht, char const *filename, struct stat64 const *st)
71
{
71
{
72
  if (*ht == NULL)
72
  if (*ht == NULL)
73
    {
73
    {
Lines 199-205 Link Here
199
        }
199
        }
200
      else
200
      else
201
        {
201
        {
202
          struct stat st;
202
          struct stat64 st;
203
203
204
          if (!ISSLASH (dest[-1]))
204
          if (!ISSLASH (dest[-1]))
205
            *dest++ = '/';
205
            *dest++ = '/';
Lines 230-236 Link Here
230
                 component existence.  */
230
                 component existence.  */
231
              st.st_mode = 0;
231
              st.st_mode = 0;
232
            }
232
            }
233
          else if ((logical ? stat (rname, &st) : lstat (rname, &st)) != 0)
233
          else if ((logical ? stat64 (rname, &st) : lstat64 (rname, &st)) != 0)
234
            {
234
            {
235
              saved_errno = errno;
235
              saved_errno = errno;
236
              if (can_mode == CAN_EXISTING)
236
              if (can_mode == CAN_EXISTING)
(-)sandbox-2.10.orig/libsbutil/gnulib/file-set.c (-2 / +2 lines)
Lines 26-32 Link Here
26
   If HT is NULL, return immediately.
26
   If HT is NULL, return immediately.
27
   If memory allocation fails, exit immediately.  */
27
   If memory allocation fails, exit immediately.  */
28
void
28
void
29
record_file (Hash_table *ht, char const *file, struct stat const *stats)
29
record_file (Hash_table *ht, char const *file, struct stat64 const *stats)
30
{
30
{
31
  struct F_triple *ent;
31
  struct F_triple *ent;
32
32
Lines 59-65 Link Here
59
   for the file described by FILE and STATS.  */
59
   for the file described by FILE and STATS.  */
60
bool
60
bool
61
seen_file (Hash_table const *ht, char const *file,
61
seen_file (Hash_table const *ht, char const *file,
62
           struct stat const *stats)
62
           struct stat64 const *stats)
63
{
63
{
64
  struct F_triple new_ent;
64
  struct F_triple new_ent;
65
65
(-)sandbox-2.10.orig/libsbutil/gnulib/file-set.h (-2 / +2 lines)
Lines 5-15 Link Here
5
#include "hash.h"
5
#include "hash.h"
6
6
7
extern void record_file (Hash_table *ht, char const *file,
7
extern void record_file (Hash_table *ht, char const *file,
8
                         struct stat const *stats)
8
                         struct stat64 const *stats)
9
#if defined __GNUC__ && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3)
9
#if defined __GNUC__ && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3)
10
  __attribute__ ((nonnull (2, 3)))
10
  __attribute__ ((nonnull (2, 3)))
11
#endif
11
#endif
12
;
12
;
13
13
14
extern bool seen_file (Hash_table const *ht, char const *file,
14
extern bool seen_file (Hash_table const *ht, char const *file,
15
                       struct stat const *stats);
15
                       struct stat64 const *stats);
(-)sandbox-2.10.orig/libsbutil/src/file.c (-10 / +10 lines)
Lines 15-27 Link Here
15
bool
15
bool
16
rc_file_exists (const char *pathname)
16
rc_file_exists (const char *pathname)
17
{
17
{
18
  struct stat buf;
18
  struct stat64 buf;
19
  int retval;
19
  int retval;
20
20
21
  if (!check_str (pathname))
21
  if (!check_str (pathname))
22
    return false;
22
    return false;
23
23
24
  retval = lstat (pathname, &buf);
24
  retval = lstat64 (pathname, &buf);
25
  if (-1 != retval)
25
  if (-1 != retval)
26
    retval = true;
26
    retval = true;
27
  else
27
  else
Lines 33-45 Link Here
33
bool
33
bool
34
rc_is_file (const char *pathname, bool follow_link)
34
rc_is_file (const char *pathname, bool follow_link)
35
{
35
{
36
  struct stat buf;
36
  struct stat64 buf;
37
  int retval;
37
  int retval;
38
38
39
  if (!check_str (pathname))
39
  if (!check_str (pathname))
40
    return false;
40
    return false;
41
41
42
  retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
42
  retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
43
  if ((-1 != retval) && (S_ISREG (buf.st_mode)))
43
  if ((-1 != retval) && (S_ISREG (buf.st_mode)))
44
    retval = true;
44
    retval = true;
45
  else
45
  else
Lines 51-63 Link Here
51
bool
51
bool
52
rc_is_dir (const char *pathname, bool follow_link)
52
rc_is_dir (const char *pathname, bool follow_link)
53
{
53
{
54
  struct stat buf;
54
  struct stat64 buf;
55
  int retval;
55
  int retval;
56
56
57
  if (!check_str (pathname))
57
  if (!check_str (pathname))
58
    return false;
58
    return false;
59
59
60
  retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
60
  retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
61
  if ((-1 != retval) && (S_ISDIR (buf.st_mode)))
61
  if ((-1 != retval) && (S_ISDIR (buf.st_mode)))
62
    retval = true;
62
    retval = true;
63
  else
63
  else
Lines 69-81 Link Here
69
off_t
69
off_t
70
rc_get_size (const char *pathname, bool follow_link)
70
rc_get_size (const char *pathname, bool follow_link)
71
{
71
{
72
  struct stat buf;
72
  struct stat64 buf;
73
  int retval;
73
  int retval;
74
74
75
  if (!check_str (pathname))
75
  if (!check_str (pathname))
76
    return 0;
76
    return 0;
77
77
78
  retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
78
  retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
79
  if (-1 != retval)
79
  if (-1 != retval)
80
    retval = buf.st_size;
80
    retval = buf.st_size;
81
  else
81
  else
Lines 196-202 Link Here
196
int
196
int
197
rc_file_map (const char *filename, char **buf, size_t * bufsize)
197
rc_file_map (const char *filename, char **buf, size_t * bufsize)
198
{
198
{
199
  struct stat stats;
199
  struct stat64 stats;
200
  int fd;
200
  int fd;
201
201
202
  fd = open (filename, O_RDONLY);
202
  fd = open (filename, O_RDONLY);
Lines 207-213 Link Here
207
      return -1;
207
      return -1;
208
    }
208
    }
209
209
210
  if (fstat (fd, &stats) < 0)
210
  if (fstat64 (fd, &stats) < 0)
211
    {
211
    {
212
      rc_errno_set (errno);
212
      rc_errno_set (errno);
213
      DBG_MSG ("Failed to stat file!\n");
213
      DBG_MSG ("Failed to stat file!\n");
(-)sandbox-2.10.orig/tests/get-group.c (-2 / +2 lines)
Lines 31-38 Link Here
31
				printf("%i\n", grp->gr_gid);
31
				printf("%i\n", grp->gr_gid);
32
			} else {
32
			} else {
33
				const char *file = argv[1];
33
				const char *file = argv[1];
34
				struct stat st;
34
				struct stat64 st;
35
				if (lstat(file, &st))
35
				if (lstat64(file, &st))
36
					errp("lstat(%s) failed", file);
36
					errp("lstat(%s) failed", file);
37
				printf("%i\n", st.st_gid);
37
				printf("%i\n", st.st_gid);
38
			}
38
			}
(-)sandbox-2.10.orig/tests/get-user.c (-2 / +2 lines)
Lines 31-38 Link Here
31
				printf("%i\n", pwd->pw_uid);
31
				printf("%i\n", pwd->pw_uid);
32
			} else {
32
			} else {
33
				const char *file = argv[1];
33
				const char *file = argv[1];
34
				struct stat st;
34
				struct stat64 st;
35
				if (lstat(file, &st))
35
				if (lstat64(file, &st))
36
					errp("lstat(%s) failed", file);
36
					errp("lstat(%s) failed", file);
37
				printf("%i\n", st.st_uid);
37
				printf("%i\n", st.st_uid);
38
			}
38
			}

Return to bug 584930