diff options
author | Lars Roland <Lars.Roland@gmx.net> | 2005-01-07 03:19:39 +0000 |
---|---|---|
committer | Lars Roland <Lars.Roland@gmx.net> | 2005-01-07 03:19:39 +0000 |
commit | 0a771e1c65f03c067bd49e2197a93cc088683499 (patch) | |
tree | 917e01d254dac6eeee78da7b97181a3999b2bf45 /epan/addr_resolv.c | |
parent | ccf44f7fb1b4c2c1a84cdbbae239beedc06ec9fd (diff) | |
download | wireshark-0a771e1c65f03c067bd49e2197a93cc088683499.tar.gz wireshark-0a771e1c65f03c067bd49e2197a93cc088683499.tar.bz2 wireshark-0a771e1c65f03c067bd49e2197a93cc088683499.zip |
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.c | 10 |
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 */ |