summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--moduli.c11
-rw-r--r--ssh-keygen.c46
3 files changed, 42 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 82ab680f0..caf31ec86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -71,6 +71,11 @@
71 - jmc@cvs.openbsd.org 2005/05/20 11:23:32 71 - jmc@cvs.openbsd.org 2005/05/20 11:23:32
72 [ssh_config.5] 72 [ssh_config.5]
73 oops - article and spacing; 73 oops - article and spacing;
74 - avsm@cvs.openbsd.org 2005/05/23 22:44:01
75 [moduli.c ssh-keygen.c]
76 - removes signed/unsigned comparisons in moduli generation
77 - use strtonum instead of atoi where its easier
78 - check some strlcpy overflow and fatal instead of truncate
74 79
7520050524 8020050524
76 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec] 81 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
@@ -2570,4 +2575,4 @@
2570 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 2575 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
2571 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 2576 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
2572 2577
2573$Id: ChangeLog,v 1.3782 2005/05/26 02:14:32 djm Exp $ 2578$Id: ChangeLog,v 1.3783 2005/05/26 02:16:18 djm Exp $
diff --git a/moduli.c b/moduli.c
index 8b05248e2..c13c535d6 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.10 2005/01/17 03:25:46 dtucker Exp $ */ 1/* $OpenBSD: moduli.c,v 1.11 2005/05/23 22:44:01 avsm Exp $ */
2/* 2/*
3 * Copyright 1994 Phil Karn <karn@qualcomm.com> 3 * Copyright 1994 Phil Karn <karn@qualcomm.com>
4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> 4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
@@ -144,7 +144,7 @@ static u_int32_t *LargeSieve, largewords, largetries, largenumbers;
144static u_int32_t largebits, largememory; /* megabytes */ 144static u_int32_t largebits, largememory; /* megabytes */
145static BIGNUM *largebase; 145static BIGNUM *largebase;
146 146
147int gen_candidates(FILE *, int, int, BIGNUM *); 147int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
148int prime_test(FILE *, FILE *, u_int32_t, u_int32_t); 148int prime_test(FILE *, FILE *, u_int32_t, u_int32_t);
149 149
150/* 150/*
@@ -241,14 +241,15 @@ sieve_large(u_int32_t s)
241 * The list is checked against small known primes (less than 2**30). 241 * The list is checked against small known primes (less than 2**30).
242 */ 242 */
243int 243int
244gen_candidates(FILE *out, int memory, int power, BIGNUM *start) 244gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start)
245{ 245{
246 BIGNUM *q; 246 BIGNUM *q;
247 u_int32_t j, r, s, t; 247 u_int32_t j, r, s, t;
248 u_int32_t smallwords = TINY_NUMBER >> 6; 248 u_int32_t smallwords = TINY_NUMBER >> 6;
249 u_int32_t tinywords = TINY_NUMBER >> 6; 249 u_int32_t tinywords = TINY_NUMBER >> 6;
250 time_t time_start, time_stop; 250 time_t time_start, time_stop;
251 int i, ret = 0; 251 u_int32_t i;
252 int ret = 0;
252 253
253 largememory = memory; 254 largememory = memory;
254 255
@@ -548,7 +549,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted)
548 * due to earlier inconsistencies in interpretation, check 549 * due to earlier inconsistencies in interpretation, check
549 * the proposed bit size. 550 * the proposed bit size.
550 */ 551 */
551 if (BN_num_bits(p) != (in_size + 1)) { 552 if ((u_int32_t)BN_num_bits(p) != (in_size + 1)) {
552 debug2("%10u: bit size %u mismatch", count_in, in_size); 553 debug2("%10u: bit size %u mismatch", count_in, in_size);
553 continue; 554 continue;
554 } 555 }
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 6f0713dab..bee431242 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: ssh-keygen.c,v 1.123 2005/04/05 13:45:31 otto Exp $"); 15RCSID("$OpenBSD: ssh-keygen.c,v 1.124 2005/05/23 22:44:01 avsm Exp $");
16 16
17#include <openssl/evp.h> 17#include <openssl/evp.h>
18#include <openssl/pem.h> 18#include <openssl/pem.h>
@@ -36,7 +36,7 @@ RCSID("$OpenBSD: ssh-keygen.c,v 1.123 2005/04/05 13:45:31 otto Exp $");
36#include "dns.h" 36#include "dns.h"
37 37
38/* Number of bits in the RSA/DSA key. This value can be changed on the command line. */ 38/* Number of bits in the RSA/DSA key. This value can be changed on the command line. */
39int bits = 1024; 39u_int32_t bits = 1024;
40 40
41/* 41/*
42 * Flag indicating that we just want to change the passphrase. This can be 42 * Flag indicating that we just want to change the passphrase. This can be
@@ -90,7 +90,7 @@ extern char *__progname;
90char hostname[MAXHOSTNAMELEN]; 90char hostname[MAXHOSTNAMELEN];
91 91
92/* moduli.c */ 92/* moduli.c */
93int gen_candidates(FILE *, int, int, BIGNUM *); 93int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
94int prime_test(FILE *, FILE *, u_int32_t, u_int32_t); 94int prime_test(FILE *, FILE *, u_int32_t, u_int32_t);
95 95
96static void 96static void
@@ -1007,8 +1007,8 @@ main(int ac, char **av)
1007 Key *private, *public; 1007 Key *private, *public;
1008 struct passwd *pw; 1008 struct passwd *pw;
1009 struct stat st; 1009 struct stat st;
1010 int opt, type, fd, download = 0, memory = 0; 1010 int opt, type, fd, download = 0;
1011 int generator_wanted = 0, trials = 100; 1011 uint32_t memory = 0, generator_wanted = 0, trials = 100;
1012 int do_gen_candidates = 0, do_screen_candidates = 0; 1012 int do_gen_candidates = 0, do_screen_candidates = 0;
1013 int log_level = SYSLOG_LEVEL_INFO; 1013 int log_level = SYSLOG_LEVEL_INFO;
1014 BIGNUM *start = NULL; 1014 BIGNUM *start = NULL;
@@ -1016,6 +1016,7 @@ main(int ac, char **av)
1016 1016
1017 extern int optind; 1017 extern int optind;
1018 extern char *optarg; 1018 extern char *optarg;
1019 const char *errstr;
1019 1020
1020 __progname = ssh_get_progname(av[0]); 1021 __progname = ssh_get_progname(av[0]);
1021 1022
@@ -1040,9 +1041,9 @@ main(int ac, char **av)
1040 "degiqpclBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) { 1041 "degiqpclBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) {
1041 switch (opt) { 1042 switch (opt) {
1042 case 'b': 1043 case 'b':
1043 bits = atoi(optarg); 1044 bits = strtonum(optarg, 512, 32768, &errstr);
1044 if (bits < 512 || bits > 32768) { 1045 if (errstr) {
1045 printf("Bits has bad value.\n"); 1046 printf("Bits has bad value %s (%s)\n", optarg, errstr);
1046 exit(1); 1047 exit(1);
1047 } 1048 }
1048 break; 1049 break;
@@ -1070,7 +1071,9 @@ main(int ac, char **av)
1070 change_comment = 1; 1071 change_comment = 1;
1071 break; 1072 break;
1072 case 'f': 1073 case 'f':
1073 strlcpy(identity_file, optarg, sizeof(identity_file)); 1074 if (strlcpy(identity_file, optarg, sizeof(identity_file)) >=
1075 sizeof(identity_file))
1076 fatal("Identity filename too long");
1074 have_identity = 1; 1077 have_identity = 1;
1075 break; 1078 break;
1076 case 'g': 1079 case 'g':
@@ -1125,23 +1128,34 @@ main(int ac, char **av)
1125 rr_hostname = optarg; 1128 rr_hostname = optarg;
1126 break; 1129 break;
1127 case 'W': 1130 case 'W':
1128 generator_wanted = atoi(optarg); 1131 generator_wanted = strtonum(optarg, 1, UINT_MAX, &errstr);
1129 if (generator_wanted < 1) 1132 if (errstr)
1130 fatal("Desired generator has bad value."); 1133 fatal("Desired generator has bad value: %s (%s)",
1134 optarg, errstr);
1131 break; 1135 break;
1132 case 'a': 1136 case 'a':
1133 trials = atoi(optarg); 1137 trials = strtonum(optarg, 1, UINT_MAX, &errstr);
1138 if (errstr)
1139 fatal("Invalid number of trials: %s (%s)",
1140 optarg, errstr);
1134 break; 1141 break;
1135 case 'M': 1142 case 'M':
1136 memory = atoi(optarg); 1143 memory = strtonum(optarg, 1, UINT_MAX, &errstr);
1144 if (errstr) {
1145 fatal("Memory limit is %s: %s", errstr, optarg);
1146 }
1137 break; 1147 break;
1138 case 'G': 1148 case 'G':
1139 do_gen_candidates = 1; 1149 do_gen_candidates = 1;
1140 strlcpy(out_file, optarg, sizeof(out_file)); 1150 if (strlcpy(out_file, optarg, sizeof(out_file)) >=
1151 sizeof(out_file))
1152 fatal("Output filename too long");
1141 break; 1153 break;
1142 case 'T': 1154 case 'T':
1143 do_screen_candidates = 1; 1155 do_screen_candidates = 1;
1144 strlcpy(out_file, optarg, sizeof(out_file)); 1156 if (strlcpy(out_file, optarg, sizeof(out_file)) >=
1157 sizeof(out_file))
1158 fatal("Output filename too long");
1145 break; 1159 break;
1146 case 'S': 1160 case 'S':
1147 /* XXX - also compare length against bits */ 1161 /* XXX - also compare length against bits */