加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0007-restore-bufsize-to-prevent-log-loss.patch 5.08 KB
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2024-06-11 08:07 . sync from upstream
From 27b2deef3e4d64b44a7a4cdfd76ac99bfad80f64 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 9 Apr 2024 10:34:32 +0800
Subject: [PATCH 07/14] restore bufsize to prevent log loss
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/constants.h | 3 ---
src/runtime/conf.c | 2 +-
src/runtime/error.c | 12 ++++++------
src/runtime/lcrcontainer.c | 2 +-
src/runtime/lcrcontainer_execute.c | 4 ++--
src/third_party/libocispec/read_file.c | 5 -----
6 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/constants.h b/src/constants.h
index b62026d..d29a872 100644
--- a/src/constants.h
+++ b/src/constants.h
@@ -54,9 +54,6 @@ extern "C" {
#define DEBUG_DIRECTORY_MODE 0750
-/* buffer constants defined here */
-#define ISULA_PAGE_BUFSIZE 4096
-
#ifdef __cplusplus
}
#endif
diff --git a/src/runtime/conf.c b/src/runtime/conf.c
index b9da377..de07353 100644
--- a/src/runtime/conf.c
+++ b/src/runtime/conf.c
@@ -2931,7 +2931,7 @@ static struct isula_linked_list *trans_oci_linux_sysctl(const json_map_string_st
isula_linked_list_init(conf);
for (i = 0; i < sysctl->len; i++) {
- char sysk[ISULA_PAGE_BUFSIZE] = { 0 };
+ char sysk[BUFSIZ] = { 0 };
int nret = snprintf(sysk, sizeof(sysk), "lxc.sysctl.%s", sysctl->keys[i]);
if (nret < 0 || (size_t)nret >= sizeof(sysk)) {
ERROR("Failed to print string");
diff --git a/src/runtime/error.c b/src/runtime/error.c
index 7eb4832..d0bfcce 100644
--- a/src/runtime/error.c
+++ b/src/runtime/error.c
@@ -66,12 +66,12 @@ void clear_error_message(engine_error_t *error)
void lcr_set_error_message(lcr_errno_t errcode, const char *format, ...)
{
int ret = 0;
- char errbuf[ISULA_PAGE_BUFSIZE + 1] = { 0 };
+ char errbuf[BUFSIZ + 1] = { 0 };
va_list argp;
va_start(argp, format);
- ret = vsnprintf(errbuf, ISULA_PAGE_BUFSIZE, format, argp);
+ ret = vsnprintf(errbuf, BUFSIZ, format, argp);
va_end(argp);
clear_error_message(&g_lcr_error);
if (ret < 0) {
@@ -85,14 +85,14 @@ void lcr_set_error_message(lcr_errno_t errcode, const char *format, ...)
void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...)
{
int ret = 0;
- char errbuf[ISULA_PAGE_BUFSIZE + 1] = { 0 };
+ char errbuf[BUFSIZ + 1] = { 0 };
va_list argp;
if (g_lcr_error.errmsg != NULL || g_lcr_error.errcode != LCR_SUCCESS) {
return;
}
va_start(argp, format);
- ret = vsnprintf(errbuf, ISULA_PAGE_BUFSIZE, format, argp);
+ ret = vsnprintf(errbuf, BUFSIZ, format, argp);
va_end(argp);
clear_error_message(&g_lcr_error);
if (ret < 0) {
@@ -106,13 +106,13 @@ void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...)
void lcr_append_error_message(lcr_errno_t errcode, const char *format, ...)
{
int ret = 0;
- char errbuf[ISULA_PAGE_BUFSIZE + 1] = { 0 };
+ char errbuf[BUFSIZ + 1] = { 0 };
char *result = NULL;
va_list argp;
va_start(argp, format);
- ret = vsnprintf(errbuf, ISULA_PAGE_BUFSIZE, format, argp);
+ ret = vsnprintf(errbuf, BUFSIZ, format, argp);
va_end(argp);
if (ret < 0) {
g_lcr_error.errcode = LCR_ERR_FORMAT;
diff --git a/src/runtime/lcrcontainer.c b/src/runtime/lcrcontainer.c
index f93afb8..2f0c9dd 100644
--- a/src/runtime/lcrcontainer.c
+++ b/src/runtime/lcrcontainer.c
@@ -227,7 +227,7 @@ static bool wait_start_pid(pid_t pid, int rfd, const char *name, const char *pat
{
int ret;
ssize_t size_read = 0;
- char buffer[ISULA_PAGE_BUFSIZE] = { 0 };
+ char buffer[BUFSIZ] = { 0 };
ret = isula_wait_pid(pid);
if (ret == 0) {
diff --git a/src/runtime/lcrcontainer_execute.c b/src/runtime/lcrcontainer_execute.c
index 5c327f5..251fb85 100644
--- a/src/runtime/lcrcontainer_execute.c
+++ b/src/runtime/lcrcontainer_execute.c
@@ -927,7 +927,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request
bool ret = false;
pid_t pid = 0;
ssize_t size_read = 0;
- char buffer[ISULA_PAGE_BUFSIZE + 1] = {0};
+ char buffer[BUFSIZ + 1] = {0};
int pipefd[2] = {-1, -1};
int status = 0;
@@ -980,7 +980,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request
*exit_code = do_attach_get_exit_code(status);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- size_read = read(pipefd[0], buffer, ISULA_PAGE_BUFSIZE);
+ size_read = read(pipefd[0], buffer, BUFSIZ);
/* if we read errmsg means the runtime failed to exec */
if (size_read > 0) {
ERROR("Runtime error: %s", buffer);
diff --git a/src/third_party/libocispec/read_file.c b/src/third_party/libocispec/read_file.c
index 41bb650..b7c0232 100644
--- a/src/third_party/libocispec/read_file.c
+++ b/src/third_party/libocispec/read_file.c
@@ -21,11 +21,6 @@
#include <limits.h>
#include <stdio.h>
-#ifndef BUFSIZ
-// default use BUFSIZ from stdio.h
-#define BUFSIZ 8096
-#endif
-
#ifndef JSON_MAX_SIZE
#define JSON_MAX_SIZE (10LL * 1024LL * 1024LL)
#endif
--
2.34.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化