summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-10 11:58:38 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-10 20:02:51 +0000
commit3544fa9ec2e17e481785382317ef93ec2ac32ddf (patch)
treeb9d2d32d1d93da33cb8304841b37321c05e00cd6
parentf01b28cf76d641881fa1c5bf7f9dd2487b9ced6b (diff)
Use memcpy() instead of memmove() when buffers are known not to overlap
Most of these came from a mass bcopy() -> memmove() substitution in 1993 with a commit comment of "ANSIfied for R6". Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--chooser/chooser.c16
-rw-r--r--xdm/access.c6
-rw-r--r--xdm/auth.c8
-rw-r--r--xdm/choose.c3
-rw-r--r--xdm/krb5auth.c2
-rw-r--r--xdm/mitauth.c2
-rw-r--r--xdm/policy.c2
-rw-r--r--xdm/protodpy.c2
-rw-r--r--xdm/rpcauth.c4
-rw-r--r--xdm/server.c2
-rw-r--r--xdm/socket.c2
-rw-r--r--xdm/xdmauth.c10
-rw-r--r--xdm/xdmcp.c26
13 files changed, 43 insertions, 42 deletions
diff --git a/chooser/chooser.c b/chooser/chooser.c
index 6ebf2cc..4ccff56 100644
--- a/chooser/chooser.c
+++ b/chooser/chooser.c
@@ -347,7 +347,7 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi
XdmcpDisposeARRAY8 (hostname);
host = (char *)hostent->h_name;
XdmcpAllocARRAY8 (hostname, strlen (host));
- memmove( hostname->data, host, hostname->length);
+ memcpy(hostname->data, host, hostname->length);
}
}
}
@@ -358,7 +358,7 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi
free (new);
return 0;
}
- memmove( new->hostaddr.data, hostAddr.data, hostAddr.length);
+ memcpy(new->hostaddr.data, hostAddr.data, hostAddr.length);
new->connectionType = connectionType;
new->hostname = *hostname;
@@ -498,7 +498,7 @@ RegisterHostaddr (struct sockaddr *addr, int len, xdmOpCode type)
free (host);
return;
}
- memmove( (char *) host->addr, (char *) addr, len);
+ memcpy(host->addr, addr, len);
host->addrlen = len;
host->type = type;
for (prev = &hostAddrdb; *prev; prev = &(*prev)->next)
@@ -638,7 +638,7 @@ RegisterHostname (char *name)
if (hostent->h_addrtype != AF_INET || hostent->h_length != 4)
return;
in_addr.sin_family = hostent->h_addrtype;
- memmove( &in_addr.sin_addr, hostent->h_addr, 4);
+ memcpy(&in_addr.sin_addr, hostent->h_addr, 4);
}
in_addr.sin_port = htons (XDM_UDP_PORT);
# ifdef BSD44SOCKETS
@@ -727,8 +727,8 @@ Choose (HostName *h)
in_addr.sin_len = sizeof(in_addr);
#endif
in_addr.sin_family = family;
- memmove( &in_addr.sin_port, xdm + 2, 2);
- memmove( &in_addr.sin_addr, xdm + 4, 4);
+ memcpy(&in_addr.sin_port, xdm + 2, 2);
+ memcpy(&in_addr.sin_addr, xdm + 4, 4);
addr = (struct sockaddr *) &in_addr;
len = sizeof (in_addr);
break;
@@ -739,8 +739,8 @@ Choose (HostName *h)
in6_addr.sin6_len = sizeof(in6_addr);
# endif
in6_addr.sin6_family = family;
- memmove( &in6_addr.sin6_port, xdm + 2, 2);
- memmove( &in6_addr.sin6_addr, xdm + 4, 16);
+ memcpy(&in6_addr.sin6_port, xdm + 2, 2);
+ memcpy(&in6_addr.sin6_addr, xdm + 4, 16);
addr = (struct sockaddr *) &in6_addr;
len = sizeof (in6_addr);
break;
diff --git a/xdm/access.c b/xdm/access.c
index 7d6dfd0..b70cafe 100644
--- a/xdm/access.c
+++ b/xdm/access.c
@@ -165,7 +165,7 @@ getLocalAddress (void)
hostent = gethostbyname (localHostname());
if (hostent != NULL) {
if (XdmcpAllocARRAY8 (&localAddress, hostent->h_length)) {
- memmove(localAddress.data, hostent->h_addr, hostent->h_length);
+ memcpy(localAddress.data, hostent->h_addr, hostent->h_length);
haveLocalAddress = 1;
}
} else {
@@ -403,7 +403,7 @@ tryagain:
# endif
return NULL;
}
- memmove( h->entry.hostAddress.data, addr, addr_length);
+ memcpy(h->entry.hostAddress.data, addr, addr_length);
# if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
@@ -528,7 +528,7 @@ tryagain:
# endif
return NULL;
}
- memmove( display->clientAddress.data, addr, addr_length);
+ memcpy(display->clientAddress.data, addr, addr_length);
# if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
diff --git a/xdm/auth.c b/xdm/auth.c
index 07dd836..3469ca0 100644
--- a/xdm/auth.c
+++ b/xdm/auth.c
@@ -683,7 +683,7 @@ saveEntry (Xauth *auth)
free (new);
return;
}
- memmove( new->address, auth->address, (int) auth->address_length);
+ memcpy(new->address, auth->address, (int) auth->address_length);
} else
new->address = NULL;
if ((new->number_length = auth->number_length) > 0) {
@@ -694,7 +694,7 @@ saveEntry (Xauth *auth)
free (new);
return;
}
- memmove( new->number, auth->number, (int) auth->number_length);
+ memcpy(new->number, auth->number, (int) auth->number_length);
} else
new->number = NULL;
if ((new->name_length = auth->name_length) > 0) {
@@ -706,7 +706,7 @@ saveEntry (Xauth *auth)
free (new);
return;
}
- memmove( new->name, auth->name, (int) auth->name_length);
+ memcpy(new->name, auth->name, (int) auth->name_length);
} else
new->name = NULL;
new->family = auth->family;
@@ -1052,7 +1052,7 @@ DefineSelf (int fd, int file, int auth)
if (hp != NULL) {
saddr.sa.sa_family = hp->h_addrtype;
inetaddr = (struct sockaddr_in *) (&(saddr.sa));
- memmove( (char *) &(inetaddr->sin_addr), (char *) hp->h_addr, (int) hp->h_length);
+ memcpy(&(inetaddr->sin_addr), hp->h_addr, hp->h_length);
family = ConvertAddr ( &(saddr.sa), &len, &addr);
if ( family >= 0) {
writeAddr (FamilyInternet, sizeof (inetaddr->sin_addr),
diff --git a/xdm/choose.c b/xdm/choose.c
index c167964..5df0f67 100644
--- a/xdm/choose.c
+++ b/xdm/choose.c
@@ -227,8 +227,7 @@ FormatChooserArgument (char *buf, int len)
result_buf[1] = netfamily & 0xFF;
result_buf[2] = port[0];
result_buf[3] = port[1];
- memmove( (char *)result_buf+4, (char *)localAddress->data,
- localAddress->length);
+ memcpy(result_buf+4, localAddress->data, localAddress->length);
result_len = 4 + localAddress->length;
}
break;
diff --git a/xdm/krb5auth.c b/xdm/krb5auth.c
index c4498d0..a5a681d 100644
--- a/xdm/krb5auth.c
+++ b/xdm/krb5auth.c
@@ -132,7 +132,7 @@ Krb5GetAuthFor(unsigned short namelen, char *name, char *dname)
free (new);
return (Xauth *) 0;
}
- memmove( new->name, name, namelen);
+ memcpy(new->name, name, namelen);
new->name_length = namelen;
return new;
}
diff --git a/xdm/mitauth.c b/xdm/mitauth.c
index d100798..f8486cc 100644
--- a/xdm/mitauth.c
+++ b/xdm/mitauth.c
@@ -79,7 +79,7 @@ MitGetAuth (unsigned short namelen, char *name)
free (new);
return (Xauth *) 0;
}
- memmove( (char *)new->name, name, namelen);
+ memcpy(new->name, name, namelen);
new->name_length = namelen;
if (!GenerateAuthData (new->data, AUTH_DATA_LEN))
{
diff --git a/xdm/policy.c b/xdm/policy.c
index fb1e7de..3fad69b 100644
--- a/xdm/policy.c
+++ b/xdm/policy.c
@@ -161,7 +161,7 @@ Willing (
if (!status->data)
status->length = 0;
else
- memmove( status->data, statusBuf, status->length);
+ memcpy(status->data, statusBuf, status->length);
return ret;
}
diff --git a/xdm/protodpy.c b/xdm/protodpy.c
index 2ff44a8..0b59903 100644
--- a/xdm/protodpy.c
+++ b/xdm/protodpy.c
@@ -116,7 +116,7 @@ NewProtoDisplay (
return NULL;
}
pdpy->addrlen = addrlen;
- memmove( pdpy->address, address, addrlen);
+ memcpy(pdpy->address, address, addrlen);
pdpy->displayNumber = displayNumber;
pdpy->connectionType = connectionType;
pdpy->date = date;
diff --git a/xdm/rpcauth.c b/xdm/rpcauth.c
index 6fb9a1e..5fb1a5d 100644
--- a/xdm/rpcauth.c
+++ b/xdm/rpcauth.c
@@ -82,8 +82,8 @@ SecureRPCGetAuth (
free (new);
return (Xauth *) 0;
}
- memmove( new->name, name, namelen);
+ memcpy(new->name, name, namelen);
new->name_length = namelen;
- memmove( new->data, key, new->data_length);
+ memcpy(new->data, key, new->data_length);
return new;
}
diff --git a/xdm/server.c b/xdm/server.c
index ffa1ffc..ad41e0f 100644
--- a/xdm/server.c
+++ b/xdm/server.c
@@ -257,7 +257,7 @@ GetRemoteAddress (struct display *d, int fd)
d->peer = malloc (len);
if (d->peer)
{
- memmove( (char *) d->peer, buf, len);
+ memcpy(d->peer, buf, len);
d->peerlen = len;
}
}
diff --git a/xdm/socket.c b/xdm/socket.c
index 5131d18..6f3cf1a 100644
--- a/xdm/socket.c
+++ b/xdm/socket.c
@@ -129,7 +129,7 @@ GetChooserAddr (
if (*lenp < len)
retval = -2;
else
- memmove( addr, (char *) &in_addr, len);
+ memcpy(addr, &in_addr, len);
*lenp = len;
return retval;
diff --git a/xdm/xdmauth.c b/xdm/xdmauth.c
index b3c1c16..bee25d4 100644
--- a/xdm/xdmauth.c
+++ b/xdm/xdmauth.c
@@ -111,7 +111,7 @@ XdmGetAuthHelper (unsigned short namelen, char *name, int includeRho)
free (new);
return (Xauth *) 0;
}
- memmove( (char *)new->name, name, namelen);
+ memcpy(new->name, name, namelen);
new->name_length = namelen;
if (!GenerateAuthData ((char *)new->data, new->data_length))
{
@@ -172,9 +172,9 @@ XdmGetXdmcpAuth (struct protoDisplay *pdpy,
* which is simply the number we've been passing back and
* forth via XDMCP
*/
- memmove( fileauth->name, xdmcpauth->name, xdmcpauth->name_length);
- memmove( fileauth->data, pdpy->authenticationData.data, 8);
- memmove( fileauth->data + 8, xdmcpauth->data, 8);
+ memcpy(fileauth->name, xdmcpauth->name, xdmcpauth->name_length);
+ memcpy(fileauth->data, pdpy->authenticationData.data, 8);
+ memcpy(fileauth->data + 8, xdmcpauth->data, 8);
XdmPrintDataHex ("Accept packet auth", xdmcpauth->data, xdmcpauth->data_length);
XdmPrintDataHex ("Auth file auth", fileauth->data, fileauth->data_length);
/* encrypt the session key for its trip back to the server */
@@ -245,7 +245,7 @@ XdmGetKey(struct protoDisplay *pdpy, ARRAY8Ptr displayID)
while (keylen < 7)
key[keylen++] = '\0';
pdpy->key.data[0] = '\0';
- memmove( pdpy->key.data + 1, key, 7);
+ memcpy(pdpy->key.data + 1, key, 7);
bzero(key, sizeof(key));
fclose (keys);
return TRUE;
diff --git a/xdm/xdmcp.c b/xdm/xdmcp.c
index ddf2418..a1b0202 100644
--- a/xdm/xdmcp.c
+++ b/xdm/xdmcp.c
@@ -163,7 +163,7 @@ sendForward (
in_addr.sin_port = htons ((short) XDM_UDP_PORT);
if (address->length != 4)
return;
- memmove( (char *) &in_addr.sin_addr, address->data, address->length);
+ memcpy(&in_addr.sin_addr, address->data, address->length);
addrlen = sizeof (struct sockaddr_in);
break;
# endif
@@ -178,7 +178,7 @@ sendForward (
in6_addr.sin6_port = htons ((short) XDM_UDP_PORT);
if (address->length != 16)
return;
- memmove( (char *) &in6_addr.sin6_addr, address->data, address->length);
+ memcpy(&in6_addr.sin6_addr, address->data, address->length);
addrlen = sizeof (struct sockaddr_in6);
break;
# endif
@@ -204,12 +204,12 @@ ClientAddress (
data = NetaddrPort((XdmcpNetaddr) from, &length);
XdmcpAllocARRAY8 (port, length);
- memmove( port->data, data, length);
+ memcpy(port->data, data, length);
port->length = length;
family = ConvertAddr((XdmcpNetaddr) from, &length, &data);
XdmcpAllocARRAY8 (addr, length);
- memmove( addr->data, data, length);
+ memcpy(addr->data, data, length);
addr->length = length;
*type = family;
@@ -745,8 +745,8 @@ forward_respond (
in_addr.sin_len = sizeof(in_addr);
# endif
in_addr.sin_family = AF_INET;
- memmove( &in_addr.sin_addr, clientAddress.data, 4);
- memmove( (char *) &in_addr.sin_port, clientPort.data, 2);
+ memcpy(&in_addr.sin_addr, clientAddress.data, 4);
+ memcpy(&in_addr.sin_port, clientPort.data, 2);
client = (struct sockaddr *) &in_addr;
clientlen = sizeof (in_addr);
all_query_respond (client, clientlen, &authenticationNames,
@@ -770,7 +770,7 @@ forward_respond (
# endif
in6_addr.sin6_family = AF_INET6;
if (clientAddress.length == 16) {
- memmove(in6_addr.sin6_addr.s6_addr, clientAddress.data, 16);
+ memcpy(in6_addr.sin6_addr.s6_addr, clientAddress.data, 16);
} else {
/* If the client wants to forward the xdm server to an
ipv4 hosts it sends an ipv4 address in the forward
@@ -785,9 +785,10 @@ forward_respond (
*/
in6_addr.sin6_addr.s6_addr[10] = 0xff;
in6_addr.sin6_addr.s6_addr[11] = 0xff;
- memmove(in6_addr.sin6_addr.s6_addr + 12, clientAddress.data, 4);
+ memcpy(in6_addr.sin6_addr.s6_addr + 12,
+ clientAddress.data, 4);
}
- memmove((char *) &in6_addr.sin6_port, clientPort.data, 2);
+ memcpy(&in6_addr.sin6_port, clientPort.data, 2);
client = (struct sockaddr *) &in6_addr;
clientlen = sizeof (in6_addr);
all_query_respond (client, clientlen, &authenticationNames,
@@ -804,7 +805,8 @@ forward_respond (
goto badAddress;
bzero ((char *) &un_addr, sizeof (un_addr));
un_addr.sun_family = AF_UNIX;
- memmove( un_addr.sun_path, clientAddress.data, clientAddress.length);
+ memcpy(un_addr.sun_path, clientAddress.data,
+ clientAddress.length);
un_addr.sun_path[clientAddress.length] = '\0';
client = (struct sockaddr *) &un_addr;
# if defined(BSD44SOCKETS) && defined(UNIXCONN)
@@ -1192,7 +1194,7 @@ manage (
}
if (displayClass.length)
{
- memmove( class, displayClass.data, displayClass.length);
+ memcpy(class, displayClass.data, displayClass.length);
class[displayClass.length] = '\0';
}
else
@@ -1207,7 +1209,7 @@ manage (
"out of memory", fd);
goto abort;
}
- memmove( from_save, from, fromlen);
+ memcpy(from_save, from, fromlen);
d = NewDisplay (name, class);
if (!d)
{