mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Ron Yorston <rmy@frippery.org>
To: musl@lists.openwall.com
Subject: [PATCH] fix if_nametoindex return value when socket open fails
Date: Fri, 15 Jan 2016 09:39:44 +0000	[thread overview]
Message-ID: <5698be60.uat8s3q4Wfvl5TQE%rmy@frippery.org> (raw)

The return value of if_nametoindex is unsigned; it should return 0
on error.
---
 src/network/if_nametoindex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c
index cb6ec05..331413c 100644
--- a/src/network/if_nametoindex.c
+++ b/src/network/if_nametoindex.c
@@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
 	struct ifreq ifr;
 	int fd, r;
 
-	if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return -1;
+	if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
 	strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
 	r = ioctl(fd, SIOCGIFINDEX, &ifr);
 	__syscall(SYS_close, fd);
-- 
2.5.0



             reply	other threads:[~2016-01-15  9:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15  9:39 Ron Yorston [this message]
2016-01-15 18:57 ` Rich Felker
2016-01-17 22:34 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5698be60.uat8s3q4Wfvl5TQE%rmy@frippery.org \
    --to=rmy@frippery.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).