Skip to content

Commit

Permalink
Merge branch 'vertex-imagen' into ah/vertex-imagen-preview-2
Browse files Browse the repository at this point in the history
# Conflicts:
#	FirebaseVertexAI/Sources/VertexAI.swift
#	FirebaseVertexAI/Tests/TestApp/VertexAITestApp.xcodeproj/project.pbxproj
#	Firestore/core/src/nanopb/byte_string.cc
#	Firestore/core/test/unit/nanopb/byte_string_test.cc
#	Firestore/core/test/unit/util/executor_test.cc
#	Firestore/core/test/unit/util/schedule_test.cc
  • Loading branch information
andrewheard committed Jan 27, 2025
2 parents 4bf3b54 + d0e2014 commit fa02c07
Show file tree
Hide file tree
Showing 190 changed files with 2,085 additions and 1,593 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/client_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ jobs:
matrix:
#TODO(ncooke3): Add multi-platform support: tvOS, macOS, catalyst
platform: [iOS]
scheme: [ClientApp-iOS13]
# TODO(ncooke3): Re-enable after updating Firestore binary.
#scheme: [ClientApp, ClientApp-iOS13]
scheme: [ClientApp]
steps:
- uses: actions/checkout@v4
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
Expand All @@ -53,7 +51,7 @@ jobs:
matrix:
#TODO(ncooke3): Add multi-platform support: tvOS, macOS, catalyst
platform: [iOS]
scheme: [ClientApp, ClientApp-iOS13]
scheme: [ClientApp]
steps:
- uses: actions/checkout@v4
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
Expand All @@ -70,7 +68,7 @@ jobs:
runs-on: macos-14
strategy:
matrix:
scheme: [ClientApp-CocoaPods, ClientApp-CocoaPods-iOS13]
scheme: [ClientApp-CocoaPods]
steps:
- uses: actions/checkout@v4
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/firestore-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.11'

- name: Install Secret GoogleService-Info.plist
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore-nightly.plist.gpg \
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/firestore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
name: firestore

on:
workflow_dispatch:
pull_request:
schedule:
# Run every day at 12am (PST) - cron uses UTC times
Expand Down Expand Up @@ -57,6 +58,9 @@ jobs:
- 'FirebaseFirestoreInternal.podspec'
- 'FirebaseFirestore.podspec'
# Package.swift
- 'Package.swift'
# CMake
- '**CMakeLists.txt'
- 'cmake/**'
Expand Down Expand Up @@ -311,7 +315,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.11'

- name: Setup build
run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
Expand Down
4 changes: 4 additions & 0 deletions Crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 11.7.0
- [fixed] Updated `upload-symbols` to version 3.20, wait for `debug.dylib` DWARF content getting generated when build with `--build-phase` option. Added `debug.dylib` DWARF content to run script input file list for user who enabled user script sandboxing (#14054).
- [fixed] Updated all memory allocation from `malloc()` to `calloc()` (#14209).

# 11.5.0
- [changed] Updated `upload-symbols` to version 3.19, removed all methods require CFRelease and switch to modern classes (#13420).

Expand Down
2 changes: 1 addition & 1 deletion Crashlytics/Crashlytics/Components/FIRCLSBinaryImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static void FIRCLSBinaryImageChanged(bool added,
// fill imageDetails fields using slice & vmaddr_slide
FIRCLSBinaryImageFillInImageDetails(&imageDetails);

FIRCLSImageChange* change = malloc(sizeof(FIRCLSImageChange));
FIRCLSImageChange* change = calloc(1, sizeof(FIRCLSImageChange));
if (!change) return;
change->added = added;
change->details = imageDetails;
Expand Down
22 changes: 11 additions & 11 deletions Crashlytics/Crashlytics/Helpers/FIRCLSAllocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FIRCLSAllocatorRef FIRCLSAllocatorCreate(size_t writableSpace, size_t readableSp
}

// Make one big, continuous allocation, adding additional pages for our guards. Note
// that we cannot use malloc (or valloc) in this case, because we need to assert full
// that we cannot use malloc, calloc (or valloc) in this case, because we need to assert full
// ownership over these allocations. mmap is a much better choice. We also mark these
// pages as MAP_NOCACHE.
allocationSize = writableRegion.size + readableRegion.size + pageSize * 3;
Expand Down Expand Up @@ -174,10 +174,10 @@ void* FIRCLSAllocatorSafeAllocateFromRegion(FIRCLSAllocationRegion* region, size

// this shouldn't happen unless we make a mistake with our size pre-computations
if ((uintptr_t)originalCursor - (uintptr_t)region->start + size > region->size) {
FIRCLSSDKLog("Unable to allocate sufficient memory, falling back to malloc\n");
void* ptr = malloc(size);
FIRCLSSDKLog("Unable to allocate sufficient memory, falling back to calloc\n");
void* ptr = calloc(1, size);
if (!ptr) {
FIRCLSSDKLog("Unable to malloc in FIRCLSAllocatorSafeAllocateFromRegion\n");
FIRCLSSDKLog("Unable to calloc in FIRCLSAllocatorSafeAllocateFromRegion\n");
return NULL;
}
return ptr;
Expand All @@ -195,21 +195,21 @@ void* FIRCLSAllocatorSafeAllocate(FIRCLSAllocatorRef allocator,
FIRCLSAllocationRegion* region;

if (!allocator) {
// fall back to malloc in this case
FIRCLSSDKLog("Allocator invalid, falling back to malloc\n");
void* ptr = malloc(size);
// fall back to calloc in this case
FIRCLSSDKLog("Allocator invalid, falling back to calloc\n");
void* ptr = calloc(1, size);
if (!ptr) {
FIRCLSSDKLog("Unable to malloc in FIRCLSAllocatorSafeAllocate\n");
FIRCLSSDKLog("Unable to calloc in FIRCLSAllocatorSafeAllocate\n");
return NULL;
}
return ptr;
}

if (allocator->protectionEnabled) {
FIRCLSSDKLog("Allocator already protected, falling back to malloc\n");
void* ptr = malloc(size);
FIRCLSSDKLog("Allocator already protected, falling back to calloc\n");
void* ptr = calloc(1, size);
if (!ptr) {
FIRCLSSDKLog("Unable to malloc in FIRCLSAllocatorSafeAllocate\n");
FIRCLSSDKLog("Unable to calloc in FIRCLSAllocatorSafeAllocate\n");
return NULL;
}
return ptr;
Expand Down
12 changes: 6 additions & 6 deletions Crashlytics/Crashlytics/Helpers/FIRCLSFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ static bool FIRCLSFileInit(

file->bufferWrites = bufferWrites;
if (bufferWrites) {
file->writeBuffer = malloc(FIRCLSWriteBufferLength * sizeof(char));
file->writeBuffer = calloc(1, FIRCLSWriteBufferLength * sizeof(char));
if (!file->writeBuffer) {
FIRCLSErrorLog(@"Unable to malloc in FIRCLSFileInit");
FIRCLSErrorLog(@"Unable to calloc in FIRCLSFileInit");
return false;
}

Expand Down Expand Up @@ -668,10 +668,10 @@ void FIRCLSFileWriteArrayEntryHexEncodedString(FIRCLSFile* file, const char* val

NSString* FIRCLSFileHexEncodeString(const char* string) {
size_t length = strlen(string);
char* encodedBuffer = malloc(length * 2 + 1);
char* encodedBuffer = calloc(1, length * 2 + 1);

if (!encodedBuffer) {
FIRCLSErrorLog(@"Unable to malloc in FIRCLSFileHexEncodeString");
FIRCLSErrorLog(@"Unable to calloc in FIRCLSFileHexEncodeString");
return nil;
}

Expand All @@ -693,9 +693,9 @@ void FIRCLSFileWriteArrayEntryHexEncodedString(FIRCLSFile* file, const char* val

NSString* FIRCLSFileHexDecodeString(const char* string) {
size_t length = strlen(string);
char* decodedBuffer = malloc(length); // too long, but safe
char* decodedBuffer = calloc(1, length); // too long, but safe
if (!decodedBuffer) {
FIRCLSErrorLog(@"Unable to malloc in FIRCLSFileHexDecodeString");
FIRCLSErrorLog(@"Unable to calloc in FIRCLSFileHexDecodeString");
return nil;
}

Expand Down
4 changes: 2 additions & 2 deletions Crashlytics/Crashlytics/Helpers/FIRCLSUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ void FIRCLSRedactUUID(char* value) {
// null terminator
length = [data length];
size = (length * 2) + 1;
buffer = malloc(sizeof(char) * size);
buffer = calloc(1, sizeof(char) * size);

if (!buffer) {
FIRCLSErrorLog(@"Unable to malloc in FIRCLSNSDataToNSString");
FIRCLSErrorLog(@"Unable to calloc in FIRCLSNSDataToNSString");
return nil;
}

Expand Down
23 changes: 19 additions & 4 deletions Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ - (google_crashlytics_FilesPayload)protoFilesPayload {

NSArray<NSString *> *clsRecords = [self clsRecordFilePaths];
google_crashlytics_FilesPayload_File *files =
malloc(sizeof(google_crashlytics_FilesPayload_File) * clsRecords.count);
calloc(1, sizeof(google_crashlytics_FilesPayload_File) * clsRecords.count);

if (files == NULL) {
// files and files_count are initialized to NULL and 0 by default.
Expand Down Expand Up @@ -236,7 +236,7 @@ - (google_crashlytics_Platforms)protoPlatformFromString:(NSString *)str {
}
}

/** Mallocs a pb_bytes_array and copies the given NSString's bytes into the bytes array.
/** Callocs a pb_bytes_array and copies the given NSString's bytes into the bytes array.
* @note Memory needs to be freed manually, through pb_free or pb_release.
* @param string The string to encode as pb_bytes.
*/
Expand All @@ -251,12 +251,27 @@ - (google_crashlytics_Platforms)protoPlatformFromString:(NSString *)str {
return FIRCLSEncodeData(stringBytes);
}

/** Mallocs a pb_bytes_array and copies the given NSData bytes into the bytes array.
/** Callocs a pb_bytes_array and copies the given NSData bytes into the bytes array.
* @note Memory needs to be free manually, through pb_free or pb_release.
* @param data The data to copy into the new bytes array.
*/
pb_bytes_array_t *FIRCLSEncodeData(NSData *data) {
pb_bytes_array_t *pbBytes = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data.length));
// We have received couple security tickets before for using calloc here.
// Here is a short explaination on how it is calculated so buffer overflow is prevented:
// We will alloc an amount of memeory for struct `pb_bytes_array_t`, this struct contains two
// attributes:
// pb_size_t size
// pb_byte_t bytes[1]
// It contains the size the of the data and the actually data information in byte form (which
// is represented by a pointer), for more information check the declaration in nanopb/pb.h.

// For size, NSData return size in `unsigned long` type which is the same size as `pb_size_t` and
// it is declared in compile time depending on the arch of system. If overflow happened it should
// happend at NSData level first when user trying to inserting data to NSData.
// For bytes, it is just a strict memeory copy of the data in NSData.
// The whole structure will be freed as a part of process for deallocing report in dealloc() of
// this class
pb_bytes_array_t *pbBytes = calloc(1, PB_BYTES_ARRAY_T_ALLOCSIZE(data.length));
if (pbBytes == NULL) {
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions Crashlytics/CrashlyticsInputFiles.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ $(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}.debug.dylib
2 changes: 1 addition & 1 deletion Crashlytics/Shared/FIRCLSByteUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void FIRCLSSafeHexToString(const uint8_t *value, size_t length, char *outputBuff
// null terminator
length = data.length;
size = (length * 2) + 1;
buffer = malloc(sizeof(char) * size);
buffer = calloc(1, sizeof(char) * size);

if (!buffer) {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion Crashlytics/Shared/FIRCLSMachO/FIRCLSMachOBinary.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void FIRCLSSafeHexToString(const uint8_t* value, size_t length, char* out
// null terminator
length = [data length];
size = (length * 2) + 1;
buffer = malloc(sizeof(char) * size);
buffer = calloc(1, sizeof(char) * size);

if (!buffer) {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion Crashlytics/UnitTests/FIRCLSCompactUnwindTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ @implementation FIRCLSCompactUnwindTests
- (void)setUp {
[super setUp];

_firclsContext.readonly = malloc(sizeof(FIRCLSReadOnlyContext));
_firclsContext.readonly = calloc(1, sizeof(FIRCLSReadOnlyContext));
_firclsContext.readonly->logPath = "/tmp/test.log";
}

Expand Down
2 changes: 1 addition & 1 deletion Crashlytics/UnitTests/FIRCLSDwarfTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ @implementation FIRCLSDwarfTests
- (void)setUp {
[super setUp];

_firclsContext.readonly = malloc(sizeof(FIRCLSReadOnlyContext));
_firclsContext.readonly = calloc(1, sizeof(FIRCLSReadOnlyContext));
_firclsContext.readonly->logPath = "/tmp/test.log";
}

Expand Down
4 changes: 2 additions & 2 deletions Crashlytics/UnitTests/FIRCLSFileTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (void)hexEncodingLongStringWithFile:(FIRCLSFile *)file
filePath:(NSString *)filePath
length:(size_t)length
buffered:(BOOL)buffered {
char *longString = malloc(length * sizeof(char));
char *longString = calloc(1, length * sizeof(char));

memset(longString, 'a', length); // fill it with 'a' characters
longString[length - 1] = 0; // null terminate
Expand Down Expand Up @@ -432,7 +432,7 @@ - (void)closeAndOpenAlternatingBufferedOptionWithFile:(FIRCLSFile *)file

- (void)testLoggingInputLongerThanBuffer {
size_t inputLength = (FIRCLSWriteBufferLength + 2) * sizeof(char);
char *input = malloc(inputLength);
char *input = calloc(1, inputLength);
for (size_t i = 0; i < inputLength - 1; i++) {
input[i] = i % 26 + 'a';
}
Expand Down
2 changes: 1 addition & 1 deletion Crashlytics/UnitTests/FIRCLSLoggingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ - (void)testUserLogNil {

- (void)testLargeLogLine {
size_t strLength = 100 * 1024; // Attempt to write 100k of data
char* longLine = malloc(strLength + 1);
char* longLine = calloc(1, strLength + 1);
memset(longLine, 'a', strLength);
longLine[strLength] = '\0';
NSString* longStr = [[NSString alloc] initWithBytesNoCopy:longLine
Expand Down
Binary file modified Crashlytics/upload-symbols
Binary file not shown.
Loading

0 comments on commit fa02c07

Please sign in to comment.