shithub: sox

Download patch

ref: ab21e50c5ab36e94974cf9f55db891487c3e8f81
parent: 50857c46c03a85c72826e819f5e815aad4a4633d
author: Mans Rullgard <mans@mansr.com>
date: Mon Aug 3 06:44:06 EDT 2020

mp3: use memmove() where blocks might overlap [bug #327]

--- a/src/mp3-util.h
+++ b/src/mp3-util.h
@@ -268,7 +268,7 @@
     int read, padding = 0;
     size_t leftover = mad_stream.bufend - mad_stream.next_frame;
 
-    memcpy(p->mp3_buffer, mad_stream.this_frame, leftover);
+    memmove(p->mp3_buffer, mad_stream.this_frame, leftover);
     read = lsx_readbuf(ft, p->mp3_buffer + leftover, p->mp3_buffer_size - leftover);
     if (read <= 0) {
       lsx_debug("got exact duration by scan to EOF (frames=%" PRIuPTR " leftover=%" PRIuPTR ")", frames, leftover);
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -590,7 +590,7 @@
     size_t read;
     size_t leftover = p->Stream.bufend - p->Stream.next_frame;
 
-    memcpy(p->mp3_buffer, p->Stream.this_frame, leftover);
+    memmove(p->mp3_buffer, p->Stream.this_frame, leftover);
     read = lsx_readbuf(ft, p->mp3_buffer + leftover, p->mp3_buffer_size - leftover);
     if (read == 0) {
       lsx_debug("seek failure. unexpected EOF (frames=%" PRIuPTR " leftover=%" PRIuPTR ")", p->FrameCount, leftover);