Chromium Code Reviews| Index: net/dns/dns_response.cc |
| diff --git a/net/dns/dns_response.cc b/net/dns/dns_response.cc |
| index 4a3371c2adb1b42b267f7a1c161ca58f191f94f4..28f9e8037da767cc9d947c3e2fc4d2fe1497893c 100644 |
| --- a/net/dns/dns_response.cc |
| +++ b/net/dns/dns_response.cc |
| @@ -162,6 +162,7 @@ DnsResponse::~DnsResponse() { |
| } |
| bool DnsResponse::InitParse(int nbytes, const DnsQuery& query) { |
| + DCHECK(nbytes >= 0); |
|
szym
2013/05/17 21:07:00
nit: DCHECK_GE(nbytes, 0)
Noam Samuel
2013/05/17 21:23:50
Done.
|
| // Response includes query, it should be at least that size. |
| if (nbytes < query.io_buffer()->size() || nbytes >= io_buffer_->size()) |
| return false; |
| @@ -190,10 +191,14 @@ bool DnsResponse::InitParse(int nbytes, const DnsQuery& query) { |
| } |
| bool DnsResponse::InitParseWithoutQuery(int nbytes) { |
| - if (nbytes >= io_buffer_->size()) |
| + DCHECK(nbytes >= 0); |
|
szym
2013/05/17 21:07:00
ditto
Noam Samuel
2013/05/17 21:23:50
Done.
|
| + |
| + int hdr_size = (int)sizeof(dns_protocol::Header); |
|
szym
2013/05/17 21:07:00
static_cast<int>, but I'd prefer if you used size_
Noam Samuel
2013/05/17 21:23:50
Done.
|
| + |
| + if (nbytes < hdr_size || |
| + nbytes >= io_buffer_->size()) |
|
szym
2013/05/17 21:07:00
nit: single line.
Noam Samuel
2013/05/17 21:23:50
Done.
|
| return false; |
| - size_t hdr_size = sizeof(dns_protocol::Header); |
| parser_ = DnsRecordParser( |
| io_buffer_->data(), nbytes, hdr_size); |