patch-2.2.13 linux/net/ax25/af_ax25.c

Next file: linux/net/ax25/ax25_timer.c
Previous file: linux/net/802/tr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c
@@ -95,6 +95,7 @@
  *	AX.25 037	Jonathan(G4KLX)		New timer architecture.
  *      AX.25 038       Matthias(DG2FEF)        Small fixes to the syscall interface to make kernel
  *                                              independent of AX25_MAX_DIGIS used by applications.
+ *                      Tomi(OH2BNS)            Fixed ax25_getname().
  */
 
 #include <linux/config.h>
@@ -1278,37 +1279,34 @@
 static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
 {
 	struct sock *sk = sock->sk;
+	struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr;
 	unsigned char ndigi, i;
-	struct full_sockaddr_ax25 fsa;
 
 	if (peer != 0) {
 		if (sk->state != TCP_ESTABLISHED)
 			return -ENOTCONN;
 
-		fsa.fsa_ax25.sax25_family = AF_AX25;
-		fsa.fsa_ax25.sax25_call   = sk->protinfo.ax25->dest_addr;
-		fsa.fsa_ax25.sax25_ndigis = 0;
+		fsa->fsa_ax25.sax25_family = AF_AX25;
+		fsa->fsa_ax25.sax25_call   = sk->protinfo.ax25->dest_addr;
+		fsa->fsa_ax25.sax25_ndigis = 0;
 
 		if (sk->protinfo.ax25->digipeat != NULL) {
 			ndigi = sk->protinfo.ax25->digipeat->ndigi;
-			fsa.fsa_ax25.sax25_ndigis = ndigi;
+			fsa->fsa_ax25.sax25_ndigis = ndigi;
 			for (i = 0; i < ndigi; i++)
-				fsa.fsa_digipeater[i] = sk->protinfo.ax25->digipeat->calls[i];
+				fsa->fsa_digipeater[i] = sk->protinfo.ax25->digipeat->calls[i];
 		}
 	} else {
-		fsa.fsa_ax25.sax25_family = AF_AX25;
-		fsa.fsa_ax25.sax25_call   = sk->protinfo.ax25->source_addr;
-		fsa.fsa_ax25.sax25_ndigis = 1;
+		fsa->fsa_ax25.sax25_family = AF_AX25;
+		fsa->fsa_ax25.sax25_call   = sk->protinfo.ax25->source_addr;
+		fsa->fsa_ax25.sax25_ndigis = 1;
 		if (sk->protinfo.ax25->ax25_dev != NULL) {
-			memcpy(&fsa.fsa_digipeater[0], sk->protinfo.ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN);
+			memcpy(&fsa->fsa_digipeater[0], sk->protinfo.ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN);
 		} else {
-			fsa.fsa_digipeater[0] = null_ax25_address;
+			fsa->fsa_digipeater[0] = null_ax25_address;
 		}
 	}
-	if (*uaddr_len > sizeof (struct full_sockaddr_ax25))
-		*uaddr_len = sizeof (struct full_sockaddr_ax25);
-	memcpy(uaddr, &fsa, *uaddr_len);
-
+	*uaddr_len = sizeof (struct full_sockaddr_ax25);
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)