Hi,

On 05/01/2021 14:17, Arne Schwabe wrote:
> This ensure that all unused fields in msg are zero.
> 
> Spotted by Coverity:
> 
> Using uninitialized value "msg". Field "msg.msg_flags" is uninitialized
> when calling "sendmsg".

No signed-off-by ?

> ---
>  src/openvpn/manage.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
> index a4f99c9a..103ccadc 100644
> --- a/src/openvpn/manage.c
> +++ b/src/openvpn/manage.c
> @@ -2092,7 +2092,7 @@ man_io_error(struct management *man, const char *prefix)
>  static ssize_t
>  man_send_with_fd(int fd, void *ptr, size_t nbytes, int flags, int sendfd)
>  {
> -    struct msghdr msg;
> +    struct msghdr msg = {0};

In the rest of the code we have spaces around the 0, like "{ 0 }"
I suggest using the same style.

>      struct iovec iov[1];
>  
>      union {
> @@ -2124,7 +2124,7 @@ man_send_with_fd(int fd, void *ptr, size_t nbytes, int 
> flags, int sendfd)
>  static ssize_t
>  man_recv_with_fd(int fd, void *ptr, size_t nbytes, int flags, int *recvfd)
>  {
> -    struct msghdr msghdr;
> +    struct msghdr msghdr = {0};

same as above.

>      struct iovec iov[1];
>      ssize_t n;
>  
> 

Other than that it's Feature-ACK.
We should always fully initialize objects that we pass around.

Cheers,

-- 
Antonio Quartulli


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to