Subject: [netatalk-admins] a few memory/file leaks plugged

From: a sun <[email-masked]>
Date: Tue, 26 Aug 1997 10:05:34 -0700 (PDT)

here's a patch against 1.4b2 that fixes a couple potential memory
leaks. it'll be in my a15 patchset as well. as an aside, i noticed
this when i ran afpd without atalkd and saw that it still had an open
ddp socket. 

--- netatalk-1.4b2/libatalk/atp/atp_close.c.save	Tue Aug 26 09:59:26 1997
+++ netatalk-1.4b2/libatalk/atp/atp_close.c	Tue Aug 26 10:01:22 1997
@@ -42,9 +42,7 @@
     print_bufuse( ah, "atp_close");
 #endif EBUG
 
-    if ( close( ah->atph_socket ) < 0 ) {
-	return -1;
-    }
+    close( ah->atph_socket );
 
     while ( ah->atph_queue != NULL ) {
 	cq = ah->atph_queue;
--- netatalk-1.4b2/libatalk/atp/atp_open.c.save	Tue Aug 26 09:59:31 1997
+++ netatalk-1.4b2/libatalk/atp/atp_open.c	Tue Aug 26 10:01:02 1997
@@ -46,6 +46,7 @@
     }
 
     if (( atp = (ATP) alloc_buf()) == NULL ) {
+	close(s);
 	return 0;
     }
 
@@ -62,11 +63,15 @@
     if ( bind( s, (struct sockaddr *) &atp->atph_saddr,
 	    sizeof( struct sockaddr_at )) != 0 ) {
 	free_buf( (struct atp_buf *)atp );
+	close(s);
 	return NULL;
     }
     /* get the real address from the kernel */
     nlen = sizeof( struct sockaddr_at);
     if ( getsockname( s, (struct sockaddr *) &atp->atph_saddr, &nlen ) != 0 ) {
+	free_buf( (struct atp_buf *)atp );
+	close(s);
+
 	return NULL;
     }
     atp->atph_socket = s;
--- netatalk-1.4b2/libatalk/asp/asp_close.c.save	Tue Aug 26 09:58:41 1997
+++ netatalk-1.4b2/libatalk/asp/asp_close.c	Tue Aug 26 09:59:18 1997
@@ -42,12 +42,8 @@
     atpb.atp_sresiov = iov;
     atpb.atp_sresiovcnt = 1;
 
-    if ( atp_sresp( asp->asp_atp, &atpb ) < 0 ) {
-	return( -1 );
-    }
-    if ( atp_close( asp->asp_atp ) < 0 ) {
-	return( -1 );
-    }
+    atp_sresp( asp->asp_atp, &atpb );
+    atp_close( asp->asp_atp );
     free( asp );
     return( 0 );
 }