1 Star 0 Fork 12

src-oepkgs-oE-rv/python-pyinstaller

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Fix-Gcc-warnings-for-strncpy-and-strncat.patch 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
hht8 提交于 2020-06-29 09:47 . Package init
From 22ad4f7200a56da969e9296d8fecf2f0b8368afc Mon Sep 17 00:00:00 2001
From: Dan Yeaw <dyeaw@ford.com>
Date: Mon, 23 Dec 2019 15:31:04 -0500
Subject: [PATCH] Bootloader: Fix GCC warnings for strncpy and strncat.
Fixes Issue #4196. GCC 8.1 and later added checks to prevent using
strncpy and strncat with the bounds depending on the length of the
source str. In order to fix this, a few approaches were made:
1. Where guards already existed to ensure that added paths weren't
larger than the PATH_MAX, changed to strcpy / strcat which don't take a
length parameter.
2. Where path length checks didn't exist, set the bounds of the strncpy
and strncat to PATH_MAX.
Signed-off-by: Dan Yeaw <dyeaw@ford.com>
---
bootloader/src/pyi_path.c | 7 ++++---
bootloader/src/pyi_pythonlib.c | 12 ++++++------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/bootloader/src/pyi_path.c b/bootloader/src/pyi_path.c
index a449f79..d36e3d2 100644
--- a/bootloader/src/pyi_path.c
+++ b/bootloader/src/pyi_path.c
@@ -56,7 +56,7 @@ pyi_path_dirname(char *result, const char *path)
char *match = NULL;
/* Copy path to result and then just write '\0' to the place with path separator. */
- strncpy(result, path, strlen(path) + 1);
+ strncpy(result, path, PATH_MAX);
/* Remove separator from the end. */
len = strlen(result);
@@ -143,7 +143,7 @@ pyi_path_join(char *result, const char *path1, const char *path2)
memset(result, 0, PATH_MAX);
}
/* Copy path1 to result without null terminator */
- strncpy(result, path1, strlen(path1));
+ strcpy(result, path1);
/* Append trailing slash if missing. */
len = strlen(result);
@@ -156,7 +156,8 @@ pyi_path_join(char *result, const char *path1, const char *path2)
if (path2[len - 1] == PYI_SEP) {
/* Append path2 without slash. */
- strncat(result, path2, len - 2);
+ strcat(result, path2);
+ result[strlen(result) - 1] = PYI_NULLCHAR;
}
else {
/* path2 does not end with slash. */
diff --git a/bootloader/src/pyi_pythonlib.c b/bootloader/src/pyi_pythonlib.c
index ee4b3b2..d90c239 100644
--- a/bootloader/src/pyi_pythonlib.c
+++ b/bootloader/src/pyi_pythonlib.c
@@ -480,15 +480,15 @@ pyi_pylib_start_python(ARCHIVE_STATUS *status)
/* Set sys.path */
if (is_py2) {
/* sys.path = [mainpath] */
- strncpy(pypath, status->mainpath, strlen(status->mainpath));
+ strncpy(pypath, status->mainpath, PATH_MAX);
}
else {
/* sys.path = [base_library, mainpath] */
- strncpy(pypath, status->mainpath, strlen(status->mainpath));
- strncat(pypath, PYI_SEPSTR, strlen(PYI_SEPSTR));
- strncat(pypath, "base_library.zip", strlen("base_library.zip"));
- strncat(pypath, PYI_PATHSEPSTR, strlen(PYI_PATHSEPSTR));
- strncat(pypath, status->mainpath, strlen(status->mainpath));
+ strncpy(pypath, status->mainpath, PATH_MAX);
+ strncat(pypath, PYI_SEPSTR, PATH_MAX);
+ strncat(pypath, "base_library.zip", PATH_MAX);
+ strncat(pypath, PYI_PATHSEPSTR, PATH_MAX);
+ strncat(pypath, status->mainpath, PATH_MAX);
};
/*
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs-oe-rv/python-pyinstaller.git
git@gitee.com:src-oepkgs-oe-rv/python-pyinstaller.git
src-oepkgs-oe-rv
python-pyinstaller
python-pyinstaller
master

搜索帮助