On 04/03/2012 07:10 AM, Michal Privoznik wrote: > Currently, we put no strains on escape sequence possibly leaving users > with console that cannot be terminated. However, not all ASCII > characters can be used as escape sequence. Only those falling in > @ - _ can be; implement and document this constraint.
> vshGetEscapeChar(const char *s)
> {
> if (*s == '^')
> - return CONTROL(s[1]);
> + return CONTROL(c_islower(s[1]) ? c_toupper(s[1]) : s[1]);
Unlike toupper(), c_toupper() is safe even on non-alphabetic characters
(that's part of why gnulib wrote "c-ctype.h"); you can shorten this to:
return CONTROL(c_toupper(s[1]));
>
> return *s;
> }
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 1ed2dda..cfdd040 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -19879,6 +19879,16 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
> vshPrint(ctl, "\n");
> }
>
> +static bool
> +vshAllowedEscapeChar(char c)
> +{
> + /* Allowed escape characters:
> + * a-z A-Z @ [ \ ] ^ _
> + */
> + return ('a' <= c && c <= 'z') ||
> + ('@' <= c && c <= '_');
Assumes ASCII encoding, but I guess it's okay (no one has really
complained about compiling libvirt on EBCDIC).
ACK with nit fixed.
--
Eric Blake [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
