- fix arp unaligned access (#220438)

This commit is contained in:
Radek Vokál 2006-12-27 08:34:03 +00:00
parent 97c2c7cf9e
commit de3645c36c
2 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,116 @@
--- net-tools-1.60/arp.c 2001-04-08 10:05:05.000000000 -0700
+++ net-tools-1.60.new/arp.c 2006-01-31 13:10:01.479716750 -0800
@@ -100,7 +100,7 @@ static int arp_del(char **args)
{
char host[128];
struct arpreq req;
- struct sockaddr sa;
+ struct sockaddr_storage ss;
int flags = 0;
int err;
@@ -112,12 +112,12 @@ static int arp_del(char **args)
return (-1);
}
safe_strncpy(host, *args, (sizeof host));
- if (ap->input(0, host, &sa) < 0) {
+ if (ap->input(0, host, (struct sockaddr*)&ss) < 0) {
ap->herror(host);
return (-1);
}
/* If a host has more than one address, use the correct one! */
- memcpy((char *) &req.arp_pa, (char *) &sa, sizeof(struct sockaddr));
+ memcpy((char *) &req.arp_pa, (char *) &ss, sizeof(struct sockaddr));
if (hw_set)
req.arp_ha.sa_family = hw->type;
@@ -177,11 +177,11 @@ static int arp_del(char **args)
usage();
if (strcmp(*args, "255.255.255.255") != 0) {
strcpy(host, *args);
- if (ap->input(0, host, &sa) < 0) {
+ if (ap->input(0, host, (struct sockaddr*)&ss) < 0) {
ap->herror(host);
return (-1);
}
- memcpy((char *) &req.arp_netmask, (char *) &sa,
+ memcpy((char *) &req.arp_netmask, (char *) &ss,
sizeof(struct sockaddr));
req.arp_flags |= ATF_NETMASK;
}
@@ -260,7 +260,7 @@ static int arp_set(char **args)
{
char host[128];
struct arpreq req;
- struct sockaddr sa;
+ struct sockaddr_storage ss;
int flags;
memset((char *) &req, 0, sizeof(req));
@@ -271,12 +271,12 @@ static int arp_set(char **args)
return (-1);
}
safe_strncpy(host, *args++, (sizeof host));
- if (ap->input(0, host, &sa) < 0) {
+ if (ap->input(0, host, (struct sockaddr*)&ss) < 0) {
ap->herror(host);
return (-1);
}
/* If a host has more than one address, use the correct one! */
- memcpy((char *) &req.arp_pa, (char *) &sa, sizeof(struct sockaddr));
+ memcpy((char *) &req.arp_pa, (char *) &ss, sizeof(struct sockaddr));
/* Fetch the hardware address. */
if (*args == NULL) {
@@ -346,11 +346,11 @@ static int arp_set(char **args)
usage();
if (strcmp(*args, "255.255.255.255") != 0) {
strcpy(host, *args);
- if (ap->input(0, host, &sa) < 0) {
+ if (ap->input(0, host, (struct sockaddr*)&ss) < 0) {
ap->herror(host);
return (-1);
}
- memcpy((char *) &req.arp_netmask, (char *) &sa,
+ memcpy((char *) &req.arp_netmask, (char *) &ss,
sizeof(struct sockaddr));
flags |= ATF_NETMASK;
}
@@ -519,7 +519,7 @@ static void arp_disp(char *name, char *i
static int arp_show(char *name)
{
char host[100];
- struct sockaddr sa;
+ struct sockaddr_storage ss;
char ip[100];
char hwa[100];
char mask[100];
@@ -535,11 +535,11 @@ static int arp_show(char *name)
if (name != NULL) {
/* Resolve the host name. */
safe_strncpy(host, name, (sizeof host));
- if (ap->input(0, host, &sa) < 0) {
+ if (ap->input(0, host, (struct sockaddr*)&ss) < 0) {
ap->herror(host);
return (-1);
}
- safe_strncpy(host, ap->sprint(&sa, 1), sizeof(host));
+ safe_strncpy(host, ap->sprint((struct sockaddr*)&ss, 1), sizeof(host));
}
/* Open the PROCps kernel table. */
if ((fp = fopen(_PATH_PROCNET_ARP, "r")) == NULL) {
@@ -575,10 +575,11 @@ static int arp_show(char *name)
if (opt_n)
hostname = "?";
else {
- if (ap->input(0, ip, &sa) < 0)
+ if (ap->input(0, ip, (struct sockaddr*)&ss) < 0)
hostname = ip;
else
- hostname = ap->sprint(&sa, opt_n | 0x8000);
+ hostname = ap->sprint((struct sockaddr*)&ss,
+ opt_n | 0x8000);
if (strcmp(hostname, ip) == 0)
hostname = "?";
}

View File

@ -70,6 +70,7 @@ Patch55: net-tools-1.60-netdevice.patch
Patch56: net-tools-1.60-skip.patch Patch56: net-tools-1.60-skip.patch
Patch57: net-tools-1.60-netstat-I-fix.patch Patch57: net-tools-1.60-netstat-I-fix.patch
Patch58: net-tools-1.60-nameif_strncpy.patch Patch58: net-tools-1.60-nameif_strncpy.patch
Patch59: net-tools-1.60-arp-unaligned-access.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires(post,preun): chkconfig Requires(post,preun): chkconfig
@ -137,6 +138,7 @@ ifconfig, netstat, route, and others.
%patch56 -p1 -b .skip %patch56 -p1 -b .skip
%patch57 -p1 %patch57 -p1
%patch58 -p1 -b .strncpy %patch58 -p1 -b .strncpy
%patch59 -p1 -b .arp-un-access
cp %SOURCE2 ./config.h cp %SOURCE2 ./config.h
cp %SOURCE3 ./config.make cp %SOURCE3 ./config.make
@ -248,6 +250,9 @@ exit 0
%{_sysconfdir}/rc.d/init.d/netplugd %{_sysconfdir}/rc.d/init.d/netplugd
%changelog %changelog
* Wed Dec 27 2006 Radek Vokál <rvokal@redhat.com> - 1.60-76
- fix arp unaligned access (#220438)
* Wed Oct 4 2006 Radek Vokal <rvokal@redhat.com> - 1.60-75 * Wed Oct 4 2006 Radek Vokal <rvokal@redhat.com> - 1.60-75
- fix nameif crash for 16char long interface names (#209120) - fix nameif crash for 16char long interface names (#209120)