[Heimdal-bugs] workaround brokenness in setrerror_r()
Love Hörnquist Åstrand
lha at kth.se
Sun Dec 13 13:44:24 MST 2009
Tridge,
Since strerror_r is used several places I replaced strerror_r with rk_strerror_r and added glue in roken to rewrite the symbol.
Love
10 dec 2009 kl. 19:42 skrev tridge at samba.org:
> Hi Love,
>
> Here is a patch to work around the brokenness between GNU and XSI
> strerror_r(). It uses a trick to detect the difference at runtime,
> rather than trying to do this at the configure level. As the runtime
> trick is fast and should be reliable that seemed a reasonable
> approach.
>
> Cheers, Tridge
>
>
>> From cb7afe7ffbbe2187c59dfc6fe3c3b309d34a7354 Mon Sep 17 00:00:00 2001
> From: Andrew Tridgell <tridge at samba.org>
> Date: Fri, 11 Dec 2009 14:39:33 +1100
> Subject: [PATCH] heimdal: work around differences between GNU and XSI strerror_r()
>
> This is a fairly ugly workaround, but then again, strerror_r() is a
> very ugly mess.
> ---
> source4/heimdal/lib/krb5/fcache.c | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/source4/heimdal/lib/krb5/fcache.c b/source4/heimdal/lib/krb5/fcache.c
> index cda15e4..bec37b2 100644
> --- a/source4/heimdal/lib/krb5/fcache.c
> +++ b/source4/heimdal/lib/krb5/fcache.c
> @@ -374,10 +374,18 @@ fcc_open(krb5_context context,
> fd = open(filename, flags, mode);
> if(fd < 0) {
> char buf[128];
> + char *estr;
> ret = errno;
> - strerror_r(ret, buf, sizeof(buf));
> + buf[0] = 0;
> + estr = (char *)strerror_r(ret, buf, sizeof(buf));
> + if (buf[0] != 0) {
> + /* we've got the BSD/XSI strerror_r, and it use the
> + * buffer. Otherwise we have the GNU strerror_r, and
> + * it used a static string. Ain't standards great? */
> + estr = buf;
> + }
> krb5_set_error_message(context, ret, N_("open(%s): %s", "file, error"),
> - filename, buf);
> + filename, estr);
> return ret;
> }
> rk_cloexec(fd);
> --
> 1.6.3.3
>
More information about the samba-technical
mailing list