• A
    src: Don't rely on strncpy()-like behavior · 583bdfa6
    Andrea Bolognani 提交于
    The strncpy() function has this quirk where it will copy
    *up* to the requested number of bytes, that is, it will
    stop early if it encounters a NULL byte in the source
    string.
    
    This makes it legal to pass the size of the destination
    buffer (minus one byte needed for the string terminator)
    as the number of bytes to copy and still get something
    somewhat reasonable out of the operation; unfortunately,
    it also makes the function difficult to reason about
    and way too easy to misuse.
    
    We want to move away from the way strncpy() behaves and
    towards better defined semantics, where virStrncpy()
    will always copy *exactly* the number of bytes it's
    been asked to copy; before we can do that, though, we
    have to change a few of the callers.
    Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
    583bdfa6
xenapi_driver.c 65.9 KB