"GOT", but the "O" is a cute, smiling sun Index | Thread

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: gotwebd: error path leak & semplification for render_index
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 5 Nov 2022 17:04:25 +0100

Download raw body.

On Sat, Nov 05, 2022 at 03:27:46PM +0100, Omar Polo wrote:
> Honestly, I don't really like the idea of got_path_dir_is_empty.  What

Why? Because it opens and closes the directory again even
though gotwebd already has an open handle to the directory?
Or is there another reason?

> @@ -2443,6 +2439,17 @@ done:
>  		goto err;
>  	}
>  
> +	while ((dent = readdir(dt)) != NULL) {
> +		if (strcmp(dent->d_name, ".") == 0 ||
> +		    strcmp(dent->d_name, "..") == 0)
> +			continue;
> +		empty = 0;
> +		break;
> +	}

Instead of hand-rolling this loop, we could have a function which implements
this loop in path.c, and call it from here and from got_path_dir_is_empty().