I have found an issue with the handling of the script when embedding into the C code of "dispatcher.c". I have introduced "format" commands in two places that are using the "%.." format description; this interferes badly with the sprintf command. The attached patch separates the sprintf operation from the rest of the script code.

Unfortunately, I have run into bug #656063 afterwards, but that's annother story.

Josua Dietze
diff -urN usb-modeswitch-1.2.2/dispatcher.c usb-modeswitch-1.2.2-1/dispatcher.c
--- usb-modeswitch-1.2.2/dispatcher.c   2012-01-19 01:01:50.000000000 +0100
+++ usb-modeswitch-1.2.2-1/dispatcher.c 2012-01-22 09:21:50.000000000 +0100
@@ -63,8 +63,9 @@
                strncat(arglist,arg,MAX_ARGSIZE-1);
        }
 
-    char code[sizeof(RAW) + sizeof(arglist)];
-       sprintf(code, RAW, arglist, argc-1);
+       char code[sizeof(RAW) + sizeof(arglist) + 28];
+       sprintf(code, "set argv {%s}\nset argc %d\n", arglist, argc-1);
+       strncat(code, RAW, sizeof(RAW));
 
        /* Create Jim instance */
        interp = Jim_CreateInterp();
diff -urN usb-modeswitch-1.2.2/make_string.tcl 
usb-modeswitch-1.2.2-1/make_string.tcl
--- usb-modeswitch-1.2.2/make_string.tcl        2012-01-19 01:02:04.000000000 
+0100
+++ usb-modeswitch-1.2.2-1/make_string.tcl      2012-01-22 09:22:06.000000000 
+0100
@@ -28,4 +28,4 @@
        }
 }
 close $f
-puts "#define RAW \"set argv {%s}\\nset argc %d\\n[join $sourcelines ""]\""
+puts "#define RAW \"[join $sourcelines ""]\""

Reply via email to