Skip to content

Commit 3e0636e

Browse files
committed
fix(system_check): add platform-specific handling for strncpy in GPG check
Introduced platform-specific logic to handle `strncpy` for better compatibility: - On Windows, `strncpy_s` is used with `_TRUNCATE`. - On non-Windows systems, fallback to `strncpy` with manual null-termination.
1 parent dd8976c commit 3e0636e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/system_check.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ int check_gpg_installation(char *gpg_path, size_t path_size) {
1010
}
1111

1212
if (fgets(result, sizeof(result), fp) != NULL) {
13-
strncpy_s(gpg_path, path_size, result, _TRUNCATE);
13+
#ifdef _WIN32
14+
strncpy_s(gpg_path, path_size, result, _TRUNCATE);
15+
#else
16+
strncpy(gpg_path, result, path_size - 1);
17+
gpg_path[path_size - 1] = '\0';
18+
#endif
1419
_pclose(fp);
1520
return SUCCESS;
1621
}

0 commit comments

Comments
 (0)