Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ttssh2/ttxssh/hosts.c

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

revision 2980 by maya, Wed Jun 6 14:10:12 2007 UTC revision 2992 by maya, Wed Aug 8 16:04:09 2007 UTC
# Line 157  static int begin_read_file(PTInstVar pva Line 157  static int begin_read_file(PTInstVar pva
157                  if (!suppress_errors) {                  if (!suppress_errors) {
158                          if (errno == ENOENT) {                          if (errno == ENOENT) {
159  #ifndef NO_I18N  #ifndef NO_I18N
160                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to read a known_hosts file.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
161                                                                                  "The specified filename does not exist.");                                          "An error occurred while trying to read a known_hosts file.\n"
162                                            "The specified filename does not exist.",
163                                            _TRUNCATE);
164                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ENOENT_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ENOENT_ERROR", pvar);
165                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
166  #else  #else
# Line 168  static int begin_read_file(PTInstVar pva Line 170  static int begin_read_file(PTInstVar pva
170  #endif  #endif
171                          } else {                          } else {
172  #ifndef NO_I18N  #ifndef NO_I18N
173                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to read a known_hosts file.");                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "An error occurred while trying to read a known_hosts file.", _TRUNCATE);
174                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);
175                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
176  #else  #else
# Line 188  static int begin_read_file(PTInstVar pva Line 190  static int begin_read_file(PTInstVar pva
190                  if (pvar->hosts_state.file_data == NULL) {                  if (pvar->hosts_state.file_data == NULL) {
191                          if (!suppress_errors) {                          if (!suppress_errors) {
192  #ifndef NO_I18N  #ifndef NO_I18N
193                                  strcpy(pvar->ts->UIMsg, "Memory ran out while trying to allocate space to read a known_hosts file.");                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "Memory ran out while trying to allocate space to read a known_hosts file.", _TRUNCATE);
194                                  UTIL_get_lang_msg("MSG_HOSTS_ALLOC_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_ALLOC_ERROR", pvar);
195                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
196  #else  #else
# Line 202  static int begin_read_file(PTInstVar pva Line 204  static int begin_read_file(PTInstVar pva
204          } else {          } else {
205                  if (!suppress_errors) {                  if (!suppress_errors) {
206  #ifndef NO_I18N  #ifndef NO_I18N
207                          strcpy(pvar->ts->UIMsg, "An error occurred while trying to read a known_hosts file.");                          strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "An error occurred while trying to read a known_hosts file.", _TRUNCATE);
208                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);
209                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
210  #else  #else
# Line 222  static int begin_read_file(PTInstVar pva Line 224  static int begin_read_file(PTInstVar pva
224          if (amount_read != length) {          if (amount_read != length) {
225                  if (!suppress_errors) {                  if (!suppress_errors) {
226  #ifndef NO_I18N  #ifndef NO_I18N
227                          strcpy(pvar->ts->UIMsg, "An error occurred while trying to read a known_hosts file.");                          strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "An error occurred while trying to read a known_hosts file.", _TRUNCATE);
228                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar);
229                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
230  #else  #else
# Line 660  static int read_host_key(PTInstVar pvar, Line 662  static int read_host_key(PTInstVar pvar,
662                  if (!is_pattern_char(ch) || ch == '*' || ch == '?') {                  if (!is_pattern_char(ch) || ch == '*' || ch == '?') {
663                          if (!suppress_errors) {                          if (!suppress_errors) {
664  #ifndef NO_I18N  #ifndef NO_I18N
665                                  strcpy(pvar->ts->UIMsg, "The host name contains an invalid character.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
666                                                                                  "This session will be terminated.");                                          "The host name contains an invalid character.\n"
667                                            "This session will be terminated.",
668                                            _TRUNCATE);
669                                  UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_INVALID_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_INVALID_ERROR", pvar);
670                                  notify_fatal_error(pvar, pvar->ts->UIMsg);                                  notify_fatal_error(pvar, pvar->ts->UIMsg);
671  #else  #else
# Line 677  static int read_host_key(PTInstVar pvar, Line 681  static int read_host_key(PTInstVar pvar,
681          if (i == 0) {          if (i == 0) {
682                  if (!suppress_errors) {                  if (!suppress_errors) {
683  #ifndef NO_I18N  #ifndef NO_I18N
684                          strcpy(pvar->ts->UIMsg, "The host name should not be empty.\n"                          strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
685                                                                          "This session will be terminated.");                                  "The host name should not be empty.\n"
686                                    "This session will be terminated.",
687                                    _TRUNCATE);
688                          UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_EMPTY_ERROR", pvar);                          UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_EMPTY_ERROR", pvar);
689                          notify_fatal_error(pvar, pvar->ts->UIMsg);                          notify_fatal_error(pvar, pvar->ts->UIMsg);
690  #else  #else
# Line 840  static void init_hosts_dlg(PTInstVar pva Line 846  static void init_hosts_dlg(PTInstVar pva
846          for (i = 0; (ch = buf[i]) != 0 && ch != '#'; i++) {          for (i = 0; (ch = buf[i]) != 0 && ch != '#'; i++) {
847                  buf2[i] = ch;                  buf2[i] = ch;
848          }          }
849          if (sizeof(buf2) - i - 1 > 0) {          strncpy_s(buf2 + i, sizeof(buf2) - i,
850                  strncpy(buf2 + i, pvar->hosts_state.prefetched_hostname,                            pvar->hosts_state.prefetched_hostname, _TRUNCATE);
                                 sizeof(buf2) - i - 1);  
         }  
851          j = i + strlen(buf2 + i);          j = i + strlen(buf2 + i);
852          for (; buf[i] == '#'; i++) {          for (; buf[i] == '#'; i++) {
853          }          }
854          if (sizeof(buf2) - j - 1 > 0) {          strncpy_s(buf2 + j, sizeof(buf2) - j, buf + i, _TRUNCATE);
                 strncpy(buf2 + j, buf + i, sizeof(buf2) - j - 1);  
         }  
         buf2[sizeof(buf2) - 1] = 0;  
855    
856          SetDlgItemText(dlg, IDC_HOSTWARNING, buf2);          SetDlgItemText(dlg, IDC_HOSTWARNING, buf2);
857    
# Line 894  static char FAR *format_host_key(PTInstV Line 895  static char FAR *format_host_key(PTInstV
895          enum hostkey_type type = pvar->hosts_state.hostkey.type;          enum hostkey_type type = pvar->hosts_state.hostkey.type;
896    
897          if (type == KEY_RSA1) {          if (type == KEY_RSA1) {
898                  result = (char FAR *) malloc(host_len                  int result_len = host_len + 50 +
899                                                                                     + 50 +                                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.exp) / 3 +
900                                                                                     get_ushort16_MSBfirst(pvar->hosts_state.hostkey.exp) /                                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.mod) / 3;
901                                                                                     3 +                  result = (char FAR *) malloc(result_len);
                                                                                    get_ushort16_MSBfirst(pvar->hosts_state.hostkey.mod) /  
                                                                                    3);  
902    
903                  strcpy(result, pvar->hosts_state.prefetched_hostname);                  strncpy_s(result, result_len, pvar->hosts_state.prefetched_hostname, _TRUNCATE);
904                  index = host_len;                  index = host_len;
905    
906                  sprintf(result + index, " %d ", pvar->hosts_state.hostkey.bits);                  _snprintf_s(result + index, result_len - host_len, _TRUNCATE,
907                            " %d ", pvar->hosts_state.hostkey.bits);
908                  index += strlen(result + index);                  index += strlen(result + index);
909                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.exp);                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.exp);
910                  result[index] = ' ';                  result[index] = ' ';
911                  index++;                  index++;
912                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.mod);                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.mod);
913                  strcpy(result + index, " \r\n");                  strncpy_s(result + index, result_len - index, " \r\n", _TRUNCATE);
914    
915          } else if (type == KEY_RSA || type == KEY_DSA) {          } else if (type == KEY_RSA || type == KEY_DSA) {
916                  Key *key = &pvar->hosts_state.hostkey;                  Key *key = &pvar->hosts_state.hostkey;
# Line 934  static char FAR *format_host_key(PTInstV Line 934  static char FAR *format_host_key(PTInstV
934                          }                          }
935    
936                          // setup                          // setup
937                          _snprintf(result, msize, "%s %s %s\r\n",                          _snprintf_s(result, msize, _TRUNCATE, "%s %s %s\r\n",
938                                  pvar->hosts_state.prefetched_hostname,                                  pvar->hosts_state.prefetched_hostname,
939                                  get_sshname_from_key(key),                                  get_sshname_from_key(key),
940                                  uu);                                  uu);
# Line 959  static void add_host_key(PTInstVar pvar) Line 959  static void add_host_key(PTInstVar pvar)
959    
960          if (name == NULL || name[0] == 0) {          if (name == NULL || name[0] == 0) {
961  #ifndef NO_I18N  #ifndef NO_I18N
962                  strcpy(pvar->ts->UIMsg, "The host and its key cannot be added, because no known-hosts file has been specified.\n"                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
963                                                                  "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");                          "The host and its key cannot be added, because no known-hosts file has been specified.\n"
964                            "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.",
965                            _TRUNCATE);
966                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar);                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar);
967                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
968  #else  #else
# Line 984  static void add_host_key(PTInstVar pvar) Line 986  static void add_host_key(PTInstVar pvar)
986                  if (fd == -1) {                  if (fd == -1) {
987                          if (errno == EACCES) {                          if (errno == EACCES) {
988  #ifndef NO_I18N  #ifndef NO_I18N
989                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
990                                                                                  "You do not have permission to write to the known-hosts file.");                                          "An error occurred while trying to write the host key.\n"
991                                            "You do not have permission to write to the known-hosts file.",
992                                            _TRUNCATE);
993                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar);
994                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
995  #else  #else
# Line 995  static void add_host_key(PTInstVar pvar) Line 999  static void add_host_key(PTInstVar pvar)
999  #endif  #endif
1000                          } else {                          } else {
1001  #ifndef NO_I18N  #ifndef NO_I18N
1002                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1003                                                                                  "The host key could not be written.");                                          "An error occurred while trying to write the host key.\n"
1004                                            "The host key could not be written.",
1005                                            _TRUNCATE);
1006                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);
1007                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1008  #else  #else
# Line 1014  static void add_host_key(PTInstVar pvar) Line 1020  static void add_host_key(PTInstVar pvar)
1020    
1021                  if (amount_written != length || close_result == -1) {                  if (amount_written != length || close_result == -1) {
1022  #ifndef NO_I18N  #ifndef NO_I18N
1023                          strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                          strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1024                                                                          "The host key could not be written.");                                  "An error occurred while trying to write the host key.\n"
1025                                    "The host key could not be written.",
1026                                    _TRUNCATE);
1027                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);
1028                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1029  #else  #else
# Line 1049  static void delete_different_key(PTInstV Line 1057  static void delete_different_key(PTInstV
1057    
1058          if (name == NULL || name[0] == 0) {          if (name == NULL || name[0] == 0) {
1059  #ifndef NO_I18N  #ifndef NO_I18N
1060                  strcpy(pvar->ts->UIMsg, "The host and its key cannot be added, because no known-hosts file has been specified.\n"                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1061                                                                  "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");                          "The host and its key cannot be added, because no known-hosts file has been specified.\n"
1062                            "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.",
1063                            _TRUNCATE);
1064                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar);                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar);
1065                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1066  #else  #else
# Line 1080  static void delete_different_key(PTInstV Line 1090  static void delete_different_key(PTInstV
1090                  if (fd == -1) {                  if (fd == -1) {
1091                          if (errno == EACCES) {                          if (errno == EACCES) {
1092  #ifndef NO_I18N  #ifndef NO_I18N
1093                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1094                                                                                  "You do not have permission to write to the known-hosts file.");                                          "An error occurred while trying to write the host key.\n"
1095                                            "You do not have permission to write to the known-hosts file.",
1096                                            _TRUNCATE);
1097                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar);
1098                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1099  #else  #else
# Line 1091  static void delete_different_key(PTInstV Line 1103  static void delete_different_key(PTInstV
1103  #endif  #endif
1104                          } else {                          } else {
1105  #ifndef NO_I18N  #ifndef NO_I18N
1106                                  strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                                  strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1107                                                                                  "The host key could not be written.");                                          "An error occurred while trying to write the host key.\n"
1108                                            "The host key could not be written.",
1109                                            _TRUNCATE);
1110                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);
1111                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1112  #else  #else
# Line 1218  error1: Line 1232  error1:
1232                  close_result = _close(fd);                  close_result = _close(fd);
1233                  if (amount_written != length || close_result == -1) {                  if (amount_written != length || close_result == -1) {
1234  #ifndef NO_I18N  #ifndef NO_I18N
1235                          strcpy(pvar->ts->UIMsg, "An error occurred while trying to write the host key.\n"                          strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg),
1236                                                                          "The host key could not be written.");                                  "An error occurred while trying to write the host key.\n"
1237                                    "The host key could not be written.",
1238                                    _TRUNCATE);
1239                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar);
1240                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1241  #else  #else
# Line 1620  void HOSTS_end(PTInstVar pvar) Line 1636  void HOSTS_end(PTInstVar pvar)
1636    
1637  /*  /*
1638   * $Log: not supported by cvs2svn $   * $Log: not supported by cvs2svn $
1639     * Revision 1.16  2007/06/06 14:10:12  maya
1640     * プリプロセッサにより構造体が変わってしまうので、INET6 と I18N の #define を逆転させた。
1641     *
1642   * Revision 1.15  2007/01/04 08:36:42  maya   * Revision 1.15  2007/01/04 08:36:42  maya
1643   * フォントを変更する部分を追加した。   * フォントを変更する部分を追加した。
1644   *   *

Legend:
Removed from v.2980  
changed lines
  Added in v.2992

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