summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgroo <groo@NetBSD.org>2002-04-16 19:12:40 +0000
committergroo <groo@NetBSD.org>2002-04-16 19:12:40 +0000
commit6bf409aa5b9733e7cbe7da7e48f80da81e8cf484 (patch)
tree7dc3bf5377ad4678c9757e8f0002eaf9004e71a7
parent50d2b6a96fa35c629befded52c8008c830ad021a (diff)
Minor KNF + proper end of string detection in read_config_file()
Inspired by xs@kittenz.org
-rw-r--r--lib/libc/net/hesiod.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
index 0422054fb3f..d3192e81bfa 100644
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -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 @@ __IDSTRING(rcsid_hesiod_p_h,
"#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 @@ hesiod_to_bind(void *context, const char *name, const char *type)
/* 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 @@ read_config_file(ctx, filename)
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 ||