Following patch corrects an error in the function of the mysql dispatcher which 
otherwise causes either no file to be dispatched, or in extreme cases a core 
dump of the module.

This is against version 0.39 but from looking at CVS also appears to be 
required for subsequent versions.

uname -a: OpenBSD shelob 3.6 GENERIC#59 i386 - no patches applied

packages: mod_mp3-0.39-mysql, mysql-client-4.0.20, mysql-server-4.0.20, 
p5-DBD-mysql-2.9004, p5-DBI-1.43, p5-Net-Daemon-0.38, p5-PlRPC-0.2018



--- mod_mp3-0.39-original/src/mysql_dispatch.c  Thu Sep 19 07:13:21 2002
+++ mod_mp3-0.39/src/mysql_dispatch.c   Sat Jun 11 17:52:21 2005
@@ -195,18 +195,25 @@
        if(!context->sth) {
                if(files) {
                        if(!context->each_sql) {
                        /* We should create a temp pool while doing this -Brian 
*/
                                find_files = (char **)files->elts;
-                               for(x = 0; x < files->nelts; x++) {
-                                       list = ap_psprintf(p, "%s '%s'", list, 
find_files[x]);
-                                       if (x  < (files->nelts - 1))
-                                               list = ap_psprintf(p, "%s 
'%s'", list, find_files[x]);
-                                       else
-                                               list = ap_psprintf(p, "%s 
'%s',", list);
+
+                               /* M Crossley 11 June 2005:  patched to make 
sure the list is built properly on OpenBSD 3.6 port */
+                               /* existing code had a problem because OpenBSD 
version of ap_psprintf '%s' returns (NULL) for a  */
+                               /* null string argument; whereas the original 
code expected an empty string.  This version       */
+                               /* should be considerably safer */
+
+                               if ( (files->nelts) > 0 ) {
+                                       list = ap_psprintf(p, "'%s'", 
find_files[0]);
+                                       for(x = 1; x < (files->nelts); x++)
+                                               list = ap_psprintf(p, "%s, 
'%s'", list, find_files[x]);
                                }
-                               /* Final one we don't need a comma for */
+
+                               /* end of patched code */
+
+
                                if (random) {
                                        context->each_sql = ap_psprintf(p, 
MYSQL_MP3_GET_LIST_RANDOM, context->table, list);
                                } else {
                                        context->each_sql = ap_psprintf(p, 
MYSQL_MP3_GET_LIST, context->table, list);
                                }


Reply via email to