1
1
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@622 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Andreas Schneider 2009-04-27 11:39:25 +00:00
родитель 5d23142599
Коммит db79fff00d
2 изменённых файлов: 31 добавлений и 13 удалений

Просмотреть файл

@ -647,7 +647,8 @@ SFTP_ATTRIBUTES *sftp_parse_attr(SFTP_SESSION *session, BUFFER *buf,int expectna
SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp); SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp);
void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg); void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg);
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, char *name, SFTP_ATTRIBUTES *attr); int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
SFTP_ATTRIBUTES *attr);
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle); int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle);
STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info); STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr); int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);

Просмотреть файл

@ -224,19 +224,36 @@ void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg) {
SAFE_FREE(msg); SAFE_FREE(msg);
} }
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, char *name, SFTP_ATTRIBUTES *attr){ int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
BUFFER *out=buffer_new(); SFTP_ATTRIBUTES *attr) {
STRING *file=string_from_char(name); BUFFER *out;
int r; STRING *file;
buffer_add_u32(out,msg->id);
buffer_add_u32(out,htonl(1)); out = buffer_new();
buffer_add_ssh_string(out,file); if (out == NULL) {
buffer_add_ssh_string(out,file); /* the protocol is broken here between 3 & 4 */ return -1;
free(file); }
buffer_add_attributes(out,attr);
r=sftp_packet_write(msg->sftp,SSH_FXP_NAME,out); file = string_from_char(name);
if (file == NULL) {
buffer_free(out); buffer_free(out);
return r<0; return -1;
}
if (buffer_add_u32(out, msg->id) < 0 ||
buffer_add_u32(out, htonl(1)) < 0 ||
buffer_add_ssh_string(out, file) < 0 ||
buffer_add_ssh_string(out, file) < 0 || /* The protocol is broken here between 3 & 4 */
buffer_add_attributes(out, attr) < 0 ||
sftp_packet_write(msg->sftp, SSH_FXP_NAME, out) < 0) {
buffer_free(out);
string_free(file);
return -1;
}
buffer_free(out);
string_free(file);
return 0;
} }
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle){ int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle){