diff options
author | Wayne Davison <wayned@samba.org> | 2011-09-20 13:02:12 -0700 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2011-09-20 13:02:12 -0700 |
commit | de219101ed2d1eca188c37f9a06b9764c4ca528e (patch) | |
tree | d1c2ccc92ce8b29ddeeb59c34d505434b706cfba | |
parent | 79853c30c0f25a18fe82d93b424b0e8521a90c68 (diff) | |
download | rsync-de219101ed2d1eca188c37f9a06b9764c4ca528e.tar.gz |
Change stat order for better ELOOP determination.
-rw-r--r-- | syscall.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -464,9 +464,14 @@ int do_open_nofollow(const char *pathname, int flags) #ifdef O_NOFOLLOW fd = open(pathname, flags|O_NOFOLLOW); #else + if (do_lstat(pathname, &l_st) < 0) + return -1; + if (S_ISLNK(l_st.st_mode)) { + errno = ELOOP; + return -1; + } if ((fd = open(pathname, flags)) < 0) return fd; - if (do_fstat(fd, &f_st) < 0) { close_and_return_error: { @@ -476,12 +481,6 @@ int do_open_nofollow(const char *pathname, int flags) } return -1; } - if (do_lstat(pathname, &l_st) < 0) - goto close_and_return_error; - if (S_ISLNK(l_st.st_mode)) { - errno = ELOOP; - goto close_and_return_error; - } if (l_st.st_dev != f_st.st_dev || l_st.st_ino != f_st.st_ino) { errno = EINVAL; goto close_and_return_error; |