Fix malloc/delete mismatch
ClosedPublic

Authored by hallas on Mar 14 2019, 7:06 PM.

Details

Summary

Fixes pointer was allocated with malloc (by libssh) but freed with
delete. This is not safe and causes undefined behavior.

Test Plan

Build and run kio_sftp with address sanitizer

Diff Detail

Repository
R320 KIO Extras
Branch
fix_malloc_delete_mismatch (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9591
Build 9609: arc lint + arc unit
hallas created this revision.Mar 14 2019, 7:06 PM
Restricted Application added projects: Dolphin, Frameworks. · View Herald TranscriptMar 14 2019, 7:06 PM
Restricted Application added subscribers: kfm-devel, kde-frameworks-devel. · View Herald Transcript
hallas requested review of this revision.Mar 14 2019, 7:06 PM
aacid added a subscriber: aacid.Mar 14 2019, 9:04 PM
aacid added inline comments.
sftp/kio_sftp.cpp
446

Use ssh_string_free_char ?

sitter added inline comments.Mar 15 2019, 10:09 AM
sftp/kio_sftp.cpp
446

+1

"The caller needs to free the memory using ssh_string_free_char()."

http://api.libssh.org/stable/group__libssh__sftp.html#gab4860a441da019060f78c8d236d9ec91

hallas updated this revision to Diff 54054.Mar 17 2019, 6:33 AM
hallas marked 2 inline comments as done.

Use ssh_string_free_char instead of free as documentated by libssh

Good catch ;) I have changed it to call ssh_string_free_char instead

aacid accepted this revision.Mar 17 2019, 11:26 AM
This revision is now accepted and ready to land.Mar 17 2019, 11:26 AM
hallas closed this revision.Mar 17 2019, 2:45 PM