diff options
Diffstat (limited to 'audio-libs/libid3tag/patches/libid3tag-0.15.1b-file-write.patch')
-rw-r--r-- | audio-libs/libid3tag/patches/libid3tag-0.15.1b-file-write.patch | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/audio-libs/libid3tag/patches/libid3tag-0.15.1b-file-write.patch b/audio-libs/libid3tag/patches/libid3tag-0.15.1b-file-write.patch new file mode 100644 index 0000000000..aa61d09f87 --- /dev/null +++ b/audio-libs/libid3tag/patches/libid3tag-0.15.1b-file-write.patch @@ -0,0 +1,52 @@ +diff -ur -x '*.lo' -x '*.o' -x config.h -x config.log libid3tag-0.15.1b/file.c libid3tag-0.15.1b-fixed/file.c +--- libid3tag-0.15.1b/file.c 2004-01-23 12:41:32.000000000 +0300 ++++ libid3tag-0.15.1b-fixed/file.c 2005-05-24 23:34:08.000000000 +0400 +@@ -37,6 +37,10 @@ + # include <assert.h> + # endif + ++# ifdef HAVE_SYS_STAT_H ++# include <sys/stat.h> ++# endif ++ + # include "id3tag.h" + # include "file.h" + # include "tag.h" +@@ -575,6 +579,10 @@ + int v2_write(struct id3_file *file, + id3_byte_t const *data, id3_length_t length) + { ++ struct stat st; ++ char *buffer; ++ id3_length_t datalen, offset; ++ + assert(!data || length > 0); + + if (data && +@@ -592,9 +600,25 @@ + } + + /* hard general case: rewrite entire file */ ++ if (stat(file->path, &st) == -1) ++ return -1; + +- /* ... */ ++ offset = file->tags ? file->tags[0].length : 0; ++ datalen = st.st_size - offset; ++ if ((buffer = (char *) malloc(datalen)) == NULL) ++ return -1; + ++ if (fseek(file->iofile, offset, SEEK_SET) == -1 || ++ fread(buffer, datalen, 1, file->iofile) != 1 || ++ fseek(file->iofile, 0, SEEK_SET) == -1 || ++ fwrite(data, length, 1, file->iofile) != 1 || ++ fwrite(buffer, datalen, 1, file->iofile) != 1 || ++ fflush(file->iofile) == EOF) { ++ free(buffer); ++ return -1; ++ } ++ free(buffer); ++ + done: + return 0; + } |