Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/nameser fix the part of the code that does not get ...



details:   https://anonhg.NetBSD.org/src/rev/f29b8cadb7a7
branches:  trunk
changeset: 782702:f29b8cadb7a7
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 15 16:43:30 2012 +0000

description:
fix the part of the code that does not get usually compiled in libc.

diffstat:

 lib/libc/nameser/ns_samedomain.c |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (80 lines):

diff -r 021d36ac030f -r f29b8cadb7a7 lib/libc/nameser/ns_samedomain.c
--- a/lib/libc/nameser/ns_samedomain.c  Thu Nov 15 16:42:26 2012 +0000
+++ b/lib/libc/nameser/ns_samedomain.c  Thu Nov 15 16:43:30 2012 +0000
@@ -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 @@
 
 #include "port_after.h"
 
-#ifndef _LIBC
+#ifdef _LIBRESOLV
 /*%
  *     Check whether a name belongs to a domain.
  *
@@ -57,8 +57,8 @@
 
 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 @@
        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 @@
        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 @@
 
        /* 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 @@
          * 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



Home | Main Index | Thread Index | Old Index