mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
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:
1 parent
f3cb4a4e57
commit
4d8c476536
4 files changed
+46
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user