From c6cfe68b5f2cf92623431f7a888d550cd15cb75b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 29 Sep 2005 18:58:42 +0000 Subject: [PATCH] fix string/int length check SVN-Revision: 2007 --- .../webif/files/usr/lib/webif/validate.awk | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/openwrt/package/webif/files/usr/lib/webif/validate.awk b/openwrt/package/webif/files/usr/lib/webif/validate.awk index 77d4ff695c..c806400ca2 100644 --- a/openwrt/package/webif/files/usr/lib/webif/validate.awk +++ b/openwrt/package/webif/files/usr/lib/webif/validate.awk @@ -78,23 +78,21 @@ valid == 1 { if (options[i] == "required") { if (value == "") { valid = 0; verr = "No value entered" } } else if ((options[i] ~ /^min=/) && (value != "")) { + min = options[i] + sub(/^min=/, "", min) + min = int(min) if ($1 == "int") { - min = options[i] - sub(/^min=/, "", min) if (value < min) { valid = 0; verr = "Value too small" } } else if ($1 == "string") { - min = options[i] - sub(/^min=/, "", min) - if (length(value) < min) { valid = 0; verr = "Value too small" } + if (length(value) < min) { valid = 0; verr = "Value too small: " length(value) " < " min } } } else if ((options[i] ~ /^max=/) && (value != "")) { + max = options[i] + sub(/^max=/, "", max) + max = int(max) if ($1 == "int") { - max = options[i] - sub(/^max=/, "", max) if (value > max) { valid = 0; verr = "Value too large" } } else if ($1 == "string") { - max = options[i] - sub(/^max=/, "", max) if (length(value) > max) { valid = 0; verr = "Value too large" } } } else if ((options[i] == "nodots") && ($1 == "hostname")) { -- 2.30.2