Fix potential overlap dest buffer
PATCH 1/1 Fix potential overlap dest buffer
To meet requirements of Common Criteria certification vulnerablility assessment. Static code analysis has been run and found the following error. Overlapping_buffer: The source buffer potentially overlaps with the destination buffer, which results in undefined behavior for "memcpy".
The change is to use memmove instead of memcpy.
--- sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sha1.c +1 -1
@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) {sha1_process_block (ctx->buffer,64 , ctx); left_over -=64 ; -memcpy (ctx->buffer, &ctx->buffer[16 ], left_over); +memmove (ctx->buffer, &ctx->buffer[16 ], left_over); } ctx->buflen = left_over; }
Signature · 1 line
2.29.2
Quoted 9 lines · Nigel Croxon
To meet requirements of Common Criteria certification vulnerablility assessment. Static code analysis has been run and found the following error.
Overlapping_buffer: The source buffer potentially overlaps with the destination buffer, which results in undefined behavior for "memcpy".The change is to use memmove instead of memcpy.
Signed-off-by Nigel Croxon <[email protected]>
Thanks,
NeilBrown
Quoted 21 lines
--- sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sha1.c +1
-1@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) {sha1_process_block (ctx->buffer,64 , ctx); left_over -=64 ; -memcpy (ctx->buffer, &ctx->buffer[16 ], left_over); +memmove (ctx->buffer, &ctx->buffer[16 ], left_over); } ctx->buflen = left_over; }Signature · 1 line
2.29.2
Dear Nigel,
Am 17.08.21 um 15:14 schrieb Nigel Croxon:
Quoted 1 line
To meet requirements of Common Criteria certification vulnerablility
vulnerability
Quoted 1 line
assessment.
That’s only part of a sentence? Is that supposed to be read as a continuation of the commit message summary: … to meet requirements …?
Quoted 2 lines
Static code analysis has been run and found the following error.
Overlapping_buffer: The source buffer potentially overlaps
It’d be great, if you denoted, which tool was run. Maybe even add a Found-by tag.
Quoted 15 lines
with the destination buffer, which results in undefined behavior for "memcpy".
The change is to use memmove instead of memcpy.
Signed-off-by Nigel Croxon <[email protected]>--- sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sha1.c +0
-0
sha1.c sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) · line 264
Quoted 8 lines
sha1.c +1
-1@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) {sha1_process_block (ctx->buffer,64 , ctx); left_over -=64 ; -memcpy (ctx->buffer, &ctx->buffer[16 ], left_over); +memmove (ctx->buffer, &ctx->buffer[16 ], left_over); } ctx->buflen = left_over; }
Kind regards,
Paul
Quoted 12 lines · Paul Menzel
Dear Nigel,
Am 17.08.21 um 15:14 schrieb Nigel Croxon:
Quoted 1 line
To meet requirements of Common Criteria certification vulnerablility
vulnerability
Quoted 1 line
assessment.
That’s only part of a sentence? Is that supposed to be read as a continuation of the commit message summary: … to meet requirements …?
Continuation of the commit message. Thanks for catching the spelling mistake.
Quoted 5 lines
Quoted 2 lines
Static code analysis has been run and found the following error.
Overlapping_buffer: The source buffer potentially overlapsIt’d be great, if you denoted, which tool was run. Maybe even add a Found-by tag.
I ran the Coverity scan on the latest build.
https://people.redhat.com/ncroxon/mdadm-4.2-rc2-scan-results.html
Quoted 32 lines
Quoted 23 lines
with the destination buffer, which results in undefined behavior for "memcpy".
The change is to use memmove instead of memcpy.
Signed-off-by Nigel Croxon <[email protected]>---
sha1.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)sha1.c +1
-1@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) { sha1_process_block (ctx->buffer, 64, ctx); left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); + memmove (ctx->buffer, &ctx->buffer[16], left_over); } ctx->buflen = left_over;Quoted 1 line
}
Reviewed-by Paul Menzel <[email protected]>Kind regards,
Paul
Jes Sorensen
AppliedQuoted 19 lines · Nigel Croxon
To meet requirements of Common Criteria certification vulnerablility assessment. Static code analysis has been run and found the following error.
Overlapping_buffer: The source buffer potentially overlaps with the destination buffer, which results in undefined behavior for "memcpy".The change is to use memmove instead of memcpy.
Signed-off-by Nigel Croxon <[email protected]>--- sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sha1.c +0
-0
sha1.c sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) · line 264
Quoted 8 lines
sha1.c +1
-1@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) {sha1_process_block (ctx->buffer,64 , ctx); left_over -=64 ; -memcpy (ctx->buffer, &ctx->buffer[16 ], left_over); +memmove (ctx->buffer, &ctx->buffer[16 ], left_over); } ctx->buflen = left_over; }
Applied!
Thanks,
Jes