summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-07-01 17:33:11 -0700
committerSage Weil <sage@inktank.com>2013-07-02 10:08:30 -0700
commit7e878bcc8c1b51538f3c05f854a9dac74c09b116 (patch)
tree23536efb2e885a8de0e9f2940695a2dc29dea8c7
parentca61402855966210ba1598239eaf454eaad0f5f2 (diff)
downloadceph-7e878bcc8c1b51538f3c05f854a9dac74c09b116.tar.gz
rgw: add RGWFormatter_Plain allocation to sidestep cranky strlen()
Valgrind complains about an invalid read when we don't pad the allocation, and because it is inlined we can't whitelist it for valgrind. Workaround the warning by just padding our allocations a bit. Fixes: #5346 Backport: cuttlefish Signed-off-by: Sage Weil <sage@inktank.com> (cherry picked from commit 49ff63b1750789070a8c6fef830c9526ae0f6d9f)
-rw-r--r--src/rgw/rgw_formats.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rgw/rgw_formats.cc b/src/rgw/rgw_formats.cc
index 66704c4f5bb..56fc7e7da08 100644
--- a/src/rgw/rgw_formats.cc
+++ b/src/rgw/rgw_formats.cc
@@ -165,7 +165,7 @@ void RGWFormatter_Plain::write_data(const char *fmt, ...)
{
#define LARGE_ENOUGH_LEN 128
int n, size = LARGE_ENOUGH_LEN;
- char s[size];
+ char s[size + 8];
char *p, *np;
bool p_on_stack;
va_list ap;
@@ -187,9 +187,9 @@ void RGWFormatter_Plain::write_data(const char *fmt, ...)
else /* glibc 2.0 */
size *= 2; /* twice the old size */
if (p_on_stack)
- np = (char *)malloc(size);
+ np = (char *)malloc(size + 8);
else
- np = (char *)realloc(p, size);
+ np = (char *)realloc(p, size + 8);
if (!np)
goto done_free;
p = np;