Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darray.h: avoid UB when decrementing zero pointer #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jul 28, 2019

  1. darray.h: avoid UB when decrementing zero pointer

    Sometimes the `&(arr).item[(arr).size]` is a zero pointer. In these
    cases decrementing this pointer aka `i` results in something like
    0xfffffff8. This is UB, and UB sanitizer in particular reports it as
    
    ../iscsi/tcmu-runner/libtcmu.c:563:2: runtime error: pointer index expression with base 0x000000000000 overflowed to 0xfffffffffffffff8
    
    In these cases size is `zero` as well, so fix this by simply not running
    the cycle when the `size` is zero.
    
    Signed-off-by: Konstantin Kharlamov <[email protected]>
    Hi-Angel committed Jul 28, 2019
    Configuration menu
    Copy the full SHA
    f463655 View commit details
    Browse the repository at this point in the history