summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/roken/strerror_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/roken/strerror_r.c')
-rw-r--r--source4/heimdal/lib/roken/strerror_r.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/source4/heimdal/lib/roken/strerror_r.c b/source4/heimdal/lib/roken/strerror_r.c
index 63dae09a7d..5155c28cb5 100644
--- a/source4/heimdal/lib/roken/strerror_r.c
+++ b/source4/heimdal/lib/roken/strerror_r.c
@@ -33,11 +33,12 @@
#include <config.h>
-#if !defined(HAVE_STRERROR_R) && !defined(STRERROR_R_PROTO_COMPATIBLE)
+#if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include "roken.h"
#ifdef _MSC_VER
@@ -58,11 +59,6 @@ rk_strerror_r(int eno, char * strerrbuf, size_t buflen)
#else /* _MSC_VER */
-#ifndef HAVE_STRERROR_R
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
-
int ROKEN_LIB_FUNCTION
rk_strerror_r(int eno, char *strerrbuf, size_t buflen)
{
@@ -76,11 +72,7 @@ rk_strerror_r(int eno, char *strerrbuf, size_t buflen)
return 0;
#else
int ret;
- if(eno < 0 || eno >= sys_nerr) {
- snprintf(strerrbuf, buflen, "Error %d occurred.", eno);
- return EINVAL;
- }
- ret = snprintf(strerrbuf, buflen, "%s", sys_errlist[eno]);
+ ret = strlcpy(strerrbuf, buflen, strerror(eno));
if (ret > buflen)
return ERANGE;
return 0;