diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-02 00:35:05 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-02 00:35:05 +0100 |
commit | d21b09b328956996466f35a45b28c4ab51f1f4e3 (patch) | |
tree | bdab638b37c65d6acf69e49372d7ac4b7e67d963 /procfs | |
parent | fbfc77cead9bfbc34181a438cfed18c69dd8cc04 (diff) | |
download | hurd-d21b09b328956996466f35a45b28c4ab51f1f4e3.tar.gz hurd-d21b09b328956996466f35a45b28c4ab51f1f4e3.tar.bz2 hurd-d21b09b328956996466f35a45b28c4ab51f1f4e3.zip |
procfs: Add padding to align struct dirent
Diffstat (limited to 'procfs')
-rw-r--r-- | procfs/netfs.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/procfs/netfs.c b/procfs/netfs.c index 20238386..967e6109 100644 --- a/procfs/netfs.c +++ b/procfs/netfs.c @@ -123,6 +123,7 @@ error_t netfs_attempt_readlink (struct iouser *user, struct node *np, static int putentries (char *contents, size_t contents_len, int nentries, char *data, mach_msg_type_number_t *datacnt) { + int align = __alignof (struct dirent); int i; *datacnt = 0; @@ -130,6 +131,8 @@ static int putentries (char *contents, size_t contents_len, int nentries, { int namlen = strlen (contents); int reclen = sizeof (struct dirent) + namlen; + int extra = reclen & (align - 1); + int pad = extra ? align - extra : 0; if (data) { @@ -138,7 +141,9 @@ static int putentries (char *contents, size_t contents_len, int nentries, d->d_namlen = namlen; d->d_reclen = reclen; d->d_type = DT_UNKNOWN; - strcpy (d->d_name, contents); + memcpy (d->d_name, contents, namlen + 1); + if (pad) + memset(d->d_name + namlen + 1, 0, pad); } *datacnt += reclen; |