加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0166-misc-fix-invalid-character-recongition-in-strto-l.patch 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:34 . import grub2-2.02-81.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aaron Miller <aaronmiller@fb.com>
Date: Fri, 29 Jul 2016 17:41:27 +0800
Subject: [PATCH] misc: fix invalid character recongition in strto*l
Would previously allow digits larger than the base and didn't check that
subtracting the difference from 0-9 to lowercase letters for characters
larger than 9 didn't result in a value lower than 9, which allowed the
parses: ` = 9, _ = 8, ^ = 7, ] = 6, \ = 5, and [ = 4
---
grub-core/kern/misc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 0e89c483d5e..5c3899f0e5b 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -434,11 +434,14 @@ grub_strtoull (const char *str, char **end, int base)
unsigned long digit;
digit = grub_tolower (*str) - '0';
- if (digit >= 'a' - '0')
- digit += '0' - 'a' + 10;
- else if (digit > 9)
- break;
-
+ if (digit > 9)
+ {
+ digit += '0' - 'a' + 10;
+ /* digit <= 9 check is needed to keep chars larger than
+ '9' but less than 'a' from being read as numbers */
+ if (digit >= (unsigned long) base || digit <= 9)
+ break;
+ }
if (digit >= (unsigned long) base)
break;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化