summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJorg Schuler <jcsjcs@users.sourceforge.net>2007-06-01 13:56:32 +0000
committerJorg Schuler <jcsjcs@users.sourceforge.net>2007-06-01 13:56:32 +0000
commit0f0282ae958409f87b0da99d4f0664cee0d76afa (patch)
tree54443d4dd2134351da8c4cbfd998f68fea159a6b /src
parent5596541efc1090ba11dc93f1236d4b7e9affc136 (diff)
downloadlibgpod-tmz-0f0282ae958409f87b0da99d4f0664cee0d76afa.tar.gz
libgpod-tmz-0f0282ae958409f87b0da99d4f0664cee0d76afa.tar.xz
libgpod-tmz-0f0282ae958409f87b0da99d4f0664cee0d76afa.zip
* src/db-artwork-parser.c (parse_mhba): non-zero terminated
string was copied using g_strdup() instead of g_strndup(). This affected album names of the Photo Database. src/db-artwork-writer.c (write_mhod_type_1): convert 'type' as 16 bit integer, not 32 bit integer. Potential problem on non-standard endian system (iPod side). src/db-itunes-parser.h: '#if 0' unused structure to avoid confusion. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1514 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src')
-rw-r--r--src/db-artwork-parser.c6
-rw-r--r--src/db-artwork-writer.c6
-rw-r--r--src/db-itunes-parser.h5
3 files changed, 11 insertions, 6 deletions
diff --git a/src/db-artwork-parser.c b/src/db-artwork-parser.c
index 7b84327..9d3c05d 100644
--- a/src/db-artwork-parser.c
+++ b/src/db-artwork-parser.c
@@ -355,15 +355,17 @@ parse_mhba (DBParseContext *ctx, GError *error)
mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset);
num_children = get_gint32 (mhba->num_mhods, ctx->byte_order);
while ((num_children > 0) && (mhod_ctx != NULL)) {
+ MhodHeaderArtworkType1 *mhod1;
/* FIXME: First mhod is album name, whats the others for? */
mhod = db_parse_context_get_m_header (mhod_ctx, ArtworkDB_MhodHeader, "mhod");
if (mhod == NULL) {
return -1;
}
db_parse_context_set_total_len (mhod_ctx, get_gint32(mhod->total_len, ctx->byte_order));
- album->name = g_strdup( (char *)((MhodHeaderArtworkType1*)mhod)->string );
+ mhod1 = (MhodHeaderArtworkType1*)mhod;
+ album->name = g_strndup ((gchar *)mhod1->string, mhod1->string_len);
cur_offset += mhod_ctx->total_len;
- dump_mhod_type_1 ((MhodHeaderArtworkType1*)mhod);
+ dump_mhod_type_1 (mhod1);
g_free (mhod_ctx);
num_children--;
}
diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c
index 9fef856..ff7f76c 100644
--- a/src/db-artwork-writer.c
+++ b/src/db-artwork-writer.c
@@ -330,7 +330,7 @@ write_mhod_type_1 (gchar *string, iPodBuffer *buffer)
padding = 4 - ( (total_bytes + len) % 4 );
mhod->padding = padding;
- mhod->type = get_gint32 (0x0001, buffer->byte_order);
+ mhod->type = get_gint16 (0x01, buffer->byte_order);
/* Make sure we have enough free space to write the string */
if (ipod_buffer_maybe_grow (buffer, total_bytes + len + padding ) != 0) {
@@ -384,7 +384,7 @@ write_mhod_type_3 (gchar *string, iPodBuffer *buffer)
/* number of bytes of the string encoded in UTF-16 */
mhod->string_len = get_gint32 (2*len, buffer->byte_order);
padding = 4 - ( (total_bytes + 2*len) % 4 );
- mhod->padding = padding; /* high byte is padding length (0-3) */
+ mhod->padding = padding;
/* Make sure we have enough free space to write the string */
if (ipod_buffer_maybe_grow (buffer, total_bytes + 2*len+padding) != 0) {
@@ -410,7 +410,7 @@ write_mhod_type_3 (gchar *string, iPodBuffer *buffer)
/* e.g. len = 7 bytes, len%4 = 3, 4-3=1 -> requires 1 byte
padding */
padding = 4 - ( (total_bytes + len) % 4 );
- mhod->padding = padding; /* high byte is padding length (0-3) */
+ mhod->padding = padding;
/* Make sure we have enough free space to write the string */
if (ipod_buffer_maybe_grow (buffer, total_bytes + 2*len+padding) != 0) {
return -1;
diff --git a/src/db-itunes-parser.h b/src/db-itunes-parser.h
index 74fdd03..b699283 100644
--- a/src/db-itunes-parser.h
+++ b/src/db-itunes-parser.h
@@ -20,7 +20,7 @@
*
* This product is not supported/written/published by Apple!
*
- * $Id$
+ * $Id: db-itunes-parser.h,v 1.11 2007/04/27 14:09:59 jcsjcs Exp $
*/
@@ -377,6 +377,8 @@ struct _MhodHeaderArtworkType1 {
unsigned char string[];
};
+#if 0
+/* not used at all */
struct _MhodHeaderArtworkType3 {
unsigned char header_id[4];
gint32 header_len;
@@ -390,6 +392,7 @@ struct _MhodHeaderArtworkType3 {
gint32 unknown4;
gunichar2 string[];
};
+#endif
struct _ArtworkDB_MhodHeaderArtworkType3 {
unsigned char header_id[4];