]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/patches/jwhois-4.0-idna.patch
Replace whois by jwhois.
[people/teissler/ipfire-2.x.git] / src / patches / jwhois-4.0-idna.patch
diff --git a/src/patches/jwhois-4.0-idna.patch b/src/patches/jwhois-4.0-idna.patch
new file mode 100644 (file)
index 0000000..ff13a4f
--- /dev/null
@@ -0,0 +1,43 @@
+diff -up jwhois-4.0/src/jwhois.c.orig jwhois-4.0/src/jwhois.c
+--- jwhois-4.0/src/jwhois.c.orig       2007-06-26 08:59:35.000000000 +0200
++++ jwhois-4.0/src/jwhois.c    2011-05-24 12:29:37.398892451 +0200
+@@ -98,7 +98,7 @@ main(int argc, char **argv)
+   /* Parse remaining arguments and place them into the wq
+      structure. */
+-  while (optind < argc)
++  while (optind < argc-1)
+     {
+       count += strlen(argv[optind])+1;
+       if (!qstring)
+@@ -116,19 +116,25 @@ main(int argc, char **argv)
+       strcat(qstring, " ");
+       optind++;
+     }
+-  qstring[strlen(qstring)-1] = '\0';
+ #ifdef LIBIDN
+-  rc = idna_to_ascii_lz(qstring, &idn, 0);
++  rc = idna_to_ascii_lz(argv[optind], &idn, 0);
+   if (rc != IDNA_SUCCESS)
+     {
+-      printf("[IDN encoding of '%s' failed with error code %d]\n", qstring, rc);
++      printf("[IDN encoding of '%s' failed with error code %d]\n", argv[optind], rc);
+       exit(1);
+     }
+-  wq.query = strdup(idn);
++  qstring = realloc(qstring, count+strlen(idn)+1);
++  memcpy(qstring+count,
++         idn,
++         strlen(idn)+1);
+   free(idn);
+ #else
+-  wq.query = qstring;
++  qstring = realloc(qstring, count+strlen(argv[optind])+1);
++  memcpy(qstring+count,
++         argv[optind],
++         strlen(argv[optind])+1);
+ #endif
++  wq.query = qstring;
+   if (ghost)
+     {