=head1 NAME

nbd_set_pread_initialize - control whether libnbd pre-initializes read
buffers

=head1 SYNOPSIS

 #include <libnbd.h>

 int nbd_set_pread_initialize (
       struct nbd_handle *h, bool request
     );

=head1 DESCRIPTION

By default, libnbd will pre-initialize the contents of a buffer
passed to calls such as L<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
L<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 C<request> set to false tells libnbd to
skip the buffer initialization step in read commands.

=head1 RETURN VALUE

If the call is successful the function returns C<0>.

=head1 ERRORS

On error C<-1> is returned.

Refer to L<libnbd(3)/ERROR HANDLING>
for how to get further details of the error.

The following parameters must not be NULL: C<h>.
For more information see L<libnbd(3)/Non-NULL parameters>.

=head1 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

=head1 SEE ALSO

L<nbd_aio_pread(3)>,
L<nbd_aio_pread_structured(3)>,
L<nbd_create(3)>,
L<nbd_get_pread_initialize(3)>,
L<nbd_pread(3)>,
L<nbd_pread_structured(3)>,
L<nbd_set_strict_mode(3)>,
L<libnbd(3)>.

=head1 AUTHORS

Eric Blake

Richard W.M. Jones

=head1 COPYRIGHT

Copyright Red Hat
