Fix incorrect ifname buffer size

- Add 0167-print_ifindex-fix-IFNAME_QUOTED_SZ-definition.patch
   (v5.15~1 "print_ifindex: fix IFNAME_QUOTED_SZ definition")

* 0167-print_ifindex-fix-IFNAME_QUOTED_SZ-definition.patch: New file.
* strace.spec (Release): Bump to 5.
(Patch167): New patch.
(%prep): Apply it.
(%changelog): Mention it.

Resolves: #2028166
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
This commit is contained in:
Eugene Syromiatnikov 2022-01-06 14:02:25 +01:00
parent 57e29808e3
commit 9afcb3818c
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,55 @@
From e27b06773eaf5c0307bcc5637d7457be9be1e6ea Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 1 Dec 2021 17:11:02 +0100
Subject: [PATCH] print_ifindex: fix IFNAME_QUOTED_SZ definition
sizeof(IFNAMSIZ) instead of IFNAMSIZ was mistakenly used
for IFNAME_QUOTED_SZ initial definition in commit v4.23~87
"print_ifindex: respect xlat style settings".
* src/print_ifindex.c (IFNAME_QUOTED_SZ): Use IFNAMSIZ
instead of sizeof(IFNAMSIZ).
* NEWS: Mention it.
Reported-by: Paulo Andrade <pandrade@redhat.com>
Suggested-by: Paulo Andrade <pandrade@redhat.com>
Fixes: v4.23~87 "print_ifindex: respect xlat style settings"
References: https://bugzilla.redhat.com/show_bug.cgi?id=2028146
---
NEWS | 4 ++++
src/print_ifindex.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 9bab673..a3036b8 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,12 @@ Noteworthy changes in release ?.?? (????-??-??)
PTRACE_*, RTM_*, RTPROT_*, TRAP_*, UFFD_*, UFFDIO_*, and V4L2_* constants.
* Updated lists of ioctl commands from Linux 5.13.
+ * Bug fixes
+ * Fixed insufficient buffer size used for network interface name printing,
+ that previously led to assertions on attempts of printing interface names
+ that require quoting, for example, names longer than 4 characters in -xx
+ mode (addresses RHBZ bug #2028146).
+
* Portability
* On powerpc and powerpc64, linux kernel >= 2.6.23 is required.
Older versions without a decent PTRACE_GETREGS support will not work.
diff --git a/src/print_ifindex.c b/src/print_ifindex.c
index ec48093..dc9d592 100644
--- a/src/print_ifindex.c
+++ b/src/print_ifindex.c
@@ -13,7 +13,7 @@
# define INI_PFX "if_nametoindex(\""
# define INI_SFX "\")"
-# define IFNAME_QUOTED_SZ (sizeof(IFNAMSIZ) * 4 + 3)
+# define IFNAME_QUOTED_SZ (IFNAMSIZ * 4 + 3)
const char *
get_ifname(const unsigned int ifindex)
--
2.1.4

View File

@ -1,7 +1,7 @@
Summary: Tracks and displays system calls associated with a running process
Name: strace
Version: 5.13
Release: 3%{?dist}
Release: 5%{?dist}
# The test suite is GPLv2+, all the rest is LGPLv2.1+.
License: LGPL-2.1+ and GPL-2.0+
# Some distros require Group tag to be present,
@ -54,6 +54,9 @@ Patch152: 0152-trie-use-BIT-and-MASK-macros.patch
Patch153: 0153-tee-rewrite-num_params-access-in-tee_fetch_buf_data.patch
Patch154: 0154-tests-call-setsockopt-directly-in-sockopt-timestamp.patch
# v5.15~1 "print_ifindex: fix IFNAME_QUOTED_SZ definition"
Patch167: 0167-print_ifindex-fix-IFNAME_QUOTED_SZ-definition.patch
# Fallback definitions for make_build/make_install macros
%{?!__make: %global __make %_bindir/make}
%{?!__install: %global __install %_bindir/install}
@ -80,6 +83,8 @@ received by a process.
%patch153 -p1
%patch154 -p1
%patch167 -p1
echo -n %version-%release > .tarball-version
echo -n 2021 > .year
echo -n 2021-07-20 > doc/.strace.1.in.date
@ -136,6 +141,9 @@ echo 'END OF TEST SUITE INFORMATION'
%{_mandir}/man1/*
%changelog
* Wed Jan 05 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-5
- Fix incorrect ifname printing buffer size (#2028166).
* Mon Aug 23 2021 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-3
- Address some issues reported by covscan (#1996691).
- Replace 0141-tests-disable-sockopt-timestamp-on-new-glibc-with-__.patch