Kris Kennaway wrote:
> rpcgen -s `perl -e 'print "a"x5120'`
> rpcgen -n `perl -e 'print "a"x5120'`
> 
> will both segfault when you ^D them.


This is because of the commit that Alfred made to invert the sense
of the "-b" option to generate TIRPC output by default, instead.

You can make the problem go away in -current by adding "-b", or
you can make the problem show up in older versions of FreeBSD by
adding the "-b" to get the TIRPC output, so technically, all he
did was uncover an existing problem in a code path that was not
normally used, which he then made the default.  The problem only
occurs when rpcgen'ing from stdin.  Of course, making the problem
"go away" gets you the wrong output code.

Attached is a minimal diff that will fix the problem (which is
basically everywhere infile is used without being cheched to see
if it's non-NULL, as an argument to strrchr()).

The fix works by substituting "" for NULL before this happens,
but *after* the output file names have been created, to avoid
creating files with a bogus prefix name.

-- Terry
Index: Makefile
===================================================================
RCS file: /cvs/src/usr.bin/rpcgen/Makefile,v
retrieving revision 1.7
diff -c -r1.7 Makefile
*** Makefile    14 Jul 2002 17:55:35 -0000      1.7
--- Makefile    12 Oct 2002 21:18:28 -0000
***************
*** 9,14 ****
--- 9,15 ----
  # This is a kludge to work around the fact that this program
  # uses 'inline' as a variable name.
  #
+ CFLAGS+=-g
  CFLAGS+=-Dinline=rpcgen_inline
  
  .include <bsd.prog.mk>
Index: rpc_svcout.c
===================================================================
RCS file: /cvs/src/usr.bin/rpcgen/rpc_svcout.c,v
retrieving revision 1.14
diff -c -r1.14 rpc_svcout.c
*** rpc_svcout.c        21 Jul 2002 12:55:04 -0000      1.14
--- rpc_svcout.c        12 Oct 2002 21:47:39 -0000
***************
*** 107,112 ****
--- 107,115 ----
        int netflag;
        int nomain;
  {
+       if (!infile)
+               infile = "";
+ 
        if (inetdflag || pmflag) {
                char* var_type;
                var_type = (nomain? "extern" : "static");

Reply via email to