Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/net Minor KNF + proper end of string detection in r...



details:   https://anonhg.NetBSD.org/src/rev/325f29cda922
branches:  trunk
changeset: 525743:325f29cda922
user:      groo <groo%NetBSD.org@localhost>
date:      Tue Apr 16 19:12:40 2002 +0000

description:
Minor KNF + proper end of string detection in read_config_file()
Inspired by xs%kittenz.org@localhost

diffstat:

 lib/libc/net/hesiod.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 4cb1b4b234db -r 325f29cda922 lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c     Tue Apr 16 19:08:43 2002 +0000
+++ b/lib/libc/net/hesiod.c     Tue Apr 16 19:12:40 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hesiod.c,v 1.16 2001/02/13 15:41:18 sommerfeld Exp $   */
+/*     $NetBSD: hesiod.c,v 1.17 2002/04/16 19:12:40 groo Exp $ */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -52,7 +52,7 @@
     "#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
 __IDSTRING(rcsid_hescompat_c,
     "#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
-__RCSID("$NetBSD: hesiod.c,v 1.16 2001/02/13 15:41:18 sommerfeld Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.17 2002/04/16 19:12:40 groo Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -254,7 +254,7 @@
 
                /* Make a copy of the result and return it to the caller. */
        ret = strdup(bindname);
-       if (!ret)
+       if (ret == NULL)
                errno = ENOMEM;
        return ret;
 }
@@ -351,15 +351,24 @@
                while (*p == ' ' || *p == '\t')
                        p++;
                key = p;
-               while (*p != ' ' && *p != '\t' && *p != '=')
+               while (*p != ' ' && *p != '\t' && *p != '=' && *p)
                        p++;
+
+               if (*p == '\0')
+                       continue;
+
                *p++ = 0;
 
                while (isspace((u_char) *p) || *p == '=')
                        p++;
+
+               if (*p == '\0')
+                       continue;
+
                data = p;
-               while (!isspace((u_char) *p))
+               while (!isspace((u_char) *p) && *p)
                        p++;
+
                *p = 0;
 
                if (strcasecmp(key, "lhs") == 0 ||



Home | Main Index | Thread Index | Old Index