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

Diff for /src/usr.bin/ssh/dh.c between version 1.72 and 1.73

version 1.72, 2020/10/18 11:32:01 version 1.73, 2021/03/12 04:08:19
Line 38 
Line 38 
 #include "misc.h"  #include "misc.h"
 #include "ssherr.h"  #include "ssherr.h"
   
   static const char *moduli_filename;
   
   void dh_set_moduli_file(const char *filename)
   {
           moduli_filename = filename;
   }
   
   static const char * get_moduli_filename(void)
   {
           return moduli_filename ? moduli_filename : _PATH_DH_MODULI;
   }
   
 static int  static int
 parse_prime(int linenum, char *line, struct dhgroup *dhg)  parse_prime(int linenum, char *line, struct dhgroup *dhg)
 {  {
Line 145 
Line 157 
         int best, bestcount, which, linenum;          int best, bestcount, which, linenum;
         struct dhgroup dhg;          struct dhgroup dhg;
   
         if ((f = fopen(_PATH_DH_MODULI, "r")) == NULL) {          if ((f = fopen(get_moduli_filename(), "r")) == NULL) {
                 logit("WARNING: could not open %s (%s), using fixed modulus",                  logit("WARNING: could not open %s (%s), using fixed modulus",
                     _PATH_DH_MODULI, strerror(errno));                      get_moduli_filename(), strerror(errno));
                 return (dh_new_group_fallback(max));                  return (dh_new_group_fallback(max));
         }          }
   
Line 178 
Line 190 
   
         if (bestcount == 0) {          if (bestcount == 0) {
                 fclose(f);                  fclose(f);
                 logit("WARNING: no suitable primes in %s", _PATH_DH_MODULI);                  logit("WARNING: no suitable primes in %s",
                       get_moduli_filename());
                 return (dh_new_group_fallback(max));                  return (dh_new_group_fallback(max));
         }          }
         which = arc4random_uniform(bestcount);          which = arc4random_uniform(bestcount);
Line 203 
Line 216 
         fclose(f);          fclose(f);
         if (bestcount != which + 1) {          if (bestcount != which + 1) {
                 logit("WARNING: selected prime disappeared in %s, giving up",                  logit("WARNING: selected prime disappeared in %s, giving up",
                     _PATH_DH_MODULI);                      get_moduli_filename());
                 return (dh_new_group_fallback(max));                  return (dh_new_group_fallback(max));
         }          }
   

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.73