* lib/commonio.c: Avoid PATH_MAX. On glibc, we can use realpath
with a NULL argument. * src/useradd.c: Replace PATH_MAX by a fixed constant. The buffer was not meant as a storage for a path. * src/useradd.c, src/newusers.c, src/chpasswd.c: Better detection of fgets errors. Lines shall end with a \n, unless we reached the end of file. * libmisc/copydir.c: Avoid PATH_MAX. Support file paths with any length. Added readlink_malloc().
This commit is contained in:
@@ -434,11 +434,13 @@ int main (int argc, char **argv)
|
||||
if (NULL != cp) {
|
||||
*cp = '\0';
|
||||
} else {
|
||||
fprintf (stderr,
|
||||
_("%s: line %d: line too long\n"),
|
||||
Prog, line);
|
||||
errors++;
|
||||
continue;
|
||||
if (feof (stdin) == 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: line %d: line too long\n"),
|
||||
Prog, line);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -863,10 +863,13 @@ int main (int argc, char **argv)
|
||||
if (NULL != cp) {
|
||||
*cp = '\0';
|
||||
} else {
|
||||
fprintf (stderr, _("%s: line %d: line too long\n"),
|
||||
Prog, line);
|
||||
errors++;
|
||||
continue;
|
||||
if (feof (stdin) == 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: line %d: line too long\n"),
|
||||
Prog, line);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -421,7 +421,7 @@ static int set_defaults (void)
|
||||
{
|
||||
FILE *ifp;
|
||||
FILE *ofp;
|
||||
char buf[PATH_MAX];
|
||||
char buf[1024];
|
||||
static char new_file[] = NEW_USER_FILE;
|
||||
char *cp;
|
||||
int ofd;
|
||||
@@ -468,6 +468,16 @@ static int set_defaults (void)
|
||||
cp = strrchr (buf, '\n');
|
||||
if (NULL != cp) {
|
||||
*cp = '\0';
|
||||
} else {
|
||||
/* A line which does not end with \n is only valid
|
||||
* at the end of the file.
|
||||
*/
|
||||
if (feof (ifp) == 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: line too long in %s: %s..."),
|
||||
Prog, def_file, buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!out_group && MATCH (buf, DGROUP)) {
|
||||
|
Reference in New Issue
Block a user