NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/54574: usr.bin/make/parse.c $Id: 1.231 drops core on NetBSD-5.2 in realpath(3)



The following reply was made to PR toolchain/54574; it has been noted by GNATS.

From: "Simon J. Gerraty" <sjg%juniper.net@localhost>
To: <gnats-bugs%netbsd.org@localhost>
Cc: <gnats-admin%netbsd.org@localhost>, <netbsd-bugs%netbsd.org@localhost>, <buhrow%nfbcal.org@localhost>,
        <sjg%juniper.net@localhost>
Subject: Re: bin/54574: usr.bin/make/parse.c $Id: 1.231 drops core on NetBSD-5.2 in realpath(3)
Date: Wed, 25 Sep 2019 23:35:32 -0700

 John Nemeth <jnemeth%cue.bc.ca@localhost> wrote:
 >       The realpath() function call first appeared in 4.4BSD.  In NetBSD =
 7.0 the
 >       function was updated to accept a NULL pointer for the resolvedname
 >       argument.
 >  =
 
 >  POSIX says:
 >  =
 
 >  If resolved_name is a null pointer, the behavior of realpath() is
 >  implementation-defined.
 >  =
 
 >  parse.c:1.231 in ParseVErrorInternal() calls realpath() with a null
 >  pointer for resolved_name thus relying on the NetBSD 7.0 behaviour.
 >  This is a portability bug.
 
 The following should be safe:
 
 Index: parse.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/usr.bin/make/parse.c,v
 retrieving revision 1.232
 diff -u -p -r1.232 parse.c
 --- parse.c	9 Apr 2019 18:28:10 -0000	1.232
 +++ parse.c	26 Sep 2019 06:31:44 -0000
 @@ -669,6 +669,7 @@ static void
  ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type=
 ,
      const char *fmt, va_list ap)
  {
  	static Boolean fatal_warning_error_printed =3D FALSE;
 +	char dirbuf[MAXPATHLEN+1];
  =
 
  	(void)fprintf(f, "%s: ", progname);
 @@ -688,7 +689,7 @@ ParseVErrorInternal(FILE *f, const char =
 
  			if (dir =3D=3D NULL)
  				dir =3D ".";
  			if (*dir !=3D '/') {
 -				dir =3D cp2 =3D realpath(dir, NULL);
 +				dir =3D cp2 =3D realpath(dir, dirbuf);
  				free(cp);
  				cp =3D cp2; /* cp2 set to NULL by Var_Value */
  			}
 


Home | Main Index | Thread Index | Old Index