diff options
| author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2025-02-12 19:46:06 +0100 |
|---|---|---|
| committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2025-02-13 16:31:28 -0300 |
| commit | 6a3cb6b1bd63e167fc525cce07010ff78197b271 (patch) | |
| tree | 7fcc3d2f846503b5ee993096c0ad6212aa0cdc2c /support | |
| parent | 991febc2f46d51801691bbd489d290820728d241 (diff) | |
| download | glibc-6a3cb6b1bd63e167fc525cce07010ff78197b271.tar.xz glibc-6a3cb6b1bd63e167fc525cce07010ff78197b271.zip | |
nss: Improve network number parsers (bz 32573, 32575)
Make sure that numbers never overflow uint32_t in inet_network to
properly validate octets encountered in IPv4 addresses.
Avoid malloca in NSS networks file code because /etc/networks lines
can be arbitrarily long. Instead of handcrafting the input for
inet_network by adding ".0" octets if they are missing, just left shift
the result. Also, do not accept invalid entries, but ignore the line
instead.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'support')
| -rw-r--r-- | support/namespace.h | 2 | ||||
| -rw-r--r-- | support/support_chroot.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/support/namespace.h b/support/namespace.h index 456157a4e0..6b9b226f95 100644 --- a/support/namespace.h +++ b/support/namespace.h @@ -75,6 +75,7 @@ struct support_chroot_configuration const char *hosts; /* /etc/hosts. */ const char *host_conf; /* /etc/host.conf. */ const char *aliases; /* /etc/aliases. */ + const char *networks; /* /etc/networks. */ }; /* The result of the creation of a chroot. */ @@ -92,6 +93,7 @@ struct support_chroot char *path_hosts; /* /etc/hosts. */ char *path_host_conf; /* /etc/host.conf. */ char *path_aliases; /* /etc/aliases. */ + char *path_networks; /* /etc/networks. */ }; /* Create a chroot environment. The returned data should be freed diff --git a/support/support_chroot.c b/support/support_chroot.c index 2637dd1522..92c2a453aa 100644 --- a/support/support_chroot.c +++ b/support/support_chroot.c @@ -57,6 +57,7 @@ support_chroot_create (struct support_chroot_configuration conf) write_file (path_etc, "hosts", conf.hosts, &chroot->path_hosts); write_file (path_etc, "host.conf", conf.host_conf, &chroot->path_host_conf); write_file (path_etc, "aliases", conf.aliases, &chroot->path_aliases); + write_file (path_etc, "networks", conf.networks, &chroot->path_networks); free (path_etc); @@ -79,5 +80,6 @@ support_chroot_free (struct support_chroot *chroot) free (chroot->path_hosts); free (chroot->path_host_conf); free (chroot->path_aliases); + free (chroot->path_networks); free (chroot); } |
