mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-26 04:30:27 +01:00
51722: Safety for extracting elements of $historywords
This commit is contained in:
parent
b4d1c756f5
commit
a95198e268
2 changed files with 14 additions and 2 deletions
|
|
@ -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>
|
2023-05-13 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
* 51738: Doc/Zsh/mod_pcre.yo, Src/Modules/pcre.c,
|
* 51738: Doc/Zsh/mod_pcre.yo, Src/Modules/pcre.c,
|
||||||
|
|
|
||||||
|
|
@ -1233,9 +1233,16 @@ histwgetfn(UNUSED(Param pm))
|
||||||
pushnode(l, getdata(n));
|
pushnode(l, getdata(n));
|
||||||
|
|
||||||
while (he) {
|
while (he) {
|
||||||
|
char *hstr = he->node.nam;
|
||||||
|
int len = strlen(hstr);
|
||||||
for (iw = he->nwords - 1; iw >= 0; iw--) {
|
for (iw = he->nwords - 1; iw >= 0; iw--) {
|
||||||
h = he->node.nam + he->words[iw * 2];
|
int wbegin = he->words[iw * 2];
|
||||||
e = he->node.nam + he->words[iw * 2 + 1];
|
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;
|
sav = *e;
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
addlinknode(l, dupstring(h));
|
addlinknode(l, dupstring(h));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue