aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-09-04 18:26:09 +0300
committerAris Adamantiadis <aris@0xbadc0de.be>2009-09-13 14:03:33 +0300
commit6f2225e8fb9fd6b2dcc2ec8fbcb5130777efb76a (patch)
treea492ab6fdaa10d8887d28912c3055a2425b5ea43
parent07a9e6b7c634491db1b6875f5a2018fa9f90773a (diff)
downloadlibssh-6f2225e8fb9fd6b2dcc2ec8fbcb5130777efb76a.tar.gz
libssh-6f2225e8fb9fd6b2dcc2ec8fbcb5130777efb76a.tar.xz
libssh-6f2225e8fb9fd6b2dcc2ec8fbcb5130777efb76a.zip
fix ssh_scp_string_mode() bug + debug msgs
-rw-r--r--libssh/scp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libssh/scp.c b/libssh/scp.c
index 92cd1342..40c11e66 100644
--- a/libssh/scp.c
+++ b/libssh/scp.c
@@ -66,6 +66,7 @@ int ssh_scp_init(ssh_scp scp){
ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_init called under invalid state");
return SSH_ERROR;
}
+ ssh_log(scp->session,SSH_LOG_PROTOCOL,"Initializing scp session %s on location '%s'",scp->mode==SSH_SCP_WRITE?"write":"read",scp->location);
scp->channel=channel_new(scp->session);
if(scp->channel == NULL){
scp->state=SSH_SCP_ERROR;
@@ -201,15 +202,17 @@ int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int mode){
int r;
uint8_t code;
char *file;
- const char *perms;
+ char *perms;
if(scp->state != SSH_SCP_WRITE_INITED){
ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_push_file called under invalid state");
return SSH_ERROR;
}
file=ssh_basename(filename);
perms=ssh_scp_string_mode(mode);
+ ssh_log(scp->session,SSH_LOG_PROTOCOL,"SCP pushing file %s, size %" PRIdS " with permissions '%s'",file,size,perms);
snprintf(buffer, sizeof(buffer), "C%s %" PRIdS " %s\n", perms, size, file);
SAFE_FREE(file);
+ SAFE_FREE(perms);
r=channel_write(scp->channel,buffer,strlen(buffer));
if(r==SSH_ERROR){
scp->state=SSH_SCP_ERROR;
@@ -504,6 +507,6 @@ int ssh_scp_integer_mode(const char *mode){
*/
char *ssh_scp_string_mode(int mode){
char buffer[16];
- snprintf(buffer,sizeof(buffer),"%4o",mode);
+ snprintf(buffer,sizeof(buffer),"%.4o",mode);
return strdup(buffer);
}