From: Yasuhiro M. <mat...@gm...> - 2014-02-28 00:42:28
|
[snip] > [from URL above:] > > --- a/src/itdb_device.c > > +++ b/src/itdb_device.c > > @@ -1047,7 +1047,7 @@ gboolean itdb_device_read_sysinfo (Itdb_Device *device) > > gchar *ptr; > > gint len = strlen (buf); > > /* suppress newline at end of line */ > > - if ((len>0) && (buf[len-1]==0x0a)) > > + if ((len>0) && (buf[len-1]==0x0a || buf[len-1]==0x0d)) > > I don't know what this data is for, but (going with the comment) > shouldn't you strip newlines and carriage returns? So something like > (untested): > > while(len>0 && (buf[len-1]==0x0a || buf[len-1]==0x0d)) > { > buf[len-1]=0; > --len; > } > > And, again speaking from ignorance: it's not clear why the fopen() on > line 1041 of this file doesn't get the "rb" treatment like the other > fopen() calls. Yes, you are right. This should be triming carriage return. And this part doesn't need to be modified. So patch become below. diff --git a/src/itdb_artwork.c b/src/itdb_artwork.c index c595d70..14dc960 100644 --- a/src/itdb_artwork.c +++ b/src/itdb_artwork.c @@ -653,7 +653,7 @@ get_pixel_data (Itdb_Device *device, Itdb_Thumb_Ipod_Item *thumb) goto error; } - f = fopen (filename, "r"); + f = fopen (filename, "rb"); if (f == NULL) { g_print ("Failed to open %s: %s\n", filename, strerror (errno)); @@ -1108,7 +1108,7 @@ gboolean itdb_device_write_sysinfo (Itdb_Device *device, GError **error) if (devicedir) { gchar *sysfile = g_build_filename (devicedir, "SysInfo", NULL); - FILE *sysinfo = fopen (sysfile, "w"); + FILE *sysinfo = fopen (sysfile, "wb"); if (sysinfo) { if (device->sysinfo) @@ -1538,7 +1538,7 @@ static guint endianess_check_path (const gchar *path, const gchar *hdr) if (path) { - int fd = open (path, O_RDONLY); + int fd = open (path, O_RDONLY | O_BINARY); if (fd != -1) { gchar buf[4]; diff --git a/src/itdb_tzinfo.c b/src/itdb_tzinfo.c index 3c29947..a34eb36 100644 --- a/src/itdb_tzinfo.c +++ b/src/itdb_tzinfo.c @@ -98,7 +98,7 @@ static gboolean itdb_device_read_raw_timezone (const char *prefs_path, return FALSE; } - f = fopen (prefs_path, "r"); + f = fopen (prefs_path, "rb"); if (f == NULL) { return FALSE; } diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c index 6b47aa6..a1e8dae 100644 --- a/src/ithumb-writer.c +++ b/src/ithumb-writer.c @@ -1262,7 +1262,7 @@ static gboolean ithumb_rearrange_thumbnail_file (gpointer _key, goto out; } - fd = open (filename, O_RDWR, 0); + fd = open (filename, O_RDWR | O_BINARY, 0); if (fd == -1) { *result = FALSE; -- - Yasuhiro Matsumoto |