代码拉取完成,页面将自动刷新
From 3145a1f4ded700cfda3f2dffc203cc5c3cfb1d13 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 11:39:01 +0800
Subject: [PATCH] [thin_metadata_size] Fix potential string overflow
---
thin-provisioning/thin_metadata_size.cc | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/thin-provisioning/thin_metadata_size.cc b/thin-provisioning/thin_metadata_size.cc
index b6a5718e..f14696c3 100644
--- a/thin-provisioning/thin_metadata_size.cc
+++ b/thin-provisioning/thin_metadata_size.cc
@@ -192,9 +192,13 @@ static void printf_aligned(struct global *g, char const *a, char const *b, char
{
char buf[80];
- strcpy(buf, b);
- if (units)
- strcat(buf, mandatory ? "{" :"["), strcat(buf, g->unit.chars), strcat(buf, mandatory ? "}" : "]");
+ if (units) {
+ char left_bracket = mandatory ? '{' : '[';
+ char right_bracket = mandatory ? '}' : ']';
+ snprintf(buf, 80, "%s%c%s%c", b, left_bracket, g->unit.chars, right_bracket);
+ } else {
+ snprintf(buf, 80, "%s", b);
+ }
printf("\t%-4s%-44s%s\n", a, buf, c);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。