Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 135745 | Differences between
and this patch

Collapse All | Expand All

(-)libsandbox/wrappers.c.orig (+36 lines)
Lines 153-158 Link Here
153
FILE *_name(const char *pathname, const char *mode) \
153
FILE *_name(const char *pathname, const char *mode) \
154
{ \
154
{ \
155
	FILE *result = NULL; \
155
	FILE *result = NULL; \
156
	int my_errno = errno; \
157
	struct stat st; \
158
\
159
	if (mode!=NULL && mode[0]=='r') { \
160
		/* If we're trying to read, fail normally if file does not stat */\
161
		if (-1 == stat(pathname, &st)) { \
162
			return NULL; \
163
		} \
164
	} \
165
	errno = my_errno; \
156
\
166
\
157
	if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen", pathname, mode) { \
167
	if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen", pathname, mode) { \
158
		check_dlsym(_name); \
168
		check_dlsym(_name); \
Lines 326-337 Link Here
326
	va_list ap; \
336
	va_list ap; \
327
	int mode = 0; \
337
	int mode = 0; \
328
	int result = -1; \
338
	int result = -1; \
339
	int my_errno = errno; \
340
	struct stat st; \
329
\
341
\
330
	if (flags & O_CREAT) { \
342
	if (flags & O_CREAT) { \
331
		va_start(ap, flags); \
343
		va_start(ap, flags); \
332
		mode = va_arg(ap, int); \
344
		mode = va_arg(ap, int); \
333
		va_end(ap); \
345
		va_end(ap); \
346
	} else { \
347
		/* If we're not trying to create, fail normally if file does not stat */\
348
		if (-1 == stat(pathname, &st)) { \
349
			return -1; \
350
		} \
334
	} \
351
	} \
352
	errno = my_errno; \
335
\
353
\
336
	if FUNCTION_SANDBOX_SAFE_OPEN_INT("open", pathname, flags) { \
354
	if FUNCTION_SANDBOX_SAFE_OPEN_INT("open", pathname, flags) { \
337
		check_dlsym(_name); \
355
		check_dlsym(_name); \
Lines 491-496 Link Here
491
FILE *_name(const char *pathname, const char *mode) \
509
FILE *_name(const char *pathname, const char *mode) \
492
{ \
510
{ \
493
	FILE *result = NULL; \
511
	FILE *result = NULL; \
512
	int my_errno = errno; \
513
	struct stat64 st; \
514
\
515
	if (mode!=NULL && mode[0]=='r') { \
516
		/* If we're trying to read, fail normally if file does not stat */\
517
		if (-1 == stat64(pathname, &st)) { \
518
			return NULL; \
519
		} \
520
	} \
521
	errno = my_errno; \
494
\
522
\
495
	if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen64", pathname, mode) { \
523
	if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen64", pathname, mode) { \
496
		check_dlsym(_name); \
524
		check_dlsym(_name); \
Lines 511-522 Link Here
511
	va_list ap; \
539
	va_list ap; \
512
	int mode = 0; \
540
	int mode = 0; \
513
	int result = -1; \
541
	int result = -1; \
542
	int my_errno = errno; \
543
	struct stat64 st; \
514
\
544
\
515
	if (flags & O_CREAT) { \
545
	if (flags & O_CREAT) { \
516
		va_start(ap, flags); \
546
		va_start(ap, flags); \
517
		mode = va_arg(ap, int); \
547
		mode = va_arg(ap, int); \
518
		va_end(ap); \
548
		va_end(ap); \
549
	} else { \
550
		/* If we're not trying to create, fail normally if file does not stat */\
551
		if (-1 == stat64(pathname, &st)) { \
552
			return -1; \
553
		} \
519
	} \
554
	} \
555
	errno = my_errno; \
520
\
556
\
521
	if FUNCTION_SANDBOX_SAFE_OPEN_INT("open64", pathname, flags) { \
557
	if FUNCTION_SANDBOX_SAFE_OPEN_INT("open64", pathname, flags) { \
522
		check_dlsym(_name); \
558
		check_dlsym(_name); \

Return to bug 135745