[PATCH] heimdal: work around differences between GNU and XSI strerror_r()

Andrew Tridgell tridge at samba.org
Thu Dec 10 20:39:33 MST 2009


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