Blob Blame History Raw
From 0144bc2fa99421725585dbc7ecbe2e412f7f8d27 Mon Sep 17 00:00:00 2001
From: Markus Metzger <markus.t.metzger@intel.com>
Date: Thu, 12 Oct 2023 12:57:41 +0000
Subject: [PATCH 1/2] pttc, lto: fix lto strnlen size warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Building with -flto results in

    .../pttc/src/util.c:48:15: error: ‘strnlen’ specified bound 4096 exceeds source size 1024 [-Werror=stringop-overread]
       48 |         len = strnlen(s, n);
          |               ^
    .../pttc/src/util.c: In function ‘yasm_advance_next_line.part.0’:
    .../pttc/src/yasm.c:790:14: note: source object declared here
      790 |         char s[1024];
          |              ^

Increase the size to fix this.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
---
 pttc/src/yasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pttc/src/yasm.c b/pttc/src/yasm.c
index 33b8eb9..1004cfa 100644
--- a/pttc/src/yasm.c
+++ b/pttc/src/yasm.c
@@ -787,7 +787,7 @@ int yasm_lookup_label(const struct yasm *y, uint64_t *addr,
 
 static int yasm_advance_next_line(struct yasm *y)
 {
-	char s[1024];
+	char s[FILENAME_MAX+1];
 	char filename[FILENAME_MAX+1];
 	int errcode;
 	int asm_line, asm_inc;
-- 
2.41.0