Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exceeds data length error on some mp3 files with version4 #88

Closed
andriypohorilko opened this issue Feb 5, 2022 · 5 comments
Closed

Comments

@andriypohorilko
Copy link

andriypohorilko commented Feb 5, 2022

I get an error -[Foundation.__NSSwiftData subdataWithRange:]: range {115888, 24847503} exceeds data length 11634651
on trying to read mp3 songs with version4.

I've uploaded the mp3 file below.

I use ID3TagEditor 4.1.3

Steps to reproduce the behavior:

  1. Go to Example App macOS version
  2. Add file "The Black Eyed Peas - I Gotta Feeling" to the project
  3. Change "pathFor(name:)" in ViewController file, line 20 to "The Black Eyed Peas - I Gotta Feeling"
  4. Run the app

The Black Eyed Peas - I Gotta Feeling.mp3.zip

@andriypohorilko
Copy link
Author

Problem is in ID3FramesParser.parse(mp3:id3Tag:) func.
At some point NSRange(location: currentFramePosition, length: frameSize) becomes bigger than mp3.length itself.

So, this code seems to solve the issue but I don't think this is the correct way.
if currentFramePosition + frameSize > mp3.length { return }

Screenshot 2022-02-06 at 10 36 54

andriypohorilko added a commit to andriypohorilko/ID3TagEditor that referenced this issue Feb 6, 2022
@chicio
Copy link
Owner

chicio commented Feb 7, 2022

Hi @andriypohorilko ,

this error could happen if:

  • the id3 tag is not well formed with respect to the standard (ID3TagEditor is strict)
  • the id3 tag contains some encoding for the text frames that it is still not supported

I will try to debug it in the following weekends (after finishing some improvement I'm doing to the read API). If you discover something new just let me know.
Thank you for using ID3TagEditor.

Fabrizio.

@chicio
Copy link
Owner

chicio commented Feb 11, 2022

Hi @andriypohorilko, I debug your mp3 and put in place some test. The problem is related to how it is stored the attached picture frame size. Seems like your mp3 has this data saved as a normal integer instead of a Synchsafe one. Anyway I will try to add a fallback to support your case (because seems like other reader are not following the standard strictly as I do). I will keep you updated.

@chicio
Copy link
Owner

chicio commented Feb 11, 2022

Hi @andriypohorilko, I made further investigation and I was wrong. The size reported in a frame after the APIC (images) is wrong. I would close these as the only thing I could do is doing a fallback like the one you suggested and keep the frames parsed until that moment.

chicio added a commit that referenced this issue Feb 11, 2022
@chicio
Copy link
Owner

chicio commented Feb 11, 2022

Fix released in version 4.2.1

@chicio chicio closed this as completed Feb 11, 2022
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

No branches or pull requests

2 participants