From 34211cbde959d55fb8e6b818365341d0193e7253 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 19:33:25 +0000 Subject: In case of rename validate the length of the new name Check early that the new name fits MAXLOGNAME and store it in pwconf --- pw/pw_group.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pw/pw_group.c') diff --git a/pw/pw_group.c b/pw/pw_group.c index b06b59e..f95d263 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -51,7 +51,6 @@ int pw_group(int mode, char *name, long id, struct cargs * args) { int rc; - struct carg *a_newname = getarg(args, 'l'); struct carg *arg; struct group *grp = NULL; int grmembers = 0; @@ -133,8 +132,8 @@ pw_group(int mode, char *name, long id, struct cargs * args) if (id > 0) grp->gr_gid = (gid_t) id; - if (a_newname != NULL) - grp->gr_name = pw_checkname(a_newname->val, 0); + if (conf.newname != NULL) + grp->gr_name = pw_checkname(conf.newname, 0); } else { if (name == NULL) /* Required */ errx(EX_DATAERR, "group name required"); @@ -262,8 +261,8 @@ pw_group(int mode, char *name, long id, struct cargs * args) err(EX_IOERR, "group update"); } - if (a_newname != NULL) - name = a_newname->val; + if (conf.newname != NULL) + name = conf.newname; /* grp may have been invalidated */ if ((grp = GETGRNAM(name)) == NULL) errx(EX_SOFTWARE, "group disappeared during update"); -- cgit v1.2.3