Skip to content

Commit ea9b1a6

Browse files
authored
Potential integer overflow fix (#8103)
1 parent 5a8c78e commit ea9b1a6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- [changed] Incorporated code quality changes around integer overflow and reinstalling signal handlers.
3+
14
# v8.0.0
25
- [changed] Added a warning to upload-symbols when it detects a dSYM with hidden symbols.
36

Crashlytics/Crashlytics/Helpers/FIRCLSFile.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,14 @@ bool FIRCLSFileLoopWithWriteBlock(const void* buffer,
237237
for (size_t count = 0; length > 0 && count < CLS_FILE_MAX_WRITE_ATTEMPTS; ++count) {
238238
// try to write all that is left
239239
ssize_t ret = writeBlock(buffer, length);
240-
if (ret >= 0 && ret == length) {
240+
241+
if (length > SIZE_MAX) {
242+
// if this happens we can't convert it to a signed version due to overflow
243+
return false;
244+
}
245+
const ssize_t signedLength = (ssize_t)length;
246+
247+
if (ret >= 0 && ret == signedLength) {
241248
return true;
242249
}
243250

@@ -247,7 +254,7 @@ bool FIRCLSFileLoopWithWriteBlock(const void* buffer,
247254
}
248255

249256
// We wrote more bytes than we expected, abort
250-
if (ret > length) {
257+
if (ret > signedLength) {
251258
return false;
252259
}
253260

0 commit comments

Comments
 (0)