bug 898221 - search backwards for the last punycode delimiter instead of forwards. r=hurley
authorpchang9@cs.wisc.edu
Tue, 30 Jul 2013 13:01:11 -0700
changeset 152887 515d75612e530483a10b6fc6faace73ebff48eed
parent 152886 9805018b868ebe214d256c022002c1fc3d117aed
child 152888 1e8481e37d06671b471715b98070bf1a10b6d368
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershurley
bugs898221
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 898221 - search backwards for the last punycode delimiter instead of forwards. r=hurley
netwerk/dns/punycode.c
--- a/netwerk/dns/punycode.c
+++ b/netwerk/dns/punycode.c
@@ -210,17 +210,22 @@ enum punycode_status punycode_decode(
   out = i = 0;
   max_out = *output_length;
   bias = initial_bias;
 
   /* Handle the basic code points:  Let b be the number of input code */
   /* points before the last delimiter, or 0 if there is none, then    */
   /* copy the first b code points to the output.                      */
 
-  for (b = j = 0;  j < input_length;  ++j) if (delim(input[j])) b = j;
+  for (b = 0, j = input_length - 1 ;  j > 0;  --j) {
+    if (delim(input[j])) {
+      b = j;
+      break;
+    }
+  }
   if (b > max_out) return punycode_big_output;
 
   for (j = 0;  j < b;  ++j) {
     if (case_flags) case_flags[out] = flagged(input[j]);
     if (!basic(input[j])) return punycode_bad_input;
     output[out++] = input[j];
   }