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

Side by Side Diff: net/der/input.h

Issue 1160643002: Remove dangerous std::string constructor for der::Input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put helper in anonymous namespace Created 5 years, 6 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
« no previous file with comments | « net/cert/internal/verify_name_match_unittest.cc ('k') | net/der/input.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_DER_INPUT_H_ 5 #ifndef NET_DER_INPUT_H_
6 #define NET_DER_INPUT_H_ 6 #define NET_DER_INPUT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Input(); 42 Input();
43 43
44 // Creates an Input from a constant array |data|. 44 // Creates an Input from a constant array |data|.
45 template <size_t N> 45 template <size_t N>
46 explicit Input(const uint8_t(&data)[N]) 46 explicit Input(const uint8_t(&data)[N])
47 : data_(data), len_(N) {} 47 : data_(data), len_(N) {}
48 48
49 // Creates an Input from the given |data| and |len|. 49 // Creates an Input from the given |data| and |len|.
50 Input(const uint8_t* data, size_t len); 50 Input(const uint8_t* data, size_t len);
51 51
52 // Creates an Input from the given string |s|.
53 explicit Input(const std::string& s);
54
55 // Returns the length in bytes of an Input's data. 52 // Returns the length in bytes of an Input's data.
56 size_t Length() const { return len_; } 53 size_t Length() const { return len_; }
57 54
58 // Return true if the Input's data and |other|'s data are byte-wise equal. 55 // Return true if the Input's data and |other|'s data are byte-wise equal.
59 bool Equals(const Input& other) const; 56 bool Equals(const Input& other) const;
60 57
61 // Returns a pointer to the Input's data. This method is marked as "unsafe" 58 // Returns a pointer to the Input's data. This method is marked as "unsafe"
62 // because access to the Input's data should be done through ByteReader 59 // because access to the Input's data should be done through ByteReader
63 // instead. This method should only be used where using a ByteReader truly 60 // instead. This method should only be used where using a ByteReader truly
64 // is not an option. 61 // is not an option.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 explicit Mark(const uint8_t* ptr); 148 explicit Mark(const uint8_t* ptr);
152 Mark(); 149 Mark();
153 const uint8_t* ptr_; 150 const uint8_t* ptr_;
154 }; 151 };
155 152
156 } // namespace der 153 } // namespace der
157 154
158 } // namespace net 155 } // namespace net
159 156
160 #endif // NET_DER_INPUT_H_ 157 #endif // NET_DER_INPUT_H_
OLDNEW
« no previous file with comments | « net/cert/internal/verify_name_match_unittest.cc ('k') | net/der/input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698