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:
parent
c33b75e5bf
commit
3abbb0dcb5
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue