Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | From 424d5967e94f6adf4c0669d390779af8da0bef20 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lee Duncan <lduncan@suse.com> |
| 3 | Date: Sat, 18 Sep 2021 16:10:50 -0700 |
| 4 | Subject: [PATCH] Fix compiler error introduced with recent IPv6 commit. |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Commit 76350316de38 ("Handle IPv6 interfaces correctly.") added |
| 10 | a string copy that creates this gcc-11 error message: |
| 11 | |
| 12 | > gcc-11 -O2 -g -Wall -Werror -Wextra -fvisibility=hidden -fPIC -I/usr/include/kmod -c -o idbm.o idbm.c |
| 13 | > idbm.c: In function ‘_idbm_node_rec_link’: |
| 14 | > idbm.c:999:17: error: ‘strncpy’ specified bound 65 equals destination size [-Werror=stringop-truncation] |
| 15 | > 999 | strncpy((*node).iface.name, iface_name, ISCSI_MAX_IFACE_LEN); |
| 16 | > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 17 | |
| 18 | So copy one less character, maximum. |
| 19 | |
| 20 | Upstream-Status: Backport |
| 21 | [https://github.com/open-iscsi/open-iscsi/commit/424d5967e94f6adf4c0669d390779af8da0bef20] |
| 22 | |
| 23 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| 24 | --- |
| 25 | libopeniscsiusr/idbm.c | 2 +- |
| 26 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 27 | |
| 28 | diff --git a/libopeniscsiusr/idbm.c b/libopeniscsiusr/idbm.c |
| 29 | index b2524ed..6f57e45 100644 |
| 30 | --- a/libopeniscsiusr/idbm.c |
| 31 | +++ b/libopeniscsiusr/idbm.c |
| 32 | @@ -996,7 +996,7 @@ static void _idbm_node_rec_link(struct iscsi_node *node, struct idbm_rec *recs, |
| 33 | |
| 34 | /* use the interface name passed in, if any */ |
| 35 | if (iface_name) |
| 36 | - strncpy((*node).iface.name, iface_name, ISCSI_MAX_IFACE_LEN); |
| 37 | + strncpy((*node).iface.name, iface_name, ISCSI_MAX_IFACE_LEN-1); |
| 38 | |
| 39 | /* |
| 40 | * Note: because we do not add the iface.iscsi_ifacename to |
| 41 | -- |
| 42 | 2.25.1 |
| 43 | |