• R
    crypto: avoid undefined behavior in nettle calls · d3462e37
    Radim Krčmář 提交于
    Calling a function pointer that was cast from an incompatible function
    results in undefined behavior.  'void *' isn't compatible with 'struct
    XXX *', so we can't cast to nettle_cipher_func, but have to provide a
    wrapper.  (Conversion from 'void *' to 'struct XXX *' might require
    computation, which won't be done if we drop argument's true type, and
    pointers can have different sizes so passing arguments on stack would
    bug.)
    
    Having two different prototypes based on nettle version doesn't make
    this solution any nicer.
    Reported-by: NPeter Maydell <peter.maydell@linaro.org>
    Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
    Message-Id: <1437062641-12684-3-git-send-email-rkrcmar@redhat.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    d3462e37
cipher-nettle.c 6.6 KB