cut: Avoid undefined behavior.

Summary: UBSAN complains about p[signed - unsigned] wrapping around.

Reviewed by:	kevans
Differential Revision: https://reviews.freebsd.org/D53226
This commit is contained in:
Bryan Drewery
2025-10-20 11:33:31 -07:00
parent 30394f3c87
commit 35f375549c
+2 -2
View File
@@ -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;