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 <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #11841 Closes #11843
This commit is contained in:
parent
7428adc6b7
commit
dfc25ea91c
|
@ -4915,8 +4915,8 @@ get_interval_count(int *argcp, char **argv, float *iv,
|
||||||
|
|
||||||
if (*end == '\0' && errno == 0) {
|
if (*end == '\0' && errno == 0) {
|
||||||
if (interval == 0) {
|
if (interval == 0) {
|
||||||
(void) fprintf(stderr, gettext("interval "
|
(void) fprintf(stderr, gettext(
|
||||||
"cannot be zero\n"));
|
"interval cannot be zero\n"));
|
||||||
usage(B_FALSE);
|
usage(B_FALSE);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -4946,8 +4946,8 @@ get_interval_count(int *argcp, char **argv, float *iv,
|
||||||
|
|
||||||
if (*end == '\0' && errno == 0) {
|
if (*end == '\0' && errno == 0) {
|
||||||
if (interval == 0) {
|
if (interval == 0) {
|
||||||
(void) fprintf(stderr, gettext("interval "
|
(void) fprintf(stderr, gettext(
|
||||||
"cannot be zero\n"));
|
"interval cannot be zero\n"));
|
||||||
usage(B_FALSE);
|
usage(B_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
boolean_t
|
boolean_t
|
||||||
zfs_isnumber(const char *str)
|
zfs_isnumber(const char *str)
|
||||||
{
|
{
|
||||||
|
if (!*str)
|
||||||
|
return (B_FALSE);
|
||||||
|
|
||||||
for (; *str; str++)
|
for (; *str; str++)
|
||||||
if (!(isdigit(*str) || (*str == '.')))
|
if (!(isdigit(*str) || (*str == '.')))
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
Loading…
Reference in New Issue