about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--extra/edit/edit.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/extra/edit/edit.c b/extra/edit/edit.c
index 51c913c..793e413 100644
--- a/extra/edit/edit.c
+++ b/extra/edit/edit.c
@@ -236,7 +236,6 @@ static const char *Boolean[] = {
 	"no-names", "no-sts", "palaver", "sasl-external", "verbose",
 };
 
-// FIXME: size needs to be validated for power of two
 static const char *Integer[] = {
 	"local-port", "port", "queue-interval", "size",
 };
@@ -290,8 +289,12 @@ static const char *validate(const char *name, const char *value) {
 		if (!safe(name)) return "cannot be set";
 		if (!value) return "requires a value";
 		char *end;
-		strtoul(value, &end, 10);
-		return (!*value || *end ? "must be an integer" : NULL);
+		size_t n = strtoull(value, &end, 10);
+		if (!*value || *end) return "must be an integer";
+		if (!strcmp(name, "size") && (!n || n & (n-1))) {
+			return "must be a power of two";
+		}
+		return NULL;
 	}
 	for (size_t i = 0; i < ARRAY_LEN(String); ++i) {
 		if (strcmp(String[i], name)) continue;
d>Use mtags for sh in source-filterJune McEnroe 2021-01-20Generate tags for sh files in mtagsJune McEnroe 2021-01-20Add messy sh lexerJune McEnroe 2021-01-20Add all target to git.causal.agency MakefileJune McEnroe 2021-01-20Remove Lua supportJune McEnroe 2021-01-20Fix tests for diff spansJune McEnroe 2021-01-20Avoid matching ':' in make tagsJune McEnroe 2021-01-19Prefer tag matches not preceded by [[:alnum:]]June McEnroe 2021-01-19Escape \ and / in mtags search patternsJune McEnroe 2021-01-20Use mtags in source-filterJune McEnroe 2021-01-19Add mtags to generate tags for make and mdocJune McEnroe 2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe 2021-01-19Don't use a pager if reading standard inputJune McEnroe 2021-01-19Support BSD make syntax and match *.amJune McEnroe 2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe 2021-01-18Allow matching lexers using first input lineJune McEnroe