https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3af7cb825fbdc6f515071…
commit 3af7cb825fbdc6f5150710169096367f14bdc451
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Apr 28 20:23:35 2019 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Jul 20 13:56:18 2019 +0200
[NTOSKRNL] Replace overlapping strcopy with memmove
Fixes 4 GCC 8 warnings of the kind:
ntoskrnl/kdbg/kdb_cli.c:3015:21: error: 'strcpy' accessing 1 byte at offsets 0
and [0, 2147483647] may overlap 1 byte at offset 0 [-Werror=restrict]
strcpy(p2, p2 + j);
^~~~~~~~~~~~~~~~~~
---
ntoskrnl/kdbg/kdb_cli.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index 32d2fe553a5..e4921e488e9 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -2662,15 +2662,16 @@ KdbpPrint(
{
while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
{
+ size_t len = strlen(p2);
if (p2[1] == '[')
{
j = 2;
while (!isalpha(p2[j++]));
- strcpy(p2, p2 + j);
+ memmove(p2, p2 + j, len + 1 - j);
}
else
{
- strcpy(p2, p2 + 1);
+ memmove(p2, p2 + 1, len);
}
}
}
@@ -3007,15 +3008,16 @@ KdbpPager(
{
while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
{
+ size_t len = strlen(p2);
if (p2[1] == '[')
{
j = 2;
while (!isalpha(p2[j++]));
- strcpy(p2, p2 + j);
+ memmove(p2, p2 + j, len + 1 - j);
}
else
{
- strcpy(p2, p2 + 1);
+ memmove(p2, p2 + 1, len);
}
}
}