From 0bd396011ae7122222175e6dae02fdb1c5a51fe2 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Mon, 22 Dec 2008 22:13:23 +0000 Subject: [PATCH] * src/gpasswd.c: Fix the support for usernames with arbitrary length. --- ChangeLog | 5 +++++ src/gpasswd.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4afdc7c7..9383a67a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-12-22 Nicolas François + + * src/gpasswd.c: Fix the support for usernames with arbitrary + length. + 2008-12-22 Nicolas François * src/groupadd.c, src/groupdel.c, src/groupmod.c: Re-indent. diff --git a/src/gpasswd.c b/src/gpasswd.c index 926e41dc..d1b68468 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -211,14 +211,16 @@ static void fail_exit (int status) */ static bool is_valid_user_list (const char *users) { - const char *username, *end; + char *username, *end; bool is_valid = true; + char *tmpusers = xstrdup (users); - for (username = users; + for (username = tmpusers; (NULL != username) && ('\0' != *username); username = end) { end = strchr (username, ','); if (NULL != end) { + *end = '\0'; end++; } @@ -233,6 +235,9 @@ static bool is_valid_user_list (const char *users) is_valid = false; } } + + free (tmpusers); + return is_valid; } -- 2.40.0