[Unbound-users] Segfault on user not found with 1.5.3
Maciej Soltysiak
maciej at soltysiak.com
Mon Mar 23 17:04:39 UTC 2015
Hi,
I just took the latest 1.5.3, compiled it and ran the executable without
doing any config. Just to see what happens.
It segfaulted after saying user unbound not found.
The issue is in util/config_file.c in function config_lookup_uid().
getpwnam() can return NULL and so subsequent referrences to pw_uid and
pw_gid are invalid.
This patch corrects the code path to assign uid and gid only if getpwnam()
is successful.
It also removes the log_err() call, because perform_setup() in
daemon/unbound.c would print it anyway in fatal_exit()
I know it's a tiny buglet, but I couldn't resist fixing a segfault :-)
Best regards,
Maciej Soltysiak
DNSCrypt Poland
https://dnscrypt.pl/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nlnetlabs.nl/pipermail/unbound-users/attachments/20150323/cd5c74ef/attachment.htm>
-------------- next part --------------
diff -ru unbound-1.5.3.orig/util/config_file.c unbound-1.5.3/util/config_file.c
--- unbound-1.5.3.orig/util/config_file.c 2015-02-20 15:48:04.000000000 +0100
+++ unbound-1.5.3/util/config_file.c 2015-03-23 17:50:30.080579234 +0100
@@ -1211,10 +1211,10 @@
/* translate username into uid and gid */
if(cfg->username && cfg->username[0]) {
struct passwd *pwd;
- if((pwd = getpwnam(cfg->username)) == NULL)
- log_err("user '%s' does not exist.", cfg->username);
- cfg_uid = pwd->pw_uid;
- cfg_gid = pwd->pw_gid;
+ if((pwd = getpwnam(cfg->username)) != NULL) {
+ cfg_uid = pwd->pw_uid;
+ cfg_gid = pwd->pw_gid;
+ }
}
#else
(void)cfg;
More information about the Unbound-users
mailing list