|
|
0f0231 |
From 35e96e07c956a501cb8a12f5b873db173bb09179 Mon Sep 17 00:00:00 2001
|
|
|
0f0231 |
From: Ming-Hung Tsai <mtsai@redhat.com>
|
|
|
0f0231 |
Date: Wed, 2 Jun 2021 11:39:01 +0800
|
|
|
0f0231 |
Subject: [PATCH 06/10] [thin_metadata_size] Fix potential string overflow
|
|
|
0f0231 |
|
|
|
0f0231 |
---
|
|
|
0f0231 |
thin-provisioning/thin_metadata_size.cc | 10 +++++++---
|
|
|
0f0231 |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
0f0231 |
|
|
|
0f0231 |
diff --git a/thin-provisioning/thin_metadata_size.cc b/thin-provisioning/thin_metadata_size.cc
|
|
|
0f0231 |
index b6a5718..f14696c 100644
|
|
|
0f0231 |
--- a/thin-provisioning/thin_metadata_size.cc
|
|
|
0f0231 |
+++ b/thin-provisioning/thin_metadata_size.cc
|
|
|
0f0231 |
@@ -192,9 +192,13 @@ static void printf_aligned(struct global *g, char const *a, char const *b, char
|
|
|
0f0231 |
{
|
|
|
0f0231 |
char buf[80];
|
|
|
0f0231 |
|
|
|
0f0231 |
- strcpy(buf, b);
|
|
|
0f0231 |
- if (units)
|
|
|
0f0231 |
- strcat(buf, mandatory ? "{" :"["), strcat(buf, g->unit.chars), strcat(buf, mandatory ? "}" : "]");
|
|
|
0f0231 |
+ if (units) {
|
|
|
0f0231 |
+ char left_bracket = mandatory ? '{' : '[';
|
|
|
0f0231 |
+ char right_bracket = mandatory ? '}' : ']';
|
|
|
0f0231 |
+ snprintf(buf, 80, "%s%c%s%c", b, left_bracket, g->unit.chars, right_bracket);
|
|
|
0f0231 |
+ } else {
|
|
|
0f0231 |
+ snprintf(buf, 80, "%s", b);
|
|
|
0f0231 |
+ }
|
|
|
0f0231 |
|
|
|
0f0231 |
printf("\t%-4s%-44s%s\n", a, buf, c);
|
|
|
0f0231 |
}
|
|
|
0f0231 |
--
|
|
|
0f0231 |
1.8.3.1
|
|
|
0f0231 |
|