]> git.saurik.com Git - apple/mdnsresponder.git/blobdiff - mDNSPosix/mDNSUNP.c
mDNSResponder-176.2.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / mDNSUNP.c
index f9bd4a6e42304b21dfaf5eca7fae3847d1eab418..852883d7baea669b66b7c78b5984889b686a8f17 100755 (executable)
@@ -2,28 +2,35 @@
  *
  * Copyright (c) 2002-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: mDNSUNP.c,v $
+Revision 1.36  2008/04/21 18:21:22  mkrochma
+<rdar://problem/5877307> Need to free ifi_netmask
+Submitted by Igor Seleznev
+
+Revision 1.35  2007/11/15 21:36:19  cheshire
+<rdar://problem/5289340> POSIX: Off by one overflow in get_ifi_info_linuxv6()
+
+Revision 1.34  2006/08/14 23:24:47  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.33  2006/03/13 23:14:21  cheshire
+<rdar://problem/4427969> Compile problems on FreeBSD
+Use <netinet/in_var.h> instead of <netinet6/in6_var.h>
+
 Revision 1.32  2005/12/21 02:56:43  cheshire
 <rdar://problem/4243433> get_ifi_info() should fake ifi_index when SIOCGIFINDEX undefined
 
@@ -169,7 +176,9 @@ First checkin
 #endif
 
 #if defined(AF_INET6) && HAVE_IPV6 && !HAVE_LINUX
-#include <netinet6/in6_var.h>
+#include <net/if_var.h>
+#include <netinet/in_var.h>
+// NOTE: netinet/in_var.h implicitly includes netinet6/in6_var.h for us
 #endif
 
 #if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
@@ -186,8 +195,7 @@ void plen_to_mask(int plen, char *addr) {
                if(plen>bits_in_block) ones_in_block=bits_in_block;
                else                   ones_in_block=plen;
                block = ones & (ones << (bits_in_block-ones_in_block));
-               i==0 ? sprintf(addr, "%x", block) :
- sprintf(addr, "%s:%x", addr, block);
+               i==0 ? sprintf(addr, "%x", block) : sprintf(addr, "%s:%x", addr, block);
                plen -= ones_in_block;
                }
        }
@@ -199,7 +207,7 @@ struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
        FILE *fp;
        char addr[8][5];
        int flags, myflags, index, plen, scope;
-       char ifname[8], lastname[IFNAMSIZ];
+       char ifname[9], lastname[IFNAMSIZ];
        char addr6[32+7+1]; /* don't forget the seven ':' */
        struct addrinfo hints, *res0;
        struct sockaddr_in6 *sin6;
@@ -546,6 +554,8 @@ free_ifi_info(struct ifi_info *ifihead)
     for (ifi = ifihead; ifi != NULL; ifi = ifinext) {
         if (ifi->ifi_addr != NULL)
             free(ifi->ifi_addr);
+        if (ifi->ifi_netmask != NULL)
+            free(ifi->ifi_netmask);
         if (ifi->ifi_brdaddr != NULL)
             free(ifi->ifi_brdaddr);
         if (ifi->ifi_dstaddr != NULL)