diff --git a/CHANGES b/CHANGES index 2acf417b0b..d465d087be 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3698. [cleanup] Replaced all uses of memcpy() with memmove(). + [RT #35120] + 3697. [bug] Handle "." as a search list element when IDN support is enabled. [RT #35133] diff --git a/bin/confgen/ddns-confgen.c b/bin/confgen/ddns-confgen.c index d655145eaf..bfba12aa43 100644 --- a/bin/confgen/ddns-confgen.c +++ b/bin/confgen/ddns-confgen.c @@ -101,7 +101,7 @@ main(int argc, char **argv) { result = isc_file_progname(*argv, program, sizeof(program)); if (result != ISC_R_SUCCESS) - memcpy(program, "ddns-confgen", 13); + memmove(program, "ddns-confgen", 13); progname = program; isc_commandline_errprint = ISC_FALSE; diff --git a/bin/confgen/rndc-confgen.c b/bin/confgen/rndc-confgen.c index 3fd54fe2bb..a680d1f42b 100644 --- a/bin/confgen/rndc-confgen.c +++ b/bin/confgen/rndc-confgen.c @@ -120,7 +120,7 @@ main(int argc, char **argv) { result = isc_file_progname(*argv, program, sizeof(program)); if (result != ISC_R_SUCCESS) - memcpy(program, "rndc-confgen", 13); + memmove(program, "rndc-confgen", 13); progname = program; keyname = DEFAULT_KEYNAME; diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 42942ce053..94ab297166 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -448,7 +448,7 @@ static isc_result_t append(const char *text, int len, char **p, char *end) { if (len > end - *p) return (ISC_R_NOSPACE); - memcpy(*p, text, len); + memmove(*p, text, len); *p += len; return (ISC_R_SUCCESS); } @@ -3945,7 +3945,7 @@ output_filter(isc_buffer_t *buffer, unsigned int used_org, fromlen = isc_buffer_usedlength(buffer) - used_org; if (fromlen >= MAXDLEN) return (ISC_R_SUCCESS); - memcpy(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen); + memmove(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen); end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE; if (absolute && !end_with_dot) { fromlen++; @@ -3974,7 +3974,7 @@ output_filter(isc_buffer_t *buffer, unsigned int used_org, return (ISC_R_NOSPACE); isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org); - memcpy(isc_buffer_used(buffer), tmp1, tolen); + memmove(isc_buffer_used(buffer), tmp1, tolen); isc_buffer_add(buffer, (unsigned int)tolen); return (ISC_R_SUCCESS); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 6737063908..3aeb8e28c2 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -729,7 +729,7 @@ hashlist_add(hashlist_t *l, const unsigned char *hash, size_t len) fatal("unable to grow hashlist: out of memory"); } memset(l->hashbuf + l->entries * l->length, 0, l->length); - memcpy(l->hashbuf + l->entries * l->length, hash, len); + memmove(l->hashbuf + l->entries * l->length, hash, len); l->entries++; } @@ -2666,7 +2666,7 @@ set_nsec3params(isc_boolean_t update_chain, isc_boolean_t set_salt, "Use -u to update it."); } else if (!set_salt) { salt_length = orig_saltlen; - memcpy(saltbuf, orig_salt, orig_saltlen); + memmove(saltbuf, orig_salt, orig_saltlen); salt = saltbuf; } diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 5f5f7d88c9..e03d0419e0 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -725,11 +725,11 @@ record_nsec3(const unsigned char *rawhash, const dns_rdata_nsec3_t *nsec3, element->next_length = nsec3->next_length; element->iterations = nsec3->iterations; cp = (unsigned char *)(element + 1); - memcpy(cp, nsec3->salt, nsec3->salt_length); + memmove(cp, nsec3->salt, nsec3->salt_length); cp += nsec3->salt_length; - memcpy(cp, rawhash, nsec3->next_length); + memmove(cp, rawhash, nsec3->next_length); cp += nsec3->next_length; - memcpy(cp, nsec3->next, nsec3->next_length); + memmove(cp, nsec3->next, nsec3->next_length); result = isc_heap_insert(chains, element); if (result != ISC_R_SUCCESS) { fprintf(stderr, "isc_heap_insert failed: %s\n", diff --git a/bin/named/builtin.c b/bin/named/builtin.c index d6d7538a19..a3db410595 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -117,7 +117,7 @@ dns64_rdata(unsigned char *v, size_t start, unsigned char *rdata) { rdata[j++] = decimal[c]; } } - memcpy(&rdata[j], "\07in-addr\04arpa", 14); + memmove(&rdata[j], "\07in-addr\04arpa", 14); return (j + 14); } @@ -320,7 +320,7 @@ put_txt(dns_sdblookup_t *lookup, const char *text) { if (len > 255) len = 255; /* Silently truncate */ buf[0] = len; - memcpy(&buf[1], text, len); + memmove(&buf[1], text, len); return (dns_sdb_putrdata(lookup, dns_rdatatype_txt, 0, buf, len + 1)); } @@ -502,11 +502,11 @@ builtin_create(const char *zone, int argc, char **argv, isc_mem_put(ns_g_mctx, empty, sizeof (*empty)); } else { if (strcmp(argv[0], "empty") == 0) - memcpy(empty, &empty_builtin, - sizeof (empty_builtin)); + memmove(empty, &empty_builtin, + sizeof (empty_builtin)); else - memcpy(empty, &dns64_builtin, - sizeof (empty_builtin)); + memmove(empty, &dns64_builtin, + sizeof (empty_builtin)); empty->server = server; empty->contact = contact; *dbdata = empty; diff --git a/bin/named/config.c b/bin/named/config.c index da06e4b66d..50d41ad1ad 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -634,7 +634,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, if (new == NULL) goto cleanup; if (listcount != 0) { - memcpy(new, lists, oldsize); + memmove(new, lists, oldsize); isc_mem_put(mctx, lists, oldsize); } lists = new; @@ -669,7 +669,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, if (new == NULL) goto cleanup; if (stackcount != 0) { - memcpy(new, stack, oldsize); + memmove(new, stack, oldsize); isc_mem_put(mctx, stack, oldsize); } stack = new; @@ -697,7 +697,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, if (new == NULL) goto cleanup; if (addrcount != 0) { - memcpy(new, addrs, oldsize); + memmove(new, addrs, oldsize); isc_mem_put(mctx, addrs, oldsize); } addrs = new; @@ -709,7 +709,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, if (new == NULL) goto cleanup; if (dscpcount != 0) { - memcpy(new, dscps, oldsize); + memmove(new, dscps, oldsize); isc_mem_put(mctx, dscps, oldsize); } dscps = new; @@ -721,7 +721,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, if (new == NULL) goto cleanup; if (keycount != 0) { - memcpy(new, keys, oldsize); + memmove(new, keys, oldsize); isc_mem_put(mctx, keys, oldsize); } keys = new; @@ -773,7 +773,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, new = isc_mem_get(mctx, newsize); if (new == NULL) goto cleanup; - memcpy(new, addrs, newsize); + memmove(new, addrs, newsize); } else new = NULL; isc_mem_put(mctx, addrs, oldsize); @@ -786,7 +786,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, new = isc_mem_get(mctx, newsize); if (new == NULL) goto cleanup; - memcpy(new, dscps, newsize); + memmove(new, dscps, newsize); } else new = NULL; isc_mem_put(mctx, dscps, oldsize); @@ -799,7 +799,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, new = isc_mem_get(mctx, newsize); if (new == NULL) goto cleanup; - memcpy(new, keys, newsize); + memmove(new, keys, newsize); } else new = NULL; isc_mem_put(mctx, keys, oldsize); diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index f53877df6f..a090a223e7 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -370,7 +370,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) { secret.rstart = isc_mem_get(listener->mctx, key->secret.length); if (secret.rstart == NULL) goto cleanup; - memcpy(secret.rstart, key->secret.base, key->secret.length); + memmove(secret.rstart, key->secret.base, key->secret.length); secret.rend = secret.rstart + key->secret.length; algorithm = key->algorithm; result = isccc_cc_fromwire(&ccregion, &request, @@ -795,8 +795,8 @@ register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist, free_controlkey(keyid, mctx); break; } - memcpy(keyid->secret.base, isc_buffer_base(&b), - keyid->secret.length); + memmove(keyid->secret.base, isc_buffer_base(&b), + keyid->secret.length); } } } @@ -879,8 +879,8 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) { "out of memory", keyid->keyname); CHECK(ISC_R_NOMEMORY); } - memcpy(keyid->secret.base, isc_buffer_base(&b), - keyid->secret.length); + memmove(keyid->secret.base, isc_buffer_base(&b), + keyid->secret.length); ISC_LIST_APPEND(*keyids, keyid, link); keyid = NULL; result = ISC_R_SUCCESS; diff --git a/bin/named/lwaddr.c b/bin/named/lwaddr.c index ed7880ac26..ed93b6982c 100644 --- a/bin/named/lwaddr.c +++ b/bin/named/lwaddr.c @@ -41,11 +41,11 @@ lwaddr_netaddr_fromlwresaddr(isc_netaddr_t *na, lwres_addr_t *la) { if (la->family == LWRES_ADDRTYPE_V4) { struct in_addr ina; - memcpy(&ina.s_addr, la->address, 4); + memmove(&ina.s_addr, la->address, 4); isc_netaddr_fromin(na, &ina); } else { struct in6_addr ina6; - memcpy(&ina6.s6_addr, la->address, 16); + memmove(&ina6.s6_addr, la->address, 16); isc_netaddr_fromin6(na, &ina6); } return (ISC_R_SUCCESS); @@ -77,11 +77,11 @@ lwaddr_lwresaddr_fromnetaddr(lwres_addr_t *la, isc_netaddr_t *na) { if (na->family == AF_INET) { la->family = LWRES_ADDRTYPE_V4; la->length = 4; - memcpy(la->address, &na->type.in, 4); + memmove(la->address, &na->type.in, 4); } else { la->family = LWRES_ADDRTYPE_V6; la->length = 16; - memcpy(la->address, &na->type.in6, 16); + memmove(la->address, &na->type.in6, 16); } return (ISC_R_SUCCESS); } diff --git a/bin/named/lwdgnba.c b/bin/named/lwdgnba.c index dfc2ad6543..f5b3033026 100644 --- a/bin/named/lwdgnba.c +++ b/bin/named/lwdgnba.c @@ -226,12 +226,12 @@ ns_lwdclient_processgnba(ns_lwdclient_t *client, lwres_buffer_t *b) { client->na.family = AF_INET; if (req->addr.length != 4) goto out; - memcpy(&client->na.type.in, req->addr.address, 4); + memmove(&client->na.type.in, req->addr.address, 4); } else if (req->addr.family == LWRES_ADDRTYPE_V6) { client->na.family = AF_INET6; if (req->addr.length != 16) goto out; - memcpy(&client->na.type.in6, req->addr.address, 16); + memmove(&client->na.type.in6, req->addr.address, 16); } else { goto out; } diff --git a/bin/named/lwdgrbn.c b/bin/named/lwdgrbn.c index bbb4fbc5f6..06ff106ec1 100644 --- a/bin/named/lwdgrbn.c +++ b/bin/named/lwdgrbn.c @@ -124,8 +124,8 @@ iterate_node(lwres_grbnresponse_t *grbn, dns_db_t *db, dns_dbnode_t *node, lens = isc_mem_get(mctx, size * sizeof(*lens)); if (lens == NULL) goto out; - memcpy(rdatas, oldrdatas, used * sizeof(*rdatas)); - memcpy(lens, oldlens, used * sizeof(*lens)); + memmove(rdatas, oldrdatas, used * sizeof(*rdatas)); + memmove(lens, oldlens, used * sizeof(*lens)); isc_mem_put(mctx, oldrdatas, oldsize * sizeof(*oldrdatas)); isc_mem_put(mctx, oldlens, oldsize * sizeof(*oldlens)); @@ -158,8 +158,8 @@ iterate_node(lwres_grbnresponse_t *grbn, dns_db_t *db, dns_dbnode_t *node, newlens = isc_mem_get(mctx, used * sizeof(*lens)); if (newlens == NULL) goto out; - memcpy(newrdatas, rdatas, used * sizeof(*rdatas)); - memcpy(newlens, lens, used * sizeof(*lens)); + memmove(newrdatas, rdatas, used * sizeof(*rdatas)); + memmove(newlens, lens, used * sizeof(*lens)); isc_mem_put(mctx, rdatas, size * sizeof(*rdatas)); isc_mem_put(mctx, lens, size * sizeof(*lens)); grbn->rdatas = newrdatas; diff --git a/bin/named/query.c b/bin/named/query.c index 1eede63b78..2abf409765 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -4606,12 +4606,12 @@ rpz_rewrite_ip_rrset(ns_client_t *client, switch (rdata.type) { case dns_rdatatype_a: INSIST(rdata.length == 4); - memcpy(&ina.s_addr, rdata.data, 4); + memmove(&ina.s_addr, rdata.data, 4); isc_netaddr_fromin(&netaddr, &ina); break; case dns_rdatatype_aaaa: INSIST(rdata.length == 16); - memcpy(in6a.s6_addr, rdata.data, 16); + memmove(in6a.s6_addr, rdata.data, 16); isc_netaddr_fromin6(&netaddr, &in6a); break; default: @@ -5381,12 +5381,12 @@ rdata_tonetaddr(const dns_rdata_t *rdata, isc_netaddr_t *netaddr) { switch (rdata->type) { case dns_rdatatype_a: INSIST(rdata->length == 4); - memcpy(&ina.s_addr, rdata->data, 4); + memmove(&ina.s_addr, rdata->data, 4); isc_netaddr_fromin(netaddr, &ina); return (ISC_R_SUCCESS); case dns_rdatatype_aaaa: INSIST(rdata->length == 16); - memcpy(in6a.s6_addr, rdata->data, 16); + memmove(in6a.s6_addr, rdata->data, 16); isc_netaddr_fromin6(netaddr, &in6a); return (ISC_R_SUCCESS); default: diff --git a/bin/named/server.c b/bin/named/server.c index 9af6d38b89..22e3b4d590 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -9124,7 +9124,7 @@ ns_server_signing(ns_server_t *server, char *args, isc_buffer_t *text) { ptr = next_token(&args, " \t"); if (ptr == NULL) return (ISC_R_UNEXPECTEDEND); - memcpy(keystr, ptr, sizeof(keystr)); + memmove(keystr, ptr, sizeof(keystr)); } else if (strcasecmp(ptr, "-nsec3param") == 0) { const char *hashstr, *flagstr, *iterstr; char nbuf[512]; diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 47565c7a97..492054a6ce 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -462,7 +462,7 @@ configure_staticstub_serveraddrs(const cfg_obj_t *zconfig, dns_zone_t *zone, if (rdata == NULL) return (ISC_R_NOMEMORY); region.base = (unsigned char *)(rdata + 1); - memcpy(region.base, &na.type, region.length); + memmove(region.base, &na.type, region.length); dns_rdata_init(rdata); dns_rdata_fromregion(rdata, dns_zone_getclass(zone), rdatalist->type, ®ion); @@ -490,7 +490,7 @@ configure_staticstub_serveraddrs(const cfg_obj_t *zconfig, dns_zone_t *zone, } region.length = sregion.length; region.base = (unsigned char *)(rdata + 1); - memcpy(region.base, sregion.base, region.length); + memmove(region.base, sregion.base, region.length); dns_rdata_init(rdata); dns_rdata_fromregion(rdata, dns_zone_getclass(zone), dns_rdatatype_ns, ®ion); @@ -554,7 +554,7 @@ configure_staticstub_servernames(const cfg_obj_t *zconfig, dns_zone_t *zone, return (ISC_R_NOMEMORY); region.length = sregion.length; region.base = (unsigned char *)(rdata + 1); - memcpy(region.base, sregion.base, region.length); + memmove(region.base, sregion.base, region.length); dns_rdata_init(rdata); dns_rdata_fromregion(rdata, dns_zone_getclass(zone), dns_rdatatype_ns, ®ion); diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index b10523fa4f..78e0e9bef6 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -840,13 +840,16 @@ setup_system(void) { if (servers == NULL) fatal("out of memory"); for (i = 0; i < ns_total; i++) { - if (lwconf->nameservers[i].family == LWRES_ADDRTYPE_V4) { + if (lwconf->nameservers[i].family == LWRES_ADDRTYPE_V4) + { struct in_addr in4; - memcpy(&in4, lwconf->nameservers[i].address, 4); + memmove(&in4, + lwconf->nameservers[i].address, 4); isc_sockaddr_fromin(&servers[i], &in4, dnsport); } else { struct in6_addr in6; - memcpy(&in6, lwconf->nameservers[i].address, 16); + memmove(&in6, + lwconf->nameservers[i].address, 16); isc_sockaddr_fromin6(&servers[i], &in6, dnsport); } @@ -2607,7 +2610,7 @@ start_gssrequest(dns_name_t *master) { if (userserver == NULL) get_address(namestr, dnsport, kserver); else - (void)memcpy(kserver, userserver, sizeof(isc_sockaddr_t)); + (void)memmove(kserver, userserver, sizeof(isc_sockaddr_t)); dns_fixedname_init(&fname); servname = dns_fixedname_name(&fname); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index f811830f8f..05564bc777 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -745,7 +745,7 @@ main(int argc, char **argv) { result = isc_file_progname(*argv, program, sizeof(program)); if (result != ISC_R_SUCCESS) - memcpy(program, "rndc", 5); + memmove(program, "rndc", 5); progname = program; admin_conffile = RNDC_CONFFILE; @@ -877,7 +877,7 @@ main(int argc, char **argv) { p = args; for (i = 0; i < argc; i++) { size_t len = strlen(argv[i]); - memcpy(p, argv[i], len); + memmove(p, argv[i], len); p += len; *p++ = ' '; } diff --git a/bin/tests/hash_test.c b/bin/tests/hash_test.c index 73d397b010..980b4bc3bd 100644 --- a/bin/tests/hash_test.c +++ b/bin/tests/hash_test.c @@ -66,35 +66,35 @@ main(int argc, char **argv) { s = "abc"; isc_sha1_init(&sha1); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_sha1_update(&sha1, buffer, strlen(s)); isc_sha1_final(&sha1, digest); print_digest(s, "sha1", digest, ISC_SHA1_DIGESTLENGTH/4); s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; isc_sha1_init(&sha1); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_sha1_update(&sha1, buffer, strlen(s)); isc_sha1_final(&sha1, digest); print_digest(s, "sha1", digest, ISC_SHA1_DIGESTLENGTH/4); s = "abc"; isc_sha224_init(&sha224); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_sha224_update(&sha224, buffer, strlen(s)); isc_sha224_final(digest, &sha224); print_digest(s, "sha224", digest, ISC_SHA224_DIGESTLENGTH/4); s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; isc_sha224_init(&sha224); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_sha224_update(&sha224, buffer, strlen(s)); isc_sha224_final(digest, &sha224); print_digest(s, "sha224", digest, ISC_SHA224_DIGESTLENGTH/4); s = "abc"; isc_md5_init(&md5); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_md5_update(&md5, buffer, strlen(s)); isc_md5_final(&md5, digest); print_digest(s, "md5", digest, 4); @@ -105,7 +105,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 16); isc_hmacmd5_init(&hmacmd5, key, 16); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(s, "hmacmd5", digest, 4); @@ -113,7 +113,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacmd5_init(&hmacmd5, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(s, "hmacmd5", digest, 4); @@ -125,7 +125,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 16); isc_hmacmd5_init(&hmacmd5, key, 16); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(s, "hmacmd5", digest, 4); @@ -136,7 +136,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 20); isc_hmacsha1_init(&hmacsha1, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha1_update(&hmacsha1, buffer, strlen(s)); isc_hmacsha1_sign(&hmacsha1, digest, ISC_SHA1_DIGESTLENGTH); print_digest(s, "hmacsha1", digest, ISC_SHA1_DIGESTLENGTH/4); @@ -144,7 +144,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacsha1_init(&hmacsha1, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha1_update(&hmacsha1, buffer, strlen(s)); isc_hmacsha1_sign(&hmacsha1, digest, ISC_SHA1_DIGESTLENGTH); print_digest(s, "hmacsha1", digest, ISC_SHA1_DIGESTLENGTH/4); @@ -156,7 +156,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 20); isc_hmacsha1_init(&hmacsha1, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha1_update(&hmacsha1, buffer, strlen(s)); isc_hmacsha1_sign(&hmacsha1, digest, ISC_SHA1_DIGESTLENGTH); print_digest(s, "hmacsha1", digest, ISC_SHA1_DIGESTLENGTH/4); @@ -167,7 +167,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 20); isc_hmacsha224_init(&hmacsha224, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha224_update(&hmacsha224, buffer, strlen(s)); isc_hmacsha224_sign(&hmacsha224, digest, ISC_SHA224_DIGESTLENGTH); print_digest(s, "hmacsha224", digest, ISC_SHA224_DIGESTLENGTH/4); @@ -175,7 +175,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacsha224_init(&hmacsha224, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha224_update(&hmacsha224, buffer, strlen(s)); isc_hmacsha224_sign(&hmacsha224, digest, ISC_SHA224_DIGESTLENGTH); print_digest(s, "hmacsha224", digest, ISC_SHA224_DIGESTLENGTH/4); @@ -187,7 +187,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 20); isc_hmacsha224_init(&hmacsha224, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha224_update(&hmacsha224, buffer, strlen(s)); isc_hmacsha224_sign(&hmacsha224, digest, ISC_SHA224_DIGESTLENGTH); print_digest(s, "hmacsha224", digest, ISC_SHA224_DIGESTLENGTH/4); @@ -198,7 +198,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 20); isc_hmacsha256_init(&hmacsha256, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha256_update(&hmacsha256, buffer, strlen(s)); isc_hmacsha256_sign(&hmacsha256, digest, ISC_SHA256_DIGESTLENGTH); print_digest(s, "hmacsha256", digest, ISC_SHA256_DIGESTLENGTH/4); @@ -206,7 +206,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacsha256_init(&hmacsha256, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha256_update(&hmacsha256, buffer, strlen(s)); isc_hmacsha256_sign(&hmacsha256, digest, ISC_SHA256_DIGESTLENGTH); print_digest(s, "hmacsha256", digest, ISC_SHA256_DIGESTLENGTH/4); @@ -218,7 +218,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 20); isc_hmacsha256_init(&hmacsha256, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha256_update(&hmacsha256, buffer, strlen(s)); isc_hmacsha256_sign(&hmacsha256, digest, ISC_SHA256_DIGESTLENGTH); print_digest(s, "hmacsha256", digest, ISC_SHA256_DIGESTLENGTH/4); @@ -229,7 +229,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 20); isc_hmacsha384_init(&hmacsha384, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha384_update(&hmacsha384, buffer, strlen(s)); isc_hmacsha384_sign(&hmacsha384, digest, ISC_SHA384_DIGESTLENGTH); print_digest(s, "hmacsha384", digest, ISC_SHA384_DIGESTLENGTH/4); @@ -237,7 +237,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacsha384_init(&hmacsha384, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha384_update(&hmacsha384, buffer, strlen(s)); isc_hmacsha384_sign(&hmacsha384, digest, ISC_SHA384_DIGESTLENGTH); print_digest(s, "hmacsha384", digest, ISC_SHA384_DIGESTLENGTH/4); @@ -249,7 +249,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 20); isc_hmacsha384_init(&hmacsha384, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha384_update(&hmacsha384, buffer, strlen(s)); isc_hmacsha384_sign(&hmacsha384, digest, ISC_SHA384_DIGESTLENGTH); print_digest(s, "hmacsha384", digest, ISC_SHA384_DIGESTLENGTH/4); @@ -260,7 +260,7 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 20); isc_hmacsha512_init(&hmacsha512, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha512_update(&hmacsha512, buffer, strlen(s)); isc_hmacsha512_sign(&hmacsha512, digest, ISC_SHA512_DIGESTLENGTH); print_digest(s, "hmacsha512", digest, ISC_SHA512_DIGESTLENGTH/4); @@ -268,7 +268,7 @@ main(int argc, char **argv) { s = "what do ya want for nothing?"; strcpy((char *)key, "Jefe"); isc_hmacsha512_init(&hmacsha512, key, 4); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha512_update(&hmacsha512, buffer, strlen(s)); isc_hmacsha512_sign(&hmacsha512, digest, ISC_SHA512_DIGESTLENGTH); print_digest(s, "hmacsha512", digest, ISC_SHA512_DIGESTLENGTH/4); @@ -280,7 +280,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 20); isc_hmacsha512_init(&hmacsha512, key, 20); - memcpy(buffer, s, strlen(s)); + memmove(buffer, s, strlen(s)); isc_hmacsha512_update(&hmacsha512, buffer, strlen(s)); isc_hmacsha512_sign(&hmacsha512, digest, ISC_SHA512_DIGESTLENGTH); print_digest(s, "hmacsha512", digest, ISC_SHA512_DIGESTLENGTH/4); diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c index 4b710e674a..d9856eda3d 100644 --- a/bin/tests/names/t_names.c +++ b/bin/tests/names/t_names.c @@ -296,7 +296,7 @@ hname_to_tname(char *src, char *target, size_t len) { */ if (srclen >= len) return (1); - memcpy(target, src, srclen + 1); + memmove(target, src, srclen + 1); return (0); } diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index 51cc406a48..b5105a0c31 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -1193,7 +1193,7 @@ main(int argc, char *argv[]) { dns_rdata_init(&last); region.base = malloc(region.length = rdata.length); if (region.base) { - memcpy(region.base, rdata.data, rdata.length); + memmove(region.base, rdata.data, rdata.length); dns_rdata_fromregion(&last, class, type, ®ion); lasttype = type; first = 0; diff --git a/lib/bind9/check.c b/lib/bind9/check.c index 0285b4c76c..2d0dfe20ba 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -1262,7 +1262,7 @@ validate_masters(const cfg_obj_t *obj, const cfg_obj_t *config, void *ptr; DE_CONST(stack, ptr); - memcpy(new, stack, oldsize); + memmove(new, stack, oldsize); isc_mem_put(mctx, ptr, oldsize); } stack = new; diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 78b0929aa6..a8385fc4b1 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -292,8 +292,8 @@ dns_acl_merge(dns_acl_t *dest, dns_acl_t *source, isc_boolean_t pos) return (ISC_R_NOMEMORY); /* Copy in the original elements */ - memcpy(newmem, dest->elements, - dest->length * sizeof(dns_aclelement_t)); + memmove(newmem, dest->elements, + dest->length * sizeof(dns_aclelement_t)); /* Release the memory for the old elements array */ isc_mem_put(dest->mctx, dest->elements, diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 54e39d0115..135fa117c5 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -888,12 +888,12 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset, dns_rdataset_current(rdataset, &rdata); if (rdtype == dns_rdatatype_a) { INSIST(rdata.length == 4); - memcpy(&ina.s_addr, rdata.data, 4); + memmove(&ina.s_addr, rdata.data, 4); isc_sockaddr_fromin(&sockaddr, &ina, 0); hookhead = &adbname->v4; } else { INSIST(rdata.length == 16); - memcpy(in6a.s6_addr, rdata.data, 16); + memmove(in6a.s6_addr, rdata.data, 16); isc_sockaddr_fromin6(&sockaddr, &in6a, 0); hookhead = &adbname->v6; } diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 6e4c0fd8a3..3f10a29e26 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -79,7 +79,7 @@ dns_difftuple_create(isc_mem_t *mctx, datap = (unsigned char *)(t + 1); - memcpy(datap, name->ndata, name->length); + memmove(datap, name->ndata, name->length); dns_name_init(&t->name, NULL); dns_name_clone(name, &t->name); t->name.ndata = datap; @@ -87,7 +87,7 @@ dns_difftuple_create(isc_mem_t *mctx, t->ttl = ttl; - memcpy(datap, rdata->data, rdata->length); + memmove(datap, rdata->data, rdata->length); dns_rdata_init(&t->rdata); dns_rdata_clone(rdata, &t->rdata); t->rdata.data = datap; diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index bac8b850dc..0164c4d6ea 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -3679,7 +3679,7 @@ dns_dispatch_importrecv(dns_dispatch_t *disp, isc_event_t *event) { isc_event_free(ISC_EVENT_PTR(&newsevent)); return; } - memcpy(buf, sevent->region.base, sevent->n); + memmove(buf, sevent->region.base, sevent->n); newsevent->region.base = buf; newsevent->region.length = disp->mgr->buffersize; newsevent->n = sevent->n; diff --git a/lib/dns/dns64.c b/lib/dns/dns64.c index 78eff579a2..baeed9f11d 100644 --- a/lib/dns/dns64.c +++ b/lib/dns/dns64.c @@ -83,10 +83,10 @@ dns_dns64_create(isc_mem_t *mctx, isc_netaddr_t *prefix, if (new == NULL) return (ISC_R_NOMEMORY); memset(new->bits, 0, sizeof(new->bits)); - memcpy(new->bits, prefix->type.in6.s6_addr, prefixlen / 8); + memmove(new->bits, prefix->type.in6.s6_addr, prefixlen / 8); if (suffix != NULL) - memcpy(new->bits + nbytes, suffix->type.in6.s6_addr + nbytes, - 16 - nbytes); + memmove(new->bits + nbytes, suffix->type.in6.s6_addr + nbytes, + 16 - nbytes); new->clients = NULL; if (clients != NULL) dns_acl_attach(clients, &new->clients); @@ -155,7 +155,7 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, struct in_addr ina; isc_netaddr_t netaddr; - memcpy(&ina.s_addr, a, 4); + memmove(&ina.s_addr, a, 4); isc_netaddr_fromin(&netaddr, &ina); result = dns_acl_match(&netaddr, NULL, dns64->mapped, env, &match, NULL); @@ -168,7 +168,7 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, nbytes = dns64->prefixlen / 8; INSIST(nbytes <= 12); /* Copy prefix. */ - memcpy(aaaa, dns64->bits, nbytes); + memmove(aaaa, dns64->bits, nbytes); /* Bits 64-71 are zeros. draft-ietf-behave-address-format-04 */ if (nbytes == 8) aaaa[nbytes++] = 0; @@ -180,7 +180,7 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, aaaa[nbytes++] = 0; } /* Copy suffix. */ - memcpy(aaaa + nbytes, dns64->bits + nbytes, 16 - nbytes); + memmove(aaaa + nbytes, dns64->bits + nbytes, 16 - nbytes); return (ISC_R_SUCCESS); } @@ -268,7 +268,7 @@ dns_dns64_aaaaok(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, if (aaaaok == NULL || !aaaaok[i]) { dns_rdataset_current(rdataset, &rdata); - memcpy(&in6.s6_addr, rdata.data, 16); + memmove(&in6.s6_addr, rdata.data, 16); isc_netaddr_fromin6(&netaddr, &in6); result = dns_acl_match(&netaddr, NULL, diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 2a4ab4f6cf..e78f6d70cd 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -295,7 +295,7 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, * Create an envelope for each rdata: . */ isc_buffer_init(&envbuf, data, sizeof(data)); - memcpy(data, r.base, r.length); + memmove(data, r.base, r.length); isc_buffer_add(&envbuf, r.length); isc_buffer_putuint16(&envbuf, set->type); isc_buffer_putuint16(&envbuf, set->rdclass); @@ -501,10 +501,10 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, if (labels - sig.labels > 0) { isc_buffer_putuint8(&envbuf, 1); isc_buffer_putuint8(&envbuf, '*'); - memcpy(data + 2, r.base, r.length); + memmove(data + 2, r.base, r.length); } else - memcpy(data, r.base, r.length); + memmove(data, r.base, r.length); isc_buffer_add(&envbuf, r.length); isc_buffer_putuint16(&envbuf, set->type); isc_buffer_putuint16(&envbuf, set->rdclass); @@ -1040,14 +1040,14 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, /* * Extract the header. */ - memcpy(header, source_r.base, DNS_MESSAGE_HEADERLEN); + memmove(header, source_r.base, DNS_MESSAGE_HEADERLEN); /* * Decrement the additional field counter. */ - memcpy(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); + memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); - memcpy(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); + memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); /* * Digest the modified header. diff --git a/lib/dns/gssapi_link.c b/lib/dns/gssapi_link.c index fab12153cd..1c9f5bc1c2 100644 --- a/lib/dns/gssapi_link.c +++ b/lib/dns/gssapi_link.c @@ -216,7 +216,7 @@ gssapi_verify(dst_context_t *dctx, const isc_region_t *sig) { buf = isc_mem_allocate(dst__memory_pool, sig->length); if (buf == NULL) return (ISC_R_FAILURE); - memcpy(buf, sig->base, sig->length); + memmove(buf, sig->base, sig->length); r.base = buf; r.length = sig->length; REGION_TO_GBUFFER(r, gsig); diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c index 1f1a0ca6bc..e11d08f15a 100644 --- a/lib/dns/hmac_link.c +++ b/lib/dns/hmac_link.c @@ -228,9 +228,8 @@ hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_md5_update(&md5ctx, r.base, r.length); isc_md5_final(&md5ctx, hkey->key); keylen = ISC_MD5_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } @@ -505,9 +504,8 @@ hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_sha1_update(&sha1ctx, r.base, r.length); isc_sha1_final(&sha1ctx, hkey->key); keylen = ISC_SHA1_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } @@ -784,9 +782,8 @@ hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_sha224_update(&sha224ctx, r.base, r.length); isc_sha224_final(hkey->key, &sha224ctx); keylen = ISC_SHA224_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } @@ -1063,9 +1060,8 @@ hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_sha256_update(&sha256ctx, r.base, r.length); isc_sha256_final(hkey->key, &sha256ctx); keylen = ISC_SHA256_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } @@ -1342,9 +1338,8 @@ hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_sha384_update(&sha384ctx, r.base, r.length); isc_sha384_final(hkey->key, &sha384ctx); keylen = ISC_SHA384_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } @@ -1621,9 +1616,8 @@ hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_sha512_update(&sha512ctx, r.base, r.length); isc_sha512_final(hkey->key, &sha512ctx); keylen = ISC_SHA512_DIGESTLENGTH; - } - else { - memcpy(hkey->key, r.base, r.length); + } else { + memmove(hkey->key, r.base, r.length); keylen = r.length; } diff --git a/lib/dns/journal.c b/lib/dns/journal.c index f2c24d7537..3a43365474 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -357,7 +357,7 @@ journal_pos_encode(journal_rawpos_t *raw, journal_pos_t *cooked) { static void journal_header_decode(journal_rawheader_t *raw, journal_header_t *cooked) { INSIST(sizeof(cooked->format) == sizeof(raw->h.format)); - memcpy(cooked->format, raw->h.format, sizeof(cooked->format)); + memmove(cooked->format, raw->h.format, sizeof(cooked->format)); journal_pos_decode(&raw->h.begin, &cooked->begin); journal_pos_decode(&raw->h.end, &cooked->end); cooked->index_size = decode_uint32(raw->h.index_size); @@ -371,7 +371,7 @@ journal_header_encode(journal_header_t *cooked, journal_rawheader_t *raw) { INSIST(sizeof(cooked->format) == sizeof(raw->h.format)); memset(raw->pad, 0, sizeof(raw->pad)); - memcpy(raw->h.format, cooked->format, sizeof(raw->h.format)); + memmove(raw->h.format, cooked->format, sizeof(raw->h.format)); journal_pos_encode(&raw->h.begin, &cooked->begin); journal_pos_encode(&raw->h.end, &cooked->end); encode_uint32(cooked->index_size, raw->h.index_size); @@ -529,7 +529,7 @@ journal_file_create(isc_mem_t *mctx, const char *filename) { return (ISC_R_NOMEMORY); } memset(mem, 0, size); - memcpy(mem, &rawheader, sizeof(rawheader)); + memmove(mem, &rawheader, sizeof(rawheader)); result = isc_stdio_write(mem, 1, (size_t) size, fp, NULL); if (result != ISC_R_SUCCESS) { diff --git a/lib/dns/keydata.c b/lib/dns/keydata.c index 822bd467dc..b4c79b0b41 100644 --- a/lib/dns/keydata.c +++ b/lib/dns/keydata.c @@ -51,7 +51,7 @@ dns_keydata_todnskey(dns_rdata_keydata_t *keydata, dnskey->data = isc_mem_allocate(mctx, dnskey->datalen); if (dnskey->data == NULL) return (ISC_R_NOMEMORY); - memcpy(dnskey->data, keydata->data, dnskey->datalen); + memmove(dnskey->data, keydata->data, dnskey->datalen); } return (ISC_R_SUCCESS); @@ -82,7 +82,7 @@ dns_keydata_fromdnskey(dns_rdata_keydata_t *keydata, keydata->data = isc_mem_allocate(mctx, keydata->datalen); if (keydata->data == NULL) return (ISC_R_NOMEMORY); - memcpy(keydata->data, dnskey->data, keydata->datalen); + memmove(keydata->data, dnskey->data, keydata->datalen); } return (ISC_R_SUCCESS); diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 6086390f2e..d31a238f01 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -246,7 +246,7 @@ indent(unsigned int *current, unsigned int to, int tabwidth, int n = t; if (n > N_TABS) n = N_TABS; - memcpy(p, tabs, n); + memmove(p, tabs, n); p += n; t -= n; } @@ -267,7 +267,7 @@ indent(unsigned int *current, unsigned int to, int tabwidth, int n = t; if (n > N_SPACES) n = N_SPACES; - memcpy(p, spaces, n); + memmove(p, spaces, n); p += n; t -= n; } @@ -357,7 +357,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } @@ -474,7 +474,7 @@ rdataset_totext(dns_rdataset_t *rdataset, isc_buffer_availableregion(target, &r); if (r.length < length) return (ISC_R_NOSPACE); - memcpy(r.base, ttlbuf, length); + memmove(r.base, ttlbuf, length); isc_buffer_add(target, length); column += length; diff --git a/lib/dns/message.c b/lib/dns/message.c index 9af0430aca..f7fa522e9c 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -1675,8 +1675,8 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, msg->saved.base = isc_mem_get(msg->mctx, msg->saved.length); if (msg->saved.base == NULL) return (ISC_R_NOMEMORY); - memcpy(msg->saved.base, isc_buffer_base(&origsource), - msg->saved.length); + memmove(msg->saved.base, isc_buffer_base(&origsource), + msg->saved.length); msg->free_saved = 1; } @@ -1748,7 +1748,7 @@ dns_message_renderchangebuffer(dns_message_t *msg, isc_buffer_t *buffer) { * Copy the contents from the old to the new buffer. */ isc_buffer_add(buffer, r.length); - memcpy(rn.base, r.base, r.length); + memmove(rn.base, r.base, r.length); msg->buffer = buffer; diff --git a/lib/dns/name.c b/lib/dns/name.c index 26e404f49a..1840ecbb47 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1011,8 +1011,8 @@ dns_name_clone(const dns_name_t *source, dns_name_t *target) { DNS_NAMEATTR_DYNOFFSETS); if (target->offsets != NULL && source->labels > 0) { if (source->offsets != NULL) - memcpy(target->offsets, source->offsets, - source->labels); + memmove(target->offsets, source->offsets, + source->labels); else set_offsets(target, target->offsets, NULL); } @@ -1041,7 +1041,7 @@ dns_name_fromregion(dns_name_t *name, const isc_region_t *r) { len = (r->length < r2.length) ? r->length : r2.length; if (len > DNS_NAME_MAXWIRE) len = DNS_NAME_MAXWIRE; - memcpy(r2.base, r->base, len); + memmove(r2.base, r->base, len); name->ndata = r2.base; name->length = len; } else { @@ -2025,8 +2025,8 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx, if (gf) { if (target->length - target->used < gp.length) return (ISC_R_NOSPACE); - (void)memcpy((unsigned char *)target->base + target->used, - gp.ndata, (size_t)gp.length); + (void)memmove((unsigned char *)target->base + target->used, + gp.ndata, (size_t)gp.length); isc_buffer_add(target, gp.length); go |= 0xc000; if (target->length - target->used < 2) @@ -2037,8 +2037,8 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx, } else { if (target->length - target->used < name->length) return (ISC_R_NOSPACE); - (void)memcpy((unsigned char *)target->base + target->used, - name->ndata, (size_t)name->length); + (void)memmove((unsigned char *)target->base + target->used, + name->ndata, (size_t)name->length); isc_buffer_add(target, name->length); dns_compress_add(cctx, name, name, offset); } @@ -2122,8 +2122,8 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, memmove(ndata + prefix_length, suffix->ndata, suffix->length); else - memcpy(ndata + prefix_length, suffix->ndata, - suffix->length); + memmove(ndata + prefix_length, suffix->ndata, + suffix->length); } /* @@ -2132,7 +2132,7 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, * copy anything. */ if (copy_prefix && (prefix != name || prefix->buffer != target)) - memcpy(ndata, prefix->ndata, prefix_length); + memmove(ndata, prefix->ndata, prefix_length); name->ndata = ndata; name->labels = labels; @@ -2206,7 +2206,7 @@ dns_name_dup(const dns_name_t *source, isc_mem_t *mctx, if (target->ndata == NULL) return (ISC_R_NOMEMORY); - memcpy(target->ndata, source->ndata, source->length); + memmove(target->ndata, source->ndata, source->length); target->length = source->length; target->labels = source->labels; @@ -2215,8 +2215,8 @@ dns_name_dup(const dns_name_t *source, isc_mem_t *mctx, target->attributes |= DNS_NAMEATTR_ABSOLUTE; if (target->offsets != NULL) { if (source->offsets != NULL) - memcpy(target->offsets, source->offsets, - source->labels); + memmove(target->offsets, source->offsets, + source->labels); else set_offsets(target, target->offsets, NULL); } @@ -2248,7 +2248,7 @@ dns_name_dupwithoffsets(dns_name_t *source, isc_mem_t *mctx, if (target->ndata == NULL) return (ISC_R_NOMEMORY); - memcpy(target->ndata, source->ndata, source->length); + memmove(target->ndata, source->ndata, source->length); target->length = source->length; target->labels = source->labels; @@ -2258,7 +2258,7 @@ dns_name_dupwithoffsets(dns_name_t *source, isc_mem_t *mctx, target->attributes |= DNS_NAMEATTR_ABSOLUTE; target->offsets = target->ndata + source->length; if (source->offsets != NULL) - memcpy(target->offsets, source->offsets, source->labels); + memmove(target->offsets, source->offsets, source->labels); else set_offsets(target, target->offsets, NULL); @@ -2438,7 +2438,7 @@ dns_name_tostring(dns_name_t *name, char **target, isc_mem_t *mctx) { isc_buffer_usedregion(&buf, ®); p = isc_mem_allocate(mctx, reg.length + 1); - memcpy(p, (char *) reg.base, (int) reg.length); + memmove(p, (char *) reg.base, (int) reg.length); p[reg.length] = '\0'; *target = p; @@ -2514,7 +2514,7 @@ dns_name_copy(dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) { ndata = (unsigned char *)target->base + target->used; dest->ndata = target->base; - memcpy(ndata, source->ndata, source->length); + memmove(ndata, source->ndata, source->length); dest->ndata = ndata; dest->labels = source->labels; @@ -2526,7 +2526,7 @@ dns_name_copy(dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) { if (dest->labels > 0 && dest->offsets != NULL) { if (source->offsets != NULL) - memcpy(dest->offsets, source->offsets, source->labels); + memmove(dest->offsets, source->offsets, source->labels); else set_offsets(dest, dest->offsets, NULL); } diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 8821311f47..f02bda87c7 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -115,7 +115,7 @@ dns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version, memset(buffer, 0, DNS_NSEC_BUFFERSIZE); dns_name_toregion(target, &r); - memcpy(buffer, r.base, r.length); + memmove(buffer, r.base, r.length); r.base = buffer; /* * Use the end of the space for a raw bitmap leaving enough diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index ef2c584211..ab0e0c0faa 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -98,11 +98,11 @@ dns_nsec3_buildrdata(dns_db_t *db, dns_dbversion_t *version, *p++ = iterations; *p++ = (unsigned char)salt_length; - memcpy(p, salt, salt_length); + memmove(p, salt, salt_length); p += salt_length; *p++ = (unsigned char)hash_length; - memcpy(p, nexthash, hash_length); + memmove(p, nexthash, hash_length); p += hash_length; r.length = (unsigned int)(p - buffer); @@ -591,7 +591,7 @@ dns_nsec3_addnsec3(dns_db_t *db, dns_dbversion_t *version, flags = nsec3.flags; next_length = nsec3.next_length; INSIST(next_length <= sizeof(nexthash)); - memcpy(nexthash, nsec3.next, next_length); + memmove(nexthash, nsec3.next, next_length); dns_rdataset_disassociate(&rdataset); /* * If the NSEC3 is not for a unsecure delegation then @@ -688,7 +688,7 @@ dns_nsec3_addnsec3(dns_db_t *db, dns_dbversion_t *version, rdataset.ttl, &rdata, &tuple)); CHECK(do_one_tuple(&tuple, db, version, diff)); INSIST(old_length <= sizeof(nexthash)); - memcpy(nexthash, old_next, old_length); + memmove(nexthash, old_next, old_length); if (!CREATE(nsec3param->flags)) flags = nsec3.flags; dns_rdata_reset(&rdata); @@ -809,7 +809,7 @@ dns_nsec3_addnsec3(dns_db_t *db, dns_dbversion_t *version, &tuple)); CHECK(do_one_tuple(&tuple, db, version, diff)); INSIST(old_length <= sizeof(nexthash)); - memcpy(nexthash, old_next, old_length); + memmove(nexthash, old_next, old_length); if (!CREATE(nsec3param->flags)) flags = nsec3.flags; dns_rdata_reset(&rdata); @@ -958,7 +958,7 @@ dns_nsec3param_toprivate(dns_rdata_t *src, dns_rdata_t *target, REQUIRE(DNS_RDATA_INITIALIZED(target)); - memcpy(buf + 1, src->data, src->length); + memmove(buf + 1, src->data, src->length); buf[0] = 0; target->data = buf; target->length = src->length + 1; @@ -1094,7 +1094,7 @@ dns_nsec3param_deletechains(dns_db_t *db, dns_dbversion_t *ver, dns_rdata_reset(&rdata); dns_rdataset_current(&rdataset, &rdata); INSIST(rdata.length <= sizeof(buf)); - memcpy(buf, rdata.data, rdata.length); + memmove(buf, rdata.data, rdata.length); /* * Private NSEC3 record length >= 6. @@ -1357,7 +1357,7 @@ dns_nsec3_delnsec3(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name, if (result == ISC_R_SUCCESS) { next_length = nsec3.next_length; INSIST(next_length <= sizeof(nexthash)); - memcpy(nexthash, nsec3.next, next_length); + memmove(nexthash, nsec3.next, next_length); } dns_rdataset_disassociate(&rdataset); if (result == ISC_R_NOMORE) @@ -1460,7 +1460,7 @@ dns_nsec3_delnsec3(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name, if (result == ISC_R_SUCCESS) { next_length = nsec3.next_length; INSIST(next_length <= sizeof(nexthash)); - memcpy(nexthash, nsec3.next, next_length); + memmove(nexthash, nsec3.next, next_length); } dns_rdataset_disassociate(&rdataset); if (result == ISC_R_NOMORE) diff --git a/lib/dns/opensslecdsa_link.c b/lib/dns/opensslecdsa_link.c index 2a76c8524d..240e4d481a 100644 --- a/lib/dns/opensslecdsa_link.c +++ b/lib/dns/opensslecdsa_link.c @@ -371,7 +371,7 @@ opensslecdsa_todns(const dst_key_t *key, isc_buffer_t *data) { cp = buf; if (!i2o_ECPublicKey(eckey, &cp)) DST_RET (dst__openssl_toresult(ISC_R_FAILURE)); - memcpy(r.base, buf + 1, len); + memmove(r.base, buf + 1, len); isc_buffer_add(data, len); ret = ISC_R_SUCCESS; @@ -414,7 +414,7 @@ opensslecdsa_fromdns(dst_key_t *key, isc_buffer_t *data) { return (dst__openssl_toresult(DST_R_OPENSSLFAILURE)); buf[0] = POINT_CONVERSION_UNCOMPRESSED; - memcpy(buf + 1, r.base, len); + memmove(buf + 1, r.base, len); cp = buf; if (o2i_ECPublicKey(&eckey, (const unsigned char **) &cp, diff --git a/lib/dns/opensslgost_link.c b/lib/dns/opensslgost_link.c index 74d8646477..bd52152e0e 100644 --- a/lib/dns/opensslgost_link.c +++ b/lib/dns/opensslgost_link.c @@ -253,7 +253,7 @@ opensslgost_todns(const dst_key_t *key, isc_buffer_t *data) { len = i2d_PUBKEY(pkey, &p); INSIST(len == sizeof(der)); INSIST(memcmp(gost_prefix, der, 37) == 0); - memcpy(r.base, der + 37, 64); + memmove(r.base, der + 37, 64); isc_buffer_add(data, 64); return (ISC_R_SUCCESS); @@ -272,8 +272,8 @@ opensslgost_fromdns(dst_key_t *key, isc_buffer_t *data) { if (r.length != 64) return (DST_R_INVALIDPUBLICKEY); - memcpy(der, gost_prefix, 37); - memcpy(der + 37, r.base, 64); + memmove(der, gost_prefix, 37); + memmove(der + 37, r.base, 64); isc_buffer_forward(data, 64); p = der; diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index d3454a5ea4..f52f932671 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -481,7 +481,7 @@ opensslrsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { INSIST(prefixlen + digestlen <= sizeof(digest)); memmove(digest + prefixlen, digest, digestlen); - memcpy(digest, prefix, prefixlen); + memmove(digest, prefix, prefixlen); status = RSA_private_encrypt(digestlen + prefixlen, digest, r.base, rsa, RSA_PKCS1_PADDING); diff --git a/lib/dns/portlist.c b/lib/dns/portlist.c index 5bc89f4829..ee24abd584 100644 --- a/lib/dns/portlist.c +++ b/lib/dns/portlist.c @@ -164,8 +164,8 @@ dns_portlist_add(dns_portlist_t *portlist, int af, in_port_t port) { goto unlock; } if (portlist->list != NULL) { - memcpy(el, portlist->list, - portlist->allocated * sizeof(*el)); + memmove(el, portlist->list, + portlist->allocated * sizeof(*el)); isc_mem_put(portlist->mctx, portlist->list, portlist->allocated * sizeof(*el)); } diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 9ce5acaa52..5eb29f9995 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -429,8 +429,8 @@ write_header(FILE *file, dns_rbt_t *rbt, isc_uint64_t first_node_offset, } memset(&header, 0, sizeof(file_header_t)); - memcpy(header.version1, FILE_VERSION, sizeof(header.version1)); - memcpy(header.version2, FILE_VERSION, sizeof(header.version2)); + memmove(header.version1, FILE_VERSION, sizeof(header.version1)); + memmove(header.version2, FILE_VERSION, sizeof(header.version2)); header.first_node_offset = first_node_offset; header.ptrsize = (isc_uint32_t) sizeof(void *); header.bigendian = (1 == htonl(1)) ? 1 : 0; @@ -700,7 +700,7 @@ treefix(dns_rbt_t *rbt, void *base, size_t filesize, dns_rbtnode_t *n, } /* memorize header contents prior to fixup */ - memcpy(&header, n, sizeof(header)); + memmove(&header, n, sizeof(header)); if (n->left_is_relative) { CONFIRM(n->left <= (dns_rbtnode_t *) nodemax); @@ -2141,8 +2141,8 @@ create_node(isc_mem_t *mctx, dns_name_t *name, dns_rbtnode_t **nodep) { OLDOFFSETLEN(node) = OFFSETLEN(node) = labels; ATTRS(node) = name->attributes; - memcpy(NAME(node), region.base, region.length); - memcpy(OFFSETS(node), name->offsets, labels); + memmove(NAME(node), region.base, region.length); + memmove(OFFSETS(node), name->offsets, labels); #if DNS_RBT_USEMAGIC node->magic = DNS_RBTNODE_MAGIC; @@ -2506,7 +2506,7 @@ deletefromlevel(dns_rbtnode_t *delete, dns_rbtnode_t **rootp) { * information, which will be needed when linking up * delete to the successor's old location. */ - memcpy(tmp, successor, sizeof(dns_rbtnode_t)); + memmove(tmp, successor, sizeof(dns_rbtnode_t)); if (IS_ROOT(delete)) { *rootp = successor; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 300f504ffa..62233391eb 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -1243,8 +1243,8 @@ newversion(dns_db_t *db, dns_dbversion_t **versionp) { version->hash = rbtdb->current_version->hash; version->salt_length = rbtdb->current_version->salt_length; - memcpy(version->salt, rbtdb->current_version->salt, - version->salt_length); + memmove(version->salt, rbtdb->current_version->salt, + version->salt_length); } else { version->flags = 0; version->iterations = 0; @@ -2284,8 +2284,8 @@ setnsec3parameters(dns_db_t *db, rbtdb_version_t *version) { if (nsec3param.flags != 0) continue; - memcpy(version->salt, nsec3param.salt, - nsec3param.salt_length); + memmove(version->salt, nsec3param.salt, + nsec3param.salt_length); version->hash = nsec3param.hash; version->salt_length = nsec3param.salt_length; version->iterations = nsec3param.iterations; @@ -7314,7 +7314,7 @@ rbt_datawriter(FILE *rbtfile, unsigned char *data, void *arg, sizeof(rdatasetheader_t)); p = (unsigned char *) header; - memcpy(&newheader, p, sizeof(rdatasetheader_t)); + memmove(&newheader, p, sizeof(rdatasetheader_t)); newheader.down = NULL; newheader.next = NULL; off = where; @@ -7401,8 +7401,8 @@ rbtdb_write_header(FILE *rbtfile, off_t tree_location, off_t nsec_location, } memset(&header, 0, sizeof(rbtdb_file_header_t)); - memcpy(header.version1, FILE_VERSION, sizeof(header.version1)); - memcpy(header.version2, FILE_VERSION, sizeof(header.version2)); + memmove(header.version1, FILE_VERSION, sizeof(header.version1)); + memmove(header.version2, FILE_VERSION, sizeof(header.version2)); header.ptrsize = (isc_uint32_t) sizeof(void *); header.bigendian = (1 == htonl(1)) ? 1 : 0; header.tree = (isc_uint64_t) tree_location; @@ -7627,7 +7627,8 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash, *hash = rbtversion->hash; if (salt != NULL && salt_length != NULL) { REQUIRE(*salt_length >= rbtversion->salt_length); - memcpy(salt, rbtversion->salt, rbtversion->salt_length); + memmove(salt, rbtversion->salt, + rbtversion->salt_length); } if (salt_length != NULL) *salt_length = rbtversion->salt_length; diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c index c4e70e6e70..8c45b56c49 100644 --- a/lib/dns/rcode.c +++ b/lib/dns/rcode.c @@ -206,7 +206,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index f71c80a8d5..0d92878fb0 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -282,7 +282,7 @@ locator_pton(const char *src, unsigned char *dst) { } if (tp != endp) return (0); - memcpy(dst, tmp, NS_LOCATORSZ); + memmove(dst, tmp, NS_LOCATORSZ); return (1); } @@ -323,7 +323,7 @@ mem_maybedup(isc_mem_t *mctx, void *source, size_t length) { return (source); new = isc_mem_allocate(mctx, length); if (new != NULL) - memcpy(new, source, length); + memmove(new, source, length); return (new); } @@ -590,7 +590,7 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_availableregion(target, &tr); if (tr.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(tr.base, rdata->data, rdata->length); + memmove(tr.base, rdata->data, rdata->length); isc_buffer_add(target, rdata->length); return (ISC_R_SUCCESS); } @@ -1269,7 +1269,7 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { return (ISC_R_NOSPACE); if (tregion.base != sregion.base) - memcpy(tregion.base, sregion.base, n); + memmove(tregion.base, sregion.base, n); isc_buffer_forward(source, n); isc_buffer_add(target, n); return (ISC_R_SUCCESS); @@ -1419,7 +1419,7 @@ multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { return (ISC_R_NOSPACE); if (tregion.base != sregion.base) - memcpy(tregion.base, sregion.base, n); + memmove(tregion.base, sregion.base, n); isc_buffer_forward(source, n); isc_buffer_add(target, n); isc_buffer_activeregion(source, &sregion); @@ -1470,7 +1470,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } @@ -1596,7 +1596,7 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { if (length > tr.length) return (ISC_R_NOSPACE); if (tr.base != base) - memcpy(tr.base, base, length); + memmove(tr.base, base, length); isc_buffer_add(target, length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/ch_3/a_1.c b/lib/dns/rdata/ch_3/a_1.c index e3f9810651..5bccc199da 100644 --- a/lib/dns/rdata/ch_3/a_1.c +++ b/lib/dns/rdata/ch_3/a_1.c @@ -117,7 +117,7 @@ fromwire_ch_a(ARGS_FROMWIRE) { if (tregion.length < 2) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 2); + memmove(tregion.base, sregion.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); @@ -149,7 +149,7 @@ towire_ch_a(ARGS_TOWIRE) { if (tregion.length < 2) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 2); + memmove(tregion.base, sregion.base, 2); isc_buffer_add(target, 2); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index 279f86c677..9e951d033d 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -113,7 +113,7 @@ fromwire_afsdb(ARGS_FROMWIRE) { return (ISC_R_NOSPACE); if (sr.length < 2) return (ISC_R_UNEXPECTEDEND); - memcpy(tr.base, sr.base, 2); + memmove(tr.base, sr.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); return (dns_name_fromwire(&name, source, dctx, options, target)); @@ -134,7 +134,7 @@ towire_afsdb(ARGS_TOWIRE) { dns_rdata_toregion(rdata, &sr); if (tr.length < 2) return (ISC_R_NOSPACE); - memcpy(tr.base, sr.base, 2); + memmove(tr.base, sr.base, 2); isc_region_consume(&sr, 2); isc_buffer_add(target, 2); diff --git a/lib/dns/rdata/generic/eui48_108.c b/lib/dns/rdata/generic/eui48_108.c index 3e52fec0ed..898ffc71db 100644 --- a/lib/dns/rdata/generic/eui48_108.c +++ b/lib/dns/rdata/generic/eui48_108.c @@ -142,7 +142,7 @@ tostruct_eui48(ARGS_TOSTRUCT) { eui48->common.rdtype = rdata->type; ISC_LINK_INIT(&eui48->common, link); - memcpy(eui48->eui48, rdata->data, rdata->length); + memmove(eui48->eui48, rdata->data, rdata->length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/eui64_109.c b/lib/dns/rdata/generic/eui64_109.c index 245994fdf5..17eb7e820d 100644 --- a/lib/dns/rdata/generic/eui64_109.c +++ b/lib/dns/rdata/generic/eui64_109.c @@ -147,7 +147,7 @@ tostruct_eui64(ARGS_TOSTRUCT) { eui64->common.rdtype = rdata->type; ISC_LINK_INIT(&eui64->common, link); - memcpy(eui64->eui64, rdata->data, rdata->length); + memmove(eui64->eui64, rdata->data, rdata->length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/ipseckey_45.c b/lib/dns/rdata/generic/ipseckey_45.c index 1d2508c42e..43d6318ce1 100644 --- a/lib/dns/rdata/generic/ipseckey_45.c +++ b/lib/dns/rdata/generic/ipseckey_45.c @@ -87,7 +87,7 @@ fromtext_ipseckey(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 4) return (ISC_R_NOSPACE); - memcpy(region.base, &addr, 4); + memmove(region.base, &addr, 4); isc_buffer_add(target, 4); break; @@ -97,7 +97,7 @@ fromtext_ipseckey(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 16) return (ISC_R_NOSPACE); - memcpy(region.base, addr6, 16); + memmove(region.base, addr6, 16); isc_buffer_add(target, 16); break; @@ -364,7 +364,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) { break; case 2: - memcpy(ipseckey->in6_addr.s6_addr, region.base, 16); + memmove(ipseckey->in6_addr.s6_addr, region.base, 16); isc_region_consume(®ion, 16); break; diff --git a/lib/dns/rdata/generic/l32_105.c b/lib/dns/rdata/generic/l32_105.c index 763ddb953f..9ef962bd42 100644 --- a/lib/dns/rdata/generic/l32_105.c +++ b/lib/dns/rdata/generic/l32_105.c @@ -51,7 +51,7 @@ fromtext_l32(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 4) return (ISC_R_NOSPACE); - memcpy(region.base, &addr, 4); + memmove(region.base, &addr, 4); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/l64_106.c b/lib/dns/rdata/generic/l64_106.c index ff20663355..3f611faca8 100644 --- a/lib/dns/rdata/generic/l64_106.c +++ b/lib/dns/rdata/generic/l64_106.c @@ -155,7 +155,7 @@ tostruct_l64(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, ®ion); l64->pref = uint16_fromregion(®ion); - memcpy(l64->l64, region.base, region.length); + memmove(l64->l64, region.base, region.length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/nid_104.c b/lib/dns/rdata/generic/nid_104.c index c96b0bf9c9..72479113e6 100644 --- a/lib/dns/rdata/generic/nid_104.c +++ b/lib/dns/rdata/generic/nid_104.c @@ -155,7 +155,7 @@ tostruct_nid(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, ®ion); nid->pref = uint16_fromregion(®ion); - memcpy(nid->nid, region.base, region.length); + memmove(nid->nid, region.base, region.length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index b64a6234ae..31adcf7922 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -162,7 +162,7 @@ fromwire_opt(ARGS_FROMWIRE) { isc_buffer_availableregion(target, &tregion); if (tregion.length < total) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, total); + memmove(tregion.base, sregion.base, total); isc_buffer_forward(source, total); isc_buffer_add(target, total); diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index 8f71a2afc8..e18ff531e7 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -109,7 +109,7 @@ fromwire_rt(ARGS_FROMWIRE) { return (ISC_R_NOSPACE); if (sregion.length < 2) return (ISC_R_UNEXPECTEDEND); - memcpy(tregion.base, sregion.base, 2); + memmove(tregion.base, sregion.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); return (dns_name_fromwire(&name, source, dctx, options, target)); @@ -130,7 +130,7 @@ towire_rt(ARGS_TOWIRE) { dns_rdata_toregion(rdata, ®ion); if (tr.length < 2) return (ISC_R_NOSPACE); - memcpy(tr.base, region.base, 2); + memmove(tr.base, region.base, 2); isc_region_consume(®ion, 2); isc_buffer_add(target, 2); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index ac0a38f7c1..6eb05aed03 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -186,7 +186,7 @@ fromwire_soa(ARGS_FROMWIRE) { if (tregion.length < 20) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 20); + memmove(tregion.base, sregion.base, 20); isc_buffer_forward(source, 20); isc_buffer_add(target, 20); @@ -224,7 +224,7 @@ towire_soa(ARGS_TOWIRE) { if (tregion.length < 20) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 20); + memmove(tregion.base, sregion.base, 20); isc_buffer_add(target, 20); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/spf_99.c b/lib/dns/rdata/generic/spf_99.c index 492e315d45..ade94373bf 100644 --- a/lib/dns/rdata/generic/spf_99.c +++ b/lib/dns/rdata/generic/spf_99.c @@ -103,7 +103,7 @@ towire_spf(ARGS_TOWIRE) { if (region.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(region.base, rdata->data, rdata->length); + memmove(region.base, rdata->data, rdata->length); isc_buffer_add(target, rdata->length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index e1bce6a0de..8ac629b06f 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -110,7 +110,7 @@ towire_txt(ARGS_TOWIRE) { if (region.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(region.base, rdata->data, rdata->length); + memmove(region.base, rdata->data, rdata->length); isc_buffer_add(target, rdata->length); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index 50ae25d52b..db9578fce6 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -48,7 +48,7 @@ fromtext_hs_a(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 4) return (ISC_R_NOSPACE); - memcpy(region.base, &addr, 4); + memmove(region.base, &addr, 4); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); } @@ -87,7 +87,7 @@ fromwire_hs_a(ARGS_FROMWIRE) { if (tregion.length < 4) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 4); + memmove(tregion.base, sregion.base, 4); isc_buffer_forward(source, 4); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); @@ -106,7 +106,7 @@ towire_hs_a(ARGS_TOWIRE) { isc_buffer_availableregion(target, ®ion); if (region.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(region.base, rdata->data, rdata->length); + memmove(region.base, rdata->data, rdata->length); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index 8619f8a213..41554d3eef 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -122,7 +122,7 @@ totext_in_a6(ARGS_TOTEXT) { if (prefixlen != 128) { octets = prefixlen/8; memset(addr, 0, sizeof(addr)); - memcpy(&addr[octets], sr.base, 16 - octets); + memmove(&addr[octets], sr.base, 16 - octets); mask = 0xff >> (prefixlen % 8); addr[octets] &= mask; ar.base = addr; @@ -347,7 +347,7 @@ tostruct_in_a6(ARGS_TOSTRUCT) { if (a6->prefixlen != 128) { octets = 16 - a6->prefixlen / 8; INSIST(r.length >= octets); - memcpy(a6->in6_addr.s6_addr + 16 - octets, r.base, octets); + memmove(a6->in6_addr.s6_addr + 16 - octets, r.base, octets); isc_region_consume(&r, octets); } diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 902932e025..7ff210fd74 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -50,7 +50,7 @@ fromtext_in_a(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 4) return (ISC_R_NOSPACE); - memcpy(region.base, &addr, 4); + memmove(region.base, &addr, 4); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); } @@ -89,7 +89,7 @@ fromwire_in_a(ARGS_FROMWIRE) { if (tregion.length < 4) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 4); + memmove(tregion.base, sregion.base, 4); isc_buffer_forward(source, 4); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); @@ -108,7 +108,7 @@ towire_in_a(ARGS_TOWIRE) { isc_buffer_availableregion(target, ®ion); if (region.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(region.base, rdata->data, rdata->length); + memmove(region.base, rdata->data, rdata->length); isc_buffer_add(target, 4); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index 5aa59b2ccc..2a755f2208 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -51,7 +51,7 @@ fromtext_in_aaaa(ARGS_FROMTEXT) { isc_buffer_availableregion(target, ®ion); if (region.length < 16) return (ISC_R_NOSPACE); - memcpy(region.base, addr, 16); + memmove(region.base, addr, 16); isc_buffer_add(target, 16); return (ISC_R_SUCCESS); } @@ -90,7 +90,7 @@ fromwire_in_aaaa(ARGS_FROMWIRE) { if (tregion.length < 16) return (ISC_R_NOSPACE); - memcpy(tregion.base, sregion.base, 16); + memmove(tregion.base, sregion.base, 16); isc_buffer_forward(source, 16); isc_buffer_add(target, 16); return (ISC_R_SUCCESS); @@ -109,7 +109,7 @@ towire_in_aaaa(ARGS_TOWIRE) { isc_buffer_availableregion(target, ®ion); if (region.length < rdata->length) return (ISC_R_NOSPACE); - memcpy(region.base, rdata->data, rdata->length); + memmove(region.base, rdata->data, rdata->length); isc_buffer_add(target, 16); return (ISC_R_SUCCESS); } @@ -165,7 +165,7 @@ tostruct_in_aaaa(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); INSIST(r.length == 16); - memcpy(aaaa->in6_addr.s6_addr, r.base, 16); + memmove(aaaa->in6_addr.s6_addr, r.base, 16); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/in_1/apl_42.c b/lib/dns/rdata/in_1/apl_42.c index eb927b9219..8515274e49 100644 --- a/lib/dns/rdata/in_1/apl_42.c +++ b/lib/dns/rdata/in_1/apl_42.c @@ -148,7 +148,7 @@ totext_in_apl(ARGS_TOTEXT) { INSIST(len <= 4); INSIST(prefix <= 32); memset(buf, 0, sizeof(buf)); - memcpy(buf, sr.base, len); + memmove(buf, sr.base, len); RETERR(inet_totext(AF_INET, &ir, target)); break; @@ -156,7 +156,7 @@ totext_in_apl(ARGS_TOTEXT) { INSIST(len <= 16); INSIST(prefix <= 128); memset(buf, 0, sizeof(buf)); - memcpy(buf, sr.base, len); + memmove(buf, sr.base, len); RETERR(inet_totext(AF_INET6, &ir, target)); break; diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 12cd4a1300..1d73014c0e 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -98,7 +98,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { RETTOK(DNS_R_BADDOTTEDQUAD); if (region.length < 4) return (ISC_R_NOSPACE); - memcpy(region.base, &addr, 4); + memmove(region.base, &addr, 4); isc_buffer_add(target, 4); /* @@ -222,7 +222,7 @@ fromwire_in_wks(ARGS_FROMWIRE) { if (tr.length < sr.length) return (ISC_R_NOSPACE); - memcpy(tr.base, sr.base, sr.length); + memmove(tr.base, sr.base, sr.length); isc_buffer_add(target, sr.length); isc_buffer_forward(source, sr.length); diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index c53c24c23e..fd7a65aa4c 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -318,7 +318,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, *rawbuf++ |= (x[i].rdata.flags & DNS_RDATA_OFFLINE) ? DNS_RDATASLAB_OFFLINE : 0; } - memcpy(rawbuf, x[i].rdata.data, x[i].rdata.length); + memmove(rawbuf, x[i].rdata.data, x[i].rdata.length); rawbuf += x[i].rdata.length; } @@ -711,7 +711,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, tstart = isc_mem_get(mctx, tlength); if (tstart == NULL) return (ISC_R_NOMEMORY); - memcpy(tstart, nslab, reservelen); + memmove(tstart, nslab, reservelen); tcurrent = tstart + reservelen; #if DNS_RDATASET_FIXED offsetbase = tcurrent; @@ -790,7 +790,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, #if DNS_RDATASET_FIXED tcurrent += 2; /* fill in later */ #endif - memcpy(tcurrent, data, length); + memmove(tcurrent, data, length); tcurrent += length; oadded++; if (oadded < ocount) { @@ -817,7 +817,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, #if DNS_RDATASET_FIXED tcurrent += 2; /* fill in later */ #endif - memcpy(tcurrent, data, length); + memmove(tcurrent, data, length); tcurrent += length; nadded++; if (nadded < ncount) { @@ -949,7 +949,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab, tstart = isc_mem_get(mctx, tlength); if (tstart == NULL) return (ISC_R_NOMEMORY); - memcpy(tstart, mslab, reservelen); + memmove(tstart, mslab, reservelen); tcurrent = tstart + reservelen; #if DNS_RDATASET_FIXED offsetbase = tcurrent; @@ -1005,7 +1005,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab, #if DNS_RDATASET_FIXED offsettable[order] = tcurrent - offsetbase; #endif - memcpy(tcurrent, mrdatabegin, length); + memmove(tcurrent, mrdatabegin, length); tcurrent += length; } dns_rdata_reset(&mrdata); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 6df7e561a4..4d71c9b876 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -5579,11 +5579,11 @@ is_answeraddress_allowed(dns_view_t *view, dns_name_t *name, dns_rdataset_current(rdataset, &rdata); if (rdataset->type == dns_rdatatype_a) { INSIST(rdata.length == sizeof(ina.s_addr)); - memcpy(&ina.s_addr, rdata.data, sizeof(ina.s_addr)); + memmove(&ina.s_addr, rdata.data, sizeof(ina.s_addr)); isc_netaddr_fromin(&netaddr, &ina); } else { INSIST(rdata.length == sizeof(in6a.s6_addr)); - memcpy(in6a.s6_addr, rdata.data, sizeof(in6a.s6_addr)); + memmove(in6a.s6_addr, rdata.data, sizeof(in6a.s6_addr)); isc_netaddr_fromin6(&netaddr, &in6a); } @@ -9065,7 +9065,7 @@ dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name, } memset(new, 0, len); if (algorithms != NULL) - memcpy(new, algorithms, *algorithms); + memmove(new, algorithms, *algorithms); new[len-1] |= mask; *new = len; node->data = new; @@ -9179,7 +9179,7 @@ dns_resolver_disable_ds_digest(dns_resolver_t *resolver, dns_name_t *name, } memset(new, 0, len); if (digests != NULL) - memcpy(new, digests, *digests); + memmove(new, digests, *digests); new[len-1] |= mask; *new = len; node->data = new; diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 9bdf33072e..283a1409cb 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1431,8 +1431,8 @@ dns_rpz_beginload(dns_rpz_zones_t **load_rpzsp, load_rpzs = *load_rpzsp; load_rpzs->p.num_zones = rpzs->p.num_zones; load_rpzs->total_triggers = rpzs->total_triggers; - memcpy(load_rpzs->triggers, rpzs->triggers, - sizeof(load_rpzs->triggers)); + memmove(load_rpzs->triggers, rpzs->triggers, + sizeof(load_rpzs->triggers)); memset(&load_rpzs->triggers[rpz_num], 0, sizeof(load_rpzs->triggers[rpz_num])); load_rpzs->zones[rpz_num] = rpz; @@ -1457,7 +1457,7 @@ fix_triggers(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num) { rpzs->have.type |= zbit; \ } - memcpy(&old_totals, &rpzs->total_triggers, sizeof(old_totals)); + memmove(&old_totals, &rpzs->total_triggers, sizeof(old_totals)); memset(&rpzs->total_triggers, 0, sizeof(rpzs->total_triggers)); for (n = 0; n < rpzs->p.num_zones; ++n) { zbit = DNS_RPZ_ZBIT(n); @@ -1946,7 +1946,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, * one could cast netaddr->type.in6 to dns_rpz_cidr_key_t *, * but some people object. */ - memcpy(src_ip6.w, &netaddr->type.in6, sizeof(src_ip6.w)); + memmove(src_ip6.w, &netaddr->type.in6, sizeof(src_ip6.w)); for (i = 0; i < 4; i++) { tgt_ip.w[i] = ntohl(src_ip6.w[i]); } diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index d2193942fa..db18991046 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -439,8 +439,8 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key, break; case AF_INET6: key->s.ipv6 = ISC_TRUE; - memcpy(key->s.ip, &client_addr->type.sin6.sin6_addr, - sizeof(key->s.ip)); + memmove(key->s.ip, &client_addr->type.sin6.sin6_addr, + sizeof(key->s.ip)); for (i = 0; i < DNS_RRL_MAX_PREFIX/32; ++i) key->s.ip[i] &= rrl->ipv6_mask[i]; break; @@ -776,7 +776,7 @@ add_log_str(isc_buffer_t *lb, const char *str, unsigned int str_len) { return; str_len = region.length; } - memcpy(region.base, str, str_len); + memmove(region.base, str, str_len); isc_buffer_add(lb, str_len); } @@ -863,7 +863,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, snprintf(strbuf, sizeof(strbuf), "/%d", rrl->ipv6_prefixlen); cidr.family = AF_INET6; memset(&cidr.type.in6, 0, sizeof(cidr.type.in6)); - memcpy(&cidr.type.in6, e->key.s.ip, sizeof(e->key.s.ip)); + memmove(&cidr.type.in6, e->key.s.ip, sizeof(e->key.s.ip)); } else { snprintf(strbuf, sizeof(strbuf), "/%d", rrl->ipv4_prefixlen); cidr.family = AF_INET; diff --git a/lib/dns/spnego.c b/lib/dns/spnego.c index b6c9e2a3e0..008ee817e8 100644 --- a/lib/dns/spnego.c +++ b/lib/dns/spnego.c @@ -463,7 +463,7 @@ code_NegTokenArg(OM_uint32 * minor_status, free(buf); return (GSS_S_FAILURE); } - memcpy(*outbuf, buf + buf_size - buf_len, buf_len); + memmove(*outbuf, buf + buf_size - buf_len, buf_len); *outbuf_size = buf_len; free(buf); @@ -856,7 +856,7 @@ der_get_octet_string(const unsigned char *p, size_t len, data->data = malloc(len); if (data->data == NULL) return (ENOMEM); - memcpy(data->data, p, len); + memmove(data->data, p, len); } else data->data = NULL; if (size) @@ -1217,7 +1217,7 @@ der_put_octet_string(unsigned char *p, size_t len, p -= data->length; len -= data->length; POST(len); - memcpy(p + 1, data->data, data->length); + memmove(p + 1, data->data, data->length); *size = data->length; return (0); } @@ -1397,7 +1397,7 @@ gssapi_mech_make_header(u_char *p, p += len_len; *p++ = 0x06; *p++ = mech->length; - memcpy(p, mech->elements, mech->length); + memmove(p, mech->elements, mech->length); p += mech->length; return (p); } @@ -1430,7 +1430,7 @@ gssapi_spnego_encapsulate(OM_uint32 * minor_status, gss_release_buffer(minor_status, output_token); return (GSS_S_FAILURE); } - memcpy(p, buf, buf_size); + memmove(p, buf, buf_size); return (GSS_S_COMPLETE); } diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index 49a777a644..a162f04206 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -217,7 +217,7 @@ dns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant, result = ISC_R_NOMEMORY; goto failure; } - memcpy(rule->types, types, ntypes * sizeof(dns_rdatatype_t)); + memmove(rule->types, types, ntypes * sizeof(dns_rdatatype_t)); } else rule->types = NULL; diff --git a/lib/dns/tests/rbt_test.c b/lib/dns/tests/rbt_test.c index 83f88c5d6f..b6717e6b3d 100644 --- a/lib/dns/tests/rbt_test.c +++ b/lib/dns/tests/rbt_test.c @@ -205,7 +205,7 @@ add_test_data(isc_mem_t *mctx, dns_rbt_t *rbt) { dns_compress_init(&cctx, -1, mctx); while (testdatap->name != NULL && testdatap->data.data != NULL) { - memcpy(buffer, testdatap->name, testdatap->name_len); + memmove(buffer, testdatap->name, testdatap->name_len); isc_buffer_init(&b, buffer, testdatap->name_len); isc_buffer_add(&b, testdatap->name_len); @@ -247,7 +247,7 @@ check_test_data(dns_rbt_t *rbt) { foundname = dns_fixedname_name(&fixed); while (testdatap->name != NULL && testdatap->data.data != NULL) { - memcpy(buffer, testdatap->name, testdatap->name_len + 1); + memmove(buffer, testdatap->name, testdatap->name_len + 1); arg = buffer; isc_buffer_init(&b, arg, testdatap->name_len); diff --git a/lib/dns/time.c b/lib/dns/time.c index 0f245a246a..ab16f4f585 100644 --- a/lib/dns/time.c +++ b/lib/dns/time.c @@ -98,7 +98,7 @@ dns_time64_totext(isc_int64_t t, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, buf, l); + memmove(region.base, buf, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 161c18808e..cb090b3138 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -152,7 +152,7 @@ add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata, dns_rdata_toregion(rdata, &r); RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length)); isc_buffer_availableregion(tmprdatabuf, &newr); - memcpy(newr.base, r.base, r.length); + memmove(newr.base, r.base, r.length); dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr); dns_message_takebuffer(msg, &tmprdatabuf); @@ -252,12 +252,12 @@ compute_secret(isc_buffer_t *shared, isc_region_t *queryrandomness, if (r.length < sizeof(digests) || r.length < r2.length) return (ISC_R_NOSPACE); if (r2.length > sizeof(digests)) { - memcpy(r.base, r2.base, r2.length); + memmove(r.base, r2.base, r2.length); for (i = 0; i < sizeof(digests); i++) r.base[i] ^= digests[i]; isc_buffer_add(secret, r2.length); } else { - memcpy(r.base, digests, sizeof(digests)); + memmove(r.base, digests, sizeof(digests)); for (i = 0; i < r2.length; i++) r.base[i] ^= r2.base[i]; isc_buffer_add(secret, sizeof(digests)); @@ -534,7 +534,7 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, goto failure; } tkeyout->keylen = isc_buffer_usedlength(outtoken); - memcpy(tkeyout->key, isc_buffer_base(outtoken), + memmove(tkeyout->key, isc_buffer_base(outtoken), isc_buffer_usedlength(outtoken)); isc_buffer_free(&outtoken); } else { @@ -544,7 +544,7 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, goto failure; } tkeyout->keylen = tkeyin->keylen; - memcpy(tkeyout->key, tkeyin->key, tkeyin->keylen); + memmove(tkeyout->key, tkeyin->key, tkeyin->keylen); } tkeyout->error = dns_rcode_noerror; diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index c7768f4c78..afb9007584 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -1370,21 +1370,21 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, * Extract the header. */ isc_buffer_usedregion(source, &r); - memcpy(header, r.base, DNS_MESSAGE_HEADERLEN); + memmove(header, r.base, DNS_MESSAGE_HEADERLEN); isc_region_consume(&r, DNS_MESSAGE_HEADERLEN); /* * Decrement the additional field counter. */ - memcpy(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); + memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); - memcpy(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); + memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); /* * Put in the original id. */ id = htons(tsig.originalid); - memcpy(&header[0], &id, 2); + memmove(&header[0], &id, 2); /* * Digest the modified header. @@ -1609,16 +1609,16 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { * Extract the header. */ isc_buffer_usedregion(source, &r); - memcpy(header, r.base, DNS_MESSAGE_HEADERLEN); + memmove(header, r.base, DNS_MESSAGE_HEADERLEN); isc_region_consume(&r, DNS_MESSAGE_HEADERLEN); /* * Decrement the additional field counter if necessary. */ if (has_tsig) { - memcpy(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); + memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); - memcpy(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); + memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); } /* @@ -1627,7 +1627,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { /* XXX Can TCP transfers be forwarded? How would that work? */ if (has_tsig) { id = htons(tsig.originalid); - memcpy(&header[0], &id, 2); + memmove(&header[0], &id, 2); } /* diff --git a/lib/dns/ttl.c b/lib/dns/ttl.c index d33f0b4dd3..1416a96e80 100644 --- a/lib/dns/ttl.c +++ b/lib/dns/ttl.c @@ -68,7 +68,7 @@ ttlfmt(unsigned int t, const char *s, isc_boolean_t verbose, isc_buffer_availableregion(target, ®ion); if (len > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, tmp, len); + memmove(region.base, tmp, len); isc_buffer_add(target, len); return (ISC_R_SUCCESS); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index f620793156..197beb3bf6 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -2709,7 +2709,7 @@ isspf(const dns_rdata_t *rdata) { INSIST(tl <= rdl); if (len > sizeof(buf) - i - 1) len = sizeof(buf) - i - 1; - memcpy(buf + i, data, len); + memmove(buf + i, data, len); i += len; data += tl; rdl -= tl; @@ -3066,7 +3066,7 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { nsec3chain->nsec3param.iterations = nsec3param->iterations; nsec3chain->nsec3param.flags = nsec3param->flags; nsec3chain->nsec3param.salt_length = nsec3param->salt_length; - memcpy(nsec3chain->salt, nsec3param->salt, nsec3param->salt_length); + memmove(nsec3chain->salt, nsec3param->salt, nsec3param->salt_length); nsec3chain->nsec3param.salt = nsec3chain->salt; nsec3chain->seen_nsec = ISC_FALSE; nsec3chain->delete_nsec = ISC_FALSE; @@ -5311,7 +5311,7 @@ set_addrkeylist(unsigned int count, newaddrs = isc_mem_get(mctx, count * sizeof(*newaddrs)); if (newaddrs == NULL) return (ISC_R_NOMEMORY); - memcpy(newaddrs, addrs, count * sizeof(*newaddrs)); + memmove(newaddrs, addrs, count * sizeof(*newaddrs)); if (dscp != NULL) { newdscp = isc_mem_get(mctx, count * sizeof(*newdscp)); @@ -5319,7 +5319,7 @@ set_addrkeylist(unsigned int count, isc_mem_put(mctx, newaddrs, count * sizeof(*newaddrs)); return (ISC_R_NOMEMORY); } - memcpy(newdscp, dscp, count * sizeof(*newdscp)); + memmove(newdscp, dscp, count * sizeof(*newdscp)); } else newdscp = NULL; diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index 1de540f296..2fe18062f8 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -409,7 +409,7 @@ getaddrinfo(const char *hostname, const char *servname, * Convert to a V4 mapped address. */ struct in6_addr *a6 = (struct in6_addr *)abuf; - memcpy(&a6->s6_addr[12], &a6->s6_addr[0], 4); + memmove(&a6->s6_addr[12], &a6->s6_addr[0], 4); memset(&a6->s6_addr[10], 0xff, 2); memset(&a6->s6_addr[0], 0, 10); goto inet6_addr; @@ -446,7 +446,7 @@ getaddrinfo(const char *hostname, const char *servname, ai_list = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy((char *)ai->ai_addr + addroff, abuf, addrsize); + memmove((char *)ai->ai_addr + addroff, abuf, addrsize); if ((flags & AI_CANONNAME) != 0) { #ifdef IRS_HAVE_SIN6_SCOPE_ID if (ai->ai_family == AF_INET6) @@ -789,8 +789,8 @@ process_answer(isc_task_t *task, isc_event_t *event) { RUNTIME_CHECK(result == ISC_R_SUCCESS); SIN(ai->ai_addr)->sin_port = resstate->head->ai_port; - memcpy(&SIN(ai->ai_addr)->sin_addr, - &rdata_a.in_addr, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, + &rdata_a.in_addr, 4); dns_rdata_freestruct(&rdata_a); break; case AF_INET6: @@ -800,8 +800,8 @@ process_answer(isc_task_t *task, isc_event_t *event) { RUNTIME_CHECK(result == ISC_R_SUCCESS); SIN6(ai->ai_addr)->sin6_port = resstate->head->ai_port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, - &rdata_aaaa.in6_addr, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, + &rdata_aaaa.in6_addr, 16); dns_rdata_freestruct(&rdata_aaaa); break; } @@ -1130,7 +1130,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); return (0); } @@ -1153,7 +1153,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); return (0); } diff --git a/lib/irs/resconf.c b/lib/irs/resconf.c index 88bdac1641..12f5cc3a9c 100644 --- a/lib/irs/resconf.c +++ b/lib/irs/resconf.c @@ -224,7 +224,7 @@ add_server(isc_mem_t *mctx, const char *address_str, v4 = &((struct sockaddr_in *)res->ai_addr)->sin_addr; if (memcmp(v4, zeroaddress, 4) == 0) - memcpy(v4, loopaddress, 4); + memmove(v4, loopaddress, 4); } address = isc_mem_get(mctx, sizeof(*address)); @@ -238,7 +238,7 @@ add_server(isc_mem_t *mctx, const char *address_str, goto cleanup; } address->length = res->ai_addrlen; - memcpy(&address->type.ss, res->ai_addr, res->ai_addrlen); + memmove(&address->type.ss, res->ai_addr, res->ai_addrlen); ISC_LINK_INIT(address, link); ISC_LIST_APPEND(*nameservers, address, link); @@ -258,14 +258,14 @@ create_addr(const char *buffer, isc_netaddr_t *addr, int convert_zero) { unsigned char zeroaddress[] = {0, 0, 0, 0}; unsigned char loopaddress[] = {127, 0, 0, 1}; if (memcmp(&v4, zeroaddress, 4) == 0) - memcpy(&v4, loopaddress, 4); + memmove(&v4, loopaddress, 4); } addr->family = AF_INET; - memcpy(&addr->type.in, &v4, NS_INADDRSZ); + memmove(&addr->type.in, &v4, NS_INADDRSZ); addr->zone = 0; } else if (inet_pton(AF_INET6, buffer, &v6) == 1) { addr->family = AF_INET6; - memcpy(&addr->type.in6, &v6, NS_IN6ADDRSZ); + memmove(&addr->type.in6, &v6, NS_IN6ADDRSZ); addr->zone = 0; } else return (ISC_R_BADADDRESSFORM); /* Unrecognised format. */ diff --git a/lib/isc/base32.c b/lib/isc/base32.c index f595cf14f7..17dd071d72 100644 --- a/lib/isc/base32.c +++ b/lib/isc/base32.c @@ -355,7 +355,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } @@ -367,7 +367,7 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { isc_buffer_availableregion(target, &tr); if (length > tr.length) return (ISC_R_NOSPACE); - memcpy(tr.base, base, length); + memmove(tr.base, base, length); isc_buffer_add(target, length); return (ISC_R_SUCCESS); } diff --git a/lib/isc/base64.c b/lib/isc/base64.c index 00d00d4bc6..7be587401a 100644 --- a/lib/isc/base64.c +++ b/lib/isc/base64.c @@ -234,7 +234,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } @@ -246,7 +246,7 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { isc_buffer_availableregion(target, &tr); if (length > tr.length) return (ISC_R_NOSPACE); - memcpy(tr.base, base, length); + memmove(tr.base, base, length); isc_buffer_add(target, length); return (ISC_R_SUCCESS); } diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index e37af15968..2d74477379 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -420,7 +420,7 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) { REQUIRE(l <= isc_buffer_availablelength(b)); cp = isc_buffer_used(b); - memcpy(cp, source, l); + memmove(cp, source, l); b->used += l; } @@ -439,7 +439,7 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) { available = isc_buffer_availablelength(b); if (r->length > available) return (ISC_R_NOSPACE); - memcpy(base, r->base, r->length); + memmove(base, r->base, r->length); b->used += r->length; return (ISC_R_SUCCESS); diff --git a/lib/isc/hash.c b/lib/isc/hash.c index a2914dbc21..cbe629fcf0 100644 --- a/lib/isc/hash.c +++ b/lib/isc/hash.c @@ -262,7 +262,7 @@ isc_hash_ctxinit(isc_hash_t *hctx) { else copylen = hctx->vectorlen - i; - memcpy(p, &pr, copylen); + memmove(p, &pr, copylen); } INSIST(p == (unsigned char *)hctx->rndvector + hctx->vectorlen); @@ -314,9 +314,9 @@ destroy(isc_hash_t **hctxp) { DESTROYLOCK(&hctx->lock); - memcpy(canary0, hctx + 1, sizeof(canary0)); + memmove(canary0, hctx + 1, sizeof(canary0)); memset(hctx, 0, sizeof(isc_hash_t)); - memcpy(canary1, hctx + 1, sizeof(canary1)); + memmove(canary1, hctx + 1, sizeof(canary1)); INSIST(memcmp(canary0, canary1, sizeof(canary0)) == 0); isc_mem_put(mctx, hctx, sizeof(isc_hash_t)); isc_mem_detach(&mctx); diff --git a/lib/isc/heap.c b/lib/isc/heap.c index 4edaface85..a902e9e537 100644 --- a/lib/isc/heap.c +++ b/lib/isc/heap.c @@ -32,7 +32,7 @@ #include #include #include -#include /* Required for memcpy. */ +#include /* Required for memmove. */ #include /*@{*/ @@ -132,7 +132,7 @@ resize(isc_heap_t *heap) { if (new_array == NULL) return (ISC_FALSE); if (heap->array != NULL) { - memcpy(new_array, heap->array, heap->size * sizeof(void *)); + memmove(new_array, heap->array, heap->size * sizeof(void *)); isc_mem_put(heap->mctx, heap->array, heap->size * sizeof(void *)); } diff --git a/lib/isc/hex.c b/lib/isc/hex.c index 60addf5ce8..d4843f95ee 100644 --- a/lib/isc/hex.c +++ b/lib/isc/hex.c @@ -183,7 +183,7 @@ str_totext(const char *source, isc_buffer_t *target) { if (l > region.length) return (ISC_R_NOSPACE); - memcpy(region.base, source, l); + memmove(region.base, source, l); isc_buffer_add(target, l); return (ISC_R_SUCCESS); } @@ -195,7 +195,7 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { isc_buffer_availableregion(target, &tr); if (length > tr.length) return (ISC_R_NOSPACE); - memcpy(tr.base, base, length); + memmove(tr.base, base, length); isc_buffer_add(target, length); return (ISC_R_SUCCESS); } diff --git a/lib/isc/hmacmd5.c b/lib/isc/hmacmd5.c index 4c4046df35..b76213c684 100644 --- a/lib/isc/hmacmd5.c +++ b/lib/isc/hmacmd5.c @@ -83,7 +83,7 @@ isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key, isc_md5_update(&md5ctx, key, len); isc_md5_final(&md5ctx, ctx->key); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_md5_init(&ctx->md5ctx); memset(ipad, IPAD, sizeof(ipad)); diff --git a/lib/isc/hmacsha.c b/lib/isc/hmacsha.c index 3870963701..0e1a36ac5c 100644 --- a/lib/isc/hmacsha.c +++ b/lib/isc/hmacsha.c @@ -63,7 +63,7 @@ isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) { HMAC_Final(ctx, newdigest, NULL); HMAC_CTX_cleanup(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -94,7 +94,7 @@ isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) { HMAC_Final(ctx, newdigest, NULL); HMAC_CTX_cleanup(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -125,7 +125,7 @@ isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) { HMAC_Final(ctx, newdigest, NULL); HMAC_CTX_cleanup(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -156,7 +156,7 @@ isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) { HMAC_Final(ctx, newdigest, NULL); HMAC_CTX_cleanup(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -187,7 +187,7 @@ isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) { HMAC_Final(ctx, newdigest, NULL); HMAC_CTX_cleanup(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -213,7 +213,7 @@ isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key, isc_sha1_update(&sha1ctx, key, len); isc_sha1_final(&sha1ctx, ctx->key); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_sha1_init(&ctx->sha1ctx); memset(ipad, IPAD, sizeof(ipad)); @@ -260,7 +260,7 @@ isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) { isc_sha1_update(&ctx->sha1ctx, newdigest, ISC_SHA1_DIGESTLENGTH); isc_sha1_final(&ctx->sha1ctx, newdigest); isc_hmacsha1_invalidate(ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -281,7 +281,7 @@ isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key, isc_sha224_update(&sha224ctx, key, len); isc_sha224_final(ctx->key, &sha224ctx); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_sha224_init(&ctx->sha224ctx); memset(ipad, IPAD, sizeof(ipad)); @@ -326,7 +326,7 @@ isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) { isc_sha224_update(&ctx->sha224ctx, opad, sizeof(opad)); isc_sha224_update(&ctx->sha224ctx, newdigest, ISC_SHA224_DIGESTLENGTH); isc_sha224_final(newdigest, &ctx->sha224ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -347,7 +347,7 @@ isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key, isc_sha256_update(&sha256ctx, key, len); isc_sha256_final(ctx->key, &sha256ctx); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_sha256_init(&ctx->sha256ctx); memset(ipad, IPAD, sizeof(ipad)); @@ -392,7 +392,7 @@ isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) { isc_sha256_update(&ctx->sha256ctx, opad, sizeof(opad)); isc_sha256_update(&ctx->sha256ctx, newdigest, ISC_SHA256_DIGESTLENGTH); isc_sha256_final(newdigest, &ctx->sha256ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -413,7 +413,7 @@ isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key, isc_sha384_update(&sha384ctx, key, len); isc_sha384_final(ctx->key, &sha384ctx); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_sha384_init(&ctx->sha384ctx); memset(ipad, IPAD, sizeof(ipad)); @@ -458,7 +458,7 @@ isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) { isc_sha384_update(&ctx->sha384ctx, opad, sizeof(opad)); isc_sha384_update(&ctx->sha384ctx, newdigest, ISC_SHA384_DIGESTLENGTH); isc_sha384_final(newdigest, &ctx->sha384ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } @@ -479,7 +479,7 @@ isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key, isc_sha512_update(&sha512ctx, key, len); isc_sha512_final(ctx->key, &sha512ctx); } else - memcpy(ctx->key, key, len); + memmove(ctx->key, key, len); isc_sha512_init(&ctx->sha512ctx); memset(ipad, IPAD, sizeof(ipad)); @@ -524,7 +524,7 @@ isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) { isc_sha512_update(&ctx->sha512ctx, opad, sizeof(opad)); isc_sha512_update(&ctx->sha512ctx, newdigest, ISC_SHA512_DIGESTLENGTH); isc_sha512_final(newdigest, &ctx->sha512ctx); - memcpy(digest, newdigest, len); + memmove(digest, newdigest, len); memset(newdigest, 0, sizeof(newdigest)); } #endif /* !ISC_PLATFORM_OPENSSLHASH */ diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 72b856056a..aa22bb6bce 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -787,7 +787,7 @@ ISC_LANG_ENDDECLS #define ISC__BUFFER_PUTMEM(_b, _base, _length) \ do { \ - memcpy(isc_buffer_used(_b), (_base), (_length)); \ + memmove(isc_buffer_used(_b), (_base), (_length)); \ (_b)->used += (_length); \ } while (0) @@ -797,7 +797,7 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ _length = strlen(_source); \ _cp = isc_buffer_used(_b); \ - memcpy(_cp, (_source), _length); \ + memmove(_cp, (_source), _length); \ (_b)->used += (_length); \ } while (0) diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h index 47512c7228..f03f8cff41 100644 --- a/lib/isc/include/isc/radix.h +++ b/lib/isc/include/isc/radix.h @@ -41,10 +41,10 @@ (pt).family = (na)->family; \ (pt).bitlen = (bits); \ if ((pt).family == AF_INET6) { \ - memcpy(&(pt).add.sin6, &(na)->type.in6, \ + memmove(&(pt).add.sin6, &(na)->type.in6, \ ((bits)+7)/8); \ } else \ - memcpy(&(pt).add.sin, &(na)->type.in, \ + memmove(&(pt).add.sin, &(na)->type.in, \ ((bits)+7)/8); \ } else { \ (pt).family = AF_UNSPEC; \ diff --git a/lib/isc/inet_pton.c b/lib/isc/inet_pton.c index ac4defde75..c3f7a54583 100644 --- a/lib/isc/inet_pton.c +++ b/lib/isc/inet_pton.c @@ -114,7 +114,7 @@ inet_pton4(const char *src, unsigned char *dst) { } if (octets < 4) return (0); - memcpy(dst, tmp, NS_INADDRSZ); + memmove(dst, tmp, NS_INADDRSZ); return (1); } @@ -210,6 +210,6 @@ inet_pton6(const char *src, unsigned char *dst) { } if (tp != endp) return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); + memmove(dst, tmp, NS_IN6ADDRSZ); return (1); } diff --git a/lib/isc/lex.c b/lib/isc/lex.c index a4bfcd1e78..992006ad74 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -75,7 +75,7 @@ grow_data(isc_lex_t *lex, size_t *remainingp, char **currp, char **prevp) { new = isc_mem_get(lex->mctx, lex->max_token * 2 + 1); if (new == NULL) return (ISC_R_NOMEMORY); - memcpy(new, lex->data, lex->max_token + 1); + memmove(new, lex->data, lex->max_token + 1); *currp = new + (*currp - lex->data); if (*prevp != NULL) *prevp = new + (*prevp - lex->data); @@ -173,7 +173,7 @@ isc_lex_getspecials(isc_lex_t *lex, isc_lexspecials_t specials) { REQUIRE(VALID_LEX(lex)); - memcpy(specials, lex->specials, 256); + memmove(specials, lex->specials, 256); } void @@ -185,7 +185,7 @@ isc_lex_setspecials(isc_lex_t *lex, isc_lexspecials_t specials) { REQUIRE(VALID_LEX(lex)); - memcpy(lex->specials, specials, 256); + memmove(lex->specials, specials, 256); } static inline isc_result_t diff --git a/lib/isc/log.c b/lib/isc/log.c index d8262fb97a..f36cc2d5e1 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -1130,7 +1130,7 @@ sync_channellist(isc_logconfig_t *lcfg) { if (lcfg->channellist_count != 0) { bytes = lcfg->channellist_count * sizeof(ISC_LIST(isc_logchannellist_t)); - memcpy(lists, lcfg->channellists, bytes); + memmove(lists, lcfg->channellists, bytes); isc_mem_put(lctx->mctx, lcfg->channellists, bytes); } diff --git a/lib/isc/md5.c b/lib/isc/md5.c index 7c6419b2a9..ec355a95ce 100644 --- a/lib/isc/md5.c +++ b/lib/isc/md5.c @@ -217,11 +217,11 @@ isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) { t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ if (t > len) { - memcpy((unsigned char *)ctx->in + 64 - t, buf, len); + memmove((unsigned char *)ctx->in + 64 - t, buf, len); return; } /* First chunk is an odd size */ - memcpy((unsigned char *)ctx->in + 64 - t, buf, t); + memmove((unsigned char *)ctx->in + 64 - t, buf, t); byteSwap(ctx->in, 16); transform(ctx->buf, ctx->in); buf += t; @@ -229,7 +229,7 @@ isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) { /* Process data in 64-byte chunks */ while (len >= 64) { - memcpy(ctx->in, buf, 64); + memmove(ctx->in, buf, 64); byteSwap(ctx->in, 16); transform(ctx->buf, ctx->in); buf += 64; @@ -237,7 +237,7 @@ isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) { } /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + memmove(ctx->in, buf, len); } /*! @@ -271,7 +271,7 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest) { transform(ctx->buf, ctx->in); byteSwap(ctx->buf, 4); - memcpy(digest, ctx->buf, 16); + memmove(digest, ctx->buf, 16); memset(ctx, 0, sizeof(isc_md5_t)); /* In case it's sensitive */ } #endif diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 3a7279d419..0bbfc4f382 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -542,9 +542,9 @@ more_basic_blocks(isc__mem_t *ctx) { return (ISC_FALSE); } if (ctx->basic_table_size != 0) { - memcpy(table, ctx->basic_table, - ctx->basic_table_size * - sizeof(unsigned char *)); + memmove(table, ctx->basic_table, + ctx->basic_table_size * + sizeof(unsigned char *)); (ctx->memfree)(ctx->arg, ctx->basic_table); } ctx->basic_table = table; @@ -1580,7 +1580,7 @@ isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) { oldsize -= ALIGNMENT_SIZE; } copysize = (oldsize > size) ? size : oldsize; - memcpy(new_ptr, ptr, copysize); + memmove(new_ptr, ptr, copysize); isc__mem_free(ctx0, ptr FLARG_PASS); } } else if (ptr != NULL) diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 5cce1bc1a0..aacc9c2646 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -340,7 +340,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) { t->zone = 0; break; case AF_INET6: - memcpy(&t->type.in6, &s->type.sin6.sin6_addr, 16); + memmove(&t->type.in6, &s->type.sin6.sin6_addr, 16); #ifdef ISC_PLATFORM_HAVESCOPEID t->zone = s->type.sin6.sin6_scope_id; #else @@ -349,7 +349,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) { break; #ifdef ISC_PLATFORM_HAVESYSUNH case AF_UNIX: - memcpy(t->type.un, s->type.sunix.sun_path, sizeof(t->type.un)); + memmove(t->type.un, s->type.sunix.sun_path, sizeof(t->type.un)); t->zone = 0; break; #endif @@ -429,6 +429,6 @@ isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s) { memset(t, 0, sizeof(*t)); t->family = AF_INET; - memcpy(&t->type.in, (char *)&src->type.in6 + 12, 4); + memmove(&t->type.in, (char *)&src->type.in6 + 12, 4); return; } diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 3508878861..7883cc31a3 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -62,11 +62,11 @@ _new_prefix(isc_mem_t *mctx, isc_prefix_t **target, int family, void *dest, if (family == AF_INET6) { prefix->bitlen = (bitlen >= 0) ? bitlen : 128; - memcpy(&prefix->add.sin6, dest, 16); + memmove(&prefix->add.sin6, dest, 16); } else { /* AF_UNSPEC is "any" or "none"--treat it as AF_INET */ prefix->bitlen = (bitlen >= 0) ? bitlen : 32; - memcpy(&prefix->add.sin, dest, 4); + memmove(&prefix->add.sin, dest, 4); } prefix->family = family; diff --git a/lib/isc/sha1.c b/lib/isc/sha1.c index cce9603604..38ca4ac5cd 100644 --- a/lib/isc/sha1.c +++ b/lib/isc/sha1.c @@ -209,7 +209,7 @@ transform(isc_uint32_t state[5], const unsigned char buffer[64]) { INSIST(state != NULL); block = &workspace; - (void)memcpy(block, buffer, 64); + (void)memmove(block, buffer, 64); /* Copy context->state[] to working vars */ a = state[0]; @@ -301,7 +301,7 @@ isc_sha1_update(isc_sha1_t *context, const unsigned char *data, context->count[1] += (len >> 29) + 1; j = (j >> 3) & 63; if ((j + len) > 63) { - (void)memcpy(&context->buffer[j], data, (i = 64 - j)); + (void)memmove(&context->buffer[j], data, (i = 64 - j)); transform(context->state, context->buffer); for (; i + 63 < len; i += 64) transform(context->state, &data[i]); @@ -310,7 +310,7 @@ isc_sha1_update(isc_sha1_t *context, const unsigned char *data, i = 0; } - (void)memcpy(&context->buffer[j], &data[i], len - i); + (void)memmove(&context->buffer[j], &data[i], len - i); } diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c index db2e3496c4..b28be2bc97 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -560,8 +560,8 @@ isc_sha224_init(isc_sha224_t *context) { if (context == (isc_sha256_t *)0) { return; } - memcpy(context->state, sha224_initial_hash_value, - ISC_SHA256_DIGESTLENGTH); + memmove(context->state, sha224_initial_hash_value, + ISC_SHA256_DIGESTLENGTH); memset(context->buffer, 0, ISC_SHA256_BLOCK_LENGTH); context->bitcount = 0; } @@ -580,7 +580,7 @@ void isc_sha224_final(isc_uint8_t digest[], isc_sha224_t *context) { isc_uint8_t sha256_digest[ISC_SHA256_DIGESTLENGTH]; isc_sha256_final(sha256_digest, (isc_sha256_t *)context); - memcpy(digest, sha256_digest, ISC_SHA224_DIGESTLENGTH); + memmove(digest, sha256_digest, ISC_SHA224_DIGESTLENGTH); memset(sha256_digest, 0, ISC_SHA256_DIGESTLENGTH); } @@ -590,7 +590,7 @@ isc_sha256_init(isc_sha256_t *context) { if (context == (isc_sha256_t *)0) { return; } - memcpy(context->state, sha256_initial_hash_value, + memmove(context->state, sha256_initial_hash_value, ISC_SHA256_DIGESTLENGTH); memset(context->buffer, 0, ISC_SHA256_BLOCK_LENGTH); context->bitcount = 0; @@ -803,7 +803,7 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { if (len >= freespace) { /* Fill the buffer completely and process it */ - memcpy(&context->buffer[usedspace], data, freespace); + memmove(&context->buffer[usedspace], data, freespace); context->bitcount += freespace << 3; len -= freespace; data += freespace; @@ -811,7 +811,7 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { (isc_uint32_t*)context->buffer); } else { /* The buffer is not yet full */ - memcpy(&context->buffer[usedspace], data, len); + memmove(&context->buffer[usedspace], data, len); context->bitcount += len << 3; /* Clean up: */ usedspace = freespace = 0; @@ -822,7 +822,7 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { } while (len >= ISC_SHA256_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ - memcpy(context->buffer, data, ISC_SHA256_BLOCK_LENGTH); + memmove(context->buffer, data, ISC_SHA256_BLOCK_LENGTH); isc_sha256_transform(context, (isc_uint32_t*)context->buffer); context->bitcount += ISC_SHA256_BLOCK_LENGTH << 3; len -= ISC_SHA256_BLOCK_LENGTH; @@ -830,7 +830,7 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { } if (len > 0U) { /* There's left-overs, so save 'em */ - memcpy(context->buffer, data, len); + memmove(context->buffer, data, len); context->bitcount += len << 3; } /* Clean up: */ @@ -900,7 +900,7 @@ isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) { } } #else - memcpy(d, context->state, ISC_SHA256_DIGESTLENGTH); + memmove(d, context->state, ISC_SHA256_DIGESTLENGTH); #endif } @@ -916,8 +916,8 @@ isc_sha512_init(isc_sha512_t *context) { if (context == (isc_sha512_t *)0) { return; } - memcpy(context->state, sha512_initial_hash_value, - ISC_SHA512_DIGESTLENGTH); + memmove(context->state, sha512_initial_hash_value, + ISC_SHA512_DIGESTLENGTH); memset(context->buffer, 0, ISC_SHA512_BLOCK_LENGTH); context->bitcount[0] = context->bitcount[1] = 0; } @@ -1122,7 +1122,7 @@ void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t le if (len >= freespace) { /* Fill the buffer completely and process it */ - memcpy(&context->buffer[usedspace], data, freespace); + memmove(&context->buffer[usedspace], data, freespace); ADDINC128(context->bitcount, freespace << 3); len -= freespace; data += freespace; @@ -1130,7 +1130,7 @@ void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t le (isc_uint64_t*)context->buffer); } else { /* The buffer is not yet full */ - memcpy(&context->buffer[usedspace], data, len); + memmove(&context->buffer[usedspace], data, len); ADDINC128(context->bitcount, len << 3); /* Clean up: */ usedspace = freespace = 0; @@ -1141,7 +1141,7 @@ void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t le } while (len >= ISC_SHA512_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ - memcpy(context->buffer, data, ISC_SHA512_BLOCK_LENGTH); + memmove(context->buffer, data, ISC_SHA512_BLOCK_LENGTH); isc_sha512_transform(context, (isc_uint64_t*)context->buffer); ADDINC128(context->bitcount, ISC_SHA512_BLOCK_LENGTH << 3); len -= ISC_SHA512_BLOCK_LENGTH; @@ -1149,7 +1149,7 @@ void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t le } if (len > 0U) { /* There's left-overs, so save 'em */ - memcpy(context->buffer, data, len); + memmove(context->buffer, data, len); ADDINC128(context->bitcount, len << 3); } /* Clean up: */ @@ -1224,7 +1224,7 @@ void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) { } } #else - memcpy(d, context->state, ISC_SHA512_DIGESTLENGTH); + memmove(d, context->state, ISC_SHA512_DIGESTLENGTH); #endif } @@ -1239,8 +1239,8 @@ isc_sha384_init(isc_sha384_t *context) { if (context == (isc_sha384_t *)0) { return; } - memcpy(context->state, sha384_initial_hash_value, - ISC_SHA512_DIGESTLENGTH); + memmove(context->state, sha384_initial_hash_value, + ISC_SHA512_DIGESTLENGTH); memset(context->buffer, 0, ISC_SHA384_BLOCK_LENGTH); context->bitcount[0] = context->bitcount[1] = 0; } @@ -1277,7 +1277,7 @@ isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) { } } #else - memcpy(d, context->state, ISC_SHA384_DIGESTLENGTH); + memmove(d, context->state, ISC_SHA384_DIGESTLENGTH); #endif } diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index 91a949b642..95662c0e67 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -332,7 +332,7 @@ isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina, #endif sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff; sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff; - memcpy(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4); + memmove(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4); sockaddr->type.sin6.sin6_port = htons(port); sockaddr->length = sizeof(sockaddr->type.sin6); ISC_LINK_INIT(sockaddr, link); @@ -386,7 +386,7 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, #ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6); #endif - memcpy(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16); + memmove(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16); #ifdef ISC_PLATFORM_HAVESCOPEID sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na); #endif diff --git a/lib/isc/stats.c b/lib/isc/stats.c index a620de426f..48d41a34c7 100644 --- a/lib/isc/stats.c +++ b/lib/isc/stats.c @@ -275,8 +275,8 @@ copy_counters(isc_stats_t *stats) { } #else UNUSED(i); - memcpy(stats->copiedcounters, stats->counters, - stats->ncounters * sizeof(isc_stat_t)); + memmove(stats->copiedcounters, stats->counters, + stats->ncounters * sizeof(isc_stat_t)); #endif #ifdef ISC_RWLOCK_USEATOMIC diff --git a/lib/isc/string.c b/lib/isc/string.c index cba517c568..0e1b90465e 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -188,7 +188,7 @@ isc_string_regiondup(isc_mem_t *mctx, const isc_region_t *source) { target = (char *) isc_mem_allocate(mctx, source->length + 1); if (target != NULL) { - memcpy(source->base, target, source->length); + memmove(source->base, target, source->length); target[source->length] = '\0'; } diff --git a/lib/isc/tests/hash_test.c b/lib/isc/tests/hash_test.c index b2bb7bbb35..4ddc05dbda 100644 --- a/lib/isc/tests/hash_test.c +++ b/lib/isc/tests/hash_test.c @@ -964,7 +964,7 @@ ATF_TC_BODY(isc_hmacsha1, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacsha1_init(&hmacsha1, buffer, test_key->len); isc_hmacsha1_update(&hmacsha1, (const isc_uint8_t *) testcase->input, @@ -1127,7 +1127,7 @@ ATF_TC_BODY(isc_hmacsha224, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacsha224_init(&hmacsha224, buffer, test_key->len); isc_hmacsha224_update(&hmacsha224, (const isc_uint8_t *) testcase->input, @@ -1290,7 +1290,7 @@ ATF_TC_BODY(isc_hmacsha256, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacsha256_init(&hmacsha256, buffer, test_key->len); isc_hmacsha256_update(&hmacsha256, (const isc_uint8_t *) testcase->input, @@ -1459,7 +1459,7 @@ ATF_TC_BODY(isc_hmacsha384, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacsha384_init(&hmacsha384, buffer, test_key->len); isc_hmacsha384_update(&hmacsha384, (const isc_uint8_t *) testcase->input, @@ -1628,7 +1628,7 @@ ATF_TC_BODY(isc_hmacsha512, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacsha512_init(&hmacsha512, buffer, test_key->len); isc_hmacsha512_update(&hmacsha512, (const isc_uint8_t *) testcase->input, @@ -1771,7 +1771,7 @@ ATF_TC_BODY(isc_hmacmd5, tc) { hash_test_key_t *test_key = test_keys; while (testcase->input != NULL && testcase->result != NULL) { - memcpy(buffer, test_key->key, test_key->len); + memmove(buffer, test_key->key, test_key->len); isc_hmacmd5_init(&hmacmd5, buffer, test_key->len); isc_hmacmd5_update(&hmacmd5, (const isc_uint8_t *) testcase->input, diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index b50a147e6a..1ff9d1dff8 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -527,7 +527,7 @@ isc_file_progname(const char *filename, char *buf, size_t buflen) { if (len > buflen) return (ISC_R_NOSPACE); - memcpy(buf, base, len); + memmove(buf, base, len); return (ISC_R_SUCCESS); } diff --git a/lib/isc/unix/ifiter_getifaddrs.c b/lib/isc/unix/ifiter_getifaddrs.c index 637450aaf4..f139f72611 100644 --- a/lib/isc/unix/ifiter_getifaddrs.c +++ b/lib/isc/unix/ifiter_getifaddrs.c @@ -159,7 +159,7 @@ internal_current(isc_interfaceiter_t *iter) { namelen = sizeof(iter->current.name) - 1; memset(iter->current.name, 0, sizeof(iter->current.name)); - memcpy(iter->current.name, ifa->ifa_name, namelen); + memmove(iter->current.name, ifa->ifa_name, namelen); iter->current.flags = 0; diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index 38c34fd61a..cdc6d1d6cb 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -398,7 +398,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { static void get_inaddr(isc_netaddr_t *dst, struct in_addr *src) { dst->family = AF_INET; - memcpy(&dst->type.in, src, sizeof(struct in_addr)); + memmove(&dst->type.in, src, sizeof(struct in_addr)); } static isc_result_t @@ -454,7 +454,7 @@ internal_current4(isc_interfaceiter_t *iter) { ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos); memset(&ifreq, 0, sizeof(ifreq)); - memcpy(&ifreq, ifrp, sizeof(ifreq)); + memmove(&ifreq, ifrp, sizeof(ifreq)); family = ifreq.ifr_addr.sa_family; #if defined(ISC_PLATFORM_HAVEIPV6) @@ -469,7 +469,7 @@ internal_current4(isc_interfaceiter_t *iter) { INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name)); memset(iter->current.name, 0, sizeof(iter->current.name)); - memcpy(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name)); + memmove(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name)); get_addr(family, &iter->current.address, (struct sockaddr *)&ifrp->ifr_addr, ifreq.ifr_name); @@ -524,8 +524,8 @@ internal_current4(isc_interfaceiter_t *iter) { #if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR) memset(&lifreq, 0, sizeof(lifreq)); - memcpy(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name)); - memcpy(&lifreq.lifr_addr, &iter->current.address.type.in6, + memmove(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name)); + memmove(&lifreq.lifr_addr, &iter->current.address.type.in6, sizeof(iter->current.address.type.in6)); if (ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) { @@ -599,7 +599,7 @@ internal_current4(isc_interfaceiter_t *iter) { * Get the network mask. */ memset(&ifreq, 0, sizeof(ifreq)); - memcpy(&ifreq, ifrp, sizeof(ifreq)); + memmove(&ifreq, ifrp, sizeof(ifreq)); /* * Ignore the HP/UX warning about "integer overflow during * conversion. It comes from its own macro definition, @@ -637,7 +637,7 @@ internal_current6(isc_interfaceiter_t *iter) { ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6); memset(&lifreq, 0, sizeof(lifreq)); - memcpy(&lifreq, ifrp, sizeof(lifreq)); + memmove(&lifreq, ifrp, sizeof(lifreq)); family = lifreq.lifr_addr.ss_family; #ifdef ISC_PLATFORM_HAVEIPV6 @@ -652,7 +652,7 @@ internal_current6(isc_interfaceiter_t *iter) { INSIST(sizeof(lifreq.lifr_name) <= sizeof(iter->current.name)); memset(iter->current.name, 0, sizeof(iter->current.name)); - memcpy(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name)); + memmove(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name)); get_addr(family, &iter->current.address, (struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name); @@ -739,7 +739,7 @@ internal_current6(isc_interfaceiter_t *iter) { * Get the network mask. Netmask already zeroed. */ memset(&lifreq, 0, sizeof(lifreq)); - memcpy(&lifreq, ifrp, sizeof(lifreq)); + memmove(&lifreq, ifrp, sizeof(lifreq)); #ifdef lifr_addrlen /* diff --git a/lib/isc/unix/ifiter_sysctl.c b/lib/isc/unix/ifiter_sysctl.c index 9d5bf6d9e7..209325cd0c 100644 --- a/lib/isc/unix/ifiter_sysctl.c +++ b/lib/isc/unix/ifiter_sysctl.c @@ -171,7 +171,7 @@ internal_current(isc_interfaceiter_t *iter) { namelen = sizeof(iter->current.name) - 1; memset(iter->current.name, 0, sizeof(iter->current.name)); - memcpy(iter->current.name, sdl->sdl_data, namelen); + memmove(iter->current.name, sdl->sdl_data, namelen); iter->current.flags = 0; diff --git a/lib/isc/unix/interfaceiter.c b/lib/isc/unix/interfaceiter.c index af2b06d093..abbd0a6a4f 100644 --- a/lib/isc/unix/interfaceiter.c +++ b/lib/isc/unix/interfaceiter.c @@ -79,14 +79,14 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, dst->family = family; switch (family) { case AF_INET: - memcpy(&dst->type.in, - &((struct sockaddr_in *) src)->sin_addr, - sizeof(struct in_addr)); + memmove(&dst->type.in, + &((struct sockaddr_in *) src)->sin_addr, + sizeof(struct in_addr)); break; case AF_INET6: sa6 = (struct sockaddr_in6 *)src; - memcpy(&dst->type.in6, &sa6->sin6_addr, - sizeof(struct in6_addr)); + memmove(&dst->type.in6, &sa6->sin6_addr, + sizeof(struct in6_addr)); #ifdef ISC_PLATFORM_HAVESCOPEID if (sa6->sin6_scope_id != 0) isc_netaddr_setzone(dst, sa6->sin6_scope_id); @@ -105,8 +105,8 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) { isc_uint16_t zone16; - memcpy(&zone16, &sa6->sin6_addr.s6_addr[2], - sizeof(zone16)); + memmove(&zone16, &sa6->sin6_addr.s6_addr[2], + sizeof(zone16)); zone16 = ntohs(zone16); if (zone16 != 0) { /* the zone ID is embedded */ @@ -252,7 +252,7 @@ isc_interfaceiter_current(isc_interfaceiter_t *iter, isc_interface_t *ifdata) { REQUIRE(iter->result == ISC_R_SUCCESS); - memcpy(ifdata, &iter->current, sizeof(*ifdata)); + memmove(ifdata, &iter->current, sizeof(*ifdata)); return (ISC_R_SUCCESS); } diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index f64ea6d328..9b34f859b7 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -540,7 +540,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { #ifdef IPV6_TCLASS case IPV6_TCLASS: cmsgp->cmsg_len = cmsg_len(sizeof(dscp)); - memcpy(CMSG_DATA(cmsgp), &dscp, sizeof(dscp)); + memmove(CMSG_DATA(cmsgp), &dscp, sizeof(dscp)); break; #endif default: diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index f92178ff34..e849678e0d 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1305,8 +1305,8 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { && cmsgp->cmsg_type == IPV6_PKTINFO) { pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); - memcpy(&dev->pktinfo, pktinfop, - sizeof(struct in6_pktinfo)); + memmove(&dev->pktinfo, pktinfop, + sizeof(struct in6_pktinfo)); dev->attributes |= ISC_SOCKEVENTATTR_PKTINFO; socket_log(sock, NULL, TRACE, isc_msgcat, ISC_MSGSET_SOCKET, @@ -1324,7 +1324,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { && cmsgp->cmsg_type == SCM_TIMESTAMP) { struct timeval tv; timevalp = CMSG_DATA(cmsgp); - memcpy(&tv, timevalp, sizeof(tv)); + memmove(&tv, timevalp, sizeof(tv)); dev->timestamp.seconds = tv.tv_sec; dev->timestamp.nanoseconds = tv.tv_usec * 1000; dev->attributes |= ISC_SOCKEVENTATTR_TIMESTAMP; @@ -1475,7 +1475,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev, cmsgp->cmsg_type = IPV6_PKTINFO; cmsgp->cmsg_len = cmsg_len(sizeof(struct in6_pktinfo)); pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); - memcpy(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); + memmove(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); #if defined(IPV6_USE_MIN_MTU) /* * Set IPV6_USE_MIN_MTU as a per packet option as FreeBSD @@ -1490,7 +1490,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev, cmsgp->cmsg_level = IPPROTO_IPV6; cmsgp->cmsg_type = IPV6_USE_MIN_MTU; cmsgp->cmsg_len = cmsg_len(sizeof(use_min_mtu)); - memcpy(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu)); + memmove(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu)); #endif } if (isc_dscp_check_value != -1) { @@ -1550,7 +1550,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev, cmsgp->cmsg_level = IPPROTO_IPV6; cmsgp->cmsg_type = IPV6_TCLASS; cmsgp->cmsg_len = cmsg_len(sizeof(dscp)); - memcpy(CMSG_DATA(cmsgp), &dscp, sizeof(dscp)); + memmove(CMSG_DATA(cmsgp), &dscp, sizeof(dscp)); } else if (sock->pf == AF_INET6) { if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS, (void *)&dscp, sizeof(int)) < 0) { @@ -4064,10 +4064,10 @@ watcher(void *uap) { cc = ioctl(manager->devpoll_fd, DP_POLL, &dvp); #elif defined(USE_SELECT) LOCK(&manager->lock); - memcpy(manager->read_fds_copy, manager->read_fds, - manager->fd_bufsize); - memcpy(manager->write_fds_copy, manager->write_fds, - manager->fd_bufsize); + memmove(manager->read_fds_copy, manager->read_fds, + manager->fd_bufsize); + memmove(manager->write_fds_copy, manager->write_fds, + manager->fd_bufsize); maxfd = manager->maxfd + 1; UNLOCK(&manager->lock); @@ -6127,9 +6127,9 @@ isc__socketmgr_waitevents(isc_socketmgr_t *manager0, struct timeval *tvp, swait_private.nevents = ioctl(manager->devpoll_fd, DP_POLL, &dvp); n = swait_private.nevents; #elif defined(USE_SELECT) - memcpy(manager->read_fds_copy, manager->read_fds, manager->fd_bufsize); - memcpy(manager->write_fds_copy, manager->write_fds, - manager->fd_bufsize); + memmove(manager->read_fds_copy, manager->read_fds, manager->fd_bufsize); + memmove(manager->write_fds_copy, manager->write_fds, + manager->fd_bufsize); swait_private.readset = manager->read_fds_copy; swait_private.writeset = manager->write_fds_copy; diff --git a/lib/isc/win32/interfaceiter.c b/lib/isc/win32/interfaceiter.c index c7a9cbb241..18789ea74a 100644 --- a/lib/isc/win32/interfaceiter.c +++ b/lib/isc/win32/interfaceiter.c @@ -88,14 +88,14 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) { dst->family = family; switch (family) { case AF_INET: - memcpy(&dst->type.in, - &((struct sockaddr_in *) src)->sin_addr, - sizeof(struct in_addr)); + memmove(&dst->type.in, + &((struct sockaddr_in *) src)->sin_addr, + sizeof(struct in_addr)); break; case AF_INET6: - memcpy(&dst->type.in6, - &((struct sockaddr_in6 *) src)->sin6_addr, - sizeof(struct in6_addr)); + memmove(&dst->type.in6, + &((struct sockaddr_in6 *) src)->sin6_addr, + sizeof(struct in6_addr)); dst->zone = ((struct sockaddr_in6 *) src)->sin6_scope_id; break; default: @@ -425,7 +425,7 @@ internal_next(isc_interfaceiter_t *iter) { return (ISC_R_NOMORE); memset(&(iter->IFData), 0, sizeof(INTERFACE_INFO)); - memcpy(&(iter->IFData), iter->pos4, sizeof(INTERFACE_INFO)); + memmove(&(iter->IFData), iter->pos4, sizeof(INTERFACE_INFO)); iter->numIF++; return (ISC_R_SUCCESS); @@ -443,7 +443,7 @@ isc_result_t isc_interfaceiter_current(isc_interfaceiter_t *iter, isc_interface_t *ifdata) { REQUIRE(iter->result == ISC_R_SUCCESS); - memcpy(ifdata, &iter->current, sizeof(*ifdata)); + memmove(ifdata, &iter->current, sizeof(*ifdata)); return (ISC_R_SUCCESS); } diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index 17b15c6680..7fda2e15fb 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -962,7 +962,7 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, memset(msg, 0, sizeof(*msg)); - memcpy(&msg->to_addr, &dev->address.type, dev->address.length); + memmove(&msg->to_addr, &dev->address.type, dev->address.length); msg->to_addr_len = dev->address.length; buffer = ISC_LIST_HEAD(dev->bufferlist); @@ -984,7 +984,7 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, "alloc_buffer %p %d %p %d", cpbuffer, sizeof(buflist_t), cpbuffer->buf, write_count); - memcpy(cpbuffer->buf,(dev->region.base + dev->n), write_count); + memmove(cpbuffer->buf,(dev->region.base + dev->n), write_count); cpbuffer->buflen = (unsigned int)write_count; ISC_LIST_ENQUEUE(lpo->bufferlist, cpbuffer, link); iov[0].buf = cpbuffer->buf; @@ -1024,7 +1024,7 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, "alloc_buffer %p %d %p %d", cpbuffer, sizeof(buflist_t), cpbuffer->buf, write_count); - memcpy(cpbuffer->buf,(used.base + skip_count), uselen); + memmove(cpbuffer->buf,(used.base + skip_count), uselen); cpbuffer->buflen = uselen; iov[iovcount].buf = cpbuffer->buf; iov[iovcount].len = (u_long)(used.length - skip_count); @@ -1227,8 +1227,8 @@ fill_recv(isc_socket_t *sock, isc_socketevent_t *dev) { if (sock->type == isc_sockettype_udp) { dev->address.length = sock->recvbuf.from_addr_len; - memcpy(&dev->address.type, &sock->recvbuf.from_addr, - sock->recvbuf.from_addr_len); + memmove(&dev->address.type, &sock->recvbuf.from_addr, + sock->recvbuf.from_addr_len); if (isc_sockaddr_getport(&dev->address) == 0) { if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { socket_log(__LINE__, sock, &dev->address, IOEVENT, @@ -1254,8 +1254,10 @@ fill_recv(isc_socket_t *sock, isc_socketevent_t *dev) { REQUIRE(ISC_BUFFER_VALID(buffer)); if (isc_buffer_availablelength(buffer) > 0) { isc_buffer_availableregion(buffer, &r); - copylen = min(r.length, sock->recvbuf.remaining); - memcpy(r.base, sock->recvbuf.consume_position, copylen); + copylen = min(r.length, + sock->recvbuf.remaining); + memmove(r.base, sock->recvbuf.consume_position, + copylen); sock->recvbuf.consume_position += copylen; sock->recvbuf.remaining -= copylen; isc_buffer_add(buffer, copylen); @@ -1265,7 +1267,8 @@ fill_recv(isc_socket_t *sock, isc_socketevent_t *dev) { } } else { // Single-buffer receive copylen = min(dev->region.length - dev->n, sock->recvbuf.remaining); - memcpy(dev->region.base + dev->n, sock->recvbuf.consume_position, copylen); + memmove(dev->region.base + dev->n, + sock->recvbuf.consume_position, copylen); sock->recvbuf.consume_position += copylen; sock->recvbuf.remaining -= copylen; dev->n += copylen; @@ -2068,7 +2071,7 @@ internal_accept(isc_socket_t *sock, IoCompletionInfo *lpo, int accept_errno) { sizeof(SOCKADDR_STORAGE) + 16, sizeof(SOCKADDR_STORAGE) + 16, (LPSOCKADDR *)&localaddr, &localaddr_len, (LPSOCKADDR *)&remoteaddr, &remoteaddr_len); - memcpy(&adev->address.type, remoteaddr, remoteaddr_len); + memmove(&adev->address.type, remoteaddr, remoteaddr_len); adev->address.length = remoteaddr_len; nsock->address = adev->address; nsock->pf = adev->address.type.sa.sa_family; diff --git a/lib/isccc/include/isccc/util.h b/lib/isccc/include/isccc/util.h index 2e36b6e32d..ccc17335fb 100644 --- a/lib/isccc/include/isccc/util.h +++ b/lib/isccc/include/isccc/util.h @@ -109,7 +109,7 @@ #define GET_MEM(v, c, w) \ do { \ - memcpy(v, w, c); \ + memmove(v, w, c); \ w += c; \ } while (0) @@ -193,7 +193,7 @@ #define PUT_MEM(s, c, w) \ do { \ - memcpy(w, s, c); \ + memmove(w, s, c); \ w += c; \ } while (0) diff --git a/lib/isccc/sexpr.c b/lib/isccc/sexpr.c index e96536dfce..44efd908db 100644 --- a/lib/isccc/sexpr.c +++ b/lib/isccc/sexpr.c @@ -112,7 +112,7 @@ isccc_sexpr_frombinary(const isccc_region_t *region) } sexpr->value.as_region.rend = sexpr->value.as_region.rstart + region_size; - memcpy(sexpr->value.as_region.rstart, region->rstart, region_size); + memmove(sexpr->value.as_region.rstart, region->rstart, region_size); /* * NUL terminate. */ diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 0638b3fd29..397a4f4776 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -391,7 +391,7 @@ parse_updatepolicy(cfg_parser_t *pctx, const cfg_type_t *type, isc_mem_put(pctx->mctx, obj, sizeof(*obj)); return (ISC_R_NOMEMORY); } - memcpy(obj->value.string.base, "local", 5); + memmove(obj->value.string.base, "local", 5); obj->value.string.base[5] = '\0'; *ret = obj; return (ISC_R_SUCCESS); diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 38325d7fb0..0cf57ef137 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -702,7 +702,7 @@ create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type, isc_mem_put(pctx->mctx, obj, sizeof(*obj)); return (ISC_R_NOMEMORY); } - memcpy(obj->value.string.base, contents, len); + memmove(obj->value.string.base, contents, len); obj->value.string.base[len] = '\0'; *ret = obj; @@ -1638,7 +1638,7 @@ parse_token(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { goto cleanup; } obj->value.string.length = r.length; - memcpy(obj->value.string.base, r.base, r.length); + memmove(obj->value.string.base, r.base, r.length); obj->value.string.base[r.length] = '\0'; *ret = obj; return (result); diff --git a/lib/lwres/context.c b/lib/lwres/context.c index e16bc0aa6b..97de740d05 100644 --- a/lib/lwres/context.c +++ b/lib/lwres/context.c @@ -303,8 +303,8 @@ context_connect(lwres_context_t *ctx) { int domain; if (ctx->confdata.lwnext != 0) { - memcpy(&ctx->address, &ctx->confdata.lwservers[0], - sizeof(lwres_addr_t)); + memmove(&ctx->address, &ctx->confdata.lwservers[0], + sizeof(lwres_addr_t)); LWRES_LINK_INIT(&ctx->address, link); } else { /* The default is the IPv4 loopback address 127.0.0.1. */ @@ -318,16 +318,16 @@ context_connect(lwres_context_t *ctx) { } if (ctx->address.family == LWRES_ADDRTYPE_V4) { - memcpy(&sin.sin_addr, ctx->address.address, - sizeof(sin.sin_addr)); + memmove(&sin.sin_addr, ctx->address.address, + sizeof(sin.sin_addr)); sin.sin_port = htons(lwres_udp_port); sin.sin_family = AF_INET; sa = (struct sockaddr *)&sin; salen = sizeof(sin); domain = PF_INET; } else if (ctx->address.family == LWRES_ADDRTYPE_V6) { - memcpy(&sin6.sin6_addr, ctx->address.address, - sizeof(sin6.sin6_addr)); + memmove(&sin6.sin6_addr, ctx->address.address, + sizeof(sin6.sin6_addr)); sin6.sin6_port = htons(lwres_udp_port); sin6.sin6_family = AF_INET6; sa = (struct sockaddr *)&sin6; diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 7d5f2fb04c..0b637b8c72 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -392,7 +392,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, * Convert to a V4 mapped address. */ struct in6_addr *a6 = (struct in6_addr *)abuf; - memcpy(&a6->s6_addr[12], &a6->s6_addr[0], 4); + memmove(&a6->s6_addr[12], &a6->s6_addr[0], 4); memset(&a6->s6_addr[10], 0xff, 2); memset(&a6->s6_addr[0], 0, 10); goto inet6_addr; @@ -427,7 +427,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, ai_list = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy((char *)ai->ai_addr + addroff, abuf, addrsize); + memmove((char *)ai->ai_addr + addroff, abuf, addrsize); if (flags & AI_CANONNAME) { #if defined(LWRES_HAVE_SIN6_SCOPE_ID) if (ai->ai_family == AF_INET6) @@ -579,7 +579,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); } else { lwres = lwres_getaddrsbyname(lwrctx, hostname, LWRES_ADDRTYPE_V4, &by); @@ -597,8 +597,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy(&SIN(ai->ai_addr)->sin_addr, - addr->address, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, + addr->address, 4); if (flags & AI_CANONNAME) { ai->ai_canonname = strdup(by->realname); if (ai->ai_canonname == NULL) @@ -643,7 +643,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); } else { lwres = lwres_getaddrsbyname(lwrctx, hostname, LWRES_ADDRTYPE_V6, &by); @@ -661,8 +661,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, - addr->address, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, + addr->address, 16); if (flags & AI_CANONNAME) { ai->ai_canonname = strdup(by->realname); if (ai->ai_canonname == NULL) diff --git a/lib/lwres/gethost.c b/lib/lwres/gethost.c index 60d9d5ee99..3a0c9ca46f 100644 --- a/lib/lwres/gethost.c +++ b/lib/lwres/gethost.c @@ -331,7 +331,7 @@ copytobuf(struct hostent *he, struct hostent *hptr, char *buf, int buflen) { */ hptr->h_addr_list = ptr; for (i = 0; he->h_addr_list[i]; i++, ptr++) { - memcpy(cp, he->h_addr_list[i], n); + memmove(cp, he->h_addr_list[i], n); hptr->h_addr_list[i] = cp; cp += n; } diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 300376ef13..294bb92cc7 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -420,7 +420,7 @@ lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { /* * Restore original address. */ - memcpy(he2->h_addr, src, len); + memmove(he2->h_addr, src, len); return (he2); } @@ -595,7 +595,7 @@ scan_interfaces6(int *have_v4, int *have_v6) { for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&lifreq, cp, sizeof(lifreq)); + memmove(&lifreq, cp, sizeof(lifreq)); #ifdef LWRES_PLATFORM_HAVESALEN #ifdef FIX_ZERO_SA_LEN if (lifreq.lifr_addr.sa_len == 0) @@ -620,10 +620,10 @@ scan_interfaces6(int *have_v4, int *have_v6) { switch (lifreq.lifr_addr.ss_family) { case AF_INET: if (*have_v4 == 0) { - memcpy(&in4, - &((struct sockaddr_in *) - &lifreq.lifr_addr)->sin_addr, - sizeof(in4)); + memmove(&in4, + &((struct sockaddr_in *) + &lifreq.lifr_addr)->sin_addr, + sizeof(in4)); if (in4.s_addr == INADDR_ANY) break; n = ioctl(s, SIOCGLIFFLAGS, (char *)&lifreq); @@ -636,10 +636,10 @@ scan_interfaces6(int *have_v4, int *have_v6) { break; case AF_INET6: if (*have_v6 == 0) { - memcpy(&in6, - &((struct sockaddr_in6 *) - &lifreq.lifr_addr)->sin6_addr, - sizeof(in6)); + memmove(&in6, + &((struct sockaddr_in6 *) + &lifreq.lifr_addr)->sin6_addr, + sizeof(in6)); if (memcmp(&in6, &in6addr_any, sizeof(in6)) == 0) break; @@ -760,7 +760,7 @@ scan_interfaces(int *have_v4, int *have_v6) { for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&u.ifreq, cp, sizeof(u.ifreq)); + memmove(&u.ifreq, cp, sizeof(u.ifreq)); #ifdef LWRES_PLATFORM_HAVESALEN #ifdef FIX_ZERO_SA_LEN if (u.ifreq.ifr_addr.sa_len == 0) @@ -775,7 +775,7 @@ scan_interfaces(int *have_v4, int *have_v6) { cpsize = sizeof(u.ifreq.ifr_name) + u.ifreq.ifr_addr.sa_len; #endif /* HAVE_MINIMUM_IFREQ */ if (cpsize > sizeof(u.ifreq) && cpsize <= sizeof(u)) - memcpy(&u.ifreq, cp, cpsize); + memmove(&u.ifreq, cp, cpsize); #elif defined SIOCGIFCONF_ADDR cpsize = sizeof(u.ifreq); #else @@ -787,10 +787,10 @@ scan_interfaces(int *have_v4, int *have_v6) { switch (u.ifreq.ifr_addr.sa_family) { case AF_INET: if (*have_v4 == 0) { - memcpy(&in4, - &((struct sockaddr_in *) - &u.ifreq.ifr_addr)->sin_addr, - sizeof(in4)); + memmove(&in4, + &((struct sockaddr_in *) + &u.ifreq.ifr_addr)->sin_addr, + sizeof(in4)); if (in4.s_addr == INADDR_ANY) break; n = ioctl(s, SIOCGIFFLAGS, (char *)&u.ifreq); @@ -803,10 +803,10 @@ scan_interfaces(int *have_v4, int *have_v6) { break; case AF_INET6: if (*have_v6 == 0) { - memcpy(&in6, - &((struct sockaddr_in6 *) - &u.ifreq.ifr_addr)->sin6_addr, - sizeof(in6)); + memmove(&in6, + &((struct sockaddr_in6 *) + &u.ifreq.ifr_addr)->sin6_addr, + sizeof(in6)); if (memcmp(&in6, &in6addr_any, sizeof(in6)) == 0) break; @@ -908,13 +908,13 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) * Convert to mapped if required. */ if (af == AF_INET6 && he1->h_addrtype == AF_INET) { - memcpy(*npp, in6addr_mapped, - sizeof(in6addr_mapped)); - memcpy(*npp + sizeof(in6addr_mapped), *cpp, - INADDRSZ); + memmove(*npp, in6addr_mapped, + sizeof(in6addr_mapped)); + memmove(*npp + sizeof(in6addr_mapped), *cpp, + INADDRSZ); } else { - memcpy(*npp, *cpp, - (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); + memmove(*npp, *cpp, + (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); } cpp++; npp++; @@ -931,13 +931,13 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) * Convert to mapped if required. */ if (af == AF_INET6 && he2->h_addrtype == AF_INET) { - memcpy(*npp, in6addr_mapped, - sizeof(in6addr_mapped)); - memcpy(*npp + sizeof(in6addr_mapped), *cpp, - INADDRSZ); + memmove(*npp, in6addr_mapped, + sizeof(in6addr_mapped)); + memmove(*npp + sizeof(in6addr_mapped), *cpp, + INADDRSZ); } else { - memcpy(*npp, *cpp, - (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); + memmove(*npp, *cpp, + (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); } cpp++; npp++; @@ -1060,7 +1060,7 @@ hostfromaddr(lwres_gnbaresponse_t *addr, int af, const void *src) { he->h_addr_list[0] = malloc(he->h_length); if (he->h_addr_list[0] == NULL) goto cleanup; - memcpy(he->h_addr_list[0], src, he->h_length); + memmove(he->h_addr_list[0], src, he->h_length); he->h_addr_list[1] = NULL; return (he); @@ -1140,7 +1140,7 @@ hostfromname(lwres_gabnresponse_t *name, int af) { he->h_addr_list[i] = malloc(he->h_length); if (he->h_addr_list[i] == NULL) goto cleanup; - memcpy(he->h_addr_list[i], addr->address, he->h_length); + memmove(he->h_addr_list[i], addr->address, he->h_length); addr = LWRES_LIST_NEXT(addr, link); i++; } diff --git a/lib/lwres/getrrset.c b/lib/lwres/getrrset.c index 16af741d2e..981de235db 100644 --- a/lib/lwres/getrrset.c +++ b/lib/lwres/getrrset.c @@ -228,8 +228,8 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, result = ERRSET_NOMEMORY; goto fail; } - memcpy(rrset->rri_rdatas[i].rdi_data, response->rdatas[i], - rrset->rri_rdatas[i].rdi_length); + memmove(rrset->rri_rdatas[i].rdi_data, response->rdatas[i], + rrset->rri_rdatas[i].rdi_length); } rrset->rri_nsigs = response->nsigs; rrset->rri_sigs = sane_calloc(rrset->rri_nsigs, @@ -246,8 +246,8 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, result = ERRSET_NOMEMORY; goto fail; } - memcpy(rrset->rri_sigs[i].rdi_data, response->sigs[i], - rrset->rri_sigs[i].rdi_length); + memmove(rrset->rri_sigs[i].rdi_data, response->sigs[i], + rrset->rri_sigs[i].rdi_length); } lwres_grbnresponse_free(lwrctx, &response); diff --git a/lib/lwres/lwbuffer.c b/lib/lwres/lwbuffer.c index 49aaeb7bc9..92dbb02c06 100644 --- a/lib/lwres/lwbuffer.c +++ b/lib/lwres/lwbuffer.c @@ -339,7 +339,7 @@ lwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base, REQUIRE(b->used + length <= b->length); cp = (unsigned char *)b->base + b->used; - memcpy(cp, base, length); + memmove(cp, base, length); b->used += length; } @@ -357,5 +357,5 @@ lwres_buffer_getmem(lwres_buffer_t *b, unsigned char *base, cp += b->current; b->current += length; - memcpy(base, cp, length); + memmove(base, cp, length); } diff --git a/lib/lwres/lwconfig.c b/lib/lwres/lwconfig.c index e9a867100f..23cc885992 100644 --- a/lib/lwres/lwconfig.c +++ b/lib/lwres/lwconfig.c @@ -455,16 +455,16 @@ lwres_create_addr(const char *buffer, lwres_addr_t *addr, int convert_zero) { unsigned char zeroaddress[] = {0, 0, 0, 0}; unsigned char loopaddress[] = {127, 0, 0, 1}; if (memcmp(&v4, zeroaddress, 4) == 0) - memcpy(&v4, loopaddress, 4); + memmove(&v4, loopaddress, 4); } addr->family = LWRES_ADDRTYPE_V4; addr->length = NS_INADDRSZ; - memcpy((void *)addr->address, &v4, NS_INADDRSZ); + memmove((void *)addr->address, &v4, NS_INADDRSZ); } else if (lwres_net_pton(AF_INET6, buffer, &v6) == 1) { addr->family = LWRES_ADDRTYPE_V6; addr->length = NS_IN6ADDRSZ; - memcpy((void *)addr->address, &v6, NS_IN6ADDRSZ); + memmove((void *)addr->address, &v6, NS_IN6ADDRSZ); } else { return (LWRES_R_FAILURE); /* Unrecognised format. */ } diff --git a/lib/lwres/lwinetpton.c b/lib/lwres/lwinetpton.c index 65a8998ce1..bd52e2320b 100644 --- a/lib/lwres/lwinetpton.c +++ b/lib/lwres/lwinetpton.c @@ -116,7 +116,7 @@ inet_pton4(const char *src, unsigned char *dst) { } if (octets < 4) return (0); - memcpy(dst, tmp, NS_INADDRSZ); + memmove(dst, tmp, NS_INADDRSZ); return (1); } @@ -210,6 +210,6 @@ inet_pton6(const char *src, unsigned char *dst) { } if (tp != endp) return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); + memmove(dst, tmp, NS_IN6ADDRSZ); return (1); } diff --git a/lib/lwres/lwresutil.c b/lib/lwres/lwresutil.c index 3bf5660f3d..d947def7a1 100644 --- a/lib/lwres/lwresutil.c +++ b/lib/lwres/lwresutil.c @@ -390,7 +390,7 @@ lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, request.flags = 0; request.addr.family = addrtype; request.addr.length = addrlen; - memcpy(request.addr.address, addr, addrlen); + memmove(request.addr.address, addr, addrlen); pkt.pktflags = 0; pkt.serial = serial; pkt.result = 0; diff --git a/lib/samples/nsprobe.c b/lib/samples/nsprobe.c index 1d7ed3b4c9..c579b2dd31 100644 --- a/lib/samples/nsprobe.c +++ b/lib/samples/nsprobe.c @@ -1101,7 +1101,7 @@ main(int argc, char *argv[]) { (long)res->ai_addrlen); exit(1); } - memcpy(&sa.type.sa, res->ai_addr, res->ai_addrlen); + memmove(&sa.type.sa, res->ai_addr, res->ai_addrlen); sa.length = res->ai_addrlen; freeaddrinfo(res); ISC_LINK_INIT(&sa, link); diff --git a/lib/samples/resolve.c b/lib/samples/resolve.c index 68780ab684..724526e509 100644 --- a/lib/samples/resolve.c +++ b/lib/samples/resolve.c @@ -202,7 +202,7 @@ addserver(dns_client_t *client, const char *addrstr, const char *port, exit(1); } INSIST(res->ai_addrlen <= sizeof(sa.type)); - memcpy(&sa.type, res->ai_addr, res->ai_addrlen); + memmove(&sa.type, res->ai_addr, res->ai_addrlen); sa.length = res->ai_addrlen; freeaddrinfo(res); ISC_LINK_INIT(&sa, link); diff --git a/lib/samples/sample-request.c b/lib/samples/sample-request.c index 07baf39507..fe805216b9 100644 --- a/lib/samples/sample-request.c +++ b/lib/samples/sample-request.c @@ -221,7 +221,7 @@ main(int argc, char *argv[]) { exit(1); } INSIST(res->ai_addrlen <= sizeof(sa.type)); - memcpy(&sa.type, res->ai_addr, res->ai_addrlen); + memmove(&sa.type, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); sa.length = res->ai_addrlen; ISC_LINK_INIT(&sa, link); diff --git a/lib/samples/sample-update.c b/lib/samples/sample-update.c index 2c35baa6e2..5a3b9b3bdb 100644 --- a/lib/samples/sample-update.c +++ b/lib/samples/sample-update.c @@ -188,7 +188,7 @@ main(int argc, char *argv[]) { exit(1); } INSIST(res->ai_addrlen <= sizeof(sa_auth.type)); - memcpy(&sa_auth.type, res->ai_addr, res->ai_addrlen); + memmove(&sa_auth.type, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); sa_auth.length = res->ai_addrlen; ISC_LINK_INIT(&sa_auth, link); @@ -210,7 +210,7 @@ main(int argc, char *argv[]) { exit(1); } INSIST(res->ai_addrlen <= sizeof(sa_recursive.type)); - memcpy(&sa_recursive.type, res->ai_addr, res->ai_addrlen); + memmove(&sa_recursive.type, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); sa_recursive.length = res->ai_addrlen; ISC_LINK_INIT(&sa_recursive, link);