Changeset 3538bc8


Ignore:
Timestamp:
Feb 11, 2009, 12:20:22 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
823671c
Parents:
99b50a5
git-author:
Sam Hartman <hartmans@mit.edu> (02/10/09 17:57:06)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/11/09 12:20:22)
Message:
zwrite.c: toline should not use sprintf

The construction of toline uses sprintf without bounds checking.
Use dynamic allocation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zwrite.c

    r44a61ac r3538bc8  
    222222{
    223223  int i, j;
    224   char toline[LINE];
     224  char *toline = NULL;
    225225  char *tmp = NULL;
    226226
     
    229229  j=owl_list_get_size(&(z->recips));
    230230  if (j>0 && z->cc) {
    231     strcpy(toline, "CC: ");
     231    toline = owl_strdup( "CC: ");
    232232    for (i=0; i<j; i++) {
     233      tmp = toline;
    233234      if (strcmp(z->realm, "")) {
    234         sprintf(toline + strlen(toline), "%s@%s ", (char *) owl_list_get_element(&(z->recips), i), z->realm);
     235        toline = owl_sprintf( "%s%s@%s ", toline, (char *) owl_list_get_element(&(z->recips), i), z->realm);
    235236      } else {
    236         sprintf(toline + strlen(toline), "%s ", (char *) owl_list_get_element(&(z->recips), i));
    237       }
     237        toline = owl_sprintf( "%s%s ", toline, (char *) owl_list_get_element(&(z->recips), i));
     238      }
     239      owl_free(tmp);
     240      tmp = NULL;
    238241    }
    239242    tmp = owl_get_iso_8859_1_if_possible(msg);
    240243    z->message=owl_sprintf("%s\n%s", toline, tmp);
     244    owl_free(toline);
    241245  } else {
    242246    z->message=owl_get_iso_8859_1_if_possible(msg);
Note: See TracChangeset for help on using the changeset viewer.