The branch main has been updated by bdrewery:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=35f375549c7f4d479ba1d9fcd0a368b0219c4ae6

commit 35f375549c7f4d479ba1d9fcd0a368b0219c4ae6
Author:     Bryan Drewery <[email protected]>
AuthorDate: 2025-10-20 18:33:31 +0000
Commit:     Bryan Drewery <[email protected]>
CommitDate: 2025-10-24 00:01:58 +0000

    cut: Avoid undefined behavior.
    
    Summary: UBSAN complains about p[signed - unsigned] wrapping around.
    
    Reviewed by:    kevans
    Differential Revision: https://reviews.freebsd.org/D53226
---
 usr.bin/cut/cut.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c
index 60ff5a31062a..e4e322b4e5c9 100644
--- a/usr.bin/cut/cut.c
+++ b/usr.bin/cut/cut.c
@@ -448,8 +448,8 @@ f_cut(FILE *fp, const char *fname)
                                        break;
                                }
                                if (*pos)
-                                       for (i = 0; i < (int)clen; i++)
-                                               putchar(p[i - clen]);
+                                       (void)fwrite(p - clen, 1, clen,
+                                           stdout);
                        }
                        if (ch == '\n')
                                break;

Reply via email to