Skip to content

Commit bffcb4d

Browse files
carenasgitster
authored andcommitted
git-cvsserver: protect against NULL in crypt(3)
Some versions of crypt(3) will return NULL when passed an unsupported hash type (ex: OpenBSD with DES), so check for undef instead of using it directly. Also use this to probe the system and select a better hash function in the tests, so it can pass successfully. Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]> [jc: <CAPUEspjqD5zy8TLuFA96usU7FYi=0wF84y7NgOVFqegtxL9zbw@mail.gmail.com>] Signed-off-by: Junio C Hamano <[email protected]>
1 parent a7775c7 commit bffcb4d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

git-cvsserver.perl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@
222222
open my $passwd, "<", $authdb or die $!;
223223
while (<$passwd>) {
224224
if (m{^\Q$user\E:(.*)}) {
225-
if (crypt(descramble($password), $1) eq $1) {
225+
my $hash = crypt(descramble($password), $1);
226+
if (defined $hash and $hash eq $1) {
226227
$auth_ok = 1;
227228
}
228-
};
229+
}
229230
}
230231
close $passwd;
231232

t/t9400-git-cvsserver-server.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ CVSWORK="$PWD/cvswork"
3636
CVS_SERVER=git-cvsserver
3737
export CVSROOT CVS_SERVER
3838

39-
PWDHASH='lac2ItudM3.KM'
39+
if perl -e 'exit(1) if not defined crypt("", "cv")'
40+
then
41+
PWDHASH='lac2ItudM3.KM'
42+
else
43+
PWDHASH='$2b$10$t8fGvE/a9eLmfOLzsZme2uOa2QtoMYwIxq9wZA6aBKtF1Yb7FJIzi'
44+
fi
4045

4146
rm -rf "$CVSWORK" "$SERVERDIR"
4247
test_expect_success 'setup' '

0 commit comments

Comments
 (0)