Ahmed Khider, le lun. 30 nov. 2026 02:13:46 +0300, a ecrit:
> ---
> hurd/fd-read.c | 17 ++++++++++++++---
> hurd/fd-write.c | 13 +++++++++++--
> 2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/hurd/fd-read.c b/hurd/fd-read.c
> index 7f4833d8..b912f705 100644
> --- a/hurd/fd-read.c
> +++ b/hurd/fd-read.c
> @@ -15,6 +15,7 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +#include <stdint.h>
> #include <errno.h>
> #include <unistd.h>
> #include <hurd.h>
> @@ -27,18 +28,28 @@ _hurd_fd_read (struct hurd_fd *fd, void *buf, size_t
> *nbytes, loff_t offset)
> error_t err;
> char *data;
> mach_msg_type_number_t nread;
> + size_t max;
> + size_t rbytes;
You can as well put the initalizations of the variables directly along
their definitions.
> +
> + max = ((size_t) 1 << sizeof(mach_msg_kind_t) * (8 - 1)) - 1;
Please actually check the value of max, this looks completely wrong,
it'd rather be
max = ((size_t) 1 << (sizeof(mach_msg_type_number_t) * 8 - 1)) - 1;
Samuel
> + rbytes = *nbytes;
> +
> + if (rbytes > max)
> + rbytes = max;
> +
>
> error_t readfd (io_t port)
> {
> - return __io_read (port, &data, &nread, offset, *nbytes);
> + return __io_read (port, &data, &nread, offset, rbytes);
> }
>
> data = buf;
> - nread = *nbytes;
> + nread = rbytes;
> +
> if (err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_input (port, ctty,
> readfd)))
> return err;
>
> - if (__glibc_unlikely (nread > *nbytes)) /* Sanity check for bogus
> server. */
> + if (__glibc_unlikely (nread > rbytes)) /* Sanity check for bogus
> server. */
> {
> if (data != buf)
> __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread);
> diff --git a/hurd/fd-write.c b/hurd/fd-write.c
> index 2dc2eedf..9d6a6036 100644
> --- a/hurd/fd-write.c
> +++ b/hurd/fd-write.c
> @@ -16,6 +16,7 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +#include <stdint.h>
> #include <errno.h>
> #include <unistd.h>
> #include <hurd.h>
> @@ -27,17 +28,25 @@ _hurd_fd_write (struct hurd_fd *fd,
> {
> error_t err;
> vm_size_t wrote;
> + size_t max;
> + size_t wbytes;
> +
> + max = ((size_t) 1 << sizeof(mach_msg_kind_t) * (8 - 1)) - 1;
> + wbytes = *nbytes;
> +
> + if (wbytes > max)
> + wbytes = max;
>
> error_t writefd (io_t port)
> {
> - return __io_write (port, buf, *nbytes, offset, &wrote);
> + return __io_write (port, buf, wbytes, offset, &wrote);
> }
>
> err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty,
> writefd));
> if (err)
> return err;
>
> - if (__glibc_unlikely (wrote > *nbytes)) /* Sanity check for bogus
> server. */
> + if (__glibc_unlikely (wrote > wbytes)) /* Sanity check for bogus
> server. */
> return EGRATUITOUS;
>
> *nbytes = wrote;
> --
> 2.47.3
>
>
--
Samuel
J'ai un gros problème: j'ai cet exercice à rendre demain lundi, mais ma
TI 89 ne sait pas le faire...
Est-ce que quelqu'un pourrait m'aider??
-+- OD In Guide du Neuneu Usenet : Comment ça ! Il faut réfléchir ?-+-