xfs_quota does not properly parse users or groups that begin with a number.
Only call atoi when user or group consists of digits only.
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
Reported-by: James Carter <james.carter@bytemark.co.uk>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Chandra Seetharaman <sekharan@us.ibm.com>
#include <grp.h>
#include <sys/types.h>
#include <xfs/project.h>
+#include <stdbool.h>
extern char **breakline(char *input, int *count);
extern void doneline(char *input, char **vec);
extern uid_t uid_from_string(char *user);
extern gid_t gid_from_string(char *group);
extern prid_t prid_from_string(char *project);
+extern bool isdigits_only(const char *str);
#define HAVE_FTW_H 1 /* TODO: configure me */
#include <xfs/xfs.h>
#include <xfs/input.h>
#include <ctype.h>
+#include <stdbool.h>
#if defined(ENABLE_READLINE)
# include <readline/history.h>
return -1;
}
+bool isdigits_only(
+ const char *str)
+{
+ int i;
+
+ for (i = 0; i < strlen(str); i++) {
+ if (!isdigit(str[i]))
+ return false;
+ }
+ return true;
+}
+
#define HAVE_FTW_H 1 /* TODO: configure me */
#ifndef HAVE_FTW_H
uid_t id;
if (name) {
- if (isdigit(name[0])) {
+ if (isdigits_only(name)) {
id = atoi(name);
name = getusername(id, flags & NO_LOOKUP_FLAG);
} else if ((u = getpwnam(name))) {
int i, ngroups, dofree = 0;
if (name) {
- if (isdigit(name[0])) {
+ if (isdigits_only(name)) {
gid = atoi(name);
name = getgroupname(gid, flags & NO_LOOKUP_FLAG);
} else {
return;
}
- if (isdigit(name[0])) {
+ if (isdigits_only(name)) {
id = atoi(name);
name = getprojectname(id, flags & NO_LOOKUP_FLAG);
} else if ((p = getprnam(name))) {
#include <xfs/xqm.h>
#include <xfs/path.h>
#include <xfs/project.h>
+#include <stdbool.h>
/*
* Different forms of XFS quota
extern char *uid_to_name(__uint32_t __uid);
extern char *gid_to_name(__uint32_t __gid);
extern char *prid_to_name(__uint32_t __prid);
+extern bool isdigits_only(const char *);