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

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