Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ext/openssl/ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,27 @@ void ossl_want_uninitialized(VALUE self, const rb_data_type_t *type);
*/
#ifndef HAVE_RB_LEN_T /* Ruby 4.1 */
typedef long rb_len_t;
typedef unsigned long rb_ulen_t;
#endif
#ifndef SIZEOF_RB_LEN_T
# define SIZEOF_RB_LEN_T SIZEOF_LONG
#endif
#ifndef RB_LEN_MAX
# define RB_LEN_MAX LONG_MAX
#endif
#ifndef PRIdLEN
# define PRIdLEN "ld"
#endif
#ifndef FIX2LEN
# define FIX2LEN FIX2LONG
#endif
#ifndef NUM2LEN
# define NUM2LEN NUM2LONG
#endif
#ifndef LEN2NUM
# define LEN2NUM LONG2NUM
#endif
#ifndef HAVE_RB_LEN_T
static inline long
rb_len2long(rb_len_t n)
{
Expand Down
10 changes: 5 additions & 5 deletions ext/openssl/ossl_bn.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ integer_to_bnptr(VALUE obj, BIGNUM *orig)
BIGNUM *bn;

if (FIXNUM_P(obj)) {
long i;
unsigned char bin[sizeof(long)];
long n = FIX2LONG(obj);
unsigned long un = labs(n);
size_t i;
unsigned char bin[sizeof(rb_ulen_t)];
rb_len_t n = FIX2LEN(obj);
rb_ulen_t un = n < 0 ? 0 - (rb_ulen_t)n : (rb_ulen_t)n;

for (i = sizeof(long) - 1; 0 <= i; i--) {
for (i = sizeof(bin); 0 < i--;) {
bin[i] = un & 0xff;
un >>= 8;
}
Expand Down
Loading