aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzutil
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-06 21:25:53 +0200
committerGitHub <[email protected]>2021-04-06 12:25:53 -0700
commit61b50107a58a1da9d86f5f81dc35d039ca629aae (patch)
treed993ac52cb1f4261e553ad41b5f77ea83a15c267 /lib/libzutil
parentec580225d2b2fb78ea9e12d0b08a185fbb50c7a6 (diff)
libzutil: zfs_isnumber(): return false if input empty
zpool list, which is the only user, would mistakenly try to parse the empty string as the interval in this case: $ zpool list "a" cannot open 'a': no such pool $ zpool list "" interval cannot be zero usage: <usage string follows> which is now symmetric with zpool get: $ zpool list "" cannot open '': name must begin with a letter Avoid breaking the "interval cannot be zero" string. There simply isn't a need for this, and it's user-facing. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11841 Closes #11843
Diffstat (limited to 'lib/libzutil')
-rw-r--r--lib/libzutil/zutil_nicenum.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libzutil/zutil_nicenum.c b/lib/libzutil/zutil_nicenum.c
index 306cec3ca..1a19db0df 100644
--- a/lib/libzutil/zutil_nicenum.c
+++ b/lib/libzutil/zutil_nicenum.c
@@ -35,6 +35,9 @@
boolean_t
zfs_isnumber(const char *str)
{
+ if (!*str)
+ return (B_FALSE);
+
for (; *str; str++)
if (!(isdigit(*str) || (*str == '.')))
return (B_FALSE);