CVS commit: src/sys/netinet

2012-06-21 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Jun 21 10:30:47 UTC 2012

Modified Files:
src/sys/netinet: rfc6056.c

Log Message:
whitespace and cosmetics.  no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/rfc6056.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/rfc6056.c
diff -u src/sys/netinet/rfc6056.c:1.6 src/sys/netinet/rfc6056.c:1.7
--- src/sys/netinet/rfc6056.c:1.6	Fri Apr 13 15:38:04 2012
+++ src/sys/netinet/rfc6056.c	Thu Jun 21 10:30:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rfc6056.c,v 1.6 2012/04/13 15:38:04 yamt Exp $	*/
+/*	$NetBSD: rfc6056.c,v 1.7 2012/06/21 10:30:47 yamt Exp $	*/
 
 /*
  * Copyright 2011 Vlad Balan
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.6 2012/04/13 15:38:04 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.7 2012/06/21 10:30:47 yamt Exp $);
 
 #include opt_inet.h
 
@@ -143,13 +143,13 @@ static int
 pcb_getports(struct inpcb_hdr *inp_hdr, uint16_t *lastport,
 uint16_t *mymin, uint16_t *mymax, uint16_t **pnext_ephemeral, int algo)
 {
+	struct inpcbtable * const table = inp_hdr-inph_table;
 	struct socket *so;
 	int rfc6056_proto;
 	int rfc6056_af;
 	int rfc6056_range;
 
 	so = inp_hdr-inph_socket;
-
 	switch (so-so_type) {
 	case SOCK_DGRAM: /* UDP or DCCP */
 		rfc6056_proto = RFC6056_UDP;
@@ -165,10 +165,8 @@ pcb_getports(struct inpcb_hdr *inp_hdr, 
 #ifdef INET
 	case AF_INET: {
 		struct inpcb *inp = (struct inpcb *)(void *)inp_hdr;
-		struct inpcbtable *table = inp-inp_table;
 
 		rfc6056_af = RFC6056_IPV4;
-
 		if (inp-inp_flags  INP_LOWPORT) {
 			*mymin = lowportmin;
 			*mymax = lowportmax;
@@ -186,10 +184,8 @@ pcb_getports(struct inpcb_hdr *inp_hdr, 
 #ifdef INET6
 	case AF_INET6: {
 		struct in6pcb *in6p = (struct in6pcb *)(void *)inp_hdr;
-		struct inpcbtable *table = in6p-in6p_table;
 
 		rfc6056_af = RFC6056_IPV6;
-
 		if (in6p-in6p_flags  IN6P_LOWPORT) {
 			*mymin = ip6_lowportmin;
 			*mymax = ip6_lowportmax;
@@ -233,10 +229,9 @@ pcb_getports(struct inpcb_hdr *inp_hdr, 
  * shamelessly copied from in_pcb.c.
  */
 static bool
-check_suitable_port(uint16_t port, struct inpcb_hdr *inp_hdr,
-kauth_cred_t cred)
+check_suitable_port(uint16_t port, struct inpcb_hdr *inp_hdr, kauth_cred_t cred)
 {
-	struct inpcbtable *table;
+	struct inpcbtable * const table = inp_hdr-inph_table;
 #ifdef INET
 	vestigial_inpcb_t vestigial;
 #endif
@@ -248,28 +243,14 @@ kauth_cred_t cred)
 
 	DPRINTF(%s called for argument %d\n, __func__, port);
 
-
 	switch (inp_hdr-inph_af) {
 #ifdef INET
 	case AF_INET: { /* IPv4 */
 		struct inpcb *inp = (struct inpcb *)(void *)inp_hdr;
 		struct inpcb *pcb;
 		struct sockaddr_in sin;
-		enum kauth_network_req req;
-
-		if (inp-inp_flags  INP_LOWPORT) {
-#ifndef IPNOPRIVPORTS
-			req = KAUTH_REQ_NETWORK_BIND_PRIVPORT;
-#else
-			req = KAUTH_REQ_NETWORK_BIND_PORT;
-#endif
-		} else
-			req = KAUTH_REQ_NETWORK_BIND_PORT;
-
-		table = inp-inp_table;
 
 		sin.sin_addr = inp-inp_laddr;
-
 		pcb = in_pcblookup_port(table, sin.sin_addr, htons(port), 1,
 		vestigial);
 
@@ -278,6 +259,18 @@ kauth_cred_t cred)
 		__func__, pcb, vestigial.valid);
 
 		if ((!pcb)  (!vestigial.valid)) {
+			enum kauth_network_req req;
+
+			/* We have a free port. Check with the secmodel. */
+			if (inp-inp_flags  INP_LOWPORT) {
+#ifndef IPNOPRIVPORTS
+req = KAUTH_REQ_NETWORK_BIND_PRIVPORT;
+#else
+req = KAUTH_REQ_NETWORK_BIND_PORT;
+#endif
+			} else
+req = KAUTH_REQ_NETWORK_BIND_PORT;
+
 			sin.sin_port = port;
 			error = kauth_authorize_network(cred,
 			KAUTH_NETWORK_BIND,
@@ -296,21 +289,9 @@ kauth_cred_t cred)
 #ifdef INET6
 	case AF_INET6: { /* IPv6 */
 		struct in6pcb *in6p = (struct in6pcb *)(void *)inp_hdr;
-		table = in6p-in6p_table;
 		struct sockaddr_in6 sin6;
-		enum kauth_network_req req;
 		void *t;
 
-		if (in6p-in6p_flags  IN6P_LOWPORT) {
-#ifndef IPNOPRIVPORTS
-			req = KAUTH_REQ_NETWORK_BIND_PRIVPORT;
-#else
-			req = KAUTH_REQ_NETWORK_BIND_PORT;
-#endif
-		} else {
-			req = KAUTH_REQ_NETWORK_BIND_PORT;
-		}
-
 		sin6.sin6_addr = in6p-in6p_laddr;
 		so = in6p-in6p_socket;
 
@@ -341,8 +322,20 @@ kauth_cred_t cred)
 return false;
 			}
 		}
-		if (t == 0) {
+		if (t == NULL) {
+			enum kauth_network_req req;
+
 			/* We have a free port. Check with the secmodel. */
+			if (in6p-in6p_flags  IN6P_LOWPORT) {
+#ifndef IPNOPRIVPORTS
+req = KAUTH_REQ_NETWORK_BIND_PRIVPORT;
+#else
+req = KAUTH_REQ_NETWORK_BIND_PORT;
+#endif
+			} else {
+req = KAUTH_REQ_NETWORK_BIND_PORT;
+			}
+
 			sin6.sin6_port = port;
 			error = kauth_authorize_network(cred,
 			KAUTH_NETWORK_BIND, req, so, sin6, NULL);
@@ -720,7 +713,6 @@ static int
 algo_randinc(int algo, uint16_t *port, struct inpcb_hdr *inp_hdr,
 kauth_cred_t cred)
 {
-
 	static const uint16_t N = 500;	/* Determines the trade-off */
 	

CVS commit: src/sys/netinet

2012-06-21 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Jun 21 10:31:45 UTC 2012

Modified Files:
src/sys/netinet: in_pcb.c

Log Message:
constify, comments.
no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/netinet/in_pcb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/in_pcb.c
diff -u src/sys/netinet/in_pcb.c:1.141 src/sys/netinet/in_pcb.c:1.142
--- src/sys/netinet/in_pcb.c:1.141	Thu Mar 22 20:34:38 2012
+++ src/sys/netinet/in_pcb.c	Thu Jun 21 10:31:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.141 2012/03/22 20:34:38 drochner Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.142 2012/06/21 10:31:45 yamt Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: in_pcb.c,v 1.141 2012/03/22 20:34:38 drochner Exp $);
+__KERNEL_RCSID(0, $NetBSD: in_pcb.c,v 1.142 2012/06/21 10:31:45 yamt Exp $);
 
 #include opt_inet.h
 #include opt_ipsec.h
@@ -806,8 +806,9 @@ in_pcblookup_port(struct inpcbtable *tab
 {
 	struct inpcbhead *head;
 	struct inpcb_hdr *inph;
-	struct inpcb *inp, *match = 0;
-	int matchwild = 3, wildcard;
+	struct inpcb *match = NULL;
+	int matchwild = 3;
+	int wildcard;
 	u_int16_t lport = lport_arg;
 
 	if (vp)
@@ -815,12 +816,23 @@ in_pcblookup_port(struct inpcbtable *tab
 
 	head = INPCBHASH_PORT(table, lport);
 	LIST_FOREACH(inph, head, inph_lhash) {
-		inp = (struct inpcb *)inph;
+		struct inpcb * const inp = (struct inpcb *)inph;
+
 		if (inp-inp_af != AF_INET)
 			continue;
-
 		if (inp-inp_lport != lport)
 			continue;
+		/*
+		 * check if inp's faddr and laddr match with ours.
+		 * our faddr is considered null.
+		 * count the number of wildcard matches. (0 - 2)
+		 *
+		 *	null	null	match
+		 *	A	null	wildcard match
+		 *	null	B	wildcard match
+		 *	A	B	non match
+		 *	A	A	match
+		 */
 		wildcard = 0;
 		if (!in_nullhost(inp-inp_faddr))
 			wildcard++;
@@ -837,6 +849,9 @@ in_pcblookup_port(struct inpcbtable *tab
 		}
 		if (wildcard  !lookup_wildcard)
 			continue;
+		/*
+		 * prefer an address with less wildcards.
+		 */
 		if (wildcard  matchwild) {
 			match = inp;
 			matchwild = wildcard;



CVS commit: src/sys/netinet

2012-06-21 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Jun 21 10:35:29 UTC 2012

Modified Files:
src/sys/netinet: rfc6056.c

Log Message:
for the default bsd algorithm, restore the pre rfc6056 changes behaviour.
fix anonportmin/max.

probably other algorithms need similar fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/netinet/rfc6056.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/rfc6056.c
diff -u src/sys/netinet/rfc6056.c:1.7 src/sys/netinet/rfc6056.c:1.8
--- src/sys/netinet/rfc6056.c:1.7	Thu Jun 21 10:30:47 2012
+++ src/sys/netinet/rfc6056.c	Thu Jun 21 10:35:28 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rfc6056.c,v 1.7 2012/06/21 10:30:47 yamt Exp $	*/
+/*	$NetBSD: rfc6056.c,v 1.8 2012/06/21 10:35:28 yamt Exp $	*/
 
 /*
  * Copyright 2011 Vlad Balan
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.7 2012/06/21 10:30:47 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.8 2012/06/21 10:35:28 yamt Exp $);
 
 #include opt_inet.h
 
@@ -359,47 +359,35 @@ check_suitable_port(uint16_t port, struc
 
 /* This is the default BSD algorithm, as described in RFC 6056 */
 static int
-algo_bsd(int algo, uint16_t *port, struct inpcb_hdr *inp_hdr,
-kauth_cred_t cred)
+algo_bsd(int algo, uint16_t *port, struct inpcb_hdr *inp_hdr, kauth_cred_t cred)
 {
-	uint16_t count, num_ephemeral;
+	uint16_t count;
 	uint16_t mymin, mymax, lastport;
 	uint16_t *next_ephemeral;
 	int error;
 
 	DPRINTF(%s called\n, __func__);
-
 	error = pcb_getports(inp_hdr, lastport, mymin, mymax,
 	next_ephemeral, algo);
 	if (error)
 		return error;
-
-	/* Ephemeral port selection function */
-	num_ephemeral = mymax - mymin + 1;
-
-	if (*next_ephemeral == 0)
-		*next_ephemeral = mymax;
-
-	count = num_ephemeral;
+	count = mymax - mymin + 1;
 	do {
 		uint16_t myport = *next_ephemeral;
-		if (*next_ephemeral = mymin)
-			*next_ephemeral = mymax;
-		else
-			(*next_ephemeral)--;
 
+		if (myport  mymin || mymax  myport)
+			myport = mymax;
+		*next_ephemeral = myport - 1;
 		if (check_suitable_port(myport, inp_hdr, cred)) {
 			*port = myport;
 			DPRINTF(%s returning port %d\n, __func__, *port);
 			return 0;
 		}
 		count--;
-
 	} while (count  0);
 
-	DPRINTF(%s returning EINVAL\n, __func__);
-
-	return EINVAL;
+	DPRINTF(%s returning EAGAIN\n, __func__);
+	return EAGAIN;
 }
 
 /*
@@ -816,19 +804,18 @@ rfc6056_randport(uint16_t *port, struct 
 
 	DPRINTF(%s rfc6056algo = %d\n, __func__, algo);
 
-
 	error = (*algos[algo].func)(algo, lport, inp_hdr, cred);
-	if (error == 0)
+	if (error == 0) {
 		*port = lport;
-	else {
+	} else if (error != EAGAIN) {
 		uint16_t lastport, mymin, mymax, *pnext_ephemeral;
+
 		error = pcb_getports(inp_hdr, lastport, mymin,
 		mymax, pnext_ephemeral, algo);
 		if (error)
 			return error;
 		*port = lastport - 1;
 	}
-
 	return error;
 }
 



CVS commit: src/sys/compat/linux/common

2012-06-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 21 17:55:16 UTC 2012

Modified Files:
src/sys/compat/linux/common: linux_socketcall.c

Log Message:
fix token pasting.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/compat/linux/common/linux_socketcall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socketcall.c
diff -u src/sys/compat/linux/common/linux_socketcall.c:1.40 src/sys/compat/linux/common/linux_socketcall.c:1.41
--- src/sys/compat/linux/common/linux_socketcall.c:1.40	Wed Jun 20 11:03:18 2012
+++ src/sys/compat/linux/common/linux_socketcall.c	Thu Jun 21 13:55:15 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $	*/
+/*	$NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -89,7 +89,7 @@ static const struct {
 	const char *name;
 	int argsize;
 } linux_socketcall[LINUX_MAX_SOCKETCALL+1] = {
-#define L(a) linux/ ## a
+#define L(a) linux/ a
 	{L(invalid),	-1},		/* 0 */
 	{L(socket),	sizeof(struct linux_sys_socket_args)},		/* 1 */
 	{L(bind),	sizeof(struct linux_sys_bind_args)},		/* 2 */



CVS commit: src/etc/etc.sandpoint

2012-06-21 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jun 21 19:22:08 UTC 2012

Modified Files:
src/etc/etc.sandpoint: MAKEDEV.conf

Log Message:
Add raid0 to init), in case we have /tmp on mfs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/etc/etc.sandpoint/MAKEDEV.conf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/etc.sandpoint/MAKEDEV.conf
diff -u src/etc/etc.sandpoint/MAKEDEV.conf:1.14 src/etc/etc.sandpoint/MAKEDEV.conf:1.15
--- src/etc/etc.sandpoint/MAKEDEV.conf:1.14	Tue Sep  6 14:40:11 2011
+++ src/etc/etc.sandpoint/MAKEDEV.conf	Thu Jun 21 19:22:07 2012
@@ -1,8 +1,8 @@
-# $NetBSD: MAKEDEV.conf,v 1.14 2011/09/06 14:40:11 apb Exp $
+# $NetBSD: MAKEDEV.conf,v 1.15 2012/06/21 19:22:07 jdc Exp $
 
 init)
 	makedev std tty00 tty01 opty ptm pty0
-	makedev md0 wd0 wd1
+	makedev md0 wd0 wd1 raid0
 	makedev pci0 bpf clockctl
 	;;
 



CVS commit: src/lib/libc/gen

2012-06-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 21 21:13:07 UTC 2012

Modified Files:
src/lib/libc/gen: getcwd.c realpath.3

Log Message:
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libc/gen/getcwd.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/realpath.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/getcwd.c
diff -u src/lib/libc/gen/getcwd.c:1.51 src/lib/libc/gen/getcwd.c:1.52
--- src/lib/libc/gen/getcwd.c:1.51	Tue Mar 13 17:13:35 2012
+++ src/lib/libc/gen/getcwd.c	Thu Jun 21 17:13:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getcwd.c,v 1.51 2012/03/13 21:13:35 christos Exp $	*/
+/*	$NetBSD: getcwd.c,v 1.52 2012/06/21 21:13:07 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)getcwd.c	8.5 (Berkeley) 2/7/95;
 #else
-__RCSID($NetBSD: getcwd.c,v 1.51 2012/03/13 21:13:35 christos Exp $);
+__RCSID($NetBSD: getcwd.c,v 1.52 2012/06/21 21:13:07 christos Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -61,30 +61,36 @@ __weak_alias(realpath,_realpath)
 #endif
 
 /*
- * char *realpath(const char *path, char resolved[MAXPATHLEN]);
+ * char *realpath(const char *path, char *resolved);
  *
  * Find the real name of path, by removing all ., .. and symlink
  * components.  Returns (resolved) on success, or (NULL) on failure,
  * in which case the path which caused trouble is left in (resolved).
  */
 char *
-realpath(const char *path, char *resolved)
+realpath(const char * __restrict path, char * __restrict resolved)
 {
 	struct stat sb;
 	int idx = 0, nlnk = 0;
 	const char *q;
-	char *p, wbuf[2][MAXPATHLEN];
+	char *p, wbuf[2][MAXPATHLEN], *fres;
 	size_t len;
 	ssize_t n;
 
-	_DIAGASSERT(resolved != NULL);
-
 	/* POSIX sez we must test for this */
 	if (path == NULL) {
 		errno = EINVAL;
 		return NULL;
 	}
 
+	if (resolved == NULL) {
+		fres = resolved = malloc(MAXPATHLEN);
+		if (resolved == NULL)
+			return NULL;
+	} else
+		fres = NULL;
+
+
 	/*
 	 * Build real path one by one with paying an attention to .,
 	 * .. and symbolic link.
@@ -96,10 +102,10 @@ realpath(const char *path, char *resolve
 	 */
 	p = resolved;
 
-	if (*path == 0) {
-		*p = 0;
+	if (*path == '\0') {
+		*p = '\0';
 		errno = ENOENT;
-		return (NULL);
+		goto out;
 	}
 
 	/* If relative path, start from current working directory. */
@@ -107,8 +113,8 @@ realpath(const char *path, char *resolve
 		/* check for resolved pointer to appease coverity */
 		if (resolved  getcwd(resolved, MAXPATHLEN) == NULL) {
 			p[0] = '.';
-			p[1] = 0;
-			return (NULL);
+			p[1] = '\0';
+			goto out;
 		}
 		len = strlen(resolved);
 		if (len  1)
@@ -120,18 +126,18 @@ loop:
 	while (*path == '/')
 		path++;
 
-	if (*path == 0) {
+	if (*path == '\0') {
 		if (p == resolved)
 			*p++ = '/';
-		*p = 0;
-		return (resolved);
+		*p = '\0';
+		return resolved;
 	}
 
 	/* Find the end of this component. */
 	q = path;
 	do
 		q++;
-	while (*q != '/'  *q != 0);
+	while (*q != '/'  *q != '\0');
 
 	/* Test . or .. */
 	if (path[0] == '.') {
@@ -143,7 +149,7 @@ loop:
 			/* Trim the last component. */
 			if (p != resolved)
 while (*--p != '/')
-	;
+	continue;
 			path = q;
 			goto loop;
 		}
@@ -154,39 +160,39 @@ loop:
 		errno = ENAMETOOLONG;
 		if (p == resolved)
 			*p++ = '/';
-		*p = 0;
-		return (NULL);
+		*p = '\0';
+		goto out;
 	}
 	p[0] = '/';
 	memcpy(p[1], path,
 	/* LINTED We know q  path. */
 	q - path);
-	p[1 + q - path] = 0;
+	p[1 + q - path] = '\0';
 
 	/*
 	 * If this component is a symlink, toss it and prepend link
 	 * target to unresolved path.
 	 */
-	if (lstat(resolved, sb) == -1) {
-		return (NULL);
-	}
+	if (lstat(resolved, sb) == -1)
+		goto out;
+
 	if (S_ISLNK(sb.st_mode)) {
 		if (nlnk++ = MAXSYMLINKS) {
 			errno = ELOOP;
-			return (NULL);
+			goto out;
 		}
 		n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
 		if (n  0)
 			return (NULL);
 		if (n == 0) {
 			errno = ENOENT;
-			return (NULL);
+			goto out;
 		}
 
 		/* Append unresolved path to link target and switch to it. */
 		if (n + (len = strlen(q)) + 1  sizeof(wbuf[0])) {
 			errno = ENAMETOOLONG;
-			return (NULL);
+			goto out;
 		}
 		memcpy(wbuf[idx][n], q, len + 1);
 		path = wbuf[idx];
@@ -199,13 +205,16 @@ loop:
 	}
 	if (*q == '/'  !S_ISDIR(sb.st_mode)) {
 		errno = ENOTDIR;
-		return (NULL);
+		goto out;
 	}
 
 	/* Advance both resolved and unresolved path. */
 	p += 1 + q - path;
 	path = q;
 	goto loop;
+out:
+	free(fres);
+	return NULL;
 }
 
 char *

Index: src/lib/libc/gen/realpath.3
diff -u src/lib/libc/gen/realpath.3:1.12 src/lib/libc/gen/realpath.3:1.13
--- src/lib/libc/gen/realpath.3:1.12	Sat Aug 13 15:53:53 2005
+++ src/lib/libc/gen/realpath.3	Thu Jun 21 

CVS commit: src/include

2012-06-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 21 21:13:29 UTC 2012

Modified Files:
src/include: stdlib.h

Log Message:
sprinkle restrict in realpath(3)


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/include/stdlib.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/stdlib.h
diff -u src/include/stdlib.h:1.99 src/include/stdlib.h:1.100
--- src/include/stdlib.h:1.99	Sun Jun  3 17:42:46 2012
+++ src/include/stdlib.h	Thu Jun 21 17:13:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: stdlib.h,v 1.99 2012/06/03 21:42:46 joerg Exp $	*/
+/*	$NetBSD: stdlib.h,v 1.100 2012/06/21 21:13:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -192,7 +192,7 @@ char	*mktemp(char *)
 
 int	 setkey(const char *);
 
-char	*realpath(const char *, char *);
+char	*realpath(const char * __restrict, char * __restrict);
 
 int	 ttyslot(void);
 



CVS commit: src/lib/libc/gen

2012-06-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jun 21 21:35:25 UTC 2012

Modified Files:
src/lib/libc/gen: realpath.3

Log Message:
Drop trailing whitespace and avoid xr to itself.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/realpath.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/realpath.3
diff -u src/lib/libc/gen/realpath.3:1.13 src/lib/libc/gen/realpath.3:1.14
--- src/lib/libc/gen/realpath.3:1.13	Thu Jun 21 21:13:07 2012
+++ src/lib/libc/gen/realpath.3	Thu Jun 21 21:35:25 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: realpath.3,v 1.13 2012/06/21 21:13:07 christos Exp $
+.\	$NetBSD: realpath.3,v 1.14 2012/06/21 21:35:25 wiz Exp $
 .\
 .\ Copyright (c) 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -91,7 +91,7 @@ returns
 and
 .Fa resolvedname
 was not allocated by
-.Xr realpath ,
+.Nm ,
 it will contain the pathname which caused the problem.
 .Sh ERRORS
 The function
@@ -113,7 +113,7 @@ and
 .Sh STANDARDS
 .Fn realpath
 first appeared in
-.St -xpg4.2 
+.St -xpg4.2
 and is part of
 .St -p1003.1-2001 .
 .Sh HISTORY



CVS commit: src/lib/libc/gen

2012-06-21 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Thu Jun 21 23:29:23 UTC 2012

Modified Files:
src/lib/libc/gen: getcwd.c

Log Message:
All error path must go through the free function call after an
allocation of resolved path might succeeded.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libc/gen/getcwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/getcwd.c
diff -u src/lib/libc/gen/getcwd.c:1.52 src/lib/libc/gen/getcwd.c:1.53
--- src/lib/libc/gen/getcwd.c:1.52	Thu Jun 21 21:13:07 2012
+++ src/lib/libc/gen/getcwd.c	Thu Jun 21 23:29:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getcwd.c,v 1.52 2012/06/21 21:13:07 christos Exp $	*/
+/*	$NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)getcwd.c	8.5 (Berkeley) 2/7/95;
 #else
-__RCSID($NetBSD: getcwd.c,v 1.52 2012/06/21 21:13:07 christos Exp $);
+__RCSID($NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -183,7 +183,7 @@ loop:
 		}
 		n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
 		if (n  0)
-			return (NULL);
+			goto out;
 		if (n == 0) {
 			errno = ENOENT;
 			goto out;



CVS commit: src/sys/dev/usb

2012-06-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jun 22 00:12:24 UTC 2012

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
fix locking for isoc transfers, as reported (and the fix tested) by prlw1.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.191 src/sys/dev/usb/ehci.c:1.192
--- src/sys/dev/usb/ehci.c:1.191	Tue Jun 19 07:15:41 2012
+++ src/sys/dev/usb/ehci.c	Fri Jun 22 00:12:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.191 2012/06/19 07:15:41 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.192 2012/06/22 00:12:23 mrg Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.191 2012/06/19 07:15:41 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.192 2012/06/22 00:12:23 mrg Exp $);
 
 #include ohci.h
 #include uhci.h
@@ -2892,7 +2892,7 @@ ehci_alloc_itd(ehci_softc_t *sc)
 	int i, offs, frindex, previndex;
 	usb_dma_t dma;
 
-	KASSERT(mutex_owned(sc-sc_lock));
+	mutex_enter(sc-sc_lock);
 
 	/* Find an itd that wasn't freed this frame or last frame. This can
 	 * discard itds that were freed before frindex wrapped around
@@ -2918,6 +2918,7 @@ ehci_alloc_itd(ehci_softc_t *sc)
 
 		if (err) {
 			DPRINTF((ehci_alloc_itd, alloc returned %d\n, err));
+			mutex_exit(sc-sc_lock);
 			return NULL;
 		}
 
@@ -2944,6 +2945,8 @@ ehci_alloc_itd(ehci_softc_t *sc)
 	itd-xfer_next = NULL;
 	itd-slot = 0;
 
+	mutex_exit(sc-sc_lock);
+
 	return itd;
 }