mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-09 10:50:08 +00:00
Update.
* sysdeps/unix/sysv/linux/getdents.c (__getdents): The Linux kernel does not allow relative seeks on descriptors associated with directories. Go back to get the position in the directory every time we enter the function. Return -1 and set errno if one entry could be read from the kernel but does not fit into the buffer passed in by the user.
This commit is contained in:
parent
a0dc52061f
commit
f11b9da654
@ -1,5 +1,12 @@
|
|||||||
2000-04-06 Ulrich Drepper <drepper@redhat.com>
|
2000-04-06 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/getdents.c (__getdents): The Linux
|
||||||
|
kernel does not allow relative seeks on descriptors associated
|
||||||
|
with directories. Go back to get the position in the directory
|
||||||
|
every time we enter the function. Return -1 and set errno if one
|
||||||
|
entry could be read from the kernel but does not fit into the
|
||||||
|
buffer passed in by the user.
|
||||||
|
|
||||||
* locale/programs/charmap.c (charmap_new_char): Add parameter step.
|
* locale/programs/charmap.c (charmap_new_char): Add parameter step.
|
||||||
Support ..(2).. ellipsis.
|
Support ..(2).. ellipsis.
|
||||||
(parse_charmap): Recognize ..(2).. etc and pass step down.
|
(parse_charmap): Recognize ..(2).. etc and pass step down.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -67,7 +67,7 @@ ssize_t
|
|||||||
internal_function
|
internal_function
|
||||||
__getdents (int fd, char *buf, size_t nbytes)
|
__getdents (int fd, char *buf, size_t nbytes)
|
||||||
{
|
{
|
||||||
off_t last_offset = 0;
|
off_t last_offset = __lseek (fd, 0, SEEK_CUR);
|
||||||
size_t red_nbytes;
|
size_t red_nbytes;
|
||||||
struct kernel_dirent *skdp, *kdp;
|
struct kernel_dirent *skdp, *kdp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
@ -96,13 +96,17 @@ __getdents (int fd, char *buf, size_t nbytes)
|
|||||||
if ((char *) dp + new_reclen > buf + nbytes)
|
if ((char *) dp + new_reclen > buf + nbytes)
|
||||||
{
|
{
|
||||||
/* Our heuristic failed. We read too many entries. Reset
|
/* Our heuristic failed. We read too many entries. Reset
|
||||||
the stream. `last_offset' contains the last known
|
the stream. */
|
||||||
position. If it is zero this is the first record we are
|
__lseek (fd, last_offset, SEEK_SET);
|
||||||
reading. In this case do a relative search. */
|
|
||||||
if (last_offset == 0)
|
if ((char *) dp == buf)
|
||||||
__lseek (fd, -retval, SEEK_CUR);
|
{
|
||||||
else
|
/* The buffer the user passed in is too small to hold even
|
||||||
__lseek (fd, last_offset, SEEK_SET);
|
one entry. */
|
||||||
|
__set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user