File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Crashlytics/Crashlytics/Models/Record Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,21 @@ - (google_crashlytics_Platforms)protoPlatformFromString:(NSString *)str {
256
256
* @param data The data to copy into the new bytes array.
257
257
*/
258
258
pb_bytes_array_t *FIRCLSEncodeData (NSData *data) {
259
+ // We have received couple security tickets before for using malloc here.
260
+ // Here is a short explaination on how it is calculated so buffer overflow is prevented:
261
+ // We will alloc an amount of memeory for struct `pb_bytes_array_t`, this struct contains two
262
+ // attributes:
263
+ // pb_size_t size
264
+ // pb_byte_t bytes[1]
265
+ // It contains the size the of the data and the actually data information in byte form (which
266
+ // is represented by a pointer), for more information check the declaration in nanopb/pb.h.
267
+
268
+ // For size, NSData return size in `unsigned long` type which is the same size as `pb_size_t` and
269
+ // it is declared in compile time depending on the arch of system. If overflow happened it should
270
+ // happend at NSData level first when user trying to inserting data to NSData.
271
+ // For bytes, it is just a strict memeory copy of the data in NSData.
272
+ // The whole structure will be freed as a part of process for deallocing report in dealloc() of
273
+ // this class
259
274
pb_bytes_array_t *pbBytes = malloc (PB_BYTES_ARRAY_T_ALLOCSIZE (data.length ));
260
275
if (pbBytes == NULL ) {
261
276
return NULL ;
You can’t perform that action at this time.
0 commit comments