From 2bac7daa58da1a313bd452369b0508b31e146637 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 31 Jan 2019 18:49:58 +0100 Subject: nss_files: Fix /etc/aliases null pointer dereference [BZ #24059] If /etc/aliases ends with a continuation line (a line that starts with whitespace) which does not have a trailing newline character, the file parser would crash due to a null pointer dereference. Reviewed-by: Carlos O'Donell --- support/namespace.h | 2 ++ support/support_chroot.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'support') diff --git a/support/namespace.h b/support/namespace.h index f93754934f..4770cf9e90 100644 --- a/support/namespace.h +++ b/support/namespace.h @@ -74,6 +74,7 @@ struct support_chroot_configuration const char *resolv_conf; /* /etc/resolv.conf. */ const char *hosts; /* /etc/hosts. */ const char *host_conf; /* /etc/host.conf. */ + const char *aliases; /* /etc/aliases. */ }; /* The result of the creation of a chroot. */ @@ -90,6 +91,7 @@ struct support_chroot char *path_resolv_conf; /* /etc/resolv.conf. */ char *path_hosts; /* /etc/hosts. */ char *path_host_conf; /* /etc/host.conf. */ + char *path_aliases; /* /etc/aliases. */ }; /* Create a chroot environment. The returned data should be freed diff --git a/support/support_chroot.c b/support/support_chroot.c index b866b89a18..412ec33f53 100644 --- a/support/support_chroot.c +++ b/support/support_chroot.c @@ -56,6 +56,7 @@ support_chroot_create (struct support_chroot_configuration conf) &chroot->path_resolv_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); free (path_etc); @@ -77,5 +78,6 @@ support_chroot_free (struct support_chroot *chroot) free (chroot->path_resolv_conf); free (chroot->path_hosts); free (chroot->path_host_conf); + free (chroot->path_aliases); free (chroot); } -- cgit 1.4.1