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