diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-12-26 01:23:21 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-12-26 01:29:02 -0500 |
commit | 1643e0e287797f99825322124a26c961cca7c6c3 (patch) | |
tree | 58a0a87c80edcb0c9c5373dfbd1defafbe4586ce | |
parent | b07d7d6af0c823eea31829d48e68841973d6c7b6 (diff) | |
download | rockbox-1643e0e287.tar.gz rockbox-1643e0e287.zip |
[Bugfix] metadata.c copy_mp3entry() dest and orig may overlap
I meant to add this with the last patch b07d7d6
since it may supply UNBUFFERED_ID3 to the peek function
which uses UNBUFFERED_ID3 and will try to copy it back
wich is undefined behavior for memcpy
Change-Id: I91160570adac22134c84d3b37f8fcecb097d87d6
-rw-r--r-- | lib/rbcodec/metadata/metadata.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c index 0820c649c2..ace252b2ce 100644 --- a/lib/rbcodec/metadata/metadata.c +++ b/lib/rbcodec/metadata/metadata.c @@ -522,8 +522,11 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig) { - memcpy(dest, orig, sizeof(struct mp3entry)); - adjust_mp3entry(dest, dest, orig); + if (dest != orig) + { + memcpy(dest, orig, sizeof(struct mp3entry)); + adjust_mp3entry(dest, dest, orig); + } } /* A shortcut to simplify the common task of clearing the struct */ |