1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Overlapping buffers in hist_word (#234)

While experimenting with #233, a memory segmentation fault occurred.
A search of other emacs issues found a potential matching issue as
described in https://github.com/att/ast/pull/791. Also, a duplicate
PR of https://github.com/att/ast/pull/1489 was submitted. This
commit backports that fix.

src/cmd/ksh93/edit/history.c: hist_word():
- Switch from using strcpy to memmove as the two strings could overlap.
This commit is contained in:
hyenias 2021-03-20 12:07:30 -04:00 committed by GitHub
parent c33b75e5bf
commit 3abbb0dcb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1115,7 +1115,8 @@ char *hist_word(char *string,int size,int word)
}
*cp = 0;
if(s1 != string)
strcpy(string,s1);
/* We can't use strcpy() because the two buffers may overlap. */
memmove(string,s1,strlen(s1)+1);
return(string);
}