mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-26 06:50:07 +00:00
* sysdeps/unix/readdir.c: Make sure we don't modify errno when we reached EOF.
This commit is contained in:
parent
4ceae91566
commit
a92544ca12
@ -39,6 +39,7 @@ DIRENT_TYPE *
|
|||||||
__READDIR (DIR *dirp)
|
__READDIR (DIR *dirp)
|
||||||
{
|
{
|
||||||
DIRENT_TYPE *dp;
|
DIRENT_TYPE *dp;
|
||||||
|
int saved_errno = errno;
|
||||||
|
|
||||||
__libc_lock_lock (dirp->lock);
|
__libc_lock_lock (dirp->lock);
|
||||||
|
|
||||||
@ -63,6 +64,9 @@ __READDIR (DIR *dirp)
|
|||||||
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
|
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
|
||||||
if (bytes <= 0)
|
if (bytes <= 0)
|
||||||
{
|
{
|
||||||
|
/* Don't modifiy errno when reaching EOF. */
|
||||||
|
if (bytes == 0)
|
||||||
|
__set_errno (saved_errno);
|
||||||
dp = NULL;
|
dp = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user