when sftp destination is roun out of space, libcurl hangs, and try send more data forever. The error is in lib/ssh.c at Curl_scp_send and Curl_sftp_send function:
The libssh2_sftp_write returns number of bytes written or negative on failure. (http://www.libssh2.org/libssh2_sftp_write.html), the libssh2_channel_write function do the same.
The original bug report was found here: https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1056141 and it contains a patch.
The original bug report seems to be for curl 7.19 but a quick look at current (7.28.0) code indicates that the problem remains today.
The ubuntu bug report is incorrect. The code treats a negative return value as an error and will cause the libcurl functions to return CURLE_SEND_ERROR internally. I can't detect how the suggested patch would make anything differently.