2 * Copyright (c) 1990 - 1994, Julianne Frances Haugh
3 * Copyright (c) 1996 - 2000, Marek Michałkiewicz
4 * Copyright (c) 2001 , Michał Moskal
5 * Copyright (c) 2003 - 2005, Tomasz Kłoczko
6 * Copyright (c) 2007 - 2009, Nicolas François
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the copyright holders or contributors may not be used to
18 * endorse or promote products derived from this software without
19 * specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ident "$Id: pwmem.c 2777 2009-04-23 17:43:27Z nekral-guest $"
40 #include "prototypes.h"
43 /*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent)
47 pw = (struct passwd *) malloc (sizeof *pw);
52 pw->pw_name = strdup (pwent->pw_name);
53 if (NULL == pw->pw_name) {
56 pw->pw_passwd = strdup (pwent->pw_passwd);
57 if (NULL == pw->pw_passwd) {
60 pw->pw_gecos = strdup (pwent->pw_gecos);
61 if (NULL == pw->pw_gecos) {
64 pw->pw_dir = strdup (pwent->pw_dir);
65 if (NULL == pw->pw_dir) {
68 pw->pw_shell = strdup (pwent->pw_shell);
69 if (NULL == pw->pw_shell) {
76 void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
78 free (pwent->pw_name);
79 memzero (pwent->pw_passwd, strlen (pwent->pw_passwd));
80 free (pwent->pw_passwd);
81 free (pwent->pw_gecos);
83 free (pwent->pw_shell);