OLD | NEW |
---|---|
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 false); | 135 false); |
136 CFReadStreamRef read_stream = CFReadStreamCreateWithFile(NULL, sys_vers); | 136 CFReadStreamRef read_stream = CFReadStreamCreateWithFile(NULL, sys_vers); |
137 CFRelease(sys_vers); | 137 CFRelease(sys_vers); |
138 if (!read_stream) { | 138 if (!read_stream) { |
139 return; | 139 return; |
140 } | 140 } |
141 if (!CFReadStreamOpen(read_stream)) { | 141 if (!CFReadStreamOpen(read_stream)) { |
142 CFRelease(read_stream); | 142 CFRelease(read_stream); |
143 return; | 143 return; |
144 } | 144 } |
145 CFDataRef data = NULL; | 145 // Actual data file tests: Mac at 480 bytes and iOS at 413 bytes. |
146 CFIndex num_bytes_read = 0; | 146 const CFIndex kMaxBufferLength = 1024; |
147 const UInt8 *data_bytes = | 147 UInt8 data_bytes[kMaxBufferLength]; |
148 CFReadStreamGetBuffer(read_stream, 0, &num_bytes_read); | 148 CFMutableDataRef data = NULL; |
Mark Mentovai
2016/01/31 02:12:05
There is a logic problem.
| |
149 if (data_bytes) { | 149 CFIndex num_bytes_read = |
150 data = CFDataCreate(NULL, data_bytes, num_bytes_read); | 150 CFReadStreamRead(read_stream, data_bytes, kMaxBufferLength); |
Mark Mentovai
2016/01/31 02:12:05
Say that this reads some data and returns a positi
| |
151 while (num_bytes_read > 0) { | |
152 if (data == NULL) { | |
153 data = CFDataCreateMutable(NULL, 0); | |
154 } | |
155 CFDataAppendBytes(data, data_bytes, num_bytes_read); | |
156 if (num_bytes_read < kMaxBufferLength) break; | |
Mark Mentovai
2016/01/29 14:40:11
seh wrote:
Mark Mentovai
2016/01/31 02:12:05
…but the positive number is less than kMaxBufferLe
Mark Mentovai
2016/01/31 02:12:05
…then you’ll break out here…
| |
157 | |
158 num_bytes_read = | |
159 CFReadStreamRead(read_stream, data_bytes, kMaxBufferLength); | |
Mark Mentovai
2016/01/31 02:12:05
…without ever trying to read more…
| |
151 } | 160 } |
152 CFReadStreamClose(read_stream); | 161 CFReadStreamClose(read_stream); |
153 CFRelease(read_stream); | 162 CFRelease(read_stream); |
163 if (num_bytes_read < 0) { | |
164 CFRelease(data); | |
165 return; | |
166 } | |
154 if (!data) { | 167 if (!data) { |
155 return; | 168 return; |
156 } | 169 } |
157 CFDictionaryRef list = static_cast<CFDictionaryRef> | 170 CFDictionaryRef list = static_cast<CFDictionaryRef> |
158 (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, | 171 (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, |
Mark Mentovai
2016/01/31 02:12:05
…but you haven’t actually read the entire file bec
| |
159 NULL)); | 172 NULL)); |
Mark Mentovai
2016/01/31 02:12:05
So, once again, what do you think about
while (tr
| |
160 CFRelease(data); | 173 CFRelease(data); |
161 if (!list) { | 174 if (!list) { |
162 return; | 175 return; |
163 } | 176 } |
164 CFStringRef build_version = static_cast<CFStringRef> | 177 CFStringRef build_version = static_cast<CFStringRef> |
165 (CFDictionaryGetValue(list, CFSTR("ProductBuildVersion"))); | 178 (CFDictionaryGetValue(list, CFSTR("ProductBuildVersion"))); |
166 CFStringRef product_version = static_cast<CFStringRef> | 179 CFStringRef product_version = static_cast<CFStringRef> |
167 (CFDictionaryGetValue(list, CFSTR("ProductVersion"))); | 180 (CFDictionaryGetValue(list, CFSTR("ProductVersion"))); |
168 string build_str = ConvertToString(build_version); | 181 string build_str = ConvertToString(build_version); |
169 string product_str = ConvertToString(product_version); | 182 string product_str = ConvertToString(product_version); |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1582 } else { | 1595 } else { |
1583 info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID; | 1596 info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID; |
1584 info_ptr->dump_thread_id = handler_thread_; | 1597 info_ptr->dump_thread_id = handler_thread_; |
1585 info_ptr->requesting_thread_id = 0; | 1598 info_ptr->requesting_thread_id = 0; |
1586 } | 1599 } |
1587 | 1600 |
1588 return true; | 1601 return true; |
1589 } | 1602 } |
1590 | 1603 |
1591 } // namespace google_breakpad | 1604 } // namespace google_breakpad |
OLD | NEW |