summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-05-25 06:08:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-05-25 06:08:33 +0000
commit06135d973dd6fdf749198edd3e38f815ec977cb6 (patch)
tree733092407ef72fe0e2cbbac3e9bdb8a4f6958c98
parent18f27be3580fcbd81c5b8f17a43648e8d1fd039e (diff)
__uClibc_main.c: save ~70 bytes by not checking that /dev/null
is indeed a char device with correct (maj,min). (If it's not such a char device, the system is screwed anyway, nothing can be done about it...) text data bss dec hex filename - 715 4 21 740 2e4 libc/misc/internals/__uClibc_main.o + 644 4 21 669 29d libc/misc/internals/__uClibc_main.o
-rw-r--r--libc/misc/internals/__uClibc_main.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 60989298e..351161593 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -132,16 +132,14 @@ size_t __pagesize = 0;
static void __check_one_fd(int fd, int mode)
{
/* Check if the specified fd is already open */
- if (unlikely(__libc_fcntl(fd, F_GETFD)==-1 && *(__errno_location())==EBADF))
+ if (__libc_fcntl(fd, F_GETFD) == -1)
{
/* The descriptor is probably not open, so try to use /dev/null */
- struct stat st;
int nullfd = __libc_open(_PATH_DEVNULL, mode);
/* /dev/null is major=1 minor=3. Make absolutely certain
* that is in fact the device that we have opened and not
* some other wierd file... */
- if ( (nullfd!=fd) || fstat(fd, &st) || !S_ISCHR(st.st_mode) ||
- (st.st_rdev != makedev(1, 3)))
+ if (nullfd!=fd)
{
abort();
}
@@ -155,13 +153,13 @@ static int __check_suid(void)
uid = getuid();
euid = geteuid();
+ if (uid != euid)
+ return 1;
gid = getgid();
egid = getegid();
-
- if(uid == euid && gid == egid) {
- return 0;
- }
- return 1;
+ if (gid != egid)
+ return 1;
+ return 0; /* we are not suid */
}
#endif