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
This commit is contained in:
Lars Roland 2005-01-07 03:19:39 +00:00
parent ccf44f7fb1
commit 0a771e1c65
1 changed files with 7 additions and 3 deletions

View File

@ -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 */