[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/6] pci-arbiter: Fix brokenness
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 1/6] pci-arbiter: Fix brokenness |
Date: |
Sun, 7 Mar 2021 11:17:19 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Damien Zammit, le dim. 07 mars 2021 17:39:05 +1100, a ecrit:
> - if (max_entries < 0)
> - count = dir->dir->num_entries;
> + count = nentries - first_entry;
> + if (max_entries > 0 && count > max_entries)
> + count = max_entries;
It was previously considering max_entries == 0 meaning really zero, so
better keep it that way by testing for max_entries >= 0.
> - size =
> - (count * DIRENTS_CHUNK_SIZE) >
> - max_data_len ? max_data_len : count * DIRENTS_CHUNK_SIZE;
> + size = count * DIRENTS_CHUNK_SIZE;
You need to keep taking max_data_len into account.
Also, the exact same code is appearing in acpi/netfs_impl.c, so please
apply the same fixes there, otherwise we'll keep that max_entries bug
along with acpi (and who knows when that will be cargo-culted again).
> @@ -234,8 +228,8 @@ netfs_get_dirents (struct iouser * cred, struct node *
> dir,
>
> if (dir->nn->ln->dir)
> {
> - err = get_dirents (dir->nn->ln, first_entry, max_entries,
> - data, data_len, max_entries, data_entries);
> + err = get_dirents (dir->nn->ln, first_entry, -1,
> + data, data_len, 0, data_entries);
Keep max_entries as such, the RPC caller could be very surprised to get
more entries than what it asked for.
> @@ -257,6 +251,24 @@ netfs_attempt_lookup (struct iouser * user, struct node
> * dir,
> {
> error_t err = 0;
> struct pcifs_dirent *entry;
> + char *last = name;
> +
> + /* Strip trailing slashes */
> + if (*last)
> + {
> + while (*last)
> + last++;
> + last--;
Rather use last += strlen(last)-1, strlen is optimized by glibc.
> + while (*last == '/' && last >= name)
> + {
> + *last = '\0';
> + last--;
It should also record in a mustbedir boolean that there was a trailing
slash. A trailing slash, in Posix, means that the caller really wanted
to lookup a directory, so the flag should passed to the lookup()
function above to check that IFTODT (e->stat.st_mode) == DT_DIR, and
otherwise return an ENOTDIR error.
Samuel
- [PATCH: hurd x6], Damien Zammit, 2021/03/07
- [PATCH 2/6] pci-arbiter: Introduce machdev into this server, Damien Zammit, 2021/03/07
- [PATCH 3/6] libnetfs: Hacks to allow pci to run with no cred, Damien Zammit, 2021/03/07
- [PATCH 4/6] rumpdisk: Don't pretend to be the arbiter anymore, Damien Zammit, 2021/03/07
- [PATCH 1/6] pci-arbiter: Fix brokenness, Damien Zammit, 2021/03/07
- Re: [PATCH 1/6] pci-arbiter: Fix brokenness,
Samuel Thibault <=
- [PATCH 6/6] pci-arbiter: Close correctly, Damien Zammit, 2021/03/07
- [PATCH 5/6] machdev,pci,rump: fix shutdown dosync, Damien Zammit, 2021/03/07
- Re: [PATCH: hurd x6], Samuel Thibault, 2021/03/07