Changes in / [e488ec5:f93cc34]
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
aim.c
rc5873be r5e5f08f 7 7 8 8 struct owlfaim_priv { 9 char *aimbinarypath; 9 10 char *screenname; 10 11 char *password; … … 64 65 /* static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs); */ 65 66 static int faimtest_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...); 67 static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname); 68 static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...); 66 69 /* static void printuserflags(fu16_t flags); */ 67 70 static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...); … … 514 517 va_end(ap); 515 518 519 owl_function_debugmsg("faimtest_parse_login: %s %s %s", priv->screenname, priv->password, key); 520 516 521 aim_send_login(sess, fr->conn, priv->screenname, priv->password, &info, key); 517 522 … … 630 635 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0); 631 636 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, faimtest_locrights, 0); 637 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, faimtest_memrequest, 0); 632 638 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0); 633 639 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0); … … 945 951 946 952 /* 953 * This is a little more complicated than it looks. The module 954 * name (proto, boscore, etc) may or may not be given. If it is 955 * not given, then use aim.exe. If it is given, put ".ocm" on the 956 * end of it. 957 * 958 * Now, if the offset or length requested would cause a read past 959 * the end of the file, then the request is considered invalid. Invalid 960 * requests are processed specially. The value hashed is the 961 * the request, put into little-endian (eight bytes: offset followed 962 * by length). 963 * 964 * Additionally, if the request is valid, the length is mod 4096. It is 965 * important that the length is checked for validity first before doing 966 * the mod. 967 * 968 * Note to Bosco's Brigade: if you'd like to break this, put the 969 * module name on an invalid request. 970 * 971 */ 972 static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname) 973 { 974 struct owlfaim_priv *priv = sess->aux_data; 975 FILE *f; 976 static const char defaultmod[] = "aim.exe"; 977 char *filename = NULL; 978 struct stat st; 979 unsigned char *buf; 980 int invalid = 0; 981 982 if (!bufret || !buflenret) 983 return -1; 984 985 if (modname) { 986 filename = owl_sprintf("%s/%s.ocm", priv->aimbinarypath, modname); 987 } else { 988 filename = owl_sprintf("%s/%s", priv->aimbinarypath, defaultmod); 989 } 990 991 if (stat(filename, &st) == -1) { 992 if (!modname) { 993 /* perror("memrequest: stat"); */ 994 owl_free(filename); 995 return -1; 996 } 997 invalid = 1; 998 } 999 1000 if (!invalid) { 1001 if ((offset > st.st_size) || (len > st.st_size)) 1002 invalid = 1; 1003 else if ((st.st_size - offset) < len) 1004 len = st.st_size - offset; 1005 else if ((st.st_size - len) < len) 1006 len = st.st_size - len; 1007 } 1008 1009 if (!invalid && len) { 1010 len %= 4096; 1011 } 1012 1013 if (invalid) { 1014 int i; 1015 1016 owl_free(filename); /* not needed */ 1017 owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname); 1018 i = 8; 1019 if (modname) { 1020 i+=strlen(modname); 1021 } 1022 1023 if (!(buf = owl_malloc(i))) { 1024 return -1; 1025 } 1026 1027 i=0; 1028 1029 if (modname) { 1030 memcpy(buf, modname, strlen(modname)); 1031 i+=strlen(modname); 1032 } 1033 1034 /* Damn endianness. This must be little (LSB first) endian. */ 1035 buf[i++] = offset & 0xff; 1036 buf[i++] = (offset >> 8) & 0xff; 1037 buf[i++] = (offset >> 16) & 0xff; 1038 buf[i++] = (offset >> 24) & 0xff; 1039 buf[i++] = len & 0xff; 1040 buf[i++] = (len >> 8) & 0xff; 1041 buf[i++] = (len >> 16) & 0xff; 1042 buf[i++] = (len >> 24) & 0xff; 1043 1044 *bufret = buf; 1045 *buflenret = i; 1046 } else { 1047 if (!(buf = owl_malloc(len))) { 1048 owl_free(filename); 1049 return -1; 1050 } 1051 /* printf("memrequest: loading %ld bytes from 0x%08lx in \"%s\"...\n", len, offset, filename); */ 1052 if (!(f = fopen(filename, "r"))) { 1053 /* perror("memrequest: fopen"); */ 1054 owl_free(filename); 1055 owl_free(buf); 1056 return -1; 1057 } 1058 1059 owl_free(filename); 1060 1061 if (fseek(f, offset, SEEK_SET) == -1) { 1062 /* perror("memrequest: fseek"); */ 1063 fclose(f); 1064 owl_free(buf); 1065 return -1; 1066 } 1067 1068 if (fread(buf, len, 1, f) != 1) { 1069 /* perror("memrequest: fread"); */ 1070 fclose(f); 1071 owl_free(buf); 1072 return -1; 1073 } 1074 1075 fclose(f); 1076 *bufret = buf; 1077 *buflenret = len; 1078 } 1079 return 0; /* success! */ 1080 } 1081 1082 /* 1083 * This will get an offset and a length. The client should read this 1084 * data out of whatever AIM.EXE binary the user has provided (hopefully 1085 * it matches the client information thats sent at login) and pass a 1086 * buffer back to libfaim so it can hash the data and send it to AOL for 1087 * inspection by the client police. 1088 */ 1089 static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) 1090 { 1091 struct owlfaim_priv *priv = sess->aux_data; 1092 va_list ap; 1093 fu32_t offset, len; 1094 const char *modname; 1095 unsigned char *buf; 1096 int buflen; 1097 1098 va_start(ap, fr); 1099 offset = va_arg(ap, fu32_t); 1100 len = va_arg(ap, fu32_t); 1101 modname = va_arg(ap, const char *); 1102 va_end(ap); 1103 1104 if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) { 1105 aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 1106 owl_free(buf); 1107 } else { 1108 owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname); 1109 aim_sendmemblock(sess, fr->conn, offset, len, NULL, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 1110 } 1111 return 1; 1112 } 1113 1114 /* 947 1115 static void printuserflags(fu16_t flags) 948 1116 { -
functions.c
rd12a8c7 r8bba1ae 1177 1177 return; 1178 1178 1179 file = owl_global_get_debug_file_handle(&g);1179 file = fopen(owl_global_get_debug_file(&g), "a"); 1180 1180 if (!file) /* XXX should report this */ 1181 1181 return; … … 1187 1187 vfprintf(file, fmt, ap); 1188 1188 putc('\n', file); 1189 f flush(file);1189 fclose(file); 1190 1190 1191 1191 va_end(ap); -
global.c
r26ad412 r8bba1ae 983 983 filters[i].desc)); 984 984 } 985 986 FILE *owl_global_get_debug_file_handle(owl_global *g) {987 static char *open_file = NULL;988 const char *filename = owl_global_get_debug_file(g);989 if (g->debug_file == NULL ||990 (open_file && strcmp(filename, open_file) != 0)) {991 char *path;992 int fd;993 994 if (g->debug_file)995 fclose(g->debug_file);996 997 g->debug_file = NULL;998 999 path = owl_sprintf("%s.%d", filename, getpid());1000 fd = open(path, O_CREAT|O_WRONLY|O_EXCL, 0600);1001 owl_free(path);1002 1003 if (fd >= 0)1004 g->debug_file = fdopen(fd, "a");1005 1006 owl_free(open_file);1007 open_file = owl_strdup(filename);1008 }1009 return g->debug_file;1010 } -
owl.c
r205e164 r205e164 457 457 g.load_initial_subs = opts.load_initial_subs; 458 458 459 owl_function_debugmsg("startup: Finished parsing arguments"); 460 459 461 owl_register_signal_handlers(); 460 462 owl_start_curses(); -
owl.h
r26ad412 r987cf3f 76 76 77 77 #define OWL_DEBUG 0 78 #define OWL_DEBUG_FILE "/var/tmp/ barnowl-debug"78 #define OWL_DEBUG_FILE "/var/tmp/owldebug" 79 79 80 80 #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ … … 643 643 int load_initial_subs; 644 644 volatile sig_atomic_t interrupted; 645 FILE *debug_file;646 645 } owl_global; 647 646 -
variable.c
r26ad412 rf6fae8d 186 186 OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE, 187 187 "path for logging debug messages when debugging is enabled", 188 "This file will be logged to if 'debug' is set to 'on'.\n" 189 "BarnOwl will append a dot and the current process's pid to the filename."), 188 "This file will be logged to if 'debug' is set to 'on'.\n"), 190 189 191 190 OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL, -
zephyr.c
r8ab1f28 r987cf3f 179 179 { 180 180 #ifdef HAVE_LIBZEPHYR 181 Code_t code; 182 if(owl_global_is_havezephyr(&g)) { 183 if((code = ZPending()) < 0) { 184 owl_function_debugmsg("Error (%s) in ZPending()\n", 185 error_message(code)); 186 return 0; 187 } 188 return code; 189 } 181 if(owl_global_is_havezephyr(&g)) 182 return(ZPending()); 190 183 #endif 191 184 return 0; … … 1404 1397 #ifdef HAVE_LIBZEPHYR 1405 1398 ZNotice_t notice; 1406 Code_t code;1407 1399 owl_message *m=NULL; 1408 1400 1409 1401 while(owl_zephyr_zpending() && zpendcount < OWL_MAX_ZEPHYRGRAMS_TO_PROCESS) { 1410 1402 if (owl_zephyr_zpending()) { 1411 if ((code = ZReceiveNotice(¬ice, NULL)) != ZERR_NONE) { 1412 owl_function_debugmsg("Error: %s while calling ZReceiveNotice\n", 1413 error_message(code)); 1414 continue; 1415 } 1403 ZReceiveNotice(¬ice, NULL); 1416 1404 zpendcount++; 1417 1405
Note: See TracChangeset
for help on using the changeset viewer.