Module Name:    src
Committed By:   christos
Date:           Thu Dec 13 19:38:41 UTC 2012

Modified Files:
        src/usr.sbin/inetd: inetd.c

Log Message:
PR/47318: Henning Petersen: Replace (r)index with str(r)chr in inetd.c
And while here strncpy with strlcpy


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/usr.sbin/inetd/inetd.c

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

Modified files:

Index: src/usr.sbin/inetd/inetd.c
diff -u src/usr.sbin/inetd/inetd.c:1.120 src/usr.sbin/inetd/inetd.c:1.121
--- src/usr.sbin/inetd/inetd.c:1.120	Wed Jan  4 11:09:43 2012
+++ src/usr.sbin/inetd/inetd.c	Thu Dec 13 14:38:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: inetd.c,v 1.120 2012/01/04 16:09:43 drochner Exp $	*/
+/*	$NetBSD: inetd.c,v 1.121 2012/12/13 19:38:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)inetd.c	8.4 (Berkeley) 4/13/94";
 #else
-__RCSID("$NetBSD: inetd.c,v 1.120 2012/01/04 16:09:43 drochner Exp $");
+__RCSID("$NetBSD: inetd.c,v 1.121 2012/12/13 19:38:40 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -842,14 +842,14 @@ config(void)
 			if (sep->se_fd != -1)
 				break;
 			n = strlen(sep->se_service);
-			if (n > sizeof(sep->se_ctrladdr_un.sun_path)) {
+			if (n >= sizeof(sep->se_ctrladdr_un.sun_path)) {
 				syslog(LOG_ERR, "%s: address too long",
 				    sep->se_service);
 				sep->se_checked = 0;
 				continue;
 			}
 			(void)unlink(sep->se_service);
-			strncpy(sep->se_ctrladdr_un.sun_path,
+			strlcpy(sep->se_ctrladdr_un.sun_path,
 			    sep->se_service, n);
 			sep->se_ctrladdr_un.sun_family = AF_LOCAL;
 			sep->se_ctrladdr_size = (int)(n +
@@ -1367,22 +1367,22 @@ more:
 		sep->se_socktype = SOCK_STREAM;
 
 		/* one and only one accept filter */
-		accf = index(arg, ':');	
+		accf = strchr(arg, ':');	
 		if (accf) {
-	    		if (accf != rindex(arg, ':') ||	/* more than one */
+	    		if (accf != strrchr(arg, ':') ||/* more than one */
 	    		    *(accf + 1) == '\0') {	/* nothing beyond */
 				sep->se_socktype = -1;
 			} else {
 				accf++;			/* skip delimiter */
-				strncpy(sep->se_accf.af_name, accf,
+				strlcpy(sep->se_accf.af_name, accf,
 					sizeof(sep->se_accf.af_name));
-				accf_arg = index(accf, ',');
+				accf_arg = strchr(accf, ',');
 				if (accf_arg) {	/* zero or one arg, no more */
-					if ((rindex(accf, ',') != accf_arg)) {
+					if (strrchr(accf, ',') != accf_arg) {
 						sep->se_socktype = -1;
 					} else {
 						accf_arg++;
-						strncpy(sep->se_accf.af_arg,
+						strlcpy(sep->se_accf.af_arg,
 							accf_arg,
 							sizeof(sep->se_accf.af_arg));
 					}

Reply via email to