Project

General

Profile

Submit #3262 ยป 0001-talk-talk-into-account-sa_len-field-in-sockaddr.patch

dancrossnyc, 01/14/2021 07:21 PM

View differences:

usr.bin/talk/look_up.c
33 33
#include <sys/param.h>
34 34
#include <sys/socket.h>
35 35
#include <protocols/talkd.h>
36
#include <netinet/in.h>
36 37
#include <errno.h>
38
#include <string.h>
37 39
#include "talk_ctl.h"
38 40
#include "talk.h"
39 41

  
......
63 65
	 */
64 66
	current_state = "Waiting to connect with caller";
65 67
	do {
68
		struct sockaddr_in addr;
69
		struct sockaddr_in *raddr;
70

  
66 71
		if (rp->addr.sa_family != AF_INET)
67 72
			p_error("Response uses invalid network address");
73
		raddr = (struct sockaddr_in *)&rp->addr;
74
		memset(&addr, 0, sizeof(addr));
75
		addr.sin_family = AF_INET;
76
		addr.sin_port = raddr->sin_port;
77
		addr.sin_addr = raddr->sin_addr;
68 78
		errno = 0;
69 79
		if (connect(sockt,
70
		    (struct sockaddr *)&rp->addr, sizeof (rp->addr)) != -1)
80
		    (struct sockaddr *)&addr, sizeof(addr)) != -1)
71 81
			return (1);
72 82
	} while (errno == EINTR);
73 83
	if (errno == ECONNREFUSED) {
    (1-1/1)