aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangskz <sandyzhang@google.com>2024-02-12 21:07:59 -0500
committerGitHub <noreply@github.com>2024-02-12 21:07:59 -0500
commit70e459f9d43ef00ae1405eeb1d50d4bb61551d58 (patch)
tree3504df23defe0a61b32897d06a953c8d12a6d776
parent971fbf639b5801885150c73c3cd107f5cdde5bc6 (diff)
parent17ec19db930216d59eb8efdb0bbf6d1f5355f147 (diff)
downloadprotobuf-70e459f9d43ef00ae1405eeb1d50d4bb61551d58.tar.gz
Merge pull request #15802 from protocolbuffers/cp-25.x
Cherrypick Apple Privacy Manifest changes to make these available in 25.x
-rw-r--r--.github/workflows/test_cpp.yml2
-rwxr-xr-xPrivacyInfo.xcprivacy14
-rw-r--r--Protobuf-C++.podspec9
-rw-r--r--Protobuf.podspec9
-rw-r--r--objectivec/GPBCodedInputStream.m18
-rw-r--r--src/google/protobuf/map.h4
6 files changed, 45 insertions, 11 deletions
diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml
index cc2004bc3..087b1ea81 100644
--- a/.github/workflows/test_cpp.yml
+++ b/.github/workflows/test_cpp.yml
@@ -367,7 +367,7 @@ jobs:
vsversion: '2019'
cache-prefix: windows-2019-cmake
# windows-2019 has python3.7 installed, which is incompatible with the latest gcloud
- python-version: '3.8'
+ python-version: '3.9'
- name: Windows CMake 32-bit
os: windows-2022
flags: >-
diff --git a/PrivacyInfo.xcprivacy b/PrivacyInfo.xcprivacy
new file mode 100755
index 000000000..e08a130bc
--- /dev/null
+++ b/PrivacyInfo.xcprivacy
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrivacyTracking</key>
+ <false/>
+ <key>NSPrivacyTrackingDomains</key>
+ <array/>
+ <key>NSPrivacyCollectedDataTypes</key>
+ <array/>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <array/>
+</dict>
+</plist>
diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec
index 1600f710a..8c0e99e3e 100644
--- a/Protobuf-C++.podspec
+++ b/Protobuf-C++.podspec
@@ -5,7 +5,10 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/google/protobuf'
s.license = 'BSD-3-Clause'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
- s.cocoapods_version = '>= 1.0'
+
+ # Ensure developers won't hit CocoaPods/CocoaPods#11402 with the resource
+ # bundle for the privacy manifest.
+ s.cocoapods_version = '>= 1.12.0'
s.source = { :git => 'https://github.com/google/protobuf.git',
:tag => "v#{s.version}" }
@@ -23,6 +26,10 @@ Pod::Spec.new do |s|
'src/google/protobuf/map_test_util*.{h,cc,inc}',
'src/google/protobuf/reflection_tester.{h,cc}'
+ s.resource_bundle = {
+ "Protobuf-C++_Privacy" => "PrivacyInfo.xcprivacy"
+ }
+
s.header_mappings_dir = 'src'
s.ios.deployment_target = '12.0'
diff --git a/Protobuf.podspec b/Protobuf.podspec
index fe62bdc43..9a76fba1d 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -10,7 +10,10 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
- s.cocoapods_version = '>= 1.0'
+
+ # Ensure developers won't hit CocoaPods/CocoaPods#11402 with the resource
+ # bundle for the privacy manifest.
+ s.cocoapods_version = '>= 1.12.0'
s.source = { :git => 'https://github.com/protocolbuffers/protobuf.git',
:tag => "v#{s.version}" }
@@ -30,6 +33,10 @@ Pod::Spec.new do |s|
# left out, as it's an umbrella implementation file.
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
+ s.resource_bundle = {
+ "Protobuf_Privacy" => "PrivacyInfo.xcprivacy"
+ }
+
# Set a CPP symbol so the code knows to use framework imports.
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m
index d172536d9..9b2122d21 100644
--- a/objectivec/GPBCodedInputStream.m
+++ b/objectivec/GPBCodedInputStream.m
@@ -219,7 +219,8 @@ NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
if (size == 0) {
result = @"";
} else {
- CheckSize(state, size);
+ size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
+ CheckSize(state, size2);
result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
length:ns_size
encoding:NSUTF8StringEncoding];
@@ -239,8 +240,9 @@ NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
uint64_t size = GPBCodedInputStreamReadUInt64(state);
CheckFieldSize(size);
+ size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
+ CheckSize(state, size2);
NSUInteger ns_size = (NSUInteger)size;
- CheckSize(state, size);
NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos length:ns_size];
state->bufferPos += size;
return result;
@@ -249,8 +251,9 @@ NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state) {
uint64_t size = GPBCodedInputStreamReadUInt64(state);
CheckFieldSize(size);
+ size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
+ CheckSize(state, size2);
NSUInteger ns_size = (NSUInteger)size;
- CheckSize(state, size);
// Cast is safe because freeWhenDone is NO.
NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
length:ns_size
@@ -338,7 +341,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
case GPBWireFormatLengthDelimited: {
uint64_t size = GPBCodedInputStreamReadUInt64(&state_);
CheckFieldSize(size);
- SkipRawData(&state_, size);
+ size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
+ SkipRawData(&state_, size2);
return YES;
}
case GPBWireFormatStartGroup:
@@ -441,7 +445,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
CheckRecursionLimit(&state_);
uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
CheckFieldSize(length);
- size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
+ size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
+ size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
@@ -456,7 +461,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
CheckRecursionLimit(&state_);
uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
CheckFieldSize(length);
- size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
+ size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
+ size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
++state_.recursionDepth;
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, parentMessage);
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index e84ca694d..83a3cf20f 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -25,7 +25,7 @@
#include <utility>
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
-#include <mach/mach_time.h>
+#include <time.h>
#endif
#include "google/protobuf/stubs/common.h"
@@ -691,7 +691,7 @@ class PROTOBUF_EXPORT UntypedMapBase {
#if defined(__APPLE__)
// Use a commpage-based fast time function on Apple environments (MacOS,
// iOS, tvOS, watchOS, etc).
- s += mach_absolute_time();
+ s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
#elif defined(__x86_64__) && defined(__GNUC__)
uint32_t hi, lo;
asm volatile("rdtsc" : "=a"(lo), "=d"(hi));