Skip to content

Commit

Permalink
修正configfile函数文件名溢出
Browse files Browse the repository at this point in the history
  • Loading branch information
yaya2007 committed Jun 15, 2023
1 parent 48db72d commit 2efa1bb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
4 changes: 4 additions & 0 deletions ChangeLog_chenall.txt
@@ -1,4 +1,8 @@
更新说明:
2023-06-15 (yaya)
修正configfile函数文件名溢出。
改进color函数帮助信息。issues #414

2023-06-05 (yaya)
使用gcc-11高版本编译

Expand Down
31 changes: 9 additions & 22 deletions stage2/asm.S
Expand Up @@ -122,35 +122,18 @@ VARIABLE(force_lba)
VARIABLE(version_string)
.string VERSION

VARIABLE(config_file)
VARIABLE(config_file) //0x821e 配置文件 最长65字节
.string "/menu.lst"

. = EXT_C(main) + 0x34 //0x8234 0x8238-0x8243 12字节未使用!!

.word 0x14C /* CPU type for i386 and compatibles */
.word 1 /* there is 1 section */
VARIABLE(ext_timer) //0x8238 外部定时器 int*
.long 0
VARIABLE(cursor_state) //0x823C 鼠标状态 int
.long 0 // bit 0=1 show cursor,bit 1=1 show splashimage
VARIABLE(grub_timeout) //0x8240 倒计时 int
.long -1

. = EXT_C(main) + 0x44 //0x8244 0x824e-0x8259 18字节未使用!!

.word 0x00 /* size of optional header */
.word 3 /* flags: "no relocation" and "valid executable" */
.word 0x722E /* section name for resources */
.word 0x7273
.word 0x63

. = EXT_C(main) + 0x60

VARIABLE(hotkey_func) //int* //0x8260 外置热键功能
.long 0

.long 0 //未使用
.long 0 //未使用
VARIABLE(ext_timer) //0x8264 外部定时器 int*
.long 0
VARIABLE(grub_timeout) //0x8268 倒计时 int
.long -1

/* Utilities may use this to locate the bss starting address,
* where the "bootlace" signature is placed and preset-menu
Expand Down Expand Up @@ -379,6 +362,7 @@ VARIABLE(buf_track)
VARIABLE(buf_drive)
.long -1
VARIABLE(current_x_resolution) //0x834c 当前水平像素 int
.long 0

. = EXT_C(main) + 0x150

Expand All @@ -392,6 +376,9 @@ VARIABLE(count_ms)
.word 0
VARIABLE(beep_frequency)
.word 0
.byte 0 //0x835b 未使用
VARIABLE(cursor_state) //0x835C 鼠标状态 int
.long 0 // bit 0=1 show cursor,bit 1=1 show splashimage

. = EXT_C(main) + 0x160

Expand Down
21 changes: 13 additions & 8 deletions stage2/builtins.c
Expand Up @@ -3370,15 +3370,17 @@ static struct builtin builtin_color =
"If you omit HELPTEXT and/or HEADING, then NORMAL is used.\n"
"1. Assign colors by target, the order can not be messed up.\n"
" The color can be replaced by a placeholder n.\n"
"e.g. color 0x888800000000 0x888800ffff00 0x888800880000 0x88880000ff00. (64 bit number.)\n"
"e.g. color 0x0000888800000000 0x0000888800ffff00 0x0000888800880000 0x000088880000ff00. (64 bit number."
" The upper 32 bits are the background color, and the lower 32 bits are the foreground color.)\n"
"2. Can assign colors to a specified target. NORMAL should be in the first place.\n"
"e.g. color normal=0x888800000000. (The rest is the same as NORMAL.)\n"
"e.g. color normal=0x4444440000ffff helptext=0xff0000 highlight=0x00ffff heading=0xffff00\n"
" border=0x00ff00. (Background color from NORMAL.)\n"
"e.g. color standard=0xFFFFFF. (Change the console color.)\n"
"e.g. color normal=0x0000888800000000. (The rest is the same as NORMAL.)\n"
"e.g. color normal=0x004444440000ffff helptext=0xff0000 highlight=0x00ffff heading=0xffff00"
" border=0x0000ff00. (Background color from NORMAL.)\n"
"e.g. color standard=0x00FFFFFF. (Change the console color.)\n"
"e.g. color --64bit 0x30. (Make numbers less than 0x100 treated in 64-bit color.)\n"
"Display color list if no parameters.\n"
"Use 'echo -rrggbb' to view colors."
"Use 'echo -rrggbb' to view colors.\n"
"note that if in graphics hi-res mode, the background colour for normal text and help text will be ignored and will be set to transparent."
};


Expand Down Expand Up @@ -3424,8 +3426,11 @@ configfile_func (char *arg, int flags)
nul_terminate (arg);

/* check possible filename overflow */
if (grub_strlen (arg) >= ((char *)0x8270 - new_config))
return ! (errnum = ERR_WONT_FIT);
if (grub_strlen (arg) >= 0x49) //0x821e-0x825f
{
printf_errinfo ("The full path of the configuration file should be less than 73\n");
return ! (errnum = 0x1234);
}

/* Check if the file ARG is present. */
if (! grub_open (arg))
Expand Down
3 changes: 2 additions & 1 deletion stage2/console.c
Expand Up @@ -51,7 +51,8 @@ unsigned long long console_color_64bit[COLOR_STATE_MAX] = {
/* represents the user defined colors for heading line */
[COLOR_STATE_HEADING] = 0xAAAAAA,
/* represents the user defined colors for notes */
[COLOR_STATE_BORDER] = 0x3399
// [COLOR_STATE_BORDER] = 0x3399
[COLOR_STATE_BORDER] = 0xAAAAAA

};

Expand Down
4 changes: 2 additions & 2 deletions stage2/stage2.c
Expand Up @@ -3104,8 +3104,8 @@ extern int graphicsmode_func (char *, int);
pxe_restart_config = 1; /* pxe_detect will use configfile to run menu */

/* go ahead and make sure the terminal is setup */
if (current_term->startup)
(*current_term->startup)();
// if (current_term->startup) 无用 2023-06-13
// (*current_term->startup)();

if (! num_entries)
{
Expand Down

0 comments on commit 2efa1bb

Please sign in to comment.