HTTrack Website Copier
Free software offline browser - FORUM
Subject: Re: Passing arguments to callback functions broken
Author: Xavier Roche
Date: 04/23/2007 18:41
 
Here's the fixed patch (for the second argument parsing bug)

--- htscoremain.c.orig  2007-04-23 18:40:17.424532500 +0200
+++ htscoremain.c       2007-04-23 18:37:53.000000000 +0200
@@ -1242,23 +1242,32 @@
                 htsmain_free();
                 return -1;
               } else {
-                char callbackname[128];
-                char* a = argv[na + 1];
-                char* pos; /*  = strchr(a, '='); */
-                for(pos = a ; *pos != '\0' && *pos != '=' && *pos != ',' &&
*pos != ':' ; pos++);
+                char* pos;
+                na++;
+                for(pos = argv[na] ; *pos != '\0' && *pos != '=' && *pos !=
',' && *pos != ':' ; pos++);
                 /* httrack --wrapper callback[,foo] */
                 if (*pos == 0 || *pos == ',' || *pos == ':') {
-                  int ret = plug_wrapper(opt, argv[na + 1], argv[na + 1]);
+                  int ret;
+                  char *moduleName;
+                  if (*pos == ',' || *pos == ':') {
+                    *pos = '\0';
+                    moduleName = strdupt(argv[na]);
+                    *pos = ',';   /* foce seperator to ',' */
+                  } else {
+                    moduleName = strdupt(argv[na]);
+                  }
+                  ret = plug_wrapper(opt, moduleName, argv[na]);
+                  freet(moduleName);
                   if (ret == 0) {
                     char BIGSTK tmp[1024 * 2];
-                    sprintf(tmp, "option %%W : unable to plug the module %s
(returncode != 1)", a);
+                    sprintf(tmp, "option %%W : unable to plug the module %s
(returncode != 1)", argv[na]);
                     HTS_PANIC_PRINTF(tmp);
                     htsmain_free();
                     return -1;
                   } else if (ret == -1) {
                     char BIGSTK tmp[1024 * 2];
                     int last_errno = errno;
-                    sprintf(tmp, "option %%W : unable to load the module %s:
%s (check the library path ?)", a, strerror(last_errno));
+                    sprintf(tmp, "option %%W : unable to load the module %s:
%s (check the library path ?)", argv[na], strerror(last_errno));
                     HTS_PANIC_PRINTF(tmp);
                     htsmain_free();
                     return -1;
@@ -1266,9 +1275,9 @@
                 }
                 /* Old style */
                 /* httrack --wrapper save-name=callback:process,string */
-                else if (*pos == '=' && (pos - a) > 0 && (pos - a + 2) <
sizeof(callbackname)) {
+                else if (*pos == '=') {
                   fprintf(stderr, "Syntax error in option %%W : the old
(<3.41) API is no more supported!\n");
-                  HTS_PANIC_PRINTF("Syntax error in option %W : this function
needs to be followed by a blank space, and a module name");
+                  HTS_PANIC_PRINTF("Syntax error in option %W : the old
(<3.41) API is no more supported!");
                   printf("Example: -%%W check-link=checklink.so:check\n");
                   htsmain_free();
                   return -1;

 
Reply Create subthread


All articles

Subject Author Date
Passing arguments to callback functions broken?

04/18/2007 12:58
Re: Passing arguments to callback functions broken

04/21/2007 15:01
Re: Passing arguments to callback functions broken

04/23/2007 14:40
Re: Passing arguments to callback functions broken

04/23/2007 18:41




9

Created with FORUM 2.0.11