nbd_set_pread_initialize3
Control whether libnbd pre-initializes read buffers
Usage
#include <libnbd.h>int nbd_set_pread_initialize (struct nbd_handle *h, bool request);
Overview
By default, libnbd will pre-initialize the contents of a buffer passed to calls such as nbd_pread(3) to all zeroes prior to checking for any other errors, so that even if a client application passed in an uninitialized buffer but fails to check for errors, it will not result in a potential security risk caused by an accidental leak of prior heap contents (see CVE-2022-0485 in libnbd-security(3) for an example of a security hole in an application built against an earlier version of libnbd that lacked consistent pre-initialization). However, for a client application that has audited that an uninitialized buffer is never dereferenced, or which performs its own pre-initialization, libnbd's sanitization efforts merely pessimize performance (although the time spent in pre-initialization may pale in comparison to time spent waiting on network packets).
Calling this function with "request" set to false tells libnbd to skip the buffer initialization step in read commands.
Return value
If the call is successful the function returns 0.
Errors
On error -1 is returned.
Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.
The following parameters must not be NULL: "h". For more information see "Non-NULL parameters" in libnbd(3).
Version
This function first appeared in libnbd 1.12.
If you need to test if this function is available at compile time check if the following macro is defined:
#define LIBNBD_HAVE_NBD_SET_PREAD_INITIALIZE 1
Releases
3 releases since Debian 12 (Bookworm); the text changed 2 times.