Blame SOURCES/man-db-2.7.6.1-fix_rhbz1495507.patch

b9042c
From 79308ac147be9e9c889798cba78bab2af05048e1 Mon Sep 17 00:00:00 2001
b9042c
From: Jiri Kucera <jkucera@redhat.com>
b9042c
Date: Wed, 17 Jan 2018 13:57:34 +0100
b9042c
Subject: [PATCH] Fix a segfault in 'man -D --help'
b9042c
b9042c
This patch is an adjusted version (due to the patch rejected hunk issues) of its original (by Colin Watson) from: https://git.savannah.gnu.org/cgit/man-db.git/patch/?id=b32977ff73220cd351387abe558fb523d1deedbb
b9042c
b9042c
Reported by Jiri Kucera.
b9042c
b9042c
* src/man.c (init_html_pager): New function.
b9042c
(parse_opt): Call init_html_pager rather than setting html_pager to
b9042c
NULL.
b9042c
(help_filter): Assert that browser is non-NULL.
b9042c
(main): Call init_html_pager rather than doing the same thing directly.
b9042c
* NEWS: Document this.
b9042c
---
b9042c
 NEWS      | 10 ++++++++++
b9042c
 src/man.c | 17 +++++++++++------
b9042c
 2 files changed, 21 insertions(+), 6 deletions(-)
b9042c
b9042c
diff --git a/NEWS b/NEWS
b9042c
index 366a0263..ff35e884 100644
b9042c
--- a/NEWS
b9042c
+++ b/NEWS
b9042c
@@ -1,3 +1,13 @@
b9042c
+man-db 2.7.7
b9042c
+============
b9042c
+
b9042c
+Major changes since man-db 2.7.6.1:
b9042c
+
b9042c
+	Fixes:
b9042c
+	------
b9042c
+
b9042c
+	o Fix a segfault in 'man -D --help'.
b9042c
+
b9042c
 man-db 2.7.6.1 (12 December 2016)
b9042c
 =================================
b9042c
 
b9042c
diff --git a/src/man.c b/src/man.c
b9042c
index 8b11f43e..cb0930b8 100644
b9042c
--- a/src/man.c
b9042c
+++ b/src/man.c
b9042c
@@ -345,6 +345,13 @@ static struct argp_option options[] = {
b9042c
 	{ 0 }
b9042c
 };
b9042c
 
b9042c
+static void init_html_pager (void)
b9042c
+{
b9042c
+	html_pager = getenv ("BROWSER");
b9042c
+	if (!html_pager)
b9042c
+		html_pager = WEB_BROWSER;
b9042c
+}
b9042c
+
b9042c
 static error_t parse_opt (int key, char *arg, struct argp_state *state)
b9042c
 {
b9042c
 	static int apropos, whatis; /* retain values between calls */
b9042c
@@ -369,7 +376,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
b9042c
 			ditroff = 0;
b9042c
 			gxditview = NULL;
b9042c
 			htmlout = 0;
b9042c
-			html_pager = NULL;
b9042c
+			init_html_pager ();
b9042c
 #endif
b9042c
 			roff_device = want_encoding = extension = pager =
b9042c
 				locale = alt_system_name = external =
b9042c
@@ -582,6 +589,7 @@ static char *help_filter (int key, const char *text,
b9042c
 # ifdef TROFF_IS_GROFF
b9042c
 		case 'H':
b9042c
 			browser = html_pager;
b9042c
+			assert (browser);
b9042c
 			if (STRNEQ (browser, "exec ", 5))
b9042c
 				browser += 5;
b9042c
 			return xasprintf (text, browser);
b9042c
@@ -4018,11 +4026,8 @@ int main (int argc, char *argv[])
b9042c
 
b9042c
 #ifdef TROFF_IS_GROFF
b9042c
 	/* used in --help, so initialise early */
b9042c
-	if (!html_pager) {
b9042c
-		html_pager = getenv ("BROWSER");
b9042c
-		if (!html_pager)
b9042c
-			html_pager = WEB_BROWSER;
b9042c
-	}
b9042c
+	if (!html_pager)
b9042c
+		init_html_pager ();
b9042c
 #endif /* TROFF_IS_GROFF */
b9042c
 
b9042c
 	/* First of all, find out if $MANOPT is set. If so, put it in 
b9042c
-- 
b9042c
2.14.3
b9042c