Re: [PATCH] crypto: fix a few memleaks/undefined pointer dereferences
Sverker Eriksson <[email protected]> Fri, 20 Dec 2013 16:13:42 +0100
| Newsgroups | gmane.comp.lang.erlang.patches |
|---|---|
| Message-ID | <[email protected]> |
On 12/16/2013 05:24 PM, Florian Zumbiehl wrote: >>> what I am wondering about is >>> whether it is correct that almost none of the OpenSSL calls in crypto are >>> being checked for memory allocation failures!? >> Not sure what you mean. Can you give an example. > For example, almost none of the bignum calls (BN_.*) are checked for error > returns, the OpensSSL documentation explicitly states that you always have > to check returns because it uses dynamic memory allocation and thus > allocation failures might occur. Looking around in the code, I also found a > call to HMAC_Init(), for example, which I'm pretty sure also uses dynamic > allocation (and in any case, the OpenSSL documentation shows that is has an > error return, even though the possible causes of failure are not listed), > and then there are all those <algorithm>_Init calls and the like, of which > I don't have a clue whether they do use dynamic allocation, but in any > case, the OpenSSL documentation shows they also have error returns, and > those generally don't seem to be checked either. > A simple fix to this would be to let the crypto_alloc (in crypto_callback.c) to call abort() if the allocation failed as that is the strategy otherwise in out-of-memory scenarios. Thus a "nice crash" with an "Out of memory" message instead of a segmentation violation. /Sverker _______________________________________________ erlang-patches mailing list [email protected] http://erlang.org/mailman/listinfo/erlang-patches