Module Name: src
Committed By: christos
Date: Thu Nov 15 16:43:30 UTC 2012
Modified Files:
src/lib/libc/nameser: ns_samedomain.c
Log Message:
fix the part of the code that does not get usually compiled in libc.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/nameser/ns_samedomain.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/nameser/ns_samedomain.c
diff -u src/lib/libc/nameser/ns_samedomain.c:1.6 src/lib/libc/nameser/ns_samedomain.c:1.7
--- src/lib/libc/nameser/ns_samedomain.c:1.6 Sun Apr 12 13:07:17 2009
+++ src/lib/libc/nameser/ns_samedomain.c Thu Nov 15 11:43:30 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ns_samedomain.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: ns_samedomain.c,v 1.7 2012/11/15 16:43:30 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -22,7 +22,7 @@
#ifdef notdef
static const char rcsid[] = "Id: ns_samedomain.c,v 1.6 2005/04/27 04:56:40 sra Exp";
#else
-__RCSID("$NetBSD: ns_samedomain.c,v 1.6 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: ns_samedomain.c,v 1.7 2012/11/15 16:43:30 christos Exp $");
#endif
#endif
@@ -35,7 +35,7 @@ __RCSID("$NetBSD: ns_samedomain.c,v 1.6
#include "port_after.h"
-#ifndef _LIBC
+#ifdef _LIBRESOLV
/*%
* Check whether a name belongs to a domain.
*
@@ -57,8 +57,8 @@ __RCSID("$NetBSD: ns_samedomain.c,v 1.6
int
ns_samedomain(const char *a, const char *b) {
- size_t la, lb;
- int diff, i, escaped;
+ size_t la, lb, i;
+ int diff, escaped;
const char *cp;
la = strlen(a);
@@ -68,8 +68,8 @@ ns_samedomain(const char *a, const char
if (la != 0U && a[la - 1] == '.') {
escaped = 0;
/* Note this loop doesn't get executed if la==1. */
- for (i = la - 2; i >= 0; i--)
- if (a[i] == '\\') {
+ for (i = la - 1; i > 0; i--)
+ if (a[i - 1] == '\\') {
if (escaped)
escaped = 0;
else
@@ -84,8 +84,8 @@ ns_samedomain(const char *a, const char
if (lb != 0U && b[lb - 1] == '.') {
escaped = 0;
/* note this loop doesn't get executed if lb==1 */
- for (i = lb - 2; i >= 0; i--)
- if (b[i] == '\\') {
+ for (i = lb - 1; i > 0; i--)
+ if (b[i - 1] == '\\') {
if (escaped)
escaped = 0;
else
@@ -110,7 +110,7 @@ ns_samedomain(const char *a, const char
/* Ok, we know la > lb. */
- diff = la - lb;
+ diff = (int)(la - lb);
/*
* If 'a' is only 1 character longer than 'b', then it can't be
@@ -133,8 +133,8 @@ ns_samedomain(const char *a, const char
* and thus not a really a label separator.
*/
escaped = 0;
- for (i = diff - 2; i >= 0; i--)
- if (a[i] == '\\') {
+ for (i = diff - 1; i > 0; i--)
+ if (a[i - 1] == '\\') {
if (escaped)
escaped = 0;
else