On Tue, Jan 04, 2022 at 10:28:51PM +0100, Steinar H. Gunderson wrote:
> I made a straw man to test whether this was really true, and it turns it is.
> See the attached patch,

Now actually attached.

/* Steinar */
-- 
Homepage: https://www.sesse.net/
--- man-db-2.9.4.orig/lib/sandbox.c
+++ man-db-2.9.4/lib/sandbox.c
@@ -52,6 +52,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#undef HAVE_LIBSECCOMP
 #ifdef HAVE_LIBSECCOMP
 #  include <sys/ioctl.h>
 #  include <sys/ipc.h>
--- man-db-2.9.4.orig/src/lexgrog.c
+++ man-db-2.9.4/src/lexgrog.c
@@ -2,6 +2,8 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#include "zlib.h"
+
 #include "manconfig.h"
 
 /* Flex emits several functions which might reasonably have various
@@ -13,7 +15,7 @@
 #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 #pragma GCC diagnostic ignored "-Wunused-macros"
 
-#line 17 "lexgrog.c"
+#line 19 "lexgrog.c"
 
 #define  YY_INT_ALIGNED short int
 
@@ -2646,7 +2648,7 @@ int yy_flex_debug = 0;
 char *yytext;
 #line 1 "lexgrog.l"
 
-#line 19 "lexgrog.l"
+#line 21 "lexgrog.l"
 
 /*
  * lexgrog.l: extract 'whatis' info from nroff man / formatted cat pages.
@@ -2861,22 +2863,25 @@ static char filters[MAX_FILTERS];
 static int fill_mode;
 static int waiting_for_quote;
 
-static pipeline *decomp;
+//static pipeline *decomp;
+const char *decomp, *decomp_end;
 
 #define YY_INPUT(buf,result,max_size) { \
 	size_t size = max_size; \
-	const char *block = pipeline_read (decomp, &size); \
-	if (block && size != 0) { \
-		memcpy (buf, block, size); \
-		buf[size] = '\0'; \
+	if (max_size > decomp_end - decomp) { \
+		size = decomp_end - decomp; \
+	} \
+	if (size > 0) { \
+		memcpy (buf, decomp, size); \
+		decomp += size; \
 		result = size; \
 	} else \
 		result = YY_NULL; \
 }
 #define YY_NO_INPUT
-#line 2878 "lexgrog.c"
+#line 2883 "lexgrog.c"
 
-#line 292 "lexgrog.l"
+#line 297 "lexgrog.l"
  /* Please add to this list if you know how. */
  /* Note that, since flex only supports UTF-8 by accident, character classes
   * including non-ASCII characters must be written out as (a|b|c|d) rather
@@ -2884,7 +2889,7 @@ static pipeline *decomp;
   */
  /* NOME also works for gl, pt */
  /* eptgrv : eqn, pic, tbl, grap, refer, vgrind */
-#line 2888 "lexgrog.c"
+#line 2893 "lexgrog.c"
 
 #define INITIAL 0
 #define MAN_PRENAME 1
@@ -3116,11 +3121,11 @@ YY_DECL
 		}
 
 	{
-#line 340 "lexgrog.l"
+#line 345 "lexgrog.l"
 
 
  /* begin NAME section processing */
-#line 3124 "lexgrog.c"
+#line 3129 "lexgrog.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -3176,42 +3181,42 @@ do_action:	/* This label is used only to
 case 1:
 /* rule 1 can match eol */
 YY_RULE_SETUP
-#line 343 "lexgrog.l"
+#line 348 "lexgrog.l"
 BEGIN (MAN_PRENAME);
 	YY_BREAK
 case 2:
 /* rule 2 can match eol */
 YY_RULE_SETUP
-#line 344 "lexgrog.l"
+#line 349 "lexgrog.l"
 BEGIN (CAT_NAME);
 	YY_BREAK
 /* general text matching */
 
 case 3:
-#line 349 "lexgrog.l"
+#line 354 "lexgrog.l"
 case 4:
-#line 350 "lexgrog.l"
+#line 355 "lexgrog.l"
 case 5:
-#line 351 "lexgrog.l"
+#line 356 "lexgrog.l"
 case 6:
 /* rule 6 can match eol */
 YY_RULE_SETUP
-#line 351 "lexgrog.l"
+#line 356 "lexgrog.l"
 
 	YY_BREAK
 
 
 case 7:
-#line 356 "lexgrog.l"
+#line 361 "lexgrog.l"
 case 8:
-#line 357 "lexgrog.l"
+#line 362 "lexgrog.l"
 case 9:
 /* rule 9 can match eol */
-#line 358 "lexgrog.l"
+#line 363 "lexgrog.l"
 case 10:
 /* rule 10 can match eol */
 YY_RULE_SETUP
-#line 358 "lexgrog.l"
+#line 363 "lexgrog.l"
 
 	YY_BREAK
 
@@ -3219,45 +3224,45 @@ YY_RULE_SETUP
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 362 "lexgrog.l"
+#line 367 "lexgrog.l"
 filters[TBL_FILTER] = 't';
 	YY_BREAK
 case 12:
 /* rule 12 can match eol */
 YY_RULE_SETUP
-#line 363 "lexgrog.l"
+#line 368 "lexgrog.l"
 filters[EQN_FILTER] = 'e';
 	YY_BREAK
 case 13:
 /* rule 13 can match eol */
 YY_RULE_SETUP
-#line 364 "lexgrog.l"
+#line 369 "lexgrog.l"
 filters[PIC_FILTER] = 'p';
 	YY_BREAK
 case 14:
 /* rule 14 can match eol */
 YY_RULE_SETUP
-#line 365 "lexgrog.l"
+#line 370 "lexgrog.l"
 filters[GRAP_FILTER] = 'g';
 	YY_BREAK
 case 15:
 /* rule 15 can match eol */
-#line 367 "lexgrog.l"
+#line 372 "lexgrog.l"
 case 16:
 /* rule 16 can match eol */
 YY_RULE_SETUP
-#line 367 "lexgrog.l"
+#line 372 "lexgrog.l"
 filters[REF_FILTER] = 'r';
 	YY_BREAK
 case 17:
 /* rule 17 can match eol */
 YY_RULE_SETUP
-#line 368 "lexgrog.l"
+#line 373 "lexgrog.l"
 filters[VGRIND_FILTER] = 'v';
 	YY_BREAK
 
 case YY_STATE_EOF(MAN_REST):
-#line 370 "lexgrog.l"
+#line 375 "lexgrog.l"
 {	/* exit */
 	*p_name = '\0'; /* terminate the string */
 	yyterminate ();
@@ -3266,14 +3271,14 @@ case YY_STATE_EOF(MAN_REST):
 case 18:
 /* rule 18 can match eol */
 YY_RULE_SETUP
-#line 374 "lexgrog.l"
+#line 379 "lexgrog.l"
 
 	YY_BREAK
 /* rules to end NAME section processing */
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 377 "lexgrog.l"
+#line 382 "lexgrog.l"
 {	/* forced exit */
 	*p_name = '\0'; /* terminate the string */
 	yyterminate ();
@@ -3281,10 +3286,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 20:
 /* rule 20 can match eol */
-#line 383 "lexgrog.l"
+#line 388 "lexgrog.l"
 YY_RULE_SETUP
 case YY_STATE_EOF(MAN_PRENAME):
-#line 383 "lexgrog.l"
+#line 388 "lexgrog.l"
 {	/* no NAME at all */
 	*p_name = '\0';
 	BEGIN (MAN_REST);
@@ -3295,23 +3300,23 @@ case YY_STATE_EOF(MAN_PRENAME):
 
 case 21:
 /* rule 21 can match eol */
-#line 392 "lexgrog.l"
+#line 397 "lexgrog.l"
 case 22:
 /* rule 22 can match eol */
-#line 393 "lexgrog.l"
+#line 398 "lexgrog.l"
 case 23:
 /* rule 23 can match eol */
-#line 394 "lexgrog.l"
+#line 399 "lexgrog.l"
 case 24:
 /* rule 24 can match eol */
-#line 395 "lexgrog.l"
+#line 400 "lexgrog.l"
 case 25:
 /* rule 25 can match eol */
-#line 396 "lexgrog.l"
+#line 401 "lexgrog.l"
 case 26:
 /* rule 26 can match eol */
 YY_RULE_SETUP
-#line 396 "lexgrog.l"
+#line 401 "lexgrog.l"
 {
 		yyless (0);
 		BEGIN (MAN_NAME);
@@ -3323,19 +3328,19 @@ YY_RULE_SETUP
 case 27:
 /* rule 27 can match eol */
 YY_RULE_SETUP
-#line 404 "lexgrog.l"
+#line 409 "lexgrog.l"
 
 	YY_BREAK
 case 28:
 /* rule 28 can match eol */
 YY_RULE_SETUP
-#line 406 "lexgrog.l"
+#line 411 "lexgrog.l"
 yyless (1);
 	YY_BREAK
 case 29:
 /* rule 29 can match eol */
 YY_RULE_SETUP
-#line 408 "lexgrog.l"
+#line 413 "lexgrog.l"
 {
 	yyless (0);
 	BEGIN (MAN_NAME);
@@ -3344,30 +3349,30 @@ YY_RULE_SETUP
 
 case 30:
 /* rule 30 can match eol */
-#line 415 "lexgrog.l"
+#line 420 "lexgrog.l"
 case 31:
 /* rule 31 can match eol */
-#line 416 "lexgrog.l"
+#line 421 "lexgrog.l"
 case 32:
 /* rule 32 can match eol */
-#line 417 "lexgrog.l"
+#line 422 "lexgrog.l"
 case 33:
 /* rule 33 can match eol */
-#line 418 "lexgrog.l"
+#line 423 "lexgrog.l"
 case 34:
 /* rule 34 can match eol */
-#line 419 "lexgrog.l"
+#line 424 "lexgrog.l"
 case 35:
 /* rule 35 can match eol */
-#line 420 "lexgrog.l"
+#line 425 "lexgrog.l"
 case 36:
 /* rule 36 can match eol */
-#line 421 "lexgrog.l"
+#line 426 "lexgrog.l"
 YY_RULE_SETUP
 case YY_STATE_EOF(MAN_NAME):
 YY_RULE_SETUP
 case YY_STATE_EOF(MAN_DESC):
-#line 421 "lexgrog.l"
+#line 426 "lexgrog.l"
 {	/* terminate the string */
 		*p_name = '\0';
 		BEGIN (MAN_REST);
@@ -3377,14 +3382,14 @@ case YY_STATE_EOF(MAN_DESC):
 
 case 37:
 /* rule 37 can match eol */
-#line 429 "lexgrog.l"
+#line 434 "lexgrog.l"
 case 38:
 /* rule 38 can match eol */
-#line 430 "lexgrog.l"
+#line 435 "lexgrog.l"
 case 39:
 /* rule 39 can match eol */
 YY_RULE_SETUP
-#line 430 "lexgrog.l"
+#line 435 "lexgrog.l"
 {	/* terminate the string */
 		*p_name = '\0';
 		BEGIN (CAT_REST);
@@ -3398,7 +3403,7 @@ YY_RULE_SETUP
 case 40:
 /* rule 40 can match eol */
 YY_RULE_SETUP
-#line 440 "lexgrog.l"
+#line 445 "lexgrog.l"
 {
 		newline_found ();
 		waiting_for_quote = 1;
@@ -3406,32 +3411,32 @@ YY_RULE_SETUP
 	YY_BREAK
 case 41:
 /* rule 41 can match eol */
-#line 446 "lexgrog.l"
+#line 451 "lexgrog.l"
 case 42:
 /* rule 42 can match eol */
-#line 447 "lexgrog.l"
+#line 452 "lexgrog.l"
 case 43:
 /* rule 43 can match eol */
-#line 448 "lexgrog.l"
+#line 453 "lexgrog.l"
 case 44:
 /* rule 44 can match eol */
-#line 449 "lexgrog.l"
+#line 454 "lexgrog.l"
 case 45:
 /* rule 45 can match eol */
-#line 450 "lexgrog.l"
+#line 455 "lexgrog.l"
 case 46:
 /* rule 46 can match eol */
-#line 451 "lexgrog.l"
+#line 456 "lexgrog.l"
 case 47:
 /* rule 47 can match eol */
-#line 452 "lexgrog.l"
+#line 457 "lexgrog.l"
 case 48:
 /* rule 48 can match eol */
-#line 453 "lexgrog.l"
+#line 458 "lexgrog.l"
 case 49:
 /* rule 49 can match eol */
 YY_RULE_SETUP
-#line 453 "lexgrog.l"
+#line 458 "lexgrog.l"
 {	/* per line comments */
 		newline_found ();
 	}
@@ -3446,7 +3451,7 @@ YY_LINENO_REWIND_TO(yy_cp - 1);
 (yy_c_buf_p) = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 460 "lexgrog.l"
+#line 465 "lexgrog.l"
 newline_found ();
 	YY_BREAK
 case 51:
@@ -3456,7 +3461,7 @@ YY_LINENO_REWIND_TO(yy_cp - 1);
 (yy_c_buf_p) = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 461 "lexgrog.l"
+#line 466 "lexgrog.l"
 newline_found ();
 	YY_BREAK
 
@@ -3465,40 +3470,40 @@ newline_found ();
 case 52:
 /* rule 52 can match eol */
 YY_RULE_SETUP
-#line 466 "lexgrog.l"
+#line 471 "lexgrog.l"
 fill_mode = 0;
 	YY_BREAK
 case 53:
 /* rule 53 can match eol */
 YY_RULE_SETUP
-#line 467 "lexgrog.l"
+#line 472 "lexgrog.l"
 fill_mode = 1;
 	YY_BREAK
 
 case 54:
 /* rule 54 can match eol */
 YY_RULE_SETUP
-#line 470 "lexgrog.l"
+#line 475 "lexgrog.l"
 /* strip continuations */
 	YY_BREAK
 /* convert to DASH */
 
 case 55:
 /* rule 55 can match eol */
-#line 475 "lexgrog.l"
+#line 480 "lexgrog.l"
 case 56:
 /* rule 56 can match eol */
-#line 476 "lexgrog.l"
+#line 481 "lexgrog.l"
 case 57:
 /* rule 57 can match eol */
-#line 477 "lexgrog.l"
+#line 482 "lexgrog.l"
 case 58:
 /* rule 58 can match eol */
-#line 478 "lexgrog.l"
+#line 483 "lexgrog.l"
 case 59:
 /* rule 59 can match eol */
 YY_RULE_SETUP
-#line 478 "lexgrog.l"
+#line 483 "lexgrog.l"
 {
 		add_separator_to_whatis ();
 		BEGIN (MAN_DESC);
@@ -3508,7 +3513,7 @@ YY_RULE_SETUP
 case 60:
 /* rule 60 can match eol */
 YY_RULE_SETUP
-#line 483 "lexgrog.l"
+#line 488 "lexgrog.l"
 add_separator_to_whatis ();
 	YY_BREAK
 /* escape sequences and special characters */
@@ -3516,147 +3521,147 @@ add_separator_to_whatis ();
 case 61:
 /* rule 61 can match eol */
 YY_RULE_SETUP
-#line 487 "lexgrog.l"
+#line 492 "lexgrog.l"
 add_char_to_whatis ('\\');
 	YY_BREAK
 case 62:
 /* rule 62 can match eol */
 YY_RULE_SETUP
-#line 488 "lexgrog.l"
+#line 493 "lexgrog.l"
 add_char_to_whatis ('\'');
 	YY_BREAK
 case 63:
 /* rule 63 can match eol */
 YY_RULE_SETUP
-#line 489 "lexgrog.l"
+#line 494 "lexgrog.l"
 add_char_to_whatis ('`');
 	YY_BREAK
 case 64:
 /* rule 64 can match eol */
 YY_RULE_SETUP
-#line 490 "lexgrog.l"
+#line 495 "lexgrog.l"
 add_char_to_whatis ('-');
 	YY_BREAK
 case 65:
 /* rule 65 can match eol */
 YY_RULE_SETUP
-#line 491 "lexgrog.l"
+#line 496 "lexgrog.l"
 add_char_to_whatis ('-');
 	YY_BREAK
 case 66:
 /* rule 66 can match eol */
 YY_RULE_SETUP
-#line 492 "lexgrog.l"
+#line 497 "lexgrog.l"
 add_char_to_whatis ('.');
 	YY_BREAK
 case 67:
 /* rule 67 can match eol */
 YY_RULE_SETUP
-#line 493 "lexgrog.l"
+#line 498 "lexgrog.l"
 add_char_to_whatis (' ');
 	YY_BREAK
 case 68:
 /* rule 68 can match eol */
 YY_RULE_SETUP
-#line 494 "lexgrog.l"
+#line 499 "lexgrog.l"
 add_char_to_whatis ('_');
 	YY_BREAK
 case 69:
 /* rule 69 can match eol */
 YY_RULE_SETUP
-#line 495 "lexgrog.l"
+#line 500 "lexgrog.l"
 add_char_to_whatis ('\t');
 	YY_BREAK
 case 70:
 /* rule 70 can match eol */
 YY_RULE_SETUP
-#line 497 "lexgrog.l"
+#line 502 "lexgrog.l"
 /* various useless control chars */
 	YY_BREAK
 case 71:
 /* rule 71 can match eol */
 YY_RULE_SETUP
-#line 498 "lexgrog.l"
+#line 503 "lexgrog.l"
 /* various inline functions */
 	YY_BREAK
 case 72:
 /* rule 72 can match eol */
 YY_RULE_SETUP
-#line 500 "lexgrog.l"
+#line 505 "lexgrog.l"
 /* interpolate arg */
 	YY_BREAK
 /* roff named glyphs */
 case 73:
 /* rule 73 can match eol */
 YY_RULE_SETUP
-#line 503 "lexgrog.l"
+#line 508 "lexgrog.l"
 add_glyph_to_whatis (yytext + 2, 2);
 	YY_BREAK
 /* perldoc strings */
 case 74:
 /* rule 74 can match eol */
 YY_RULE_SETUP
-#line 505 "lexgrog.l"
+#line 510 "lexgrog.l"
 add_perldoc_to_whatis (yytext + 3, 2);
 	YY_BREAK
 case 75:
 /* rule 75 can match eol */
 YY_RULE_SETUP
-#line 506 "lexgrog.l"
+#line 511 "lexgrog.l"
 add_perldoc_to_whatis (yytext + 2, 1);
 	YY_BREAK
 case 76:
 /* rule 76 can match eol */
 YY_RULE_SETUP
-#line 508 "lexgrog.l"
+#line 513 "lexgrog.l"
 /* comment */
 	YY_BREAK
 case 77:
 /* rule 77 can match eol */
 YY_RULE_SETUP
-#line 510 "lexgrog.l"
+#line 515 "lexgrog.l"
 /* font changes */
 	YY_BREAK
 case 78:
 /* rule 78 can match eol */
 YY_RULE_SETUP
-#line 511 "lexgrog.l"
+#line 516 "lexgrog.l"
 /* mark input place in register */
 	YY_BREAK
 case 79:
 /* rule 79 can match eol */
 YY_RULE_SETUP
-#line 513 "lexgrog.l"
+#line 518 "lexgrog.l"
 /* interpolate number register */
 	YY_BREAK
 case 80:
 /* rule 80 can match eol */
 YY_RULE_SETUP
-#line 514 "lexgrog.l"
+#line 519 "lexgrog.l"
 /* overstrike chars */
 	YY_BREAK
 case 81:
 /* rule 81 can match eol */
 YY_RULE_SETUP
-#line 516 "lexgrog.l"
+#line 521 "lexgrog.l"
 /* size changes */
 	YY_BREAK
 case 82:
 /* rule 82 can match eol */
 YY_RULE_SETUP
-#line 517 "lexgrog.l"
+#line 522 "lexgrog.l"
 /* width of string */
 	YY_BREAK
 case 83:
 /* rule 83 can match eol */
 YY_RULE_SETUP
-#line 519 "lexgrog.l"
+#line 524 "lexgrog.l"
 /* catch all */
 	YY_BREAK
 case 84:
 /* rule 84 can match eol */
 YY_RULE_SETUP
-#line 521 "lexgrog.l"
+#line 526 "lexgrog.l"
 /* function() in hpux */
 	YY_BREAK
 
@@ -3667,49 +3672,49 @@ YY_RULE_SETUP
 case 85:
 /* rule 85 can match eol */
 YY_RULE_SETUP
-#line 528 "lexgrog.l"
+#line 533 "lexgrog.l"
 BEGIN (MAN_DESC_AT);
 	YY_BREAK
 case 86:
 /* rule 86 can match eol */
 YY_RULE_SETUP
-#line 529 "lexgrog.l"
+#line 534 "lexgrog.l"
 BEGIN (MAN_DESC_BSX);
 	YY_BREAK
 case 87:
 /* rule 87 can match eol */
 YY_RULE_SETUP
-#line 530 "lexgrog.l"
+#line 535 "lexgrog.l"
 BEGIN (MAN_DESC_BX);
 	YY_BREAK
 case 88:
 /* rule 88 can match eol */
 YY_RULE_SETUP
-#line 531 "lexgrog.l"
+#line 536 "lexgrog.l"
 BEGIN (MAN_DESC_FX);
 	YY_BREAK
 case 89:
 /* rule 89 can match eol */
 YY_RULE_SETUP
-#line 532 "lexgrog.l"
+#line 537 "lexgrog.l"
 BEGIN (MAN_DESC_NX);
 	YY_BREAK
 case 90:
 /* rule 90 can match eol */
 YY_RULE_SETUP
-#line 533 "lexgrog.l"
+#line 538 "lexgrog.l"
 BEGIN (MAN_DESC_OX);
 	YY_BREAK
 case 91:
 /* rule 91 can match eol */
 YY_RULE_SETUP
-#line 534 "lexgrog.l"
+#line 539 "lexgrog.l"
 add_word_to_whatis ("UNIX");
 	YY_BREAK
 case 92:
 /* rule 92 can match eol */
 YY_RULE_SETUP
-#line 536 "lexgrog.l"
+#line 541 "lexgrog.l"
 {
 		add_word_to_whatis ("\"");
 		BEGIN (MAN_DESC_DQ);
@@ -3719,73 +3724,73 @@ YY_RULE_SETUP
 
 case 93:
 YY_RULE_SETUP
-#line 543 "lexgrog.l"
+#line 548 "lexgrog.l"
 mdoc_text ("Version 32V AT&T UNIX");
 	YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 544 "lexgrog.l"
+#line 549 "lexgrog.l"
 mdoc_text ("Version 1 AT&T UNIX");
 	YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 545 "lexgrog.l"
+#line 550 "lexgrog.l"
 mdoc_text ("Version 2 AT&T UNIX");
 	YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 546 "lexgrog.l"
+#line 551 "lexgrog.l"
 mdoc_text ("Version 3 AT&T UNIX");
 	YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 547 "lexgrog.l"
+#line 552 "lexgrog.l"
 mdoc_text ("Version 4 AT&T UNIX");
 	YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 548 "lexgrog.l"
+#line 553 "lexgrog.l"
 mdoc_text ("Version 5 AT&T UNIX");
 	YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 549 "lexgrog.l"
+#line 554 "lexgrog.l"
 mdoc_text ("Version 6 AT&T UNIX");
 	YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 550 "lexgrog.l"
+#line 555 "lexgrog.l"
 mdoc_text ("Version 7 AT&T UNIX");
 	YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 551 "lexgrog.l"
+#line 556 "lexgrog.l"
 mdoc_text ("AT&T System V UNIX");
 	YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 552 "lexgrog.l"
+#line 557 "lexgrog.l"
 mdoc_text ("AT&T System V.1 UNIX");
 	YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 553 "lexgrog.l"
+#line 558 "lexgrog.l"
 mdoc_text ("AT&T System V.2 UNIX");
 	YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 554 "lexgrog.l"
+#line 559 "lexgrog.l"
 mdoc_text ("AT&T System V.3 UNIX");
 	YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 555 "lexgrog.l"
+#line 560 "lexgrog.l"
 mdoc_text ("AT&T System V.4 UNIX");
 	YY_BREAK
 case 106:
 /* rule 106 can match eol */
 YY_RULE_SETUP
-#line 556 "lexgrog.l"
+#line 561 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("AT&T UNIX");
@@ -3795,7 +3800,7 @@ YY_RULE_SETUP
 
 case 107:
 YY_RULE_SETUP
-#line 563 "lexgrog.l"
+#line 568 "lexgrog.l"
 {
 		add_word_to_whatis ("BSD/OS");
 		add_wordn_to_whatis (yytext, yyleng);
@@ -3805,7 +3810,7 @@ YY_RULE_SETUP
 case 108:
 /* rule 108 can match eol */
 YY_RULE_SETUP
-#line 568 "lexgrog.l"
+#line 573 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("BSD/OS");
@@ -3815,22 +3820,22 @@ YY_RULE_SETUP
 
 case 109:
 YY_RULE_SETUP
-#line 575 "lexgrog.l"
+#line 580 "lexgrog.l"
 mdoc_text ("BSD (currently in alpha test)");
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 576 "lexgrog.l"
+#line 581 "lexgrog.l"
 mdoc_text ("BSD (currently in beta test)");
 	YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 577 "lexgrog.l"
+#line 582 "lexgrog.l"
 mdoc_text ("BSD (currently under development");
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 578 "lexgrog.l"
+#line 583 "lexgrog.l"
 {
 		add_wordn_to_whatis (yytext, yyleng);
 		add_str_to_whatis ("BSD", 3);
@@ -3840,7 +3845,7 @@ YY_RULE_SETUP
 case 113:
 /* rule 113 can match eol */
 YY_RULE_SETUP
-#line 583 "lexgrog.l"
+#line 588 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("BSD");
@@ -3850,7 +3855,7 @@ YY_RULE_SETUP
 
 case 114:
 YY_RULE_SETUP
-#line 590 "lexgrog.l"
+#line 595 "lexgrog.l"
 {
 		add_str_to_whatis ("-Reno", 5);
 		BEGIN (MAN_DESC);
@@ -3858,7 +3863,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 594 "lexgrog.l"
+#line 599 "lexgrog.l"
 {
 		add_str_to_whatis ("-Tahoe", 6);
 		BEGIN (MAN_DESC);
@@ -3866,7 +3871,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 598 "lexgrog.l"
+#line 603 "lexgrog.l"
 {
 		add_str_to_whatis ("-Lite", 5);
 		BEGIN (MAN_DESC);
@@ -3874,7 +3879,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 602 "lexgrog.l"
+#line 607 "lexgrog.l"
 {
 		add_str_to_whatis ("-Lite2", 6);
 		BEGIN (MAN_DESC);
@@ -3883,7 +3888,7 @@ YY_RULE_SETUP
 case 118:
 /* rule 118 can match eol */
 YY_RULE_SETUP
-#line 606 "lexgrog.l"
+#line 611 "lexgrog.l"
 {
 		yyless (0);
 		BEGIN (MAN_DESC);
@@ -3892,7 +3897,7 @@ YY_RULE_SETUP
 
 case 119:
 YY_RULE_SETUP
-#line 612 "lexgrog.l"
+#line 617 "lexgrog.l"
 {
 	add_str_to_whatis (yytext, yyleng);
 	add_char_to_whatis ('"');
@@ -3902,7 +3907,7 @@ YY_RULE_SETUP
 
 case 120:
 YY_RULE_SETUP
-#line 619 "lexgrog.l"
+#line 624 "lexgrog.l"
 {
 		add_word_to_whatis ("FreeBSD");
 		add_wordn_to_whatis (yytext, yyleng);
@@ -3912,7 +3917,7 @@ YY_RULE_SETUP
 case 121:
 /* rule 121 can match eol */
 YY_RULE_SETUP
-#line 624 "lexgrog.l"
+#line 629 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("FreeBSD");
@@ -3922,7 +3927,7 @@ YY_RULE_SETUP
 
 case 122:
 YY_RULE_SETUP
-#line 631 "lexgrog.l"
+#line 636 "lexgrog.l"
 {
 		add_word_to_whatis ("NetBSD");
 		add_wordn_to_whatis (yytext, yyleng);
@@ -3932,7 +3937,7 @@ YY_RULE_SETUP
 case 123:
 /* rule 123 can match eol */
 YY_RULE_SETUP
-#line 636 "lexgrog.l"
+#line 641 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("NetBSD");
@@ -3942,7 +3947,7 @@ YY_RULE_SETUP
 
 case 124:
 YY_RULE_SETUP
-#line 643 "lexgrog.l"
+#line 648 "lexgrog.l"
 {
 		add_word_to_whatis ("OpenBSD");
 		add_wordn_to_whatis (yytext, yyleng);
@@ -3952,7 +3957,7 @@ YY_RULE_SETUP
 case 125:
 /* rule 125 can match eol */
 YY_RULE_SETUP
-#line 648 "lexgrog.l"
+#line 653 "lexgrog.l"
 {
 		yyless (0);
 		mdoc_text ("OpenBSD");
@@ -3963,7 +3968,7 @@ YY_RULE_SETUP
 case 126:
 /* rule 126 can match eol */
 YY_RULE_SETUP
-#line 655 "lexgrog.l"
+#line 660 "lexgrog.l"
 add_char_to_whatis (' ');
 	YY_BREAK
 /* a ROFF break request, a paragraph request, or an indentation change
@@ -3972,29 +3977,29 @@ add_char_to_whatis (' ');
 
 case 127:
 /* rule 127 can match eol */
-#line 662 "lexgrog.l"
+#line 667 "lexgrog.l"
 case 128:
 /* rule 128 can match eol */
-#line 663 "lexgrog.l"
+#line 668 "lexgrog.l"
 case 129:
 /* rule 129 can match eol */
-#line 664 "lexgrog.l"
+#line 669 "lexgrog.l"
 case 130:
 /* rule 130 can match eol */
-#line 665 "lexgrog.l"
+#line 670 "lexgrog.l"
 case 131:
 /* rule 131 can match eol */
-#line 666 "lexgrog.l"
+#line 671 "lexgrog.l"
 case 132:
 /* rule 132 can match eol */
-#line 667 "lexgrog.l"
+#line 672 "lexgrog.l"
 case 133:
 /* rule 133 can match eol */
-#line 668 "lexgrog.l"
+#line 673 "lexgrog.l"
 case 134:
 /* rule 134 can match eol */
 YY_RULE_SETUP
-#line 668 "lexgrog.l"
+#line 673 "lexgrog.l"
 {
 		add_char_to_whatis ((char) 0x11);
 		BEGIN (MAN_NAME);
@@ -4005,7 +4010,7 @@ YY_RULE_SETUP
 case 135:
 /* rule 135 can match eol */
 YY_RULE_SETUP
-#line 675 "lexgrog.l"
+#line 680 "lexgrog.l"
 {
 	*p_name = '\0';
 	BEGIN (MAN_REST);
@@ -4014,23 +4019,23 @@ YY_RULE_SETUP
 /* pass words as a chunk. speed optimization */
 case 136:
 YY_RULE_SETUP
-#line 681 "lexgrog.l"
+#line 686 "lexgrog.l"
 add_str_to_whatis (yytext, yyleng);
 	YY_BREAK
 /* normalise the comma (,) separators */
 case 137:
 /* rule 137 can match eol */
-#line 685 "lexgrog.l"
+#line 690 "lexgrog.l"
 case 138:
 /* rule 138 can match eol */
 YY_RULE_SETUP
-#line 685 "lexgrog.l"
+#line 690 "lexgrog.l"
 add_str_to_whatis (", ", 2);
 	YY_BREAK
 case 139:
 /* rule 139 can match eol */
 YY_RULE_SETUP
-#line 687 "lexgrog.l"
+#line 692 "lexgrog.l"
 {
 	newline_found ();
 	add_char_to_whatis (yytext[yyleng - 1]);
@@ -4038,7 +4043,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 692 "lexgrog.l"
+#line 697 "lexgrog.l"
 add_char_to_whatis (*yytext);
 	YY_BREAK
 /* default EOF rule */
@@ -4056,15 +4061,15 @@ case YY_STATE_EOF(CAT_FILE):
 case YY_STATE_EOF(MAN_FILE):
 case YY_STATE_EOF(CAT_REST):
 case YY_STATE_EOF(FORCE_EXIT):
-#line 695 "lexgrog.l"
+#line 700 "lexgrog.l"
 return 1;
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 697 "lexgrog.l"
+#line 702 "lexgrog.l"
 ECHO;
 	YY_BREAK
-#line 4068 "lexgrog.c"
+#line 4073 "lexgrog.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -5031,7 +5036,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 697 "lexgrog.l"
+#line 702 "lexgrog.l"
 
 
 /* print warning and force scanner to terminate */
@@ -5169,6 +5174,8 @@ static void newline_found (void)
 	waiting_for_quote = 0;
 }
 
+char tmpbuf[1048576];
+
 int find_name (const char *file, const char *filename, lexgrog *p_lg,
 	       const char *encoding)
 {
@@ -5176,6 +5183,33 @@ int find_name (const char *file, const c
 	pipeline *p;
 	char *page_encoding = NULL;
 
+#if 1
+	gzFile fp = gzopen(file, "r");
+	if (fp == NULL) {
+		error (0, errno, "%s", file);
+		return 0;
+	}
+
+	int num_bytes = gzread(fp, tmpbuf, sizeof(tmpbuf));
+	gzclose(fp);
+	if (num_bytes < 0) {
+		return 0;
+	}
+
+	decomp = tmpbuf;
+	decomp_end = tmpbuf + num_bytes;
+
+	// TODO: encoding
+	// if (!page_encoding && encoding)
+	// 	page_encoding = xstrdup (encoding);
+	// if (page_encoding)
+	// 	add_manconv (p, page_encoding, "UTF-8");
+
+	ret = find_name_decompressed (p, filename, p_lg);
+
+
+	return ret;
+#else
 	if (strcmp (file, "-") == 0) {
 		p = decompress_fdopen (dup (STDIN_FILENO));
 	} else {
@@ -5224,14 +5258,13 @@ int find_name (const char *file, const c
 	ret = find_name_decompressed (p, filename, p_lg);
 	pipeline_free (p);
 	return ret;
+#endif
 }
 
 int find_name_decompressed (pipeline *p, const char *filename, lexgrog *p_lg)
 {
 	int ret;
 
-	decomp = p;
-
 	fname = filename;
 	*(p_name = newname) = '\0';
 	memset (filters, '_', sizeof (filters));
@@ -5244,15 +5277,9 @@ int find_name_decompressed (pipeline *p,
 	else
 		BEGIN (MAN_FILE);
 
-	drop_effective_privs ();
-
 	yyrestart (NULL);
 	ret = yylex ();
 
-	regain_effective_privs ();
-
-	pipeline_wait (decomp);
-
 	if (ret)
 		return 0;
 	else {
--- man-db-2.9.4.orig/src/lexgrog.l
+++ man-db-2.9.4/src/lexgrog.l
@@ -3,6 +3,8 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#include "zlib.h"
+
 #include "manconfig.h"
 
 /* Flex emits several functions which might reasonably have various
@@ -230,14 +232,17 @@ static char filters[MAX_FILTERS];
 static int fill_mode;
 static int waiting_for_quote;
 
-static pipeline *decomp;
+//static pipeline *decomp;
+const char *decomp, *decomp_end;
 
 #define YY_INPUT(buf,result,max_size) { \
 	size_t size = max_size; \
-	const char *block = pipeline_read (decomp, &size); \
-	if (block && size != 0) { \
-		memcpy (buf, block, size); \
-		buf[size] = '\0'; \
+	if (max_size > decomp_end - decomp) { \
+		size = decomp_end - decomp; \
+	} \
+	if (size > 0) { \
+		memcpy (buf, decomp, size); \
+		decomp += size; \
 		result = size; \
 	} else \
 		result = YY_NULL; \
@@ -830,6 +835,8 @@ static void newline_found (void)
 	waiting_for_quote = 0;
 }
 
+char tmpbuf[1048576];
+
 int find_name (const char *file, const char *filename, lexgrog *p_lg,
 	       const char *encoding)
 {
@@ -837,6 +844,33 @@ int find_name (const char *file, const c
 	pipeline *p;
 	char *page_encoding = NULL;
 
+#if 1
+	gzFile fp = gzopen(file, "r");
+	if (fp == NULL) {
+		error (0, errno, "%s", file);
+		return 0;
+	}
+
+	int num_bytes = gzread(fp, tmpbuf, sizeof(tmpbuf));
+	gzclose(fp);
+	if (num_bytes < 0) {
+		return 0;
+	}
+
+	decomp = tmpbuf;
+	decomp_end = tmpbuf + num_bytes;
+
+	// TODO: encoding
+	// if (!page_encoding && encoding)
+	// 	page_encoding = xstrdup (encoding);
+	// if (page_encoding)
+	// 	add_manconv (p, page_encoding, "UTF-8");
+
+	ret = find_name_decompressed (p, filename, p_lg);
+
+
+	return ret;
+#else
 	if (strcmp (file, "-") == 0) {
 		p = decompress_fdopen (dup (STDIN_FILENO));
 	} else {
@@ -885,14 +919,13 @@ int find_name (const char *file, const c
 	ret = find_name_decompressed (p, filename, p_lg);
 	pipeline_free (p);
 	return ret;
+#endif
 }
 
 int find_name_decompressed (pipeline *p, const char *filename, lexgrog *p_lg)
 {
 	int ret;
 
-	decomp = p;
-
 	fname = filename;
 	*(p_name = newname) = '\0';
 	memset (filters, '_', sizeof (filters));
@@ -905,15 +938,9 @@ int find_name_decompressed (pipeline *p,
 	else
 		BEGIN (MAN_FILE);
 
-	drop_effective_privs ();
-
 	yyrestart (NULL);
 	ret = yylex ();
 
-	regain_effective_privs ();
-
-	pipeline_wait (decomp);
-
 	if (ret)
 		return 0;
 	else {
--- man-db-2.9.4.orig/src/ult_src.c
+++ man-db-2.9.4/src/ult_src.c
@@ -42,6 +42,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <unistd.h>
+#include <zlib.h>
 
 #include "canonicalize.h"
 #include "dirname.h"
@@ -327,19 +328,31 @@ const char *ult_src (const char *name, c
 		 * decompress_open doesn't keep its own copy.
 		 */
 		decomp_base = xstrdup (base);
-		decomp = decompress_open (decomp_base);
-		if (!decomp) {
+
+		char tmpbuf[4096];
+		gzFile fp = gzopen(decomp_base, "r");
+		if (fp == NULL) {
 			if (quiet < 2)
 				error (0, errno, _("can't open %s"), base);
 			free (decomp_base);
 			return NULL;
 		}
-		pipeline_start (decomp);
+
+		int num_bytes = gzread(fp, tmpbuf, sizeof(tmpbuf));
+		gzclose(fp);
+		if (num_bytes < 0) {
+			// FIXME: throw an error
+			return NULL;
+		}
+
+		FILE *memfp = fmemopen(tmpbuf, num_bytes, "r");
 
 		/* make sure that we skip over any comments */
+		char linebuf[4096];
 		do {
-			buffer = pipeline_readline (decomp);
+			buffer = fgets(linebuf, sizeof(linebuf), memfp);
 		} while (buffer && STRNEQ (buffer, ".\\\"", 3));
+		fclose(memfp);
 
 		include = test_for_include (buffer);
 		if (include) {
@@ -361,14 +374,10 @@ const char *ult_src (const char *name, c
 			free (new_name);
 			recurse--;
 
-			pipeline_wait (decomp);
-			pipeline_free (decomp);
 			free (decomp_base);
 			return ult;
 		}
 
-		pipeline_wait (decomp);
-		pipeline_free (decomp);
 		free (decomp_base);
 	}
 

Reply via email to