Crash in createUserAgentHeader on Android (Port)

Description

Creating a replicator causes the following crash on Android 5 to 8 (~20% of all Android devices):

```

  •  

    •  

      • *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:5.1.1/LMY48X/6695563:userdebug/test-keys'
        Revision: '0'
        ABI: 'x86'
        pid: 3483, tid: 3502, name: 1.ui >>> com.terwesten.gabriel.cbl_e2e_tests_flutter <<<
        signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
        Abort message: 'stack corruption detected'
        eax 00000000 ebx 00000d9b ecx 00000dae edx 00000006
        esi a209adb8 edi 00000002
        xcs 00000073 xds 0000007b xes 0000007b xfs 00000077 xss 0000007b
        eip b75762e6 ebp 00000dae esp a2099cc0 flags 00200282
        backtrace:
        #00 pc 000742e6 /system/lib/libc.so (tgkill+22)
        #01 pc 0002217b /system/lib/libc.so (pthread_kill+155)
        #02 pc 000239f4 /system/lib/libc.so (raise+36)
        #03 pc 0001bdf4 /system/lib/libc.so (abort+84)
        #04 pc 0001ea60 /system/lib/libc.so (__libc_fatal+32)
        #05 pc 000739fc /system/lib/libc.so (__stack_chk_fail+28)
        #06 pc 000826ce /data/app/com.terwesten.gabriel.cbl_e2e_tests_flutter-1/lib/x86/libcblite.so (createUserAgentHeader()+1486)
        #07 pc 000813d1 /data/app/com.terwesten.gabriel.cbl_e2e_tests_flutter-1/lib/x86/libcblite.so (cbl_internal::ReplicatorConfiguration::ReplicatorConfiguration(CBLReplicatorConfiguration const&)+1489)
        #08 pc 0007d798 /data/app/com.terwesten.gabriel.cbl_e2e_tests_flutter-1/lib/x86/libcblite.so (CBLReplicator::CBLReplicator(CBLReplicatorConfiguration const&)+184)
        #09 pc 0007d60f /data/app/com.terwesten.gabriel.cbl_e2e_tests_flutter-1/lib/x86/libcblite.so (CBLReplicator_Create+95)
        #10 pc 0001a851 /data/app/com.terwesten.gabriel.cbl_e2e_tests_flutter-1/lib/x86/libcblitedart.so (CBLDart_CBLReplicator_Create+513)
        ```

The problem is that `createUserAgentHeader` only allocates 3 bytes for `ro.build.version.release`, which is not enough for some releases, e.g. `5.0.1`.

The docs for `__system_property_get` state that a value can have at most `PROP_VALUE_MAX` bytes.

clones

Activity

Show:

CB robot March 10, 2023 at 7:49 PM

Build couchbase-lite-c-3.2.0-5 contains couchbase-lite-c commit 0a0711c with commit message:
: Fix crash when getting User-Agent on Android (#463)

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created March 10, 2023 at 3:19 PM
Updated August 31, 2024 at 10:56 AM
Resolved March 18, 2024 at 4:42 PM
Instabug