lock();
if (fptr == NULL) {
unlock();
+#ifdef HAVE_STRERROR_R
+ if (strerror_r (code, ep->scratch_buf, sizeof(ep->scratch_buf)) == 0)
+ return ep->scratch_buf;
+ /* If strerror_r didn't work with the 1K buffer, we can try a
+ really big one. This seems kind of gratuitous though. */
+#define BIG_ERR_BUFSIZ 8192
+ r = malloc(BIG_ERR_BUFSIZ);
+ if (r) {
+ if (strerror_r (code, r, BIG_ERR_BUFSIZ) == 0) {
+ r2 = realloc (r, 1 + strlen(r));
+ if (r2)
+ return r2;
+ return r;
+ }
+ free (r);
+ }
+#endif
r = strerror (code);
if (r) {
if (strlen (r) < sizeof (ep->scratch_buf)
#endif
#endif
+
+#ifdef HAVE_STRERROR_R
+#define ERRSTR(ERR, BUF) \
+ (strerror_r (ERR, BUF, sizeof(BUF)) == 0 ? BUF : strerror (ERR))
+#else
+#define ERRSTR(ERR, BUF) \
+ (strerror (ERR))
+#endif
+
int32_t KRB5_CALLCONV
krb5int_open_plugin_dir (const char *dirname,
struct plugin_dir_handle *dirhandle)
int nh;
int error = 0;
char path[MAXPATHLEN];
+ char errbuf[1024];
h = NULL;
nh = 0;
dir = opendir(dirname);
if (dir == NULL) {
error = errno;
- Tprintf("-> error %d/%s\n", error, strerror(error));
+ Tprintf("-> error %d/%s\n", error, ERRSTR(error, errbuf));
if (error == ENOENT)
return 0;
return error;
/* Optimization: Linux includes a file type field in the
directory structure. */
if (stat(path, &statbuf) < 0) {
- Tprintf("stat(%s): %s\n", path, strerror(errno));
+ Tprintf("stat(%s): %s\n", path, ERRSTR(errno, errbuf));
continue;
}
if ((statbuf.st_mode & S_IFMT) != S_IFREG) {