aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorLars Roland <Lars.Roland@gmx.net>2005-01-07 03:19:39 +0000
committerLars Roland <Lars.Roland@gmx.net>2005-01-07 03:19:39 +0000
commit0a771e1c65f03c067bd49e2197a93cc088683499 (patch)
tree917e01d254dac6eeee78da7b97181a3999b2bf45 /epan/addr_resolv.c
parentccf44f7fb1b4c2c1a84cdbbae239beedc06ec9fd (diff)
Check return value of getenv().
It can return NULL, which would lead here to strcpy(hostspath, NULL); *Very* bad. replace g_malloc(), strcpy() and strcat() with one single g_strconcat(). svn path=/trunk/; revision=12970
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 1b4503859d..b945bff0c2 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -1582,9 +1582,10 @@ host_name_lookup_init(void) {
#ifdef WIN32
sysroot = getenv("SYSTEMROOT");
- hostspath = g_malloc(strlen(sysroot) + sizeof rootpath);
- strcpy(hostspath, sysroot);
- strcat(hostspath, rootpath);
+ /* getenv() returns NULL, if requested environment variable can't be found */
+ if(sysroot != NULL) {
+ hostspath = g_strconcat(sysroot, rootpath, NULL);
+
#else
hostspath = g_strdup("/etc/hosts");
#endif
@@ -1595,6 +1596,9 @@ host_name_lookup_init(void) {
}
g_free(hostspath);
+#ifdef WIN32
+ } /* endif(sysroot != NULL) */
+#endif
/* XXX - Any flags we should be using? */
/* XXX - We could provide config settings for DNS servers, and
pass them to ADNS with adns_init_strcfg */