Skip to content
Merged
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
6 changes: 5 additions & 1 deletion ext/digest/bubblebabble/bubblebabble.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <ruby/ruby.h>
#include "../digest.h"

#ifndef HAVE_RB_LEN_T
# define RB_LEN_MAX LONG_MAX
#endif

static ID id_digest;

static VALUE
Expand All @@ -36,7 +40,7 @@ bubblebabble_str_new(VALUE str_digest)
digest = RSTRING_PTR(str_digest);
digest_len = RSTRING_LEN(str_digest);

if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
if ((RB_LEN_MAX - 2) / 3 < (digest_len | 1)) {
rb_raise(rb_eRuntimeError, "digest string too long");
}

Expand Down
3 changes: 2 additions & 1 deletion ext/digest/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "digest.h"

#ifndef HAVE_RB_LEN_T
# define RB_LEN_MAX LONG_MAX
# define LEN2NUM LONG2NUM
#endif

Expand Down Expand Up @@ -116,7 +117,7 @@ hexencode_str_new(VALUE str_digest)
digest = RSTRING_PTR(str_digest);
digest_len = RSTRING_LEN(str_digest);

if (LONG_MAX / 2 < digest_len) {
if (RB_LEN_MAX / 2 < digest_len) {
rb_raise(rb_eRuntimeError, "digest string too long");
}

Expand Down
Loading