]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: don't allow NAN as fstrim percentage
authorDarrick J. Wong <djwong@kernel.org>
Thu, 4 Jun 2026 06:07:43 +0000 (23:07 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 11 Jun 2026 10:26:04 +0000 (12:26 +0200)
Don't let users pass us -o fstrim_pct=NaN, because strtod will happily
return what looks like success but isn't actually a number.  Codex found
this fun little nit.

Cc: linux-xfs@vger.kernel.org # v6.10.0
Fixes: 34bed605490f93 ("xfs_scrub: tune fstrim minlen parameter based on free space histograms")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
scrub/xfs_scrub.c

index 383aa8752b2ce74f0b626fd60165a058774ba1dd..9e73dac92e0502b9d03081755be1d62522dc6c3d 100644 (file)
@@ -7,6 +7,7 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include <paths.h>
+#include <math.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/statvfs.h>
@@ -683,7 +684,7 @@ parse_o_opts(
                        errno = 0;
                        dval = strtod(val, &endp);
 
-                       if (*endp) {
+                       if (*endp || isnan(dval)) {
                                fprintf(stderr,
  _("-o fstrim_pct must be a floating point number\n"));
                                usage();