Changes in crypting.c [43e3368:34759e6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
crypting.c
r43e3368 r34759e6 46 46 } irc_t; 47 47 48 #define set_add( a, b, c, d )49 #define set_find( a, b ) NULL50 51 48 #include "md5.h" 52 49 #include "crypting.h" … … 55 52 #include <stdlib.h> 56 53 57 #define irc_usermsg58 59 54 #endif 60 55 … … 65 60 \*/ 66 61 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) { 62 int checkpass (const char *pass, const char *md5sum) 63 { 89 64 md5_state_t md5state; 90 65 md5_byte_t digest[16]; … … 103 78 if (digits[1] != md5sum[j + 1]) return (-1); 104 79 } 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 111 84 112 85 char *hashpass (irc_t *irc) { … … 135 108 } 136 109 137 char *obfucrypt (irc_t *irc, char *line) { 110 char *obfucrypt (irc_t *irc, char *line) 111 { 138 112 int i, j; 139 113 char *rv; … … 141 115 if (irc->password == NULL) return (NULL); 142 116 143 rv = (char *)g_malloc (strlen (line) + 1); 144 memset (rv, '\0', strlen (line) + 1); 117 rv = g_new0(char, strlen (line) + 1); 145 118 146 119 i = j = 0; … … 160 133 } 161 134 162 char *deobfucrypt (irc_t *irc, char *line) { 135 char *deobfucrypt (irc_t *irc, char *line) 136 { 163 137 int i, j; 164 138 char *rv; … … 166 140 if (irc->password == NULL) return (NULL); 167 141 168 rv = (char *)g_malloc (strlen (line) + 1); 169 memset (rv, '\0', strlen (line) + 1); 142 rv = g_new0(char, strlen (line) + 1); 170 143 171 144 i = j = 0; … … 189 162 int main( int argc, char *argv[] ) 190 163 { 191 irc_t *irc = g_ malloc( sizeof( irc_t ));164 irc_t *irc = g_new0( irc_t, 1 ); 192 165 char *hash, *action, line[256]; 193 166 char* (*func)( irc_t *, char * ); … … 201 174 } 202 175 203 memset( irc, 0, sizeof( irc_t ) );204 176 irc->password = g_strdup( argv[1] ); 205 177
Note: See TracChangeset
for help on using the changeset viewer.