cvs commit: patches/zlib zlib-1.1.4-vsnprintf.patch

jim at linuxfromscratch.org jim at linuxfromscratch.org
Mon Sep 29 21:40:25 PDT 2003


jim         03/09/29 22:40:25

  Added:       bash     bash-2.05b-2.patch
               bison    bison-1.875-attribute.patch
               coreutils coreutils-5.0-hostname-2.patch
                        coreutils-5.0-uname.patch
               ed       ed-0.2.patch
               expect   expect-5.39.0.patch
               gawk     gawk-3.1.3.patch
               gcc      gcc-2.95.3-2.patch gcc-2.95.3-no-fixinc.patch
                        gcc-2.95.3-returntype-fix.patch
                        gcc-3.3.1-no_fixincludes-2.patch
                        gcc-3.3.1-specs-2.patch
                        gcc-3.3.1-suppress-libiberty.patch
               kbd      kbd-1.08.patch
               man      man-1.5m2-80cols.patch man-1.5m2-manpath.patch
                        man-1.5m2-pager.patch
               ncurses  ncurses-5.3-etip-2.patch ncurses-5.3-vsscanf.patch
               procps   procps-3.1.11.patch
               shadow   shadow-4.0.3-newgrp-fix.patch
               zlib     zlib-1.1.4-vsnprintf.patch
  Log:
  Added: LFS patches for 5.0 release
  
  Revision  Changes    Path
  1.1                  patches/bash/bash-2.05b-2.patch
  
  Index: bash-2.05b-2.patch
  ===================================================================
  Submitted by: Jeremy Utley <jeremy at linuxfromscratch.org>
  Date: 2003-08-28
  Version: 2
  Origin: ftp://ftp.gnu.org/gnu/bash
  Description: Integrates all 7 published bash-2.05b patches into a single
               patch file for LFS use.
  
  
  diff -Naur bash-2.05b/bashline.c bash-2.05b-new/bashline.c
  --- bash-2.05b/bashline.c	2002-05-07 15:52:42.000000000 -0400
  +++ bash-2.05b-new/bashline.c	2003-08-28 13:29:37.000000000 -0400
  @@ -1044,7 +1044,10 @@
   	}
         else
   	{
  +#define CMD_IS_DIR(x)	(absolute_pathname(x) == 0 && *(x) != '~' && test_for_directory (x))
  +
   	  matches = rl_completion_matches (text, command_word_completion_function);
  +
   	  /* If we are attempting command completion and nothing matches, we
   	     do not want readline to perform filename completion for us.  We
   	     still want to be able to complete partial pathnames, so set the
  @@ -1052,7 +1055,7 @@
   	     filenames and leave directories in the match list. */
   	  if (matches == (char **)NULL)
   	    rl_ignore_some_completions_function = bash_ignore_filenames;
  -	  else if (matches[1] == 0 && *matches[0] != '/')
  +	  else if (matches[1] == 0 && CMD_IS_DIR(matches[0]))
   	    /* Turn off rl_filename_completion_desired so readline doesn't
   	       append a slash if there is a directory with the same name
   	       in the current directory, or other filename-specific things.
  @@ -1061,7 +1064,7 @@
   	       looking in the current directory anyway, so there's no
   	       conflict. */
   	    rl_filename_completion_desired = 0;
  -	  else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && *matches[0] != '/')
  +	  else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0]))
   	    /* There are multiple instances of the same match (duplicate
   	       completions haven't yet been removed).  In this case, all of
   	       the matches will be the same, and the duplicate removal code
  diff -Naur bash-2.05b/lib/readline/bind.c bash-2.05b-new/lib/readline/bind.c
  --- bash-2.05b/lib/readline/bind.c	2002-01-24 11:15:52.000000000 -0500
  +++ bash-2.05b-new/lib/readline/bind.c	2003-08-28 13:29:37.000000000 -0400
  @@ -311,7 +311,7 @@
   	     mapped to something, `abc' to be mapped to something else,
   	     and the function bound  to `a' to be executed when the user
   	     types `abx', leaving `bx' in the input queue. */
  -	  if (k.function /* && k.type == ISFUNC */)
  +	  if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
   	    {
   	      map[ANYOTHERKEY] = k;
   	      k.function = 0;
  diff -Naur bash-2.05b/lib/readline/display.c bash-2.05b-new/lib/readline/display.c
  --- bash-2.05b/lib/readline/display.c	2002-06-04 10:54:47.000000000 -0400
  +++ bash-2.05b-new/lib/readline/display.c	2003-08-28 13:29:37.000000000 -0400
  @@ -70,7 +70,7 @@
   static void cr PARAMS((void));
   
   #if defined (HANDLE_MULTIBYTE)
  -static int _rl_col_width PARAMS((char *, int, int));
  +static int _rl_col_width PARAMS((const char *, int, int));
   static int *_rl_wrapped_line;
   #else
   #  define _rl_col_width(l, s, e)	(((e) <= (s)) ? 0 : (e) - (s))
  @@ -1348,9 +1348,9 @@
   	    {
   	      _rl_output_some_chars (nfd + lendiff, temp - lendiff);
   #if 0
  -	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;
  -#else
   	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
  +#else
  +	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
   #endif
   	    }
   	}
  @@ -1510,8 +1510,15 @@
   #if defined (HANDLE_MULTIBYTE)
     /* If we have multibyte characters, NEW is indexed by the buffer point in
        a multibyte string, but _rl_last_c_pos is the display position.  In
  -     this case, NEW's display position is not obvious. */
  -  if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;
  +     this case, NEW's display position is not obvious and must be
  +     calculated. */
  +  if (MB_CUR_MAX == 1 || rl_byte_oriented)
  +    {
  +      if (_rl_last_c_pos == new)
  +	return;
  +    }
  +  else if (_rl_last_c_pos == _rl_col_width (data, 0, new))
  +    return;
   #else
     if (_rl_last_c_pos == new) return;
   #endif
  @@ -1594,11 +1601,7 @@
   #endif
       {
         if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
  -	{
  -	  tputs (_rl_term_cr, 1, _rl_output_character_function);
  -	  for (i = 0; i < new; i++)
  -	    putc (data[i], rl_outstream);
  -	}
  +	_rl_backspace (_rl_last_c_pos - _rl_col_width (data, 0, new));
         else
   	_rl_backspace (_rl_last_c_pos - new);
       }
  @@ -2117,7 +2120,7 @@
      scan from the beginning of the string to take the state into account. */
   static int
   _rl_col_width (str, start, end)
  -     char *str;
  +     const char *str;
        int start, end;
   {
     wchar_t wc;
  @@ -2193,4 +2196,3 @@
     return width;
   }
   #endif /* HANDLE_MULTIBYTE */
  -	  
  diff -Naur bash-2.05b/lib/readline/mbutil.c bash-2.05b-new/lib/readline/mbutil.c
  --- bash-2.05b/lib/readline/mbutil.c	2002-06-04 11:54:29.000000000 -0400
  +++ bash-2.05b-new/lib/readline/mbutil.c	2003-08-28 13:29:37.000000000 -0400
  @@ -205,14 +205,16 @@
     if (tmp == (size_t)(-2))
       {
         /* shorted to compose multibyte char */
  -      memset (ps, 0, sizeof(mbstate_t));
  +      if (ps)
  +	memset (ps, 0, sizeof(mbstate_t));
         return -2;
       }
     else if (tmp == (size_t)(-1))
       {
         /* invalid to compose multibyte char */
         /* initialize the conversion state */
  -      memset (ps, 0, sizeof(mbstate_t));
  +      if (ps)
  +	memset (ps, 0, sizeof(mbstate_t));
         return -1;
       }
     else if (tmp == (size_t)0)
  @@ -225,9 +227,12 @@
      return 1. Otherwise return 0. */
   int
   _rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
  -     char *buf1, *buf2;
  -     mbstate_t *ps1, *ps2;
  -     int pos1, pos2;
  +     char *buf1;
  +     int pos1;
  +     mbstate_t *ps1;
  +     char *buf2;
  +     int pos2;
  +     mbstate_t *ps2;
   {
     int i, w1, w2;
   
  @@ -276,8 +281,11 @@
   	  pos++;
   	  /* clear the state of the byte sequence, because
   	     in this case effect of mbstate is undefined  */
  -	  memset (ps, 0, sizeof (mbstate_t));
  +	  if (ps)
  +	    memset (ps, 0, sizeof (mbstate_t));
   	}
  +      else if (tmp == 0)
  +	pos++;
         else
   	pos += tmp;
       }
  diff -Naur bash-2.05b/lib/readline/readline.c bash-2.05b-new/lib/readline/readline.c
  --- bash-2.05b/lib/readline/readline.c	2002-03-13 17:10:46.000000000 -0500
  +++ bash-2.05b-new/lib/readline/readline.c	2003-08-28 13:29:37.000000000 -0400
  @@ -684,6 +684,7 @@
       }
   #if defined (VI_MODE)
     if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
  +      key != ANYOTHERKEY &&
         _rl_vi_textmod_command (key))
       _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
   #endif
  diff -Naur bash-2.05b/lib/readline/vi_mode.c bash-2.05b-new/lib/readline/vi_mode.c
  --- bash-2.05b/lib/readline/vi_mode.c	2002-05-23 13:27:58.000000000 -0400
  +++ bash-2.05b-new/lib/readline/vi_mode.c	2003-08-28 13:29:37.000000000 -0400
  @@ -680,7 +680,8 @@
        int count;
   {
     wchar_t wc;
  -  char mb[MB_LEN_MAX];
  +  char mb[MB_LEN_MAX+1];
  +  int mblen;
     mbstate_t ps;
   
     memset (&ps, 0, sizeof (mbstate_t));
  @@ -703,7 +704,9 @@
         /* Vi is kind of strange here. */
         if (wc)
   	{
  -	  wctomb (mb, wc);
  +	  mblen = wctomb (mb, wc);
  +	  if (mblen >= 0)
  +	    mb[mblen] = '\0';
   	  rl_begin_undo_group ();
   	  rl_delete (1, 0);
   	  rl_insert_text (mb);
  diff -Naur bash-2.05b/subst.c bash-2.05b-new/subst.c
  --- bash-2.05b/subst.c	2002-06-24 07:59:45.000000000 -0400
  +++ bash-2.05b-new/subst.c	2003-08-28 13:29:37.000000000 -0400
  @@ -1638,11 +1638,10 @@
   
   /* This performs word splitting and quoted null character removal on
      STRING. */
  -#if 0
  -#define issep(c)	((separators)[1] ? (member ((c), separators)) : (c) == (separators)[0])
  -#else
  -#define issep(c)	((separators)[1] ? isifs(c) : (c) == (separators)[0])
  -#endif
  +#define issep(c) \
  +	(((separators)[0]) ? ((separators)[1] ? isifs(c) \
  +					      : (c) == (separators)[0]) \
  +			   : 0)
   
   WORD_LIST *
   list_string (string, separators, quoted)
  
  
  
  1.1                  patches/bison/bison-1.875-attribute.patch
  
  Index: bison-1.875-attribute.patch
  ===================================================================
  --- bison-1.875/data/yacc.c	2002-12-28 03:36:02.000000000 -0500
  +++ bison-1.875a/data/yacc.c	2003-01-22 01:38:32.000000000 -0500
  @@ -1,7 +1,7 @@
   m4_divert(-1)                                                       -*- C -*-
   
   # Yacc compatible skeleton for Bison
  -# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002
  +# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003
   # Free Software Foundation, Inc.
   
   # This program is free software; you can redistribute it and/or modify
  @@ -134,7 +134,7 @@
   m4_divert(0)dnl
   @output @output_parser_name@
   b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
  -             [1984, 1989, 1990, 2000, 2001, 2002])[
  +             [1984, 1989, 1990, 2000, 2001, 2002, 2003])[
   
   /* As a special exception, when this file is copied by Bison into a
      Bison output file, you may use that output file without restriction.
  @@ -465,7 +465,15 @@
   
   #define YYACCEPT	goto yyacceptlab
   #define YYABORT		goto yyabortlab
  -#define YYERROR		goto yyerrlab1
  +#define YYERROR		]b4_location_if([do				\
  +			  {				\
  +			    yylerrsp = yylsp;		\
  +			    *++yylerrsp = yyloc;	\
  +			    goto yyerrlab1;		\
  +			  }				\
  +			while (0)],
  +			[goto yyerrlab1])[
  +
   
   /* Like YYERROR except do call yyerror.  This remains here temporarily
      to ease the transition to the new meaning of YYERROR, for GCC.
  @@ -1103,29 +1111,13 @@
   
     /* Else will try to reuse lookahead token after shifting the error
        token.  */
  -  goto yyerrlab2;
  +  goto yyerrlab1;
   
   
   /*----------------------------------------------------.
   | yyerrlab1 -- error raised explicitly by an action.  |
   `----------------------------------------------------*/
   yyerrlab1:
  -
  -  /* Suppress GCC warning that yyerrlab1 is unused when no action
  -     invokes YYERROR.  */
  -#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
  -  __attribute__ ((__unused__))
  -#endif
  -
  -]b4_location_if([  yylerrsp = yylsp;
  -  *++yylerrsp = yyloc;])[
  -  goto yyerrlab2;
  -
  -
  -/*---------------------------------------------------------------.
  -| yyerrlab2 -- pop states until the error token can be shifted.  |
  -`---------------------------------------------------------------*/
  -yyerrlab2:
     yyerrstatus = 3;	/* Each real token shifted decrements this.  */
   
     for (;;)
  @@ -1204,7 +1196,7 @@
   m4_if(b4_defines_flag, 0, [],
   [@output @output_header_name@
   b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
  -             [1984, 1989, 1990, 2000, 2001, 2002])
  +             [1984, 1989, 1990, 2000, 2001, 2002, 2003])
   
   /* As a special exception, when this file is copied by Bison into a
      Bison output file, you may use that output file without restriction.
  
  
  
  1.1                  patches/coreutils/coreutils-5.0-hostname-2.patch
  
  Index: coreutils-5.0-hostname-2.patch
  ===================================================================
  Submitted by: ttrepl at yahoo.de
  Date: 2003-09-09
  Initial Package Version: 5.0
  Description: Removes installation of hostname binary, and also suppresses
  tests on that binary.
  
  diff -Naur coreutils-5.0.orig/man/Makefile.in coreutils-5.0/man/Makefile.in
  --- coreutils-5.0.orig/man/Makefile.in	2003-04-02 16:28:42.000000000 +0200
  +++ coreutils-5.0/man/Makefile.in	2003-09-09 17:57:47.000000000 +0200
  @@ -152,7 +152,7 @@
     basename.1 cat.1 chgrp.1 chmod.1 chown.1 chroot.1 cksum.1 comm.1 \
     cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \
     echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \
  -  head.1 hostid.1 hostname.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
  +  head.1 hostid.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
     ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nice.1 nl.1 nohup.1 od.1 \
     paste.1 pathchk.1 pinky.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 readlink.1 \
     rm.1 rmdir.1 seq.1 sha1sum.1 shred.1 sleep.1 sort.1 split.1 stat.1 stty.1 \
  @@ -401,7 +401,6 @@
   groups.1:	$(common_dep)	$(srcdir)/groups.x	../src/groups.sh
   head.1:		$(common_dep)	$(srcdir)/head.x	../src/head.c
   hostid.1:	$(common_dep)	$(srcdir)/hostid.x	../src/hostid.c
  -hostname.1:	$(common_dep)	$(srcdir)/hostname.x	../src/hostname.c
   id.1:		$(common_dep)	$(srcdir)/id.x		../src/id.c
   install.1:	$(common_dep)	$(srcdir)/install.x	../src/install.c
   join.1:		$(common_dep)	$(srcdir)/join.x	../src/join.c
  @@ -481,7 +480,7 @@
   check-x-vs-1:
   	PATH=../src at PATH_SEPARATOR@$$PATH; export PATH;			\
   	t=ls-files.$$$$;						\
  -	(cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | sort > $$t;	\
  +	(cd $(srcdir) && ls -1 *.x) | grep -v 'hostname.x' | sed 's/\.x$$//' | sort > $$t;	\
   	echo $(dist_man_MANS) | fmt -w1 | sed 's/\.1$$//' | sort -u	\
   	  | diff - $$t || { rm $$t; exit 1; };				\
   	rm $$t
  diff -Naur coreutils-5.0.orig/README coreutils-5.0/README
  --- coreutils-5.0.orig/README	2003-03-29 15:24:00.000000000 +0100
  +++ coreutils-5.0/README	2003-09-09 17:36:56.000000000 +0200
  @@ -9,7 +9,7 @@
   
     basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd
     df dir dircolors dirname du echo env expand expr factor false fmt fold
  -  ginstall groups head hostid hostname id join kill link ln logname ls
  +  ginstall groups head hostid id join kill link ln logname ls
     md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr
     printenv printf ptx pwd readlink rm rmdir seq sha1sum shred sleep sort
     split stat stty su sum sync tac tail tee test touch tr true tsort tty
  diff -Naur coreutils-5.0.orig/src/Makefile.in coreutils-5.0/src/Makefile.in
  --- coreutils-5.0.orig/src/Makefile.in	2003-04-02 16:46:19.000000000 +0200
  +++ coreutils-5.0/src/Makefile.in	2003-09-09 17:36:38.000000000 +0200
  @@ -165,7 +165,7 @@
     cat cksum comm csplit cut expand fmt fold head join md5sum \
     nl od paste pr ptx sha1sum sort split sum tac tail tr tsort unexpand uniq wc \
     basename date dirname echo env expr factor false \
  -  hostname id kill logname pathchk printenv printf pwd seq sleep tee \
  +  id kill logname pathchk printenv printf pwd seq sleep tee \
     test true tty whoami yes \
     @OPTIONAL_BIN_PROGS@ @DF_PROG@
   
  @@ -305,7 +305,7 @@
   	tac$(EXEEXT) tail$(EXEEXT) tr$(EXEEXT) tsort$(EXEEXT) \
   	unexpand$(EXEEXT) uniq$(EXEEXT) wc$(EXEEXT) basename$(EXEEXT) \
   	date$(EXEEXT) dirname$(EXEEXT) echo$(EXEEXT) env$(EXEEXT) \
  -	expr$(EXEEXT) factor$(EXEEXT) false$(EXEEXT) hostname$(EXEEXT) \
  +	expr$(EXEEXT) factor$(EXEEXT) false$(EXEEXT) \
   	id$(EXEEXT) kill$(EXEEXT) logname$(EXEEXT) pathchk$(EXEEXT) \
   	printenv$(EXEEXT) printf$(EXEEXT) pwd$(EXEEXT) seq$(EXEEXT) \
   	sleep$(EXEEXT) tee$(EXEEXT) test$(EXEEXT) true$(EXEEXT) \
  
  
  
  1.1                  patches/coreutils/coreutils-5.0-uname.patch
  
  Index: coreutils-5.0-uname.patch
  ===================================================================
  diff -urN coreutils-5.0.old/src/uname.c coreutils-5.0/src/uname.c
  --- coreutils-5.0.old/src/uname.c	2002-12-06 15:40:55.000000000 +0000
  +++ coreutils-5.0/src/uname.c	2003-04-30 22:28:16.000000000 +0100
  @@ -240,13 +240,19 @@
     if (toprint & PRINT_PROCESSOR)
       {
         char const *element = unknown;
  -#if HAVE_SYSINFO && defined SI_ARCHITECTURE
  -      {
  -	static char processor[257];
  -	if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
  -	  element = processor;
  +      char processor[BUFSIZ]="unknown";
  +      FILE *ffd;
  +      char temp_string[BUFSIZ];
  +
  +      if ((ffd=fopen("/proc/cpuinfo", "r") )!=NULL) {
  +              while ( fscanf(ffd, "%s :", temp_string) != EOF)
  +                      if (!(strcmp(temp_string, "vendor_id"))) {
  +                                      fscanf(ffd, "%s", processor);
  +                                      break;
  +                      }
  +              fclose(ffd);
         }
  -#endif
  +      element = processor;
   #ifdef UNAME_PROCESSOR
         if (element == unknown)
   	{
  
  
  
  1.1                  patches/ed/ed-0.2.patch
  
  Index: ed-0.2.patch
  ===================================================================
  diff -Naur ed-0.2/buf.c ed-0.2-2/buf.c
  --- ed-0.2/buf.c	Sat Nov 19 04:37:59 1994
  +++ ed-0.2-2/buf.c	Tue May 28 18:38:23 2002
  @@ -200,13 +200,13 @@
   int
   open_sbuf ()
   {
  -  char *mktemp ();
  -  int u;
  +  int u, sfd;
   
     isbinary = newline_added = 0;
     u = umask(077);
     strcpy (sfn, "/tmp/ed.XXXXXX");
  -  if (mktemp (sfn) == NULL || (sfp = fopen (sfn, "w+")) == NULL)
  +  sfd = mkstemp(sfn);
  +    if ((sfd == -1) || (sfp = fopen (sfn, "w+")) == NULL)
       {
         fprintf (stderr, "%s: %s\n", sfn, strerror (errno));
         sprintf (errmsg, "Cannot open temp file");
  
  
  
  1.1                  patches/expect/expect-5.39.0.patch
  
  Index: expect-5.39.0.patch
  ===================================================================
  diff -uNr expect-5.38.orig/exp_chan.c expect-5.38/exp_chan.c
  --- expect-5.38.orig/exp_chan.c	2002-02-12 13:00:55.000000000 +1100
  +++ expect-5.38/exp_chan.c	2003-03-01 10:36:18.000000000 +1100
  @@ -519,6 +519,7 @@
       esPtr->buffer = Tcl_NewStringObj("",0);
       Tcl_IncrRefCount(esPtr->buffer);
       esPtr->umsize = exp_default_match_max;
  +    esPtr->umsize_changed = exp_default_match_max_changed;
       /* this will reallocate object with an appropriate sized buffer */
       expAdjust(esPtr);
   
  diff -uNr expect-5.38.orig/exp_command.h expect-5.38/exp_command.h
  --- expect-5.38.orig/exp_command.h	2002-04-08 08:57:20.000000000 +1000
  +++ expect-5.38/exp_command.h	2003-03-01 10:36:18.000000000 +1100
  @@ -25,6 +25,7 @@
   EXTERN char *		exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
   
   EXTERN int exp_default_match_max;
  +EXTERN int exp_default_match_max_changed;
   EXTERN int exp_default_parity;
   EXTERN int exp_default_rm_nulls;
   
  @@ -97,6 +98,7 @@
       int msize;	        /* # of bytes that buffer can hold (max) */
       int umsize;	        /* # of bytes (min) that is guaranteed to match */
   			/* this comes from match_max command */
  +    int umsize_changed;	/* is umsize changed by user?  */
       int printed;	/* # of bytes written to stdout (if logging on) */
                           /* but not actually returned via a match yet */
       int echoed;	        /* additional # of bytes (beyond "printed" above) */
  diff -uNr expect-5.38.orig/expect.c expect-5.38/expect.c
  --- expect-5.38.orig/expect.c	2002-04-08 09:00:33.000000000 +1000
  +++ expect-5.38/expect.c	2003-03-01 10:36:18.000000000 +1100
  @@ -41,8 +41,17 @@
   #include "tcldbg.h"
   #endif
   
  +/* The initial length is 2000. We increment it by 2000. The maximum
  +   is 8MB (0x800000).  */
  +#define EXP_MATCH_MAX		2000
  +#define EXP_MATCH_INC		2000
  +#define EXP_MATCH_STEP_LIMIT	0x700000
  +#define EXP_MATCH_LIMIT		0x800000
  +#define EXP_MATCH_LIMIT_QUOTE	"0x800000"
  +
   /* initial length of strings that we can guarantee patterns can match */
  -int exp_default_match_max =	2000;
  +int exp_default_match_max =	EXP_MATCH_MAX;
  +int exp_default_match_max_changed = 0;
   #define INIT_EXPECT_TIMEOUT_LIT	"10"	/* seconds */
   #define INIT_EXPECT_TIMEOUT	10	/* seconds */
   int exp_default_parity =	TRUE;
  @@ -1618,6 +1627,76 @@
       return newsize;
   }
   
  +/* returns # of bytes until we see a newline at the end or EOF.  */
  +/*ARGSUSED*/
  +static int
  +expReadNewLine(interp,esPtr,save_flags) /* INTL */
  +Tcl_Interp *interp;
  +ExpState *esPtr;
  +int save_flags;
  +{
  +    int size;
  +    int exp_size;
  +    int full_size;
  +    int count;
  +    char *str;
  +
  +    count = 0;
  +    for (;;) {
  +	exp_size = expSizeGet(esPtr);
  +
  +	/* When we reach the limit, we will only read one char at a
  +	   time.  */
  +	if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT)
  +	    size = TCL_UTF_MAX;
  +	else
  +	    size = exp_size;
  +
  +	if (exp_size + TCL_UTF_MAX >= esPtr->msize) {
  +	    if (esPtr->umsize >= EXP_MATCH_LIMIT) {
  +		expDiagLogU("WARNING: interact buffer is full. probably your program\r\n");
  +		expDiagLogU("is not interactive or has a very long output line. The\r\n");
  +		expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n");
  +		expDiagLogU("Dumping first half of buffer in order to continue\r\n");
  +		expDiagLogU("Recommend you enlarge the buffer.\r\n");
  +		exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
  +		return count;
  +	    }
  +	    else {
  +		esPtr->umsize += EXP_MATCH_INC;
  +		expAdjust(esPtr);
  +	    }
  +	}
  +
  +	full_size = esPtr->msize - (size / TCL_UTF_MAX);
  +	size = Tcl_ReadChars(esPtr->channel,
  +			esPtr->buffer,
  +			full_size,
  +			1 /* append */);
  +	if (size > 0) {
  +	    count += size;
  +	    /* We try again if there are more to read and we haven't
  +	       seen a newline at the end. */
  +	    if (size == full_size) {
  +		str = Tcl_GetStringFromObj(esPtr->buffer, &size);
  +		if (str[size - 1] != '\n')
  +		    continue;
  +	    }
  +	}
  +	else {
  +	    /* It is even trickier. We got an error from read. We have
  +	       to recover from it. Let's make sure the size of
  +	       buffer is correct. It can be corrupted. */
  +	    str = Tcl_GetString(esPtr->buffer);
  +	    Tcl_SetObjLength(esPtr->buffer, strlen(str));
  +	}
  +
  +	break;
  +    }
  +
  +    return count;
  +}
  +
   /* returns # of bytes read or (non-positive) error of form EXP_XXX */
   /* returns 0 for end of file */
   /* If timeout is non-zero, set an alarm before doing the read, else assume */
  @@ -1632,6 +1711,8 @@
   {
       int cc = EXP_TIMEOUT;
       int size = expSizeGet(esPtr);
  +    int full_size;
  +    int count;
   
       if (size + TCL_UTF_MAX >= esPtr->msize) 
   	exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
  @@ -1648,11 +1729,43 @@
       }
   #endif
   
  -    
  +    /* FIXME: If we ask less than what is available in the tcl buffer
  +       when tcl has seen EOF, we will throw away the remaining data
  +       since the next read will get EOF. Since expect is line-oriented,
  +       we exand our buffer to get EOF or the next newline at the end of
  +       the input buffer. I don't know if it is the right fix.  H.J. */
  +    count = 0;
  +    full_size = esPtr->msize - (size / TCL_UTF_MAX);
       cc = Tcl_ReadChars(esPtr->channel,
  -	    esPtr->buffer,
  -	    esPtr->msize - (size / TCL_UTF_MAX),
  -	    1 /* append */);
  +		esPtr->buffer,
  +		full_size,
  +		1 /* append */);
  +    if (cc > 0) {
  +	count += cc;
  +	/* It gets very tricky. There are more to read. We will expand
  +	   our buffer and get EOF or a newline at the end unless the
  +	   buffer length has been changed.  */
  +	if (cc == full_size) {
  +	    char *str;
  +	    str = Tcl_GetStringFromObj(esPtr->buffer, &size);
  +	    if (str[size - 1] != '\n') {
  +		if (esPtr->umsize_changed) {
  +		    char buf[20];	/* big enough for 64bit int in hex.  */
  +		    snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize);
  +		    expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n");
  +		    expDiagLogU("all output. probably your program is not interactive or\r\n");
  +		    expDiagLogU("has a very long output line. The current limit is ");
  +		    expDiagLogU(buf);
  +		    expDiagLogU(".\r\n");
  +		}
  +		else {
  +		    cc = expReadNewLine(interp,esPtr,save_flags);
  +		    if (cc > 0)
  +			count += cc;
  +		}
  +	    }
  +	}
  +    }
       i_read_errno = errno;
   
   #ifdef SIMPLE_EVENT
  @@ -1673,7 +1786,7 @@
   	}
       }
   #endif
  -    return cc;	
  +    return count > 0 ? count : cc;
   }
   
   /*
  @@ -2746,8 +2859,14 @@
   	return(TCL_ERROR);
       }
   
  -    if (Default) exp_default_match_max = size;
  -    else esPtr->umsize = size;
  +    if (Default) {
  +	exp_default_match_max = size;
  +	exp_default_match_max_changed = 1;
  +    }
  +    else {
  +	esPtr->umsize = size;
  +	esPtr->umsize_changed = 1;
  +    }
   
       return(TCL_OK);
   }
  
  
  
  1.1                  patches/gawk/gawk-3.1.3.patch
  
  Index: gawk-3.1.3.patch
  ===================================================================
  diff -Naur gawk-3.1.3-orig/Makefile.in gawk-3.1.3/Makefile.in
  --- gawk-3.1.3-orig/Makefile.in	2003-07-10 14:36:14.000000000 +0000
  +++ gawk-3.1.3/Makefile.in	2003-07-10 14:37:50.000000000 +0000
  @@ -261,7 +261,7 @@
   
   # Get extra libs as needed
   LDADD = @LIBINTL@ @SOCKET_LIBS@
  -awkdatadir = @datadir@/awk
  +awkdatadir = @datadir@/gawk-3.1.3
   
   # stuff for compiling gawk/pgawk
   DEFPATH = "\".$(PATH_SEPARATOR)$(awkdatadir)\""
  diff -Naur gawk-3.1.3-orig/awklib/Makefile.in gawk-3.1.3/awklib/Makefile.in
  --- gawk-3.1.3-orig/awklib/Makefile.in	2003-07-10 14:36:14.000000000 +0000
  +++ gawk-3.1.3/awklib/Makefile.in	2003-07-10 14:39:16.000000000 +0000
  @@ -144,7 +144,7 @@
   build_os = @build_os@
   build_vendor = @build_vendor@
   
  -datadir = @datadir@/awk
  +datadir = @datadir@/gawk-3.1.3
   exec_prefix = @exec_prefix@
   host = @host@
   host_alias = @host_alias@
  @@ -155,7 +155,7 @@
   infodir = @infodir@
   install_sh = @install_sh@
   libdir = @libdir@
  -libexecdir = @libexecdir@/awk
  +libexecdir = @libexecdir@
   localstatedir = @localstatedir@
   mandir = @mandir@
   oldincludedir = @oldincludedir@
  @@ -487,7 +487,9 @@
   
   # libexecdir and datadir are removed in the top level Makefile's uninstall
   uninstall-local:
  -	rm -fr $(DESTDIR)$(libexecdir)/* $(DESTDIR)$(datadir)/*
  +	rm -f $(DESTDIR)$(libexecdir)/grcat
  +	rm -f $(DESTDIR)$(libexecdir)/pwcat
  +	rm -fr $(DESTDIR)$(datadir)
   	rm -f $(DESTDIR)$(bindir)/igawk
   
   clean-local:
  
  
  
  1.1                  patches/gcc/gcc-2.95.3-2.patch
  
  Index: gcc-2.95.3-2.patch
  ===================================================================
  diff -uNr gcc-2.95.3.orig/gcc/c-common.c gcc-2.95.3/gcc/c-common.c
  --- gcc-2.95.3.orig/gcc/c-common.c	Tue Sep  7 18:11:16 1999
  +++ gcc-2.95.3/gcc/c-common.c	Sat Aug 18 07:18:42 2001
  @@ -697,7 +697,23 @@
   	    if (exact_log2 (align) == -1)
   	      error ("requested alignment is not a power of 2");
   	    else if (is_type)
  -	      TYPE_ALIGN (type) = align;
  +	      {
  +		/* If we have a TYPE_DECL, then copy the type, so that we
  +		   don't accidentally modify a builtin type.  See pushdecl.  */
  +		if (decl && TREE_TYPE (decl) != error_mark_node
  +		    && DECL_ORIGINAL_TYPE (decl) == NULL_TREE)
  +		  {
  +		    tree tt = TREE_TYPE (decl);
  +		    DECL_ORIGINAL_TYPE (decl) = tt;
  +		    tt = build_type_copy (tt);
  +		    TYPE_NAME (tt) = decl;
  +		    TREE_USED (tt) = TREE_USED (decl);
  +		    TREE_TYPE (decl) = tt;
  +		    type = tt;
  +		  }
  +
  +		TYPE_ALIGN (type) = align;
  +	      }
   	    else if (TREE_CODE (decl) != VAR_DECL
   		     && TREE_CODE (decl) != FIELD_DECL)
   	      error_with_decl (decl,
  diff -uNr gcc-2.95.3.orig/gcc/config/alpha/crtbegin.asm gcc-2.95.3/gcc/config/alpha/crtbegin.asm
  --- gcc-2.95.3.orig/gcc/config/alpha/crtbegin.asm	Thu Dec 17 08:00:53 1998
  +++ gcc-2.95.3/gcc/config/alpha/crtbegin.asm	Sat Aug 18 07:18:42 2001
  @@ -97,6 +97,31 @@
    # Support recursive calls to exit.
   $ptr:	.quad	__DTOR_LIST__
   
  +/* A globally unique widget for c++ local destructors to hang off.
  +
  +   This has a unique value in every dso; in the main program its
  +   value is zero.  The object should be protected.  This means the
  +   instance in any dso or the main program is not used in any other
  +   dso.  The dynamic linker takes care of this.  */
  +
  +	.global __dso_handle
  +	.type __dso_handle, at object
  +	.size __dso_handle,8
  +#ifdef SHARED
  +.section .data
  +	.align 3
  +__dso_handle:
  +	.quad	__dso_handle
  +#else
  +.section .bss
  +	.align 3
  +__dso_handle:
  +	.zero 8
  +#endif
  +#ifdef HAVE_GAS_HIDDEN
  +	.hidden __dso_handle
  +#endif
  +
   .text
   
   	.align 3
  diff -uNr gcc-2.95.3.orig/gcc/config/i386/i386.c gcc-2.95.3/gcc/config/i386/i386.c
  --- gcc-2.95.3.orig/gcc/config/i386/i386.c	Tue Sep  7 17:38:56 1999
  +++ gcc-2.95.3/gcc/config/i386/i386.c	Sat Aug 18 07:18:42 2001
  @@ -291,7 +291,7 @@
   
     if (ix86_arch_string == 0)
       {
  -      ix86_arch_string = PROCESSOR_PENTIUM_STRING;
  +      ix86_arch_string = PROCESSOR_DEFAULT_STRING;
         if (ix86_cpu_string == 0)
   	ix86_cpu_string = PROCESSOR_DEFAULT_STRING;
       }
  @@ -308,7 +308,7 @@
     if (i == ptt_size)
       {
         error ("bad value (%s) for -march= switch", ix86_arch_string);
  -      ix86_arch_string = PROCESSOR_PENTIUM_STRING;
  +      ix86_arch_string = PROCESSOR_DEFAULT_STRING;
         ix86_arch = PROCESSOR_DEFAULT;
       }
   
  diff -uNr gcc-2.95.3.orig/gcc/config/i386/linux.h gcc-2.95.3/gcc/config/i386/linux.h
  --- gcc-2.95.3.orig/gcc/config/i386/linux.h	Thu Apr  8 10:32:13 1999
  +++ gcc-2.95.3/gcc/config/i386/linux.h	Sat Aug 18 07:18:42 2001
  @@ -234,3 +234,21 @@
       }									\
     } while (0)
   #endif
  +
  +#if defined(__PIC__) && defined (USE_GNULIBC_1)
  +/* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr,
  +   __environ and atexit (). We have to make sure they are in the .dynsym
  +   section. We accomplish it by making a dummy call here. This
  +   code is never reached.  */
  +         
  +#define CRT_END_INIT_DUMMY		\
  +  do					\
  +    {					\
  +      extern void *___brk_addr;		\
  +      extern char **__environ;		\
  +					\
  +      ___brk_addr = __environ;		\
  +      atexit (0);			\
  +    }					\
  +  while (0)
  +#endif
  diff -uNr gcc-2.95.3.orig/gcc/config/rs6000/rs6000.md gcc-2.95.3/gcc/config/rs6000/rs6000.md
  --- gcc-2.95.3.orig/gcc/config/rs6000/rs6000.md	Fri Jan 26 01:03:35 2001
  +++ gcc-2.95.3/gcc/config/rs6000/rs6000.md	Sat Aug 18 07:18:42 2001
  @@ -6184,7 +6184,9 @@
        reg.  So expand it.  */
     if (GET_CODE (operands[0]) == SUBREG
         && GET_CODE (SUBREG_REG (operands[0])) == REG
  -      && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
  +      && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER
  +      && (! REG_FUNCTION_VALUE_P (SUBREG_REG (operands[0]))
  +	  || ! rtx_equal_function_value_matters))
       operands[0] = alter_subreg (operands[0]);
     if (GET_CODE (operands[1]) == SUBREG
         && GET_CODE (SUBREG_REG (operands[1])) == REG
  diff -uNr gcc-2.95.3.orig/gcc/config.in gcc-2.95.3/gcc/config.in
  --- gcc-2.95.3.orig/gcc/config.in	Sat Mar 17 01:13:48 2001
  +++ gcc-2.95.3/gcc/config.in	Sat Aug 18 07:18:42 2001
  @@ -34,6 +34,9 @@
      emitting at the beginning of your section */
   #undef HAVE_GAS_SUBSECTION_ORDERING
   
  +/* Define if your assembler supports .hidden.  */
  +#undef HAVE_GAS_HIDDEN
  +
   /* Define if your assembler uses the old HImode fild and fist notation.  */
   #undef HAVE_GAS_FILDS_FISTS
   
  diff -uNr gcc-2.95.3.orig/gcc/configure gcc-2.95.3/gcc/configure
  --- gcc-2.95.3.orig/gcc/configure	Sat Mar 17 01:13:48 2001
  +++ gcc-2.95.3/gcc/configure	Sat Aug 18 07:18:42 2001
  @@ -1311,7 +1311,7 @@
   fi
   
   # Find some useful tools
  -for ac_prog in gawk mawk nawk awk
  +for ac_prog in mawk gawk nawk awk
   do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
   set dummy $ac_prog; ac_word=$2
  @@ -8229,8 +8229,26 @@
   fi
   echo "$ac_t""$gcc_cv_as_subsections" 1>&6
   
  +echo $ac_n "checking assembler hidden support""... $ac_c" 1>&6
  +echo "configure:8234: checking assembler hidden support" >&5
  +gcc_cv_as_hidden=
  +if test x$gcc_cv_as != x; then
  +	# Check if we have .hidden
  +	echo "  .hidden foobar" > conftest.s
  +	echo "foobar:" >> conftest.s
  +	if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
  +		cat >> confdefs.h <<\EOF
  +#define HAVE_GAS_HIDDEN 1
  +EOF
  +
  +		gcc_cv_as_hidden="yes"
  +	fi
  +	rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
  +fi
  +echo "$ac_t""$gcc_cv_as_hidden" 1>&6
  +
   echo $ac_n "checking assembler instructions""... $ac_c" 1>&6
  -echo "configure:8234: checking assembler instructions" >&5
  +echo "configure:8252: checking assembler instructions" >&5
   gcc_cv_as_instructions=
   if test x$gcc_cv_as != x; then
   	set "filds fists" "filds mem; fists mem"
  diff -uNr gcc-2.95.3.orig/gcc/configure.in gcc-2.95.3/gcc/configure.in
  --- gcc-2.95.3.orig/gcc/configure.in	Fri Jan 26 01:03:02 2001
  +++ gcc-2.95.3/gcc/configure.in	Sat Aug 18 07:18:42 2001
  @@ -4066,6 +4066,21 @@
   fi
   AC_MSG_RESULT($gcc_cv_as_subsections)
   
  +AC_MSG_CHECKING(assembler hidden support)
  +gcc_cv_as_hidden=
  +if test x$gcc_cv_as != x; then
  +	# Check if we have .hidden
  +	echo "  .hidden foobar" > conftest.s
  +	echo "foobar:" >> conftest.s
  +	if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
  +		AC_DEFINE(HAVE_GAS_HIDDEN, 1,
  +			[Define if your assembler supports .hidden.])
  +		gcc_cv_as_hidden="yes"
  +	fi
  +	rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
  +fi
  +AC_MSG_RESULT($gcc_cv_as_hidden)
  +
   AC_MSG_CHECKING(assembler instructions)
   gcc_cv_as_instructions=
   if test x$gcc_cv_as != x; then
  diff -uNr gcc-2.95.3.orig/gcc/crtstuff.c gcc-2.95.3/gcc/crtstuff.c
  --- gcc-2.95.3.orig/gcc/crtstuff.c	Tue Mar 23 11:43:51 1999
  +++ gcc-2.95.3/gcc/crtstuff.c	Sat Aug 18 07:18:42 2001
  @@ -55,6 +55,7 @@
   #include "defaults.h"
   #include <stddef.h>
   #include "frame.h"
  +#include "auto-host.h"
   
   /* We do not want to add the weak attribute to the declarations of these
      routines in frame.h because that will cause the definition of these
  @@ -134,6 +135,28 @@
   #ifdef INIT_SECTION_ASM_OP
   
   #ifdef OBJECT_FORMAT_ELF
  +/* Declare the __dso_handle variable.  It should have a unique value
  +   in every shared-object; in a main program its value is zero.  The
  +   object should in any case be protected.  This means the instance
  +   in one DSO or the main program is not used in another object.  The
  +   dynamic linker takes care of this.  */
  +
  +/* XXX Ideally the following should be implemented using
  +   __attribute__ ((__visibility__ ("hidden")))
  +   but the __attribute__ support is not yet there.  */
  +#ifdef HAVE_GAS_HIDDEN
  +asm (".hidden\t__dso_handle");
  +#endif
  +
  +#ifdef CRTSTUFFS_O
  +void *__dso_handle = &__dso_handle;
  +#else
  +void *__dso_handle = 0;
  +#endif
  +
  +/* The __cxa_finalize function may not be available so we use only a
  +   weak declaration.  */
  +extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
   
   /* Run all the global destructors on exit from the program.  */
    
  @@ -165,6 +188,11 @@
     if (completed)
       return;
   
  +#ifdef CRTSTUFFS_O
  +  if (__cxa_finalize)
  +    __cxa_finalize (__dso_handle);
  +#endif
  +
     while (*p)
       {
         p++;
  @@ -380,19 +408,8 @@
   #endif
     asm (TEXT_SECTION_ASM_OP);
   
  -/* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr,
  -   __environ and atexit (). We have to make sure they are in the .dynsym
  -   section. We accomplish it by making a dummy call here. This
  -   code is never reached.  */
  - 
  -#if defined(__linux__) && defined(__PIC__) && defined(__i386__)
  -  {
  -    extern void *___brk_addr;
  -    extern char **__environ;
  -
  -    ___brk_addr = __environ;
  -    atexit ();
  -  }
  +#ifdef CRT_END_INIT_DUMMY
  +  CRT_END_INIT_DUMMY;
   #endif
   }
   
  diff -uNr gcc-2.95.3.orig/gcc/cse.c gcc-2.95.3/gcc/cse.c
  --- gcc-2.95.3.orig/gcc/cse.c	Fri Jan 26 01:03:03 2001
  +++ gcc-2.95.3/gcc/cse.c	Sat Aug 18 07:18:42 2001
  @@ -695,8 +695,6 @@
   static struct cse_reg_info* get_cse_reg_info PROTO((int));
   static void free_cse_reg_info   PROTO((splay_tree_value));
   static void flush_hash_table	PROTO((void));
  -
  -extern int rtx_equal_function_value_matters;
   
   /* Dump the expressions in the equivalence class indicated by CLASSP.
      This function is used only for debugging.  */
  diff -uNr gcc-2.95.3.orig/gcc/cstamp-h.in gcc-2.95.3/gcc/cstamp-h.in
  --- gcc-2.95.3.orig/gcc/cstamp-h.in	Sat Mar 17 01:13:48 2001
  +++ gcc-2.95.3/gcc/cstamp-h.in	Sat Aug 18 07:19:11 2001
  @@ -1 +1 @@
  -timestamp
  +timestamp-fudged
  diff -uNr gcc-2.95.3.orig/gcc/function.c gcc-2.95.3/gcc/function.c
  --- gcc-2.95.3.orig/gcc/function.c	Fri Jan 26 01:03:15 2001
  +++ gcc-2.95.3/gcc/function.c	Sat Aug 18 07:18:42 2001
  @@ -5292,7 +5292,18 @@
   				- offset_ptr->constant); 
       }
   #else /* !ARGS_GROW_DOWNWARD */
  -  pad_to_arg_alignment (initial_offset_ptr, boundary);
  +  if (!in_regs 
  +#ifdef REG_PARM_STACK_SPACE
  +      || REG_PARM_STACK_SPACE (fndecl) > 0
  +#else
  +      /* For the gcc-2_95-branch we want to make sure not to break something
  +         on platforms which pass argument in registers but don't define
  +         REG_PARM_STACK_SPACE. So we force the original behaviour here.  */
  +      || 1
  +#endif
  +      )
  +    pad_to_arg_alignment (initial_offset_ptr, boundary);
  +
     *offset_ptr = *initial_offset_ptr;
   
   #ifdef PUSH_ROUNDING
  diff -uNr gcc-2.95.3.orig/gcc/rtl.h gcc-2.95.3/gcc/rtl.h
  --- gcc-2.95.3.orig/gcc/rtl.h	Fri Jan 26 01:03:22 2001
  +++ gcc-2.95.3/gcc/rtl.h	Sat Aug 18 07:18:42 2001
  @@ -168,7 +168,8 @@
        either changing how we compute the frame address or saving and
        restoring registers in the prologue and epilogue.  
        1 in a MEM if the MEM refers to a scalar, rather than a member of
  -     an aggregate.  */
  +     an aggregate.
  +     1 in a SYMBOL_REF if the symbol is weak.  */
     unsigned frame_related : 1;
     /* The first element of the operands of this rtx.
        The number of operands and their types are controlled
  @@ -661,6 +662,9 @@
   /* 1 means a SYMBOL_REF has been the library function in emit_library_call.  */
   #define SYMBOL_REF_USED(RTX) ((RTX)->used)
   
  +/* 1 means a SYMBOL_REF is weak.  */
  +#define SYMBOL_REF_WEAK(RTX) ((RTX)->frame_related)
  +
   /* For an INLINE_HEADER rtx, FIRST_FUNCTION_INSN is the first insn
      of the function that is not involved in copying parameters to
      pseudo-registers.  FIRST_PARM_INSN is the very first insn of
  @@ -888,6 +892,12 @@
   /* For a NOTE_INSN_LIVE note, the original basic block number.  */
   #define RANGE_LIVE_ORIG_BLOCK(INSN) (XINT (INSN, 1))
   
  +/* Nonzero if we need to distinguish between the return value of this function
  +   and the return value of a function called by this function.  This helps
  +   integrate.c.
  +   This is 1 until after the rtl generation pass.  */
  +extern int rtx_equal_function_value_matters;
  +
   /* Generally useful functions.  */
   
   /* The following functions accept a wide integer argument.  Rather than
  diff -uNr gcc-2.95.3.orig/gcc/rtlanal.c gcc-2.95.3/gcc/rtlanal.c
  --- gcc-2.95.3.orig/gcc/rtlanal.c	Fri Jan 26 01:03:22 2001
  +++ gcc-2.95.3/gcc/rtlanal.c	Sat Aug 18 07:18:42 2001
  @@ -136,11 +136,9 @@
     switch (code)
       {
       case SYMBOL_REF:
  +      return SYMBOL_REF_WEAK (x);
  +
       case LABEL_REF:
  -      /* SYMBOL_REF is problematic due to the possible presence of
  -	 a #pragma weak, but to say that loads from symbols can trap is
  -	 *very* costly.  It's not at all clear what's best here.  For
  -	 now, we ignore the impact of #pragma weak.  */
         return 0;
   
       case REG:
  diff -uNr gcc-2.95.3.orig/gcc/stor-layout.c gcc-2.95.3/gcc/stor-layout.c
  --- gcc-2.95.3.orig/gcc/stor-layout.c	Fri Mar 12 00:56:20 1999
  +++ gcc-2.95.3/gcc/stor-layout.c	Sat Aug 18 07:18:42 2001
  @@ -264,8 +264,8 @@
         if (spec_size == 0 && DECL_NAME (decl) != 0)
   	abort ();
   
  -      /* Size is specified number of bits.  */
  -      DECL_SIZE (decl) = size_int (spec_size);
  +      /* Size is specified in number of bits.  */
  +      DECL_SIZE (decl) = bitsize_int (spec_size, 0);
       }
     /* Force alignment required for the data type.
        But if the decl itself wants greater alignment, don't override that.
  @@ -301,7 +301,7 @@
   	  DECL_ALIGN (decl) = MAX ((unsigned) GET_MODE_ALIGNMENT (xmode),
   				   DECL_ALIGN (decl));
   	  DECL_MODE (decl) = xmode;
  -	  DECL_SIZE (decl) = size_int (GET_MODE_BITSIZE (xmode));
  +	  DECL_SIZE (decl) = bitsize_int (GET_MODE_BITSIZE (xmode), 0);
   	  /* This no longer needs to be accessed as a bit field.  */
   	  DECL_BIT_FIELD (decl) = 0;
   	}
  @@ -520,7 +520,7 @@
   	DECL_FIELD_BITPOS (field) = var_size;
         else
   	{
  -	  DECL_FIELD_BITPOS (field) = size_int (const_size);
  +	  DECL_FIELD_BITPOS (field) = bitsize_int (const_size, 0L);
   
   	  /* If this field ended up more aligned than we thought it
   	     would be (we approximate this by seeing if its position
  @@ -562,7 +562,7 @@
   
     if (var_size == 0)
       {
  -      TYPE_SIZE (rec) = size_int (const_size);
  +      TYPE_SIZE (rec) = bitsize_int (const_size, 0L);
       }
     else
       {
  @@ -610,7 +610,7 @@
     /* The size of the union, based on the fields scanned so far,
        is max (CONST_SIZE, VAR_SIZE).
        VAR_SIZE may be null; then CONST_SIZE by itself is the size.  */
  -  register int const_size = 0;
  +  register HOST_WIDE_INT const_size = 0;
     register tree var_size = 0;
   
   #ifdef STRUCTURE_SIZE_BOUNDARY
  @@ -627,6 +627,8 @@
   
     for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field))
       {
  +      tree dsize;
  +      
         /* Enums which are local to this class need not be laid out.  */
         if (TREE_CODE (field) == CONST_DECL || TREE_CODE (field) == TYPE_DECL)
   	continue;
  @@ -645,19 +647,22 @@
   	union_align = MAX (union_align, TYPE_ALIGN (TREE_TYPE (field)));
   #endif
   
  +      dsize = DECL_SIZE (field);
         if (TREE_CODE (rec) == UNION_TYPE)
   	{
   	  /* Set union_size to max (decl_size, union_size).
   	     There are more and less general ways to do this.
   	     Use only CONST_SIZE unless forced to use VAR_SIZE.  */
   
  -	  if (TREE_CODE (DECL_SIZE (field)) == INTEGER_CST)
  +	  if (TREE_CODE (dsize) == INTEGER_CST
  +              && ! TREE_CONSTANT_OVERFLOW (dsize)
  +              && TREE_INT_CST_HIGH (dsize) == 0)
   	    const_size
  -	      = MAX (const_size, TREE_INT_CST_LOW (DECL_SIZE (field)));
  +	      = MAX (const_size, TREE_INT_CST_LOW (dsize));
   	  else if (var_size == 0)
  -	    var_size = DECL_SIZE (field);
  +	    var_size = dsize;
   	  else
  -	    var_size = size_binop (MAX_EXPR, var_size, DECL_SIZE (field));
  +	    var_size = size_binop (MAX_EXPR, var_size, dsize);
   	}
         else if (TREE_CODE (rec) == QUAL_UNION_TYPE)
   	var_size = fold (build (COND_EXPR, sizetype, DECL_QUALIFIER (field),
  diff -uNr gcc-2.95.3.orig/gcc/toplev.c gcc-2.95.3/gcc/toplev.c
  --- gcc-2.95.3.orig/gcc/toplev.c	Fri Jan 26 01:03:23 2001
  +++ gcc-2.95.3/gcc/toplev.c	Sat Aug 18 07:18:42 2001
  @@ -137,8 +137,6 @@
   #define DIR_SEPARATOR '/'
   #endif
   
  -extern int rtx_equal_function_value_matters;
  -
   #if ! (defined (VMS) || defined (OS2))
   extern char **environ;
   #endif
  diff -uNr gcc-2.95.3.orig/gcc/varasm.c gcc-2.95.3/gcc/varasm.c
  --- gcc-2.95.3.orig/gcc/varasm.c	Tue Feb 20 01:02:02 2001
  +++ gcc-2.95.3/gcc/varasm.c	Sat Aug 18 07:18:42 2001
  @@ -723,6 +723,8 @@
   	 Also handle vars declared register invalidly.  */
         if (DECL_RTL (decl) == 0)
   	{
  +	  rtx x;
  +
   	  /* Can't use just the variable's own name for a variable
   	     whose scope is less than the whole file.
   	     Concatenate a distinguishing number.  */
  @@ -752,8 +754,10 @@
   	      			   new_name, strlen (new_name));
   	    }
   
  -	  DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
  -					 gen_rtx_SYMBOL_REF (Pmode, name));
  +	  x = gen_rtx_SYMBOL_REF (Pmode, name);
  +	  SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
  +	  DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl), x);
  +
   	  MEM_ALIAS_SET (DECL_RTL (decl)) = get_alias_set (decl);
   	    
   	  /* If this variable is to be treated as volatile, show its
  
  
  
  1.1                  patches/gcc/gcc-2.95.3-no-fixinc.patch
  
  Index: gcc-2.95.3-no-fixinc.patch
  ===================================================================
  diff -ur gcc-2.95.3/gcc/Makefile.in gcc-2.95.3.no-fixinc/gcc/Makefile.in
  --- gcc-2.95.3/gcc/Makefile.in	2001-01-25 08:02:58.000000000 -0600
  +++ gcc-2.95.3.no-fixinc/gcc/Makefile.in	2003-03-31 14:14:59.000000000 -0600
  @@ -2120,8 +2120,8 @@
   	else :; fi
   # Install the README
   	rm -f include/README
  -	cp $(srcdir)/README-fixinc include/README
  -	chmod a+r include/README
  +	#cp $(srcdir)/README-fixinc include/README
  +	#chmod a+r include/README
   	touch $@
   
   # Now that float.h no longer depends upon enquire, this is actually a no-op.
  @@ -2163,7 +2163,7 @@
   	TARGET_MACHINE=$(target); srcdir=`cd $(srcdir); pwd`; \
   	INSTALL_ASSERT_H=$(INSTALL_ASSERT_H); SHELL=$(SHELL) ;\
   	export TARGET_MACHINE srcdir INSTALL_ASSERT_H SHELL ; \
  -	$(SHELL) ./fixinc.sh `pwd`/include $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS)
  +	#$(SHELL) ./fixinc.sh `pwd`/include $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS)
   	rm -f include/syslimits.h
   	if [ -f include/limits.h ]; then \
   	  mv include/limits.h include/syslimits.h; \
  
  
  
  1.1                  patches/gcc/gcc-2.95.3-returntype-fix.patch
  
  Index: gcc-2.95.3-returntype-fix.patch
  ===================================================================
  Submitted By: Zack Winkles <winkie at linuxfromscratch.org>
  Date:
  Initial Package Version: 2.95.3
  Source: LFS-Dev archives
  Description: Fixes gcc 2.95.3 so the -Wreturn-type flag will work, even when
  g++ is not compiled.
  
  
  diff -Naur gcc-2.95.3.orig/gcc/toplev.c gcc-2.95.3/gcc/toplev.c
  --- gcc-2.95.3.orig/gcc/toplev.c	2003-05-28 16:09:29.000000000 -0400
  +++ gcc-2.95.3/gcc/toplev.c	2003-05-28 16:16:05.425858120 -0400
  @@ -1079,6 +1079,8 @@
     { "-Wno-nested-externs", "" },
     { "-Wparentheses", "Warn about possible missing parentheses" },
     { "-Wno-parentheses", "" },
  +  { "-Wreturn-type", "Warn about inconsistent return types" },
  +  { "-Wno-return-type", "" },
     { "-Wpointer-arith", "Warn about function pointer arithmetic" },
     { "-Wno-pointer-arith", "" },
     { "-Wredundant-decls",
  
  
  
  1.1                  patches/gcc/gcc-3.3.1-no_fixincludes-2.patch
  
  Index: gcc-3.3.1-no_fixincludes-2.patch
  ===================================================================
  Submitted By: Ronald Hummelink <ronald at hummelink dot xs4all dot nl>
  Date: 2003-08-16
  Initial Package Version: GCC 3.3.1
  Origin: Originally developed for GCC 3.2 by Greg Schafer <gschafer at zip dot com dot au>
  Description: Prevent fixincludes script from running.
  
  --- gcc-3.3.1.orig/gcc/Makefile.in	2003-08-03 15:48:36.000000000 +0000
  +++ gcc-3.3.1/gcc/Makefile.in	2003-08-15 23:40:28.000000000 +0000
  @@ -2335,10 +2335,6 @@
   	rm -f include/limits.h
   	cp xlimits.h include/limits.h
   	chmod a+r include/limits.h
  -# Install the README
  -	rm -f include/README
  -	cp $(srcdir)/README-fixinc include/README
  -	chmod a+r include/README
   	$(STAMP) $@
   
   # fixinc.sh depends on this, not on specs directly.
  @@ -2369,7 +2365,6 @@
   	(TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); ${PWD_COMMAND}`; \
   	SHELL='$(SHELL)' ;\
   	export TARGET_MACHINE srcdir SHELL ; \
  -	$(SHELL) ./fixinc.sh `${PWD_COMMAND}`/include $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS); \
   	rm -f include/syslimits.h; \
   	if [ -f include/limits.h ]; then \
   	  mv include/limits.h include/syslimits.h; \
  
  
  
  1.1                  patches/gcc/gcc-3.3.1-specs-2.patch
  
  Index: gcc-3.3.1-specs-2.patch
  ===================================================================
  Submitted By: Greg Schafer <gschafer at zip dot com dot au>
  Date: 2003-09-20
  Initial Package Version: 3.3.1
  Origin: Idea originally developed by Ryan Oliver and Greg Schafer for the Pure LFS project.
          More architectures added by Zack Winkles.
          Further fine tunings by Greg Schafer.
  Description: This patch modifies the location of the dynamic linker for the GCC Pass 2 build in LFS Chapter 5.
               It also removes /usr/include from the include search path.
  
               NOTE - !defined(USE_GNULIBC_1) is assumed i.e. libc5 is not supported.
               WARNING - Not all architectures addressed by this patch have been properly tested due
                         to lack of access to those architectures. If you notice any problems with
                         this patch on your architecture, please report them to
                         lfs-dev at linuxfromscratch dot org
  
  diff -Naur gcc-3.3.1.orig/gcc/config/alpha/linux-elf.h gcc-3.3.1/gcc/config/alpha/linux-elf.h
  --- gcc-3.3.1.orig/gcc/config/alpha/linux-elf.h	2002-12-10 10:55:31.000000000 +0000
  +++ gcc-3.3.1/gcc/config/alpha/linux-elf.h	2003-09-20 03:35:41.000000000 +0000
  @@ -30,7 +30,7 @@
   #ifdef USE_GNULIBC_1
   #define ELF_DYNAMIC_LINKER	"/lib/ld.so.1"
   #else
  -#define ELF_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
  +#define ELF_DYNAMIC_LINKER	"/tools/lib/ld-linux.so.2"
   #endif
   
   #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax}		\
  diff -Naur gcc-3.3.1.orig/gcc/config/arm/linux-elf.h gcc-3.3.1/gcc/config/arm/linux-elf.h
  --- gcc-3.3.1.orig/gcc/config/arm/linux-elf.h	2002-12-10 10:55:31.000000000 +0000
  +++ gcc-3.3.1/gcc/config/arm/linux-elf.h	2003-09-20 03:36:10.000000000 +0000
  @@ -84,7 +84,7 @@
      %{shared:-shared} \
      %{symbolic:-Bsymbolic} \
      %{rdynamic:-export-dynamic} \
  -   %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
  +   %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2} \
      -X \
      %{mbig-endian:-EB}" \
      SUBTARGET_EXTRA_LINK_SPEC
  diff -Naur gcc-3.3.1.orig/gcc/config/i386/linux.h gcc-3.3.1/gcc/config/i386/linux.h
  --- gcc-3.3.1.orig/gcc/config/i386/linux.h	2002-11-15 14:57:12.000000000 +0000
  +++ gcc-3.3.1/gcc/config/i386/linux.h	2003-09-20 03:37:11.000000000 +0000
  @@ -141,7 +141,7 @@
       %{!ibcs: \
         %{!static: \
   	%{rdynamic:-export-dynamic} \
  -	%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
  +	%{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \
   	%{static:-static}}}"
   #endif
   
  diff -Naur gcc-3.3.1.orig/gcc/config/i386/linux64.h gcc-3.3.1/gcc/config/i386/linux64.h
  --- gcc-3.3.1.orig/gcc/config/i386/linux64.h	2003-03-14 06:31:16.000000000 +0000
  +++ gcc-3.3.1/gcc/config/i386/linux64.h	2003-09-20 03:36:44.000000000 +0000
  @@ -67,8 +67,8 @@
     %{!shared: \
       %{!static: \
         %{rdynamic:-export-dynamic} \
  -      %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
  -      %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
  +      %{m32:%{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \
  +      %{!m32:%{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux-x86-64.so.2}}} \
       %{static:-static}}"
   
   #undef  STARTFILE_SPEC
  diff -Naur gcc-3.3.1.orig/gcc/config/ia64/linux.h gcc-3.3.1/gcc/config/ia64/linux.h
  --- gcc-3.3.1.orig/gcc/config/ia64/linux.h	2002-09-03 21:09:54.000000000 +0000
  +++ gcc-3.3.1/gcc/config/ia64/linux.h	2003-09-20 03:37:29.000000000 +0000
  @@ -43,7 +43,7 @@
     %{!shared: \
       %{!static: \
         %{rdynamic:-export-dynamic} \
  -      %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
  +      %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux-ia64.so.2}} \
         %{static:-static}}"
   
   
  diff -Naur gcc-3.3.1.orig/gcc/config/linux.h gcc-3.3.1/gcc/config/linux.h
  --- gcc-3.3.1.orig/gcc/config/linux.h	2003-02-22 18:35:00.000000000 +0000
  +++ gcc-3.3.1/gcc/config/linux.h	2003-09-20 04:33:05.000000000 +0000
  @@ -112,3 +112,7 @@
   #define HANDLE_PRAGMA_PACK_PUSH_POP
   
   #define TARGET_HAS_F_SETLKW
  +
  +/* Remove /usr/include from the end of the include search path.  */
  +#undef STANDARD_INCLUDE_DIR
  +#define STANDARD_INCLUDE_DIR 0
  diff -Naur gcc-3.3.1.orig/gcc/config/m68k/linux.h gcc-3.3.1/gcc/config/m68k/linux.h
  --- gcc-3.3.1.orig/gcc/config/m68k/linux.h	2003-01-28 22:18:15.000000000 +0000
  +++ gcc-3.3.1/gcc/config/m68k/linux.h	2003-09-20 03:44:19.000000000 +0000
  @@ -179,7 +179,7 @@
     %{!shared: \
       %{!static: \
         %{rdynamic:-export-dynamic} \
  -      %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
  +      %{!dynamic-linker*:-dynamic-linker /tools/lib/ld.so.1}} \
       %{static}}"
   #endif
   
  diff -Naur gcc-3.3.1.orig/gcc/config/mips/linux.h gcc-3.3.1/gcc/config/mips/linux.h
  --- gcc-3.3.1.orig/gcc/config/mips/linux.h	2003-05-08 17:31:34.000000000 +0000
  +++ gcc-3.3.1/gcc/config/mips/linux.h	2003-09-20 04:05:48.000000000 +0000
  @@ -182,7 +182,7 @@
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \
           %{static:-static}}}"
   
   #undef SUBTARGET_ASM_SPEC
  diff -Naur gcc-3.3.1.orig/gcc/config/pa/pa-linux.h gcc-3.3.1/gcc/config/pa/pa-linux.h
  --- gcc-3.3.1.orig/gcc/config/pa/pa-linux.h	2002-12-10 10:55:31.000000000 +0000
  +++ gcc-3.3.1/gcc/config/pa/pa-linux.h	2003-09-20 04:06:52.000000000 +0000
  @@ -88,7 +88,7 @@
     %{!shared: \
       %{!static: \
         %{rdynamic:-export-dynamic} \
  -      %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
  +      %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \
         %{static:-static}}"
   
   /* glibc's profiling functions don't need gcc to allocate counters.  */
  diff -Naur gcc-3.3.1.orig/gcc/config/rs6000/linux64.h gcc-3.3.1/gcc/config/rs6000/linux64.h
  --- gcc-3.3.1.orig/gcc/config/rs6000/linux64.h	2003-06-07 06:21:30.000000000 +0000
  +++ gcc-3.3.1/gcc/config/rs6000/linux64.h	2003-09-20 04:15:08.000000000 +0000
  @@ -155,7 +155,7 @@
   #undef  LINK_OS_LINUX_SPEC
   #define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
     %{rdynamic:-export-dynamic} \
  -  %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
  +  %{!dynamic-linker:-dynamic-linker /tools/lib64/ld64.so.1}}}"
   
   #ifdef NATIVE_CROSS
   #define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/"
  diff -Naur gcc-3.3.1.orig/gcc/config/rs6000/sysv4.h gcc-3.3.1/gcc/config/rs6000/sysv4.h
  --- gcc-3.3.1.orig/gcc/config/rs6000/sysv4.h	2003-06-17 15:59:10.000000000 +0000
  +++ gcc-3.3.1/gcc/config/rs6000/sysv4.h	2003-09-20 04:12:54.000000000 +0000
  @@ -1146,7 +1146,7 @@
   
   #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
     %{rdynamic:-export-dynamic} \
  -  %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
  +  %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}}}"
   
   #if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
   # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
  diff -Naur gcc-3.3.1.orig/gcc/config/s390/linux.h gcc-3.3.1/gcc/config/s390/linux.h
  --- gcc-3.3.1.orig/gcc/config/s390/linux.h	2002-11-21 12:03:49.000000000 +0000
  +++ gcc-3.3.1/gcc/config/s390/linux.h	2003-09-20 04:16:33.000000000 +0000
  @@ -94,7 +94,7 @@
         %{static:-static} \
         %{!static: \
   	%{rdynamic:-export-dynamic} \
  -	%{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
  +	%{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}}}"
   
   #define LINK_ARCH64_SPEC \
     "-m elf64_s390 \
  @@ -103,7 +103,7 @@
         %{static:-static} \
         %{!static: \
   	%{rdynamic:-export-dynamic} \
  -	%{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}}}"
  +	%{!dynamic-linker:-dynamic-linker /tools/lib/ld64.so.1}}}"
   
   #ifdef DEFAULT_TARGET_64BIT
   #undef  LINK_SPEC
  diff -Naur gcc-3.3.1.orig/gcc/config/sh/linux.h gcc-3.3.1/gcc/config/sh/linux.h
  --- gcc-3.3.1.orig/gcc/config/sh/linux.h	2003-06-06 02:30:59.000000000 +0000
  +++ gcc-3.3.1/gcc/config/sh/linux.h	2003-09-20 03:44:48.000000000 +0000
  @@ -48,8 +48,8 @@
     "%{shared:-shared} \
      %{!static: \
        %{rdynamic:-export-dynamic} \
  -     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
  -     %{!rpath:-rpath /lib}} \
  +     %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2} \
  +     %{!rpath:-rpath /tools/lib}} \
      %{static:-static}"
   
   /* The GNU C++ standard library requires that these macros be defined.  */
  diff -Naur gcc-3.3.1.orig/gcc/config/sparc/linux.h gcc-3.3.1/gcc/config/sparc/linux.h
  --- gcc-3.3.1.orig/gcc/config/sparc/linux.h	2002-12-10 10:55:32.000000000 +0000
  +++ gcc-3.3.1/gcc/config/sparc/linux.h	2003-09-20 03:46:27.000000000 +0000
  @@ -170,13 +170,13 @@
           %{static:-static}}}"
   #endif
   #else
  -#define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
  +#define LINK_SPEC "-m elf32_sparc -Y P,/tools/lib %{shared:-shared} \
     %{!mno-relax:%{!r:-relax}} \
     %{!shared: \
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \
           %{static:-static}}}"
   #endif
   
  diff -Naur gcc-3.3.1.orig/gcc/config/sparc/linux64.h gcc-3.3.1/gcc/config/sparc/linux64.h
  --- gcc-3.3.1.orig/gcc/config/sparc/linux64.h	2002-12-10 10:55:32.000000000 +0000
  +++ gcc-3.3.1/gcc/config/sparc/linux64.h	2003-09-20 03:47:39.000000000 +0000
  @@ -153,21 +153,21 @@
     { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },	  \
     { "link_arch",	 LINK_ARCH_SPEC },
       
  -#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
  +#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/tools/lib %{shared:-shared} \
     %{!shared: \
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \
           %{static:-static}}} \
   "
   
  -#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
  +#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/tools/lib64 %{shared:-shared} \
     %{!shared: \
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux.so.2}} \
           %{static:-static}}} \
   "
   
  @@ -222,12 +222,12 @@
   #else /* !SPARC_BI_ARCH */
   
   #undef LINK_SPEC
  -#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
  +#define LINK_SPEC "-m elf64_sparc -Y P,/tools/lib64 %{shared:-shared} \
     %{!shared: \
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux.so.2}} \
           %{static:-static}}} \
   %{mlittle-endian:-EL} \
   %{!mno-relax:%{!r:-relax}} \
  diff -Naur gcc-3.3.1.orig/gcc/config/xtensa/linux.h gcc-3.3.1/gcc/config/xtensa/linux.h
  --- gcc-3.3.1.orig/gcc/config/xtensa/linux.h	2003-04-26 00:43:44.000000000 +0000
  +++ gcc-3.3.1/gcc/config/xtensa/linux.h	2003-09-20 04:20:16.000000000 +0000
  @@ -52,7 +52,7 @@
       %{!ibcs: \
         %{!static: \
           %{rdynamic:-export-dynamic} \
  -        %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
  +        %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \
         %{static:-static}}}"
   
   #undef LOCAL_LABEL_PREFIX
  
  
  
  1.1                  patches/gcc/gcc-3.3.1-suppress-libiberty.patch
  
  Index: gcc-3.3.1-suppress-libiberty.patch
  ===================================================================
  Submitted By: Greg Schafer <gschafer at zip dot com dot au>
  Date: 2003-08-10
  Initial Package Version: 3.3.1
  Origin: Developed by Greg Schafer <gschafer at zip dot com dot au>
  Description: Suppresses installation of libiberty, as we'll be using the one from binutils.
  
  --- gcc-3.3.1/libiberty/Makefile.in.GWS	2003-03-23 21:16:03.000000000 +1100
  +++ gcc-3.3.1/libiberty/Makefile.in	2003-08-10 16:05:06.000000000 +1000
  @@ -260,7 +260,7 @@
   @MAINT@	echo stamp > stamp-functions
   
   INSTALL_DEST = @INSTALL_DEST@
  -install: install_to_$(INSTALL_DEST) install-subdir
  +install: install-subdir
   
   install_to_libdir: all
   	${mkinstalldirs} $(DESTDIR)$(libdir)$(MULTISUBDIR)
  
  
  
  1.1                  patches/kbd/kbd-1.08.patch
  
  Index: kbd-1.08.patch
  ===================================================================
  diff -Naur kbd-1.08/src/Makefile.in kbd-1.08-patched/src/Makefile.in
  --- kbd-1.08/src/Makefile.in	Sun Oct 13 03:34:10 2002
  +++ kbd-1.08-patched/src/Makefile.in	Tue Oct 15 17:24:22 2002
  @@ -37,8 +37,9 @@
   OLDPROGS= mapscrn loadunimap
   
   # Not installed by default
  -MISC    = screendump setlogcons setvesablank spawn_console spawn_login \
  -	  getunimap clrunimap outpsfheader setpalette
  +#MISC    = screendump setlogcons setvesablank spawn_console spawn_login \
  +#	  getunimap clrunimap outpsfheader setpalette
  +MISC     = setlogcons setvesablank getunimap
   
   # Installed by default
   SHCMDS  = unicode_start unicode_stop
  @@ -64,7 +65,7 @@
   install:	all
   	install -d -m 755 $(BINDIR) $(LOADKEYS_BINDIR)
   	install -s -m 0755 -o root $(PROGS) $(OLDPROGS) $(BINDIR)
  -#	install -s -m 0755 -o root $(MISC) $(BINDIR)
  +	install -s -m 0755 -o root $(MISC) $(BINDIR)
   	install -c -m 0755 -o root $(SHCMDS) $(BINDIR)
   	for i in psfaddtable psfgettable psfstriptable; do \
   		rm -f $(BINDIR)/$$i; ln -s psfxtable $(BINDIR)/$$i; \
  
  
  
  1.1                  patches/man/man-1.5m2-80cols.patch
  
  Index: man-1.5m2-80cols.patch
  ===================================================================
  diff -Naur man-1.5l.orig/src/man.c man-1.5l/src/man.c
  --- man-1.5l.orig/src/man.c	2002-12-17 16:28:14.000000000 -0700
  +++ man-1.5l/src/man.c	2003-04-24 16:49:05.000000000 -0600
  @@ -546,7 +546,9 @@
   	       /* we should set line length and title line length */
   	       /* however, a .lt command here fails, only
   		  .ev 1; .lt ...; .ev helps for my version of groff */
  -	       sprintf(eos(bufh), "echo \".ll %d.%di\"; ", ll/10, ll%10);
  +		  /* use the LL register instead of .ll to keep up with
  +		  * changes in the groff-1.18 series */
  +		  sprintf(eos(bufh), "echo \".nr LL %d.%di\"; ", ll/10, ll%10);
   #if 0
   	       sprintf(eos(bufh), "echo \".lt %d.%di\"; ", ll/10, ll%10);
   #endif
  
  
  
  1.1                  patches/man/man-1.5m2-manpath.patch
  
  Index: man-1.5m2-manpath.patch
  ===================================================================
  diff -Naur man-1.5k.orig/src/man.conf.in man-1.5k/src/man.conf.in
  --- man-1.5k.orig/src/man.conf.in	2002-07-17 13:08:40.000000000 -0600
  +++ man-1.5k/src/man.conf.in	2002-09-28 17:43:41.000000000 -0600
  @@ -36,7 +36,7 @@
   #
   # Every automatically generated MANPATH includes these fields
   #
  -MANPATH	/usr/man
  +#MANPATH	/usr/man
   MANPATH /usr/share/man
   MANPATH	/usr/local/man
   MANPATH	/usr/X11R6/man
  
  
  
  1.1                  patches/man/man-1.5m2-pager.patch
  
  Index: man-1.5m2-pager.patch
  ===================================================================
  diff -Naur man-1.5l.orig/configure man-1.5l/configure
  --- man-1.5l.orig/configure	2003-03-10 13:21:00.000000000 -0700
  +++ man-1.5l/configure	2003-04-24 16:50:30.000000000 -0600
  @@ -26,7 +26,7 @@
   # (Indeed, -r may cause the terminal to get into funny states.
   # Very inconvenient. For viewing pages in strange locales, set LC_*.)
   #
  -DEFAULTLESSOPT="-is"
  +DEFAULTLESSOPT="-isR"
   #
   # Note that not creating any cat directories (/var/cache/man or so)
   # and not making man suid or sgid is recommended.
  
  
  
  1.1                  patches/ncurses/ncurses-5.3-etip-2.patch
  
  Index: ncurses-5.3-etip-2.patch
  ===================================================================
  diff -uNr ncurses-5.3.orig/aclocal.m4 ncurses-5.3/aclocal.m4
  --- ncurses-5.3.orig/aclocal.m4	2002-09-22 10 49:14.000000000 +1000
  +++ ncurses-5.3/aclocal.m4	2003-03-19 12:34:43.000000000 +1100
  @@ -554,7 +554,7 @@
   do
   for cf_excp in "" MATH_EXCEPTION
   do
  -	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
  +	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
   	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
   	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
   AC_TRY_COMPILE([
  diff -uNr ncurses-5.3.orig/configure ncurses-5.3/configure
  --- ncurses-5.3.orig/configure	2002-09-22 10:49:14.000000000 +1000
  +++ ncurses-5.3/configure	2003-03-19 12:34:43.000000000 +1100
  @@ -9659,7 +9659,7 @@
   do
   for cf_excp in "" MATH_EXCEPTION
   do
  -	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
  +	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
   	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
   	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
   cat >conftest.$ac_ext <<_ACEOF
  
  
  
  1.1                  patches/ncurses/ncurses-5.3-vsscanf.patch
  
  Index: ncurses-5.3-vsscanf.patch
  ===================================================================
  diff -urN ncurses-5.3/c++/cursesw.cc ncurses-5.3.new/c++/cursesw.cc
  --- ncurses-5.3/c++/cursesw.cc	2002-07-06 16:47:52.000000000 +0100
  +++ ncurses-5.3.new/c++/cursesw.cc	2003-04-28 18:19:03.000000000 +0100
  @@ -64,12 +64,10 @@
   	if (::vsscanf(buf, fmt, args) != -1)
   	    result = OK;
   #elif USE_STRSTREAM_VSCAN	/* powerpc, os390 */
  -	strstreambuf ss(buf, sizeof(buf));
  -	if (ss.vscan(fmt, args) != -1)
  +	if (::vsscanf(buf, fmt, args) != -1)
   	    result = OK;
   #elif USE_STRSTREAM_VSCAN_CAST	/* pre-gcc 3.0 */
  -	strstreambuf ss(buf, sizeof(buf));
  -	if (ss.vscan(fmt, (_IO_va_list)args) != -1)
  +	if (::vsscanf(buf, fmt, (_IO_va_list)args) != -1)
   	    result = OK;
   #endif
   	va_end(args);
  @@ -92,12 +90,10 @@
   	    if (::vsscanf(buf, fmt, args) != -1)
   		result = OK;
   #elif USE_STRSTREAM_VSCAN	/* powerpc, os390 */
  -	    strstreambuf ss(buf, sizeof(buf));
  -	    if (ss.vscan(fmt, args) != -1)
  +	    if (::vsscanf(buf, fmt, args) != -1)
   		result = OK;
   #elif USE_STRSTREAM_VSCAN_CAST	/* pre-gcc 3.0 */
  -	    strstreambuf ss(buf, sizeof(buf));
  -	    if (ss.vscan(fmt, (_IO_va_list)args) != -1)
  +	    if (::vsscanf(buf, fmt, (_IO_va_list)args) != -1)
   		result = OK;
   #endif
   	    va_end(args);
  
  
  
  1.1                  patches/procps/procps-3.1.11.patch
  
  Index: procps-3.1.11.patch
  ===================================================================
  diff -Naur procps-3.1.8.orig/w.c procps-3.1.8/w.c
  --- procps-3.1.8.orig/w.c	2002-12-21 06:30:33.000000000 -0700
  +++ procps-3.1.8/w.c	2003-04-24 17:00:53.000000000 -0600
  @@ -237,7 +237,7 @@
       from = 0;
   #endif
   
  -    setlocale(LC_ALL, "");
  +    setlocale(LC_NUMERIC, "C");
       for (args=0; (ch = getopt(argc, argv, "hlusfV")) != EOF; args++)
   	switch (ch) {
   	  case 'h': header = 0;		break;
  
  
  
  1.1                  patches/shadow/shadow-4.0.3-newgrp-fix.patch
  
  Index: shadow-4.0.3-newgrp-fix.patch
  ===================================================================
  Submitted By: Greg Schafer <gschafer at zip dot com dot au>
  Date: 2003-09-01
  Initial Package Version: 4.0.3
  Origin: LFS Mailing Lists
  Description: Fixes the newgrp command in the shadow suite - now also appearing in Shadow CVS
  
  diff -uNr shadow-4.0.3.orig/src/newgrp.c shadow-4.0.3/src/newgrp.c
  --- shadow-4.0.3.orig/src/newgrp.c	2002-01-07 02:00:07.000000000 +1100
  +++ shadow-4.0.3/src/newgrp.c	2003-03-11 12:02:12.000000000 +1100
  @@ -398,6 +398,7 @@
   		SYSLOG ((LOG_INFO,
   			 "user `%s' (login `%s' on %s) switched to group `%s'",
   			 name, loginname, tty, group));
  +#ifdef USE_PAM
   		if (getdef_bool ("CLOSE_SESSIONS")) {
   			/*
   			 * We want to fork and exec the new shell in the child, leaving the
  @@ -450,6 +451,7 @@
   			signal (SIGTTIN, SIG_DFL);
   			signal (SIGTTOU, SIG_DFL);
   		}
  +#endif // USE_PAM
   	}
   #endif				/* USE_SYSLOG */
   
  
  
  
  1.1                  patches/zlib/zlib-1.1.4-vsnprintf.patch
  
  Index: zlib-1.1.4-vsnprintf.patch
  ===================================================================
  diff -Naur zlib-1.1.4/ChangeLog zlib-1.1.4-vsnprintf/ChangeLog
  --- zlib-1.1.4/ChangeLog	2002-03-11 09:02:35.000000000 -0600
  +++ zlib-1.1.4-vsnprintf/ChangeLog	2003-03-05 13:14:50.000000000 -0600
  @@ -1,6 +1,13 @@
   
   		ChangeLog file for zlib
   
  +Changes in 1.1.4-patched (23 February 2003)
  +- fix a security vulnerability related to improper use of snprintf/vsnprintf
  +  function.
  +- ./configure now detects the presence of snprintf/vsnprintf and enables it
  +  automatically if present.
  +- README.vsnprintf added.
  +
   Changes in 1.1.4 (11 March 2002)
   - ZFREE was repeated on same allocation on some error conditions.
     This creates a security problem described in
  diff -Naur zlib-1.1.4/README.vsnprintf zlib-1.1.4-vsnprintf/README.vsnprintf
  --- zlib-1.1.4/README.vsnprintf	1969-12-31 18:00:00.000000000 -0600
  +++ zlib-1.1.4-vsnprintf/README.vsnprintf	2003-03-05 13:14:50.000000000 -0600
  @@ -0,0 +1,23 @@
  +During a recent audit of zlib-1.1.4, a buffer-overflow and string-format
  +vulnerability was found in the gzprintf() function.  This has been corrected in
  +this version of zlib; in addition, some ./configure checks have been added to
  +make sure the host system can utilize the corrections fully.
  +
  +As a result, it is now strongly recommended that your host system or compiler
  +provide a fully C99-compliant implementation of the vsnprintf() function.
  +Anything less will reduce the functionality and/or security of the gzprintf()
  +function.  The most critical aspect is that vsnprintf() should be present and
  +should provide a return value.  If this function is missing, one of the
  +fallback functions (vsprintf(), snprintf(), vsnprintf()) will have to be used,
  +and if so, they too should return a value.  If your system is lacking in any of
  +these aspects, the ./configure script should warn you and refer you to this
  +file.
  +
  +In addition, the HAS_vsnprintf and HAS_snprintf macros are automatically
  +defined if these functions are available.  zlib-1.1.4 and older versions did
  +not do this, potentially leading to a broken and vulnerable zlib even when the
  +host system supported the requisite functionality to avoid this.
  +
  +
  +                                  -- Kelledin <kelledin at users.sourceforge.net>
  +
  diff -Naur zlib-1.1.4/configure zlib-1.1.4-vsnprintf/configure
  --- zlib-1.1.4/configure	1998-07-08 13:19:35.000000000 -0500
  +++ zlib-1.1.4-vsnprintf/configure	2003-03-05 13:15:00.000000000 -0600
  @@ -155,7 +155,212 @@
     echo "Checking for unistd.h... No."
   fi
   
  -cat > $test.c <<EOF
  +cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdlib.h>
  +
  +#if (defined(__MSDOS__) || defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)) && !defined(STDC)
  +#  define STDC
  +#endif
  +
  +int main() 
  +{
  +#ifndef STDC
  +  choke me
  +#endif
  +
  +  return 0;
  +}
  +EOF
  +
  +if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +  echo "Checking whether to use vsnprintf() or snprintf()... using vsnprintf()"
  +
  +  cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest(char *fmt, ...)
  +{
  +  char buf[20];
  +  va_list ap;
  +
  +  va_start(ap, fmt);
  +  vsnprintf(buf, sizeof(buf), fmt, ap);
  +  va_end(ap);
  +  return 0;
  +}
  +
  +int main()
  +{
  +  return (mytest("Hello%d\n", 1));
  +}
  +EOF
  +  
  +  if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +    CFLAGS="$CFLAGS -DHAS_vsnprintf"
  +    echo "Checking for vsnprintf() in stdio.h... Yes."
  +
  +    cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest(char *fmt, ...)
  +{
  +  int i;
  +  char buf[20];
  +  va_list ap;
  +
  +  va_start(ap, fmt);
  +  i = vsnprintf(buf, sizeof(buf), fmt, ap);
  +  va_end(ap);
  +  return 0;
  +}
  +
  +int main()
  +{
  +  return (mytest("Hello%d\n", 1));
  +}
  +EOF
  +
  +    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +      CFLAGS="$CFLAGS -DHAS_vsnprintf_return"
  +      echo "Checking for return value of vsnprintf()... Yes."
  +    else
  +      echo "Checking for return value of vsnprintf()... No."
  +      echo "  WARNING: apparently vsnprintf() does not return a value. zlib"
  +      echo "  can build but will be open to possible string-format security"
  +      echo "  vulnerabilities."
  +    fi
  +  else
  +    echo "Checking for vsnprintf() in stdio.h... No."
  +    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
  +    echo "  can build but will be open to possible buffer-overflow security"
  +    echo "  vulnerabilities."
  +
  +    cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest(char *fmt, ...)
  +{
  +  int i;
  +  char buf[20];
  +  va_list ap;
  +
  +  va_start(ap, fmt);
  +  i = vsprintf(buf, fmt, ap);
  +  va_end(ap);
  +  return 0;
  +}
  +
  +int main() 
  +{
  +  return (mytest("Hello%d\n", 1));
  +}
  +EOF
  +
  +    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +      CFLAGS="$CFLAGS -DHAS_vsprintf_return"
  +      echo "Checking for return value of vsprintf()... Yes."
  +    else
  +      echo "Checking for return value of vsprintf()... No."
  +      echo "  WARNING: apparently vsprintf() does not return a value. zlib"
  +      echo "  can build but will be open to possible string-format security"
  +      echo "  vulnerabilities."
  +    fi
  +  fi
  +else
  +  echo "Checking whether to use vsnprintf() or snprintf()... using snprintf()"
  +
  +  cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest() 
  +{
  +  char buf[20];
  +
  +  snprintf(buf, sizeof(buf), "%s", "foo");
  +  return 0;
  +}
  +
  +int main() 
  +{
  +  return (mytest());
  +}
  +EOF
  +
  +  if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +    CFLAGS="$CFLAGS -DHAS_snprintf"
  +    echo "Checking for snprintf() in stdio.h... Yes."
  +
  +    cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest(char *fmt, ...)
  +{
  +  int i;
  +  char buf[20];
  +
  +  i = snprintf(buf, sizeof(buf), "%s", "foo");
  +  return 0;
  +}
  +
  +int main() 
  +{
  +  return (mytest());
  +}
  +EOF
  +
  +    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +      CFLAGS="$CFLAGS -DHAS_snprintf_return"
  +      echo "Checking for return value of snprintf()... Yes."
  +    else
  +      echo "Checking for return value of snprintf()... No."
  +      echo "  WARNING: apparently snprintf() does not return a value. zlib"
  +      echo "  can build but will be open to possible string-format security"
  +      echo "  vulnerabilities."
  +    fi
  +  else
  +    echo "Checking for snprintf() in stdio.h... No."
  +    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib"
  +    echo "  can build but will be open to possible buffer-overflow security"
  +    echo "  vulnerabilities."
  +
  +    cat >$test.c <<EOF
  +#include <stdio.h>
  +#include <stdarg.h>
  +
  +int mytest(char *fmt, ...) 
  +{
  +  int i;
  +  char buf[20];
  +
  +  i = sprintf(buf, "%s", "foo");
  +  return 0;
  +}
  +
  +int main() 
  +{
  +  return (mytest());
  +}
  +EOF
  +
  +    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  +      CFLAGS="$CFLAGS -DHAS_sprintf_return"
  +      echo "Checking for return value of sprintf()... Yes."
  +    else
  +      echo "Checking for return value of sprintf()... No."
  +      echo "  WARNING: apparently sprintf() does not return a value. zlib"
  +      echo "  can build but will be open to possible string-format security"
  +      echo "  vulnerabilities."
  +    fi
  +  fi
  +fi
  +
  +cat >$test.c <<EOF
   #include <errno.h>
   int main() { return 0; }
   EOF
  diff -Naur zlib-1.1.4/gzio.c zlib-1.1.4-vsnprintf/gzio.c
  --- zlib-1.1.4/gzio.c	2002-03-11 07:16:01.000000000 -0600
  +++ zlib-1.1.4-vsnprintf/gzio.c	2003-03-05 13:14:50.000000000 -0600
  @@ -529,14 +529,42 @@
       int len;
   
       va_start(va, format);
  +
  +    /* 2003/02/23: Add proper length checking here, if possible.
  +     *
  +     *    -- Kelledin
  +     */
   #ifdef HAS_vsnprintf
  -    (void)vsnprintf(buf, sizeof(buf), format, va);
  +#  ifdef HAS_vsnprintf_return
  +    len=vsnprintf(buf, sizeof(buf), format, va);
  +    va_end(va);
  +
  +    if (len <= 0 || len >= sizeof(buf)) {
  +        /* Resulting string too large to fit in the buffer. */
  +        return 0;
  +    }
  +#  else
  +    vsnprintf(buf, sizeof(buf), format, va);
  +    va_end(va);
  +    len=strlen(buf);
  +    if (len <= 0) return 0;
  +#  endif
   #else
  -    (void)vsprintf(buf, format, va);
  -#endif
  +#  ifdef HAS_vsprintf_return
  +    len=vsprintf(buf, format, va);
  +    va_end(va);
  +
  +    if (len <= 0 || len >= sizeof(buf)) {
  +        /* Resulting string too large to fit in the buffer. */
  +        return 0;
  +    }
  +#  else
  +    vsprintf(buf, format, va);
       va_end(va);
  -    len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
  +    len=strlen(buf);
       if (len <= 0) return 0;
  +#  endif
  +#endif
   
       return gzwrite(file, buf, (unsigned)len);
   }
  @@ -552,15 +580,41 @@
       char buf[Z_PRINTF_BUFSIZE];
       int len;
   
  +    /* 2003/02/23: Add proper length checking here when possible.
  +     *
  +     *    -- Kelledin
  +     */
   #ifdef HAS_snprintf
  +#  ifdef HAS_snprintf_return
  +    len=snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
  +	         a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
  +
  +    if (len <= 0 || len >= sizeof(buf)) {
  +        /* Resulting string too large to fit in the buffer. */
  +        return 0;
  +    }
  +#  else
       snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
   	     a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
  +    len=strlen(buf);
  +    if (len <= 0) return 0;
  +#  endif
   #else
  +#  ifdef HAS_sprintf_return
  +    len=sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
  +	        a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
  +
  +    if (len <= 0 || len >= sizeof(buf)) {
  +        /* Resulting string too large to fit in the buffer. */
  +        return 0;
  +    }
  +#  else
       sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
   	    a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
  -#endif
  -    len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */
  +    len=strlen(buf);
       if (len <= 0) return 0;
  +#  endif
  +#endif
   
       return gzwrite(file, buf, len);
   }
  
  
  



More information about the patches mailing list