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)
- 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 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)