summaryrefslogtreecommitdiff
path: root/git-cvsserver.perl
diff options
context:
space:
mode:
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>2021-09-15 08:09:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-17 03:47:23 (GMT)
commitbffcb4d9d6394a68a7f6c03598087705c6d34510 (patch)
treeb0f7c93d815ea351888dc6bf7c19a1cb2721ae28 /git-cvsserver.perl
parenta7775c7eb8074fcf37f22bdcdc0971448c1aa4d1 (diff)
downloadgit-bffcb4d9d6394a68a7f6c03598087705c6d34510.zip
git-bffcb4d9d6394a68a7f6c03598087705c6d34510.tar.gz
git-bffcb4d9d6394a68a7f6c03598087705c6d34510.tar.bz2
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 <carenas@gmail.com> [jc: <CAPUEspjqD5zy8TLuFA96usU7FYi=0wF84y7NgOVFqegtxL9zbw@mail.gmail.com>] Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-cvsserver.perl')
-rwxr-xr-xgit-cvsserver.perl5
1 files changed, 3 insertions, 2 deletions
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 4c93b5d..64319be 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -222,10 +222,11 @@ if ($state->{method} eq 'pserver') {
open my $passwd, "<", $authdb or die $!;
while (<$passwd>) {
if (m{^\Q$user\E:(.*)}) {
- if (crypt(descramble($password), $1) eq $1) {
+ my $hash = crypt(descramble($password), $1);
+ if (defined $hash and $hash eq $1) {
$auth_ok = 1;
}
- };
+ }
}
close $passwd;