strdup -> xstrdup
authorChristos Zoulas <christos@zoulas.com>
Thu, 6 Oct 2011 14:48:32 +0000 (10:48 -0400)
committerChristos Zoulas <christos@zoulas.com>
Thu, 6 Oct 2011 14:48:32 +0000 (10:48 -0400)
hlfsd/hlfsd.c
hlfsd/homedir.c

index a39d67330658800a25d42668045e50f188f5e9d2..4cf4ae97f408e08c192eae5a44ccace481a6a75a 100644 (file)
@@ -310,7 +310,11 @@ main(int argc, char *argv[])
   }
 
   /* get hostname for logging and open log before we reset umask */
-  gethostname(hostname, sizeof(hostname));
+  if (gethostname(hostname, sizeof(hostname)) == -1) {
+    fprintf(stderr, "%s: gethostname failed \"%s\".\n",
+           am_get_progname(), strerror(errno));
+    exit(1);
+  }
   hostname[sizeof(hostname) - 1] = '\0';
   if ((dot = strchr(hostname, '.')) != NULL)
     *dot = '\0';
index 424707ad7f6935b7a233c34877c8b026868f5ce7..b817a0b6884be1472c619ab97da436ee8fc89cfc 100644 (file)
@@ -562,7 +562,7 @@ plt_init(void)
       int len;
       if (root_home)
        XFREE(root_home);
-      root_home = strdup(pent_p->pw_dir);
+      root_home = xstrdup(pent_p->pw_dir);
       len = strlen(root_home);
       /* remove any trailing '/' chars from root's home (even if just one) */
       while (len > 0 && root_home[len - 1] == '/') {
@@ -579,7 +579,7 @@ plt_init(void)
        unt_compare_fxn);
 
   if (!root_home)
-    root_home = strdup("");
+    root_home = xstrdup("");
 
   plog(XLOG_INFO, "password map read and sorted");
 }
@@ -674,14 +674,14 @@ table_add(u_int u, const char *h, const char *n)
     }
 
   /* add new password entry */
-  pwtab[cur_pwtab_num].home = strdup(h);
+  pwtab[cur_pwtab_num].home = xstrdup(h);
   pwtab[cur_pwtab_num].child = 0;
   pwtab[cur_pwtab_num].last_access_time = 0;
   pwtab[cur_pwtab_num].last_status = 0;        /* assume best: used homedir */
   pwtab[cur_pwtab_num].uid = u;
 
   /* add new userhome entry */
-  untab[cur_pwtab_num].username = strdup(n);
+  untab[cur_pwtab_num].username = xstrdup(n);
 
   /* just a second pointer */
   pwtab[cur_pwtab_num].uname = untab[cur_pwtab_num].username;