File simple-obfs-gcc-buildfixes.patch of Package simple-obfs

From 117dd05632cbc05ad54d5aa5da949835e09ef0f0 Mon Sep 17 00:00:00 2001
From: Zane <ticonci@users.noreply.github.com>
Date: Fri, 6 Jul 2018 11:03:24 +0800
Subject: [PATCH] fix compile warning with GCC8

---
 src/netutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/netutils.c b/src/netutils.c
index 66d0a7c..b7fcb64 100644
--- a/src/netutils.c
+++ b/src/netutils.c
@@ -85,7 +85,8 @@ setinterface(int socket_fd, const char *interface_name)
 {
     struct ifreq interface;
     memset(&interface, 0, sizeof(struct ifreq));
-    strncpy(interface.ifr_name, interface_name, IFNAMSIZ);
+    strncpy(interface.ifr_name, interface_name, IFNAMSIZ - 1);
+    interface.ifr_name[IFNAMSIZ - 1] = '\0';
     int res = setsockopt(socket_fd, SOL_SOCKET, SO_BINDTODEVICE, &interface,
                          sizeof(struct ifreq));
     return res;


From 1fab9b9d7b05a9b40084712a5a60fee49bf554b1 Mon Sep 17 00:00:00 2001
From: Roger Shimizu <rogershimizu@gmail.com>
Date: Sat, 17 Aug 2019 01:22:36 +0900
Subject: [PATCH] Fix FTBFS under GCC-9

Resolve report from Debian:
 - https://bugs.debian.org/925829

obfs_http.c: In function 'check_http_header':
obfs_http.c:247:13: error: 'strncasecmp' specified bound
18446744073709551614 exceeds maximum object size 9223372036854775807
[-Werror=stringop-overflow=]
  247 |         if (strncasecmp(hostname, obfs_http->host, result) == 0)
{
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 src/obfs_http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/obfs_http.c b/src/obfs_http.c
index 9051222..30eae6b 100644
--- a/src/obfs_http.c
+++ b/src/obfs_http.c
@@ -245,7 +245,7 @@ check_http_header(buffer_t *buf)
             }
 
         result = OBFS_ERROR;
-        if (strncasecmp(hostname, obfs_http->host, result) == 0) {
+        if (strncasecmp(hostname, obfs_http->host, len) == 0) {
             result = OBFS_OK;
         }
         free(hostname);

openSUSE Build Service is sponsored by