NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49247: getsockname(2) requires sockaddr structure to cleared



The following reply was made to PR kern/49247; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%britannica.bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/49247: getsockname(2) requires sockaddr structure to cleared
Date: Tue, 30 Sep 2014 11:18:03 +0200

 --9amGYk9869ThD9tj
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Please try the attached patch.
 
 Joerg
 
 --9amGYk9869ThD9tj
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="uipc_usrreq.c.diff"
 
 Index: uipc_usrreq.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/src/sys/kern/uipc_usrreq.c,v
 retrieving revision 1.171
 diff -u -p -r1.171 uipc_usrreq.c
 --- uipc_usrreq.c	5 Sep 2014 09:20:59 -0000	1.171
 +++ uipc_usrreq.c	30 Sep 2014 09:14:31 -0000
 @@ -354,7 +354,7 @@ unp_setaddr(struct socket *so, struct mb
  		}
  		if (sun == NULL)
  			sun = &sun_noname;
 -		nam->m_len = sun->sun_len;
 +		nam->m_len = sun->sun_len + 1;
  		if (nam->m_len > MLEN && !ext) {
  			sounlock(so);
  			MEXTMALLOC(nam, MAXPATHLEN * 2, M_WAITOK);
 @@ -362,7 +362,8 @@ unp_setaddr(struct socket *so, struct mb
  			ext = true;
  		} else {
  			KASSERT(nam->m_len <= MAXPATHLEN * 2);
 -			memcpy(mtod(nam, void *), sun, (size_t)nam->m_len);
 +			memcpy(mtod(nam, void *), sun, (size_t)nam->m_len - 1);
 +			mtod(nam, char *)[nam->m_len] = 0;
  			break;
  		}
  	}
 
 --9amGYk9869ThD9tj--
 


Home | Main Index | Thread Index | Old Index