aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzutil/zutil_nicenum.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libzutil/zutil_nicenum.c')
-rw-r--r--lib/libzutil/zutil_nicenum.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libzutil/zutil_nicenum.c b/lib/libzutil/zutil_nicenum.c
index 1a19db0df..4dcac1f85 100644
--- a/lib/libzutil/zutil_nicenum.c
+++ b/lib/libzutil/zutil_nicenum.c
@@ -27,6 +27,7 @@
#include <math.h>
#include <stdio.h>
#include <libzutil.h>
+#include <string.h>
/*
* Return B_TRUE if "str" is a number string, B_FALSE otherwise.
@@ -42,6 +43,14 @@ zfs_isnumber(const char *str)
if (!(isdigit(*str) || (*str == '.')))
return (B_FALSE);
+ /*
+ * Numbers should not end with a period ("." ".." or "5." are
+ * not valid)
+ */
+ if (str[strlen(str) - 1] == '.') {
+ return (B_FALSE);
+ }
+
return (B_TRUE);
}