Introduced POLARSSL_HAVE_READDIR_R for systems without it
diff --git a/ChangeLog b/ChangeLog
index 86beaf7..77107d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
PolarSSL ChangeLog
+= Branch 1.2
+Changes
+ * Introduced POLARSSL_HAVE_READDIR_R for systems without it
+
= Version 1.2.10 released 2013-10-07
Changes
* Changed RSA blinding to a slower but thread-safe version
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index bd1a466..c22830b 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -94,6 +94,17 @@
*
#define POLARSSL_HAVE_SSE2
*/
+
+/**
+ * \def POLARSSL_HAVE_READDIR_R
+ *
+ * (Non Windows) System has readdir_r().
+ *
+ * Required for x509_crt_parse_path() in non-Windows systems.
+ *
+ * Comment if your system does not have support.
+ */
+#define POLARSSL_HAVE_READDIR_R
/* \} name */
/**
diff --git a/library/x509parse.c b/library/x509parse.c
index 2aa0499..42eaf58 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -1948,6 +1948,7 @@
cleanup:
FindClose( hFind );
#else
+#if defined(POLARSSL_HAVE_READDIR_R)
int t_ret, i;
struct stat sb;
struct dirent entry, *result = NULL;
@@ -1984,7 +1985,12 @@
ret += t_ret;
}
closedir( dir );
-#endif
+#else /* POLARSSL_HAVE_READDIR_R */
+ ((void) chain);
+ ((void) path);
+ ret = POLARSSL_ERR_X509_FEATURE_UNAVAILABLE;
+#endif /* POLARSSL_HAVE_READDIR_R */
+#endif /* _WIN32 */
return( ret );
}