|
|
4fb1b2 |
diff -up shadow-4.5/lib/defines.h.long-entry shadow-4.5/lib/defines.h
|
|
|
4fb1b2 |
--- shadow-4.5/lib/defines.h.long-entry 2014-09-01 16:36:40.000000000 +0200
|
|
|
4fb1b2 |
+++ shadow-4.5/lib/defines.h 2018-04-20 11:53:07.419308212 +0200
|
|
|
4fb1b2 |
@@ -382,4 +382,7 @@ extern char *strerror ();
|
|
|
4fb1b2 |
# endif
|
|
|
4fb1b2 |
#endif
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
+/* Maximum length of passwd entry */
|
|
|
4fb1b2 |
+#define PASSWD_ENTRY_MAX_LENGTH 32768
|
|
|
4fb1b2 |
+
|
|
|
4fb1b2 |
#endif /* _DEFINES_H_ */
|
|
|
4fb1b2 |
diff -up shadow-4.5/lib/pwio.c.long-entry shadow-4.5/lib/pwio.c
|
|
|
4fb1b2 |
--- shadow-4.5/lib/pwio.c.long-entry 2015-11-17 17:45:15.000000000 +0100
|
|
|
4fb1b2 |
+++ shadow-4.5/lib/pwio.c 2018-04-20 12:10:24.400837235 +0200
|
|
|
4fb1b2 |
@@ -79,7 +79,10 @@ static int passwd_put (const void *ent,
|
|
|
4fb1b2 |
|| (pw->pw_gid == (gid_t)-1)
|
|
|
4fb1b2 |
|| (valid_field (pw->pw_gecos, ":\n") == -1)
|
|
|
4fb1b2 |
|| (valid_field (pw->pw_dir, ":\n") == -1)
|
|
|
4fb1b2 |
- || (valid_field (pw->pw_shell, ":\n") == -1)) {
|
|
|
4fb1b2 |
+ || (valid_field (pw->pw_shell, ":\n") == -1)
|
|
|
4fb1b2 |
+ || (strlen (pw->pw_name) + strlen (pw->pw_passwd) +
|
|
|
4fb1b2 |
+ strlen (pw->pw_gecos) + strlen (pw->pw_dir) +
|
|
|
4fb1b2 |
+ strlen (pw->pw_shell) + 100 > PASSWD_ENTRY_MAX_LENGTH)) {
|
|
|
4fb1b2 |
return -1;
|
|
|
4fb1b2 |
}
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
diff -up shadow-4.5/lib/sgetpwent.c.long-entry shadow-4.5/lib/sgetpwent.c
|
|
|
4fb1b2 |
--- shadow-4.5/lib/sgetpwent.c.long-entry 2014-09-01 16:36:40.000000000 +0200
|
|
|
4fb1b2 |
+++ shadow-4.5/lib/sgetpwent.c 2018-04-20 12:16:31.911513808 +0200
|
|
|
4fb1b2 |
@@ -57,7 +57,7 @@
|
|
|
4fb1b2 |
struct passwd *sgetpwent (const char *buf)
|
|
|
4fb1b2 |
{
|
|
|
4fb1b2 |
static struct passwd pwent;
|
|
|
4fb1b2 |
- static char pwdbuf[1024];
|
|
|
4fb1b2 |
+ static char pwdbuf[PASSWD_ENTRY_MAX_LENGTH];
|
|
|
4fb1b2 |
register int i;
|
|
|
4fb1b2 |
register char *cp;
|
|
|
4fb1b2 |
char *fields[NFIELDS];
|
|
|
4fb1b2 |
@@ -67,8 +67,10 @@ struct passwd *sgetpwent (const char *bu
|
|
|
4fb1b2 |
* the password structure remain valid.
|
|
|
4fb1b2 |
*/
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
- if (strlen (buf) >= sizeof pwdbuf)
|
|
|
4fb1b2 |
+ if (strlen (buf) >= sizeof pwdbuf) {
|
|
|
4fb1b2 |
+ fprintf (stderr, "Too long passwd entry encountered, file corruption?\n");
|
|
|
4fb1b2 |
return 0; /* fail if too long */
|
|
|
4fb1b2 |
+ }
|
|
|
4fb1b2 |
strcpy (pwdbuf, buf);
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
/*
|
|
|
4fb1b2 |
diff -up shadow-4.5/lib/sgetspent.c.long-entry shadow-4.5/lib/sgetspent.c
|
|
|
4fb1b2 |
--- shadow-4.5/lib/sgetspent.c.long-entry 2014-09-01 16:36:40.000000000 +0200
|
|
|
4fb1b2 |
+++ shadow-4.5/lib/sgetspent.c 2018-04-20 12:16:54.505056257 +0200
|
|
|
4fb1b2 |
@@ -48,7 +48,7 @@
|
|
|
4fb1b2 |
*/
|
|
|
4fb1b2 |
struct spwd *sgetspent (const char *string)
|
|
|
4fb1b2 |
{
|
|
|
4fb1b2 |
- static char spwbuf[1024];
|
|
|
4fb1b2 |
+ static char spwbuf[PASSWD_ENTRY_MAX_LENGTH];
|
|
|
4fb1b2 |
static struct spwd spwd;
|
|
|
4fb1b2 |
char *fields[FIELDS];
|
|
|
4fb1b2 |
char *cp;
|
|
|
4fb1b2 |
@@ -61,6 +61,7 @@ struct spwd *sgetspent (const char *stri
|
|
|
4fb1b2 |
*/
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
if (strlen (string) >= sizeof spwbuf) {
|
|
|
4fb1b2 |
+ fprintf (stderr, "Too long shadow entry encountered, file corruption?\n");
|
|
|
4fb1b2 |
return 0; /* fail if too long */
|
|
|
4fb1b2 |
}
|
|
|
4fb1b2 |
strcpy (spwbuf, string);
|
|
|
4fb1b2 |
diff -up shadow-4.5/lib/shadowio.c.long-entry shadow-4.5/lib/shadowio.c
|
|
|
4fb1b2 |
--- shadow-4.5/lib/shadowio.c.long-entry 2016-12-07 06:30:41.000000001 +0100
|
|
|
4fb1b2 |
+++ shadow-4.5/lib/shadowio.c 2018-04-20 12:12:03.292171667 +0200
|
|
|
4fb1b2 |
@@ -79,7 +79,9 @@ static int shadow_put (const void *ent,
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
if ( (NULL == sp)
|
|
|
4fb1b2 |
|| (valid_field (sp->sp_namp, ":\n") == -1)
|
|
|
4fb1b2 |
- || (valid_field (sp->sp_pwdp, ":\n") == -1)) {
|
|
|
4fb1b2 |
+ || (valid_field (sp->sp_pwdp, ":\n") == -1)
|
|
|
4fb1b2 |
+ || (strlen (sp->sp_namp) + strlen (sp->sp_pwdp) +
|
|
|
4fb1b2 |
+ 1000 > PASSWD_ENTRY_MAX_LENGTH)) {
|
|
|
4fb1b2 |
return -1;
|
|
|
4fb1b2 |
}
|
|
|
4fb1b2 |
|