commit 319ae6d958ac336e6b614fa8b38fa3396d0382f8 from: Thomas date: Thu Mar 28 12:23:56 2019 UTC empty buffer before writing empty the buffer the temporary music information is stored in to prevent corrupted text. this only has to be done when less bytes are read than before since otherwise these will only be overwritten. commit - 1aa7eef17892069fab528c922d949c77c86f632b commit + 319ae6d958ac336e6b614fa8b38fa3396d0382f8 blob - ed5a5c16e6ad4ca5530d407bf41277af0e61c727 blob + a9c2df64482101211537b5ff1910e18716b5e4bc --- id3v1.c +++ id3v1.c @@ -53,6 +53,9 @@ printid3v1(FILE *f) fread(buffer, 30, 1, f); printf("Album: %s\n", buffer); + /* empty the buffer before writing 4 bytes */ + /* last byte can be set to 0 since 0 == '\0' */ + memset(buffer, 0, sizeof(buffer)); /* read 4 bytes for the year */ fread(buffer, 4, 1, f); printf("Year: %s\n", buffer); @@ -61,6 +64,8 @@ printid3v1(FILE *f) fread(buffer, 30, 1, f); printf("Comment: %s\n", buffer); + /* empty the buffer before writing 1 byte */ + memset(buffer, 0, sizeof(buffer)); /* read 1 byte for the genre */ fread(buffer, 1, 1, f); printf("Genre: %d\n", buffer[0]);