Changeset dab82f29 for zephyr.c


Ignore:
Timestamp:
Mar 28, 2009, 5:00:34 PM (15 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
owl
Children:
4de643d
Parents:
5189631
Message:
Don't crash on mobile device AIM messages [BZ 20]
Don't crash when sending to someone not on AIM buddy list [BZ 94]
Fix overflow vulerability in zwrite.c and zcrypt.c
Add stack protector and -D_FORTIFY_SOURCE=2 where possible
Fix hang [barnowl 4c46dfdebc294ca24fef59924f01688b8ee07dee]
Fix segfault on missing subs [barnowl 99dabeed7de6d19acb50f1e73aa0bfe5f9469c02]
Fix zcrypt bufffer size bug [barnowl 559076cd86edc3a8317819814dd5877b8bc7c3cb]
Fix double free [barnowl e97c4a306ae2c9d2147d83da29fee59918198e70]
Memory leak fix [barnowl c0a90c2c7ab97b9465c9873757faf312faa0021e]
Memory leak fix [barnowl 95caa16b2e9ba10770d87d0955198c14c2d0e16a]
Memory leak fix [barnowl 1716fed8c2650e46892cf6571555eac937266c6e]
Add getstyle command [barnowl 216c73421653e3ef0e957aa9a9804e208a77c80e]
Binary search for msgid [barnowl 0c8ab5eadbb6ecc97a120c91b9a824b33538c764]
File-handle leak [barnowl e78397d6ac5da0de31a4e269c0ba7f3d691857a3]
Fix delay in jump from top to bottom [barnowl 801b7ac63b962640debbcfd422cb9a60da5fea31]
Load subs in chunks [barnowl 93e883d60051b80bf6d35391f9d76fd7dfd198e3]
Load subs in chunks [barnowl f6050ee9b0a171a5031f84409eb181062afacd18]
Better zsig logging [barnowl d857b667a5a9b108b1a2a26b4a5513bef2b53f80]
free() -> owlfree() [barnowl d524c838ac7c115628424b8ac171c3489622ea3a]
Escape AIM users in smartfilters [barnowl af9b92e3e7ccb7de276a94b5c7e5861b24e71eff]
Better regex escape chars [barnowl 80e54a7631f091be8c9762adb9746bad38104738]
Deal with quotes in smart filters [barnowl 4099cf83702763fa8d1efc4f1582a605431bdb77]
Deal with 0 length zephyr fields [barnowl 128171aaf7cefa91a4bb1eada93a19d8fd0c355c]
Deal with 0 length zephyr fields [barnowl 50e29e35c64d64e223d378d350a7bc4f038d78f5]
Deal with 0 length zephyr fields [barnowl 804ab8af8b6d00bcd7e2402df892db8fbd61a3ec]
Leave curmsg on screen after resize [barnowl c0f9e3009bc03e80a44de64cd5f2b4033290236e]
Rip out brower stuff [barnowl 8e5935d11c699a7ce5a3e6e9a47799564c696d6a]
Rip out browser stuff [barnowl 4f15e8e9ceada0d4b2cc969ebf43b0a1fb3709ea]
No passwords in command history [barnowl 6e400cc71aa59e041dce677aadf50dc1f25228e2]
Format NOC mssages [barnowl a1bb1980e4bca23b8329cc0e7c0bd5027055ea0a]
Expand ~ in loadsubs [barnowl 27d8d835dc6d58c08fae10e75aae306c49215143]
Expand ~ in source [barnowl 10d67d57cb29221f63a43a30643c697fc7b38911]
Only use resizeterm() if it's available
Debian backports
Change license to GPLv3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r180cd15 rdab82f29  
    6666#endif
    6767}
     68
     69#ifdef HAVE_LIBZEPHYR
     70int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
     71{
     72  int i, ret = 0;
     73  /* sub without defaults */
     74  if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
     75    owl_function_error("Error subscribing to zephyr notifications.");
     76    ret=-2;
     77  }
     78
     79  /* free stuff */
     80  for (i=0; i<count; i++) {
     81    owl_free(subs[i].zsub_class);
     82    owl_free(subs[i].zsub_classinst);
     83    owl_free(subs[i].zsub_recipient);
     84  }
     85  return ret;
     86}
     87#endif
    6888
    6989/* Load zephyr subscriptions form 'filename'.  If 'filename' is NULL,
     
    82102  char buffer[1024], subsfile[1024];
    83103  ZSubscription_t subs[3001];
    84   int count, ret, i;
     104  int count, ret;
    85105  struct stat statbuff;
    86106
     
    98118
    99119  ZResetAuthentication();
    100   /* need to redo this to do chunks, not just bail after 3000 */
    101120  count=0;
    102121  file=fopen(subsfile, "r");
     
    111130    }
    112131   
    113     if (count >= 3000) break; /* also tell the user */
     132    if (count >= 3000) {
     133      ret = owl_zephyr_loadsubs_helper(subs, count);
     134      if (ret != 0) {
     135        fclose(file);
     136        return(ret);
     137      }
     138      count=0;
     139    }
    114140   
    115141    /* add it to the list of subs */
     
    130156  fclose(file);
    131157
    132   /* sub without defaults */
    133   ret=0;
    134   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    135     owl_function_error("Error subscribing to zephyr notifications.");
    136     ret=-2;
    137   }
    138 
    139   /* free stuff */
    140   for (i=0; i<count; i++) {
    141     owl_free(subs[i].zsub_class);
    142     owl_free(subs[i].zsub_classinst);
    143     owl_free(subs[i].zsub_recipient);
    144   }
     158  ret=owl_zephyr_loadsubs_helper(subs, count);
    145159
    146160  return(ret);
     
    291305  int i, count, save;
    292306  char *out;
     307
     308  /* If there's no message here, just run along now */
     309  if (n->z_message_len == 0)
     310    return(owl_strdup(""));
    293311
    294312  count=save=0;
     
    327345  int i, fields;
    328346
     347  if(n->z_message_len == 0)
     348    return 0;
     349
    329350  fields=1;
    330351  for (i=0; i<n->z_message_len; i++) {
     
    355376  if (!strcasecmp(n->z_sender, "olc.matisse@ATHENA.MIT.EDU")) {
    356377    return(owl_zephyr_get_field(n, 1));
     378  }
     379  /* deal with MIT NOC messages */
     380  else if (!strcasecmp(n->z_sender, "rcmd.achilles@ATHENA.MIT.EDU")) {
     381    /* $opcode service on $instance $3.\n$4 */
     382    char *msg, *opcode, *instance, *field3, *field4;
     383
     384    opcode = n->z_opcode;
     385    instance = n->z_class_inst;
     386    field3 = owl_zephyr_get_field(n, 3);
     387    field4 = owl_zephyr_get_field(n, 4);
     388
     389    msg = owl_sprintf("%s service on %s %s\n%s", opcode, instance, field3, field4);
     390    if (msg) {
     391      return msg;
     392    }
    357393  }
    358394
     
    629665        owl_function_error("Subscription already present in %s", subsfile);
    630666        owl_free(line);
     667        fclose(file);
    631668        return;
    632669      }
    633670    }
     671    fclose(file);
    634672  }
    635673
    636674  /* if we get here then we didn't find it */
    637   fclose(file);
    638675  file=fopen(subsfile, "a");
    639676  if (!file) {
     
    9691006#endif
    9701007}
     1008
     1009
     1010#ifdef HAVE_LIBZEPHYR
     1011void owl_zephyr_process_events(owl_dispatch *d) {
     1012  int zpendcount=0;
     1013  ZNotice_t notice;
     1014  struct sockaddr_in from;
     1015  owl_message *m=NULL;
     1016
     1017  while(owl_zephyr_zpending() && zpendcount < 20) {
     1018    if (owl_zephyr_zpending()) {
     1019      ZReceiveNotice(&notice, &from);
     1020      zpendcount++;
     1021
     1022      /* is this an ack from a zephyr we sent? */
     1023      if (owl_zephyr_notice_is_ack(&notice)) {
     1024        owl_zephyr_handle_ack(&notice);
     1025        continue;
     1026      }
     1027
     1028      /* if it's a ping and we're not viewing pings then skip it */
     1029      if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) {
     1030        continue;
     1031      }
     1032
     1033      /* create the new message */
     1034      m=owl_malloc(sizeof(owl_message));
     1035      owl_message_create_from_znotice(m, &notice);
     1036
     1037      owl_global_messagequeue_addmsg(&g, m);
     1038    }
     1039  }
     1040}
     1041
     1042#else
     1043void owl_zephyr_process_events(owl_dispatch *d) {
     1044 
     1045}
     1046#endif
Note: See TracChangeset for help on using the changeset viewer.