Linux NFS development
 help / color / mirror / Atom feed
From: Benny Halevy <bhalevy@tonian.com>
To: Olga Kornievskaia <aglo@citi.umich.edu>,
	Michael Groshans <groshans@umich.edu>
Cc: NFS list <linux-nfs@vger.kernel.org>
Subject: [PATCH] pnfsd: dlm: fix bug in DS tcp/tcp6 address string
Date: Tue, 18 Oct 2011 17:52:10 -0700	[thread overview]
Message-ID: <4E9E1F3A.2090709@tonian.com> (raw)

squash into "pnfsd: Correctly set netid to tcp or tcp6 for non-local exports"

Currently, the code looks for ':' using strcspn that requires a null terminated string
while the address buffer isn't null terminated.

Instead, just use strnchr to look for a ':' and if not found assume
it's an IPv4 address, otherwise it's IPv6

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 fs/nfsd/nfs4pnfsdlm.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/nfsd/nfs4pnfsdlm.c b/fs/nfsd/nfs4pnfsdlm.c
index abc4d83..d07a6037 100644
--- a/fs/nfsd/nfs4pnfsdlm.c
+++ b/fs/nfsd/nfs4pnfsdlm.c
@@ -328,13 +328,8 @@ static int nfsd4_pnfs_dlm_getdevinfo(struct super_block *sb,
 		memcpy(daddr->r_addr.data + len, ".8.1", 4);
 		daddr->r_addr.len = len + 4;

-		if (strcspn(daddr->r_addr.data, ":") - 1 == daddr->r_addr.len) {
-			daddr->r_netid.data = "tcp";
-			daddr->r_netid.len = 3;
-		} else {
-			daddr->r_netid.data = "tcp6";
-			daddr->r_netid.len = 4;
-		}
+		daddr->r_netid.data = "tcp6";
+		daddr->r_netid.len = strnchr(daddr->r_addr.data, len, ':') ? 4 : 3;

 		fdev.fl_device_list[i].fl_multipath_length = 1;
 		fdev.fl_device_list[i].fl_multipath_list = daddr;
-- 
1.7.6


             reply	other threads:[~2011-10-19  0:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-19  0:52 Benny Halevy [this message]
2011-10-19 16:07 ` [PATCH] pnfsd: dlm: fix bug in DS tcp/tcp6 address string Weston Andros Adamson
2011-10-31 21:16 ` Olga Kornievskaia
2011-11-02 11:33   ` Benny Halevy

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=4E9E1F3A.2090709@tonian.com \
    --to=bhalevy@tonian.com \
    --cc=aglo@citi.umich.edu \
    --cc=groshans@umich.edu \
    --cc=linux-nfs@vger.kernel.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox