commit 5681496a7e2f68031875586154f941ff8aed6e11
parent 1753c88bd29cbd06d07867ce1ef1af9637f1f357
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 29 Nov 2015 09:21:33 +0100
Avoid buffer overrun in gettxt()
It is a very bad idea check first the content before than
the limits of the array.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ed.c b/ed.c
@@ -159,7 +159,7 @@ repeat:
csize = n;
lasto = block;
}
- for (p = &buf[off - lasto]; *p != '\n' && p < &buf[csize]; ++p) {
+ for (p = &buf[off - lasto]; p < &buf[csize] && *p != '\n'; ++p) {
++off;
addchar(*p);
}