Imported Upstream version 1.8.7
[debian/sudo] / compat / pw_dup.c
index ec5659982caa65f0808fc432547bb3ed531abeef..6f9312ef7910b1c84d6dcdd2cddd6d4f0ed4b7dd 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2000, 2002, 2012 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2000, 2002, 2012-2013
+ *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -20,6 +21,8 @@
 
 #include <config.h>
 
+#ifndef HAVE_PW_DUP
+
 #include <sys/types.h>
 
 #include <stdio.h>
@@ -62,12 +65,12 @@ do {                                                        \
 struct passwd *
 pw_dup(const struct passwd *pw)
 {
-       char            *cp;
-       size_t           nsize, psize, gsize, dsize, ssize, total;
+       size_t nsize = 0, psize = 0, gsize = 0, dsize = 0, ssize = 0, total;
 #ifdef HAVE_LOGIN_CAP_H
-       size_t           csize;
+       size_t csize;
 #endif
-       struct passwd   *newpw;
+       struct passwd *newpw;
+       char *cp;
 
        /* Allocate in one big chunk for easy freeing */
        total = sizeof(struct passwd);
@@ -81,7 +84,7 @@ pw_dup(const struct passwd *pw)
        PW_SIZE(pw_shell, ssize);
 
        if ((cp = malloc(total)) == NULL)
-               return (NULL);
+               return NULL;
        newpw = (struct passwd *)cp;
 
        /*
@@ -102,3 +105,4 @@ pw_dup(const struct passwd *pw)
 
        return newpw;
 }
+#endif /* HAVE_PW_DUP */