* [PATCH] Cygwin: fstatat: call fstat64 instead of fstat
@ 2021-01-12 19:45 Ken Brown
2021-01-13 8:56 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Ken Brown @ 2021-01-12 19:45 UTC (permalink / raw)
To: cygwin-patches
This fixes a bug on 32-bit Cygwin that was introduced in commit
84252946, "Cygwin: fstatat, fchownat: support the AT_EMPTY_PATH flag".
Add a comment explaining why fstat should not be called.
Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
---
winsup/cygwin/release/3.2.0 | 3 +++
winsup/cygwin/syscalls.cc | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index 22f78e7a7..132d5c810 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -42,3 +42,6 @@ Bug Fixes
- Fix return value of sqrtl on negative infinity.
Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
+
+- Fix a bug in fstatat(2) on 32 bit that could cause it to return garbage.
+ Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 885ca375a..525efecf3 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1929,6 +1929,9 @@ _fstat64_r (struct _reent *ptr, int fd, struct stat *buf)
}
#ifdef __i386__
+/* This entry point is retained only to serve old 32 bit applications
+built under Cygwin 1.3.x or earlier. Newer 32 bit apps are redirected
+to fstat64; see NEW_FUNCTIONS in Makefile.in. */
extern "C" int
fstat (int fd, struct stat *buf)
{
@@ -4852,7 +4855,7 @@ fstatat (int dirfd, const char *__restrict pathname, struct stat *__restrict st,
cwdstuff::cwd_lock.release ();
}
else
- return fstat (dirfd, st);
+ return fstat64 (dirfd, st);
}
path_conv pc (path, ((flags & AT_SYMLINK_NOFOLLOW)
? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
--
2.30.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cygwin: fstatat: call fstat64 instead of fstat
2021-01-12 19:45 [PATCH] Cygwin: fstatat: call fstat64 instead of fstat Ken Brown
@ 2021-01-13 8:56 ` Corinna Vinschen
2021-01-13 13:15 ` Ken Brown
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2021-01-13 8:56 UTC (permalink / raw)
To: cygwin-patches
Hi Ken,
Happy New Year, btw :)
On Jan 12 14:45, Ken Brown via Cygwin-patches wrote:
> This fixes a bug on 32-bit Cygwin that was introduced in commit
> 84252946, "Cygwin: fstatat, fchownat: support the AT_EMPTY_PATH flag".
>
> Add a comment explaining why fstat should not be called.
>
> Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
> ---
> winsup/cygwin/release/3.2.0 | 3 +++
> winsup/cygwin/syscalls.cc | 5 ++++-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
> index 22f78e7a7..132d5c810 100644
> --- a/winsup/cygwin/release/3.2.0
> +++ b/winsup/cygwin/release/3.2.0
> @@ -42,3 +42,6 @@ Bug Fixes
>
> - Fix return value of sqrtl on negative infinity.
> Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
> +
> +- Fix a bug in fstatat(2) on 32 bit that could cause it to return garbage.
> + Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
> diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
> index 885ca375a..525efecf3 100644
> --- a/winsup/cygwin/syscalls.cc
> +++ b/winsup/cygwin/syscalls.cc
> @@ -1929,6 +1929,9 @@ _fstat64_r (struct _reent *ptr, int fd, struct stat *buf)
> }
>
> #ifdef __i386__
> +/* This entry point is retained only to serve old 32 bit applications
> +built under Cygwin 1.3.x or earlier. Newer 32 bit apps are redirected
> +to fstat64; see NEW_FUNCTIONS in Makefile.in. */
> extern "C" int
> fstat (int fd, struct stat *buf)
> {
> @@ -4852,7 +4855,7 @@ fstatat (int dirfd, const char *__restrict pathname, struct stat *__restrict st,
> cwdstuff::cwd_lock.release ();
> }
> else
> - return fstat (dirfd, st);
> + return fstat64 (dirfd, st);
> }
> path_conv pc (path, ((flags & AT_SYMLINK_NOFOLLOW)
> ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
> --
> 2.30.0
Sure, please go ahead.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cygwin: fstatat: call fstat64 instead of fstat
2021-01-13 8:56 ` Corinna Vinschen
@ 2021-01-13 13:15 ` Ken Brown
0 siblings, 0 replies; 3+ messages in thread
From: Ken Brown @ 2021-01-13 13:15 UTC (permalink / raw)
To: cygwin-patches
On 1/13/2021 3:56 AM, Corinna Vinschen via Cygwin-patches wrote:
> Hi Ken,
>
> Happy New Year, btw :)
Thanks, same to you!
Ken
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-13 13:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 19:45 [PATCH] Cygwin: fstatat: call fstat64 instead of fstat Ken Brown
2021-01-13 8:56 ` Corinna Vinschen
2021-01-13 13:15 ` Ken Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).