Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • crypting.c

    r43e3368 r34759e6  
    4646} irc_t;
    4747
    48 #define set_add( a, b, c, d )
    49 #define set_find( a, b ) NULL
    50 
    5148#include "md5.h"
    5249#include "crypting.h"
     
    5552#include <stdlib.h>
    5653
    57 #define irc_usermsg
    58 
    5954#endif
    6055
     
    6560\*/
    6661
    67 /* USE WITH CAUTION!
    68    Sets pass without checking */
    69 void setpassnc (irc_t *irc, char *pass) {
    70         if (!set_find (irc, "password"))
    71                 set_add (irc, "password", NULL, passchange);
    72        
    73         if (irc->password) g_free (irc->password);
    74        
    75         if (pass) {
    76                 irc->password = g_strdup (pass);
    77                 irc_usermsg (irc, "Password successfully changed");
    78         } else {
    79                 irc->password = NULL;
    80         }
    81 }
    82 
    83 char *passchange (irc_t *irc, void *set, char *value) {
    84         setpassnc (irc, value);
    85         return (NULL);
    86 }
    87 
    88 int setpass (irc_t *irc, char *pass, char* md5sum) {
     62int checkpass (const char *pass, const char *md5sum)
     63{
    8964        md5_state_t md5state;
    9065        md5_byte_t digest[16];
     
    10378                if (digits[1] != md5sum[j + 1]) return (-1);
    10479        }
    105        
    106         /* If pass is correct, we end up here and we set the pass */
    107         setpassnc (irc, pass);
    108        
    109         return (0);
    110 }
     80
     81        return( 0 );
     82}
     83
    11184
    11285char *hashpass (irc_t *irc) {
     
    135108}
    136109
    137 char *obfucrypt (irc_t *irc, char *line) {
     110char *obfucrypt (irc_t *irc, char *line)
     111{
    138112        int i, j;
    139113        char *rv;
     
    141115        if (irc->password == NULL) return (NULL);
    142116       
    143         rv = (char *)g_malloc (strlen (line) + 1);
    144         memset (rv, '\0', strlen (line) + 1);
     117        rv = g_new0(char, strlen (line) + 1);
    145118       
    146119        i = j = 0;
     
    160133}
    161134
    162 char *deobfucrypt (irc_t *irc, char *line) {
     135char *deobfucrypt (irc_t *irc, char *line)
     136{
    163137        int i, j;
    164138        char *rv;
     
    166140        if (irc->password == NULL) return (NULL);
    167141       
    168         rv = (char *)g_malloc (strlen (line) + 1);
    169         memset (rv, '\0', strlen (line) + 1);
     142        rv = g_new0(char, strlen (line) + 1);
    170143       
    171144        i = j = 0;
     
    189162int main( int argc, char *argv[] )
    190163{
    191         irc_t *irc = g_malloc( sizeof( irc_t ) );
     164        irc_t *irc = g_new0( irc_t, 1 );
    192165        char *hash, *action, line[256];
    193166        char* (*func)( irc_t *, char * );
     
    201174        }
    202175       
    203         memset( irc, 0, sizeof( irc_t ) );
    204176        irc->password = g_strdup( argv[1] );
    205177       
Note: See TracChangeset for help on using the changeset viewer.