]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: fix width= property parsing
authorKarel Zak <kzak@redhat.com>
Wed, 11 Mar 2026 10:24:01 +0000 (11:24 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Mar 2026 10:24:01 +0000 (11:24 +0100)
The code uses 'errno' to detect errors, but the variable is not set to
zero before parsing the number. As a result, any previous error can
affect the width number parsing.

Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/column.c

index a36e54690e00966dcfab3011c4ee7a2c5162f49d..461b6a69004851e04b1d8895c56d11421353ef48 100644 (file)
@@ -1024,7 +1024,10 @@ int scols_column_set_properties(struct libscols_column *cl, const char *opts)
                } else if (value && strncmp(name, "width", namesz) == 0) {
 
                        char *end = NULL;
-                       double x = strtod(value, &end);
+                       double x;
+
+                       errno = 0;
+                       x = strtod(value, &end);
                        if (errno || value == end)
                                return -EINVAL;
                        rc = scols_column_set_whint(cl, x);