https://bugs.kde.org/show_bug.cgi?id=524859

            Bug ID: 524859
           Summary: SFTP Plugin fails silently if a corrupted SD card is
                    present in the system
    Classification: Applications
           Product: kdeconnect
      Version First unspecified
       Reported In:
          Platform: Android
                OS: Android 11.x
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: android-application
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

DESCRIPTION

Okay this bug haunted me for more than a year. On Android, If you insert an SD
Card and the system deemed it "corrupted" (often a false-positive), KDE connect
on the device won't mount the filesystem at all and won't expose it to other
peers. Causing a silent failure on KDE Connect Windows peer, while Dolphin will
just timeout with "Failed to mount filesystem: device not responding".

STEPS TO REPRODUCE
1. Insert a corrupted SD Card into an Android device
2. Pair any recent KDE Connect installation on the device with a desktop client
3. Attempt to "Browse this device"

OBSERVED RESULT

Operation fails for an unexplained reason. 

EXPECTED RESULT

either dolphin displays the phone's contents, or KDE Connect opens a compatible
SFTP client.

SOFTWARE/OS VERSIONS

Android 11
KDE Connect (F-droid) 1.35.13

ADDITIONAL INFORMATION

no logs are present on the desktop clients beside the error itself. While on
the phone, logcat displays the following:

08-27 22:13:38.478 E/Device  ( 9471): Exception in SftpPlugin's
onPacketReceived()
08-27 22:13:38.478 E/Device  ( 9471): java.lang.NullPointerException: Attempt
to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a
null object reference
08-27 22:13:38.478 E/Device  ( 9471):   at
org.kde.kdeconnect.plugins.sftp.SftpPlugin.onPacketReceived(r8-map-id-d195a484c08b870b97431c12016832904869bb41eb36ebb53768d30cc5041a10:151)
08-27 22:13:38.478 E/Device  ( 9471):   at
org.kde.kdeconnect.Device.notifyPluginPacketReceived(r8-map-id-d195a484c08b870b97431c12016832904869bb41eb36ebb53768d30cc5041a10:113)
08-27 22:13:38.478 E/Device  ( 9471):   at
org.kde.kdeconnect.Device.onPacketReceived(r8-map-id-d195a484c08b870b97431c12016832904869bb41eb36ebb53768d30cc5041a10:66)
... (the log continues)

After recompiling the f-droid release and debugging the SFTP plugin, I found
that the problem lies in SftpPlugin.kt:102, the following loop:

  97 │             val volumes = context.getSystemService(
  98 │                 StorageManager::class.java
  99 │             ).storageVolumes
 100 │             for (sv in volumes) {
 101 │                 pathNames.add(sv.getDescription(context))
 102 │                 paths.add(sv.directory!!.path)
 103 │             }

The corrupted SD Card counts as a volume despite being "corrupted" and not
mounted, thus missing a directory, thus having a NULL directory (notice
sv.directory!!.path), causing a null pointer exception to be thrown and the
plugin to silently fail.

I think the fix would be to simply check if sv.directory is null before
dereferencing and skipping the volume entirely in case of a null directory, but
I never coded in Kotlin so Idk.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to