From 01cb9e297c5d0ac85cadb37c4f25964ba1e8638a Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 8 Mar 2017 19:19:45 -0600 Subject: [PATCH 1/7] Use the same parameter types as what's defined by the GNU crypt_r function call. --- ext/mri/ow-crypt.h | 2 +- ext/mri/wrapper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index 2e48794..4db4f11 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,7 +24,7 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); -extern char *crypt_r(__const char *key, __const char *setting, void *data); +extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); #endif #ifndef __SKIP_OW diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index 1e49c90..6d326ab 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,7 +176,7 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } -char *crypt_r(const char *key, const char *setting, void *data) +char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( crypt_rn(key, setting, data, CRYPT_OUTPUT_SIZE), From 1c743ab0144f36816d1b0f6a36d586268c102c16 Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Sat, 14 Apr 2018 09:35:40 +1000 Subject: [PATCH 2/7] Attempt at FreeBSD 12 check --- ext/mri/ow-crypt.h | 4 ++++ ext/mri/wrapper.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index 4db4f11..42a7e95 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,7 +24,11 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); +#if __FreeBSD_version <= 1200000 extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); +#else +extern char *crypt_r(__const char *key, __const char *setting, void *data); +#endif #endif #ifndef __SKIP_OW diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index 6d326ab..c557158 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,6 +176,7 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } +#if __FreeBSD_version <= 1200000 char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( @@ -191,6 +192,14 @@ char *crypt(const char *key, const char *setting) crypt_rn(key, setting, output, sizeof(output)), setting, output, sizeof(output)); } +#else +char *crypt_r(__const char *key, __const char *setting, void *data) +{ + return _crypt_retval_magic( + crypt_rn(key, setting, data, CRYPT_OUTPUT_SIZE), + setting, (char *)data); +} +#endif #define __crypt_gensalt_rn crypt_gensalt_rn #define __crypt_gensalt_ra crypt_gensalt_ra From c7c949e7b6d4fd53f282c8bbf233431b2bab291a Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Sat, 14 Apr 2018 10:10:01 +1000 Subject: [PATCH 3/7] So it looks like you need brackets :-) --- ext/mri/ow-crypt.h | 2 +- ext/mri/wrapper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index 42a7e95..b868ba6 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,7 +24,7 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); -#if __FreeBSD_version <= 1200000 +#if (__FreeBSD_version >= 1200000) extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); #else extern char *crypt_r(__const char *key, __const char *setting, void *data); diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index c557158..be2b60a 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,7 +176,7 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } -#if __FreeBSD_version <= 1200000 +#if (__FreeBSD_version >= 1200000) char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( From 0b6d5ff41669a1e489ab37f1eb05641d660038a0 Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Sat, 14 Apr 2018 10:12:29 +1000 Subject: [PATCH 4/7] Better be careful than sorry --- ext/mri/ow-crypt.h | 2 +- ext/mri/wrapper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index b868ba6..f4cbdc3 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,7 +24,7 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); -#if (__FreeBSD_version >= 1200000) +#if (defined(__FreeBSD__) && (__FreeBSD_version >= 1200000)) extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); #else extern char *crypt_r(__const char *key, __const char *setting, void *data); diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index be2b60a..30a6cf5 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,7 +176,7 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } -#if (__FreeBSD_version >= 1200000) +#if (defined(__FreeBSD__) && (__FreeBSD_version >= 1200000)) char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( From a1454c661c8e826a0be43683185b721a5ebb7f4c Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Sun, 15 Apr 2018 16:05:18 +1000 Subject: [PATCH 5/7] Checking for FreeBSD and including OS check --- ext/mri/ow-crypt.h | 5 ++++- ext/mri/wrapper.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index f4cbdc3..79c62e3 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,7 +24,10 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); -#if (defined(__FreeBSD__) && (__FreeBSD_version >= 1200000)) +#if defined(__FreeBSD__) +#include +#endif +#if __FreeBSD_version >= 1200062 extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); #else extern char *crypt_r(__const char *key, __const char *setting, void *data); diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index 30a6cf5..b1bde8c 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,7 +176,10 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } -#if (defined(__FreeBSD__) && (__FreeBSD_version >= 1200000)) +#if defined(__FreeBSD__) +#include +#endif +#if __FreeBSD_version >= 1200062 char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( From 63f6088e82275256f570fb644d57e4b680e41092 Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Mon, 16 Apr 2018 08:04:33 +1000 Subject: [PATCH 6/7] Lowered version requirement --- ext/mri/ow-crypt.h | 2 +- ext/mri/wrapper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index 79c62e3..ecab8bb 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -27,7 +27,7 @@ extern char *crypt(__const char *key, __const char *setting); #if defined(__FreeBSD__) #include #endif -#if __FreeBSD_version >= 1200062 +#if __FreeBSD_version >= 1200061 extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); #else extern char *crypt_r(__const char *key, __const char *setting, void *data); diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index b1bde8c..9ded7a4 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -179,7 +179,7 @@ char *crypt_ra(const char *key, const char *setting, #if defined(__FreeBSD__) #include #endif -#if __FreeBSD_version >= 1200062 +#if __FreeBSD_version >= 1200061 char *crypt_r(const char *key, const char *setting, struct crypt_data *data) { return _crypt_retval_magic( From ba5684a9d98e2914a0f0655c99813f64752ab5bd Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Mon, 3 Dec 2018 19:17:51 +1100 Subject: [PATCH 7/7] Looks like crypt_r is not a thing anymore See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=212304 --- ext/mri/ow-crypt.h | 8 -------- ext/mri/wrapper.c | 19 ------------------- 2 files changed, 27 deletions(-) diff --git a/ext/mri/ow-crypt.h b/ext/mri/ow-crypt.h index ecab8bb..d792ae0 100644 --- a/ext/mri/ow-crypt.h +++ b/ext/mri/ow-crypt.h @@ -24,14 +24,6 @@ #ifndef __SKIP_GNU extern char *crypt(__const char *key, __const char *setting); -#if defined(__FreeBSD__) -#include -#endif -#if __FreeBSD_version >= 1200061 -extern char *crypt_r(__const char *key, __const char *setting, struct crypt_data *data); -#else -extern char *crypt_r(__const char *key, __const char *setting, void *data); -#endif #endif #ifndef __SKIP_OW diff --git a/ext/mri/wrapper.c b/ext/mri/wrapper.c index 9ded7a4..ef45488 100644 --- a/ext/mri/wrapper.c +++ b/ext/mri/wrapper.c @@ -176,17 +176,6 @@ char *crypt_ra(const char *key, const char *setting, return _crypt_blowfish_rn(key, setting, (char *)*data, *size); } -#if defined(__FreeBSD__) -#include -#endif -#if __FreeBSD_version >= 1200061 -char *crypt_r(const char *key, const char *setting, struct crypt_data *data) -{ - return _crypt_retval_magic( - crypt_rn(key, setting, data, CRYPT_OUTPUT_SIZE), - setting, (char *)data, CRYPT_OUTPUT_SIZE); -} - char *crypt(const char *key, const char *setting) { static char output[CRYPT_OUTPUT_SIZE]; @@ -195,14 +184,6 @@ char *crypt(const char *key, const char *setting) crypt_rn(key, setting, output, sizeof(output)), setting, output, sizeof(output)); } -#else -char *crypt_r(__const char *key, __const char *setting, void *data) -{ - return _crypt_retval_magic( - crypt_rn(key, setting, data, CRYPT_OUTPUT_SIZE), - setting, (char *)data); -} -#endif #define __crypt_gensalt_rn crypt_gensalt_rn #define __crypt_gensalt_ra crypt_gensalt_ra