FTBFS: Don't attempt to memcpy() zero bytes

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2024-02-06 21:23:00 -05:00
parent 106e662e89
commit 3132bf66ab
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From 78a5e2e17bba531b41101ca036a5bb1a0d5caca5 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 6 Feb 2024 21:15:33 -0500
Subject: [PATCH 2/2] Don't attempt to memcpy() zero bytes
add_rtattr_nest() is called in several places in the code. As part of
its operation, it calls add_rtattr(nm type, NULL, 0) which results in
NULL and 0 being passed to memcpy(). This fails with -Werror=nonnull
on recent GCC.
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
lib/rtnetlink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c
index 3b8413718997568a20752791807b19c1f299955e..faa60d7c12f68af175d223b6c3c3257a982e4f37 100644
--- a/lib/rtnetlink.c
+++ b/lib/rtnetlink.c
@@ -172,7 +172,10 @@ static void add_rtattr(struct nlmsghdr *n, int type, const void *data, int alen)
rta->rta_type = type;
rta->rta_len = len;
- memcpy(RTA_DATA(rta), data, alen);
+ if (alen > 0)
+ {
+ memcpy(RTA_DATA(rta), data, alen);
+ }
n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
}
--
2.43.0

View File

@ -7,7 +7,7 @@
Name: fcoe-utils
Version: 1.0.34
Release: 8.git%{shortcommit0}%{?dist}
Release: 9.git%{shortcommit0}%{?dist}
Summary: Fibre Channel over Ethernet utilities
License: GPL-2.0-only
URL: http://www.open-fcoe.org
@ -29,6 +29,9 @@ Requires(postun): systemd
Patch1: 0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch
# https://github.com/openSUSE/fcoe-utils/pull/25
Patch2: 0002-Don-t-attempt-to-memcpy-zero-bytes.patch
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch: %{ix86}
@ -83,6 +86,9 @@ done
%{_libexecdir}/fcoe/
%changelog
* Tue Feb 06 2024 Stephen Gallagher <sgallagh@redhat.com> - 1.0.34-9.gitb233050
- FTBFS: Don't attempt to memcpy() zero bytes
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.34-8.gitb233050
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild