Project

General

Profile

Bug #4579 ยป ossl_rand2.patch

kosaki (Motohiro KOSAKI), 04/16/2011 12:14 AM

View differences:

ext/openssl/ossl_rand.c (working copy)
171 171
    return RAND_status() ? Qtrue : Qfalse;
172 172
}
173 173

  
174
static void
175
ossl_rand_cleanup(void)
176
{
177
    char rand[16];
178

  
179
    RAND_bytes(rand, 16);
180
    RAND_cleanup();
181
    RAND_seed(rand, 16);
182
}
183

  
174 184
#define DEFMETH(class, name, func, argc) \
175 185
	rb_define_method((class), (name), (func), (argc)); \
176 186
	rb_define_singleton_method((class), (name), (func), (argc));
......
197 207
    DEFMETH(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
198 208
    DEFMETH(mRandom, "egd", ossl_rand_egd, 1);
199 209
    DEFMETH(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
200
    DEFMETH(mRandom, "status?", ossl_rand_status, 0)
210
    DEFMETH(mRandom, "status?", ossl_rand_status, 0);
211

  
212
    pthread_atfork(NULL, NULL, ossl_rand_cleanup);
201 213
}
202 214