Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/ssh.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6821 by doda, Mon Jun 26 10:38:04 2017 UTC revision 6824 by doda, Mon Jun 26 10:38:37 2017 UTC
# Line 349  static Channel_t *ssh2_channel_lookup(in Line 349  static Channel_t *ssh2_channel_lookup(in
349          Channel_t *c;          Channel_t *c;
350    
351          if (id < 0 || id >= CHANNEL_MAX) {          if (id < 0 || id >= CHANNEL_MAX) {
352                    logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": invalid channel id. (%d)", id);
353                  return (NULL);                  return (NULL);
354          }          }
355          c = &channels[id];          c = &channels[id];
356          if (c->used == 0) { // already freed          if (c->used == 0) { // already freed
357                    logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": channel was already freed. id:%d", id);
358                  return (NULL);                  return (NULL);
359          }          }
360          return (c);          return (c);
# Line 1068  void finish_send_packet_special(PTInstVa Line 1070  void finish_send_packet_special(PTInstVa
1070                          msg = buffer_init();                          msg = buffer_init();
1071                          if (msg == NULL) {                          if (msg == NULL) {
1072                                  // TODO: error check                                  // TODO: error check
1073                                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
1074                                  return;                                  return;
1075                          }                          }
1076    
# Line 2075  void SSH2_dispatch_add_message(unsigned Line 2078  void SSH2_dispatch_add_message(unsigned
2078    
2079          if (handle_message_count >= HANDLE_MESSAGE_MAX) {          if (handle_message_count >= HANDLE_MESSAGE_MAX) {
2080                  // TODO: error check                  // TODO: error check
2081                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": too many handlers. handlers:%d, max:%d",
2082                            handle_message_count, HANDLE_MESSAGE_MAX);
2083                  return;                  return;
2084          }          }
2085    
# Line 2766  void SSH_notify_disconnecting(PTInstVar Line 2771  void SSH_notify_disconnecting(PTInstVar
2771                  msg = buffer_init();                  msg = buffer_init();
2772                  if (msg == NULL) {                  if (msg == NULL) {
2773                          // TODO: error check                          // TODO: error check
2774                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
2775                          return;                          return;
2776                  }                  }
2777                  buffer_put_int(msg, SSH2_DISCONNECT_BY_APPLICATION);                  buffer_put_int(msg, SSH2_DISCONNECT_BY_APPLICATION);
# Line 2840  void SSH_notify_win_size(PTInstVar pvar, Line 2846  void SSH_notify_win_size(PTInstVar pvar,
2846                  Channel_t *c;                  Channel_t *c;
2847    
2848                  c = ssh2_channel_lookup(pvar->shell_id);                  c = ssh2_channel_lookup(pvar->shell_id);
2849                  if (c == NULL)                  if (c == NULL) {
2850                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
2851                          return;                          return;
2852                    }
2853    
2854    
2855                  msg = buffer_init();                  msg = buffer_init();
2856                  if (msg == NULL) {                  if (msg == NULL) {
2857                          // TODO: error check                          // TODO: error check
2858                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
2859                          return;                          return;
2860                  }                  }
2861                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 2885  int SSH_notify_break_signal(PTInstVar pv Line 2895  int SSH_notify_break_signal(PTInstVar pv
2895                  Channel_t *c;                  Channel_t *c;
2896    
2897                  c = ssh2_channel_lookup(pvar->shell_id);                  c = ssh2_channel_lookup(pvar->shell_id);
2898                  if (c == NULL)                  if (c == NULL) {
2899                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
2900                          goto error;                          goto error;
2901                    }
2902    
2903                  msg = buffer_init();                  msg = buffer_init();
2904                  if (msg == NULL) {                  if (msg == NULL) {
2905                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
2906                          goto error;                          goto error;
2907                  }                  }
2908                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 3015  void SSH_send(PTInstVar pvar, unsigned c Line 3028  void SSH_send(PTInstVar pvar, unsigned c
3028    
3029          } else { // for SSH2(yutaka)          } else { // for SSH2(yutaka)
3030                  Channel_t *c = ssh2_channel_lookup(pvar->shell_id);                  Channel_t *c = ssh2_channel_lookup(pvar->shell_id);
3031                  SSH2_send_channel_data(pvar, c, (unsigned char *)buf, buflen, 0);                  if (c == NULL) {
3032                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
3033                    }
3034                    else {
3035                            SSH2_send_channel_data(pvar, c, (unsigned char *)buf, buflen, 0);
3036                    }
3037          }          }
3038    
3039  }  }
# Line 3270  void SSH2_send_channel_data(PTInstVar pv Line 3288  void SSH2_send_channel_data(PTInstVar pv
3288          if (pvar->rekeying) {          if (pvar->rekeying) {
3289                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、
3290                  // 将来直すことにする。                  // 将来直すことにする。
3291                    logputs(LOG_LEVEL_INFO, __FUNCTION__ ": now rekeying. data is not sent.");
3292    
3293                  c = NULL;                  c = NULL;
3294    
3295                  return;                  return;
# Line 3298  void SSH2_send_channel_data(PTInstVar pv Line 3318  void SSH2_send_channel_data(PTInstVar pv
3318                  msg = buffer_init();                  msg = buffer_init();
3319                  if (msg == NULL) {                  if (msg == NULL) {
3320                          // TODO: error check                          // TODO: error check
3321                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3322                          return;                          return;
3323                  }                  }
3324                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 3309  void SSH2_send_channel_data(PTInstVar pv Line 3330  void SSH2_send_channel_data(PTInstVar pv
3330                  memcpy(outmsg, buffer_ptr(msg), len);                  memcpy(outmsg, buffer_ptr(msg), len);
3331                  finish_send_packet(pvar);                  finish_send_packet(pvar);
3332                  buffer_free(msg);                  buffer_free(msg);
                 //debug_print(1, pvar->ssh_state.outbuf, 7 + 4 + 1 + 1 + len);  
3333    
3334                  logprintf(LOG_LEVEL_SSHDUMP, "SSH2_MSG_CHANNEL_DATA was sent at SSH2_send_channel_data(). local:%d remote:%d", c->self_id, c->remote_id);                  logprintf(LOG_LEVEL_SSHDUMP, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_DATA. "
3335                            "local:%d remote:%d len:%d", c->self_id, c->remote_id, buflen);
3336    
3337                  // remote window sizeの調整                  // remote window sizeの調整
3338                  if (buflen <= c->remote_window) {                  if (buflen <= c->remote_window) {
# Line 3396  void SSH_fail_channel_open(PTInstVar pva Line 3417  void SSH_fail_channel_open(PTInstVar pva
3417                  msg = buffer_init();                  msg = buffer_init();
3418                  if (msg == NULL) {                  if (msg == NULL) {
3419                          // TODO: error check                          // TODO: error check
3420                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3421                          return;                          return;
3422                  }                  }
3423                  buffer_put_int(msg, remote_channel_num);                  buffer_put_int(msg, remote_channel_num);
# Line 3425  void SSH2_confirm_channel_open(PTInstVar Line 3447  void SSH2_confirm_channel_open(PTInstVar
3447          msg = buffer_init();          msg = buffer_init();
3448          if (msg == NULL) {          if (msg == NULL) {
3449                  // TODO: error check                  // TODO: error check
3450                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3451                  return;                  return;
3452          }          }
3453          buffer_put_int(msg, c->remote_id);          buffer_put_int(msg, c->remote_id);
# Line 3493  void SSH2_channel_input_eof(PTInstVar pv Line 3516  void SSH2_channel_input_eof(PTInstVar pv
3516          if (pvar->rekeying) {          if (pvar->rekeying) {
3517                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、
3518                  // 将来直すことにする。                  // 将来直すことにする。
3519                    logputs(LOG_LEVEL_INFO, __FUNCTION__ ": now rekeying. data is not sent.");
3520    
3521                  c = NULL;                  c = NULL;
3522    
3523                  return;                  return;
# Line 3501  void SSH2_channel_input_eof(PTInstVar pv Line 3526  void SSH2_channel_input_eof(PTInstVar pv
3526          msg = buffer_init();          msg = buffer_init();
3527          if (msg == NULL) {          if (msg == NULL) {
3528                  // TODO: error check                  // TODO: error check
3529                  logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL");                  logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3530                  return;                  return;
3531          }          }
3532          buffer_put_int(msg, c->remote_id);  // remote ID          buffer_put_int(msg, c->remote_id);  // remote ID
# Line 3574  void SSH_request_forwarding(PTInstVar pv Line 3599  void SSH_request_forwarding(PTInstVar pv
3599                  msg = buffer_init();                  msg = buffer_init();
3600                  if (msg == NULL) {                  if (msg == NULL) {
3601                          // TODO: error check                          // TODO: error check
3602                          logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL");                          logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3603                          return;                          return;
3604                  }                  }
3605                  req = "tcpip-forward";                  req = "tcpip-forward";
# Line 3607  void SSH_cancel_request_forwarding(PTIns Line 3632  void SSH_cancel_request_forwarding(PTIns
3632                  msg = buffer_init();                  msg = buffer_init();
3633                  if (msg == NULL) {                  if (msg == NULL) {
3634                          // TODO: error check                          // TODO: error check
3635                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3636                          return;                          return;
3637                  }                  }
3638                  s = "cancel-tcpip-forward";                  s = "cancel-tcpip-forward";
# Line 3669  void SSH_request_X11_forwarding(PTInstVa Line 3695  void SSH_request_X11_forwarding(PTInstVa
3695                  msg = buffer_init();                  msg = buffer_init();
3696                  if (msg == NULL) {                  if (msg == NULL) {
3697                          // TODO: error check                          // TODO: error check
3698                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3699                          return;                          return;
3700                  }                  }
3701    
3702                  c = ssh2_channel_lookup(pvar->shell_id);                  c = ssh2_channel_lookup(pvar->shell_id);
3703                  if (c == NULL)                  if (c == NULL) {
3704                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
3705                          return;                          return;
3706                    }
3707    
3708                  // making the fake data                  // making the fake data
3709                  newlen = 2 * auth_data_len + 1;                  newlen = 2 * auth_data_len + 1;
# Line 3759  void SSH_open_channel(PTInstVar pvar, ui Line 3788  void SSH_open_channel(PTInstVar pvar, ui
3788                          if (pvar->rekeying) {                          if (pvar->rekeying) {
3789                                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、                                  // TODO: 理想としてはパケット破棄ではなく、パケット読み取り遅延にしたいところだが、
3790                                  // 将来直すことにする。                                  // 将来直すことにする。
3791                                    logputs(LOG_LEVEL_INFO, __FUNCTION__ ": now rekeying. channel open request is not sent.");
3792    
3793                                  c = NULL;                                  c = NULL;
3794    
3795                                  return;                                  return;
# Line 3779  void SSH_open_channel(PTInstVar pvar, ui Line 3810  void SSH_open_channel(PTInstVar pvar, ui
3810                          msg = buffer_init();                          msg = buffer_init();
3811                          if (msg == NULL) {                          if (msg == NULL) {
3812                                  // TODO: error check                                  // TODO: error check
3813                                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
3814                                  return;                                  return;
3815                          }                          }
3816                          s = "direct-tcpip";                          s = "direct-tcpip";
# Line 4545  void SSH2_send_kexinit(PTInstVar pvar) Line 4577  void SSH2_send_kexinit(PTInstVar pvar)
4577          msg = buffer_init();          msg = buffer_init();
4578          if (msg == NULL) {          if (msg == NULL) {
4579                  // TODO: error check                  // TODO: error check
4580                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
4581                  return;                  return;
4582          }          }
4583          if (pvar->my_kex != NULL)          if (pvar->my_kex != NULL)
# Line 5140  static void SSH2_dh_kex_init(PTInstVar p Line 5173  static void SSH2_dh_kex_init(PTInstVar p
5173          msg = buffer_init();          msg = buffer_init();
5174          if (msg == NULL) {          if (msg == NULL) {
5175                  // TODO: error check                  // TODO: error check
5176                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
5177                  return;                  return;
5178          }          }
5179    
# Line 5425  static void SSH2_ecdh_kex_init(PTInstVar Line 5459  static void SSH2_ecdh_kex_init(PTInstVar
5459          msg = buffer_init();          msg = buffer_init();
5460          if (msg == NULL) {          if (msg == NULL) {
5461                  // TODO: error check                  // TODO: error check
5462                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
5463                  return;                  return;
5464          }          }
5465    
# Line 6328  BOOL do_SSH2_userauth(PTInstVar pvar) Line 6363  BOOL do_SSH2_userauth(PTInstVar pvar)
6363          msg = buffer_init();          msg = buffer_init();
6364          if (msg == NULL) {          if (msg == NULL) {
6365                  // TODO: error check                  // TODO: error check
6366                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
6367                  return FALSE;                  return FALSE;
6368          }          }
6369          s = "ssh-userauth";          s = "ssh-userauth";
# Line 6396  BOOL do_SSH2_authrequest(PTInstVar pvar) Line 6432  BOOL do_SSH2_authrequest(PTInstVar pvar)
6432          msg = buffer_init();          msg = buffer_init();
6433          if (msg == NULL) {          if (msg == NULL) {
6434                  // TODO: error check                  // TODO: error check
6435                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
6436                  return FALSE;                  return FALSE;
6437          }          }
6438    
# Line 6588  static LRESULT CALLBACK ssh_heartbeat_dl Line 6625  static LRESULT CALLBACK ssh_heartbeat_dl
6625                          msg = buffer_init();                          msg = buffer_init();
6626                          if (msg == NULL) {                          if (msg == NULL) {
6627                                  // TODO: error check                                  // TODO: error check
6628                                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
6629                                  return FALSE;                                  return FALSE;
6630                          }                          }
6631                          s = "ssh-heartbeat";                          s = "ssh-heartbeat";
# Line 6753  static BOOL handle_SSH2_userauth_success Line 6791  static BOOL handle_SSH2_userauth_success
6791          msg = buffer_init();          msg = buffer_init();
6792          if (msg == NULL) {          if (msg == NULL) {
6793                  // TODO: error check                  // TODO: error check
6794                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
6795                  return FALSE;                  return FALSE;
6796          }          }
6797          s = "session";          s = "session";
# Line 6985  BOOL handle_SSH2_userauth_inforeq(PTInst Line 7024  BOOL handle_SSH2_userauth_inforeq(PTInst
7024          num = get_uint32_MSBfirst(data);          num = get_uint32_MSBfirst(data);
7025          data += 4;          data += 4;
7026    
7027            logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": prompts=%d", num);
7028    
7029          ///////// step2          ///////// step2
7030          // サーバへパスフレーズを送る          // サーバへパスフレーズを送る
7031          msg = buffer_init();          msg = buffer_init();
7032          if (msg == NULL) {          if (msg == NULL) {
7033                  // TODO: error check                  // TODO: error check
7034                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
7035                  return FALSE;                  return FALSE;
7036          }          }
7037          buffer_put_int(msg, num);          buffer_put_int(msg, num);
# Line 7010  BOOL handle_SSH2_userauth_inforeq(PTInst Line 7052  BOOL handle_SSH2_userauth_inforeq(PTInst
7052    
7053                  // get boolean                  // get boolean
7054                  echo = data[0];                  echo = data[0];
7055                    data[0] = '\0'; // ログ出力の為、一時的に NUL Terminate する
7056    
7057                    logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ":   prompt[%d]=\"%s\", echo=%d, pass-state=%d",
7058                            i, prompt, slen, pvar->keyboard_interactive_password_input);
7059    
7060                    data[0] = echo; // ログ出力を行ったので、元の値に書き戻す
7061                  data += 1;                  data += 1;
7062    
7063                  // keyboard-interactive method (2005.3.12 yutaka)                  // keyboard-interactive method (2005.3.12 yutaka)
# Line 7037  BOOL handle_SSH2_userauth_inforeq(PTInst Line 7085  BOOL handle_SSH2_userauth_inforeq(PTInst
7085          finish_send_packet(pvar);          finish_send_packet(pvar);
7086          buffer_free(msg);          buffer_free(msg);
7087    
7088          logputs(LOG_LEVEL_VERBOSE, "SSH2_MSG_USERAUTH_INFO_RESPONSE was sent at handle_SSH2_userauth_inforeq().");          logputs(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_USERAUTH_INFO_RESPONSE.");
7089          return TRUE;          return TRUE;
7090  }  }
7091    
# Line 7302  BOOL handle_SSH2_userauth_passwd_changer Line 7350  BOOL handle_SSH2_userauth_passwd_changer
7350          msg = buffer_init();          msg = buffer_init();
7351          if (msg == NULL) {          if (msg == NULL) {
7352                  // TODO: error check                  // TODO: error check
7353                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
7354                  return FALSE;                  return FALSE;
7355          }          }
7356    
# Line 7390  BOOL send_pty_request(PTInstVar pvar, Ch Line 7439  BOOL send_pty_request(PTInstVar pvar, Ch
7439          msg = buffer_init();          msg = buffer_init();
7440          if (msg == NULL) {          if (msg == NULL) {
7441                  // TODO: error check                  // TODO: error check
7442                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL. (msg)");
7443                  return FALSE;                  return FALSE;
7444          }          }
7445          ttymsg = buffer_init();          ttymsg = buffer_init();
7446          if (ttymsg == NULL) {          if (ttymsg == NULL) {
7447                  // TODO: error check                  // TODO: error check
7448                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL. (ttymsg)");
7449                  buffer_free(msg);                  buffer_free(msg);
7450                  return FALSE;                  return FALSE;
7451          }          }
# Line 7493  static BOOL handle_SSH2_open_confirm(PTI Line 7544  static BOOL handle_SSH2_open_confirm(PTI
7544          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
7545          if (c == NULL) {          if (c == NULL) {
7546                  // TODO:                  // TODO:
7547                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
7548                  return FALSE;                  return FALSE;
7549          }          }
7550    
# Line 7606  static BOOL handle_SSH2_open_failure(PTI Line 7658  static BOOL handle_SSH2_open_failure(PTI
7658          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
7659          if (c == NULL) {          if (c == NULL) {
7660                  // TODO: SSH2_MSG_DISCONNECTを送る                  // TODO: SSH2_MSG_DISCONNECTを送る
7661                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
7662                  return FALSE;                  return FALSE;
7663          }          }
7664    
# Line 7752  static BOOL handle_SSH2_channel_success( Line 7805  static BOOL handle_SSH2_channel_success(
7805                  c = ssh2_channel_lookup(pvar->shell_id);                  c = ssh2_channel_lookup(pvar->shell_id);
7806                  if (c == NULL) {                  if (c == NULL) {
7807                          // TODO: error check                          // TODO: error check
7808                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
7809                          return FALSE;                          return FALSE;
7810                  }                  }
7811                  pvar->agentfwd_enable = TRUE;                  pvar->agentfwd_enable = TRUE;
# Line 7764  static BOOL handle_SSH2_channel_success( Line 7818  static BOOL handle_SSH2_channel_success(
7818                  c = ssh2_channel_lookup(pvar->shell_id);                  c = ssh2_channel_lookup(pvar->shell_id);
7819                  if (c == NULL) {                  if (c == NULL) {
7820                          // TODO: error check                          // TODO: error check
7821                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": shell channel not found.");
7822                          return FALSE;                          return FALSE;
7823                  }                  }
7824    
# Line 7799  static BOOL handle_SSH2_channel_failure( Line 7854  static BOOL handle_SSH2_channel_failure(
7854          c = ssh2_channel_lookup(channel_id);          c = ssh2_channel_lookup(channel_id);
7855          if (c == NULL) {          if (c == NULL) {
7856                  // TODO: error check                  // TODO: error check
7857                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", channel_id);
7858                  return FALSE;                  return FALSE;
7859          }          }
7860    
# Line 7847  static void do_SSH2_adjust_window_size(P Line 7903  static void do_SSH2_adjust_window_size(P
7903                  msg = buffer_init();                  msg = buffer_init();
7904                  if (msg == NULL) {                  if (msg == NULL) {
7905                          // TODO: error check                          // TODO: error check
7906                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
7907                          return;                          return;
7908                  }                  }
7909                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 7882  void ssh2_channel_send_close(PTInstVar p Line 7939  void ssh2_channel_send_close(PTInstVar p
7939                  msg = buffer_init();                  msg = buffer_init();
7940                  if (msg == NULL) {                  if (msg == NULL) {
7941                          // TODO: error check                          // TODO: error check
7942                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
7943                          return;                          return;
7944                  }                  }
7945                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 8548  static BOOL handle_SSH2_channel_data(PTI Line 8606  static BOOL handle_SSH2_channel_data(PTI
8606          // パケットサイズ - (パディングサイズ+1);真のパケットサイズ          // パケットサイズ - (パディングサイズ+1);真のパケットサイズ
8607          len = pvar->ssh_state.payloadlen;          len = pvar->ssh_state.payloadlen;
8608    
         //debug_print(80, data, len);  
   
8609          // channel number          // channel number
8610          id = get_uint32_MSBfirst(data);          id = get_uint32_MSBfirst(data);
8611          data += 4;          data += 4;
# Line 8557  static BOOL handle_SSH2_channel_data(PTI Line 8613  static BOOL handle_SSH2_channel_data(PTI
8613          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
8614          if (c == NULL) {          if (c == NULL) {
8615                  // TODO:                  // TODO:
8616                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
8617                  return FALSE;                  return FALSE;
8618          }          }
8619    
         logprintf(LOG_LEVEL_SSHDUMP, "SSH2_MSG_CHANNEL_DATA was received. local:%d remote:%d", c->self_id, c->remote_id);  
   
8620          // string length          // string length
8621          str_len = get_uint32_MSBfirst(data);          str_len = get_uint32_MSBfirst(data);
8622          data += 4;          data += 4;
8623    
         // RAWパケットダンプを追加 (2008.8.15 yutaka)  
8624          if (LogLevel(pvar, LOG_LEVEL_SSHDUMP)) {          if (LogLevel(pvar, LOG_LEVEL_SSHDUMP)) {
8625                    logprintf(LOG_LEVEL_SSHDUMP, "SSH2_MSG_CHANNEL_DATA was received. local:%d remote:%d len:%d", c->self_id, c->remote_id, str_len);
8626                  init_memdump();                  init_memdump();
8627                  push_memdump("SSH receiving packet", "PKT_recv", (char *)data, str_len);                  push_memdump("SSH receiving packet", "PKT_recv", (char *)data, str_len);
8628          }          }
8629    
8630          // バッファサイズのチェック          // バッファサイズのチェック
8631          if (str_len > c->local_maxpacket) {          if (str_len > c->local_maxpacket) {
8632                  // TODO: logging                  logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": Data length is larger than local_maxpacket. "
8633                            "len:%d local_maxpacket:%d", str_len, c->local_maxpacket);
8634          }          }
8635          if (str_len > c->local_window) {          if (str_len > c->local_window) {
8636                  // TODO: logging                  // TODO: logging
8637                  // local window sizeより大きなパケットは捨てる                  // local window sizeより大きなパケットは捨てる
8638                    logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": Data length is larger than local_window. "
8639                            "len:%d local_window:%d", str_len, c->local_window);
8640                  return FALSE;                  return FALSE;
8641          }          }
8642    
# Line 8603  static BOOL handle_SSH2_channel_data(PTI Line 8661  static BOOL handle_SSH2_channel_data(PTI
8661                  }                  }
8662          }          }
8663    
         //debug_print(200, data, strlen);  
   
8664          // ウィンドウサイズの調整          // ウィンドウサイズの調整
8665          c->local_window -= str_len;          c->local_window -= str_len;
8666    
# Line 8642  static BOOL handle_SSH2_channel_extended Line 8698  static BOOL handle_SSH2_channel_extended
8698          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
8699          if (c == NULL) {          if (c == NULL) {
8700                  // TODO:                  // TODO:
8701                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
8702                  return FALSE;                  return FALSE;
8703          }          }
8704    
# Line 8656  static BOOL handle_SSH2_channel_extended Line 8713  static BOOL handle_SSH2_channel_extended
8713          // バッファサイズのチェック          // バッファサイズのチェック
8714          if (strlen > c->local_maxpacket) {          if (strlen > c->local_maxpacket) {
8715                  // TODO: logging                  // TODO: logging
8716                    logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": Data length is larger than local_maxpacket. "
8717                            "len:%d local_maxpacket:%d", strlen, c->local_maxpacket);
8718          }          }
8719          if (strlen > c->local_window) {          if (strlen > c->local_window) {
8720                  // TODO: logging                  // TODO: logging
8721                  // local window sizeより大きなパケットは捨てる                  // local window sizeより大きなパケットは捨てる
8722                    logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": Data length is larger than local_window. "
8723                            "len:%d local_window:%d", strlen, c->local_window);
8724                  return FALSE;                  return FALSE;
8725          }          }
8726    
# Line 8715  static BOOL handle_SSH2_channel_eof(PTIn Line 8776  static BOOL handle_SSH2_channel_eof(PTIn
8776          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
8777          if (c == NULL) {          if (c == NULL) {
8778                  // TODO:                  // TODO:
8779                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
8780                  return FALSE;                  return FALSE;
8781          }          }
8782    
# Line 8870  static BOOL handle_SSH2_channel_open(PTI Line 8932  static BOOL handle_SSH2_channel_open(PTI
8932                          msg = buffer_init();                          msg = buffer_init();
8933                          if (msg == NULL) {                          if (msg == NULL) {
8934                                  // TODO: error check                                  // TODO: error check
8935                                    logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
8936                                  return FALSE;                                  return FALSE;
8937                          }                          }
8938                          buffer_put_int(msg, remote_id);                          buffer_put_int(msg, remote_id);
# Line 8919  static BOOL handle_SSH2_channel_close(PT Line 8982  static BOOL handle_SSH2_channel_close(PT
8982          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
8983          if (c == NULL) {          if (c == NULL) {
8984                  // TODO:                  // TODO:
8985                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
8986                  return FALSE;                  return FALSE;
8987          }          }
8988    
# Line 8978  static BOOL handle_SSH2_channel_request( Line 9042  static BOOL handle_SSH2_channel_request(
9042          c = ssh2_channel_lookup(id);          c = ssh2_channel_lookup(id);
9043          if (c == NULL) {          if (c == NULL) {
9044                  // TODO:                  // TODO:
9045                    logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": channel not found. (%d)", id);
9046                  return FALSE;                  return FALSE;
9047          }          }
9048    
# Line 9024  static BOOL handle_SSH2_channel_request( Line 9089  static BOOL handle_SSH2_channel_request(
9089                  msg = buffer_init();                  msg = buffer_init();
9090                  if (msg == NULL) {                  if (msg == NULL) {
9091                          // TODO: error check                          // TODO: error check
9092                            logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
9093                          return FALSE;                          return FALSE;
9094                  }                  }
9095                  buffer_put_int(msg, c->remote_id);                  buffer_put_int(msg, c->remote_id);
# Line 9070  static BOOL handle_SSH2_window_adjust(PT Line 9136  static BOOL handle_SSH2_window_adjust(PT
9136          if (c == NULL) {          if (c == NULL) {
9137                  // channel close後にadjust messageが遅れてやってくるケースもあるため、                  // channel close後にadjust messageが遅れてやってくるケースもあるため、
9138                  // FALSEでは返さないようにする。(2007.12.26 yutaka)                  // FALSEでは返さないようにする。(2007.12.26 yutaka)
9139                    logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": channel not found. (%d)", id);
9140                  return TRUE;                  return TRUE;
9141          }          }
9142    

Legend:
Removed from v.6821  
changed lines
  Added in v.6824

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26