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

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