NetBSD-Bugs archive

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

Re: bin/52737 (bmake crash for invalid usage of .PATH)



I'd rather unconditionally free "paths" if it was not NULL rather than add more complexity
to the code. This function needs to be split up; it is too big and complicated.

christos

> On Apr 8, 2019, at 4:25 PM, Simon J. Gerraty <sjg%juniper.net@localhost> wrote:
> 
> The following reply was made to PR bin/52737; 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>, <bsiegert%NetBSD.org@localhost>,
>        <n54%gmx.com@localhost>, <sjg%juniper.net@localhost>
> Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
> Date: Mon, 8 Apr 2019 13:35:14 -0700
> 
>> Synopsis: bmake crash for invalid usage of .PATH
> 
> The assert could be removed, or made conditional
> on seeing valid dependency line:
> 
> diff -r 6f103b9234c3 bmake/parse.c
> --- a/bmake/parse.c	Sun Dec 30 09:28:02 2018 -0800
> +++ b/bmake/parse.c	Mon Apr 08 13:33:09 2019 -0700
> @@ -1222,6 +1222,7 @@
>      Lst 	    curTargs;	/* list of target names to be found and added
>  				 * to the targets list */
>      char	   *lstart = line;
> +    Boolean	    colon_seen;
> 
>      if (DEBUG(PARSE))
>  	fprintf(debug_file, "ParseDoDependency(%s)\n", line);
> @@ -1229,6 +1230,7 @@
> 
>      specType = Not;
>      paths = NULL;
> +    colon_seen = FALSE;
> 
>      curTargs = Lst_Init(FALSE);
> 
> @@ -1313,6 +1315,8 @@
> 
>  	/* Insert a null terminator. */
>  	savec = *cp;
> +	if (*cp == ':')
> +	    colon_seen = TRUE;
>  	*cp = '\0';
> 
>  	/*
> @@ -1768,6 +1772,10 @@
>      }
> 
>  out:
> +    if (paths && !colon_seen) {
> +	Lst_Destroy(paths, NULL);
> +	paths = NULL;
> +    }
>      assert(paths == NULL);
>      if (curTargs)
>  	    Lst_Destroy(curTargs, NULL);
> 



Home | Main Index | Thread Index | Old Index