summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-08-09 10:58:08 -0400
committerSimo Sorce <simo@redhat.com>2014-08-10 14:29:37 -0400
commitb927c52eefa7daf894253ea54193835d790b4659 (patch)
treec11e35a558c2bff4fd7adf104d6eab81f5986980
parent66a06abe4a687170882888bf52750abd3ce5afbf (diff)
downloadgss-ntlmssp-b927c52eefa7daf894253ea54193835d790b4659.tar.gz
gss-ntlmssp-b927c52eefa7daf894253ea54193835d790b4659.tar.xz
gss-ntlmssp-b927c52eefa7daf894253ea54193835d790b4659.zip
Add support for both strerror_r variants
-rw-r--r--src/gss_err.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gss_err.c b/src/gss_err.c
index 712203d..321ed90 100644
--- a/src/gss_err.c
+++ b/src/gss_err.c
@@ -42,12 +42,29 @@ uint32_t gssntlm_display_status(uint32_t *minor_status,
goto done;
}
+ /* handle both XSI and GNU specific varints of strerror_r */
errno = 0;
+#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
+ /* XSI version */
err = strerror_r(status_value, buf, 400);
/* The XSI-compliant strerror_r() function returns 0 on success.
* On error, a (positive) error number is returned (since glibc
* 2.13), or -1 is returned and errno is set to indicate the
* error (glibc versions before 2.13). */
+#else
+ {
+ char *ret;
+ ret = strerror_r(errnum, buf, 400);
+ if (ret == NULL) {
+ err = errno;
+ } else {
+ if (ret != buf) {
+ memmove(buf, ret, strlen(ret) + 1);
+ }
+ err = 0;
+ }
+ }
+#endif
if (err == -1) err = errno;
switch (err) {
case ERANGE: