mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-22 07:56:03 +02:00
51722: Safety for extracting elements of $historywords
This commit is contained in:
parent
b4d1c756f5
commit
a95198e268
|
@ -1,3 +1,8 @@
|
|||
2023-05-13 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 51722: Src/Modules/parameter.c: Add safety to extracting
|
||||
elements of $historywords.
|
||||
|
||||
2023-05-13 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 51738: Doc/Zsh/mod_pcre.yo, Src/Modules/pcre.c,
|
||||
|
|
|
@ -1233,9 +1233,16 @@ histwgetfn(UNUSED(Param pm))
|
|||
pushnode(l, getdata(n));
|
||||
|
||||
while (he) {
|
||||
char *hstr = he->node.nam;
|
||||
int len = strlen(hstr);
|
||||
for (iw = he->nwords - 1; iw >= 0; iw--) {
|
||||
h = he->node.nam + he->words[iw * 2];
|
||||
e = he->node.nam + he->words[iw * 2 + 1];
|
||||
int wbegin = he->words[iw * 2];
|
||||
int wend = he->words[iw * 2 + 1];
|
||||
|
||||
if (wbegin < 0 || wbegin >= len || wend < 0 || wend > len)
|
||||
break;
|
||||
h = hstr + wbegin;
|
||||
e = hstr + wend;
|
||||
sav = *e;
|
||||
*e = '\0';
|
||||
addlinknode(l, dupstring(h));
|
||||
|
|
Loading…
Reference in New Issue