diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-11 11:15:36 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-11 11:15:36 +0000 |
commit | 8b6b7405d3844271f7bff56e527bfeb1a4872975 (patch) | |
tree | 56a1eb9eb88e02abf706740811cfbcc5a694a837 /unix.c | |
parent | 75ec2c8398afde059e3a2403ca8907229d3720de (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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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" ); |