On 5/7/24 12:25 AM, Simon Josefsson wrote:
> Yes please indent code and write a NEWS entry about fixing some ASAN
> alarms.
I've pushed the attached patch. Now 'make syntax-check' should be
happy.
Collin
From cd3a8b26fba59ef62905dbfa19bf07be0a61e993 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 7 May 2024 02:09:03 -0700
Subject: [PATCH] maint: Update NEWS and run 'make indent'.
* NEWS: Mention the AddressSanitizer error fixed by the previous
commit.
* ifconfig/printif.c (print_interfaceX): Run 'make indent' to satisfy
syntax-check.
---
NEWS | 4 ++++
ifconfig/printif.c | 18 +++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/NEWS b/NEWS
index bb3f5f1d..9f546c3b 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ https://lists.gnu.org/archive/html/bug-inetutils/2024-03/msg00000.html
** ifconfig: With -A, reject invalid prefix length specifications, and
correctly handle a prefix length of 0.
+** ifconfig: Fix a 'dynamic-stack-buffer-overflow' detected by AddressSanitizer
+when using the --format or --short option. More details in
+<https://lists.gnu.org/archive/html/bug-inetutils/2024-05/msg00020.html>.
+
* Noteworthy changes in release 2.5 (2023-12-29) [stable]
** ftpd, rcp, rlogin, rsh, rshd, uucpd
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index f68547bd..44237329 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -1133,7 +1133,7 @@ print_interfaceX (format_data_t form, int quiet)
form->format = p;
print_interfaceX (form, 1);
q = form->format;
- argv = xrealloc (argv, (argc + 1) * sizeof (char *));
+ argv = xrealloc (argv, (argc + 1) * sizeof (char *));
argv[argc] = xmalloc (q - p + 1);
memcpy (argv[argc], p, q - p);
argv[argc][q - p] = '\0';
@@ -1144,14 +1144,14 @@ print_interfaceX (format_data_t form, int quiet)
}
format_handler (id, form, argc, argv);
- if (argv != NULL)
- {
- /* Clean up. */
- while (--argc >= 0)
- free (argv[argc]);
- free (argv);
- }
- form->format = p;
+ if (argv != NULL)
+ {
+ /* Clean up. */
+ while (--argc >= 0)
+ free (argv[argc]);
+ free (argv);
+ }
+ form->format = p;
}
}
}
--
2.45.0