* Ricardo Neri <ricardo.neri-calde...@linux.intel.com> wrote:

> +const char * const umip_insns[5] = {
> +     [UMIP_INST_SGDT] = "sgdt",
> +     [UMIP_INST_SIDT] = "sidt",
> +     [UMIP_INST_SMSW] = "smsw",
> +     [UMIP_INST_SLDT] = "sldt",
> +     [UMIP_INST_STR] = "str",
> +};

Sigh ...

> +/*
> + * If you change these strings, ensure that buffers using them are 
> sufficiently
> + * large.
> + */
> +static const char umip_warn_use[] = "cannot be used by applications.";
> +static const char umip_warn_emu[] = "For now, expensive software emulation 
> returns result.";

Please use the string literals directly, don't add an extra obfuscation layer.

Plus:

> +     unsigned char buf[MAX_INSN_SIZE], warn[128];

> +     snprintf(warn, sizeof(warn), "%s %s", umip_insns[umip_inst],
> +              umip_warn_use);

This is incredibly fragile against future buffer overflows, and warning about 
it 
in comments does not make it less fragile!

Thanks,

        Ingo

Reply via email to