I've been familiarizing myself with libssh2 examples and trying things out.
While testing my own code I noticed that valgrind gives a warning about
uninitialized memory and reproduced it with 'scp_write_nonblock' example.
See the attachment for valgrind log.
The environment is Debian 8.9 with libssh2-1:amd64 1.4.3-4.1+deb8u1
Can you comment whether this is a bug in the example, in libssh2 1.4.3 or
false positive report? Please, note that Debian 8 as well as RHEL/Centos 7
ship a (security) patched 1.4.3 libssh2.
The example code is taken as-is from
https://www.libssh2.org/examples/scp_write_nonblock.html and compiled with
system-provided libssh2.
- Jarkko
$ valgrind ./scp_write_nonblock <ip> <user> <password> /tmp/scp_src /tmp/test
==11576== Memcheck, a memory error detector
==11576== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11576== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==11576== Command: ./scp_write_nonblock 10.128.20.101 fsqm_default aaa
/tmp/scp_src /tmp/test
==11576==
Fingerprint: [XXX]
==11576== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==11576== at 0x51475ED: send (send.c:27)
==11576== by 0x4E41838: _libssh2_send (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4E4FC91: _libssh2_transport_send (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4E3B8A1: _libssh2_channel_process_startup (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4E44DC3: scp_send (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4E45EC7: libssh2_scp_send_ex (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4015DB: main (scp_write_nonblock.c:210)
==11576== Address 0x5b1beda is 17,034 bytes inside a block of size 54,480
alloc'd
==11576== at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==11576== by 0x4E4610D: libssh2_session_init_ex (in
/usr/lib/x86_64-linux-gnu/libssh2.so.1.0.1)
==11576== by 0x4013CD: main (scp_write_nonblock.c:153)
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel