-/* $OpenBSD: netcat.c,v 1.138 2015/09/13 11:12:09 beck Exp $ */
+/* $OpenBSD: netcat.c,v 1.139 2015/10/11 00:26:23 guenther Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
* Copyright (c) 2015 Bob Beck. All rights reserved.
#include <tls.h>
#include "atomicio.h"
-#ifndef SUN_LEN
-#define SUN_LEN(su) \
- (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
-#endif
-
#define PORT_MAX 65535
#define PORT_MAX_LEN 6
#define UNIX_DG_TMP_SOCKET_SIZE 19
return (-1);
}
- if (bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
+ if (bind(s, (struct sockaddr *)&sun, sizeof(sun)) < 0) {
close(s);
return (-1);
}
errno = ENAMETOOLONG;
return (-1);
}
- if (connect(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
+ if (connect(s, (struct sockaddr *)&sun, sizeof(sun)) < 0) {
close(s);
return (-1);
}
-/* $OpenBSD: client.c,v 1.95 2015/09/24 12:06:20 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.96 2015/10/11 00:26:23 guenther Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
fatal("socket failed");
log_debug("trying connect");
- if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
+ if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
log_debug("connect failed: %s", strerror(errno));
if (errno != ECONNREFUSED && errno != ENOENT)
goto failed;
-/* $OpenBSD: server.c,v 1.139 2015/09/01 10:01:56 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.140 2015/10/11 00:26:23 guenther Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
return (-1);
mask = umask(S_IXUSR|S_IXGRP|S_IRWXO);
- if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1)
+ if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1)
return (-1);
umask(mask);