dhcpcd-discuss

Re: minor duid_get bug

Roy Marples

Fri Jun 12 09:55:56 2015

Hi Bob

On 12/06/2015 05:43, rfc wrote:
> in duid.c:duid_get() i see:
> 
> 	x = fprintf(fp, "%s\n", hwaddr_ntoa(d, len, line, sizeof(line)));
> 	fclose(fp);
> 	/* Failed to write the duid? scrub it, we cannot use it */
> 	if (x < 1) {
> 		...
> 	}
> 
> a write error here is more likely to occur in the fclose than the
> fprintf.  a simple fix might be:
> 
> 	if (fclose(fp) == EOF)
> 		x = 0;

Nice catch!
I fixed this in a few more places here:
http://roy.marples.name/projects/dhcpcd/ci/ea7faaa4d40bbba6?sbs=0

Thanks

Roy

References:
minor duid_get bugrfc
Archive administrator: postmaster@marples.name