diff options
author | Darren Tucker <dtucker@zip.com.au> | 2013-05-16 20:33:10 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2013-05-16 20:33:10 +1000 |
commit | b7ee8521448100e5b268111ff90feb017e657e44 (patch) | |
tree | df47ebf881ca05ff249a9658c7a5123b07647888 | |
parent | dbee308253931f8c1aeebf781d7e7730ff6a0dc1 (diff) |
- dtucker@cvs.openbsd.org 2013/05/16 09:12:31
[readconf.c servconf.c]
switch RekeyLimit traffic volume parsing to scan_scaled. ok djm@
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | readconf.c | 35 | ||||
-rw-r--r-- | servconf.c | 35 |
3 files changed, 17 insertions, 56 deletions
@@ -47,6 +47,9 @@ | |||
47 | [log.c scp.c sshd.c serverloop.c schnorr.c sftp.c] | 47 | [log.c scp.c sshd.c serverloop.c schnorr.c sftp.c] |
48 | Fix some "unused result" warnings found via clang and -portable. | 48 | Fix some "unused result" warnings found via clang and -portable. |
49 | ok markus@ | 49 | ok markus@ |
50 | - dtucker@cvs.openbsd.org 2013/05/16 09:12:31 | ||
51 | [readconf.c servconf.c] | ||
52 | switch RekeyLimit traffic volume parsing to scan_scaled. ok djm@ | ||
50 | 53 | ||
51 | 20130510 | 54 | 20130510 |
52 | - (dtucker) [configure.ac] Enable -Wsizeof-pointer-memaccess if the compiler | 55 | - (dtucker) [configure.ac] Enable -Wsizeof-pointer-memaccess if the compiler |
diff --git a/readconf.c b/readconf.c index 51b23a3b8..dccf3ba16 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.199 2013/05/16 04:27:50 djm Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.200 2013/05/16 09:12:31 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -30,6 +30,7 @@ | |||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <util.h> | ||
33 | 34 | ||
34 | #include "xmalloc.h" | 35 | #include "xmalloc.h" |
35 | #include "ssh.h" | 36 | #include "ssh.h" |
@@ -579,33 +580,11 @@ parse_yesnoask: | |||
579 | if (strcmp(arg, "default") == 0) { | 580 | if (strcmp(arg, "default") == 0) { |
580 | val64 = 0; | 581 | val64 = 0; |
581 | } else { | 582 | } else { |
582 | if (arg[0] < '0' || arg[0] > '9') | 583 | if (scan_scaled(arg, &val64) == -1) |
583 | fatal("%.200s line %d: Bad number.", filename, | 584 | fatal("%.200s line %d: Bad number '%s': %s", |
584 | linenum); | 585 | filename, linenum, arg, strerror(errno)); |
585 | orig = val64 = strtoll(arg, &endofnumber, 10); | 586 | /* check for too-large or too-small limits */ |
586 | if (arg == endofnumber) | 587 | if (val64 > UINT_MAX) |
587 | fatal("%.200s line %d: Bad number.", filename, | ||
588 | linenum); | ||
589 | switch (toupper(*endofnumber)) { | ||
590 | case '\0': | ||
591 | scale = 1; | ||
592 | break; | ||
593 | case 'K': | ||
594 | scale = 1<<10; | ||
595 | break; | ||
596 | case 'M': | ||
597 | scale = 1<<20; | ||
598 | break; | ||
599 | case 'G': | ||
600 | scale = 1<<30; | ||
601 | break; | ||
602 | default: | ||
603 | fatal("%.200s line %d: Invalid RekeyLimit " | ||
604 | "suffix", filename, linenum); | ||
605 | } | ||
606 | val64 *= scale; | ||
607 | /* detect integer wrap and too-large limits */ | ||
608 | if ((val64 / scale) != orig || val64 > UINT_MAX) | ||
609 | fatal("%.200s line %d: RekeyLimit too large", | 588 | fatal("%.200s line %d: RekeyLimit too large", |
610 | filename, linenum); | 589 | filename, linenum); |
611 | if (val64 != 0 && val64 < 16) | 590 | if (val64 != 0 && val64 < 16) |
diff --git a/servconf.c b/servconf.c index 4e3026b83..145239342 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | /* $OpenBSD: servconf.c,v 1.235 2013/05/16 04:09:14 dtucker Exp $ */ | 2 | /* $OpenBSD: servconf.c,v 1.236 2013/05/16 09:12:31 dtucker Exp $ */ |
3 | /* | 3 | /* |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
5 | * All rights reserved | 5 | * All rights reserved |
@@ -30,6 +30,7 @@ | |||
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | #include <stdarg.h> | 31 | #include <stdarg.h> |
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <util.h> | ||
33 | 34 | ||
34 | #include "openbsd-compat/sys-queue.h" | 35 | #include "openbsd-compat/sys-queue.h" |
35 | #include "xmalloc.h" | 36 | #include "xmalloc.h" |
@@ -1134,33 +1135,11 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1134 | if (strcmp(arg, "default") == 0) { | 1135 | if (strcmp(arg, "default") == 0) { |
1135 | val64 = 0; | 1136 | val64 = 0; |
1136 | } else { | 1137 | } else { |
1137 | if (arg[0] < '0' || arg[0] > '9') | 1138 | if (scan_scaled(arg, &val64) == -1) |
1138 | fatal("%.200s line %d: Bad number.", filename, | 1139 | fatal("%.200s line %d: Bad number '%s': %s", |
1139 | linenum); | 1140 | filename, linenum, arg, strerror(errno)); |
1140 | orig = val64 = strtoll(arg, &endofnumber, 10); | 1141 | /* check for too-large or too-small limits */ |
1141 | if (arg == endofnumber) | 1142 | if (val64 > UINT_MAX) |
1142 | fatal("%.200s line %d: Bad number.", filename, | ||
1143 | linenum); | ||
1144 | switch (toupper(*endofnumber)) { | ||
1145 | case '\0': | ||
1146 | scale = 1; | ||
1147 | break; | ||
1148 | case 'K': | ||
1149 | scale = 1<<10; | ||
1150 | break; | ||
1151 | case 'M': | ||
1152 | scale = 1<<20; | ||
1153 | break; | ||
1154 | case 'G': | ||
1155 | scale = 1<<30; | ||
1156 | break; | ||
1157 | default: | ||
1158 | fatal("%.200s line %d: Invalid RekeyLimit " | ||
1159 | "suffix", filename, linenum); | ||
1160 | } | ||
1161 | val64 *= scale; | ||
1162 | /* detect integer wrap and too-large limits */ | ||
1163 | if ((val64 / scale) != orig || val64 > UINT_MAX) | ||
1164 | fatal("%.200s line %d: RekeyLimit too large", | 1143 | fatal("%.200s line %d: RekeyLimit too large", |
1165 | filename, linenum); | 1144 | filename, linenum); |
1166 | if (val64 != 0 && val64 < 16) | 1145 | if (val64 != 0 && val64 < 16) |