Skip to content

Conversation

rwmjones
Copy link

@rwmjones rwmjones commented Mar 4, 2024

Coverity found the following test where memcpy is used to copy an overlapping buffer. memmove should be used instead.

Error: BUFFER_SIZE (CWE-474):
libmspack-0.10.1alpha/test/md5.c:281: overlapping_buffer: The source buffer "&ctx->buffer[64]" potentially overlaps with the destination buffer "ctx->buffer", which results in undefined behavior for "memcpy". libmspack-0.10.1alpha/test/md5.c:281: remediation: Use memmove instead of "memcpy".
  279|             md5_process_block (ctx->buffer, 64, ctx);
  280|             left_over -= 64;
  281|->           memcpy (ctx->buffer, &ctx->buffer[64], left_over);
  282|           }
  283|         ctx->buflen = left_over;

Coverity found the following test where memcpy is used to copy an
overlapping buffer.  'memmove' should be used instead.

Error: BUFFER_SIZE (CWE-474):
libmspack-0.10.1alpha/test/md5.c:281: overlapping_buffer: The source buffer "&ctx->buffer[64]" potentially overlaps with the destination buffer "ctx->buffer", which results in undefined behavior for "memcpy".
libmspack-0.10.1alpha/test/md5.c:281: remediation: Use memmove instead of "memcpy".
  279|             md5_process_block (ctx->buffer, 64, ctx);
  280|             left_over -= 64;
  281|->           memcpy (ctx->buffer, &ctx->buffer[64], left_over);
  282|           }
  283|         ctx->buflen = left_over;

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant