char *xmalloc ();
char *xrealloc ();
-static int change_dir_group __P ((char *dir, int group, struct stat *statp));
+static int change_dir_group __P ((const char *dir, int group,
+ const struct stat *statp));
/* The name the program was run with. */
char *program_name;
static int changes_only;
/* The name of the group to which ownership of the files is being given. */
-static char *groupname;
+static const char *groupname;
/* If nonzero, display usage information and exit. */
static int show_help;
has been given; if CHANGED is zero, FILE was that group already. */
static void
-describe_change (char *file, int changed)
+describe_change (const char *file, int changed)
{
if (changed)
printf (_("group of %s changed to %s\n"), file, groupname);
/* Set *G according to NAME. */
static void
-parse_group (char *name, int *g)
+parse_group (const char *name, int *g)
{
struct group *grp;
strtol_error s_err;
unsigned long int tmp_long;
+ if (!ISDIGIT (*name))
+ error (1, 0, _("invalid group name `%s'"), name);
+
s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
+ if (s_err != LONGINT_OK)
+ STRTOL_FATAL_ERROR (name, _("group number"), s_err);
+
+ if (tmp_long > INT_MAX)
+ error (1, 0, _("invalid group number `%s'"), name);
+
*g = tmp_long;
- if (s_err == LONGINT_OVERFLOW || tmp_long > INT_MAX)
- {
- STRTOL_FATAL_ERROR (name, _("group number"), s_err);
- }
}
else
*g = grp->gr_gid;
Return 0 if successful, 1 if errors occurred. */
static int
-change_file_group (char *file, int group)
+change_file_group (const char *file, int group)
{
struct stat file_stats;
int errors = 0;
Return 0 if successful, 1 if errors occurred. */
static int
-change_dir_group (char *dir, int group, struct stat *statp)
+change_dir_group (const char *dir, int group, const struct stat *statp)
{
char *name_space, *namep;
char *path; /* Full path of each entry to process. */