=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/dh.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- src/usr.bin/ssh/dh.c 2001/05/07 21:09:29 1.2.2.4 +++ src/usr.bin/ssh/dh.c 2001/09/27 00:15:42 1.2.2.5 @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: dh.c,v 1.2.2.4 2001/05/07 21:09:29 jason Exp $"); +RCSID("$OpenBSD: dh.c,v 1.2.2.5 2001/09/27 00:15:42 miod Exp $"); #include "xmalloc.h" @@ -39,7 +39,7 @@ #include "log.h" #include "misc.h" -int +static int parse_prime(int linenum, char *line, struct dhgroup *dhg) { char *cp, *arg; @@ -103,14 +103,14 @@ choose_dh(int min, int wantbits, int max) { FILE *f; - char line[1024]; + char line[2048]; int best, bestcount, which; int linenum; struct dhgroup dhg; - f = fopen(_PATH_DH_PRIMES, "r"); - if (!f) { - log("WARNING: %s does not exist, using old prime", _PATH_DH_PRIMES); + if ((f = fopen(_PATH_DH_MODULI, "r")) == NULL && + (f = fopen(_PATH_DH_PRIMES, "r")) == NULL) { + log("WARNING: %s does not exist, using old modulus", _PATH_DH_MODULI); return (dh_new_group1()); } @@ -134,16 +134,12 @@ if (dhg.size == best) bestcount++; } - fclose (f); + rewind(f); if (bestcount == 0) { + fclose(f); log("WARNING: no suitable primes in %s", _PATH_DH_PRIMES); return (NULL); - } - - f = fopen(_PATH_DH_PRIMES, "r"); - if (!f) { - fatal("WARNING: %s disappeared, giving up", _PATH_DH_PRIMES); } linenum = 0;