Re: [Rhythmbox-devel] music sharing patch #2



On Tue, 2005-08-09 at 12:25 +0100, Peter Robinson wrote:
> The second problem (when trying to compile it not through my rpm build
> system) was due I think to FC4 using gcc 4 which is stricter when it
> comes to some things. Output below.
<snip output>

The daap code doesn't compile with warnings about signedness of
characters (which --enable-more-warnings turns on), and I found this out
about an hour ago. I've attached a patch that will make it compile - I
think it should work fine, but it might break some code that depends on
the signedness of various strings (I haven't had a chance to test it
properly yet).


Cheers,

James "Doc" Livingston 
-- 
"Hmmm... Perhaps Magic just consists of hacking the prayer firewall. How
many Hail Marys do we need for a buffer overflow attack?" 
    -- Bob Dowling 
--- rhythmbox--daap-orig/daapsharing/rb-daap-structure.c	2005-08-09 20:21:02.000000000 +1000
+++ rhythmbox/daapsharing/rb-daap-structure.c	2005-08-09 20:43:31.000000000 +1000
@@ -256,7 +256,7 @@
 	RBDAAPType rb_daap_type;
 	guint32 size = GINT32_TO_BE (item->size);
 
-	g_byte_array_append (array, rb_daap_content_code_string (item->content_code), 4);
+	g_byte_array_append (array, (guchar*) rb_daap_content_code_string (item->content_code), 4);
 	g_byte_array_append (array, (const guint8 *)&size, 4);
 	
 	rb_daap_type = rb_daap_content_code_rb_daap_type (item->content_code);
@@ -264,7 +264,7 @@
 	switch (rb_daap_type) {
 		case RB_DAAP_TYPE_BYTE: 
 		case RB_DAAP_TYPE_SIGNED_INT: {
-			gchar c = g_value_get_char (&(item->content));
+			guchar c = g_value_get_char (&(item->content));
 			
 			g_byte_array_append (array, &c, 1);
 			
--- rhythmbox--daap-orig/sources/rb-daap-connection.c	2005-08-09 20:21:03.000000000 +1000
+++ rhythmbox/sources/rb-daap-connection.c	2005-08-09 20:41:52.000000000 +1000
@@ -300,13 +300,13 @@
 
 
 static int staticHashDone = 0;
-static char staticHash_42[256*65] = {0};
-static char staticHash_45[256*65] = {0};
+static unsigned char staticHash_42[256*65] = {0};
+static unsigned char staticHash_45[256*65] = {0};
 
-static const char hexchars[] = "0123456789ABCDEF";
-static const char appleCopyright[] = "Copyright 2003 Apple Computer, Inc.";
+static const unsigned char hexchars[] = "0123456789ABCDEF";
+static const unsigned char appleCopyright[] = "Copyright 2003 Apple Computer, Inc.";
 
-static void DigestToString(const unsigned char *digest, char *string)
+static void DigestToString(const unsigned char *digest, unsigned char *string)
 {
     int i;
     for (i = 0; i < 16; i++)
@@ -322,13 +322,13 @@
     MD5_CTX ctx;
     unsigned char *p = staticHash_42;
     int i;
-    char buf[16];
+    unsigned char buf[16];
 
     for (i = 0; i < 256; i++)
     {
         OpenDaap_MD5Init(&ctx, 0);
 
-#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, str, strlen(str))
+#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (const unsigned char*)str, strlen(str))
 
         if ((i & 0x80) != 0)
             MD5_STRUPDATE("Accept-Language");
@@ -382,13 +382,13 @@
     MD5_CTX ctx;
     unsigned char *p = staticHash_45;
     int i;
-    char buf[16];
+    unsigned char buf[16];
 
     for (i = 0; i < 256; i++)
     {
         OpenDaap_MD5Init(&ctx, 1);
 
-#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, str, strlen(str))
+#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (const unsigned char*)str, strlen(str))
 
         if ((i & 0x40) != 0)
             MD5_STRUPDATE("eqwsdxcqwesdc");
@@ -439,15 +439,15 @@
 }
 
 static void rb_daap_hash_generate (short version_major, 
-				const guchar *url, 
+				const gchar *url, 
 				guchar hash_select, 
-				guchar *out, 
+				gchar *out, 
 				gint request_id)
 {
-    char buf[16];
+    unsigned char buf[16];
     MD5_CTX ctx;
 
-    char *hashTable = (version_major == 3) ?
+    unsigned char *hashTable = (version_major == 3) ?
                       staticHash_45 : staticHash_42;
 
     if (!staticHashDone)
@@ -459,8 +459,8 @@
 
     OpenDaap_MD5Init (&ctx, (version_major == 3) ? 1 : 0);
 
-    OpenDaap_MD5Update (&ctx, url, strlen(url));
-    OpenDaap_MD5Update (&ctx, appleCopyright, strlen (appleCopyright));
+    OpenDaap_MD5Update (&ctx, (const guchar*)url, strlen((const char*)url));
+    OpenDaap_MD5Update (&ctx, appleCopyright, strlen ((const char*)appleCopyright));
 
     OpenDaap_MD5Update (&ctx, &hashTable[hash_select * 65], 32);
 
@@ -468,11 +468,11 @@
     {
         char scribble[20];
         sprintf (scribble, "%u", request_id);
-        OpenDaap_MD5Update (&ctx, scribble, strlen (scribble));
+        OpenDaap_MD5Update (&ctx, (const unsigned char*)scribble, strlen (scribble));
     }
 
     OpenDaap_MD5Final (&ctx, buf);
-    DigestToString (buf, out);
+    DigestToString (buf, (guchar*)out);
 
     return;
 }
--- rhythmbox--daap-orig/sources/rb-daap-source.c	2005-08-09 20:21:03.000000000 +1000
+++ rhythmbox/sources/rb-daap-source.c	2005-08-09 21:03:28.000000000 +1000
@@ -276,7 +276,7 @@
 					  NULL);
 
 	if (result != GNOME_VFS_OK) {
-		g_warning ("Could not start listening for DAAP hosts");
+		g_warning ("Could not start listening for DAAP hosts, code %u", result);
 		return;
 	}
 

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]