[PATCH] posix: Fix attribute access mode on getcwd with GNU extension [BZ #27476]
Aurelien Jarno
aurelien@aurel32.net
Wed Sep 8 22:52:50 GMT 2021
There is a GNU extension that allows to call getcwd(NULL, >0). It is
described in the documentation, but also directly in the unistd.h
header, just above the declaration.
Therefore, do not define the attribute access mode when __USE_GNU is in
used.
---
posix/unistd.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Note: I am aware of BZ #26545, however while it is being discussed, the
bug is still there, so I don't think we should block on a decision to
fix it.
diff --git a/posix/unistd.h b/posix/unistd.h
index 3dca65732f..506d34d2ec 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -529,7 +529,10 @@ extern int fchdir (int __fd) __THROW __wur;
bytes long, unless SIZE == 0, in which case it is as
big as necessary. */
extern char *getcwd (char *__buf, size_t __size) __THROW __wur
- __attr_access ((__write_only__, 1, 2));
+#ifndef __USE_GNU
+ __attr_access ((__write_only__, 1, 2))
+#endif
+ ;
#ifdef __USE_GNU
/* Return a malloc'd string containing the current directory name.
--
2.30.2
More information about the Libc-alpha
mailing list