aboutsummaryrefslogtreecommitdiffstats
path: root/unix.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-03-11 11:15:36 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2010-03-11 11:15:36 +0000
commit8b6b7405d3844271f7bff56e527bfeb1a4872975 (patch)
tree56a1eb9eb88e02abf706740811cfbcc5a694a837 /unix.c
parent75ec2c8398afde059e3a2403ca8907229d3720de (diff)
Document the new -x flag in one useful location and make it a bit better at
argument checking to avoid ugly (even though harmless) segfaults. Also skip any md5: prefix that may be present when checking hashes.
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/unix.c b/unix.c
index 00bea6c8..7088d0f8 100644
--- a/unix.c
+++ b/unix.c
@@ -172,7 +172,8 @@ static int crypt_main( int argc, char *argv[] )
int pass_len;
unsigned char *pass_cr, *pass_cl;
- if( argc < 3 )
+ if( argc < 4 || ( strcmp( argv[2], "hash" ) != 0 &&
+ strcmp( argv[2], "unhash" ) != 0 && argc < 5 ) )
{
printf( "Supported:\n"
" %s -x enc <key> <cleartext password>\n"
@@ -213,7 +214,8 @@ static int crypt_main( int argc, char *argv[] )
}
else if( strcmp( argv[2], "chkhash" ) == 0 )
{
- int st = md5_verify_password( argv[4], argv[3] );
+ char *hash = strncmp( argv[3], "md5:", 4 ) == 0 ? argv[3] + 4 : argv[3];
+ int st = md5_verify_password( argv[4], hash );
printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" );