]> git.saurik.com Git - apple/mdnsresponder.git/blobdiff - mDNSShared/Java/TXTRecord.java
mDNSResponder-161.1.tar.gz
[apple/mdnsresponder.git] / mDNSShared / Java / TXTRecord.java
index 5eed93eb74b44179ab9313d6fa999bce13a7b3d9..16aff3cc9aa01b8de1291c009cd360713ab7f28a 100644 (file)
@@ -1,28 +1,31 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
 
     Change History (most recent first):
 
 $Log: TXTRecord.java,v $
+Revision 1.8  2007/03/16 23:39:40  vazquez
+<rdar://problem/4612778> Java: Coding error in java wrappers, limited TXTRecord length
+
+Revision 1.7  2006/12/13 07:13:23  mkrochma
+<rdar://problem/4612778> Java: Coding error in java wrappers, limited TXTRecord length
+
+Revision 1.6  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2004/08/25 21:54:36  rpantos
 <rdar://problem/3773973> Fix getValue() for values containing '='.
 
@@ -127,20 +130,20 @@ public class      TXTRecord
                byte[]  oldBytes = fBytes;
                int             valLen = (value != null) ? value.length : 0;
                int             insertion = 0;
-               byte    newLen, avLen;
+               int             newLen, avLen;
        
                // locate the insertion point
                for ( int i=0; i < index && insertion < fBytes.length; i++)
-                       insertion += fBytes[ insertion] + 1;
+                       insertion += (0xFF & (fBytes[ insertion] + 1));
        
-               avLen = (byte) ( keyBytes.length + valLen + (value != null ? 1 : 0));
-               newLen = (byte) ( avLen + oldBytes.length + 1);
+               avLen = keyBytes.length + valLen + (value != null ? 1 : 0);
+               newLen = avLen + oldBytes.length + 1;
 
                fBytes = new byte[ newLen];
                System.arraycopy( oldBytes, 0, fBytes, 0, insertion);
                int secondHalfLen = oldBytes.length - insertion;
                System.arraycopy( oldBytes, insertion, fBytes, newLen - secondHalfLen, secondHalfLen);
-               fBytes[ insertion] = avLen;
+               fBytes[ insertion] = ( byte) avLen;
                System.arraycopy( keyBytes, 0, fBytes, insertion + 1, keyBytes.length);
                if ( value != null)
                {
@@ -170,7 +173,7 @@ public class        TXTRecord
                                        return i;
                                }
                        }
-                       avStart += avLen + 1;
+                       avStart += (0xFF & (avLen + 1));
                }
                return -1;
        }
@@ -181,7 +184,7 @@ public class        TXTRecord
                int             i, avStart;
 
                for ( i=0, avStart=0; avStart < fBytes.length; i++)
-                       avStart += fBytes[ avStart] + 1;
+                       avStart += (0xFF & (fBytes[ avStart] + 1));
                return i;
        }