Changeset d28f3b35 for storage_xml.c


Ignore:
Timestamp:
2006-06-18T23:07:28Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d028a77
Parents:
10efa91
Message:

Now saving the password's md5sum instead of the plaintext version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r10efa91 rd28f3b35  
    2626#define BITLBEE_CORE
    2727#include "bitlbee.h"
     28#include "md5.h"
    2829
    2930typedef enum
     
    8182                                     "Missing attributes for %s element", element_name );
    8283                }
    83                 else if( strcmp( nick, xd->given_nick ) == 0 &&
    84                          strcmp( pass, xd->given_pass ) == 0 )
    85                 {
    86                         if( xd->pass_st != XML_PASS_CHECK_ONLY )
    87                                 xd->pass_st = XML_PASS_OK;
    88                 }
    8984                else
    9085                {
    91                         g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
    92                                      XML_PASS_ERRORMSG );
     86                        md5_byte_t pass_md5[16];
     87                        md5_state_t md5_state;
     88                        int pass_match, i, j;
     89                       
     90                        md5_init( &md5_state );
     91                        md5_append( &md5_state, xd->given_pass, strlen( xd->given_pass ) );
     92                        md5_finish( &md5_state, pass_md5 );
     93                       
     94                        for( i = 0; i < 16 && pass[i*2] && pass[i*2+1]; i ++ )
     95                        {
     96                                sscanf( pass + i * 2, "%2x", &j );
     97                                if( j != pass_md5[i] )
     98                                        break;
     99                        }
     100                        /* If we reached the end of the loop, it was a match! */
     101                        pass_match = i == 16;
     102                       
     103                        if( strcmp( nick, xd->given_nick ) == 0 && pass_match )
     104                        {
     105                                if( xd->pass_st != XML_PASS_CHECK_ONLY )
     106                                        xd->pass_st = XML_PASS_OK;
     107                        }
     108                        else
     109                        {
     110                                g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
     111                                             XML_PASS_ERRORMSG );
     112                        }
    93113                }
    94114        }
Note: See TracChangeset for help on using the changeset viewer.