File: gcc12_valuetest.patch

package info (click to toggle)
rapidjson 1.1.0%2Bdfsg2-7.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,176 kB
  • sloc: cpp: 18,839; ansic: 2,434; python: 235; xml: 182; sh: 83; makefile: 8; javascript: 2
file content (34 lines) | stat: -rw-r--r-- 1,296 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 1f59c69cd18cd508395fe0bb5c2f8ee909e3c48d Mon Sep 17 00:00:00 2001
From: Tom Briden <tom@decompile.me.uk>
Date: Sun, 15 May 2022 10:15:26 +0100
Subject: [PATCH] valuetest: fix potential write of terminating nul past the
 end of the destination

Fixes 2 compile errors with gcc-12, eg:

tesunittest/valuetest.cpp:1516:30: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
test/unittest/valuetest.cpp:1516:20: note: 'sprintf' output between 2 and 11 bytes into a destination of size 10
---
 test/unittest/valuetest.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/test/unittest/valuetest.cpp
+++ b/test/unittest/valuetest.cpp
@@ -1512,7 +1512,7 @@
     {
         int i = 0;
         for (auto& m : x.GetObject()) {
-            char name[10];
+            char name[11];
             sprintf(name, "%d", i);
             EXPECT_STREQ(name, m.name.GetString());
             EXPECT_EQ(i, m.value.GetInt());
@@ -1523,7 +1523,7 @@
     {
         int i = 0;
         for (const auto& m : const_cast<const Value&>(x).GetObject()) {
-            char name[10];
+            char name[11];
             sprintf(name, "%d", i);
             EXPECT_STREQ(name, m.name.GetString());
             EXPECT_EQ(i, m.value.GetInt());