(1) change to krb5_error_code
authorJohn Kohl <jtkohl@mit.edu>
Tue, 30 Jan 1990 18:21:08 +0000 (18:21 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Tue, 30 Jan 1990 18:21:08 +0000 (18:21 +0000)
(2) changes for new allocation strategy

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@218 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/localaddr.c

index 1b1acbf45addc204226c96534eaeff729fa5b133..2c8fad17768d6acc2a78b6918b2d68df2f93a005 100644 (file)
@@ -76,7 +76,7 @@ extern int errno;
  * This uses the SIOCGIFCONF, SIOCGIFFLAGS, and SIOCGIFADDR ioctl's.
  */
 
-int krb5_os_localaddr(addr)
+krb5_error_code krb5_os_localaddr(addr)
     krb5_address ***addr;
 {
     struct ifreq *ifr;
@@ -130,13 +130,21 @@ int krb5_os_localaddr(addr)
                    (struct sockaddr_in *)&ifr->ifr_addr;
                
                address = (krb5_address *)
-                   malloc (sizeof(krb5_address) + sizeof(struct in_addr));
+                   malloc (sizeof(krb5_address));
                if (address) {
                    address->addrtype = ADDRTYPE_INET;
                    address->length = sizeof(struct in_addr);
-                   memcpy ((char *)address->contents, (char *)&in->sin_addr, 
-                           address->length);
-                   break;
+                   address->contents = (unsigned char *)malloc(address->length);
+                   if (!address->contents) {
+                       free((char *)address);
+                       address = 0;
+                       mem_err++;
+                   } else {
+                       memcpy ((char *)address->contents,
+                               (char *)&in->sin_addr, 
+                               address->length);
+                       break;
+                   }
                } else mem_err++;
            }
 #endif