File target-isns-Replace-zero-length-arrays-with-empty-arrays.patch of Package target-isns

From 1f6b255f010014e69760766c07901bf0aad92027 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Sat, 30 May 2020 14:09:45 -0700
Subject: [PATCH] Replace zero-length arrays with pointers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There are two zero-length arrays used, in struct
isns_hdr and struct isns_tlv, that are really meant
as place-holders for allocated arrays. These should
just be pointers.

This fixes a gcc-10 warning that looks like:

In function ‘isns_rsp_handle’,
    inlined from ‘isns_handle’ at .../src/isns.c:789:3:
.../src/isns.c:724:34: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  724 |    *((char *) tlv->value + slen) = '\0';
      |                                  ^
.../src/isns.c: In function ‘isns_handle’:
.../src/isns_proto.h:33:11: note: at offset 0 to object ‘value’ with size 0 declared here
   33 |  uint32_t value[0];
      |           ^
---
 src/isns_proto.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/isns_proto.h b/src/isns_proto.h
index a5c0f52b05e6..cc369c0e08b5 100644
--- a/src/isns_proto.h
+++ b/src/isns_proto.h
@@ -24,13 +24,13 @@ struct isns_hdr {
 	uint16_t flags;
 	uint16_t transaction;
 	uint16_t sequence;
-	uint32_t pdu[0];
+	uint32_t pdu[];
 } __attribute__ ((packed));
 
 struct isns_tlv {
 	uint32_t tag;
 	uint32_t length;
-	uint32_t value[0];
+	uint32_t value[];
 } __attribute__ ((packed));
 
 /* X-macro describing iSNSP commands and responses (4.1.3) */
-- 
2.26.2

openSUSE Build Service is sponsored by