Don't allow overlapping strcpy. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit c2dc0bc20739803cac5d1c9ab450f32734c56fe7
(DIR) parent 04656a34bd9c853f3bcaa7cf00a240675e35a8f1
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Thu, 22 Sep 2016 11:06:40 -0500
Don't allow overlapping strcpy.
Diffstat:
libframe/frbox.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/libframe/frbox.c b/libframe/frbox.c
@@ -117,8 +117,10 @@ chopbox(Frame *f, Frbox *b, int n) /* drop first n chars; no allocation done */
{
if(b->nrune<0 || b->nrune<n)
berror("chopbox");
- strcpy((char*)b->a.ptr, (char*)runeindex(b->a.ptr, n));
+ memmove(b->a.ptr, runeindex(b->a.ptr, n), b->nrune - n);
+ // XXX strcpy((char*)b->a.ptr, (char*)runeindex(b->a.ptr, n));
b->nrune -= n;
+ b->a.ptr[b->nrune] = 0;
b->wid = strwidth(f->font, (char *)b->a.ptr);
}