Changeset 8b6b740 for unix.c


Ignore:
Timestamp:
2010-03-11T11:15:36Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
547c94c, be609ff
Parents:
75ec2c8
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • unix.c

    r75ec2c8 r8b6b740  
    173173        unsigned char *pass_cr, *pass_cl;
    174174       
    175         if( argc < 3 )
     175        if( argc < 4 || ( strcmp( argv[2], "hash" ) != 0 &&
     176                          strcmp( argv[2], "unhash" ) != 0 && argc < 5 ) )
    176177        {
    177178                printf( "Supported:\n"
     
    214215        else if( strcmp( argv[2], "chkhash" ) == 0 )
    215216        {
    216                 int st = md5_verify_password( argv[4], argv[3] );
     217                char *hash = strncmp( argv[3], "md5:", 4 ) == 0 ? argv[3] + 4 : argv[3];
     218                int st = md5_verify_password( argv[4], hash );
    217219               
    218220                printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" );
Note: See TracChangeset for help on using the changeset viewer.