Changeset e50cd56


Ignore:
Timestamp:
Jul 11, 2002, 12:47:16 AM (19 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
aa2f33b3
Parents:
e173507
Message:
Fixed some buffer overruns in the "reply" command.
When repying to "all" on a message that begins with "CC:" (eg, sent
         with "zwrite -C", the reply line will be constructed
         from the sender and the usernames on the CC: line
         of the message being replied to.
There is no such thing as C-R, so left C-r as it is but added:
         M-r --- edit reply to all
         M-R --- edit reply to sender
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    re173507 re50cd56  
    5454                 sane on admin messages.
    5555        Added opera to the allowed options to the webbrowser variable.
     56        Fixed some buffer overruns in the "reply" command.
     57        When repying to "all" on a message that begins with "CC:" (eg, sent
     58                 with "zwrite -C", the reply line will be constructed
     59                 from the sender and the usernames on the CC: line
     60                 of the message being replied to.
     61        There is no such thing as C-R, so left C-r as it is but added:
     62                 M-r --- edit reply to all
     63                 M-R --- edit reply to sender
    5664       
    57651.2.1-pre-1
  • functions.c

    rae9e6be re50cd56  
    13551355   * if enter = 1 then don't wait for editing
    13561356   */
    1357   char buff[1024];
     1357  char *buff, *oldbuff;
    13581358  owl_message *m;
    13591359  owl_filter *f;
     
    13621362    owl_function_makemsg("No message selected");
    13631363  } else {
    1364     char *class, *inst, *to;
     1364    char *class, *inst, *to, *cc=NULL;
    13651365   
    13661366    m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
     
    13951395        inst=owl_message_get_instance(m);
    13961396        to=owl_message_get_recipient(m);
     1397        cc=owl_message_get_cc(m);
    13971398        if (!strcmp(to, "") || !strcmp(to, "*")) {
    13981399          to="";
     
    14051406     
    14061407      /* create the command line */
    1407       strcpy(buff, "zwrite");
     1408      buff = owl_strdup("zwrite");
    14081409      if (strcasecmp(class, "message")) {
    1409         sprintf(buff, "%s -c %s%s%s", buff, owl_getquoting(class), class, owl_getquoting(class));
     1410        buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
     1411        owl_free(oldbuff);
    14101412      }
    14111413      if (strcasecmp(inst, "personal")) {
    1412         sprintf(buff, "%s -i %s%s%s", buff, owl_getquoting(inst), inst, owl_getquoting(inst));
     1414        buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
     1415        owl_free(oldbuff);
    14131416      }
    14141417      if (*to != '\0') {
    1415         char *tmp;
     1418        char *tmp, *oldtmp;
    14161419        tmp=pretty_sender(to);
    1417         sprintf(buff, "%s %s", buff, tmp);
     1420        if (cc) {
     1421          tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
     1422          owl_free(oldtmp);
     1423          buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
     1424          owl_free(oldbuff);
     1425        } else {
     1426          tmp=pretty_sender(to);
     1427          buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
     1428          owl_free(oldbuff);
     1429        }
    14181430        owl_free(tmp);
    14191431      }
     1432      if (cc) owl_free(cc);
    14201433
    14211434      if (enter) {
     
    14271440        owl_function_start_command(buff);
    14281441      }
     1442      owl_free(buff);
    14291443    }
    14301444  }
  • keys.c

    r10b866d re50cd56  
    244244  BIND_CMD("R",   "reply sender",     "reply to sender of the current message");
    245245  BIND_CMD("C-r", "reply -e",         "reply to the current message, but allow editing of recipient");
    246   BIND_CMD("C-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
     246  BIND_CMD("M-r", "reply -e",         "reply to the current message, but allow editing of recipient");
     247  BIND_CMD("M-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
    247248                 
    248249  BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
  • message.c

    r1aee7d9 re50cd56  
    607607}
    608608
     609/* caller must free return value. */
     610char *owl_message_get_cc(owl_message *m) {
     611  char *cur, *out, *end;
     612
     613  cur = owl_message_get_body(m);
     614  while (*cur && *cur==' ') cur++;
     615  if (strncasecmp(cur, "cc:", 2)) return(NULL);
     616  cur+=3;
     617  while (*cur && *cur==' ') cur++;
     618  out = owl_strdup(cur);
     619  end = strchr(out, '\n');
     620  if (end) end[0] = '\0';
     621  return(out);
     622}
     623
    609624int owl_message_get_id(owl_message *m) {
    610625  return(m->id);
  • util.c

    re1c4636 re50cd56  
    298298  return(ret);
    299299}
     300
     301/* Caller must free response.
     302   Takes in strings which are space-separated lists of tokens
     303   and returns a single string containing no token more than once.
     304   If prohibit is non-null, no token may start with a character
     305   in prohibit.
     306*/
     307char *owl_util_uniq(char *A, char *B, char *prohibit) {
     308  char *cat, **tok;
     309  int toklen, i, j, first=1;
     310  cat = owl_malloc(strlen(A)+strlen(B)+3);
     311  strcpy(cat, A);
     312  strcat(cat, " ");
     313  strcat(cat, B);
     314  tok = atokenize(cat, " ", &toklen);
     315  strcpy(cat, "");
     316  for (i=0; i<toklen; i++) {
     317    int dup=0;
     318    for (j=0; j<i; j++) {
     319      if (!strcmp(tok[i], tok[j])) dup=1;
     320    }
     321    if (!dup && (!prohibit || !strchr(prohibit, tok[i][0]))) {
     322      if (!first) {
     323        strcat(cat, " ");
     324      }
     325      first=0;
     326      strcat(cat, tok[i]);
     327    }
     328  }
     329  atokenize_free(tok, toklen);
     330  return(cat);
     331}
     332
     333
    300334
    301335/* returns if a string is only whitespace */
     
    482516              !strcmp("meep", skiptokens("foo 'bar quux' meep", 2)));
    483517
     518  FAIL_UNLESS("owl_util_uniq 1",
     519              !strcmp("foo bar x", owl_util_uniq("foo", "bar x", "-")));
     520  FAIL_UNLESS("owl_util_uniq 2",
     521              !strcmp("foo bar x", owl_util_uniq("foo", "bar -y x", "-")));
     522  FAIL_UNLESS("owl_util_uniq 3",
     523              !strcmp("meep foo bar", owl_util_uniq("meep foo", "bar foo meep", "-")));
     524
    484525  if (numfailed) printf("*** WARNING: failures encountered with owl_util\n");
    485526  printf("END testing owl_util (%d failures)\n", numfailed);
Note: See TracChangeset for help on using the changeset viewer.