lib: Avoid declaring zero-length VLAs in various messaging functions
In messaging_rec_create(), messaging_recv_cb() and messaging_dispatch_rec(), variable length arrays of file descriptors are declared using an incoming num_fds parameter. However, there are several scenarios where num_fds can be zero, and declaring a zero-length VLA is undefined behavior. This can lead to segmentation faults and/or other crashes when compiling with recent versions of clang at high optimization levels. To avoid ever using zero as the length for these declarations, use MAX(1, length) instead. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14605Signed-off-by:Dimitry Andric <dimitry@andric.com>
Showing
Please register or sign in to comment