]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
col: guard c_width sign before size_t cast in BS branch
authorAizal Khan <aizumusheer2@gmail.com>
Tue, 7 Jul 2026 10:14:38 +0000 (15:44 +0530)
committerAizal Khan <aizumusheer2@gmail.com>
Tue, 7 Jul 2026 10:14:38 +0000 (15:44 +0530)
Signed-off-by: Aizal Khan <aizumusheer2@gmail.com>
text-utils/col.c

index 9c0c9acefcc2ce612052cb12040d22312f65b273..9c8f9c225a2f6c499cc3175106aa907df8cb866b 100644 (file)
@@ -397,7 +397,7 @@ static int handle_not_graphic(struct col_ctl *ctl, struct col_lines *lns)
                if (lns->cur_col == 0)
                        return 1;       /* can't go back further */
                if (lns->c) {
-                       if ((size_t) lns->c->c_width <= lns->cur_col)
+                       if (lns->c->c_width >= 0 && (size_t) lns->c->c_width <= lns->cur_col)
                                lns->cur_col -= lns->c->c_width;
                        else
                                lns->cur_col = 0;