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)
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
===================================================================
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 = FALSE;
+ char dirbuf[MAXPATHLEN+1];
(void)fprintf(f, "%s: ", progname);
@@ -688,7 +689,7 @@ ParseVErrorInternal(FILE *f, const char
if (dir == NULL)
dir = ".";
if (*dir != '/') {
- dir = cp2 = realpath(dir, NULL);
+ dir = cp2 = realpath(dir, dirbuf);
free(cp);
cp = cp2; /* cp2 set to NULL by Var_Value */
}
Home |
Main Index |
Thread Index |
Old Index