diff --git a/pscp.c b/pscp.c index 4cc09a41..d1efe426 100644 --- a/pscp.c +++ b/pscp.c @@ -1015,7 +1015,7 @@ int scp_send_dirname(const char *name, int modes) * exists and is a directory we will assume we were either * successful or it didn't matter. */ - req = fxp_mkdir_send(fullname); + req = fxp_mkdir_send(fullname, NULL); pktin = sftp_wait_for_reply(req); ret = fxp_mkdir_recv(pktin, req); diff --git a/psftp.c b/psftp.c index c20bfb44..557264be 100644 --- a/psftp.c +++ b/psftp.c @@ -516,7 +516,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) if (!result || !(attrs.flags & SSH_FILEXFER_ATTR_PERMISSIONS) || !(attrs.permissions & 0040000)) { - req = fxp_mkdir_send(outfname); + req = fxp_mkdir_send(outfname, NULL); pktin = sftp_wait_for_reply(req); result = fxp_mkdir_recv(pktin, req); @@ -1422,7 +1422,7 @@ int sftp_cmd_mkdir(struct sftp_command *cmd) return 0; } - req = fxp_mkdir_send(dir); + req = fxp_mkdir_send(dir, NULL); pktin = sftp_wait_for_reply(req); result = fxp_mkdir_recv(pktin, req); diff --git a/sftp.c b/sftp.c index 7e7f1ffa..9aa4a7db 100644 --- a/sftp.c +++ b/sftp.c @@ -85,6 +85,8 @@ static void BinarySink_put_fxp_attrs(BinarySink *bs, struct fxp_attrs attrs) } } +static const struct fxp_attrs no_attrs = { 0 }; + #define put_fxp_attrs(bs, attrs) \ BinarySink_put_fxp_attrs(BinarySink_UPCAST(bs), attrs) @@ -460,7 +462,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req) * Open a file. */ struct sftp_request *fxp_open_send(const char *path, int type, - struct fxp_attrs *attrs) + const struct fxp_attrs *attrs) { struct sftp_request *req = sftp_alloc_request(); struct sftp_packet *pktout; @@ -469,10 +471,7 @@ struct sftp_request *fxp_open_send(const char *path, int type, put_uint32(pktout, req->id); put_stringz(pktout, path); put_uint32(pktout, type); - if (attrs) - put_fxp_attrs(pktout, *attrs); - else - put_uint32(pktout, 0); /* empty ATTRS structure */ + put_fxp_attrs(pktout, attrs ? *attrs : no_attrs); sftp_send(pktout); return req; @@ -566,7 +565,8 @@ int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req) return fxp_errtype == SSH_FX_OK; } -struct sftp_request *fxp_mkdir_send(const char *path) +struct sftp_request *fxp_mkdir_send(const char *path, + const struct fxp_attrs *attrs) { struct sftp_request *req = sftp_alloc_request(); struct sftp_packet *pktout; @@ -574,7 +574,7 @@ struct sftp_request *fxp_mkdir_send(const char *path) pktout = sftp_pkt_init(SSH_FXP_MKDIR); put_uint32(pktout, req->id); put_stringz(pktout, path); - put_uint32(pktout, 0); /* (FIXME) empty ATTRS structure */ + put_fxp_attrs(pktout, attrs ? *attrs : no_attrs); sftp_send(pktout); return req; diff --git a/sftp.h b/sftp.h index 7e93356b..65c8a44d 100644 --- a/sftp.h +++ b/sftp.h @@ -138,7 +138,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req); * if it's being created. */ struct sftp_request *fxp_open_send(const char *path, int type, - struct fxp_attrs *attrs); + const struct fxp_attrs *attrs); struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin, struct sftp_request *req); @@ -158,7 +158,8 @@ int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req); /* * Make a directory. */ -struct sftp_request *fxp_mkdir_send(const char *path); +struct sftp_request *fxp_mkdir_send(const char *path, + const struct fxp_attrs *attrs); int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req); /*