87 lines
3.1 KiB
Diff
87 lines
3.1 KiB
Diff
diff -up shadow-4.12.3/lib/defines.h.long-entry shadow-4.12.3/lib/defines.h
|
|
--- shadow-4.12.3/lib/defines.h.long-entry 2022-08-18 23:51:37.000000000 +0200
|
|
+++ shadow-4.12.3/lib/defines.h 2022-08-22 16:12:27.412522768 +0200
|
|
@@ -335,6 +335,9 @@ extern char *strerror ();
|
|
# endif
|
|
#endif
|
|
|
|
+/* Maximum length of passwd entry */
|
|
+#define PASSWD_ENTRY_MAX_LENGTH 32768
|
|
+
|
|
#ifdef HAVE_SECURE_GETENV
|
|
# define shadow_getenv(name) secure_getenv(name)
|
|
# else
|
|
diff -up shadow-4.12.3/lib/pwio.c.long-entry shadow-4.12.3/lib/pwio.c
|
|
--- shadow-4.12.3/lib/pwio.c.long-entry 2022-06-19 16:16:48.000000000 +0200
|
|
+++ shadow-4.12.3/lib/pwio.c 2022-08-22 16:12:27.412522768 +0200
|
|
@@ -56,7 +56,10 @@ static int passwd_put (const void *ent,
|
|
|| (pw->pw_gid == (gid_t)-1)
|
|
|| (valid_field (pw->pw_gecos, ":\n") == -1)
|
|
|| (valid_field (pw->pw_dir, ":\n") == -1)
|
|
- || (valid_field (pw->pw_shell, ":\n") == -1)) {
|
|
+ || (valid_field (pw->pw_shell, ":\n") == -1)
|
|
+ || (strlen (pw->pw_name) + strlen (pw->pw_passwd) +
|
|
+ strlen (pw->pw_gecos) + strlen (pw->pw_dir) +
|
|
+ strlen (pw->pw_shell) + 100 > PASSWD_ENTRY_MAX_LENGTH)) {
|
|
return -1;
|
|
}
|
|
|
|
diff -up shadow-4.12.3/lib/sgetpwent.c.long-entry shadow-4.12.3/lib/sgetpwent.c
|
|
--- shadow-4.12.3/lib/sgetpwent.c.long-entry 2022-08-09 00:30:40.000000000 +0200
|
|
+++ shadow-4.12.3/lib/sgetpwent.c 2022-08-22 16:14:10.955309200 +0200
|
|
@@ -34,7 +34,7 @@
|
|
struct passwd *sgetpwent (const char *buf)
|
|
{
|
|
static struct passwd pwent;
|
|
- static char pwdbuf[1024];
|
|
+ static char pwdbuf[PASSWD_ENTRY_MAX_LENGTH];
|
|
int i;
|
|
char *cp;
|
|
char *fields[NFIELDS];
|
|
@@ -44,8 +44,10 @@ struct passwd *sgetpwent (const char *bu
|
|
* the password structure remain valid.
|
|
*/
|
|
|
|
- if (strlen (buf) >= sizeof pwdbuf)
|
|
+ if (strlen (buf) >= sizeof pwdbuf) {
|
|
+ fprintf (stderr, "Too long passwd entry encountered, file corruption?\n");
|
|
return 0; /* fail if too long */
|
|
+ }
|
|
strcpy (pwdbuf, buf);
|
|
|
|
/*
|
|
diff -up shadow-4.12.3/lib/sgetspent.c.long-entry shadow-4.12.3/lib/sgetspent.c
|
|
--- shadow-4.12.3/lib/sgetspent.c.long-entry 2022-06-19 16:16:54.000000000 +0200
|
|
+++ shadow-4.12.3/lib/sgetspent.c 2022-08-22 16:12:27.413522776 +0200
|
|
@@ -25,7 +25,7 @@
|
|
*/
|
|
struct spwd *sgetspent (const char *string)
|
|
{
|
|
- static char spwbuf[1024];
|
|
+ static char spwbuf[PASSWD_ENTRY_MAX_LENGTH];
|
|
static struct spwd spwd;
|
|
char *fields[FIELDS];
|
|
char *cp;
|
|
@@ -37,6 +37,7 @@ struct spwd *sgetspent (const char *stri
|
|
*/
|
|
|
|
if (strlen (string) >= sizeof spwbuf) {
|
|
+ fprintf (stderr, "Too long shadow entry encountered, file corruption?\n");
|
|
return 0; /* fail if too long */
|
|
}
|
|
strcpy (spwbuf, string);
|
|
diff -up shadow-4.12.3/lib/shadowio.c.long-entry shadow-4.12.3/lib/shadowio.c
|
|
--- shadow-4.12.3/lib/shadowio.c.long-entry 2022-06-19 16:16:48.000000000 +0200
|
|
+++ shadow-4.12.3/lib/shadowio.c 2022-08-22 16:12:27.413522776 +0200
|
|
@@ -56,7 +56,9 @@ static int shadow_put (const void *ent,
|
|
|
|
if ( (NULL == sp)
|
|
|| (valid_field (sp->sp_namp, ":\n") == -1)
|
|
- || (valid_field (sp->sp_pwdp, ":\n") == -1)) {
|
|
+ || (valid_field (sp->sp_pwdp, ":\n") == -1)
|
|
+ || (strlen (sp->sp_namp) + strlen (sp->sp_pwdp) +
|
|
+ 1000 > PASSWD_ENTRY_MAX_LENGTH)) {
|
|
return -1;
|
|
}
|
|
|