From nobody@FreeBSD.org  Fri Mar 25 14:36:16 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CA9081065675
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Mar 2011 14:36:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id B93B28FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Mar 2011 14:36:16 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2PEaGdq045648
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Mar 2011 14:36:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p2PEaFOk045647;
	Fri, 25 Mar 2011 14:36:15 GMT
	(envelope-from nobody)
Message-Id: <201103251436.p2PEaFOk045647@red.freebsd.org>
Date: Fri, 25 Mar 2011 14:36:15 GMT
From: Michael Gmelin <freebsd@grem.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Incorporate patch from the Ice project into devel/mcpp
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: kmatsui@t3.rim.or.jp

>Number:         155934
>Category:       ports
>Synopsis:       Incorporate patch from the Ice project into devel/mcpp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ohauer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 25 14:40:10 UTC 2011
>Closed-Date:    Wed Mar 30 18:29:16 UTC 2011
>Last-Modified:  Wed Mar 30 18:30:12 UTC 2011
>Originator:     Michael Gmelin
>Release:        FreeBSD 8.1 RELEASE amd64
>Organization:
Grem Equity GmbH
>Environment:
FreeBSD server.grem.de 8.1-RELEASE-p2 FreeBSD 8.1-RELEASE-p2 #2 r216068: Tue Nov 30 03:00:30 CET 2010 root@bsdsource.grem.de:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
The Ice project by ZeroC (devel/ice and devel/py-ice) did some patches and security updates for the mcpp preprocessor. Without those patches, important parts of ice are not functioning properly. The patches have been applied to various linux package trees in the past successfully. I got in touch with the author and package maintainer of the devel/mcpp port, but he's currently unable to do any work on the project, but gave his consent to applying the patch:

====
Hello,

I'm very sorry, but I have no time for mcpp now.  I think the Zeroc
patch is correct, and has no undesirable side effect.  So, if someone
make an mcpp package applying the patch, and commit it to FreeBSD or any
other system, I will agree with it.

--
Kiyoshi Matsui, the maintainer of mcpp
===

It should be emphasized, that right now ice is the only port using mcpp and that it's misbehaving in subtle ways if the patch is not applied at runtime. So this is somehow critical.
>How-To-Repeat:
Run mcpp like this:
mcpp -C << EOF
> test; // comment
> EOF
#line 1 "<stdin>"
// commenttest;

This clearly shows the critical misbehaviour when comments are preserved (that's the way slice2java, slice2py and slice2html are calling mcpp).
>Fix:
Apply the patch attached to this PR and reinstall mcpp:

sudo mkdir -p /usr/ports/devel/mcpp/files
sudo cp patch-mcpp-ice.txt /usr/ports/devel/mcpp/files
sudo portupgrade -f devel/mcpp

It would be good, if this patch could be incorporated into the port skeleton of devel/mcpp directly. The original patch is part of the third party sources tarball found on zeroc.com: http://www.zeroc.com/download/Ice/3.4/ThirdParty-Sources-3.4.1.tar.gz


Patch attached with submission follows:

diff -c -r -N ../mcpp-2.7.2/src/internal.H ./src/internal.H
*** ../mcpp-2.7.2/src/internal.H	2008-08-27 10:31:16.000000000 -0230
--- ./src/internal.H	2009-12-17 21:01:35.000000000 -0330
***************
*** 390,395 ****
--- 390,397 ----
  extern char     identifier[];       /* Lastly scanned name          */
  extern IFINFO   ifstack[];          /* Information of #if nesting   */
  extern char     work_buf[];
+ extern FILEINFO * sh_file;
+ extern int      sh_line;
          /* Temporary buffer for directive line and macro expansion  */
  
  /* main.c   */
***************
*** 557,562 ****
  #endif
  #endif
  
! #if HOST_HAVE_STPCPY
  extern char *   stpcpy( char * dest, const char * src);
  #endif
--- 559,564 ----
  #endif
  #endif
  
! #if HOST_HAVE_STPCPY && !defined(stpcpy)
  extern char *   stpcpy( char * dest, const char * src);
  #endif
diff -c -r -N ../mcpp-2.7.2/src/main.c ./src/main.c
*** ../mcpp-2.7.2/src/main.c	2008-11-05 05:04:46.000000000 -0330
--- ./src/main.c	2009-12-17 20:42:42.000000000 -0330
***************
*** 326,331 ****
--- 326,333 ----
              = FALSE;
      option_flags.trig = TRIGRAPHS_INIT;
      option_flags.dig = DIGRAPHS_INIT;
+     sh_file = NULL;
+     sh_line = 0;
  }
  
  int     mcpp_lib_main
diff -c -r -N ../mcpp-2.7.2/src/support.c ./src/support.c
*** ../mcpp-2.7.2/src/support.c	2008-06-10 06:02:33.000000000 -0230
--- ./src/support.c	2009-12-17 20:42:39.000000000 -0330
***************
*** 188,194 ****
      size_t      length
  )
  {
!     if (mem_buf_p->bytes_avail < length) {  /* Need to allocate more memory */
          size_t size = MAX( BUF_INCR_SIZE, length);
  
          if (mem_buf_p->buffer == NULL) {            /* 1st append   */
--- 188,194 ----
      size_t      length
  )
  {
!     if (mem_buf_p->bytes_avail < length + 1) {  /* Need to allocate more memory */
          size_t size = MAX( BUF_INCR_SIZE, length);
  
          if (mem_buf_p->buffer == NULL) {            /* 1st append   */
***************
*** 1722,1727 ****
--- 1722,1729 ----
                      sp -= 2;
                      while (*sp != '\n')     /* Until end of line    */
                          mcpp_fputc( *sp++, OUT);
+                     mcpp_fputc( '\n', OUT);
+                     wrong_line = TRUE;
                  }
                  goto  end_line;
              default:                        /* Not a comment        */
diff -c -r -N ../mcpp-2.7.2/src/system.c ./src/system.c
*** ../mcpp-2.7.2/src/system.c	2008-11-26 06:23:51.000000000 -0330
--- ./src/system.c	2009-12-17 20:42:42.000000000 -0330
***************
*** 3858,3863 ****
--- 3858,3866 ----
  }
  #endif
  
+ FILEINFO*       sh_file;
+ int             sh_line;
+ 
  void    sharp(
      FILEINFO *  sharp_file,
      int         flag        /* Flag to append to the line for GCC   */
***************
*** 3868,3875 ****
   * else (i.e. 'sharp_file' is NULL) 'infile'.
   */
  {
-     static FILEINFO *   sh_file;
-     static int  sh_line;
      FILEINFO *  file;
      int         line;
  
--- 3871,3876 ----


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Fri Mar 25 14:40:31 UTC 2011 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155934 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: kmatsui@t3.rim.or.jp
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/155934: Incorporate patch from the Ice project into devel/mcpp
Date: Fri, 25 Mar 2011 14:40:29 UT

 Maintainer of devel/mcpp,
 
 Please note that PR ports/155934 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/155934
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Michael Gmelin <freebsd@grem.de>
To: bug-followup@FreeBSD.org,
 freebsd@grem.de
Cc:  
Subject: Re: ports/155934: Incorporate patch from the Ice project into devel/mcpp
Date: Fri, 25 Mar 2011 18:09:00 +0100

 --Apple-Mail-69-643193647
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 Please find attached a full patch against the ports tree (Makefile with =
 PORTREVISION bumped etc.) which should apply cleanly against devel/mcpp, =
 so minimal effort required by ports maintainer).
 
 
 --Apple-Mail-69-643193647
 Content-Disposition: attachment;
 	filename=mcpp.patch.txt
 Content-Type: text/plain;
 	name="mcpp.patch.txt"
 Content-Transfer-Encoding: quoted-printable
 
 =3D=3D=3D> Generating patch
 =3D=3D=3D> Viewing diff with more
 diff -ruN --exclude=3DCVS /usr/ports/devel/mcpp.orig/Makefile =
 /usr/ports/devel/mcpp/Makefile
 --- /usr/ports/devel/mcpp.orig/Makefile	2011-03-25 17:31:41.000000000 =
 +0100
 +++ /usr/ports/devel/mcpp/Makefile	2011-03-25 04:31:04.596814000 =
 +0100
 @@ -7,6 +7,7 @@
 =20
  PORTNAME=3D	mcpp
  PORTVERSION=3D	2.7.2
 +PORTREVISION=3D	1
  CATEGORIES=3D	devel
  MASTER_SITES=3D	SF/${PORTNAME}/${PORTNAME}/V.${PORTVERSION}
 =20
 diff -ruN --exclude=3DCVS =
 /usr/ports/devel/mcpp.orig/files/patch-mcpp-ice =
 /usr/ports/devel/mcpp/files/patch-mcpp-ice
 --- /usr/ports/devel/mcpp.orig/files/patch-mcpp-ice	1970-01-01 =
 01:00:00.000000000 +0100
 +++ /usr/ports/devel/mcpp/files/patch-mcpp-ice	2011-03-23 =
 07:45:47.000000000 +0100
 @@ -0,0 +1,100 @@
 +diff -c -r -N ../mcpp-2.7.2/src/internal.H ./src/internal.H
 +*** ../mcpp-2.7.2/src/internal.H	2008-08-27 10:31:16.000000000 =
 -0230
 +--- ./src/internal.H	2009-12-17 21:01:35.000000000 -0330
 +***************
 +*** 390,395 ****
 +--- 390,397 ----
 +  extern char     identifier[];       /* Lastly scanned name          =
 */
 +  extern IFINFO   ifstack[];          /* Information of #if nesting   =
 */
 +  extern char     work_buf[];
 ++ extern FILEINFO * sh_file;
 ++ extern int      sh_line;
 +          /* Temporary buffer for directive line and macro expansion  =
 */
 + =20
 +  /* main.c   */
 +***************
 +*** 557,562 ****
 +  #endif
 +  #endif
 + =20
 +! #if HOST_HAVE_STPCPY
 +  extern char *   stpcpy( char * dest, const char * src);
 +  #endif
 +--- 559,564 ----
 +  #endif
 +  #endif
 + =20
 +! #if HOST_HAVE_STPCPY && !defined(stpcpy)
 +  extern char *   stpcpy( char * dest, const char * src);
 +  #endif
 +diff -c -r -N ../mcpp-2.7.2/src/main.c ./src/main.c
 +*** ../mcpp-2.7.2/src/main.c	2008-11-05 05:04:46.000000000 -0330
 +--- ./src/main.c	2009-12-17 20:42:42.000000000 -0330
 +***************
 +*** 326,331 ****
 +--- 326,333 ----
 +              =3D FALSE;
 +      option_flags.trig =3D TRIGRAPHS_INIT;
 +      option_flags.dig =3D DIGRAPHS_INIT;
 ++     sh_file =3D NULL;
 ++     sh_line =3D 0;
 +  }
 + =20
 +  int     mcpp_lib_main
 +diff -c -r -N ../mcpp-2.7.2/src/support.c ./src/support.c
 +*** ../mcpp-2.7.2/src/support.c	2008-06-10 06:02:33.000000000 =
 -0230
 +--- ./src/support.c	2009-12-17 20:42:39.000000000 -0330
 +***************
 +*** 188,194 ****
 +      size_t      length
 +  )
 +  {
 +!     if (mem_buf_p->bytes_avail < length) {  /* Need to allocate more =
 memory */
 +          size_t size =3D MAX( BUF_INCR_SIZE, length);
 + =20
 +          if (mem_buf_p->buffer =3D=3D NULL) {            /* 1st append =
   */
 +--- 188,194 ----
 +      size_t      length
 +  )
 +  {
 +!     if (mem_buf_p->bytes_avail < length + 1) {  /* Need to allocate =
 more memory */
 +          size_t size =3D MAX( BUF_INCR_SIZE, length);
 + =20
 +          if (mem_buf_p->buffer =3D=3D NULL) {            /* 1st append =
   */
 +***************
 +*** 1722,1727 ****
 +--- 1722,1729 ----
 +                      sp -=3D 2;
 +                      while (*sp !=3D '\n')     /* Until end of line    =
 */
 +                          mcpp_fputc( *sp++, OUT);
 ++                     mcpp_fputc( '\n', OUT);
 ++                     wrong_line =3D TRUE;
 +                  }
 +                  goto  end_line;
 +              default:                        /* Not a comment        =
 */
 +diff -c -r -N ../mcpp-2.7.2/src/system.c ./src/system.c
 +*** ../mcpp-2.7.2/src/system.c	2008-11-26 06:23:51.000000000 -0330
 +--- ./src/system.c	2009-12-17 20:42:42.000000000 -0330
 +***************
 +*** 3858,3863 ****
 +--- 3858,3866 ----
 +  }
 +  #endif
 + =20
 ++ FILEINFO*       sh_file;
 ++ int             sh_line;
 ++=20
 +  void    sharp(
 +      FILEINFO *  sharp_file,
 +      int         flag        /* Flag to append to the line for GCC   =
 */
 +***************
 +*** 3868,3875 ****
 +   * else (i.e. 'sharp_file' is NULL) 'infile'.
 +   */
 +  {
 +-     static FILEINFO *   sh_file;
 +-     static int  sh_line;
 +      FILEINFO *  file;
 +      int         line;
 + =20
 +--- 3871,3876 ----
 =3D=3D=3D> Done
 
 --Apple-Mail-69-643193647
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 
 
 
 --Apple-Mail-69-643193647--

From: Kiyoshi MATSUI <kmatsui@t3.rim.or.jp>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/155934: Incorporate patch from the Ice project into
 devel/mcpp
Date: Sat, 26 Mar 2011 21:34:05 +0900

 I approve the ZeroC patch, and hope that the new package by Michael will
 be committed to FreeBSD.  Thanks for spending your time on mcpp
 maintainance.
 
 --
 Kiyoshi Matsui, the maintainer of mcpp
 
 
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 26 17:06:34 UTC 2011 
State-Changed-Why:  
Maintainer approved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155934 
Responsible-Changed-From-To: freebsd-ports-bugs->ohauer 
Responsible-Changed-By: ohauer 
Responsible-Changed-When: Wed Mar 30 18:13:05 UTC 2011 
Responsible-Changed-Why:  
I'll take it 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155934 
State-Changed-From-To: open->closed 
State-Changed-By: ohauer 
State-Changed-When: Wed Mar 30 18:28:56 UTC 2011 
State-Changed-Why:  
Committed, Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155934 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/155934: commit references a PR
Date: Wed, 30 Mar 2011 18:26:51 +0000 (UTC)

 ohauer      2011-03-30 18:26:40 UTC
 
   FreeBSD ports repository
 
   Modified files:
     devel/mcpp           Makefile 
   Added files:
     devel/mcpp/files     patch-src__internal.H patch-src__main.c 
                          patch-src__support.c patch-src__system.c 
   Log:
    - add patches to fix some security and functionality issues
   
   PR:             ports/155934
   Submitted by:   Michael Gmelin <freebsd _at_ grem.de>
   Approved by:    Kiyoshi MATSUI <kmatsui _at_ t3.rim.or.jp> (maintainer)
   
   Revision  Changes    Path
   1.12      +1 -0      ports/devel/mcpp/Makefile
   1.1       +19 -0     ports/devel/mcpp/files/patch-src__internal.H (new)
   1.1       +11 -0     ports/devel/mcpp/files/patch-src__main.c (new)
   1.1       +20 -0     ports/devel/mcpp/files/patch-src__support.c (new)
   1.1       +21 -0     ports/devel/mcpp/files/patch-src__system.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
