Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/url_canon_ip.cc

Issue 155077: Fix: Make DoCanonicalizeIPv6Address safer by changing loop condition and addi... (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 host_info->out_host.begin = output->length(); 633 host_info->out_host.begin = output->length();
634 output->push_back('['); 634 output->push_back('[');
635 635
636 // We will now output the address according to the rules in: 636 // We will now output the address according to the rules in:
637 // http://tools.ietf.org/html/draft-kawamura-ipv6-text-representation-01#secti on-4 637 // http://tools.ietf.org/html/draft-kawamura-ipv6-text-representation-01#secti on-4
638 638
639 // Start by finding where to place the "::" contraction (if any). 639 // Start by finding where to place the "::" contraction (if any).
640 url_parse::Component contraction_range; 640 url_parse::Component contraction_range;
641 ChooseIPv6ContractionRange(address, &contraction_range); 641 ChooseIPv6ContractionRange(address, &contraction_range);
642 642
643 for (int i = 0; i < 16;) { 643 for (int i = 0; i <= 14;) {
644 // We check 2 bytes at a time, from bytes (0, 1) to (14, 15), inclusive.
645 DCHECK(i % 2 == 0);
644 if (i == contraction_range.begin && contraction_range.len > 0) { 646 if (i == contraction_range.begin && contraction_range.len > 0) {
645 // Jump over the contraction. 647 // Jump over the contraction.
646 if (i == 0) 648 if (i == 0)
647 output->push_back(':'); 649 output->push_back(':');
648 output->push_back(':'); 650 output->push_back(':');
649 i = contraction_range.end(); 651 i = contraction_range.end();
650 } else { 652 } else {
651 // Consume the next 16 bits from |address|. 653 // Consume the next 16 bits from |address|.
652 int x = address[i] << 8 | address[i + 1]; 654 int x = address[i] << 8 | address[i + 1];
653 655
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 CanonHostInfo* host_info) { 706 CanonHostInfo* host_info) {
705 if (DoCanonicalizeIPv4Address<char16, char16>( 707 if (DoCanonicalizeIPv4Address<char16, char16>(
706 spec, host, output, host_info)) 708 spec, host, output, host_info))
707 return; 709 return;
708 if (DoCanonicalizeIPv6Address<char16, char16>( 710 if (DoCanonicalizeIPv6Address<char16, char16>(
709 spec, host, output, host_info)) 711 spec, host, output, host_info))
710 return; 712 return;
711 } 713 }
712 714
713 } // namespace url_canon 715 } // namespace url_canon
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698