mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
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.
This commit is contained in:
parent
ed06248019
commit
5968125f55
25
hurd/xattr.c
25
hurd/xattr.c
@ -50,7 +50,15 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size)
|
|||||||
else if (value)
|
else if (value)
|
||||||
{
|
{
|
||||||
if (*size < sizeof st.st_author)
|
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);
|
memcpy (value, &st.st_author, sizeof st.st_author);
|
||||||
}
|
}
|
||||||
*size = 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);
|
err = __file_get_translator (port, &buf, &bufsz);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (value != NULL && *size < bufsz)
|
|
||||||
|
if (*size < bufsz)
|
||||||
{
|
{
|
||||||
if (buf != value)
|
if (buf != value)
|
||||||
__munmap (buf, bufsz);
|
__munmap (buf, bufsz);
|
||||||
return ERANGE;
|
|
||||||
|
if (*size > 0)
|
||||||
|
return ERANGE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*size = bufsz;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf != value && bufsz > 0)
|
if (buf != value && bufsz > 0)
|
||||||
{
|
{
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
@ -201,7 +218,7 @@ _hurd_xattr_list (io_t port, void *buffer, size_t *size)
|
|||||||
if (st.st_mode & S_IPTRANS)
|
if (st.st_mode & S_IPTRANS)
|
||||||
add ("gnu.translator");
|
add ("gnu.translator");
|
||||||
|
|
||||||
if (buffer != NULL && total > *size)
|
if (*size > 0 && total > *size)
|
||||||
return ERANGE;
|
return ERANGE;
|
||||||
*size = total;
|
*size = total;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user