Changeset e01449c


Ignore:
Timestamp:
Mar 29, 2009, 4:59:32 PM (12 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
owl
Children:
765fa34
Parents:
61f7250
Message:
fix some sprintfs in zephyr.c
make zlocate allocate and caller frees
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r488ebf6 re01449c  
    20952095{
    20962096  owl_fmtext fm;
    2097   char *ptr, buff[LINE];
     2097  char *ptr, *buff;
    20982098  int i;
    20992099
     
    21022102  for (i=0; i<argc; i++) {
    21032103    ptr=long_zuser(argv[i]);
    2104     owl_zephyr_zlocate(ptr, buff, auth);
     2104    buff=owl_zephyr_zlocate(ptr, auth);
    21052105    owl_fmtext_append_normal(&fm, buff);
    21062106    owl_free(ptr);
     2107    owl_free(buff);
    21072108  }
    21082109
  • zephyr.c

    rdab82f29 re01449c  
    487487void owl_zephyr_handle_ack(ZNotice_t *retnotice)
    488488{
    489   char *tmp;
     489  char *tmp, *buff;
    490490 
    491491  /* if it's an HMACK ignore it */
     
    509509  } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) {
    510510    if (strcasecmp(retnotice->z_class, "message")) {
    511       char buff[1024];
    512511      owl_function_error("No one subscribed to class class %s", retnotice->z_class);
    513       sprintf(buff, "Could not send message to class %s: no one subscribed.\n", retnotice->z_class);
     512      buff=owl_sprintf("Could not send message to class %s: no one subscribed.\n",
     513                       retnotice->z_class);
    514514      owl_function_adminmsg("", buff);
     515      owl_free(buff);
    515516    } else {
    516       char buff[1024];
    517517      tmp = short_zuser(retnotice->z_recipient);
    518518      owl_function_error("%s: Not logged in or subscribing to messages.", tmp);
    519       sprintf(buff, "Could not send message to %s: not logged in or subscribing to messages.\n", tmp);
     519      buff=owl_sprintf("Could not send message to %s: not logged in or subscribing to messages.\n",
     520                       tmp);
    520521      owl_function_adminmsg("", buff);
    521522      owl_log_outgoing_zephyr_error(tmp, buff);
    522523      owl_free(tmp);
     524      owl_free(buff);
    523525    }
    524526  } else {
     
    609611#endif
    610612
    611 void owl_zephyr_zlocate(char *user, char *out, int auth)
     613char *owl_zephyr_zlocate(char *user, int auth)
    612614{
    613615#ifdef HAVE_LIBZEPHYR
     
    615617  int one = 1;
    616618  ZLocations_t locations;
    617   char *myuser;
    618  
    619   strcpy(out, "");
     619  char *myuser, *out, *tmp;
     620 
    620621  ZResetAuthentication();
    621622  ret=ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH);
    622623  if (ret != ZERR_NONE) {
    623     sprintf(out, "Error locating user %s\n", user);
    624     return;
     624    return(owl_sprintf("Error locating user %s\n", user));
    625625  }
    626626
    627627  if (numlocs==0) {
    628628    myuser=short_zuser(user);
    629     sprintf(out, "%s: Hidden or not logged-in\n", myuser);
     629    out=owl_sprintf("%s: Hidden or not logged in\n", myuser);
    630630    owl_free(myuser);
    631     return;
    632   }
    633    
     631    return(out);
     632  }
     633
     634  out=strdup("");
    634635  for (;numlocs;numlocs--) {
    635636    ZGetLocations(&locations,&one);
    636637    myuser=short_zuser(user);
    637     sprintf(out, "%s%s: %s\t%s\t%s\n", out, myuser,
    638             locations.host ? locations.host : "?",
    639             locations.tty ? locations.tty : "?",
    640             locations.time ? locations.time : "?");
     638    tmp=owl_sprintf("%s%s: %s\t%s\t%s\n",
     639                    out,
     640                    myuser,
     641                    locations.host ? locations.host : "?",
     642                    locations.tty ? locations.tty : "?",
     643                    locations.time ? locations.time : "?");
     644    owl_free(out);
     645    out=tmp;
    641646    owl_free(myuser);
    642647  }
     648  return(out);
    643649#endif
    644650}
Note: See TracChangeset for help on using the changeset viewer.