[PATCH] Fix the FreeBSD build

Jeremy Allison jra at samba.org
Wed Jun 7 17:17:09 UTC 2017


On Wed, Jun 07, 2017 at 10:09:50PM +1200, Andrew Bartlett via samba-technical wrote:
>  }
> +#elif (!defined(STRERROR_R_XSI_NOT_GNU))
> +#undef strerror_r
> +int rep_strerror_r(int errnum, char *buf, size_t buflen)
> +{
> +	char *s = strerror_r(errnum, buf, buflen);
> +	if (s == NULL) {
> +		/* Shouldn't happen, should always get a string */
> +		return EINVAL;
> +	} else if (s != buf) {
> +		strlcpy(buf, s, buflen);
> +		if (strlen(s) > buflen - 1) {
> +			return ERANGE;
> +		}

Minor nit - the ERANGE check should be *before*
the strlcpy, that way we don't touch *buf if we're
returning an error.



More information about the samba-technical mailing list