Bug #9659 » 001-detect-digest-failure.patch
ext/digest/digest.c | ||
---|---|---|
Data_Get_Struct(obj, rb_digest_metadata_t, algo);
|
||
switch (algo->api_version) {
|
||
case 2:
|
||
case 3:
|
||
break;
|
||
/*
|
||
... | ... | |
algo = get_digest_base_metadata(klass);
|
||
pctx = xmalloc(algo->ctx_size);
|
||
algo->init_func(pctx);
|
||
if (algo->init_func(pctx) != 1) {
|
||
rb_raise(rb_eRuntimeError, "Digest initialization failed.");
|
||
}
|
||
obj = Data_Wrap_Struct(klass, 0, xfree, pctx);
|
||
... | ... | |
Data_Get_Struct(self, void, pctx);
|
||
algo->init_func(pctx);
|
||
if (algo->init_func(pctx) != 1) {
|
||
rb_raise(rb_eRuntimeError, "Digest initialization failed.");
|
||
}
|
||
return self;
|
||
}
|
||
... | ... | |
algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str));
|
||
/* avoid potential coredump caused by use of a finished context */
|
||
algo->init_func(pctx);
|
||
if (algo->init_func(pctx) != 1) {
|
||
rb_raise(rb_eRuntimeError, "Digest initialization failed.");
|
||
}
|
||
return str;
|
||
}
|
ext/digest/digest.h | ||
---|---|---|
#include "ruby.h"
|
||
#define RUBY_DIGEST_API_VERSION 2
|
||
#define RUBY_DIGEST_API_VERSION 3
|
||
typedef void (*rb_digest_hash_init_func_t)(void *);
|
||
typedef int (*rb_digest_hash_init_func_t)(void *);
|
||
typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t);
|
||
typedef void (*rb_digest_hash_finish_func_t)(void *, unsigned char *);
|
||
typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *);
|
||
typedef struct {
|
||
int api_version;
|