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 /readconf.c | |
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@
Diffstat (limited to 'readconf.c')
-rw-r--r-- | readconf.c | 35 |
1 files changed, 7 insertions, 28 deletions
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) |