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