Skip to content

Commit 70e459f

Browse files
authored
Merge pull request #15802 from protocolbuffers/cp-25.x
Cherrypick Apple Privacy Manifest changes to make these available in 25.x
2 parents 971fbf6 + 17ec19d commit 70e459f

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed

.github/workflows/test_cpp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ jobs:
367367
vsversion: '2019'
368368
cache-prefix: windows-2019-cmake
369369
# windows-2019 has python3.7 installed, which is incompatible with the latest gcloud
370-
python-version: '3.8'
370+
python-version: '3.9'
371371
- name: Windows CMake 32-bit
372372
os: windows-2022
373373
flags: >-

PrivacyInfo.xcprivacy

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyTracking</key>
6+
<false/>
7+
<key>NSPrivacyTrackingDomains</key>
8+
<array/>
9+
<key>NSPrivacyCollectedDataTypes</key>
10+
<array/>
11+
<key>NSPrivacyAccessedAPITypes</key>
12+
<array/>
13+
</dict>
14+
</plist>

Protobuf-C++.podspec

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Pod::Spec.new do |s|
55
s.homepage = 'https://github.com/google/protobuf'
66
s.license = 'BSD-3-Clause'
77
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
8-
s.cocoapods_version = '>= 1.0'
8+
9+
# Ensure developers won't hit CocoaPods/CocoaPods#11402 with the resource
10+
# bundle for the privacy manifest.
11+
s.cocoapods_version = '>= 1.12.0'
912

1013
s.source = { :git => 'https://github.com/google/protobuf.git',
1114
:tag => "v#{s.version}" }
@@ -23,6 +26,10 @@ Pod::Spec.new do |s|
2326
'src/google/protobuf/map_test_util*.{h,cc,inc}',
2427
'src/google/protobuf/reflection_tester.{h,cc}'
2528

29+
s.resource_bundle = {
30+
"Protobuf-C++_Privacy" => "PrivacyInfo.xcprivacy"
31+
}
32+
2633
s.header_mappings_dir = 'src'
2734

2835
s.ios.deployment_target = '12.0'

Protobuf.podspec

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ Pod::Spec.new do |s|
1010
s.homepage = 'https://github.com/protocolbuffers/protobuf'
1111
s.license = 'BSD-3-Clause'
1212
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
13-
s.cocoapods_version = '>= 1.0'
13+
14+
# Ensure developers won't hit CocoaPods/CocoaPods#11402 with the resource
15+
# bundle for the privacy manifest.
16+
s.cocoapods_version = '>= 1.12.0'
1417

1518
s.source = { :git => 'https://github.com/protocolbuffers/protobuf.git',
1619
:tag => "v#{s.version}" }
@@ -30,6 +33,10 @@ Pod::Spec.new do |s|
3033
# left out, as it's an umbrella implementation file.
3134
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
3235

36+
s.resource_bundle = {
37+
"Protobuf_Privacy" => "PrivacyInfo.xcprivacy"
38+
}
39+
3340
# Set a CPP symbol so the code knows to use framework imports.
3441
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
3542
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }

objectivec/GPBCodedInputStream.m

+12-6
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
219219
if (size == 0) {
220220
result = @"";
221221
} else {
222-
CheckSize(state, size);
222+
size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
223+
CheckSize(state, size2);
223224
result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
224225
length:ns_size
225226
encoding:NSUTF8StringEncoding];
@@ -239,8 +240,9 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
239240
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
240241
uint64_t size = GPBCodedInputStreamReadUInt64(state);
241242
CheckFieldSize(size);
243+
size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
244+
CheckSize(state, size2);
242245
NSUInteger ns_size = (NSUInteger)size;
243-
CheckSize(state, size);
244246
NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos length:ns_size];
245247
state->bufferPos += size;
246248
return result;
@@ -249,8 +251,9 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
249251
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state) {
250252
uint64_t size = GPBCodedInputStreamReadUInt64(state);
251253
CheckFieldSize(size);
254+
size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
255+
CheckSize(state, size2);
252256
NSUInteger ns_size = (NSUInteger)size;
253-
CheckSize(state, size);
254257
// Cast is safe because freeWhenDone is NO.
255258
NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
256259
length:ns_size
@@ -338,7 +341,8 @@ - (BOOL)skipField:(int32_t)tag {
338341
case GPBWireFormatLengthDelimited: {
339342
uint64_t size = GPBCodedInputStreamReadUInt64(&state_);
340343
CheckFieldSize(size);
341-
SkipRawData(&state_, size);
344+
size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
345+
SkipRawData(&state_, size2);
342346
return YES;
343347
}
344348
case GPBWireFormatStartGroup:
@@ -441,7 +445,8 @@ - (void)readMessage:(GPBMessage *)message
441445
CheckRecursionLimit(&state_);
442446
uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
443447
CheckFieldSize(length);
444-
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
448+
size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
449+
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
445450
++state_.recursionDepth;
446451
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
447452
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
@@ -456,7 +461,8 @@ - (void)readMapEntry:(id)mapDictionary
456461
CheckRecursionLimit(&state_);
457462
uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
458463
CheckFieldSize(length);
459-
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
464+
size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
465+
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
460466
++state_.recursionDepth;
461467
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, parentMessage);
462468
GPBCodedInputStreamCheckLastTagWas(&state_, 0);

src/google/protobuf/map.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <utility>
2626

2727
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
28-
#include <mach/mach_time.h>
28+
#include <time.h>
2929
#endif
3030

3131
#include "google/protobuf/stubs/common.h"
@@ -691,7 +691,7 @@ class PROTOBUF_EXPORT UntypedMapBase {
691691
#if defined(__APPLE__)
692692
// Use a commpage-based fast time function on Apple environments (MacOS,
693693
// iOS, tvOS, watchOS, etc).
694-
s += mach_absolute_time();
694+
s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
695695
#elif defined(__x86_64__) && defined(__GNUC__)
696696
uint32_t hi, lo;
697697
asm volatile("rdtsc" : "=a"(lo), "=d"(hi));

0 commit comments

Comments
 (0)