mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 14:03:17 +00:00
src/passwd.c: inconsistent password length limit
The passwd utility had hardcoded limit for password lenght set
to 200 characters. In the agetpass.c is used PASS_MAX for
this purpose.
This patch moves the PASS_MAX definition to common place
and uses it in both places.
Signed-off-by: Tomas Halman <tomas@halman.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f024002b3d66 ("src/passwd.c: inconsistent password length limit")
Cc: Serge Hallyn <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/953>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
c4eae35466
commit
bed23cc34d
@ -9,7 +9,6 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <readpassphrase.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -23,11 +22,6 @@
|
||||
#endif /* WITH_LIBBSD */
|
||||
|
||||
|
||||
#if !defined(PASS_MAX)
|
||||
#define PASS_MAX BUFSIZ - 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* SYNOPSIS
|
||||
* [[gnu::malloc(erase_pass)]]
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -240,4 +241,14 @@ static inline void memzero(void *ptr, size_t size)
|
||||
# define shadow_getenv(name) getenv(name)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum password length
|
||||
*
|
||||
* Consider that there is also limit in PAM (PAM_MAX_RESP_SIZE)
|
||||
* currently set to 512.
|
||||
*/
|
||||
#if !defined(PASS_MAX)
|
||||
#define PASS_MAX BUFSIZ - 1
|
||||
#endif
|
||||
|
||||
#endif /* _DEFINES_H_ */
|
||||
|
||||
@ -192,8 +192,8 @@ static int new_password (const struct passwd *pw)
|
||||
char *cipher; /* Pointer to cipher text */
|
||||
const char *salt; /* Pointer to new salt */
|
||||
char *cp; /* Pointer to agetpass() response */
|
||||
char orig[200]; /* Original password */
|
||||
char pass[200]; /* New password */
|
||||
char orig[PASS_MAX + 1]; /* Original password */
|
||||
char pass[PASS_MAX + 1]; /* New password */
|
||||
int i; /* Counter for retries */
|
||||
bool warned;
|
||||
int pass_max_len = -1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user