mirror of
				https://git.ffmpeg.org/ffmpeg.git
				synced 2025-11-04 01:30:56 +00:00 
			
		
		
		
	mp3enc: avoid truncating id3v1 tags by one byte
Avoid writing the trailing null-byte for id3v1 tags if length reaches max length. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		
							parent
							
								
									33789862aa
								
							
						
					
					
						commit
						0f39fa0279
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -55,11 +55,12 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
 | 
			
		|||
    buf[0] = 'T';
 | 
			
		||||
    buf[1] = 'A';
 | 
			
		||||
    buf[2] = 'G';
 | 
			
		||||
    count += id3v1_set_string(s, "TIT2",    buf +  3, 30);       //title
 | 
			
		||||
    count += id3v1_set_string(s, "TPE1",    buf + 33, 30);       //author|artist
 | 
			
		||||
    count += id3v1_set_string(s, "TALB",    buf + 63, 30);       //album
 | 
			
		||||
    count += id3v1_set_string(s, "TDRL",    buf + 93,  4);       //date
 | 
			
		||||
    count += id3v1_set_string(s, "comment", buf + 97, 30);
 | 
			
		||||
    /* we knowingly overspecify each tag length by one byte to compensate for the mandatory null byte added by av_strlcpy */
 | 
			
		||||
    count += id3v1_set_string(s, "TIT2",    buf +  3, 30 + 1);       //title
 | 
			
		||||
    count += id3v1_set_string(s, "TPE1",    buf + 33, 30 + 1);       //author|artist
 | 
			
		||||
    count += id3v1_set_string(s, "TALB",    buf + 63, 30 + 1);       //album
 | 
			
		||||
    count += id3v1_set_string(s, "TDRL",    buf + 93,  4 + 1);       //date
 | 
			
		||||
    count += id3v1_set_string(s, "comment", buf + 97, 30 + 1);
 | 
			
		||||
    if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
 | 
			
		||||
        buf[125] = 0;
 | 
			
		||||
        buf[126] = atoi(tag->value);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue