summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2013-05-16 20:33:10 +1000
committerDarren Tucker <dtucker@zip.com.au>2013-05-16 20:33:10 +1000
commitb7ee8521448100e5b268111ff90feb017e657e44 (patch)
treedf47ebf881ca05ff249a9658c7a5123b07647888 /servconf.c
parentdbee308253931f8c1aeebf781d7e7730ff6a0dc1 (diff)
downloadopenssh-git-b7ee8521448100e5b268111ff90feb017e657e44.tar.gz
- 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 'servconf.c')
-rw-r--r--servconf.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/servconf.c b/servconf.c
index 4e3026b8..14523934 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: servconf.c,v 1.235 2013/05/16 04:09:14 dtucker Exp $ */
+/* $OpenBSD: servconf.c,v 1.236 2013/05/16 09:12:31 dtucker Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
+#include <util.h>
#include "openbsd-compat/sys-queue.h"
#include "xmalloc.h"
@@ -1134,33 +1135,11 @@ process_server_config_line(ServerOptions *options, char *line,
if (strcmp(arg, "default") == 0) {
val64 = 0;
} else {
- if (arg[0] < '0' || arg[0] > '9')
- fatal("%.200s line %d: Bad number.", filename,
- linenum);
- orig = val64 = strtoll(arg, &endofnumber, 10);
- if (arg == endofnumber)
- fatal("%.200s line %d: Bad number.", filename,
- linenum);
- switch (toupper(*endofnumber)) {
- case '\0':
- scale = 1;
- break;
- case 'K':
- scale = 1<<10;
- break;
- case 'M':
- scale = 1<<20;
- break;
- case 'G':
- scale = 1<<30;
- break;
- default:
- fatal("%.200s line %d: Invalid RekeyLimit "
- "suffix", filename, linenum);
- }
- val64 *= scale;
- /* detect integer wrap and too-large limits */
- if ((val64 / scale) != orig || val64 > UINT_MAX)
+ if (scan_scaled(arg, &val64) == -1)
+ fatal("%.200s line %d: Bad number '%s': %s",
+ filename, linenum, arg, strerror(errno));
+ /* check for too-large or too-small limits */
+ if (val64 > UINT_MAX)
fatal("%.200s line %d: RekeyLimit too large",
filename, linenum);
if (val64 != 0 && val64 < 16)