]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Address static analysis warning
authorDimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Thu, 18 Sep 2025 18:36:42 +0000 (20:36 +0200)
committerDimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Fri, 19 Sep 2025 17:17:52 +0000 (19:17 +0200)
gpst.c: In function 'gpst_connect':
gpst.c:723:46: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (13 chars into 12 available) [-Wunterminated-string-initialization]
  723 |         static const char start_tunnel[12] = "START_TUNNEL"; /* NOT zero-terminated */
      |                                              ^~~~~~~~~~~~~~
gpst.c: At top level:
gpst.c:1433:38: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Wunterminated-string-initialization]
 1433 | static char magic_ping_payload[16] = "monitor\x00\x00pan ha ";
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Dimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
gpst.c

diff --git a/gpst.c b/gpst.c
index cb17bcd4d854928a2ec507a8e566c1faa846340f..244aaf044f2ce640b79d5e8aecc275987e11b485 100644 (file)
--- a/gpst.c
+++ b/gpst.c
@@ -720,7 +720,7 @@ static int gpst_connect(struct openconnect_info *vpninfo)
 {
        int ret;
        struct oc_text_buf *reqbuf;
-       static const char start_tunnel[12] = "START_TUNNEL"; /* NOT zero-terminated */
+       static const char start_tunnel[12] __attribute__((nonstring)) = "START_TUNNEL"; /* NOT NUL-terminated */
        char buf[256];
 
        /* We do NOT actually start the HTTPS tunnel if ESP is enabled and we received
@@ -1430,7 +1430,7 @@ static inline uint16_t csum(void *buf, int nwords)
        return csum_finish(csum_partial(buf, nwords));
 }
 
-static char magic_ping_payload[16] = "monitor\x00\x00pan ha ";
+static char magic_ping_payload[16] __attribute__((nonstring)) = "monitor\x00\x00pan ha "; /* NOT NUL-terminated */
 
 int gpst_esp_send_probes(struct openconnect_info *vpninfo)
 {