Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/inetd PR/47318: Henning Petersen: Replace (r)index ...



details:   https://anonhg.NetBSD.org/src/rev/d31a5e9bbe2c
branches:  trunk
changeset: 783292:d31a5e9bbe2c
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 13 19:38:40 2012 +0000

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

diffstat:

 usr.sbin/inetd/inetd.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (64 lines):

diff -r 290089852472 -r d31a5e9bbe2c usr.sbin/inetd/inetd.c
--- a/usr.sbin/inetd/inetd.c    Thu Dec 13 19:33:23 2012 +0000
+++ b/usr.sbin/inetd/inetd.c    Thu Dec 13 19:38:40 2012 +0000
@@ -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 @@
 #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 @@
                        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 @@
                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));
                                        }



Home | Main Index | Thread Index | Old Index