oops, forgot to commit this. the sockaddr_un init code was missing

initialisers for sun_len and not accounting for it in the sizeof
calculation.  Ie: it was potentially sending an unterminated string into
the kernel.
This commit is contained in:
Peter Wemm 1996-11-15 15:56:45 +00:00
parent d21fb5dc4c
commit a2c9113628
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19779

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: yppasswd_comm.c,v 1.1.1.1 1996/02/12 15:09:01 wpaul Exp $
* $Id: yppasswd_comm.c,v 1.2 1996/11/15 14:12:21 peter Exp $
*/
/*
@ -73,7 +73,7 @@
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: yppasswd_comm.c,v 1.1.1.1 1996/02/12 15:09:01 wpaul Exp $";
static const char rcsid[] = "$Id: yppasswd_comm.c,v 1.2 1996/11/15 14:12:21 peter Exp $";
#endif
char *sockname = "/var/run/ypsock";
@ -147,7 +147,8 @@ int makeservsock()
bzero((char *)&us, sizeof(us));
us.sun_family = AF_UNIX;
strcpy((char *)&us.sun_path, sockname);
len = strlen(us.sun_path) + sizeof(us.sun_family) + 1;
us.sun_len = len = sizeof(us.sun_len) + sizeof(us.sun_family) +
strlen(us.sun_path) + 1;
if (bind(ypsock, (struct sockaddr *)&us, len) == -1)
err(1,"failed to bind UNIX domain socket");
@ -175,7 +176,8 @@ static int makeclntsock()
bzero((char *)&us, sizeof(us));
us.sun_family = AF_UNIX;
strcpy((char *)&us.sun_path, sockname);
len = strlen(us.sun_path) + sizeof(us.sun_family) + 1;
us.sun_len = len = sizeof(us.sun_len) + sizeof(us.sun_family) +
strlen(us.sun_path) + 1;
if (connect(ypsock, (struct sockaddr *)&us, len) == -1) {
warn("failed to connect to server");