Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
5967cc56
Commit
5967cc56
authored
Jan 17, 2000
by
Kurt Zeilenga
Browse files
Even more checks around use of crypt(3).
parent
c17b89f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
libraries/liblutil/passwd.c
View file @
5967cc56
...
...
@@ -715,6 +715,7 @@ static int chk_crypt(
const
struct
berval
*
passwd
,
const
struct
berval
*
cred
)
{
char
*
cr
;
int
i
;
for
(
i
=
0
;
i
<
cred
->
bv_len
;
i
++
)
{
...
...
@@ -727,6 +728,10 @@ static int chk_crypt(
return
1
;
/* cred must behave like a string */
}
if
(
passwd
->
bv_len
<
2
)
{
return
1
;
/* passwd must be at least two characters long */
}
for
(
i
=
0
;
i
<
passwd
->
bv_len
;
i
++
)
{
if
(
passwd
->
bv_val
[
i
]
==
'\0'
)
{
return
1
;
/* NUL character in password */
...
...
@@ -737,7 +742,14 @@ static int chk_crypt(
return
1
;
/* passwd must behave like a string */
}
return
strcmp
(
passwd
->
bv_val
,
crypt
(
cred
->
bv_val
,
passwd
->
bv_val
));
cr
=
crypt
(
cred
->
bv_val
,
passwd
->
bv_val
);
if
(
cr
==
NULL
||
cr
[
0
]
==
'\0'
)
{
/* salt must have been invalid */
return
1
;
}
return
strcmp
(
passwd
->
bv_val
,
cr
);
}
# if defined( HAVE_GETSPNAM ) \
...
...
@@ -792,11 +804,17 @@ static int chk_unix(
}
# endif
if
(
pw
==
NULL
||
*
pw
==
'\0'
)
return
1
;
if
(
pw
==
NULL
||
pw
[
0
]
==
'\0'
||
pw
[
1
]
==
'\0'
)
{
/* password must must be at least two characters long */
return
1
;
}
cr
=
crypt
(
cred
->
bv_val
,
pw
);
if
(
cr
==
NULL
||
*
cr
==
'\0'
)
return
1
;
if
(
cr
==
NULL
||
cr
[
0
]
==
'\0'
)
{
/* salt must have been invalid */
return
1
;
}
return
strcmp
(
pw
,
cr
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment