Changeset 987cf3f for commands.c


Ignore:
Timestamp:
Jul 4, 2010, 12:15:12 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
efc460e
Parents:
aeadc74
git-author:
Nelson Elhage <nelhage@mit.edu> (06/20/10 16:47:23)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/04/10 12:15:12)
Message:
Pass around owl_zwrite objects, instead of continually re-parsing them.

In addition to be cleaner and shorter, this fixes a bug where ': zcrypt' ended
in an unencrypted zwrite.

Reported-by: Tony Valderrama <tvald@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r89ce405 r987cf3f  
    136136              "Send a local message.\n"),
    137137
    138   OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
     138  OWLCMD_ARGS("zcrypt", owl_command_zwrite, OWL_CTX_INTERACTIVE,
    139139              "send an encrypted zephyr",
    140140              "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcode] [-m <message...>]\n",
     
    19141914char *owl_command_zwrite(int argc, const char *const *argv, const char *buff)
    19151915{
    1916   owl_zwrite z;
     1916  owl_zwrite *z;
    19171917
    19181918  if (!owl_global_is_havezephyr(&g)) {
     
    19211921  }
    19221922  /* check for a zwrite -m */
    1923   owl_zwrite_create_from_line(&z, buff);
    1924   if (owl_zwrite_is_message_set(&z)) {
    1925     owl_function_zwrite(buff, NULL);
    1926     owl_zwrite_cleanup(&z);
    1927     return (NULL);
    1928   }
    1929   owl_zwrite_cleanup(&z);
     1923  z = owl_zwrite_new(buff);
     1924  if (!z) {
     1925    owl_function_error("Error in zwrite arguments");
     1926    return NULL;
     1927  }
     1928
     1929  if (owl_zwrite_is_message_set(z)) {
     1930    owl_function_zwrite(z, NULL);
     1931    owl_zwrite_delete(z);
     1932    return NULL;
     1933  }
    19301934
    19311935  if (argc < 2) {
     1936    owl_zwrite_delete(z);
    19321937    owl_function_makemsg("Not enough arguments to the zwrite command.");
    19331938  } else {
    1934     owl_function_zwrite_setup(buff);
     1939    owl_function_zwrite_setup(z);
    19351940  }
    19361941  return(NULL);
     
    20192024{
    20202025  owl_function_loopwrite_setup();
    2021   return(NULL);
    2022 }
    2023 
    2024 char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff)
    2025 {
    2026   owl_zwrite z;
    2027 
    2028   if (!owl_global_is_havezephyr(&g)) {
    2029     owl_function_makemsg("Zephyr is not available");
    2030     return(NULL);
    2031   }
    2032   /* check for a zcrypt -m */
    2033   owl_zwrite_create_from_line(&z, buff);
    2034   if (owl_zwrite_is_message_set(&z)) {
    2035     owl_function_zcrypt(buff, NULL);
    2036     owl_zwrite_cleanup(&z);
    2037     return (NULL);
    2038   }
    2039   owl_zwrite_cleanup(&z);
    2040 
    2041   if (argc < 2) {
    2042     owl_function_makemsg("Not enough arguments to the zcrypt command.");
    2043   } else {
    2044     owl_function_zwrite_setup(buff);
    2045   }
    20462026  return(NULL);
    20472027}
Note: See TracChangeset for help on using the changeset viewer.