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

Diff for /src/usr.bin/ssh/hostfile.c between version 1.91 and 1.92

version 1.91, 2021/07/05 01:16:46 version 1.92, 2021/10/02 03:17:01
Line 116 
Line 116 
         struct ssh_hmac_ctx *ctx;          struct ssh_hmac_ctx *ctx;
         u_char salt[256], result[256];          u_char salt[256], result[256];
         char uu_salt[512], uu_result[512];          char uu_salt[512], uu_result[512];
         static char encoded[1024];          char *encoded = NULL;
         u_int len;          u_int len;
   
         len = ssh_digest_bytes(SSH_DIGEST_SHA1);          len = ssh_digest_bytes(SSH_DIGEST_SHA1);
Line 141 
Line 141 
         if (__b64_ntop(salt, len, uu_salt, sizeof(uu_salt)) == -1 ||          if (__b64_ntop(salt, len, uu_salt, sizeof(uu_salt)) == -1 ||
             __b64_ntop(result, len, uu_result, sizeof(uu_result)) == -1)              __b64_ntop(result, len, uu_result, sizeof(uu_result)) == -1)
                 fatal_f("__b64_ntop failed");                  fatal_f("__b64_ntop failed");
           xasprintf(&encoded, "%s%s%c%s", HASH_MAGIC, uu_salt, HASH_DELIM,
               uu_result);
   
         snprintf(encoded, sizeof(encoded), "%s%s%c%s", HASH_MAGIC, uu_salt,  
             HASH_DELIM, uu_result);  
   
         return (encoded);          return (encoded);
 }  }
   
Line 454 
Line 453 
         else {          else {
                 fprintf(f, "%s ", lhost);                  fprintf(f, "%s ", lhost);
         }          }
           free(hashed_host);
         free(lhost);          free(lhost);
         if ((r = sshkey_write(key, f)) == 0)          if ((r = sshkey_write(key, f)) == 0)
                 success = 1;                  success = 1;
Line 723 
Line 723 
 static int  static int
 match_maybe_hashed(const char *host, const char *names, int *was_hashed)  match_maybe_hashed(const char *host, const char *names, int *was_hashed)
 {  {
         int hashed = *names == HASH_DELIM;          int hashed = *names == HASH_DELIM, ret;
         const char *hashed_host;          char *hashed_host = NULL;
         size_t nlen = strlen(names);          size_t nlen = strlen(names);
   
         if (was_hashed != NULL)          if (was_hashed != NULL)
Line 732 
Line 732 
         if (hashed) {          if (hashed) {
                 if ((hashed_host = host_hash(host, names, nlen)) == NULL)                  if ((hashed_host = host_hash(host, names, nlen)) == NULL)
                         return -1;                          return -1;
                 return nlen == strlen(hashed_host) &&                  ret = (nlen == strlen(hashed_host) &&
                     strncmp(hashed_host, names, nlen) == 0;                      strncmp(hashed_host, names, nlen) == 0);
                   free(hashed_host);
                   return ret;
         }          }
         return match_hostname(host, names) == 1;          return match_hostname(host, names) == 1;
 }  }

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92