public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] hurd: Fix getxattr/listxattr returning ERANGE
@ 2024-06-10 20:09 Samuel Thibault
0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2024-06-10 20:09 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5968125f55a3a3f3394e4ebe45e1f96d4864c576
commit 5968125f55a3a3f3394e4ebe45e1f96d4864c576
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Mon Jun 10 22:01:40 2024 +0200
hurd: Fix getxattr/listxattr returning ERANGE
The manpage says that when the passed size is zero, they should set the
expected size and return 0. ERANGE shall be returned only when the non-zero
passed size is not large enough.
Diff:
---
hurd/xattr.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/hurd/xattr.c b/hurd/xattr.c
index 1a84c90db8..2d83edf2fe 100644
--- a/hurd/xattr.c
+++ b/hurd/xattr.c
@@ -50,7 +50,15 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size)
else if (value)
{
if (*size < sizeof st.st_author)
- return ERANGE;
+ {
+ if (*size > 0)
+ return ERANGE;
+ else
+ {
+ *size = sizeof st.st_author;
+ return 0;
+ }
+ }
memcpy (value, &st.st_author, sizeof st.st_author);
}
*size = sizeof st.st_author;
@@ -73,12 +81,21 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size)
err = __file_get_translator (port, &buf, &bufsz);
if (err)
return err;
- if (value != NULL && *size < bufsz)
+
+ if (*size < bufsz)
{
if (buf != value)
__munmap (buf, bufsz);
- return ERANGE;
+
+ if (*size > 0)
+ return ERANGE;
+ else
+ {
+ *size = bufsz;
+ return 0;
+ }
}
+
if (buf != value && bufsz > 0)
{
if (value != NULL)
@@ -201,7 +218,7 @@ _hurd_xattr_list (io_t port, void *buffer, size_t *size)
if (st.st_mode & S_IPTRANS)
add ("gnu.translator");
- if (buffer != NULL && total > *size)
+ if (*size > 0 && total > *size)
return ERANGE;
*size = total;
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-10 20:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 20:09 [glibc] hurd: Fix getxattr/listxattr returning ERANGE Samuel Thibault
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).