Browse Source

[nfs] : fix bug in nfs when enable ipv6

SummerGift 7 years ago
parent
commit
98d8145661
1 changed files with 9 additions and 1 deletions
  1. 9 1
      components/dfs/filesystems/nfs/rpc/clnt_generic.c

+ 9 - 1
components/dfs/filesystems/nfs/rpc/clnt_generic.c

@@ -62,7 +62,15 @@ CLIENT *clnt_create (const char *hostname, const unsigned long prog,
 	memset((char*)&sin,0,sizeof(sin));
 	sin.sin_family = h->h_addrtype;
 	sin.sin_port = 0;
-	memmove((char *) &sin.sin_addr, h->h_addr, h->h_length);
+	
+	if (h->h_addrtype == AF_INET)
+	{
+		memmove((char *) &sin.sin_addr, h->h_addr, sizeof(sin.sin_addr)); 
+	}
+	else
+	{
+		return NULL;
+	}
 
 	sock = -1;
 	if (strcmp(proto, "udp") == 0)