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:
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user