1nbd_set_pread_initialize(3) LIBNBD nbd_set_pread_initialize(3)
2
3
4
6 nbd_set_pread_initialize - control whether libnbd pre-initializes read
7 buffers
8
10 #include <libnbd.h>
11
12 int nbd_set_pread_initialize (
13 struct nbd_handle *h, bool request
14 );
15
17 By default, libnbd will pre-initialize the contents of a buffer passed
18 to calls such as nbd_pread(3) to all zeroes prior to checking for any
19 other errors, so that even if a client application passed in an
20 uninitialized buffer but fails to check for errors, it will not result
21 in a potential security risk caused by an accidental leak of prior heap
22 contents (see CVE-2022-0485 in libnbd-security(3) for an example of a
23 security hole in an application built against an earlier version of
24 libnbd that lacked consistent pre-initialization). However, for a
25 client application that has audited that an uninitialized buffer is
26 never dereferenced, or which performs its own pre-initialization,
27 libnbd's sanitization efforts merely pessimize performance (although
28 the time spent in pre-initialization may pale in comparison to time
29 spent waiting on network packets).
30
31 Calling this function with "request" set to false tells libnbd to skip
32 the buffer initialization step in read commands.
33
35 If the call is successful the function returns 0.
36
38 On error -1 is returned.
39
40 Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
41 of the error.
42
43 The following parameters must not be NULL: "h". For more information
44 see "Non-NULL parameters" in libnbd(3).
45
47 This function first appeared in libnbd 1.12.
48
49 If you need to test if this function is available at compile time check
50 if the following macro is defined:
51
52 #define LIBNBD_HAVE_NBD_SET_PREAD_INITIALIZE 1
53
55 nbd_aio_pread(3), nbd_aio_pread_structured(3), nbd_create(3),
56 nbd_get_pread_initialize(3), nbd_pread(3), nbd_pread_structured(3),
57 nbd_set_strict_mode(3), libnbd(3).
58
60 Eric Blake
61
62 Richard W.M. Jones
63
65 Copyright Red Hat
66
68 This library is free software; you can redistribute it and/or modify it
69 under the terms of the GNU Lesser General Public License as published
70 by the Free Software Foundation; either version 2 of the License, or
71 (at your option) any later version.
72
73 This library is distributed in the hope that it will be useful, but
74 WITHOUT ANY WARRANTY; without even the implied warranty of
75 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
76 Lesser General Public License for more details.
77
78 You should have received a copy of the GNU Lesser General Public
79 License along with this library; if not, write to the Free Software
80 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
81 02110-1301 USA
82
83
84
85libnbd-1.18.1 2023-10-31 nbd_set_pread_initialize(3)