#229: static const EVP_CIPHER * make_ctr_evp (size_t keylen) in openssl.c
not threadsafe
-----------------------+----------------------
Reporter: engstrom | Owner: bagder
Type: defect | Status: assigned
Priority: normal | Milestone: 1.2.9
Component: API | Version: 1.3.0
Resolution: | Keywords:
Blocked By: | Blocks:
-----------------------+----------------------
Comment (by engstrom):
Replying to [comment:9 bagder]:
> static structs are zero'ed already, defined by the C standard. We don't
need to clear them.
>
> Thus just skipping the memset() is a MUCH smaller change and creates
much less duplicated code imho...
True, the C standard does guarantee a static structure is zeroed but the C
standard does not guarantee that the pointer assignment (e.g.
aes_ctr_cipher.do_cipher = aes_ctr_do_cipher;) is atomic - therefore the
pointer may be in an undetermined state when one thread is trying to
deference it while another thread is trying to assign the pointer. Hence
the need to set the structure members before they are used.
Once again, thanks for taking the time to look into this problem.
-- Ticket URL: <http://trac.libssh2.org/ticket/229#comment:11> libssh2 <http://trac.libssh2.org/> C library for writing portable SSH2 clients _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-develReceived on 2011-09-29