lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120820125522.2e5eb519@nehalam.linuxnetplumber.net>
Date:	Mon, 20 Aug 2012 12:55:22 -0700
From:	Stephen Hemminger <shemminger@...tta.com>
To:	Pavel Emelyanov <xemul@...allels.com>
Cc:	Stephen Hemminger <shemminger@...ux-foundation.org>,
	Linux Netdev List <netdev@...r.kernel.org>
Subject: Re: [PATCH] iproute: Fix errno propagation from rtnl_talk

On Mon, 20 Aug 2012 12:08:40 +0400
Pavel Emelyanov <xemul@...allels.com> wrote:

> Callers of rtnl_talk check errno value for their needs. In particular, the addrs
> and routes restoring code validly reports success if the EEXISTS is in there.
> 
> However, the errno value can be sometimes screwed up by the perror call. Thus
> we should only set it _after_ the message was emitted.
> 
> Signed-off-by: Pavel Emelyanov <xemul@...allels.com>
> 
> ---
> 
> diff --git a/lib/libnetlink.c b/lib/libnetlink.c
> index 878911e..8e8c8b9 100644
> --- a/lib/libnetlink.c
> +++ b/lib/libnetlink.c
> @@ -360,13 +360,14 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
>  				if (l < sizeof(struct nlmsgerr)) {
>  					fprintf(stderr, "ERROR truncated\n");
>  				} else {
> -					errno = -err->error;
> -					if (errno == 0) {
> +					if (!err->error) {
>  						if (answer)
>  							memcpy(answer, h, h->nlmsg_len);
>  						return 0;
>  					}
> -					perror("RTNETLINK answers");
> +
> +					fprintf(stderr, "RTNETLINK answers: %s\n", strerror(-err->error));
> +					errno = -err->error;
>  				}
>  				return -1;
>  			}

Applied
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ