[BACK]Return to telnet.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Diff for /src/usr.bin/telnet/telnet.c between version 1.29 and 1.30

version 1.29, 2014/07/22 07:30:24 version 1.30, 2014/09/09 03:41:08
Line 68 
Line 68 
 static void     slc(unsigned char *, int);  static void     slc(unsigned char *, int);
 static int      slc_update(void);  static int      slc_update(void);
   
 static void     env_opt(unsigned char *, int);  static void     env_opt(char *, int);
 static void     env_opt_start(void);  static void     env_opt_start(void);
   
 char    options[256];           /* The combined options */  char    options[256];           /* The combined options */
Line 155 
Line 155 
     env_init();      env_init();
   
     SB_CLEAR();      SB_CLEAR();
     memset((char *)options, 0, sizeof options);      memset(options, 0, sizeof options);
   
     connected = ISend = localflow = donebinarytoggle = 0;      connected = ISend = localflow = donebinarytoggle = 0;
     restartany = -1;      restartany = -1;
Line 382 
Line 382 
                 break;                  break;
   
             case TELOPT_XDISPLOC:       /* X Display location */              case TELOPT_XDISPLOC:       /* X Display location */
                 if (env_getvalue((unsigned char *)"DISPLAY", 0))                  if (env_getvalue("DISPLAY", 0))
                     new_state_ok = 1;                      new_state_ok = 1;
                 break;                  break;
   
Line 474 
Line 474 
         char c, *cp, **argvp, *cp2, **argv, **avt;          char c, *cp, **argvp, *cp2, **argv, **avt;
   
         if (name) {          if (name) {
                 if ((int)strlen(name) > 40) {                  if (strlen(name) > 40) {
                         name = NULL;                          name = NULL;
                         unknown[0] = name_unknown;                          unknown[0] = name_unknown;
                 } else {                  } else {
Line 493 
Line 493 
         /*          /*
          * Allocate an array to put the name pointers into           * Allocate an array to put the name pointers into
          */           */
         argv = (char **)malloc((n+3)*sizeof(char *));          argv = reallocarray(NULL, n+3, sizeof(char *));
         if (argv == NULL)          if (argv == NULL)
                 return(unknown);                  return(unknown);
   
Line 605 
Line 605 
                 resettermname = 0;                  resettermname = 0;
                 if (tnamep && tnamep != unknown)                  if (tnamep && tnamep != unknown)
                         free(tnamep);                          free(tnamep);
                 if ((tname = (char *)env_getvalue((unsigned char *)"TERM", 0)) &&                  if ((tname = env_getvalue("TERM", 0)) &&
                                 (setupterm(tname, 1, &errret) == OK)) {                      (setupterm(tname, 1, &errret) == OK)) {
                         tnamep = mklist(ttytype, tname);                          tnamep = mklist(ttytype, tname);
                 } else {                  } else {
                         if (tname && ((int)strlen(tname) <= 40)) {                          if (tname && (strlen(tname) <= 40)) {
                                 unknown[0] = tname;                                  unknown[0] = tname;
                                 upcase(tname);                                  upcase(tname);
                         } else                          } else
Line 773 
Line 773 
             unsigned char temp[50], *dp;              unsigned char temp[50], *dp;
             int len;              int len;
   
             if ((dp = env_getvalue((unsigned char *)"DISPLAY", 0)) == NULL) {              if ((dp = env_getvalue("DISPLAY", 0)) == NULL) {
                 /*                  /*
                  * Something happened, we no longer have a DISPLAY                   * Something happened, we no longer have a DISPLAY
                  * variable.  So, turn off the option.                   * variable.  So, turn off the option.
Line 1206 
Line 1206 
 }  }
   
 static void  static void
 env_opt(unsigned char *buf, int len)  env_opt(char *buf, int len)
 {  {
         unsigned char *ep = 0, *epc = 0;          char *ep = 0, *epc = 0;
         int i;          int i;
   
         switch(buf[0]&0xff) {          switch(buf[0]&0xff) {
Line 1270 
Line 1270 
 {  {
         unsigned char *p;          unsigned char *p;
   
         p = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE);          p = realloc(opt_reply, OPT_REPLY_SIZE);
         if (p == NULL)          if (p == NULL)
                 free(opt_reply);                  free(opt_reply);
         opt_reply = p;          opt_reply = p;
Line 1296 
Line 1296 
 }  }
   
 void  void
 env_opt_add(unsigned char *ep)  env_opt_add(char *ep)
 {  {
         unsigned char *vp, c;          char *vp, c;
   
         if (opt_reply == NULL)          /*XXX*/          if (opt_reply == NULL)          /*XXX*/
                 return;                 /*XXX*/                  return;                 /*XXX*/
Line 1316 
Line 1316 
                 return;                  return;
         }          }
         vp = env_getvalue(ep, 1);          vp = env_getvalue(ep, 1);
         if (opt_replyp + 2 * (vp ? strlen((char *)vp) : 0) +          if (2 * (vp ? strlen(vp) : 0) + 2 * strlen(ep) + 6 >
                                 2 * strlen((char *)ep) + 6 > opt_replyend)              opt_replyend - opt_replyp)
         {          {
                 size_t len;                  size_t len;
                 unsigned char *p;                  unsigned char *p;
Line 1326 
Line 1326 
                 len += OPT_REPLY_SIZE + 2 * strlen(ep);                  len += OPT_REPLY_SIZE + 2 * strlen(ep);
                 if (vp)                  if (vp)
                         len += 2 * strlen(vp);                          len += 2 * strlen(vp);
                 p = (unsigned char *)realloc(opt_reply, len);                  p = realloc(opt_reply, len);
                 if (p == NULL) {                  if (p == NULL) {
                         free(opt_reply);                          free(opt_reply);
 /*@*/                   printf("env_opt_add: realloc() failed!!!\n");  /*@*/                   printf("env_opt_add: realloc() failed!!!\n");
Line 1337 
Line 1337 
                 opt_replyend = p + len;                  opt_replyend = p + len;
                 opt_reply = p;                  opt_reply = p;
         }          }
         if (opt_welldefined((char *)ep))          if (opt_welldefined(ep))
                         opt_add(NEW_ENV_VAR);                  opt_add(NEW_ENV_VAR);
         else          else
                 opt_add(ENV_USERVAR);                  opt_add(ENV_USERVAR);
   
Line 1366 
Line 1366 
 }  }
   
 int  int
 opt_welldefined(char *ep)  opt_welldefined(const char *ep)
 {  {
         if ((strcmp(ep, "USER") == 0) ||          if ((strcmp(ep, "USER") == 0) ||
             (strcmp(ep, "DISPLAY") == 0) ||              (strcmp(ep, "DISPLAY") == 0) ||
Line 1848 
Line 1848 
         send_will(TELOPT_LINEMODE, 1);          send_will(TELOPT_LINEMODE, 1);
         send_will(TELOPT_NEW_ENVIRON, 1);          send_will(TELOPT_NEW_ENVIRON, 1);
         send_do(TELOPT_STATUS, 1);          send_do(TELOPT_STATUS, 1);
         if (env_getvalue((unsigned char *)"DISPLAY", 0))          if (env_getvalue("DISPLAY", 0))
             send_will(TELOPT_XDISPLOC, 1);              send_will(TELOPT_XDISPLOC, 1);
         if (binary)          if (binary)
             tel_enter_binary(binary);              tel_enter_binary(binary);

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30