[PATCH 02/13] newgrp: use xstrdup to check allocation succeeded

Sami Kerola
2013-04-02T19:43:08Z

login-utils/newgrp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c
index 6269547..55dad1b 100644
--- a/login-utils/newgrp.c
+++ b/login-utils/newgrp.c
@@ -32,6 +32,7 @@
#include "closestream.h"
#include "nls.h"
#include "pathnames.h"
+#include "xalloc.h"

/* try to read password from gshadow */
static char *get_gshadow_pwd(char *groupname)
@@ -67,7 +68,7 @@ static char *get_gshadow_pwd(char *groupname)
}
}
fclose(f);
- return pwd ? strdup(pwd) : NULL;
+ return pwd ? xstrdup(pwd) : NULL;
}

static int allow_setgid(struct passwd *pe, struct group *ge)
--
1.8.2