Avoid cutting in the middle of UTF-8 string.
* include/grub/charset.h (grub_getend): New function. * grub-core/script/function.c (grub_script_function_find): Use grub_getend. * grub-core/normal/completion.c (add_completion): Likewise.
This commit is contained in:
parent
f3cb4a4e57
commit
4d8c476536
4 changed files with 46 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <grub/script_sh.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
grub_script_function_t grub_script_function_list;
|
||||
|
||||
|
@ -99,7 +100,14 @@ grub_script_function_find (char *functionname)
|
|||
break;
|
||||
|
||||
if (! func)
|
||||
grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%.20s'", functionname);
|
||||
{
|
||||
char tmp[21];
|
||||
grub_strncpy (tmp, functionname, 20);
|
||||
tmp[20] = 0;
|
||||
/* Avoid truncating inside UTF-8 character. */
|
||||
tmp[grub_getend (tmp, tmp + grub_strlen (tmp))] = 0;
|
||||
grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", tmp);
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue