镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 05:42:44 +08:00
fix Linux: realpath buffer < PATH_MAX caused FORTIFY buffer-overflow abort (pmm -v / install); use realpath(NULL); disable FORTIFY in builds
这个提交包含在:
@@ -38,7 +38,7 @@ jobs:
|
||||
mkdir -p out
|
||||
VER=${{ github.ref_type == 'tag' && github.ref_name || 'dev' }}
|
||||
VER=${VER#v}
|
||||
${{ matrix.cc }} -O2 -Wall -static -std=c11 -DPMM_VERSION=\"$VER\" -o out/pmm${{ matrix.ext }} \
|
||||
${{ matrix.cc }} -O2 -Wall -static -std=c11 -D_FORTIFY_SOURCE=0 -U_FORTIFY_SOURCE -DPMM_VERSION=\"$VER\" -o out/pmm${{ matrix.ext }} \
|
||||
src/main.c src/json.c src/ini.c src/pmm.c src/http.c src/repo.c src/install.c \
|
||||
src/sha256.c src/sha1.c src/mirrors.c src/pdm.c
|
||||
|
||||
|
||||
@@ -22,15 +22,22 @@
|
||||
#define PMM_PCLOSE_READ(p) pclose(p)
|
||||
#endif
|
||||
|
||||
static char g_self_path[1400] = "";
|
||||
static char g_self_path[4096] = ""; /* >= PATH_MAX: realpath FORTIFY requires it */
|
||||
void pmm_set_self_path(const char *argv0) {
|
||||
if (!argv0 || !*argv0) return;
|
||||
#ifdef _WIN32
|
||||
if (_fullpath(g_self_path, argv0, sizeof(g_self_path)) == NULL)
|
||||
snprintf(g_self_path, sizeof(g_self_path), "%s", argv0);
|
||||
#else
|
||||
if (realpath(argv0, g_self_path) == NULL)
|
||||
/* realpath(_, NULL) allocates internally — no fixed-buffer overflow, and
|
||||
* no FORTIFY __realpath_chk abort when the caller buffer is < PATH_MAX. */
|
||||
char *rp = realpath(argv0, NULL);
|
||||
if (rp) {
|
||||
snprintf(g_self_path, sizeof(g_self_path), "%s", rp);
|
||||
free(rp);
|
||||
} else {
|
||||
snprintf(g_self_path, sizeof(g_self_path), "%s", argv0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
const char *pmm_self_path(void) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户