diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2006-08-02 17:16:37 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2006-08-02 17:16:37 +0000 |
commit | 6d61a3859ecdcd2813a5d2f06393208fa2feb399 (patch) | |
tree | 69b99bde965279a5d0c35f4ee86b2db8006368ea /Src/params.c | |
parent | 21c83849a91360d8af60fd253c4a808bd720f07c (diff) | |
download | zsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.tar.gz zsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.tar.xz zsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.zip |
22578: ensure HISTCHARS/histchars never contains non-ASCII characters
Diffstat (limited to 'Src/params.c')
-rw-r--r-- | Src/params.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Src/params.c b/Src/params.c index 17ce2c54d..e3040fb7f 100644 --- a/Src/params.c +++ b/Src/params.c @@ -3548,10 +3548,21 @@ void histcharssetfn(UNUSED(Param pm), char *x) { if (x) { - bangchar = x[0]; - hatchar = (bangchar) ? x[1] : '\0'; - hashchar = (hatchar) ? x[2] : '\0'; - zsfree(x); + int len, i; + + unmetafy(x, &len); + if (len > 3) + len = 3; + for (i = 0; i < len; i++) { + if (!isascii(STOUC(x[i]))) { + zwarn("HISTCHARS can only contain ASCII characters"); + return; + } + } + bangchar = len ? STOUC(x[0]) : '\0'; + hatchar = len > 1 ? STOUC(x[1]) : '\0'; + hashchar = len > 2 ? STOUC(x[2]) : '\0'; + free(x); } else { bangchar = '!'; hashchar = '#'; |